@konstructio/ui 0.1.2-alpha.34 → 0.1.2-alpha.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Badge/Badge.js +42 -41
- package/dist/components/Dropdown/components/List/List.js +62 -60
- package/dist/components/Dropdown/components/ListItem/ListItem.js +57 -47
- package/dist/components/Dropdown/components/Wrapper.js +60 -58
- package/dist/components/Toast/Toast.js +173 -170
- package/dist/components/Toast/Toast.variants.js +37 -24
- package/dist/index.d.ts +4 -1
- package/dist/loader-juvMSJ9L.js +5 -0
- package/dist/package.json +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i, jsxs as A, Fragment as ae } from "react/jsx-runtime";
|
|
2
2
|
import { S as B } from "../../index-BtQfgaSF.js";
|
|
3
3
|
import * as n from "react";
|
|
4
4
|
import { useRef as xe, useEffect as be, useMemo as re, isValidElement as ne, useCallback as ge } from "react";
|
|
5
5
|
import * as Se from "react-dom";
|
|
6
|
-
import { P as
|
|
6
|
+
import { P as D, c as Ne, a as Ie, b as x, d as Ae, u as De } from "../../index-CIAmiWcw.js";
|
|
7
7
|
import { u as ie } from "../../index-DLcqcWxM.js";
|
|
8
8
|
import { c as _e } from "../../index-CigKKiZS.js";
|
|
9
9
|
import { B as Fe, R as Le } from "../../index-Dbt2vBmS.js";
|
|
@@ -27,8 +27,8 @@ var Ue = Object.freeze({
|
|
|
27
27
|
whiteSpace: "nowrap",
|
|
28
28
|
wordWrap: "normal"
|
|
29
29
|
}), Xe = "VisuallyHidden", Q = n.forwardRef(
|
|
30
|
-
(e, o) => /* @__PURE__ */
|
|
31
|
-
|
|
30
|
+
(e, o) => /* @__PURE__ */ i(
|
|
31
|
+
D.span,
|
|
32
32
|
{
|
|
33
33
|
...e,
|
|
34
34
|
ref: o,
|
|
@@ -37,33 +37,33 @@ var Ue = Object.freeze({
|
|
|
37
37
|
)
|
|
38
38
|
);
|
|
39
39
|
Q.displayName = Xe;
|
|
40
|
-
var Z = "ToastProvider", [ee, Ye, $e] = _e("Toast"), [ce, St] =
|
|
40
|
+
var Z = "ToastProvider", [ee, Ye, $e] = _e("Toast"), [ce, St] = Ne("Toast", [$e]), [Be, Y] = ce(Z), ue = (e) => {
|
|
41
41
|
const {
|
|
42
42
|
__scopeToast: o,
|
|
43
43
|
label: r = "Notification",
|
|
44
44
|
duration: t = 5e3,
|
|
45
|
-
swipeDirection:
|
|
45
|
+
swipeDirection: u = "right",
|
|
46
46
|
swipeThreshold: d = 50,
|
|
47
|
-
children:
|
|
48
|
-
} = e, [w, v] = n.useState(null), [
|
|
47
|
+
children: f
|
|
48
|
+
} = e, [w, v] = n.useState(null), [c, E] = n.useState(0), T = n.useRef(!1), N = n.useRef(!1);
|
|
49
49
|
return r.trim() || console.error(
|
|
50
50
|
`Invalid prop \`label\` supplied to \`${Z}\`. Expected non-empty \`string\`.`
|
|
51
|
-
), /* @__PURE__ */
|
|
51
|
+
), /* @__PURE__ */ i(ee.Provider, { scope: o, children: /* @__PURE__ */ i(
|
|
52
52
|
Be,
|
|
53
53
|
{
|
|
54
54
|
scope: o,
|
|
55
55
|
label: r,
|
|
56
56
|
duration: t,
|
|
57
|
-
swipeDirection:
|
|
57
|
+
swipeDirection: u,
|
|
58
58
|
swipeThreshold: d,
|
|
59
|
-
toastCount:
|
|
59
|
+
toastCount: c,
|
|
60
60
|
viewport: w,
|
|
61
61
|
onViewportChange: v,
|
|
62
|
-
onToastAdd: n.useCallback(() => E((
|
|
63
|
-
onToastRemove: n.useCallback(() => E((
|
|
62
|
+
onToastAdd: n.useCallback(() => E((R) => R + 1), []),
|
|
63
|
+
onToastRemove: n.useCallback(() => E((R) => R - 1), []),
|
|
64
64
|
isFocusedToastEscapeKeyDownRef: T,
|
|
65
|
-
isClosePausedRef:
|
|
66
|
-
children:
|
|
65
|
+
isClosePausedRef: N,
|
|
66
|
+
children: f
|
|
67
67
|
}
|
|
68
68
|
) });
|
|
69
69
|
};
|
|
@@ -73,95 +73,95 @@ var le = "ToastViewport", je = ["F8"], z = "toast.viewportPause", G = "toast.vie
|
|
|
73
73
|
const {
|
|
74
74
|
__scopeToast: r,
|
|
75
75
|
hotkey: t = je,
|
|
76
|
-
label:
|
|
76
|
+
label: u = "Notifications ({hotkey})",
|
|
77
77
|
...d
|
|
78
|
-
} = e,
|
|
78
|
+
} = e, f = Y(le, r), w = Ye(r), v = n.useRef(null), c = n.useRef(null), E = n.useRef(null), T = n.useRef(null), N = ie(o, T, f.onViewportChange), R = t.join("+").replace(/Key/g, "").replace(/Digit/g, ""), b = f.toastCount > 0;
|
|
79
79
|
n.useEffect(() => {
|
|
80
|
-
const
|
|
80
|
+
const s = (h) => {
|
|
81
81
|
t.length !== 0 && t.every((m) => h[m] || h.code === m) && T.current?.focus();
|
|
82
82
|
};
|
|
83
|
-
return document.addEventListener("keydown",
|
|
83
|
+
return document.addEventListener("keydown", s), () => document.removeEventListener("keydown", s);
|
|
84
84
|
}, [t]), n.useEffect(() => {
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
const
|
|
88
|
-
if (!
|
|
85
|
+
const s = v.current, h = T.current;
|
|
86
|
+
if (b && s && h) {
|
|
87
|
+
const p = () => {
|
|
88
|
+
if (!f.isClosePausedRef.current) {
|
|
89
89
|
const y = new CustomEvent(z);
|
|
90
|
-
h.dispatchEvent(y),
|
|
90
|
+
h.dispatchEvent(y), f.isClosePausedRef.current = !0;
|
|
91
91
|
}
|
|
92
92
|
}, m = () => {
|
|
93
|
-
if (
|
|
93
|
+
if (f.isClosePausedRef.current) {
|
|
94
94
|
const y = new CustomEvent(G);
|
|
95
|
-
h.dispatchEvent(y),
|
|
95
|
+
h.dispatchEvent(y), f.isClosePausedRef.current = !1;
|
|
96
96
|
}
|
|
97
97
|
}, P = (y) => {
|
|
98
|
-
!
|
|
98
|
+
!s.contains(y.relatedTarget) && m();
|
|
99
99
|
}, C = () => {
|
|
100
|
-
|
|
100
|
+
s.contains(document.activeElement) || m();
|
|
101
101
|
};
|
|
102
|
-
return
|
|
103
|
-
|
|
102
|
+
return s.addEventListener("focusin", p), s.addEventListener("focusout", P), s.addEventListener("pointermove", p), s.addEventListener("pointerleave", C), window.addEventListener("blur", p), window.addEventListener("focus", m), () => {
|
|
103
|
+
s.removeEventListener("focusin", p), s.removeEventListener("focusout", P), s.removeEventListener("pointermove", p), s.removeEventListener("pointerleave", C), window.removeEventListener("blur", p), window.removeEventListener("focus", m);
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
}, [
|
|
106
|
+
}, [b, f.isClosePausedRef]);
|
|
107
107
|
const l = n.useCallback(
|
|
108
|
-
({ tabbingDirection:
|
|
109
|
-
const
|
|
108
|
+
({ tabbingDirection: s }) => {
|
|
109
|
+
const p = w().map((m) => {
|
|
110
110
|
const P = m.ref.current, C = [P, ...at(P)];
|
|
111
|
-
return
|
|
111
|
+
return s === "forwards" ? C : C.reverse();
|
|
112
112
|
});
|
|
113
|
-
return (
|
|
113
|
+
return (s === "forwards" ? p.reverse() : p).flat();
|
|
114
114
|
},
|
|
115
115
|
[w]
|
|
116
116
|
);
|
|
117
117
|
return n.useEffect(() => {
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
const h = (
|
|
121
|
-
const m =
|
|
122
|
-
if (
|
|
123
|
-
const C = document.activeElement, y =
|
|
124
|
-
if (
|
|
125
|
-
|
|
118
|
+
const s = T.current;
|
|
119
|
+
if (s) {
|
|
120
|
+
const h = (p) => {
|
|
121
|
+
const m = p.altKey || p.ctrlKey || p.metaKey;
|
|
122
|
+
if (p.key === "Tab" && !m) {
|
|
123
|
+
const C = document.activeElement, y = p.shiftKey;
|
|
124
|
+
if (p.target === s && y) {
|
|
125
|
+
c.current?.focus();
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
|
-
const F = l({ tabbingDirection: y ? "backwards" : "forwards" }), V = F.findIndex((
|
|
129
|
-
q(F.slice(V + 1)) ?
|
|
128
|
+
const F = l({ tabbingDirection: y ? "backwards" : "forwards" }), V = F.findIndex((I) => I === C);
|
|
129
|
+
q(F.slice(V + 1)) ? p.preventDefault() : y ? c.current?.focus() : E.current?.focus();
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
|
-
return
|
|
132
|
+
return s.addEventListener("keydown", h), () => s.removeEventListener("keydown", h);
|
|
133
133
|
}
|
|
134
|
-
}, [w, l]), /* @__PURE__ */
|
|
134
|
+
}, [w, l]), /* @__PURE__ */ A(
|
|
135
135
|
Fe,
|
|
136
136
|
{
|
|
137
137
|
ref: v,
|
|
138
138
|
role: "region",
|
|
139
|
-
"aria-label":
|
|
139
|
+
"aria-label": u.replace("{hotkey}", R),
|
|
140
140
|
tabIndex: -1,
|
|
141
|
-
style: { pointerEvents:
|
|
141
|
+
style: { pointerEvents: b ? void 0 : "none" },
|
|
142
142
|
children: [
|
|
143
|
-
|
|
143
|
+
b && /* @__PURE__ */ i(
|
|
144
144
|
J,
|
|
145
145
|
{
|
|
146
|
-
ref:
|
|
146
|
+
ref: c,
|
|
147
147
|
onFocusFromOutsideViewport: () => {
|
|
148
|
-
const
|
|
148
|
+
const s = l({
|
|
149
149
|
tabbingDirection: "forwards"
|
|
150
150
|
});
|
|
151
|
-
q(
|
|
151
|
+
q(s);
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
),
|
|
155
|
-
/* @__PURE__ */
|
|
156
|
-
|
|
155
|
+
/* @__PURE__ */ i(ee.Slot, { scope: r, children: /* @__PURE__ */ i(D.ol, { tabIndex: -1, ...d, ref: N }) }),
|
|
156
|
+
b && /* @__PURE__ */ i(
|
|
157
157
|
J,
|
|
158
158
|
{
|
|
159
159
|
ref: E,
|
|
160
160
|
onFocusFromOutsideViewport: () => {
|
|
161
|
-
const
|
|
161
|
+
const s = l({
|
|
162
162
|
tabbingDirection: "backwards"
|
|
163
163
|
});
|
|
164
|
-
q(
|
|
164
|
+
q(s);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
)
|
|
@@ -171,61 +171,61 @@ var le = "ToastViewport", je = ["F8"], z = "toast.viewportPause", G = "toast.vie
|
|
|
171
171
|
}
|
|
172
172
|
);
|
|
173
173
|
de.displayName = le;
|
|
174
|
-
var
|
|
174
|
+
var fe = "ToastFocusProxy", J = n.forwardRef(
|
|
175
175
|
(e, o) => {
|
|
176
|
-
const { __scopeToast: r, onFocusFromOutsideViewport: t, ...
|
|
177
|
-
return /* @__PURE__ */
|
|
176
|
+
const { __scopeToast: r, onFocusFromOutsideViewport: t, ...u } = e, d = Y(fe, r);
|
|
177
|
+
return /* @__PURE__ */ i(
|
|
178
178
|
Q,
|
|
179
179
|
{
|
|
180
180
|
tabIndex: 0,
|
|
181
|
-
...
|
|
181
|
+
...u,
|
|
182
182
|
ref: o,
|
|
183
183
|
style: { position: "fixed" },
|
|
184
|
-
onFocus: (
|
|
185
|
-
const w =
|
|
184
|
+
onFocus: (f) => {
|
|
185
|
+
const w = f.relatedTarget;
|
|
186
186
|
!d.viewport?.contains(w) && t();
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
);
|
|
192
|
-
J.displayName =
|
|
193
|
-
var O = "Toast", qe = "toast.swipeStart", ze = "toast.swipeMove", Ge = "toast.swipeCancel", Je = "toast.swipeEnd",
|
|
192
|
+
J.displayName = fe;
|
|
193
|
+
var O = "Toast", qe = "toast.swipeStart", ze = "toast.swipeMove", Ge = "toast.swipeCancel", Je = "toast.swipeEnd", pe = n.forwardRef(
|
|
194
194
|
(e, o) => {
|
|
195
|
-
const { forceMount: r, open: t, defaultOpen:
|
|
195
|
+
const { forceMount: r, open: t, defaultOpen: u, onOpenChange: d, ...f } = e, [w, v] = Ie({
|
|
196
196
|
prop: t,
|
|
197
|
-
defaultProp:
|
|
197
|
+
defaultProp: u ?? !0,
|
|
198
198
|
onChange: d,
|
|
199
199
|
caller: O
|
|
200
200
|
});
|
|
201
|
-
return /* @__PURE__ */
|
|
201
|
+
return /* @__PURE__ */ i(Oe, { present: r || w, children: /* @__PURE__ */ i(
|
|
202
202
|
et,
|
|
203
203
|
{
|
|
204
204
|
open: w,
|
|
205
|
-
...
|
|
205
|
+
...f,
|
|
206
206
|
ref: o,
|
|
207
207
|
onClose: () => v(!1),
|
|
208
208
|
onPause: X(e.onPause),
|
|
209
209
|
onResume: X(e.onResume),
|
|
210
|
-
onSwipeStart: x(e.onSwipeStart, (
|
|
211
|
-
|
|
210
|
+
onSwipeStart: x(e.onSwipeStart, (c) => {
|
|
211
|
+
c.currentTarget.setAttribute("data-swipe", "start");
|
|
212
212
|
}),
|
|
213
|
-
onSwipeMove: x(e.onSwipeMove, (
|
|
214
|
-
const { x: E, y: T } =
|
|
215
|
-
|
|
213
|
+
onSwipeMove: x(e.onSwipeMove, (c) => {
|
|
214
|
+
const { x: E, y: T } = c.detail.delta;
|
|
215
|
+
c.currentTarget.setAttribute("data-swipe", "move"), c.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${E}px`), c.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${T}px`);
|
|
216
216
|
}),
|
|
217
|
-
onSwipeCancel: x(e.onSwipeCancel, (
|
|
218
|
-
|
|
217
|
+
onSwipeCancel: x(e.onSwipeCancel, (c) => {
|
|
218
|
+
c.currentTarget.setAttribute("data-swipe", "cancel"), c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"), c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y");
|
|
219
219
|
}),
|
|
220
|
-
onSwipeEnd: x(e.onSwipeEnd, (
|
|
221
|
-
const { x: E, y: T } =
|
|
222
|
-
|
|
220
|
+
onSwipeEnd: x(e.onSwipeEnd, (c) => {
|
|
221
|
+
const { x: E, y: T } = c.detail.delta;
|
|
222
|
+
c.currentTarget.setAttribute("data-swipe", "end"), c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), c.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${E}px`), c.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${T}px`), v(!1);
|
|
223
223
|
})
|
|
224
224
|
}
|
|
225
225
|
) });
|
|
226
226
|
}
|
|
227
227
|
);
|
|
228
|
-
|
|
228
|
+
pe.displayName = O;
|
|
229
229
|
var [Qe, Ze] = ce(O, {
|
|
230
230
|
onClose() {
|
|
231
231
|
}
|
|
@@ -234,44 +234,44 @@ var [Qe, Ze] = ce(O, {
|
|
|
234
234
|
const {
|
|
235
235
|
__scopeToast: r,
|
|
236
236
|
type: t = "foreground",
|
|
237
|
-
duration:
|
|
237
|
+
duration: u,
|
|
238
238
|
open: d,
|
|
239
|
-
onClose:
|
|
239
|
+
onClose: f,
|
|
240
240
|
onEscapeKeyDown: w,
|
|
241
241
|
onPause: v,
|
|
242
|
-
onResume:
|
|
242
|
+
onResume: c,
|
|
243
243
|
onSwipeStart: E,
|
|
244
244
|
onSwipeMove: T,
|
|
245
|
-
onSwipeCancel:
|
|
246
|
-
onSwipeEnd:
|
|
247
|
-
...
|
|
248
|
-
} = e, l = Y(O, r), [
|
|
249
|
-
|
|
245
|
+
onSwipeCancel: N,
|
|
246
|
+
onSwipeEnd: R,
|
|
247
|
+
...b
|
|
248
|
+
} = e, l = Y(O, r), [s, h] = n.useState(null), p = ie(o, (a) => h(a)), m = n.useRef(null), P = n.useRef(null), C = u || l.duration, y = n.useRef(0), _ = n.useRef(C), k = n.useRef(0), { onToastAdd: F, onToastRemove: V } = l, I = X(() => {
|
|
249
|
+
s?.contains(document.activeElement) && l.viewport?.focus(), f();
|
|
250
250
|
}), K = n.useCallback(
|
|
251
|
-
(
|
|
252
|
-
!
|
|
251
|
+
(a) => {
|
|
252
|
+
!a || a === 1 / 0 || (window.clearTimeout(k.current), y.current = (/* @__PURE__ */ new Date()).getTime(), k.current = window.setTimeout(I, a));
|
|
253
253
|
},
|
|
254
|
-
[
|
|
254
|
+
[I]
|
|
255
255
|
);
|
|
256
256
|
n.useEffect(() => {
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
257
|
+
const a = l.viewport;
|
|
258
|
+
if (a) {
|
|
259
259
|
const g = () => {
|
|
260
|
-
K(_.current),
|
|
261
|
-
},
|
|
260
|
+
K(_.current), c?.();
|
|
261
|
+
}, S = () => {
|
|
262
262
|
const L = (/* @__PURE__ */ new Date()).getTime() - y.current;
|
|
263
263
|
_.current = _.current - L, window.clearTimeout(k.current), v?.();
|
|
264
264
|
};
|
|
265
|
-
return
|
|
266
|
-
|
|
265
|
+
return a.addEventListener(z, S), a.addEventListener(G, g), () => {
|
|
266
|
+
a.removeEventListener(z, S), a.removeEventListener(G, g);
|
|
267
267
|
};
|
|
268
268
|
}
|
|
269
|
-
}, [l.viewport, C, v,
|
|
269
|
+
}, [l.viewport, C, v, c, K]), n.useEffect(() => {
|
|
270
270
|
d && !l.isClosePausedRef.current && K(C);
|
|
271
271
|
}, [d, C, l.isClosePausedRef, K]), n.useEffect(() => (F(), () => V()), [F, V]);
|
|
272
|
-
const te = n.useMemo(() =>
|
|
273
|
-
return l.viewport ? /* @__PURE__ */
|
|
274
|
-
te && /* @__PURE__ */
|
|
272
|
+
const te = n.useMemo(() => s ? Pe(s) : null, [s]);
|
|
273
|
+
return l.viewport ? /* @__PURE__ */ A(ae, { children: [
|
|
274
|
+
te && /* @__PURE__ */ i(
|
|
275
275
|
tt,
|
|
276
276
|
{
|
|
277
277
|
__scopeToast: r,
|
|
@@ -280,47 +280,47 @@ var [Qe, Ze] = ce(O, {
|
|
|
280
280
|
children: te
|
|
281
281
|
}
|
|
282
282
|
),
|
|
283
|
-
/* @__PURE__ */
|
|
284
|
-
/* @__PURE__ */
|
|
283
|
+
/* @__PURE__ */ i(Qe, { scope: r, onClose: I, children: Se.createPortal(
|
|
284
|
+
/* @__PURE__ */ i(ee.ItemSlot, { scope: r, children: /* @__PURE__ */ i(
|
|
285
285
|
Le,
|
|
286
286
|
{
|
|
287
287
|
asChild: !0,
|
|
288
288
|
onEscapeKeyDown: x(w, () => {
|
|
289
|
-
l.isFocusedToastEscapeKeyDownRef.current ||
|
|
289
|
+
l.isFocusedToastEscapeKeyDownRef.current || I(), l.isFocusedToastEscapeKeyDownRef.current = !1;
|
|
290
290
|
}),
|
|
291
|
-
children: /* @__PURE__ */
|
|
292
|
-
|
|
291
|
+
children: /* @__PURE__ */ i(
|
|
292
|
+
D.li,
|
|
293
293
|
{
|
|
294
294
|
tabIndex: 0,
|
|
295
295
|
"data-state": d ? "open" : "closed",
|
|
296
296
|
"data-swipe-direction": l.swipeDirection,
|
|
297
|
-
...
|
|
298
|
-
ref:
|
|
297
|
+
...b,
|
|
298
|
+
ref: p,
|
|
299
299
|
style: { userSelect: "none", touchAction: "none", ...e.style },
|
|
300
|
-
onKeyDown: x(e.onKeyDown, (
|
|
301
|
-
|
|
300
|
+
onKeyDown: x(e.onKeyDown, (a) => {
|
|
301
|
+
a.key === "Escape" && (w?.(a.nativeEvent), a.nativeEvent.defaultPrevented || (l.isFocusedToastEscapeKeyDownRef.current = !0, I()));
|
|
302
302
|
}),
|
|
303
|
-
onPointerDown: x(e.onPointerDown, (
|
|
304
|
-
|
|
303
|
+
onPointerDown: x(e.onPointerDown, (a) => {
|
|
304
|
+
a.button === 0 && (m.current = { x: a.clientX, y: a.clientY });
|
|
305
305
|
}),
|
|
306
|
-
onPointerMove: x(e.onPointerMove, (
|
|
306
|
+
onPointerMove: x(e.onPointerMove, (a) => {
|
|
307
307
|
if (!m.current) return;
|
|
308
|
-
const g =
|
|
308
|
+
const g = a.clientX - m.current.x, S = a.clientY - m.current.y, L = !!P.current, M = ["left", "right"].includes(l.swipeDirection), H = ["left", "up"].includes(l.swipeDirection) ? Math.min : Math.max, Ce = M ? H(0, g) : 0, Re = M ? 0 : H(0, S), $ = a.pointerType === "touch" ? 10 : 2, W = { x: Ce, y: Re }, oe = { originalEvent: a, delta: W };
|
|
309
309
|
L ? (P.current = W, U(ze, T, oe, {
|
|
310
310
|
discrete: !1
|
|
311
311
|
})) : se(W, l.swipeDirection, $) ? (P.current = W, U(qe, E, oe, {
|
|
312
312
|
discrete: !1
|
|
313
|
-
}),
|
|
313
|
+
}), a.target.setPointerCapture(a.pointerId)) : (Math.abs(g) > $ || Math.abs(S) > $) && (m.current = null);
|
|
314
314
|
}),
|
|
315
|
-
onPointerUp: x(e.onPointerUp, (
|
|
316
|
-
const g = P.current,
|
|
317
|
-
if (
|
|
318
|
-
const L =
|
|
319
|
-
se(g, l.swipeDirection, l.swipeThreshold) ? U(Je,
|
|
315
|
+
onPointerUp: x(e.onPointerUp, (a) => {
|
|
316
|
+
const g = P.current, S = a.target;
|
|
317
|
+
if (S.hasPointerCapture(a.pointerId) && S.releasePointerCapture(a.pointerId), P.current = null, m.current = null, g) {
|
|
318
|
+
const L = a.currentTarget, M = { originalEvent: a, delta: g };
|
|
319
|
+
se(g, l.swipeDirection, l.swipeThreshold) ? U(Je, R, M, {
|
|
320
320
|
discrete: !0
|
|
321
321
|
}) : U(
|
|
322
322
|
Ge,
|
|
323
|
-
|
|
323
|
+
N,
|
|
324
324
|
M,
|
|
325
325
|
{
|
|
326
326
|
discrete: !0
|
|
@@ -339,33 +339,33 @@ var [Qe, Ze] = ce(O, {
|
|
|
339
339
|
] }) : null;
|
|
340
340
|
}
|
|
341
341
|
), tt = (e) => {
|
|
342
|
-
const { __scopeToast: o, children: r, ...t } = e,
|
|
343
|
-
return nt(() =>
|
|
344
|
-
const
|
|
345
|
-
return () => window.clearTimeout(
|
|
346
|
-
}, []), w ? null : /* @__PURE__ */
|
|
347
|
-
|
|
342
|
+
const { __scopeToast: o, children: r, ...t } = e, u = Y(O, o), [d, f] = n.useState(!1), [w, v] = n.useState(!1);
|
|
343
|
+
return nt(() => f(!0)), n.useEffect(() => {
|
|
344
|
+
const c = window.setTimeout(() => v(!0), 1e3);
|
|
345
|
+
return () => window.clearTimeout(c);
|
|
346
|
+
}, []), w ? null : /* @__PURE__ */ i(Me, { asChild: !0, children: /* @__PURE__ */ i(Q, { ...t, children: d && /* @__PURE__ */ A(ae, { children: [
|
|
347
|
+
u.label,
|
|
348
348
|
" ",
|
|
349
349
|
r
|
|
350
350
|
] }) }) });
|
|
351
351
|
}, ot = "ToastTitle", me = n.forwardRef(
|
|
352
352
|
(e, o) => {
|
|
353
353
|
const { __scopeToast: r, ...t } = e;
|
|
354
|
-
return /* @__PURE__ */
|
|
354
|
+
return /* @__PURE__ */ i(D.div, { ...t, ref: o });
|
|
355
355
|
}
|
|
356
356
|
);
|
|
357
357
|
me.displayName = ot;
|
|
358
358
|
var rt = "ToastDescription", we = n.forwardRef(
|
|
359
359
|
(e, o) => {
|
|
360
360
|
const { __scopeToast: r, ...t } = e;
|
|
361
|
-
return /* @__PURE__ */
|
|
361
|
+
return /* @__PURE__ */ i(D.div, { ...t, ref: o });
|
|
362
362
|
}
|
|
363
363
|
);
|
|
364
364
|
we.displayName = rt;
|
|
365
365
|
var Te = "ToastAction", ve = n.forwardRef(
|
|
366
366
|
(e, o) => {
|
|
367
367
|
const { altText: r, ...t } = e;
|
|
368
|
-
return r.trim() ? /* @__PURE__ */
|
|
368
|
+
return r.trim() ? /* @__PURE__ */ i(he, { altText: r, asChild: !0, children: /* @__PURE__ */ i(ye, { ...t, ref: o }) }) : (console.error(
|
|
369
369
|
`Invalid prop \`altText\` supplied to \`${Te}\`. Expected non-empty \`string\`.`
|
|
370
370
|
), null);
|
|
371
371
|
}
|
|
@@ -373,27 +373,27 @@ var Te = "ToastAction", ve = n.forwardRef(
|
|
|
373
373
|
ve.displayName = Te;
|
|
374
374
|
var Ee = "ToastClose", ye = n.forwardRef(
|
|
375
375
|
(e, o) => {
|
|
376
|
-
const { __scopeToast: r, ...t } = e,
|
|
377
|
-
return /* @__PURE__ */
|
|
378
|
-
|
|
376
|
+
const { __scopeToast: r, ...t } = e, u = Ze(Ee, r);
|
|
377
|
+
return /* @__PURE__ */ i(he, { asChild: !0, children: /* @__PURE__ */ i(
|
|
378
|
+
D.button,
|
|
379
379
|
{
|
|
380
380
|
type: "button",
|
|
381
381
|
...t,
|
|
382
382
|
ref: o,
|
|
383
|
-
onClick: x(e.onClick,
|
|
383
|
+
onClick: x(e.onClick, u.onClose)
|
|
384
384
|
}
|
|
385
385
|
) });
|
|
386
386
|
}
|
|
387
387
|
);
|
|
388
388
|
ye.displayName = Ee;
|
|
389
389
|
var he = n.forwardRef((e, o) => {
|
|
390
|
-
const { __scopeToast: r, altText: t, ...
|
|
391
|
-
return /* @__PURE__ */
|
|
392
|
-
|
|
390
|
+
const { __scopeToast: r, altText: t, ...u } = e;
|
|
391
|
+
return /* @__PURE__ */ i(
|
|
392
|
+
D.div,
|
|
393
393
|
{
|
|
394
394
|
"data-radix-toast-announce-exclude": "",
|
|
395
395
|
"data-radix-toast-announce-alt": t || void 0,
|
|
396
|
-
...
|
|
396
|
+
...u,
|
|
397
397
|
ref: o
|
|
398
398
|
}
|
|
399
399
|
);
|
|
@@ -402,23 +402,23 @@ function Pe(e) {
|
|
|
402
402
|
const o = [];
|
|
403
403
|
return Array.from(e.childNodes).forEach((t) => {
|
|
404
404
|
if (t.nodeType === t.TEXT_NODE && t.textContent && o.push(t.textContent), st(t)) {
|
|
405
|
-
const
|
|
406
|
-
if (!
|
|
405
|
+
const u = t.ariaHidden || t.hidden || t.style.display === "none", d = t.dataset.radixToastAnnounceExclude === "";
|
|
406
|
+
if (!u)
|
|
407
407
|
if (d) {
|
|
408
|
-
const
|
|
409
|
-
|
|
408
|
+
const f = t.dataset.radixToastAnnounceAlt;
|
|
409
|
+
f && o.push(f);
|
|
410
410
|
} else
|
|
411
411
|
o.push(...Pe(t));
|
|
412
412
|
}
|
|
413
413
|
}), o;
|
|
414
414
|
}
|
|
415
415
|
function U(e, o, r, { discrete: t }) {
|
|
416
|
-
const
|
|
417
|
-
o &&
|
|
416
|
+
const u = r.originalEvent.currentTarget, d = new CustomEvent(e, { bubbles: !0, cancelable: !0, detail: r });
|
|
417
|
+
o && u.addEventListener(e, o, { once: !0 }), t ? Ae(u, d) : u.dispatchEvent(d);
|
|
418
418
|
}
|
|
419
419
|
var se = (e, o, r = 0) => {
|
|
420
|
-
const t = Math.abs(e.x),
|
|
421
|
-
return o === "left" || o === "right" ? d && t > r : !d &&
|
|
420
|
+
const t = Math.abs(e.x), u = Math.abs(e.y), d = t > u;
|
|
421
|
+
return o === "left" || o === "right" ? d && t > r : !d && u > r;
|
|
422
422
|
};
|
|
423
423
|
function nt(e = () => {
|
|
424
424
|
}) {
|
|
@@ -436,8 +436,8 @@ function st(e) {
|
|
|
436
436
|
function at(e) {
|
|
437
437
|
const o = [], r = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
|
|
438
438
|
acceptNode: (t) => {
|
|
439
|
-
const
|
|
440
|
-
return t.disabled || t.hidden ||
|
|
439
|
+
const u = t.tagName === "INPUT" && t.type === "hidden";
|
|
440
|
+
return t.disabled || t.hidden || u ? NodeFilter.FILTER_SKIP : t.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
441
441
|
}
|
|
442
442
|
});
|
|
443
443
|
for (; r.nextNode(); ) o.push(r.currentNode);
|
|
@@ -447,40 +447,43 @@ function q(e) {
|
|
|
447
447
|
const o = document.activeElement;
|
|
448
448
|
return e.some((r) => r === o ? !0 : (r.focus(), document.activeElement !== o));
|
|
449
449
|
}
|
|
450
|
-
var it = ue, ct = de, ut =
|
|
451
|
-
const
|
|
450
|
+
var it = ue, ct = de, ut = pe, lt = me, dt = we, ft = ve;
|
|
451
|
+
const Nt = ({
|
|
452
452
|
title: e,
|
|
453
453
|
duration: o = 5e3,
|
|
454
454
|
titleClassName: r,
|
|
455
455
|
descriptionClassName: t,
|
|
456
|
-
description:
|
|
456
|
+
description: u,
|
|
457
457
|
children: d,
|
|
458
|
-
theme:
|
|
458
|
+
theme: f,
|
|
459
459
|
showCloseButton: w = !0,
|
|
460
460
|
closeButtonClassName: v,
|
|
461
|
-
className:
|
|
461
|
+
className: c,
|
|
462
462
|
open: E = !1,
|
|
463
|
-
setOpen: T
|
|
463
|
+
setOpen: T,
|
|
464
|
+
variant: N
|
|
464
465
|
}) => {
|
|
465
|
-
const
|
|
466
|
-
be(() => () => clearTimeout(
|
|
467
|
-
const b = re(() => ne(e) ? /* @__PURE__ */
|
|
468
|
-
T(!1),
|
|
466
|
+
const R = xe(0);
|
|
467
|
+
be(() => () => clearTimeout(R.current), []);
|
|
468
|
+
const b = re(() => ne(e) ? /* @__PURE__ */ i(B, { className: r, children: e }) : e, [e, r]), l = re(() => ne(u) ? /* @__PURE__ */ i(B, { className: t, children: u }) : u, [u, t]), s = ge(() => {
|
|
469
|
+
T(!1), R.current = window.setTimeout(() => T(!0), 100);
|
|
469
470
|
}, [T]);
|
|
470
|
-
return /* @__PURE__ */
|
|
471
|
-
/* @__PURE__ */
|
|
472
|
-
/* @__PURE__ */
|
|
471
|
+
return /* @__PURE__ */ A(it, { swipeDirection: "right", duration: o, children: [
|
|
472
|
+
/* @__PURE__ */ i(B, { onClick: s, children: d }),
|
|
473
|
+
/* @__PURE__ */ A(
|
|
473
474
|
ut,
|
|
474
475
|
{
|
|
475
|
-
className: j(Ke({ className:
|
|
476
|
-
"data-theme":
|
|
476
|
+
className: j(Ke({ variant: N, className: c })),
|
|
477
|
+
"data-theme": f,
|
|
477
478
|
open: E,
|
|
478
479
|
onOpenChange: T,
|
|
479
480
|
children: [
|
|
480
|
-
/* @__PURE__ */
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
481
|
+
/* @__PURE__ */ A("div", { className: "flex gap-2 items-center flex-1", children: [
|
|
482
|
+
/* @__PURE__ */ i(lt, { asChild: !0, className: r, children: b }),
|
|
483
|
+
l && /* @__PURE__ */ i(dt, { asChild: !0, children: l })
|
|
484
|
+
] }),
|
|
485
|
+
w && /* @__PURE__ */ i(ft, { asChild: !0, altText: "Close the toast", children: /* @__PURE__ */ A("button", { type: "button", className: "absolute right-1.5 top-1.5", children: [
|
|
486
|
+
/* @__PURE__ */ i(
|
|
484
487
|
We,
|
|
485
488
|
{
|
|
486
489
|
className: j(
|
|
@@ -490,14 +493,14 @@ const It = ({
|
|
|
490
493
|
)
|
|
491
494
|
}
|
|
492
495
|
),
|
|
493
|
-
/* @__PURE__ */
|
|
496
|
+
/* @__PURE__ */ i(ke, { children: "Close toast" })
|
|
494
497
|
] }) })
|
|
495
498
|
]
|
|
496
499
|
}
|
|
497
500
|
),
|
|
498
|
-
/* @__PURE__ */
|
|
501
|
+
/* @__PURE__ */ i(ct, { className: j(He()) })
|
|
499
502
|
] });
|
|
500
503
|
};
|
|
501
504
|
export {
|
|
502
|
-
|
|
505
|
+
Nt as Toast
|
|
503
506
|
};
|