({
className,
children,
showCloseButton = true,
dismissOnOutsideClick = false,
onInteractOutside,
onPointerDownOutside,
forceOverlay = false,
...props
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
showCloseButton?: boolean;
/** Let a click outside the dialog close it. Off by default: a stray click on
* the page behind a form must not discard what the user typed. Turn it on
* for a dialog with nothing to lose — a confirmation, a picker, a read-only
* panel. 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;
})
| 39 | } |
| 40 | |
| 41 | function DialogContent({ |
| 42 | className, |
| 43 | children, |
| 44 | showCloseButton = true, |
| 45 | dismissOnOutsideClick = false, |
| 46 | onInteractOutside, |
| 47 | onPointerDownOutside, |
| 48 | forceOverlay = false, |
| 49 | ...props |
| 50 | }: React.ComponentProps<typeof DialogPrimitive.Content> & { |
| 51 | showCloseButton?: boolean; |
| 52 | /** Let a click outside the dialog close it. Off by default: a stray click on |
| 53 | * the page behind a form must not discard what the user typed. Turn it on |
| 54 | * for a dialog with nothing to lose — a confirmation, a picker, a read-only |
| 55 | * panel. Escape and the close button close either way. */ |
| 56 | dismissOnOutsideClick?: boolean; |
| 57 | /** Pair with `<Dialog modal={false}>`: Radix renders no overlay in non-modal |
| 58 | * mode, so this renders a plain dim layer instead. It still eats outside |
| 59 | * clicks, so the dialog keeps its modal look while the wheel stays free for |
| 60 | * portaled popups. */ |
| 61 | forceOverlay?: boolean; |
| 62 | }) { |
| 63 | return ( |
| 64 | <DialogPortal data-slot="dialog-portal"> |
| 65 | <DialogOverlay /> |
| 66 | {forceOverlay ? ( |
| 67 | <div aria-hidden data-slot="dialog-overlay" className="fixed inset-0 z-50 bg-black/50" /> |
| 68 | ) : null} |
| 69 | <DialogPrimitive.Content |
| 70 | data-slot="dialog-content" |
| 71 | onPointerDownOutside={(event) => { |
| 72 | onPointerDownOutside?.(event); |
| 73 | applyOutsideDismissPolicy(event, dismissOnOutsideClick); |
| 74 | }} |
| 75 | onInteractOutside={(event) => { |
| 76 | onInteractOutside?.(event); |
| 77 | applyOutsideDismissPolicy(event, dismissOnOutsideClick); |
| 78 | }} |
| 79 | className={cn( |
| 80 | "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", |
| 81 | className, |
| 82 | )} |
| 83 | {...props} |
| 84 | > |
| 85 | {children} |
| 86 | {showCloseButton && ( |
| 87 | <DialogPrimitive.Close |
| 88 | data-slot="dialog-close" |
| 89 | 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" |
| 90 | > |
| 91 | <XIcon /> |
| 92 | <span className="sr-only">Close</span> |
| 93 | </DialogPrimitive.Close> |
| 94 | )} |
| 95 | </DialogPrimitive.Content> |
| 96 | </DialogPortal> |
| 97 | ); |
| 98 | } |
nothing calls this directly
no test coverage detected