UNPKG

@ariakit/react-core

Version:

Ariakit React core

72 lines (56 loc) 2.18 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _26P4PLHIcjs = require('./26P4PLHI.cjs'); var _YZWMAQPAcjs = require('./YZWMAQPA.cjs'); var _WT6V7PQBcjs = require('./WT6V7PQB.cjs'); var _DMTXWFDQcjs = require('./DMTXWFDQ.cjs'); var _EMYYI4CZcjs = require('./EMYYI4CZ.cjs'); var _MZ2HG624cjs = require('./MZ2HG624.cjs'); // src/dialog/dialog-backdrop.tsx var _react = require('react'); var _jsxruntime = require('react/jsx-runtime'); function DialogBackdrop({ store, backdrop, alwaysVisible, hidden }) { const ref = _react.useRef.call(void 0, null); const disclosure = _WT6V7PQBcjs.useDisclosureStore.call(void 0, { disclosure: store }); const contentElement = _EMYYI4CZcjs.useStoreState.call(void 0, store, "contentElement"); _react.useEffect.call(void 0, () => { const backdrop2 = ref.current; const dialog = contentElement; if (!backdrop2) return; if (!dialog) return; backdrop2.style.zIndex = getComputedStyle(dialog).zIndex; }, [contentElement]); _MZ2HG624cjs.useSafeLayoutEffect.call(void 0, () => { const id = contentElement == null ? void 0 : contentElement.id; if (!id) return; const backdrop2 = ref.current; if (!backdrop2) return; return _26P4PLHIcjs.markAncestor.call(void 0, backdrop2, id); }, [contentElement]); const props = _YZWMAQPAcjs.useDisclosureContent.call(void 0, { ref, store: disclosure, role: "presentation", "data-backdrop": (contentElement == null ? void 0 : contentElement.id) || "", alwaysVisible, hidden: hidden != null ? hidden : void 0, style: { position: "fixed", top: 0, right: 0, bottom: 0, left: 0 } }); if (!backdrop) return null; if (_react.isValidElement.call(void 0, backdrop)) { return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _DMTXWFDQcjs.Role, { ...props, render: backdrop }); } const Component = typeof backdrop !== "boolean" ? backdrop : "div"; return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _DMTXWFDQcjs.Role, { ...props, render: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, {}) }); } exports.DialogBackdrop = DialogBackdrop;