{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "alert-dialog",
  "title": "Alert Dialog",
  "author": "AniBT <https://anibt.net>",
  "description": "AniBT question dialog: the stitched bar with A's 24px tinted mark (AlertDialogMedia), the quiet cancel left of a candy or red action, shadcn's size / variant props.",
  "dependencies": [
    "class-variance-authority",
    "radix-ui"
  ],
  "registryDependencies": [
    "@anibt/theme",
    "@anibt/button"
  ],
  "files": [
    {
      "path": "registry/anibt/ui/alert-dialog.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { AlertDialog as AlertDialogPrimitive } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"@/registry/anibt/ui/button\"\n\n/**\n * AlertDialog — AniBT 「贴纸手账」: a question that must be answered.\n *\n * The same floating panel and 48px stitched bar as Dialog, without a close\n * button: the reader leaves through 取消 or the action. `AlertDialogMedia` is\n * A's dialog mark, a 24px tinted tile in the bar before the title — red for a\n * destructive question. The footer is one order everywhere: the quiet cancel\n * on the left, the action on the right (`variant=\"destructive\"` for the red\n * one).\n *\n * Export names and props are shadcn's (including `size` on the content and\n * `variant` / `size` on the action and the cancel), so this file can replace\n * `components/ui/alert-dialog.tsx`.\n */\n\ntype RenderCompat = {\n  /** Base UI's `asChild`: render this element instead, with the part's props. */\n  render?: React.ReactElement\n  /** Base UI compatibility; ignored (Radix decides from the rendered element). */\n  nativeButton?: boolean\n}\n\n/** Maps Base UI's `render` onto Radix's `asChild`. */\nfunction renderAsChild<P extends { asChild?: boolean; children?: React.ReactNode }>({\n  render,\n  nativeButton: _nativeButton,\n  ...props\n}: P & RenderCompat): P {\n  void _nativeButton\n  if (!render) return props as P\n  const children = props.children === undefined ? render : React.cloneElement(render, undefined, props.children)\n  return { ...props, asChild: true, children } as P\n}\n\nfunction AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {\n  return <AlertDialogPrimitive.Root data-slot=\"alert-dialog\" {...props} />\n}\n\nfunction AlertDialogTrigger(props: React.ComponentProps<typeof AlertDialogPrimitive.Trigger> & RenderCompat) {\n  return <AlertDialogPrimitive.Trigger data-slot=\"alert-dialog-trigger\" {...renderAsChild(props)} />\n}\n\nfunction AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {\n  return <AlertDialogPrimitive.Portal data-slot=\"alert-dialog-portal\" {...props} />\n}\n\nfunction AlertDialogOverlay({ className, ...props }: 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-anibt-scrim duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction AlertDialogContent({\n  className,\n  size = \"default\",\n  ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Content> & {\n  /** `default` is 420 wide; `sm` is 320 with the two buttons side by side. */\n  size?: \"default\" | \"sm\"\n}) {\n  return (\n    <AlertDialogPortal>\n      <AlertDialogOverlay />\n      <AlertDialogPrimitive.Content\n        data-slot=\"alert-dialog-content\"\n        data-size={size}\n        className={cn(\n          \"group/alert-dialog-content anibt-pop fixed top-1/2 left-1/2 z-50 flex max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col gap-3 overflow-y-auto overscroll-contain p-4 text-[14px] duration-200 outline-none data-[size=default]:sm:max-w-[420px] data-[size=sm]:max-w-xs\",\n          \"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95\",\n          className\n        )}\n        {...props}\n      />\n    </AlertDialogPortal>\n  )\n}\n\n/** The 48px stitched bar. With a media tile the tile sits left of the title. */\nfunction AlertDialogHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"alert-dialog-header\"\n      className={cn(\n        \"anibt-stitch-under -mx-4 -mt-4 grid min-h-12 shrink-0 content-center items-center gap-x-2 gap-y-1 px-4 py-3 text-left has-data-[slot=alert-dialog-media]:grid-cols-[auto_minmax(0,1fr)] *:data-[slot=alert-dialog-description]:col-start-1 has-data-[slot=alert-dialog-media]:*:data-[slot=alert-dialog-description]:col-start-2\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/** Right-aligned buttons; `size=\"sm\"` puts them side by side at equal width. */\nfunction AlertDialogFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"alert-dialog-footer\"\n      className={cn(\n        \"flex shrink-0 flex-col-reverse gap-2 pt-1 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {\n  return (\n    <AlertDialogPrimitive.Title\n      data-slot=\"alert-dialog-title\"\n      className={cn(\"text-[14px] leading-snug font-bold text-foreground\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction AlertDialogDescription({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {\n  return (\n    <AlertDialogPrimitive.Description\n      data-slot=\"alert-dialog-description\"\n      className={cn(\"text-[13px] leading-normal text-anibt-ink2\", className)}\n      {...props}\n    />\n  )\n}\n\nconst alertDialogMediaVariants = cva(\n  \"grid size-6 shrink-0 place-items-center rounded-[6px] [&>svg]:pointer-events-none [&>svg:not([class*='size-'])]:size-4\",\n  {\n    variants: {\n      tone: {\n        default: \"bg-muted text-anibt-ink2\",\n        destructive: \"bg-anibt-danger-wash text-destructive\",\n        warning: \"bg-anibt-warn-wash text-anibt-warn\",\n        accent: \"bg-accent text-accent-foreground\",\n      },\n    },\n    defaultVariants: {\n      tone: \"default\",\n    },\n  }\n)\n\n/** A's dialog mark: a 24px tinted tile holding one icon, left of the title. */\nfunction AlertDialogMedia({\n  className,\n  tone,\n  ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof alertDialogMediaVariants>) {\n  return (\n    <div\n      data-slot=\"alert-dialog-media\"\n      aria-hidden=\"true\"\n      className={cn(alertDialogMediaVariants({ tone }), className)}\n      {...props}\n    />\n  )\n}\n\n/** The answer: candy by default, `variant=\"destructive\"` for the red one. */\nfunction AlertDialogAction({\n  className,\n  variant = \"default\",\n  size = \"default\",\n  ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Action> &\n  Pick<React.ComponentProps<typeof Button>, \"variant\" | \"size\">) {\n  return (\n    <Button variant={variant} size={size} {...{ asChild: true }}>\n      <AlertDialogPrimitive.Action data-slot=\"alert-dialog-action\" className={cn(className)} {...props} />\n    </Button>\n  )\n}\n\n/** The way out: the quiet tier, left of the action. */\nfunction AlertDialogCancel({\n  className,\n  variant = \"ghost\",\n  size = \"default\",\n  ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Cancel> &\n  Pick<React.ComponentProps<typeof Button>, \"variant\" | \"size\">) {\n  return (\n    <Button variant={variant} size={size} {...{ asChild: true }}>\n      <AlertDialogPrimitive.Cancel data-slot=\"alert-dialog-cancel\" className={cn(className)} {...props} />\n    </Button>\n  )\n}\n\nexport {\n  AlertDialog,\n  AlertDialogAction,\n  AlertDialogCancel,\n  AlertDialogContent,\n  AlertDialogDescription,\n  AlertDialogFooter,\n  AlertDialogHeader,\n  AlertDialogMedia,\n  AlertDialogOverlay,\n  AlertDialogPortal,\n  AlertDialogTitle,\n  AlertDialogTrigger,\n  alertDialogMediaVariants,\n}\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "overlay"
  ],
  "type": "registry:ui"
}