@editora/toast 2.0.8 → 2.0.9
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/CHANGELOG.md +6 -0
- package/README.md +22 -2
- package/dist/core/ToastManager.d.ts +1 -0
- package/dist/core/ToastRenderer.d.ts +1 -1
- package/dist/core/safeHtml.d.ts +4 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +422 -318
- package/dist/index.umd.js +1 -1
- package/dist/toast.css +8 -0
- package/package.json +7 -6
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class z {
|
|
2
2
|
constructor(t) {
|
|
3
3
|
this.toasts = /* @__PURE__ */ new Map(), this.groups = /* @__PURE__ */ new Map(), this.containers = /* @__PURE__ */ new Map(), this.config = { ...t };
|
|
4
4
|
}
|
|
@@ -26,8 +26,7 @@ class A {
|
|
|
26
26
|
// Group management
|
|
27
27
|
updateGroup(t) {
|
|
28
28
|
const e = t.options.group;
|
|
29
|
-
if (!e)
|
|
30
|
-
return;
|
|
29
|
+
if (!e) return;
|
|
31
30
|
let s = this.groups.get(e);
|
|
32
31
|
s || (s = { id: e, toasts: [] }, this.groups.set(e, s)), s.toasts = s.toasts.filter((i) => i.id !== t.id), t.options.group === e && s.toasts.push(t), s.toasts.length === 0 && this.groups.delete(e);
|
|
33
32
|
}
|
|
@@ -75,19 +74,19 @@ class A {
|
|
|
75
74
|
};
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
|
-
class
|
|
77
|
+
class N {
|
|
79
78
|
constructor(t) {
|
|
80
79
|
this.queue = [], this.visible = [], this.config = this.normalizeConfig(t);
|
|
81
80
|
}
|
|
82
81
|
enqueue(t) {
|
|
83
|
-
var
|
|
82
|
+
var o;
|
|
84
83
|
const e = this.findDuplicate(t);
|
|
85
|
-
if (e && ((
|
|
84
|
+
if (e && ((o = t.options.preventDuplicate) != null ? o : this.config.preventDuplicate))
|
|
86
85
|
return { show: [], hide: [], rejected: e };
|
|
87
86
|
const s = [];
|
|
88
87
|
if (t.options.important && this.visible.length >= this.maxVisible) {
|
|
89
|
-
const
|
|
90
|
-
return this.visible.push(t), { show: [t], hide:
|
|
88
|
+
const r = this.removeLowestPriorityVisible();
|
|
89
|
+
return this.visible.push(t), { show: [t], hide: r ? [...s, r] : s };
|
|
91
90
|
}
|
|
92
91
|
this.config.queueStrategy === "fifo" ? this.queue.push(t) : this.queue.unshift(t), this.sortQueue();
|
|
93
92
|
const i = this.processQueue();
|
|
@@ -123,15 +122,13 @@ class M {
|
|
|
123
122
|
}
|
|
124
123
|
for (; this.visible.length < this.maxVisible && this.queue.length > 0; ) {
|
|
125
124
|
const s = this.queue.shift();
|
|
126
|
-
if (!s)
|
|
127
|
-
break;
|
|
125
|
+
if (!s) break;
|
|
128
126
|
this.visible.push(s), t.push(s);
|
|
129
127
|
}
|
|
130
128
|
return { show: t, hide: e };
|
|
131
129
|
}
|
|
132
130
|
removeLowestPriorityVisible() {
|
|
133
|
-
if (this.visible.length === 0)
|
|
134
|
-
return;
|
|
131
|
+
if (this.visible.length === 0) return;
|
|
135
132
|
let t = 0;
|
|
136
133
|
for (let e = 1; e < this.visible.length; e += 1)
|
|
137
134
|
(this.visible[e].options.priority || 0) < (this.visible[t].options.priority || 0) && (t = e);
|
|
@@ -147,7 +144,7 @@ class M {
|
|
|
147
144
|
}
|
|
148
145
|
findDuplicate(t) {
|
|
149
146
|
const e = t.options.dedupeScope || this.config.dedupeScope, s = e === "visible" ? this.visible : e === "queue" ? this.queue : [...this.visible, ...this.queue], i = this.getDedupeKey(t);
|
|
150
|
-
return s.find((
|
|
147
|
+
return s.find((o) => this.getDedupeKey(o) === i);
|
|
151
148
|
}
|
|
152
149
|
getDedupeKey(t) {
|
|
153
150
|
return t.options.dedupeKey || `${t.options.level || "info"}:${t.options.title || ""}:${t.options.message || ""}:${t.options.description || ""}`;
|
|
@@ -168,45 +165,127 @@ class M {
|
|
|
168
165
|
};
|
|
169
166
|
}
|
|
170
167
|
}
|
|
171
|
-
|
|
168
|
+
const F = /* @__PURE__ */ new Set([
|
|
169
|
+
"a",
|
|
170
|
+
"b",
|
|
171
|
+
"strong",
|
|
172
|
+
"i",
|
|
173
|
+
"em",
|
|
174
|
+
"u",
|
|
175
|
+
"s",
|
|
176
|
+
"del",
|
|
177
|
+
"ins",
|
|
178
|
+
"mark",
|
|
179
|
+
"small",
|
|
180
|
+
"sub",
|
|
181
|
+
"sup",
|
|
182
|
+
"code",
|
|
183
|
+
"kbd",
|
|
184
|
+
"br",
|
|
185
|
+
"span",
|
|
186
|
+
"p",
|
|
187
|
+
"ul",
|
|
188
|
+
"ol",
|
|
189
|
+
"li"
|
|
190
|
+
]), I = /* @__PURE__ */ new Set([
|
|
191
|
+
"script",
|
|
192
|
+
"style",
|
|
193
|
+
"iframe",
|
|
194
|
+
"frame",
|
|
195
|
+
"frameset",
|
|
196
|
+
"object",
|
|
197
|
+
"embed",
|
|
198
|
+
"applet",
|
|
199
|
+
"noscript",
|
|
200
|
+
"template",
|
|
201
|
+
"svg",
|
|
202
|
+
"math",
|
|
203
|
+
"form",
|
|
204
|
+
"input",
|
|
205
|
+
"button",
|
|
206
|
+
"textarea",
|
|
207
|
+
"select",
|
|
208
|
+
"option",
|
|
209
|
+
"head",
|
|
210
|
+
"title",
|
|
211
|
+
"link",
|
|
212
|
+
"meta",
|
|
213
|
+
"base",
|
|
214
|
+
"audio",
|
|
215
|
+
"video",
|
|
216
|
+
"canvas"
|
|
217
|
+
]), Y = /^(?:https?:|mailto:|tel:)/i;
|
|
218
|
+
function V(c) {
|
|
219
|
+
const t = c.replace(/[\u0000- \u007f-\u009f]/g, "");
|
|
220
|
+
return t ? Y.test(t) ? !0 : !/^[a-z][a-z0-9+.-]*:/i.test(t) : !1;
|
|
221
|
+
}
|
|
222
|
+
function H(c, t, e) {
|
|
223
|
+
for (const s of Array.from(c.childNodes)) {
|
|
224
|
+
if (s.nodeType === Node.TEXT_NODE) {
|
|
225
|
+
t.appendChild(e.createTextNode(s.textContent || ""));
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (s.nodeType !== Node.ELEMENT_NODE) continue;
|
|
229
|
+
const i = s, o = i.localName.toLowerCase();
|
|
230
|
+
if (I.has(o)) continue;
|
|
231
|
+
if (!F.has(o)) {
|
|
232
|
+
H(i, t, e);
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const r = e.createElement(o);
|
|
236
|
+
if (o === "a") {
|
|
237
|
+
const n = i.getAttribute("href");
|
|
238
|
+
n && V(n) && (r.setAttribute("href", n.trim()), /^(?:https?:)?\/\//i.test(n.trim()) && (r.setAttribute("target", "_blank"), r.setAttribute("rel", "noopener noreferrer")));
|
|
239
|
+
const a = i.getAttribute("title");
|
|
240
|
+
a && r.setAttribute("title", a);
|
|
241
|
+
}
|
|
242
|
+
H(i, r, e), t.appendChild(r);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function X(c, t) {
|
|
246
|
+
const e = document.createElement("template");
|
|
247
|
+
e.innerHTML = t;
|
|
248
|
+
const s = document.createDocumentFragment();
|
|
249
|
+
H(e.content, s, document), c.textContent = "", c.appendChild(s);
|
|
250
|
+
}
|
|
251
|
+
class j {
|
|
172
252
|
constructor(t = {}) {
|
|
173
|
-
var e, s, i,
|
|
253
|
+
var e, s, i, o;
|
|
174
254
|
this.config = {
|
|
175
255
|
stiffness: (e = t.stiffness) != null ? e : 100,
|
|
176
256
|
damping: (s = t.damping) != null ? s : 10,
|
|
177
257
|
mass: (i = t.mass) != null ? i : 1,
|
|
178
|
-
precision: (
|
|
258
|
+
precision: (o = t.precision) != null ? o : 0.01
|
|
179
259
|
};
|
|
180
260
|
}
|
|
181
261
|
// Spring animation function
|
|
182
|
-
animate(t, e, s, i,
|
|
183
|
-
const
|
|
262
|
+
animate(t, e, s, i, o) {
|
|
263
|
+
const r = {
|
|
184
264
|
...this.config,
|
|
185
|
-
...
|
|
265
|
+
...o
|
|
186
266
|
};
|
|
187
|
-
let
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
h[y] += E * 0.016, d[y] += h[y] * 0.016, (Math.abs(m - b) > o.precision || Math.abs(w) > o.precision) && (p = !1);
|
|
267
|
+
let n, a = !1;
|
|
268
|
+
const l = Object.keys(e).reduce((u, P) => (u[P] = e[P].from, u), {}), d = Object.keys(e).reduce((u, P) => (u[P] = 0, u), {}), f = () => {
|
|
269
|
+
if (a) return;
|
|
270
|
+
let u = !0;
|
|
271
|
+
Object.keys(e).forEach((w) => {
|
|
272
|
+
const v = e[w].to, S = l[w], p = d[w], y = -r.stiffness * (S - v), m = -r.damping * p, T = (y + m) / r.mass;
|
|
273
|
+
d[w] += T * 0.016, l[w] += d[w] * 0.016, (Math.abs(S - v) > r.precision || Math.abs(p) > r.precision) && (u = !1);
|
|
195
274
|
});
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
return
|
|
275
|
+
const P = Object.keys(l).reduce((w, v) => {
|
|
276
|
+
const S = e[v].unit || "px";
|
|
277
|
+
return w[v] = `${l[v]}${S}`, w;
|
|
199
278
|
}, {});
|
|
200
|
-
s(
|
|
279
|
+
s(P), u ? (a = !0, i == null || i()) : n = requestAnimationFrame(f);
|
|
201
280
|
};
|
|
202
|
-
return
|
|
203
|
-
|
|
281
|
+
return n = requestAnimationFrame(f), () => {
|
|
282
|
+
a = !0, n && cancelAnimationFrame(n);
|
|
204
283
|
};
|
|
205
284
|
}
|
|
206
285
|
}
|
|
207
|
-
class
|
|
286
|
+
class W {
|
|
208
287
|
constructor() {
|
|
209
|
-
this.springAnimation = new
|
|
288
|
+
this.springAnimation = new j();
|
|
210
289
|
}
|
|
211
290
|
// Show toast with specified animation
|
|
212
291
|
async showToast(t, e, s) {
|
|
@@ -238,7 +317,6 @@ class z {
|
|
|
238
317
|
case "custom":
|
|
239
318
|
s.show ? await Promise.resolve(s.show(t, e)) : await this.animateCssShow(t);
|
|
240
319
|
break;
|
|
241
|
-
case "css":
|
|
242
320
|
default:
|
|
243
321
|
await this.animateCssShow(t);
|
|
244
322
|
break;
|
|
@@ -274,7 +352,6 @@ class z {
|
|
|
274
352
|
case "custom":
|
|
275
353
|
s.hide ? await Promise.resolve(s.hide(t, e)) : await this.animateCssHide(t);
|
|
276
354
|
break;
|
|
277
|
-
case "css":
|
|
278
355
|
default:
|
|
279
356
|
await this.animateCssHide(t);
|
|
280
357
|
break;
|
|
@@ -301,10 +378,10 @@ class z {
|
|
|
301
378
|
// Spring-based show animation
|
|
302
379
|
async animateSpringShow(t, e) {
|
|
303
380
|
return new Promise((s) => {
|
|
304
|
-
var
|
|
381
|
+
var r, n, a;
|
|
305
382
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important"), t.style.setProperty("-webkit-transition", "none", "important");
|
|
306
|
-
const
|
|
307
|
-
t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `translateY(${
|
|
383
|
+
const o = ((r = t.parentElement) == null ? void 0 : r.classList.contains("editora-toast-bottom-right")) || ((n = t.parentElement) == null ? void 0 : n.classList.contains("editora-toast-bottom-left")) || ((a = t.parentElement) == null ? void 0 : a.classList.contains("editora-toast-bottom-center")) ? 20 : -20;
|
|
384
|
+
t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `translateY(${o}px) scale(0.95)`, "important"), t.offsetHeight, setTimeout(() => {
|
|
308
385
|
t.style.setProperty("transition", "opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1)", "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) scale(1)", "important"), setTimeout(() => {
|
|
309
386
|
t.style.setProperty("transition", "none", "important"), s();
|
|
310
387
|
}, 800);
|
|
@@ -324,21 +401,21 @@ class z {
|
|
|
324
401
|
// Bounce-based show animation
|
|
325
402
|
async animateBounceShow(t, e) {
|
|
326
403
|
return new Promise((s) => {
|
|
327
|
-
var
|
|
404
|
+
var d, f, u;
|
|
328
405
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
329
|
-
const i = ((
|
|
406
|
+
const i = ((d = t.parentElement) == null ? void 0 : d.classList.contains("editora-toast-bottom-right")) || ((f = t.parentElement) == null ? void 0 : f.classList.contains("editora-toast-bottom-left")) || ((u = t.parentElement) == null ? void 0 : u.classList.contains("editora-toast-bottom-center")), o = e.direction || (i ? "up" : "down"), r = e.intensity || "normal", n = e.duration || 800, a = r === "gentle" ? 0.05 : r === "strong" ? 0.15 : 0.1, l = o === "up" ? 30 : o === "down" ? -30 : o === "left" ? 30 : -30;
|
|
330
407
|
t.style.setProperty("opacity", "0", "important"), t.style.setProperty(
|
|
331
408
|
"transform",
|
|
332
|
-
|
|
409
|
+
o === "left" || o === "right" ? `translateX(${l}px) scale(${1 - a})` : `translateY(${l}px) scale(${1 - a})`,
|
|
333
410
|
"important"
|
|
334
411
|
), t.offsetHeight, setTimeout(() => {
|
|
335
412
|
t.style.setProperty(
|
|
336
413
|
"transition",
|
|
337
|
-
`opacity ${
|
|
414
|
+
`opacity ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,
|
|
338
415
|
"important"
|
|
339
416
|
), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) scale(1)", "important"), setTimeout(() => {
|
|
340
417
|
t.style.setProperty("transition", "none", "important"), s();
|
|
341
|
-
},
|
|
418
|
+
}, n);
|
|
342
419
|
}, 16);
|
|
343
420
|
});
|
|
344
421
|
}
|
|
@@ -346,9 +423,9 @@ class z {
|
|
|
346
423
|
async animateBounceHide(t, e) {
|
|
347
424
|
return new Promise((s) => {
|
|
348
425
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
349
|
-
const i = e.intensity || "normal",
|
|
426
|
+
const i = e.intensity || "normal", o = i === "gentle" ? 0.05 : i === "strong" ? 0.15 : 0.1;
|
|
350
427
|
setTimeout(() => {
|
|
351
|
-
t.style.setProperty("transition", "opacity 0.4s ease, transform 0.4s ease", "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${1 -
|
|
428
|
+
t.style.setProperty("transition", "opacity 0.4s ease, transform 0.4s ease", "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${1 - o})`, "important"), setTimeout(() => {
|
|
352
429
|
t.style.setProperty("transition", "none", "important"), s();
|
|
353
430
|
}, 400);
|
|
354
431
|
}, 16);
|
|
@@ -357,13 +434,13 @@ class z {
|
|
|
357
434
|
// Slide-based show animation
|
|
358
435
|
async animateSlideShow(t, e) {
|
|
359
436
|
return new Promise((s) => {
|
|
360
|
-
var
|
|
437
|
+
var d, f, u;
|
|
361
438
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
362
|
-
const i = ((
|
|
363
|
-
t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform",
|
|
364
|
-
t.style.setProperty("transition", `opacity ${
|
|
439
|
+
const i = ((d = t.parentElement) == null ? void 0 : d.classList.contains("editora-toast-bottom-right")) || ((f = t.parentElement) == null ? void 0 : f.classList.contains("editora-toast-bottom-left")) || ((u = t.parentElement) == null ? void 0 : u.classList.contains("editora-toast-bottom-center")), o = e.direction || (i ? "up" : "down"), r = e.distance || 100, n = e.easing || "ease-out", a = e.duration || 400, l = o === "up" ? `translateY(${r}px)` : o === "down" ? `translateY(-${r}px)` : o === "left" ? `translateX(${r}px)` : `translateX(-${r}px)`;
|
|
440
|
+
t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", l, "important"), t.offsetHeight, setTimeout(() => {
|
|
441
|
+
t.style.setProperty("transition", `opacity ${a}ms ${n}, transform ${a}ms ${n}`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) translateX(0)", "important"), setTimeout(() => {
|
|
365
442
|
t.style.setProperty("transition", "none", "important"), s();
|
|
366
|
-
},
|
|
443
|
+
}, a);
|
|
367
444
|
}, 16);
|
|
368
445
|
});
|
|
369
446
|
}
|
|
@@ -371,11 +448,11 @@ class z {
|
|
|
371
448
|
async animateSlideHide(t, e) {
|
|
372
449
|
return new Promise((s) => {
|
|
373
450
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
374
|
-
const i = e.direction || "down",
|
|
451
|
+
const i = e.direction || "down", o = e.distance || 100, r = e.easing || "ease-in", n = e.duration || 300, a = i === "up" ? `translateY(-${o}px)` : i === "down" ? `translateY(${o}px)` : i === "left" ? `translateX(-${o}px)` : `translateX(${o}px)`;
|
|
375
452
|
setTimeout(() => {
|
|
376
|
-
t.style.setProperty("transition", `opacity ${
|
|
453
|
+
t.style.setProperty("transition", `opacity ${n}ms ${r}, transform ${n}ms ${r}`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", a, "important"), setTimeout(() => {
|
|
377
454
|
t.style.setProperty("transition", "none", "important"), s();
|
|
378
|
-
},
|
|
455
|
+
}, n);
|
|
379
456
|
}, 16);
|
|
380
457
|
});
|
|
381
458
|
}
|
|
@@ -383,11 +460,11 @@ class z {
|
|
|
383
460
|
async animateZoomShow(t, e) {
|
|
384
461
|
return new Promise((s) => {
|
|
385
462
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
386
|
-
const i = e.scale || 0.3,
|
|
387
|
-
t.style.setProperty("transform-origin",
|
|
388
|
-
t.style.setProperty("transition", `opacity ${
|
|
463
|
+
const i = e.scale || 0.3, o = e.origin || "center", r = e.easing || "ease-out", n = e.duration || 500;
|
|
464
|
+
t.style.setProperty("transform-origin", o, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${i})`, "important"), t.offsetHeight, setTimeout(() => {
|
|
465
|
+
t.style.setProperty("transition", `opacity ${n}ms ${r}, transform ${n}ms ${r}`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "scale(1)", "important"), setTimeout(() => {
|
|
389
466
|
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), s();
|
|
390
|
-
},
|
|
467
|
+
}, n);
|
|
391
468
|
}, 16);
|
|
392
469
|
});
|
|
393
470
|
}
|
|
@@ -395,11 +472,11 @@ class z {
|
|
|
395
472
|
async animateZoomHide(t, e) {
|
|
396
473
|
return new Promise((s) => {
|
|
397
474
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
398
|
-
const i = e.scale || 0.3,
|
|
399
|
-
t.style.setProperty("transform-origin",
|
|
400
|
-
t.style.setProperty("transition", `opacity ${
|
|
475
|
+
const i = e.scale || 0.3, o = e.origin || "center", r = e.easing || "ease-in", n = e.duration || 300;
|
|
476
|
+
t.style.setProperty("transform-origin", o, "important"), setTimeout(() => {
|
|
477
|
+
t.style.setProperty("transition", `opacity ${n}ms ${r}, transform ${n}ms ${r}`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${i})`, "important"), setTimeout(() => {
|
|
401
478
|
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), s();
|
|
402
|
-
},
|
|
479
|
+
}, n);
|
|
403
480
|
}, 16);
|
|
404
481
|
});
|
|
405
482
|
}
|
|
@@ -407,13 +484,13 @@ class z {
|
|
|
407
484
|
async animateFlipShow(t, e) {
|
|
408
485
|
return new Promise((s) => {
|
|
409
486
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
410
|
-
const i = e.axis || "y",
|
|
411
|
-
t.style.setProperty("transform-style", "preserve-3d", "important"), t.parentElement.style.setProperty("perspective", `${
|
|
412
|
-
const
|
|
413
|
-
t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate${i.toUpperCase()}(${
|
|
414
|
-
t.style.setProperty("transition", `opacity ${
|
|
487
|
+
const i = e.axis || "y", o = e.perspective || 1e3, r = e.direction || "forward", n = e.duration || 600;
|
|
488
|
+
t.style.setProperty("transform-style", "preserve-3d", "important"), t.parentElement.style.setProperty("perspective", `${o}px`, "important");
|
|
489
|
+
const a = r === "forward" ? i === "x" ? -90 : 90 : i === "x" ? 90 : -90;
|
|
490
|
+
t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate${i.toUpperCase()}(${a}deg)`, "important"), t.offsetHeight, setTimeout(() => {
|
|
491
|
+
t.style.setProperty("transition", `opacity ${n}ms ease, transform ${n}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "rotateX(0deg) rotateY(0deg)", "important"), setTimeout(() => {
|
|
415
492
|
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-style", "", "important"), t.parentElement.style.setProperty("perspective", "", "important"), s();
|
|
416
|
-
},
|
|
493
|
+
}, n);
|
|
417
494
|
}, 16);
|
|
418
495
|
});
|
|
419
496
|
}
|
|
@@ -421,13 +498,13 @@ class z {
|
|
|
421
498
|
async animateFlipHide(t, e) {
|
|
422
499
|
return new Promise((s) => {
|
|
423
500
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
424
|
-
const i = e.axis || "y",
|
|
425
|
-
t.style.setProperty("transform-style", "preserve-3d", "important"), t.parentElement.style.setProperty("perspective", `${
|
|
426
|
-
const
|
|
501
|
+
const i = e.axis || "y", o = e.perspective || 1e3, r = e.direction || "backward", n = e.duration || 400;
|
|
502
|
+
t.style.setProperty("transform-style", "preserve-3d", "important"), t.parentElement.style.setProperty("perspective", `${o}px`, "important");
|
|
503
|
+
const a = r === "backward" ? i === "x" ? -90 : 90 : i === "x" ? 90 : -90;
|
|
427
504
|
setTimeout(() => {
|
|
428
|
-
t.style.setProperty("transition", `opacity ${
|
|
505
|
+
t.style.setProperty("transition", `opacity ${n}ms ease, transform ${n}ms ease-in`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate${i.toUpperCase()}(${a}deg)`, "important"), setTimeout(() => {
|
|
429
506
|
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-style", "", "important"), t.parentElement.style.setProperty("perspective", "", "important"), s();
|
|
430
|
-
},
|
|
507
|
+
}, n);
|
|
431
508
|
}, 16);
|
|
432
509
|
});
|
|
433
510
|
}
|
|
@@ -435,12 +512,12 @@ class z {
|
|
|
435
512
|
async animateFadeShow(t, e) {
|
|
436
513
|
return new Promise((s) => {
|
|
437
514
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
438
|
-
const i = e.direction || "none",
|
|
439
|
-
let
|
|
440
|
-
i !== "none" && (
|
|
441
|
-
t.style.setProperty("transition", `opacity ${
|
|
515
|
+
const i = e.direction || "none", o = e.distance || 20, r = e.duration || 300;
|
|
516
|
+
let n = "translateY(0) translateX(0)";
|
|
517
|
+
i !== "none" && (n = i === "up" ? `translateY(${o}px)` : i === "down" ? `translateY(-${o}px)` : i === "left" ? `translateX(${o}px)` : `translateX(-${o}px)`), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", n, "important"), t.offsetHeight, setTimeout(() => {
|
|
518
|
+
t.style.setProperty("transition", `opacity ${r}ms ease, transform ${r}ms ease`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) translateX(0)", "important"), setTimeout(() => {
|
|
442
519
|
t.style.setProperty("transition", "none", "important"), s();
|
|
443
|
-
},
|
|
520
|
+
}, r);
|
|
444
521
|
}, 16);
|
|
445
522
|
});
|
|
446
523
|
}
|
|
@@ -448,33 +525,33 @@ class z {
|
|
|
448
525
|
async animateFadeHide(t, e) {
|
|
449
526
|
return new Promise((s) => {
|
|
450
527
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
451
|
-
const i = e.direction || "none",
|
|
452
|
-
let
|
|
453
|
-
i !== "none" && (
|
|
454
|
-
t.style.setProperty("transition", `opacity ${
|
|
528
|
+
const i = e.direction || "none", o = e.distance || 20, r = e.duration || 200;
|
|
529
|
+
let n = "translateY(0) translateX(0)";
|
|
530
|
+
i !== "none" && (n = i === "up" ? `translateY(-${o}px)` : i === "down" ? `translateY(${o}px)` : i === "left" ? `translateX(-${o}px)` : `translateX(${o}px)`), setTimeout(() => {
|
|
531
|
+
t.style.setProperty("transition", `opacity ${r}ms ease, transform ${r}ms ease`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", n, "important"), setTimeout(() => {
|
|
455
532
|
t.style.setProperty("transition", "none", "important"), s();
|
|
456
|
-
},
|
|
533
|
+
}, r);
|
|
457
534
|
}, 16);
|
|
458
535
|
});
|
|
459
536
|
}
|
|
460
537
|
// Elastic-based show animation
|
|
461
538
|
async animateElasticShow(t, e) {
|
|
462
539
|
return new Promise((s) => {
|
|
463
|
-
var
|
|
540
|
+
var d, f, u;
|
|
464
541
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
465
|
-
const i = ((
|
|
542
|
+
const i = ((d = t.parentElement) == null ? void 0 : d.classList.contains("editora-toast-bottom-right")) || ((f = t.parentElement) == null ? void 0 : f.classList.contains("editora-toast-bottom-left")) || ((u = t.parentElement) == null ? void 0 : u.classList.contains("editora-toast-bottom-center")), o = e.direction || (i ? "up" : "down"), r = e.intensity || "normal", n = e.duration || 1e3, a = r === "gentle" ? 0.1 : r === "strong" ? 0.3 : 0.2, l = o === "up" ? 40 : o === "down" ? -40 : o === "left" ? 40 : -40;
|
|
466
543
|
t.style.setProperty("opacity", "0", "important"), t.style.setProperty(
|
|
467
544
|
"transform",
|
|
468
|
-
|
|
545
|
+
o === "left" || o === "right" ? `translateX(${l}px) scale(${1 + a})` : `translateY(${l}px) scale(${1 + a})`,
|
|
469
546
|
"important"
|
|
470
547
|
), t.offsetHeight, setTimeout(() => {
|
|
471
548
|
t.style.setProperty(
|
|
472
549
|
"transition",
|
|
473
|
-
`opacity ${
|
|
550
|
+
`opacity ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,
|
|
474
551
|
"important"
|
|
475
552
|
), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) scale(1)", "important"), setTimeout(() => {
|
|
476
553
|
t.style.setProperty("transition", "none", "important"), s();
|
|
477
|
-
},
|
|
554
|
+
}, n);
|
|
478
555
|
}, 16);
|
|
479
556
|
});
|
|
480
557
|
}
|
|
@@ -482,9 +559,9 @@ class z {
|
|
|
482
559
|
async animateElasticHide(t, e) {
|
|
483
560
|
return new Promise((s) => {
|
|
484
561
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
485
|
-
const i = e.intensity || "normal",
|
|
562
|
+
const i = e.intensity || "normal", o = i === "gentle" ? 0.1 : i === "strong" ? 0.3 : 0.2;
|
|
486
563
|
e.duration, setTimeout(() => {
|
|
487
|
-
t.style.setProperty("transition", "opacity 0.4s ease, transform 0.4s ease", "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${1 +
|
|
564
|
+
t.style.setProperty("transition", "opacity 0.4s ease, transform 0.4s ease", "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${1 + o})`, "important"), setTimeout(() => {
|
|
488
565
|
t.style.setProperty("transition", "none", "important"), s();
|
|
489
566
|
}, 400);
|
|
490
567
|
}, 16);
|
|
@@ -494,11 +571,11 @@ class z {
|
|
|
494
571
|
async animateRotateShow(t, e) {
|
|
495
572
|
return new Promise((s) => {
|
|
496
573
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
497
|
-
const i = e.degrees || 360,
|
|
498
|
-
t.style.setProperty("transform-origin",
|
|
499
|
-
t.style.setProperty("transition", `opacity ${
|
|
574
|
+
const i = e.degrees || 360, o = e.direction || "clockwise", r = e.origin || "center", n = e.duration || 500, a = o === "clockwise" ? i : -i;
|
|
575
|
+
t.style.setProperty("transform-origin", r, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate(${a}deg) scale(0.8)`, "important"), t.offsetHeight, setTimeout(() => {
|
|
576
|
+
t.style.setProperty("transition", `opacity ${n}ms ease, transform ${n}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "rotate(0deg) scale(1)", "important"), setTimeout(() => {
|
|
500
577
|
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), s();
|
|
501
|
-
},
|
|
578
|
+
}, n);
|
|
502
579
|
}, 16);
|
|
503
580
|
});
|
|
504
581
|
}
|
|
@@ -506,17 +583,17 @@ class z {
|
|
|
506
583
|
async animateRotateHide(t, e) {
|
|
507
584
|
return new Promise((s) => {
|
|
508
585
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
509
|
-
const i = e.degrees || 180,
|
|
510
|
-
t.style.setProperty("transform-origin",
|
|
511
|
-
t.style.setProperty("transition", `opacity ${
|
|
586
|
+
const i = e.degrees || 180, o = e.direction || "counterclockwise", r = e.origin || "center", n = e.duration || 300, a = o === "clockwise" ? i : -i;
|
|
587
|
+
t.style.setProperty("transform-origin", r, "important"), setTimeout(() => {
|
|
588
|
+
t.style.setProperty("transition", `opacity ${n}ms ease, transform ${n}ms ease-in`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate(${a}deg) scale(0.8)`, "important"), setTimeout(() => {
|
|
512
589
|
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), s();
|
|
513
|
-
},
|
|
590
|
+
}, n);
|
|
514
591
|
}, 16);
|
|
515
592
|
});
|
|
516
593
|
}
|
|
517
594
|
}
|
|
518
|
-
const
|
|
519
|
-
class
|
|
595
|
+
const L = new W();
|
|
596
|
+
class G {
|
|
520
597
|
constructor(t) {
|
|
521
598
|
this.containers = /* @__PURE__ */ new Map(), this.cssInjected = !1, this.config = t;
|
|
522
599
|
}
|
|
@@ -535,128 +612,131 @@ class O {
|
|
|
535
612
|
// Create toast element
|
|
536
613
|
createToastElement(t) {
|
|
537
614
|
const e = t.options, s = document.createElement("div");
|
|
538
|
-
s.className = `editora-toast editora-toast-${e.level || "info"}`, s.dataset.level = e.level || "info", e.customClass && e.customClass.split(/\s+/).filter(Boolean).forEach((
|
|
615
|
+
s.className = `editora-toast editora-toast-${e.level || "info"}`, s.dataset.level = e.level || "info", e.customClass && e.customClass.split(/\s+/).filter(Boolean).forEach((n) => s.classList.add(n)), s.setAttribute("role", e.role || (e.level === "error" ? "alert" : "status")), s.setAttribute("aria-atomic", "true"), e.ariaLive && e.ariaLive !== "off" && s.setAttribute("aria-live", e.ariaLive);
|
|
539
616
|
const i = e.theme || this.config.theme;
|
|
540
617
|
i && i !== "system" && s.setAttribute("data-theme", i), (this.config.richColors || i === "colored") && s.setAttribute("data-rich-colors", "true"), (e.rtl !== void 0 ? e.rtl : this.config.rtl) && (s.setAttribute("data-rtl", "true"), s.setAttribute("dir", "rtl"));
|
|
541
|
-
const
|
|
618
|
+
const r = this.createContent(t);
|
|
542
619
|
if (e.progress) {
|
|
620
|
+
const n = document.createElement("div");
|
|
621
|
+
n.className = "editora-toast-progress-track", n.setAttribute("role", "progressbar"), n.setAttribute("aria-valuemin", "0"), n.setAttribute("aria-valuemax", "100"), n.setAttribute("aria-valuenow", String(Math.min(100, Math.max(0, e.progress.value))));
|
|
543
622
|
const a = document.createElement("div");
|
|
544
|
-
a.className = "editora-toast-progress-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
const d = document.createElement("span");
|
|
548
|
-
d.className = "editora-toast-progress-text", d.textContent = `${Math.round(e.progress.value)}%`, a.appendChild(d);
|
|
623
|
+
if (a.className = "editora-toast-progress-bar", a.style.width = `${Math.min(100, Math.max(0, e.progress.value))}%`, e.progress.showPercentage) {
|
|
624
|
+
const l = document.createElement("span");
|
|
625
|
+
l.className = "editora-toast-progress-text", l.textContent = `${Math.round(e.progress.value)}%`, n.appendChild(l);
|
|
549
626
|
}
|
|
550
|
-
|
|
551
|
-
}
|
|
552
|
-
if (s.appendChild(o), e.actions && e.actions.length > 0) {
|
|
553
|
-
const a = document.createElement("div");
|
|
554
|
-
a.className = "editora-toast-actions", e.actions.forEach((c) => a.appendChild(this.createActionButton(c, t))), s.appendChild(a);
|
|
627
|
+
n.appendChild(a), r.appendChild(n);
|
|
555
628
|
}
|
|
556
|
-
if (e.
|
|
557
|
-
const
|
|
558
|
-
|
|
629
|
+
if (s.appendChild(r), e.actions && e.actions.length > 0) {
|
|
630
|
+
const n = document.createElement("div");
|
|
631
|
+
n.className = "editora-toast-actions", e.actions.forEach((a) => n.appendChild(this.createActionButton(a, t))), s.appendChild(n);
|
|
559
632
|
}
|
|
560
|
-
return e.pauseOnHover && (s.addEventListener("mouseenter", () => this.pauseToast(t)), s.addEventListener("mouseleave", () => this.resumeToast(t))), e.pauseOnFocus && (s.addEventListener("focusin", () => this.pauseToast(t)), s.addEventListener("focusout", () => this.resumeToast(t))), e.swipeDismiss && this.addSwipeDismiss(s, t), e.dragDismiss && this.addDragDismiss(s, t), s;
|
|
633
|
+
return (e.closable || e.closeButton) && s.appendChild(this.createCloseButton(t)), e.pauseOnHover && (s.addEventListener("mouseenter", () => this.pauseToast(t)), s.addEventListener("mouseleave", () => this.resumeToast(t))), e.pauseOnFocus && (s.addEventListener("focusin", () => this.pauseToast(t)), s.addEventListener("focusout", () => this.resumeToast(t))), e.swipeDismiss && this.addSwipeDismiss(s, t), e.dragDismiss && this.addDragDismiss(s, t), s;
|
|
561
634
|
}
|
|
562
635
|
// Show toast with animation
|
|
563
636
|
async showToast(t) {
|
|
564
|
-
var
|
|
637
|
+
var o, r;
|
|
565
638
|
const e = this.ensureContainer(t.options.position || this.config.position), s = this.createToastElement(t);
|
|
566
639
|
t.element = s, e.appendChild(s), this.applyStackState(e);
|
|
567
640
|
const i = t.options.animation || this.config.animation || { type: "css" };
|
|
568
|
-
if (await
|
|
569
|
-
const
|
|
641
|
+
if (await L.showToast(s, t, i), this.config.enableAccessibility && this.announceToast(t), (r = (o = t.options).onShow) == null || r.call(o), !t.options.persistent && t.options.duration !== 0) {
|
|
642
|
+
const n = t.options.duration || this.config.duration;
|
|
570
643
|
t.timeoutId = window.setTimeout(() => {
|
|
571
644
|
t.dismiss();
|
|
572
|
-
},
|
|
645
|
+
}, n);
|
|
573
646
|
}
|
|
574
647
|
}
|
|
575
648
|
// Hide toast with animation
|
|
576
649
|
async hideToast(t) {
|
|
577
650
|
var s, i;
|
|
578
|
-
if (!t.element)
|
|
579
|
-
return;
|
|
651
|
+
if (!t.element) return;
|
|
580
652
|
t.timeoutId && (clearTimeout(t.timeoutId), t.timeoutId = void 0);
|
|
581
653
|
const e = t.options.animation || this.config.animation || { type: "css" };
|
|
582
|
-
if (await
|
|
583
|
-
const
|
|
584
|
-
t.element.parentNode.removeChild(t.element), t.element = void 0,
|
|
654
|
+
if (await L.hideToast(t.element, t, e), t.element && t.element.parentNode) {
|
|
655
|
+
const o = t.element.parentElement;
|
|
656
|
+
t.element.parentNode.removeChild(t.element), t.element = void 0, o && this.applyStackState(o);
|
|
585
657
|
}
|
|
586
658
|
(i = (s = t.options).onHide) == null || i.call(s);
|
|
587
659
|
}
|
|
588
660
|
// Update toast content
|
|
589
661
|
async updateToast(t, e) {
|
|
590
|
-
var
|
|
591
|
-
if (!t.element)
|
|
592
|
-
return;
|
|
662
|
+
var o, r, n;
|
|
663
|
+
if (!t.element) return;
|
|
593
664
|
const s = t.options.animation || this.config.animation || { type: "css" };
|
|
594
665
|
if (s.type === "custom" && s.update) {
|
|
595
|
-
await
|
|
666
|
+
await L.updateToast(t.element, t, e, s);
|
|
596
667
|
return;
|
|
597
668
|
}
|
|
598
669
|
if (Object.assign(t.options, e), e.level && (t.element.className = t.element.className.replace(/editora-toast-(info|success|error|warning|loading|progress|promise|custom)/g, ""), t.element.classList.add(`editora-toast-${e.level}`), t.element.dataset.level = e.level), e.title !== void 0 || e.description !== void 0 || e.message !== void 0 || e.icon !== void 0 || e.render) {
|
|
599
|
-
const
|
|
600
|
-
|
|
670
|
+
const a = t.element.querySelector(".editora-toast-content"), l = this.createContent(t);
|
|
671
|
+
a == null || a.replaceWith(l);
|
|
672
|
+
}
|
|
673
|
+
const i = (o = e.closeButton) != null ? o : e.closable;
|
|
674
|
+
if (i !== void 0) {
|
|
675
|
+
t.options.closable = i, t.options.closeButton = i;
|
|
676
|
+
const a = t.element.querySelector(".editora-toast-close");
|
|
677
|
+
i && !a ? t.element.appendChild(this.createCloseButton(t)) : !i && a && a.remove();
|
|
601
678
|
}
|
|
602
679
|
if (e.progress !== void 0) {
|
|
603
|
-
let
|
|
680
|
+
let a = t.element.querySelector(".editora-toast-progress-track");
|
|
604
681
|
if (e.progress) {
|
|
605
|
-
if (!
|
|
606
|
-
|
|
607
|
-
const
|
|
608
|
-
|
|
682
|
+
if (!a) {
|
|
683
|
+
a = document.createElement("div"), a.className = "editora-toast-progress-track", a.setAttribute("role", "progressbar"), a.setAttribute("aria-valuemin", "0"), a.setAttribute("aria-valuemax", "100");
|
|
684
|
+
const d = t.element.querySelector(".editora-toast-content");
|
|
685
|
+
d && d.appendChild(a);
|
|
609
686
|
}
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
if (
|
|
613
|
-
let
|
|
614
|
-
|
|
687
|
+
a.setAttribute("aria-valuenow", String(Math.min(100, Math.max(0, e.progress.value))));
|
|
688
|
+
const l = a.querySelector(".editora-toast-progress-bar");
|
|
689
|
+
if (l && (l.style.width = `${Math.min(100, Math.max(0, e.progress.value))}%`), e.progress.showPercentage) {
|
|
690
|
+
let d = a.querySelector(".editora-toast-progress-text");
|
|
691
|
+
d || (d = document.createElement("span"), d.className = "editora-toast-progress-text", a.insertBefore(d, a.firstChild)), d.textContent = `${Math.round(e.progress.value)}%`;
|
|
615
692
|
} else {
|
|
616
|
-
const
|
|
617
|
-
|
|
693
|
+
const d = a.querySelector(".editora-toast-progress-text");
|
|
694
|
+
d && d.remove();
|
|
618
695
|
}
|
|
619
|
-
} else
|
|
620
|
-
o && o.remove();
|
|
696
|
+
} else a && a.remove();
|
|
621
697
|
}
|
|
622
698
|
if (e.actions !== void 0 || e.action !== void 0 || e.cancel !== void 0) {
|
|
623
|
-
let
|
|
624
|
-
const
|
|
625
|
-
|
|
699
|
+
let a = t.element.querySelector(".editora-toast-actions");
|
|
700
|
+
const l = t.options.actions || [];
|
|
701
|
+
l.length > 0 ? (a ? a.innerHTML = "" : (a = document.createElement("div"), a.className = "editora-toast-actions", t.element.appendChild(a)), a && l.forEach((d) => a.appendChild(this.createActionButton(d, t)))) : a && a.remove();
|
|
626
702
|
}
|
|
627
703
|
if ((e.duration !== void 0 || e.persistent !== void 0 || e.level !== void 0) && (t.timeoutId && (clearTimeout(t.timeoutId), t.timeoutId = void 0), !t.options.persistent && t.options.duration !== 0)) {
|
|
628
|
-
const
|
|
704
|
+
const a = t.options.duration || this.config.duration;
|
|
629
705
|
t.timeoutId = window.setTimeout(() => {
|
|
630
706
|
t.dismiss();
|
|
631
|
-
},
|
|
707
|
+
}, a);
|
|
632
708
|
}
|
|
633
|
-
(
|
|
709
|
+
(n = (r = t.options).onUpdate) == null || n.call(r, e);
|
|
634
710
|
}
|
|
635
711
|
createContent(t) {
|
|
636
712
|
const e = t.options, s = document.createElement("div");
|
|
637
713
|
if (s.className = "editora-toast-content", e.icon) {
|
|
638
|
-
const
|
|
639
|
-
|
|
714
|
+
const o = document.createElement("span");
|
|
715
|
+
o.className = "editora-toast-icon", o.setAttribute("aria-hidden", "true"), o.textContent = e.icon, s.appendChild(o);
|
|
640
716
|
}
|
|
641
717
|
const i = document.createElement("div");
|
|
642
718
|
if (i.className = "editora-toast-body", e.render)
|
|
643
719
|
i.appendChild(e.render(t));
|
|
644
720
|
else {
|
|
645
721
|
if (e.title) {
|
|
646
|
-
const
|
|
647
|
-
|
|
722
|
+
const o = document.createElement("div");
|
|
723
|
+
o.className = "editora-toast-title", o.textContent = e.title, i.appendChild(o);
|
|
648
724
|
}
|
|
649
725
|
if (e.message) {
|
|
650
|
-
const
|
|
651
|
-
|
|
726
|
+
const o = document.createElement("div");
|
|
727
|
+
o.className = "editora-toast-message", e.html ? X(o, e.message) : o.textContent = e.message, i.appendChild(o);
|
|
652
728
|
}
|
|
653
729
|
if (e.description) {
|
|
654
|
-
const
|
|
655
|
-
|
|
730
|
+
const o = document.createElement("div");
|
|
731
|
+
o.className = "editora-toast-description", o.textContent = e.description, i.appendChild(o);
|
|
656
732
|
}
|
|
657
733
|
}
|
|
658
734
|
return s.appendChild(i), s;
|
|
659
735
|
}
|
|
736
|
+
createCloseButton(t) {
|
|
737
|
+
const e = document.createElement("button");
|
|
738
|
+
return e.className = "editora-toast-close", e.setAttribute("type", "button"), e.setAttribute("aria-label", "Close notification"), e.textContent = "×", e.onclick = () => t.dismiss(), e;
|
|
739
|
+
}
|
|
660
740
|
createActionButton(t, e) {
|
|
661
741
|
const s = document.createElement("button");
|
|
662
742
|
return s.className = `editora-toast-action ${t.primary ? "primary" : ""}`, s.textContent = t.label, t.altText && s.setAttribute("aria-label", t.altText), s.onclick = (i) => {
|
|
@@ -664,14 +744,14 @@ class O {
|
|
|
664
744
|
}, s;
|
|
665
745
|
}
|
|
666
746
|
applyContainerStyles(t, e) {
|
|
667
|
-
const s = this.toCssLength(this.config.offset), i = this.toCssLength(this.config.mobileOffset),
|
|
668
|
-
t.dataset.position = e, t.dataset.expand = String(this.config.expand), t.dataset.stack = String(this.config.stack), t.style.setProperty("--editora-toast-offset", s), t.style.setProperty("--editora-toast-mobile-offset", i), t.style.setProperty("--editora-toast-gap",
|
|
669
|
-
const
|
|
747
|
+
const s = this.toCssLength(this.config.offset), i = this.toCssLength(this.config.mobileOffset), o = this.toCssLength(this.config.gap);
|
|
748
|
+
t.dataset.position = e, t.dataset.expand = String(this.config.expand), t.dataset.stack = String(this.config.stack), t.style.setProperty("--editora-toast-offset", s), t.style.setProperty("--editora-toast-mobile-offset", i), t.style.setProperty("--editora-toast-gap", o);
|
|
749
|
+
const r = {
|
|
670
750
|
position: "fixed",
|
|
671
751
|
zIndex: (this.config.zIndex || 2147483647).toString(),
|
|
672
752
|
display: "flex",
|
|
673
753
|
flexDirection: e.startsWith("top") ? "column" : "column-reverse",
|
|
674
|
-
gap:
|
|
754
|
+
gap: o,
|
|
675
755
|
pointerEvents: "none",
|
|
676
756
|
maxWidth: "100%",
|
|
677
757
|
boxSizing: "border-box",
|
|
@@ -684,34 +764,34 @@ class O {
|
|
|
684
764
|
};
|
|
685
765
|
switch (e) {
|
|
686
766
|
case "top-left":
|
|
687
|
-
|
|
767
|
+
r.top = `max(${s}, env(safe-area-inset-top))`, r.left = `max(${s}, env(safe-area-inset-left))`;
|
|
688
768
|
break;
|
|
689
769
|
case "top-center":
|
|
690
|
-
|
|
770
|
+
r.top = `max(${s}, env(safe-area-inset-top))`, r.left = "50%", r.transform = "translateX(-50%)";
|
|
691
771
|
break;
|
|
692
772
|
case "top-right":
|
|
693
|
-
|
|
773
|
+
r.top = `max(${s}, env(safe-area-inset-top))`, r.right = `max(${s}, env(safe-area-inset-right))`;
|
|
694
774
|
break;
|
|
695
775
|
case "bottom-left":
|
|
696
|
-
|
|
776
|
+
r.bottom = `max(${s}, env(safe-area-inset-bottom))`, r.left = `max(${s}, env(safe-area-inset-left))`;
|
|
697
777
|
break;
|
|
698
778
|
case "bottom-center":
|
|
699
|
-
|
|
779
|
+
r.bottom = `max(${s}, env(safe-area-inset-bottom))`, r.left = "50%", r.transform = "translateX(-50%)";
|
|
700
780
|
break;
|
|
701
781
|
case "bottom-right":
|
|
702
|
-
|
|
782
|
+
r.bottom = `max(${s}, env(safe-area-inset-bottom))`, r.right = `max(${s}, env(safe-area-inset-right))`;
|
|
703
783
|
break;
|
|
704
784
|
case "center":
|
|
705
|
-
|
|
785
|
+
r.top = "50%", r.left = "50%", r.transform = "translate(-50%, -50%)", r.alignItems = "center";
|
|
706
786
|
break;
|
|
707
787
|
}
|
|
708
|
-
Object.assign(t.style,
|
|
788
|
+
Object.assign(t.style, r), t.style.setProperty("--editora-toast-mobile-left", i);
|
|
709
789
|
}
|
|
710
790
|
applyStackState(t) {
|
|
711
791
|
const e = Array.from(t.querySelectorAll(".editora-toast"));
|
|
712
792
|
e.forEach((s, i) => {
|
|
713
|
-
const
|
|
714
|
-
s.dataset.index = String(i), s.dataset.front = String(
|
|
793
|
+
const o = e.length - i - 1;
|
|
794
|
+
s.dataset.index = String(i), s.dataset.front = String(o === 0), s.style.setProperty("--editora-toast-index", String(i)), s.style.setProperty("--editora-toast-before", String(o));
|
|
715
795
|
});
|
|
716
796
|
}
|
|
717
797
|
toCssLength(t) {
|
|
@@ -731,56 +811,70 @@ class O {
|
|
|
731
811
|
}
|
|
732
812
|
// Swipe dismiss with directional control
|
|
733
813
|
addSwipeDismiss(t, e) {
|
|
734
|
-
let s = 0, i = 0,
|
|
735
|
-
const
|
|
736
|
-
let
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
},
|
|
740
|
-
if (
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
if ((Math.abs(m) > g || Math.abs(w) > g) && (d = !0), d) {
|
|
744
|
-
const v = Math.abs(w) > Math.abs(m) ? 25 : 20, P = Math.min(Math.max(m * 0.2, -v), v), E = Math.min(Math.max(w * 0.2, -v), v);
|
|
745
|
-
t.style.transform = `${c} translate(${P}px, ${E}px)`;
|
|
814
|
+
let s = 0, i = 0, o = !1;
|
|
815
|
+
const r = e.options.swipeDirection || this.config.swipeDirection || "any", n = 40;
|
|
816
|
+
let a = "", l = !1;
|
|
817
|
+
const d = 'button, a[href], input, select, textarea, label, summary, [role="button"], [contenteditable="true"]', f = () => {
|
|
818
|
+
t.style.transform = a, t.style.transition = "", t.style.cursor = "", t.style.userSelect = "";
|
|
819
|
+
}, u = (p, y) => {
|
|
820
|
+
if ("changedTouches" in p || "touches" in p) {
|
|
821
|
+
const m = y ? p.changedTouches : p.touches, g = m && m[0];
|
|
822
|
+
return g ? { x: g.clientX, y: g.clientY } : null;
|
|
746
823
|
}
|
|
747
|
-
|
|
748
|
-
},
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
824
|
+
return { x: p.clientX, y: p.clientY };
|
|
825
|
+
}, P = (p) => {
|
|
826
|
+
const y = p.target;
|
|
827
|
+
if (y instanceof Element && t.contains(y) && y.closest(d) || "button" in p && p.button !== 0) return;
|
|
828
|
+
const m = u(p, !1);
|
|
829
|
+
m && (o = !0, l = !1, s = m.x, i = m.y, a = t.style.transform || "");
|
|
830
|
+
}, w = (p) => {
|
|
831
|
+
var b, k;
|
|
832
|
+
if (!o) return;
|
|
833
|
+
const y = u(p, !1);
|
|
834
|
+
if (!y) return;
|
|
835
|
+
const m = y.x - s, g = y.y - i, T = 5;
|
|
836
|
+
if (!l && (Math.abs(m) > T || Math.abs(g) > T) && (l = !0, t.style.transition = "none", t.style.cursor = "grabbing", t.style.userSelect = "none", (k = (b = window.getSelection) == null ? void 0 : b.call(window)) == null || k.removeAllRanges()), l) {
|
|
837
|
+
const x = Math.abs(g) > Math.abs(m) ? 25 : 20, B = Math.min(Math.max(m * 0.2, -x), x), D = Math.min(Math.max(g * 0.2, -x), x);
|
|
838
|
+
t.style.transform = `${a} translate(${B}px, ${D}px)`, p.cancelable && p.preventDefault();
|
|
754
839
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
840
|
+
}, v = (p) => {
|
|
841
|
+
if (!o) return;
|
|
842
|
+
o = !1;
|
|
843
|
+
const y = l;
|
|
844
|
+
if (f(), !y) return;
|
|
845
|
+
const m = u(p, !0);
|
|
846
|
+
if (!m) return;
|
|
847
|
+
const g = m.x - s, T = m.y - i;
|
|
848
|
+
let b = !1;
|
|
849
|
+
const x = r === "vertical" || r === "up" || r === "down" ? 35 : n;
|
|
850
|
+
switch (r) {
|
|
759
851
|
case "any":
|
|
760
|
-
|
|
852
|
+
b = Math.abs(g) > n || Math.abs(T) > n;
|
|
761
853
|
break;
|
|
762
854
|
case "horizontal":
|
|
763
|
-
|
|
855
|
+
b = Math.abs(g) > n;
|
|
764
856
|
break;
|
|
765
857
|
case "vertical":
|
|
766
|
-
|
|
858
|
+
b = Math.abs(T) > x;
|
|
767
859
|
break;
|
|
768
860
|
case "left":
|
|
769
|
-
|
|
861
|
+
b = g < -n;
|
|
770
862
|
break;
|
|
771
863
|
case "right":
|
|
772
|
-
|
|
864
|
+
b = g > n;
|
|
773
865
|
break;
|
|
774
866
|
case "up":
|
|
775
|
-
|
|
867
|
+
b = T < -x;
|
|
776
868
|
break;
|
|
777
869
|
case "down":
|
|
778
|
-
|
|
870
|
+
b = T > x;
|
|
779
871
|
break;
|
|
780
872
|
}
|
|
781
|
-
|
|
873
|
+
b && e.dismiss();
|
|
874
|
+
}, S = () => {
|
|
875
|
+
o && (o = !1, l = !1, f());
|
|
782
876
|
};
|
|
783
|
-
t.addEventListener("dragstart", (
|
|
877
|
+
t.addEventListener("dragstart", (p) => p.preventDefault()), t.addEventListener("touchstart", P, { passive: !0 }), t.addEventListener("touchmove", w, { passive: !1 }), t.addEventListener("touchend", v), t.addEventListener("touchcancel", S), t.addEventListener("mousedown", P), t.addEventListener("mousemove", w), t.addEventListener("mouseup", v), t.addEventListener("mouseleave", v);
|
|
784
878
|
}
|
|
785
879
|
// Drag dismiss (simplified)
|
|
786
880
|
addDragDismiss(t, e) {
|
|
@@ -788,28 +882,21 @@ class O {
|
|
|
788
882
|
}
|
|
789
883
|
// Accessibility
|
|
790
884
|
announceToast(t) {
|
|
791
|
-
if (t.options.ariaLive === "off")
|
|
792
|
-
return;
|
|
885
|
+
if (t.options.ariaLive === "off") return;
|
|
793
886
|
const e = document.createElement("div");
|
|
794
887
|
e.setAttribute("aria-live", t.options.ariaLive || (t.options.level === "error" ? "assertive" : "polite")), e.setAttribute("aria-atomic", "true"), e.style.position = "absolute", e.style.left = "-10000px", e.style.width = "1px", e.style.height = "1px", e.style.overflow = "hidden";
|
|
795
888
|
const s = [t.options.title, t.options.message, t.options.description].filter(Boolean).join(". ");
|
|
796
889
|
e.textContent = `${t.options.level || "info"}: ${s}`, document.body.appendChild(e), setTimeout(() => {
|
|
797
|
-
|
|
890
|
+
e.remove();
|
|
798
891
|
}, 1e3);
|
|
799
892
|
}
|
|
800
|
-
// Security: Basic HTML sanitization
|
|
801
|
-
sanitizeHTML(t) {
|
|
802
|
-
const e = document.createElement("div");
|
|
803
|
-
return e.textContent = t, e.innerHTML;
|
|
804
|
-
}
|
|
805
893
|
// Inject CSS
|
|
806
894
|
injectCSS() {
|
|
807
|
-
if (this.cssInjected || typeof document == "undefined")
|
|
808
|
-
return;
|
|
895
|
+
if (this.cssInjected || typeof document == "undefined") return;
|
|
809
896
|
if (!Array.from(document.styleSheets).find(
|
|
810
897
|
(e) => {
|
|
811
|
-
var s, i,
|
|
812
|
-
return ((i = (s = e.ownerNode) == null ? void 0 : s.href) == null ? void 0 : i.includes("toast.css")) || ((
|
|
898
|
+
var s, i, o, r;
|
|
899
|
+
return ((i = (s = e.ownerNode) == null ? void 0 : s.href) == null ? void 0 : i.includes("toast.css")) || ((r = (o = e.ownerNode) == null ? void 0 : o.textContent) == null ? void 0 : r.includes("editora-toast"));
|
|
813
900
|
}
|
|
814
901
|
)) {
|
|
815
902
|
const e = document.createElement("style");
|
|
@@ -824,7 +911,7 @@ class O {
|
|
|
824
911
|
}), this.containers.clear();
|
|
825
912
|
}
|
|
826
913
|
}
|
|
827
|
-
class
|
|
914
|
+
class U {
|
|
828
915
|
constructor() {
|
|
829
916
|
this.plugins = [], this.hooks = {
|
|
830
917
|
beforeShow: [],
|
|
@@ -845,8 +932,7 @@ class I {
|
|
|
845
932
|
}
|
|
846
933
|
remove(t) {
|
|
847
934
|
const e = this.plugins.findIndex((i) => i.name === t);
|
|
848
|
-
if (e === -1)
|
|
849
|
-
return !1;
|
|
935
|
+
if (e === -1) return !1;
|
|
850
936
|
const s = this.plugins[e];
|
|
851
937
|
return s.uninstall && s.uninstall(this), this.plugins.splice(e, 1), !0;
|
|
852
938
|
}
|
|
@@ -867,11 +953,11 @@ class I {
|
|
|
867
953
|
async trigger(t, e, ...s) {
|
|
868
954
|
const i = this.hooks[t];
|
|
869
955
|
if (!(!i || i.length === 0))
|
|
870
|
-
for (const
|
|
956
|
+
for (const o of i)
|
|
871
957
|
try {
|
|
872
|
-
await
|
|
873
|
-
} catch (
|
|
874
|
-
console.error(`Error in ${t} hook:`,
|
|
958
|
+
await o(e, ...s);
|
|
959
|
+
} catch (r) {
|
|
960
|
+
console.error(`Error in ${t} hook:`, r);
|
|
875
961
|
}
|
|
876
962
|
}
|
|
877
963
|
// Convenience methods for common lifecycle events
|
|
@@ -906,10 +992,10 @@ class I {
|
|
|
906
992
|
async handlePromise(t, e, s, i) {
|
|
907
993
|
e();
|
|
908
994
|
try {
|
|
909
|
-
const
|
|
910
|
-
return s(
|
|
911
|
-
} catch (
|
|
912
|
-
throw i(
|
|
995
|
+
const o = await t;
|
|
996
|
+
return s(o), o;
|
|
997
|
+
} catch (o) {
|
|
998
|
+
throw i(o), o;
|
|
913
999
|
}
|
|
914
1000
|
}
|
|
915
1001
|
// Batch operations
|
|
@@ -934,7 +1020,7 @@ class I {
|
|
|
934
1020
|
});
|
|
935
1021
|
}
|
|
936
1022
|
}
|
|
937
|
-
const
|
|
1023
|
+
const O = {
|
|
938
1024
|
position: "bottom-right",
|
|
939
1025
|
duration: 4e3,
|
|
940
1026
|
maxVisible: 3,
|
|
@@ -963,36 +1049,48 @@ const L = {
|
|
|
963
1049
|
animation: { type: "css" }
|
|
964
1050
|
// Default to CSS animations
|
|
965
1051
|
};
|
|
966
|
-
class
|
|
1052
|
+
class q {
|
|
967
1053
|
constructor(t = {}) {
|
|
968
|
-
this.idCounter = 0, this.pausedToasts = /* @__PURE__ */ new Set(), this.subscribers = /* @__PURE__ */ new Set(), this.config = this.normalizeConfig({ ...
|
|
1054
|
+
this.idCounter = 0, this.pausedToasts = /* @__PURE__ */ new Set(), this.pendingShows = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Set(), this.config = this.normalizeConfig({ ...O, ...t }), this.store = new z(this.config), this.queue = new N(this.config), this.renderer = new G(this.config), this.lifecycle = new U(), this.setupWindowFocusHandling();
|
|
969
1055
|
}
|
|
970
1056
|
// Core API
|
|
971
1057
|
show(t) {
|
|
972
1058
|
const e = t.id || `toast-${++this.idCounter}`, s = {
|
|
973
1059
|
id: e,
|
|
974
|
-
options: this.normalizeToastOptions({ ...this.config, ...t }),
|
|
1060
|
+
options: this.normalizeToastOptions({ ...this.config, ...t }, t),
|
|
975
1061
|
createdAt: Date.now(),
|
|
976
1062
|
dismiss: () => this.dismiss(e),
|
|
977
|
-
update: (
|
|
1063
|
+
update: (r) => this.update(e, r)
|
|
1064
|
+
}, i = this.lifecycle.beforeShow(s).then(async () => {
|
|
1065
|
+
const r = this.queue.enqueue(s);
|
|
1066
|
+
r.rejected || (this.store.addToast(s), await this.hideToasts(r.hide, !0), await this.showToasts(r.show), this.notify());
|
|
1067
|
+
});
|
|
1068
|
+
this.pendingShows.set(e, i);
|
|
1069
|
+
const o = () => {
|
|
1070
|
+
this.pendingShows.get(e) === i && this.pendingShows.delete(e);
|
|
978
1071
|
};
|
|
979
|
-
return
|
|
980
|
-
const i = this.queue.enqueue(s);
|
|
981
|
-
i.rejected || (this.store.addToast(s), await this.hideToasts(i.hide, !0), await this.showToasts(i.show), this.notify());
|
|
982
|
-
}), s;
|
|
1072
|
+
return i.then(o, o), s;
|
|
983
1073
|
}
|
|
984
1074
|
update(t, e) {
|
|
985
|
-
const s = this.
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1075
|
+
const s = this.pendingShows.get(t);
|
|
1076
|
+
if (s)
|
|
1077
|
+
return s.then(() => this.update(t, e), () => {
|
|
1078
|
+
}), !0;
|
|
1079
|
+
const i = this.store.getToast(t);
|
|
1080
|
+
return i ? (this.lifecycle.beforeUpdate(i, e).then(async () => {
|
|
1081
|
+
const o = this.normalizeToastOptions({ ...i.options, ...e }, e);
|
|
1082
|
+
this.store.updateToast(t, { options: o }), this.queue.isVisible(t) && await this.renderer.updateToast(i, e), this.lifecycle.afterUpdate(i, e), this.notify();
|
|
989
1083
|
}), !0) : !1;
|
|
990
1084
|
}
|
|
991
1085
|
dismiss(t) {
|
|
992
|
-
const e = this.
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1086
|
+
const e = this.pendingShows.get(t);
|
|
1087
|
+
if (e)
|
|
1088
|
+
return e.then(() => this.dismiss(t), () => {
|
|
1089
|
+
}), !0;
|
|
1090
|
+
const s = this.store.getToast(t);
|
|
1091
|
+
return s ? (this.lifecycle.beforeHide(s).then(async () => {
|
|
1092
|
+
const i = this.queue.isVisible(t), o = this.queue.dequeue(t);
|
|
1093
|
+
i && await this.renderer.hideToast(s), this.store.removeToast(t), this.lifecycle.afterHide(s), await this.showToasts(o.show), this.notify();
|
|
996
1094
|
}), !0) : !1;
|
|
997
1095
|
}
|
|
998
1096
|
clear() {
|
|
@@ -1003,20 +1101,20 @@ class k {
|
|
|
1003
1101
|
}
|
|
1004
1102
|
// Promise API
|
|
1005
1103
|
async promise(t, e) {
|
|
1006
|
-
var i,
|
|
1104
|
+
var i, o;
|
|
1007
1105
|
const s = this.show(this.normalizeOptions(e.loading, "loading"));
|
|
1008
1106
|
try {
|
|
1009
|
-
const
|
|
1010
|
-
typeof e.success == "function" ? e.success(
|
|
1107
|
+
const r = await t, n = this.normalizeOptions(
|
|
1108
|
+
typeof e.success == "function" ? e.success(r) : e.success,
|
|
1011
1109
|
"success"
|
|
1012
1110
|
);
|
|
1013
|
-
return
|
|
1014
|
-
} catch (
|
|
1015
|
-
const
|
|
1016
|
-
typeof e.error == "function" ? e.error(
|
|
1111
|
+
return n.duration === void 0 && !n.persistent && (n.duration = this.config.duration), this.update(s.id, n), (i = e.onSuccess) == null || i.call(e, r), r;
|
|
1112
|
+
} catch (r) {
|
|
1113
|
+
const n = this.normalizeOptions(
|
|
1114
|
+
typeof e.error == "function" ? e.error(r) : e.error,
|
|
1017
1115
|
"error"
|
|
1018
1116
|
);
|
|
1019
|
-
throw
|
|
1117
|
+
throw n.duration === void 0 && !n.persistent && (n.duration = this.config.duration), this.update(s.id, n), (o = e.onError) == null || o.call(e, r), r;
|
|
1020
1118
|
}
|
|
1021
1119
|
}
|
|
1022
1120
|
// Group API
|
|
@@ -1029,10 +1127,10 @@ class k {
|
|
|
1029
1127
|
}
|
|
1030
1128
|
// Configuration
|
|
1031
1129
|
configure(t) {
|
|
1032
|
-
const e = this.config.pauseOnWindowBlur;
|
|
1033
|
-
this.config = this.normalizeConfig(
|
|
1034
|
-
const
|
|
1035
|
-
this.hideToasts(
|
|
1130
|
+
const e = this.config.pauseOnWindowBlur, s = { ...this.config, ...t };
|
|
1131
|
+
t.maxVisible !== void 0 && t.visibleToasts === void 0 && delete s.visibleToasts, this.config = this.normalizeConfig(s), this.store.updateConfig(this.config), this.renderer.updateConfig(this.config);
|
|
1132
|
+
const i = this.queue.updateConfig(this.config);
|
|
1133
|
+
this.hideToasts(i.hide, !0).then(() => this.showToasts(i.show)).then(() => this.notify()), t.pauseOnWindowBlur !== void 0 && t.pauseOnWindowBlur !== e && (this.teardownWindowFocusHandling(), this.setupWindowFocusHandling());
|
|
1036
1134
|
}
|
|
1037
1135
|
getConfig() {
|
|
1038
1136
|
return { ...this.config };
|
|
@@ -1079,27 +1177,34 @@ class k {
|
|
|
1079
1177
|
return typeof t == "string" ? { message: t, level: e } : { ...t, level: t.level || e };
|
|
1080
1178
|
}
|
|
1081
1179
|
normalizeConfig(t) {
|
|
1082
|
-
const e = t.visibleToasts || t.maxVisible ||
|
|
1180
|
+
const e = t.visibleToasts || t.maxVisible || O.maxVisible;
|
|
1083
1181
|
return {
|
|
1084
1182
|
...t,
|
|
1085
1183
|
maxVisible: e,
|
|
1086
1184
|
visibleToasts: e
|
|
1087
1185
|
};
|
|
1088
1186
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1187
|
+
// `options` is the caller's options already merged over the config (or over the toast's current options when
|
|
1188
|
+
// updating); `explicit` is just what the caller passed. The close button has to be decided from what the
|
|
1189
|
+
// caller passed first: the merged object always carries the config's `closeButton: false`, so reading it
|
|
1190
|
+
// first made an explicit `closable: true` lose and the documented option silently did nothing.
|
|
1191
|
+
normalizeToastOptions(t, e = t) {
|
|
1192
|
+
var r, n, a, l, d, f;
|
|
1193
|
+
const s = (l = (a = (n = (r = e.closeButton) != null ? r : e.closable) != null ? n : t.closable) != null ? a : t.closeButton) != null ? l : this.config.closeButton, i = t.action ? { ...t.action, primary: (d = t.action.primary) != null ? d : !0 } : void 0, o = [
|
|
1194
|
+
...i ? [i] : [],
|
|
1093
1195
|
...t.cancel ? [t.cancel] : [],
|
|
1094
1196
|
...t.actions || []
|
|
1095
1197
|
];
|
|
1096
1198
|
return {
|
|
1097
1199
|
...t,
|
|
1098
|
-
closable:
|
|
1099
|
-
|
|
1200
|
+
closable: s,
|
|
1201
|
+
// Keep the alias in step: the renderer shows the button if either flag is set, and the merged config
|
|
1202
|
+
// value would otherwise re-enable a button the caller explicitly turned off.
|
|
1203
|
+
closeButton: s,
|
|
1204
|
+
actions: o.length > 0 ? o : void 0,
|
|
1100
1205
|
ariaLive: t.ariaLive || (t.level === "error" || t.important ? "assertive" : "polite"),
|
|
1101
1206
|
role: t.role || (t.level === "error" || t.important ? "alert" : "status"),
|
|
1102
|
-
preventDuplicate: (
|
|
1207
|
+
preventDuplicate: (f = t.preventDuplicate) != null ? f : this.config.preventDuplicate,
|
|
1103
1208
|
dedupeScope: t.dedupeScope || this.config.dedupeScope
|
|
1104
1209
|
};
|
|
1105
1210
|
}
|
|
@@ -1115,8 +1220,7 @@ class k {
|
|
|
1115
1220
|
await this.lifecycle.beforeHide(t), await this.renderer.hideToast(t), e && this.store.removeToast(t.id), await this.lifecycle.afterHide(t);
|
|
1116
1221
|
}
|
|
1117
1222
|
notify() {
|
|
1118
|
-
if (this.subscribers.size === 0)
|
|
1119
|
-
return;
|
|
1223
|
+
if (this.subscribers.size === 0) return;
|
|
1120
1224
|
const t = this.getState();
|
|
1121
1225
|
this.subscribers.forEach((e) => e(t));
|
|
1122
1226
|
}
|
|
@@ -1156,89 +1260,89 @@ class k {
|
|
|
1156
1260
|
this.teardownWindowFocusHandling(), this.clear(), this.renderer.destroy(), this.lifecycle.destroy();
|
|
1157
1261
|
}
|
|
1158
1262
|
}
|
|
1159
|
-
let
|
|
1160
|
-
function
|
|
1161
|
-
return
|
|
1263
|
+
let E = null;
|
|
1264
|
+
function h() {
|
|
1265
|
+
return E || (E = new q()), E;
|
|
1162
1266
|
}
|
|
1163
|
-
function
|
|
1267
|
+
function C(c) {
|
|
1164
1268
|
return typeof document == "undefined" ? { dismiss: () => {
|
|
1165
|
-
} } :
|
|
1269
|
+
} } : h().show(c);
|
|
1166
1270
|
}
|
|
1167
|
-
function
|
|
1271
|
+
function $(c, t, e, s) {
|
|
1168
1272
|
let i = {};
|
|
1169
1273
|
t && typeof t == "object" ? i = { ...t } : typeof t == "number" && (i.duration = t), e && (i.theme = e), s && (i.position = s);
|
|
1170
|
-
const
|
|
1171
|
-
message:
|
|
1274
|
+
const o = {
|
|
1275
|
+
message: c,
|
|
1172
1276
|
...i,
|
|
1173
1277
|
level: i.level || void 0
|
|
1174
1278
|
};
|
|
1175
|
-
return i.duration !== void 0 && (
|
|
1279
|
+
return i.duration !== void 0 && (o.duration = i.duration), i.position && (o.position = i.position), i.theme && (o.theme = i.theme), o;
|
|
1176
1280
|
}
|
|
1177
|
-
const
|
|
1178
|
-
info: (
|
|
1179
|
-
|
|
1281
|
+
const M = {
|
|
1282
|
+
info: (c, t, e, s) => C({
|
|
1283
|
+
...$(c, t, e, s),
|
|
1180
1284
|
level: "info"
|
|
1181
1285
|
}),
|
|
1182
|
-
success: (
|
|
1183
|
-
|
|
1286
|
+
success: (c, t, e, s) => C({
|
|
1287
|
+
...$(c, t, e, s),
|
|
1184
1288
|
level: "success"
|
|
1185
1289
|
}),
|
|
1186
|
-
error: (
|
|
1187
|
-
|
|
1290
|
+
error: (c, t, e, s) => C({
|
|
1291
|
+
...$(c, t, e, s),
|
|
1188
1292
|
level: "error"
|
|
1189
1293
|
}),
|
|
1190
|
-
warning: (
|
|
1191
|
-
|
|
1294
|
+
warning: (c, t, e, s) => C({
|
|
1295
|
+
...$(c, t, e, s),
|
|
1192
1296
|
level: "warning"
|
|
1193
1297
|
}),
|
|
1194
|
-
loading: (
|
|
1195
|
-
|
|
1298
|
+
loading: (c, t, e, s) => C({
|
|
1299
|
+
...$(c, t, e, s),
|
|
1196
1300
|
level: "loading"
|
|
1197
1301
|
})
|
|
1198
|
-
},
|
|
1302
|
+
}, A = {
|
|
1199
1303
|
// Core methods
|
|
1200
|
-
show: (
|
|
1201
|
-
update: (
|
|
1202
|
-
dismiss: (
|
|
1203
|
-
clear: () =>
|
|
1304
|
+
show: (c) => h().show(c),
|
|
1305
|
+
update: (c, t) => h().update(c, t),
|
|
1306
|
+
dismiss: (c) => h().dismiss(c),
|
|
1307
|
+
clear: () => h().clear(),
|
|
1204
1308
|
// Convenience methods
|
|
1205
|
-
info: (
|
|
1206
|
-
success: (
|
|
1207
|
-
error: (
|
|
1208
|
-
warning: (
|
|
1209
|
-
loading: (
|
|
1309
|
+
info: (c, t) => h().show({ message: c, level: "info", ...t }),
|
|
1310
|
+
success: (c, t) => h().show({ message: c, level: "success", ...t }),
|
|
1311
|
+
error: (c, t) => h().show({ message: c, level: "error", ...t }),
|
|
1312
|
+
warning: (c, t) => h().show({ message: c, level: "warning", ...t }),
|
|
1313
|
+
loading: (c, t) => h().show({ message: c, level: "loading", ...t }),
|
|
1210
1314
|
// Advanced features
|
|
1211
|
-
promise: (
|
|
1212
|
-
group: (
|
|
1213
|
-
configure: (
|
|
1214
|
-
use: (
|
|
1315
|
+
promise: (c, t) => h().promise(c, t),
|
|
1316
|
+
group: (c, t) => h().group(c, t),
|
|
1317
|
+
configure: (c) => h().configure(c),
|
|
1318
|
+
use: (c) => h().use(c),
|
|
1215
1319
|
// State queries
|
|
1216
|
-
getToasts: () =>
|
|
1217
|
-
getGroups: () =>
|
|
1218
|
-
getConfig: () =>
|
|
1219
|
-
getState: () =>
|
|
1220
|
-
subscribe: (
|
|
1320
|
+
getToasts: () => h().getToasts(),
|
|
1321
|
+
getGroups: () => h().getGroups(),
|
|
1322
|
+
getConfig: () => h().getConfig(),
|
|
1323
|
+
getState: () => h().getState(),
|
|
1324
|
+
subscribe: (c) => h().subscribe(c),
|
|
1221
1325
|
// Editor integration
|
|
1222
|
-
onEditorEvent: (
|
|
1223
|
-
triggerEditorEvent: (
|
|
1326
|
+
onEditorEvent: (c, t) => h().onEditorEvent(c, t),
|
|
1327
|
+
triggerEditorEvent: (c, t, ...e) => h().triggerEditorEvent(c, t, ...e),
|
|
1224
1328
|
// Cleanup
|
|
1225
1329
|
destroy: () => {
|
|
1226
|
-
|
|
1330
|
+
E && (E.destroy(), E = null);
|
|
1227
1331
|
}
|
|
1228
1332
|
};
|
|
1229
1333
|
if (typeof window != "undefined" && typeof document != "undefined") {
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1334
|
+
const c = window;
|
|
1335
|
+
c.toast = M, c.toastAdvanced = A, c.toastPro = A, c.ToastManager = q, c.__editoraToastReady || (c.__editoraToastReady = !0, window.dispatchEvent(
|
|
1232
1336
|
new CustomEvent("toastReady", {
|
|
1233
|
-
detail: { toast:
|
|
1337
|
+
detail: { toast: M, toastAdvanced: A, toastPro: A, ToastManager: q }
|
|
1234
1338
|
})
|
|
1235
1339
|
));
|
|
1236
1340
|
}
|
|
1237
1341
|
export {
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1342
|
+
q as ToastManager,
|
|
1343
|
+
M as default,
|
|
1344
|
+
M as toast,
|
|
1345
|
+
A as toastAdvanced,
|
|
1346
|
+
A as toastPro
|
|
1243
1347
|
};
|
|
1244
1348
|
//# sourceMappingURL=index.esm.js.map
|