UNPKG

@base-ui-components/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

50 lines (48 loc) 1.47 kB
'use client'; import * as React from 'react'; import { usePreviewCardRootContext } from "../root/PreviewCardContext.js"; import { popupStateMapping as baseMapping } from "../../utils/popupStateMapping.js"; import { transitionStatusMapping } from "../../utils/stateAttributesMapping.js"; import { useRenderElement } from "../../utils/useRenderElement.js"; const stateAttributesMapping = { ...baseMapping, ...transitionStatusMapping }; /** * An overlay displayed beneath the popup. * Renders a `<div>` element. * * Documentation: [Base UI Preview Card](https://base-ui.com/react/components/preview-card) */ export const PreviewCardBackdrop = /*#__PURE__*/React.forwardRef(function PreviewCardBackdrop(componentProps, forwardedRef) { const { render, className, ...elementProps } = componentProps; const { open, mounted, transitionStatus } = usePreviewCardRootContext(); const state = React.useMemo(() => ({ open, transitionStatus }), [open, transitionStatus]); const element = useRenderElement('div', componentProps, { state, ref: [forwardedRef], props: [{ role: 'presentation', hidden: !mounted, style: { pointerEvents: 'none', userSelect: 'none', WebkitUserSelect: 'none' } }, elementProps], stateAttributesMapping }); return element; }); if (process.env.NODE_ENV !== "production") PreviewCardBackdrop.displayName = "PreviewCardBackdrop";