sander-ui 0.1.19 → 0.1.21
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/ToastProvider-CdoCvWCg.js +190 -0
- package/dist/index.js +39 -37
- package/dist/toast.js +4 -2
- package/dist/types/components/ui/Toast/ToastProvider.d.ts +7 -0
- package/dist/types/components/ui/Toast/index.d.ts +2 -1
- package/dist/types/components/ui/Toast/useToast.d.ts +1 -1
- package/dist/types/components/ui/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/useToast-BX2dQTGH.js +0 -170
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { jsxs as w, jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as C, useEffect as N, useSyncExternalStore as T, useMemo as S, createElement as x, useContext as E, createContext as y } from "react";
|
|
3
|
+
import { c as h } from "./index-p1eeF8LQ.js";
|
|
4
|
+
import { c as D } from "./createLucideIcon-CP-mMPfa.js";
|
|
5
|
+
import { I as b, T as M, C as P, a as R } from "./triangle-alert-CvNSSzY6.js";
|
|
6
|
+
import { X as k } from "./x-B9bYxG31.js";
|
|
7
|
+
const z = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], j = D("loader-circle", z), L = "_container_d8npe_1", O = "_toast_d8npe_79", U = "_dismissing_d8npe_95", $ = "_icon_d8npe_115", B = "_iconSpin_d8npe_119", V = "_spin_d8npe_1", X = "_message_d8npe_123", q = "_dismiss_d8npe_95", F = "_success_d8npe_159", G = "_error_d8npe_165", H = "_warning_d8npe_171", J = "_info_d8npe_177", K = "_loading_d8npe_183", u = {
|
|
8
|
+
container: L,
|
|
9
|
+
"bottom-right": "_bottom-right_d8npe_25",
|
|
10
|
+
"bottom-left": "_bottom-left_d8npe_26",
|
|
11
|
+
"top-right": "_top-right_d8npe_30",
|
|
12
|
+
"top-left": "_top-left_d8npe_31",
|
|
13
|
+
toast: O,
|
|
14
|
+
"slide-in-bottom": "_slide-in-bottom_d8npe_1",
|
|
15
|
+
dismissing: U,
|
|
16
|
+
"slide-out-bottom": "_slide-out-bottom_d8npe_1",
|
|
17
|
+
"slide-in-top": "_slide-in-top_d8npe_1",
|
|
18
|
+
"slide-out-top": "_slide-out-top_d8npe_1",
|
|
19
|
+
icon: $,
|
|
20
|
+
iconSpin: B,
|
|
21
|
+
spin: V,
|
|
22
|
+
message: X,
|
|
23
|
+
dismiss: q,
|
|
24
|
+
default: "_default_d8npe_153",
|
|
25
|
+
success: F,
|
|
26
|
+
error: G,
|
|
27
|
+
warning: H,
|
|
28
|
+
info: J,
|
|
29
|
+
loading: K,
|
|
30
|
+
"slide-in-right": "_slide-in-right_d8npe_1",
|
|
31
|
+
"slide-out-right": "_slide-out-right_d8npe_1",
|
|
32
|
+
"slide-in-left": "_slide-in-left_d8npe_1",
|
|
33
|
+
"slide-out-left": "_slide-out-left_d8npe_1"
|
|
34
|
+
}, Q = {
|
|
35
|
+
default: b,
|
|
36
|
+
success: R,
|
|
37
|
+
error: P,
|
|
38
|
+
warning: M,
|
|
39
|
+
info: b,
|
|
40
|
+
loading: j
|
|
41
|
+
}, W = ({ toast: t, onDismiss: o, onRemove: l }) => {
|
|
42
|
+
const r = t.variant === "error", s = Q[t.variant];
|
|
43
|
+
return /* @__PURE__ */ w(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
role: r ? "alert" : "status",
|
|
47
|
+
"aria-atomic": "true",
|
|
48
|
+
className: h(
|
|
49
|
+
u.toast,
|
|
50
|
+
u[t.variant],
|
|
51
|
+
t.dismissing && u.dismissing
|
|
52
|
+
),
|
|
53
|
+
onAnimationEnd: () => {
|
|
54
|
+
t.dismissing && l(t.id);
|
|
55
|
+
},
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ f(
|
|
58
|
+
s,
|
|
59
|
+
{
|
|
60
|
+
size: 18,
|
|
61
|
+
className: h(
|
|
62
|
+
u.icon,
|
|
63
|
+
t.variant === "loading" && u.iconSpin
|
|
64
|
+
),
|
|
65
|
+
"aria-hidden": "true"
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ f("p", { className: u.message, children: t.message }),
|
|
69
|
+
/* @__PURE__ */ f(
|
|
70
|
+
"button",
|
|
71
|
+
{
|
|
72
|
+
onClick: () => o(t.id),
|
|
73
|
+
"aria-label": "Dismiss notification",
|
|
74
|
+
className: u.dismiss,
|
|
75
|
+
children: /* @__PURE__ */ f(k, { size: 16 })
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}, Y = ({
|
|
82
|
+
toasts: t,
|
|
83
|
+
position: o = "top-right",
|
|
84
|
+
onDismiss: l,
|
|
85
|
+
onRemove: r
|
|
86
|
+
}) => {
|
|
87
|
+
const s = C(null), m = t.length > 0;
|
|
88
|
+
return N(() => {
|
|
89
|
+
const a = s.current;
|
|
90
|
+
a && (m && !a.matches(":popover-open") ? a.showPopover() : !m && a.matches(":popover-open") && a.hidePopover());
|
|
91
|
+
}, [m]), /* @__PURE__ */ f(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
ref: s,
|
|
95
|
+
popover: "manual",
|
|
96
|
+
className: h(u.container, u[o]),
|
|
97
|
+
"aria-live": "polite",
|
|
98
|
+
"aria-relevant": "additions",
|
|
99
|
+
children: t.map((a) => /* @__PURE__ */ f(W, { toast: a, onDismiss: l, onRemove: r }, a.id))
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
let Z = 0;
|
|
104
|
+
const ss = () => `toast-${++Z}-${Date.now()}`, ts = 4e3, es = {
|
|
105
|
+
default: !0,
|
|
106
|
+
success: !0,
|
|
107
|
+
info: !0,
|
|
108
|
+
warning: !0,
|
|
109
|
+
error: !1,
|
|
110
|
+
loading: !1
|
|
111
|
+
};
|
|
112
|
+
function ns(t) {
|
|
113
|
+
let o = [];
|
|
114
|
+
const l = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), s = () => l.forEach((e) => e()), m = (e) => (l.add(e), () => {
|
|
115
|
+
l.delete(e);
|
|
116
|
+
}), a = () => o, g = (e) => {
|
|
117
|
+
const n = r.get(e);
|
|
118
|
+
n && (clearTimeout(n), r.delete(e));
|
|
119
|
+
}, v = (e) => {
|
|
120
|
+
g(e), o = o.map(
|
|
121
|
+
(n) => n.id === e ? { ...n, dismissing: !0 } : n
|
|
122
|
+
), s();
|
|
123
|
+
}, c = (e) => {
|
|
124
|
+
o = o.filter((n) => n.id !== e), s();
|
|
125
|
+
}, i = (e, n, _) => {
|
|
126
|
+
if (!es[n] && _ === void 0) return;
|
|
127
|
+
const A = setTimeout(() => v(e), _ ?? t);
|
|
128
|
+
r.set(e, A);
|
|
129
|
+
};
|
|
130
|
+
return { subscribe: m, getSnapshot: a, addToast: (e, n = {}) => {
|
|
131
|
+
const _ = ss(), p = n.variant ?? "default";
|
|
132
|
+
return o = [...o, { id: _, message: e, variant: p }], s(), i(_, p, n.duration), _;
|
|
133
|
+
}, dismiss: v, remove: c, update: (e, n) => {
|
|
134
|
+
g(e), o = o.map((p) => p.id !== e ? p : {
|
|
135
|
+
...p,
|
|
136
|
+
...n.message !== void 0 && { message: n.message },
|
|
137
|
+
...n.variant !== void 0 && { variant: n.variant },
|
|
138
|
+
dismissing: !1
|
|
139
|
+
}), s();
|
|
140
|
+
const _ = n.variant;
|
|
141
|
+
_ && i(e, _, n.duration);
|
|
142
|
+
} };
|
|
143
|
+
}
|
|
144
|
+
function os(t = {}) {
|
|
145
|
+
const { position: o = "top-right", duration: l = ts } = t, r = C(null);
|
|
146
|
+
r.current || (r.current = ns(l));
|
|
147
|
+
const s = r.current, m = T(s.subscribe, s.getSnapshot), a = s.dismiss, g = S(() => {
|
|
148
|
+
const c = (i, d) => s.addToast(i, d);
|
|
149
|
+
return c.success = (i, d) => s.addToast(i, { ...d, variant: "success" }), c.error = (i, d) => s.addToast(i, { ...d, variant: "error" }), c.warning = (i, d) => s.addToast(i, { ...d, variant: "warning" }), c.info = (i, d) => s.addToast(i, { ...d, variant: "info" }), c.loading = (i, d) => s.addToast(i, { ...d, variant: "loading" }), c.update = s.update, c;
|
|
150
|
+
}, [s]), v = S(() => {
|
|
151
|
+
const c = () => {
|
|
152
|
+
const i = T(
|
|
153
|
+
s.subscribe,
|
|
154
|
+
s.getSnapshot
|
|
155
|
+
);
|
|
156
|
+
return x(Y, {
|
|
157
|
+
toasts: i,
|
|
158
|
+
position: o,
|
|
159
|
+
onDismiss: s.dismiss,
|
|
160
|
+
onRemove: s.remove
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
return c.displayName = "Toasts", c;
|
|
164
|
+
}, [s, o]);
|
|
165
|
+
return { toasts: m, toast: g, dismiss: a, Toasts: v };
|
|
166
|
+
}
|
|
167
|
+
const I = y(null);
|
|
168
|
+
function ms({
|
|
169
|
+
children: t,
|
|
170
|
+
...o
|
|
171
|
+
}) {
|
|
172
|
+
const { toast: l, Toasts: r } = os(o);
|
|
173
|
+
return /* @__PURE__ */ w(I.Provider, { value: l, children: [
|
|
174
|
+
t,
|
|
175
|
+
/* @__PURE__ */ f(r, {})
|
|
176
|
+
] });
|
|
177
|
+
}
|
|
178
|
+
function ps() {
|
|
179
|
+
const t = E(I);
|
|
180
|
+
if (!t)
|
|
181
|
+
throw new Error("useToast must be used within a <ToastProvider>");
|
|
182
|
+
return t;
|
|
183
|
+
}
|
|
184
|
+
export {
|
|
185
|
+
W as T,
|
|
186
|
+
Y as a,
|
|
187
|
+
ms as b,
|
|
188
|
+
os as c,
|
|
189
|
+
ps as u
|
|
190
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as r, a as e } from "./Accordion-_Ot21_IX.js";
|
|
2
2
|
import { A as t } from "./Alert-Cbx2Hx3u.js";
|
|
3
|
-
import { A as m, a as
|
|
3
|
+
import { A as m, a as d } from "./Avatar-7zC49FAM.js";
|
|
4
4
|
import { B as f } from "./Badge-D1SsfPgP.js";
|
|
5
5
|
import { B as T } from "./Breadcrumbs-u6K5JP-p.js";
|
|
6
6
|
import { B as b } from "./Button-CZyNozz2.js";
|
|
@@ -8,7 +8,7 @@ import { C as i, a as C, b as B, c as w } from "./Card-sDTrEkr0.js";
|
|
|
8
8
|
import { C as u } from "./Checkbox-D-5XA5nS.js";
|
|
9
9
|
import { C as A, M as H, a as g, b as I, c as M } from "./ConfirmModal-CVz_ziw_.js";
|
|
10
10
|
import { C as y } from "./Container-ahtH8Cdw.js";
|
|
11
|
-
import { D as
|
|
11
|
+
import { D as v, a as F, b as R, c as h } from "./Drawer-DQlmckRl.js";
|
|
12
12
|
import { D as L, a as j, b as q, c as z, d as E } from "./Dropdown-GLV9Ia6O.js";
|
|
13
13
|
import { H as K } from "./Heading-Ch7JpxBQ.js";
|
|
14
14
|
import { I as O } from "./IconButton-CwyqSRAA.js";
|
|
@@ -16,23 +16,23 @@ import { I as U } from "./Input-DZz1lKfC.js";
|
|
|
16
16
|
import { L as W } from "./LinkButton-DjDpX08N.js";
|
|
17
17
|
import { P as Y } from "./Pagination-C3F8WZwF.js";
|
|
18
18
|
import { P as _ } from "./Progress-DkSwmZPr.js";
|
|
19
|
-
import { R as
|
|
20
|
-
import { S as
|
|
21
|
-
import { S as
|
|
22
|
-
import { S as
|
|
23
|
-
import { S as
|
|
24
|
-
import { T as
|
|
25
|
-
import { T as
|
|
26
|
-
import { T as
|
|
27
|
-
import { T as
|
|
28
|
-
import { T as
|
|
29
|
-
import { T as
|
|
19
|
+
import { R as aa } from "./Radio-0ZIweAXI.js";
|
|
20
|
+
import { S as ra } from "./Select-DDvtRanl.js";
|
|
21
|
+
import { S as sa } from "./Skeleton-8HbsCzY1.js";
|
|
22
|
+
import { S as pa } from "./Spinner-BBsu1HN3.js";
|
|
23
|
+
import { S as da } from "./Switch-D7LlrXzk.js";
|
|
24
|
+
import { T as fa, a as na } from "./Tabs-CEWSRAh7.js";
|
|
25
|
+
import { T as la, a as ba, b as ca, c as ia, d as Ca, e as Ba } from "./Table-BUCUALeG.js";
|
|
26
|
+
import { T as Da } from "./Text-EMaNgj_L.js";
|
|
27
|
+
import { T as Sa } from "./Textarea-Btoxtbz0.js";
|
|
28
|
+
import { T as Ha, a as ga, b as Ia, u as Ma, c as Pa } from "./ToastProvider-CdoCvWCg.js";
|
|
29
|
+
import { T as ka } from "./Tooltip-DENWDJQ8.js";
|
|
30
30
|
export {
|
|
31
31
|
r as Accordion,
|
|
32
32
|
e as AccordionItem,
|
|
33
33
|
t as Alert,
|
|
34
34
|
m as Avatar,
|
|
35
|
-
|
|
35
|
+
d as AvatarGroup,
|
|
36
36
|
f as Badge,
|
|
37
37
|
T as Breadcrumbs,
|
|
38
38
|
b as Button,
|
|
@@ -43,10 +43,10 @@ export {
|
|
|
43
43
|
u as Checkbox,
|
|
44
44
|
A as ConfirmModal,
|
|
45
45
|
y as Container,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
v as Drawer,
|
|
47
|
+
F as DrawerBody,
|
|
48
|
+
R as DrawerFooter,
|
|
49
|
+
h as DrawerHeader,
|
|
50
50
|
L as Dropdown,
|
|
51
51
|
j as DropdownContent,
|
|
52
52
|
q as DropdownItem,
|
|
@@ -62,23 +62,25 @@ export {
|
|
|
62
62
|
M as ModalHeader,
|
|
63
63
|
Y as Pagination,
|
|
64
64
|
_ as Progress,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
65
|
+
aa as RadioGroup,
|
|
66
|
+
ra as Select,
|
|
67
|
+
sa as Skeleton,
|
|
68
|
+
pa as Spinner,
|
|
69
|
+
da as Switch,
|
|
70
|
+
fa as TabPanel,
|
|
71
|
+
la as Table,
|
|
72
|
+
ba as TableBody,
|
|
73
|
+
ca as TableCell,
|
|
74
|
+
ia as TableHead,
|
|
75
|
+
Ca as TableHeader,
|
|
76
|
+
Ba as TableRow,
|
|
77
|
+
na as Tabs,
|
|
78
|
+
Da as Text,
|
|
79
|
+
Sa as Textarea,
|
|
80
|
+
Ha as Toast,
|
|
81
|
+
ga as ToastContainer,
|
|
82
|
+
Ia as ToastProvider,
|
|
83
|
+
ka as Tooltip,
|
|
84
|
+
Ma as useToast,
|
|
85
|
+
Pa as useToastState
|
|
84
86
|
};
|
package/dist/toast.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { T as o, a as t, u as T } from "./
|
|
1
|
+
import { T as o, a as t, b as e, u as T, c as r } from "./ToastProvider-CdoCvWCg.js";
|
|
2
2
|
export {
|
|
3
3
|
o as Toast,
|
|
4
4
|
t as ToastContainer,
|
|
5
|
-
|
|
5
|
+
e as ToastProvider,
|
|
6
|
+
T as useToast,
|
|
7
|
+
r as useToastState
|
|
6
8
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { UseToastOptions } from "./Toast.types";
|
|
3
|
+
import type { ToastFn } from "./useToast";
|
|
4
|
+
export declare function ToastProvider({ children, ...options }: {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
} & UseToastOptions): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function useToast(): ToastFn;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Toast } from "./Toast";
|
|
2
2
|
export { ToastContainer } from "./ToastContainer";
|
|
3
|
-
export {
|
|
3
|
+
export { useToastState } from "./useToast";
|
|
4
|
+
export { ToastProvider, useToast } from "./ToastProvider";
|
|
4
5
|
export type { ToastProps, ToastContainerProps, ToastData, ToastVariant, ToastPosition, UseToastOptions } from "./Toast.types";
|
|
5
6
|
export type { ToastFn, UseToastReturn } from "./useToast";
|
|
@@ -49,7 +49,7 @@ export { Text } from "./Text";
|
|
|
49
49
|
export type { TextProps } from "./Text";
|
|
50
50
|
export { Textarea } from "./Textarea";
|
|
51
51
|
export type { TextareaProps } from "./Textarea";
|
|
52
|
-
export { Toast, ToastContainer, useToast } from "./Toast";
|
|
52
|
+
export { Toast, ToastContainer, useToastState, ToastProvider, useToast } from "./Toast";
|
|
53
53
|
export type { ToastProps, ToastContainerProps, ToastData, ToastVariant, ToastPosition, UseToastOptions } from "./Toast";
|
|
54
54
|
export type { ToastFn, UseToastReturn } from "./Toast";
|
|
55
55
|
export { Tooltip } from "./Tooltip";
|
package/package.json
CHANGED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { useRef as I, useEffect as D, useState as M, useCallback as p, useMemo as b, createElement as y } from "react";
|
|
2
|
-
import { jsxs as k, jsx as u } from "react/jsx-runtime";
|
|
3
|
-
import { c as h } from "./index-p1eeF8LQ.js";
|
|
4
|
-
import { c as E } from "./createLucideIcon-CP-mMPfa.js";
|
|
5
|
-
import { I as w, T as x, C as z, a as R } from "./triangle-alert-CvNSSzY6.js";
|
|
6
|
-
import { X as j } from "./x-B9bYxG31.js";
|
|
7
|
-
const L = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], O = E("loader-circle", L), P = "_container_d8npe_1", U = "_toast_d8npe_79", $ = "_dismissing_d8npe_95", B = "_icon_d8npe_115", V = "_iconSpin_d8npe_119", X = "_spin_d8npe_1", q = "_message_d8npe_123", F = "_dismiss_d8npe_95", G = "_success_d8npe_159", H = "_error_d8npe_165", J = "_warning_d8npe_171", K = "_info_d8npe_177", Q = "_loading_d8npe_183", r = {
|
|
8
|
-
container: P,
|
|
9
|
-
"bottom-right": "_bottom-right_d8npe_25",
|
|
10
|
-
"bottom-left": "_bottom-left_d8npe_26",
|
|
11
|
-
"top-right": "_top-right_d8npe_30",
|
|
12
|
-
"top-left": "_top-left_d8npe_31",
|
|
13
|
-
toast: U,
|
|
14
|
-
"slide-in-bottom": "_slide-in-bottom_d8npe_1",
|
|
15
|
-
dismissing: $,
|
|
16
|
-
"slide-out-bottom": "_slide-out-bottom_d8npe_1",
|
|
17
|
-
"slide-in-top": "_slide-in-top_d8npe_1",
|
|
18
|
-
"slide-out-top": "_slide-out-top_d8npe_1",
|
|
19
|
-
icon: B,
|
|
20
|
-
iconSpin: V,
|
|
21
|
-
spin: X,
|
|
22
|
-
message: q,
|
|
23
|
-
dismiss: F,
|
|
24
|
-
default: "_default_d8npe_153",
|
|
25
|
-
success: G,
|
|
26
|
-
error: H,
|
|
27
|
-
warning: J,
|
|
28
|
-
info: K,
|
|
29
|
-
loading: Q,
|
|
30
|
-
"slide-in-right": "_slide-in-right_d8npe_1",
|
|
31
|
-
"slide-out-right": "_slide-out-right_d8npe_1",
|
|
32
|
-
"slide-in-left": "_slide-in-left_d8npe_1",
|
|
33
|
-
"slide-out-left": "_slide-out-left_d8npe_1"
|
|
34
|
-
}, W = {
|
|
35
|
-
default: w,
|
|
36
|
-
success: R,
|
|
37
|
-
error: z,
|
|
38
|
-
warning: x,
|
|
39
|
-
info: w,
|
|
40
|
-
loading: O
|
|
41
|
-
}, Y = ({ toast: i, onDismiss: l, onRemove: _ }) => {
|
|
42
|
-
const a = i.variant === "error", o = W[i.variant];
|
|
43
|
-
return /* @__PURE__ */ k(
|
|
44
|
-
"div",
|
|
45
|
-
{
|
|
46
|
-
role: a ? "alert" : "status",
|
|
47
|
-
"aria-atomic": "true",
|
|
48
|
-
className: h(
|
|
49
|
-
r.toast,
|
|
50
|
-
r[i.variant],
|
|
51
|
-
i.dismissing && r.dismissing
|
|
52
|
-
),
|
|
53
|
-
onAnimationEnd: () => {
|
|
54
|
-
i.dismissing && _(i.id);
|
|
55
|
-
},
|
|
56
|
-
children: [
|
|
57
|
-
/* @__PURE__ */ u(
|
|
58
|
-
o,
|
|
59
|
-
{
|
|
60
|
-
size: 18,
|
|
61
|
-
className: h(
|
|
62
|
-
r.icon,
|
|
63
|
-
i.variant === "loading" && r.iconSpin
|
|
64
|
-
),
|
|
65
|
-
"aria-hidden": "true"
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
/* @__PURE__ */ u("p", { className: r.message, children: i.message }),
|
|
69
|
-
/* @__PURE__ */ u(
|
|
70
|
-
"button",
|
|
71
|
-
{
|
|
72
|
-
onClick: () => l(i.id),
|
|
73
|
-
"aria-label": "Dismiss notification",
|
|
74
|
-
className: r.dismiss,
|
|
75
|
-
children: /* @__PURE__ */ u(j, { size: 16 })
|
|
76
|
-
}
|
|
77
|
-
)
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
|
-
}, Z = ({
|
|
82
|
-
toasts: i,
|
|
83
|
-
position: l = "top-right",
|
|
84
|
-
onDismiss: _,
|
|
85
|
-
onRemove: a
|
|
86
|
-
}) => {
|
|
87
|
-
const o = I(null), c = i.length > 0;
|
|
88
|
-
return D(() => {
|
|
89
|
-
const t = o.current;
|
|
90
|
-
t && (c && !t.matches(":popover-open") ? t.showPopover() : !c && t.matches(":popover-open") && t.hidePopover());
|
|
91
|
-
}, [c]), /* @__PURE__ */ u(
|
|
92
|
-
"div",
|
|
93
|
-
{
|
|
94
|
-
ref: o,
|
|
95
|
-
popover: "manual",
|
|
96
|
-
className: h(r.container, r[l]),
|
|
97
|
-
"aria-live": "polite",
|
|
98
|
-
"aria-relevant": "additions",
|
|
99
|
-
children: i.map((t) => /* @__PURE__ */ u(Y, { toast: t, onDismiss: _, onRemove: a }, t.id))
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
};
|
|
103
|
-
let nn = 0;
|
|
104
|
-
const en = () => `toast-${++nn}-${Date.now()}`, sn = 4e3, tn = {
|
|
105
|
-
default: !0,
|
|
106
|
-
success: !0,
|
|
107
|
-
info: !0,
|
|
108
|
-
warning: !0,
|
|
109
|
-
error: !1,
|
|
110
|
-
loading: !1
|
|
111
|
-
};
|
|
112
|
-
function _n(i = {}) {
|
|
113
|
-
const { position: l = "top-right", duration: _ = sn } = i, [a, o] = M([]), c = I(/* @__PURE__ */ new Map()), t = p((e) => {
|
|
114
|
-
const n = c.current.get(e);
|
|
115
|
-
n && (clearTimeout(n), c.current.delete(e));
|
|
116
|
-
}, []), f = p(
|
|
117
|
-
(e) => {
|
|
118
|
-
t(e), o(
|
|
119
|
-
(n) => n.map((s) => s.id === e ? { ...s, dismissing: !0 } : s)
|
|
120
|
-
);
|
|
121
|
-
},
|
|
122
|
-
[t]
|
|
123
|
-
), T = p((e) => {
|
|
124
|
-
o((n) => n.filter((s) => s.id !== e));
|
|
125
|
-
}, []), v = p(
|
|
126
|
-
(e, n, s) => {
|
|
127
|
-
if (!tn[n] && s === void 0) return;
|
|
128
|
-
const N = setTimeout(() => f(e), s ?? _);
|
|
129
|
-
c.current.set(e, N);
|
|
130
|
-
},
|
|
131
|
-
[_, f]
|
|
132
|
-
), d = p(
|
|
133
|
-
(e, n = {}) => {
|
|
134
|
-
const s = en(), g = n.variant ?? "default";
|
|
135
|
-
return o((m) => [...m, { id: s, message: e, variant: g }]), v(s, g, n.duration), s;
|
|
136
|
-
},
|
|
137
|
-
[v]
|
|
138
|
-
), S = p(
|
|
139
|
-
(e, n) => {
|
|
140
|
-
t(e), o(
|
|
141
|
-
(g) => g.map((m) => m.id !== e ? m : {
|
|
142
|
-
...m,
|
|
143
|
-
...n.message !== void 0 && { message: n.message },
|
|
144
|
-
...n.variant !== void 0 && { variant: n.variant },
|
|
145
|
-
dismissing: !1
|
|
146
|
-
})
|
|
147
|
-
);
|
|
148
|
-
const s = n.variant;
|
|
149
|
-
s && v(e, s, n.duration);
|
|
150
|
-
},
|
|
151
|
-
[t, v]
|
|
152
|
-
), A = b(() => {
|
|
153
|
-
const e = (n, s) => d(n, s);
|
|
154
|
-
return e.success = (n, s) => d(n, { ...s, variant: "success" }), e.error = (n, s) => d(n, { ...s, variant: "error" }), e.warning = (n, s) => d(n, { ...s, variant: "warning" }), e.info = (n, s) => d(n, { ...s, variant: "info" }), e.loading = (n, s) => d(n, { ...s, variant: "loading" }), e.update = S, e;
|
|
155
|
-
}, [d, S]), C = b(() => {
|
|
156
|
-
const e = () => y(Z, {
|
|
157
|
-
toasts: a,
|
|
158
|
-
position: l,
|
|
159
|
-
onDismiss: f,
|
|
160
|
-
onRemove: T
|
|
161
|
-
});
|
|
162
|
-
return e.displayName = "Toasts", e;
|
|
163
|
-
}, [a, l, f, T]);
|
|
164
|
-
return { toasts: a, toast: A, dismiss: f, Toasts: C };
|
|
165
|
-
}
|
|
166
|
-
export {
|
|
167
|
-
Y as T,
|
|
168
|
-
Z as a,
|
|
169
|
-
_n as u
|
|
170
|
-
};
|