kitzo 2.3.38 → 2.3.40
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
CHANGED
|
@@ -33,7 +33,7 @@ export declare const toast: ToastFn;
|
|
|
33
33
|
|
|
34
34
|
declare type ToastContent = ((dismiss: () => void) => ReactNode) | ReactNode;
|
|
35
35
|
|
|
36
|
-
export declare function Toaster(props: ToasterProps): JSX.Element;
|
|
36
|
+
export declare function Toaster(props: ToasterProps): JSX.Element | null;
|
|
37
37
|
|
|
38
38
|
declare type ToasterProps = {
|
|
39
39
|
position?: Positions;
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import t from "react";
|
|
3
3
|
import { subscribe as E } from "./helpers/listenar.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { ToasterContext as
|
|
7
|
-
import { initSwipeToClose as
|
|
8
|
-
function
|
|
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 I(d) {
|
|
9
9
|
const {
|
|
10
|
-
position:
|
|
11
|
-
richColors:
|
|
12
|
-
animateTransformOrigin:
|
|
13
|
-
gap:
|
|
14
|
-
edgeOffset:
|
|
15
|
-
isDark:
|
|
16
|
-
pauseOnHover:
|
|
17
|
-
swipeToClose:
|
|
18
|
-
} =
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
position: h = "top-center",
|
|
11
|
+
richColors: p = !1,
|
|
12
|
+
animateTransformOrigin: g = !0,
|
|
13
|
+
gap: s = 8,
|
|
14
|
+
edgeOffset: i = 16,
|
|
15
|
+
isDark: n,
|
|
16
|
+
pauseOnHover: b = !0,
|
|
17
|
+
swipeToClose: y = !0
|
|
18
|
+
} = d, [k, T] = t.useState(!1);
|
|
19
|
+
t.useEffect(() => {
|
|
20
|
+
T(!0);
|
|
21
|
+
}, []);
|
|
22
|
+
const [u, l] = t.useState([]);
|
|
23
|
+
t.useEffect(() => {
|
|
24
|
+
const e = E((o) => w({ toast: o, setToasts: l })), r = S();
|
|
21
25
|
return () => {
|
|
22
|
-
|
|
26
|
+
e(), r();
|
|
23
27
|
};
|
|
24
28
|
}, []);
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
27
|
-
const
|
|
29
|
+
const c = t.useRef(null), f = t.useCallback(() => {
|
|
30
|
+
if (!c.current) return;
|
|
31
|
+
const e = c.current.querySelectorAll("[data-toast-container]"), r = {
|
|
28
32
|
"top-left": 0,
|
|
29
33
|
"top-center": 0,
|
|
30
34
|
"top-right": 0,
|
|
@@ -32,50 +36,52 @@ function D(m) {
|
|
|
32
36
|
"bottom-center": 0,
|
|
33
37
|
"bottom-right": 0
|
|
34
38
|
};
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
39
|
+
e.forEach((o) => {
|
|
40
|
+
const m = o.getAttribute("data-toast-position") || "top-center", x = parseFloat(o.style.getPropertyValue("--toast-height")) || 0;
|
|
41
|
+
o.style.setProperty("--toast-offset-y", `${r[m]}px`);
|
|
42
|
+
const C = isNaN(+s) ? 8 : +s;
|
|
43
|
+
r[m] += x + C;
|
|
40
44
|
});
|
|
41
|
-
}, [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}, [
|
|
45
|
+
}, [s]);
|
|
46
|
+
if (t.useLayoutEffect(() => {
|
|
47
|
+
f();
|
|
48
|
+
}, [u, f]), !k) return null;
|
|
49
|
+
const v = typeof n == "boolean" ? n : window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
50
|
+
return /* @__PURE__ */ a(
|
|
45
51
|
"div",
|
|
46
52
|
{
|
|
47
|
-
ref:
|
|
53
|
+
ref: c,
|
|
48
54
|
style: {
|
|
49
55
|
position: "fixed",
|
|
50
56
|
inset: 0,
|
|
51
57
|
zIndex: 2147483647,
|
|
52
58
|
pointerEvents: "none",
|
|
53
59
|
display: "grid",
|
|
54
|
-
padding:
|
|
60
|
+
padding: i != null ? `${Math.max(Math.min(+i, 200), 0)}px` : 16
|
|
55
61
|
},
|
|
56
|
-
className: `kitzo-toaster ${
|
|
57
|
-
children: /* @__PURE__ */
|
|
62
|
+
className: `kitzo-toaster ${p ? "kitzo-toaster-rich-colors" : ""} ${v ? "kitzo-toaster-dark" : ""}`,
|
|
63
|
+
children: /* @__PURE__ */ a(
|
|
58
64
|
"div",
|
|
59
65
|
{
|
|
60
66
|
style: {
|
|
61
67
|
position: "relative"
|
|
62
68
|
},
|
|
63
|
-
children: /* @__PURE__ */
|
|
64
|
-
|
|
69
|
+
children: /* @__PURE__ */ a(
|
|
70
|
+
O.Provider,
|
|
65
71
|
{
|
|
66
72
|
value: {
|
|
67
|
-
position:
|
|
68
|
-
richColors:
|
|
69
|
-
isDark:
|
|
70
|
-
gap:
|
|
71
|
-
edgeOffset:
|
|
72
|
-
animateTransformOrigin:
|
|
73
|
-
pauseOnHover:
|
|
74
|
-
swipeToClose:
|
|
73
|
+
position: h,
|
|
74
|
+
richColors: p,
|
|
75
|
+
isDark: n,
|
|
76
|
+
gap: s,
|
|
77
|
+
edgeOffset: i,
|
|
78
|
+
animateTransformOrigin: g,
|
|
79
|
+
pauseOnHover: b,
|
|
80
|
+
swipeToClose: y,
|
|
75
81
|
setToasts: l,
|
|
76
|
-
updateOffsets:
|
|
82
|
+
updateOffsets: f
|
|
77
83
|
},
|
|
78
|
-
children:
|
|
84
|
+
children: u.map((e) => /* @__PURE__ */ a(M, { t: e }, e.id))
|
|
79
85
|
}
|
|
80
86
|
)
|
|
81
87
|
}
|
|
@@ -84,5 +90,5 @@ function D(m) {
|
|
|
84
90
|
);
|
|
85
91
|
}
|
|
86
92
|
export {
|
|
87
|
-
|
|
93
|
+
I as default
|
|
88
94
|
};
|
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
import { jsx as i, Fragment as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import { jsx as i, Fragment as d, jsxs as T } from "react/jsx-runtime";
|
|
2
|
+
import c from "react";
|
|
3
|
+
import v from "./helpers/addTooltipStyles.js";
|
|
4
|
+
import w from "./helpers/getPositionClass.js";
|
|
5
|
+
import O from "./partials/TooltipWrapper.js";
|
|
6
|
+
import k from "./helpers/getAnimationProperties.js";
|
|
7
|
+
function C(h) {
|
|
7
8
|
const {
|
|
8
9
|
content: r,
|
|
9
10
|
children: t,
|
|
10
|
-
position:
|
|
11
|
+
position: y = "top",
|
|
11
12
|
animation: a = !0,
|
|
12
13
|
isHidden: n = !1,
|
|
13
14
|
offset: s = 8,
|
|
14
|
-
smartHover:
|
|
15
|
-
hideOnTouch:
|
|
16
|
-
isDark:
|
|
17
|
-
} = c;
|
|
18
|
-
if (
|
|
15
|
+
smartHover: f = !0,
|
|
16
|
+
hideOnTouch: m = !0,
|
|
17
|
+
isDark: l
|
|
18
|
+
} = h, [D, b] = c.useState(!1);
|
|
19
|
+
if (c.useEffect(() => {
|
|
20
|
+
b(!0), v();
|
|
21
|
+
}, []), !D) return null;
|
|
22
|
+
if (typeof n == "boolean" && n) return /* @__PURE__ */ i(d, { children: t });
|
|
19
23
|
if (r == null)
|
|
20
|
-
return /* @__PURE__ */ i(
|
|
24
|
+
return /* @__PURE__ */ i(d, { children: t });
|
|
21
25
|
const o = {
|
|
22
26
|
offset: isNaN(Number(s)) ? 8 : Number(s),
|
|
23
|
-
smartHover: typeof
|
|
24
|
-
hideOnTouch: typeof
|
|
27
|
+
smartHover: typeof f == "boolean" ? f : !0,
|
|
28
|
+
hideOnTouch: typeof m == "boolean" ? m : !0
|
|
25
29
|
};
|
|
26
|
-
let
|
|
27
|
-
if (typeof window < "u" && (
|
|
28
|
-
const
|
|
30
|
+
let u = !1, p = !1;
|
|
31
|
+
if (typeof window < "u" && (p = window.matchMedia("(pointer: coarse)").matches || navigator.maxTouchPoints > 0, u = typeof l == "boolean" ? l : window.matchMedia("(prefers-color-scheme: dark)").matches), p && o.hideOnTouch) return t;
|
|
32
|
+
const x = w(y), M = !!a, e = k(
|
|
29
33
|
a === !0 ? {} : a
|
|
30
34
|
);
|
|
31
|
-
return
|
|
35
|
+
return /* @__PURE__ */ T(
|
|
32
36
|
"div",
|
|
33
37
|
{
|
|
34
38
|
style: {
|
|
@@ -43,14 +47,14 @@ function H(c) {
|
|
|
43
47
|
"--startDelay": Math.max(0, e.startDelay),
|
|
44
48
|
"--endDelay": Math.max(0, e.endDelay)
|
|
45
49
|
},
|
|
46
|
-
className: `kitzo-tooltip-root ${
|
|
50
|
+
className: `kitzo-tooltip-root ${u ? "tooltip-theme-dark" : ""} ${o.smartHover ? "smart-hover" : ""} ${M ? "animate-tooltip" : ""}`,
|
|
47
51
|
children: [
|
|
48
52
|
t,
|
|
49
53
|
/* @__PURE__ */ i(
|
|
50
|
-
|
|
54
|
+
O,
|
|
51
55
|
{
|
|
52
56
|
content: r,
|
|
53
|
-
positionClass:
|
|
57
|
+
positionClass: x,
|
|
54
58
|
finalOptions: o
|
|
55
59
|
}
|
|
56
60
|
)
|
|
@@ -59,5 +63,5 @@ function H(c) {
|
|
|
59
63
|
);
|
|
60
64
|
}
|
|
61
65
|
export {
|
|
62
|
-
|
|
66
|
+
C as default
|
|
63
67
|
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
const [
|
|
4
|
-
screenWidth:
|
|
5
|
-
screenHeight:
|
|
6
|
-
}), e =
|
|
7
|
-
return
|
|
8
|
-
function
|
|
1
|
+
import t from "react";
|
|
2
|
+
function o(i = 30) {
|
|
3
|
+
const [r, c] = t.useState({
|
|
4
|
+
screenWidth: 0,
|
|
5
|
+
screenHeight: 0
|
|
6
|
+
}), e = t.useRef(null);
|
|
7
|
+
return t.useEffect(() => {
|
|
8
|
+
function n() {
|
|
9
9
|
e.current && clearTimeout(e.current), e.current = setTimeout(
|
|
10
10
|
() => {
|
|
11
|
-
|
|
11
|
+
c({
|
|
12
12
|
screenWidth: window.innerWidth,
|
|
13
13
|
screenHeight: window.innerHeight
|
|
14
14
|
});
|
|
15
15
|
},
|
|
16
|
-
Math.max(0, +
|
|
16
|
+
Math.max(0, +i)
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
|
-
return typeof window < "u" && window.addEventListener("resize",
|
|
20
|
-
e.current && clearTimeout(e.current), window.removeEventListener("resize",
|
|
19
|
+
return typeof window < "u" && (n(), window.addEventListener("resize", n)), () => {
|
|
20
|
+
e.current && clearTimeout(e.current), window.removeEventListener("resize", n);
|
|
21
21
|
};
|
|
22
|
-
}, [
|
|
22
|
+
}, [i]), r;
|
|
23
23
|
}
|
|
24
24
|
export {
|
|
25
|
-
|
|
25
|
+
o as default
|
|
26
26
|
};
|