boottent-design 0.1.211 → 0.1.213
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks.cjs.js +1 -1
- package/dist/hooks.es.js +27 -16
- package/dist/portal-manager-CyWNKHmr.cjs +1 -0
- package/dist/portal-manager-fk0biCEh.js +142 -0
- package/dist/provider.cjs.js +1 -1
- package/dist/provider.es.js +53 -51
- package/dist/types/hooks.d.ts +1 -0
- package/dist/types/utils.d.ts +2 -1
- package/dist/utils.cjs.js +1 -1
- package/dist/utils.es.js +1 -1
- package/package.json +1 -1
- package/dist/portal-manager-BDctJ_Mt.js +0 -138
- package/dist/portal-manager-BGE-3NOa.cjs +0 -1
package/dist/hooks.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./use-metadata-CZiZDN9j.cjs");require("react/jsx-runtime");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./use-metadata-CZiZDN9j.cjs");require("react/jsx-runtime");const a=require("react"),o=require("./portal-manager-CyWNKHmr.cjs");require("./preview-9QZ5P9LT.cjs");require("./index-Cv4pTXfv.cjs");const s=require("./use-toastmodal-B1QxDevT.cjs"),q=()=>{const[u,r]=a.useState([]);a.useEffect(()=>{const e=(c,k)=>{r(n=>k?[...new Set([...n,c.id])]:n.filter(f=>f!==c.id))},l=o.portalManager.subscribe(e);return r(o.portalManager.getOpenPortals()),()=>l()},[]);const t=a.useCallback((e,l)=>o.portalManager.openPortal(e,{...l,onClose:l.onClose??(()=>{})}),[]),d=a.useCallback(e=>t("modal",e),[t]),i=a.useCallback(e=>typeof e=="string"?t("alert",{description:e}):t("alert",e),[t]),g=a.useCallback(e=>t("dialog",e),[t]),M=a.useCallback(e=>t("custom",e),[t]),b=a.useCallback(e=>o.portalManager.getIsPortalOpen(e),[]),P=a.useCallback(e=>o.portalManager.closePortal(e),[]),C=a.useCallback(e=>o.portalManager.forceClosePortal(e),[]),p=a.useCallback(()=>o.portalManager.closeAllPortals(),[]);return{open:t,confirm:d,alert:i,dialog:g,custom:M,getIsOpen:b,closePortal:P,forceClosePortal:C,closeAllPortals:p,openPortals:u}};exports.useMetadata=m.useMetadata;exports.modalReducer=s.modalReducer;exports.toast=s.toast;exports.toastModal=s.toastModal;exports.toastReducer=s.toastReducer;exports.useToast=s.useToast;exports.useToastModal=s.useToastModal;exports.usePortal=q;
|
package/dist/hooks.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { u as
|
|
1
|
+
import { u as y } from "./use-metadata-BrY8rtWx.js";
|
|
2
2
|
import "react/jsx-runtime";
|
|
3
3
|
import { useState as M, useEffect as O, useCallback as s } from "react";
|
|
4
|
-
import { p as e } from "./portal-manager-
|
|
4
|
+
import { p as e } from "./portal-manager-fk0biCEh.js";
|
|
5
5
|
import "./preview-Cocn_vDi.js";
|
|
6
6
|
import "./index-DT339AZp.js";
|
|
7
|
-
import { m as
|
|
8
|
-
const
|
|
7
|
+
import { m as h, a as j, b as q, t as z, u as B, c as D } from "./use-toastmodal-BpqFNqCw.js";
|
|
8
|
+
const T = () => {
|
|
9
9
|
const [c, r] = M([]);
|
|
10
10
|
O(() => {
|
|
11
|
-
const t = (l,
|
|
12
|
-
r((n) =>
|
|
11
|
+
const t = (l, b) => {
|
|
12
|
+
r((n) => b ? [.../* @__PURE__ */ new Set([...n, l.id])] : n.filter((C) => C !== l.id));
|
|
13
13
|
}, a = e.subscribe(t);
|
|
14
14
|
return r(e.getOpenPortals()), () => a();
|
|
15
15
|
}, []);
|
|
@@ -23,16 +23,27 @@ const S = () => {
|
|
|
23
23
|
), u = s((t) => o("modal", t), [o]), i = s(
|
|
24
24
|
(t) => typeof t == "string" ? o("alert", { description: t }) : o("alert", t),
|
|
25
25
|
[o]
|
|
26
|
-
), m = s((t) => o("dialog", t), [o]), d = s((t) => o("custom", t), [o]),
|
|
27
|
-
return {
|
|
26
|
+
), m = s((t) => o("dialog", t), [o]), d = s((t) => o("custom", t), [o]), P = s((t) => e.getIsPortalOpen(t), []), f = s((t) => e.closePortal(t), []), p = s((t) => e.forceClosePortal(t), []), g = s(() => e.closeAllPortals(), []);
|
|
27
|
+
return {
|
|
28
|
+
open: o,
|
|
29
|
+
confirm: u,
|
|
30
|
+
alert: i,
|
|
31
|
+
dialog: m,
|
|
32
|
+
custom: d,
|
|
33
|
+
getIsOpen: P,
|
|
34
|
+
closePortal: f,
|
|
35
|
+
forceClosePortal: p,
|
|
36
|
+
closeAllPortals: g,
|
|
37
|
+
openPortals: c
|
|
38
|
+
};
|
|
28
39
|
};
|
|
29
40
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
h as modalReducer,
|
|
42
|
+
j as toast,
|
|
43
|
+
q as toastModal,
|
|
44
|
+
z as toastReducer,
|
|
45
|
+
y as useMetadata,
|
|
46
|
+
T as usePortal,
|
|
47
|
+
B as useToast,
|
|
48
|
+
D as useToastModal
|
|
38
49
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var d=Object.defineProperty;var h=(s,t,e)=>t in s?d(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var a=(s,t,e)=>h(s,typeof t!="symbol"?t+"":t,e);let l;const f=new Uint8Array(16);function g(){if(!l&&(l=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!l))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return l(f)}const r=[];for(let s=0;s<256;++s)r.push((s+256).toString(16).slice(1));function w(s,t=0){return r[s[t+0]]+r[s[t+1]]+r[s[t+2]]+r[s[t+3]]+"-"+r[s[t+4]]+r[s[t+5]]+"-"+r[s[t+6]]+r[s[t+7]]+"-"+r[s[t+8]]+r[s[t+9]]+"-"+r[s[t+10]]+r[s[t+11]]+r[s[t+12]]+r[s[t+13]]+r[s[t+14]]+r[s[t+15]]}const y=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),p={randomUUID:y};function P(s,t,e){if(p.randomUUID&&!s)return p.randomUUID();s=s||{};const n=s.random||(s.rng||g)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,w(n)}class m{constructor(){a(this,"listeners",new Set);a(this,"portals",new Map);a(this,"queue",[]);a(this,"isProcessing",!1);a(this,"pendingEvents",[]);a(this,"broadcastScheduled",!1)}schedule(t){typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(()=>t()):setTimeout(t,0)}processQueue(){if(this.isProcessing||this.queue.length===0)return;this.isProcessing=!0;const t=()=>{const e=this.queue.shift();if(!e){this.isProcessing=!1;return}try{e()}finally{this.schedule(t)}};t()}scheduleBroadcast(t){this.pendingEvents.push(t),!this.broadcastScheduled&&(this.broadcastScheduled=!0,this.queue.push(()=>{const e=this.pendingEvents.slice();this.pendingEvents=[],this.broadcastScheduled=!1;for(const n of e)this.listeners.forEach(o=>{try{o(n.options,n.isOpen)}catch(i){process.env.NODE_ENV!=="production"&&console.error("[PortalManager] listener error:",i)}})}),this.processQueue())}isPortalOpen(t){var e;return((e=this.portals.get(t))==null?void 0:e.isOpen)??!1}isDuplicateAllowed(t){return t==="toast"}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}openPortal(t,e){const n=e.id??this.generateId(t);if(!this.isDuplicateAllowed(t)&&this.isPortalOpen(n))return n;const i={...{id:n,type:t,props:{...e,id:n}},isOpen:!0};return this.portals.set(n,i),this.scheduleBroadcast({options:i,isOpen:!0}),n}setPortalOpen(t,e,n="default"){var i,u;const o=this.portals.get(t);if(o&&!(!e&&o.props.forceMount&&n!=="force")&&o.isOpen!==e){if(!e){const c=o._openedAt;if(c&&Date.now()-c<300)return}o.isOpen=e,e&&(o._openedAt=Date.now()),this.portals.set(t,o),this.scheduleBroadcast({options:o,isOpen:e}),e||(u=(i=o.props).onClose)==null||u.call(i)}}updatePortal(t,e,n){const o=this.portals.get(t);if(!o||o.type!==e)return;const i={...o,props:{...o.props,...n}};this.portals.set(t,i),this.scheduleBroadcast({options:i,isOpen:!0})}closePortal(t){this.setPortalOpen(t,!1)}forceClosePortal(t){const e=this.portals.get(t);e&&(e.props._forceClose=!0,this.setPortalOpen(t,!1,"force"),delete e.props._forceClose)}closeAllPortals(){this.getOpenPortals().forEach(t=>this.closePortal(t))}getIsPortalOpen(t){var e;return((e=this.portals.get(t))==null?void 0:e.isOpen)??!1}getOpenPortals(){const t=[];for(const[e,n]of this.portals.entries())n.isOpen&&t.push(e);return t}generateId(t){const e=typeof window<"u"&&window.location?window.location.pathname:"ssr",n=`${t}_${e}`;return this.isDuplicateAllowed(t)?`${n}_${P()}`:n}}const b=new m;exports.portalManager=b;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var h = (s, e, t) => e in s ? d(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var a = (s, e, t) => h(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
let l;
|
|
5
|
+
const f = new Uint8Array(16);
|
|
6
|
+
function g() {
|
|
7
|
+
if (!l && (l = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !l))
|
|
8
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
9
|
+
return l(f);
|
|
10
|
+
}
|
|
11
|
+
const r = [];
|
|
12
|
+
for (let s = 0; s < 256; ++s)
|
|
13
|
+
r.push((s + 256).toString(16).slice(1));
|
|
14
|
+
function w(s, e = 0) {
|
|
15
|
+
return r[s[e + 0]] + r[s[e + 1]] + r[s[e + 2]] + r[s[e + 3]] + "-" + r[s[e + 4]] + r[s[e + 5]] + "-" + r[s[e + 6]] + r[s[e + 7]] + "-" + r[s[e + 8]] + r[s[e + 9]] + "-" + r[s[e + 10]] + r[s[e + 11]] + r[s[e + 12]] + r[s[e + 13]] + r[s[e + 14]] + r[s[e + 15]];
|
|
16
|
+
}
|
|
17
|
+
const y = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), p = {
|
|
18
|
+
randomUUID: y
|
|
19
|
+
};
|
|
20
|
+
function P(s, e, t) {
|
|
21
|
+
if (p.randomUUID && !s)
|
|
22
|
+
return p.randomUUID();
|
|
23
|
+
s = s || {};
|
|
24
|
+
const n = s.random || (s.rng || g)();
|
|
25
|
+
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, w(n);
|
|
26
|
+
}
|
|
27
|
+
class m {
|
|
28
|
+
constructor() {
|
|
29
|
+
a(this, "listeners", /* @__PURE__ */ new Set());
|
|
30
|
+
a(this, "portals", /* @__PURE__ */ new Map());
|
|
31
|
+
a(this, "queue", []);
|
|
32
|
+
a(this, "isProcessing", !1);
|
|
33
|
+
a(this, "pendingEvents", []);
|
|
34
|
+
a(this, "broadcastScheduled", !1);
|
|
35
|
+
}
|
|
36
|
+
schedule(e) {
|
|
37
|
+
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(() => e()) : setTimeout(e, 0);
|
|
38
|
+
}
|
|
39
|
+
processQueue() {
|
|
40
|
+
if (this.isProcessing || this.queue.length === 0) return;
|
|
41
|
+
this.isProcessing = !0;
|
|
42
|
+
const e = () => {
|
|
43
|
+
const t = this.queue.shift();
|
|
44
|
+
if (!t) {
|
|
45
|
+
this.isProcessing = !1;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
t();
|
|
50
|
+
} finally {
|
|
51
|
+
this.schedule(e);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
e();
|
|
55
|
+
}
|
|
56
|
+
scheduleBroadcast(e) {
|
|
57
|
+
this.pendingEvents.push(e), !this.broadcastScheduled && (this.broadcastScheduled = !0, this.queue.push(() => {
|
|
58
|
+
const t = this.pendingEvents.slice();
|
|
59
|
+
this.pendingEvents = [], this.broadcastScheduled = !1;
|
|
60
|
+
for (const n of t)
|
|
61
|
+
this.listeners.forEach((o) => {
|
|
62
|
+
try {
|
|
63
|
+
o(n.options, n.isOpen);
|
|
64
|
+
} catch (i) {
|
|
65
|
+
process.env.NODE_ENV !== "production" && console.error("[PortalManager] listener error:", i);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}), this.processQueue());
|
|
69
|
+
}
|
|
70
|
+
isPortalOpen(e) {
|
|
71
|
+
var t;
|
|
72
|
+
return ((t = this.portals.get(e)) == null ? void 0 : t.isOpen) ?? !1;
|
|
73
|
+
}
|
|
74
|
+
isDuplicateAllowed(e) {
|
|
75
|
+
return e === "toast";
|
|
76
|
+
}
|
|
77
|
+
subscribe(e) {
|
|
78
|
+
return this.listeners.add(e), () => {
|
|
79
|
+
this.listeners.delete(e);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
openPortal(e, t) {
|
|
83
|
+
const n = t.id ?? this.generateId(e);
|
|
84
|
+
if (!this.isDuplicateAllowed(e) && this.isPortalOpen(n))
|
|
85
|
+
return n;
|
|
86
|
+
const i = { ...{
|
|
87
|
+
id: n,
|
|
88
|
+
type: e,
|
|
89
|
+
props: { ...t, id: n }
|
|
90
|
+
}, isOpen: !0 };
|
|
91
|
+
return this.portals.set(n, i), this.scheduleBroadcast({ options: i, isOpen: !0 }), n;
|
|
92
|
+
}
|
|
93
|
+
setPortalOpen(e, t, n = "default") {
|
|
94
|
+
var i, u;
|
|
95
|
+
const o = this.portals.get(e);
|
|
96
|
+
if (o && !(!t && o.props.forceMount && n !== "force") && o.isOpen !== t) {
|
|
97
|
+
if (!t) {
|
|
98
|
+
const c = o._openedAt;
|
|
99
|
+
if (c && Date.now() - c < 300)
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
o.isOpen = t, t && (o._openedAt = Date.now()), this.portals.set(e, o), this.scheduleBroadcast({ options: o, isOpen: t }), t || (u = (i = o.props).onClose) == null || u.call(i);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
updatePortal(e, t, n) {
|
|
106
|
+
const o = this.portals.get(e);
|
|
107
|
+
if (!o || o.type !== t) return;
|
|
108
|
+
const i = {
|
|
109
|
+
...o,
|
|
110
|
+
props: { ...o.props, ...n }
|
|
111
|
+
};
|
|
112
|
+
this.portals.set(e, i), this.scheduleBroadcast({ options: i, isOpen: !0 });
|
|
113
|
+
}
|
|
114
|
+
closePortal(e) {
|
|
115
|
+
this.setPortalOpen(e, !1);
|
|
116
|
+
}
|
|
117
|
+
forceClosePortal(e) {
|
|
118
|
+
const t = this.portals.get(e);
|
|
119
|
+
t && (t.props._forceClose = !0, this.setPortalOpen(e, !1, "force"), delete t.props._forceClose);
|
|
120
|
+
}
|
|
121
|
+
closeAllPortals() {
|
|
122
|
+
this.getOpenPortals().forEach((e) => this.closePortal(e));
|
|
123
|
+
}
|
|
124
|
+
getIsPortalOpen(e) {
|
|
125
|
+
var t;
|
|
126
|
+
return ((t = this.portals.get(e)) == null ? void 0 : t.isOpen) ?? !1;
|
|
127
|
+
}
|
|
128
|
+
getOpenPortals() {
|
|
129
|
+
const e = [];
|
|
130
|
+
for (const [t, n] of this.portals.entries())
|
|
131
|
+
n.isOpen && e.push(t);
|
|
132
|
+
return e;
|
|
133
|
+
}
|
|
134
|
+
generateId(e) {
|
|
135
|
+
const t = typeof window < "u" && window.location ? window.location.pathname : "ssr", n = `${e}_${t}`;
|
|
136
|
+
return this.isDuplicateAllowed(e) ? `${n}_${P()}` : n;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const O = new m();
|
|
140
|
+
export {
|
|
141
|
+
O as p
|
|
142
|
+
};
|
package/dist/provider.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),h=require("./use-toastmodal-B1QxDevT.cjs"),d=require("./index-C1T36J_d.cjs"),P=require("./preview-9QZ5P9LT.cjs"),T=require("./toast-form-BjkW_vXG.cjs"),f=require("react"),g=require("./portal-manager-CyWNKHmr.cjs");require("./index-z9hRvvSX.cjs");require("./index-Cv4pTXfv.cjs");const w=require("react-dom");function C(){const{modals:e,dismiss:n}=h.useToastModal(),a=e.some(o=>o.open);return s.jsxs(d.ToastModalProvider,{children:[e.map(function({id:o,title:x,description:j,content:t,onConfirm:r,confirmText:m="확인",onCancel:c,cancelText:u="취소",size:i,contents:l,variant:M,width:O,closeType:p,...E}){return s.jsxs(d.ToastModal,{width:O,...E,className:"flex flex-col gap-4",children:[s.jsx(d.ToastModalTitle,{children:x}),s.jsxs("div",{className:"flex flex-col gap-2",children:[j&&s.jsx(d.ToastModalDescription,{className:"text-sm text-foreground",children:j}),t&&s.jsx(d.ToastModalDescription,{children:t})]}),l&&s.jsx(d.ToastModalContents,{children:l}),s.jsxs("div",{className:P.cn("flex items-center justify-between gap-2",p&&"justify-end"),children:[!p&&s.jsx(d.ToastModalClose,{className:"w-1/2",size:i,variant:"outline",children:u}),s.jsx(d.ToastModalAction,{className:p?"":"w-1/2",altText:"confirm",size:i,variant:M,onClick:r,children:m})]})]},o)}),s.jsx(d.ToastModalViewport,{isOpen:a?"open":"close",onClick:()=>e.forEach(o=>!o.closeType&&n(o.id))})]})}const q={modal:(e,n)=>s.jsx(T.ModalForm,{...e.props,onClose:n},e.id),alert:(e,n)=>s.jsx(T.AlertForm,{...e.props,onClose:n},e.id),dialog:(e,n)=>s.jsx(T.DialogForm,{...e.props,onClose:n},e.id),custom:(e,n)=>s.jsx(T.FreeForm,{...e.props,onClose:n},e.id)},D=()=>{const[e,n]=f.useState([]),a=f.useRef(new Map),o=300,x=f.useRef(new Map);f.useEffect(()=>{const t=g.portalManager.subscribe((r,m)=>{n(c=>{const u=c.findIndex(i=>i.id===r.id);if(m)if(u===-1){const i=[...c,{...r,isOpen:!0}];x.current.set(r.id,Date.now());const l=a.current.get(r.id);return l&&(clearTimeout(l),a.current.delete(r.id)),i}else{const i=c.slice();i[u]={...i[u],...r,isOpen:!0},x.current.set(r.id,Date.now());const l=a.current.get(r.id);return l&&(clearTimeout(l),a.current.delete(r.id)),i}else{if(u===-1)return c;const i=r.props._forceClose===!0;if(c[u].props.forceMount&&!i)return c;const l=x.current.get(r.id);if(l&&Date.now()-l<o)return c;const M=c.slice();return M[u]={...M[u],isOpen:!1},M}})});return()=>t()},[]);const j=f.useCallback(t=>{const r=e.find(m=>m.id===t);r&&r.props.forceMount||g.portalManager.setPortalOpen(t,!1)},[e]);return f.useEffect(()=>(e.forEach(t=>{if(!t.isOpen&&!a.current.has(t.id)){const r=setTimeout(()=>{n(m=>m.filter(c=>c.id!==t.id)),a.current.delete(t.id)},300);a.current.set(t.id,r)}}),()=>{a.current.forEach(t=>clearTimeout(t)),a.current.clear()}),[e]),s.jsx(b,{children:e.map(t=>{if(!t.isOpen||t.type==="toast")return null;const r=q[t.type];return r(t,()=>j(t.id))})})},b=({children:e})=>{const[n,a]=f.useState(null);return f.useEffect(()=>{if(typeof document>"u")return;let o=document.getElementById("portal");o||(o=document.createElement("div"),o.id="portal",document.body.appendChild(o)),a(o)},[]),n?w.createPortal(e,n):null};function y(){const{toasts:e}=h.useToast();return s.jsxs(d.ToastProvider,{children:[e.map(n=>s.jsx(T.ToastForm,{...n},n.id)),s.jsx(d.ToastViewport,{})]})}exports.ModalManager=C;exports.PortalProvider=D;exports.ToastManager=y;
|
package/dist/provider.es.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { c as
|
|
3
|
-
import { T as
|
|
1
|
+
import { jsxs as p, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { c as E, u as P } from "./use-toastmodal-BpqFNqCw.js";
|
|
3
|
+
import { T as F, a as b, b as N, c as g, d as y, e as A, f as _, g as R, h as j, i as k } from "./index-DuUh97OP.js";
|
|
4
4
|
import { c as v } from "./preview-Cocn_vDi.js";
|
|
5
5
|
import { F as S, D as I, A as U, M as V, T as B } from "./toast-form-B3hEA_lp.js";
|
|
6
|
-
import { useState as
|
|
7
|
-
import { p as
|
|
6
|
+
import { useState as C, useRef as x, useEffect as h, useCallback as G } from "react";
|
|
7
|
+
import { p as O } from "./portal-manager-fk0biCEh.js";
|
|
8
8
|
import "./index-CEwEyzHV.js";
|
|
9
9
|
import "./index-DT339AZp.js";
|
|
10
10
|
import J from "react-dom";
|
|
11
11
|
function te() {
|
|
12
|
-
const { modals: e, dismiss: n } =
|
|
13
|
-
return /* @__PURE__ */
|
|
12
|
+
const { modals: e, dismiss: n } = E(), a = e.some((s) => s.open);
|
|
13
|
+
return /* @__PURE__ */ p(F, { children: [
|
|
14
14
|
e.map(function({
|
|
15
15
|
id: s,
|
|
16
16
|
title: f,
|
|
17
|
-
description:
|
|
17
|
+
description: T,
|
|
18
18
|
content: t,
|
|
19
19
|
onConfirm: r,
|
|
20
20
|
confirmText: u = "확인",
|
|
21
|
-
onCancel:
|
|
21
|
+
onCancel: c,
|
|
22
22
|
cancelText: d = "취소",
|
|
23
23
|
size: i,
|
|
24
|
-
contents:
|
|
25
|
-
variant:
|
|
26
|
-
width:
|
|
27
|
-
closeType:
|
|
28
|
-
...
|
|
24
|
+
contents: l,
|
|
25
|
+
variant: m,
|
|
26
|
+
width: w,
|
|
27
|
+
closeType: M,
|
|
28
|
+
...D
|
|
29
29
|
}) {
|
|
30
|
-
return /* @__PURE__ */
|
|
30
|
+
return /* @__PURE__ */ p(b, { width: w, ...D, className: "flex flex-col gap-4", children: [
|
|
31
31
|
/* @__PURE__ */ o(N, { children: f }),
|
|
32
|
-
/* @__PURE__ */
|
|
33
|
-
|
|
34
|
-
t && /* @__PURE__ */ o(
|
|
32
|
+
/* @__PURE__ */ p("div", { className: "flex flex-col gap-2", children: [
|
|
33
|
+
T && /* @__PURE__ */ o(g, { className: "text-sm text-foreground", children: T }),
|
|
34
|
+
t && /* @__PURE__ */ o(g, { children: t })
|
|
35
35
|
] }),
|
|
36
|
-
|
|
37
|
-
/* @__PURE__ */
|
|
38
|
-
!
|
|
36
|
+
l && /* @__PURE__ */ o(y, { children: l }),
|
|
37
|
+
/* @__PURE__ */ p("div", { className: v("flex items-center justify-between gap-2", M && "justify-end"), children: [
|
|
38
|
+
!M && /* @__PURE__ */ o(A, { className: "w-1/2", size: i, variant: "outline", children: d }),
|
|
39
39
|
/* @__PURE__ */ o(
|
|
40
|
-
|
|
40
|
+
_,
|
|
41
41
|
{
|
|
42
|
-
className:
|
|
42
|
+
className: M ? "" : "w-1/2",
|
|
43
43
|
altText: "confirm",
|
|
44
44
|
size: i,
|
|
45
|
-
variant:
|
|
45
|
+
variant: m,
|
|
46
46
|
onClick: r,
|
|
47
47
|
children: u
|
|
48
48
|
}
|
|
@@ -51,7 +51,7 @@ function te() {
|
|
|
51
51
|
] }, s);
|
|
52
52
|
}),
|
|
53
53
|
/* @__PURE__ */ o(
|
|
54
|
-
|
|
54
|
+
R,
|
|
55
55
|
{
|
|
56
56
|
isOpen: a ? "open" : "close",
|
|
57
57
|
onClick: () => e.forEach((s) => !s.closeType && n(s.id))
|
|
@@ -65,47 +65,49 @@ const q = {
|
|
|
65
65
|
dialog: (e, n) => /* @__PURE__ */ o(I, { ...e.props, onClose: n }, e.id),
|
|
66
66
|
custom: (e, n) => /* @__PURE__ */ o(S, { ...e.props, onClose: n }, e.id)
|
|
67
67
|
}, re = () => {
|
|
68
|
-
const [e, n] =
|
|
69
|
-
|
|
70
|
-
const t =
|
|
71
|
-
n((
|
|
72
|
-
const d =
|
|
68
|
+
const [e, n] = C([]), a = x(/* @__PURE__ */ new Map()), s = 300, f = x(/* @__PURE__ */ new Map());
|
|
69
|
+
h(() => {
|
|
70
|
+
const t = O.subscribe((r, u) => {
|
|
71
|
+
n((c) => {
|
|
72
|
+
const d = c.findIndex((i) => i.id === r.id);
|
|
73
73
|
if (u)
|
|
74
74
|
if (d === -1) {
|
|
75
|
-
const i = [...
|
|
75
|
+
const i = [...c, { ...r, isOpen: !0 }];
|
|
76
76
|
f.current.set(r.id, Date.now());
|
|
77
|
-
const
|
|
78
|
-
return
|
|
77
|
+
const l = a.current.get(r.id);
|
|
78
|
+
return l && (clearTimeout(l), a.current.delete(r.id)), i;
|
|
79
79
|
} else {
|
|
80
|
-
const i =
|
|
80
|
+
const i = c.slice();
|
|
81
81
|
i[d] = { ...i[d], ...r, isOpen: !0 }, f.current.set(r.id, Date.now());
|
|
82
|
-
const
|
|
83
|
-
return
|
|
82
|
+
const l = a.current.get(r.id);
|
|
83
|
+
return l && (clearTimeout(l), a.current.delete(r.id)), i;
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
|
-
if (d === -1
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
if (d === -1) return c;
|
|
87
|
+
const i = r.props._forceClose === !0;
|
|
88
|
+
if (c[d].props.forceMount && !i)
|
|
89
|
+
return c;
|
|
90
|
+
const l = f.current.get(r.id);
|
|
91
|
+
if (l && Date.now() - l < s)
|
|
92
|
+
return c;
|
|
93
|
+
const m = c.slice();
|
|
94
|
+
return m[d] = { ...m[d], isOpen: !1 }, m;
|
|
93
95
|
}
|
|
94
96
|
});
|
|
95
97
|
});
|
|
96
98
|
return () => t();
|
|
97
99
|
}, []);
|
|
98
|
-
const
|
|
100
|
+
const T = G(
|
|
99
101
|
(t) => {
|
|
100
102
|
const r = e.find((u) => u.id === t);
|
|
101
|
-
r && r.props.forceMount ||
|
|
103
|
+
r && r.props.forceMount || O.setPortalOpen(t, !1);
|
|
102
104
|
},
|
|
103
105
|
[e]
|
|
104
106
|
);
|
|
105
|
-
return
|
|
107
|
+
return h(() => (e.forEach((t) => {
|
|
106
108
|
if (!t.isOpen && !a.current.has(t.id)) {
|
|
107
109
|
const r = setTimeout(() => {
|
|
108
|
-
n((u) => u.filter((
|
|
110
|
+
n((u) => u.filter((c) => c.id !== t.id)), a.current.delete(t.id);
|
|
109
111
|
}, 300);
|
|
110
112
|
a.current.set(t.id, r);
|
|
111
113
|
}
|
|
@@ -114,11 +116,11 @@ const q = {
|
|
|
114
116
|
}), [e]), /* @__PURE__ */ o(H, { children: e.map((t) => {
|
|
115
117
|
if (!t.isOpen || t.type === "toast") return null;
|
|
116
118
|
const r = q[t.type];
|
|
117
|
-
return r(t, () =>
|
|
119
|
+
return r(t, () => T(t.id));
|
|
118
120
|
}) });
|
|
119
121
|
}, H = ({ children: e }) => {
|
|
120
|
-
const [n, a] =
|
|
121
|
-
return
|
|
122
|
+
const [n, a] = C(null);
|
|
123
|
+
return h(() => {
|
|
122
124
|
if (typeof document > "u") return;
|
|
123
125
|
let s = document.getElementById("portal");
|
|
124
126
|
s || (s = document.createElement("div"), s.id = "portal", document.body.appendChild(s)), a(s);
|
|
@@ -126,7 +128,7 @@ const q = {
|
|
|
126
128
|
};
|
|
127
129
|
function ne() {
|
|
128
130
|
const { toasts: e } = P();
|
|
129
|
-
return /* @__PURE__ */
|
|
131
|
+
return /* @__PURE__ */ p(j, { children: [
|
|
130
132
|
e.map((n) => /* @__PURE__ */ o(B, { ...n }, n.id)),
|
|
131
133
|
/* @__PURE__ */ o(k, {})
|
|
132
134
|
] });
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -219,6 +219,7 @@ export declare const usePortal: () => {
|
|
|
219
219
|
custom: (props: FreeFormProps) => string;
|
|
220
220
|
getIsOpen: (id: string) => boolean;
|
|
221
221
|
closePortal: (id: string) => void;
|
|
222
|
+
forceClosePortal: (id: string) => void;
|
|
222
223
|
closeAllPortals: () => void;
|
|
223
224
|
openPortals: string[];
|
|
224
225
|
};
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -227,9 +227,10 @@ declare class PortalManager {
|
|
|
227
227
|
openPortal<T extends PortalType>(type: T, props: PortalTypeMap[T] & {
|
|
228
228
|
id?: string;
|
|
229
229
|
}): string;
|
|
230
|
-
setPortalOpen(id: string, isOpen: boolean): void;
|
|
230
|
+
setPortalOpen(id: string, isOpen: boolean, trigger?: "force" | "default"): void;
|
|
231
231
|
updatePortal<T extends PortalType>(id: string, type: T, patch: Partial<PortalTypeMap[T]>): void;
|
|
232
232
|
closePortal(id: string): void;
|
|
233
|
+
forceClosePortal(id: string): void;
|
|
233
234
|
closeAllPortals(): void;
|
|
234
235
|
getIsPortalOpen(id: string): boolean;
|
|
235
236
|
getOpenPortals(): string[];
|
package/dist/utils.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./notion-Sqp-Xzqi.cjs"),t=require("./preview-9QZ5P9LT.cjs"),r=require("./portal-manager-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./notion-Sqp-Xzqi.cjs"),t=require("./preview-9QZ5P9LT.cjs"),r=require("./portal-manager-CyWNKHmr.cjs");exports.buildBlockTree=e.buildBlockTree;exports.getCampDateText=e.getCampDateText;exports.getCampDdayText=e.getCampDdayText;exports.getDropdownButtonText=e.getDropdownButtonText;exports.getEventCampCostValue=e.getEventCampCostValue;exports.getPriority=e.getPriority;exports.getWrapperComponent=e.getWrapperComponent;exports.getYoutubeEmbedUrl=e.getYoutubeEmbedUrl;exports.groupBlocks=e.groupBlocks;exports.isListOrInsideList=e.isListOrInsideList;exports.isPriorityHeading=e.isPriorityHeading;exports.listTypes=e.listTypes;exports.addUTMtoUrl=t.addUTMtoUrl;exports.cn=t.cn;exports.convertBorderColorToHex=t.convertBorderColorToHex;exports.createHexToTokenMap=t.createHexToTokenMap;exports.getDaysDifference=t.getDaysDifference;exports.hexToTokenMap=t.hexToTokenMap;exports.parseDateString=t.parseDateString;exports.parseInlineStyle=t.parseInlineStyle;exports.rgbToHex=t.rgbToHex;exports.portalManager=r.portalManager;
|
package/dist/utils.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as s, g as t, a as r, c as o, b as p, e as i, f as n, k as g, j as l, h as T, i as d, l as x } from "./notion-CfqLwM8d.js";
|
|
2
2
|
import { a as m, c as b, d as f, e as u, g as y, h as C, b as D, p as k, r as B } from "./preview-Cocn_vDi.js";
|
|
3
|
-
import { p as M } from "./portal-manager-
|
|
3
|
+
import { p as M } from "./portal-manager-fk0biCEh.js";
|
|
4
4
|
export {
|
|
5
5
|
m as addUTMtoUrl,
|
|
6
6
|
s as buildBlockTree,
|
package/package.json
CHANGED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
var d = Object.defineProperty;
|
|
2
|
-
var p = (e, t, s) => t in e ? d(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
-
var a = (e, t, s) => p(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
-
let u;
|
|
5
|
-
const h = new Uint8Array(16);
|
|
6
|
-
function g() {
|
|
7
|
-
if (!u && (u = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !u))
|
|
8
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
9
|
-
return u(h);
|
|
10
|
-
}
|
|
11
|
-
const o = [];
|
|
12
|
-
for (let e = 0; e < 256; ++e)
|
|
13
|
-
o.push((e + 256).toString(16).slice(1));
|
|
14
|
-
function f(e, t = 0) {
|
|
15
|
-
return o[e[t + 0]] + o[e[t + 1]] + o[e[t + 2]] + o[e[t + 3]] + "-" + o[e[t + 4]] + o[e[t + 5]] + "-" + o[e[t + 6]] + o[e[t + 7]] + "-" + o[e[t + 8]] + o[e[t + 9]] + "-" + o[e[t + 10]] + o[e[t + 11]] + o[e[t + 12]] + o[e[t + 13]] + o[e[t + 14]] + o[e[t + 15]];
|
|
16
|
-
}
|
|
17
|
-
const w = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), c = {
|
|
18
|
-
randomUUID: w
|
|
19
|
-
};
|
|
20
|
-
function y(e, t, s) {
|
|
21
|
-
if (c.randomUUID && !e)
|
|
22
|
-
return c.randomUUID();
|
|
23
|
-
e = e || {};
|
|
24
|
-
const n = e.random || (e.rng || g)();
|
|
25
|
-
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, f(n);
|
|
26
|
-
}
|
|
27
|
-
class m {
|
|
28
|
-
constructor() {
|
|
29
|
-
a(this, "listeners", /* @__PURE__ */ new Set());
|
|
30
|
-
a(this, "portals", /* @__PURE__ */ new Map());
|
|
31
|
-
a(this, "queue", []);
|
|
32
|
-
a(this, "isProcessing", !1);
|
|
33
|
-
a(this, "pendingEvents", []);
|
|
34
|
-
a(this, "broadcastScheduled", !1);
|
|
35
|
-
}
|
|
36
|
-
schedule(t) {
|
|
37
|
-
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(() => t()) : setTimeout(t, 0);
|
|
38
|
-
}
|
|
39
|
-
processQueue() {
|
|
40
|
-
if (this.isProcessing || this.queue.length === 0) return;
|
|
41
|
-
this.isProcessing = !0;
|
|
42
|
-
const t = () => {
|
|
43
|
-
const s = this.queue.shift();
|
|
44
|
-
if (!s) {
|
|
45
|
-
this.isProcessing = !1;
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
s();
|
|
50
|
-
} finally {
|
|
51
|
-
this.schedule(t);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
t();
|
|
55
|
-
}
|
|
56
|
-
scheduleBroadcast(t) {
|
|
57
|
-
this.pendingEvents.push(t), !this.broadcastScheduled && (this.broadcastScheduled = !0, this.queue.push(() => {
|
|
58
|
-
const s = this.pendingEvents.slice();
|
|
59
|
-
this.pendingEvents = [], this.broadcastScheduled = !1;
|
|
60
|
-
for (const n of s)
|
|
61
|
-
this.listeners.forEach((r) => {
|
|
62
|
-
try {
|
|
63
|
-
r(n.options, n.isOpen);
|
|
64
|
-
} catch (i) {
|
|
65
|
-
process.env.NODE_ENV !== "production" && console.error("[PortalManager] listener error:", i);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}), this.processQueue());
|
|
69
|
-
}
|
|
70
|
-
isPortalOpen(t) {
|
|
71
|
-
var s;
|
|
72
|
-
return ((s = this.portals.get(t)) == null ? void 0 : s.isOpen) ?? !1;
|
|
73
|
-
}
|
|
74
|
-
isDuplicateAllowed(t) {
|
|
75
|
-
return t === "toast";
|
|
76
|
-
}
|
|
77
|
-
subscribe(t) {
|
|
78
|
-
return this.listeners.add(t), () => {
|
|
79
|
-
this.listeners.delete(t);
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
openPortal(t, s) {
|
|
83
|
-
const n = s.id ?? this.generateId(t);
|
|
84
|
-
if (!this.isDuplicateAllowed(t) && this.isPortalOpen(n))
|
|
85
|
-
return n;
|
|
86
|
-
const i = { ...{
|
|
87
|
-
id: n,
|
|
88
|
-
type: t,
|
|
89
|
-
props: { ...s, id: n }
|
|
90
|
-
}, isOpen: !0 };
|
|
91
|
-
return this.portals.set(n, i), this.scheduleBroadcast({ options: i, isOpen: !0 }), n;
|
|
92
|
-
}
|
|
93
|
-
setPortalOpen(t, s) {
|
|
94
|
-
var r, i;
|
|
95
|
-
const n = this.portals.get(t);
|
|
96
|
-
if (n && !(!s && n.props.forceMount) && n.isOpen !== s) {
|
|
97
|
-
if (!s) {
|
|
98
|
-
const l = n._openedAt;
|
|
99
|
-
if (l && Date.now() - l < 300)
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
n.isOpen = s, s && (n._openedAt = Date.now()), this.portals.set(t, n), this.scheduleBroadcast({ options: n, isOpen: s }), s || (i = (r = n.props).onClose) == null || i.call(r);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
updatePortal(t, s, n) {
|
|
106
|
-
const r = this.portals.get(t);
|
|
107
|
-
if (!r || r.type !== s) return;
|
|
108
|
-
const i = {
|
|
109
|
-
...r,
|
|
110
|
-
props: { ...r.props, ...n }
|
|
111
|
-
};
|
|
112
|
-
this.portals.set(t, i), this.scheduleBroadcast({ options: i, isOpen: !0 });
|
|
113
|
-
}
|
|
114
|
-
closePortal(t) {
|
|
115
|
-
this.setPortalOpen(t, !1);
|
|
116
|
-
}
|
|
117
|
-
closeAllPortals() {
|
|
118
|
-
this.getOpenPortals().forEach((t) => this.closePortal(t));
|
|
119
|
-
}
|
|
120
|
-
getIsPortalOpen(t) {
|
|
121
|
-
var s;
|
|
122
|
-
return ((s = this.portals.get(t)) == null ? void 0 : s.isOpen) ?? !1;
|
|
123
|
-
}
|
|
124
|
-
getOpenPortals() {
|
|
125
|
-
const t = [];
|
|
126
|
-
for (const [s, n] of this.portals.entries())
|
|
127
|
-
n.isOpen && t.push(s);
|
|
128
|
-
return t;
|
|
129
|
-
}
|
|
130
|
-
generateId(t) {
|
|
131
|
-
const s = typeof window < "u" && window.location ? window.location.pathname : "ssr", n = `${t}_${s}`;
|
|
132
|
-
return this.isDuplicateAllowed(t) ? `${n}_${y()}` : n;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
const b = new m();
|
|
136
|
-
export {
|
|
137
|
-
b as p
|
|
138
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var p=(e,t,s)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var a=(e,t,s)=>p(e,typeof t!="symbol"?t+"":t,s);let u;const h=new Uint8Array(16);function g(){if(!u&&(u=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!u))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return u(h)}const o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));function f(e,t=0){return o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]}const w=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),c={randomUUID:w};function y(e,t,s){if(c.randomUUID&&!e)return c.randomUUID();e=e||{};const n=e.random||(e.rng||g)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,f(n)}class m{constructor(){a(this,"listeners",new Set);a(this,"portals",new Map);a(this,"queue",[]);a(this,"isProcessing",!1);a(this,"pendingEvents",[]);a(this,"broadcastScheduled",!1)}schedule(t){typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(()=>t()):setTimeout(t,0)}processQueue(){if(this.isProcessing||this.queue.length===0)return;this.isProcessing=!0;const t=()=>{const s=this.queue.shift();if(!s){this.isProcessing=!1;return}try{s()}finally{this.schedule(t)}};t()}scheduleBroadcast(t){this.pendingEvents.push(t),!this.broadcastScheduled&&(this.broadcastScheduled=!0,this.queue.push(()=>{const s=this.pendingEvents.slice();this.pendingEvents=[],this.broadcastScheduled=!1;for(const n of s)this.listeners.forEach(r=>{try{r(n.options,n.isOpen)}catch(i){process.env.NODE_ENV!=="production"&&console.error("[PortalManager] listener error:",i)}})}),this.processQueue())}isPortalOpen(t){var s;return((s=this.portals.get(t))==null?void 0:s.isOpen)??!1}isDuplicateAllowed(t){return t==="toast"}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}openPortal(t,s){const n=s.id??this.generateId(t);if(!this.isDuplicateAllowed(t)&&this.isPortalOpen(n))return n;const i={...{id:n,type:t,props:{...s,id:n}},isOpen:!0};return this.portals.set(n,i),this.scheduleBroadcast({options:i,isOpen:!0}),n}setPortalOpen(t,s){var r,i;const n=this.portals.get(t);if(n&&!(!s&&n.props.forceMount)&&n.isOpen!==s){if(!s){const l=n._openedAt;if(l&&Date.now()-l<300)return}n.isOpen=s,s&&(n._openedAt=Date.now()),this.portals.set(t,n),this.scheduleBroadcast({options:n,isOpen:s}),s||(i=(r=n.props).onClose)==null||i.call(r)}}updatePortal(t,s,n){const r=this.portals.get(t);if(!r||r.type!==s)return;const i={...r,props:{...r.props,...n}};this.portals.set(t,i),this.scheduleBroadcast({options:i,isOpen:!0})}closePortal(t){this.setPortalOpen(t,!1)}closeAllPortals(){this.getOpenPortals().forEach(t=>this.closePortal(t))}getIsPortalOpen(t){var s;return((s=this.portals.get(t))==null?void 0:s.isOpen)??!1}getOpenPortals(){const t=[];for(const[s,n]of this.portals.entries())n.isOpen&&t.push(s);return t}generateId(t){const s=typeof window<"u"&&window.location?window.location.pathname:"ssr",n=`${t}_${s}`;return this.isDuplicateAllowed(t)?`${n}_${y()}`:n}}const P=new m;exports.portalManager=P;
|