@konstructio/ui 0.0.12-alpha.6 → 0.0.12-alpha.8
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/Loading/Loading.js +5 -5
- package/dist/components/TextArea/TextArea.js +26 -31
- package/dist/components/Toast/Toast.js +141 -128
- package/dist/components/Toast/Toast.variants.js +2 -3
- package/dist/index.d.ts +3 -0
- package/dist/package.json +22 -22
- package/dist/styles.css +1 -1
- package/dist/utils/index.js +320 -322
- package/package.json +22 -22
|
@@ -4,14 +4,14 @@ import { loadingVariants as g } from "./Loading.variants.js";
|
|
|
4
4
|
import { forwardRef as s, createElement as i } from "react";
|
|
5
5
|
import { useTheme as w } from "../../contexts/theme.hook.js";
|
|
6
6
|
/**
|
|
7
|
-
* @license lucide-react v0.
|
|
7
|
+
* @license lucide-react v0.477.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/
|
|
12
12
|
const C = (r) => r.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), m = (...r) => r.filter((e, o, t) => !!e && e.trim() !== "" && t.indexOf(e) === o).join(" ").trim();
|
|
13
13
|
/**
|
|
14
|
-
* @license lucide-react v0.
|
|
14
|
+
* @license lucide-react v0.477.0 - ISC
|
|
15
15
|
*
|
|
16
16
|
* This source code is licensed under the ISC license.
|
|
17
17
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -28,7 +28,7 @@ var L = {
|
|
|
28
28
|
strokeLinejoin: "round"
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
|
-
* @license lucide-react v0.
|
|
31
|
+
* @license lucide-react v0.477.0 - ISC
|
|
32
32
|
*
|
|
33
33
|
* This source code is licensed under the ISC license.
|
|
34
34
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -62,7 +62,7 @@ const k = s(
|
|
|
62
62
|
)
|
|
63
63
|
);
|
|
64
64
|
/**
|
|
65
|
-
* @license lucide-react v0.
|
|
65
|
+
* @license lucide-react v0.477.0 - ISC
|
|
66
66
|
*
|
|
67
67
|
* This source code is licensed under the ISC license.
|
|
68
68
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -79,7 +79,7 @@ const x = (r, e) => {
|
|
|
79
79
|
return o.displayName = `${r}`, o;
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
82
|
-
* @license lucide-react v0.
|
|
82
|
+
* @license lucide-react v0.477.0 - ISC
|
|
83
83
|
*
|
|
84
84
|
* This source code is licensed under the ISC license.
|
|
85
85
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1,44 +1,39 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { textAreaVariants as
|
|
5
|
-
import { useTheme as
|
|
6
|
-
const
|
|
1
|
+
import { jsxs as d, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as h, useId as u } from "react";
|
|
3
|
+
import { cn as p } from "../../utils/index.js";
|
|
4
|
+
import { textAreaVariants as v } from "./TextArea.variants.js";
|
|
5
|
+
import { useTheme as N } from "../../contexts/theme.hook.js";
|
|
6
|
+
const w = h(
|
|
7
7
|
({
|
|
8
|
-
initialValue:
|
|
9
|
-
label:
|
|
10
|
-
name:
|
|
11
|
-
placeholder:
|
|
12
|
-
rows:
|
|
13
|
-
theme:
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
initialValue: a,
|
|
9
|
+
label: e,
|
|
10
|
+
name: s,
|
|
11
|
+
placeholder: l,
|
|
12
|
+
rows: c = 3,
|
|
13
|
+
theme: n,
|
|
14
|
+
className: i,
|
|
15
|
+
...r
|
|
16
16
|
}, f) => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
[e]
|
|
22
|
-
);
|
|
23
|
-
return /* @__PURE__ */ N("div", { className: "flex flex-col gap-2", children: [
|
|
24
|
-
t ? /* @__PURE__ */ m("label", { htmlFor: s, className: "cursor-pointer", children: t }) : null,
|
|
25
|
-
/* @__PURE__ */ m(
|
|
17
|
+
const t = u(), { theme: x } = N(), m = s ? `${t}-name` : t;
|
|
18
|
+
return /* @__PURE__ */ d("div", { className: "flex flex-col gap-2", children: [
|
|
19
|
+
e ? /* @__PURE__ */ o("label", { htmlFor: m, className: "cursor-pointer", children: e }) : null,
|
|
20
|
+
/* @__PURE__ */ o(
|
|
26
21
|
"textarea",
|
|
27
22
|
{
|
|
28
|
-
id:
|
|
23
|
+
id: m,
|
|
29
24
|
ref: f,
|
|
30
|
-
className:
|
|
31
|
-
|
|
25
|
+
className: p(
|
|
26
|
+
v({ className: i, theme: n ?? x })
|
|
32
27
|
),
|
|
33
|
-
rows:
|
|
34
|
-
placeholder:
|
|
35
|
-
value:
|
|
36
|
-
|
|
28
|
+
rows: c,
|
|
29
|
+
placeholder: l,
|
|
30
|
+
value: a ?? r.value,
|
|
31
|
+
...r
|
|
37
32
|
}
|
|
38
33
|
)
|
|
39
34
|
] });
|
|
40
35
|
}
|
|
41
36
|
);
|
|
42
37
|
export {
|
|
43
|
-
|
|
38
|
+
w as TextArea
|
|
44
39
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx as c, jsxs as D, Fragment as se } from "react/jsx-runtime";
|
|
2
2
|
import { u as ae, S as j } from "../../index-B_6_jmOO.js";
|
|
3
3
|
import * as s from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { P as L, r as
|
|
6
|
-
import { c as
|
|
7
|
-
import { c as
|
|
8
|
-
import { B as
|
|
9
|
-
import { P as
|
|
10
|
-
import { V as ie, R as
|
|
4
|
+
import { useRef as Re, useEffect as be, useMemo as oe, isValidElement as re, useCallback as ge } from "react";
|
|
5
|
+
import { P as L, r as Se, d as Ie } from "../../index-D7QNmo_D.js";
|
|
6
|
+
import { c as Ne, a as Ae, b, d as X, u as Fe } from "../../index-Cva-e5M4.js";
|
|
7
|
+
import { c as _e } from "../../index-BbsJ0VIJ.js";
|
|
8
|
+
import { B as De, R as Le, P as Me } from "../../index-D_76wh4w.js";
|
|
9
|
+
import { P as Oe } from "../../index-Dj1pom3_.js";
|
|
10
|
+
import { V as ie, R as ke } from "../../index-CbTU3cnP.js";
|
|
11
11
|
import { cn as q } from "../../utils/index.js";
|
|
12
|
-
import { closeToastVariants as
|
|
13
|
-
import { X as
|
|
14
|
-
import { useTheme as
|
|
15
|
-
var Z = "ToastProvider", [ee,
|
|
12
|
+
import { closeToastVariants as Ve, toastVariants as Ke, viewportToastVariants as He } from "./Toast.variants.js";
|
|
13
|
+
import { X as We } from "../../x-DU-Zw-L_.js";
|
|
14
|
+
import { useTheme as Xe } from "../../contexts/theme.hook.js";
|
|
15
|
+
var Z = "ToastProvider", [ee, $e, Ue] = _e("Toast"), [ce, bt] = Ne("Toast", [Ue]), [Ye, $] = ce(Z), ue = (e) => {
|
|
16
16
|
const {
|
|
17
17
|
__scopeToast: r,
|
|
18
18
|
label: o = "Notification",
|
|
@@ -20,11 +20,11 @@ var Z = "ToastProvider", [ee, Ue, Ye] = De("Toast"), [ce, gt] = Ae("Toast", [Ye]
|
|
|
20
20
|
swipeDirection: u = "right",
|
|
21
21
|
swipeThreshold: d = 50,
|
|
22
22
|
children: f
|
|
23
|
-
} = e, [m, v] = s.useState(null), [n,
|
|
23
|
+
} = e, [m, v] = s.useState(null), [n, y] = s.useState(0), w = s.useRef(!1), S = s.useRef(!1);
|
|
24
24
|
return o.trim() || console.error(
|
|
25
25
|
`Invalid prop \`label\` supplied to \`${Z}\`. Expected non-empty \`string\`.`
|
|
26
26
|
), /* @__PURE__ */ c(ee.Provider, { scope: r, children: /* @__PURE__ */ c(
|
|
27
|
-
|
|
27
|
+
Ye,
|
|
28
28
|
{
|
|
29
29
|
scope: r,
|
|
30
30
|
label: o,
|
|
@@ -34,90 +34,90 @@ var Z = "ToastProvider", [ee, Ue, Ye] = De("Toast"), [ce, gt] = Ae("Toast", [Ye]
|
|
|
34
34
|
toastCount: n,
|
|
35
35
|
viewport: m,
|
|
36
36
|
onViewportChange: v,
|
|
37
|
-
onToastAdd: s.useCallback(() =>
|
|
38
|
-
onToastRemove: s.useCallback(() =>
|
|
39
|
-
isFocusedToastEscapeKeyDownRef:
|
|
40
|
-
isClosePausedRef:
|
|
37
|
+
onToastAdd: s.useCallback(() => y((g) => g + 1), []),
|
|
38
|
+
onToastRemove: s.useCallback(() => y((g) => g - 1), []),
|
|
39
|
+
isFocusedToastEscapeKeyDownRef: w,
|
|
40
|
+
isClosePausedRef: S,
|
|
41
41
|
children: f
|
|
42
42
|
}
|
|
43
43
|
) });
|
|
44
44
|
};
|
|
45
45
|
ue.displayName = Z;
|
|
46
|
-
var le = "ToastViewport",
|
|
46
|
+
var le = "ToastViewport", Be = ["F8"], G = "toast.viewportPause", J = "toast.viewportResume", de = s.forwardRef(
|
|
47
47
|
(e, r) => {
|
|
48
48
|
const {
|
|
49
49
|
__scopeToast: o,
|
|
50
|
-
hotkey: t =
|
|
50
|
+
hotkey: t = Be,
|
|
51
51
|
label: u = "Notifications ({hotkey})",
|
|
52
52
|
...d
|
|
53
|
-
} = e, f = $(le, o), m =
|
|
53
|
+
} = e, f = $(le, o), m = $e(o), v = s.useRef(null), n = s.useRef(null), y = s.useRef(null), w = s.useRef(null), S = ae(r, w, f.onViewportChange), g = t.join("+").replace(/Key/g, "").replace(/Digit/g, ""), R = f.toastCount > 0;
|
|
54
54
|
s.useEffect(() => {
|
|
55
|
-
const a = (
|
|
55
|
+
const a = (h) => {
|
|
56
56
|
var T;
|
|
57
|
-
t.length !== 0 && t.every((
|
|
57
|
+
t.length !== 0 && t.every((E) => h[E] || h.code === E) && ((T = w.current) == null || T.focus());
|
|
58
58
|
};
|
|
59
59
|
return document.addEventListener("keydown", a), () => document.removeEventListener("keydown", a);
|
|
60
60
|
}, [t]), s.useEffect(() => {
|
|
61
|
-
const a = v.current,
|
|
62
|
-
if (
|
|
61
|
+
const a = v.current, h = w.current;
|
|
62
|
+
if (R && a && h) {
|
|
63
63
|
const p = () => {
|
|
64
64
|
if (!f.isClosePausedRef.current) {
|
|
65
|
-
const
|
|
66
|
-
|
|
65
|
+
const P = new CustomEvent(G);
|
|
66
|
+
h.dispatchEvent(P), f.isClosePausedRef.current = !0;
|
|
67
67
|
}
|
|
68
68
|
}, T = () => {
|
|
69
69
|
if (f.isClosePausedRef.current) {
|
|
70
|
-
const
|
|
71
|
-
|
|
70
|
+
const P = new CustomEvent(J);
|
|
71
|
+
h.dispatchEvent(P), f.isClosePausedRef.current = !1;
|
|
72
72
|
}
|
|
73
|
-
},
|
|
74
|
-
!a.contains(
|
|
75
|
-
},
|
|
73
|
+
}, E = (P) => {
|
|
74
|
+
!a.contains(P.relatedTarget) && T();
|
|
75
|
+
}, C = () => {
|
|
76
76
|
a.contains(document.activeElement) || T();
|
|
77
77
|
};
|
|
78
|
-
return a.addEventListener("focusin", p), a.addEventListener("focusout",
|
|
79
|
-
a.removeEventListener("focusin", p), a.removeEventListener("focusout",
|
|
78
|
+
return a.addEventListener("focusin", p), a.addEventListener("focusout", E), a.addEventListener("pointermove", p), a.addEventListener("pointerleave", C), window.addEventListener("blur", p), window.addEventListener("focus", T), () => {
|
|
79
|
+
a.removeEventListener("focusin", p), a.removeEventListener("focusout", E), a.removeEventListener("pointermove", p), a.removeEventListener("pointerleave", C), window.removeEventListener("blur", p), window.removeEventListener("focus", T);
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
}, [
|
|
82
|
+
}, [R, f.isClosePausedRef]);
|
|
83
83
|
const l = s.useCallback(
|
|
84
84
|
({ tabbingDirection: a }) => {
|
|
85
85
|
const p = m().map((T) => {
|
|
86
|
-
const
|
|
87
|
-
return a === "forwards" ?
|
|
86
|
+
const E = T.ref.current, C = [E, ...st(E)];
|
|
87
|
+
return a === "forwards" ? C : C.reverse();
|
|
88
88
|
});
|
|
89
89
|
return (a === "forwards" ? p.reverse() : p).flat();
|
|
90
90
|
},
|
|
91
91
|
[m]
|
|
92
92
|
);
|
|
93
93
|
return s.useEffect(() => {
|
|
94
|
-
const a =
|
|
94
|
+
const a = w.current;
|
|
95
95
|
if (a) {
|
|
96
|
-
const
|
|
97
|
-
var
|
|
96
|
+
const h = (p) => {
|
|
97
|
+
var C, P, N;
|
|
98
98
|
const T = p.altKey || p.ctrlKey || p.metaKey;
|
|
99
99
|
if (p.key === "Tab" && !T) {
|
|
100
|
-
const
|
|
100
|
+
const M = document.activeElement, F = p.shiftKey;
|
|
101
101
|
if (p.target === a && F) {
|
|
102
|
-
(
|
|
102
|
+
(C = n.current) == null || C.focus();
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
const A = l({ tabbingDirection: F ? "backwards" : "forwards" }), V = A.findIndex((i) => i ===
|
|
106
|
-
z(A.slice(V + 1)) ? p.preventDefault() : F ? (
|
|
105
|
+
const A = l({ tabbingDirection: F ? "backwards" : "forwards" }), V = A.findIndex((i) => i === M);
|
|
106
|
+
z(A.slice(V + 1)) ? p.preventDefault() : F ? (P = n.current) == null || P.focus() : (N = y.current) == null || N.focus();
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
-
return a.addEventListener("keydown",
|
|
109
|
+
return a.addEventListener("keydown", h), () => a.removeEventListener("keydown", h);
|
|
110
110
|
}
|
|
111
111
|
}, [m, l]), /* @__PURE__ */ D(
|
|
112
|
-
|
|
112
|
+
De,
|
|
113
113
|
{
|
|
114
114
|
ref: v,
|
|
115
115
|
role: "region",
|
|
116
|
-
"aria-label": u.replace("{hotkey}",
|
|
116
|
+
"aria-label": u.replace("{hotkey}", g),
|
|
117
117
|
tabIndex: -1,
|
|
118
|
-
style: { pointerEvents:
|
|
118
|
+
style: { pointerEvents: R ? void 0 : "none" },
|
|
119
119
|
children: [
|
|
120
|
-
|
|
120
|
+
R && /* @__PURE__ */ c(
|
|
121
121
|
Q,
|
|
122
122
|
{
|
|
123
123
|
ref: n,
|
|
@@ -129,11 +129,11 @@ var le = "ToastViewport", je = ["F8"], G = "toast.viewportPause", J = "toast.vie
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
),
|
|
132
|
-
/* @__PURE__ */ c(ee.Slot, { scope: o, children: /* @__PURE__ */ c(L.ol, { tabIndex: -1, ...d, ref:
|
|
133
|
-
|
|
132
|
+
/* @__PURE__ */ c(ee.Slot, { scope: o, children: /* @__PURE__ */ c(L.ol, { tabIndex: -1, ...d, ref: S }) }),
|
|
133
|
+
R && /* @__PURE__ */ c(
|
|
134
134
|
Q,
|
|
135
135
|
{
|
|
136
|
-
ref:
|
|
136
|
+
ref: y,
|
|
137
137
|
onFocusFromOutsideViewport: () => {
|
|
138
138
|
const a = l({
|
|
139
139
|
tabbingDirection: "backwards"
|
|
@@ -169,15 +169,15 @@ var fe = "ToastFocusProxy", Q = s.forwardRef(
|
|
|
169
169
|
}
|
|
170
170
|
);
|
|
171
171
|
Q.displayName = fe;
|
|
172
|
-
var U = "Toast",
|
|
172
|
+
var U = "Toast", je = "toast.swipeStart", qe = "toast.swipeMove", ze = "toast.swipeCancel", Ge = "toast.swipeEnd", pe = s.forwardRef(
|
|
173
173
|
(e, r) => {
|
|
174
|
-
const { forceMount: o, open: t, defaultOpen: u, onOpenChange: d, ...f } = e, [m = !0, v] =
|
|
174
|
+
const { forceMount: o, open: t, defaultOpen: u, onOpenChange: d, ...f } = e, [m = !0, v] = Ae({
|
|
175
175
|
prop: t,
|
|
176
176
|
defaultProp: u,
|
|
177
177
|
onChange: d
|
|
178
178
|
});
|
|
179
|
-
return /* @__PURE__ */ c(
|
|
180
|
-
|
|
179
|
+
return /* @__PURE__ */ c(Oe, { present: o || m, children: /* @__PURE__ */ c(
|
|
180
|
+
Ze,
|
|
181
181
|
{
|
|
182
182
|
open: m,
|
|
183
183
|
...f,
|
|
@@ -189,25 +189,25 @@ var U = "Toast", qe = "toast.swipeStart", ze = "toast.swipeMove", Ge = "toast.sw
|
|
|
189
189
|
n.currentTarget.setAttribute("data-swipe", "start");
|
|
190
190
|
}),
|
|
191
191
|
onSwipeMove: b(e.onSwipeMove, (n) => {
|
|
192
|
-
const { x:
|
|
193
|
-
n.currentTarget.setAttribute("data-swipe", "move"), n.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${
|
|
192
|
+
const { x: y, y: w } = n.detail.delta;
|
|
193
|
+
n.currentTarget.setAttribute("data-swipe", "move"), n.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${y}px`), n.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${w}px`);
|
|
194
194
|
}),
|
|
195
195
|
onSwipeCancel: b(e.onSwipeCancel, (n) => {
|
|
196
196
|
n.currentTarget.setAttribute("data-swipe", "cancel"), n.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), n.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), n.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"), n.currentTarget.style.removeProperty("--radix-toast-swipe-end-y");
|
|
197
197
|
}),
|
|
198
198
|
onSwipeEnd: b(e.onSwipeEnd, (n) => {
|
|
199
|
-
const { x:
|
|
200
|
-
n.currentTarget.setAttribute("data-swipe", "end"), n.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), n.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), n.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${
|
|
199
|
+
const { x: y, y: w } = n.detail.delta;
|
|
200
|
+
n.currentTarget.setAttribute("data-swipe", "end"), n.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), n.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), n.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${y}px`), n.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${w}px`), v(!1);
|
|
201
201
|
})
|
|
202
202
|
}
|
|
203
203
|
) });
|
|
204
204
|
}
|
|
205
205
|
);
|
|
206
206
|
pe.displayName = U;
|
|
207
|
-
var [
|
|
207
|
+
var [Je, Qe] = ce(U, {
|
|
208
208
|
onClose() {
|
|
209
209
|
}
|
|
210
|
-
}),
|
|
210
|
+
}), Ze = s.forwardRef(
|
|
211
211
|
(e, r) => {
|
|
212
212
|
const {
|
|
213
213
|
__scopeToast: o,
|
|
@@ -218,17 +218,17 @@ var [Qe, Ze] = ce(U, {
|
|
|
218
218
|
onEscapeKeyDown: m,
|
|
219
219
|
onPause: v,
|
|
220
220
|
onResume: n,
|
|
221
|
-
onSwipeStart:
|
|
222
|
-
onSwipeMove:
|
|
223
|
-
onSwipeCancel:
|
|
224
|
-
onSwipeEnd:
|
|
225
|
-
...
|
|
226
|
-
} = e, l = $(U, o), [a,
|
|
221
|
+
onSwipeStart: y,
|
|
222
|
+
onSwipeMove: w,
|
|
223
|
+
onSwipeCancel: S,
|
|
224
|
+
onSwipeEnd: g,
|
|
225
|
+
...R
|
|
226
|
+
} = e, l = $(U, o), [a, h] = s.useState(null), p = ae(r, (i) => h(i)), T = s.useRef(null), E = s.useRef(null), C = u || l.duration, P = s.useRef(0), N = s.useRef(C), M = s.useRef(0), { onToastAdd: F, onToastRemove: Y } = l, _ = X(() => {
|
|
227
227
|
var x;
|
|
228
228
|
(a == null ? void 0 : a.contains(document.activeElement)) && ((x = l.viewport) == null || x.focus()), f();
|
|
229
229
|
}), A = s.useCallback(
|
|
230
230
|
(i) => {
|
|
231
|
-
!i || i === 1 / 0 || (window.clearTimeout(
|
|
231
|
+
!i || i === 1 / 0 || (window.clearTimeout(M.current), P.current = (/* @__PURE__ */ new Date()).getTime(), M.current = window.setTimeout(_, i));
|
|
232
232
|
},
|
|
233
233
|
[_]
|
|
234
234
|
);
|
|
@@ -237,21 +237,21 @@ var [Qe, Ze] = ce(U, {
|
|
|
237
237
|
if (i) {
|
|
238
238
|
const x = () => {
|
|
239
239
|
A(N.current), n == null || n();
|
|
240
|
-
},
|
|
241
|
-
const
|
|
242
|
-
N.current = N.current -
|
|
240
|
+
}, I = () => {
|
|
241
|
+
const O = (/* @__PURE__ */ new Date()).getTime() - P.current;
|
|
242
|
+
N.current = N.current - O, window.clearTimeout(M.current), v == null || v();
|
|
243
243
|
};
|
|
244
|
-
return i.addEventListener(G,
|
|
245
|
-
i.removeEventListener(G,
|
|
244
|
+
return i.addEventListener(G, I), i.addEventListener(J, x), () => {
|
|
245
|
+
i.removeEventListener(G, I), i.removeEventListener(J, x);
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
|
-
}, [l.viewport,
|
|
249
|
-
d && !l.isClosePausedRef.current && A(
|
|
250
|
-
}, [d,
|
|
251
|
-
const V = s.useMemo(() => a ?
|
|
248
|
+
}, [l.viewport, C, v, n, A]), s.useEffect(() => {
|
|
249
|
+
d && !l.isClosePausedRef.current && A(C);
|
|
250
|
+
}, [d, C, l.isClosePausedRef, A]), s.useEffect(() => (F(), () => Y()), [F, Y]);
|
|
251
|
+
const V = s.useMemo(() => a ? Ce(a) : null, [a]);
|
|
252
252
|
return l.viewport ? /* @__PURE__ */ D(se, { children: [
|
|
253
253
|
V && /* @__PURE__ */ c(
|
|
254
|
-
|
|
254
|
+
et,
|
|
255
255
|
{
|
|
256
256
|
__scopeToast: o,
|
|
257
257
|
role: "status",
|
|
@@ -260,9 +260,9 @@ var [Qe, Ze] = ce(U, {
|
|
|
260
260
|
children: V
|
|
261
261
|
}
|
|
262
262
|
),
|
|
263
|
-
/* @__PURE__ */ c(
|
|
263
|
+
/* @__PURE__ */ c(Je, { scope: o, onClose: _, children: Se.createPortal(
|
|
264
264
|
/* @__PURE__ */ c(ee.ItemSlot, { scope: o, children: /* @__PURE__ */ c(
|
|
265
|
-
|
|
265
|
+
Le,
|
|
266
266
|
{
|
|
267
267
|
asChild: !0,
|
|
268
268
|
onEscapeKeyDown: b(m, () => {
|
|
@@ -277,7 +277,7 @@ var [Qe, Ze] = ce(U, {
|
|
|
277
277
|
tabIndex: 0,
|
|
278
278
|
"data-state": d ? "open" : "closed",
|
|
279
279
|
"data-swipe-direction": l.swipeDirection,
|
|
280
|
-
...
|
|
280
|
+
...R,
|
|
281
281
|
ref: p,
|
|
282
282
|
style: { userSelect: "none", touchAction: "none", ...e.style },
|
|
283
283
|
onKeyDown: b(e.onKeyDown, (i) => {
|
|
@@ -288,27 +288,27 @@ var [Qe, Ze] = ce(U, {
|
|
|
288
288
|
}),
|
|
289
289
|
onPointerMove: b(e.onPointerMove, (i) => {
|
|
290
290
|
if (!T.current) return;
|
|
291
|
-
const x = i.clientX - T.current.x,
|
|
292
|
-
|
|
291
|
+
const x = i.clientX - T.current.x, I = i.clientY - T.current.y, O = !!E.current, k = ["left", "right"].includes(l.swipeDirection), K = ["left", "up"].includes(l.swipeDirection) ? Math.min : Math.max, Pe = k ? K(0, x) : 0, xe = k ? 0 : K(0, I), B = i.pointerType === "touch" ? 10 : 2, H = { x: Pe, y: xe }, te = { originalEvent: i, delta: H };
|
|
292
|
+
O ? (E.current = H, W(qe, w, te, {
|
|
293
293
|
discrete: !1
|
|
294
|
-
})) : ne(H, l.swipeDirection, B) ? (
|
|
294
|
+
})) : ne(H, l.swipeDirection, B) ? (E.current = H, W(je, y, te, {
|
|
295
295
|
discrete: !1
|
|
296
|
-
}), i.target.setPointerCapture(i.pointerId)) : (Math.abs(x) > B || Math.abs(
|
|
296
|
+
}), i.target.setPointerCapture(i.pointerId)) : (Math.abs(x) > B || Math.abs(I) > B) && (T.current = null);
|
|
297
297
|
}),
|
|
298
298
|
onPointerUp: b(e.onPointerUp, (i) => {
|
|
299
|
-
const x =
|
|
300
|
-
if (
|
|
301
|
-
const
|
|
302
|
-
ne(x, l.swipeDirection, l.swipeThreshold) ? W(
|
|
299
|
+
const x = E.current, I = i.target;
|
|
300
|
+
if (I.hasPointerCapture(i.pointerId) && I.releasePointerCapture(i.pointerId), E.current = null, T.current = null, x) {
|
|
301
|
+
const O = i.currentTarget, k = { originalEvent: i, delta: x };
|
|
302
|
+
ne(x, l.swipeDirection, l.swipeThreshold) ? W(Ge, g, k, {
|
|
303
303
|
discrete: !0
|
|
304
304
|
}) : W(
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
ze,
|
|
306
|
+
S,
|
|
307
307
|
k,
|
|
308
308
|
{
|
|
309
309
|
discrete: !0
|
|
310
310
|
}
|
|
311
|
-
),
|
|
311
|
+
), O.addEventListener("click", (K) => K.preventDefault(), {
|
|
312
312
|
once: !0
|
|
313
313
|
});
|
|
314
314
|
}
|
|
@@ -321,9 +321,9 @@ var [Qe, Ze] = ce(U, {
|
|
|
321
321
|
) })
|
|
322
322
|
] }) : null;
|
|
323
323
|
}
|
|
324
|
-
),
|
|
324
|
+
), et = (e) => {
|
|
325
325
|
const { __scopeToast: r, children: o, ...t } = e, u = $(U, r), [d, f] = s.useState(!1), [m, v] = s.useState(!1);
|
|
326
|
-
return
|
|
326
|
+
return rt(() => f(!0)), s.useEffect(() => {
|
|
327
327
|
const n = window.setTimeout(() => v(!0), 1e3);
|
|
328
328
|
return () => window.clearTimeout(n);
|
|
329
329
|
}, []), m ? null : /* @__PURE__ */ c(Me, { asChild: !0, children: /* @__PURE__ */ c(ie, { ...t, children: d && /* @__PURE__ */ D(se, { children: [
|
|
@@ -331,20 +331,20 @@ var [Qe, Ze] = ce(U, {
|
|
|
331
331
|
" ",
|
|
332
332
|
o
|
|
333
333
|
] }) }) });
|
|
334
|
-
},
|
|
334
|
+
}, tt = "ToastTitle", me = s.forwardRef(
|
|
335
335
|
(e, r) => {
|
|
336
336
|
const { __scopeToast: o, ...t } = e;
|
|
337
337
|
return /* @__PURE__ */ c(L.div, { ...t, ref: r });
|
|
338
338
|
}
|
|
339
339
|
);
|
|
340
|
-
me.displayName =
|
|
341
|
-
var
|
|
340
|
+
me.displayName = tt;
|
|
341
|
+
var ot = "ToastDescription", Te = s.forwardRef(
|
|
342
342
|
(e, r) => {
|
|
343
343
|
const { __scopeToast: o, ...t } = e;
|
|
344
344
|
return /* @__PURE__ */ c(L.div, { ...t, ref: r });
|
|
345
345
|
}
|
|
346
346
|
);
|
|
347
|
-
Te.displayName =
|
|
347
|
+
Te.displayName = ot;
|
|
348
348
|
var ve = "ToastAction", we = s.forwardRef(
|
|
349
349
|
(e, r) => {
|
|
350
350
|
const { altText: o, ...t } = e;
|
|
@@ -356,7 +356,7 @@ var ve = "ToastAction", we = s.forwardRef(
|
|
|
356
356
|
we.displayName = ve;
|
|
357
357
|
var Ee = "ToastClose", he = s.forwardRef(
|
|
358
358
|
(e, r) => {
|
|
359
|
-
const { __scopeToast: o, ...t } = e, u =
|
|
359
|
+
const { __scopeToast: o, ...t } = e, u = Qe(Ee, o);
|
|
360
360
|
return /* @__PURE__ */ c(ye, { asChild: !0, children: /* @__PURE__ */ c(
|
|
361
361
|
L.button,
|
|
362
362
|
{
|
|
@@ -381,42 +381,42 @@ var ye = s.forwardRef((e, r) => {
|
|
|
381
381
|
}
|
|
382
382
|
);
|
|
383
383
|
});
|
|
384
|
-
function
|
|
384
|
+
function Ce(e) {
|
|
385
385
|
const r = [];
|
|
386
386
|
return Array.from(e.childNodes).forEach((t) => {
|
|
387
|
-
if (t.nodeType === t.TEXT_NODE && t.textContent && r.push(t.textContent),
|
|
387
|
+
if (t.nodeType === t.TEXT_NODE && t.textContent && r.push(t.textContent), nt(t)) {
|
|
388
388
|
const u = t.ariaHidden || t.hidden || t.style.display === "none", d = t.dataset.radixToastAnnounceExclude === "";
|
|
389
389
|
if (!u)
|
|
390
390
|
if (d) {
|
|
391
391
|
const f = t.dataset.radixToastAnnounceAlt;
|
|
392
392
|
f && r.push(f);
|
|
393
393
|
} else
|
|
394
|
-
r.push(...
|
|
394
|
+
r.push(...Ce(t));
|
|
395
395
|
}
|
|
396
396
|
}), r;
|
|
397
397
|
}
|
|
398
398
|
function W(e, r, o, { discrete: t }) {
|
|
399
399
|
const u = o.originalEvent.currentTarget, d = new CustomEvent(e, { bubbles: !0, cancelable: !0, detail: o });
|
|
400
|
-
r && u.addEventListener(e, r, { once: !0 }), t ?
|
|
400
|
+
r && u.addEventListener(e, r, { once: !0 }), t ? Ie(u, d) : u.dispatchEvent(d);
|
|
401
401
|
}
|
|
402
402
|
var ne = (e, r, o = 0) => {
|
|
403
403
|
const t = Math.abs(e.x), u = Math.abs(e.y), d = t > u;
|
|
404
404
|
return r === "left" || r === "right" ? d && t > o : !d && u > o;
|
|
405
405
|
};
|
|
406
|
-
function
|
|
406
|
+
function rt(e = () => {
|
|
407
407
|
}) {
|
|
408
408
|
const r = X(e);
|
|
409
|
-
|
|
409
|
+
Fe(() => {
|
|
410
410
|
let o = 0, t = 0;
|
|
411
411
|
return o = window.requestAnimationFrame(() => t = window.requestAnimationFrame(r)), () => {
|
|
412
412
|
window.cancelAnimationFrame(o), window.cancelAnimationFrame(t);
|
|
413
413
|
};
|
|
414
414
|
}, [r]);
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function nt(e) {
|
|
417
417
|
return e.nodeType === e.ELEMENT_NODE;
|
|
418
418
|
}
|
|
419
|
-
function
|
|
419
|
+
function st(e) {
|
|
420
420
|
const r = [], o = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
|
|
421
421
|
acceptNode: (t) => {
|
|
422
422
|
const u = t.tagName === "INPUT" && t.type === "hidden";
|
|
@@ -430,8 +430,8 @@ function z(e) {
|
|
|
430
430
|
const r = document.activeElement;
|
|
431
431
|
return e.some((o) => o === r ? !0 : (o.focus(), document.activeElement !== r));
|
|
432
432
|
}
|
|
433
|
-
var
|
|
434
|
-
const
|
|
433
|
+
var at = ue, it = de, ct = pe, ut = me, lt = Te, dt = we;
|
|
434
|
+
const gt = ({
|
|
435
435
|
title: e,
|
|
436
436
|
duration: r = 5e3,
|
|
437
437
|
titleClassName: o,
|
|
@@ -440,39 +440,52 @@ const St = ({
|
|
|
440
440
|
children: d,
|
|
441
441
|
theme: f,
|
|
442
442
|
showCloseButton: m = !0,
|
|
443
|
-
|
|
443
|
+
closeButtonClassName: v,
|
|
444
|
+
className: n,
|
|
445
|
+
open: y = !1,
|
|
446
|
+
setOpen: w
|
|
444
447
|
}) => {
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
const
|
|
448
|
-
w(!1),
|
|
449
|
-
}, []);
|
|
450
|
-
return /* @__PURE__ */ D(
|
|
451
|
-
/* @__PURE__ */ c(j, { onClick:
|
|
448
|
+
const S = Re(0), { theme: g } = Xe(), R = f ?? g;
|
|
449
|
+
be(() => () => clearTimeout(S.current), []);
|
|
450
|
+
const l = oe(() => re(e) ? /* @__PURE__ */ c(j, { className: o, children: e }) : e, [e, o]), a = oe(() => re(u) ? /* @__PURE__ */ c(j, { className: t, children: u }) : u, [u, t]), h = ge(() => {
|
|
451
|
+
w(!1), S.current = window.setTimeout(() => w(!0), 100);
|
|
452
|
+
}, [w]);
|
|
453
|
+
return /* @__PURE__ */ D(at, { swipeDirection: "right", duration: r, children: [
|
|
454
|
+
/* @__PURE__ */ c(j, { onClick: h, children: d }),
|
|
452
455
|
/* @__PURE__ */ D(
|
|
453
|
-
|
|
456
|
+
ct,
|
|
454
457
|
{
|
|
455
|
-
className: q(
|
|
456
|
-
open:
|
|
458
|
+
className: q(Ke({ theme: R, className: n })),
|
|
459
|
+
open: y,
|
|
457
460
|
onOpenChange: w,
|
|
458
461
|
children: [
|
|
459
|
-
/* @__PURE__ */ c(
|
|
460
|
-
/* @__PURE__ */ c(
|
|
461
|
-
m && /* @__PURE__ */ c(
|
|
462
|
-
/* @__PURE__ */ c(
|
|
463
|
-
|
|
462
|
+
/* @__PURE__ */ c(ut, { asChild: !0, className: o, children: l }),
|
|
463
|
+
a && /* @__PURE__ */ c(lt, { asChild: !0, children: a }),
|
|
464
|
+
m && /* @__PURE__ */ c(dt, { asChild: !0, altText: "Close the toast", children: /* @__PURE__ */ D("button", { type: "button", className: "absolute right-1.5 top-1.5", children: [
|
|
465
|
+
/* @__PURE__ */ c(
|
|
466
|
+
We,
|
|
467
|
+
{
|
|
468
|
+
className: q(
|
|
469
|
+
Ve({
|
|
470
|
+
theme: R,
|
|
471
|
+
className: v
|
|
472
|
+
})
|
|
473
|
+
)
|
|
474
|
+
}
|
|
475
|
+
),
|
|
476
|
+
/* @__PURE__ */ c(ke, { children: "Close toast" })
|
|
464
477
|
] }) })
|
|
465
478
|
]
|
|
466
479
|
}
|
|
467
480
|
),
|
|
468
481
|
/* @__PURE__ */ c(
|
|
469
|
-
|
|
482
|
+
it,
|
|
470
483
|
{
|
|
471
|
-
className: q(
|
|
484
|
+
className: q(He({ theme: R }))
|
|
472
485
|
}
|
|
473
486
|
)
|
|
474
487
|
] });
|
|
475
488
|
};
|
|
476
489
|
export {
|
|
477
|
-
|
|
490
|
+
gt as Toast
|
|
478
491
|
};
|