{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dialog",
  "title": "Dialog",
  "description": "Modal dialog with header, body, footer, media and illustration parts, and width and scrolling options.",
  "dependencies": [
    "class-variance-authority@^0.7.1",
    "lucide-react@^1.27.0",
    "radix-ui@^1.6.7"
  ],
  "registryDependencies": [
    "@pestoui/button",
    "@pestoui/style",
    "@pestoui/utils"
  ],
  "files": [
    {
      "path": "pestoui/ui/dialog.tsx",
      "content": "import * as React from \"react\"\nimport { Dialog as DialogPrimitive } from \"radix-ui\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"@/components/ui/button\"\nimport { XIcon } from \"lucide-react\"\n\nfunction Dialog({\n  ...props\n}: React.ComponentProps<typeof DialogPrimitive.Root>) {\n  return <DialogPrimitive.Root data-slot=\"dialog\" {...props} />\n}\n\nfunction DialogTrigger({\n  ...props\n}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {\n  return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />\n}\n\nfunction DialogPortal({\n  ...props\n}: React.ComponentProps<typeof DialogPrimitive.Portal>) {\n  return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />\n}\n\nfunction DialogClose({\n  ...props\n}: React.ComponentProps<typeof DialogPrimitive.Close>) {\n  return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />\n}\n\nfunction DialogOverlay({\n  className,\n  ...props\n}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {\n  return (\n    <DialogPrimitive.Overlay\n      data-slot=\"dialog-overlay\"\n      className={cn(\n        \"fixed inset-0 isolate z-50 bg-black/10 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-open:duration-(--duration-slow) data-open:ease-out-expo data-closed:animate-out data-closed:fade-out-0 data-closed:duration-(--duration-exit) data-closed:ease-out-expo\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/* Two axes on the panel: how wide it is, and whether the middle scrolls.\n\n   `scrollable: false` is the historical single-box layout — one padded grid,\n   children separated by the gap. `scrollable: true` hands padding down to the\n   slots and turns the panel into a capped flex column so DialogBody can shrink\n   below its content and scroll while the header and footer stay put.\n\n   A flex column rather than a fixed row template on purpose: a row template\n   has to name every row up front, so adding a DialogIllustration would\n   silently promote the header into the flexible row. A column capped by\n   max-height is agnostic to how many slots are present and in what order. */\nconst dialogContentVariants = cva(\n  \"group/dialog-content fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl bg-popover text-sm text-popover-foreground shadow-float ring-1 ring-foreground/[0.06] outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-97 data-open:slide-in-from-bottom-4 data-open:duration-(--duration-spring-panel) data-open:ease-spring-panel data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:slide-out-to-bottom-2 data-closed:duration-(--duration-exit) data-closed:ease-out-expo\",\n  {\n    variants: {\n      size: {\n        sm: \"sm:max-w-sm\",\n        default: \"sm:max-w-md\",\n        lg: \"sm:max-w-lg\",\n        xl: \"sm:max-w-2xl\",\n      },\n      scrollable: {\n        /* The cap is the floor of the contract, not a layout choice: a panel\n           is centred with -translate-y-1/2, so anything taller than the\n           viewport loses its top and bottom off-screen with no way to reach\n           them. Scrolling the whole panel is the crude version — the close\n           button travels with it — which is why anything with real content\n           should take scrollable and let DialogBody scroll under a pinned\n           header and footer. This just makes the failure impossible. */\n        false: \"max-h-[calc(100dvh-4rem)] gap-5 overflow-y-auto p-7\",\n        /* Children own their padding here — see Header / Body / Footer. */\n        true: \"flex max-h-[min(40rem,calc(100dvh-4rem))] flex-col gap-0 p-0\",\n      },\n    },\n    defaultVariants: {\n      size: \"default\",\n      scrollable: false,\n    },\n  }\n)\n\nexport interface DialogContentProps\n  extends React.ComponentProps<typeof DialogPrimitive.Content>,\n    VariantProps<typeof dialogContentVariants> {\n  showCloseButton?: boolean\n}\n\nfunction DialogContent({\n  className,\n  children,\n  size,\n  scrollable,\n  showCloseButton = true,\n  ...props\n}: DialogContentProps) {\n  return (\n    <DialogPortal>\n      <DialogOverlay />\n      <DialogPrimitive.Content\n        data-slot=\"dialog-content\"\n        /* Emitted for descendants (header / body / footer / illustration) to\n           select on. The panel's own classes come from the cva above. */\n        data-size={size ?? \"default\"}\n        data-scrollable={scrollable ? \"true\" : \"false\"}\n        className={cn(dialogContentVariants({ size, scrollable }), className)}\n        {...props}\n      >\n        {children}\n        {showCloseButton && (\n          <DialogPrimitive.Close data-slot=\"dialog-close\" asChild>\n            <Button\n              variant=\"ghost\"\n              /* Over a full-bleed illustration the ghost button has no surface\n                 to sit on, so it earns a translucent chip. */\n              className=\"absolute top-4 right-4 text-muted-foreground group-has-data-[slot=dialog-illustration]/dialog-content:bg-background/70 group-has-data-[slot=dialog-illustration]/dialog-content:supports-backdrop-filter:backdrop-blur-xs\"\n              size=\"icon-sm\"\n            >\n              <XIcon />\n              <span className=\"sr-only\">Close</span>\n            </Button>\n          </DialogPrimitive.Close>\n        )}\n      </DialogPrimitive.Content>\n    </DialogPortal>\n  )\n}\n\n/* Squircle tile for the header glyph. Tone is the only thing tone touches —\n   the copy and the panel stay neutral, matching how Alert and Banner tint.\n\n   Tint only, never a solid fill: there is no destructive-foreground token, so\n   a filled treatment would need either a new token or a bare colour literal.\n\n   The radius comes off the shared radius scale rather than a per-size value.\n   That keeps the tile inside the squircle band at every size and lands within\n   a fraction of a pixel of the tile alert-dialog already ships at the default\n   size, so the two never visually disagree. */\nconst dialogMediaVariants = cva(\n  \"inline-flex shrink-0 items-center justify-center rounded-md ring-1 group-data-open/dialog-content:animate-in group-data-open/dialog-content:fade-in-0 group-data-open/dialog-content:zoom-in-90 group-data-open/dialog-content:fill-mode-backwards group-data-open/dialog-content:delay-(--stagger-loose) group-data-open/dialog-content:anim-spring-bouncy group-data-open/dialog-content:ease-spring-bouncy\",\n  {\n    variants: {\n      tone: {\n        neutral: \"bg-secondary text-foreground shadow-soft ring-foreground/[0.04]\",\n        /* --selected, never --primary: the CTA lime sits far too light to\n             carry a glyph or a hairline ring. --selected lands in the same\n             lightness band as info / success / destructive below, so every\n             tone in the set tints, rings and draws its glyph at one\n             strength. */\n        brand: \"bg-selected/10 text-selected ring-selected/20\",\n        info: \"bg-info/10 text-info ring-info/20\",\n        success: \"bg-success/10 text-success ring-success/20\",\n        /* Warning runs one notch heavier than its siblings — the swatch is the\n           lightest of the set, so the tint and ring carry the shape. */\n        warning: \"bg-warning/15 text-warning ring-warning/30\",\n        destructive: \"bg-destructive/10 text-destructive ring-destructive/20\",\n      },\n      size: {\n        sm: \"size-10 *:[svg:not([class*='size-'])]:size-5\",\n        md: \"size-11 *:[svg:not([class*='size-'])]:size-6\",\n        lg: \"size-12 *:[svg:not([class*='size-'])]:size-6\",\n      },\n    },\n    defaultVariants: {\n      tone: \"neutral\",\n      size: \"md\",\n    },\n  }\n)\n\nexport interface DialogMediaProps\n  extends React.ComponentProps<\"div\">,\n    VariantProps<typeof dialogMediaVariants> {}\n\nfunction DialogMedia({ className, tone, size, ...props }: DialogMediaProps) {\n  return (\n    <div\n      data-slot=\"dialog-media\"\n      data-tone={tone ?? \"neutral\"}\n      aria-hidden=\"true\"\n      className={cn(dialogMediaVariants({ tone, size }), className)}\n      {...props}\n    />\n  )\n}\n\n/* Alignment is an explicit choice, not a by-product of size and breakpoint.\n   `lead` puts the tile in a leading column, which needs DialogHeaderText to\n   group the title and description into one flex child beside it. */\nconst dialogHeaderVariants = cva(\n  \"flex gap-2 group-data-open/dialog-content:animate-in group-data-open/dialog-content:fade-in-0 group-data-open/dialog-content:slide-in-from-bottom-2 group-data-open/dialog-content:fill-mode-backwards group-data-open/dialog-content:delay-(--stagger-loose) group-data-open/dialog-content:duration-(--duration-base) group-data-open/dialog-content:ease-out-expo group-data-[scrollable=true]/dialog-content:shrink-0 group-data-[scrollable=true]/dialog-content:border-b group-data-[scrollable=true]/dialog-content:border-border group-data-[scrollable=true]/dialog-content:px-7 group-data-[scrollable=true]/dialog-content:py-5\",\n  {\n    variants: {\n      align: {\n        start: \"flex-col\",\n        center: \"flex-col items-center text-center\",\n        lead: \"flex-row items-start gap-4 *:data-[slot=dialog-media]:mt-0.5\",\n      },\n    },\n    defaultVariants: {\n      align: \"start\",\n    },\n  }\n)\n\nexport interface DialogHeaderProps\n  extends Omit<React.ComponentProps<\"div\">, \"align\">,\n    VariantProps<typeof dialogHeaderVariants> {}\n\nfunction DialogHeader({ className, align, ...props }: DialogHeaderProps) {\n  return (\n    <div\n      data-slot=\"dialog-header\"\n      className={cn(dialogHeaderVariants({ align }), className)}\n      {...props}\n    />\n  )\n}\n\nexport interface DialogHeaderTextProps extends React.ComponentProps<\"div\"> {}\n\n/* Groups Title + Description into one flex child so align=\"lead\" sets them\n   beside the tile rather than making them siblings of it. */\nfunction DialogHeaderText({ className, ...props }: DialogHeaderTextProps) {\n  return (\n    <div\n      data-slot=\"dialog-header-text\"\n      className={cn(\"flex min-w-0 flex-col gap-2\", className)}\n      {...props}\n    />\n  )\n}\n\nexport interface DialogBodyProps extends React.ComponentProps<\"div\"> {}\n\n/* The scroll region. Inert in the default layout — it only takes over padding\n   and overflow once the panel is scrollable. min-h-0 is what lets it shrink\n   below its own content inside the capped column. */\nfunction DialogBody({ className, ...props }: DialogBodyProps) {\n  return (\n    <div\n      data-slot=\"dialog-body\"\n      className={cn(\n        \"min-h-0 group-data-[scrollable=true]/dialog-content:overflow-y-auto group-data-[scrollable=true]/dialog-content:overscroll-contain group-data-[scrollable=true]/dialog-content:px-7 group-data-[scrollable=true]/dialog-content:py-5\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/* `end` is the historical single trailing cluster. `split` pushes a secondary\n   action to the far edge. `stacked` is the full-width equal pair for when the\n   two choices carry the same weight. */\nconst dialogFooterVariants = cva(\n  \"flex gap-3 group-data-[scrollable=true]/dialog-content:shrink-0 group-data-[scrollable=true]/dialog-content:border-t group-data-[scrollable=true]/dialog-content:border-border group-data-[scrollable=true]/dialog-content:px-7 group-data-[scrollable=true]/dialog-content:py-5\",\n  {\n    variants: {\n      layout: {\n        end: \"flex-col-reverse sm:flex-row sm:justify-end\",\n        split: \"flex-col-reverse sm:flex-row sm:justify-between\",\n        stacked: \"grid grid-cols-1 sm:grid-cols-2 *:w-full\",\n      },\n    },\n    defaultVariants: {\n      layout: \"end\",\n    },\n  }\n)\n\nexport interface DialogFooterProps\n  extends React.ComponentProps<\"div\">,\n    VariantProps<typeof dialogFooterVariants> {\n  showCloseButton?: boolean\n}\n\nfunction DialogFooter({\n  className,\n  layout,\n  showCloseButton = false,\n  children,\n  ...props\n}: DialogFooterProps) {\n  return (\n    <div\n      data-slot=\"dialog-footer\"\n      className={cn(dialogFooterVariants({ layout }), className)}\n      {...props}\n    >\n      {children}\n      {showCloseButton && (\n        <DialogPrimitive.Close asChild>\n          <Button variant=\"outline\">Close</Button>\n        </DialogPrimitive.Close>\n      )}\n    </div>\n  )\n}\n\nexport interface DialogIllustrationProps extends React.ComponentProps<\"div\"> {}\n\n/* Full-bleed media header. In the default layout it cancels the panel padding\n   with negative margins; in the scrollable layout there is no padding to\n   cancel, so it only clips. The top corners have to track the panel radius or\n   an unclipped corner shows through immediately — and overflow lives here, on\n   the wrapper, not on the image. */\nfunction DialogIllustration({ className, ...props }: DialogIllustrationProps) {\n  return (\n    <div\n      data-slot=\"dialog-illustration\"\n      className={cn(\n        \"overflow-hidden rounded-t-xl group-data-open/dialog-content:animate-in group-data-open/dialog-content:fade-in-0 group-data-open/dialog-content:blur-in-6 group-data-open/dialog-content:anim-spring-panel group-data-open/dialog-content:ease-spring-panel group-data-[scrollable=false]/dialog-content:-mx-7 group-data-[scrollable=false]/dialog-content:-mt-7 group-data-[scrollable=true]/dialog-content:shrink-0\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction DialogTitle({\n  className,\n  ...props\n}: React.ComponentProps<typeof DialogPrimitive.Title>) {\n  return (\n    <DialogPrimitive.Title\n      data-slot=\"dialog-title\"\n      className={cn(\n        \"font-heading text-[1.375rem] leading-tight font-semibold tracking-title\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction DialogDescription({\n  className,\n  ...props\n}: React.ComponentProps<typeof DialogPrimitive.Description>) {\n  return (\n    <DialogPrimitive.Description\n      data-slot=\"dialog-description\"\n      className={cn(\n        \"text-body leading-normal text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nexport {\n  Dialog,\n  DialogBody,\n  DialogClose,\n  DialogContent,\n  dialogContentVariants,\n  DialogDescription,\n  DialogFooter,\n  dialogFooterVariants,\n  DialogHeader,\n  dialogHeaderVariants,\n  DialogHeaderText,\n  DialogIllustration,\n  DialogMedia,\n  dialogMediaVariants,\n  DialogOverlay,\n  DialogPortal,\n  DialogTitle,\n  DialogTrigger,\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}