toast-23 1.0.2 → 2.0.0
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/LICENSE +21 -0
- package/README.md +113 -102
- package/dist/context.d.ts.map +1 -1
- package/dist/devtools.d.ts +24 -0
- package/dist/devtools.d.ts.map +1 -0
- package/dist/headless-store.d.ts +3 -0
- package/dist/headless-store.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1464 -279
- package/dist/index.mjs.map +1 -1
- package/dist/inject-styles.d.ts +13 -0
- package/dist/inject-styles.d.ts.map +1 -0
- package/dist/notification.d.ts +4 -0
- package/dist/notification.d.ts.map +1 -0
- package/dist/provider.d.ts.map +1 -1
- package/dist/sound.d.ts +3 -0
- package/dist/sound.d.ts.map +1 -0
- package/dist/standalone.d.ts +14 -22
- package/dist/standalone.d.ts.map +1 -1
- package/dist/toast-23.css +1 -1
- package/dist/toast-container.d.ts +5 -5
- package/dist/toast-container.d.ts.map +1 -1
- package/dist/toast-item.d.ts +16 -3
- package/dist/toast-item.d.ts.map +1 -1
- package/dist/types.d.ts +137 -39
- package/dist/types.d.ts.map +1 -1
- package/dist/use-toast-headless.d.ts +14 -0
- package/dist/use-toast-headless.d.ts.map +1 -0
- package/dist/use-toast.d.ts.map +1 -1
- package/dist/utils.d.ts +4 -6
- package/dist/utils.d.ts.map +1 -1
- package/package.json +9 -4
package/dist/index.mjs
CHANGED
|
@@ -1,43 +1,48 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as i, jsxs as d, Fragment as st } from "react/jsx-runtime";
|
|
2
|
+
import * as Z from "react";
|
|
3
|
+
import { createContext as Tt, useState as P, useEffect as Y, useRef as Q, useCallback as w, useContext as nt, useReducer as Ct, useMemo as ot, useSyncExternalStore as ft } from "react";
|
|
4
|
+
import { createPortal as St } from "react-dom";
|
|
5
|
+
import { createRoot as At } from "react-dom/client";
|
|
6
|
+
const tt = Tt(null);
|
|
7
|
+
function Et(t, n) {
|
|
8
|
+
switch (n.type) {
|
|
8
9
|
case "ADD":
|
|
9
|
-
return [...
|
|
10
|
+
return [...t, n.toast];
|
|
10
11
|
case "UPSERT":
|
|
11
|
-
return
|
|
12
|
-
(
|
|
13
|
-
...
|
|
14
|
-
...
|
|
15
|
-
version:
|
|
12
|
+
return t.some((a) => a.id === n.toast.id) ? t.map(
|
|
13
|
+
(a) => a.id === n.toast.id ? {
|
|
14
|
+
...a,
|
|
15
|
+
...n.toast,
|
|
16
|
+
version: a.version + 1,
|
|
16
17
|
isExiting: !1
|
|
17
|
-
} :
|
|
18
|
-
) : [...
|
|
18
|
+
} : a
|
|
19
|
+
) : [...t, n.toast];
|
|
19
20
|
case "UPDATE":
|
|
20
|
-
return
|
|
21
|
-
(
|
|
22
|
-
...
|
|
23
|
-
...
|
|
24
|
-
|
|
25
|
-
version: t.version + 1,
|
|
26
|
-
// If the toast was exiting, cancel exit on update
|
|
21
|
+
return t.map(
|
|
22
|
+
(o) => o.id === n.id ? {
|
|
23
|
+
...o,
|
|
24
|
+
...n.updates,
|
|
25
|
+
version: o.version + 1,
|
|
27
26
|
isExiting: !1
|
|
28
|
-
} :
|
|
27
|
+
} : o
|
|
29
28
|
);
|
|
30
29
|
case "DISMISS":
|
|
31
|
-
return
|
|
32
|
-
(
|
|
33
|
-
) :
|
|
30
|
+
return n.id ? t.map(
|
|
31
|
+
(o) => o.id === n.id && !o.isExiting ? { ...o, isExiting: !0 } : o
|
|
32
|
+
) : t.map((o) => o.isExiting ? o : { ...o, isExiting: !0 });
|
|
34
33
|
case "REMOVE":
|
|
35
|
-
return
|
|
34
|
+
return n.id ? t.filter((o) => o.id !== n.id) : [];
|
|
35
|
+
case "DISMISS_GROUP":
|
|
36
|
+
return t.map(
|
|
37
|
+
(o) => o.group === n.group && !o.isExiting ? { ...o, isExiting: !0 } : o
|
|
38
|
+
);
|
|
39
|
+
case "REMOVE_GROUP":
|
|
40
|
+
return t.filter((o) => o.group !== n.group);
|
|
36
41
|
default:
|
|
37
|
-
return
|
|
42
|
+
return t;
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
|
-
const
|
|
45
|
+
const Rt = (t) => /* @__PURE__ */ d(
|
|
41
46
|
"svg",
|
|
42
47
|
{
|
|
43
48
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -45,10 +50,10 @@ const $ = (e) => /* @__PURE__ */ h(
|
|
|
45
50
|
width: "1.25em",
|
|
46
51
|
height: "1.25em",
|
|
47
52
|
fill: "none",
|
|
48
|
-
...
|
|
53
|
+
...t,
|
|
49
54
|
children: [
|
|
50
|
-
/* @__PURE__ */
|
|
51
|
-
/* @__PURE__ */
|
|
55
|
+
/* @__PURE__ */ i("circle", { cx: 12, cy: 12, r: 10, fill: "currentColor" }),
|
|
56
|
+
/* @__PURE__ */ i(
|
|
52
57
|
"path",
|
|
53
58
|
{
|
|
54
59
|
d: "M8 12.5l2.5 2.5 5-5",
|
|
@@ -61,7 +66,7 @@ const $ = (e) => /* @__PURE__ */ h(
|
|
|
61
66
|
)
|
|
62
67
|
]
|
|
63
68
|
}
|
|
64
|
-
),
|
|
69
|
+
), It = (t) => /* @__PURE__ */ d(
|
|
65
70
|
"svg",
|
|
66
71
|
{
|
|
67
72
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -69,10 +74,10 @@ const $ = (e) => /* @__PURE__ */ h(
|
|
|
69
74
|
width: "1.25em",
|
|
70
75
|
height: "1.25em",
|
|
71
76
|
fill: "none",
|
|
72
|
-
...
|
|
77
|
+
...t,
|
|
73
78
|
children: [
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ i("circle", { cx: 12, cy: 12, r: 10, fill: "currentColor" }),
|
|
80
|
+
/* @__PURE__ */ i(
|
|
76
81
|
"line",
|
|
77
82
|
{
|
|
78
83
|
x1: 12,
|
|
@@ -84,10 +89,10 @@ const $ = (e) => /* @__PURE__ */ h(
|
|
|
84
89
|
strokeLinecap: "round"
|
|
85
90
|
}
|
|
86
91
|
),
|
|
87
|
-
/* @__PURE__ */
|
|
92
|
+
/* @__PURE__ */ i("circle", { cx: 12, cy: 16, r: 1, fill: "#fff" })
|
|
88
93
|
]
|
|
89
94
|
}
|
|
90
|
-
),
|
|
95
|
+
), Mt = (t) => /* @__PURE__ */ d(
|
|
91
96
|
"svg",
|
|
92
97
|
{
|
|
93
98
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -95,16 +100,16 @@ const $ = (e) => /* @__PURE__ */ h(
|
|
|
95
100
|
width: "1.25em",
|
|
96
101
|
height: "1.25em",
|
|
97
102
|
fill: "none",
|
|
98
|
-
...
|
|
103
|
+
...t,
|
|
99
104
|
children: [
|
|
100
|
-
/* @__PURE__ */
|
|
105
|
+
/* @__PURE__ */ i(
|
|
101
106
|
"path",
|
|
102
107
|
{
|
|
103
108
|
d: "M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z",
|
|
104
109
|
fill: "currentColor"
|
|
105
110
|
}
|
|
106
111
|
),
|
|
107
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ i(
|
|
108
113
|
"line",
|
|
109
114
|
{
|
|
110
115
|
x1: 12,
|
|
@@ -116,10 +121,10 @@ const $ = (e) => /* @__PURE__ */ h(
|
|
|
116
121
|
strokeLinecap: "round"
|
|
117
122
|
}
|
|
118
123
|
),
|
|
119
|
-
/* @__PURE__ */
|
|
124
|
+
/* @__PURE__ */ i("circle", { cx: 12, cy: 17, r: 1, fill: "#fff" })
|
|
120
125
|
]
|
|
121
126
|
}
|
|
122
|
-
),
|
|
127
|
+
), ct = (t) => /* @__PURE__ */ d(
|
|
123
128
|
"svg",
|
|
124
129
|
{
|
|
125
130
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -127,10 +132,10 @@ const $ = (e) => /* @__PURE__ */ h(
|
|
|
127
132
|
width: "1.25em",
|
|
128
133
|
height: "1.25em",
|
|
129
134
|
fill: "none",
|
|
130
|
-
...
|
|
135
|
+
...t,
|
|
131
136
|
children: [
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
/* @__PURE__ */
|
|
137
|
+
/* @__PURE__ */ i("circle", { cx: 12, cy: 12, r: 10, fill: "currentColor" }),
|
|
138
|
+
/* @__PURE__ */ i(
|
|
134
139
|
"line",
|
|
135
140
|
{
|
|
136
141
|
x1: 12,
|
|
@@ -142,10 +147,10 @@ const $ = (e) => /* @__PURE__ */ h(
|
|
|
142
147
|
strokeLinecap: "round"
|
|
143
148
|
}
|
|
144
149
|
),
|
|
145
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ i("circle", { cx: 12, cy: 8, r: 1, fill: "#fff" })
|
|
146
151
|
]
|
|
147
152
|
}
|
|
148
|
-
),
|
|
153
|
+
), Bt = (t) => /* @__PURE__ */ d(
|
|
149
154
|
"svg",
|
|
150
155
|
{
|
|
151
156
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -157,13 +162,13 @@ const $ = (e) => /* @__PURE__ */ h(
|
|
|
157
162
|
strokeLinejoin: "round",
|
|
158
163
|
width: "0.875em",
|
|
159
164
|
height: "0.875em",
|
|
160
|
-
...
|
|
165
|
+
...t,
|
|
161
166
|
children: [
|
|
162
|
-
/* @__PURE__ */
|
|
163
|
-
/* @__PURE__ */
|
|
167
|
+
/* @__PURE__ */ i("line", { x1: 18, y1: 6, x2: 6, y2: 18 }),
|
|
168
|
+
/* @__PURE__ */ i("line", { x1: 6, y1: 6, x2: 18, y2: 18 })
|
|
164
169
|
]
|
|
165
170
|
}
|
|
166
|
-
),
|
|
171
|
+
), Nt = (t) => /* @__PURE__ */ i(
|
|
167
172
|
"svg",
|
|
168
173
|
{
|
|
169
174
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -176,126 +181,239 @@ const $ = (e) => /* @__PURE__ */ h(
|
|
|
176
181
|
width: "1.25em",
|
|
177
182
|
height: "1.25em",
|
|
178
183
|
className: "toast23-spinner",
|
|
179
|
-
...
|
|
180
|
-
children: /* @__PURE__ */
|
|
184
|
+
...t,
|
|
185
|
+
children: /* @__PURE__ */ i("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
|
|
181
186
|
}
|
|
182
187
|
);
|
|
183
|
-
let
|
|
184
|
-
function
|
|
185
|
-
return `t23-${++
|
|
188
|
+
let Pt = 0;
|
|
189
|
+
function rt() {
|
|
190
|
+
return `t23-${++Pt}-${Math.random().toString(36).slice(2, 9)}`;
|
|
191
|
+
}
|
|
192
|
+
function W(...t) {
|
|
193
|
+
return t.filter(Boolean).join(" ");
|
|
186
194
|
}
|
|
187
|
-
function
|
|
188
|
-
return
|
|
195
|
+
function Dt(t) {
|
|
196
|
+
return t.endsWith("right") ? 1 : t.endsWith("left") ? -1 : 0;
|
|
189
197
|
}
|
|
190
|
-
const
|
|
191
|
-
success:
|
|
192
|
-
error:
|
|
193
|
-
warning:
|
|
194
|
-
info:
|
|
195
|
-
default:
|
|
196
|
-
loading:
|
|
197
|
-
},
|
|
198
|
-
({
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
198
|
+
const Lt = {
|
|
199
|
+
success: Rt,
|
|
200
|
+
error: It,
|
|
201
|
+
warning: Mt,
|
|
202
|
+
info: ct,
|
|
203
|
+
default: ct,
|
|
204
|
+
loading: Nt
|
|
205
|
+
}, $t = 200, it = 180, pt = Z.memo(
|
|
206
|
+
({
|
|
207
|
+
toast: t,
|
|
208
|
+
onDismiss: n,
|
|
209
|
+
onRemove: o,
|
|
210
|
+
globallyPaused: a,
|
|
211
|
+
swipeEnabled: p,
|
|
212
|
+
swipeThreshold: m,
|
|
213
|
+
stackIndex: E,
|
|
214
|
+
stackMode: f,
|
|
215
|
+
stackExpanded: y,
|
|
216
|
+
stackIsBottom: B,
|
|
217
|
+
dir: G
|
|
218
|
+
}) => {
|
|
219
|
+
const [k, R] = P(!1);
|
|
220
|
+
Y(() => {
|
|
221
|
+
const x = requestAnimationFrame(() => R(!0));
|
|
222
|
+
return () => cancelAnimationFrame(x);
|
|
223
|
+
}, []), Y(() => {
|
|
224
|
+
if (!t.isExiting) return;
|
|
225
|
+
const x = setTimeout(() => o(t.id), t.removeDelay);
|
|
226
|
+
return () => clearTimeout(x);
|
|
227
|
+
}, [t.isExiting, t.id, t.removeDelay, o]);
|
|
228
|
+
const [b, T] = P(!1), C = b || a, [M, N] = P(1), [v, h] = P("none");
|
|
229
|
+
Y(() => {
|
|
230
|
+
N(1), h("none");
|
|
231
|
+
}, [t.version, t.duration]);
|
|
232
|
+
const S = typeof t.progress == "number";
|
|
233
|
+
Y(() => {
|
|
234
|
+
S && (h("transform 120ms linear"), N(t.progress ?? 0));
|
|
235
|
+
}, [t.progress, S]), Y(() => {
|
|
236
|
+
if (S || t.duration <= 0 || t.variant === "loading" || !k || t.isExiting)
|
|
213
237
|
return;
|
|
214
|
-
if (
|
|
215
|
-
|
|
238
|
+
if (C) {
|
|
239
|
+
h(`transform ${$t}ms ease-out`), N(1);
|
|
216
240
|
return;
|
|
217
241
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
242
|
+
h("none"), N(1);
|
|
243
|
+
const x = requestAnimationFrame(() => {
|
|
244
|
+
h(`transform ${t.duration}ms linear`), N(0);
|
|
245
|
+
}), $ = setTimeout(() => n(t.id), t.duration);
|
|
246
|
+
return () => {
|
|
247
|
+
cancelAnimationFrame(x), clearTimeout($);
|
|
248
|
+
};
|
|
225
249
|
}, [
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
250
|
+
C,
|
|
251
|
+
k,
|
|
252
|
+
t.isExiting,
|
|
253
|
+
t.duration,
|
|
254
|
+
t.variant,
|
|
255
|
+
t.id,
|
|
256
|
+
t.version,
|
|
257
|
+
S,
|
|
258
|
+
n
|
|
233
259
|
]);
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
),
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
260
|
+
const u = Q({
|
|
261
|
+
startX: 0,
|
|
262
|
+
startY: 0,
|
|
263
|
+
dx: 0,
|
|
264
|
+
isDragging: !1,
|
|
265
|
+
pointerId: -1
|
|
266
|
+
}), [s, c] = P(0), [A, I] = P(""), _ = Dt(t.position), j = w(
|
|
267
|
+
(x) => {
|
|
268
|
+
!p || x.button !== void 0 && x.button !== 0 || x.target.closest("button") || (u.current.startX = x.clientX, u.current.startY = x.clientY, u.current.dx = 0, u.current.isDragging = !0, u.current.pointerId = x.pointerId, I(""));
|
|
269
|
+
},
|
|
270
|
+
[p]
|
|
271
|
+
), z = w(
|
|
272
|
+
(x) => {
|
|
273
|
+
if (!u.current.isDragging || x.pointerId !== u.current.pointerId) return;
|
|
274
|
+
const $ = x.clientX - u.current.startX, V = x.clientY - u.current.startY;
|
|
275
|
+
if (Math.abs(V) > Math.abs($) && Math.abs(V) > 10) return;
|
|
276
|
+
const lt = _ === 0 ? $ : _ === 1 ? Math.max(0, $) : Math.min(0, $);
|
|
277
|
+
u.current.dx = lt, c(lt);
|
|
278
|
+
},
|
|
279
|
+
[_]
|
|
280
|
+
), q = w(
|
|
281
|
+
(x) => {
|
|
282
|
+
if (!u.current.isDragging || x.pointerId !== u.current.pointerId) return;
|
|
283
|
+
u.current.isDragging = !1;
|
|
284
|
+
const $ = u.current.dx;
|
|
285
|
+
Math.abs($) >= m ? (I(
|
|
286
|
+
`transform ${it}ms ease-out, opacity ${it}ms ease-out`
|
|
287
|
+
), c($ > 0 ? window.innerWidth : -window.innerWidth), setTimeout(() => n(t.id), it)) : (I("transform 180ms ease-out"), c(0));
|
|
288
|
+
},
|
|
289
|
+
[m, n, t.id]
|
|
290
|
+
), F = 10, r = 0.06, O = Math.min(E, 3), K = (() => {
|
|
291
|
+
if (!f || y) return "";
|
|
292
|
+
const $ = (B ? 1 : -1) * O * F, V = 1 - O * r;
|
|
293
|
+
return `translateY(${$}px) scale(${V})`;
|
|
294
|
+
})(), H = f && !y && O > 0 ? Math.max(0.4, 1 - O * 0.25) : void 0, U = s !== 0 ? `translateX(${s}px)` : K, l = s !== 0 ? Math.max(0, 1 - Math.abs(s) / (m * 2)) : void 0, e = w(() => T(!0), []), g = w(() => T(!1), []), D = Lt[t.variant] ?? ct, L = w(
|
|
295
|
+
() => n(t.id),
|
|
296
|
+
[n, t.id]
|
|
297
|
+
), xt = w(() => {
|
|
298
|
+
if (!t.action) return;
|
|
299
|
+
const x = t.action.dismissOnClick !== !1;
|
|
300
|
+
t.action.onClick(L), x && L();
|
|
301
|
+
}, [t.action, L]), wt = w(() => {
|
|
302
|
+
if (!t.cancelAction) return;
|
|
303
|
+
const x = t.cancelAction.dismissOnClick !== !1;
|
|
304
|
+
t.cancelAction.onClick(L), x && L();
|
|
305
|
+
}, [t.cancelAction, L]);
|
|
306
|
+
if (t.isCustom)
|
|
307
|
+
return /* @__PURE__ */ i(
|
|
308
|
+
"div",
|
|
309
|
+
{
|
|
310
|
+
className: W(
|
|
311
|
+
"toast23-item toast23-item--custom",
|
|
312
|
+
!k && "toast23-item--entering",
|
|
313
|
+
t.isExiting && "toast23-item--exiting"
|
|
314
|
+
),
|
|
315
|
+
role: "status",
|
|
316
|
+
"aria-live": "polite",
|
|
317
|
+
"aria-atomic": "true",
|
|
318
|
+
style: {
|
|
319
|
+
transform: U || void 0,
|
|
320
|
+
opacity: l ?? H,
|
|
321
|
+
transition: A || void 0,
|
|
322
|
+
pointerEvents: f && !y && O > 0 ? "none" : void 0
|
|
323
|
+
},
|
|
324
|
+
onMouseEnter: e,
|
|
325
|
+
onMouseLeave: g,
|
|
326
|
+
onPointerDown: j,
|
|
327
|
+
onPointerMove: z,
|
|
328
|
+
onPointerUp: q,
|
|
329
|
+
onPointerCancel: q,
|
|
330
|
+
children: t.message
|
|
331
|
+
}
|
|
332
|
+
);
|
|
333
|
+
const kt = !!(t.action && t.cancelAction);
|
|
334
|
+
return /* @__PURE__ */ d(
|
|
251
335
|
"div",
|
|
252
336
|
{
|
|
253
|
-
className:
|
|
337
|
+
className: W(
|
|
254
338
|
"toast23-item",
|
|
255
|
-
`toast23-item--${
|
|
256
|
-
!
|
|
257
|
-
|
|
339
|
+
`toast23-item--${t.variant}`,
|
|
340
|
+
!k && "toast23-item--entering",
|
|
341
|
+
t.isExiting && "toast23-item--exiting",
|
|
342
|
+
f && "toast23-item--stack",
|
|
343
|
+
kt && "toast23-item--confirm"
|
|
258
344
|
),
|
|
259
|
-
role: "alert",
|
|
260
|
-
"aria-live":
|
|
345
|
+
role: t.variant === "error" ? "alert" : "status",
|
|
346
|
+
"aria-live": t.variant === "error" ? "assertive" : "polite",
|
|
261
347
|
"aria-atomic": "true",
|
|
262
|
-
|
|
263
|
-
|
|
348
|
+
style: {
|
|
349
|
+
transform: U || void 0,
|
|
350
|
+
opacity: l ?? H,
|
|
351
|
+
transition: A || void 0
|
|
352
|
+
},
|
|
353
|
+
onMouseEnter: e,
|
|
354
|
+
onMouseLeave: g,
|
|
355
|
+
onPointerDown: j,
|
|
356
|
+
onPointerMove: z,
|
|
357
|
+
onPointerUp: q,
|
|
358
|
+
onPointerCancel: q,
|
|
264
359
|
children: [
|
|
265
|
-
/* @__PURE__ */
|
|
266
|
-
/* @__PURE__ */
|
|
267
|
-
|
|
268
|
-
/* @__PURE__ */
|
|
360
|
+
/* @__PURE__ */ i("span", { className: W("toast23-icon", `toast23-icon--${t.variant}`), children: /* @__PURE__ */ i(D, {}) }),
|
|
361
|
+
/* @__PURE__ */ d("div", { className: "toast23-content", children: [
|
|
362
|
+
t.title && /* @__PURE__ */ i("div", { className: "toast23-title", children: t.title }),
|
|
363
|
+
/* @__PURE__ */ i(
|
|
269
364
|
"div",
|
|
270
365
|
{
|
|
271
|
-
className:
|
|
366
|
+
className: W(
|
|
272
367
|
"toast23-message",
|
|
273
|
-
|
|
368
|
+
t.title && "toast23-message--with-title"
|
|
274
369
|
),
|
|
275
|
-
children:
|
|
370
|
+
children: t.message
|
|
371
|
+
}
|
|
372
|
+
)
|
|
373
|
+
] }),
|
|
374
|
+
(t.action || t.cancelAction) && /* @__PURE__ */ d("div", { className: "toast23-actions", children: [
|
|
375
|
+
t.cancelAction && /* @__PURE__ */ i(
|
|
376
|
+
"button",
|
|
377
|
+
{
|
|
378
|
+
type: "button",
|
|
379
|
+
className: W(
|
|
380
|
+
"toast23-action toast23-action--cancel",
|
|
381
|
+
t.cancelAction.className
|
|
382
|
+
),
|
|
383
|
+
onClick: wt,
|
|
384
|
+
children: t.cancelAction.label
|
|
385
|
+
}
|
|
386
|
+
),
|
|
387
|
+
t.action && /* @__PURE__ */ i(
|
|
388
|
+
"button",
|
|
389
|
+
{
|
|
390
|
+
type: "button",
|
|
391
|
+
className: W("toast23-action", t.action.className),
|
|
392
|
+
onClick: xt,
|
|
393
|
+
children: t.action.label
|
|
276
394
|
}
|
|
277
395
|
)
|
|
278
396
|
] }),
|
|
279
|
-
|
|
397
|
+
t.dismissible && /* @__PURE__ */ i(
|
|
280
398
|
"button",
|
|
281
399
|
{
|
|
282
400
|
type: "button",
|
|
283
401
|
className: "toast23-dismiss",
|
|
284
|
-
onClick: () =>
|
|
402
|
+
onClick: () => n(t.id),
|
|
285
403
|
"aria-label": "Dismiss notification",
|
|
286
|
-
children: /* @__PURE__ */
|
|
404
|
+
children: /* @__PURE__ */ i(Bt, {})
|
|
287
405
|
}
|
|
288
406
|
),
|
|
289
|
-
|
|
407
|
+
(t.duration > 0 || S) && t.variant !== "loading" && /* @__PURE__ */ i(
|
|
290
408
|
"div",
|
|
291
409
|
{
|
|
292
|
-
className:
|
|
410
|
+
className: W(
|
|
293
411
|
"toast23-progress",
|
|
294
|
-
`toast23-progress--${
|
|
412
|
+
`toast23-progress--${t.variant}`
|
|
295
413
|
),
|
|
296
414
|
style: {
|
|
297
|
-
|
|
298
|
-
transition:
|
|
415
|
+
transform: `scaleX(${M})`,
|
|
416
|
+
transition: v
|
|
299
417
|
}
|
|
300
418
|
}
|
|
301
419
|
)
|
|
@@ -304,33 +422,55 @@ const F = {
|
|
|
304
422
|
);
|
|
305
423
|
}
|
|
306
424
|
);
|
|
307
|
-
|
|
308
|
-
const
|
|
309
|
-
({ position:
|
|
310
|
-
const
|
|
311
|
-
if (!
|
|
312
|
-
const
|
|
313
|
-
if (
|
|
314
|
-
const
|
|
315
|
-
return /* @__PURE__ */
|
|
425
|
+
pt.displayName = "ToastItem";
|
|
426
|
+
const mt = Z.memo(
|
|
427
|
+
({ position: t, toasts: n, maxVisible: o, layout: a, dir: p, theme: m, inline: E }) => {
|
|
428
|
+
const f = nt(tt), [y, B] = P(!1), G = w(() => B(!0), []), k = w(() => B(!1), []);
|
|
429
|
+
if (!f) return null;
|
|
430
|
+
const R = n.filter((v) => !v.isExiting), b = n.filter((v) => v.isExiting), T = [...R.slice(0, o), ...b], C = Math.max(0, R.length - o);
|
|
431
|
+
if (T.length === 0) return null;
|
|
432
|
+
const M = a === "stack", N = t.startsWith("bottom");
|
|
433
|
+
return /* @__PURE__ */ d(
|
|
316
434
|
"div",
|
|
317
435
|
{
|
|
318
|
-
className:
|
|
436
|
+
className: W(
|
|
437
|
+
"toast23-container",
|
|
438
|
+
`toast23-container--${t}`,
|
|
439
|
+
M && "toast23-container--stack",
|
|
440
|
+
M && y && "toast23-container--expanded",
|
|
441
|
+
E && "toast23-container--inline",
|
|
442
|
+
p === "rtl" && "toast23-container--rtl",
|
|
443
|
+
m === "dark" && "toast23-container--dark",
|
|
444
|
+
m === "light" && "toast23-container--light"
|
|
445
|
+
),
|
|
446
|
+
dir: p,
|
|
319
447
|
"aria-label": "Notifications",
|
|
320
448
|
role: "region",
|
|
449
|
+
tabIndex: -1,
|
|
450
|
+
"data-toast23-region": "true",
|
|
451
|
+
onMouseEnter: M ? G : void 0,
|
|
452
|
+
onMouseLeave: M ? k : void 0,
|
|
321
453
|
children: [
|
|
322
|
-
|
|
323
|
-
|
|
454
|
+
T.map((v, h) => /* @__PURE__ */ i(
|
|
455
|
+
pt,
|
|
324
456
|
{
|
|
325
|
-
toast:
|
|
326
|
-
|
|
327
|
-
|
|
457
|
+
toast: v,
|
|
458
|
+
stackIndex: M ? h : 0,
|
|
459
|
+
stackMode: M,
|
|
460
|
+
stackExpanded: y,
|
|
461
|
+
stackIsBottom: N,
|
|
462
|
+
dir: p,
|
|
463
|
+
onDismiss: f.dismissToast,
|
|
464
|
+
onRemove: f.removeToast,
|
|
465
|
+
globallyPaused: f.isPausedGlobally,
|
|
466
|
+
swipeEnabled: f.config.swipeEnabled,
|
|
467
|
+
swipeThreshold: f.config.swipeThreshold
|
|
328
468
|
},
|
|
329
|
-
|
|
469
|
+
v.id
|
|
330
470
|
)),
|
|
331
|
-
|
|
471
|
+
C > 0 && /* @__PURE__ */ d("div", { className: "toast23-queue-badge", "aria-live": "polite", children: [
|
|
332
472
|
"+",
|
|
333
|
-
|
|
473
|
+
C,
|
|
334
474
|
" more"
|
|
335
475
|
] })
|
|
336
476
|
]
|
|
@@ -338,71 +478,291 @@ const M = T.memo(
|
|
|
338
478
|
);
|
|
339
479
|
}
|
|
340
480
|
);
|
|
341
|
-
|
|
342
|
-
const V = [
|
|
481
|
+
mt.displayName = "ToastContainer";
|
|
482
|
+
const Gt = ':root{--toast23-z: 9999;--toast23-min-width: 320px;--toast23-max-width: 26rem;--toast23-radius: .75rem;--toast23-gap: .75rem;--toast23-padding: .875rem 1rem;--toast23-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;--toast23-shadow: 0 4px 6px -1px rgba(0, 0, 0, .08), 0 2px 4px -2px rgba(0, 0, 0, .05);--toast23-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -4px rgba(0, 0, 0, .06);--toast23-bg-default: rgba(249, 250, 251, .95);--toast23-bg-success: rgba(240, 253, 244, .95);--toast23-bg-error: rgba(254, 242, 242, .95);--toast23-bg-warning: rgba(254, 252, 232, .95);--toast23-bg-info: rgba(239, 246, 255, .95);--toast23-border-default: #e5e7eb;--toast23-border-success: #bbf7d0;--toast23-border-error: #fecaca;--toast23-border-warning: #fef08a;--toast23-border-info: #bfdbfe;--toast23-color-success: #22c55e;--toast23-color-error: #ef4444;--toast23-color-warning: #eab308;--toast23-color-info: #3b82f6;--toast23-color-default: #6b7280;--toast23-color-loading: #3b82f6;--toast23-text-title: #111827;--toast23-text-body: #1f2937;--toast23-text-muted: #6b7280;--toast23-action-bg: rgba(0, 0, 0, .06);--toast23-action-bg-hover: rgba(0, 0, 0, .1);--toast23-action-text: #111827;--toast23-cancel-bg: #d1d5db;--toast23-cancel-bg-hover: #9ca3af;--toast23-cancel-text: #111827;--toast23-queue-bg: rgba(255, 255, 255, .8);--toast23-enter-duration: .3s;--toast23-exit-duration: .3s;--toast23-easing: cubic-bezier(.4, 0, .2, 1)}.toast23-container,.toast23-container *,.toast23-container *:before,.toast23-container *:after{box-sizing:border-box;margin:0;padding:0}.toast23-container{position:fixed;z-index:var(--toast23-z);display:flex;flex-direction:column;gap:var(--toast23-gap);padding:1rem;pointer-events:none;max-height:100vh;overflow:visible}.toast23-container--inline{position:absolute;inset:0;height:100%;pointer-events:none}.toast23-container--top-right{top:0;right:0}.toast23-container--top-left{top:0;left:0}.toast23-container--top-center{top:0;left:50%;transform:translate(-50%);align-items:center}.toast23-container--bottom-right{bottom:0;right:0;flex-direction:column-reverse}.toast23-container--bottom-left{bottom:0;left:0;flex-direction:column-reverse}.toast23-container--bottom-center{bottom:0;left:50%;transform:translate(-50%);flex-direction:column-reverse;align-items:center}.toast23-container--rtl.toast23-container--top-right,.toast23-container--rtl.toast23-container--bottom-right{right:auto;left:0}.toast23-container--rtl.toast23-container--top-left,.toast23-container--rtl.toast23-container--bottom-left{left:auto;right:0}.toast23-item{pointer-events:auto;position:relative;display:flex;align-items:flex-start;gap:.75rem;min-width:var(--toast23-min-width);max-width:var(--toast23-max-width);padding:var(--toast23-padding);border-radius:var(--toast23-radius);overflow:hidden;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);font-family:var(--toast23-font);line-height:1.5;box-shadow:inset 0 0 0 1px var(--toast23-item-border, transparent),var(--toast23-shadow);transform:translate(0);opacity:1;transition:transform var(--toast23-enter-duration) var(--toast23-easing),opacity var(--toast23-enter-duration) var(--toast23-easing),box-shadow .15s ease;cursor:default;touch-action:pan-y}.toast23-item:hover{box-shadow:inset 0 0 0 1px var(--toast23-item-border, transparent),var(--toast23-shadow-hover)}.toast23-container--top-right .toast23-item--entering,.toast23-container--top-right .toast23-item--exiting,.toast23-container--bottom-right .toast23-item--entering,.toast23-container--bottom-right .toast23-item--exiting{transform:translate(calc(100% + 1rem));opacity:0}.toast23-container--top-left .toast23-item--entering,.toast23-container--top-left .toast23-item--exiting,.toast23-container--bottom-left .toast23-item--entering,.toast23-container--bottom-left .toast23-item--exiting{transform:translate(calc(-100% - 1rem));opacity:0}.toast23-container--top-center .toast23-item--entering,.toast23-container--top-center .toast23-item--exiting{transform:translateY(-100%);opacity:0}.toast23-container--bottom-center .toast23-item--entering,.toast23-container--bottom-center .toast23-item--exiting{transform:translateY(100%);opacity:0}.toast23-container--stack .toast23-item--stack{transition:transform .25s var(--toast23-easing),opacity .25s var(--toast23-easing),box-shadow .15s ease}.toast23-item--success{background:var(--toast23-bg-success);--toast23-item-border: var(--toast23-border-success)}.toast23-item--error{background:var(--toast23-bg-error);--toast23-item-border: var(--toast23-border-error)}.toast23-item--warning{background:var(--toast23-bg-warning);--toast23-item-border: var(--toast23-border-warning)}.toast23-item--info{background:var(--toast23-bg-info);--toast23-item-border: var(--toast23-border-info)}.toast23-item--default,.toast23-item--loading{background:var(--toast23-bg-default);--toast23-item-border: var(--toast23-border-default)}@media(prefers-color-scheme:dark){:root{--toast23-bg-default: rgba(55, 65, 81, .5);--toast23-bg-success: rgba(22, 101, 52, .25);--toast23-bg-error: rgba(153, 27, 27, .25);--toast23-bg-warning: rgba(133, 77, 14, .25);--toast23-bg-info: rgba(30, 64, 175, .25);--toast23-border-default: #4b5563;--toast23-border-success: #166534;--toast23-border-error: #991b1b;--toast23-border-warning: #854d0e;--toast23-border-info: #1e40af;--toast23-text-title: #f9fafb;--toast23-text-body: #e5e7eb;--toast23-text-muted: #d1d5db;--toast23-action-bg: rgba(255, 255, 255, .08);--toast23-action-bg-hover: rgba(255, 255, 255, .15);--toast23-action-text: #f9fafb;--toast23-cancel-bg: #374151;--toast23-cancel-bg-hover: #4b5563;--toast23-cancel-text: #f9fafb;--toast23-queue-bg: rgba(55, 65, 81, .7)}}.dark,.toast23-container--dark{--toast23-bg-default: rgba(55, 65, 81, .5);--toast23-bg-success: rgba(22, 101, 52, .25);--toast23-bg-error: rgba(153, 27, 27, .25);--toast23-bg-warning: rgba(133, 77, 14, .25);--toast23-bg-info: rgba(30, 64, 175, .25);--toast23-border-default: #4b5563;--toast23-border-success: #166534;--toast23-border-error: #991b1b;--toast23-border-warning: #854d0e;--toast23-border-info: #1e40af;--toast23-text-title: #f9fafb;--toast23-text-body: #e5e7eb;--toast23-text-muted: #d1d5db;--toast23-action-bg: rgba(255, 255, 255, .08);--toast23-action-bg-hover: rgba(255, 255, 255, .15);--toast23-action-text: #f9fafb;--toast23-cancel-bg: #374151;--toast23-cancel-bg-hover: #4b5563;--toast23-cancel-text: #f9fafb;--toast23-queue-bg: rgba(55, 65, 81, .7)}.toast23-container--light{--toast23-bg-default: rgba(249, 250, 251, .95);--toast23-bg-success: rgba(240, 253, 244, .95);--toast23-bg-error: rgba(254, 242, 242, .95);--toast23-bg-warning: rgba(254, 252, 232, .95);--toast23-bg-info: rgba(239, 246, 255, .95);--toast23-border-default: #e5e7eb;--toast23-border-success: #bbf7d0;--toast23-border-error: #fecaca;--toast23-border-warning: #fef08a;--toast23-border-info: #bfdbfe;--toast23-text-title: #111827;--toast23-text-body: #1f2937;--toast23-text-muted: #6b7280;--toast23-action-bg: rgba(0, 0, 0, .06);--toast23-action-bg-hover: rgba(0, 0, 0, .1);--toast23-action-text: #111827;--toast23-cancel-bg: #d1d5db;--toast23-cancel-bg-hover: #9ca3af;--toast23-cancel-text: #111827;--toast23-queue-bg: rgba(255, 255, 255, .8)}.toast23-icon{display:flex;align-items:center;flex-shrink:0;margin-top:1px}.toast23-icon--success{color:var(--toast23-color-success)}.toast23-icon--error{color:var(--toast23-color-error)}.toast23-icon--warning{color:var(--toast23-color-warning)}.toast23-icon--info{color:var(--toast23-color-info)}.toast23-icon--default{color:var(--toast23-color-default)}.toast23-icon--loading{color:var(--toast23-color-loading)}.toast23-content{flex:1;min-width:0}.toast23-title{font-size:.875rem;font-weight:600;color:var(--toast23-text-title);margin-bottom:.125rem;line-height:1.3}.toast23-message{font-size:.875rem;font-weight:500;color:var(--toast23-text-body);word-break:break-word}.toast23-message--with-title{color:var(--toast23-text-muted);font-weight:400}.toast23-actions{display:flex;gap:.375rem;align-items:center;flex-shrink:0;margin-left:.25rem}.toast23-item--confirm{flex-wrap:wrap;padding-right:2.5rem}.toast23-item--confirm .toast23-dismiss{position:absolute;top:.5rem;right:.5rem;margin:0}.toast23-item--confirm .toast23-actions{flex-basis:100%;margin-left:0;margin-top:.625rem;gap:.5rem;justify-content:stretch}.toast23-item--confirm .toast23-action{flex:1 1 0;justify-content:center;padding:.5rem .85rem;font-size:.875rem}.toast23-action{display:inline-flex;align-items:center;justify-content:center;padding:.3rem .65rem;border:none;background:var(--toast23-action-bg);color:var(--toast23-action-text);font:600 .8125rem var(--toast23-font);border-radius:.375rem;cursor:pointer;transition:background-color .15s ease;white-space:nowrap}.toast23-action:hover{background:var(--toast23-action-bg-hover)}.toast23-action:focus-visible{outline:2px solid var(--toast23-color-info);outline-offset:1px}.toast23-action--cancel{background:var(--toast23-cancel-bg);color:var(--toast23-cancel-text);font-weight:600}.toast23-action--cancel:hover{background:var(--toast23-cancel-bg-hover)}.toast23-action--confirm{background:var(--toast23-color-info);color:#fff;box-shadow:0 1px 2px #00000014,0 0 0 1px #0000000d}.toast23-action--confirm:hover{filter:brightness(1.08)}.toast23-action--confirm:active{filter:brightness(.95)}.toast23-dismiss{display:flex;align-items:center;justify-content:center;flex-shrink:0;width:1.5rem;height:1.5rem;border:none;background:transparent;color:var(--toast23-text-muted);cursor:pointer;border-radius:.25rem;transition:color .15s ease,background-color .15s ease;margin:-.125rem -.25rem 0 0;padding:0}.toast23-dismiss:hover{color:var(--toast23-text-title);background:#0000000d}.toast23-dismiss:focus-visible{outline:2px solid var(--toast23-color-info);outline-offset:1px}.toast23-progress{position:absolute;bottom:0;left:0;width:100%;height:3.5px;transform-origin:left center;will-change:transform;border-radius:0 0 0 var(--toast23-radius)}.toast23-container--rtl .toast23-progress{transform-origin:right center;left:auto;right:0;border-radius:0 0 var(--toast23-radius) 0}.toast23-progress--success{background:var(--toast23-color-success)}.toast23-progress--error{background:var(--toast23-color-error)}.toast23-progress--warning{background:var(--toast23-color-warning)}.toast23-progress--info{background:var(--toast23-color-info)}.toast23-progress--default{background:var(--toast23-color-default)}.toast23-queue-badge{font-family:inherit;font-size:.75rem;font-weight:500;color:var(--toast23-text-muted);background:var(--toast23-queue-bg);border:1px solid var(--toast23-border-default);border-radius:9999px;padding:.25rem .75rem;text-align:center;pointer-events:none;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.toast23-spinner{animation:toast23-spin .7s linear infinite}@keyframes toast23-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.toast23-item,.toast23-item--entering,.toast23-item--exiting,.toast23-progress{transition-duration:1ms!important;transform:none!important}.toast23-item--entering,.toast23-item--exiting{opacity:0}.toast23-spinner{animation:none}}@media(max-width:480px){.toast23-container{padding:.75rem;left:0!important;right:0!important}.toast23-item{min-width:0;max-width:100%}}', dt = "data-toast23-styles";
|
|
483
|
+
function bt() {
|
|
484
|
+
if (typeof document > "u" || document.querySelector(`style[${dt}]`)) return;
|
|
485
|
+
const t = document.createElement("style");
|
|
486
|
+
t.setAttribute(dt, ""), t.textContent = Gt, document.head.appendChild(t);
|
|
487
|
+
}
|
|
488
|
+
let et = null;
|
|
489
|
+
function qt() {
|
|
490
|
+
if (typeof window > "u") return null;
|
|
491
|
+
if (et) return et;
|
|
492
|
+
const t = window.AudioContext ?? window.webkitAudioContext;
|
|
493
|
+
if (!t) return null;
|
|
494
|
+
try {
|
|
495
|
+
return et = new t(), et;
|
|
496
|
+
} catch {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
const Ot = {
|
|
501
|
+
// Cheerful two-note rise.
|
|
502
|
+
success: [
|
|
503
|
+
{ freq: 660, ms: 90, gain: 0.18, type: "sine" },
|
|
504
|
+
{ freq: 880, ms: 130, gain: 0.18, type: "sine" }
|
|
505
|
+
],
|
|
506
|
+
// Descending "uh-oh" — triangle gives richer harmonics so it cuts through.
|
|
507
|
+
error: [
|
|
508
|
+
{ freq: 622, ms: 140, gain: 0.3, type: "triangle" },
|
|
509
|
+
{ freq: 415, ms: 220, gain: 0.3, type: "triangle" }
|
|
510
|
+
],
|
|
511
|
+
// Quick double pulse — alert feel.
|
|
512
|
+
warning: [
|
|
513
|
+
{ freq: 880, ms: 110, gain: 0.24, type: "triangle" },
|
|
514
|
+
{ freq: 880, ms: 110, gain: 0.24, type: "triangle" }
|
|
515
|
+
],
|
|
516
|
+
// Soft single chime.
|
|
517
|
+
info: [{ freq: 784, ms: 130, gain: 0.18, type: "sine" }],
|
|
518
|
+
default: [{ freq: 660, ms: 100, gain: 0.16, type: "sine" }],
|
|
519
|
+
loading: []
|
|
520
|
+
};
|
|
521
|
+
function _t(t, n, o) {
|
|
522
|
+
const a = n.ms / 1e3, p = t.createOscillator(), m = t.createGain();
|
|
523
|
+
p.type = n.type, p.frequency.value = n.freq;
|
|
524
|
+
const E = 8e-3;
|
|
525
|
+
return m.gain.setValueAtTime(1e-4, o), m.gain.exponentialRampToValueAtTime(n.gain, o + E), m.gain.exponentialRampToValueAtTime(1e-4, o + a), p.connect(m).connect(t.destination), p.start(o), p.stop(o + a), o + a;
|
|
526
|
+
}
|
|
527
|
+
function ut(t, n) {
|
|
528
|
+
try {
|
|
529
|
+
let o = t.currentTime + 0.03;
|
|
530
|
+
const a = 0.02;
|
|
531
|
+
for (const p of n)
|
|
532
|
+
o = _t(t, p, o) + a;
|
|
533
|
+
} catch {
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function ht(t) {
|
|
537
|
+
const n = qt();
|
|
538
|
+
if (!n) return;
|
|
539
|
+
const o = Ot[t];
|
|
540
|
+
if (!(!o || o.length === 0)) {
|
|
541
|
+
if (n.state === "suspended") {
|
|
542
|
+
n.resume().then(
|
|
543
|
+
() => ut(n, o),
|
|
544
|
+
() => {
|
|
545
|
+
}
|
|
546
|
+
);
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
ut(n, o);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
function zt() {
|
|
553
|
+
return typeof document > "u" || typeof Notification > "u" ? !1 : document.hidden;
|
|
554
|
+
}
|
|
555
|
+
let gt = !1;
|
|
556
|
+
function Wt(t, n, o) {
|
|
557
|
+
if (!zt()) return;
|
|
558
|
+
const a = () => {
|
|
559
|
+
try {
|
|
560
|
+
new Notification(o ?? `[${n}]`, {
|
|
561
|
+
body: t,
|
|
562
|
+
tag: "toast-23"
|
|
563
|
+
});
|
|
564
|
+
} catch {
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
if (Notification.permission === "granted") {
|
|
568
|
+
a();
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
Notification.permission === "default" && !gt && (gt = !0, Notification.requestPermission().then((p) => {
|
|
572
|
+
p === "granted" && a();
|
|
573
|
+
}).catch(() => {
|
|
574
|
+
}));
|
|
575
|
+
}
|
|
576
|
+
function yt() {
|
|
577
|
+
let t = [];
|
|
578
|
+
const n = /* @__PURE__ */ new Set();
|
|
579
|
+
return {
|
|
580
|
+
publish(o) {
|
|
581
|
+
t !== o && (t = o, n.forEach((a) => a()));
|
|
582
|
+
},
|
|
583
|
+
getSnapshot() {
|
|
584
|
+
return t;
|
|
585
|
+
},
|
|
586
|
+
subscribe(o) {
|
|
587
|
+
return n.add(o), () => {
|
|
588
|
+
n.delete(o);
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
bt();
|
|
594
|
+
const jt = [
|
|
343
595
|
"top-right",
|
|
344
596
|
"top-left",
|
|
345
597
|
"top-center",
|
|
346
598
|
"bottom-right",
|
|
347
599
|
"bottom-left",
|
|
348
600
|
"bottom-center"
|
|
349
|
-
],
|
|
350
|
-
children:
|
|
351
|
-
maxVisible:
|
|
352
|
-
position:
|
|
353
|
-
duration:
|
|
601
|
+
], vt = ({
|
|
602
|
+
children: t,
|
|
603
|
+
maxVisible: n = 5,
|
|
604
|
+
position: o = "top-right",
|
|
605
|
+
duration: a = 5e3,
|
|
606
|
+
layout: p = "default",
|
|
607
|
+
dir: m = "ltr",
|
|
608
|
+
theme: E = "auto",
|
|
609
|
+
target: f = null,
|
|
610
|
+
historySize: y = 50,
|
|
611
|
+
focusShortcut: B = "F8",
|
|
612
|
+
swipeThreshold: G = 80,
|
|
613
|
+
swipeEnabled: k = !0,
|
|
614
|
+
sound: R = !1,
|
|
615
|
+
fallbackToNotification: b = !1
|
|
354
616
|
}) => {
|
|
355
|
-
const [
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
617
|
+
const [T, C] = Ct(Et, []), [M, N] = P(!1), v = Q(T);
|
|
618
|
+
v.current = T;
|
|
619
|
+
const h = Q();
|
|
620
|
+
h.current || (h.current = yt());
|
|
621
|
+
const S = h.current, u = Q([]), s = Q(/* @__PURE__ */ new Set()), c = w(
|
|
622
|
+
(l) => {
|
|
623
|
+
if (s.current.has(l.id)) return;
|
|
624
|
+
s.current.add(l.id);
|
|
625
|
+
const e = {
|
|
626
|
+
id: l.id,
|
|
627
|
+
message: l.message,
|
|
628
|
+
title: l.title,
|
|
629
|
+
variant: l.variant === "loading" ? "info" : l.variant,
|
|
630
|
+
dismissedAt: Date.now(),
|
|
631
|
+
group: l.group
|
|
632
|
+
};
|
|
633
|
+
if (u.current = [e, ...u.current].slice(0, y), l.onDismiss)
|
|
634
|
+
try {
|
|
635
|
+
l.onDismiss();
|
|
636
|
+
} catch {
|
|
637
|
+
}
|
|
638
|
+
},
|
|
639
|
+
[y]
|
|
640
|
+
), A = w(
|
|
641
|
+
(l, e) => {
|
|
642
|
+
const g = e?.id ?? rt(), D = e?.variant ?? "default", L = {
|
|
643
|
+
id: g,
|
|
644
|
+
message: l,
|
|
645
|
+
title: e?.title,
|
|
646
|
+
variant: D,
|
|
647
|
+
duration: e?.duration ?? a,
|
|
648
|
+
position: e?.position ?? o,
|
|
649
|
+
dismissible: e?.dismissible ?? !0,
|
|
650
|
+
removeDelay: e?.removeDelay ?? 300,
|
|
366
651
|
isExiting: !1,
|
|
367
652
|
createdAt: Date.now(),
|
|
368
653
|
version: 0,
|
|
369
|
-
isCustom:
|
|
654
|
+
isCustom: e?.isCustom,
|
|
655
|
+
action: e?.action,
|
|
656
|
+
cancelAction: e?.cancelAction,
|
|
657
|
+
onDismiss: e?.onDismiss,
|
|
658
|
+
group: e?.group,
|
|
659
|
+
sound: e?.sound ?? R,
|
|
660
|
+
fallbackToNotification: e?.fallbackToNotification ?? b
|
|
370
661
|
};
|
|
371
|
-
return
|
|
662
|
+
return e?.id ? C({ type: "UPSERT", toast: L }) : C({ type: "ADD", toast: L }), L.sound && ht(D), L.fallbackToNotification && typeof l == "string" && Wt(l, D, L.title), g;
|
|
372
663
|
},
|
|
373
|
-
[
|
|
374
|
-
),
|
|
375
|
-
(
|
|
376
|
-
|
|
664
|
+
[a, o, R, b]
|
|
665
|
+
), I = w(
|
|
666
|
+
(l, e) => {
|
|
667
|
+
C({ type: "UPDATE", id: l, updates: e });
|
|
377
668
|
},
|
|
378
669
|
[]
|
|
379
|
-
),
|
|
380
|
-
l
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
670
|
+
), _ = w(
|
|
671
|
+
(l) => {
|
|
672
|
+
if (l) {
|
|
673
|
+
const e = v.current.find((g) => g.id === l);
|
|
674
|
+
e && c(e);
|
|
675
|
+
} else
|
|
676
|
+
v.current.forEach(c);
|
|
677
|
+
C({ type: "DISMISS", id: l });
|
|
678
|
+
},
|
|
679
|
+
[c]
|
|
680
|
+
), j = w(
|
|
681
|
+
(l) => {
|
|
682
|
+
if (l) {
|
|
683
|
+
const e = v.current.find((g) => g.id === l);
|
|
684
|
+
e && c(e), C({ type: "REMOVE", id: l }), s.current.delete(l);
|
|
685
|
+
} else
|
|
686
|
+
v.current.forEach(c), C({ type: "REMOVE", id: l }), s.current.clear();
|
|
687
|
+
},
|
|
688
|
+
[c]
|
|
689
|
+
), z = w(
|
|
690
|
+
(l) => {
|
|
691
|
+
v.current.filter((e) => e.group === l).forEach(c), C({ type: "DISMISS_GROUP", group: l });
|
|
692
|
+
},
|
|
693
|
+
[c]
|
|
694
|
+
), q = w(
|
|
695
|
+
(l) => {
|
|
696
|
+
const e = v.current.filter((g) => g.group === l);
|
|
697
|
+
e.forEach(c), C({ type: "REMOVE_GROUP", group: l });
|
|
698
|
+
for (const g of e) s.current.delete(g.id);
|
|
699
|
+
},
|
|
700
|
+
[c]
|
|
701
|
+
), F = w(() => N(!0), []), r = w(() => N(!1), []), X = w(() => u.current, []), O = ot(
|
|
384
702
|
() => ({
|
|
385
|
-
addToast:
|
|
386
|
-
updateToast:
|
|
387
|
-
dismissToast:
|
|
388
|
-
removeToast:
|
|
703
|
+
addToast: A,
|
|
704
|
+
updateToast: I,
|
|
705
|
+
dismissToast: _,
|
|
706
|
+
removeToast: j,
|
|
707
|
+
dismissGroup: z,
|
|
708
|
+
removeGroup: q,
|
|
709
|
+
pauseAll: F,
|
|
710
|
+
resumeAll: r,
|
|
711
|
+
history: X,
|
|
712
|
+
headlessStore: S,
|
|
389
713
|
config: {
|
|
390
|
-
maxVisible:
|
|
391
|
-
position:
|
|
392
|
-
duration:
|
|
393
|
-
|
|
714
|
+
maxVisible: n,
|
|
715
|
+
position: o,
|
|
716
|
+
duration: a,
|
|
717
|
+
layout: p,
|
|
718
|
+
dir: m,
|
|
719
|
+
theme: E,
|
|
720
|
+
swipeThreshold: G,
|
|
721
|
+
swipeEnabled: k,
|
|
722
|
+
sound: R,
|
|
723
|
+
fallbackToNotification: b
|
|
724
|
+
},
|
|
725
|
+
isPausedGlobally: M
|
|
394
726
|
}),
|
|
395
727
|
[
|
|
396
|
-
|
|
397
|
-
|
|
728
|
+
A,
|
|
729
|
+
I,
|
|
730
|
+
_,
|
|
731
|
+
j,
|
|
732
|
+
z,
|
|
733
|
+
q,
|
|
734
|
+
F,
|
|
735
|
+
r,
|
|
736
|
+
X,
|
|
737
|
+
S,
|
|
738
|
+
n,
|
|
739
|
+
o,
|
|
398
740
|
a,
|
|
741
|
+
p,
|
|
399
742
|
m,
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
743
|
+
E,
|
|
744
|
+
G,
|
|
745
|
+
k,
|
|
746
|
+
R,
|
|
747
|
+
b,
|
|
748
|
+
M
|
|
403
749
|
]
|
|
404
|
-
)
|
|
405
|
-
|
|
750
|
+
);
|
|
751
|
+
Y(() => {
|
|
752
|
+
S.publish(T);
|
|
753
|
+
}, [T, S]), Y(() => {
|
|
754
|
+
if (!B || typeof window > "u") return;
|
|
755
|
+
const l = (e) => {
|
|
756
|
+
if (e.key !== B) return;
|
|
757
|
+
const g = document.querySelector(
|
|
758
|
+
'[data-toast23-region="true"]'
|
|
759
|
+
);
|
|
760
|
+
g && (e.preventDefault(), g.focus());
|
|
761
|
+
};
|
|
762
|
+
return window.addEventListener("keydown", l), () => window.removeEventListener("keydown", l);
|
|
763
|
+
}, [B]);
|
|
764
|
+
const K = ot(() => {
|
|
765
|
+
const l = {
|
|
406
766
|
"top-right": [],
|
|
407
767
|
"top-left": [],
|
|
408
768
|
"top-center": [],
|
|
@@ -410,107 +770,932 @@ const V = [
|
|
|
410
770
|
"bottom-left": [],
|
|
411
771
|
"bottom-center": []
|
|
412
772
|
};
|
|
413
|
-
for (const
|
|
414
|
-
|
|
415
|
-
return
|
|
416
|
-
}, [
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
773
|
+
for (const e of T)
|
|
774
|
+
(l[e.position] ?? l[o]).push(e);
|
|
775
|
+
return l;
|
|
776
|
+
}, [T, o]), H = /* @__PURE__ */ i(st, { children: jt.map(
|
|
777
|
+
(l) => K[l].length > 0 ? /* @__PURE__ */ i(
|
|
778
|
+
mt,
|
|
779
|
+
{
|
|
780
|
+
position: l,
|
|
781
|
+
toasts: K[l],
|
|
782
|
+
maxVisible: n,
|
|
783
|
+
layout: p,
|
|
784
|
+
dir: m,
|
|
785
|
+
theme: E,
|
|
786
|
+
inline: f != null
|
|
787
|
+
},
|
|
788
|
+
l
|
|
789
|
+
) : null
|
|
790
|
+
) }), U = f ?? (typeof document < "u" ? document.body : null);
|
|
791
|
+
return /* @__PURE__ */ d(tt.Provider, { value: O, children: [
|
|
792
|
+
t,
|
|
793
|
+
U ? St(H, U) : H
|
|
794
|
+
] });
|
|
795
|
+
};
|
|
796
|
+
vt.displayName = "Toast23Provider";
|
|
797
|
+
const at = [
|
|
798
|
+
"default",
|
|
799
|
+
"success",
|
|
800
|
+
"info",
|
|
801
|
+
"warning",
|
|
802
|
+
"error",
|
|
803
|
+
"loading"
|
|
804
|
+
], Ft = [
|
|
805
|
+
"top-left",
|
|
806
|
+
"top-center",
|
|
807
|
+
"top-right",
|
|
808
|
+
"bottom-left",
|
|
809
|
+
"bottom-center",
|
|
810
|
+
"bottom-right"
|
|
811
|
+
], J = {
|
|
812
|
+
success: "#16a34a",
|
|
813
|
+
error: "#dc2626",
|
|
814
|
+
warning: "#ca8a04",
|
|
815
|
+
info: "#2563eb",
|
|
816
|
+
loading: "#7c3aed",
|
|
817
|
+
default: "#6b7280"
|
|
818
|
+
}, Kt = {
|
|
819
|
+
compact: { width: 360, height: 480 },
|
|
820
|
+
expanded: { width: 620, height: 720 }
|
|
821
|
+
}, Ht = yt(), Ut = ({
|
|
822
|
+
position: t = "bottom-left",
|
|
823
|
+
collapsed: n = !0
|
|
824
|
+
}) => {
|
|
825
|
+
const o = nt(tt), [a, p] = P(n), [m, E] = P("compact"), [f, y] = P("queue"), [B, G] = P(/* @__PURE__ */ new Set()), [k, R] = P(null), [b, T] = P(""), [C, M] = P(4e3), N = o?.headlessStore ?? Ht, v = ft(
|
|
826
|
+
N.subscribe,
|
|
827
|
+
N.getSnapshot,
|
|
828
|
+
N.getSnapshot
|
|
829
|
+
), h = ot(
|
|
830
|
+
() => o ? o.history() : [],
|
|
831
|
+
// `toasts` is in the deps so this memo invalidates whenever the queue
|
|
832
|
+
// mutates — which is also when `ctx.history()` gains/loses entries.
|
|
833
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
834
|
+
[o, v]
|
|
835
|
+
), S = w((e) => {
|
|
836
|
+
G((g) => {
|
|
837
|
+
const D = new Set(g);
|
|
838
|
+
return D.has(e) ? D.delete(e) : D.add(e), D;
|
|
839
|
+
});
|
|
840
|
+
}, []), u = w((e) => {
|
|
841
|
+
R(e), window.setTimeout(() => {
|
|
842
|
+
R((g) => g === e ? null : g);
|
|
843
|
+
}, 1200);
|
|
844
|
+
}, []), s = w(
|
|
845
|
+
(e, g) => {
|
|
846
|
+
const D = JSON.stringify(e, null, 2);
|
|
847
|
+
try {
|
|
848
|
+
navigator?.clipboard?.writeText ? navigator.clipboard.writeText(D).then(
|
|
849
|
+
() => u(g),
|
|
850
|
+
() => u(g)
|
|
851
|
+
) : u(g);
|
|
852
|
+
} catch {
|
|
853
|
+
u(g);
|
|
854
|
+
}
|
|
855
|
+
},
|
|
856
|
+
[u]
|
|
857
|
+
);
|
|
858
|
+
if (!o) return null;
|
|
859
|
+
const c = v.filter((e) => !B.has(e.variant)), A = h.filter((e) => !B.has(e.variant)), I = v.length, _ = (e) => {
|
|
860
|
+
o.addToast(e.message, {
|
|
861
|
+
variant: e.variant,
|
|
862
|
+
title: e.title,
|
|
863
|
+
group: e.group
|
|
864
|
+
});
|
|
865
|
+
}, j = (e) => {
|
|
866
|
+
o.addToast(`Test ${e} toast`, {
|
|
867
|
+
variant: e,
|
|
868
|
+
title: e === "default" ? void 0 : e.toUpperCase(),
|
|
869
|
+
duration: C,
|
|
870
|
+
position: b || void 0
|
|
871
|
+
});
|
|
872
|
+
}, z = Kt[m], q = t.startsWith("top"), F = t.endsWith("right"), r = {
|
|
873
|
+
chip: {
|
|
874
|
+
position: "fixed",
|
|
875
|
+
[q ? "top" : "bottom"]: 16,
|
|
876
|
+
[F ? "right" : "left"]: 16,
|
|
877
|
+
zIndex: 1e5,
|
|
878
|
+
display: "inline-flex",
|
|
879
|
+
alignItems: "center",
|
|
880
|
+
gap: 6,
|
|
881
|
+
padding: "6px 12px",
|
|
882
|
+
background: "rgba(17, 24, 39, 0.96)",
|
|
883
|
+
color: "#f9fafb",
|
|
884
|
+
borderRadius: 999,
|
|
885
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
|
|
886
|
+
fontSize: 11,
|
|
887
|
+
lineHeight: 1,
|
|
888
|
+
boxShadow: "0 6px 20px rgba(0,0,0,0.25)",
|
|
889
|
+
border: "1px solid rgba(255,255,255,0.08)",
|
|
890
|
+
cursor: "pointer",
|
|
891
|
+
userSelect: "none"
|
|
892
|
+
},
|
|
893
|
+
panel: {
|
|
894
|
+
position: "fixed",
|
|
895
|
+
[q ? "top" : "bottom"]: 16,
|
|
896
|
+
[F ? "right" : "left"]: 16,
|
|
897
|
+
zIndex: 1e5,
|
|
898
|
+
width: `min(${z.width}px, calc(100vw - 32px))`,
|
|
899
|
+
height: `min(${z.height}px, calc(100vh - 32px))`,
|
|
900
|
+
background: "rgba(17, 24, 39, 0.97)",
|
|
901
|
+
color: "#f9fafb",
|
|
902
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
|
|
903
|
+
fontSize: 11,
|
|
904
|
+
lineHeight: 1.5,
|
|
905
|
+
borderRadius: 10,
|
|
906
|
+
boxShadow: "0 10px 30px rgba(0,0,0,0.35)",
|
|
907
|
+
border: "1px solid rgba(255,255,255,0.08)",
|
|
908
|
+
overflow: "hidden",
|
|
909
|
+
display: "flex",
|
|
910
|
+
flexDirection: "column"
|
|
911
|
+
},
|
|
912
|
+
header: {
|
|
913
|
+
display: "flex",
|
|
914
|
+
alignItems: "center",
|
|
915
|
+
justifyContent: "space-between",
|
|
916
|
+
gap: 8,
|
|
917
|
+
padding: "8px 10px",
|
|
918
|
+
borderBottom: "1px solid rgba(255,255,255,0.08)"
|
|
919
|
+
},
|
|
920
|
+
title: {
|
|
921
|
+
display: "inline-flex",
|
|
922
|
+
alignItems: "center",
|
|
923
|
+
gap: 6,
|
|
924
|
+
fontWeight: 700,
|
|
925
|
+
letterSpacing: 0.3
|
|
926
|
+
},
|
|
927
|
+
badge: {
|
|
928
|
+
display: "inline-flex",
|
|
929
|
+
alignItems: "center",
|
|
930
|
+
justifyContent: "center",
|
|
931
|
+
minWidth: 18,
|
|
932
|
+
height: 18,
|
|
933
|
+
padding: "0 5px",
|
|
934
|
+
borderRadius: 999,
|
|
935
|
+
background: "#3b82f6",
|
|
936
|
+
color: "#fff",
|
|
937
|
+
fontSize: 10,
|
|
938
|
+
fontWeight: 700
|
|
939
|
+
},
|
|
940
|
+
iconBtn: {
|
|
941
|
+
display: "inline-flex",
|
|
942
|
+
alignItems: "center",
|
|
943
|
+
justifyContent: "center",
|
|
944
|
+
width: 22,
|
|
945
|
+
height: 22,
|
|
946
|
+
padding: 0,
|
|
947
|
+
borderRadius: 4,
|
|
948
|
+
background: "transparent",
|
|
949
|
+
color: "#cbd5e1",
|
|
950
|
+
border: "1px solid rgba(255,255,255,0.12)",
|
|
951
|
+
cursor: "pointer",
|
|
952
|
+
fontSize: 12,
|
|
953
|
+
fontFamily: "inherit"
|
|
954
|
+
},
|
|
955
|
+
tabs: {
|
|
956
|
+
display: "flex",
|
|
957
|
+
gap: 4,
|
|
958
|
+
padding: "8px 10px 0"
|
|
959
|
+
},
|
|
960
|
+
tab: {
|
|
961
|
+
flex: 1,
|
|
962
|
+
padding: "5px 8px",
|
|
963
|
+
borderRadius: 6,
|
|
964
|
+
background: "transparent",
|
|
965
|
+
color: "#9ca3af",
|
|
966
|
+
border: "1px solid transparent",
|
|
967
|
+
cursor: "pointer",
|
|
968
|
+
fontSize: 10,
|
|
969
|
+
fontFamily: "inherit",
|
|
970
|
+
fontWeight: 600,
|
|
971
|
+
textTransform: "uppercase",
|
|
972
|
+
letterSpacing: 0.5
|
|
973
|
+
},
|
|
974
|
+
tabActive: {
|
|
975
|
+
background: "rgba(59, 130, 246, 0.15)",
|
|
976
|
+
color: "#bfdbfe",
|
|
977
|
+
borderColor: "rgba(59, 130, 246, 0.4)"
|
|
978
|
+
},
|
|
979
|
+
chipRow: {
|
|
980
|
+
display: "flex",
|
|
981
|
+
flexWrap: "wrap",
|
|
982
|
+
gap: 4,
|
|
983
|
+
padding: "8px 10px",
|
|
984
|
+
borderBottom: "1px solid rgba(255,255,255,0.05)"
|
|
985
|
+
},
|
|
986
|
+
filterChip: {
|
|
987
|
+
display: "inline-flex",
|
|
988
|
+
alignItems: "center",
|
|
989
|
+
gap: 4,
|
|
990
|
+
padding: "2px 7px",
|
|
991
|
+
borderRadius: 999,
|
|
992
|
+
border: "1px solid rgba(255,255,255,0.12)",
|
|
993
|
+
background: "rgba(255,255,255,0.04)",
|
|
994
|
+
color: "#e5e7eb",
|
|
995
|
+
fontSize: 9,
|
|
996
|
+
fontWeight: 600,
|
|
997
|
+
textTransform: "uppercase",
|
|
998
|
+
letterSpacing: 0.4,
|
|
999
|
+
cursor: "pointer",
|
|
1000
|
+
fontFamily: "inherit"
|
|
1001
|
+
},
|
|
1002
|
+
filterChipOff: {
|
|
1003
|
+
opacity: 0.35,
|
|
1004
|
+
textDecoration: "line-through"
|
|
1005
|
+
},
|
|
1006
|
+
body: {
|
|
1007
|
+
flex: 1,
|
|
1008
|
+
overflow: "auto"
|
|
1009
|
+
},
|
|
1010
|
+
empty: {
|
|
1011
|
+
padding: "20px 12px",
|
|
1012
|
+
color: "#6b7280",
|
|
1013
|
+
textAlign: "center"
|
|
1014
|
+
},
|
|
1015
|
+
row: {
|
|
1016
|
+
padding: "8px 12px",
|
|
1017
|
+
borderBottom: "1px solid rgba(255,255,255,0.04)"
|
|
1018
|
+
},
|
|
1019
|
+
rowTop: {
|
|
1020
|
+
display: "flex",
|
|
1021
|
+
justifyContent: "space-between",
|
|
1022
|
+
alignItems: "center",
|
|
1023
|
+
gap: 8,
|
|
1024
|
+
marginBottom: 4
|
|
1025
|
+
},
|
|
1026
|
+
variantTag: {
|
|
1027
|
+
fontSize: 9,
|
|
1028
|
+
padding: "1px 6px",
|
|
1029
|
+
borderRadius: 3,
|
|
1030
|
+
color: "#fff",
|
|
1031
|
+
textTransform: "uppercase",
|
|
1032
|
+
letterSpacing: 0.3,
|
|
1033
|
+
fontWeight: 700
|
|
1034
|
+
},
|
|
1035
|
+
rowMeta: {
|
|
1036
|
+
color: "#9ca3af",
|
|
1037
|
+
fontSize: 10,
|
|
1038
|
+
overflow: "hidden",
|
|
1039
|
+
textOverflow: "ellipsis",
|
|
1040
|
+
whiteSpace: "nowrap"
|
|
1041
|
+
},
|
|
1042
|
+
rowMessage: {
|
|
1043
|
+
color: "#e5e7eb",
|
|
1044
|
+
whiteSpace: "pre-wrap",
|
|
1045
|
+
wordBreak: "break-word"
|
|
1046
|
+
},
|
|
1047
|
+
rowActions: {
|
|
1048
|
+
display: "flex",
|
|
1049
|
+
gap: 4,
|
|
1050
|
+
marginTop: 6
|
|
1051
|
+
},
|
|
1052
|
+
smallBtn: {
|
|
1053
|
+
flex: 1,
|
|
1054
|
+
padding: "3px 7px",
|
|
1055
|
+
borderRadius: 4,
|
|
1056
|
+
background: "rgba(255,255,255,0.06)",
|
|
1057
|
+
color: "#f9fafb",
|
|
1058
|
+
border: "1px solid rgba(255,255,255,0.1)",
|
|
1059
|
+
cursor: "pointer",
|
|
1060
|
+
fontSize: 10,
|
|
1061
|
+
fontFamily: "inherit"
|
|
1062
|
+
},
|
|
1063
|
+
smallBtnActive: {
|
|
1064
|
+
background: "rgba(34, 197, 94, 0.18)",
|
|
1065
|
+
borderColor: "rgba(34, 197, 94, 0.5)",
|
|
1066
|
+
color: "#bbf7d0"
|
|
1067
|
+
},
|
|
1068
|
+
footer: {
|
|
1069
|
+
display: "flex",
|
|
1070
|
+
gap: 4,
|
|
1071
|
+
padding: "8px 10px",
|
|
1072
|
+
borderTop: "1px solid rgba(255,255,255,0.08)",
|
|
1073
|
+
background: "rgba(0,0,0,0.2)"
|
|
1074
|
+
},
|
|
1075
|
+
section: {
|
|
1076
|
+
padding: "10px 12px",
|
|
1077
|
+
borderBottom: "1px solid rgba(255,255,255,0.04)"
|
|
1078
|
+
},
|
|
1079
|
+
sectionTitle: {
|
|
1080
|
+
fontSize: 9,
|
|
1081
|
+
fontWeight: 700,
|
|
1082
|
+
textTransform: "uppercase",
|
|
1083
|
+
letterSpacing: 0.6,
|
|
1084
|
+
color: "#9ca3af",
|
|
1085
|
+
marginBottom: 8
|
|
1086
|
+
},
|
|
1087
|
+
grid3: {
|
|
1088
|
+
display: "grid",
|
|
1089
|
+
gridTemplateColumns: "repeat(3, 1fr)",
|
|
1090
|
+
gap: 4
|
|
1091
|
+
},
|
|
1092
|
+
grid6: {
|
|
1093
|
+
display: "grid",
|
|
1094
|
+
gridTemplateColumns: "repeat(6, 1fr)",
|
|
1095
|
+
gap: 4
|
|
1096
|
+
},
|
|
1097
|
+
kvRow: {
|
|
1098
|
+
display: "flex",
|
|
1099
|
+
justifyContent: "space-between",
|
|
1100
|
+
alignItems: "center",
|
|
1101
|
+
padding: "3px 0",
|
|
1102
|
+
color: "#cbd5e1",
|
|
1103
|
+
fontSize: 10
|
|
1104
|
+
},
|
|
1105
|
+
kvKey: { color: "#9ca3af" },
|
|
1106
|
+
inputRow: {
|
|
1107
|
+
display: "flex",
|
|
1108
|
+
alignItems: "center",
|
|
1109
|
+
gap: 6,
|
|
1110
|
+
marginBottom: 8
|
|
1111
|
+
},
|
|
1112
|
+
input: {
|
|
1113
|
+
flex: 1,
|
|
1114
|
+
padding: "3px 6px",
|
|
1115
|
+
borderRadius: 4,
|
|
1116
|
+
background: "rgba(255,255,255,0.06)",
|
|
1117
|
+
color: "#f9fafb",
|
|
1118
|
+
border: "1px solid rgba(255,255,255,0.1)",
|
|
1119
|
+
fontSize: 10,
|
|
1120
|
+
fontFamily: "inherit"
|
|
1121
|
+
}
|
|
1122
|
+
}, X = (e) => ({
|
|
1123
|
+
...r.variantTag,
|
|
1124
|
+
background: J[e]
|
|
1125
|
+
}), O = /* @__PURE__ */ d(
|
|
1126
|
+
"button",
|
|
1127
|
+
{
|
|
1128
|
+
type: "button",
|
|
1129
|
+
style: r.chip,
|
|
1130
|
+
onClick: () => p(!1),
|
|
1131
|
+
"data-toast23-devtools": "chip",
|
|
1132
|
+
"aria-label": `Open toast-23 devtools (${I} active)`,
|
|
1133
|
+
children: [
|
|
1134
|
+
/* @__PURE__ */ i("span", { style: { fontWeight: 700, letterSpacing: 0.3 }, children: "toast-23 devtools" }),
|
|
1135
|
+
/* @__PURE__ */ i("span", { style: r.badge, children: I }),
|
|
1136
|
+
o.isPausedGlobally && /* @__PURE__ */ i("span", { style: { ...r.badge, background: "#dc2626" }, children: "paused" })
|
|
1137
|
+
]
|
|
1138
|
+
}
|
|
1139
|
+
);
|
|
1140
|
+
if (a) return O;
|
|
1141
|
+
const K = /* @__PURE__ */ i("div", { style: r.chipRow, children: at.map((e) => {
|
|
1142
|
+
const g = B.has(e);
|
|
1143
|
+
return /* @__PURE__ */ d(
|
|
1144
|
+
"button",
|
|
1145
|
+
{
|
|
1146
|
+
type: "button",
|
|
1147
|
+
onClick: () => S(e),
|
|
1148
|
+
style: {
|
|
1149
|
+
...r.filterChip,
|
|
1150
|
+
...g ? r.filterChipOff : null,
|
|
1151
|
+
borderColor: g ? "rgba(255,255,255,0.12)" : J[e] + "80"
|
|
1152
|
+
},
|
|
1153
|
+
"aria-pressed": !g,
|
|
1154
|
+
title: g ? `Show ${e}` : `Hide ${e}`,
|
|
1155
|
+
children: [
|
|
1156
|
+
/* @__PURE__ */ i(
|
|
1157
|
+
"span",
|
|
1158
|
+
{
|
|
1159
|
+
style: {
|
|
1160
|
+
width: 6,
|
|
1161
|
+
height: 6,
|
|
1162
|
+
borderRadius: 999,
|
|
1163
|
+
background: J[e],
|
|
1164
|
+
display: "inline-block"
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
),
|
|
1168
|
+
e
|
|
1169
|
+
]
|
|
1170
|
+
},
|
|
1171
|
+
e
|
|
1172
|
+
);
|
|
1173
|
+
}) }), H = /* @__PURE__ */ d(st, { children: [
|
|
1174
|
+
K,
|
|
1175
|
+
/* @__PURE__ */ d("div", { style: r.body, children: [
|
|
1176
|
+
c.length === 0 && /* @__PURE__ */ i("div", { style: r.empty, children: v.length === 0 ? "Queue is empty." : "All variants filtered out." }),
|
|
1177
|
+
c.map((e) => {
|
|
1178
|
+
const g = `q-${e.id}`;
|
|
1179
|
+
return /* @__PURE__ */ d("div", { style: r.row, children: [
|
|
1180
|
+
/* @__PURE__ */ d("div", { style: r.rowTop, children: [
|
|
1181
|
+
/* @__PURE__ */ i("span", { style: X(e.variant), children: e.variant }),
|
|
1182
|
+
/* @__PURE__ */ i("span", { style: r.rowMeta, title: e.id, children: e.id })
|
|
1183
|
+
] }),
|
|
1184
|
+
/* @__PURE__ */ i("div", { style: r.rowMessage, children: typeof e.message == "string" ? e.message : "[ReactNode message]" }),
|
|
1185
|
+
/* @__PURE__ */ d("div", { style: { ...r.rowMeta, marginTop: 2 }, children: [
|
|
1186
|
+
e.duration,
|
|
1187
|
+
"ms · ",
|
|
1188
|
+
e.position,
|
|
1189
|
+
e.group && ` · group: ${e.group}`,
|
|
1190
|
+
e.isExiting && " · exiting"
|
|
1191
|
+
] }),
|
|
1192
|
+
/* @__PURE__ */ d("div", { style: r.rowActions, children: [
|
|
1193
|
+
/* @__PURE__ */ i(
|
|
1194
|
+
"button",
|
|
1195
|
+
{
|
|
1196
|
+
type: "button",
|
|
1197
|
+
style: r.smallBtn,
|
|
1198
|
+
onClick: () => o.dismissToast(e.id),
|
|
1199
|
+
children: "Dismiss"
|
|
1200
|
+
}
|
|
1201
|
+
),
|
|
1202
|
+
/* @__PURE__ */ i(
|
|
1203
|
+
"button",
|
|
1204
|
+
{
|
|
1205
|
+
type: "button",
|
|
1206
|
+
style: r.smallBtn,
|
|
1207
|
+
onClick: () => o.removeToast(e.id),
|
|
1208
|
+
children: "Remove"
|
|
1209
|
+
}
|
|
1210
|
+
),
|
|
1211
|
+
/* @__PURE__ */ i(
|
|
1212
|
+
"button",
|
|
1213
|
+
{
|
|
1214
|
+
type: "button",
|
|
1215
|
+
style: k === g ? { ...r.smallBtn, ...r.smallBtnActive } : r.smallBtn,
|
|
1216
|
+
onClick: () => s(
|
|
1217
|
+
{
|
|
1218
|
+
id: e.id,
|
|
1219
|
+
variant: e.variant,
|
|
1220
|
+
message: typeof e.message == "string" ? e.message : "[ReactNode]",
|
|
1221
|
+
title: e.title,
|
|
1222
|
+
duration: e.duration,
|
|
1223
|
+
position: e.position,
|
|
1224
|
+
group: e.group,
|
|
1225
|
+
createdAt: e.createdAt
|
|
1226
|
+
},
|
|
1227
|
+
g
|
|
1228
|
+
),
|
|
1229
|
+
children: k === g ? "Copied" : "Copy"
|
|
1230
|
+
}
|
|
1231
|
+
)
|
|
1232
|
+
] })
|
|
1233
|
+
] }, e.id);
|
|
1234
|
+
})
|
|
1235
|
+
] }),
|
|
1236
|
+
/* @__PURE__ */ d("div", { style: r.footer, children: [
|
|
1237
|
+
/* @__PURE__ */ i(
|
|
1238
|
+
"button",
|
|
1239
|
+
{
|
|
1240
|
+
type: "button",
|
|
1241
|
+
style: r.smallBtn,
|
|
1242
|
+
onClick: () => o.isPausedGlobally ? o.resumeAll() : o.pauseAll(),
|
|
1243
|
+
children: o.isPausedGlobally ? "Resume all" : "Pause all"
|
|
1244
|
+
}
|
|
1245
|
+
),
|
|
1246
|
+
/* @__PURE__ */ i(
|
|
1247
|
+
"button",
|
|
1248
|
+
{
|
|
1249
|
+
type: "button",
|
|
1250
|
+
style: r.smallBtn,
|
|
1251
|
+
onClick: () => o.dismissToast(),
|
|
1252
|
+
children: "Dismiss all"
|
|
1253
|
+
}
|
|
1254
|
+
),
|
|
1255
|
+
/* @__PURE__ */ i(
|
|
1256
|
+
"button",
|
|
1257
|
+
{
|
|
1258
|
+
type: "button",
|
|
1259
|
+
style: r.smallBtn,
|
|
1260
|
+
onClick: () => o.removeToast(),
|
|
1261
|
+
children: "Clear"
|
|
1262
|
+
}
|
|
1263
|
+
)
|
|
1264
|
+
] })
|
|
1265
|
+
] }), U = /* @__PURE__ */ d(st, { children: [
|
|
1266
|
+
K,
|
|
1267
|
+
/* @__PURE__ */ d("div", { style: r.body, children: [
|
|
1268
|
+
A.length === 0 && /* @__PURE__ */ i("div", { style: r.empty, children: h.length === 0 ? "No dismissed toasts yet. Fire a toast and dismiss it." : "All variants filtered out." }),
|
|
1269
|
+
A.map((e) => {
|
|
1270
|
+
const g = `h-${e.id}`, D = Yt(Date.now() - e.dismissedAt);
|
|
1271
|
+
return /* @__PURE__ */ d("div", { style: r.row, children: [
|
|
1272
|
+
/* @__PURE__ */ d("div", { style: r.rowTop, children: [
|
|
1273
|
+
/* @__PURE__ */ i("span", { style: X(e.variant), children: e.variant }),
|
|
1274
|
+
/* @__PURE__ */ i("span", { style: r.rowMeta, title: new Date(e.dismissedAt).toISOString(), children: D })
|
|
1275
|
+
] }),
|
|
1276
|
+
e.title && /* @__PURE__ */ i(
|
|
1277
|
+
"div",
|
|
1278
|
+
{
|
|
1279
|
+
style: { fontWeight: 700, color: "#f9fafb", marginBottom: 2 },
|
|
1280
|
+
children: e.title
|
|
1281
|
+
}
|
|
1282
|
+
),
|
|
1283
|
+
/* @__PURE__ */ i("div", { style: r.rowMessage, children: typeof e.message == "string" ? e.message : "[ReactNode message]" }),
|
|
1284
|
+
e.group && /* @__PURE__ */ d("div", { style: { ...r.rowMeta, marginTop: 2 }, children: [
|
|
1285
|
+
"group: ",
|
|
1286
|
+
e.group
|
|
1287
|
+
] }),
|
|
1288
|
+
/* @__PURE__ */ d("div", { style: r.rowActions, children: [
|
|
1289
|
+
/* @__PURE__ */ i(
|
|
1290
|
+
"button",
|
|
1291
|
+
{
|
|
1292
|
+
type: "button",
|
|
1293
|
+
style: r.smallBtn,
|
|
1294
|
+
onClick: () => _(e),
|
|
1295
|
+
title: "Re-fire this toast",
|
|
1296
|
+
children: "Replay"
|
|
1297
|
+
}
|
|
1298
|
+
),
|
|
1299
|
+
/* @__PURE__ */ i(
|
|
1300
|
+
"button",
|
|
1301
|
+
{
|
|
1302
|
+
type: "button",
|
|
1303
|
+
style: k === g ? { ...r.smallBtn, ...r.smallBtnActive } : r.smallBtn,
|
|
1304
|
+
onClick: () => s(
|
|
1305
|
+
{
|
|
1306
|
+
id: e.id,
|
|
1307
|
+
variant: e.variant,
|
|
1308
|
+
message: typeof e.message == "string" ? e.message : "[ReactNode]",
|
|
1309
|
+
title: e.title,
|
|
1310
|
+
group: e.group,
|
|
1311
|
+
dismissedAt: e.dismissedAt
|
|
1312
|
+
},
|
|
1313
|
+
g
|
|
1314
|
+
),
|
|
1315
|
+
children: k === g ? "Copied" : "Copy"
|
|
1316
|
+
}
|
|
1317
|
+
)
|
|
1318
|
+
] })
|
|
1319
|
+
] }, e.id);
|
|
1320
|
+
})
|
|
1321
|
+
] }),
|
|
1322
|
+
/* @__PURE__ */ i("div", { style: r.footer, children: /* @__PURE__ */ d("span", { style: { ...r.rowMeta, alignSelf: "center", flex: 1 }, children: [
|
|
1323
|
+
h.length,
|
|
1324
|
+
" entries · cap ",
|
|
1325
|
+
h.length >= 50 ? "reached" : "ok"
|
|
1326
|
+
] }) })
|
|
1327
|
+
] }), l = /* @__PURE__ */ d("div", { style: r.body, children: [
|
|
1328
|
+
/* @__PURE__ */ d("div", { style: r.section, children: [
|
|
1329
|
+
/* @__PURE__ */ i("div", { style: r.sectionTitle, children: "Spawn test toast" }),
|
|
1330
|
+
/* @__PURE__ */ i("div", { style: r.grid6, children: at.map((e) => /* @__PURE__ */ i(
|
|
1331
|
+
"button",
|
|
422
1332
|
{
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
1333
|
+
type: "button",
|
|
1334
|
+
style: {
|
|
1335
|
+
...r.smallBtn,
|
|
1336
|
+
background: J[e] + "33",
|
|
1337
|
+
borderColor: J[e] + "80",
|
|
1338
|
+
color: "#fff"
|
|
1339
|
+
},
|
|
1340
|
+
onClick: () => j(e),
|
|
1341
|
+
title: `Fire a ${e} toast`,
|
|
1342
|
+
children: e
|
|
426
1343
|
},
|
|
427
|
-
|
|
428
|
-
)
|
|
429
|
-
)
|
|
1344
|
+
e
|
|
1345
|
+
)) })
|
|
1346
|
+
] }),
|
|
1347
|
+
/* @__PURE__ */ d("div", { style: r.section, children: [
|
|
1348
|
+
/* @__PURE__ */ i("div", { style: r.sectionTitle, children: "Sound preview" }),
|
|
1349
|
+
/* @__PURE__ */ i("div", { style: r.grid6, children: at.map((e) => /* @__PURE__ */ d(
|
|
1350
|
+
"button",
|
|
1351
|
+
{
|
|
1352
|
+
type: "button",
|
|
1353
|
+
style: r.smallBtn,
|
|
1354
|
+
onClick: () => ht(e),
|
|
1355
|
+
title: `Play ${e} tone`,
|
|
1356
|
+
children: [
|
|
1357
|
+
"♪ ",
|
|
1358
|
+
e.slice(0, 4)
|
|
1359
|
+
]
|
|
1360
|
+
},
|
|
1361
|
+
e
|
|
1362
|
+
)) }),
|
|
1363
|
+
/* @__PURE__ */ i("div", { style: { ...r.rowMeta, marginTop: 6 }, children: "Plays the tone patch directly. Requires a prior user gesture (browser autoplay policy)." })
|
|
1364
|
+
] }),
|
|
1365
|
+
/* @__PURE__ */ d("div", { style: r.section, children: [
|
|
1366
|
+
/* @__PURE__ */ i("div", { style: r.sectionTitle, children: "Test overrides" }),
|
|
1367
|
+
/* @__PURE__ */ d("div", { style: r.inputRow, children: [
|
|
1368
|
+
/* @__PURE__ */ i("span", { style: r.kvKey, children: "duration" }),
|
|
1369
|
+
/* @__PURE__ */ i(
|
|
1370
|
+
"input",
|
|
1371
|
+
{
|
|
1372
|
+
type: "number",
|
|
1373
|
+
min: 0,
|
|
1374
|
+
step: 500,
|
|
1375
|
+
value: C,
|
|
1376
|
+
onChange: (e) => M(Number(e.target.value) || 0),
|
|
1377
|
+
style: r.input
|
|
1378
|
+
}
|
|
1379
|
+
),
|
|
1380
|
+
/* @__PURE__ */ i("span", { style: r.kvKey, children: "ms" })
|
|
1381
|
+
] }),
|
|
1382
|
+
/* @__PURE__ */ i("div", { style: { ...r.kvKey, marginBottom: 4, fontSize: 10 }, children: "position" }),
|
|
1383
|
+
/* @__PURE__ */ d("div", { style: r.grid3, children: [
|
|
1384
|
+
/* @__PURE__ */ i(
|
|
1385
|
+
"button",
|
|
1386
|
+
{
|
|
1387
|
+
type: "button",
|
|
1388
|
+
style: b === "" ? { ...r.smallBtn, ...r.smallBtnActive } : r.smallBtn,
|
|
1389
|
+
onClick: () => T(""),
|
|
1390
|
+
children: "inherit"
|
|
1391
|
+
}
|
|
1392
|
+
),
|
|
1393
|
+
Ft.map((e) => /* @__PURE__ */ i(
|
|
1394
|
+
"button",
|
|
1395
|
+
{
|
|
1396
|
+
type: "button",
|
|
1397
|
+
style: b === e ? { ...r.smallBtn, ...r.smallBtnActive } : r.smallBtn,
|
|
1398
|
+
onClick: () => T(e),
|
|
1399
|
+
title: e,
|
|
1400
|
+
children: e.replace("top-", "↑").replace("bottom-", "↓")
|
|
1401
|
+
},
|
|
1402
|
+
e
|
|
1403
|
+
))
|
|
1404
|
+
] })
|
|
1405
|
+
] }),
|
|
1406
|
+
/* @__PURE__ */ d("div", { style: r.section, children: [
|
|
1407
|
+
/* @__PURE__ */ d(
|
|
1408
|
+
"div",
|
|
1409
|
+
{
|
|
1410
|
+
style: {
|
|
1411
|
+
...r.sectionTitle,
|
|
1412
|
+
display: "flex",
|
|
1413
|
+
justifyContent: "space-between"
|
|
1414
|
+
},
|
|
1415
|
+
children: [
|
|
1416
|
+
/* @__PURE__ */ i("span", { children: "Provider config" }),
|
|
1417
|
+
/* @__PURE__ */ i(
|
|
1418
|
+
"button",
|
|
1419
|
+
{
|
|
1420
|
+
type: "button",
|
|
1421
|
+
style: k === "config" ? {
|
|
1422
|
+
...r.smallBtn,
|
|
1423
|
+
...r.smallBtnActive,
|
|
1424
|
+
flex: "0 0 auto",
|
|
1425
|
+
padding: "2px 8px"
|
|
1426
|
+
} : { ...r.smallBtn, flex: "0 0 auto", padding: "2px 8px" },
|
|
1427
|
+
onClick: () => s({ ...o.config }, "config"),
|
|
1428
|
+
children: k === "config" ? "Copied" : "Copy JSON"
|
|
1429
|
+
}
|
|
1430
|
+
)
|
|
1431
|
+
]
|
|
1432
|
+
}
|
|
1433
|
+
),
|
|
1434
|
+
Object.entries(o.config).map(([e, g]) => /* @__PURE__ */ d("div", { style: r.kvRow, children: [
|
|
1435
|
+
/* @__PURE__ */ i("span", { style: r.kvKey, children: e }),
|
|
1436
|
+
/* @__PURE__ */ i("span", { children: String(g) })
|
|
1437
|
+
] }, e)),
|
|
1438
|
+
/* @__PURE__ */ d("div", { style: { ...r.kvRow, marginTop: 6 }, children: [
|
|
1439
|
+
/* @__PURE__ */ i("span", { style: r.kvKey, children: "paused" }),
|
|
1440
|
+
/* @__PURE__ */ i("span", { children: o.isPausedGlobally ? "yes" : "no" })
|
|
1441
|
+
] })
|
|
1442
|
+
] })
|
|
1443
|
+
] });
|
|
1444
|
+
return /* @__PURE__ */ d("div", { style: r.panel, "data-toast23-devtools": "panel", children: [
|
|
1445
|
+
/* @__PURE__ */ d("div", { style: r.header, children: [
|
|
1446
|
+
/* @__PURE__ */ d("span", { style: r.title, children: [
|
|
1447
|
+
"toast-23",
|
|
1448
|
+
/* @__PURE__ */ i("span", { style: r.badge, children: I }),
|
|
1449
|
+
o.isPausedGlobally && /* @__PURE__ */ i("span", { style: { ...r.badge, background: "#dc2626" }, children: "paused" })
|
|
1450
|
+
] }),
|
|
1451
|
+
/* @__PURE__ */ d("span", { style: { display: "inline-flex", gap: 4 }, children: [
|
|
1452
|
+
/* @__PURE__ */ i(
|
|
1453
|
+
"button",
|
|
1454
|
+
{
|
|
1455
|
+
type: "button",
|
|
1456
|
+
style: r.iconBtn,
|
|
1457
|
+
onClick: () => E((e) => e === "compact" ? "expanded" : "compact"),
|
|
1458
|
+
title: m === "compact" ? "Expand" : "Shrink",
|
|
1459
|
+
"aria-label": m === "compact" ? "Expand panel" : "Shrink panel",
|
|
1460
|
+
children: m === "compact" ? "⤢" : "⤡"
|
|
1461
|
+
}
|
|
1462
|
+
),
|
|
1463
|
+
/* @__PURE__ */ i(
|
|
1464
|
+
"button",
|
|
1465
|
+
{
|
|
1466
|
+
type: "button",
|
|
1467
|
+
style: r.iconBtn,
|
|
1468
|
+
onClick: () => p(!0),
|
|
1469
|
+
title: "Collapse to chip",
|
|
1470
|
+
"aria-label": "Collapse to chip",
|
|
1471
|
+
children: "–"
|
|
1472
|
+
}
|
|
1473
|
+
)
|
|
1474
|
+
] })
|
|
1475
|
+
] }),
|
|
1476
|
+
/* @__PURE__ */ i("div", { style: r.tabs, children: ["queue", "history", "settings"].map((e) => /* @__PURE__ */ d(
|
|
1477
|
+
"button",
|
|
1478
|
+
{
|
|
1479
|
+
type: "button",
|
|
1480
|
+
style: f === e ? { ...r.tab, ...r.tabActive } : r.tab,
|
|
1481
|
+
onClick: () => y(e),
|
|
1482
|
+
children: [
|
|
1483
|
+
e,
|
|
1484
|
+
e === "queue" && I > 0 ? ` (${I})` : "",
|
|
1485
|
+
e === "history" && h.length > 0 ? ` (${h.length})` : ""
|
|
1486
|
+
]
|
|
1487
|
+
},
|
|
1488
|
+
e
|
|
1489
|
+
)) }),
|
|
1490
|
+
f === "queue" && H,
|
|
1491
|
+
f === "history" && U,
|
|
1492
|
+
f === "settings" && l
|
|
430
1493
|
] });
|
|
431
1494
|
};
|
|
432
|
-
|
|
433
|
-
function
|
|
434
|
-
|
|
435
|
-
|
|
1495
|
+
Ut.displayName = "Toast23DevTools";
|
|
1496
|
+
function Yt(t) {
|
|
1497
|
+
if (t < 0) return "now";
|
|
1498
|
+
const n = Math.floor(t / 1e3);
|
|
1499
|
+
if (n < 5) return "just now";
|
|
1500
|
+
if (n < 60) return `${n}s ago`;
|
|
1501
|
+
const o = Math.floor(n / 60);
|
|
1502
|
+
if (o < 60) return `${o}m ago`;
|
|
1503
|
+
const a = Math.floor(o / 60);
|
|
1504
|
+
return a < 24 ? `${a}h ago` : `${Math.floor(a / 24)}d ago`;
|
|
1505
|
+
}
|
|
1506
|
+
function Xt() {
|
|
1507
|
+
const t = nt(tt);
|
|
1508
|
+
if (!t)
|
|
436
1509
|
throw new Error(
|
|
437
1510
|
"[toast-23] useToast() must be used inside a <Toast23Provider>. Wrap your application root with <Toast23Provider> to fix this."
|
|
438
1511
|
);
|
|
439
|
-
return
|
|
440
|
-
const
|
|
441
|
-
return
|
|
442
|
-
...
|
|
1512
|
+
return ot(() => {
|
|
1513
|
+
const n = ((o, a) => t.addToast(o, a));
|
|
1514
|
+
return n.success = (o, a) => t.addToast(o, { ...a, variant: "success" }), n.error = (o, a) => t.addToast(o, { ...a, variant: "error" }), n.warning = (o, a) => t.addToast(o, { ...a, variant: "warning" }), n.info = (o, a) => t.addToast(o, { ...a, variant: "info" }), n.loading = (o, a) => t.addToast(o, {
|
|
1515
|
+
...a,
|
|
443
1516
|
variant: "loading",
|
|
444
|
-
duration:
|
|
445
|
-
dismissible:
|
|
446
|
-
}),
|
|
447
|
-
const
|
|
448
|
-
...
|
|
1517
|
+
duration: a?.duration ?? 0,
|
|
1518
|
+
dismissible: a?.dismissible ?? !1
|
|
1519
|
+
}), n.custom = (o, a) => t.addToast(o, { ...a, variant: "default", isCustom: !0 }), n.dismiss = (o) => t.dismissToast(o), n.remove = (o) => t.removeToast(o), n.dismissGroup = (o) => t.dismissGroup(o), n.removeGroup = (o) => t.removeGroup(o), n.pauseAll = () => t.pauseAll(), n.resumeAll = () => t.resumeAll(), n.history = () => t.history(), n.promise = async (o, a, p) => {
|
|
1520
|
+
const m = t.addToast(a.loading, {
|
|
1521
|
+
...p,
|
|
449
1522
|
variant: "loading",
|
|
450
1523
|
duration: 0,
|
|
451
1524
|
dismissible: !1
|
|
452
|
-
})
|
|
1525
|
+
});
|
|
1526
|
+
if (a.progress)
|
|
1527
|
+
try {
|
|
1528
|
+
a.progress((f) => {
|
|
1529
|
+
t.updateToast(m, { progress: Math.max(0, Math.min(1, f)) });
|
|
1530
|
+
});
|
|
1531
|
+
} catch {
|
|
1532
|
+
}
|
|
1533
|
+
const E = typeof o == "function" ? o() : o;
|
|
453
1534
|
try {
|
|
454
|
-
const
|
|
455
|
-
return
|
|
456
|
-
message:
|
|
1535
|
+
const f = await E, y = typeof a.success == "function" ? a.success(f) : a.success;
|
|
1536
|
+
return t.updateToast(m, {
|
|
1537
|
+
message: y,
|
|
457
1538
|
variant: "success",
|
|
458
|
-
duration:
|
|
459
|
-
dismissible: !0
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
1539
|
+
duration: p?.duration ?? t.config.duration,
|
|
1540
|
+
dismissible: !0,
|
|
1541
|
+
progress: void 0
|
|
1542
|
+
}), f;
|
|
1543
|
+
} catch (f) {
|
|
1544
|
+
const y = typeof a.error == "function" ? a.error(f) : a.error;
|
|
1545
|
+
throw t.updateToast(m, {
|
|
1546
|
+
message: y,
|
|
465
1547
|
variant: "error",
|
|
466
|
-
duration:
|
|
467
|
-
dismissible: !0
|
|
468
|
-
|
|
1548
|
+
duration: p?.duration ?? t.config.duration,
|
|
1549
|
+
dismissible: !0,
|
|
1550
|
+
progress: void 0
|
|
1551
|
+
}), f;
|
|
469
1552
|
}
|
|
470
|
-
}, o
|
|
1553
|
+
}, n.confirm = (o, a) => new Promise((p) => {
|
|
1554
|
+
const m = rt();
|
|
1555
|
+
let E = !1;
|
|
1556
|
+
const f = (y) => {
|
|
1557
|
+
E || (E = !0, p(y));
|
|
1558
|
+
};
|
|
1559
|
+
t.addToast(o, {
|
|
1560
|
+
id: m,
|
|
1561
|
+
variant: a?.variant ?? "warning",
|
|
1562
|
+
title: a?.title,
|
|
1563
|
+
position: a?.position,
|
|
1564
|
+
duration: 0,
|
|
1565
|
+
// never auto-dismiss
|
|
1566
|
+
dismissible: !0,
|
|
1567
|
+
action: {
|
|
1568
|
+
label: a?.confirmLabel ?? "Confirm",
|
|
1569
|
+
onClick: (y) => {
|
|
1570
|
+
f(!0), y();
|
|
1571
|
+
},
|
|
1572
|
+
dismissOnClick: !1,
|
|
1573
|
+
className: "toast23-action--confirm"
|
|
1574
|
+
},
|
|
1575
|
+
cancelAction: {
|
|
1576
|
+
label: a?.cancelLabel ?? "Cancel",
|
|
1577
|
+
onClick: (y) => {
|
|
1578
|
+
f(!1), y();
|
|
1579
|
+
},
|
|
1580
|
+
dismissOnClick: !1
|
|
1581
|
+
},
|
|
1582
|
+
// If user closes via X button or anything else, treat as cancel.
|
|
1583
|
+
onDismiss: () => f(!1)
|
|
1584
|
+
});
|
|
1585
|
+
}), n;
|
|
471
1586
|
}, [
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
1587
|
+
t.addToast,
|
|
1588
|
+
t.updateToast,
|
|
1589
|
+
t.dismissToast,
|
|
1590
|
+
t.removeToast,
|
|
1591
|
+
t.dismissGroup,
|
|
1592
|
+
t.removeGroup,
|
|
1593
|
+
t.pauseAll,
|
|
1594
|
+
t.resumeAll,
|
|
1595
|
+
t.history,
|
|
1596
|
+
t.config.duration
|
|
477
1597
|
]);
|
|
478
1598
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
1599
|
+
function ee() {
|
|
1600
|
+
const t = nt(tt);
|
|
1601
|
+
if (!t)
|
|
1602
|
+
throw new Error(
|
|
1603
|
+
"[toast-23] useToast23Headless() must be used inside a <Toast23Provider>."
|
|
1604
|
+
);
|
|
1605
|
+
const { headlessStore: n } = t;
|
|
1606
|
+
return {
|
|
1607
|
+
toasts: ft(
|
|
1608
|
+
n.subscribe,
|
|
1609
|
+
n.getSnapshot,
|
|
1610
|
+
n.getSnapshot
|
|
1611
|
+
),
|
|
1612
|
+
dismiss: t.dismissToast,
|
|
1613
|
+
remove: t.removeToast,
|
|
1614
|
+
dismissGroup: t.dismissGroup,
|
|
1615
|
+
removeGroup: t.removeGroup,
|
|
1616
|
+
pauseAll: t.pauseAll,
|
|
1617
|
+
resumeAll: t.resumeAll,
|
|
1618
|
+
history: t.history,
|
|
1619
|
+
isPausedGlobally: t.isPausedGlobally
|
|
1620
|
+
};
|
|
485
1621
|
}
|
|
486
|
-
function
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
1622
|
+
function Vt(t) {
|
|
1623
|
+
return function() {
|
|
1624
|
+
const o = Xt();
|
|
1625
|
+
return Z.useEffect(() => {
|
|
1626
|
+
t(o);
|
|
1627
|
+
}, [o]), null;
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
function oe(t = {}) {
|
|
1631
|
+
const {
|
|
1632
|
+
position: n = "top-right",
|
|
1633
|
+
maxVisible: o = 5,
|
|
1634
|
+
duration: a = 5e3,
|
|
1635
|
+
layout: p = "default",
|
|
1636
|
+
dir: m = "ltr",
|
|
1637
|
+
historySize: E,
|
|
1638
|
+
sound: f,
|
|
1639
|
+
fallbackToNotification: y,
|
|
1640
|
+
swipeEnabled: B,
|
|
1641
|
+
swipeThreshold: G
|
|
1642
|
+
} = t;
|
|
1643
|
+
bt();
|
|
1644
|
+
const k = document.createElement("div");
|
|
1645
|
+
k.setAttribute("data-toast23-standalone", ""), k.style.display = "contents", document.body.appendChild(k);
|
|
1646
|
+
let R = At(k), b = null;
|
|
1647
|
+
const T = [];
|
|
1648
|
+
let C;
|
|
1649
|
+
const M = new Promise((s) => {
|
|
1650
|
+
C = s;
|
|
1651
|
+
}), v = Vt((s) => {
|
|
1652
|
+
for (b = s, C(s); T.length > 0; ) {
|
|
1653
|
+
const c = T.shift();
|
|
1654
|
+
try {
|
|
1655
|
+
c.method === "__call__" ? s(...c.args) : s[c.method](...c.args);
|
|
1656
|
+
} catch {
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
});
|
|
1660
|
+
R.render(
|
|
1661
|
+
Z.createElement(
|
|
1662
|
+
vt,
|
|
1663
|
+
{
|
|
1664
|
+
position: n,
|
|
1665
|
+
maxVisible: o,
|
|
1666
|
+
duration: a,
|
|
1667
|
+
layout: p,
|
|
1668
|
+
dir: m,
|
|
1669
|
+
...E !== void 0 && { historySize: E },
|
|
1670
|
+
...f !== void 0 && { sound: f },
|
|
1671
|
+
...y !== void 0 && { fallbackToNotification: y },
|
|
1672
|
+
...B !== void 0 && { swipeEnabled: B },
|
|
1673
|
+
...G !== void 0 && { swipeThreshold: G }
|
|
1674
|
+
},
|
|
1675
|
+
Z.createElement(v)
|
|
504
1676
|
)
|
|
505
1677
|
);
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
},
|
|
1678
|
+
const h = (s, ...c) => {
|
|
1679
|
+
if (b) return b[s](...c);
|
|
1680
|
+
T.push({ method: s, args: c });
|
|
1681
|
+
}, S = (s, c, A) => {
|
|
1682
|
+
if (b) return b[s](c, A);
|
|
1683
|
+
const I = A?.id ?? rt();
|
|
1684
|
+
return T.push({ method: s, args: [c, { ...A, id: I }] }), I;
|
|
1685
|
+
}, u = ((s, c) => {
|
|
1686
|
+
if (b) return b(s, c);
|
|
1687
|
+
const A = c?.id ?? rt();
|
|
1688
|
+
return T.push({ method: "__call__", args: [s, { ...c, id: A }] }), A;
|
|
1689
|
+
});
|
|
1690
|
+
return u.success = (s, c) => S("success", s, c), u.error = (s, c) => S("error", s, c), u.warning = (s, c) => S("warning", s, c), u.info = (s, c) => S("info", s, c), u.loading = (s, c) => S("loading", s, c), u.custom = (s, c) => S("custom", s, c), u.dismiss = (s) => h("dismiss", s), u.remove = (s) => h("remove", s), u.dismissGroup = (s) => h("dismissGroup", s), u.removeGroup = (s) => h("removeGroup", s), u.pauseAll = () => h("pauseAll"), u.resumeAll = () => h("resumeAll"), u.history = () => b ? b.history() : [], u.promise = (s, c, A) => b ? b.promise(s, c, A) : M.then((I) => I.promise(s, c, A)), u.confirm = (s, c) => b ? b.confirm(s, c) : M.then((A) => A.confirm(s, c)), u.destroy = () => {
|
|
1691
|
+
T.length = 0, R && (R.unmount(), R = null), k.remove(), b = null;
|
|
1692
|
+
}, u;
|
|
510
1693
|
}
|
|
511
1694
|
export {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
1695
|
+
Ut as Toast23DevTools,
|
|
1696
|
+
vt as Toast23Provider,
|
|
1697
|
+
oe as createToast23,
|
|
1698
|
+
Xt as useToast,
|
|
1699
|
+
ee as useToast23Headless
|
|
515
1700
|
};
|
|
516
1701
|
//# sourceMappingURL=index.mjs.map
|