boottent-design 0.1.209 → 0.1.211

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-DZmFgCdy.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 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;
package/dist/hooks.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { u as w } 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-C2SAuVCB.js";
4
+ import { p as e } from "./portal-manager-BDctJ_Mt.js";
5
5
  import "./preview-Cocn_vDi.js";
6
6
  import "./index-DT339AZp.js";
7
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";
@@ -1,30 +1,30 @@
1
- var c = Object.defineProperty;
2
- var p = (e, t, s) => t in e ? c(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
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
3
  var a = (e, t, s) => p(e, typeof t != "symbol" ? t + "" : t, s);
4
4
  let u;
5
- const d = new Uint8Array(16);
6
- function h() {
5
+ const h = new Uint8Array(16);
6
+ function g() {
7
7
  if (!u && (u = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !u))
8
8
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
9
- return u(d);
9
+ return u(h);
10
10
  }
11
11
  const o = [];
12
12
  for (let e = 0; e < 256; ++e)
13
13
  o.push((e + 256).toString(16).slice(1));
14
- function g(e, t = 0) {
14
+ function f(e, t = 0) {
15
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
16
  }
17
- const w = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), l = {
17
+ const w = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), c = {
18
18
  randomUUID: w
19
19
  };
20
20
  function y(e, t, s) {
21
- if (l.randomUUID && !e)
22
- return l.randomUUID();
21
+ if (c.randomUUID && !e)
22
+ return c.randomUUID();
23
23
  e = e || {};
24
- const n = e.random || (e.rng || h)();
25
- return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, g(n);
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
26
  }
27
- class f {
27
+ class m {
28
28
  constructor() {
29
29
  a(this, "listeners", /* @__PURE__ */ new Set());
30
30
  a(this, "portals", /* @__PURE__ */ new Map());
@@ -93,7 +93,14 @@ class f {
93
93
  setPortalOpen(t, s) {
94
94
  var r, i;
95
95
  const n = this.portals.get(t);
96
- n && n.isOpen !== s && (n.isOpen = s, this.portals.set(t, n), this.scheduleBroadcast({ options: n, isOpen: s }), s || (i = (r = n.props).onClose) == null || i.call(r));
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
+ }
97
104
  }
98
105
  updatePortal(t, s, n) {
99
106
  const r = this.portals.get(t);
@@ -125,7 +132,7 @@ class f {
125
132
  return this.isDuplicateAllowed(t) ? `${n}_${y()}` : n;
126
133
  }
127
134
  }
128
- const P = new f();
135
+ const b = new m();
129
136
  export {
130
- P as p
137
+ b as p
131
138
  };
@@ -1 +1 @@
1
- "use strict";var c=Object.defineProperty;var d=(e,t,s)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var a=(e,t,s)=>d(e,typeof t!="symbol"?t+"":t,s);let u;const p=new Uint8Array(16);function h(){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(p)}const o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));function g(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),l={randomUUID:w};function y(e,t,s){if(l.randomUUID&&!e)return l.randomUUID();e=e||{};const n=e.random||(e.rng||h)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,g(n)}class f{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);n&&n.isOpen!==s&&(n.isOpen=s,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 m=new f;exports.portalManager=m;
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;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),h=require("./use-toastmodal-B1QxDevT.cjs"),l=require("./index-C1T36J_d.cjs"),P=require("./preview-9QZ5P9LT.cjs"),M=require("./toast-form-BjkW_vXG.cjs"),f=require("react"),g=require("./portal-manager-DZmFgCdy.cjs");require("./index-z9hRvvSX.cjs");require("./index-Cv4pTXfv.cjs");const w=require("react-dom");function q(){const{modals:e,dismiss:s}=h.useToastModal(),a=e.some(o=>o.open);return r.jsxs(l.ToastModalProvider,{children:[e.map(function({id:o,title:m,description:T,content:t,onConfirm:n,confirmText:x="확인",onCancel:d,cancelText:u="취소",size:i,contents:c,variant:p,width:O,closeType:j,...E}){return r.jsxs(l.ToastModal,{width:O,...E,className:"flex flex-col gap-4",children:[r.jsx(l.ToastModalTitle,{children:m}),r.jsxs("div",{className:"flex flex-col gap-2",children:[T&&r.jsx(l.ToastModalDescription,{className:"text-sm text-foreground",children:T}),t&&r.jsx(l.ToastModalDescription,{children:t})]}),c&&r.jsx(l.ToastModalContents,{children:c}),r.jsxs("div",{className:P.cn("flex items-center justify-between gap-2",j&&"justify-end"),children:[!j&&r.jsx(l.ToastModalClose,{className:"w-1/2",size:i,variant:"outline",children:u}),r.jsx(l.ToastModalAction,{className:j?"":"w-1/2",altText:"confirm",size:i,variant:p,onClick:n,children:x})]})]},o)}),r.jsx(l.ToastModalViewport,{isOpen:a?"open":"close",onClick:()=>e.forEach(o=>!o.closeType&&s(o.id))})]})}const D={modal:(e,s)=>r.jsx(M.ModalForm,{...e.props,onClose:s},e.id),alert:(e,s)=>r.jsx(M.AlertForm,{...e.props,onClose:s},e.id),dialog:(e,s)=>r.jsx(M.DialogForm,{...e.props,onClose:s},e.id),custom:(e,s)=>r.jsx(M.FreeForm,{...e.props,onClose:s},e.id)},C=()=>{const[e,s]=f.useState([]),a=f.useRef(new Map),o=80,m=f.useRef(new Map);f.useEffect(()=>{const t=g.portalManager.subscribe((n,x)=>{s(d=>{const u=d.findIndex(i=>i.id===n.id);if(x)if(u===-1){const i=[...d,{...n,isOpen:!0}];m.current.set(n.id,Date.now());const c=a.current.get(n.id);return c&&(clearTimeout(c),a.current.delete(n.id)),i}else{const i=d.slice();i[u]={...i[u],...n,isOpen:!0},m.current.set(n.id,Date.now());const c=a.current.get(n.id);return c&&(clearTimeout(c),a.current.delete(n.id)),i}else{if(u===-1)return d;const i=m.current.get(n.id);if(i&&Date.now()-i<o)return d;const c=d.slice();return c[u]={...c[u],isOpen:!1},c}})});return()=>t()},[]);const T=f.useCallback(t=>{g.portalManager.setPortalOpen(t,!1)},[]);return f.useEffect(()=>(e.forEach(t=>{if(!t.isOpen&&!a.current.has(t.id)){const n=setTimeout(()=>{s(x=>x.filter(d=>d.id!==t.id)),a.current.delete(t.id)},300);a.current.set(t.id,n)}}),()=>{a.current.forEach(t=>clearTimeout(t)),a.current.clear()}),[e]),r.jsx(b,{children:e.map(t=>{if(!t.isOpen||t.type==="toast")return null;const n=D[t.type];return n(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 v(){const{toasts:e}=h.useToast();return r.jsxs(l.ToastProvider,{children:[e.map(s=>r.jsx(M.ToastForm,{...s},s.id)),r.jsx(l.ToastViewport,{})]})}exports.ModalManager=q;exports.PortalProvider=C;exports.ToastManager=v;
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,23 +1,23 @@
1
- import { jsxs as f, jsx as a } from "react/jsx-runtime";
1
+ import { jsxs as m, jsx as o } from "react/jsx-runtime";
2
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 v, g as R, h as _, i as j } from "./index-DuUh97OP.js";
4
- import { c as k } from "./preview-Cocn_vDi.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";
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
6
  import { useState as O, useRef as g, useEffect as M, useCallback as G } from "react";
7
- import { p as x } from "./portal-manager-C2SAuVCB.js";
7
+ import { p as x } from "./portal-manager-BDctJ_Mt.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: r } = C(), o = e.some((s) => s.open);
13
- return /* @__PURE__ */ f(b, { children: [
12
+ const { modals: e, dismiss: n } = C(), a = e.some((s) => s.open);
13
+ return /* @__PURE__ */ m(b, { children: [
14
14
  e.map(function({
15
15
  id: s,
16
- title: u,
16
+ title: f,
17
17
  description: p,
18
18
  content: t,
19
- onConfirm: n,
20
- confirmText: m = "확인",
19
+ onConfirm: r,
20
+ confirmText: u = "확인",
21
21
  onCancel: l,
22
22
  cancelText: d = "취소",
23
23
  size: i,
@@ -27,64 +27,65 @@ function te() {
27
27
  closeType: T,
28
28
  ...E
29
29
  }) {
30
- return /* @__PURE__ */ f(F, { width: D, ...E, className: "flex flex-col gap-4", children: [
31
- /* @__PURE__ */ a(N, { children: u }),
32
- /* @__PURE__ */ f("div", { className: "flex flex-col gap-2", children: [
33
- p && /* @__PURE__ */ a(h, { className: "text-sm text-foreground", children: p }),
34
- t && /* @__PURE__ */ a(h, { children: t })
30
+ return /* @__PURE__ */ m(F, { width: D, ...E, className: "flex flex-col gap-4", children: [
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 })
35
35
  ] }),
36
- c && /* @__PURE__ */ a(y, { children: c }),
37
- /* @__PURE__ */ f("div", { className: k("flex items-center justify-between gap-2", T && "justify-end"), children: [
38
- !T && /* @__PURE__ */ a(A, { className: "w-1/2", size: i, variant: "outline", children: d }),
39
- /* @__PURE__ */ a(
40
- v,
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 }),
39
+ /* @__PURE__ */ o(
40
+ R,
41
41
  {
42
42
  className: T ? "" : "w-1/2",
43
43
  altText: "confirm",
44
44
  size: i,
45
45
  variant: w,
46
- onClick: n,
47
- children: m
46
+ onClick: r,
47
+ children: u
48
48
  }
49
49
  )
50
50
  ] })
51
51
  ] }, s);
52
52
  }),
53
- /* @__PURE__ */ a(
54
- R,
53
+ /* @__PURE__ */ o(
54
+ _,
55
55
  {
56
- isOpen: o ? "open" : "close",
57
- onClick: () => e.forEach((s) => !s.closeType && r(s.id))
56
+ isOpen: a ? "open" : "close",
57
+ onClick: () => e.forEach((s) => !s.closeType && n(s.id))
58
58
  }
59
59
  )
60
60
  ] });
61
61
  }
62
62
  const q = {
63
- modal: (e, r) => /* @__PURE__ */ a(V, { ...e.props, onClose: r }, e.id),
64
- alert: (e, r) => /* @__PURE__ */ a(U, { ...e.props, onClose: r }, e.id),
65
- dialog: (e, r) => /* @__PURE__ */ a(I, { ...e.props, onClose: r }, e.id),
66
- custom: (e, r) => /* @__PURE__ */ a(S, { ...e.props, onClose: r }, e.id)
63
+ modal: (e, n) => /* @__PURE__ */ o(V, { ...e.props, onClose: n }, e.id),
64
+ alert: (e, n) => /* @__PURE__ */ o(U, { ...e.props, onClose: n }, e.id),
65
+ dialog: (e, n) => /* @__PURE__ */ o(I, { ...e.props, onClose: n }, e.id),
66
+ custom: (e, n) => /* @__PURE__ */ o(S, { ...e.props, onClose: n }, e.id)
67
67
  }, re = () => {
68
- const [e, r] = O([]), o = g(/* @__PURE__ */ new Map()), s = 80, u = g(/* @__PURE__ */ new Map());
68
+ const [e, n] = O([]), a = g(/* @__PURE__ */ new Map()), s = 300, f = g(/* @__PURE__ */ new Map());
69
69
  M(() => {
70
- const t = x.subscribe((n, m) => {
71
- r((l) => {
72
- const d = l.findIndex((i) => i.id === n.id);
73
- if (m)
70
+ const t = x.subscribe((r, u) => {
71
+ n((l) => {
72
+ const d = l.findIndex((i) => i.id === r.id);
73
+ if (u)
74
74
  if (d === -1) {
75
- const i = [...l, { ...n, isOpen: !0 }];
76
- u.current.set(n.id, Date.now());
77
- const c = o.current.get(n.id);
78
- return c && (clearTimeout(c), o.current.delete(n.id)), i;
75
+ const i = [...l, { ...r, isOpen: !0 }];
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;
79
79
  } else {
80
80
  const i = l.slice();
81
- i[d] = { ...i[d], ...n, isOpen: !0 }, u.current.set(n.id, Date.now());
82
- const c = o.current.get(n.id);
83
- return c && (clearTimeout(c), o.current.delete(n.id)), i;
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;
84
84
  }
85
85
  else {
86
- if (d === -1) return l;
87
- const i = u.current.get(n.id);
86
+ if (d === -1 || l[d].props.forceMount)
87
+ return l;
88
+ const i = f.current.get(r.id);
88
89
  if (i && Date.now() - i < s)
89
90
  return l;
90
91
  const c = l.slice();
@@ -94,36 +95,40 @@ const q = {
94
95
  });
95
96
  return () => t();
96
97
  }, []);
97
- const p = G((t) => {
98
- x.setPortalOpen(t, !1);
99
- }, []);
98
+ const p = G(
99
+ (t) => {
100
+ const r = e.find((u) => u.id === t);
101
+ r && r.props.forceMount || x.setPortalOpen(t, !1);
102
+ },
103
+ [e]
104
+ );
100
105
  return M(() => (e.forEach((t) => {
101
- if (!t.isOpen && !o.current.has(t.id)) {
102
- const n = setTimeout(() => {
103
- r((m) => m.filter((l) => l.id !== t.id)), o.current.delete(t.id);
106
+ if (!t.isOpen && !a.current.has(t.id)) {
107
+ const r = setTimeout(() => {
108
+ n((u) => u.filter((l) => l.id !== t.id)), a.current.delete(t.id);
104
109
  }, 300);
105
- o.current.set(t.id, n);
110
+ a.current.set(t.id, r);
106
111
  }
107
112
  }), () => {
108
- o.current.forEach((t) => clearTimeout(t)), o.current.clear();
109
- }), [e]), /* @__PURE__ */ a(H, { children: e.map((t) => {
113
+ a.current.forEach((t) => clearTimeout(t)), a.current.clear();
114
+ }), [e]), /* @__PURE__ */ o(H, { children: e.map((t) => {
110
115
  if (!t.isOpen || t.type === "toast") return null;
111
- const n = q[t.type];
112
- return n(t, () => p(t.id));
116
+ const r = q[t.type];
117
+ return r(t, () => p(t.id));
113
118
  }) });
114
119
  }, H = ({ children: e }) => {
115
- const [r, o] = O(null);
120
+ const [n, a] = O(null);
116
121
  return M(() => {
117
122
  if (typeof document > "u") return;
118
123
  let s = document.getElementById("portal");
119
- s || (s = document.createElement("div"), s.id = "portal", document.body.appendChild(s)), o(s);
120
- }, []), r ? J.createPortal(e, r) : null;
124
+ s || (s = document.createElement("div"), s.id = "portal", document.body.appendChild(s)), a(s);
125
+ }, []), n ? J.createPortal(e, n) : null;
121
126
  };
122
127
  function ne() {
123
128
  const { toasts: e } = P();
124
- return /* @__PURE__ */ f(_, { children: [
125
- e.map((r) => /* @__PURE__ */ a(B, { ...r }, r.id)),
126
- /* @__PURE__ */ a(j, {})
129
+ return /* @__PURE__ */ m(j, { children: [
130
+ e.map((n) => /* @__PURE__ */ o(B, { ...n }, n.id)),
131
+ /* @__PURE__ */ o(k, {})
127
132
  ] });
128
133
  }
129
134
  export {
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-DZmFgCdy.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-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;
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-C2SAuVCB.js";
3
+ import { p as M } from "./portal-manager-BDctJ_Mt.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.209",
4
+ "version": "0.1.211",
5
5
  "description": "부트텐트 디자인시스템 라이브러리",
6
6
  "repository": {
7
7
  "type": "git",