kitzo 2.3.36 → 2.3.37
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,24 +1,30 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { subscribe as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { ToasterContext as
|
|
7
|
-
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as k, useEffect as v, useRef as x, useCallback as C, useLayoutEffect as w } from "react";
|
|
3
|
+
import { subscribe as E } from "./helpers/listenar.js";
|
|
4
|
+
import O from "./helpers/manageToasts/manageToasts.js";
|
|
5
|
+
import z from "./partials/ToastContainer.js";
|
|
6
|
+
import { ToasterContext as S } from "./context/ToasterContext.js";
|
|
7
|
+
import { initSwipeToClose as $ } from "./helpers/manageToasts/swipeClose.js";
|
|
8
|
+
function D(m) {
|
|
8
9
|
const {
|
|
9
10
|
position: d = "top-center",
|
|
10
11
|
richColors: c = !1,
|
|
11
12
|
animateTransformOrigin: h = !0,
|
|
12
|
-
gap:
|
|
13
|
-
edgeOffset:
|
|
14
|
-
isDark:
|
|
13
|
+
gap: o = 8,
|
|
14
|
+
edgeOffset: a = 16,
|
|
15
|
+
isDark: p = window.matchMedia("(prefers-color-scheme: dark)").matches,
|
|
15
16
|
pauseOnHover: g = !0,
|
|
16
|
-
swipeToClose:
|
|
17
|
-
} = m, [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
swipeToClose: b = !0
|
|
18
|
+
} = m, [f, l] = k([]);
|
|
19
|
+
v(() => {
|
|
20
|
+
const t = E((e) => O({ toast: e, setToasts: l })), s = $();
|
|
21
|
+
return () => {
|
|
22
|
+
t(), s();
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
const i = x(null), n = C(() => {
|
|
26
|
+
if (!i.current) return;
|
|
27
|
+
const t = i.current.querySelectorAll("[data-toast-container]"), s = {
|
|
22
28
|
"top-left": 0,
|
|
23
29
|
"top-center": 0,
|
|
24
30
|
"top-right": 0,
|
|
@@ -26,50 +32,50 @@ function j(m) {
|
|
|
26
32
|
"bottom-center": 0,
|
|
27
33
|
"bottom-right": 0
|
|
28
34
|
};
|
|
29
|
-
t.forEach((
|
|
30
|
-
const u =
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
35
|
+
t.forEach((e) => {
|
|
36
|
+
const u = e.getAttribute("data-toast-position") || "top-center", y = parseFloat(e.style.getPropertyValue("--toast-height")) || 0;
|
|
37
|
+
e.style.setProperty("--toast-offset-y", `${s[u]}px`);
|
|
38
|
+
const T = isNaN(+o) ? 8 : +o;
|
|
39
|
+
s[u] += y + T;
|
|
34
40
|
});
|
|
35
|
-
}, [
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
}, [
|
|
41
|
+
}, [o]);
|
|
42
|
+
return w(() => {
|
|
43
|
+
n();
|
|
44
|
+
}, [f, n]), /* @__PURE__ */ r(
|
|
39
45
|
"div",
|
|
40
46
|
{
|
|
41
|
-
ref:
|
|
47
|
+
ref: i,
|
|
42
48
|
style: {
|
|
43
49
|
position: "fixed",
|
|
44
50
|
inset: 0,
|
|
45
51
|
zIndex: 2147483647,
|
|
46
52
|
pointerEvents: "none",
|
|
47
53
|
display: "grid",
|
|
48
|
-
padding:
|
|
54
|
+
padding: a != null ? `${Math.max(Math.min(+a, 200), 0)}px` : 16
|
|
49
55
|
},
|
|
50
|
-
className: `kitzo-toaster ${c ? "kitzo-toaster-rich-colors" : ""} ${
|
|
51
|
-
children: /* @__PURE__ */
|
|
56
|
+
className: `kitzo-toaster ${c ? "kitzo-toaster-rich-colors" : ""} ${p ? "kitzo-toaster-dark" : ""}`,
|
|
57
|
+
children: /* @__PURE__ */ r(
|
|
52
58
|
"div",
|
|
53
59
|
{
|
|
54
60
|
style: {
|
|
55
61
|
position: "relative"
|
|
56
62
|
},
|
|
57
|
-
children: /* @__PURE__ */
|
|
58
|
-
|
|
63
|
+
children: /* @__PURE__ */ r(
|
|
64
|
+
S.Provider,
|
|
59
65
|
{
|
|
60
66
|
value: {
|
|
61
67
|
position: d,
|
|
62
68
|
richColors: c,
|
|
63
|
-
isDark:
|
|
64
|
-
gap:
|
|
65
|
-
edgeOffset:
|
|
69
|
+
isDark: p,
|
|
70
|
+
gap: o,
|
|
71
|
+
edgeOffset: a,
|
|
66
72
|
animateTransformOrigin: h,
|
|
67
73
|
pauseOnHover: g,
|
|
68
|
-
swipeToClose:
|
|
74
|
+
swipeToClose: b,
|
|
69
75
|
setToasts: l,
|
|
70
|
-
updateOffsets:
|
|
76
|
+
updateOffsets: n
|
|
71
77
|
},
|
|
72
|
-
children:
|
|
78
|
+
children: f.map((t) => /* @__PURE__ */ r(z, { t }, t.id))
|
|
73
79
|
}
|
|
74
80
|
)
|
|
75
81
|
}
|
|
@@ -78,5 +84,5 @@ function j(m) {
|
|
|
78
84
|
);
|
|
79
85
|
}
|
|
80
86
|
export {
|
|
81
|
-
|
|
87
|
+
D as default
|
|
82
88
|
};
|
|
@@ -1,70 +1,78 @@
|
|
|
1
|
-
import
|
|
2
|
-
let
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
return
|
|
1
|
+
import b from "../triggerToasts.js";
|
|
2
|
+
let s = !1, t = null, c = null, w = 0, r = 0, a = !1, l = null;
|
|
3
|
+
const L = 2, y = 90, S = 20, g = 100;
|
|
4
|
+
function P(e) {
|
|
5
|
+
const o = Math.sign(e) || 1, n = Math.abs(e), h = S * (1 - Math.exp(-n / g));
|
|
6
|
+
return o * h;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
if (!
|
|
10
|
-
const
|
|
11
|
-
return
|
|
8
|
+
function E(e) {
|
|
9
|
+
if (!e) return !1;
|
|
10
|
+
const o = e.dataset.swipeable === "true", n = e.dataset.isPromise === "true";
|
|
11
|
+
return o && !n;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
if (!
|
|
15
|
-
if (document.body.style.userSelect = "auto",
|
|
13
|
+
function i(e = !0) {
|
|
14
|
+
if (!t) return;
|
|
15
|
+
if (document.body.style.userSelect = "auto", e && l != null)
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
t.releasePointerCapture(l);
|
|
18
18
|
} catch {
|
|
19
19
|
console.error("");
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
21
|
+
t.style.setProperty("--swipe-x", "0px"), t.classList.remove("is-swiping");
|
|
22
|
+
const o = t;
|
|
23
|
+
if (t = null, c = null, l = null, a = !1, s = !1, r = 0, !o.matches(":hover")) {
|
|
24
|
+
const n = new MouseEvent("mouseleave", {
|
|
25
25
|
bubbles: !0,
|
|
26
26
|
cancelable: !0,
|
|
27
27
|
view: window
|
|
28
28
|
});
|
|
29
|
-
|
|
29
|
+
o.dispatchEvent(n);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!
|
|
38
|
-
if (r =
|
|
39
|
-
|
|
32
|
+
function d(e) {
|
|
33
|
+
const n = e.target.closest(".kitzo-toast");
|
|
34
|
+
n && (t = n, c = n.id, w = e.clientX, r = 0, a = !0, s = !1, l = e.pointerId);
|
|
35
|
+
}
|
|
36
|
+
function p(e) {
|
|
37
|
+
if (!a || !t) return;
|
|
38
|
+
if (r = e.clientX - w, !s && Math.abs(r) > L) {
|
|
39
|
+
s = !0, t.classList.add("is-swiping");
|
|
40
40
|
try {
|
|
41
|
-
|
|
41
|
+
t.setPointerCapture(e.pointerId), document.body.style.userSelect = "none";
|
|
42
42
|
} catch {
|
|
43
43
|
console.error("Failed to capture pointer");
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
if (!
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!
|
|
52
|
-
|
|
46
|
+
if (!s) return;
|
|
47
|
+
const n = E(t) ? r : P(r);
|
|
48
|
+
t.style.setProperty("--swipe-x", `${n}px`);
|
|
49
|
+
}
|
|
50
|
+
function f() {
|
|
51
|
+
if (!a || !t || c == null) {
|
|
52
|
+
i();
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
58
|
-
|
|
55
|
+
const e = E(t);
|
|
56
|
+
if (s && e && Math.abs(r) > y) {
|
|
57
|
+
const o = r > 0 ? 1 : -1, n = Math.abs(r) + 220;
|
|
58
|
+
t.style.setProperty("--exit-x", `${o * n}px`), t.dataset.exit = "swipe", b.dismiss(c);
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
60
|
+
i();
|
|
61
|
+
}
|
|
62
|
+
function v() {
|
|
63
|
+
i();
|
|
64
|
+
}
|
|
65
|
+
function m() {
|
|
66
|
+
a && i();
|
|
67
|
+
}
|
|
68
|
+
let u = !1;
|
|
69
|
+
function M() {
|
|
70
|
+
return u ? () => {
|
|
71
|
+
} : (u = !0, document.addEventListener("pointerdown", d), document.addEventListener("pointermove", p), document.addEventListener("pointerup", f), document.addEventListener("pointercancel", v), window.addEventListener("blur", m), () => {
|
|
72
|
+
i(), u = !1, document.removeEventListener("pointerdown", d), document.removeEventListener("pointermove", p), document.removeEventListener("pointerup", f), document.removeEventListener("pointercancel", v), window.removeEventListener("blur", m);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
68
75
|
export {
|
|
69
|
-
|
|
76
|
+
s as dragStarted,
|
|
77
|
+
M as initSwipeToClose
|
|
70
78
|
};
|