import React from 'react'; import { Button, Header, ListBoxSection, Select as RACSelect, SelectValue, type ListBoxItemProps, type ListBoxProps, type SectionProps, } from 'react-aria-components'; import { twMerge } from 'tailwind-merge'; import { tv } from 'tailwind-variants'; import { Description, FieldError, Label } from '../Field/Field.quanta'; import { DropdownItem, ListBox } from '../ListBox/ListBox.quanta'; import { Popover } from '../Popover/Popover.quanta'; import { composeTailwindRenderProps, focusRing } from '../utils'; import { ChevrondownIcon } from '../icons'; import { SelectSectionHeader as BasicSelectSectionHeader, type SelectItemObject, type SelectProps, } from './Select'; const triggerStyles = tv({ extend: focusRing, base: ` flex min-h-11 min-w-[180px] items-center gap-3 rounded-lg bg-quanta-snow px-3 py-2 text-left text-sm text-quanta-space transition hover:bg-quanta-smoke focus:bg-quanta-air active:bg-quanta-air forced-colors:bg-[Field] `, variants: { isDisabled: { true: ` cursor-not-allowed bg-quanta-air text-quanta-silver hover:bg-quanta-air forced-colors:text-[GrayText] `, }, isInvalid: { true: ` bg-quanta-ballet hover:bg-quanta-flamingo `, }, }, }); function DefaultSelectItem(item: SelectItemObject) { return {item.value}; } export function Select< T extends object = SelectItemObject, M extends 'single' | 'multiple' = 'single', >({ label, description, errorMessage, children, items, ...props }: SelectProps) { return ( {({ isOpen }) => ( <> {label && } {description && {description}} {errorMessage} {children ? ( {children} ) : ( items={items as Iterable | undefined} > {DefaultSelectItem} )} )} ); } function SelectChevron({ isOpen }: { isOpen: boolean }) { return ( ); } export function SelectListBox(props: ListBoxProps) { return ( ); } export function SelectItem(props: ListBoxItemProps) { return ; } export function SelectSection(props: SectionProps) { return ( ); } export function SelectSectionHeader( props: React.ComponentProps, ) { return (
); } export type { SelectItemObject, SelectProps };