stone-kit
Version:
uikit for redesign
78 lines (77 loc) • 1.95 kB
JavaScript
import { jsxs as B, jsx as a } from "react/jsx-runtime";
import { useEffect as $ } from "react";
import { createPortal as N } from "react-dom";
const C = "_root_1vbbc_11", L = "_modalBody_1vbbc_25", x = "_modalOverlay_1vbbc_30", I = "_isTransparentBack_1vbbc_41", T = "_fadeInUp_1vbbc_1", s = {
root: C,
modalBody: L,
modalOverlay: x,
isTransparentBack: I,
fadeInUp: T
}, h = ({
isOpen: d,
emitIsOpen: c,
isTransparentBack: l = !1,
isClickOutside: t = !0,
leaveDisableScroll: r = !1,
createPortalObj: o,
additionalClass: i,
additionalClassOverlay: m,
additionalClassModalBody: f,
opacity: u = 0.7,
colorOverlay: e,
notDisableScroll: v = !1,
children: y,
modalBodyRef: _,
additionalStylesModalBody: b
}) => {
const p = () => {
t && c(!1);
};
$(() => {
if (!v) {
if (d) {
if (document.body.classList.contains("disable-scroll"))
return;
document.body.classList.add("disable-scroll");
} else {
if (r)
return;
document.body.classList.remove("disable-scroll");
}
return () => document.body.classList.remove("disable-scroll");
}
}, [d]);
const n = /* @__PURE__ */ B(
"div",
{
className: `${s.root} ${i}`,
onClick: (k) => k.stopPropagation(),
children: [
/* @__PURE__ */ a(
"div",
{
onClick: p,
className: `${s.modalOverlay} ${m} ${l ? s.isTransparentBack : ""}`,
style: {
opacity: l ? u : void 0,
backgroundColor: e || void 0
}
}
),
/* @__PURE__ */ a(
"div",
{
className: `${s.modalBody} ${f}`,
ref: _,
style: b,
children: y
}
)
]
}
);
return d ? o != null && o.domNode && o.domNode.isConnected ? N(n, o.domNode, o.key) : n : null;
};
export {
h as Modal
};