{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "option-select",
  "title": "Option Select",
  "description": "A select for one value from a list of options, each with an optional icon such as a flag, with a placeholder, built on the shadcn Select so its menu follows your style and font.",
  "registryDependencies": [
    "select"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/option-select.tsx",
      "content": "'use client'\n\nimport type { KeyboardEvent, ReactNode, Ref } from 'react'\n\nimport {\n  Select,\n  SelectContent,\n  SelectItem,\n  SelectTrigger,\n  SelectValue,\n} from '@/components/ui/select'\n\ninterface SelectOption<V extends string = string> {\n  disabled?: boolean\n  /** Shown before the label, in the menu and once picked, such as a country's flag. */\n  icon?: ReactNode\n  label: string\n  value: V\n}\n\ninterface OptionSelectProps<V extends string = string> {\n  'aria-describedby'?: string\n  'aria-invalid'?: boolean\n  'aria-label'?: string\n  className?: string\n  defaultOpen?: boolean\n  disabled?: boolean\n  id?: string\n  name?: string\n  onKeyDown?: (event: KeyboardEvent<HTMLButtonElement>) => void\n  onOpenChange?: (open: boolean) => void\n  onValueChange?: (value: V) => void\n  options: readonly SelectOption<V>[]\n  /** Shown while `value` is `null`. */\n  placeholder?: string\n  ref?: Ref<HTMLButtonElement>\n  size?: 'default' | 'sm'\n  value: V | null\n  [data: `data-${string}`]: string | undefined\n}\n\nfunction OptionLabel({ option }: { option: SelectOption }) {\n  if (!option.icon) return option.label\n  return (\n    <span className='flex min-w-0 items-center gap-2'>\n      {option.icon}\n      <span className='truncate'>{option.label}</span>\n    </span>\n  )\n}\n\nfunction OptionSelect<V extends string>({\n  defaultOpen,\n  disabled,\n  name,\n  onOpenChange,\n  onValueChange,\n  options,\n  placeholder,\n  value,\n  ...props\n}: OptionSelectProps<V>) {\n  return (\n    <Select\n      defaultOpen={defaultOpen}\n      disabled={disabled}\n      name={name}\n      value={value ?? ''}\n      onOpenChange={onOpenChange}\n      onValueChange={(next) => {\n        const option = options.find((item) => item.value === next)\n        if (option) onValueChange?.(option.value)\n      }}\n    >\n      <SelectTrigger {...props}>\n        <SelectValue placeholder={placeholder} />\n      </SelectTrigger>\n      <SelectContent>\n        {options.map((option) => (\n          <SelectItem key={option.value} value={option.value} disabled={option.disabled}>\n            <OptionLabel option={option} />\n          </SelectItem>\n        ))}\n      </SelectContent>\n    </Select>\n  )\n}\n\nexport { OptionSelect }\nexport type { OptionSelectProps, SelectOption }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/option-select.tsx"
    }
  ],
  "type": "registry:component"
}
