sander-ui 0.1.19 → 0.1.20
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.js +1 -1
- package/dist/toast.js +1 -1
- package/dist/useToast-BQudQhlt.js +171 -0
- package/package.json +1 -1
- package/dist/useToast-BX2dQTGH.js +0 -170
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ import { T as no, a as To } from "./Tabs-CEWSRAh7.js";
|
|
|
25
25
|
import { T as bo, a as co, b as io, c as Co, d as Bo, e as wo } from "./Table-BUCUALeG.js";
|
|
26
26
|
import { T as uo } from "./Text-EMaNgj_L.js";
|
|
27
27
|
import { T as Ao } from "./Textarea-Btoxtbz0.js";
|
|
28
|
-
import { T as go, a as Io, u as Mo } from "./useToast-
|
|
28
|
+
import { T as go, a as Io, u as Mo } from "./useToast-BQudQhlt.js";
|
|
29
29
|
import { T as yo } from "./Tooltip-DENWDJQ8.js";
|
|
30
30
|
export {
|
|
31
31
|
r as Accordion,
|
package/dist/toast.js
CHANGED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { useRef as w, useEffect as A, useSyncExternalStore as T, useMemo as S, createElement as N } from "react";
|
|
2
|
+
import { jsxs as C, jsx as f } from "react/jsx-runtime";
|
|
3
|
+
import { c as h } from "./index-p1eeF8LQ.js";
|
|
4
|
+
import { c as y } from "./createLucideIcon-CP-mMPfa.js";
|
|
5
|
+
import { I as b, T as D, C as E, a as M } from "./triangle-alert-CvNSSzY6.js";
|
|
6
|
+
import { X as x } from "./x-B9bYxG31.js";
|
|
7
|
+
const R = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], k = y("loader-circle", R), z = "_container_d8npe_1", j = "_toast_d8npe_79", L = "_dismissing_d8npe_95", O = "_icon_d8npe_115", P = "_iconSpin_d8npe_119", U = "_spin_d8npe_1", $ = "_message_d8npe_123", B = "_dismiss_d8npe_95", V = "_success_d8npe_159", X = "_error_d8npe_165", q = "_warning_d8npe_171", F = "_info_d8npe_177", G = "_loading_d8npe_183", m = {
|
|
8
|
+
container: z,
|
|
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: j,
|
|
14
|
+
"slide-in-bottom": "_slide-in-bottom_d8npe_1",
|
|
15
|
+
dismissing: L,
|
|
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: O,
|
|
20
|
+
iconSpin: P,
|
|
21
|
+
spin: U,
|
|
22
|
+
message: $,
|
|
23
|
+
dismiss: B,
|
|
24
|
+
default: "_default_d8npe_153",
|
|
25
|
+
success: V,
|
|
26
|
+
error: X,
|
|
27
|
+
warning: q,
|
|
28
|
+
info: F,
|
|
29
|
+
loading: G,
|
|
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
|
+
}, H = {
|
|
35
|
+
default: b,
|
|
36
|
+
success: M,
|
|
37
|
+
error: E,
|
|
38
|
+
warning: D,
|
|
39
|
+
info: b,
|
|
40
|
+
loading: k
|
|
41
|
+
}, J = ({ toast: n, onDismiss: o, onRemove: l }) => {
|
|
42
|
+
const d = n.variant === "error", s = H[n.variant];
|
|
43
|
+
return /* @__PURE__ */ C(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
role: d ? "alert" : "status",
|
|
47
|
+
"aria-atomic": "true",
|
|
48
|
+
className: h(
|
|
49
|
+
m.toast,
|
|
50
|
+
m[n.variant],
|
|
51
|
+
n.dismissing && m.dismissing
|
|
52
|
+
),
|
|
53
|
+
onAnimationEnd: () => {
|
|
54
|
+
n.dismissing && l(n.id);
|
|
55
|
+
},
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ f(
|
|
58
|
+
s,
|
|
59
|
+
{
|
|
60
|
+
size: 18,
|
|
61
|
+
className: h(
|
|
62
|
+
m.icon,
|
|
63
|
+
n.variant === "loading" && m.iconSpin
|
|
64
|
+
),
|
|
65
|
+
"aria-hidden": "true"
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ f("p", { className: m.message, children: n.message }),
|
|
69
|
+
/* @__PURE__ */ f(
|
|
70
|
+
"button",
|
|
71
|
+
{
|
|
72
|
+
onClick: () => o(n.id),
|
|
73
|
+
"aria-label": "Dismiss notification",
|
|
74
|
+
className: m.dismiss,
|
|
75
|
+
children: /* @__PURE__ */ f(x, { size: 16 })
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}, K = ({
|
|
82
|
+
toasts: n,
|
|
83
|
+
position: o = "top-right",
|
|
84
|
+
onDismiss: l,
|
|
85
|
+
onRemove: d
|
|
86
|
+
}) => {
|
|
87
|
+
const s = w(null), u = n.length > 0;
|
|
88
|
+
return A(() => {
|
|
89
|
+
const r = s.current;
|
|
90
|
+
r && (u && !r.matches(":popover-open") ? r.showPopover() : !u && r.matches(":popover-open") && r.hidePopover());
|
|
91
|
+
}, [u]), /* @__PURE__ */ f(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
ref: s,
|
|
95
|
+
popover: "manual",
|
|
96
|
+
className: h(m.container, m[o]),
|
|
97
|
+
"aria-live": "polite",
|
|
98
|
+
"aria-relevant": "additions",
|
|
99
|
+
children: n.map((r) => /* @__PURE__ */ f(J, { toast: r, onDismiss: l, onRemove: d }, r.id))
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
let Q = 0;
|
|
104
|
+
const W = () => `toast-${++Q}-${Date.now()}`, Y = 4e3, Z = {
|
|
105
|
+
default: !0,
|
|
106
|
+
success: !0,
|
|
107
|
+
info: !0,
|
|
108
|
+
warning: !0,
|
|
109
|
+
error: !1,
|
|
110
|
+
loading: !1
|
|
111
|
+
};
|
|
112
|
+
function ss(n) {
|
|
113
|
+
let o = [];
|
|
114
|
+
const l = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Map(), s = () => l.forEach((e) => e()), u = (e) => (l.add(e), () => {
|
|
115
|
+
l.delete(e);
|
|
116
|
+
}), r = () => o, g = (e) => {
|
|
117
|
+
const t = d.get(e);
|
|
118
|
+
t && (clearTimeout(t), d.delete(e));
|
|
119
|
+
}, v = (e) => {
|
|
120
|
+
g(e), o = o.map(
|
|
121
|
+
(t) => t.id === e ? { ...t, dismissing: !0 } : t
|
|
122
|
+
), s();
|
|
123
|
+
}, a = (e) => {
|
|
124
|
+
o = o.filter((t) => t.id !== e), s();
|
|
125
|
+
}, i = (e, t, _) => {
|
|
126
|
+
if (!Z[t] && _ === void 0) return;
|
|
127
|
+
const I = setTimeout(() => v(e), _ ?? n);
|
|
128
|
+
d.set(e, I);
|
|
129
|
+
};
|
|
130
|
+
return { subscribe: u, getSnapshot: r, addToast: (e, t = {}) => {
|
|
131
|
+
const _ = W(), p = t.variant ?? "default";
|
|
132
|
+
return o = [...o, { id: _, message: e, variant: p }], s(), i(_, p, t.duration), _;
|
|
133
|
+
}, dismiss: v, remove: a, update: (e, t) => {
|
|
134
|
+
g(e), o = o.map((p) => p.id !== e ? p : {
|
|
135
|
+
...p,
|
|
136
|
+
...t.message !== void 0 && { message: t.message },
|
|
137
|
+
...t.variant !== void 0 && { variant: t.variant },
|
|
138
|
+
dismissing: !1
|
|
139
|
+
}), s();
|
|
140
|
+
const _ = t.variant;
|
|
141
|
+
_ && i(e, _, t.duration);
|
|
142
|
+
} };
|
|
143
|
+
}
|
|
144
|
+
function ds(n = {}) {
|
|
145
|
+
const { position: o = "top-right", duration: l = Y } = n, d = w(null);
|
|
146
|
+
d.current || (d.current = ss(l));
|
|
147
|
+
const s = d.current, u = T(s.subscribe, s.getSnapshot), r = s.dismiss, g = S(() => {
|
|
148
|
+
const a = (i, c) => s.addToast(i, c);
|
|
149
|
+
return a.success = (i, c) => s.addToast(i, { ...c, variant: "success" }), a.error = (i, c) => s.addToast(i, { ...c, variant: "error" }), a.warning = (i, c) => s.addToast(i, { ...c, variant: "warning" }), a.info = (i, c) => s.addToast(i, { ...c, variant: "info" }), a.loading = (i, c) => s.addToast(i, { ...c, variant: "loading" }), a.update = s.update, a;
|
|
150
|
+
}, [s]), v = S(() => {
|
|
151
|
+
const a = () => {
|
|
152
|
+
const i = T(
|
|
153
|
+
s.subscribe,
|
|
154
|
+
s.getSnapshot
|
|
155
|
+
);
|
|
156
|
+
return N(K, {
|
|
157
|
+
toasts: i,
|
|
158
|
+
position: o,
|
|
159
|
+
onDismiss: s.dismiss,
|
|
160
|
+
onRemove: s.remove
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
return a.displayName = "Toasts", a;
|
|
164
|
+
}, [s, o]);
|
|
165
|
+
return { toasts: u, toast: g, dismiss: r, Toasts: v };
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
J as T,
|
|
169
|
+
K as a,
|
|
170
|
+
ds as u
|
|
171
|
+
};
|
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
|
-
};
|