({
className,
children,
showCloseButton = true,
dismissOnOutsideClick,
onInteractOutside,
onPointerDownOutside,
forceOverlay = false,
ref,
...props
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
showCloseButton?: boolean;
/** Whether a click outside the dialog closes it. Unset, the dialog decides
* from its contents: it stays open while it holds a form field — a stray
* click on the page behind a form must not discard what the user typed —
* and closes when it has nothing to lose. Pass a boolean to override the
* detection. Escape and the close button close either way. */
dismissOnOutsideClick?: boolean;
/** Pair with `<Dialog modal={false}>`: Radix renders no overlay in non-modal
* mode, so this renders a plain dim layer instead. It still eats outside
* clicks, so the dialog keeps its modal look while the wheel stays free for
* portaled popups. */
forceOverlay?: boolean;
})
| 40 | } |
| 41 | |
| 42 | function DialogContent({ |
| 43 | className, |
| 44 | children, |
| 45 | showCloseButton = true, |
| 46 | dismissOnOutsideClick, |
| 47 | onInteractOutside, |
| 48 | onPointerDownOutside, |
| 49 | forceOverlay = false, |
| 50 | ref, |
| 51 | ...props |
| 52 | }: React.ComponentProps<typeof DialogPrimitive.Content> & { |
| 53 | showCloseButton?: boolean; |
| 54 | /** Whether a click outside the dialog closes it. Unset, the dialog decides |
| 55 | * from its contents: it stays open while it holds a form field — a stray |
| 56 | * click on the page behind a form must not discard what the user typed — |
| 57 | * and closes when it has nothing to lose. Pass a boolean to override the |
| 58 | * detection. Escape and the close button close either way. */ |
| 59 | dismissOnOutsideClick?: boolean; |
| 60 | /** Pair with `<Dialog modal={false}>`: Radix renders no overlay in non-modal |
| 61 | * mode, so this renders a plain dim layer instead. It still eats outside |
| 62 | * clicks, so the dialog keeps its modal look while the wheel stays free for |
| 63 | * portaled popups. */ |
| 64 | forceOverlay?: boolean; |
| 65 | }) { |
| 66 | const contentRef = React.useRef<React.ComponentRef<typeof DialogPrimitive.Content> | null>(null); |
| 67 | const composedRef = useComposedRef(ref, contentRef); |
| 68 | return ( |
| 69 | <DialogPortal data-slot="dialog-portal"> |
| 70 | <DialogOverlay /> |
| 71 | {forceOverlay ? ( |
| 72 | <div aria-hidden data-slot="dialog-overlay" className="fixed inset-0 z-50 bg-black/50" /> |
| 73 | ) : null} |
| 74 | <DialogPrimitive.Content |
| 75 | data-slot="dialog-content" |
| 76 | ref={composedRef} |
| 77 | onPointerDownOutside={(event) => { |
| 78 | onPointerDownOutside?.(event); |
| 79 | applyOutsideDismissPolicy(event, dismissOnOutsideClick, contentRef.current); |
| 80 | }} |
| 81 | onInteractOutside={(event) => { |
| 82 | onInteractOutside?.(event); |
| 83 | applyOutsideDismissPolicy(event, dismissOnOutsideClick, contentRef.current); |
| 84 | }} |
| 85 | className={cn( |
| 86 | "fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg 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 sm:max-w-lg", |
| 87 | className, |
| 88 | )} |
| 89 | {...props} |
| 90 | > |
| 91 | {children} |
| 92 | {showCloseButton && ( |
| 93 | <DialogPrimitive.Close |
| 94 | data-slot="dialog-close" |
| 95 | className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4" |
| 96 | > |
| 97 | <XIcon /> |
| 98 | <span className="sr-only">Close</span> |
| 99 | </DialogPrimitive.Close> |
nothing calls this directly
no test coverage detected