{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "combobox-3",
  "type": "registry:component",
  "title": "Combobox 3",
  "description": "Combobox 3. A combobox component for selecting from a list of options.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "command",
    "label",
    "popover"
  ],
  "files": [
    {
      "path": "components/watermelon/combobox-3.tsx",
      "type": "registry:component",
      "content": "'use client'\n\nimport { Fragment, useId, useState } from 'react'\n\nimport { ChevronsUpDownIcon } from 'lucide-react'\n\nimport {\n  Command,\n  CommandEmpty,\n  CommandGroup,\n  CommandInput,\n  CommandItem,\n  CommandList\n} from '@/components/base-ui/command'\nimport { Label } from '@/components/base-ui/label'\nimport { Popover, PopoverContent, PopoverTrigger } from '@/components/base-ui/popover'\n\nimport { cn } from '@/lib/utils'\n\ntype ComboboxItem = {\n  disabled?: boolean\n  value: string\n}\n\ntype ComboboxGroup = {\n  category: string\n  items: readonly ComboboxItem[]\n}\n\nconst items: readonly ComboboxGroup[] = [\n  {\n    category: 'Workspace',\n    items: [{ value: 'Overview' }, { value: 'Inbox' }, { value: 'Library' }]\n  },\n  {\n    category: 'Planning',\n    items: [\n      { value: 'Roadmap' },\n      { value: 'Timeline', disabled: true },\n      { value: 'Calendar' }\n    ]\n  },\n  {\n    category: 'People',\n    items: [\n      { value: 'Members' },\n      { value: 'Guests', disabled: true },\n      { value: 'Roles' }\n    ]\n  }\n] as const\n\ntype ComboboxValue = ComboboxItem['value']\n\nconst isComboboxValue = (value: string): value is ComboboxValue =>\n  items.some((group) => group.items.some((item) => item.value === value))\n\nconst Combobox3 = () => {\n  const id = useId()\n  const [open, setOpen] = useState<boolean>(false)\n  const [selectedValue, setSelectedValue] = useState<ComboboxValue | ''>('')\n\n  return (\n    <div className='w-full max-w-xs space-y-2'>\n      <Label htmlFor={id} className='text-sm font-medium'>\n        Choose a workspace section\n      </Label>\n      <Popover open={open} onOpenChange={setOpen}>\n        <PopoverTrigger\n          id={id}\n          role='combobox'\n          aria-expanded={open}\n          className='flex h-10 w-full items-center justify-between rounded-xl border border-border/60 bg-background px-3 text-sm font-normal shadow-xs outline-offset-0 outline-none transition-colors hover:bg-accent/20 focus-visible:ring-[3px] focus-visible:ring-ring/50'\n        >\n          {selectedValue ? (\n            <span className='flex min-w-0 items-center gap-2'>\n              <span className='truncate'>{selectedValue}</span>\n            </span>\n          ) : (\n            <span className='text-muted-foreground'>Select section</span>\n          )}\n          <ChevronsUpDownIcon\n            className='text-muted-foreground/80 size-4 shrink-0'\n            aria-hidden='true'\n          />\n        </PopoverTrigger>\n        <PopoverContent\n          className='w-full min-w-[var(--radix-popper-anchor-width)] rounded-xl border-border/60 p-0 shadow-sm'\n          align='start'\n        >\n          <Command>\n            <CommandInput placeholder='Search section...' className='h-9' />\n            <CommandList>\n              <CommandEmpty>No section found.</CommandEmpty>\n              {items.map(group => (\n                <Fragment key={group.category}>\n                  <CommandGroup heading={group.category}>\n                    {group.items.map(item => (\n                      <CommandItem\n                        key={item.value}\n                        value={item.value}\n                        data-checked={selectedValue === item.value}\n                        onSelect={currentValue => {\n                          if (item.disabled) {\n                            return\n                          }\n\n                          if (!isComboboxValue(currentValue)) {\n                            return\n                          }\n\n                          setSelectedValue(currentValue)\n                          setOpen(false)\n                        }}\n                        className={cn('pr-2', item.disabled && 'cursor-not-allowed opacity-50')}\n                        disabled={item.disabled ?? false}\n                      >\n                        {item.value}\n                      </CommandItem>\n                    ))}\n                  </CommandGroup>\n                </Fragment>\n              ))}\n            </CommandList>\n          </Command>\n        </PopoverContent>\n      </Popover>\n    </div>\n  )\n}\n\nexport default Combobox3\n"
    }
  ]
}
