{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "combobox", "title": "Combobox", "description": "A combobox with search built on Command and Popover.", "dependencies": [ "lucide-react" ], "registryDependencies": [ "https://ds.formance.com/r/button.json", "https://ds.formance.com/r/command.json", "https://ds.formance.com/r/popover.json" ], "files": [ { "path": "registry/default/ui/combobox.tsx", "content": "'use client';\n\nimport { Check, ChevronsUpDown } from 'lucide-react';\nimport React from 'react';\n\nimport { Button } from '@/registry/default/ui/button';\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n} from '@/registry/default/ui/command';\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from '@/registry/default/ui/popover';\nimport { cn } from '@/lib/utils';\n\ntype ComboboxProps = {\n groups: { label: string; value: string }[];\n label: string;\n placeholder: string;\n};\n\nfunction Combobox({ groups, label, placeholder }: ComboboxProps) {\n const [open, setOpen] = React.useState(false);\n const [value, setValue] = React.useState(groups[0]!.value || '');\n\n return (\n \n \n \n {value ? groups.find((group) => group.value === value)?.label : label}\n \n \n \n \n \n \n No group found.\n \n \n {groups.map((group) => (\n {\n setValue(currentValue === value ? '' : currentValue);\n setOpen(false);\n }}\n >\n \n {group.label}\n \n ))}\n \n \n \n \n \n );\n}\n\nCombobox.displayName = 'Combobox';\n\nexport { Combobox };\n", "type": "registry:ui" } ], "type": "registry:ui" }