"use client" import { Button } from "@/components/ui/button" import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@/components/ui/command" import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover" import { cn } from "@/lib/utils" import { Check, ChevronDown } from "lucide-react" import { ButtonHTMLAttributes, forwardRef, useState } from "react" interface ComboboxProps extends ButtonHTMLAttributes { options: { label: string value: string }[] placeholder?: string defaultValue?: string className?: string onValueChange: (value: string) => void } export const Combobox = forwardRef( ({ options, placeholder, defaultValue, className, onValueChange, ...props }, ref) => { const [open, setOpen] = useState(false) const [value, setValue] = useState(defaultValue) return ( { const extendValue = value + " " + keywords.join(" ") if (extendValue.toLowerCase().includes(search.toLowerCase())) { return 1 } return 0 }} > No result found. {options.map((option) => ( { setValue(currentValue === value ? "" : currentValue) onValueChange( currentValue === value ? "" : currentValue, ) setOpen(false) }} > {option.label} ))} ) }, )