@koide-labs/ui 0.0.13 → 0.0.14
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.
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { jsx as E, jsxs as
|
|
2
|
-
import { c as
|
|
3
|
-
import { Button as
|
|
4
|
-
import { Heading as
|
|
5
|
-
import { IconButton as
|
|
6
|
-
import { Surface as
|
|
7
|
-
import { Text as
|
|
8
|
-
import { View as
|
|
9
|
-
import { T as
|
|
1
|
+
import { jsx as E, jsxs as ae } from "react/jsx-runtime";
|
|
2
|
+
import { c as Ne } from "../../clsx-OuTLNxxd.js";
|
|
3
|
+
import { Button as it } from "../button/index.js";
|
|
4
|
+
import { Heading as at } from "../heading/index.js";
|
|
5
|
+
import { IconButton as ct } from "../icon-button/index.js";
|
|
6
|
+
import { Surface as ut } from "../surface/index.js";
|
|
7
|
+
import { Text as lt } from "../text/index.js";
|
|
8
|
+
import { View as Pe } from "../view/index.js";
|
|
9
|
+
import { T as ft, a as be, u as dt } from "../../use-toast-manager-Dq-44AuW.js";
|
|
10
10
|
import * as e from "react";
|
|
11
11
|
import { o as ne } from "../../owner-rKN292Q9.js";
|
|
12
|
-
import { u as
|
|
13
|
-
import { T as
|
|
14
|
-
import { h as
|
|
15
|
-
import { F as
|
|
16
|
-
import { v as
|
|
12
|
+
import { u as U } from "../../useStableCallback-CkTrVkNX.js";
|
|
13
|
+
import { T as Oe } from "../../useTimeout-CflX-kz3.js";
|
|
14
|
+
import { h as pe, f as re, m as Ee, e as Re } from "../../element-CZEOj04G.js";
|
|
15
|
+
import { F as pt } from "../../FloatingPortalLite-DVyq6YhV.js";
|
|
16
|
+
import { v as mt } from "../../visuallyHidden-CpJ-mhai.js";
|
|
17
17
|
import { F as Te } from "../../FloatingPortal-tWyuKRSN.js";
|
|
18
|
-
import { u as
|
|
19
|
-
import { d as
|
|
20
|
-
import * as
|
|
21
|
-
import { i as
|
|
22
|
-
import { u as
|
|
23
|
-
import { f as
|
|
24
|
-
import { a as
|
|
25
|
-
import { u as
|
|
26
|
-
import { u as
|
|
27
|
-
import '../../toast.css';let
|
|
28
|
-
function
|
|
29
|
-
return
|
|
18
|
+
import { u as oe } from "../../useRenderElement-DwToLA61.js";
|
|
19
|
+
import { d as Ce } from "../../floating-ui.utils.dom-C7FS5id0.js";
|
|
20
|
+
import * as ht from "react-dom";
|
|
21
|
+
import { i as gt } from "../../inertValue-BCYGsdmf.js";
|
|
22
|
+
import { u as me } from "../../useIsoLayoutEffect-CIDbvm3Q.js";
|
|
23
|
+
import { f as vt } from "../../formatErrorMessage-BqPuTBN-.js";
|
|
24
|
+
import { a as _t, t as wt } from "../../useOpenChangeComplete-Dse9kY9E.js";
|
|
25
|
+
import { u as He } from "../../useId-C5kyn6tA.js";
|
|
26
|
+
import { u as yt } from "../../useButton-DfIwsdb8.js";
|
|
27
|
+
import '../../toast.css';let Fe = 0;
|
|
28
|
+
function xt(f) {
|
|
29
|
+
return Fe += 1, `${f}-${Math.random().toString(36).slice(2, 6)}-${Fe}`;
|
|
30
30
|
}
|
|
31
31
|
function De(f, d) {
|
|
32
32
|
if (typeof f == "string")
|
|
@@ -34,292 +34,292 @@ function De(f, d) {
|
|
|
34
34
|
description: f
|
|
35
35
|
};
|
|
36
36
|
if (typeof f == "function") {
|
|
37
|
-
const
|
|
38
|
-
return typeof
|
|
39
|
-
description:
|
|
40
|
-
} :
|
|
37
|
+
const h = f(d);
|
|
38
|
+
return typeof h == "string" ? {
|
|
39
|
+
description: h
|
|
40
|
+
} : h;
|
|
41
41
|
}
|
|
42
42
|
return f;
|
|
43
43
|
}
|
|
44
|
-
const
|
|
44
|
+
const ke = function(d) {
|
|
45
45
|
const {
|
|
46
|
-
children:
|
|
46
|
+
children: h,
|
|
47
47
|
timeout: s = 5e3,
|
|
48
|
-
limit:
|
|
49
|
-
toastManager:
|
|
50
|
-
} = d, [
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
function
|
|
54
|
-
const m =
|
|
55
|
-
if (!Y.current || !
|
|
48
|
+
limit: F = 3,
|
|
49
|
+
toastManager: M
|
|
50
|
+
} = d, [y, a] = e.useState([]), [g, t] = e.useState(!1), [l, _] = e.useState(!1), [o, R] = e.useState(null);
|
|
51
|
+
y.length === 0 && (g && t(!1), l && _(!1));
|
|
52
|
+
const b = g || l, N = e.useRef(/* @__PURE__ */ new Map()), Y = e.useRef(null), C = e.useRef(!0), X = e.useRef(!1);
|
|
53
|
+
function j(n) {
|
|
54
|
+
const m = pe(ne(Y.current));
|
|
55
|
+
if (!Y.current || !re(Y.current, m) || !Ee(m))
|
|
56
56
|
return;
|
|
57
|
-
const
|
|
58
|
-
let
|
|
59
|
-
for (;
|
|
60
|
-
if (
|
|
61
|
-
|
|
57
|
+
const w = y.findIndex((r) => r.id === n);
|
|
58
|
+
let i = null, v = w + 1;
|
|
59
|
+
for (; v < y.length; ) {
|
|
60
|
+
if (y[v].transitionStatus !== "ending") {
|
|
61
|
+
i = y[v];
|
|
62
62
|
break;
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
v += 1;
|
|
65
65
|
}
|
|
66
|
-
if (!
|
|
67
|
-
for (
|
|
68
|
-
if (
|
|
69
|
-
|
|
66
|
+
if (!i)
|
|
67
|
+
for (v = w - 1; v >= 0; ) {
|
|
68
|
+
if (y[v].transitionStatus !== "ending") {
|
|
69
|
+
i = y[v];
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
v -= 1;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
i ? i.ref?.current?.focus() : o?.focus({
|
|
75
75
|
preventScroll: !0
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
const D =
|
|
79
|
-
X.current || (X.current = !0,
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
const m = Date.now() -
|
|
83
|
-
|
|
78
|
+
const D = U(() => {
|
|
79
|
+
X.current || (X.current = !0, N.current.forEach((n) => {
|
|
80
|
+
if (n.timeout) {
|
|
81
|
+
n.timeout.clear();
|
|
82
|
+
const m = Date.now() - n.start, w = n.delay - m;
|
|
83
|
+
n.remaining = w > 0 ? w : 0;
|
|
84
84
|
}
|
|
85
85
|
}));
|
|
86
|
-
}),
|
|
87
|
-
X.current && (X.current = !1,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}),
|
|
86
|
+
}), I = U(() => {
|
|
87
|
+
X.current && (X.current = !1, N.current.forEach((n, m) => {
|
|
88
|
+
n.remaining = n.remaining > 0 ? n.remaining : n.delay, n.timeout ??= Oe.create(), n.timeout.start(n.remaining, () => {
|
|
89
|
+
N.current.delete(m), n.callback();
|
|
90
|
+
}), n.start = Date.now();
|
|
91
91
|
}));
|
|
92
|
-
}),
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
...
|
|
92
|
+
}), L = U((n) => {
|
|
93
|
+
a((i) => {
|
|
94
|
+
const v = i.map((p) => p.id === n ? {
|
|
95
|
+
...p,
|
|
96
96
|
transitionStatus: "ending",
|
|
97
97
|
height: 0
|
|
98
|
-
} :
|
|
99
|
-
return
|
|
100
|
-
if (
|
|
101
|
-
return
|
|
102
|
-
const x =
|
|
98
|
+
} : p), r = v.filter((p) => p.transitionStatus !== "ending");
|
|
99
|
+
return v.map((p) => {
|
|
100
|
+
if (p.transitionStatus === "ending")
|
|
101
|
+
return p;
|
|
102
|
+
const x = r.indexOf(p) >= F;
|
|
103
103
|
return {
|
|
104
|
-
...
|
|
104
|
+
...p,
|
|
105
105
|
limited: x
|
|
106
106
|
};
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
|
-
const m =
|
|
110
|
-
m && m.timeout && (m.timeout.clear(),
|
|
111
|
-
}), q =
|
|
112
|
-
|
|
113
|
-
}), V =
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}),
|
|
118
|
-
timeout:
|
|
119
|
-
start:
|
|
109
|
+
const m = N.current.get(n);
|
|
110
|
+
m && m.timeout && (m.timeout.clear(), N.current.delete(n)), y.find((i) => i.id === n)?.onClose?.(), j(n), y.length === 1 && (t(!1), _(!1));
|
|
111
|
+
}), q = U((n) => {
|
|
112
|
+
a((w) => w.filter((i) => i.id !== n)), y.find((w) => w.id === n)?.onRemove?.();
|
|
113
|
+
}), V = U((n, m, w) => {
|
|
114
|
+
const i = Date.now(), v = C.current && !g && !l, r = v ? Oe.create() : void 0;
|
|
115
|
+
r?.start(m, () => {
|
|
116
|
+
N.current.delete(n), w();
|
|
117
|
+
}), N.current.set(n, {
|
|
118
|
+
timeout: r,
|
|
119
|
+
start: v ? i : 0,
|
|
120
120
|
delay: m,
|
|
121
121
|
remaining: m,
|
|
122
|
-
callback:
|
|
122
|
+
callback: w
|
|
123
123
|
});
|
|
124
|
-
}), G =
|
|
125
|
-
const m =
|
|
126
|
-
...
|
|
124
|
+
}), G = U((n) => {
|
|
125
|
+
const m = n.id || xt("toast"), w = {
|
|
126
|
+
...n,
|
|
127
127
|
id: m,
|
|
128
128
|
transitionStatus: "starting"
|
|
129
129
|
};
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
if (
|
|
133
|
-
const x =
|
|
134
|
-
return
|
|
135
|
-
...
|
|
130
|
+
a((v) => {
|
|
131
|
+
const r = [w, ...v], p = r.filter((x) => x.transitionStatus !== "ending");
|
|
132
|
+
if (p.length > F) {
|
|
133
|
+
const x = p.length - F, T = p.slice(-x);
|
|
134
|
+
return r.map((H) => T.some((Z) => Z.id === H.id) ? {
|
|
135
|
+
...H,
|
|
136
136
|
limited: !0
|
|
137
137
|
} : {
|
|
138
|
-
...
|
|
138
|
+
...H,
|
|
139
139
|
limited: !1
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
|
-
return
|
|
142
|
+
return r.map((x) => ({
|
|
143
143
|
...x,
|
|
144
144
|
limited: !1
|
|
145
145
|
}));
|
|
146
146
|
});
|
|
147
|
-
const
|
|
148
|
-
return
|
|
149
|
-
}), K =
|
|
150
|
-
|
|
151
|
-
...
|
|
147
|
+
const i = w.timeout ?? s;
|
|
148
|
+
return w.type !== "loading" && i > 0 && V(m, i, () => L(m)), (g || l || !C.current) && D(), m;
|
|
149
|
+
}), K = U((n, m) => {
|
|
150
|
+
a((w) => w.map((i) => i.id === n ? {
|
|
151
|
+
...i,
|
|
152
152
|
...m
|
|
153
|
-
} :
|
|
154
|
-
}), O =
|
|
155
|
-
const
|
|
156
|
-
...
|
|
153
|
+
} : i));
|
|
154
|
+
}), O = U((n, m) => {
|
|
155
|
+
const w = De(m.loading), i = G({
|
|
156
|
+
...w,
|
|
157
157
|
type: "loading"
|
|
158
|
-
}),
|
|
159
|
-
const
|
|
160
|
-
K(
|
|
161
|
-
...
|
|
158
|
+
}), v = n.then((r) => {
|
|
159
|
+
const p = De(m.success, r);
|
|
160
|
+
K(i, {
|
|
161
|
+
...p,
|
|
162
162
|
type: "success"
|
|
163
163
|
});
|
|
164
|
-
const x =
|
|
165
|
-
return x > 0 && V(
|
|
166
|
-
}).catch((
|
|
167
|
-
const
|
|
168
|
-
K(
|
|
169
|
-
...
|
|
164
|
+
const x = p.timeout ?? s;
|
|
165
|
+
return x > 0 && V(i, x, () => L(i)), (g || l || !C.current) && D(), r;
|
|
166
|
+
}).catch((r) => {
|
|
167
|
+
const p = De(m.error, r);
|
|
168
|
+
K(i, {
|
|
169
|
+
...p,
|
|
170
170
|
type: "error"
|
|
171
171
|
});
|
|
172
|
-
const x =
|
|
173
|
-
return x > 0 && V(
|
|
172
|
+
const x = p.timeout ?? s;
|
|
173
|
+
return x > 0 && V(i, x, () => L(i)), (g || l || !C.current) && D(), Promise.reject(r);
|
|
174
174
|
});
|
|
175
|
-
return {}.hasOwnProperty.call(m, "setPromise") && m.setPromise(
|
|
175
|
+
return {}.hasOwnProperty.call(m, "setPromise") && m.setPromise(v), v;
|
|
176
176
|
});
|
|
177
177
|
e.useEffect(function() {
|
|
178
|
-
return
|
|
179
|
-
action:
|
|
180
|
-
options:
|
|
178
|
+
return M ? M[" subscribe"](({
|
|
179
|
+
action: w,
|
|
180
|
+
options: i
|
|
181
181
|
}) => {
|
|
182
|
-
const
|
|
183
|
-
|
|
182
|
+
const v = i.id;
|
|
183
|
+
w === "promise" && i.promise ? O(i.promise, i) : w === "update" && v ? K(v, i) : w === "close" && v ? L(v) : G(i);
|
|
184
184
|
}) : void 0;
|
|
185
|
-
}, [G, K, V, s,
|
|
185
|
+
}, [G, K, V, s, M, O, L]);
|
|
186
186
|
const J = e.useMemo(() => ({
|
|
187
|
-
toasts:
|
|
188
|
-
setToasts:
|
|
189
|
-
hovering:
|
|
190
|
-
setHovering:
|
|
191
|
-
focused:
|
|
192
|
-
setFocused:
|
|
193
|
-
expanded:
|
|
187
|
+
toasts: y,
|
|
188
|
+
setToasts: a,
|
|
189
|
+
hovering: g,
|
|
190
|
+
setHovering: t,
|
|
191
|
+
focused: l,
|
|
192
|
+
setFocused: _,
|
|
193
|
+
expanded: b,
|
|
194
194
|
add: G,
|
|
195
|
-
close:
|
|
195
|
+
close: L,
|
|
196
196
|
remove: q,
|
|
197
197
|
update: K,
|
|
198
198
|
promise: O,
|
|
199
199
|
pauseTimers: D,
|
|
200
|
-
resumeTimers:
|
|
201
|
-
prevFocusElement:
|
|
200
|
+
resumeTimers: I,
|
|
201
|
+
prevFocusElement: o,
|
|
202
202
|
setPrevFocusElement: R,
|
|
203
203
|
viewportRef: Y,
|
|
204
204
|
scheduleTimer: V,
|
|
205
205
|
windowFocusedRef: C
|
|
206
|
-
}), [G,
|
|
207
|
-
return /* @__PURE__ */ E(
|
|
206
|
+
}), [G, L, l, g, b, D, o, O, q, I, V, y, K]);
|
|
207
|
+
return /* @__PURE__ */ E(ft.Provider, {
|
|
208
208
|
value: J,
|
|
209
|
-
children:
|
|
209
|
+
children: h
|
|
210
210
|
});
|
|
211
211
|
};
|
|
212
|
-
process.env.NODE_ENV !== "production" && (
|
|
213
|
-
const
|
|
214
|
-
process.env.NODE_ENV !== "production" && (
|
|
215
|
-
let
|
|
212
|
+
process.env.NODE_ENV !== "production" && (ke.displayName = "ToastProvider");
|
|
213
|
+
const ze = /* @__PURE__ */ e.createContext(void 0);
|
|
214
|
+
process.env.NODE_ENV !== "production" && (ze.displayName = "ToastViewportContext");
|
|
215
|
+
let Tt = /* @__PURE__ */ (function(f) {
|
|
216
216
|
return f.frontmostHeight = "--toast-frontmost-height", f;
|
|
217
217
|
})({});
|
|
218
|
-
const
|
|
218
|
+
const Ve = /* @__PURE__ */ e.forwardRef(function(d, h) {
|
|
219
219
|
const {
|
|
220
220
|
render: s,
|
|
221
|
-
className:
|
|
222
|
-
children:
|
|
223
|
-
...
|
|
221
|
+
className: F,
|
|
222
|
+
children: M,
|
|
223
|
+
...y
|
|
224
224
|
} = d, {
|
|
225
|
-
toasts:
|
|
226
|
-
pauseTimers:
|
|
227
|
-
resumeTimers:
|
|
228
|
-
setHovering:
|
|
229
|
-
setFocused:
|
|
230
|
-
viewportRef:
|
|
225
|
+
toasts: a,
|
|
226
|
+
pauseTimers: g,
|
|
227
|
+
resumeTimers: t,
|
|
228
|
+
setHovering: l,
|
|
229
|
+
setFocused: _,
|
|
230
|
+
viewportRef: o,
|
|
231
231
|
windowFocusedRef: R,
|
|
232
|
-
prevFocusElement:
|
|
233
|
-
setPrevFocusElement:
|
|
232
|
+
prevFocusElement: b,
|
|
233
|
+
setPrevFocusElement: N,
|
|
234
234
|
expanded: Y,
|
|
235
235
|
focused: C
|
|
236
|
-
} =
|
|
236
|
+
} = be(), X = e.useRef(!1), j = e.useRef(!1), D = a.length, I = a[0]?.height ?? 0, L = e.useMemo(() => a.some((r) => r.transitionStatus === "ending"), [a]);
|
|
237
237
|
e.useEffect(() => {
|
|
238
|
-
if (!
|
|
238
|
+
if (!o.current)
|
|
239
239
|
return;
|
|
240
|
-
function
|
|
241
|
-
D !== 0 && x.key === "F6" && x.target !==
|
|
240
|
+
function r(x) {
|
|
241
|
+
D !== 0 && x.key === "F6" && x.target !== o.current && (x.preventDefault(), N(pe(ne(o.current))), o.current?.focus({
|
|
242
242
|
preventScroll: !0
|
|
243
|
-
}),
|
|
243
|
+
}), g(), _(!0));
|
|
244
244
|
}
|
|
245
|
-
const
|
|
246
|
-
return
|
|
247
|
-
|
|
245
|
+
const p = Ce(o.current);
|
|
246
|
+
return p.addEventListener("keydown", r), () => {
|
|
247
|
+
p.removeEventListener("keydown", r);
|
|
248
248
|
};
|
|
249
|
-
}, [
|
|
250
|
-
if (!
|
|
249
|
+
}, [g, _, N, D, o]), e.useEffect(() => {
|
|
250
|
+
if (!o.current || !D)
|
|
251
251
|
return;
|
|
252
|
-
const
|
|
253
|
-
function
|
|
254
|
-
T.target ===
|
|
252
|
+
const r = Ce(o.current);
|
|
253
|
+
function p(T) {
|
|
254
|
+
T.target === r && (R.current = !1, g());
|
|
255
255
|
}
|
|
256
256
|
function x(T) {
|
|
257
|
-
if (T.relatedTarget || T.target ===
|
|
257
|
+
if (T.relatedTarget || T.target === r)
|
|
258
258
|
return;
|
|
259
|
-
const
|
|
260
|
-
(!
|
|
259
|
+
const H = Re(T), Z = pe(ne(o.current));
|
|
260
|
+
(!re(o.current, H) || !Ee(Z)) && t(), setTimeout(() => {
|
|
261
261
|
R.current = !0;
|
|
262
262
|
});
|
|
263
263
|
}
|
|
264
|
-
return
|
|
265
|
-
|
|
264
|
+
return r.addEventListener("blur", p, !0), r.addEventListener("focus", x, !0), () => {
|
|
265
|
+
r.removeEventListener("blur", p, !0), r.removeEventListener("focus", x, !0);
|
|
266
266
|
};
|
|
267
267
|
}, [
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
268
|
+
g,
|
|
269
|
+
t,
|
|
270
|
+
o,
|
|
271
271
|
R,
|
|
272
|
-
|
|
272
|
+
_,
|
|
273
273
|
// `viewportRef.current` isn't available on the first render,
|
|
274
274
|
// since the portal node hasn't yet been created.
|
|
275
275
|
// By adding this dependency, we ensure the window listeners
|
|
276
276
|
// are added when toasts have been created, once the ref is available.
|
|
277
277
|
D
|
|
278
278
|
]), e.useEffect(() => {
|
|
279
|
-
const
|
|
280
|
-
if (!
|
|
279
|
+
const r = o.current;
|
|
280
|
+
if (!r || D === 0)
|
|
281
281
|
return;
|
|
282
|
-
const
|
|
282
|
+
const p = ne(r);
|
|
283
283
|
function x(T) {
|
|
284
284
|
if (T.pointerType !== "touch")
|
|
285
285
|
return;
|
|
286
|
-
const
|
|
287
|
-
|
|
286
|
+
const H = Re(T);
|
|
287
|
+
re(r, H) || (t(), l(!1), _(!1));
|
|
288
288
|
}
|
|
289
|
-
return
|
|
290
|
-
|
|
289
|
+
return p.addEventListener("pointerdown", x, !0), () => {
|
|
290
|
+
p.removeEventListener("pointerdown", x, !0);
|
|
291
291
|
};
|
|
292
|
-
}, [D,
|
|
293
|
-
function q(
|
|
294
|
-
|
|
292
|
+
}, [D, t, _, l, o]);
|
|
293
|
+
function q(r) {
|
|
294
|
+
o.current && (X.current = !0, r.relatedTarget === o.current ? a[0]?.ref?.current?.focus() : b?.focus({
|
|
295
295
|
preventScroll: !0
|
|
296
296
|
}));
|
|
297
297
|
}
|
|
298
|
-
function V(
|
|
299
|
-
|
|
298
|
+
function V(r) {
|
|
299
|
+
r.key === "Tab" && r.shiftKey && r.target === o.current && (r.preventDefault(), b?.focus({
|
|
300
300
|
preventScroll: !0
|
|
301
|
-
}),
|
|
301
|
+
}), t());
|
|
302
302
|
}
|
|
303
303
|
e.useEffect(() => {
|
|
304
|
-
!R.current ||
|
|
305
|
-
}, [
|
|
304
|
+
!R.current || L || !j.current || (t(), l(!1), j.current = !1);
|
|
305
|
+
}, [L, t, l, R]);
|
|
306
306
|
function G() {
|
|
307
|
-
|
|
307
|
+
g(), l(!0), j.current = !1;
|
|
308
308
|
}
|
|
309
309
|
function K() {
|
|
310
|
-
|
|
310
|
+
a.some((r) => r.transitionStatus === "ending") ? j.current = !0 : (t(), l(!1));
|
|
311
311
|
}
|
|
312
312
|
function O() {
|
|
313
313
|
if (X.current) {
|
|
314
314
|
X.current = !1;
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
317
|
-
C || Ee(ne(
|
|
317
|
+
C || Ee(ne(o.current).activeElement) && (_(!0), g());
|
|
318
318
|
}
|
|
319
|
-
function J(
|
|
320
|
-
!C ||
|
|
319
|
+
function J(r) {
|
|
320
|
+
!C || re(o.current, r.relatedTarget) || (_(!1), t());
|
|
321
321
|
}
|
|
322
|
-
const
|
|
322
|
+
const n = {
|
|
323
323
|
tabIndex: -1,
|
|
324
324
|
role: "region",
|
|
325
325
|
"aria-live": "polite",
|
|
@@ -335,69 +335,69 @@ const ke = /* @__PURE__ */ e.forwardRef(function(d, w) {
|
|
|
335
335
|
onClick: O
|
|
336
336
|
}, m = e.useMemo(() => ({
|
|
337
337
|
expanded: Y
|
|
338
|
-
}), [Y]),
|
|
339
|
-
ref: [
|
|
338
|
+
}), [Y]), w = oe("div", d, {
|
|
339
|
+
ref: [h, o],
|
|
340
340
|
state: m,
|
|
341
|
-
props: [
|
|
341
|
+
props: [n, {
|
|
342
342
|
style: {
|
|
343
|
-
[
|
|
343
|
+
[Tt.frontmostHeight]: I ? `${I}px` : void 0
|
|
344
344
|
}
|
|
345
|
-
},
|
|
346
|
-
children: /* @__PURE__ */
|
|
347
|
-
children: [D > 0 &&
|
|
345
|
+
}, y, {
|
|
346
|
+
children: /* @__PURE__ */ ae(e.Fragment, {
|
|
347
|
+
children: [D > 0 && b && /* @__PURE__ */ E(Te, {
|
|
348
348
|
onFocus: q
|
|
349
|
-
}),
|
|
349
|
+
}), M, D > 0 && b && /* @__PURE__ */ E(Te, {
|
|
350
350
|
onFocus: q
|
|
351
351
|
})]
|
|
352
352
|
})
|
|
353
353
|
}]
|
|
354
|
-
}),
|
|
355
|
-
viewportRef:
|
|
356
|
-
}), [
|
|
357
|
-
return /* @__PURE__ */
|
|
358
|
-
value:
|
|
359
|
-
children: [D > 0 &&
|
|
354
|
+
}), i = e.useMemo(() => ({
|
|
355
|
+
viewportRef: o
|
|
356
|
+
}), [o]), v = e.useMemo(() => a.filter((r) => r.priority === "high"), [a]);
|
|
357
|
+
return /* @__PURE__ */ ae(ze.Provider, {
|
|
358
|
+
value: i,
|
|
359
|
+
children: [D > 0 && b && /* @__PURE__ */ E(Te, {
|
|
360
360
|
onFocus: q
|
|
361
|
-
}),
|
|
362
|
-
style:
|
|
363
|
-
children:
|
|
361
|
+
}), w, !C && v.length > 0 && /* @__PURE__ */ E("div", {
|
|
362
|
+
style: mt,
|
|
363
|
+
children: v.map((r) => /* @__PURE__ */ ae("div", {
|
|
364
364
|
role: "alert",
|
|
365
365
|
"aria-atomic": !0,
|
|
366
366
|
children: [/* @__PURE__ */ E("div", {
|
|
367
|
-
children:
|
|
367
|
+
children: r.title
|
|
368
368
|
}), /* @__PURE__ */ E("div", {
|
|
369
|
-
children:
|
|
369
|
+
children: r.description
|
|
370
370
|
})]
|
|
371
|
-
},
|
|
371
|
+
}, r.id))
|
|
372
372
|
})]
|
|
373
373
|
});
|
|
374
374
|
});
|
|
375
|
-
process.env.NODE_ENV !== "production" && (
|
|
376
|
-
const
|
|
377
|
-
process.env.NODE_ENV !== "production" && (
|
|
378
|
-
function
|
|
379
|
-
const f = e.useContext(
|
|
375
|
+
process.env.NODE_ENV !== "production" && (Ve.displayName = "ToastViewport");
|
|
376
|
+
const Se = /* @__PURE__ */ e.createContext(void 0);
|
|
377
|
+
process.env.NODE_ENV !== "production" && (Se.displayName = "ToastRootContext");
|
|
378
|
+
function se() {
|
|
379
|
+
const f = e.useContext(Se);
|
|
380
380
|
if (!f)
|
|
381
|
-
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: ToastRootContext is missing. Toast parts must be used within <Toast.Root>." :
|
|
381
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: ToastRootContext is missing. Toast parts must be used within <Toast.Root>." : vt(66));
|
|
382
382
|
return f;
|
|
383
383
|
}
|
|
384
384
|
let ee = /* @__PURE__ */ (function(f) {
|
|
385
385
|
return f.index = "--toast-index", f.offsetY = "--toast-offset-y", f.height = "--toast-height", f.swipeMovementX = "--toast-swipe-movement-x", f.swipeMovementY = "--toast-swipe-movement-y", f;
|
|
386
386
|
})({});
|
|
387
|
-
const
|
|
387
|
+
const Dt = {
|
|
388
388
|
...wt,
|
|
389
389
|
swipeDirection(f) {
|
|
390
390
|
return f ? {
|
|
391
391
|
"data-swipe-direction": f
|
|
392
392
|
} : null;
|
|
393
393
|
}
|
|
394
|
-
},
|
|
395
|
-
function
|
|
394
|
+
}, ie = 40, Et = 10, Q = 0.5, Rt = 1;
|
|
395
|
+
function Ie(f, d, h) {
|
|
396
396
|
switch (f) {
|
|
397
397
|
case "up":
|
|
398
|
-
return -
|
|
398
|
+
return -h;
|
|
399
399
|
case "down":
|
|
400
|
-
return
|
|
400
|
+
return h;
|
|
401
401
|
case "left":
|
|
402
402
|
return -d;
|
|
403
403
|
case "right":
|
|
@@ -407,458 +407,503 @@ function Fe(f, d, w) {
|
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
function bt(f) {
|
|
410
|
-
const
|
|
411
|
-
let s = 0,
|
|
412
|
-
if (
|
|
413
|
-
const
|
|
414
|
-
if (
|
|
415
|
-
const
|
|
416
|
-
|
|
410
|
+
const h = window.getComputedStyle(f).transform;
|
|
411
|
+
let s = 0, F = 0, M = 1;
|
|
412
|
+
if (h && h !== "none") {
|
|
413
|
+
const y = h.match(/matrix(?:3d)?\(([^)]+)\)/);
|
|
414
|
+
if (y) {
|
|
415
|
+
const a = y[1].split(", ").map(parseFloat);
|
|
416
|
+
a.length === 6 ? (s = a[4], F = a[5], M = Math.sqrt(a[0] * a[0] + a[1] * a[1])) : a.length === 16 && (s = a[12], F = a[13], M = a[0]);
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
return {
|
|
420
420
|
x: s,
|
|
421
|
-
y:
|
|
422
|
-
scale:
|
|
421
|
+
y: F,
|
|
422
|
+
scale: M
|
|
423
423
|
};
|
|
424
424
|
}
|
|
425
|
-
const
|
|
425
|
+
const $e = /* @__PURE__ */ e.forwardRef(function(d, h) {
|
|
426
426
|
const {
|
|
427
427
|
toast: s,
|
|
428
|
-
render:
|
|
429
|
-
className:
|
|
430
|
-
swipeDirection:
|
|
431
|
-
...
|
|
432
|
-
} = d,
|
|
433
|
-
let
|
|
434
|
-
|
|
435
|
-
const
|
|
436
|
-
toasts:
|
|
437
|
-
focused:
|
|
428
|
+
render: F,
|
|
429
|
+
className: M,
|
|
430
|
+
swipeDirection: y = ["down", "right"],
|
|
431
|
+
...a
|
|
432
|
+
} = d, g = s.positionerProps?.anchor !== void 0;
|
|
433
|
+
let t = [];
|
|
434
|
+
g || (t = Array.isArray(y) ? y : [y]);
|
|
435
|
+
const l = t.length > 0, {
|
|
436
|
+
toasts: _,
|
|
437
|
+
focused: o,
|
|
438
438
|
close: R,
|
|
439
|
-
remove:
|
|
440
|
-
setToasts:
|
|
439
|
+
remove: b,
|
|
440
|
+
setToasts: N,
|
|
441
441
|
pauseTimers: Y,
|
|
442
442
|
expanded: C,
|
|
443
443
|
setHovering: X
|
|
444
|
-
} =
|
|
444
|
+
} = be(), [j, D] = e.useState(void 0), [I, L] = e.useState(!1), [q, V] = e.useState(!1), [G, K] = e.useState(!1), [O, J] = e.useState({
|
|
445
445
|
x: 0,
|
|
446
446
|
y: 0
|
|
447
|
-
}), [
|
|
447
|
+
}), [n, m] = e.useState({
|
|
448
448
|
x: 0,
|
|
449
449
|
y: 0,
|
|
450
450
|
scale: 1
|
|
451
|
-
}), [
|
|
451
|
+
}), [w, i] = e.useState(), [v, r] = e.useState(), [p, x] = e.useState(null), T = e.useRef(null), H = e.useRef({
|
|
452
452
|
x: 0,
|
|
453
453
|
y: 0
|
|
454
454
|
}), Z = e.useRef({
|
|
455
455
|
x: 0,
|
|
456
456
|
y: 0,
|
|
457
457
|
scale: 1
|
|
458
|
-
}),
|
|
458
|
+
}), ce = e.useRef(void 0), he = e.useRef(0), ue = e.useRef(!1), $ = e.useRef({
|
|
459
459
|
x: 0,
|
|
460
460
|
y: 0
|
|
461
|
-
}),
|
|
462
|
-
|
|
461
|
+
}), ge = e.useRef(!1), ve = e.useMemo(() => _.indexOf(s), [s, _]), _e = e.useMemo(() => _.filter((c) => c.transitionStatus !== "ending").indexOf(s), [s, _]), Ge = e.useMemo(() => _.slice(0, _.indexOf(s)).reduce((c, u) => c + (u.height || 0), 0), [_, s]);
|
|
462
|
+
_t({
|
|
463
463
|
open: s.transitionStatus !== "ending",
|
|
464
464
|
ref: T,
|
|
465
465
|
onComplete() {
|
|
466
|
-
s.transitionStatus === "ending" &&
|
|
466
|
+
s.transitionStatus === "ending" && b(s.id);
|
|
467
467
|
}
|
|
468
468
|
});
|
|
469
|
-
const
|
|
470
|
-
const
|
|
471
|
-
if (!
|
|
469
|
+
const le = U((c = !1) => {
|
|
470
|
+
const u = T.current;
|
|
471
|
+
if (!u)
|
|
472
472
|
return;
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
function
|
|
478
|
-
|
|
479
|
-
...
|
|
473
|
+
const S = u.style.height;
|
|
474
|
+
u.style.height = "auto";
|
|
475
|
+
const P = u.offsetHeight;
|
|
476
|
+
u.style.height = S;
|
|
477
|
+
function B() {
|
|
478
|
+
N((k) => k.map((z) => z.id === s.id ? {
|
|
479
|
+
...z,
|
|
480
480
|
ref: T,
|
|
481
|
-
height:
|
|
481
|
+
height: P,
|
|
482
482
|
transitionStatus: void 0
|
|
483
|
-
} :
|
|
483
|
+
} : z));
|
|
484
484
|
}
|
|
485
|
-
|
|
485
|
+
c ? ht.flushSync(B) : B();
|
|
486
486
|
});
|
|
487
|
-
|
|
488
|
-
function
|
|
489
|
-
let
|
|
490
|
-
return !
|
|
491
|
-
x:
|
|
492
|
-
y:
|
|
487
|
+
me(le, [le]);
|
|
488
|
+
function Ke(c, u) {
|
|
489
|
+
let S = c, P = u;
|
|
490
|
+
return !t.includes("left") && !t.includes("right") ? S = c > 0 ? c ** Q : -(Math.abs(c) ** Q) : (!t.includes("right") && c > 0 && (S = c ** Q), !t.includes("left") && c < 0 && (S = -(Math.abs(c) ** Q))), !t.includes("up") && !t.includes("down") ? P = u > 0 ? u ** Q : -(Math.abs(u) ** Q) : (!t.includes("down") && u > 0 && (P = u ** Q), !t.includes("up") && u < 0 && (P = -(Math.abs(u) ** Q))), {
|
|
491
|
+
x: S,
|
|
492
|
+
y: P
|
|
493
493
|
};
|
|
494
494
|
}
|
|
495
|
-
function
|
|
496
|
-
if (
|
|
495
|
+
function We(c) {
|
|
496
|
+
if (c.button !== 0)
|
|
497
497
|
return;
|
|
498
|
-
|
|
499
|
-
const
|
|
500
|
-
if (!(
|
|
501
|
-
if (
|
|
502
|
-
x:
|
|
503
|
-
y:
|
|
504
|
-
}, $.current =
|
|
505
|
-
const
|
|
506
|
-
Z.current =
|
|
507
|
-
x:
|
|
508
|
-
y:
|
|
498
|
+
c.pointerType === "touch" && Y();
|
|
499
|
+
const u = Re(c.nativeEvent);
|
|
500
|
+
if (!(u && u.closest('button,a,input,textarea,[role="button"],[data-swipe-ignore]'))) {
|
|
501
|
+
if (ue.current = !1, ce.current = void 0, he.current = 0, H.current = {
|
|
502
|
+
x: c.clientX,
|
|
503
|
+
y: c.clientY
|
|
504
|
+
}, $.current = H.current, T.current) {
|
|
505
|
+
const P = bt(T.current);
|
|
506
|
+
Z.current = P, m(P), J({
|
|
507
|
+
x: P.x,
|
|
508
|
+
y: P.y
|
|
509
509
|
});
|
|
510
510
|
}
|
|
511
|
-
X(!0),
|
|
511
|
+
X(!0), L(!0), V(!1), x(null), ge.current = !0, T.current?.setPointerCapture(c.pointerId);
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
|
-
function
|
|
515
|
-
if (!
|
|
514
|
+
function je(c) {
|
|
515
|
+
if (!I)
|
|
516
516
|
return;
|
|
517
|
-
|
|
518
|
-
x:
|
|
519
|
-
y:
|
|
520
|
-
},
|
|
517
|
+
c.preventDefault(), ge.current && (H.current = {
|
|
518
|
+
x: c.clientX,
|
|
519
|
+
y: c.clientY
|
|
520
|
+
}, ge.current = !1);
|
|
521
521
|
const {
|
|
522
|
-
clientY:
|
|
523
|
-
clientX:
|
|
524
|
-
movementX:
|
|
525
|
-
movementY:
|
|
526
|
-
} =
|
|
527
|
-
(
|
|
522
|
+
clientY: u,
|
|
523
|
+
clientX: S,
|
|
524
|
+
movementX: P,
|
|
525
|
+
movementY: B
|
|
526
|
+
} = c;
|
|
527
|
+
(B < 0 && u > $.current.y || B > 0 && u < $.current.y) && ($.current = {
|
|
528
528
|
x: $.current.x,
|
|
529
|
-
y:
|
|
530
|
-
}), (
|
|
531
|
-
x:
|
|
529
|
+
y: u
|
|
530
|
+
}), (P < 0 && S > $.current.x || P > 0 && S < $.current.x) && ($.current = {
|
|
531
|
+
x: S,
|
|
532
532
|
y: $.current.y
|
|
533
533
|
});
|
|
534
|
-
const
|
|
535
|
-
if (!q && Math.sqrt(
|
|
536
|
-
const
|
|
537
|
-
if (
|
|
538
|
-
const
|
|
539
|
-
x(
|
|
534
|
+
const k = S - H.current.x, z = u - H.current.y, tt = u - $.current.y, nt = S - $.current.x;
|
|
535
|
+
if (!q && Math.sqrt(k * k + z * z) >= Rt && (V(!0), p === null)) {
|
|
536
|
+
const de = t.includes("left") || t.includes("right"), rt = t.includes("up") || t.includes("down");
|
|
537
|
+
if (de && rt) {
|
|
538
|
+
const st = Math.abs(k), ot = Math.abs(z);
|
|
539
|
+
x(st > ot ? "horizontal" : "vertical");
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
|
-
let
|
|
543
|
-
if (!
|
|
544
|
-
|
|
542
|
+
let A;
|
|
543
|
+
if (!ce.current)
|
|
544
|
+
p === "vertical" ? z > 0 ? A = "down" : z < 0 && (A = "up") : p === "horizontal" ? k > 0 ? A = "right" : k < 0 && (A = "left") : Math.abs(k) >= Math.abs(z) ? A = k > 0 ? "right" : "left" : A = z > 0 ? "down" : "up", A && t.includes(A) && (ce.current = A, he.current = Ie(A, k, z), D(A));
|
|
545
545
|
else {
|
|
546
|
-
const
|
|
547
|
-
|
|
546
|
+
const xe = ce.current, de = Ie(xe, nt, tt);
|
|
547
|
+
de > ie ? (ue.current = !1, D(xe)) : !(t.includes("left") && t.includes("right")) && !(t.includes("up") && t.includes("down")) && he.current - de >= Et && (ue.current = !0);
|
|
548
548
|
}
|
|
549
|
-
const
|
|
550
|
-
let
|
|
551
|
-
|
|
552
|
-
x:
|
|
553
|
-
y:
|
|
549
|
+
const fe = Ke(k, z);
|
|
550
|
+
let we = Z.current.x, ye = Z.current.y;
|
|
551
|
+
p === "horizontal" ? (t.includes("left") || t.includes("right")) && (we += fe.x) : (p === "vertical" || (t.includes("left") || t.includes("right")) && (we += fe.x), (t.includes("up") || t.includes("down")) && (ye += fe.y)), J({
|
|
552
|
+
x: we,
|
|
553
|
+
y: ye
|
|
554
554
|
});
|
|
555
555
|
}
|
|
556
|
-
function
|
|
557
|
-
if (!
|
|
556
|
+
function Ue(c) {
|
|
557
|
+
if (!I)
|
|
558
558
|
return;
|
|
559
|
-
if (
|
|
559
|
+
if (L(!1), V(!1), x(null), T.current?.releasePointerCapture(c.pointerId), ue.current) {
|
|
560
560
|
J({
|
|
561
|
-
x:
|
|
562
|
-
y:
|
|
561
|
+
x: n.x,
|
|
562
|
+
y: n.y
|
|
563
563
|
}), D(void 0);
|
|
564
564
|
return;
|
|
565
565
|
}
|
|
566
|
-
let
|
|
567
|
-
const
|
|
568
|
-
let
|
|
569
|
-
for (const
|
|
570
|
-
switch (
|
|
566
|
+
let u = !1;
|
|
567
|
+
const S = O.x - n.x, P = O.y - n.y;
|
|
568
|
+
let B;
|
|
569
|
+
for (const k of t) {
|
|
570
|
+
switch (k) {
|
|
571
571
|
case "right":
|
|
572
|
-
|
|
572
|
+
S > ie && (u = !0, B = "right");
|
|
573
573
|
break;
|
|
574
574
|
case "left":
|
|
575
|
-
|
|
575
|
+
S < -ie && (u = !0, B = "left");
|
|
576
576
|
break;
|
|
577
577
|
case "down":
|
|
578
|
-
|
|
578
|
+
P > ie && (u = !0, B = "down");
|
|
579
579
|
break;
|
|
580
580
|
case "up":
|
|
581
|
-
|
|
581
|
+
P < -ie && (u = !0, B = "up");
|
|
582
582
|
break;
|
|
583
583
|
}
|
|
584
|
-
if (
|
|
584
|
+
if (u)
|
|
585
585
|
break;
|
|
586
586
|
}
|
|
587
|
-
|
|
588
|
-
x:
|
|
589
|
-
y:
|
|
587
|
+
u ? (D(B), K(!0), R(s.id)) : (J({
|
|
588
|
+
x: n.x,
|
|
589
|
+
y: n.y
|
|
590
590
|
}), D(void 0));
|
|
591
591
|
}
|
|
592
|
-
function
|
|
593
|
-
if (
|
|
594
|
-
if (!T.current || !
|
|
592
|
+
function qe(c) {
|
|
593
|
+
if (c.key === "Escape") {
|
|
594
|
+
if (!T.current || !re(T.current, pe(ne(T.current))))
|
|
595
595
|
return;
|
|
596
596
|
R(s.id);
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
e.useEffect(() => {
|
|
600
|
-
if (!
|
|
600
|
+
if (!l)
|
|
601
601
|
return;
|
|
602
|
-
const
|
|
603
|
-
if (!
|
|
602
|
+
const c = T.current;
|
|
603
|
+
if (!c)
|
|
604
604
|
return;
|
|
605
|
-
function
|
|
606
|
-
|
|
605
|
+
function u(S) {
|
|
606
|
+
re(c, S.target) && S.preventDefault();
|
|
607
607
|
}
|
|
608
|
-
return
|
|
608
|
+
return c.addEventListener("touchmove", u, {
|
|
609
609
|
passive: !1
|
|
610
610
|
}), () => {
|
|
611
|
-
|
|
611
|
+
c.removeEventListener("touchmove", u);
|
|
612
612
|
};
|
|
613
|
-
}, [
|
|
614
|
-
function
|
|
615
|
-
if (!
|
|
613
|
+
}, [l]);
|
|
614
|
+
function Je() {
|
|
615
|
+
if (!I && O.x === n.x && O.y === n.y && !G)
|
|
616
616
|
return {
|
|
617
617
|
[ee.swipeMovementX]: "0px",
|
|
618
618
|
[ee.swipeMovementY]: "0px"
|
|
619
619
|
};
|
|
620
|
-
const
|
|
620
|
+
const c = O.x - n.x, u = O.y - n.y;
|
|
621
621
|
return {
|
|
622
|
-
transition:
|
|
622
|
+
transition: I ? "none" : void 0,
|
|
623
623
|
// While swiping, freeze the element at its current visual transform so it doesn't snap to the
|
|
624
624
|
// end position.
|
|
625
|
-
transform:
|
|
626
|
-
[ee.swipeMovementX]: `${
|
|
627
|
-
[ee.swipeMovementY]: `${
|
|
625
|
+
transform: I ? `translateX(${O.x}px) translateY(${O.y}px) scale(${n.scale})` : void 0,
|
|
626
|
+
[ee.swipeMovementX]: `${c}px`,
|
|
627
|
+
[ee.swipeMovementY]: `${u}px`
|
|
628
628
|
};
|
|
629
629
|
}
|
|
630
|
-
const
|
|
631
|
-
role:
|
|
630
|
+
const Me = s.priority === "high", Qe = {
|
|
631
|
+
role: Me ? "alertdialog" : "dialog",
|
|
632
632
|
tabIndex: 0,
|
|
633
633
|
"aria-modal": !1,
|
|
634
|
-
"aria-labelledby":
|
|
635
|
-
"aria-describedby":
|
|
636
|
-
"aria-hidden":
|
|
637
|
-
onPointerDown:
|
|
638
|
-
onPointerMove:
|
|
639
|
-
onPointerUp:
|
|
640
|
-
onKeyDown:
|
|
641
|
-
inert:
|
|
634
|
+
"aria-labelledby": w,
|
|
635
|
+
"aria-describedby": v,
|
|
636
|
+
"aria-hidden": Me && !o ? !0 : void 0,
|
|
637
|
+
onPointerDown: l ? We : void 0,
|
|
638
|
+
onPointerMove: l ? je : void 0,
|
|
639
|
+
onPointerUp: l ? Ue : void 0,
|
|
640
|
+
onKeyDown: qe,
|
|
641
|
+
inert: gt(s.limited),
|
|
642
642
|
style: {
|
|
643
|
-
...
|
|
644
|
-
[ee.index]: s.transitionStatus === "ending" ?
|
|
645
|
-
[ee.offsetY]: `${
|
|
643
|
+
...Je(),
|
|
644
|
+
[ee.index]: s.transitionStatus === "ending" ? ve : _e,
|
|
645
|
+
[ee.offsetY]: `${Ge}px`,
|
|
646
646
|
[ee.height]: s.height ? `${s.height}px` : void 0
|
|
647
647
|
}
|
|
648
648
|
}, te = e.useMemo(() => ({
|
|
649
649
|
rootRef: T,
|
|
650
650
|
toast: s,
|
|
651
|
-
titleId:
|
|
652
|
-
setTitleId:
|
|
653
|
-
descriptionId:
|
|
654
|
-
setDescriptionId:
|
|
655
|
-
swiping:
|
|
656
|
-
swipeDirection:
|
|
657
|
-
recalculateHeight:
|
|
658
|
-
index:
|
|
659
|
-
visibleIndex:
|
|
651
|
+
titleId: w,
|
|
652
|
+
setTitleId: i,
|
|
653
|
+
descriptionId: v,
|
|
654
|
+
setDescriptionId: r,
|
|
655
|
+
swiping: I,
|
|
656
|
+
swipeDirection: j,
|
|
657
|
+
recalculateHeight: le,
|
|
658
|
+
index: ve,
|
|
659
|
+
visibleIndex: _e,
|
|
660
660
|
expanded: C
|
|
661
|
-
}), [s,
|
|
661
|
+
}), [s, w, v, I, j, le, ve, _e, C]), Ze = e.useMemo(() => ({
|
|
662
662
|
transitionStatus: s.transitionStatus,
|
|
663
663
|
expanded: C,
|
|
664
664
|
limited: s.limited || !1,
|
|
665
665
|
type: s.type,
|
|
666
666
|
swiping: te.swiping,
|
|
667
667
|
swipeDirection: te.swipeDirection
|
|
668
|
-
}), [C, s.transitionStatus, s.limited, s.type, te.swiping, te.swipeDirection]),
|
|
669
|
-
ref: [
|
|
670
|
-
state:
|
|
671
|
-
stateAttributesMapping:
|
|
672
|
-
props: [
|
|
668
|
+
}), [C, s.transitionStatus, s.limited, s.type, te.swiping, te.swipeDirection]), et = oe("div", d, {
|
|
669
|
+
ref: [h, te.rootRef],
|
|
670
|
+
state: Ze,
|
|
671
|
+
stateAttributesMapping: Dt,
|
|
672
|
+
props: [Qe, a]
|
|
673
673
|
});
|
|
674
|
-
return /* @__PURE__ */ E(
|
|
674
|
+
return /* @__PURE__ */ E(Se.Provider, {
|
|
675
675
|
value: te,
|
|
676
|
-
children:
|
|
676
|
+
children: et
|
|
677
677
|
});
|
|
678
678
|
});
|
|
679
|
-
process.env.NODE_ENV !== "production" && (
|
|
680
|
-
const
|
|
679
|
+
process.env.NODE_ENV !== "production" && ($e.displayName = "ToastRoot");
|
|
680
|
+
const Be = /* @__PURE__ */ e.forwardRef(function(d, h) {
|
|
681
681
|
const {
|
|
682
682
|
render: s,
|
|
683
|
-
className:
|
|
684
|
-
...
|
|
683
|
+
className: F,
|
|
684
|
+
...M
|
|
685
685
|
} = d, {
|
|
686
|
-
visibleIndex:
|
|
687
|
-
expanded:
|
|
688
|
-
recalculateHeight:
|
|
689
|
-
} =
|
|
690
|
-
|
|
691
|
-
const R =
|
|
692
|
-
if (!R || (
|
|
686
|
+
visibleIndex: y,
|
|
687
|
+
expanded: a,
|
|
688
|
+
recalculateHeight: g
|
|
689
|
+
} = se(), t = e.useRef(null);
|
|
690
|
+
me(() => {
|
|
691
|
+
const R = t.current;
|
|
692
|
+
if (!R || (g(), typeof ResizeObserver != "function" || typeof MutationObserver != "function"))
|
|
693
693
|
return;
|
|
694
|
-
const
|
|
695
|
-
return
|
|
694
|
+
const b = new ResizeObserver(() => g(!0)), N = new MutationObserver(() => g(!0));
|
|
695
|
+
return b.observe(R), N.observe(R, {
|
|
696
696
|
childList: !0,
|
|
697
697
|
subtree: !0,
|
|
698
698
|
characterData: !0
|
|
699
699
|
}), () => {
|
|
700
|
-
|
|
700
|
+
b.disconnect(), N.disconnect();
|
|
701
701
|
};
|
|
702
|
-
}, [
|
|
703
|
-
const
|
|
704
|
-
expanded:
|
|
705
|
-
behind:
|
|
706
|
-
}), [
|
|
707
|
-
return
|
|
708
|
-
ref: [
|
|
709
|
-
state:
|
|
710
|
-
props:
|
|
702
|
+
}, [g]);
|
|
703
|
+
const l = y > 0, _ = e.useMemo(() => ({
|
|
704
|
+
expanded: a,
|
|
705
|
+
behind: l
|
|
706
|
+
}), [a, l]);
|
|
707
|
+
return oe("div", d, {
|
|
708
|
+
ref: [h, t],
|
|
709
|
+
state: _,
|
|
710
|
+
props: M
|
|
711
|
+
});
|
|
712
|
+
});
|
|
713
|
+
process.env.NODE_ENV !== "production" && (Be.displayName = "ToastContent");
|
|
714
|
+
const Ae = /* @__PURE__ */ e.forwardRef(function(d, h) {
|
|
715
|
+
const {
|
|
716
|
+
render: s,
|
|
717
|
+
className: F,
|
|
718
|
+
id: M,
|
|
719
|
+
children: y,
|
|
720
|
+
...a
|
|
721
|
+
} = d, {
|
|
722
|
+
toast: g
|
|
723
|
+
} = se(), t = y ?? g.description, l = !!t, _ = He(M), {
|
|
724
|
+
setDescriptionId: o
|
|
725
|
+
} = se();
|
|
726
|
+
me(() => {
|
|
727
|
+
if (l)
|
|
728
|
+
return o(_), () => {
|
|
729
|
+
o(void 0);
|
|
730
|
+
};
|
|
731
|
+
}, [l, _, o]);
|
|
732
|
+
const R = e.useMemo(() => ({
|
|
733
|
+
type: g.type
|
|
734
|
+
}), [g.type]), b = oe("p", d, {
|
|
735
|
+
ref: h,
|
|
736
|
+
state: R,
|
|
737
|
+
props: {
|
|
738
|
+
...a,
|
|
739
|
+
id: _,
|
|
740
|
+
children: t
|
|
741
|
+
}
|
|
711
742
|
});
|
|
743
|
+
return l ? b : null;
|
|
712
744
|
});
|
|
713
|
-
process.env.NODE_ENV !== "production" && (
|
|
714
|
-
const
|
|
745
|
+
process.env.NODE_ENV !== "production" && (Ae.displayName = "ToastDescription");
|
|
746
|
+
const Ye = /* @__PURE__ */ e.forwardRef(function(d, h) {
|
|
715
747
|
const {
|
|
716
748
|
render: s,
|
|
717
|
-
className:
|
|
718
|
-
id:
|
|
719
|
-
children:
|
|
720
|
-
...
|
|
749
|
+
className: F,
|
|
750
|
+
id: M,
|
|
751
|
+
children: y,
|
|
752
|
+
...a
|
|
721
753
|
} = d, {
|
|
722
|
-
toast:
|
|
723
|
-
} =
|
|
724
|
-
|
|
725
|
-
} =
|
|
726
|
-
|
|
727
|
-
if (
|
|
728
|
-
return
|
|
729
|
-
|
|
754
|
+
toast: g
|
|
755
|
+
} = se(), t = y ?? g.title, l = !!t, _ = He(M), {
|
|
756
|
+
setTitleId: o
|
|
757
|
+
} = se();
|
|
758
|
+
me(() => {
|
|
759
|
+
if (l)
|
|
760
|
+
return o(_), () => {
|
|
761
|
+
o(void 0);
|
|
730
762
|
};
|
|
731
|
-
}, [
|
|
763
|
+
}, [l, _, o]);
|
|
732
764
|
const R = e.useMemo(() => ({
|
|
733
|
-
type:
|
|
734
|
-
}), [
|
|
735
|
-
ref:
|
|
765
|
+
type: g.type
|
|
766
|
+
}), [g.type]), b = oe("h2", d, {
|
|
767
|
+
ref: h,
|
|
736
768
|
state: R,
|
|
737
769
|
props: {
|
|
738
|
-
...
|
|
739
|
-
id:
|
|
740
|
-
children:
|
|
770
|
+
...a,
|
|
771
|
+
id: _,
|
|
772
|
+
children: t
|
|
741
773
|
}
|
|
742
774
|
});
|
|
743
|
-
return
|
|
775
|
+
return l ? b : null;
|
|
744
776
|
});
|
|
745
|
-
process.env.NODE_ENV !== "production" && (
|
|
746
|
-
const
|
|
777
|
+
process.env.NODE_ENV !== "production" && (Ye.displayName = "ToastTitle");
|
|
778
|
+
const Xe = /* @__PURE__ */ e.forwardRef(function(d, h) {
|
|
747
779
|
const {
|
|
748
780
|
render: s,
|
|
749
|
-
className:
|
|
750
|
-
disabled:
|
|
751
|
-
nativeButton:
|
|
752
|
-
...
|
|
781
|
+
className: F,
|
|
782
|
+
disabled: M,
|
|
783
|
+
nativeButton: y = !0,
|
|
784
|
+
...a
|
|
753
785
|
} = d, {
|
|
754
|
-
close:
|
|
755
|
-
expanded:
|
|
756
|
-
} =
|
|
757
|
-
toast:
|
|
758
|
-
} =
|
|
786
|
+
close: g,
|
|
787
|
+
expanded: t
|
|
788
|
+
} = be(), {
|
|
789
|
+
toast: l
|
|
790
|
+
} = se(), [_, o] = e.useState(!1), {
|
|
759
791
|
getButtonProps: R,
|
|
760
|
-
buttonRef:
|
|
761
|
-
} =
|
|
762
|
-
disabled:
|
|
763
|
-
native:
|
|
764
|
-
}),
|
|
765
|
-
type:
|
|
766
|
-
}), [
|
|
767
|
-
return
|
|
768
|
-
ref: [
|
|
769
|
-
state:
|
|
792
|
+
buttonRef: b
|
|
793
|
+
} = yt({
|
|
794
|
+
disabled: M,
|
|
795
|
+
native: y
|
|
796
|
+
}), N = e.useMemo(() => ({
|
|
797
|
+
type: l.type
|
|
798
|
+
}), [l.type]);
|
|
799
|
+
return oe("button", d, {
|
|
800
|
+
ref: [h, b],
|
|
801
|
+
state: N,
|
|
770
802
|
props: [{
|
|
771
|
-
"aria-hidden": !
|
|
803
|
+
"aria-hidden": !t && !_,
|
|
772
804
|
onClick() {
|
|
773
|
-
|
|
805
|
+
g(l.id);
|
|
774
806
|
},
|
|
775
807
|
onFocus() {
|
|
776
|
-
|
|
808
|
+
o(!0);
|
|
777
809
|
},
|
|
778
810
|
onBlur() {
|
|
779
|
-
|
|
811
|
+
o(!1);
|
|
780
812
|
}
|
|
781
|
-
},
|
|
813
|
+
}, a, R]
|
|
782
814
|
});
|
|
783
815
|
});
|
|
784
|
-
process.env.NODE_ENV !== "production" && (
|
|
785
|
-
const
|
|
786
|
-
toast__viewport:
|
|
787
|
-
toast:
|
|
788
|
-
toast_variant_neutral:
|
|
789
|
-
toast_variant_colorway:
|
|
790
|
-
toast__content:
|
|
791
|
-
toast__header:
|
|
792
|
-
|
|
793
|
-
toast__title:
|
|
794
|
-
toast__description:
|
|
795
|
-
|
|
816
|
+
process.env.NODE_ENV !== "production" && (Xe.displayName = "ToastClose");
|
|
817
|
+
const St = pt, Mt = "_toast__viewport_uzvu6_1", Nt = "_toast_uzvu6_1", Pt = "_toast_variant_neutral_uzvu6_111", Ot = "_toast_variant_colorway_uzvu6_117", Ct = "_toast__content_uzvu6_123", Ft = "_toast__header_uzvu6_142", It = "_toast__header_pad_uzvu6_146", Lt = "_toast__title_uzvu6_150", Ht = "_toast__description_uzvu6_154", kt = "_toast__close_uzvu6_158", W = {
|
|
818
|
+
toast__viewport: Mt,
|
|
819
|
+
toast: Nt,
|
|
820
|
+
toast_variant_neutral: Pt,
|
|
821
|
+
toast_variant_colorway: Ot,
|
|
822
|
+
toast__content: Ct,
|
|
823
|
+
toast__header: Ft,
|
|
824
|
+
toast__header_pad: It,
|
|
825
|
+
toast__title: Lt,
|
|
826
|
+
toast__description: Ht,
|
|
827
|
+
toast__close: kt
|
|
828
|
+
}, ln = ke, Le = {
|
|
796
829
|
info: "blue",
|
|
797
830
|
error: "red",
|
|
798
831
|
warning: "yellow",
|
|
799
832
|
success: "green"
|
|
800
833
|
};
|
|
801
|
-
function
|
|
802
|
-
return /* @__PURE__ */ E(
|
|
834
|
+
function fn() {
|
|
835
|
+
return /* @__PURE__ */ E(St, { children: /* @__PURE__ */ E(Ve, { className: W.toast__viewport, children: /* @__PURE__ */ E(zt, {}) }) });
|
|
803
836
|
}
|
|
804
|
-
function
|
|
805
|
-
return
|
|
806
|
-
const
|
|
837
|
+
function zt() {
|
|
838
|
+
return dt().toasts.map((d) => {
|
|
839
|
+
const h = d.type && d.type in Le ? Le[d.type] : void 0;
|
|
807
840
|
return /* @__PURE__ */ E(
|
|
808
|
-
|
|
841
|
+
$e,
|
|
809
842
|
{
|
|
810
843
|
toast: d,
|
|
811
|
-
className:
|
|
812
|
-
|
|
813
|
-
|
|
844
|
+
className: Ne(
|
|
845
|
+
W.toast,
|
|
846
|
+
h ? W.toast_variant_colorway : W.toast_variant_neutral
|
|
814
847
|
),
|
|
815
|
-
render: /* @__PURE__ */ E(
|
|
816
|
-
children: /* @__PURE__ */
|
|
817
|
-
|
|
848
|
+
render: /* @__PURE__ */ E(ut, { background: "default", color: h }),
|
|
849
|
+
children: /* @__PURE__ */ ae(
|
|
850
|
+
Pe,
|
|
818
851
|
{
|
|
819
|
-
render: /* @__PURE__ */ E(
|
|
820
|
-
className:
|
|
852
|
+
render: /* @__PURE__ */ E(Be, {}),
|
|
853
|
+
className: W.toast__content,
|
|
821
854
|
children: [
|
|
822
|
-
/* @__PURE__ */
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
}
|
|
833
|
-
) : null,
|
|
834
|
-
/* @__PURE__ */ E(
|
|
835
|
-
$e,
|
|
836
|
-
{
|
|
837
|
-
render: /* @__PURE__ */ E(ct, { multiline: !0, color: w ? "inherit" : "dimmer" }),
|
|
838
|
-
className: U.toast__description
|
|
839
|
-
}
|
|
840
|
-
)
|
|
841
|
-
] }),
|
|
842
|
-
/* @__PURE__ */ E(
|
|
843
|
-
Ae,
|
|
844
|
-
{
|
|
845
|
-
render: /* @__PURE__ */ E(
|
|
846
|
-
it,
|
|
855
|
+
/* @__PURE__ */ ae(
|
|
856
|
+
Pe,
|
|
857
|
+
{
|
|
858
|
+
className: Ne(
|
|
859
|
+
W.toast__header,
|
|
860
|
+
!d.title && W.toast__header_pad
|
|
861
|
+
),
|
|
862
|
+
children: [
|
|
863
|
+
/* @__PURE__ */ E(
|
|
864
|
+
Ye,
|
|
847
865
|
{
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
866
|
+
render: /* @__PURE__ */ E(
|
|
867
|
+
at,
|
|
868
|
+
{
|
|
869
|
+
level: 2,
|
|
870
|
+
size: "lg",
|
|
871
|
+
color: "inherit",
|
|
872
|
+
className: W.toast__title
|
|
873
|
+
}
|
|
874
|
+
)
|
|
875
|
+
}
|
|
876
|
+
),
|
|
877
|
+
/* @__PURE__ */ E(
|
|
878
|
+
Ae,
|
|
879
|
+
{
|
|
880
|
+
render: /* @__PURE__ */ E(lt, { multiline: !0, color: h ? "inherit" : "dimmer" }),
|
|
881
|
+
className: W.toast__description
|
|
852
882
|
}
|
|
853
883
|
)
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
884
|
+
]
|
|
885
|
+
}
|
|
886
|
+
),
|
|
887
|
+
/* @__PURE__ */ E(
|
|
888
|
+
Xe,
|
|
889
|
+
{
|
|
890
|
+
render: /* @__PURE__ */ E(
|
|
891
|
+
ct,
|
|
892
|
+
{
|
|
893
|
+
interactive: h ? `${h}_no-fill` : "no-fill",
|
|
894
|
+
icon: "close-line",
|
|
895
|
+
size: "sm",
|
|
896
|
+
alt: "Close",
|
|
897
|
+
className: W.toast__close
|
|
898
|
+
}
|
|
899
|
+
)
|
|
900
|
+
}
|
|
901
|
+
),
|
|
857
902
|
d.action ? /* @__PURE__ */ E(
|
|
858
|
-
|
|
903
|
+
it,
|
|
859
904
|
{
|
|
860
905
|
...d.action,
|
|
861
|
-
interactive:
|
|
906
|
+
interactive: h ? `${h}_fill` : !0,
|
|
862
907
|
children: d.action.children
|
|
863
908
|
}
|
|
864
909
|
) : null
|
|
@@ -871,6 +916,6 @@ function Ht() {
|
|
|
871
916
|
});
|
|
872
917
|
}
|
|
873
918
|
export {
|
|
874
|
-
|
|
875
|
-
|
|
919
|
+
ln as ToastProvider,
|
|
920
|
+
fn as ToastViewport
|
|
876
921
|
};
|