{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "jsonforms-enum-control",
  "description": "JSONForms select/dropdown renderer for enum type fields.",
  "dependencies": [
    "@jsonforms/core",
    "@jsonforms/react"
  ],
  "registryDependencies": [
    "https://mksingh.dev/r/typography.json",
    "select"
  ],
  "files": [
    {
      "path": "registry/forms/renderers/enum-control.tsx",
      "content": "import { useState } from 'react';\n\nimport { ControlProps, isEnumControl, rankWith } from '@jsonforms/core';\nimport { withJsonFormsControlProps } from '@jsonforms/react';\n\nimport Typography from '~/components/ui/typography';\nimport { Label } from '~/components/ui/label';\nimport {\n    Select,\n    SelectContent,\n    SelectItem,\n    SelectTrigger,\n    SelectValue,\n} from '~/components/ui/select';\nimport { shouldShowError } from '~/components/forms/utils';\n\nconst EnumControlRenderer = (props: ControlProps) => {\n    const { label, data, handleChange, path, visible, enabled, schema, errors, config } = props;\n    const [touched, setTouched] = useState(false);\n    const options = (schema.enum ?? []) as string[];\n\n    if (!visible) return null;\n\n    return (\n        <div className=\"flex flex-col gap-1 py-2\" onBlur={() => setTouched(true)}>\n            {label && <Label className=\"text-xs font-medium text-foreground\">{label}</Label>}\n            <Select\n                value={data ?? ''}\n                onValueChange={value => handleChange(path, value)}\n                disabled={!enabled}\n            >\n                <SelectTrigger>\n                    <SelectValue placeholder={`Select ${label ?? 'option'}`} />\n                </SelectTrigger>\n                <SelectContent>\n                    {options.map(option => (\n                        <SelectItem key={option} value={option}>\n                            {option}\n                        </SelectItem>\n                    ))}\n                </SelectContent>\n            </Select>\n            {shouldShowError(config, touched) && errors && <Typography variant=\"error\">{errors.split(\"\\n\")[0]}</Typography>}\n        </div>\n    );\n};\n\nexport const enumControlTester = rankWith(11, isEnumControl);\nexport default withJsonFormsControlProps(EnumControlRenderer);\n",
      "type": "registry:component",
      "target": "components/forms/renderers/enum-control.tsx"
    }
  ],
  "type": "registry:component"
}