{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "radix-dialog", "type": "registry:ui", "title": "Dialog", "description": "A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.", "dependencies": [ "motion", "lucide-react", "radix-ui" ], "files": [ { "path": "registry/radix/dialog/index.tsx", "content": "'use client';\n\nimport * as React from 'react';\nimport { Dialog as DialogPrimitive } from 'radix-ui';\nimport { X } from 'lucide-react';\nimport {\n AnimatePresence,\n motion,\n type HTMLMotionProps,\n type Transition,\n} from 'motion/react';\n\nimport { cn } from '@/lib/utils';\n\ntype DialogContextType = {\n isOpen: boolean;\n};\n\nconst DialogContext = React.createContext(\n undefined,\n);\n\nconst useDialog = (): DialogContextType => {\n const context = React.useContext(DialogContext);\n if (!context) {\n throw new Error('useDialog must be used within a Dialog');\n }\n return context;\n};\n\ntype DialogProps = React.ComponentProps;\n\nfunction Dialog({ children, ...props }: DialogProps) {\n const [isOpen, setIsOpen] = React.useState(\n props?.open ?? props?.defaultOpen ?? false,\n );\n\n React.useEffect(() => {\n if (props?.open !== undefined) setIsOpen(props.open);\n }, [props?.open]);\n\n const handleOpenChange = React.useCallback(\n (open: boolean) => {\n setIsOpen(open);\n props.onOpenChange?.(open);\n },\n [props],\n );\n\n return (\n \n \n {children}\n \n \n );\n}\n\ntype DialogTriggerProps = React.ComponentProps;\n\nfunction DialogTrigger(props: DialogTriggerProps) {\n return ;\n}\n\ntype DialogPortalProps = React.ComponentProps;\n\nfunction DialogPortal(props: DialogPortalProps) {\n return ;\n}\n\ntype DialogCloseProps = React.ComponentProps;\n\nfunction DialogClose(props: DialogCloseProps) {\n return ;\n}\n\ntype DialogOverlayProps = React.ComponentProps;\n\nfunction DialogOverlay({ className, ...props }: DialogOverlayProps) {\n return (\n \n );\n}\n\ntype FlipDirection = 'top' | 'bottom' | 'left' | 'right';\n\ntype DialogContentProps = React.ComponentProps &\n HTMLMotionProps<'div'> & {\n from?: FlipDirection;\n transition?: Transition;\n };\n\nfunction DialogContent({\n className,\n children,\n from = 'top',\n transition = { type: 'spring', stiffness: 150, damping: 25 },\n ...props\n}: DialogContentProps) {\n const { isOpen } = useDialog();\n\n const initialRotation =\n from === 'top' || from === 'left' ? '20deg' : '-20deg';\n const isVertical = from === 'top' || from === 'bottom';\n const rotateAxis = isVertical ? 'rotateX' : 'rotateY';\n\n return (\n \n {isOpen && (\n \n \n \n \n \n \n {children}\n \n \n Close\n \n \n \n \n )}\n \n );\n}\n\ntype DialogHeaderProps = React.ComponentProps<'div'>;\n\nfunction DialogHeader({ className, ...props }: DialogHeaderProps) {\n return (\n \n );\n}\n\ntype DialogFooterProps = React.ComponentProps<'div'>;\n\nfunction DialogFooter({ className, ...props }: DialogFooterProps) {\n return (\n \n );\n}\n\ntype DialogTitleProps = React.ComponentProps;\n\nfunction DialogTitle({ className, ...props }: DialogTitleProps) {\n return (\n \n );\n}\n\ntype DialogDescriptionProps = React.ComponentProps<\n typeof DialogPrimitive.Description\n>;\n\nfunction DialogDescription({ className, ...props }: DialogDescriptionProps) {\n return (\n \n );\n}\n\nexport {\n Dialog,\n DialogPortal,\n DialogOverlay,\n DialogClose,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n useDialog,\n type DialogContextType,\n type DialogProps,\n type DialogTriggerProps,\n type DialogPortalProps,\n type DialogCloseProps,\n type DialogOverlayProps,\n type DialogContentProps,\n type DialogHeaderProps,\n type DialogFooterProps,\n type DialogTitleProps,\n type DialogDescriptionProps,\n};\n", "type": "registry:ui", "target": "components/animate-ui/radix/dialog.tsx" } ] }