UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

149 lines (147 loc) • 8.76 kB
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); if (shadow) (window.__efpStyleElements||(window.__efpStyleElements=[])).push(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.39.1" }; var t = new e.Error().stack; t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "cffed87c-5fcc-41b2-a737-5f4d11a378dd", e._sentryDebugIdIdentifier = "sentry-dbid-cffed87c-5fcc-41b2-a737-5f4d11a378dd"); } catch {} })(); import { n as e, r as t } from "./rolldown-runtime-BOCG9HEF.js"; import { s as n } from "./i18n-BVE2kS7w.js"; import { t as r } from "./react-CM7l092i.js"; import { t as i } from "./jsx-runtime-BGutO_I9.js"; import { t as a } from "./react-dom-DV2t60Bu.js"; import { t as o } from "./classnames-4Iik8FC_.js"; import { t as s } from "./Button-DDJ9HcfI.js"; import { n as c, t as l } from "./useRenderTarget-Z7iVu1Bc.js"; import { t as u } from "./index.module-CVo9wrU4.js"; //#region ../ui/src/components/Modal/Modal.tsx var d = /* @__PURE__ */ t(o(), 1), f = /* @__PURE__ */ t(r(), 1), p = /* @__PURE__ */ t(a(), 1), m = i(), h = 200, g = (e) => e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden", _ = ({ open: e, className: t, variant: n = "default", title: r, ariaLabel: i, maxWidth: a, children: o, closeLabel: l, renderTarget: u, footerLeft: _ = [], footerRight: v = [], onClose: y }) => { let b = (0, f.useRef)(null), x = (0, f.useRef)(null), S = (0, f.useId)(), [C, w] = (0, f.useState)(e), [T, E] = (0, f.useState)(e); if ((0, f.useEffect)(() => { if (!e) { var t; let e = requestAnimationFrame(() => w(!1)), n = setTimeout(() => E(!1), h); return (t = x.current) == null || t.focus(), x.current = null, () => { cancelAnimationFrame(e), clearTimeout(n); }; } if (!u) return; x.current != null || (x.current = c(b.current)); let n = document.body.style.overflow; document.body.style.overflow = "hidden"; let r = 0, i = requestAnimationFrame(() => { E(!0), r = requestAnimationFrame(() => w(!0)); }); return () => { cancelAnimationFrame(i), cancelAnimationFrame(r), document.body.style.overflow = n; }; }, [e, u]), (0, f.useEffect)(() => { if (!e || !u) return; let t = (e) => { if (e.key === "Escape") { e.preventDefault(), e.stopImmediatePropagation(), y(); return; } if (e.key !== "Tab") return; let t = b.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(g); if (n.length === 0) { e.preventDefault(); return; } let r = n[0], i = n[n.length - 1], a = c(t); 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, u, y ]), (0, f.useEffect)(() => { if (!C) return; let e = 0, t = requestAnimationFrame(() => { e = requestAnimationFrame(() => { var e; return (e = b.current) == null ? void 0 : e.focus(); }); }); return () => { cancelAnimationFrame(t), cancelAnimationFrame(e); }; }, [C]), !T || !u) return null; let D = (e) => e == null ? void 0 : e.map(({ label: e, onClick: t, variant: n = "primary", disabled: r, withBadge: i }, a) => /* @__PURE__ */ (0, m.jsx)(s, { onClick: t, variant: n, size: "md", inline: !0, disabled: r, withBadge: i, children: e }, a)); return (0, p.createPortal)(/* @__PURE__ */ (0, m.jsx)("div", { className: (0, d.default)("efp-modal", `efp-modal--${n}`, { "efp-modal--open": C }, t), role: "dialog", "aria-modal": "true", "aria-labelledby": r ? S : void 0, "aria-label": r ? void 0 : i, ref: b, tabIndex: -1, onClick: y, children: /* @__PURE__ */ (0, m.jsxs)("div", { className: "efp-modal__box", style: a ? { maxWidth: `${a}px` } : void 0, onClick: (e) => e.stopPropagation(), children: [ /* @__PURE__ */ (0, m.jsxs)("div", { className: "efp-modal__header", children: [r && /* @__PURE__ */ (0, m.jsx)("div", { className: "efp-modal__title-container", children: /* @__PURE__ */ (0, m.jsx)("h2", { className: "efp-modal__title", id: S, children: r }) }), /* @__PURE__ */ (0, m.jsx)("button", { type: "button", className: "efp-modal__close", onClick: y, "aria-label": l, title: l, children: /* @__PURE__ */ (0, m.jsx)("i", { className: "icon-close", "aria-hidden": "true" }) })] }), /* @__PURE__ */ (0, m.jsx)("div", { className: "efp-modal__body", children: o }), (_.length > 0 || v.length > 0) && /* @__PURE__ */ (0, m.jsxs)("div", { className: "efp-modal__footer", children: [/* @__PURE__ */ (0, m.jsx)("div", { className: "efp-modal__footer-left", children: _.length > 0 && D(_) }), v.length > 0 && /* @__PURE__ */ (0, m.jsx)("div", { className: "efp-modal__footer-right", children: D(v) })] }) ] }) }), u); }, v = /* @__PURE__ */ e({ default: () => y }), y = u((e) => { let t = l(); return /* @__PURE__ */ (0, m.jsx)(_, { ...e, renderTarget: t, closeLabel: n("Close") }); }); //#endregion export { v as n, y 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);