vue-smart-toast 0.1.0
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/README.md +137 -0
- package/dist/types/Toaster.vue.d.ts +135 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/mobile/MobileNextArrow.vue.d.ts +3 -0
- package/dist/types/mobile/MobileToast.vue.d.ts +27 -0
- package/dist/types/mobile/MobileToastIcon.vue.d.ts +7 -0
- package/dist/types/mobile/MobileToaster.vue.d.ts +26 -0
- package/dist/types/sonner/Toast.vue.d.ts +32 -0
- package/dist/types/sonner/Toaster.vue.d.ts +48 -0
- package/dist/types/sonner/assets/CloseIcon.vue.d.ts +3 -0
- package/dist/types/sonner/assets/ErrorIcon.vue.d.ts +3 -0
- package/dist/types/sonner/assets/InfoIcon.vue.d.ts +3 -0
- package/dist/types/sonner/assets/Loader.vue.d.ts +6 -0
- package/dist/types/sonner/assets/SuccessIcon.vue.d.ts +3 -0
- package/dist/types/sonner/assets/WarningIcon.vue.d.ts +3 -0
- package/dist/types/sonner/component.d.ts +1 -0
- package/dist/types/sonner/constant.d.ts +9 -0
- package/dist/types/sonner/hooks.d.ts +11 -0
- package/dist/types/sonner/index.d.ts +8 -0
- package/dist/types/sonner/state.d.ts +56 -0
- package/dist/types/sonner/types.d.ts +174 -0
- package/dist/types/store.d.ts +10 -0
- package/dist/types/toaster-registry.d.ts +3 -0
- package/dist/types/types.d.ts +162 -0
- package/dist/types/utils.d.ts +12 -0
- package/dist/vue-smart-toast.css +2 -0
- package/dist/vue-smart-toast.js +1469 -0
- package/dist/vue-smart-toast.umd.cjs +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,1469 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createSlots as o, createTextVNode as s, createVNode as c, defineComponent as l, isVNode as u, mergeProps as d, nextTick as f, normalizeClass as p, normalizeProps as m, normalizeStyle as h, onBeforeUnmount as g, onMounted as _, openBlock as v, ref as y, renderList as b, renderSlot as x, resolveDynamicComponent as S, shallowReactive as C, toDisplayString as w, unref as T, useAttrs as E, watch as ee, watchEffect as D, withCtx as O } from "vue";
|
|
2
|
+
var k = "middle", A = 3e3;
|
|
3
|
+
function j() {
|
|
4
|
+
return typeof window < "u" && typeof document < "u";
|
|
5
|
+
}
|
|
6
|
+
function M() {
|
|
7
|
+
return j() ? window.matchMedia("(max-width: 600px), (hover: none) and (pointer: coarse)").matches : !1;
|
|
8
|
+
}
|
|
9
|
+
function N(e) {
|
|
10
|
+
return e === "pc" || e === "mobile" ? e : M() ? "mobile" : "pc";
|
|
11
|
+
}
|
|
12
|
+
function P(e) {
|
|
13
|
+
return e === "center" || !e ? k : e;
|
|
14
|
+
}
|
|
15
|
+
function F(e) {
|
|
16
|
+
return !e || e === "normal" ? "default" : e === "fail" ? "error" : e;
|
|
17
|
+
}
|
|
18
|
+
function I(e) {
|
|
19
|
+
return e === "loading" ? Infinity : A;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/store.ts
|
|
23
|
+
var L = /* @__PURE__ */ new Map(), te = 0, R = C([]);
|
|
24
|
+
function z() {
|
|
25
|
+
return te += 1, te;
|
|
26
|
+
}
|
|
27
|
+
function B(e) {
|
|
28
|
+
let t = L.get(e);
|
|
29
|
+
t && (clearTimeout(t), L.delete(e));
|
|
30
|
+
}
|
|
31
|
+
function ne(e) {
|
|
32
|
+
B(e.id), !(!Number.isFinite(e.duration) || e.duration <= 0) && L.set(e.id, setTimeout(() => {
|
|
33
|
+
V(e.id, !0);
|
|
34
|
+
}, e.duration));
|
|
35
|
+
}
|
|
36
|
+
function re(e) {
|
|
37
|
+
let t = e.type === "loading" ? "loading" : F(e.type);
|
|
38
|
+
return {
|
|
39
|
+
id: e.id ?? z(),
|
|
40
|
+
type: t,
|
|
41
|
+
message: e.message ?? "",
|
|
42
|
+
description: e.description,
|
|
43
|
+
duration: e.duration ?? I(t),
|
|
44
|
+
device: e.device ?? "auto",
|
|
45
|
+
pcPosition: e.pcPosition ?? e.position ?? "bottom-right",
|
|
46
|
+
mobilePosition: P(e.mobilePosition),
|
|
47
|
+
dismissible: e.dismissible ?? !0,
|
|
48
|
+
action: e.action,
|
|
49
|
+
cancel: e.cancel,
|
|
50
|
+
onClick: e.onClick,
|
|
51
|
+
onDismiss: e.onDismiss,
|
|
52
|
+
onAutoClose: e.onAutoClose,
|
|
53
|
+
icon: e.icon,
|
|
54
|
+
mobileIcon: e.mobileIcon,
|
|
55
|
+
class: e.class,
|
|
56
|
+
style: e.style,
|
|
57
|
+
descriptionClass: e.descriptionClass,
|
|
58
|
+
cancelButtonStyle: e.cancelButtonStyle,
|
|
59
|
+
actionButtonStyle: e.actionButtonStyle,
|
|
60
|
+
unstyled: e.unstyled,
|
|
61
|
+
classes: e.classes,
|
|
62
|
+
closeButtonAriaLabel: e.closeButtonAriaLabel,
|
|
63
|
+
closeButtonPosition: e.closeButtonPosition,
|
|
64
|
+
mobileClass: e.mobileClass,
|
|
65
|
+
mobileStyle: e.mobileStyle,
|
|
66
|
+
mobileClasses: e.mobileClasses,
|
|
67
|
+
important: e.important,
|
|
68
|
+
richColors: e.richColors,
|
|
69
|
+
closeButton: e.closeButton,
|
|
70
|
+
toasterId: e.toasterId,
|
|
71
|
+
createdAt: Date.now(),
|
|
72
|
+
dismissed: !1
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function ie(e) {
|
|
76
|
+
let t = re(e), n = R.findIndex((e) => e.id === t.id);
|
|
77
|
+
return n >= 0 ? (R[n] = {
|
|
78
|
+
...R[n],
|
|
79
|
+
...t,
|
|
80
|
+
createdAt: R[n].createdAt,
|
|
81
|
+
dismissed: !1
|
|
82
|
+
}, ne(R[n]), t.id) : (R.forEach((e) => {
|
|
83
|
+
B(e.id), e.onDismiss?.(e);
|
|
84
|
+
}), R.splice(0, R.length), R.unshift(t), ne(t), t.id);
|
|
85
|
+
}
|
|
86
|
+
function V(e, t = !1) {
|
|
87
|
+
if (e === void 0) {
|
|
88
|
+
R.forEach((e) => V(e.id, t));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
let n = R.find((t) => t.id === e);
|
|
92
|
+
!n || n.dismissed || (B(e), n.dismissed = !0, t ? n.onAutoClose?.(n) : n.onDismiss?.(n), setTimeout(() => {
|
|
93
|
+
let t = R.findIndex((t) => t.id === e);
|
|
94
|
+
t >= 0 && R[t].dismissed && R.splice(t, 1);
|
|
95
|
+
}, 240));
|
|
96
|
+
}
|
|
97
|
+
function H() {
|
|
98
|
+
V();
|
|
99
|
+
}
|
|
100
|
+
function ae() {
|
|
101
|
+
L.forEach((e) => clearTimeout(e)), L.clear(), R.splice(0, R.length);
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/sonner/state.ts
|
|
105
|
+
var U = 1, W = new class {
|
|
106
|
+
subscribers;
|
|
107
|
+
toasts;
|
|
108
|
+
dismissedToasts;
|
|
109
|
+
constructor() {
|
|
110
|
+
this.subscribers = [], this.toasts = [], this.dismissedToasts = /* @__PURE__ */ new Set();
|
|
111
|
+
}
|
|
112
|
+
subscribe = (e) => (this.subscribers.push(e), () => {
|
|
113
|
+
let t = this.subscribers.indexOf(e);
|
|
114
|
+
this.subscribers.splice(t, 1);
|
|
115
|
+
});
|
|
116
|
+
publish = (e) => {
|
|
117
|
+
this.subscribers.forEach((t) => t(e));
|
|
118
|
+
};
|
|
119
|
+
addToast = (e) => {
|
|
120
|
+
this.publish(e), this.toasts = [...this.toasts, e];
|
|
121
|
+
};
|
|
122
|
+
create = (e) => {
|
|
123
|
+
let { message: t, ...n } = e, r = typeof e.id == "number" || e.id && e.id?.length > 0 ? e.id : U++, i = this.toasts.find((e) => e.id === r), a = e.dismissible === void 0 ? !0 : e.dismissible;
|
|
124
|
+
return this.dismissedToasts.has(r) && this.dismissedToasts.delete(r), i ? this.toasts = this.toasts.map((n) => n.id === r ? (this.publish({
|
|
125
|
+
...n,
|
|
126
|
+
...e,
|
|
127
|
+
id: r,
|
|
128
|
+
title: t
|
|
129
|
+
}), {
|
|
130
|
+
...n,
|
|
131
|
+
...e,
|
|
132
|
+
id: r,
|
|
133
|
+
dismissible: a,
|
|
134
|
+
title: t
|
|
135
|
+
}) : n) : this.addToast({
|
|
136
|
+
title: t,
|
|
137
|
+
...n,
|
|
138
|
+
dismissible: a,
|
|
139
|
+
id: r
|
|
140
|
+
}), r;
|
|
141
|
+
};
|
|
142
|
+
dismiss = (e) => (e ? (this.dismissedToasts.add(e), requestAnimationFrame(() => this.subscribers.forEach((t) => t({
|
|
143
|
+
id: e,
|
|
144
|
+
dismiss: !0
|
|
145
|
+
})))) : this.toasts.forEach((e) => {
|
|
146
|
+
this.subscribers.forEach((t) => t({
|
|
147
|
+
id: e.id,
|
|
148
|
+
dismiss: !0
|
|
149
|
+
}));
|
|
150
|
+
}), e);
|
|
151
|
+
message = (e, t) => this.create({
|
|
152
|
+
...t,
|
|
153
|
+
message: e,
|
|
154
|
+
type: "default"
|
|
155
|
+
});
|
|
156
|
+
error = (e, t) => this.create({
|
|
157
|
+
...t,
|
|
158
|
+
type: "error",
|
|
159
|
+
message: e
|
|
160
|
+
});
|
|
161
|
+
success = (e, t) => this.create({
|
|
162
|
+
...t,
|
|
163
|
+
type: "success",
|
|
164
|
+
message: e
|
|
165
|
+
});
|
|
166
|
+
info = (e, t) => this.create({
|
|
167
|
+
...t,
|
|
168
|
+
type: "info",
|
|
169
|
+
message: e
|
|
170
|
+
});
|
|
171
|
+
warning = (e, t) => this.create({
|
|
172
|
+
...t,
|
|
173
|
+
type: "warning",
|
|
174
|
+
message: e
|
|
175
|
+
});
|
|
176
|
+
loading = (e, t) => this.create({
|
|
177
|
+
...t,
|
|
178
|
+
type: "loading",
|
|
179
|
+
message: e
|
|
180
|
+
});
|
|
181
|
+
promise = (e, t) => {
|
|
182
|
+
if (!t) return;
|
|
183
|
+
let n;
|
|
184
|
+
t.loading !== void 0 && (n = this.create({
|
|
185
|
+
...t,
|
|
186
|
+
promise: e,
|
|
187
|
+
type: "loading",
|
|
188
|
+
message: t.loading,
|
|
189
|
+
description: typeof t.description == "function" ? void 0 : t.description
|
|
190
|
+
}));
|
|
191
|
+
let r = Promise.resolve(e instanceof Function ? e() : e), i = n !== void 0, a, o = r.then(async (e) => {
|
|
192
|
+
if (a = ["resolve", e], u(e)) i = !1, this.create({
|
|
193
|
+
id: n,
|
|
194
|
+
type: "default",
|
|
195
|
+
message: e
|
|
196
|
+
});
|
|
197
|
+
else if (G(e) && !e.ok) {
|
|
198
|
+
i = !1;
|
|
199
|
+
let r = typeof t.error == "function" ? await t.error(`HTTP error! status: ${e.status}`) : t.error, a = typeof t.description == "function" ? await t.description(`HTTP error! status: ${e.status}`) : t.description, o = typeof r == "object" && !u(r) ? r : {
|
|
200
|
+
message: r || "",
|
|
201
|
+
id: n || ""
|
|
202
|
+
};
|
|
203
|
+
this.create({
|
|
204
|
+
id: n,
|
|
205
|
+
type: "error",
|
|
206
|
+
description: a,
|
|
207
|
+
...o
|
|
208
|
+
});
|
|
209
|
+
} else if (e instanceof Error) {
|
|
210
|
+
i = !1;
|
|
211
|
+
let r = typeof t.error == "function" ? await t.error(e) : t.error, a = typeof t.description == "function" ? await t.description(e) : t.description, o = typeof r == "object" && !u(r) ? r : {
|
|
212
|
+
message: r || "",
|
|
213
|
+
id: n || ""
|
|
214
|
+
};
|
|
215
|
+
this.create({
|
|
216
|
+
id: n,
|
|
217
|
+
type: "error",
|
|
218
|
+
description: a,
|
|
219
|
+
...o
|
|
220
|
+
});
|
|
221
|
+
} else if (t.success !== void 0) {
|
|
222
|
+
i = !1;
|
|
223
|
+
let r = typeof t.success == "function" ? await t.success(e) : t.success, a = typeof t.description == "function" ? await t.description(e) : t.description, o = typeof r == "object" && !u(r) ? r : {
|
|
224
|
+
message: r || "",
|
|
225
|
+
id: n || ""
|
|
226
|
+
};
|
|
227
|
+
this.create({
|
|
228
|
+
id: n,
|
|
229
|
+
type: "success",
|
|
230
|
+
description: a,
|
|
231
|
+
...o
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}).catch(async (e) => {
|
|
235
|
+
if (a = ["reject", e], t.error !== void 0) {
|
|
236
|
+
i = !1;
|
|
237
|
+
let r = typeof t.error == "function" ? await t.error(e) : t.error, a = typeof t.description == "function" ? await t.description(e) : t.description, o = typeof r == "object" && !u(r) ? r : {
|
|
238
|
+
message: r || "",
|
|
239
|
+
id: n || ""
|
|
240
|
+
};
|
|
241
|
+
this.create({
|
|
242
|
+
id: n,
|
|
243
|
+
type: "error",
|
|
244
|
+
description: a,
|
|
245
|
+
...o
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}).finally(() => {
|
|
249
|
+
i && (this.dismiss(n), n = void 0), t.finally?.();
|
|
250
|
+
}), s = () => new Promise((e, t) => o.then(() => a[0] === "reject" ? t(a[1]) : e(a[1])).catch(t));
|
|
251
|
+
return typeof n != "string" && typeof n != "number" ? { unwrap: s } : Object.assign(n, { unwrap: s });
|
|
252
|
+
};
|
|
253
|
+
custom = (e, t) => {
|
|
254
|
+
let n = t?.id || U++, r = this.toasts.find((e) => e.id === n), i = t?.dismissible === void 0 ? !0 : t.dismissible;
|
|
255
|
+
return this.dismissedToasts.has(n) && this.dismissedToasts.delete(n), r ? this.toasts = this.toasts.map((r) => r.id === n ? (this.publish({
|
|
256
|
+
...r,
|
|
257
|
+
component: e,
|
|
258
|
+
dismissible: i,
|
|
259
|
+
id: n,
|
|
260
|
+
...t
|
|
261
|
+
}), {
|
|
262
|
+
...r,
|
|
263
|
+
component: e,
|
|
264
|
+
dismissible: i,
|
|
265
|
+
id: n,
|
|
266
|
+
...t
|
|
267
|
+
}) : r) : this.addToast({
|
|
268
|
+
component: e,
|
|
269
|
+
dismissible: i,
|
|
270
|
+
id: n,
|
|
271
|
+
...t
|
|
272
|
+
}), n;
|
|
273
|
+
};
|
|
274
|
+
getActiveToasts = () => this.toasts.filter((e) => !this.dismissedToasts.has(e.id));
|
|
275
|
+
}();
|
|
276
|
+
function oe(e, t) {
|
|
277
|
+
let n = t?.id || U++;
|
|
278
|
+
return W.create({
|
|
279
|
+
message: e,
|
|
280
|
+
id: n,
|
|
281
|
+
type: "default",
|
|
282
|
+
...t
|
|
283
|
+
}), n;
|
|
284
|
+
}
|
|
285
|
+
var G = (e) => e && typeof e == "object" && "ok" in e && typeof e.ok == "boolean" && "status" in e && typeof e.status == "number", K = Object.assign(oe, {
|
|
286
|
+
success: W.success,
|
|
287
|
+
info: W.info,
|
|
288
|
+
warning: W.warning,
|
|
289
|
+
error: W.error,
|
|
290
|
+
custom: W.custom,
|
|
291
|
+
message: W.message,
|
|
292
|
+
promise: W.promise,
|
|
293
|
+
dismiss: W.dismiss,
|
|
294
|
+
loading: W.loading
|
|
295
|
+
}, {
|
|
296
|
+
getHistory: () => W.toasts,
|
|
297
|
+
getToasts: () => W.getActiveToasts()
|
|
298
|
+
}), q = (e, t) => {
|
|
299
|
+
let n = e.__vccOpts || e;
|
|
300
|
+
for (let [e, r] of t) n[e] = r;
|
|
301
|
+
return n;
|
|
302
|
+
}, se = {}, ce = {
|
|
303
|
+
class: "van-toast__arrow",
|
|
304
|
+
width: "24",
|
|
305
|
+
height: "24",
|
|
306
|
+
viewBox: "0 0 24 24",
|
|
307
|
+
"aria-hidden": "true",
|
|
308
|
+
fill: "none",
|
|
309
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
310
|
+
};
|
|
311
|
+
function le(e, t) {
|
|
312
|
+
return v(), i("svg", ce, [...t[0] ||= [a("g", {
|
|
313
|
+
stroke: "currentColor",
|
|
314
|
+
"stroke-width": "1.5",
|
|
315
|
+
"stroke-linecap": "round",
|
|
316
|
+
"stroke-linejoin": "round"
|
|
317
|
+
}, [a("polyline", {
|
|
318
|
+
transform: "translate(11 12) scale(-1 1) translate(-11 -12)",
|
|
319
|
+
points: "15 4 7 12 15 20"
|
|
320
|
+
})], -1)]]);
|
|
321
|
+
}
|
|
322
|
+
var ue = /*#__PURE__*/ q(se, [["render", le]]), de = {
|
|
323
|
+
key: 0,
|
|
324
|
+
class: "van-toast__icon",
|
|
325
|
+
viewBox: "0 0 24 24",
|
|
326
|
+
"aria-hidden": "true",
|
|
327
|
+
fill: "none",
|
|
328
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
329
|
+
}, J = {
|
|
330
|
+
key: 1,
|
|
331
|
+
class: "van-toast__icon",
|
|
332
|
+
viewBox: "0 0 24 24",
|
|
333
|
+
"aria-hidden": "true",
|
|
334
|
+
fill: "none",
|
|
335
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
336
|
+
}, fe = {
|
|
337
|
+
key: 2,
|
|
338
|
+
class: "van-toast__icon",
|
|
339
|
+
viewBox: "0 0 24 24",
|
|
340
|
+
"aria-hidden": "true",
|
|
341
|
+
fill: "none",
|
|
342
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
343
|
+
}, pe = {
|
|
344
|
+
key: 3,
|
|
345
|
+
class: "van-toast__icon",
|
|
346
|
+
viewBox: "0 0 24 24",
|
|
347
|
+
"aria-hidden": "true",
|
|
348
|
+
fill: "none",
|
|
349
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
350
|
+
}, Y = /* @__PURE__ */ l({
|
|
351
|
+
__name: "MobileToastIcon",
|
|
352
|
+
props: { type: {} },
|
|
353
|
+
setup(e) {
|
|
354
|
+
return (t, n) => e.type === "success" ? (v(), i("svg", de, [...n[0] ||= [a("path", {
|
|
355
|
+
d: "M20 6.5 9.5 17 4 11.5",
|
|
356
|
+
stroke: "currentColor",
|
|
357
|
+
"stroke-width": "1.5",
|
|
358
|
+
"stroke-linecap": "round",
|
|
359
|
+
"stroke-linejoin": "round"
|
|
360
|
+
}, null, -1)]])) : e.type === "error" || e.type === "fail" ? (v(), i("svg", J, [...n[1] ||= [a("path", {
|
|
361
|
+
d: "m6.5 6.5 11 11m0-11-11 11",
|
|
362
|
+
stroke: "currentColor",
|
|
363
|
+
"stroke-width": "1.5",
|
|
364
|
+
"stroke-linecap": "round",
|
|
365
|
+
"stroke-linejoin": "round"
|
|
366
|
+
}, null, -1)]])) : e.type === "warning" ? (v(), i("svg", fe, [...n[2] ||= [a("path", {
|
|
367
|
+
d: "M12 4.5 21 19.5H3L12 4.5Z",
|
|
368
|
+
stroke: "currentColor",
|
|
369
|
+
"stroke-width": "1.5",
|
|
370
|
+
"stroke-linecap": "round",
|
|
371
|
+
"stroke-linejoin": "round"
|
|
372
|
+
}, null, -1), a("path", {
|
|
373
|
+
d: "M12 9.5v4.5m0 3h.01",
|
|
374
|
+
stroke: "currentColor",
|
|
375
|
+
"stroke-width": "1.5",
|
|
376
|
+
"stroke-linecap": "round",
|
|
377
|
+
"stroke-linejoin": "round"
|
|
378
|
+
}, null, -1)]])) : e.type === "info" ? (v(), i("svg", pe, [...n[3] ||= [a("circle", {
|
|
379
|
+
cx: "12",
|
|
380
|
+
cy: "12",
|
|
381
|
+
r: "8",
|
|
382
|
+
stroke: "currentColor",
|
|
383
|
+
"stroke-width": "1.5"
|
|
384
|
+
}, null, -1), a("path", {
|
|
385
|
+
d: "M12 11v5m0-8h.01",
|
|
386
|
+
stroke: "currentColor",
|
|
387
|
+
"stroke-width": "1.5",
|
|
388
|
+
"stroke-linecap": "round",
|
|
389
|
+
"stroke-linejoin": "round"
|
|
390
|
+
}, null, -1)]])) : r("", !0);
|
|
391
|
+
}
|
|
392
|
+
}), me = ["data-removed"], he = /* @__PURE__ */ l({
|
|
393
|
+
__name: "MobileToast",
|
|
394
|
+
props: {
|
|
395
|
+
toast: {},
|
|
396
|
+
index: {},
|
|
397
|
+
toastOptions: {}
|
|
398
|
+
},
|
|
399
|
+
setup(o) {
|
|
400
|
+
let s = o;
|
|
401
|
+
function l(e) {
|
|
402
|
+
if (e) return e[s.toast.type];
|
|
403
|
+
}
|
|
404
|
+
let u = t(() => s.toastOptions?.classes), d = t(() => s.toast.mobileClasses), f = t(() => [
|
|
405
|
+
u.value?.icon,
|
|
406
|
+
l(u.value),
|
|
407
|
+
d.value?.icon,
|
|
408
|
+
l(d.value)
|
|
409
|
+
]);
|
|
410
|
+
function m() {
|
|
411
|
+
s.toast.dismissible && V(s.toast.id);
|
|
412
|
+
}
|
|
413
|
+
function g(e) {
|
|
414
|
+
!s.toast.onClick && !s.toast.action || (s.toast.onClick?.(), s.toast.action?.onClick(e), m());
|
|
415
|
+
}
|
|
416
|
+
return (t, s) => (v(), i("div", {
|
|
417
|
+
class: p(["van-toast", [
|
|
418
|
+
`van-toast--${o.toast.mobilePosition}`,
|
|
419
|
+
o.toast.type === "default" ? "van-toast--text" : `van-toast--${o.toast.type}`,
|
|
420
|
+
u.value?.toast,
|
|
421
|
+
l(u.value),
|
|
422
|
+
o.toastOptions?.class,
|
|
423
|
+
d.value?.toast,
|
|
424
|
+
l(d.value),
|
|
425
|
+
o.toast.mobileClass
|
|
426
|
+
]]),
|
|
427
|
+
"data-removed": o.toast.dismissed,
|
|
428
|
+
style: h({
|
|
429
|
+
"--vt-mobile-index": o.index,
|
|
430
|
+
...o.toastOptions?.style,
|
|
431
|
+
...o.toast.mobileStyle
|
|
432
|
+
}),
|
|
433
|
+
role: "status",
|
|
434
|
+
onClick: g
|
|
435
|
+
}, [
|
|
436
|
+
o.toast.type !== "default" && o.toast.mobileIcon !== !1 ? (v(), i(e, { key: 0 }, [o.toast.mobileIcon ? (v(), i("span", {
|
|
437
|
+
key: 0,
|
|
438
|
+
class: p(["van-toast__icon", f.value])
|
|
439
|
+
}, [(v(), n(S(o.toast.mobileIcon)))], 2)) : o.toast.type === "loading" ? (v(), i("span", {
|
|
440
|
+
key: 1,
|
|
441
|
+
class: p(["van-loading__spinner van-loading__spinner--circular van-toast__loading", f.value]),
|
|
442
|
+
"aria-hidden": "true"
|
|
443
|
+
}, [x(t.$slots, "loading-icon", {}, () => [s[0] ||= a("svg", {
|
|
444
|
+
class: "van-loading__circular",
|
|
445
|
+
viewBox: "25 25 50 50"
|
|
446
|
+
}, [a("circle", {
|
|
447
|
+
cx: "50",
|
|
448
|
+
cy: "50",
|
|
449
|
+
r: "20",
|
|
450
|
+
fill: "none"
|
|
451
|
+
})], -1)])], 2)) : (v(), i("span", {
|
|
452
|
+
key: 2,
|
|
453
|
+
class: p(["van-toast__icon", f.value])
|
|
454
|
+
}, [o.toast.type === "success" ? x(t.$slots, "success-icon", { key: 0 }, () => [c(Y, { type: o.toast.type }, null, 8, ["type"])]) : o.toast.type === "error" ? x(t.$slots, "error-icon", { key: 1 }, () => [c(Y, { type: o.toast.type }, null, 8, ["type"])]) : o.toast.type === "warning" ? x(t.$slots, "warning-icon", { key: 2 }, () => [c(Y, { type: o.toast.type }, null, 8, ["type"])]) : o.toast.type === "info" ? x(t.$slots, "info-icon", { key: 3 }, () => [c(Y, { type: o.toast.type }, null, 8, ["type"])]) : r("", !0)], 2))], 64)) : r("", !0),
|
|
455
|
+
a("div", { class: p(["van-toast__content", [u.value?.content, d.value?.content]]) }, [a("div", { class: p(["van-toast__text", [u.value?.text, d.value?.text]]) }, w(o.toast.message), 3), o.toast.onClick || o.toast.action ? (v(), n(ue, {
|
|
456
|
+
key: 0,
|
|
457
|
+
class: p([u.value?.actionIcon, d.value?.actionIcon])
|
|
458
|
+
}, null, 8, ["class"])) : r("", !0)], 2),
|
|
459
|
+
o.toast.description === void 0 ? r("", !0) : (v(), i("div", {
|
|
460
|
+
key: 1,
|
|
461
|
+
class: p(["van-toast__description", [u.value?.description, d.value?.description]])
|
|
462
|
+
}, w(o.toast.description), 3))
|
|
463
|
+
], 14, me));
|
|
464
|
+
}
|
|
465
|
+
}), ge = {
|
|
466
|
+
class: "vt-mobile-layer",
|
|
467
|
+
"aria-live": "polite",
|
|
468
|
+
"aria-relevant": "additions text"
|
|
469
|
+
}, _e = /* @__PURE__ */ l({
|
|
470
|
+
__name: "MobileToaster",
|
|
471
|
+
props: {
|
|
472
|
+
toasts: {},
|
|
473
|
+
toastOptions: {}
|
|
474
|
+
},
|
|
475
|
+
setup(t) {
|
|
476
|
+
return (r, a) => (v(), i("div", ge, [(v(!0), i(e, null, b(t.toasts, (e, i) => (v(), n(he, {
|
|
477
|
+
key: e.id,
|
|
478
|
+
toast: e,
|
|
479
|
+
index: i,
|
|
480
|
+
"toast-options": t.toastOptions
|
|
481
|
+
}, o({ _: 2 }, [
|
|
482
|
+
r.$slots["loading-icon"] ? {
|
|
483
|
+
name: "loading-icon",
|
|
484
|
+
fn: O(() => [x(r.$slots, "loading-icon")]),
|
|
485
|
+
key: "0"
|
|
486
|
+
} : void 0,
|
|
487
|
+
r.$slots["success-icon"] ? {
|
|
488
|
+
name: "success-icon",
|
|
489
|
+
fn: O(() => [x(r.$slots, "success-icon")]),
|
|
490
|
+
key: "1"
|
|
491
|
+
} : void 0,
|
|
492
|
+
r.$slots["error-icon"] ? {
|
|
493
|
+
name: "error-icon",
|
|
494
|
+
fn: O(() => [x(r.$slots, "error-icon")]),
|
|
495
|
+
key: "2"
|
|
496
|
+
} : void 0,
|
|
497
|
+
r.$slots["warning-icon"] ? {
|
|
498
|
+
name: "warning-icon",
|
|
499
|
+
fn: O(() => [x(r.$slots, "warning-icon")]),
|
|
500
|
+
key: "3"
|
|
501
|
+
} : void 0,
|
|
502
|
+
r.$slots["info-icon"] ? {
|
|
503
|
+
name: "info-icon",
|
|
504
|
+
fn: O(() => [x(r.$slots, "info-icon")]),
|
|
505
|
+
key: "4"
|
|
506
|
+
} : void 0
|
|
507
|
+
]), 1032, [
|
|
508
|
+
"toast",
|
|
509
|
+
"index",
|
|
510
|
+
"toast-options"
|
|
511
|
+
]))), 128))]));
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region src/sonner/types.ts
|
|
516
|
+
function ve(e) {
|
|
517
|
+
return e.label !== void 0;
|
|
518
|
+
}
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region src/sonner/constant.ts
|
|
521
|
+
var ye = "24px", be = "16px";
|
|
522
|
+
//#endregion
|
|
523
|
+
//#region src/sonner/hooks.ts
|
|
524
|
+
function xe() {
|
|
525
|
+
let e = y(!1);
|
|
526
|
+
return D(() => {
|
|
527
|
+
let t = () => {
|
|
528
|
+
e.value = document.hidden;
|
|
529
|
+
};
|
|
530
|
+
return document.addEventListener("visibilitychange", t), () => window.removeEventListener("visibilitychange", t);
|
|
531
|
+
}), { isDocumentHidden: e };
|
|
532
|
+
}
|
|
533
|
+
function X(...e) {
|
|
534
|
+
return e.filter(Boolean).join(" ");
|
|
535
|
+
}
|
|
536
|
+
function Se(e) {
|
|
537
|
+
let [t, n] = e.split("-"), r = [];
|
|
538
|
+
return t && r.push(t), n && r.push(n), r;
|
|
539
|
+
}
|
|
540
|
+
function Ce(e, t) {
|
|
541
|
+
let n = {};
|
|
542
|
+
return [e, t].forEach((e, t) => {
|
|
543
|
+
let r = t === 1, i = r ? "--mobile-offset" : "--offset", a = r ? be : ye;
|
|
544
|
+
function o(e) {
|
|
545
|
+
[
|
|
546
|
+
"top",
|
|
547
|
+
"right",
|
|
548
|
+
"bottom",
|
|
549
|
+
"left"
|
|
550
|
+
].forEach((t) => {
|
|
551
|
+
n[`${i}-${t}`] = typeof e == "number" ? `${e}px` : e;
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
typeof e == "number" || typeof e == "string" ? o(e) : typeof e == "object" ? [
|
|
555
|
+
"top",
|
|
556
|
+
"right",
|
|
557
|
+
"bottom",
|
|
558
|
+
"left"
|
|
559
|
+
].forEach((t) => {
|
|
560
|
+
e[t] === void 0 ? n[`${i}-${t}`] = a : n[`${i}-${t}`] = typeof e[t] == "number" ? `${e[t]}px` : e[t];
|
|
561
|
+
}) : o(a);
|
|
562
|
+
}), n;
|
|
563
|
+
}
|
|
564
|
+
//#endregion
|
|
565
|
+
//#region src/sonner/Toast.vue?vue&type=script&setup=true&lang.ts
|
|
566
|
+
var we = [
|
|
567
|
+
"data-rich-colors",
|
|
568
|
+
"data-styled",
|
|
569
|
+
"data-mounted",
|
|
570
|
+
"data-promise",
|
|
571
|
+
"data-swiped",
|
|
572
|
+
"data-removed",
|
|
573
|
+
"data-visible",
|
|
574
|
+
"data-y-position",
|
|
575
|
+
"data-x-position",
|
|
576
|
+
"data-index",
|
|
577
|
+
"data-front",
|
|
578
|
+
"data-swiping",
|
|
579
|
+
"data-dismissible",
|
|
580
|
+
"data-type",
|
|
581
|
+
"data-invert",
|
|
582
|
+
"data-swipe-out",
|
|
583
|
+
"data-swipe-direction",
|
|
584
|
+
"data-expanded",
|
|
585
|
+
"data-testid"
|
|
586
|
+
], Te = [
|
|
587
|
+
"aria-label",
|
|
588
|
+
"data-disabled",
|
|
589
|
+
"data-close-button-position"
|
|
590
|
+
], Ee = /* @__PURE__ */ l({
|
|
591
|
+
__name: "Toast",
|
|
592
|
+
props: {
|
|
593
|
+
toast: {},
|
|
594
|
+
toasts: {},
|
|
595
|
+
index: {},
|
|
596
|
+
swipeDirections: {},
|
|
597
|
+
expanded: { type: Boolean },
|
|
598
|
+
invert: { type: Boolean },
|
|
599
|
+
heights: {},
|
|
600
|
+
gap: {},
|
|
601
|
+
position: {},
|
|
602
|
+
closeButtonPosition: {},
|
|
603
|
+
visibleToasts: {},
|
|
604
|
+
expandByDefault: { type: Boolean },
|
|
605
|
+
closeButton: { type: Boolean },
|
|
606
|
+
interacting: { type: Boolean },
|
|
607
|
+
style: {},
|
|
608
|
+
cancelButtonStyle: {},
|
|
609
|
+
actionButtonStyle: {},
|
|
610
|
+
duration: {},
|
|
611
|
+
class: {},
|
|
612
|
+
unstyled: { type: Boolean },
|
|
613
|
+
descriptionClass: {},
|
|
614
|
+
loadingIcon: {},
|
|
615
|
+
classes: {},
|
|
616
|
+
icons: {},
|
|
617
|
+
closeButtonAriaLabel: {},
|
|
618
|
+
defaultRichColors: { type: Boolean }
|
|
619
|
+
},
|
|
620
|
+
emits: [
|
|
621
|
+
"update:heights",
|
|
622
|
+
"update:height",
|
|
623
|
+
"removeToast"
|
|
624
|
+
],
|
|
625
|
+
setup(o, { emit: c }) {
|
|
626
|
+
let l = o, u = c, b = y(null), C = y(null), E = y(!1), O = y(!1), k = y(!1), A = y(!1), j = y(!1), M = y(0), N = y(0), P = y(l.toast.duration || l.duration || 4e3), F = y(null), I = y(null), L = t(() => l.index === 0), te = t(() => l.index + 1 <= l.visibleToasts), R = t(() => l.toast.type), z = t(() => l.toast.dismissible !== !1), B = t(() => l.toast.class || ""), ne = t(() => l.descriptionClass || ""), re = t(() => l.toast.icon !== !1 && (R.value !== "default" || l.toast.icon || l.toast.promise)), ie = t(() => {
|
|
627
|
+
let e = l.toast.position || l.position, t = l.heights.filter((t) => t.position === e).findIndex((e) => e.toastId === l.toast.id);
|
|
628
|
+
return t >= 0 ? t : 0;
|
|
629
|
+
}), V = t(() => {
|
|
630
|
+
let e = l.toast.position || l.position;
|
|
631
|
+
return l.heights.filter((t) => t.position === e).reduce((e, t, n) => n >= ie.value ? e : e + t.height, 0);
|
|
632
|
+
}), H = t(() => ie.value * l.gap + V.value || 0), ae = t(() => l.toast.closeButton ?? l.closeButton), U = t(() => l.toast.duration || l.duration || 4e3), W = y(0), oe = y(0), G = y(null), K = t(() => l.position.split("-")), q = t(() => K.value[0]), se = t(() => K.value[1]), ce = t(() => typeof l.toast.title != "string"), le = t(() => typeof l.toast.description != "string"), { isDocumentHidden: ue } = xe(), de = t(() => R.value && R.value === "loading");
|
|
633
|
+
_(() => {
|
|
634
|
+
E.value = !0, P.value = U.value;
|
|
635
|
+
}), D(async () => {
|
|
636
|
+
if (!E.value || !I.value) return;
|
|
637
|
+
await f();
|
|
638
|
+
let e = I.value, t = e.style.height;
|
|
639
|
+
e.style.height = "auto";
|
|
640
|
+
let n = e.getBoundingClientRect().height;
|
|
641
|
+
e.style.height = t, N.value = n, u("update:height", {
|
|
642
|
+
toastId: l.toast.id,
|
|
643
|
+
height: n,
|
|
644
|
+
position: l.toast.position || l.position
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
function J() {
|
|
648
|
+
O.value = !0, M.value = H.value, setTimeout(() => {
|
|
649
|
+
u("removeToast", l.toast);
|
|
650
|
+
}, 200);
|
|
651
|
+
}
|
|
652
|
+
function fe() {
|
|
653
|
+
if (de.value || !z.value) return {};
|
|
654
|
+
J(), l.toast.onDismiss?.(l.toast);
|
|
655
|
+
}
|
|
656
|
+
function pe(e) {
|
|
657
|
+
e.button !== 2 && (de.value || !z.value || (F.value = /* @__PURE__ */ new Date(), M.value = H.value, e.target.setPointerCapture(e.pointerId), e.target.tagName !== "BUTTON" && (k.value = !0, G.value = {
|
|
658
|
+
x: e.clientX,
|
|
659
|
+
y: e.clientY
|
|
660
|
+
})));
|
|
661
|
+
}
|
|
662
|
+
function Y() {
|
|
663
|
+
if (A.value || !z.value) return;
|
|
664
|
+
G.value = null;
|
|
665
|
+
let e = Number(I.value?.style.getPropertyValue("--swipe-amount-x").replace("px", "") || 0), t = Number(I.value?.style.getPropertyValue("--swipe-amount-y").replace("px", "") || 0), n = (/* @__PURE__ */ new Date()).getTime() - (F.value?.getTime() || 0), r = b.value === "x" ? e : t, i = Math.abs(r) / n;
|
|
666
|
+
if (Math.abs(r) >= 45 || i > .11) {
|
|
667
|
+
M.value = H.value, l.toast.onDismiss?.(l.toast), b.value === "x" ? C.value = e > 0 ? "right" : "left" : C.value = t > 0 ? "down" : "up", J(), A.value = !0;
|
|
668
|
+
return;
|
|
669
|
+
} else I.value?.style.setProperty("--swipe-amount-x", "0px"), I.value?.style.setProperty("--swipe-amount-y", "0px");
|
|
670
|
+
j.value = !1, k.value = !1, b.value = null;
|
|
671
|
+
}
|
|
672
|
+
function me(e) {
|
|
673
|
+
if (!G.value || !z.value || (window?.getSelection()?.toString()?.length ?? !1)) return;
|
|
674
|
+
let t = e.clientY - G.value.y, n = e.clientX - G.value.x, r = l.swipeDirections ?? Se(l.position);
|
|
675
|
+
!b.value && (Math.abs(n) > 1 || Math.abs(t) > 1) && (b.value = Math.abs(n) > Math.abs(t) ? "x" : "y");
|
|
676
|
+
let i = {
|
|
677
|
+
x: 0,
|
|
678
|
+
y: 0
|
|
679
|
+
}, a = (e) => 1 / (1.5 + Math.abs(e) / 20);
|
|
680
|
+
if (b.value === "y") {
|
|
681
|
+
if (r.includes("top") || r.includes("bottom")) if (r.includes("top") && t < 0 || r.includes("bottom") && t > 0) i.y = t;
|
|
682
|
+
else {
|
|
683
|
+
let e = t * a(t);
|
|
684
|
+
i.y = Math.abs(e) < Math.abs(t) ? e : t;
|
|
685
|
+
}
|
|
686
|
+
} else if (b.value === "x" && (r.includes("left") || r.includes("right"))) if (r.includes("left") && n < 0 || r.includes("right") && n > 0) i.x = n;
|
|
687
|
+
else {
|
|
688
|
+
let e = n * a(n);
|
|
689
|
+
i.x = Math.abs(e) < Math.abs(n) ? e : n;
|
|
690
|
+
}
|
|
691
|
+
(Math.abs(i.x) > 0 || Math.abs(i.y) > 0) && (j.value = !0), I.value?.style.setProperty("--swipe-amount-x", `${i.x}px`), I.value?.style.setProperty("--swipe-amount-y", `${i.y}px`);
|
|
692
|
+
}
|
|
693
|
+
_(() => {
|
|
694
|
+
if (E.value = !0, !I.value) return;
|
|
695
|
+
let e = I.value.getBoundingClientRect().height;
|
|
696
|
+
N.value = e, u("update:heights", [{
|
|
697
|
+
toastId: l.toast.id,
|
|
698
|
+
height: e,
|
|
699
|
+
position: l.toast.position
|
|
700
|
+
}, ...l.heights]);
|
|
701
|
+
}), g(() => {
|
|
702
|
+
I.value && u("removeToast", l.toast);
|
|
703
|
+
}), D((e) => {
|
|
704
|
+
if (l.toast.promise && R.value === "loading" || l.toast.duration === Infinity || l.toast.type === "loading") return;
|
|
705
|
+
let t;
|
|
706
|
+
l.expanded || l.interacting || ue.value ? (() => {
|
|
707
|
+
if (oe.value < W.value) {
|
|
708
|
+
let e = (/* @__PURE__ */ new Date()).getTime() - W.value;
|
|
709
|
+
P.value -= e;
|
|
710
|
+
}
|
|
711
|
+
oe.value = (/* @__PURE__ */ new Date()).getTime();
|
|
712
|
+
})() : P.value !== Infinity && (W.value = (/* @__PURE__ */ new Date()).getTime(), t = setTimeout(() => {
|
|
713
|
+
l.toast.onAutoClose?.(l.toast), J();
|
|
714
|
+
}, P.value)), e(() => {
|
|
715
|
+
clearTimeout(t);
|
|
716
|
+
});
|
|
717
|
+
}), ee(() => l.toast.delete, (e) => {
|
|
718
|
+
e !== void 0 && e && (J(), l.toast.onDismiss?.(l.toast));
|
|
719
|
+
}, { deep: !0 });
|
|
720
|
+
function he() {
|
|
721
|
+
k.value = !1, b.value = null, G.value = null;
|
|
722
|
+
}
|
|
723
|
+
return (t, c) => (v(), i("li", {
|
|
724
|
+
tabindex: "0",
|
|
725
|
+
ref_key: "toastRef",
|
|
726
|
+
ref: I,
|
|
727
|
+
class: p(T(X)(l.class, B.value, o.classes?.toast, o.toast.classes?.toast, o.classes?.[R.value], o.toast?.classes?.[R.value])),
|
|
728
|
+
"data-sonner-toast": "",
|
|
729
|
+
"data-rich-colors": o.toast.richColors ?? o.defaultRichColors,
|
|
730
|
+
"data-styled": !(o.toast.component || o.toast?.unstyled || o.unstyled),
|
|
731
|
+
"data-mounted": E.value,
|
|
732
|
+
"data-promise": !!o.toast.promise,
|
|
733
|
+
"data-swiped": j.value,
|
|
734
|
+
"data-removed": O.value,
|
|
735
|
+
"data-visible": te.value,
|
|
736
|
+
"data-y-position": q.value,
|
|
737
|
+
"data-x-position": se.value,
|
|
738
|
+
"data-index": o.index,
|
|
739
|
+
"data-front": L.value,
|
|
740
|
+
"data-swiping": k.value,
|
|
741
|
+
"data-dismissible": z.value,
|
|
742
|
+
"data-type": R.value,
|
|
743
|
+
"data-invert": o.toast.invert || o.invert,
|
|
744
|
+
"data-swipe-out": A.value,
|
|
745
|
+
"data-swipe-direction": C.value,
|
|
746
|
+
"data-expanded": !!(o.expanded || o.expandByDefault && E.value),
|
|
747
|
+
"data-testid": o.toast.testId,
|
|
748
|
+
style: h({
|
|
749
|
+
"--index": o.index,
|
|
750
|
+
"--toasts-before": o.index,
|
|
751
|
+
"--z-index": o.toasts.length - o.index,
|
|
752
|
+
"--offset": `${O.value ? M.value : H.value}px`,
|
|
753
|
+
"--initial-height": o.expandByDefault ? "auto" : `${N.value}px`,
|
|
754
|
+
...o.style,
|
|
755
|
+
...l.toast.style
|
|
756
|
+
}),
|
|
757
|
+
onDragend: he,
|
|
758
|
+
onPointerdown: pe,
|
|
759
|
+
onPointerup: Y,
|
|
760
|
+
onPointermove: me
|
|
761
|
+
}, [ae.value && !o.toast.component && R.value !== "loading" ? (v(), i("button", {
|
|
762
|
+
key: 0,
|
|
763
|
+
"aria-label": o.closeButtonAriaLabel || "Close toast",
|
|
764
|
+
"data-disabled": de.value,
|
|
765
|
+
"data-close-button": "true",
|
|
766
|
+
"data-close-button-position": o.closeButtonPosition,
|
|
767
|
+
class: p(T(X)(o.classes?.closeButton, o.toast?.classes?.closeButton)),
|
|
768
|
+
onClick: fe
|
|
769
|
+
}, [o.icons?.close ? (v(), n(S(o.icons?.close), { key: 0 })) : x(t.$slots, "close-icon", { key: 1 })], 10, Te)) : r("", !0), o.toast.component ? (v(), n(S(o.toast.component), d({ key: 1 }, o.toast.componentProps, {
|
|
770
|
+
onCloseToast: fe,
|
|
771
|
+
isPaused: t.$props.expanded || t.$props.interacting || T(ue)
|
|
772
|
+
}), null, 16, ["isPaused"])) : (v(), i(e, { key: 2 }, [
|
|
773
|
+
re.value ? (v(), i("div", {
|
|
774
|
+
key: 0,
|
|
775
|
+
"data-icon": "",
|
|
776
|
+
class: p(T(X)(o.classes?.icon, o.toast?.classes?.icon))
|
|
777
|
+
}, [o.toast.icon ? (v(), n(S(o.toast.icon), { key: 0 })) : (v(), i(e, { key: 1 }, [R.value === "loading" ? x(t.$slots, "loading-icon", { key: 0 }) : R.value === "success" ? x(t.$slots, "success-icon", { key: 1 }) : R.value === "error" ? x(t.$slots, "error-icon", { key: 2 }) : R.value === "warning" ? x(t.$slots, "warning-icon", { key: 3 }) : R.value === "info" ? x(t.$slots, "info-icon", { key: 4 }) : r("", !0)], 64))], 2)) : r("", !0),
|
|
778
|
+
a("div", {
|
|
779
|
+
"data-content": "",
|
|
780
|
+
class: p(T(X)(o.classes?.content, o.toast?.classes?.content))
|
|
781
|
+
}, [a("div", {
|
|
782
|
+
"data-title": "",
|
|
783
|
+
class: p(T(X)(o.classes?.title, o.toast.classes?.title))
|
|
784
|
+
}, [ce.value ? (v(), n(S(o.toast.title), m(d({ key: 0 }, o.toast.componentProps)), null, 16)) : (v(), i(e, { key: 1 }, [s(w(o.toast.title), 1)], 64))], 2), o.toast.description ? (v(), i("div", {
|
|
785
|
+
key: 0,
|
|
786
|
+
"data-description": "",
|
|
787
|
+
class: p(T(X)(o.descriptionClass, ne.value, o.toast.descriptionClass, o.classes?.description, o.toast.classes?.description))
|
|
788
|
+
}, [le.value ? (v(), n(S(o.toast.description), m(d({ key: 0 }, o.toast.componentProps)), null, 16)) : (v(), i(e, { key: 1 }, [s(w(o.toast.description), 1)], 64))], 2)) : r("", !0)], 2),
|
|
789
|
+
o.toast.cancel ? (v(), i("button", {
|
|
790
|
+
key: 1,
|
|
791
|
+
style: h(o.toast.cancelButtonStyle || o.cancelButtonStyle),
|
|
792
|
+
class: p(T(X)(o.classes?.cancelButton, o.toast.classes?.cancelButton)),
|
|
793
|
+
"data-button": "",
|
|
794
|
+
"data-cancel": "",
|
|
795
|
+
onClick: c[0] ||= (e) => {
|
|
796
|
+
T(ve)(o.toast.cancel) && z.value && (o.toast.cancel.onClick?.(e), J());
|
|
797
|
+
}
|
|
798
|
+
}, w(T(ve)(o.toast.cancel) ? o.toast.cancel?.label : o.toast.cancel), 7)) : r("", !0),
|
|
799
|
+
o.toast.action ? (v(), i("button", {
|
|
800
|
+
key: 2,
|
|
801
|
+
style: h(o.toast.actionButtonStyle || o.actionButtonStyle),
|
|
802
|
+
class: p(T(X)(o.classes?.actionButton, o.toast.classes?.actionButton)),
|
|
803
|
+
"data-button": "",
|
|
804
|
+
"data-action": "",
|
|
805
|
+
onClick: c[1] ||= (e) => {
|
|
806
|
+
T(ve)(o.toast.action) && (o.toast.action.onClick?.(e), !e.defaultPrevented && J());
|
|
807
|
+
}
|
|
808
|
+
}, w(T(ve)(o.toast.action) ? o.toast.action?.label : o.toast.action), 7)) : r("", !0)
|
|
809
|
+
], 64))], 46, we));
|
|
810
|
+
}
|
|
811
|
+
}), De = {}, Oe = {
|
|
812
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
813
|
+
width: "12",
|
|
814
|
+
height: "12",
|
|
815
|
+
viewBox: "0 0 24 24",
|
|
816
|
+
fill: "none",
|
|
817
|
+
stroke: "currentColor",
|
|
818
|
+
"stoke-width": "1.5",
|
|
819
|
+
"stroke-linecap": "round",
|
|
820
|
+
"stroke-linejoin": "round"
|
|
821
|
+
};
|
|
822
|
+
function ke(e, t) {
|
|
823
|
+
return v(), i("svg", Oe, [...t[0] ||= [a("line", {
|
|
824
|
+
x1: "18",
|
|
825
|
+
y1: "6",
|
|
826
|
+
x2: "6",
|
|
827
|
+
y2: "18"
|
|
828
|
+
}, null, -1), a("line", {
|
|
829
|
+
x1: "6",
|
|
830
|
+
y1: "6",
|
|
831
|
+
x2: "18",
|
|
832
|
+
y2: "18"
|
|
833
|
+
}, null, -1)]]);
|
|
834
|
+
}
|
|
835
|
+
var Ae = /*#__PURE__*/ q(De, [["render", ke]]), je = ["data-visible"], Me = { class: "sonner-spinner" }, Ne = /* @__PURE__ */ l({
|
|
836
|
+
__name: "Loader",
|
|
837
|
+
props: { visible: { type: Boolean } },
|
|
838
|
+
setup(t) {
|
|
839
|
+
let n = Array(12).fill(0);
|
|
840
|
+
return (r, o) => (v(), i("div", {
|
|
841
|
+
class: "sonner-loading-wrapper",
|
|
842
|
+
"data-visible": t.visible
|
|
843
|
+
}, [a("div", Me, [(v(!0), i(e, null, b(T(n), (e) => (v(), i("div", {
|
|
844
|
+
key: `spinner-bar-${e}`,
|
|
845
|
+
class: "sonner-loading-bar"
|
|
846
|
+
}))), 128))])], 8, je));
|
|
847
|
+
}
|
|
848
|
+
}), Pe = {}, Fe = {
|
|
849
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
850
|
+
viewBox: "0 0 20 20",
|
|
851
|
+
fill: "currentColor",
|
|
852
|
+
height: "20",
|
|
853
|
+
width: "20"
|
|
854
|
+
};
|
|
855
|
+
function Ie(e, t) {
|
|
856
|
+
return v(), i("svg", Fe, [...t[0] ||= [a("path", {
|
|
857
|
+
"fill-rule": "evenodd",
|
|
858
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
|
|
859
|
+
"clip-rule": "evenodd"
|
|
860
|
+
}, null, -1)]]);
|
|
861
|
+
}
|
|
862
|
+
var Le = /*#__PURE__*/ q(Pe, [["render", Ie]]), Re = {}, ze = {
|
|
863
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
864
|
+
viewBox: "0 0 20 20",
|
|
865
|
+
fill: "currentColor",
|
|
866
|
+
height: "20",
|
|
867
|
+
width: "20"
|
|
868
|
+
};
|
|
869
|
+
function Be(e, t) {
|
|
870
|
+
return v(), i("svg", ze, [...t[0] ||= [a("path", {
|
|
871
|
+
"fill-rule": "evenodd",
|
|
872
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
|
|
873
|
+
"clip-rule": "evenodd"
|
|
874
|
+
}, null, -1)]]);
|
|
875
|
+
}
|
|
876
|
+
var Ve = /*#__PURE__*/ q(Re, [["render", Be]]), He = {}, Ue = {
|
|
877
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
878
|
+
viewBox: "0 0 24 24",
|
|
879
|
+
fill: "currentColor",
|
|
880
|
+
height: "20",
|
|
881
|
+
width: "20"
|
|
882
|
+
};
|
|
883
|
+
function We(e, t) {
|
|
884
|
+
return v(), i("svg", Ue, [...t[0] ||= [a("path", {
|
|
885
|
+
"fill-rule": "evenodd",
|
|
886
|
+
d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
|
|
887
|
+
"clip-rule": "evenodd"
|
|
888
|
+
}, null, -1)]]);
|
|
889
|
+
}
|
|
890
|
+
var Ge = /*#__PURE__*/ q(He, [["render", We]]), Ke = {}, qe = {
|
|
891
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
892
|
+
viewBox: "0 0 20 20",
|
|
893
|
+
fill: "currentColor",
|
|
894
|
+
height: "20",
|
|
895
|
+
width: "20"
|
|
896
|
+
};
|
|
897
|
+
function Je(e, t) {
|
|
898
|
+
return v(), i("svg", qe, [...t[0] ||= [a("path", {
|
|
899
|
+
"fill-rule": "evenodd",
|
|
900
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
|
|
901
|
+
"clip-rule": "evenodd"
|
|
902
|
+
}, null, -1)]]);
|
|
903
|
+
}
|
|
904
|
+
var Ye = /*#__PURE__*/ q(Ke, [["render", Je]]), Xe = ["aria-label"], Ze = [
|
|
905
|
+
"data-sonner-theme",
|
|
906
|
+
"dir",
|
|
907
|
+
"data-theme",
|
|
908
|
+
"data-rich-colors",
|
|
909
|
+
"data-y-position",
|
|
910
|
+
"data-x-position"
|
|
911
|
+
], Qe = typeof window < "u" && typeof document < "u";
|
|
912
|
+
function $e() {
|
|
913
|
+
if (typeof window > "u" || typeof document > "u") return "ltr";
|
|
914
|
+
let e = document.documentElement.getAttribute("dir");
|
|
915
|
+
return e === "auto" || !e ? window.getComputedStyle(document.documentElement).direction : e;
|
|
916
|
+
}
|
|
917
|
+
//#endregion
|
|
918
|
+
//#region src/sonner/Toaster.vue
|
|
919
|
+
var et = /* @__PURE__ */ l({
|
|
920
|
+
name: "Toaster",
|
|
921
|
+
inheritAttrs: !1,
|
|
922
|
+
__name: "Toaster",
|
|
923
|
+
props: {
|
|
924
|
+
id: {},
|
|
925
|
+
invert: {
|
|
926
|
+
type: Boolean,
|
|
927
|
+
default: !1
|
|
928
|
+
},
|
|
929
|
+
theme: { default: "light" },
|
|
930
|
+
position: { default: "bottom-right" },
|
|
931
|
+
closeButtonPosition: { default: "top-left" },
|
|
932
|
+
hotkey: { default: () => ["altKey", "KeyT"] },
|
|
933
|
+
richColors: {
|
|
934
|
+
type: Boolean,
|
|
935
|
+
default: !1
|
|
936
|
+
},
|
|
937
|
+
expand: {
|
|
938
|
+
type: Boolean,
|
|
939
|
+
default: !1
|
|
940
|
+
},
|
|
941
|
+
duration: {},
|
|
942
|
+
gap: { default: 14 },
|
|
943
|
+
visibleToasts: { default: 3 },
|
|
944
|
+
closeButton: {
|
|
945
|
+
type: Boolean,
|
|
946
|
+
default: !1
|
|
947
|
+
},
|
|
948
|
+
toastOptions: { default: () => ({}) },
|
|
949
|
+
class: { default: "" },
|
|
950
|
+
style: {},
|
|
951
|
+
offset: { default: ye },
|
|
952
|
+
mobileOffset: { default: be },
|
|
953
|
+
dir: { default: "auto" },
|
|
954
|
+
swipeDirections: {},
|
|
955
|
+
icons: {},
|
|
956
|
+
containerAriaLabel: { default: "Notifications" }
|
|
957
|
+
},
|
|
958
|
+
setup(r) {
|
|
959
|
+
let a = r, o = E(), s = y([]), l = t(() => a.id ? s.value.filter((e) => e.toasterId === a.id) : s.value.filter((e) => !e.toasterId));
|
|
960
|
+
function u(e, t) {
|
|
961
|
+
return l.value.filter((n) => !n.position && t === 0 || n.position === e);
|
|
962
|
+
}
|
|
963
|
+
let m = t(() => {
|
|
964
|
+
let e = l.value.filter((e) => e.position).map((e) => e.position);
|
|
965
|
+
return e.length > 0 ? Array.from(new Set([a.position].concat(e))) : [a.position];
|
|
966
|
+
}), g = t(() => {
|
|
967
|
+
let e = {};
|
|
968
|
+
return m.value.forEach((t) => {
|
|
969
|
+
e[t] = s.value.filter((e) => e.position === t);
|
|
970
|
+
}), e;
|
|
971
|
+
}), _ = y([]), C = y({}), w = y(!1);
|
|
972
|
+
D(() => {
|
|
973
|
+
m.value.forEach((e) => {
|
|
974
|
+
e in C.value || (C.value[e] = !1);
|
|
975
|
+
});
|
|
976
|
+
});
|
|
977
|
+
let ee = y(a.theme === "system" ? typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : a.theme), k = y(null), A = y(null), j = y(!1), M = a.hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
978
|
+
function N(e) {
|
|
979
|
+
s.value.find((t) => t.id === e.id)?.delete || W.dismiss(e.id), s.value = s.value.filter(({ id: t }) => t !== e.id), setTimeout(() => {
|
|
980
|
+
s.value.find((t) => t.id === e.id) || (_.value = _.value.filter((t) => t.toastId !== e.id));
|
|
981
|
+
}, 250);
|
|
982
|
+
}
|
|
983
|
+
function P(e) {
|
|
984
|
+
j.value && !e.currentTarget?.contains?.(e.relatedTarget) && (j.value = !1, A.value &&= (A.value.focus({ preventScroll: !0 }), null));
|
|
985
|
+
}
|
|
986
|
+
function F(e) {
|
|
987
|
+
e.target instanceof HTMLElement && e.target.dataset.dismissible === "false" || j.value || (j.value = !0, A.value = e.relatedTarget);
|
|
988
|
+
}
|
|
989
|
+
function I(e) {
|
|
990
|
+
e.target && e.target instanceof HTMLElement && e.target.dataset.dismissible === "false" || (w.value = !0);
|
|
991
|
+
}
|
|
992
|
+
D((e) => {
|
|
993
|
+
s.value = W.getActiveToasts(), e(W.subscribe((e) => {
|
|
994
|
+
if (e.dismiss) {
|
|
995
|
+
requestAnimationFrame(() => {
|
|
996
|
+
s.value = s.value.map((t) => t.id === e.id ? {
|
|
997
|
+
...t,
|
|
998
|
+
delete: !0
|
|
999
|
+
} : t);
|
|
1000
|
+
});
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
f(() => {
|
|
1004
|
+
let t = s.value.findIndex((t) => t.id === e.id);
|
|
1005
|
+
t === -1 ? s.value = [e, ...s.value] : s.value = [
|
|
1006
|
+
...s.value.slice(0, t),
|
|
1007
|
+
{
|
|
1008
|
+
...s.value[t],
|
|
1009
|
+
...e
|
|
1010
|
+
},
|
|
1011
|
+
...s.value.slice(t + 1)
|
|
1012
|
+
];
|
|
1013
|
+
});
|
|
1014
|
+
}));
|
|
1015
|
+
}), D((e) => {
|
|
1016
|
+
if (typeof window > "u") return;
|
|
1017
|
+
if (a.theme !== "system") {
|
|
1018
|
+
ee.value = a.theme;
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
let t = window.matchMedia("(prefers-color-scheme: dark)"), n = (e) => {
|
|
1022
|
+
ee.value = e ? "dark" : "light";
|
|
1023
|
+
};
|
|
1024
|
+
n(t.matches);
|
|
1025
|
+
let r = (e) => {
|
|
1026
|
+
n(e.matches);
|
|
1027
|
+
};
|
|
1028
|
+
try {
|
|
1029
|
+
t.addEventListener("change", r);
|
|
1030
|
+
} catch {
|
|
1031
|
+
t.addListener(r);
|
|
1032
|
+
}
|
|
1033
|
+
e(() => {
|
|
1034
|
+
try {
|
|
1035
|
+
t.removeEventListener("change", r);
|
|
1036
|
+
} catch {
|
|
1037
|
+
t.removeListener(r);
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
}), D(() => {
|
|
1041
|
+
k.value && A.value && (A.value.focus({ preventScroll: !0 }), A.value = null, j.value = !1);
|
|
1042
|
+
}), D(() => {
|
|
1043
|
+
s.value.length <= 1 && Object.keys(C.value).forEach((e) => {
|
|
1044
|
+
C.value[e] = !1;
|
|
1045
|
+
});
|
|
1046
|
+
}), D((e) => {
|
|
1047
|
+
function t(e) {
|
|
1048
|
+
let t = a.hotkey.every((t) => e[t] || e.code === t), n = Array.isArray(k.value) ? k.value[0] : k.value;
|
|
1049
|
+
t && (m.value.forEach((e) => {
|
|
1050
|
+
C.value[e] = !0;
|
|
1051
|
+
}), n?.focus());
|
|
1052
|
+
let r = document.activeElement === k.value || n?.contains(document.activeElement);
|
|
1053
|
+
e.code === "Escape" && r && m.value.forEach((e) => {
|
|
1054
|
+
C.value[e] = !1;
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
Qe && (document.addEventListener("keydown", t), e(() => {
|
|
1058
|
+
document.removeEventListener("keydown", t);
|
|
1059
|
+
}));
|
|
1060
|
+
});
|
|
1061
|
+
function L(e) {
|
|
1062
|
+
let t = e.currentTarget, n = t.getAttribute("data-y-position") + "-" + t.getAttribute("data-x-position");
|
|
1063
|
+
C.value[n] = !0;
|
|
1064
|
+
}
|
|
1065
|
+
function te(e) {
|
|
1066
|
+
if (!w.value) {
|
|
1067
|
+
let t = e.currentTarget, n = t.getAttribute("data-y-position") + "-" + t.getAttribute("data-x-position");
|
|
1068
|
+
C.value[n] = !1;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
function R() {
|
|
1072
|
+
Object.keys(C.value).forEach((e) => {
|
|
1073
|
+
C.value[e] = !1;
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
function z() {
|
|
1077
|
+
w.value = !1;
|
|
1078
|
+
}
|
|
1079
|
+
function B(e) {
|
|
1080
|
+
_.value = e;
|
|
1081
|
+
}
|
|
1082
|
+
function ne(e) {
|
|
1083
|
+
let t = _.value.findIndex((t) => t.toastId === e.toastId);
|
|
1084
|
+
if (t !== -1) _.value[t] = e;
|
|
1085
|
+
else {
|
|
1086
|
+
let t = _.value.findIndex((t) => t.position === e.position);
|
|
1087
|
+
t === -1 ? _.value.unshift(e) : _.value.splice(t, 0, e);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
return (t, s) => (v(), i("section", {
|
|
1091
|
+
"aria-label": `${r.containerAriaLabel} ${T(M)}`,
|
|
1092
|
+
tabIndex: -1,
|
|
1093
|
+
"aria-live": "polite",
|
|
1094
|
+
"aria-relevant": "additions text",
|
|
1095
|
+
"aria-atomic": "false"
|
|
1096
|
+
}, [(v(!0), i(e, null, b(m.value, (s, l) => (v(), i("ol", d({
|
|
1097
|
+
key: s,
|
|
1098
|
+
ref_for: !0,
|
|
1099
|
+
ref_key: "listRef",
|
|
1100
|
+
ref: k,
|
|
1101
|
+
"data-sonner-toaster": "",
|
|
1102
|
+
"data-sonner-theme": ee.value,
|
|
1103
|
+
class: a.class,
|
|
1104
|
+
dir: r.dir === "auto" ? $e() : r.dir,
|
|
1105
|
+
tabIndex: -1,
|
|
1106
|
+
"data-theme": r.theme,
|
|
1107
|
+
"data-rich-colors": r.richColors,
|
|
1108
|
+
"data-y-position": s.split("-")[0],
|
|
1109
|
+
"data-x-position": s.split("-")[1],
|
|
1110
|
+
style: {
|
|
1111
|
+
"--front-toast-height": `${_.value[0]?.height || 0}px`,
|
|
1112
|
+
"--width": `${T(356)}px`,
|
|
1113
|
+
"--gap": `${r.gap}px`,
|
|
1114
|
+
...r.style,
|
|
1115
|
+
...T(o).style,
|
|
1116
|
+
...T(Ce)(r.offset, r.mobileOffset)
|
|
1117
|
+
}
|
|
1118
|
+
}, { ref_for: !0 }, t.$attrs, {
|
|
1119
|
+
onBlur: P,
|
|
1120
|
+
onFocus: F,
|
|
1121
|
+
onMouseenter: L,
|
|
1122
|
+
onMousemove: L,
|
|
1123
|
+
onMouseleave: te,
|
|
1124
|
+
onDragend: R,
|
|
1125
|
+
onPointerdown: I,
|
|
1126
|
+
onPointerup: z
|
|
1127
|
+
}), [(v(!0), i(e, null, b(u(s, l), (e, i) => (v(), n(Ee, {
|
|
1128
|
+
key: e.id,
|
|
1129
|
+
heights: _.value,
|
|
1130
|
+
icons: r.icons,
|
|
1131
|
+
index: i,
|
|
1132
|
+
toast: e,
|
|
1133
|
+
defaultRichColors: r.richColors,
|
|
1134
|
+
duration: r.toastOptions?.duration ?? r.duration,
|
|
1135
|
+
class: p(r.toastOptions?.class ?? ""),
|
|
1136
|
+
descriptionClass: r.toastOptions?.descriptionClass,
|
|
1137
|
+
invert: r.invert,
|
|
1138
|
+
visibleToasts: r.visibleToasts,
|
|
1139
|
+
closeButton: r.toastOptions?.closeButton ?? r.closeButton,
|
|
1140
|
+
interacting: w.value,
|
|
1141
|
+
position: s,
|
|
1142
|
+
closeButtonPosition: r.toastOptions?.closeButtonPosition ?? r.closeButtonPosition,
|
|
1143
|
+
style: h(r.toastOptions?.style),
|
|
1144
|
+
unstyled: r.toastOptions?.unstyled,
|
|
1145
|
+
classes: r.toastOptions?.classes,
|
|
1146
|
+
cancelButtonStyle: r.toastOptions?.cancelButtonStyle,
|
|
1147
|
+
actionButtonStyle: r.toastOptions?.actionButtonStyle,
|
|
1148
|
+
"close-button-aria-label": r.toastOptions?.closeButtonAriaLabel,
|
|
1149
|
+
toasts: g.value[s],
|
|
1150
|
+
expandByDefault: r.expand,
|
|
1151
|
+
gap: r.gap,
|
|
1152
|
+
expanded: C.value[s] || !1,
|
|
1153
|
+
swipeDirections: a.swipeDirections,
|
|
1154
|
+
"onUpdate:heights": B,
|
|
1155
|
+
"onUpdate:height": ne,
|
|
1156
|
+
onRemoveToast: N
|
|
1157
|
+
}, {
|
|
1158
|
+
"close-icon": O(() => [x(t.$slots, "close-icon", {}, () => [c(Ae)])]),
|
|
1159
|
+
"loading-icon": O(() => [r.icons?.loading ? (v(), n(S(r.icons.loading), { key: 0 })) : x(t.$slots, "loading-icon", { key: 1 }, () => [c(Ne, { visible: e.type === "loading" }, null, 8, ["visible"])])]),
|
|
1160
|
+
"success-icon": O(() => [r.icons?.success ? (v(), n(S(r.icons.success), { key: 0 })) : x(t.$slots, "success-icon", { key: 1 }, () => [c(Le)])]),
|
|
1161
|
+
"error-icon": O(() => [r.icons?.error ? (v(), n(S(r.icons.error), { key: 0 })) : x(t.$slots, "error-icon", { key: 1 }, () => [c(Ye)])]),
|
|
1162
|
+
"warning-icon": O(() => [r.icons?.warning ? (v(), n(S(r.icons.warning), { key: 0 })) : x(t.$slots, "warning-icon", { key: 1 }, () => [c(Ge)])]),
|
|
1163
|
+
"info-icon": O(() => [r.icons?.info ? (v(), n(S(r.icons.info), { key: 0 })) : x(t.$slots, "info-icon", { key: 1 }, () => [c(Ve)])]),
|
|
1164
|
+
_: 2
|
|
1165
|
+
}, 1032, [
|
|
1166
|
+
"heights",
|
|
1167
|
+
"icons",
|
|
1168
|
+
"index",
|
|
1169
|
+
"toast",
|
|
1170
|
+
"defaultRichColors",
|
|
1171
|
+
"duration",
|
|
1172
|
+
"class",
|
|
1173
|
+
"descriptionClass",
|
|
1174
|
+
"invert",
|
|
1175
|
+
"visibleToasts",
|
|
1176
|
+
"closeButton",
|
|
1177
|
+
"interacting",
|
|
1178
|
+
"position",
|
|
1179
|
+
"closeButtonPosition",
|
|
1180
|
+
"style",
|
|
1181
|
+
"unstyled",
|
|
1182
|
+
"classes",
|
|
1183
|
+
"cancelButtonStyle",
|
|
1184
|
+
"actionButtonStyle",
|
|
1185
|
+
"close-button-aria-label",
|
|
1186
|
+
"toasts",
|
|
1187
|
+
"expandByDefault",
|
|
1188
|
+
"gap",
|
|
1189
|
+
"expanded",
|
|
1190
|
+
"swipeDirections"
|
|
1191
|
+
]))), 128))], 16, Ze))), 128))], 8, Xe));
|
|
1192
|
+
}
|
|
1193
|
+
}), tt = 0, nt = !1;
|
|
1194
|
+
function rt() {
|
|
1195
|
+
return tt += 1, () => {
|
|
1196
|
+
tt = Math.max(0, tt - 1);
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
function it() {
|
|
1200
|
+
tt > 0 || nt || typeof console > "u" || (nt = !0, console.warn("[vue-smart-toast] Render <Toaster /> once before calling toast()."));
|
|
1201
|
+
}
|
|
1202
|
+
//#endregion
|
|
1203
|
+
//#region src/Toaster.vue
|
|
1204
|
+
var at = /* @__PURE__ */ l({
|
|
1205
|
+
name: "Toaster",
|
|
1206
|
+
__name: "Toaster",
|
|
1207
|
+
props: {
|
|
1208
|
+
id: String,
|
|
1209
|
+
invert: Boolean,
|
|
1210
|
+
theme: {
|
|
1211
|
+
type: String,
|
|
1212
|
+
default: "light"
|
|
1213
|
+
},
|
|
1214
|
+
position: {
|
|
1215
|
+
type: String,
|
|
1216
|
+
default: "bottom-right"
|
|
1217
|
+
},
|
|
1218
|
+
closeButtonPosition: {
|
|
1219
|
+
type: String,
|
|
1220
|
+
default: "top-left"
|
|
1221
|
+
},
|
|
1222
|
+
hotkey: {
|
|
1223
|
+
type: Array,
|
|
1224
|
+
default: () => ["altKey", "KeyT"]
|
|
1225
|
+
},
|
|
1226
|
+
richColors: Boolean,
|
|
1227
|
+
expand: Boolean,
|
|
1228
|
+
duration: Number,
|
|
1229
|
+
gap: Number,
|
|
1230
|
+
visibleToasts: Number,
|
|
1231
|
+
closeButton: Boolean,
|
|
1232
|
+
toastOptions: {
|
|
1233
|
+
type: Object,
|
|
1234
|
+
default: () => ({})
|
|
1235
|
+
},
|
|
1236
|
+
mobileToastOptions: {
|
|
1237
|
+
type: Object,
|
|
1238
|
+
default: () => ({})
|
|
1239
|
+
},
|
|
1240
|
+
class: String,
|
|
1241
|
+
style: Object,
|
|
1242
|
+
offset: [
|
|
1243
|
+
String,
|
|
1244
|
+
Number,
|
|
1245
|
+
Object
|
|
1246
|
+
],
|
|
1247
|
+
mobileOffset: [
|
|
1248
|
+
String,
|
|
1249
|
+
Number,
|
|
1250
|
+
Object
|
|
1251
|
+
],
|
|
1252
|
+
dir: {
|
|
1253
|
+
type: String,
|
|
1254
|
+
default: "auto"
|
|
1255
|
+
},
|
|
1256
|
+
swipeDirections: Array,
|
|
1257
|
+
icons: Object,
|
|
1258
|
+
containerAriaLabel: String
|
|
1259
|
+
},
|
|
1260
|
+
setup(t) {
|
|
1261
|
+
let n = t, r;
|
|
1262
|
+
return _(() => {
|
|
1263
|
+
r = rt();
|
|
1264
|
+
}), g(() => {
|
|
1265
|
+
r?.();
|
|
1266
|
+
}), (t, r) => (v(), i(e, null, [c(T(et), {
|
|
1267
|
+
id: n.id,
|
|
1268
|
+
invert: n.invert,
|
|
1269
|
+
theme: n.theme,
|
|
1270
|
+
position: n.position,
|
|
1271
|
+
"close-button-position": n.closeButtonPosition,
|
|
1272
|
+
hotkey: n.hotkey,
|
|
1273
|
+
"rich-colors": n.richColors,
|
|
1274
|
+
expand: n.expand,
|
|
1275
|
+
duration: n.duration,
|
|
1276
|
+
gap: n.gap,
|
|
1277
|
+
"visible-toasts": n.visibleToasts,
|
|
1278
|
+
"close-button": n.closeButton,
|
|
1279
|
+
"toast-options": n.toastOptions,
|
|
1280
|
+
class: p(n.class),
|
|
1281
|
+
style: h(n.style),
|
|
1282
|
+
offset: n.offset,
|
|
1283
|
+
"mobile-offset": n.mobileOffset,
|
|
1284
|
+
dir: n.dir,
|
|
1285
|
+
"swipe-directions": n.swipeDirections,
|
|
1286
|
+
icons: n.icons,
|
|
1287
|
+
"container-aria-label": n.containerAriaLabel
|
|
1288
|
+
}, o({ _: 2 }, [
|
|
1289
|
+
t.$slots["close-icon"] ? {
|
|
1290
|
+
name: "close-icon",
|
|
1291
|
+
fn: O(() => [x(t.$slots, "close-icon")]),
|
|
1292
|
+
key: "0"
|
|
1293
|
+
} : void 0,
|
|
1294
|
+
t.$slots["loading-icon"] ? {
|
|
1295
|
+
name: "loading-icon",
|
|
1296
|
+
fn: O(() => [x(t.$slots, "loading-icon")]),
|
|
1297
|
+
key: "1"
|
|
1298
|
+
} : void 0,
|
|
1299
|
+
t.$slots["success-icon"] ? {
|
|
1300
|
+
name: "success-icon",
|
|
1301
|
+
fn: O(() => [x(t.$slots, "success-icon")]),
|
|
1302
|
+
key: "2"
|
|
1303
|
+
} : void 0,
|
|
1304
|
+
t.$slots["error-icon"] ? {
|
|
1305
|
+
name: "error-icon",
|
|
1306
|
+
fn: O(() => [x(t.$slots, "error-icon")]),
|
|
1307
|
+
key: "3"
|
|
1308
|
+
} : void 0,
|
|
1309
|
+
t.$slots["warning-icon"] ? {
|
|
1310
|
+
name: "warning-icon",
|
|
1311
|
+
fn: O(() => [x(t.$slots, "warning-icon")]),
|
|
1312
|
+
key: "4"
|
|
1313
|
+
} : void 0,
|
|
1314
|
+
t.$slots["info-icon"] ? {
|
|
1315
|
+
name: "info-icon",
|
|
1316
|
+
fn: O(() => [x(t.$slots, "info-icon")]),
|
|
1317
|
+
key: "5"
|
|
1318
|
+
} : void 0
|
|
1319
|
+
]), 1032, [
|
|
1320
|
+
"id",
|
|
1321
|
+
"invert",
|
|
1322
|
+
"theme",
|
|
1323
|
+
"position",
|
|
1324
|
+
"close-button-position",
|
|
1325
|
+
"hotkey",
|
|
1326
|
+
"rich-colors",
|
|
1327
|
+
"expand",
|
|
1328
|
+
"duration",
|
|
1329
|
+
"gap",
|
|
1330
|
+
"visible-toasts",
|
|
1331
|
+
"close-button",
|
|
1332
|
+
"toast-options",
|
|
1333
|
+
"class",
|
|
1334
|
+
"style",
|
|
1335
|
+
"offset",
|
|
1336
|
+
"mobile-offset",
|
|
1337
|
+
"dir",
|
|
1338
|
+
"swipe-directions",
|
|
1339
|
+
"icons",
|
|
1340
|
+
"container-aria-label"
|
|
1341
|
+
]), c(_e, {
|
|
1342
|
+
toasts: T(R),
|
|
1343
|
+
"toast-options": n.mobileToastOptions
|
|
1344
|
+
}, o({ _: 2 }, [
|
|
1345
|
+
t.$slots["mobile-loading-icon"] ? {
|
|
1346
|
+
name: "loading-icon",
|
|
1347
|
+
fn: O(() => [x(t.$slots, "mobile-loading-icon")]),
|
|
1348
|
+
key: "0"
|
|
1349
|
+
} : void 0,
|
|
1350
|
+
t.$slots["mobile-success-icon"] ? {
|
|
1351
|
+
name: "success-icon",
|
|
1352
|
+
fn: O(() => [x(t.$slots, "mobile-success-icon")]),
|
|
1353
|
+
key: "1"
|
|
1354
|
+
} : void 0,
|
|
1355
|
+
t.$slots["mobile-error-icon"] ? {
|
|
1356
|
+
name: "error-icon",
|
|
1357
|
+
fn: O(() => [x(t.$slots, "mobile-error-icon")]),
|
|
1358
|
+
key: "2"
|
|
1359
|
+
} : void 0,
|
|
1360
|
+
t.$slots["mobile-warning-icon"] ? {
|
|
1361
|
+
name: "warning-icon",
|
|
1362
|
+
fn: O(() => [x(t.$slots, "mobile-warning-icon")]),
|
|
1363
|
+
key: "3"
|
|
1364
|
+
} : void 0,
|
|
1365
|
+
t.$slots["mobile-info-icon"] ? {
|
|
1366
|
+
name: "info-icon",
|
|
1367
|
+
fn: O(() => [x(t.$slots, "mobile-info-icon")]),
|
|
1368
|
+
key: "4"
|
|
1369
|
+
} : void 0
|
|
1370
|
+
]), 1032, ["toasts", "toast-options"])], 64));
|
|
1371
|
+
}
|
|
1372
|
+
});
|
|
1373
|
+
//#endregion
|
|
1374
|
+
//#region src/index.ts
|
|
1375
|
+
function Z(e) {
|
|
1376
|
+
if (it(), N(e.device) === "mobile") return ie({
|
|
1377
|
+
...e,
|
|
1378
|
+
device: "mobile"
|
|
1379
|
+
});
|
|
1380
|
+
let t = e.type === "loading" ? "loading" : F(e.type), n = {
|
|
1381
|
+
id: e.id,
|
|
1382
|
+
description: e.description,
|
|
1383
|
+
duration: e.duration,
|
|
1384
|
+
position: e.pcPosition ?? e.position,
|
|
1385
|
+
dismissible: e.dismissible,
|
|
1386
|
+
action: e.action,
|
|
1387
|
+
cancel: e.cancel,
|
|
1388
|
+
onDismiss: e.onDismiss,
|
|
1389
|
+
onAutoClose: e.onAutoClose,
|
|
1390
|
+
icon: e.icon,
|
|
1391
|
+
class: e.class,
|
|
1392
|
+
style: e.style,
|
|
1393
|
+
descriptionClass: e.descriptionClass,
|
|
1394
|
+
cancelButtonStyle: e.cancelButtonStyle,
|
|
1395
|
+
actionButtonStyle: e.actionButtonStyle,
|
|
1396
|
+
unstyled: e.unstyled,
|
|
1397
|
+
classes: e.classes,
|
|
1398
|
+
closeButtonAriaLabel: e.closeButtonAriaLabel,
|
|
1399
|
+
closeButtonPosition: e.closeButtonPosition,
|
|
1400
|
+
important: e.important,
|
|
1401
|
+
richColors: e.richColors,
|
|
1402
|
+
closeButton: e.closeButton,
|
|
1403
|
+
toasterId: e.toasterId
|
|
1404
|
+
}, r = String(e.message ?? "");
|
|
1405
|
+
return t === "success" ? K.success(r, n) : t === "info" ? K.info(r, n) : t === "warning" ? K.warning(r, n) : t === "error" ? K.error(r, n) : t === "loading" ? K.loading(r, n) : K(r, n);
|
|
1406
|
+
}
|
|
1407
|
+
function Q(e) {
|
|
1408
|
+
return (t, n) => Z({
|
|
1409
|
+
...n,
|
|
1410
|
+
message: t,
|
|
1411
|
+
type: e
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
function ot(e, t) {
|
|
1415
|
+
return typeof e == "function" ? e(t) : e;
|
|
1416
|
+
}
|
|
1417
|
+
function st(e) {
|
|
1418
|
+
let { loading: t, success: n, error: r, description: i, finally: a, ...o } = e;
|
|
1419
|
+
return o;
|
|
1420
|
+
}
|
|
1421
|
+
var $ = ((e, t) => Z({
|
|
1422
|
+
...t,
|
|
1423
|
+
message: e,
|
|
1424
|
+
type: t?.type ?? "default"
|
|
1425
|
+
}));
|
|
1426
|
+
$.message = Q("default"), $.success = Q("success"), $.info = Q("info"), $.warning = Q("warning"), $.error = Q("error"), $.fail = Q("fail"), $.dismiss = (e) => {
|
|
1427
|
+
V(e), K.dismiss(e);
|
|
1428
|
+
}, $.clear = () => {
|
|
1429
|
+
H(), K.dismiss();
|
|
1430
|
+
}, $.promise = (e, t = {}) => {
|
|
1431
|
+
if (!t.loading && !t.success && !t.error) return;
|
|
1432
|
+
let n = st(t), r = t.loading ? Z({
|
|
1433
|
+
...n,
|
|
1434
|
+
message: t.loading,
|
|
1435
|
+
type: "loading",
|
|
1436
|
+
duration: Infinity
|
|
1437
|
+
}) : t.id;
|
|
1438
|
+
return (typeof e == "function" ? e() : e).then((e) => {
|
|
1439
|
+
let i = ot(t.success, e), a = ot(t.description, e);
|
|
1440
|
+
return i !== void 0 && r !== void 0 && Z({
|
|
1441
|
+
...n,
|
|
1442
|
+
id: r,
|
|
1443
|
+
message: i,
|
|
1444
|
+
description: a,
|
|
1445
|
+
type: "success",
|
|
1446
|
+
duration: t.duration
|
|
1447
|
+
}), e;
|
|
1448
|
+
}).catch((e) => {
|
|
1449
|
+
let i = ot(t.error, e);
|
|
1450
|
+
i !== void 0 && r !== void 0 && Z({
|
|
1451
|
+
...n,
|
|
1452
|
+
id: r,
|
|
1453
|
+
message: i,
|
|
1454
|
+
type: "error",
|
|
1455
|
+
duration: t.duration
|
|
1456
|
+
});
|
|
1457
|
+
}).finally(() => {
|
|
1458
|
+
t.finally?.();
|
|
1459
|
+
}), r;
|
|
1460
|
+
};
|
|
1461
|
+
var ct = { install(e) {
|
|
1462
|
+
e.component("Toaster", at), e.config.globalProperties.$toast = $, e.provide("toast", $);
|
|
1463
|
+
} };
|
|
1464
|
+
function lt(e) {
|
|
1465
|
+
return Z(e);
|
|
1466
|
+
}
|
|
1467
|
+
var ut = lt;
|
|
1468
|
+
//#endregion
|
|
1469
|
+
export { at as Toaster, ct as default, ae as destroyStore, V as dismissToast, ut as showToast, lt as showToastOptions, $ as toast };
|