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 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 t=require("react"),o=require("./portal-manager-BGE-3NOa.cjs");require("./preview-9QZ5P9LT.cjs");require("./index-Cv4pTXfv.cjs");const s=require("./use-toastmodal-B1QxDevT.cjs"),q=()=>{const[u,r]=t.useState([]);t.useEffect(()=>{const e=(c,p)=>{r(n=>p?[...new Set([...n,c.id])]:n.filter(k=>k!==c.id))},l=o.portalManager.subscribe(e);return r(o.portalManager.getOpenPortals()),()=>l()},[]);const a=t.useCallback((e,l)=>o.portalManager.openPortal(e,{...l,onClose:l.onClose??(()=>{})}),[]),d=t.useCallback(e=>a("modal",e),[a]),i=t.useCallback(e=>typeof e=="string"?a("alert",{description:e}):a("alert",e),[a]),g=t.useCallback(e=>a("dialog",e),[a]),M=t.useCallback(e=>a("custom",e),[a]),b=t.useCallback(e=>o.portalManager.getIsPortalOpen(e),[]),P=t.useCallback(e=>o.portalManager.closePortal(e),[]),C=t.useCallback(()=>o.portalManager.closeAllPortals(),[]);return{open:a,confirm:d,alert:i,dialog:g,custom:M,getIsOpen:b,closePortal:P,closeAllPortals:C,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;
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 w } from "./use-metadata-BrY8rtWx.js";
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-BDctJ_Mt.js";
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 E, a as h, b as j, t as q, u as z, c as B } from "./use-toastmodal-BpqFNqCw.js";
8
- const S = () => {
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, g) => {
12
- r((n) => g ? [.../* @__PURE__ */ new Set([...n, l.id])] : n.filter((b) => b !== l.id));
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]), p = s((t) => e.getIsPortalOpen(t), []), P = s((t) => e.closePortal(t), []), f = s(() => e.closeAllPortals(), []);
27
- return { open: o, confirm: u, alert: i, dialog: m, custom: d, getIsOpen: p, closePortal: P, closeAllPortals: f, openPortals: c };
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
- E as modalReducer,
31
- h as toast,
32
- j as toastModal,
33
- q as toastReducer,
34
- w as useMetadata,
35
- S as usePortal,
36
- z as useToast,
37
- B as useToastModal
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
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("./use-toastmodal-B1QxDevT.cjs"),d=require("./index-C1T36J_d.cjs"),P=require("./preview-9QZ5P9LT.cjs"),M=require("./toast-form-BjkW_vXG.cjs"),f=require("react"),p=require("./portal-manager-BGE-3NOa.cjs");require("./index-z9hRvvSX.cjs");require("./index-Cv4pTXfv.cjs");const w=require("react-dom");function q(){const{modals:e,dismiss:s}=g.useToastModal(),a=e.some(o=>o.open);return n.jsxs(d.ToastModalProvider,{children:[e.map(function({id:o,title:x,description:T,content:t,onConfirm:r,confirmText:m="확인",onCancel:l,cancelText:u="취소",size:i,contents:c,variant:h,width:O,closeType:j,...E}){return n.jsxs(d.ToastModal,{width:O,...E,className:"flex flex-col gap-4",children:[n.jsx(d.ToastModalTitle,{children:x}),n.jsxs("div",{className:"flex flex-col gap-2",children:[T&&n.jsx(d.ToastModalDescription,{className:"text-sm text-foreground",children:T}),t&&n.jsx(d.ToastModalDescription,{children:t})]}),c&&n.jsx(d.ToastModalContents,{children:c}),n.jsxs("div",{className:P.cn("flex items-center justify-between gap-2",j&&"justify-end"),children:[!j&&n.jsx(d.ToastModalClose,{className:"w-1/2",size:i,variant:"outline",children:u}),n.jsx(d.ToastModalAction,{className:j?"":"w-1/2",altText:"confirm",size:i,variant:h,onClick:r,children:m})]})]},o)}),n.jsx(d.ToastModalViewport,{isOpen:a?"open":"close",onClick:()=>e.forEach(o=>!o.closeType&&s(o.id))})]})}const D={modal:(e,s)=>n.jsx(M.ModalForm,{...e.props,onClose:s},e.id),alert:(e,s)=>n.jsx(M.AlertForm,{...e.props,onClose:s},e.id),dialog:(e,s)=>n.jsx(M.DialogForm,{...e.props,onClose:s},e.id),custom:(e,s)=>n.jsx(M.FreeForm,{...e.props,onClose:s},e.id)},C=()=>{const[e,s]=f.useState([]),a=f.useRef(new Map),o=300,x=f.useRef(new Map);f.useEffect(()=>{const t=p.portalManager.subscribe((r,m)=>{s(l=>{const u=l.findIndex(i=>i.id===r.id);if(m)if(u===-1){const i=[...l,{...r,isOpen:!0}];x.current.set(r.id,Date.now());const c=a.current.get(r.id);return c&&(clearTimeout(c),a.current.delete(r.id)),i}else{const i=l.slice();i[u]={...i[u],...r,isOpen:!0},x.current.set(r.id,Date.now());const c=a.current.get(r.id);return c&&(clearTimeout(c),a.current.delete(r.id)),i}else{if(u===-1||l[u].props.forceMount)return l;const i=x.current.get(r.id);if(i&&Date.now()-i<o)return l;const c=l.slice();return c[u]={...c[u],isOpen:!1},c}})});return()=>t()},[]);const T=f.useCallback(t=>{const r=e.find(m=>m.id===t);r&&r.props.forceMount||p.portalManager.setPortalOpen(t,!1)},[e]);return f.useEffect(()=>(e.forEach(t=>{if(!t.isOpen&&!a.current.has(t.id)){const r=setTimeout(()=>{s(m=>m.filter(l=>l.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]),n.jsx(b,{children:e.map(t=>{if(!t.isOpen||t.type==="toast")return null;const r=D[t.type];return r(t,()=>T(t.id))})})},b=({children:e})=>{const[s,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)},[]),s?w.createPortal(e,s):null};function y(){const{toasts:e}=g.useToast();return n.jsxs(d.ToastProvider,{children:[e.map(s=>n.jsx(M.ToastForm,{...s},s.id)),n.jsx(d.ToastViewport,{})]})}exports.ModalManager=q;exports.PortalProvider=C;exports.ToastManager=y;
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;
@@ -1,48 +1,48 @@
1
- import { jsxs as m, jsx as o } from "react/jsx-runtime";
2
- import { c as C, u as P } from "./use-toastmodal-BpqFNqCw.js";
3
- import { T as b, a as F, b as N, c as h, d as y, e as A, f as R, g as _, h as j, i as k } from "./index-DuUh97OP.js";
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 O, useRef as g, useEffect as M, useCallback as G } from "react";
7
- import { p as x } from "./portal-manager-BDctJ_Mt.js";
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 } = C(), a = e.some((s) => s.open);
13
- return /* @__PURE__ */ m(b, { children: [
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: p,
17
+ description: T,
18
18
  content: t,
19
19
  onConfirm: r,
20
20
  confirmText: u = "확인",
21
- onCancel: l,
21
+ onCancel: c,
22
22
  cancelText: d = "취소",
23
23
  size: i,
24
- contents: c,
25
- variant: w,
26
- width: D,
27
- closeType: T,
28
- ...E
24
+ contents: l,
25
+ variant: m,
26
+ width: w,
27
+ closeType: M,
28
+ ...D
29
29
  }) {
30
- return /* @__PURE__ */ m(F, { width: D, ...E, className: "flex flex-col gap-4", children: [
30
+ return /* @__PURE__ */ p(b, { width: w, ...D, className: "flex flex-col gap-4", children: [
31
31
  /* @__PURE__ */ o(N, { children: f }),
32
- /* @__PURE__ */ m("div", { className: "flex flex-col gap-2", children: [
33
- p && /* @__PURE__ */ o(h, { className: "text-sm text-foreground", children: p }),
34
- t && /* @__PURE__ */ o(h, { children: t })
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
- c && /* @__PURE__ */ o(y, { children: c }),
37
- /* @__PURE__ */ m("div", { className: v("flex items-center justify-between gap-2", T && "justify-end"), children: [
38
- !T && /* @__PURE__ */ o(A, { className: "w-1/2", size: i, variant: "outline", children: d }),
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
- R,
40
+ _,
41
41
  {
42
- className: T ? "" : "w-1/2",
42
+ className: M ? "" : "w-1/2",
43
43
  altText: "confirm",
44
44
  size: i,
45
- variant: w,
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] = O([]), a = g(/* @__PURE__ */ new Map()), s = 300, f = g(/* @__PURE__ */ new Map());
69
- M(() => {
70
- const t = x.subscribe((r, u) => {
71
- n((l) => {
72
- const d = l.findIndex((i) => i.id === r.id);
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 = [...l, { ...r, isOpen: !0 }];
75
+ const i = [...c, { ...r, isOpen: !0 }];
76
76
  f.current.set(r.id, Date.now());
77
- const c = a.current.get(r.id);
78
- return c && (clearTimeout(c), a.current.delete(r.id)), i;
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 = l.slice();
80
+ const i = c.slice();
81
81
  i[d] = { ...i[d], ...r, isOpen: !0 }, f.current.set(r.id, Date.now());
82
- const c = a.current.get(r.id);
83
- return c && (clearTimeout(c), a.current.delete(r.id)), i;
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 || l[d].props.forceMount)
87
- return l;
88
- const i = f.current.get(r.id);
89
- if (i && Date.now() - i < s)
90
- return l;
91
- const c = l.slice();
92
- return c[d] = { ...c[d], isOpen: !1 }, c;
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 p = G(
100
+ const T = G(
99
101
  (t) => {
100
102
  const r = e.find((u) => u.id === t);
101
- r && r.props.forceMount || x.setPortalOpen(t, !1);
103
+ r && r.props.forceMount || O.setPortalOpen(t, !1);
102
104
  },
103
105
  [e]
104
106
  );
105
- return M(() => (e.forEach((t) => {
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((l) => l.id !== t.id)), a.current.delete(t.id);
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, () => p(t.id));
119
+ return r(t, () => T(t.id));
118
120
  }) });
119
121
  }, H = ({ children: e }) => {
120
- const [n, a] = O(null);
121
- return M(() => {
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__ */ m(j, { children: [
131
+ return /* @__PURE__ */ p(j, { children: [
130
132
  e.map((n) => /* @__PURE__ */ o(B, { ...n }, n.id)),
131
133
  /* @__PURE__ */ o(k, {})
132
134
  ] });
@@ -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
  };
@@ -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-BGE-3NOa.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;
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-BDctJ_Mt.js";
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,7 +1,7 @@
1
1
  {
2
2
  "name": "boottent-design",
3
3
  "private": false,
4
- "version": "0.1.211",
4
+ "version": "0.1.213",
5
5
  "description": "부트텐트 디자인시스템 라이브러리",
6
6
  "repository": {
7
7
  "type": "git",
@@ -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;