@expofp/floorplan
Version:
Interactive floor plan library for expos and events
144 lines (142 loc) • 8.64 kB
JavaScript
function __vite_inject_css__(css, id, forceLightDom){ if (typeof document==='undefined') return; var shadow=!forceLightDom&&typeof window!=='undefined'&&window.__efpShadowDOMStyleParent; var parent=shadow||document.head; var s=document.createElement('style'); s.setAttribute('data-chunk-style', id); s.appendChild(document.createTextNode(css)); parent.appendChild(s);}
(function() {
try {
var e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {};
e.SENTRY_RELEASE = { id: "3.20.0" };
var t = new e.Error().stack;
t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "9dd6058e-e504-46fa-a82a-b47b78bbdfd9", e._sentryDebugIdIdentifier = "sentry-dbid-9dd6058e-e504-46fa-a82a-b47b78bbdfd9");
} catch {}
})();
import { n as e, r as t } from "./rolldown-runtime-7-Wh3Cc7.js";
import { s as n } from "./i18n-B6dEf7vu.js";
import { t as r } from "./react-lDheuaid.js";
import { t as i } from "./jsx-runtime-BRhWrtmW.js";
import { t as a } from "./react-dom-D8-OMRDw.js";
import { t as o } from "./classnames-DuZoMrrx.js";
import { t as s } from "./index.module-CkZa7zY4.js";
import { t as c } from "./Button-Dam5jkfA.js";
import { t as l } from "./useRenderTarget-DAy71car.js";
//#region src/ui/Modal/Modal.tsx
var u = /* @__PURE__ */ t(o(), 1), d = /* @__PURE__ */ t(r(), 1), f = /* @__PURE__ */ t(a(), 1), p = i(), m = 200, h = (e) => e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden", g = ({ open: e, className: t, variant: n = "default", title: r, ariaLabel: i, maxWidth: a, children: o, closeLabel: s, renderTarget: l, footerLeft: g = [], footerRight: _ = [], onClose: v }) => {
let y = (0, d.useRef)(null), b = (0, d.useRef)(null), x = (0, d.useId)(), [S, C] = (0, d.useState)(e), [w, T] = (0, d.useState)(e);
if ((0, d.useEffect)(() => {
if (!e) {
var t;
let e = requestAnimationFrame(() => C(!1)), n = setTimeout(() => T(!1), m);
return (t = b.current) == null || t.focus(), b.current = null, () => {
cancelAnimationFrame(e), clearTimeout(n);
};
}
b.current || (b.current = document.activeElement);
let n = document.body.style.overflow;
document.body.style.overflow = "hidden";
let r = 0, i = requestAnimationFrame(() => {
T(!0), r = requestAnimationFrame(() => C(!0));
});
return () => {
cancelAnimationFrame(i), cancelAnimationFrame(r), document.body.style.overflow = n;
};
}, [e]), (0, d.useEffect)(() => {
if (!e) return;
let t = (e) => {
if (e.key === "Escape") {
e.preventDefault(), e.stopImmediatePropagation(), v();
return;
}
if (e.key !== "Tab") return;
let t = y.current;
if (!t) return;
let n = Array.from(t.querySelectorAll("a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])")).filter(h);
if (n.length === 0) {
e.preventDefault();
return;
}
let r = n[0], i = n[n.length - 1], a = document.activeElement;
e.shiftKey ? (a === r || a === t) && (e.preventDefault(), i.focus()) : a === i && (e.preventDefault(), r.focus());
};
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
}, [e, v]), (0, d.useEffect)(() => {
if (!S) return;
let e = 0, t = requestAnimationFrame(() => {
e = requestAnimationFrame(() => {
var e;
return (e = y.current) == null ? void 0 : e.focus();
});
});
return () => {
cancelAnimationFrame(t), cancelAnimationFrame(e);
};
}, [S]), !w || !l) return null;
let E = (e) => e == null ? void 0 : e.map(({ label: e, onClick: t, variant: n = "primary", disabled: r, withBadge: i }, a) => /* @__PURE__ */ (0, p.jsx)(c, {
onClick: t,
variant: n,
size: "md",
inline: !0,
disabled: r,
withBadge: i,
children: e
}, a));
return (0, f.createPortal)(/* @__PURE__ */ (0, p.jsx)("div", {
className: (0, u.default)("efp-modal", `efp-modal--${n}`, { "efp-modal--open": S }, t),
role: "dialog",
"aria-modal": "true",
"aria-labelledby": r ? x : void 0,
"aria-label": r ? void 0 : i,
ref: y,
tabIndex: -1,
onClick: v,
children: /* @__PURE__ */ (0, p.jsxs)("div", {
className: "efp-modal__box",
style: a ? { maxWidth: `${a}px` } : void 0,
onClick: (e) => e.stopPropagation(),
children: [
/* @__PURE__ */ (0, p.jsxs)("div", {
className: "efp-modal__header",
children: [r && /* @__PURE__ */ (0, p.jsx)("div", {
className: "efp-modal__title-container",
children: /* @__PURE__ */ (0, p.jsx)("h2", {
className: "efp-modal__title",
id: x,
children: r
})
}), /* @__PURE__ */ (0, p.jsx)("button", {
type: "button",
className: "efp-modal__close",
onClick: v,
"aria-label": s,
title: s,
children: /* @__PURE__ */ (0, p.jsx)("i", {
className: "icon-close",
"aria-hidden": "true"
})
})]
}),
/* @__PURE__ */ (0, p.jsx)("div", {
className: "efp-modal__body",
children: o
}),
(g.length > 0 || _.length > 0) && /* @__PURE__ */ (0, p.jsxs)("div", {
className: "efp-modal__footer",
children: [/* @__PURE__ */ (0, p.jsx)("div", {
className: "efp-modal__footer-left",
children: g.length > 0 && E(g)
}), _.length > 0 && /* @__PURE__ */ (0, p.jsx)("div", {
className: "efp-modal__footer-right",
children: E(_)
})]
})
]
})
}), l);
}, _ = /* @__PURE__ */ e({ default: () => v }), v = s((e) => {
let t = l();
return /* @__PURE__ */ (0, p.jsx)(g, {
...e,
renderTarget: t,
closeLabel: n("Close")
});
});
//#endregion
export { _ as n, v as t };
;/* vite-per-chunk-css */
__vite_inject_css__(".efp-modal{z-index:999;width:100%;height:100%;padding:calc(1.25rem * var(--ui-scale));opacity:0;visibility:hidden;background:#a3a8afcc;justify-content:center;align-items:center;transition:opacity .2s,visibility .2s;display:flex;position:fixed;top:0;bottom:0;left:0;right:0}.efp-modal__box{width:100%;max-height:94vh;background:var(--color-white);border-radius:var(--border-radius-xl);max-height:94dvh;box-shadow:var(--shadow-md);opacity:0;flex-direction:column;transition:opacity .1s,transform .2s;display:flex;position:relative;overflow:hidden;transform:translateY(100px)}.efp-modal__header{width:100%;min-height:calc(3.75rem * var(--ui-scale));padding-inline:calc(1.5rem * var(--ui-scale)) calc(3.125rem * var(--ui-scale));border-bottom:1px solid var(--color-gray-200);flex-shrink:0;align-items:center;display:flex}.efp-modal__title-container{align-items:center;gap:calc(1.25rem * var(--ui-scale));display:flex}.efp-modal__title{align-items:center;gap:calc(.625rem * var(--ui-scale));font-size:var(--font-size-xxl);font-weight:var(--font-weight-bold);margin:0;display:flex}.efp-modal__close{top:calc(.5rem * var(--ui-scale));right:calc(.5rem * var(--ui-scale));width:calc(2.5rem * var(--ui-scale));height:calc(2.5rem * var(--ui-scale));border-radius:var(--border-radius-md);opacity:.6;color:var(--color-gray-700);cursor:pointer;background:0 0;border:0;justify-content:center;align-items:center;transition:opacity .1s,background-color .1s;display:flex;position:absolute}.efp-modal__close:hover{background-color:var(--color-gray-100);opacity:1;color:var(--color-black)}.efp-modal__body{padding:calc(1.5rem * var(--ui-scale)) calc(1.25rem * var(--ui-scale));flex:1;min-height:0;overflow:auto}.efp-modal__footer{justify-content:space-between;gap:calc(.625rem * var(--ui-scale));padding:calc(1.25rem * var(--ui-scale));border-top:1px solid var(--color-gray-200);flex-flow:wrap;flex-shrink:0;display:flex}@media (max-width:480px){.efp-modal__footer{padding:calc(.875rem * var(--ui-scale)) calc(1.25rem * var(--ui-scale));gap:calc(.875rem * var(--ui-scale))}.efp-modal__footer .efp-button{width:100%;max-width:100%}}.efp-modal__footer-left,.efp-modal__footer-right{align-items:center;gap:calc(0rem * var(--ui-scale));display:flex}.efp-modal__footer-right{flex:1;justify-content:flex-end}@media (max-width:480px){.efp-modal__footer-right{align-self:flex-end}}.efp-modal--default .efp-modal__box{max-width:900px}.efp-modal--share .efp-modal__box{max-width:420px}.efp-modal--open{opacity:1;visibility:visible}.efp-modal--open .efp-modal__box{opacity:1;transform:translateY(0)}@media (max-width:768px){.efp-modal{padding:calc(1.25rem * var(--ui-scale)) 0 0 0;align-items:flex-end}.efp-modal .efp-modal__box{border-radius:0;border-top-left-radius:var(--border-radius-xl);border-top-right-radius:var(--border-radius-xl)}}[dir=rtl] .efp-modal__close{right:unset;left:0}\n/*$vite$:1*/", "ModalContainer.css", false);