{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "jsonforms-radio-group-control",
  "description": "JSONForms radio group renderer for enum fields. Activated by setting options.format to 'radio' in the UISchema.",
  "dependencies": [
    "@jsonforms/core",
    "@jsonforms/react"
  ],
  "registryDependencies": [
    "https://mksingh.dev/r/typography.json",
    "radio-group",
    "label"
  ],
  "files": [
    {
      "path": "registry/forms/renderers/radio-group-control.tsx",
      "content": "import { useState } from 'react';\n\nimport { and, ControlProps, isEnumControl, optionIs, rankWith } from '@jsonforms/core';\nimport { withJsonFormsControlProps } from '@jsonforms/react';\n\nimport Typography from '~/components/ui/typography';\nimport { Label } from '~/components/ui/label';\nimport { RadioGroup, RadioGroupItem } from '~/components/ui/radio-group';\nimport { shouldShowError } from '~/components/forms/utils';\n\nconst RadioGroupControlRenderer = (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-2 py-2\" onBlur={() => setTouched(true)}>\n            {label && <Label className=\"text-xs font-medium text-foreground\">{label}</Label>}\n            <RadioGroup\n                value={data ?? ''}\n                onValueChange={value => handleChange(path, value)}\n                disabled={!enabled}\n            >\n                {options.map(option => (\n                    <div key={option} className=\"flex items-center gap-2\">\n                        <RadioGroupItem value={option} id={`${path}-${option}`} />\n                        <Label htmlFor={`${path}-${option}`} className=\"text-xs cursor-pointer\">\n                            {option}\n                        </Label>\n                    </div>\n                ))}\n            </RadioGroup>\n            {shouldShowError(config, touched) && errors && <Typography variant=\"error\">{errors.split(\"\\n\")[0]}</Typography>}\n        </div>\n    );\n};\n\nexport const radioGroupControlTester = rankWith(20, and(isEnumControl, optionIs('format', 'radio')));\nexport default withJsonFormsControlProps(RadioGroupControlRenderer);\n",
      "type": "registry:component",
      "target": "components/forms/renderers/radio-group-control.tsx"
    }
  ],
  "type": "registry:component"
}