react-toast-master 2.3.0 → 3.0.1
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/LICENSE +0 -0
- package/README.md +89 -25
- package/dist/index.es.js +774 -0
- package/dist/index.umd.js +75 -0
- package/dist/style.css +1 -0
- package/index.d.ts +4 -3
- package/package.json +20 -19
- package/.eslintrc.cjs +0 -20
- package/build/index.js +0 -2
- package/build/index.js.LICENSE.txt +0 -6
- package/index.html +0 -13
- package/jsconfig.json +0 -10
- package/vite.config.js +0 -7
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
import { jsx as o, jsxs as l, Fragment as z } from "react/jsx-runtime";
|
|
2
|
+
import ue, { useContext as U, createContext as Z, forwardRef as Y, createElement as H, useState as _e, useRef as O, useEffect as R, useCallback as x } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* @license lucide-react v1.17.0 - ISC
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the ISC license.
|
|
7
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
const J = (...e) => e.filter((n, s, r) => !!n && n.trim() !== "" && r.indexOf(n) === s).join(" ").trim();
|
|
10
|
+
/**
|
|
11
|
+
* @license lucide-react v1.17.0 - ISC
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the ISC license.
|
|
14
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
const he = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
17
|
+
/**
|
|
18
|
+
* @license lucide-react v1.17.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/
|
|
23
|
+
const fe = (e) => e.replace(
|
|
24
|
+
/^([A-Z])|[\s-_]+(\w)/g,
|
|
25
|
+
(n, s, r) => r ? r.toUpperCase() : s.toLowerCase()
|
|
26
|
+
);
|
|
27
|
+
/**
|
|
28
|
+
* @license lucide-react v1.17.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/
|
|
33
|
+
const K = (e) => {
|
|
34
|
+
const n = fe(e);
|
|
35
|
+
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* @license lucide-react v1.17.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/
|
|
43
|
+
var P = {
|
|
44
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
45
|
+
width: 24,
|
|
46
|
+
height: 24,
|
|
47
|
+
viewBox: "0 0 24 24",
|
|
48
|
+
fill: "none",
|
|
49
|
+
stroke: "currentColor",
|
|
50
|
+
strokeWidth: 2,
|
|
51
|
+
strokeLinecap: "round",
|
|
52
|
+
strokeLinejoin: "round"
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* @license lucide-react v1.17.0 - ISC
|
|
56
|
+
*
|
|
57
|
+
* This source code is licensed under the ISC license.
|
|
58
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
59
|
+
*/
|
|
60
|
+
const me = (e) => {
|
|
61
|
+
for (const n in e)
|
|
62
|
+
if (n.startsWith("aria-") || n === "role" || n === "title")
|
|
63
|
+
return !0;
|
|
64
|
+
return !1;
|
|
65
|
+
}, ge = Z({}), we = () => U(ge), ye = Y(
|
|
66
|
+
({ color: e, size: n, strokeWidth: s, absoluteStrokeWidth: r, className: m = "", children: _, iconNode: y, ...d }, i) => {
|
|
67
|
+
const {
|
|
68
|
+
size: g = 24,
|
|
69
|
+
strokeWidth: h = 2,
|
|
70
|
+
absoluteStrokeWidth: D = !1,
|
|
71
|
+
color: F = "currentColor",
|
|
72
|
+
className: S = ""
|
|
73
|
+
} = we() ?? {}, t = r ?? D ? Number(s ?? h) * 24 / Number(n ?? g) : s ?? h;
|
|
74
|
+
return H(
|
|
75
|
+
"svg",
|
|
76
|
+
{
|
|
77
|
+
ref: i,
|
|
78
|
+
...P,
|
|
79
|
+
width: n ?? g ?? P.width,
|
|
80
|
+
height: n ?? g ?? P.height,
|
|
81
|
+
stroke: e ?? F,
|
|
82
|
+
strokeWidth: t,
|
|
83
|
+
className: J("lucide", S, m),
|
|
84
|
+
...!_ && !me(d) && { "aria-hidden": "true" },
|
|
85
|
+
...d
|
|
86
|
+
},
|
|
87
|
+
[
|
|
88
|
+
...y.map(([a, c]) => H(a, c)),
|
|
89
|
+
...Array.isArray(_) ? _ : [_]
|
|
90
|
+
]
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
/**
|
|
95
|
+
* @license lucide-react v1.17.0 - ISC
|
|
96
|
+
*
|
|
97
|
+
* This source code is licensed under the ISC license.
|
|
98
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
99
|
+
*/
|
|
100
|
+
const B = (e, n) => {
|
|
101
|
+
const s = Y(
|
|
102
|
+
({ className: r, ...m }, _) => H(ye, {
|
|
103
|
+
ref: _,
|
|
104
|
+
iconNode: n,
|
|
105
|
+
className: J(
|
|
106
|
+
`lucide-${he(K(e))}`,
|
|
107
|
+
`lucide-${e}`,
|
|
108
|
+
r
|
|
109
|
+
),
|
|
110
|
+
...m
|
|
111
|
+
})
|
|
112
|
+
);
|
|
113
|
+
return s.displayName = K(e), s;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* @license lucide-react v1.17.0 - ISC
|
|
117
|
+
*
|
|
118
|
+
* This source code is licensed under the ISC license.
|
|
119
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
120
|
+
*/
|
|
121
|
+
const ke = [
|
|
122
|
+
["path", { d: "M18 6 7 17l-5-5", key: "116fxf" }],
|
|
123
|
+
["path", { d: "m22 10-7.5 7.5L13 16", key: "ke71qq" }]
|
|
124
|
+
], pe = B("check-check", ke);
|
|
125
|
+
/**
|
|
126
|
+
* @license lucide-react v1.17.0 - ISC
|
|
127
|
+
*
|
|
128
|
+
* This source code is licensed under the ISC license.
|
|
129
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
130
|
+
*/
|
|
131
|
+
const be = [
|
|
132
|
+
["path", { d: "M10.1 2.182a10 10 0 0 1 3.8 0", key: "5ilxe3" }],
|
|
133
|
+
["path", { d: "M13.9 21.818a10 10 0 0 1-3.8 0", key: "11zvb9" }],
|
|
134
|
+
["path", { d: "M17.609 3.721a10 10 0 0 1 2.69 2.7", key: "1iw5b2" }],
|
|
135
|
+
["path", { d: "M2.182 13.9a10 10 0 0 1 0-3.8", key: "c0bmvh" }],
|
|
136
|
+
["path", { d: "M20.279 17.609a10 10 0 0 1-2.7 2.69", key: "1ruxm7" }],
|
|
137
|
+
["path", { d: "M21.818 10.1a10 10 0 0 1 0 3.8", key: "qkgqxc" }],
|
|
138
|
+
["path", { d: "M3.721 6.391a10 10 0 0 1 2.7-2.69", key: "1mcia2" }],
|
|
139
|
+
["path", { d: "M6.391 20.279a10 10 0 0 1-2.69-2.7", key: "1fvljs" }]
|
|
140
|
+
], xe = B("circle-dashed", be);
|
|
141
|
+
/**
|
|
142
|
+
* @license lucide-react v1.17.0 - ISC
|
|
143
|
+
*
|
|
144
|
+
* This source code is licensed under the ISC license.
|
|
145
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
+
*/
|
|
147
|
+
const Ce = [
|
|
148
|
+
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
149
|
+
["path", { d: "m15 9-6 6", key: "1uzhvr" }],
|
|
150
|
+
["path", { d: "m9 9 6 6", key: "z0biqf" }]
|
|
151
|
+
], ve = B("circle-x", Ce);
|
|
152
|
+
/**
|
|
153
|
+
* @license lucide-react v1.17.0 - ISC
|
|
154
|
+
*
|
|
155
|
+
* This source code is licensed under the ISC license.
|
|
156
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
+
*/
|
|
158
|
+
const $e = [
|
|
159
|
+
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
160
|
+
["path", { d: "M12 16v-4", key: "1dtifu" }],
|
|
161
|
+
["path", { d: "M12 8h.01", key: "e9boi3" }]
|
|
162
|
+
], Te = B("info", $e);
|
|
163
|
+
/**
|
|
164
|
+
* @license lucide-react v1.17.0 - ISC
|
|
165
|
+
*
|
|
166
|
+
* This source code is licensed under the ISC license.
|
|
167
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
168
|
+
*/
|
|
169
|
+
const Ne = [
|
|
170
|
+
["path", { d: "M12 17v5", key: "bb1du9" }],
|
|
171
|
+
[
|
|
172
|
+
"path",
|
|
173
|
+
{
|
|
174
|
+
d: "M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",
|
|
175
|
+
key: "1nkz8b"
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
], Me = B("pin", Ne);
|
|
179
|
+
/**
|
|
180
|
+
* @license lucide-react v1.17.0 - ISC
|
|
181
|
+
*
|
|
182
|
+
* This source code is licensed under the ISC license.
|
|
183
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
184
|
+
*/
|
|
185
|
+
const De = [
|
|
186
|
+
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
187
|
+
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
188
|
+
], V = B("x", De), f = {
|
|
189
|
+
// Text color classes for different toast types
|
|
190
|
+
textClasses: {
|
|
191
|
+
success: "text_success",
|
|
192
|
+
error: "text_error",
|
|
193
|
+
loading: "text_warning",
|
|
194
|
+
warning: "text_warning",
|
|
195
|
+
warningStay: "text_warning",
|
|
196
|
+
info: "text_info",
|
|
197
|
+
infoStay: "text_info",
|
|
198
|
+
confirm: "text_white",
|
|
199
|
+
basic: "text_white",
|
|
200
|
+
successWhite: "text_white",
|
|
201
|
+
errorWhite: "text_white",
|
|
202
|
+
loadingWhite: "text_white",
|
|
203
|
+
warningWhite: "text_white",
|
|
204
|
+
warningStayWhite: "text_white",
|
|
205
|
+
infoWhite: "text_white",
|
|
206
|
+
infoStayWhite: "text_white",
|
|
207
|
+
successDark: "text_dark",
|
|
208
|
+
errorDark: "text_dark",
|
|
209
|
+
loadingDark: "text_dark",
|
|
210
|
+
warningDark: "text_dark",
|
|
211
|
+
warningStayDark: "text_dark",
|
|
212
|
+
infoDark: "text_dark",
|
|
213
|
+
infoStayDark: "text_dark",
|
|
214
|
+
confirmDark: "text_dark",
|
|
215
|
+
basicDark: "text_dark"
|
|
216
|
+
},
|
|
217
|
+
// Background classes
|
|
218
|
+
backgroundClasses: {
|
|
219
|
+
success: "bg_success",
|
|
220
|
+
error: "bg_error",
|
|
221
|
+
warning: "bg_warning",
|
|
222
|
+
info: "bg_info",
|
|
223
|
+
glass: "bg_glass",
|
|
224
|
+
white: "bg_white",
|
|
225
|
+
dark: "bg_dark",
|
|
226
|
+
gray: "bg_gray",
|
|
227
|
+
transparent: "bg_transparent"
|
|
228
|
+
},
|
|
229
|
+
// Position classes
|
|
230
|
+
positionClasses: {
|
|
231
|
+
top: "top",
|
|
232
|
+
topFull: "topFull",
|
|
233
|
+
topLeft: "topLeft",
|
|
234
|
+
topRight: "topRight",
|
|
235
|
+
bottom: "bottom",
|
|
236
|
+
bottomFull: "bottomFull",
|
|
237
|
+
bottomLeft: "bottomLeft",
|
|
238
|
+
bottomRight: "bottomRight",
|
|
239
|
+
center: "middle"
|
|
240
|
+
},
|
|
241
|
+
// Animation classes
|
|
242
|
+
animationClasses: {
|
|
243
|
+
down: "ani_down",
|
|
244
|
+
top: "ani_top",
|
|
245
|
+
left: "ani_left",
|
|
246
|
+
right: "ani_right",
|
|
247
|
+
fade: "ani_fade",
|
|
248
|
+
zoom: "ani_zoom",
|
|
249
|
+
jelly: "ani_jelly"
|
|
250
|
+
},
|
|
251
|
+
// Alignment classes
|
|
252
|
+
alignmentClasses: {
|
|
253
|
+
left: "text_start",
|
|
254
|
+
right: "text_end",
|
|
255
|
+
center: "text_center"
|
|
256
|
+
},
|
|
257
|
+
// Skew classes
|
|
258
|
+
skewClasses: {
|
|
259
|
+
three: "right3",
|
|
260
|
+
six: "right6",
|
|
261
|
+
twelve: "right12"
|
|
262
|
+
},
|
|
263
|
+
// Shadow classes
|
|
264
|
+
shadowClasses: {
|
|
265
|
+
none: "",
|
|
266
|
+
gray: "box_shadow",
|
|
267
|
+
block: "box_shadow_block",
|
|
268
|
+
error: "shadow_error",
|
|
269
|
+
white: "shadow_white",
|
|
270
|
+
dark: "shadow_dark",
|
|
271
|
+
success: "shadow_success",
|
|
272
|
+
info: "shadow_info",
|
|
273
|
+
warning: "shadow_warning",
|
|
274
|
+
around: "shadow_around"
|
|
275
|
+
},
|
|
276
|
+
// Border radius classes
|
|
277
|
+
radiusClasses: {
|
|
278
|
+
none: "rounded_none",
|
|
279
|
+
sm: "rounded_sm",
|
|
280
|
+
md: "rounded_md",
|
|
281
|
+
lg: "rounded_lg",
|
|
282
|
+
xl: "rounded_xl",
|
|
283
|
+
twoXl: "rounded_2xl",
|
|
284
|
+
full: "rounded_full"
|
|
285
|
+
}
|
|
286
|
+
}, u = {
|
|
287
|
+
// Types that auto-hide
|
|
288
|
+
autoHideTypes: [
|
|
289
|
+
"success",
|
|
290
|
+
"successWhite",
|
|
291
|
+
"successDark",
|
|
292
|
+
"error",
|
|
293
|
+
"errorWhite",
|
|
294
|
+
"errorDark",
|
|
295
|
+
"warning",
|
|
296
|
+
"warningWhite",
|
|
297
|
+
"warningDark",
|
|
298
|
+
"info",
|
|
299
|
+
"infoWhite",
|
|
300
|
+
"infoDark",
|
|
301
|
+
"basic",
|
|
302
|
+
"basicDark"
|
|
303
|
+
],
|
|
304
|
+
stayTypes: [
|
|
305
|
+
"infoStay",
|
|
306
|
+
"infoStayWhite",
|
|
307
|
+
"infoStayDark",
|
|
308
|
+
"warningStay",
|
|
309
|
+
"warningStayWhite",
|
|
310
|
+
"warningStayDark",
|
|
311
|
+
"customStay"
|
|
312
|
+
],
|
|
313
|
+
// Types that show an overlay
|
|
314
|
+
overlayTypes: ["confirm", "confirmDark"],
|
|
315
|
+
// Types that need special loading handling
|
|
316
|
+
loadingTypes: ["loading", "loadingWhite", "loadingDark"],
|
|
317
|
+
// Durations
|
|
318
|
+
durations: {
|
|
319
|
+
standard: 4500,
|
|
320
|
+
afterHover: 1500,
|
|
321
|
+
animationClose: 300,
|
|
322
|
+
loadingFooterDelay: 5330,
|
|
323
|
+
loadingCloseButtonDelay: 5e3
|
|
324
|
+
}
|
|
325
|
+
}, Fe = ({ footer: e, toastAlignment: n, toastBG: s }) => /* @__PURE__ */ o("div", { className: `_footer toast_width ${n} ${Se[s]}`, children: e }), Se = {
|
|
326
|
+
dark: "footer_dark",
|
|
327
|
+
warning: "footer_dark",
|
|
328
|
+
white: "footer_white",
|
|
329
|
+
info: "footer_info",
|
|
330
|
+
error: "footer_error",
|
|
331
|
+
success: "footer_success",
|
|
332
|
+
gray: "footer_success",
|
|
333
|
+
glass: "footer_success",
|
|
334
|
+
transparent: "footer_success"
|
|
335
|
+
}, X = ({ footer: e, toastAlignment: n, toastBG: s }) => /* @__PURE__ */ o("div", { className: `innerFooter ${n} ${Be[s]}`, children: e }), Be = {
|
|
336
|
+
dark: "footer_dark",
|
|
337
|
+
warning: "footer_dark",
|
|
338
|
+
white: "footer_white",
|
|
339
|
+
info: "footer_info",
|
|
340
|
+
error: "footer_error",
|
|
341
|
+
success: "footer_success",
|
|
342
|
+
gray: "footer_success",
|
|
343
|
+
glass: "footer_success",
|
|
344
|
+
transparent: "footer_success"
|
|
345
|
+
}, Le = ({ toastAlignment: e, toastBG: n, loadFooter: s }) => /* @__PURE__ */ o("div", { className: `_footer toast_width reveal_ani ${e} ${Ae[n]}`, children: s }), Ae = {
|
|
346
|
+
dark: "footer_dark",
|
|
347
|
+
warning: "footer_dark",
|
|
348
|
+
white: "footer_white",
|
|
349
|
+
info: "footer_info",
|
|
350
|
+
error: "footer_error",
|
|
351
|
+
success: "footer_success",
|
|
352
|
+
gray: "footer_success",
|
|
353
|
+
glass: "footer_success",
|
|
354
|
+
transparent: "footer_success"
|
|
355
|
+
}, We = ({ toast: e, onHide: n, onConfirm: s, onCancel: r, onMouseEnter: m, onMouseLeave: _, setToasts: y }) => {
|
|
356
|
+
const d = Object.keys(f.positionClasses).find(
|
|
357
|
+
(t) => f.positionClasses[t] === e.position
|
|
358
|
+
), i = Object.keys(f.backgroundClasses).find(
|
|
359
|
+
(t) => f.backgroundClasses[t] === e.background
|
|
360
|
+
), g = d === "bottomFull" || d === "topFull", h = u.overlayTypes.includes(e.type), D = e.type === "basic" || e.type === "basicDark", F = e.type === "custom" || e.type === "customStay", S = (t) => t.includes("success") ? /* @__PURE__ */ o(pe, {}) : t.includes("error") ? /* @__PURE__ */ o(ve, {}) : t.includes("loading") ? /* @__PURE__ */ o(xe, { className: "animate_spin" }) : t.includes("warning") ? /* @__PURE__ */ o(Te, {}) : t.includes("info") ? /* @__PURE__ */ o(Me, { className: "rotate_deg" }) : null;
|
|
361
|
+
return /* @__PURE__ */ l(ue.Fragment, { children: [
|
|
362
|
+
e.showOverlay && /* @__PURE__ */ o("div", { className: `overlay ${e.showOverlay ? "show" : ""}` }),
|
|
363
|
+
/* @__PURE__ */ o(
|
|
364
|
+
"div",
|
|
365
|
+
{
|
|
366
|
+
className: `
|
|
367
|
+
outer_container
|
|
368
|
+
${e.position}
|
|
369
|
+
${e.animation}
|
|
370
|
+
${e.isExiting ? "exiting" : ""}
|
|
371
|
+
`,
|
|
372
|
+
style: { zIndex: 9999 },
|
|
373
|
+
onAnimationEnd: () => {
|
|
374
|
+
e.isExiting && y((t) => t.filter((a) => a.id !== e.id));
|
|
375
|
+
},
|
|
376
|
+
children: F ? /* @__PURE__ */ o(
|
|
377
|
+
"div",
|
|
378
|
+
{
|
|
379
|
+
className: `inner_container ${g ? "toast_width_full" : "max_width"} ${e.radius}`,
|
|
380
|
+
onMouseEnter: () => m(e.id, e.type),
|
|
381
|
+
onMouseLeave: () => _(e.id, e.type),
|
|
382
|
+
children: e.custom
|
|
383
|
+
}
|
|
384
|
+
) : h ? /* @__PURE__ */ o(
|
|
385
|
+
"div",
|
|
386
|
+
{
|
|
387
|
+
className: `inner_container ${g ? "toast_width_full" : "max_width"} ${f.textClasses[e.type]} ${e.background} ${e.skew} ${e.shadow} ${e.radius}`,
|
|
388
|
+
onMouseEnter: () => m(e.id, e.type),
|
|
389
|
+
onMouseLeave: () => _(e.id, e.type),
|
|
390
|
+
children: /* @__PURE__ */ l("div", { className: h ? "toast_width_confirm" : "toast_width", children: [
|
|
391
|
+
/* @__PURE__ */ l("div", { className: `confirm_message ${e.alignment}`, children: [
|
|
392
|
+
!D && /* @__PURE__ */ l("div", { children: [
|
|
393
|
+
/* @__PURE__ */ o("span", { className: "sr_only", children: "toast icon" }),
|
|
394
|
+
/* @__PURE__ */ o("span", { "aria-hidden": "true", children: S(e.type) })
|
|
395
|
+
] }),
|
|
396
|
+
/* @__PURE__ */ o(z, { children: e.message }),
|
|
397
|
+
/* @__PURE__ */ o(
|
|
398
|
+
"div",
|
|
399
|
+
{
|
|
400
|
+
className: `closeDiv ${e.showCloseButton && e.showButton && !h ? "div_flex" : "div_hidden"}`,
|
|
401
|
+
children: /* @__PURE__ */ l(
|
|
402
|
+
"button",
|
|
403
|
+
{
|
|
404
|
+
onClick: () => n(e.id),
|
|
405
|
+
id: `close-${e.id}`,
|
|
406
|
+
className: `closeButton ${i === "white" ? "bg_whiter" : i === "glass" || i === "transparent" ? "bg_glass_close" : "bg_darker"}`,
|
|
407
|
+
children: [
|
|
408
|
+
/* @__PURE__ */ o("span", { className: "sr_only", children: "close toast" }),
|
|
409
|
+
/* @__PURE__ */ o(
|
|
410
|
+
V,
|
|
411
|
+
{
|
|
412
|
+
"aria-hidden": "true",
|
|
413
|
+
size: 18
|
|
414
|
+
}
|
|
415
|
+
)
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
)
|
|
419
|
+
}
|
|
420
|
+
)
|
|
421
|
+
] }),
|
|
422
|
+
e.footer && /* @__PURE__ */ o(
|
|
423
|
+
X,
|
|
424
|
+
{
|
|
425
|
+
footer: e.footer,
|
|
426
|
+
toastBG: i,
|
|
427
|
+
toastAlignment: e.alignment
|
|
428
|
+
}
|
|
429
|
+
),
|
|
430
|
+
/* @__PURE__ */ l(
|
|
431
|
+
"div",
|
|
432
|
+
{
|
|
433
|
+
className: `confirm_div ${e.alignment === "text_start" ? "justify_end" : e.alignment === "text_end" ? "justify_start" : e.alignment === "text_center" ? "justify_center" : null}`,
|
|
434
|
+
children: [
|
|
435
|
+
/* @__PURE__ */ l(
|
|
436
|
+
"button",
|
|
437
|
+
{
|
|
438
|
+
className: `cancel_button ${i === "white" ? "cancel_button_dark" : i === "success" || i === "warning" || i === "error" || i === "info" || i === "dark" ? "cancel_button_all" : "cancel_button_glass"}`,
|
|
439
|
+
onClick: () => r(e.id),
|
|
440
|
+
children: [
|
|
441
|
+
/* @__PURE__ */ o("span", { className: "sr_only", children: "close toast" }),
|
|
442
|
+
"Cancel"
|
|
443
|
+
]
|
|
444
|
+
}
|
|
445
|
+
),
|
|
446
|
+
/* @__PURE__ */ l(
|
|
447
|
+
"button",
|
|
448
|
+
{
|
|
449
|
+
className: `confirm_button ${i === "dark" ? "confirm_button_dark" : "confirm_button_white"}`,
|
|
450
|
+
onClick: () => s(e.id),
|
|
451
|
+
children: [
|
|
452
|
+
/* @__PURE__ */ o("span", { className: "sr_only", children: "confirm action" }),
|
|
453
|
+
"Confirm"
|
|
454
|
+
]
|
|
455
|
+
}
|
|
456
|
+
)
|
|
457
|
+
]
|
|
458
|
+
}
|
|
459
|
+
)
|
|
460
|
+
] })
|
|
461
|
+
}
|
|
462
|
+
) : /* @__PURE__ */ l(
|
|
463
|
+
"div",
|
|
464
|
+
{
|
|
465
|
+
className: `inner_container ${g ? "toast_width_full" : "max_width"} ${f.textClasses[e.type]} ${e.background} ${e.skew} ${e.shadow} ${e.radius}`,
|
|
466
|
+
onMouseEnter: () => m(e.id, e.type),
|
|
467
|
+
onMouseLeave: () => _(e.id, e.type),
|
|
468
|
+
children: [
|
|
469
|
+
/* @__PURE__ */ l("div", { className: h ? "toast_width_confirm" : "toast_width", children: [
|
|
470
|
+
/* @__PURE__ */ l("div", { className: `toast_message ${e.alignment}`, children: [
|
|
471
|
+
!h && !D && /* @__PURE__ */ l("div", { children: [
|
|
472
|
+
/* @__PURE__ */ o("span", { className: "sr_only", children: "toast icon" }),
|
|
473
|
+
/* @__PURE__ */ o("span", { "aria-hidden": "true", children: S(e.type) })
|
|
474
|
+
] }),
|
|
475
|
+
/* @__PURE__ */ o(z, { children: e.message }),
|
|
476
|
+
/* @__PURE__ */ o(
|
|
477
|
+
"div",
|
|
478
|
+
{
|
|
479
|
+
className: `closeDiv ${e.showCloseButton && e.showButton && !h ? "div_flex" : "div_hidden"}`,
|
|
480
|
+
children: /* @__PURE__ */ l(
|
|
481
|
+
"button",
|
|
482
|
+
{
|
|
483
|
+
onClick: () => n(e.id),
|
|
484
|
+
id: `close-${e.id}`,
|
|
485
|
+
className: `closeButton
|
|
486
|
+
${i === "white" ? "bg_whiter" : i === "glass" || i === "transparent" ? "bg_glass_close" : "bg_darker"}`,
|
|
487
|
+
children: [
|
|
488
|
+
/* @__PURE__ */ o("span", { className: "sr_only", children: "close toast" }),
|
|
489
|
+
/* @__PURE__ */ o(
|
|
490
|
+
V,
|
|
491
|
+
{
|
|
492
|
+
"aria-hidden": "true",
|
|
493
|
+
size: 18
|
|
494
|
+
}
|
|
495
|
+
)
|
|
496
|
+
]
|
|
497
|
+
}
|
|
498
|
+
)
|
|
499
|
+
}
|
|
500
|
+
)
|
|
501
|
+
] }),
|
|
502
|
+
h && e.footer && /* @__PURE__ */ o(
|
|
503
|
+
X,
|
|
504
|
+
{
|
|
505
|
+
footer: e.footer,
|
|
506
|
+
toastBG: i,
|
|
507
|
+
toastAlignment: e.alignment
|
|
508
|
+
}
|
|
509
|
+
),
|
|
510
|
+
h && /* @__PURE__ */ l(
|
|
511
|
+
"div",
|
|
512
|
+
{
|
|
513
|
+
className: `confirm_div
|
|
514
|
+
${e.alignment === "text_start" ? "justify_end" : e.alignment === "text_end" ? "justify_start" : e.alignment === "text_center" ? "justify_center" : null}
|
|
515
|
+
`,
|
|
516
|
+
children: [
|
|
517
|
+
/* @__PURE__ */ l(
|
|
518
|
+
"button",
|
|
519
|
+
{
|
|
520
|
+
className: `cancel_button ${i === "white" ? "cancel_button_dark" : i === "success" || i === "warning" || i === "error" || i === "info" || i === "dark" ? "cancel_button_all" : "cancel_button_glass"}`,
|
|
521
|
+
onClick: () => r(e.id),
|
|
522
|
+
children: [
|
|
523
|
+
/* @__PURE__ */ o("span", { className: "sr_only", children: "close toast" }),
|
|
524
|
+
"Cancel"
|
|
525
|
+
]
|
|
526
|
+
}
|
|
527
|
+
),
|
|
528
|
+
/* @__PURE__ */ l(
|
|
529
|
+
"button",
|
|
530
|
+
{
|
|
531
|
+
className: `confirm_button
|
|
532
|
+
${i === "dark" ? "confirm_button_dark" : "confirm_button_white"}`,
|
|
533
|
+
onClick: () => s(e.id),
|
|
534
|
+
children: [
|
|
535
|
+
/* @__PURE__ */ o("span", { className: "sr_only", children: "confirm action" }),
|
|
536
|
+
"Confirm"
|
|
537
|
+
]
|
|
538
|
+
}
|
|
539
|
+
)
|
|
540
|
+
]
|
|
541
|
+
}
|
|
542
|
+
)
|
|
543
|
+
] }),
|
|
544
|
+
/* @__PURE__ */ l(z, { children: [
|
|
545
|
+
!h && !g && e.footer && /* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(
|
|
546
|
+
Fe,
|
|
547
|
+
{
|
|
548
|
+
footer: e.footer,
|
|
549
|
+
toastBG: i,
|
|
550
|
+
toastAlignment: e.alignment
|
|
551
|
+
}
|
|
552
|
+
) }),
|
|
553
|
+
!h && !g && e.showLoadFooter && e.loadFooter && /* @__PURE__ */ o(
|
|
554
|
+
Le,
|
|
555
|
+
{
|
|
556
|
+
toastAlignment: e.alignment,
|
|
557
|
+
toastBG: i,
|
|
558
|
+
loadFooter: e.loadFooter
|
|
559
|
+
}
|
|
560
|
+
)
|
|
561
|
+
] })
|
|
562
|
+
]
|
|
563
|
+
}
|
|
564
|
+
)
|
|
565
|
+
}
|
|
566
|
+
)
|
|
567
|
+
] }, e.id);
|
|
568
|
+
}, G = (e, n) => {
|
|
569
|
+
let r = {
|
|
570
|
+
ani_top: "ani_slide_out_up",
|
|
571
|
+
ani_down: "ani_slide_out_down",
|
|
572
|
+
ani_left: "ani_slide_out_left",
|
|
573
|
+
ani_right: "ani_slide_out_right",
|
|
574
|
+
ani_jelly: "ani_jelly_out",
|
|
575
|
+
ani_zoom: "ani_zoom_out",
|
|
576
|
+
ani_fade: "ani_fade_out"
|
|
577
|
+
}[e] || "ani_fade_out";
|
|
578
|
+
return n && ["bottomFull", "topFull"].includes(n) && (r = "ani_fade_out_full"), r;
|
|
579
|
+
}, Ee = () => {
|
|
580
|
+
const [e, n] = _e([]), s = O(/* @__PURE__ */ new Map()), r = O(/* @__PURE__ */ new Map()), m = O(e);
|
|
581
|
+
R(() => {
|
|
582
|
+
m.current = e;
|
|
583
|
+
}, [e]);
|
|
584
|
+
const _ = x(() => `toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, []), y = x((t) => {
|
|
585
|
+
r.current.has(t) && (clearTimeout(r.current.get(t)), r.current.delete(t));
|
|
586
|
+
}, []), d = x((t) => {
|
|
587
|
+
var C, v;
|
|
588
|
+
const a = t ?? ((v = (C = m.current) == null ? void 0 : C[m.current.length - 1]) == null ? void 0 : v.id);
|
|
589
|
+
if (!a) return;
|
|
590
|
+
n((k) => {
|
|
591
|
+
const T = k.findIndex((A) => A.id === a);
|
|
592
|
+
if (T === -1) return k;
|
|
593
|
+
const L = k[T], E = Object.keys(f.positionClasses).find(
|
|
594
|
+
(A) => f.positionClasses[A] === L.position
|
|
595
|
+
), I = G(L.animation, E), W = [...k];
|
|
596
|
+
return W[T] = { ...L, animation: I, isExiting: !0 }, W;
|
|
597
|
+
});
|
|
598
|
+
const c = setTimeout(() => {
|
|
599
|
+
n((k) => k.filter((T) => T.id !== a)), s.current.delete(a);
|
|
600
|
+
}, u.durations.animationClose);
|
|
601
|
+
r.current.set(a, c);
|
|
602
|
+
}, []), i = x(
|
|
603
|
+
(t) => {
|
|
604
|
+
n((a) => {
|
|
605
|
+
const c = a.findIndex((k) => k.id === t);
|
|
606
|
+
if (c === -1) return a;
|
|
607
|
+
const C = [...a], v = C[c];
|
|
608
|
+
return C[c] = {
|
|
609
|
+
...v,
|
|
610
|
+
animation: G(v.animation, v.position)
|
|
611
|
+
}, C;
|
|
612
|
+
}), y(t), r.current.set(
|
|
613
|
+
t,
|
|
614
|
+
setTimeout(() => {
|
|
615
|
+
s.current.has(t) && (s.current.get(t)(!0), s.current.delete(t)), n((a) => a.filter((c) => c.id !== t));
|
|
616
|
+
}, u.durations.animationClose)
|
|
617
|
+
);
|
|
618
|
+
},
|
|
619
|
+
[y]
|
|
620
|
+
), g = x(
|
|
621
|
+
(t) => {
|
|
622
|
+
s.current.has(t) && (s.current.get(t)(!1), s.current.delete(t)), d(t);
|
|
623
|
+
},
|
|
624
|
+
[d]
|
|
625
|
+
), h = x(
|
|
626
|
+
(t, a) => {
|
|
627
|
+
u.autoHideTypes.includes(a) && y(t);
|
|
628
|
+
},
|
|
629
|
+
[y]
|
|
630
|
+
), D = x(
|
|
631
|
+
(t, a) => {
|
|
632
|
+
u.autoHideTypes.includes(a) && r.current.set(
|
|
633
|
+
t,
|
|
634
|
+
setTimeout(() => d(t), u.durations.afterHover)
|
|
635
|
+
);
|
|
636
|
+
},
|
|
637
|
+
[d]
|
|
638
|
+
), F = x(
|
|
639
|
+
(t, a) => {
|
|
640
|
+
const {
|
|
641
|
+
type: c = "success",
|
|
642
|
+
message: C = "",
|
|
643
|
+
bg: v = "white",
|
|
644
|
+
position: k = "top",
|
|
645
|
+
transition: T = "zoom",
|
|
646
|
+
loadFooter: L = null,
|
|
647
|
+
footer: E = null,
|
|
648
|
+
skew: I = "",
|
|
649
|
+
cancelButton: W = !0,
|
|
650
|
+
shadow: A = "gray",
|
|
651
|
+
radius: ee = "lg",
|
|
652
|
+
align: te = "center",
|
|
653
|
+
timeout: q = u.durations.standard,
|
|
654
|
+
custom: ne = null
|
|
655
|
+
} = t, N = _(), oe = f.backgroundClasses[v] || "", se = f.positionClasses[k] || "", ie = f.animationClasses[T] || "", re = f.skewClasses[I] || "", ae = f.shadowClasses[A] || "", ce = f.radiusClasses[ee] || "", le = f.alignmentClasses[te] || "", j = {
|
|
656
|
+
id: N,
|
|
657
|
+
type: c,
|
|
658
|
+
message: C,
|
|
659
|
+
position: se,
|
|
660
|
+
background: oe,
|
|
661
|
+
animation: ie,
|
|
662
|
+
skew: re,
|
|
663
|
+
shadow: ae,
|
|
664
|
+
radius: ce,
|
|
665
|
+
alignment: le,
|
|
666
|
+
footer: E,
|
|
667
|
+
loadFooter: L,
|
|
668
|
+
showButton: W,
|
|
669
|
+
showCloseButton: !0,
|
|
670
|
+
showLoadFooter: !1,
|
|
671
|
+
showOverlay: u.overlayTypes.includes(c),
|
|
672
|
+
timeout: q,
|
|
673
|
+
custom: ne
|
|
674
|
+
};
|
|
675
|
+
return u.loadingTypes.includes(c) && (j.showCloseButton = !1, j.showLoadFooter = !1), n((p) => {
|
|
676
|
+
const $ = p.filter((w) => !w.isExiting);
|
|
677
|
+
let b = [...p];
|
|
678
|
+
if ($.length >= 3) {
|
|
679
|
+
const w = $[0];
|
|
680
|
+
b = b.map(
|
|
681
|
+
(M) => M.id === w.id ? {
|
|
682
|
+
...M,
|
|
683
|
+
isExiting: !0,
|
|
684
|
+
animation: G(M.animation, M.position)
|
|
685
|
+
} : M
|
|
686
|
+
), setTimeout(() => {
|
|
687
|
+
n(
|
|
688
|
+
(M) => M.filter((de) => de.id !== w.id)
|
|
689
|
+
), r.current.has(w.id) && (clearTimeout(r.current.get(w.id)), r.current.delete(w.id));
|
|
690
|
+
}, u.durations.animationClose);
|
|
691
|
+
}
|
|
692
|
+
return [...b, j];
|
|
693
|
+
}), u.loadingTypes.includes(c) && (setTimeout(() => {
|
|
694
|
+
n((p) => {
|
|
695
|
+
const $ = p.findIndex((w) => w.id === N);
|
|
696
|
+
if ($ === -1) return p;
|
|
697
|
+
const b = [...p];
|
|
698
|
+
return b[$].showCloseButton = !0, b;
|
|
699
|
+
});
|
|
700
|
+
}, u.durations.loadingCloseButtonDelay), setTimeout(() => {
|
|
701
|
+
n((p) => {
|
|
702
|
+
const $ = p.findIndex((w) => w.id === N);
|
|
703
|
+
if ($ === -1) return p;
|
|
704
|
+
const b = [...p];
|
|
705
|
+
return b[$].showLoadFooter = !0, b;
|
|
706
|
+
});
|
|
707
|
+
}, u.durations.loadingFooterDelay)), u.overlayTypes.includes(c) && a && s.current.set(N, a), !u.stayTypes.includes(c) && !u.loadingTypes.includes(c) && !u.overlayTypes.includes(c) && r.current.set(
|
|
708
|
+
N,
|
|
709
|
+
setTimeout(() => d(N), q)
|
|
710
|
+
), N;
|
|
711
|
+
},
|
|
712
|
+
[_, d]
|
|
713
|
+
), S = x(
|
|
714
|
+
(t) => new Promise((a) => F(t, a)),
|
|
715
|
+
[F]
|
|
716
|
+
);
|
|
717
|
+
return R(() => {
|
|
718
|
+
const t = (a) => {
|
|
719
|
+
if (a.key === "Escape" && e.length > 0) {
|
|
720
|
+
const c = e[e.length - 1];
|
|
721
|
+
c && d(c.id);
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
|
|
725
|
+
}, [d, e]), R(() => () => {
|
|
726
|
+
r.current.forEach((t) => clearTimeout(t)), r.current.clear();
|
|
727
|
+
}, []), {
|
|
728
|
+
toasts: e,
|
|
729
|
+
setToasts: n,
|
|
730
|
+
toastMaster: S,
|
|
731
|
+
hideToast: d,
|
|
732
|
+
handleConfirm: i,
|
|
733
|
+
handleCancel: g,
|
|
734
|
+
handleMouseEnter: h,
|
|
735
|
+
handleMouseLeave: D
|
|
736
|
+
};
|
|
737
|
+
}, Q = Z(null), ze = ({ children: e }) => {
|
|
738
|
+
const {
|
|
739
|
+
toasts: n,
|
|
740
|
+
setToasts: s,
|
|
741
|
+
toastMaster: r,
|
|
742
|
+
hideToast: m,
|
|
743
|
+
handleConfirm: _,
|
|
744
|
+
handleCancel: y,
|
|
745
|
+
handleMouseEnter: d,
|
|
746
|
+
handleMouseLeave: i
|
|
747
|
+
} = Ee();
|
|
748
|
+
return /* @__PURE__ */ l(Q.Provider, { value: { toastMaster: r, hideToast: m }, children: [
|
|
749
|
+
e,
|
|
750
|
+
n.map((g) => /* @__PURE__ */ o(
|
|
751
|
+
We,
|
|
752
|
+
{
|
|
753
|
+
toast: g,
|
|
754
|
+
setToasts: s,
|
|
755
|
+
onHide: m,
|
|
756
|
+
onConfirm: _,
|
|
757
|
+
onCancel: y,
|
|
758
|
+
onMouseEnter: d,
|
|
759
|
+
onMouseLeave: i
|
|
760
|
+
},
|
|
761
|
+
g.id
|
|
762
|
+
))
|
|
763
|
+
] });
|
|
764
|
+
}, Oe = () => {
|
|
765
|
+
const e = U(Q);
|
|
766
|
+
if (!e)
|
|
767
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
768
|
+
return e;
|
|
769
|
+
};
|
|
770
|
+
export {
|
|
771
|
+
Q as ToastContext,
|
|
772
|
+
ze as ToastProvider,
|
|
773
|
+
Oe as useToast
|
|
774
|
+
};
|