{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "radix-dialog",
  "title": "Radix Dialog",
  "description": "An accessible modal dialog built on Radix UI with smooth Motion spring entrance and exit animations.",
  "dependencies": ["radix-ui", "motion", "lucide-react"],
  "registryDependencies": [
    "utils",
    "@soralabs/hooks-use-controlled-state",
    "@soralabs/radix-button"
  ],
  "files": [
    {
      "path": "registry/ui/radix/dialog/index.tsx",
      "content": "\"use client\";\n\nimport { useControlledState } from \"@/hooks/use-controlled-state\";\nimport { cn } from \"@/lib/utils\";\nimport { XIcon } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { Dialog as DialogPrimitive } from \"radix-ui\";\nimport { createContext, useContext, useMemo } from \"react\";\nimport type { ComponentProps } from \"react\";\n\nimport { Button } from \"@/components/sora-ui/radix/button\";\n\ninterface DialogContextValue {\n  open: boolean;\n  setOpen: (open: boolean) => void;\n}\n\nconst DialogContext = createContext<DialogContextValue | null>(null);\n\nfunction useDialogContext() {\n  return useContext(DialogContext);\n}\n\ntype DialogProps = ComponentProps<typeof DialogPrimitive.Root>;\n\n/**\n * Root container for the Dialog component powered by Radix UI and Motion.\n */\nfunction Dialog({\n  open: controlledOpen,\n  defaultOpen = false,\n  onOpenChange,\n  children,\n  ...props\n}: DialogProps) {\n  const [open, setOpen] = useControlledState({\n    defaultValue: defaultOpen,\n    onChange: onOpenChange,\n    value: controlledOpen,\n  });\n\n  const contextValue = useMemo(\n    () => ({ open: Boolean(open), setOpen }),\n    [open, setOpen]\n  );\n\n  return (\n    <DialogContext.Provider value={contextValue}>\n      <DialogPrimitive.Root\n        onOpenChange={(nextOpen) => {\n          setOpen(nextOpen);\n        }}\n        open={open}\n        {...props}\n      >\n        {children}\n      </DialogPrimitive.Root>\n    </DialogContext.Provider>\n  );\n}\n\ntype DialogTriggerProps = ComponentProps<typeof DialogPrimitive.Trigger>;\n\n/**\n * Button or trigger element that opens the dialog.\n * Features Motion hover and tap scaling.\n */\nfunction DialogTrigger({\n  className,\n  asChild,\n  children,\n  ...props\n}: DialogTriggerProps) {\n  const prefersReducedMotion = useReducedMotion();\n\n  if (asChild) {\n    return (\n      <DialogPrimitive.Trigger\n        asChild\n        className={className}\n        data-slot=\"dialog-trigger\"\n        {...props}\n      >\n        {children}\n      </DialogPrimitive.Trigger>\n    );\n  }\n\n  return (\n    <DialogPrimitive.Trigger\n      asChild\n      className={className}\n      data-slot=\"dialog-trigger\"\n      {...props}\n    >\n      <motion.button\n        data-primary-action\n        type=\"button\"\n        whileTap={prefersReducedMotion ? undefined : { scale: 0.98 }}\n      >\n        {children}\n      </motion.button>\n    </DialogPrimitive.Trigger>\n  );\n}\n\ntype DialogPortalProps = ComponentProps<typeof DialogPrimitive.Portal>;\n\n/**\n * Portals dialog overlay and content to the document body.\n */\nfunction DialogPortal({ ...props }: DialogPortalProps) {\n  return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />;\n}\n\ntype DialogCloseProps = ComponentProps<typeof DialogPrimitive.Close>;\n\n/**\n * Action button that dismisses the dialog.\n */\nfunction DialogClose({\n  className,\n  asChild,\n  children,\n  ...props\n}: DialogCloseProps) {\n  const prefersReducedMotion = useReducedMotion();\n\n  if (asChild) {\n    return (\n      <DialogPrimitive.Close\n        asChild\n        className={className}\n        data-slot=\"dialog-close\"\n        {...props}\n      >\n        {children}\n      </DialogPrimitive.Close>\n    );\n  }\n\n  return (\n    <DialogPrimitive.Close\n      asChild\n      className={className}\n      data-slot=\"dialog-close\"\n      {...props}\n    >\n      <motion.button\n        type=\"button\"\n        whileTap={prefersReducedMotion ? undefined : { scale: 0.98 }}\n      >\n        {children}\n      </motion.button>\n    </DialogPrimitive.Close>\n  );\n}\n\ntype DialogOverlayProps = ComponentProps<typeof DialogPrimitive.Overlay>;\n\n/**\n * Semi-transparent backdrop overlay behind the dialog with blur and fade transition.\n */\nfunction DialogOverlay({ className, ...props }: DialogOverlayProps) {\n  const prefersReducedMotion = useReducedMotion();\n\n  return (\n    <DialogPrimitive.Overlay\n      asChild\n      className={cn(\n        \"fixed inset-0 isolate z-50 bg-black/50 backdrop-blur-xs dark:bg-black/70\",\n        className\n      )}\n      data-slot=\"dialog-overlay\"\n      {...props}\n    >\n      <motion.div\n        animate={{ opacity: 1 }}\n        exit={{ opacity: 0 }}\n        initial={{ opacity: 0 }}\n        transition={\n          prefersReducedMotion\n            ? { duration: 0 }\n            : { duration: 0.2, ease: \"easeOut\" }\n        }\n      />\n    </DialogPrimitive.Overlay>\n  );\n}\n\ninterface DialogContentProps extends ComponentProps<\n  typeof DialogPrimitive.Content\n> {\n  /**\n   * Additional CSS class name for the fixed container wrapper.\n   */\n  containerClassName?: string;\n  /**\n   * Additional CSS class name for the backdrop overlay.\n   */\n  overlayClassName?: string;\n  /**\n   * Whether to render the standard top-right close icon button.\n   * @default true\n   */\n  showCloseButton?: boolean;\n}\n\n/**\n * Modal dialog content container with Motion 3D perspective rotation and blur entrance/exit.\n */\nfunction DialogContent({\n  className,\n  children,\n  showCloseButton = true,\n  overlayClassName,\n  containerClassName,\n  style,\n  ...props\n}: DialogContentProps) {\n  const context = useDialogContext();\n  const prefersReducedMotion = useReducedMotion();\n  const isOpen = context ? context.open : true;\n\n  return (\n    <AnimatePresence>\n      {isOpen && (\n        <DialogPrimitive.Portal forceMount>\n          <DialogOverlay className={overlayClassName} />\n          <div\n            className={cn(\n              \"pointer-events-none fixed inset-0 z-50 flex items-center justify-center p-4\",\n              containerClassName\n            )}\n          >\n            <DialogPrimitive.Content\n              asChild\n              className={cn(\n                \"border-border bg-background text-foreground pointer-events-auto relative grid w-full max-w-[calc(100%-2rem)] gap-4 rounded-xl border p-6 text-sm shadow-2xl outline-none sm:max-w-lg\",\n                className\n              )}\n              data-slot=\"dialog-content\"\n              forceMount\n              {...props}\n            >\n              <motion.div\n                animate={\n                  prefersReducedMotion\n                    ? { opacity: 1 }\n                    : {\n                        opacity: 1,\n                        filter: \"blur(0px)\",\n                        rotateX: 0,\n                        rotateY: 0,\n                        z: 0,\n                        transition: {\n                          delay: 0.2,\n                          duration: 0.5,\n                          ease: [0.17, 0.67, 0.51, 1],\n                          opacity: {\n                            delay: 0.2,\n                            duration: 0.5,\n                            ease: \"easeOut\",\n                          },\n                        },\n                      }\n                }\n                exit={\n                  prefersReducedMotion\n                    ? { opacity: 0 }\n                    : {\n                        opacity: 0,\n                        filter: \"blur(10px)\",\n                        z: -100,\n                        rotateY: 25,\n                        rotateX: 5,\n                        transformPerspective: 500,\n                        transition: {\n                          duration: 0.3,\n                          ease: [0.67, 0.17, 0.62, 0.64],\n                        },\n                      }\n                }\n                initial={\n                  prefersReducedMotion\n                    ? { opacity: 0 }\n                    : {\n                        opacity: 0,\n                        filter: \"blur(10px)\",\n                        z: -100,\n                        rotateY: 25,\n                        rotateX: 5,\n                        transformPerspective: 500,\n                      }\n                }\n                style={{\n                  transformPerspective: 500,\n                  transformStyle: \"preserve-3d\",\n                  ...style,\n                }}\n              >\n                {children}\n                {showCloseButton && (\n                  <DialogPrimitive.Close\n                    aria-label=\"Close\"\n                    asChild\n                    className=\"text-muted-foreground hover:bg-muted focus-visible:ring-ring absolute top-4 right-4 inline-flex size-7 items-center justify-center rounded-md opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus-visible:ring-2 disabled:pointer-events-none\"\n                    data-slot=\"dialog-close-button\"\n                  >\n                    <motion.button\n                      type=\"button\"\n                      whileTap={\n                        prefersReducedMotion ? undefined : { scale: 0.96 }\n                      }\n                    >\n                      <XIcon className=\"size-4\" />\n                      <span className=\"sr-only\">Close</span>\n                    </motion.button>\n                  </DialogPrimitive.Close>\n                )}\n              </motion.div>\n            </DialogPrimitive.Content>\n          </div>\n        </DialogPrimitive.Portal>\n      )}\n    </AnimatePresence>\n  );\n}\n\n/**\n * Header section containing dialog title and description.\n */\nfunction DialogHeader({ className, ...props }: ComponentProps<\"div\">) {\n  return (\n    <div\n      className={cn(\n        \"flex flex-col gap-1.5 text-center sm:text-left\",\n        className\n      )}\n      data-slot=\"dialog-header\"\n      {...props}\n    />\n  );\n}\n\ninterface DialogFooterProps extends ComponentProps<\"div\"> {\n  /**\n   * Whether to render a secondary close button inside the footer.\n   * @default false\n   */\n  showCloseButton?: boolean;\n}\n\n/**\n * Footer section for dialog action buttons.\n */\nfunction DialogFooter({\n  className,\n  showCloseButton = false,\n  children,\n  ...props\n}: DialogFooterProps) {\n  return (\n    <div\n      className={cn(\n        \"border-border bg-muted/40 -mx-6 mt-2 -mb-6 flex flex-col-reverse gap-2 rounded-b-xl border-t p-4 sm:flex-row sm:justify-end\",\n        className\n      )}\n      data-slot=\"dialog-footer\"\n      {...props}\n    >\n      {children}\n      {showCloseButton && (\n        <DialogPrimitive.Close asChild data-slot=\"dialog-footer-close\">\n          <Button variant=\"outline\">Close</Button>\n        </DialogPrimitive.Close>\n      )}\n    </div>\n  );\n}\n\ntype DialogTitleProps = ComponentProps<typeof DialogPrimitive.Title>;\n\n/**\n * Accessible title heading for the dialog.\n */\nfunction DialogTitle({ className, ...props }: DialogTitleProps) {\n  return (\n    <DialogPrimitive.Title\n      className={cn(\n        \"text-foreground text-lg leading-none font-semibold tracking-tight\",\n        className\n      )}\n      data-slot=\"dialog-title\"\n      {...props}\n    />\n  );\n}\n\ntype DialogDescriptionProps = ComponentProps<\n  typeof DialogPrimitive.Description\n>;\n\n/**\n * Accessible description explaining the purpose of the dialog.\n */\nfunction DialogDescription({ className, ...props }: DialogDescriptionProps) {\n  return (\n    <DialogPrimitive.Description\n      className={cn(\"text-muted-foreground text-sm\", className)}\n      data-slot=\"dialog-description\"\n      {...props}\n    />\n  );\n}\n\ntype DialogViewportProps = ComponentProps<\"div\">;\n\n/**\n * Optional scroll viewport wrapper for large or overflowing dialog popups.\n */\nfunction DialogViewport({ className, ...props }: DialogViewportProps) {\n  return (\n    <div\n      className={cn(\n        \"fixed inset-0 z-50 flex items-center justify-center overflow-y-auto p-4\",\n        className\n      )}\n      data-slot=\"dialog-viewport\"\n      {...props}\n    />\n  );\n}\n\nexport type {\n  DialogCloseProps,\n  DialogContentProps,\n  DialogDescriptionProps,\n  DialogFooterProps,\n  DialogOverlayProps,\n  DialogPortalProps,\n  DialogProps,\n  DialogTitleProps,\n  DialogTriggerProps,\n  DialogViewportProps,\n};\nexport {\n  Dialog,\n  Dialog as RadixDialog,\n  Dialog as default,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogFooter,\n  DialogHeader,\n  DialogOverlay,\n  DialogPortal,\n  DialogTitle,\n  DialogTrigger,\n  DialogViewport,\n};\n",
      "type": "registry:ui",
      "target": "components/sora-ui/radix/dialog.tsx"
    }
  ],
  "meta": {
    "agentMetadata": {
      "intent": "Present focused modal content with Radix focus and portal semantics.",
      "role": "overlay",
      "a11yConstraints": [
        "Keep focus trapped and provide Dialog.Title and Dialog.Description."
      ],
      "motionEngine": "Motion scale, perspective, and backdrop presence transition.",
      "compositionRules": [
        "Use Radix Dialog.Trigger and render one semantic trigger element."
      ],
      "compositionRecipes": [
        "Compose with radix/button for confirmation actions."
      ]
    }
  },
  "type": "registry:ui"
}
