{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "notification-preferences",
  "type": "registry:block",
  "title": "Notification preferences",
  "description": "An email preferences form with per-channel switches, unsaved state, and async save feedback.",
  "categories": [
    "blocks"
  ],
  "dependencies": [
    "@tabler/icons-react"
  ],
  "registryDependencies": [
    "card",
    "button",
    "switch"
  ],
  "files": [
    {
      "path": "src/registry/overtrue/notification-preferences.tsx",
      "type": "registry:component",
      "target": "components/overtrue/notification-preferences.tsx",
      "content": "\"use client\";\nimport { useId, useState } from \"react\";\nimport { IconBell, IconMail, IconReportAnalytics } from \"@tabler/icons-react\";\nimport { Button } from \"@/components/ui/button\";\nimport { Switch } from \"@/components/ui/switch\";\nimport { SectionCard } from \"./section-card\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface NotificationSettings {\n  mentions: boolean;\n  projectUpdates: boolean;\n  weeklyDigest: boolean;\n}\nconst channels = [\n  {\n    key: \"mentions\",\n    title: \"Mentions and replies\",\n    description: \"When someone needs your attention in a conversation.\",\n    icon: IconBell,\n  },\n  {\n    key: \"projectUpdates\",\n    title: \"Project updates\",\n    description: \"Milestones, status changes, and work assigned to you.\",\n    icon: IconMail,\n  },\n  {\n    key: \"weeklyDigest\",\n    title: \"Weekly digest\",\n    description: \"A Monday summary of progress across your projects.\",\n    icon: IconReportAnalytics,\n  },\n] as const;\nconst defaults: NotificationSettings = {\n  mentions: true,\n  projectUpdates: true,\n  weeklyDigest: false,\n};\n\nexport function NotificationPreferences({\n  initialValues = defaults,\n  onSave,\n  className,\n}: {\n  initialValues?: NotificationSettings;\n  onSave?: (values: NotificationSettings) => void | Promise<void>;\n  className?: string;\n}) {\n  const id = useId();\n  const [values, setValues] = useState(initialValues);\n  const [saved, setSaved] = useState(initialValues);\n  const [saving, setSaving] = useState(false);\n  const [status, setStatus] = useState(\"\");\n  const [failed, setFailed] = useState(false);\n  const dirty = channels.some(({ key }) => values[key] !== saved[key]);\n  return (\n    <SectionCard\n      title=\"Notifications\"\n      description=\"Choose what reaches your inbox.\"\n      className={cn(\"shadow-none\", className)}\n      contentClassName=\"p-0\"\n    >\n      <form\n        onSubmit={async (event) => {\n          event.preventDefault();\n          if (saving || !dirty) return;\n          setSaving(true);\n          setStatus(\"\");\n          setFailed(false);\n          try {\n            await onSave?.(values);\n            setSaved(values);\n            setStatus(\n              onSave ? \"Preferences saved.\" : \"Preferences saved in this demo.\",\n            );\n          } catch {\n            setFailed(true);\n            setStatus(\"Could not save preferences. Please try again.\");\n          } finally {\n            setSaving(false);\n          }\n        }}\n      >\n        <div className=\"divide-y divide-border px-5\">\n          {channels.map(({ key, title, description, icon: Icon }) => (\n            <div key={key} className=\"flex items-center gap-4 py-5\">\n              <span className=\"hidden size-9 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground sm:flex\">\n                <Icon aria-hidden=\"true\" className=\"size-4\" />\n              </span>\n              <div className=\"min-w-0 flex-1\">\n                <label htmlFor={`${id}-${key}`} className=\"text-sm font-medium\">\n                  {title}\n                </label>\n                <p\n                  id={`${id}-${key}-description`}\n                  className=\"m-0 mt-1 text-xs leading-5 text-muted-foreground\"\n                >\n                  {description}\n                </p>\n              </div>\n              <Switch\n                id={`${id}-${key}`}\n                aria-describedby={`${id}-${key}-description`}\n                className=\"[&>span]:shadow-none\"\n                checked={values[key]}\n                disabled={saving}\n                onCheckedChange={(checked) => {\n                  setValues((current) => ({ ...current, [key]: checked }));\n                  setStatus(\"\");\n                  setFailed(false);\n                }}\n              />\n            </div>\n          ))}\n        </div>\n        <div className=\"flex flex-wrap items-center justify-between gap-3 border-t border-border px-5 py-4\">\n          <p\n            role={failed ? \"alert\" : \"status\"}\n            className={cn(\n              \"m-0 min-w-0 grow basis-48 text-xs leading-5 text-muted-foreground\",\n              failed && \"text-destructive\",\n            )}\n          >\n            {status ||\n              (dirty ? \"You have unsaved changes.\" : \"You’re all up to date.\")}\n          </p>\n          <Button\n            type=\"submit\"\n            size=\"sm\"\n            className=\"ml-auto shrink-0 bg-primary text-primary-foreground shadow-none hover:bg-primary/90\"\n            disabled={saving || !dirty}\n          >\n            {saving ? \"Saving…\" : \"Save preferences\"}\n          </Button>\n        </div>\n      </form>\n    </SectionCard>\n  );\n}\n"
    },
    {
      "path": "src/registry/overtrue/section-card.tsx",
      "type": "registry:component",
      "target": "components/overtrue/section-card.tsx",
      "content": "import type { ComponentProps, ReactNode } from \"react\";\nimport {\n  Card,\n  CardContent,\n  CardHeader,\n  CardTitle,\n  CardDescription,\n} from \"@/components/ui/card\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface SectionCardProps extends Omit<\n  ComponentProps<typeof Card>,\n  \"title\"\n> {\n  title?: ReactNode;\n  description?: ReactNode;\n  actions?: ReactNode;\n  contentClassName?: string;\n}\n\n/** A shared heading, actions and content surface for admin panels. */\nexport function SectionCard({\n  title,\n  description,\n  actions,\n  children,\n  className,\n  contentClassName,\n  ...props\n}: SectionCardProps) {\n  return (\n    <Card\n      data-slot=\"section-card\"\n      className={cn(\n        \"min-w-0 gap-0 rounded-2xl border border-border/70 bg-card py-0 text-card-foreground ring-0\",\n        \"shadow-[0_1px_2px_rgb(0_0_0/0.04),0_8px_24px_-12px_rgb(0_0_0/0.10)] dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.05),0_1px_2px_rgb(0_0_0/0.5)]\",\n        className,\n      )}\n      {...props}\n    >\n      {(title || description || actions) && (\n        <CardHeader className=\"flex flex-row flex-wrap items-center justify-between gap-x-4 gap-y-3 border-b border-border/60 px-5 py-4 [.border-b]:pb-4\">\n          <div data-slot=\"section-card-heading\" className=\"min-w-0 flex-1\">\n            {title && (\n              <CardTitle className=\"m-0 text-sm leading-6 font-semibold tracking-tight text-card-foreground\">\n                {title}\n              </CardTitle>\n            )}\n            {description && (\n              <CardDescription className=\"m-0 mt-0.5 text-[13px] leading-5 text-muted-foreground\">\n                {description}\n              </CardDescription>\n            )}\n          </div>\n          {actions && (\n            <div\n              data-slot=\"section-card-actions\"\n              className=\"flex shrink-0 items-center gap-2\"\n            >\n              {actions}\n            </div>\n          )}\n        </CardHeader>\n      )}\n      <CardContent className={cn(\"p-5\", contentClassName)}>\n        {children}\n      </CardContent>\n    </Card>\n  );\n}\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/blocks/notification-preferences. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
