import React from 'react'; import styled, { type AnyStyledComponent } from 'styled-components'; import { Root, Value, Viewport, Trigger, Content, Item, ItemText, ItemIndicator, Portal, Icon as SelectIcon, } from '@radix-ui/react-select'; import { CheckIcon } from '@radix-ui/react-icons'; import { popoverMixins } from '@/styles/popoverMixins'; import { formMixins } from '@/styles/formMixins'; import { WithLabel } from '@/components/WithLabel'; export const SelectMenu = ({ children, className, value, onValueChange, label, withBlur, }: { children: React.ReactNode; className?: string; value: T; onValueChange: (value: T) => void; label?: React.ReactNode; withBlur?: boolean; }) => { return ( {label ? ( ) : ( )} {React.Children.toArray(children).length > 1 && } {/* */} {children} {/* */} ); }; export const SelectItem = ({ className, value, label, }: { className?: string; value: T; label: string; }) => ( {label} ); const Styled: Record = {}; Styled.Trigger = styled(Trigger)<{ $withBlur?: boolean }>` --select-menu-trigger-maxWidth: ; max-width: var(--select-menu-trigger-maxWidth); ${popoverMixins.trigger} ${({ $withBlur }) => $withBlur && popoverMixins.backdropOverlay} > * { text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } `; Styled.DropdownIcon = styled(SelectIcon)` font-size: 0.675em; color: var(--color-text-1); margin-left: auto; `; Styled.Content = styled(Content)` --select-menu-content-maxWidth: ; max-width: var(--select-menu-content-maxWidth); ${popoverMixins.popover} ${popoverMixins.popoverAnimation} `; Styled.Item = styled(Item)` ${popoverMixins.item} `; Styled.ItemIndicator = styled(ItemIndicator)` margin-left: auto; display: inline-flex; transition: transform 0.3s var(--ease-out-expo); `; Styled.WithLabel = styled(WithLabel)` ${formMixins.inputLabel} border-radius: 0; `;