"use client" import { CheckIcon, ChevronsUpDownIcon } from "lucide-react" 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" export type ComboboxOption = { value: string label: string } type OptionComboboxProps = { value: string options: ComboboxOption[] placeholder: string searchPlaceholder?: string emptyText?: string disabled?: boolean onChange: (value: string) => void } export function OptionCombobox({ value, options, placeholder, searchPlaceholder = "请输入关键字搜索", emptyText = "没有可选项", disabled = false, onChange, }: OptionComboboxProps) { const selectedLabel = options.find((option) => option.value === value)?.label ?? placeholder return ( } > {selectedLabel} {emptyText} {options.map((option) => ( onChange(option.value)} > {option.label} ))} ) }