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 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' | 'swipeToClose'>;
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/listenar.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 I(d) {
9
- const {
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();
25
- return () => {
26
- e(), r();
27
- };
28
- }, []);
29
- const c = t.useRef(null), f = t.useCallback(() => {
30
- if (!c.current) return;
31
- const e = c.current.querySelectorAll("[data-toast-container]"), r = {
32
- "top-left": 0,
33
- "top-center": 0,
34
- "top-right": 0,
35
- "bottom-left": 0,
36
- "bottom-center": 0,
37
- "bottom-right": 0
38
- };
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;
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(
51
- "div",
52
- {
53
- ref: c,
54
- style: {
55
- position: "fixed",
56
- inset: 0,
57
- zIndex: 2147483647,
58
- pointerEvents: "none",
59
- display: "grid",
60
- padding: i != null ? `${Math.max(Math.min(+i, 200), 0)}px` : 16
61
- },
62
- className: `kitzo-toaster ${p ? "kitzo-toaster-rich-colors" : ""} ${v ? "kitzo-toaster-dark" : ""}`,
63
- children: /* @__PURE__ */ a(
64
- "div",
65
- {
66
- style: {
67
- position: "relative"
68
- },
69
- children: /* @__PURE__ */ a(
70
- O.Provider,
71
- {
72
- value: {
73
- position: h,
74
- richColors: p,
75
- isDark: n,
76
- gap: s,
77
- edgeOffset: i,
78
- animateTransformOrigin: g,
79
- pauseOnHover: b,
80
- swipeToClose: y,
81
- setToasts: l,
82
- updateOffsets: f
83
- },
84
- children: u.map((e) => /* @__PURE__ */ a(M, { t: e }, e.id))
85
- }
86
- )
87
- }
88
- )
89
- }
90
- );
91
- }
92
- export {
93
- I as default
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
+ };