{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "auto-form-nested-arrays",
  "title": "Auto Form with Nested Objects and Arrays",
  "description": "A schema with a nested address object and an array of team members renders as fieldsets and a repeatable list with add, remove and reorder; errors point at the exact item. Use this when the data is a small tree, not a flat list of fields.",
  "registryDependencies": [
    "@tealmac/auto-form"
  ],
  "files": [
    {
      "path": "registry/patterns/auto-form-nested-arrays/auto-form-nested-arrays.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { AutoForm, type JsonSchema } from \"@/components/ui/auto-form\"\n\nexport const companySchema: JsonSchema = {\n  type: \"object\",\n  title: \"Company profile\",\n  required: [\"name\", \"address\", \"members\"],\n  properties: {\n    name: { type: \"string\", title: \"Company name\", minLength: 2 },\n    address: {\n      type: \"object\",\n      title: \"Registered address\",\n      required: [\"street\", \"city\"],\n      properties: {\n        street: { type: \"string\" },\n        city: { type: \"string\" },\n        postcode: {\n          type: \"string\",\n          pattern: \"^[A-Za-z0-9 -]{3,10}$\",\n          \"x-pattern-message\":\n            \"Use 3 to 10 letters, numbers, spaces or dashes.\",\n        },\n      },\n    },\n    members: {\n      type: \"array\",\n      title: \"Team members\",\n      minItems: 1,\n      maxItems: 5,\n      items: {\n        type: \"object\",\n        title: \"Member\",\n        required: [\"name\", \"email\"],\n        properties: {\n          name: { type: \"string\" },\n          email: { type: \"string\", format: \"email\" },\n          role: {\n            type: \"string\",\n            enum: [\"owner\", \"editor\", \"viewer\"],\n            default: \"editor\",\n          },\n        },\n      },\n    },\n  },\n}\n\nexport interface AutoFormNestedArraysProps {\n  onSubmit?: (values: Record<string, unknown>) => void\n}\n\nexport function AutoFormNestedArrays({ onSubmit }: AutoFormNestedArraysProps) {\n  return (\n    <div className=\"w-full max-w-lg\">\n      <AutoForm\n        schema={companySchema}\n        defaultValues={{ members: [{ name: \"\", email: \"\", role: \"owner\" }] }}\n        submitLabel=\"Save company\"\n        onSubmit={(values) => onSubmit?.(values)}\n      />\n    </div>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}