kitzo 2.3.35 → 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,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const o = `.kitzo-toaster {
|
|
2
2
|
--default-bg: hsl(0, 0%, 100%);
|
|
3
3
|
--default-text: hsl(0, 0%, 10%);
|
|
4
4
|
--default-border: hsl(0, 0%, 94%);
|
|
@@ -98,26 +98,6 @@ const r = `.kitzo-toaster {
|
|
|
98
98
|
transition: none !important;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
/*! toast transfor origin */
|
|
102
|
-
.kitzo-toast.transform-origin-top-left {
|
|
103
|
-
transform-origin: top left;
|
|
104
|
-
}
|
|
105
|
-
.kitzo-toast.transform-origin-top-center {
|
|
106
|
-
transform-origin: top center;
|
|
107
|
-
}
|
|
108
|
-
.kitzo-toast.transform-origin-top-right {
|
|
109
|
-
transform-origin: top right;
|
|
110
|
-
}
|
|
111
|
-
.kitzo-toast.transform-origin-bottom-left {
|
|
112
|
-
transform-origin: bottom left;
|
|
113
|
-
}
|
|
114
|
-
.kitzo-toast.transform-origin-bottom-center {
|
|
115
|
-
transform-origin: bottom center;
|
|
116
|
-
}
|
|
117
|
-
.kitzo-toast.transform-origin-bottom-right {
|
|
118
|
-
transform-origin: bottom right;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
101
|
/*! Toast theme styles */
|
|
122
102
|
.kitzo-toast[data-type='default'] {
|
|
123
103
|
background-color: var(--default-bg);
|
|
@@ -175,12 +155,10 @@ const r = `.kitzo-toaster {
|
|
|
175
155
|
|
|
176
156
|
.kitzo-toast[data-screen-y='top'] {
|
|
177
157
|
--motion-y: -120%;
|
|
178
|
-
transform-origin: top;
|
|
179
158
|
}
|
|
180
159
|
|
|
181
160
|
.kitzo-toast[data-screen-y='bottom'] {
|
|
182
161
|
--motion-y: 120%;
|
|
183
|
-
transform-origin: bottom;
|
|
184
162
|
}
|
|
185
163
|
|
|
186
164
|
.kitzo-toast[data-status='leaving'][data-exit='swipe'] {
|
|
@@ -219,6 +197,40 @@ const r = `.kitzo-toaster {
|
|
|
219
197
|
}
|
|
220
198
|
}
|
|
221
199
|
|
|
200
|
+
/*! toast transfor origin */
|
|
201
|
+
.kitzo-toast[data-position^='top'] {
|
|
202
|
+
transform-origin: top;
|
|
203
|
+
}
|
|
204
|
+
.kitzo-toast[data-position^='bottom'] {
|
|
205
|
+
transform-origin: bottom;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.kitzo-toast[data-animate-transform-origin='true'][data-position='top-left'] {
|
|
209
|
+
transform-origin: top left;
|
|
210
|
+
}
|
|
211
|
+
.kitzo-toast[data-animate-transform-origin='true'][data-position='top-center'] {
|
|
212
|
+
transform-origin: top;
|
|
213
|
+
}
|
|
214
|
+
.kitzo-toast[data-animate-transform-origin='true'][data-position='top-right'] {
|
|
215
|
+
transform-origin: top right;
|
|
216
|
+
}
|
|
217
|
+
.kitzo-toast[data-animate-transform-origin='true'][data-position='bottom-left'] {
|
|
218
|
+
transform-origin: bottom left;
|
|
219
|
+
}
|
|
220
|
+
.kitzo-toast[data-animate-transform-origin='true'][data-position='bottom-center'] {
|
|
221
|
+
transform-origin: bottom;
|
|
222
|
+
}
|
|
223
|
+
.kitzo-toast[data-animate-transform-origin='true'][data-position='bottom-right'] {
|
|
224
|
+
transform-origin: bottom right;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.kitzo-toast[data-status='leaving'][data-position^='top'] {
|
|
228
|
+
transform-origin: top;
|
|
229
|
+
}
|
|
230
|
+
.kitzo-toast[data-status='leaving'][data-position^='bottom'] {
|
|
231
|
+
transform-origin: bottom;
|
|
232
|
+
}
|
|
233
|
+
|
|
222
234
|
/*! svg stylings */
|
|
223
235
|
.svg-container {
|
|
224
236
|
display: grid;
|
|
@@ -259,12 +271,12 @@ const r = `.kitzo-toaster {
|
|
|
259
271
|
rotate: 360deg;
|
|
260
272
|
}
|
|
261
273
|
}`;
|
|
262
|
-
function
|
|
274
|
+
function a() {
|
|
263
275
|
if (!document.getElementById("kitzo-toast-styles")) {
|
|
264
276
|
const t = document.createElement("style");
|
|
265
|
-
t.id = "kitzo-toast-styles", t.textContent =
|
|
277
|
+
t.id = "kitzo-toast-styles", t.textContent = o, document.head.appendChild(t);
|
|
266
278
|
}
|
|
267
279
|
}
|
|
268
280
|
export {
|
|
269
|
-
|
|
281
|
+
a as default
|
|
270
282
|
};
|
|
@@ -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
|
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { jsxs as x, jsx as
|
|
2
|
-
import { resumeToast as
|
|
1
|
+
import { jsxs as x, jsx as t, Fragment as o } from "react/jsx-runtime";
|
|
2
|
+
import { resumeToast as m, pauseToast as p } from "../helpers/manageToasts/timers.js";
|
|
3
3
|
import S from "../helpers/triggerToasts.js";
|
|
4
|
-
import { InfoSvg as w, ErrorSvg as
|
|
4
|
+
import { InfoSvg as w, ErrorSvg as E, WarningSvg as T, SuccessSvg as k, LoadingSvg as I } from "./Svgs.js";
|
|
5
5
|
import { useToasterContext as L } from "../context/ToasterContext.js";
|
|
6
6
|
function C({
|
|
7
|
-
t:
|
|
8
|
-
position:
|
|
9
|
-
shouldAnimateTransformOrigin:
|
|
10
|
-
swipeToClose:
|
|
7
|
+
t: f,
|
|
8
|
+
position: n,
|
|
9
|
+
shouldAnimateTransformOrigin: c,
|
|
10
|
+
swipeToClose: u
|
|
11
11
|
}) {
|
|
12
|
-
const { setToasts:
|
|
13
|
-
loading: /* @__PURE__ */
|
|
14
|
-
success: /* @__PURE__ */
|
|
15
|
-
warning: /* @__PURE__ */
|
|
16
|
-
error: /* @__PURE__ */
|
|
17
|
-
info: /* @__PURE__ */
|
|
12
|
+
const { setToasts: l, pauseOnHover: s } = L(), { id: e, type: r, action: g, content: i, status: v, showIcon: h, icon: a, isPromise: y } = f, d = {
|
|
13
|
+
loading: /* @__PURE__ */ t(I, {}),
|
|
14
|
+
success: /* @__PURE__ */ t(k, {}),
|
|
15
|
+
warning: /* @__PURE__ */ t(T, {}),
|
|
16
|
+
error: /* @__PURE__ */ t(E, {}),
|
|
17
|
+
info: /* @__PURE__ */ t(w, {}),
|
|
18
18
|
default: null,
|
|
19
19
|
custom: null
|
|
20
20
|
};
|
|
21
21
|
return /* @__PURE__ */ x(
|
|
22
22
|
"div",
|
|
23
23
|
{
|
|
24
|
-
id:
|
|
24
|
+
id: e,
|
|
25
25
|
style: {
|
|
26
26
|
pointerEvents: "all",
|
|
27
27
|
display: "flex",
|
|
@@ -32,34 +32,36 @@ function C({
|
|
|
32
32
|
"data-action": g,
|
|
33
33
|
"data-status": v,
|
|
34
34
|
"data-type": r,
|
|
35
|
-
"data-
|
|
36
|
-
"data-screen-
|
|
35
|
+
"data-position": n,
|
|
36
|
+
"data-screen-x": n.split("-")[1],
|
|
37
|
+
"data-screen-y": n.split("-")[0],
|
|
37
38
|
"data-exit": "auto",
|
|
38
39
|
"data-is-promise": y,
|
|
39
|
-
"data-swipeable":
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
"data-swipeable": u,
|
|
41
|
+
"data-animate-transform-origin": c,
|
|
42
|
+
className: `kitzo-toast ${c ? `transform-origin-${n}` : ""}`,
|
|
43
|
+
onPointerEnter: () => s && p(e),
|
|
44
|
+
onPointerLeave: () => s && m(e, l),
|
|
45
|
+
onMouseEnter: () => s && p(e),
|
|
46
|
+
onMouseLeave: () => s && m(e, l),
|
|
45
47
|
children: [
|
|
46
|
-
h && /* @__PURE__ */
|
|
48
|
+
h && /* @__PURE__ */ t(o, { children: a ? /* @__PURE__ */ t(o, { children: typeof a == "string" || typeof a == "number" ? /* @__PURE__ */ t(
|
|
47
49
|
"div",
|
|
48
50
|
{
|
|
49
51
|
style: {
|
|
50
52
|
flexShrink: 0
|
|
51
53
|
},
|
|
52
54
|
className: "svg-container",
|
|
53
|
-
children:
|
|
55
|
+
children: a
|
|
54
56
|
}
|
|
55
|
-
) : /* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */
|
|
57
|
+
) : /* @__PURE__ */ t(o, { children: a }) }) : /* @__PURE__ */ t(o, { children: d[r] && /* @__PURE__ */ t("div", { style: { flexShrink: 0 }, className: "svg-container", children: d[r] }) }) }),
|
|
58
|
+
/* @__PURE__ */ t(
|
|
57
59
|
"div",
|
|
58
60
|
{
|
|
59
61
|
style: {
|
|
60
62
|
flex: 1
|
|
61
63
|
},
|
|
62
|
-
children: typeof i == "function" ? i(() => S.dismiss(
|
|
64
|
+
children: typeof i == "function" ? i(() => S.dismiss(e)) : i
|
|
63
65
|
}
|
|
64
66
|
)
|
|
65
67
|
]
|