"use client" import * as 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, CommandList, } from "@/components/ui/command" import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover" export interface ComboboxProps { value?: string setValue: (value: string) => void dataList: { value: string; label: string }[] placeholder?: string notFoundText?: string onOpenChange?: () => void className?: string } export function Combobox({ value, setValue, dataList, placeholder, notFoundText, onOpenChange, className }: ComboboxProps) { const [open, setOpen] = React.useState(false) return ( { onOpenChange && onOpenChange() setOpen(open)}}> {notFoundText||"未找到结果"} {dataList.map((item) => ( { setValue(currentValue === value ? "" : currentValue) setOpen(false) }} > {item.label} ))} ) }