UNPKG

stone-kit

Version:
74 lines (73 loc) 1.83 kB
import { jsxs as b, jsx as r } from "react/jsx-runtime"; import { useEffect as k } from "react"; import { createPortal as p } from "react-dom"; const N = "_root_1hmf2_11", h = "_modalBody_1hmf2_25", C = "_modalOverlay_1hmf2_30", L = "_isTransparentBack_1hmf2_41", s = { root: N, modalBody: h, modalOverlay: C, isTransparentBack: L }, g = ({ isOpen: e, emitIsOpen: t, isTransparentBack: d = !1, isClickOutside: n = !0, leaveDisableScroll: c = !1, createPortalObj: o, additionalClass: m, additionalClassOverlay: i, additionalClassModalBody: f, opacity: u = 0.7, colorOverlay: l, notDisableScroll: y = !1, children: _, modalBodyRef: v, additionalStylesModalBody: B }) => { const $ = () => { n && t(!1); }; k(() => { if (!y) { if (e) { if (document.body.classList.contains("disable-scroll")) return; document.body.classList.add("disable-scroll"); } else { if (c) return; document.body.classList.remove("disable-scroll"); } return () => document.body.classList.remove("disable-scroll"); } }, [e]); const a = /* @__PURE__ */ b( "div", { className: `${s.root} ${m}`, children: [ /* @__PURE__ */ r( "div", { onClick: $, className: `${s.modalOverlay} ${i} ${d ? s.isTransparentBack : ""}`, style: { opacity: d ? u : void 0, backgroundColor: l || void 0 } } ), /* @__PURE__ */ r( "div", { className: `${s.modalBody} ${f}`, ref: v, style: B, children: _ } ) ] } ); return e ? o?.domNode && o.domNode.isConnected ? p(a, o.domNode, o.key) : a : null; }; export { g as Modal };