{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dialog",
  "title": "dialog",
  "dependencies": [
    "@radix-ui/react-dialog",
    "class-variance-authority@^0.7"
  ],
  "registryDependencies": [
    "@dwellir/dwellir-theme",
    "@dwellir/utils",
    "@dwellir/button",
    "@dwellir/portal-container",
    "@dwellir/touch-focus",
    "@dwellir/rune-icons",
    "@dwellir/modal-surface"
  ],
  "files": [
    {
      "path": "components/ui/dialog.tsx",
      "content": "'use client';\n\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport type { ComponentProps } from 'react';\nimport { RuneClose } from '@/components/brand/rune-icons';\nimport { Button } from '@/components/ui/button';\nimport { useModalSurface } from '@/lib/modal-surface';\nimport { PortalContainer } from '@/lib/portal-container';\nimport { useScrollFocus } from '@/lib/scroll-focus';\nimport { focusContentOnTouch } from '@/lib/touch-focus';\nimport { cn } from '@/lib/utils';\n\nfunction Dialog(props: ComponentProps<typeof DialogPrimitive.Root>) {\n  return <DialogPrimitive.Root data-slot=\"dialog\" {...props} />;\n}\n\nfunction DialogTrigger(props: ComponentProps<typeof DialogPrimitive.Trigger>) {\n  return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />;\n}\n\nfunction DialogPortal(props: ComponentProps<typeof DialogPrimitive.Portal>) {\n  return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />;\n}\n\nfunction DialogClose(props: ComponentProps<typeof DialogPrimitive.Close>) {\n  return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />;\n}\n\n/* Over the navbar and the cookie notice: the modal makes the rest of the page inert. */\nfunction DialogOverlay({ className, ...props }: ComponentProps<typeof DialogPrimitive.Overlay>) {\n  return (\n    <DialogPrimitive.Overlay\n      data-slot=\"dialog-overlay\"\n      className={cn(\n        'fixed inset-0 z-modal bg-scrim 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\n/*\n * center: the modal in the middle of the screen.\n * corner: a compact panel 24px from the bottom-right corner, and a bottom\n * sheet on phones, such as the cookie preferences. The header, title,\n * description and footer read data-placement and shrink with it.\n * Both keep clear of the safe area: the modal-* and corner-* insets\n * (styles/design-system-theme.css).\n * The surface: grain on the website, plain (the popover fill, no texture) on app screens\n * (ModalSurfaceProvider sets an app's default, lib/modal-surface.tsx).\n * Without a DialogBody the panel scrolls. With one it holds still, and modal-host\n * passes its layout through a form around the parts.\n */\nconst dialogContentVariants = cva(\n  'group/dialog ui-popup-motion modal-host fixed z-modal grid overflow-y-auto overscroll-contain scrollbar-quiet border border-border text-popover-foreground shadow-popover animation-duration-200 outline-none 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  {\n    variants: {\n      placement: {\n        center:\n          'top-modal-cy left-modal-cx max-h-modal w-modal max-w-lg -translate-x-1/2 -translate-y-1/2 gap-5 rounded-3xl p-7',\n        corner:\n          'right-corner-r bottom-corner-b left-corner-l ml-auto max-h-modal-corner max-w-145 gap-4 rounded-xl p-5 max-sm:right-0 max-sm:bottom-0 max-sm:left-0 max-sm:max-h-modal-docked max-sm:max-w-none max-sm:gap-3 max-sm:rounded-b-none max-sm:p-4 max-sm:pb-docked-b',\n      },\n      surface: {\n        grain: 'bg-popover grain',\n        plain: 'bg-popover',\n      },\n    },\n    defaultVariants: { placement: 'center', surface: 'grain' },\n  },\n);\n\nfunction DialogContent({\n  className,\n  children,\n  placement,\n  surface,\n  showCloseButton = true,\n  onOpenAutoFocus,\n  ...props\n}: ComponentProps<typeof DialogPrimitive.Content> &\n  VariantProps<typeof dialogContentVariants> & { showCloseButton?: boolean }) {\n  const shown = useModalSurface(surface);\n  return (\n    <DialogPortal>\n      <DialogOverlay />\n      <DialogPrimitive.Content\n        data-slot=\"dialog-content\"\n        data-placement={placement ?? 'center'}\n        data-surface={shown}\n        data-closable={showCloseButton ? '' : undefined}\n        className={cn(dialogContentVariants({ placement, surface: shown }), className)}\n        {...props}\n        onOpenAutoFocus={focusContentOnTouch(onOpenAutoFocus)}\n      >\n        {/* Radix hides the page behind the modal: popups opened inside go to the body. */}\n        <PortalContainer id={null}>{children}</PortalContainer>\n        {/* 32px to see; a touch gets 44px. */}\n        {showCloseButton ? (\n          <DialogPrimitive.Close\n            data-slot=\"dialog-close\"\n            className=\"absolute top-5 right-5 grid size-8 place-items-center rounded-full text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none pointer-coarse:before:absolute pointer-coarse:before:-inset-1.5\"\n          >\n            <RuneClose className=\"size-4\" aria-hidden=\"true\" />\n            <span className=\"sr-only\">Close</span>\n          </DialogPrimitive.Close>\n        ) : null}\n      </DialogPrimitive.Content>\n    </DialogPortal>\n  );\n}\n\nfunction DialogHeader({ className, ...props }: ComponentProps<'div'>) {\n  return (\n    <div\n      data-slot=\"dialog-header\"\n      className={cn(\n        /* Room for the close button, when it shows. */\n        'flex flex-col gap-2 group-data-[closable]/dialog:pr-8 group-data-[placement=corner]/dialog:gap-1',\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/*\n * The part between the header and the footer that scrolls, so both stay in\n * view: the footer's action shows on a short phone. Its bar runs at the panel's\n * edge, clear of the rounded corners. It takes the panel's padding across: a\n * panel with other padding sets the body's to match.\n */\nfunction DialogBody({ className, ref, ...props }: ComponentProps<'div'>) {\n  const scrollFocus = useScrollFocus(ref);\n  return (\n    <div\n      ref={scrollFocus}\n      data-slot=\"dialog-body\"\n      className={cn(\n        'modal-body -mx-7 -my-1 px-7 py-1 group-data-[placement=corner]/dialog:-mx-5 group-data-[placement=corner]/dialog:px-5 max-sm:group-data-[placement=corner]/dialog:-mx-4 max-sm:group-data-[placement=corner]/dialog:px-4',\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/* showCloseButton adds an outline Close button after the footer's own actions. */\nfunction DialogFooter({\n  className,\n  showCloseButton = false,\n  children,\n  ...props\n}: ComponentProps<'div'> & { showCloseButton?: boolean }) {\n  return (\n    <div\n      data-slot=\"dialog-footer\"\n      className={cn(\n        'flex flex-col-reverse gap-3 sm:flex-row sm:justify-end',\n        /* A corner panel keeps its actions in one row, also on phones. */\n        'group-data-[placement=corner]/dialog:flex-row group-data-[placement=corner]/dialog:items-center group-data-[placement=corner]/dialog:justify-end group-data-[placement=corner]/dialog:gap-4 max-sm:group-data-[placement=corner]/dialog:gap-2',\n        className,\n      )}\n      {...props}\n    >\n      {children}\n      {showCloseButton ? (\n        <DialogPrimitive.Close asChild>\n          <Button variant=\"outline\">Close</Button>\n        </DialogPrimitive.Close>\n      ) : null}\n    </div>\n  );\n}\n\nfunction DialogTitle({ className, ...props }: ComponentProps<typeof DialogPrimitive.Title>) {\n  return (\n    <DialogPrimitive.Title\n      data-slot=\"dialog-title\"\n      className={cn(\n        'font-display text-2xl leading-tight font-bold tracking-tight text-balance text-title group-data-[placement=corner]/dialog:text-lg group-data-[placement=corner]/dialog:tracking-normal',\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nfunction DialogDescription({\n  className,\n  ...props\n}: ComponentProps<typeof DialogPrimitive.Description>) {\n  return (\n    <DialogPrimitive.Description\n      data-slot=\"dialog-description\"\n      className={cn(\n        'text-sm text-pretty text-muted-foreground group-data-[placement=corner]/dialog:text-xs',\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nexport {\n  Dialog,\n  DialogBody,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogFooter,\n  DialogHeader,\n  DialogOverlay,\n  DialogPortal,\n  DialogTitle,\n  DialogTrigger,\n};\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}