{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dialog",
  "title": "Dialog",
  "description": "Modal window centred over the page, with a focus trap, overlay, close button, header, footer, title and description parts.",
  "dependencies": [
    "@radix-ui/react-dialog",
    "lucide-react"
  ],
  "registryDependencies": [
    "@corsair-ui/utils"
  ],
  "files": [
    {
      "path": "registry/default/ui/dialog.tsx",
      "content": "\"use client\";\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport { XIcon } from \"lucide-react\";\nimport type { ComponentProps } from \"react\";\nimport { cn } from \"@/registry/default/lib/utils\";\n\n/**\n * A modal window centred over the page. Focus moves into it when it opens,\n * stays trapped inside, and returns to the trigger when it closes; Escape and\n * a click on the overlay close it, and the page behind it does not scroll.\n * Screen readers announce it as a dialog named by `DialogTitle` and described\n * by `DialogDescription`. With reduced motion it appears without fading or\n * zooming.\n *\n * @example\n * <Dialog>\n *   <DialogTrigger asChild>\n *     <Button>Edit profile</Button>\n *   </DialogTrigger>\n *   <DialogContent>\n *     <DialogHeader>\n *       <DialogTitle>Edit profile</DialogTitle>\n *       <DialogDescription>Changes are saved when you press Save.</DialogDescription>\n *     </DialogHeader>\n *     <DialogFooter>\n *       <DialogClose asChild>\n *         <Button variant=\"outline\">Cancel</Button>\n *       </DialogClose>\n *       <Button>Save</Button>\n *     </DialogFooter>\n *   </DialogContent>\n * </Dialog>\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\n/** Closes the dialog. Use `asChild` to turn your own button into a close button. */\nfunction DialogClose(props: ComponentProps<typeof DialogPrimitive.Close>) {\n  return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />;\n}\n\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-50 bg-black/50\",\n        // animate-in/out sit behind motion-safe: so reduced motion really turns them off.\n        \"motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0\",\n        \"motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0\",\n        className\n      )}\n      {...props}\n    />\n  );\n}\n\ninterface DialogContentProps extends ComponentProps<typeof DialogPrimitive.Content> {\n  /** Renders an icon button in the top corner that closes the dialog. */\n  showCloseButton?: boolean;\n  /** Accessible name of the close button. */\n  closeLabel?: string;\n  /**\n   * Classes for the overlay behind the window: opacity, blur, z-index. The\n   * overlay is also `data-slot=\"dialog-overlay\"` for styling from outside.\n   */\n  overlayClassName?: string;\n}\n\n/**\n * The window itself, rendered in a portal above an overlay. It needs a\n * `DialogTitle`; hide it with `sr-only` if the design has no visible heading.\n */\nfunction DialogContent({\n  className,\n  children,\n  showCloseButton = true,\n  closeLabel = \"Close\",\n  overlayClassName,\n  ...props\n}: DialogContentProps) {\n  return (\n    <DialogPortal>\n      <DialogOverlay className={overlayClassName} />\n      <DialogPrimitive.Content\n        data-slot=\"dialog-content\"\n        className={cn(\n          \"bg-background 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 gap-4 rounded-lg border p-6 shadow-lg outline-none sm:max-w-lg\",\n          \"motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95\",\n          \"motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95\",\n          className\n        )}\n        {...props}\n      >\n        {children}\n        {showCloseButton ? (\n          <DialogPrimitive.Close\n            data-slot=\"dialog-close-button\"\n            aria-label={closeLabel}\n            className={cn(\n              \"absolute top-4 right-4 inline-flex size-6 cursor-pointer items-center justify-center rounded-md opacity-70\",\n              \"transition-opacity outline-none hover:opacity-100 motion-reduce:transition-none\",\n              \"focus-visible:ring-ring/50 focus-visible:opacity-100 focus-visible:ring-[3px]\",\n              \"disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\"\n            )}\n          >\n            <XIcon aria-hidden=\"true\" />\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(\"flex flex-col gap-2 text-center sm:text-left\", className)}\n      {...props}\n    />\n  );\n}\n\nfunction DialogFooter({ className, ...props }: ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"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/** Names the dialog for screen readers. */\nfunction DialogTitle({ className, ...props }: ComponentProps<typeof DialogPrimitive.Title>) {\n  return (\n    <DialogPrimitive.Title\n      data-slot=\"dialog-title\"\n      className={cn(\"text-lg leading-none font-semibold\", className)}\n      {...props}\n    />\n  );\n}\n\n/** Read out after the title when the dialog opens. */\nfunction DialogDescription({\n  className,\n  ...props\n}: ComponentProps<typeof DialogPrimitive.Description>) {\n  return (\n    <DialogPrimitive.Description\n      data-slot=\"dialog-description\"\n      className={cn(\"text-muted-foreground text-sm\", className)}\n      {...props}\n    />\n  );\n}\n\nexport {\n  Dialog,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogFooter,\n  DialogHeader,\n  DialogOverlay,\n  DialogPortal,\n  DialogTitle,\n  DialogTrigger,\n  type DialogContentProps,\n};\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}