({
className,
children,
side = "right",
showCloseButton = true,
dismissOnOutsideClick,
onInteractOutside,
onPointerDownOutside,
ref,
...props
}: React.ComponentProps<typeof SheetPrimitive.Content> & {
side?: "top" | "right" | "bottom" | "left";
showCloseButton?: boolean;
/** Whether a click outside the sheet closes it. Unset, the sheet 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;
})
| 41 | } |
| 42 | |
| 43 | function SheetContent({ |
| 44 | className, |
| 45 | children, |
| 46 | side = "right", |
| 47 | showCloseButton = true, |
| 48 | dismissOnOutsideClick, |
| 49 | onInteractOutside, |
| 50 | onPointerDownOutside, |
| 51 | ref, |
| 52 | ...props |
| 53 | }: React.ComponentProps<typeof SheetPrimitive.Content> & { |
| 54 | side?: "top" | "right" | "bottom" | "left"; |
| 55 | showCloseButton?: boolean; |
| 56 | /** Whether a click outside the sheet closes it. Unset, the sheet decides |
| 57 | * from its contents: it stays open while it holds a form field — a stray |
| 58 | * click on the page behind a form must not discard what the user typed — |
| 59 | * and closes when it has nothing to lose. Pass a boolean to override the |
| 60 | * detection. Escape and the close button close either way. */ |
| 61 | dismissOnOutsideClick?: boolean; |
| 62 | }) { |
| 63 | const contentRef = React.useRef<React.ComponentRef<typeof SheetPrimitive.Content> | null>(null); |
| 64 | const composedRef = useComposedRef(ref, contentRef); |
| 65 | return ( |
| 66 | <SheetPortal> |
| 67 | <SheetOverlay /> |
| 68 | <SheetPrimitive.Content |
| 69 | data-slot="sheet-content" |
| 70 | ref={composedRef} |
| 71 | onPointerDownOutside={(event) => { |
| 72 | onPointerDownOutside?.(event); |
| 73 | applyOutsideDismissPolicy(event, dismissOnOutsideClick, contentRef.current); |
| 74 | }} |
| 75 | onInteractOutside={(event) => { |
| 76 | onInteractOutside?.(event); |
| 77 | applyOutsideDismissPolicy(event, dismissOnOutsideClick, contentRef.current); |
| 78 | }} |
| 79 | className={cn( |
| 80 | "fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500", |
| 81 | side === "right" && |
| 82 | "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm", |
| 83 | side === "left" && |
| 84 | "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm", |
| 85 | side === "top" && |
| 86 | "inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top", |
| 87 | side === "bottom" && |
| 88 | "inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom", |
| 89 | className, |
| 90 | )} |
| 91 | {...props} |
| 92 | > |
| 93 | {children} |
| 94 | {showCloseButton && ( |
| 95 | <SheetPrimitive.Close 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-secondary"> |
| 96 | <XIcon className="size-4" /> |
| 97 | <span className="sr-only">Close</span> |
| 98 | </SheetPrimitive.Close> |
| 99 | )} |
| 100 | </SheetPrimitive.Content> |
nothing calls this directly
no test coverage detected