import { Input } from '../input'; import { SelectOptionItem } from './SelectOptionItem'; import type { GroupedOptions } from './types'; interface SelectDropdownContentProps { searchable: boolean; search: string; onSearchChange: (v: string) => void; searchInputRef: React.RefObject; filteredOptions: GroupedOptions; multiple: boolean; isSelected: (value: string) => boolean; onSelect: (value: string) => void; ariaLabel?: string; name?: string; placeholder?: string; } export function SelectDropdownContent({ searchable, search, onSearchChange, searchInputRef, filteredOptions, multiple, isSelected, onSelect, ariaLabel, name, placeholder, }: SelectDropdownContentProps) { const hasOptions = filteredOptions.ungrouped.length > 0 || Object.keys(filteredOptions.groups).length > 0; return (
{searchable && (
onSearchChange(e.target.value)} onClick={(e) => e.stopPropagation()} className="w-full" />
)} {filteredOptions.ungrouped.length > 0 && (
{filteredOptions.ungrouped.map((option) => ( ))}
)} {Object.entries(filteredOptions.groups).map(([groupLabel, groupOptions]) => (
{groupLabel}
{groupOptions.map((option) => ( ))}
))} {!hasOptions && (
No options found
)}
); }