kitzo 2.3.41 → 2.3.43
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/index.d.ts +4 -2
- package/dist/react/components/toast/Toaster.js +97 -94
- package/dist/react/components/toast/helpers/addToastStyles.js +295 -282
- package/dist/react/components/toast/helpers/createToast.js +50 -49
- package/dist/react/components/toast/helpers/listenars.js +24 -0
- package/dist/react/components/toast/helpers/manageToasts/addToasts.js +11 -11
- package/dist/react/components/toast/helpers/manageToasts/dismissToasts.js +19 -21
- package/dist/react/components/toast/helpers/manageToasts/swipeClose.js +76 -78
- package/dist/react/components/toast/helpers/manageToasts/timers.js +73 -79
- package/dist/react/components/toast/helpers/manageToasts/updateToasts.js +14 -9
- package/dist/react/components/toast/helpers/triggerToasts.js +99 -100
- package/dist/react/components/toast/partials/Toast.js +84 -73
- package/dist/react/components/tooltip/Tooltip.js +22 -22
- package/package.json +1 -1
- package/dist/react/components/toast/helpers/listenar.js +0 -14
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ declare type PromiseToastMsgs<T, E = unknown> = {
|
|
|
27
27
|
error: ReactNode | ((err: E) => ReactNode | Promise<ReactNode>);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
declare type PromiseToastOptions = Omit<ToastOptions, 'id' | 'type'
|
|
30
|
+
declare type PromiseToastOptions = Omit<ToastOptions, 'id' | 'type'>;
|
|
31
31
|
|
|
32
32
|
export declare const toast: ToastFn;
|
|
33
33
|
|
|
@@ -44,6 +44,7 @@ declare type ToasterProps = {
|
|
|
44
44
|
isDark?: boolean;
|
|
45
45
|
pauseOnHover?: boolean;
|
|
46
46
|
swipeToClose?: boolean;
|
|
47
|
+
toasterId?: string | number;
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
declare type ToastFn = {
|
|
@@ -55,7 +56,7 @@ declare type ToastFn = {
|
|
|
55
56
|
promise: PromiseToastFn;
|
|
56
57
|
loading: (content: ToastContent, options?: Options) => void;
|
|
57
58
|
custom: (content: ToastContent, options?: Options) => void;
|
|
58
|
-
dismiss: (id?: string | number) => void;
|
|
59
|
+
dismiss: (id?: string | number, toasterId?: string | number) => void;
|
|
59
60
|
update: (id: string | number, content: ToastContent, options?: UpdateToastOptions) => void;
|
|
60
61
|
};
|
|
61
62
|
|
|
@@ -68,6 +69,7 @@ declare type ToastOptions = {
|
|
|
68
69
|
id?: string | number;
|
|
69
70
|
type?: ToastType;
|
|
70
71
|
swipeToClose?: boolean;
|
|
72
|
+
toasterId?: string | number;
|
|
71
73
|
};
|
|
72
74
|
|
|
73
75
|
declare type ToastOptionsWithoutType = Omit<ToastOptions, 'type'>;
|
|
@@ -1,94 +1,97 @@
|
|
|
1
|
-
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import t from "react";
|
|
3
|
-
import { subscribe as E } from "./helpers/
|
|
4
|
-
import w from "./helpers/manageToasts/manageToasts.js";
|
|
5
|
-
import M from "./partials/ToastContainer.js";
|
|
6
|
-
import { ToasterContext as O } from "./context/ToasterContext.js";
|
|
7
|
-
import { initSwipeToClose as S } from "./helpers/manageToasts/swipeClose.js";
|
|
8
|
-
function
|
|
9
|
-
const {
|
|
10
|
-
position: h = "top-center",
|
|
11
|
-
richColors:
|
|
12
|
-
animateTransformOrigin: g = !0,
|
|
13
|
-
gap: s = 8,
|
|
14
|
-
edgeOffset:
|
|
15
|
-
isDark:
|
|
16
|
-
pauseOnHover: b = !0,
|
|
17
|
-
swipeToClose: y = !0
|
|
18
|
-
} =
|
|
19
|
-
t.useEffect(() => {
|
|
20
|
-
T(!0);
|
|
21
|
-
}, []);
|
|
22
|
-
const [
|
|
23
|
-
t.useEffect(() => {
|
|
24
|
-
const e = E(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}, [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import t from "react";
|
|
3
|
+
import { subscribe as E } from "./helpers/listenars.js";
|
|
4
|
+
import w from "./helpers/manageToasts/manageToasts.js";
|
|
5
|
+
import M from "./partials/ToastContainer.js";
|
|
6
|
+
import { ToasterContext as O } from "./context/ToasterContext.js";
|
|
7
|
+
import { initSwipeToClose as S } from "./helpers/manageToasts/swipeClose.js";
|
|
8
|
+
function D(i) {
|
|
9
|
+
const {
|
|
10
|
+
position: h = "top-center",
|
|
11
|
+
richColors: l = !1,
|
|
12
|
+
animateTransformOrigin: g = !0,
|
|
13
|
+
gap: s = 8,
|
|
14
|
+
edgeOffset: n = 16,
|
|
15
|
+
isDark: c,
|
|
16
|
+
pauseOnHover: b = !0,
|
|
17
|
+
swipeToClose: y = !0
|
|
18
|
+
} = i, [k, T] = t.useState(!1);
|
|
19
|
+
t.useEffect(() => {
|
|
20
|
+
T(!0);
|
|
21
|
+
}, []);
|
|
22
|
+
const [p, m] = t.useState([]);
|
|
23
|
+
t.useEffect(() => {
|
|
24
|
+
const e = E(
|
|
25
|
+
(o) => w({ toast: o, setToasts: m }),
|
|
26
|
+
i.toasterId
|
|
27
|
+
), r = S();
|
|
28
|
+
return () => {
|
|
29
|
+
e(), r();
|
|
30
|
+
};
|
|
31
|
+
}, [i.toasterId]);
|
|
32
|
+
const f = t.useRef(null), u = t.useCallback(() => {
|
|
33
|
+
if (!f.current) return;
|
|
34
|
+
const e = f.current.querySelectorAll("[data-toast-container]"), r = {
|
|
35
|
+
"top-left": 0,
|
|
36
|
+
"top-center": 0,
|
|
37
|
+
"top-right": 0,
|
|
38
|
+
"bottom-left": 0,
|
|
39
|
+
"bottom-center": 0,
|
|
40
|
+
"bottom-right": 0
|
|
41
|
+
};
|
|
42
|
+
e.forEach((o) => {
|
|
43
|
+
const d = o.getAttribute("data-toast-position") || "top-center", x = parseFloat(o.style.getPropertyValue("--toast-height")) || 0;
|
|
44
|
+
o.style.setProperty("--toast-offset-y", `${r[d]}px`);
|
|
45
|
+
const C = isNaN(+s) ? 8 : +s;
|
|
46
|
+
r[d] += x + C;
|
|
47
|
+
});
|
|
48
|
+
}, [s]);
|
|
49
|
+
if (t.useLayoutEffect(() => {
|
|
50
|
+
u();
|
|
51
|
+
}, [p, u]), !k) return null;
|
|
52
|
+
const v = typeof c == "boolean" ? c : window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
53
|
+
return /* @__PURE__ */ a(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
ref: f,
|
|
57
|
+
style: {
|
|
58
|
+
position: "fixed",
|
|
59
|
+
inset: 0,
|
|
60
|
+
zIndex: 2147483647,
|
|
61
|
+
pointerEvents: "none",
|
|
62
|
+
display: "grid",
|
|
63
|
+
padding: n != null ? `${Math.max(Math.min(+n, 200), 0)}px` : 16
|
|
64
|
+
},
|
|
65
|
+
className: `kitzo-toaster ${l ? "kitzo-toaster-rich-colors" : ""} ${v ? "kitzo-toaster-dark" : ""}`,
|
|
66
|
+
children: /* @__PURE__ */ a(
|
|
67
|
+
"div",
|
|
68
|
+
{
|
|
69
|
+
style: {
|
|
70
|
+
position: "relative"
|
|
71
|
+
},
|
|
72
|
+
children: /* @__PURE__ */ a(
|
|
73
|
+
O.Provider,
|
|
74
|
+
{
|
|
75
|
+
value: {
|
|
76
|
+
position: h,
|
|
77
|
+
richColors: l,
|
|
78
|
+
isDark: c,
|
|
79
|
+
gap: s,
|
|
80
|
+
edgeOffset: n,
|
|
81
|
+
animateTransformOrigin: g,
|
|
82
|
+
pauseOnHover: b,
|
|
83
|
+
swipeToClose: y,
|
|
84
|
+
setToasts: m,
|
|
85
|
+
updateOffsets: u
|
|
86
|
+
},
|
|
87
|
+
children: p.map((e) => /* @__PURE__ */ a(M, { t: e }, e.id))
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
D as default
|
|
97
|
+
};
|