kitzo 2.3.43 → 2.3.44

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,97 +1,97 @@
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
- };
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
+ };