{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "jsonforms-anyof-string-or-enum-control",
  "description": "JSONForms combobox renderer for anyOf schemas that combine enum values with a plain string type. Renders a text input with a datalist dropdown — user can pick a suggestion or type freely.",
  "dependencies": [
    "@jsonforms/core",
    "@jsonforms/react"
  ],
  "registryDependencies": [
    "https://mksingh.dev/r/typography.json",
    "input"
  ],
  "files": [
    {
      "path": "registry/forms/renderers/anyof-string-or-enum-control.tsx",
      "content": "import { useState } from 'react';\n\nimport { ControlProps, JsonSchema, rankWith, UISchemaElement } from '@jsonforms/core';\nimport { withJsonFormsControlProps } from '@jsonforms/react';\n\nimport Typography from '~/components/ui/typography';\nimport { Input } from '~/components/ui/input';\nimport { Label } from '~/components/ui/label';\nimport { shouldShowError } from '~/components/forms/utils';\n\nconst hasEnumAndText = (schema: JsonSchema): boolean => {\n    if (!schema.anyOf) return false;\n    const hasEnum = schema.anyOf.some((s: JsonSchema) => s.enum !== undefined);\n    const hasText = schema.anyOf.some((s: JsonSchema) => s.type === 'string' && s.enum === undefined);\n    return hasEnum && hasText;\n};\n\nconst AnyOfStringOrEnumControlRenderer = (props: ControlProps) => {\n    const { label, data, handleChange, path, visible, enabled, schema, id, errors, config } = props;\n    const [touched, setTouched] = useState(false);\n\n    if (!visible) return null;\n\n    const enumOptions = schema.anyOf\n        ?.filter((s: JsonSchema) => s.enum !== undefined)\n        .flatMap((s: JsonSchema) => s.enum as string[]) ?? [];\n\n    const listId = `${id}-list`;\n\n    return (\n        <div className=\"flex flex-col gap-1 py-2\">\n            {label && <Label className=\"text-xs font-medium text-foreground\">{label}</Label>}\n            <Input\n                list={listId}\n                value={data ?? ''}\n                onChange={e => handleChange(path, e.target.value)}\n                onBlur={() => setTouched(true)}\n                disabled={!enabled}\n            />\n            <datalist id={listId}>\n                {enumOptions.map(opt => (\n                    <option key={opt} value={opt} />\n                ))}\n            </datalist>\n            {shouldShowError(config, touched) && errors && <Typography variant=\"error\">{errors.split(\"\\n\")[0]}</Typography>}\n        </div>\n    );\n};\n\nexport const anyOfStringOrEnumControlTester = rankWith(\n    5,\n    (_uischema: UISchemaElement, schema: JsonSchema) => {\n        if (!schema) return false;\n        return hasEnumAndText(schema);\n    }\n);\nexport default withJsonFormsControlProps(AnyOfStringOrEnumControlRenderer);\n",
      "type": "registry:component",
      "target": "components/forms/renderers/anyof-string-or-enum-control.tsx"
    }
  ],
  "type": "registry:component"
}