import { useMemo, useState } from 'react' import { BottomDialog, SearchBar, p as P } from 'web-components' import { Check, ChevronDown } from 'lucide-react' export interface SearchableSelectOption { label: string value: string | number disabled?: boolean } interface SearchableSelectProps { label: string options: SearchableSelectOption[] value: string | number onValueChange: (v: string | number) => void onSearch?: (q: string) => void placeholder?: string disabled?: boolean error?: boolean className?: string testID?: string // Tolerated for screen compatibility (RN BottomDropdown leftover) — ignored on web triggerComponent?: any } export function SearchableSelect({ label, options, value, onValueChange, onSearch, placeholder, disabled = false, error = false, className, testID, }: SearchableSelectProps) { const [open, setOpen] = useState(false) const [query, setQuery] = useState('') const selectedLabel = useMemo(() => { const found = options.find((o) => String(o.value) === String(value)) return found ? found.label : null }, [options, value]) const displayText = selectedLabel ?? placeholder ?? label const filtered = useMemo(() => { const q = query.trim().toLowerCase() if (!q) return options return options.filter((o) => o.label.toLowerCase().includes(q)) }, [options, query]) const handleSelect = (optionValue: string | number) => { onValueChange(optionValue) setOpen(false) } return (

{label}

setOpen(false)}>

{label}

{ setQuery(q) onSearch?.(q) }} onSearch={onSearch} className="mb-3" />
{filtered.map((option) => { const selected = String(option.value) === String(value) return ( ) })} {filtered.length === 0 ? (

No options found

) : null}
) } export default SearchableSelect