@codex-storage/marketplace-ui-components
Version:
Marketplace UI components for Codex decentralized storage network.
91 lines (90 loc) • 2.47 kB
JavaScript
import { jsxs as r, jsx as e } from "react/jsx-runtime";
import { useState as x, useEffect as h } from "react";
import { Backdrop as O } from "../Backdrop/Backdrop.js";
import { Button as u } from "../Button/Button.js";
import { classnames as S } from "../utils/classnames.js";
import { S as g } from "../../close-BypPN932.js";
import { ButtonIcon as j } from "../ButtonIcon/ButtonIcon.js";
import '../../assets/Modal.css';function P({
open: n,
onClose: t,
disableActionButton: p,
disableCloseButton: v,
className: k = "",
displayCloseButton: a = !0,
displayActionButton: l = !1,
labelActionButton: b = "Action",
labelCloseButton: w = "Close",
children: C,
title: s,
Icon: d,
onAction: m
}) {
const [c, o] = x(n);
h(() => {
o(n);
}, [n]);
const i = () => {
o(!1), setTimeout(t, 250);
};
return h(() => {
const f = (E) => {
E.key === "Escape" && (o(!1), setTimeout(t, 250));
};
return document.addEventListener("keydown", f), () => document.removeEventListener("keydown", f);
}, [o, t]), /* @__PURE__ */ r(
"div",
{
className: S(
["modal"],
["modal--internalOpen", c],
["modal--open", n],
["modal--actions", !!m],
[k]
),
children: [
/* @__PURE__ */ e(O, { open: c, onClose: i }),
/* @__PURE__ */ r("dialog", { children: [
s && /* @__PURE__ */ r("header", { children: [
/* @__PURE__ */ r("div", { children: [
d && /* @__PURE__ */ e(d, { width: 24 }),
/* @__PURE__ */ e("h6", { children: s })
] }),
/* @__PURE__ */ e(
j,
{
onClick: i,
Icon: () => /* @__PURE__ */ e(g, { width: 20 }),
variant: "small"
}
)
] }),
/* @__PURE__ */ e("main", { children: n && C }),
a || l && /* @__PURE__ */ r("footer", { children: [
a && /* @__PURE__ */ e(
u,
{
label: w,
variant: "outline",
onClick: i,
disabled: v
}
),
l && /* @__PURE__ */ e(
u,
{
label: b,
onClick: m,
disabled: p
}
)
] })
] })
]
}
);
}
export {
P as Modal
};
//# sourceMappingURL=Modal.js.map