{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "alert-dialog",
  "type": "registry:ui",
  "title": "Alert Dialog",
  "description": "Modal confirmation for destructive or irreversible actions, with required acknowledge and cancel actions.",
  "dependencies": [
    "@radix-ui/react-alert-dialog",
    "@saasflare/ui",
    "motion"
  ],
  "files": [
    {
      "path": "components/ui/alert-dialog.tsx",
      "type": "registry:ui",
      "content": "\"use client\"\n\n/**\n * @fileoverview AlertDialog — modal confirmation dialog with a Motion spring entry animation and backdrop fade.\n * @module packages/ui/components/ui/alert-dialog\n * @layer core\n *\n * Self-contained implementation built on Radix AlertDialog primitive with\n * Motion transitions. Overlay and content animations respect both the user's\n * reduced-motion preference and the resolved `animated` design-system axis.\n * Action and cancel buttons inherit the Saasflare button variant system.\n *\n * @component\n * @example\n * import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogAction, AlertDialogCancel } from \"@saasflare/ui\";\n *\n * <AlertDialog>\n *   <AlertDialogTrigger asChild><Button variant=\"outline\" intent=\"danger\">Delete</Button></AlertDialogTrigger>\n *   <AlertDialogContent>\n *     <AlertDialogHeader><AlertDialogTitle>Are you sure?</AlertDialogTitle></AlertDialogHeader>\n *     <AlertDialogCancel>Cancel</AlertDialogCancel>\n *     <AlertDialogAction>Confirm</AlertDialogAction>\n *   </AlertDialogContent>\n * </AlertDialog>\n */\n\nimport * as React from \"react\"\nimport { m } from \"motion/react\"\nimport * as AlertDialogPrimitive from \"@radix-ui/react-alert-dialog\"\nimport { cn } from \"@saasflare/ui\"\nimport { useSaasflareProps, type SaasflareComponentProps } from \"@saasflare/ui\"\nimport { useSaasflareMotion, springBouncy } from \"@saasflare/ui\"\nimport { buttonVariants } from \"@saasflare/ui\"\n\n/**\n * Root of the alert dialog. Controls open/close state for its trigger, overlay,\n * and content. Use for destructive or otherwise irreversible confirmations.\n */\nfunction AlertDialog({\n  ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {\n  return <AlertDialogPrimitive.Root data-slot=\"alert-dialog\" {...props} />\n}\n\n/** Element that opens the alert dialog when activated. Use `asChild` to wrap a custom control. */\nfunction AlertDialogTrigger({\n  ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {\n  return <AlertDialogPrimitive.Trigger data-slot=\"alert-dialog-trigger\" {...props} />\n}\n\n/** Portals the overlay and content into the document body, escaping overflow/stacking contexts. */\nfunction AlertDialogPortal({\n  ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {\n  return <AlertDialogPrimitive.Portal data-slot=\"alert-dialog-portal\" {...props} />\n}\n\n/**\n * Blurred backdrop rendered behind the dialog content. Honors the resolved\n * `animated` axis via the `data-animated` attribute forwarded from\n * {@link AlertDialogContent}, so its fade is neutralized when motion is disabled.\n */\nfunction AlertDialogOverlay({\n  className,\n  ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {\n  return (\n    <AlertDialogPrimitive.Overlay\n      data-slot=\"alert-dialog-overlay\"\n      className={cn(\n        \"fixed inset-0 z-50 bg-foreground/50 backdrop-blur-[2px] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/**\n * Props for {@link AlertDialogContent}.\n *\n * Extends the Radix AlertDialog content props with\n * {@link SaasflareComponentProps} so the design-system axes\n * (surface/radius/animated/iconWeight) can be supplied per-instance or\n * inherited from the provider.\n */\ninterface AlertDialogContentProps\n  extends Omit<React.ComponentProps<typeof AlertDialogPrimitive.Content>, keyof SaasflareComponentProps>,\n    SaasflareComponentProps {}\n\n/**\n * Centered dialog surface. The visible centerpiece of the alert dialog; resolves\n * the `surface`, `radius`, and `animated` design-system axes and emits the\n * matching `data-*` attributes on its root. The spring entry animation is gated\n * on the resolved `animated` axis (and reduced-motion preference).\n *\n * @example\n * <AlertDialog>\n *   <AlertDialogTrigger asChild><Button variant=\"outline\" intent=\"danger\">Delete</Button></AlertDialogTrigger>\n *   <AlertDialogContent surface=\"raised\" radius=\"lg\" animated>\n *     <AlertDialogHeader>\n *       <AlertDialogTitle>Delete project?</AlertDialogTitle>\n *       <AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>\n *     </AlertDialogHeader>\n *     <AlertDialogFooter>\n *       <AlertDialogCancel>Cancel</AlertDialogCancel>\n *       <AlertDialogAction>Delete</AlertDialogAction>\n *     </AlertDialogFooter>\n *   </AlertDialogContent>\n * </AlertDialog>\n */\nfunction AlertDialogContent({\n  className,\n  children,\n  surface,\n  radius,\n  animated,\n  iconWeight,\n  ...props\n}: AlertDialogContentProps) {\n  const sf = useSaasflareProps({ surface, radius, animated, iconWeight })\n  const motion = useSaasflareMotion(sf.animated, springBouncy)\n\n  return (\n    <AlertDialogPortal>\n      <AlertDialogOverlay data-animated={String(sf.animated)} />\n      <AlertDialogPrimitive.Content\n        {...props}\n        data-slot=\"alert-dialog-content\"\n        asChild\n      >\n        <m.div\n          data-surface={sf.surface}\n          data-radius={sf.radius}\n          data-animated={String(sf.animated)}\n          initial={motion.disabled ? { opacity: 1 } : { opacity: 0, scale: 0.95, y: 10 }}\n          animate={{ opacity: 1, scale: 1, y: 0 }}\n          exit={motion.disabled ? { opacity: 0 } : { opacity: 0, scale: 0.95, y: 10 }}\n          transition={motion.transition}\n          className={cn(\n            \"fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border surface-card p-6 sm:max-w-lg\",\n            className\n          )}\n        >\n          {children}\n        </m.div>\n      </AlertDialogPrimitive.Content>\n    </AlertDialogPortal>\n  )\n}\n\n/** Layout slot for the dialog title and description; stacks centered on mobile, left-aligned on `sm+`. */\nfunction AlertDialogHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"alert-dialog-header\"\n      className={cn(\"flex flex-col gap-2 text-center sm:text-left\", className)}\n      {...props}\n    />\n  )\n}\n\n/** Layout slot for the action buttons; stacks reversed on mobile, right-aligned in a row on `sm+`. */\nfunction AlertDialogFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"alert-dialog-footer\"\n      className={cn(\"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\", className)}\n      {...props}\n    />\n  )\n}\n\n/** Accessible title of the dialog, announced to assistive technology on open. */\nfunction AlertDialogTitle({\n  className,\n  ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {\n  return (\n    <AlertDialogPrimitive.Title\n      data-slot=\"alert-dialog-title\"\n      className={cn(\"text-lg font-semibold\", className)}\n      {...props}\n    />\n  )\n}\n\n/** Supporting description of the dialog, linked as the accessible description of the content. */\nfunction AlertDialogDescription({\n  className,\n  ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {\n  return (\n    <AlertDialogPrimitive.Description\n      data-slot=\"alert-dialog-description\"\n      className={cn(\"text-sm text-muted-foreground\", className)}\n      {...props}\n    />\n  )\n}\n\n/** Primary confirm button; closes the dialog and runs the destructive action. Styled with the solid button variant. */\nfunction AlertDialogAction({\n  className,\n  ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Action>) {\n  return (\n    <AlertDialogPrimitive.Action\n      data-intent=\"primary\"\n      className={cn(buttonVariants({ variant: \"solid\" }), className)}\n      {...props}\n    />\n  )\n}\n\n/** Dismiss button; closes the dialog without running the action. Styled with the outline button variant. */\nfunction AlertDialogCancel({\n  className,\n  ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>) {\n  return (\n    <AlertDialogPrimitive.Cancel\n      data-intent=\"neutral\"\n      className={cn(buttonVariants({ variant: \"outline\" }), className)}\n      {...props}\n    />\n  )\n}\n\nexport {\n  AlertDialog,\n  AlertDialogAction,\n  AlertDialogCancel,\n  AlertDialogContent,\n  AlertDialogDescription,\n  AlertDialogFooter,\n  AlertDialogHeader,\n  AlertDialogOverlay,\n  AlertDialogPortal,\n  AlertDialogTitle,\n  AlertDialogTrigger,\n  type AlertDialogContentProps,\n}\n",
      "target": "components/ui/alert-dialog.tsx"
    }
  ],
  "$meta": {
    "source": "https://ui.saasflare.io/r/alert-dialog.json"
  }
}
