import { Combobox } from "@base-ui/react/combobox"; import { Check, ChevronDown } from "lucide-react"; import cn from "~/utils/cn"; export interface SelectItem { value: string; label: string; } export interface SelectProps { items: SelectItem[]; label?: string; "aria-label"?: string; name?: string; className?: string; placeholder?: string; description?: string; required?: boolean; disabled?: boolean; invalid?: boolean; value?: string | null; defaultValue?: string | null; onValueChange?: (value: string | null) => void; } export default function Select({ items, label, className, placeholder, description, required, disabled, invalid, value, defaultValue, onValueChange, name, ...props }: SelectProps) { const selectedItem = value !== undefined ? (items.find((i) => i.value === value) ?? null) : undefined; const defaultSelectedItem = defaultValue !== undefined ? (items.find((i) => i.value === defaultValue) ?? null) : undefined; return (
{label && ( )} onValueChange?.(item?.value ?? null)} disabled={disabled} name={name} aria-label={props["aria-label"]} >
No results found. {(item: SelectItem) => ( {item.label} )}
{description && (
{description}
)}
); }