boottent-design 0.1.185 → 0.1.186
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 +12 -15
- package/dist/provider.cjs.js +1 -1
- package/dist/provider.es.js +120 -147
- package/dist/types/hooks.d.ts +1 -2
- package/package.json +1 -1
package/dist/hooks.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 d=require("./use-metadata-CZiZDN9j.cjs");require("react/jsx-runtime");const l=require("react"),e=require("./use-toastmodal-BiqEXQyI.cjs");require("./index-BoeM4gLz.cjs");const i=()=>{const[n,r]=l.useState([]);return l.useEffect(()=>{const t=(s,c)=>{r(c?a=>a.includes(s.id)?a:[...a,s.id]:a=>a.filter(u=>u!==s.id))},o=e.portalManager.subscribe(t);return r(e.portalManager.getOpenPortals()),()=>{o()}},[]),{confirm:t=>{const{onClose:o=()=>{}}=t;return e.portalManager.showPortal("modal",{...t,onClose:o})},alert:t=>{let o;return typeof t=="string"?o={description:t,onClose:()=>{}}:o={...t,onClose:t.onClose||(()=>{})},e.portalManager.showPortal("alert",o)},dialog:t=>{const{onClose:o=()=>{}}=t;return e.portalManager.showPortal("dialog",{...t,onClose:o})},custom:t=>{const{onClose:o=()=>{}}=t;return e.portalManager.showPortal("custom",{...t,onClose:o})},getIsOpen:t=>e.portalManager.getIsPortalOpen(t),closePortal:t=>{e.portalManager.closePortal(t)},closeAllPortals:()=>{e.portalManager.closeAllPortals()},openPortals:n}};exports.useMetadata=d.useMetadata;exports.modalReducer=e.modalReducer;exports.toast=e.toast;exports.toastModal=e.toastModal;exports.toastReducer=e.toastReducer;exports.useToast=e.useToast;exports.useToastModal=e.useToastModal;exports.usePortal=i;
|
package/dist/hooks.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { u as
|
|
1
|
+
import { u as p } from "./use-metadata-BrY8rtWx.js";
|
|
2
2
|
import "react/jsx-runtime";
|
|
3
3
|
import { useState as u, useEffect as i } from "react";
|
|
4
4
|
import { p as s } from "./use-toastmodal-BhR-ysRN.js";
|
|
5
|
-
import { m as
|
|
5
|
+
import { m as T, a as y, b as E, t as S, u as j, c as k } from "./use-toastmodal-BhR-ysRN.js";
|
|
6
6
|
import "./index-haM7BOE0.js";
|
|
7
|
-
const
|
|
7
|
+
const x = () => {
|
|
8
8
|
const [a, r] = u([]);
|
|
9
9
|
return i(() => {
|
|
10
10
|
const t = (l, n) => {
|
|
@@ -13,13 +13,10 @@ const A = () => {
|
|
|
13
13
|
return r(s.getOpenPortals()), () => {
|
|
14
14
|
o();
|
|
15
15
|
};
|
|
16
|
-
}, []), {
|
|
16
|
+
}, []), { confirm: (t) => {
|
|
17
17
|
const { onClose: o = () => {
|
|
18
18
|
} } = t;
|
|
19
19
|
return s.showPortal("modal", { ...t, onClose: o });
|
|
20
|
-
}, toast: (t) => {
|
|
21
|
-
let o;
|
|
22
|
-
return typeof t == "string" ? o = { description: t } : o = t, s.showPortal("toast", o);
|
|
23
20
|
}, alert: (t) => {
|
|
24
21
|
let o;
|
|
25
22
|
return typeof t == "string" ? o = { description: t, onClose: () => {
|
|
@@ -40,12 +37,12 @@ const A = () => {
|
|
|
40
37
|
}, openPortals: a };
|
|
41
38
|
};
|
|
42
39
|
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
T as modalReducer,
|
|
41
|
+
y as toast,
|
|
42
|
+
E as toastModal,
|
|
43
|
+
S as toastReducer,
|
|
44
|
+
p as useMetadata,
|
|
45
|
+
x as usePortal,
|
|
46
|
+
j as useToast,
|
|
47
|
+
k as useToastModal
|
|
51
48
|
};
|
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"),f=require("./use-toastmodal-BiqEXQyI.cjs"),t=require("./index-BydYbLSq.cjs"),g=require("./index-BoeM4gLz.cjs"),m=require("./toast-form-D-mN24Yl.cjs"),d=require("react");require("./index-z9hRvvSX.cjs");const P=require("react-dom");function E(){const{modals:n,dismiss:r}=f.useToastModal(),a=n.some(e=>e.open);return s.jsxs(t.ToastModalProvider,{children:[n.map(function({id:e,title:o,description:l,content:i,onConfirm:u,confirmText:c="확인",onCancel:F,cancelText:M="취소",size:p,contents:j,variant:C,width:T,closeType:x,...h}){return s.jsxs(t.ToastModal,{width:T,...h,className:"flex flex-col gap-4",children:[s.jsx(t.ToastModalTitle,{children:o}),s.jsxs("div",{className:"flex flex-col gap-2",children:[l&&s.jsx(t.ToastModalDescription,{className:"text-sm text-foreground",children:l}),i&&s.jsx(t.ToastModalDescription,{children:i})]}),j&&s.jsx(t.ToastModalContents,{children:j}),s.jsxs("div",{className:g.cn("flex items-center justify-between gap-2",x&&"justify-end"),children:[!x&&s.jsx(t.ToastModalClose,{className:"w-1/2",size:p,variant:"outline",children:M}),s.jsx(t.ToastModalAction,{className:x?"":"w-1/2",altText:"confirm",size:p,variant:C,onClick:u,children:c})]})]},e)}),s.jsx(t.ToastModalViewport,{isOpen:a?"open":"close",onClick:()=>n.forEach(e=>!e.closeType&&r(e.id))})]})}const v=()=>{const[n,r]=d.useState([]);d.useEffect(()=>{const e=f.portalManager.subscribe((o,l)=>{r(i=>{const u=i.find(c=>c.id===o.id);return l?u?i:[...i,{...o,isOpen:l}]:i.map(c=>c.id===o.id?{...c,isOpen:!1}:c)})});return()=>{e()}},[]);const a=d.useCallback(e=>{f.portalManager.setPortalOpen(e,!1)},[]);return d.useEffect(()=>{const e=[];return n.forEach(o=>{if(!o.isOpen){const l=setTimeout(()=>{r(i=>i.filter(u=>u.id!==o.id))},300);e.push(l)}}),()=>{e.forEach(o=>clearTimeout(o))}},[n]),s.jsx(b,{children:n.map(e=>{var o;if(!e.isOpen)return null;switch(e.type){case"modal":return s.jsx(m.ModalForm,{...e.props,onClose:()=>{e.props.onClose&&e.props.onClose(),a(e.id)},description:(o=e.props.description)==null?void 0:o.toString()},e.id);case"alert":return s.jsx(m.AlertForm,{...e.props,onClose:()=>{e.props.onClose&&e.props.onClose(),a(e.id)}},e.id);case"dialog":return s.jsx(m.DialogForm,{...e.props,onClose:()=>{e.props.onClose&&e.props.onClose(),a(e.id)}},e.id);case"custom":return s.jsx(m.FreeForm,{...e.props,onClose:()=>{e.props.onClose&&e.props.onClose(),a(e.id)},contents:e.props.contents},e.id);default:return null}})})},b=({children:n})=>{const[r,a]=d.useState(null);return d.useEffect(()=>{let e=document.getElementById("portal");e||(e=document.createElement("div"),e.id="portal",document.body.appendChild(e)),a(e)},[]),r?P.createPortal(n,r):null};function q(){const{toasts:n}=f.useToast();return s.jsxs(t.ToastProvider,{children:[n.map(function(r){return s.jsx(m.ToastForm,{...r})}),s.jsx(t.ToastViewport,{})]})}exports.ModalManager=E;exports.PortalProvider=v;exports.ToastManager=q;
|
package/dist/provider.es.js
CHANGED
|
@@ -1,189 +1,162 @@
|
|
|
1
|
-
import { jsxs as d, jsx as
|
|
2
|
-
import { c as
|
|
3
|
-
import { T as
|
|
4
|
-
import { c as
|
|
5
|
-
import {
|
|
6
|
-
import { useState as
|
|
7
|
-
import G from "react-dom";
|
|
1
|
+
import { jsxs as d, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { c as E, p as C, u as b } from "./use-toastmodal-BhR-ysRN.js";
|
|
3
|
+
import { T as v, a as F, b as w, c as h, d as N, e as O, f as D, g as j, h as y, i as k } from "./index-D6lL3AG_.js";
|
|
4
|
+
import { c as A } from "./index-haM7BOE0.js";
|
|
5
|
+
import { F as S, D as V, A as _, M as B, T as I } from "./toast-form-tgb0rBlD.js";
|
|
6
|
+
import { useState as T, useEffect as m, useCallback as R } from "react";
|
|
8
7
|
import "./index-CEwEyzHV.js";
|
|
8
|
+
import q from "react-dom";
|
|
9
9
|
function Z() {
|
|
10
|
-
const { modals: n, dismiss:
|
|
11
|
-
return /* @__PURE__ */ d(
|
|
10
|
+
const { modals: n, dismiss: t } = E(), a = n.some((e) => e.open);
|
|
11
|
+
return /* @__PURE__ */ d(v, { children: [
|
|
12
12
|
n.map(function({
|
|
13
|
-
id:
|
|
14
|
-
title:
|
|
15
|
-
description:
|
|
16
|
-
content:
|
|
17
|
-
onConfirm:
|
|
18
|
-
confirmText:
|
|
19
|
-
onCancel:
|
|
20
|
-
cancelText:
|
|
21
|
-
size:
|
|
22
|
-
contents:
|
|
23
|
-
variant:
|
|
24
|
-
width:
|
|
25
|
-
closeType:
|
|
26
|
-
...
|
|
13
|
+
id: e,
|
|
14
|
+
title: o,
|
|
15
|
+
description: i,
|
|
16
|
+
content: r,
|
|
17
|
+
onConfirm: c,
|
|
18
|
+
confirmText: l = "확인",
|
|
19
|
+
onCancel: H,
|
|
20
|
+
cancelText: M = "취소",
|
|
21
|
+
size: f,
|
|
22
|
+
contents: p,
|
|
23
|
+
variant: g,
|
|
24
|
+
width: x,
|
|
25
|
+
closeType: u,
|
|
26
|
+
...P
|
|
27
27
|
}) {
|
|
28
|
-
return /* @__PURE__ */ d(
|
|
29
|
-
/* @__PURE__ */
|
|
28
|
+
return /* @__PURE__ */ d(F, { width: x, ...P, className: "flex flex-col gap-4", children: [
|
|
29
|
+
/* @__PURE__ */ s(w, { children: o }),
|
|
30
30
|
/* @__PURE__ */ d("div", { className: "flex flex-col gap-2", children: [
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
i && /* @__PURE__ */ s(h, { className: "text-sm text-foreground", children: i }),
|
|
32
|
+
r && /* @__PURE__ */ s(h, { children: r })
|
|
33
33
|
] }),
|
|
34
|
-
|
|
35
|
-
/* @__PURE__ */ d("div", { className:
|
|
36
|
-
!
|
|
37
|
-
/* @__PURE__ */
|
|
38
|
-
|
|
34
|
+
p && /* @__PURE__ */ s(N, { children: p }),
|
|
35
|
+
/* @__PURE__ */ d("div", { className: A("flex items-center justify-between gap-2", u && "justify-end"), children: [
|
|
36
|
+
!u && /* @__PURE__ */ s(O, { className: "w-1/2", size: f, variant: "outline", children: M }),
|
|
37
|
+
/* @__PURE__ */ s(
|
|
38
|
+
D,
|
|
39
39
|
{
|
|
40
|
-
className:
|
|
40
|
+
className: u ? "" : "w-1/2",
|
|
41
41
|
altText: "confirm",
|
|
42
|
-
size:
|
|
43
|
-
variant:
|
|
44
|
-
onClick:
|
|
45
|
-
children:
|
|
42
|
+
size: f,
|
|
43
|
+
variant: g,
|
|
44
|
+
onClick: c,
|
|
45
|
+
children: l
|
|
46
46
|
}
|
|
47
47
|
)
|
|
48
48
|
] })
|
|
49
|
-
] },
|
|
49
|
+
] }, e);
|
|
50
50
|
}),
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
|
|
51
|
+
/* @__PURE__ */ s(
|
|
52
|
+
j,
|
|
53
53
|
{
|
|
54
|
-
isOpen:
|
|
55
|
-
onClick: () => n.forEach((
|
|
54
|
+
isOpen: a ? "open" : "close",
|
|
55
|
+
onClick: () => n.forEach((e) => !e.closeType && t(e.id))
|
|
56
56
|
}
|
|
57
57
|
)
|
|
58
58
|
] });
|
|
59
59
|
}
|
|
60
60
|
const $ = () => {
|
|
61
|
-
const [n,
|
|
61
|
+
const [n, t] = T([]);
|
|
62
62
|
m(() => {
|
|
63
|
-
const e =
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
return
|
|
63
|
+
const e = C.subscribe((o, i) => {
|
|
64
|
+
t((r) => {
|
|
65
|
+
const c = r.find((l) => l.id === o.id);
|
|
66
|
+
return i ? c ? r : [...r, { ...o, isOpen: i }] : r.map((l) => l.id === o.id ? { ...l, isOpen: !1 } : l);
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
69
|
return () => {
|
|
70
70
|
e();
|
|
71
71
|
};
|
|
72
72
|
}, []);
|
|
73
|
-
const
|
|
74
|
-
|
|
73
|
+
const a = R((e) => {
|
|
74
|
+
C.setPortalOpen(e, !1);
|
|
75
75
|
}, []);
|
|
76
|
-
m(() => {
|
|
76
|
+
return m(() => {
|
|
77
77
|
const e = [];
|
|
78
|
-
return n.forEach((
|
|
79
|
-
if (!
|
|
80
|
-
const
|
|
81
|
-
|
|
78
|
+
return n.forEach((o) => {
|
|
79
|
+
if (!o.isOpen) {
|
|
80
|
+
const i = setTimeout(() => {
|
|
81
|
+
t((r) => r.filter((c) => c.id !== o.id));
|
|
82
82
|
}, 300);
|
|
83
|
-
e.push(
|
|
83
|
+
e.push(i);
|
|
84
84
|
}
|
|
85
85
|
}), () => {
|
|
86
|
-
e.forEach((
|
|
86
|
+
e.forEach((o) => clearTimeout(o));
|
|
87
87
|
};
|
|
88
|
-
}, [n])
|
|
89
|
-
|
|
90
|
-
(e)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
position: s.position,
|
|
100
|
-
size: s.size,
|
|
101
|
-
className: s.className
|
|
102
|
-
}), i(e.id);
|
|
103
|
-
},
|
|
104
|
-
[i]
|
|
105
|
-
);
|
|
106
|
-
return m(() => {
|
|
107
|
-
n.forEach((e) => {
|
|
108
|
-
e.type === "toast" && e.isOpen && o(e);
|
|
109
|
-
});
|
|
110
|
-
}, [n, o]), /* @__PURE__ */ d(H, { children: [
|
|
111
|
-
/* @__PURE__ */ t(x, {}),
|
|
112
|
-
n.map((e) => {
|
|
113
|
-
var s;
|
|
114
|
-
if (!e.isOpen) return null;
|
|
115
|
-
switch (e.type) {
|
|
116
|
-
case "modal":
|
|
117
|
-
return /* @__PURE__ */ t(
|
|
118
|
-
q,
|
|
119
|
-
{
|
|
120
|
-
...e.props,
|
|
121
|
-
onClose: () => {
|
|
122
|
-
e.props.onClose && e.props.onClose(), i(e.id);
|
|
123
|
-
},
|
|
124
|
-
description: (s = e.props.description) == null ? void 0 : s.toString()
|
|
125
|
-
},
|
|
126
|
-
e.id
|
|
127
|
-
);
|
|
128
|
-
case "alert":
|
|
129
|
-
return /* @__PURE__ */ t(
|
|
130
|
-
R,
|
|
131
|
-
{
|
|
132
|
-
...e.props,
|
|
133
|
-
onClose: () => {
|
|
134
|
-
e.props.onClose && e.props.onClose(), i(e.id);
|
|
135
|
-
}
|
|
88
|
+
}, [n]), /* @__PURE__ */ s(G, { children: n.map((e) => {
|
|
89
|
+
var o;
|
|
90
|
+
if (!e.isOpen) return null;
|
|
91
|
+
switch (e.type) {
|
|
92
|
+
case "modal":
|
|
93
|
+
return /* @__PURE__ */ s(
|
|
94
|
+
B,
|
|
95
|
+
{
|
|
96
|
+
...e.props,
|
|
97
|
+
onClose: () => {
|
|
98
|
+
e.props.onClose && e.props.onClose(), a(e.id);
|
|
136
99
|
},
|
|
137
|
-
e.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
100
|
+
description: (o = e.props.description) == null ? void 0 : o.toString()
|
|
101
|
+
},
|
|
102
|
+
e.id
|
|
103
|
+
);
|
|
104
|
+
case "alert":
|
|
105
|
+
return /* @__PURE__ */ s(
|
|
106
|
+
_,
|
|
107
|
+
{
|
|
108
|
+
...e.props,
|
|
109
|
+
onClose: () => {
|
|
110
|
+
e.props.onClose && e.props.onClose(), a(e.id);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
e.id
|
|
114
|
+
);
|
|
115
|
+
case "dialog":
|
|
116
|
+
return /* @__PURE__ */ s(
|
|
117
|
+
V,
|
|
118
|
+
{
|
|
119
|
+
...e.props,
|
|
120
|
+
onClose: () => {
|
|
121
|
+
e.props.onClose && e.props.onClose(), a(e.id);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
e.id
|
|
125
|
+
);
|
|
126
|
+
case "custom":
|
|
127
|
+
return /* @__PURE__ */ s(
|
|
128
|
+
S,
|
|
129
|
+
{
|
|
130
|
+
...e.props,
|
|
131
|
+
onClose: () => {
|
|
132
|
+
e.props.onClose && e.props.onClose(), a(e.id);
|
|
159
133
|
},
|
|
160
|
-
e.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const [a, i] = g(null);
|
|
134
|
+
contents: e.props.contents
|
|
135
|
+
},
|
|
136
|
+
e.id
|
|
137
|
+
);
|
|
138
|
+
default:
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}) });
|
|
142
|
+
}, G = ({ children: n }) => {
|
|
143
|
+
const [t, a] = T(null);
|
|
171
144
|
return m(() => {
|
|
172
|
-
let
|
|
173
|
-
|
|
174
|
-
}, []),
|
|
145
|
+
let e = document.getElementById("portal");
|
|
146
|
+
e || (e = document.createElement("div"), e.id = "portal", document.body.appendChild(e)), a(e);
|
|
147
|
+
}, []), t ? q.createPortal(n, t) : null;
|
|
175
148
|
};
|
|
176
|
-
function
|
|
177
|
-
const { toasts: n } =
|
|
178
|
-
return /* @__PURE__ */ d(
|
|
179
|
-
n.map(function(
|
|
180
|
-
return /* @__PURE__ */
|
|
149
|
+
function z() {
|
|
150
|
+
const { toasts: n } = b();
|
|
151
|
+
return /* @__PURE__ */ d(y, { children: [
|
|
152
|
+
n.map(function(t) {
|
|
153
|
+
return /* @__PURE__ */ s(I, { ...t });
|
|
181
154
|
}),
|
|
182
|
-
/* @__PURE__ */
|
|
155
|
+
/* @__PURE__ */ s(k, {})
|
|
183
156
|
] });
|
|
184
157
|
}
|
|
185
158
|
export {
|
|
186
159
|
Z as ModalManager,
|
|
187
160
|
$ as PortalProvider,
|
|
188
|
-
|
|
161
|
+
z as ToastManager
|
|
189
162
|
};
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -207,8 +207,7 @@ export declare function useMetadata(url: string | null): {
|
|
|
207
207
|
};
|
|
208
208
|
|
|
209
209
|
export declare const usePortal: () => {
|
|
210
|
-
|
|
211
|
-
toast: (props: ToasterProps | string) => string | null;
|
|
210
|
+
confirm: (props: ModalProps) => string | null;
|
|
212
211
|
alert: (props: AlertProps | string) => string | null;
|
|
213
212
|
dialog: (props: DialogProps) => string | null;
|
|
214
213
|
custom: (props: FreeFormProps) => string | null;
|