motile-ui 1.0.3 → 1.0.4
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/components/Drawer/Drawer.js +56 -54
- package/dist/components/Modal/Modal.js +41 -37
- package/dist/components/Sheet/Sheet.js +59 -57
- package/dist/components/Textarea/Textarea.js +48 -44
- package/dist/components/Toast/Toast.js +26 -20
- package/dist/components/Tooltip/Tooltip.js +97 -95
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as u, jsxs as $ } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback as v, useState as S, useEffect as
|
|
2
|
+
import { useCallback as v, useState as S, useEffect as k, useId as F, useRef as x, useMemo as A, createContext as T, useContext as w } from "react";
|
|
3
3
|
import { createPortal as K } from "react-dom";
|
|
4
4
|
import { Slot as g } from "../../utils/Slot.js";
|
|
5
5
|
import { useScrollLock as N } from "../../hooks/useScrollLock.js";
|
|
@@ -8,7 +8,7 @@ import { useEscapeKey as V } from "../../hooks/useEscapeKey.js";
|
|
|
8
8
|
import { useHistoryClose as q } from "../../hooks/useHistoryClose.js";
|
|
9
9
|
import './Sheet.css';/* empty css */
|
|
10
10
|
const I = T(null);
|
|
11
|
-
function
|
|
11
|
+
function _() {
|
|
12
12
|
const e = w(I);
|
|
13
13
|
if (!e)
|
|
14
14
|
throw new Error("Sheet components must be used within Sheet.Root");
|
|
@@ -19,30 +19,30 @@ function z({
|
|
|
19
19
|
defaultValue: n = !1,
|
|
20
20
|
onChange: o
|
|
21
21
|
}) {
|
|
22
|
-
const t = e !== void 0, [
|
|
22
|
+
const t = e !== void 0, [i, a] = S(n), s = t ? e : i, l = v(
|
|
23
23
|
(r) => {
|
|
24
24
|
const f = typeof r == "function" ? r(s) : r;
|
|
25
|
-
t ||
|
|
25
|
+
t || a(f), o == null || o(f);
|
|
26
26
|
},
|
|
27
27
|
[t, o, s]
|
|
28
28
|
);
|
|
29
|
-
return [s,
|
|
29
|
+
return [s, l];
|
|
30
30
|
}
|
|
31
31
|
function B({
|
|
32
32
|
children: e,
|
|
33
33
|
position: n = "right",
|
|
34
34
|
closeOnBackdrop: o = !0,
|
|
35
35
|
maxWidth: t = "600px",
|
|
36
|
-
zIndex:
|
|
37
|
-
open:
|
|
36
|
+
zIndex: i = 1e3,
|
|
37
|
+
open: a,
|
|
38
38
|
defaultOpen: s = !1,
|
|
39
|
-
onOpenChange:
|
|
39
|
+
onOpenChange: l
|
|
40
40
|
}) {
|
|
41
|
-
const r = F().replace(/:/g, ""), f = x(null),
|
|
42
|
-
value:
|
|
41
|
+
const r = F().replace(/:/g, ""), f = x(null), h = x(null), [d, c] = z({
|
|
42
|
+
value: a,
|
|
43
43
|
defaultValue: s,
|
|
44
|
-
onChange:
|
|
45
|
-
}), { isClosingFromHistory:
|
|
44
|
+
onChange: l
|
|
45
|
+
}), { isClosingFromHistory: p, navigateAndClose: y } = q({
|
|
46
46
|
isOpen: d,
|
|
47
47
|
onClose: () => c(!1)
|
|
48
48
|
}), m = A(
|
|
@@ -52,13 +52,13 @@ function B({
|
|
|
52
52
|
position: n,
|
|
53
53
|
closeOnBackdrop: o,
|
|
54
54
|
maxWidth: t,
|
|
55
|
-
zIndex:
|
|
56
|
-
onOpenChange:
|
|
55
|
+
zIndex: i,
|
|
56
|
+
onOpenChange: l,
|
|
57
57
|
triggerId: `${r}-trigger`,
|
|
58
58
|
contentId: `${r}-content`,
|
|
59
59
|
overlayRef: f,
|
|
60
|
-
sheetRef:
|
|
61
|
-
isClosingFromHistory:
|
|
60
|
+
sheetRef: h,
|
|
61
|
+
isClosingFromHistory: p,
|
|
62
62
|
navigateAndClose: y
|
|
63
63
|
}),
|
|
64
64
|
[
|
|
@@ -67,52 +67,54 @@ function B({
|
|
|
67
67
|
n,
|
|
68
68
|
o,
|
|
69
69
|
t,
|
|
70
|
-
a,
|
|
71
70
|
i,
|
|
71
|
+
l,
|
|
72
72
|
r,
|
|
73
73
|
f,
|
|
74
|
-
p,
|
|
75
74
|
h,
|
|
75
|
+
p,
|
|
76
76
|
y
|
|
77
77
|
]
|
|
78
78
|
);
|
|
79
79
|
return /* @__PURE__ */ u(I.Provider, { value: m, children: e });
|
|
80
80
|
}
|
|
81
81
|
function P({ children: e, asChild: n = !1 }) {
|
|
82
|
-
const { open: o, setOpen: t, triggerId:
|
|
83
|
-
t((
|
|
82
|
+
const { open: o, setOpen: t, triggerId: i, contentId: a } = _(), s = v(() => {
|
|
83
|
+
t((l) => !l);
|
|
84
84
|
}, [t]);
|
|
85
85
|
return n ? /* @__PURE__ */ u(
|
|
86
86
|
g,
|
|
87
87
|
{
|
|
88
|
-
id:
|
|
88
|
+
id: i,
|
|
89
89
|
"aria-expanded": o,
|
|
90
|
-
"aria-controls":
|
|
90
|
+
"aria-controls": a,
|
|
91
91
|
onClick: s,
|
|
92
92
|
children: e
|
|
93
93
|
}
|
|
94
94
|
) : /* @__PURE__ */ u(
|
|
95
95
|
"button",
|
|
96
96
|
{
|
|
97
|
-
id:
|
|
97
|
+
id: i,
|
|
98
98
|
type: "button",
|
|
99
99
|
"aria-expanded": o,
|
|
100
|
-
"aria-controls":
|
|
100
|
+
"aria-controls": a,
|
|
101
101
|
onClick: s,
|
|
102
102
|
children: e
|
|
103
103
|
}
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
function j({ children: e, container: n }) {
|
|
107
|
-
const { open: o } =
|
|
108
|
-
return
|
|
107
|
+
const { open: o } = _(), [t, i] = S(!1);
|
|
108
|
+
return k(() => {
|
|
109
|
+
i(!0);
|
|
110
|
+
}, []), !t || !o ? null : K(e, n || document.body);
|
|
109
111
|
}
|
|
110
112
|
function E({ className: e = "", style: n }) {
|
|
111
|
-
const { open: o, setOpen: t, position:
|
|
112
|
-
escapeKey:
|
|
113
|
-
clickOutside:
|
|
113
|
+
const { open: o, setOpen: t, position: i, closeOnBackdrop: a, zIndex: s, overlayRef: l } = _(), [r, f] = S(!1), [h, d] = S(!1), c = typeof a == "boolean" ? { clickOutside: a } : {
|
|
114
|
+
escapeKey: a.escapeKey ?? !1,
|
|
115
|
+
clickOutside: a.clickOutside ?? !1
|
|
114
116
|
};
|
|
115
|
-
|
|
117
|
+
k(() => {
|
|
116
118
|
if (o)
|
|
117
119
|
f(!0);
|
|
118
120
|
else if (r) {
|
|
@@ -122,21 +124,21 @@ function E({ className: e = "", style: n }) {
|
|
|
122
124
|
}, 300);
|
|
123
125
|
return () => clearTimeout(m);
|
|
124
126
|
}
|
|
125
|
-
}, [o, r]),
|
|
127
|
+
}, [o, r]), k(() => {
|
|
126
128
|
if (!r || !o) return;
|
|
127
129
|
const m = requestAnimationFrame(() => {
|
|
128
|
-
const
|
|
130
|
+
const b = requestAnimationFrame(() => {
|
|
129
131
|
d(!0);
|
|
130
132
|
});
|
|
131
|
-
return () => cancelAnimationFrame(
|
|
133
|
+
return () => cancelAnimationFrame(b);
|
|
132
134
|
});
|
|
133
135
|
return () => cancelAnimationFrame(m);
|
|
134
136
|
}, [r, o]);
|
|
135
|
-
const
|
|
137
|
+
const p = v(
|
|
136
138
|
(m) => {
|
|
137
|
-
c.clickOutside && m.target ===
|
|
139
|
+
c.clickOutside && m.target === l.current && t(!1);
|
|
138
140
|
},
|
|
139
|
-
[c.clickOutside, t,
|
|
141
|
+
[c.clickOutside, t, l]
|
|
140
142
|
);
|
|
141
143
|
if (!r)
|
|
142
144
|
return null;
|
|
@@ -147,10 +149,10 @@ function E({ className: e = "", style: n }) {
|
|
|
147
149
|
return /* @__PURE__ */ u(
|
|
148
150
|
"div",
|
|
149
151
|
{
|
|
150
|
-
ref:
|
|
151
|
-
className: `motile-sheet__overlay ${
|
|
152
|
+
ref: l,
|
|
153
|
+
className: `motile-sheet__overlay ${h ? "motile-sheet__overlay--visible" : ""} motile-sheet__overlay--${i} ${e}`,
|
|
152
154
|
style: y,
|
|
153
|
-
onClick:
|
|
155
|
+
onClick: p,
|
|
154
156
|
role: "presentation"
|
|
155
157
|
}
|
|
156
158
|
);
|
|
@@ -158,15 +160,15 @@ function E({ className: e = "", style: n }) {
|
|
|
158
160
|
function L({ children: e, className: n = "", style: o }) {
|
|
159
161
|
const {
|
|
160
162
|
open: t,
|
|
161
|
-
setOpen:
|
|
162
|
-
position:
|
|
163
|
+
setOpen: i,
|
|
164
|
+
position: a,
|
|
163
165
|
closeOnBackdrop: s,
|
|
164
|
-
maxWidth:
|
|
166
|
+
maxWidth: l,
|
|
165
167
|
zIndex: r,
|
|
166
168
|
contentId: f,
|
|
167
|
-
sheetRef:
|
|
169
|
+
sheetRef: h,
|
|
168
170
|
isClosingFromHistory: d
|
|
169
|
-
} =
|
|
171
|
+
} = _(), [c, p] = S(!1), [y, m] = S(!1), b = typeof s == "boolean" ? { escapeKey: s, clickOutside: s } : {
|
|
170
172
|
escapeKey: s.escapeKey ?? !1,
|
|
171
173
|
clickOutside: s.clickOutside ?? !1
|
|
172
174
|
};
|
|
@@ -174,23 +176,23 @@ function L({ children: e, className: n = "", style: o }) {
|
|
|
174
176
|
enabled: t,
|
|
175
177
|
allowedSelectors: [".motile-sheet__body"]
|
|
176
178
|
}), H({
|
|
177
|
-
refs: [
|
|
178
|
-
handler: () =>
|
|
179
|
-
enabled: t &&
|
|
179
|
+
refs: [h],
|
|
180
|
+
handler: () => i(!1),
|
|
181
|
+
enabled: t && b.clickOutside
|
|
180
182
|
}), V({
|
|
181
|
-
handler: () =>
|
|
182
|
-
enabled: t &&
|
|
183
|
-
}),
|
|
183
|
+
handler: () => i(!1),
|
|
184
|
+
enabled: t && b.escapeKey
|
|
185
|
+
}), k(() => {
|
|
184
186
|
if (t)
|
|
185
|
-
|
|
187
|
+
p(!0);
|
|
186
188
|
else if (c) {
|
|
187
189
|
m(!1);
|
|
188
190
|
const C = setTimeout(() => {
|
|
189
|
-
|
|
191
|
+
p(!1);
|
|
190
192
|
}, d ? 0 : 300);
|
|
191
193
|
return () => clearTimeout(C);
|
|
192
194
|
}
|
|
193
|
-
}, [t, c, d]),
|
|
195
|
+
}, [t, c, d]), k(() => {
|
|
194
196
|
if (!c || !t || d) return;
|
|
195
197
|
const O = requestAnimationFrame(() => {
|
|
196
198
|
const C = requestAnimationFrame(() => {
|
|
@@ -202,16 +204,16 @@ function L({ children: e, className: n = "", style: o }) {
|
|
|
202
204
|
}, [c, t, d]), !c)
|
|
203
205
|
return null;
|
|
204
206
|
const R = {
|
|
205
|
-
...
|
|
207
|
+
...l !== "600px" && { "--sheet-max-width": l },
|
|
206
208
|
zIndex: r + 1,
|
|
207
209
|
...o
|
|
208
210
|
};
|
|
209
211
|
return /* @__PURE__ */ u(
|
|
210
212
|
"div",
|
|
211
213
|
{
|
|
212
|
-
ref:
|
|
214
|
+
ref: h,
|
|
213
215
|
id: f,
|
|
214
|
-
className: `motile-sheet__content motile-sheet__content--${
|
|
216
|
+
className: `motile-sheet__content motile-sheet__content--${a} ${y ? "motile-sheet__content--visible" : ""} ${n}`,
|
|
215
217
|
style: R,
|
|
216
218
|
role: "dialog",
|
|
217
219
|
"aria-modal": "true",
|
|
@@ -229,7 +231,7 @@ function W({ children: e, className: n = "" }) {
|
|
|
229
231
|
return /* @__PURE__ */ u("div", { className: `motile-sheet__body ${n}`, children: e });
|
|
230
232
|
}
|
|
231
233
|
function G({ children: e, asChild: n = !1 }) {
|
|
232
|
-
const { setOpen: o } =
|
|
234
|
+
const { setOpen: o } = _(), t = v(() => {
|
|
233
235
|
o(!1);
|
|
234
236
|
}, [o]);
|
|
235
237
|
return n ? /* @__PURE__ */ u(
|
|
@@ -1,70 +1,74 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as Q, useRef as U, useState as V, useMemo as X, useEffect as Z, useLayoutEffect as
|
|
1
|
+
import { jsxs as m, jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Q, useRef as U, useState as V, useMemo as X, useEffect as Z, useLayoutEffect as F } from "react";
|
|
3
3
|
import './Textarea.css';/* empty css */
|
|
4
|
-
const
|
|
4
|
+
const z = Q(
|
|
5
5
|
({
|
|
6
6
|
autoFocus: _ = !1,
|
|
7
|
-
autoSelect:
|
|
7
|
+
autoSelect: R = !1,
|
|
8
8
|
isError: T,
|
|
9
9
|
errorMessage: o,
|
|
10
10
|
className: C,
|
|
11
|
-
value:
|
|
12
|
-
color:
|
|
11
|
+
value: n,
|
|
12
|
+
color: b,
|
|
13
13
|
style: j,
|
|
14
|
-
maxLength:
|
|
15
|
-
label:
|
|
14
|
+
maxLength: f,
|
|
15
|
+
label: l,
|
|
16
16
|
placeholder: v,
|
|
17
17
|
rows: d = 4,
|
|
18
18
|
resize: I = "none",
|
|
19
|
-
autoSize:
|
|
19
|
+
autoSize: s = !1,
|
|
20
20
|
...H
|
|
21
|
-
},
|
|
22
|
-
const
|
|
23
|
-
minRows:
|
|
24
|
-
maxRows:
|
|
25
|
-
} : void 0, [
|
|
21
|
+
}, E) => {
|
|
22
|
+
const S = U(null), i = E || S, [c, W] = V({ height: void 0, isMaxHeight: !1 }), p = T ?? !!o, t = X(() => typeof s == "boolean" ? s ? { minRows: d, maxRows: void 0 } : void 0 : s ? {
|
|
23
|
+
minRows: s.minRows ?? d,
|
|
24
|
+
maxRows: s.maxRows
|
|
25
|
+
} : void 0, [s, d]);
|
|
26
26
|
Z(() => {
|
|
27
27
|
if (_ && i.current) {
|
|
28
|
-
const
|
|
29
|
-
i.current && (i.current.focus(),
|
|
28
|
+
const a = setTimeout(() => {
|
|
29
|
+
i.current && (i.current.focus(), R && i.current.select());
|
|
30
30
|
}, 50);
|
|
31
|
-
return () => clearTimeout(
|
|
31
|
+
return () => clearTimeout(a);
|
|
32
32
|
}
|
|
33
|
-
}, [_,
|
|
33
|
+
}, [_, R]), F(() => {
|
|
34
34
|
if (!t || !i.current) return;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
const a = i.current;
|
|
36
|
+
if (!(n && String(n).length > 0) && c.height === void 0)
|
|
37
|
+
return;
|
|
38
|
+
a.style.height = "auto";
|
|
39
|
+
const J = a.scrollHeight, h = window.getComputedStyle(a), B = parseInt(h.lineHeight, 10), K = parseInt(h.paddingTop, 10), L = parseInt(h.paddingBottom, 10), M = parseInt(h.borderTopWidth, 10), O = parseInt(h.borderBottomWidth, 10), N = K + L + M + O, x = t.minRows ? B * t.minRows + N : void 0, w = t.maxRows ? B * t.maxRows + N : void 0;
|
|
40
|
+
let r = J, u = !1;
|
|
41
|
+
x !== void 0 && r < x && (r = x), w !== void 0 && r > w && (r = w, u = !0), a.style.height = `${r}px`, W(($) => r !== $.height || u !== $.isMaxHeight ? { height: r, isMaxHeight: u } : $);
|
|
42
|
+
}, [n, t]);
|
|
41
43
|
const e = "motile-textarea", k = [
|
|
42
44
|
e,
|
|
43
45
|
p && `${e}--error`,
|
|
44
46
|
p && `${e}--shake`,
|
|
45
|
-
|
|
47
|
+
l && `${e}--with-label`,
|
|
46
48
|
C
|
|
47
49
|
].filter(Boolean).join(" "), D = [
|
|
48
50
|
`${e}-wrapper`,
|
|
49
|
-
|
|
51
|
+
l && `${e}-wrapper--with-label`
|
|
50
52
|
].filter(Boolean).join(" "), P = [
|
|
51
53
|
`${e}__label`,
|
|
52
54
|
p && `${e}__label--error`
|
|
53
|
-
].filter(Boolean).join(" "), Y =
|
|
55
|
+
].filter(Boolean).join(" "), Y = b ? { "--motile-textarea-color": b } : void 0, q = {
|
|
54
56
|
...j,
|
|
55
57
|
resize: t ? "none" : I,
|
|
56
58
|
...t ? {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
// 계산된 후에만 height 적용 (첫 렌더에서는 native rows 사용)
|
|
60
|
+
...c.height !== void 0 && { height: c.height },
|
|
61
|
+
// 계산된 후에만 minHeight 오버라이드
|
|
62
|
+
...c.height !== void 0 && { minHeight: "auto" },
|
|
63
|
+
overflowY: c.isMaxHeight ? "auto" : "hidden"
|
|
60
64
|
} : {}
|
|
61
|
-
}, A =
|
|
65
|
+
}, A = n ? String(n).length : 0, g = f !== void 0, G = [
|
|
62
66
|
H["aria-describedby"],
|
|
63
67
|
o ? `${e}-error` : void 0
|
|
64
68
|
].filter(Boolean).join(" ") || void 0;
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
|
|
69
|
+
return /* @__PURE__ */ m("div", { className: `${e}-root`, children: [
|
|
70
|
+
/* @__PURE__ */ m("div", { className: D, style: Y, children: [
|
|
71
|
+
l && /* @__PURE__ */ y("label", { className: P, children: l }),
|
|
68
72
|
/* @__PURE__ */ y(
|
|
69
73
|
"textarea",
|
|
70
74
|
{
|
|
@@ -72,18 +76,18 @@ const F = Q(
|
|
|
72
76
|
"aria-describedby": G,
|
|
73
77
|
ref: i,
|
|
74
78
|
className: k,
|
|
75
|
-
value:
|
|
76
|
-
maxLength:
|
|
77
|
-
rows: d,
|
|
79
|
+
value: n,
|
|
80
|
+
maxLength: f,
|
|
81
|
+
rows: (t == null ? void 0 : t.minRows) ?? d,
|
|
78
82
|
style: q,
|
|
79
|
-
placeholder:
|
|
83
|
+
placeholder: l ? v || " " : v
|
|
80
84
|
}
|
|
81
85
|
)
|
|
82
86
|
] }),
|
|
83
|
-
(o ||
|
|
87
|
+
(o || g) && /* @__PURE__ */ m(
|
|
84
88
|
"div",
|
|
85
89
|
{
|
|
86
|
-
className: `${e}__helper-text ${o &&
|
|
90
|
+
className: `${e}__helper-text ${o && g ? `${e}__helper-text--both` : o ? `${e}__helper-text--error-only` : `${e}__helper-text--counter-only`}`,
|
|
87
91
|
children: [
|
|
88
92
|
o && /* @__PURE__ */ y(
|
|
89
93
|
"span",
|
|
@@ -94,10 +98,10 @@ const F = Q(
|
|
|
94
98
|
children: o
|
|
95
99
|
}
|
|
96
100
|
),
|
|
97
|
-
|
|
101
|
+
g && /* @__PURE__ */ m("span", { className: `${e}__counter`, children: [
|
|
98
102
|
A,
|
|
99
103
|
"/",
|
|
100
|
-
|
|
104
|
+
f
|
|
101
105
|
] })
|
|
102
106
|
]
|
|
103
107
|
}
|
|
@@ -105,7 +109,7 @@ const F = Q(
|
|
|
105
109
|
] });
|
|
106
110
|
}
|
|
107
111
|
);
|
|
108
|
-
|
|
112
|
+
z.displayName = "Textarea";
|
|
109
113
|
export {
|
|
110
|
-
|
|
114
|
+
z as Textarea
|
|
111
115
|
};
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as w, useEffect as g, useCallback as f, useMemo as p, createContext as L, useContext as y } from "react";
|
|
3
3
|
import { createPortal as I } from "react-dom";
|
|
4
4
|
import './Toast.css';/* empty css */
|
|
5
5
|
const C = L(null);
|
|
6
6
|
function V() {
|
|
7
7
|
const e = y(C);
|
|
8
|
-
if (!e)
|
|
8
|
+
if (!e) {
|
|
9
|
+
if (typeof window > "u")
|
|
10
|
+
return {
|
|
11
|
+
toasts: [],
|
|
12
|
+
addToast: () => ""
|
|
13
|
+
};
|
|
9
14
|
throw new Error("useToastContext must be used within ToastProvider");
|
|
15
|
+
}
|
|
10
16
|
return e;
|
|
11
17
|
}
|
|
12
18
|
function $({ toast: e, onRemove: a }) {
|
|
13
|
-
const [
|
|
19
|
+
const [i, c] = w(!1), l = f(() => {
|
|
14
20
|
c(!0), setTimeout(() => {
|
|
15
21
|
a(e.id);
|
|
16
22
|
}, 250);
|
|
@@ -109,7 +115,7 @@ function $({ toast: e, onRemove: a }) {
|
|
|
109
115
|
) : null, [e.variant]), n = "motile-toast", u = [
|
|
110
116
|
n,
|
|
111
117
|
`${n}--${e.variant}`,
|
|
112
|
-
|
|
118
|
+
i && `${n}--exiting`
|
|
113
119
|
].filter(Boolean).join(" ");
|
|
114
120
|
return /* @__PURE__ */ s(
|
|
115
121
|
"div",
|
|
@@ -127,34 +133,34 @@ function $({ toast: e, onRemove: a }) {
|
|
|
127
133
|
);
|
|
128
134
|
}
|
|
129
135
|
function j({ children: e, zIndex: a = 9999 }) {
|
|
130
|
-
const [
|
|
136
|
+
const [i, c] = w([]), [l, d] = w(!1);
|
|
131
137
|
g(() => {
|
|
132
138
|
d(!0);
|
|
133
139
|
}, []);
|
|
134
|
-
const n =
|
|
135
|
-
(r, m = "default",
|
|
136
|
-
const
|
|
137
|
-
id:
|
|
140
|
+
const n = f(
|
|
141
|
+
(r, m = "default", o) => {
|
|
142
|
+
const v = `toast-${Date.now()}-${Math.random()}`, k = {
|
|
143
|
+
id: v,
|
|
138
144
|
message: r,
|
|
139
145
|
variant: m,
|
|
140
|
-
duration: (
|
|
141
|
-
zIndex:
|
|
146
|
+
duration: (o == null ? void 0 : o.duration) ?? 4e3,
|
|
147
|
+
zIndex: o == null ? void 0 : o.zIndex,
|
|
142
148
|
createdAt: Date.now()
|
|
143
149
|
};
|
|
144
|
-
return c((M) => [
|
|
150
|
+
return c((M) => [k, ...M]), v;
|
|
145
151
|
},
|
|
146
152
|
[]
|
|
147
|
-
), u =
|
|
148
|
-
c((m) => m.filter((
|
|
153
|
+
), u = f((r) => {
|
|
154
|
+
c((m) => m.filter((o) => o.id !== r));
|
|
149
155
|
}, []), h = p(
|
|
150
156
|
() => ({
|
|
151
|
-
toasts:
|
|
157
|
+
toasts: i,
|
|
152
158
|
addToast: n
|
|
153
159
|
}),
|
|
154
|
-
[
|
|
155
|
-
),
|
|
160
|
+
[i, n]
|
|
161
|
+
), x = i.filter(
|
|
156
162
|
(r) => r.zIndex !== void 0
|
|
157
|
-
),
|
|
163
|
+
), T = x.length > 0 ? Math.max(...x.map((r) => r.zIndex)) : a;
|
|
158
164
|
return /* @__PURE__ */ s(C.Provider, { value: h, children: [
|
|
159
165
|
e,
|
|
160
166
|
l && I(
|
|
@@ -164,8 +170,8 @@ function j({ children: e, zIndex: a = 9999 }) {
|
|
|
164
170
|
className: "motile-toast-container",
|
|
165
171
|
"aria-live": "polite",
|
|
166
172
|
"aria-label": "Notifications",
|
|
167
|
-
style: { zIndex:
|
|
168
|
-
children:
|
|
173
|
+
style: { zIndex: T },
|
|
174
|
+
children: i.map((r) => /* @__PURE__ */ t($, { toast: r, onRemove: u }, r.id))
|
|
169
175
|
}
|
|
170
176
|
),
|
|
171
177
|
document.body
|