{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"shadcn-studio/combobox-09","type":"registry:component","title":"Combobox 9","description":"Country selector combobox with flag icons and country selection","registryDependencies":["combobox","label","input-group","utils"],"files":[{"path":"src/registry/new-york/components/combobox/combobox-09.tsx","content":"'use client'\n\nimport { useId, useState } from 'react'\n\nimport { Combobox as ComboboxPrimitive } from '@base-ui/react'\n\nimport {\n  Combobox,\n  ComboboxContent,\n  ComboboxTrigger,\n  ComboboxEmpty,\n  ComboboxItem,\n  ComboboxList\n} from '@/registry/new-york/ui/combobox'\nimport { Label } from '@/registry/new-york/ui/label'\nimport { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '@/registry/new-york/ui/input-group'\n\nimport { cn } from '@/registry/new-york/lib/utils'\n\nconst countries = [\n  { value: '1', label: 'India', flag: 'https://cdn.shadcnstudio.com/ss-assets/flags/india.png' },\n  { value: '2', label: 'China', flag: 'https://cdn.shadcnstudio.com/ss-assets/flags/china.png' },\n  { value: '3', label: 'Monaco', flag: 'https://cdn.shadcnstudio.com/ss-assets/flags/monaco.png' },\n  { value: '4', label: 'Serbia', flag: 'https://cdn.shadcnstudio.com/ss-assets/flags/serbia.png' },\n  { value: '5', label: 'Romania', flag: 'https://cdn.shadcnstudio.com/ss-assets/flags/romania.png' },\n  { value: '6', label: 'Mayotte', flag: 'https://cdn.shadcnstudio.com/ss-assets/flags/mayotte.png' },\n  { value: '7', label: 'Iraq', flag: 'https://cdn.shadcnstudio.com/ss-assets/flags/iraq.png' },\n  { value: '8', label: 'Syria', flag: 'https://cdn.shadcnstudio.com/ss-assets/flags/syria.png' },\n  { value: '9', label: 'Korea', flag: 'https://cdn.shadcnstudio.com/ss-assets/flags/korea.png' },\n  { value: '10', label: 'Zimbabwe', flag: 'https://cdn.shadcnstudio.com/ss-assets/flags/zimbabwe.png' }\n]\n\nconst ComboboxInput = ({\n  className,\n  children,\n  disabled = false,\n  showTrigger = true,\n  flag,\n  ...props\n}: ComboboxPrimitive.Input.Props & {\n  showTrigger?: boolean\n  flag?: string\n}) => {\n  return (\n    <InputGroup className={cn('w-auto', className)}>\n      {flag && (\n        <InputGroupAddon>\n          <img src={flag} alt='Country flag' className='h-4 w-5' />\n        </InputGroupAddon>\n      )}\n      <ComboboxPrimitive.Input render={<InputGroupInput disabled={disabled} />} {...props} />\n      <InputGroupAddon align='inline-end'>\n        {showTrigger && (\n          <InputGroupButton\n            size='icon-xs'\n            variant='ghost'\n            asChild\n            data-slot='input-group-button'\n            className='data-pressed:bg-transparent'\n            disabled={disabled}\n          >\n            <ComboboxTrigger />\n          </InputGroupButton>\n        )}\n      </InputGroupAddon>\n      {children}\n    </InputGroup>\n  )\n}\n\nconst ComboboxCountryFlagDemo = () => {\n  const id = useId()\n  const [value, setValue] = useState<string>('')\n  const selectedCountry = countries.find(u => u.label === value)\n\n  return (\n    <div className='w-full max-w-xs space-y-2'>\n      <Label htmlFor={id}>Options with flag and search</Label>\n      <Combobox id={id} items={countries} value={value} onValueChange={v => setValue(v ?? '')}>\n        <ComboboxInput placeholder='Select a country' flag={selectedCountry?.flag} />\n        <ComboboxContent>\n          <ComboboxEmpty>No countries found.</ComboboxEmpty>\n          <ComboboxList>\n            {item => (\n              <ComboboxItem key={item.value} value={item.label} className='flex items-center gap-2'>\n                <img src={item.flag} alt={`${item.label} flag`} className='h-4 w-5' />\n                <span className='flex flex-col'>\n                  <span className='font-medium'>{item.label}</span>\n                </span>\n              </ComboboxItem>\n            )}\n          </ComboboxList>\n        </ComboboxContent>\n      </Combobox>\n    </div>\n  )\n}\n\nexport default ComboboxCountryFlagDemo\n","type":"registry:component","target":"components/shadcn-studio/combobox/combobox-09.tsx"}]}