{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "newsletter-dialog",
  "title": "Newsletter Subscription",
  "description": "A newsletter subscription form in a dialog.",
  "registryDependencies": [
    "@buzzform/email",
    "@buzzform/checkbox",
    "dialog",
    "button",
    "sonner"
  ],
  "files": [
    {
      "path": "registry/shadcn/examples/newsletter-dialog.tsx",
      "content": "\"use client\";\n\nimport { useState } from \"react\";\nimport { toast } from \"sonner\";\nimport { defineSchema, type InferType } from \"@buildnbuzz/form-react\";\nimport {\n  Form,\n  FormContent,\n  FormFields,\n  FormSubmit,\n} from \"@/registry/shadcn/form\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n  Dialog,\n  DialogContent,\n  DialogDescription,\n  DialogHeader,\n  DialogTitle,\n  DialogTrigger,\n} from \"@/components/ui/dialog\";\n\n// Newsletter subscription with checkbox consent\nconst newsletterSchema = defineSchema({\n  fields: [\n    {\n      type: \"email\",\n      name: \"email\",\n      label: \"Email Address\",\n      placeholder: \"you@example.com\",\n      required: true,\n    },\n    {\n      type: \"checkbox\",\n      name: \"consent\",\n      label: \"I agree to receive marketing emails and can unsubscribe anytime.\",\n      required: true,\n    },\n  ],\n});\n\ntype NewsletterSchema = InferType<typeof newsletterSchema.fields>;\n\nexport default function NewsletterDialogExample() {\n  const [open, setOpen] = useState(false);\n\n  const handleSubmit = async ({ value }: { value: unknown }) => {\n    const data = value as NewsletterSchema;\n    await new Promise((resolve) => setTimeout(resolve, 800));\n    toast(\"Subscribed!\", {\n      description: (\n        <pre className=\"mt-2 max-h-48 overflow-auto rounded-md bg-muted text-muted-foreground p-3 text-xs\">\n          <code>{JSON.stringify(data, null, 2)}</code>\n        </pre>\n      ),\n    });\n    setOpen(false);\n  };\n\n  return (\n    <Dialog open={open} onOpenChange={setOpen}>\n      <DialogTrigger render={<Button variant=\"outline\" />}>\n        Subscribe to Newsletter\n      </DialogTrigger>\n      <DialogContent className=\"sm:max-w-md\">\n        <DialogHeader>\n          <DialogTitle>Stay Updated</DialogTitle>\n          <DialogDescription>\n            Get the latest BuzzForm updates, tips, and new feature\n            announcements.\n          </DialogDescription>\n        </DialogHeader>\n        <Form schema={newsletterSchema} onSubmit={handleSubmit}>\n          <FormContent className=\"space-y-4\">\n            <FormFields />\n            <FormSubmit className=\"w-full\">Subscribe</FormSubmit>\n          </FormContent>\n        </Form>\n      </DialogContent>\n    </Dialog>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/buzzform/examples/newsletter-dialog.tsx"
    }
  ],
  "type": "registry:block"
}