{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-footer-newsletter",
  "title": "Footer Newsletter",
  "description": "Captura atômica de e-mail para newsletter com validação, estado de envio e confirmação acessível.",
  "dependencies": [
    "class-variance-authority",
    "lucide-react"
  ],
  "registryDependencies": [
    "@lema-ds/button",
    "@lema-ds/input",
    "@lema-ds/label",
    "@lema-ds/ui-i18n",
    "@lema-ds/ds-locale-provider",
    "@lema-ds/tokens"
  ],
  "files": [
    {
      "path": "components/ds/ds-footer-newsletter.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { Loader2Icon, CheckCircle2Icon, SendIcon } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Input } from \"@/components/ui/input\"\nimport { Button } from \"@/components/ui/button\"\nimport { Label } from \"@/components/ui/label\"\nimport { UI_I18N, type UILocale } from \"@/lib/ui-i18n\"\nimport { useUILocale } from \"@/components/ui/ds-locale-provider\"\n\n// ── Types ──\n\nexport interface FooterNewsletterProps\n  extends\n    Omit<React.FormHTMLAttributes<HTMLFormElement>, \"onSubmit\">,\n    VariantProps<typeof footerNewsletterVariants> {\n  title?: string\n  description?: string\n  onSubscribe?: (email: string) => Promise<boolean | void> | void\n  locale?: UILocale\n  showPrivacyNotice?: boolean\n}\n\n// ── Variants ──\n\nexport const footerNewsletterVariants = cva(\"flex w-full flex-col gap-2.5\", {\n  variants: {\n    layout: {\n      inline: \"max-w-md\",\n      stacked: \"max-w-xs\",\n    },\n  },\n  defaultVariants: {\n    layout: \"inline\",\n  },\n})\n\n// ── Component ──\n\nexport const FooterNewsletter = React.forwardRef<\n  HTMLFormElement,\n  FooterNewsletterProps\n>(\n  (\n    {\n      layout = \"inline\",\n      title,\n      description,\n      onSubscribe,\n      locale: localeProp,\n      showPrivacyNotice = true,\n      className,\n      ...props\n    },\n    ref\n  ) => {\n    const locale = useUILocale(localeProp)\n    const t = UI_I18N[locale].footer\n    const [email, setEmail] = React.useState(\"\")\n    const [loading, setLoading] = React.useState(false)\n    const [submitted, setSubmitted] = React.useState(false)\n    const inputId = React.useId()\n\n    const handleSubmit = async (e: React.FormEvent) => {\n      e.preventDefault()\n      if (!email || loading) return\n\n      try {\n        setLoading(true)\n        if (onSubscribe) {\n          await onSubscribe(email)\n        } else {\n          await new Promise((resolve) => setTimeout(resolve, 800))\n        }\n        setSubmitted(true)\n      } finally {\n        setLoading(false)\n      }\n    }\n\n    return (\n      <form\n        ref={ref}\n        onSubmit={handleSubmit}\n        className={cn(footerNewsletterVariants({ layout }), className)}\n        {...props}\n      >\n        <div className=\"flex flex-col gap-1\">\n          <h3 className=\"text-sm font-semibold text-foreground\">\n            {title || t.newsletterTitle}\n          </h3>\n          <p className=\"text-xs text-muted-foreground\">\n            {description || t.newsletterDescription}\n          </p>\n        </div>\n\n        {submitted ? (\n          <div\n            role=\"status\"\n            aria-live=\"polite\"\n            className=\"flex items-center gap-2 rounded-lg bg-success/15 px-3 py-2 text-xs font-medium text-success\"\n          >\n            <CheckCircle2Icon className=\"size-4 shrink-0\" aria-hidden=\"true\" />\n            <span>{t.subscribedSuccess}</span>\n          </div>\n        ) : (\n          <div\n            className={cn(\n              \"flex w-full gap-2\",\n              layout === \"stacked\" ? \"flex-col\" : \"flex-row items-center\"\n            )}\n          >\n            <div className=\"relative w-full\">\n              <Label htmlFor={inputId} className=\"sr-only\">\n                {t.newsletterPlaceholder}\n              </Label>\n              <Input\n                id={inputId}\n                type=\"email\"\n                required\n                value={email}\n                onChange={(e) => setEmail(e.target.value)}\n                placeholder={t.newsletterPlaceholder}\n                disabled={loading}\n                className=\"h-9 text-xs\"\n              />\n            </div>\n            <Button\n              type=\"submit\"\n              size=\"sm\"\n              disabled={loading || !email}\n              aria-busy={loading}\n              className={cn(\n                \"h-9 shrink-0 gap-1.5 font-medium\",\n                layout === \"stacked\" && \"w-full\"\n              )}\n            >\n              {loading ? (\n                <>\n                  <Loader2Icon\n                    className=\"size-3.5 animate-spin\"\n                    aria-hidden=\"true\"\n                  />\n                  <span>{t.subscribe}</span>\n                </>\n              ) : (\n                <>\n                  <span>{t.subscribe}</span>\n                  <SendIcon className=\"size-3.5\" aria-hidden=\"true\" />\n                </>\n              )}\n            </Button>\n          </div>\n        )}\n\n        {showPrivacyNotice && !submitted && (\n          <p className=\"text-xs text-muted-foreground\">{t.privacyNotice}</p>\n        )}\n      </form>\n    )\n  }\n)\nFooterNewsletter.displayName = \"FooterNewsletter\"\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
