{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "combobox-7",
  "type": "registry:component",
  "title": "Combobox 7",
  "description": "Combobox 7. A combobox component for selecting from a list of options.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "command",
    "label",
    "popover"
  ],
  "files": [
    {
      "path": "components/watermelon/combobox-7.tsx",
      "type": "registry:component",
      "content": "'use client'\n\nimport { useId, useMemo, 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 TimezoneOption = {\n  label: string\n  numericOffset: number\n  value: string\n}\n\nconst Combobox7 = () => {\n  const id = useId()\n  const [open, setOpen] = useState<boolean>(false)\n  const [selectedTimezone, setSelectedTimezone] = useState<string>(\n    'Indian/Cocos'\n  )\n\n  const supportedTimezones = Intl.supportedValuesOf('timeZone')\n\n  const formattedTimezones = useMemo<TimezoneOption[]>(() => {\n    return supportedTimezones\n      .map((timezone) => {\n        const formatter = new Intl.DateTimeFormat('en', {\n          timeZone: timezone,\n          timeZoneName: 'shortOffset'\n        })\n\n        const parts = formatter.formatToParts(new Date())\n        const offset =\n          parts.find((part) => part.type === 'timeZoneName')?.value ?? ''\n        const formattedOffset = offset === 'GMT' ? 'GMT+0' : offset\n\n        return {\n          value: timezone,\n          label: `(${formattedOffset}) ${timezone.replace(/_/g, ' ')}`,\n          numericOffset: Number.parseInt(\n            formattedOffset.replace('GMT', '').replace('+', '') || '0',\n            10\n          )\n        }\n      })\n      .sort((firstTimezone, secondTimezone) => firstTimezone.numericOffset - secondTimezone.numericOffset)\n  }, [supportedTimezones])\n\n  const selectedTimezoneLabel =\n    formattedTimezones.find((timezone) => timezone.value === selectedTimezone)\n      ?.label ?? ''\n\n  return (\n    <div className='w-full max-w-xs space-y-2'>\n      <Label htmlFor={id} className='text-sm font-medium'>\n        Timezone picker\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.5 text-sm shadow-xs outline-none transition-colors hover:bg-accent/20 focus-visible:ring-[3px] focus-visible:ring-ring/50'\n        >\n          <span className={cn('truncate', !selectedTimezone && 'text-muted-foreground')}>\n            {selectedTimezone ? (\n              selectedTimezoneLabel\n            ) : (\n              <span className='text-muted-foreground'>Select timezone</span>\n            )}\n          </span>\n          <ChevronsUpDownIcon\n            className='text-muted-foreground/80 size-4 shrink-0'\n            aria-hidden='true'\n          />\n        </PopoverTrigger>\n        <PopoverContent className='w-(--radix-popper-anchor-width) rounded-xl border-border/60 p-0 shadow-sm'>\n          <Command>\n            <CommandInput placeholder='Search timezone' className='h-9 px-1' />\n            <CommandList>\n              <CommandEmpty>No timezone found.</CommandEmpty>\n              <CommandGroup>\n                {formattedTimezones.map(({ value: timezoneValue, label }) => (\n                  <CommandItem\n                    key={timezoneValue}\n                    value={timezoneValue}\n                    data-checked={selectedTimezone === timezoneValue}\n                    onSelect={currentValue => {\n                      setSelectedTimezone(\n                        currentValue === selectedTimezone ? '' : currentValue\n                      )\n                      setOpen(false)\n                    }}\n                    className='rounded-md pr-2'\n                  >\n                    <span className='truncate'>{label}</span>\n                  </CommandItem>\n                ))}\n              </CommandGroup>\n            </CommandList>\n          </Command>\n        </PopoverContent>\n      </Popover>\n    </div>\n  )\n}\n\nexport default Combobox7\n"
    }
  ]
}
