import React from "react"; import { DrawerContext } from "./DrawerRoot"; import { Scrim } from "../scrim"; const NAME = "DrawerScrim"; type DrawerScrimProps = Omit< React.ComponentPropsWithRef, "open" | "zIndex" >; export const DrawerScrim = React.forwardRef( ({ children, onClick, ...props }, ref) => { const { onOpenChange, zIndex, open, defaultOpen } = React.useContext(DrawerContext); return ( { onOpenChange(false); onClick && onClick(event); }} ref={ref} zIndex={`calc(${zIndex} - 1)`} open={open || defaultOpen} {...props} > {children} ); } ); DrawerScrim.displayName = NAME; export type { DrawerScrimProps };