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