import React from "react"; import { Check, ChevronsUpDown } from "lucide-react"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, } from "@/components/ui/command"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; interface ComboboxProps { value: string; onChange: (value: string) => void; onInputChange: (value: string) => void; options: string[]; placeholder?: string; emptyMessage?: string; id?: string; } export function Combobox({ value, onChange, onInputChange, options = [], placeholder = "Select...", emptyMessage = "No results found.", id, }: ComboboxProps) { const [open, setOpen] = React.useState(false); const handleSelect = React.useCallback( (option: string) => { onChange(option); setOpen(false); }, [onChange], ); const handleInputChange = React.useCallback( (value: string) => { onInputChange(value); }, [onInputChange], ); return ( {emptyMessage} {options.map((option) => ( handleSelect(option)} > {option} ))} ); }