@editora/toast 2.0.0 → 2.0.2
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 +126 -0
- package/README.md +28 -26
- package/dist/core/ToastManager.d.ts +2 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +12 -8
- package/dist/index.esm.js +132 -106
- package/dist/index.umd.js +1 -1
- package/package.json +14 -4
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js.map +0 -1
- package/dist/index.umd.js.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -75,7 +75,7 @@ class k {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
class
|
|
78
|
+
class M {
|
|
79
79
|
constructor(t) {
|
|
80
80
|
this.queue = [], this.visible = [], this.config = t;
|
|
81
81
|
}
|
|
@@ -149,7 +149,7 @@ class H {
|
|
|
149
149
|
this.showToast(t);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
class
|
|
152
|
+
class A {
|
|
153
153
|
constructor(t = {}) {
|
|
154
154
|
var s, e, i, r;
|
|
155
155
|
this.config = {
|
|
@@ -166,28 +166,28 @@ class L {
|
|
|
166
166
|
...r
|
|
167
167
|
};
|
|
168
168
|
let o, a = !1;
|
|
169
|
-
const
|
|
169
|
+
const l = Object.keys(s).reduce((u, d) => (u[d] = s[d].from, u), {}), p = Object.keys(s).reduce((u, d) => (u[d] = 0, u), {}), y = () => {
|
|
170
170
|
if (a)
|
|
171
171
|
return;
|
|
172
172
|
let u = !0;
|
|
173
173
|
Object.keys(s).forEach((g) => {
|
|
174
|
-
const b = s[g].to,
|
|
175
|
-
|
|
174
|
+
const b = s[g].to, m = l[g], w = p[g], f = -n.stiffness * (m - b), v = -n.damping * w, H = (f + v) / n.mass;
|
|
175
|
+
p[g] += H * 0.016, l[g] += p[g] * 0.016, (Math.abs(m - b) > n.precision || Math.abs(w) > n.precision) && (u = !1);
|
|
176
176
|
});
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
return g[b] = `${
|
|
177
|
+
const d = Object.keys(l).reduce((g, b) => {
|
|
178
|
+
const m = s[b].unit || "px";
|
|
179
|
+
return g[b] = `${l[b]}${m}`, g;
|
|
180
180
|
}, {});
|
|
181
|
-
e(
|
|
181
|
+
e(d), u ? (a = !0, i == null || i()) : o = requestAnimationFrame(y);
|
|
182
182
|
};
|
|
183
|
-
return o = requestAnimationFrame(
|
|
183
|
+
return o = requestAnimationFrame(y), () => {
|
|
184
184
|
a = !0, o && cancelAnimationFrame(o);
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
class
|
|
188
|
+
class q {
|
|
189
189
|
constructor() {
|
|
190
|
-
this.springAnimation = new
|
|
190
|
+
this.springAnimation = new A();
|
|
191
191
|
}
|
|
192
192
|
// Show toast with specified animation
|
|
193
193
|
async showToast(t, s, e) {
|
|
@@ -301,12 +301,12 @@ class M {
|
|
|
301
301
|
// Bounce-based show animation
|
|
302
302
|
async animateBounceShow(t, s) {
|
|
303
303
|
return new Promise((e) => {
|
|
304
|
-
var
|
|
304
|
+
var p, y, u;
|
|
305
305
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
306
|
-
const i = ((
|
|
306
|
+
const i = ((p = t.parentElement) == null ? void 0 : p.classList.contains("editora-toast-bottom-right")) || ((y = t.parentElement) == null ? void 0 : y.classList.contains("editora-toast-bottom-left")) || ((u = t.parentElement) == null ? void 0 : u.classList.contains("editora-toast-bottom-center")), r = s.direction || (i ? "up" : "down"), n = s.intensity || "normal", o = s.duration || 800, a = n === "gentle" ? 0.05 : n === "strong" ? 0.15 : 0.1, l = r === "up" ? 30 : r === "down" ? -30 : r === "left" ? 30 : -30;
|
|
307
307
|
t.style.setProperty("opacity", "0", "important"), t.style.setProperty(
|
|
308
308
|
"transform",
|
|
309
|
-
r === "left" || r === "right" ? `translateX(${
|
|
309
|
+
r === "left" || r === "right" ? `translateX(${l}px) scale(${1 - a})` : `translateY(${l}px) scale(${1 - a})`,
|
|
310
310
|
"important"
|
|
311
311
|
), t.offsetHeight, setTimeout(() => {
|
|
312
312
|
t.style.setProperty(
|
|
@@ -334,10 +334,10 @@ class M {
|
|
|
334
334
|
// Slide-based show animation
|
|
335
335
|
async animateSlideShow(t, s) {
|
|
336
336
|
return new Promise((e) => {
|
|
337
|
-
var
|
|
337
|
+
var p, y, u;
|
|
338
338
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
339
|
-
const i = ((
|
|
340
|
-
t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform",
|
|
339
|
+
const i = ((p = t.parentElement) == null ? void 0 : p.classList.contains("editora-toast-bottom-right")) || ((y = t.parentElement) == null ? void 0 : y.classList.contains("editora-toast-bottom-left")) || ((u = t.parentElement) == null ? void 0 : u.classList.contains("editora-toast-bottom-center")), r = s.direction || (i ? "up" : "down"), n = s.distance || 100, o = s.easing || "ease-out", a = s.duration || 400, l = r === "up" ? `translateY(${n}px)` : r === "down" ? `translateY(-${n}px)` : r === "left" ? `translateX(${n}px)` : `translateX(-${n}px)`;
|
|
340
|
+
t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", l, "important"), t.offsetHeight, setTimeout(() => {
|
|
341
341
|
t.style.setProperty("transition", `opacity ${a}ms ${o}, transform ${a}ms ${o}`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) translateX(0)", "important"), setTimeout(() => {
|
|
342
342
|
t.style.setProperty("transition", "none", "important"), e();
|
|
343
343
|
}, a);
|
|
@@ -437,12 +437,12 @@ class M {
|
|
|
437
437
|
// Elastic-based show animation
|
|
438
438
|
async animateElasticShow(t, s) {
|
|
439
439
|
return new Promise((e) => {
|
|
440
|
-
var
|
|
440
|
+
var p, y, u;
|
|
441
441
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
442
|
-
const i = ((
|
|
442
|
+
const i = ((p = t.parentElement) == null ? void 0 : p.classList.contains("editora-toast-bottom-right")) || ((y = t.parentElement) == null ? void 0 : y.classList.contains("editora-toast-bottom-left")) || ((u = t.parentElement) == null ? void 0 : u.classList.contains("editora-toast-bottom-center")), r = s.direction || (i ? "up" : "down"), n = s.intensity || "normal", o = s.duration || 1e3, a = n === "gentle" ? 0.1 : n === "strong" ? 0.3 : 0.2, l = r === "up" ? 40 : r === "down" ? -40 : r === "left" ? 40 : -40;
|
|
443
443
|
t.style.setProperty("opacity", "0", "important"), t.style.setProperty(
|
|
444
444
|
"transform",
|
|
445
|
-
r === "left" || r === "right" ? `translateX(${
|
|
445
|
+
r === "left" || r === "right" ? `translateX(${l}px) scale(${1 + a})` : `translateY(${l}px) scale(${1 + a})`,
|
|
446
446
|
"important"
|
|
447
447
|
), t.offsetHeight, setTimeout(() => {
|
|
448
448
|
t.style.setProperty(
|
|
@@ -492,8 +492,8 @@ class M {
|
|
|
492
492
|
});
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
|
-
const
|
|
496
|
-
class
|
|
495
|
+
const S = new q();
|
|
496
|
+
class Y {
|
|
497
497
|
constructor(t) {
|
|
498
498
|
this.containers = /* @__PURE__ */ new Map(), this.cssInjected = !1, this.config = t;
|
|
499
499
|
}
|
|
@@ -554,20 +554,20 @@ class A {
|
|
|
554
554
|
if (n.appendChild(o), s.progress) {
|
|
555
555
|
const a = document.createElement("div");
|
|
556
556
|
a.className = "editora-toast-progress";
|
|
557
|
-
const
|
|
558
|
-
if (
|
|
559
|
-
const
|
|
560
|
-
|
|
557
|
+
const l = document.createElement("div");
|
|
558
|
+
if (l.className = "editora-toast-progress-bar", l.style.width = `${Math.min(100, Math.max(0, s.progress.value))}%`, s.progress.showPercentage) {
|
|
559
|
+
const p = document.createElement("span");
|
|
560
|
+
p.className = "editora-toast-progress-text", p.textContent = `${Math.round(s.progress.value)}%`, a.appendChild(p);
|
|
561
561
|
}
|
|
562
|
-
a.appendChild(
|
|
562
|
+
a.appendChild(l), n.appendChild(a);
|
|
563
563
|
}
|
|
564
564
|
if (e.appendChild(n), s.actions && s.actions.length > 0) {
|
|
565
565
|
const a = document.createElement("div");
|
|
566
|
-
a.className = "editora-toast-actions", s.actions.forEach((
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}, a.appendChild(
|
|
566
|
+
a.className = "editora-toast-actions", s.actions.forEach((l) => {
|
|
567
|
+
const p = document.createElement("button");
|
|
568
|
+
p.className = `editora-toast-action ${l.primary ? "primary" : ""}`, p.textContent = l.label, p.onclick = (y) => {
|
|
569
|
+
y.stopPropagation(), l.onClick();
|
|
570
|
+
}, a.appendChild(p);
|
|
571
571
|
}), e.appendChild(a);
|
|
572
572
|
}
|
|
573
573
|
if (s.closable !== !1) {
|
|
@@ -582,7 +582,7 @@ class A {
|
|
|
582
582
|
const s = this.ensureContainer(t.options.position || this.config.position), e = this.createToastElement(t);
|
|
583
583
|
t.element = e, s.appendChild(e);
|
|
584
584
|
const i = t.options.animation || this.config.animation || { type: "css" };
|
|
585
|
-
if (await
|
|
585
|
+
if (await S.showToast(e, t, i), this.config.enableAccessibility && this.announceToast(t), (n = (r = t.options).onShow) == null || n.call(r), !t.options.persistent && t.options.duration !== 0) {
|
|
586
586
|
const o = t.options.duration || this.config.duration;
|
|
587
587
|
t.timeoutId = window.setTimeout(() => {
|
|
588
588
|
this.hideToast(t);
|
|
@@ -596,7 +596,7 @@ class A {
|
|
|
596
596
|
return;
|
|
597
597
|
t.timeoutId && (clearTimeout(t.timeoutId), t.timeoutId = void 0);
|
|
598
598
|
const s = t.options.animation || this.config.animation || { type: "css" };
|
|
599
|
-
await
|
|
599
|
+
await S.hideToast(t.element, t, s), t.element && t.element.parentNode && (t.element.parentNode.removeChild(t.element), t.element = void 0), (i = (e = t.options).onHide) == null || i.call(e);
|
|
600
600
|
}
|
|
601
601
|
// Update toast content
|
|
602
602
|
async updateToast(t, s) {
|
|
@@ -605,7 +605,7 @@ class A {
|
|
|
605
605
|
return;
|
|
606
606
|
const e = t.options.animation || this.config.animation || { type: "css" };
|
|
607
607
|
if (e.type === "custom" && e.update) {
|
|
608
|
-
await
|
|
608
|
+
await S.updateToast(t.element, t, s, e);
|
|
609
609
|
return;
|
|
610
610
|
}
|
|
611
611
|
Object.assign(t.options, s), s.level && (t.element.className = t.element.className.replace(/editora-toast--(info|success|error|warning|loading|custom)/g, ""), t.element.classList.add(`editora-toast--${s.level}`));
|
|
@@ -626,16 +626,16 @@ class A {
|
|
|
626
626
|
if (s.progress) {
|
|
627
627
|
if (!o) {
|
|
628
628
|
o = document.createElement("div"), o.className = "editora-toast-progress";
|
|
629
|
-
const
|
|
630
|
-
|
|
629
|
+
const l = t.element.querySelector(".editora-toast-content");
|
|
630
|
+
l && l.appendChild(o);
|
|
631
631
|
}
|
|
632
632
|
const a = o.querySelector(".editora-toast-progress-bar");
|
|
633
633
|
if (a && (a.style.width = `${Math.min(100, Math.max(0, s.progress.value))}%`), s.progress.showPercentage) {
|
|
634
|
-
let
|
|
635
|
-
|
|
634
|
+
let l = o.querySelector(".editora-toast-progress-text");
|
|
635
|
+
l || (l = document.createElement("span"), l.className = "editora-toast-progress-text", o.insertBefore(l, o.firstChild)), l.textContent = `${Math.round(s.progress.value)}%`;
|
|
636
636
|
} else {
|
|
637
|
-
const
|
|
638
|
-
|
|
637
|
+
const l = o.querySelector(".editora-toast-progress-text");
|
|
638
|
+
l && l.remove();
|
|
639
639
|
}
|
|
640
640
|
} else
|
|
641
641
|
o && o.remove();
|
|
@@ -643,10 +643,10 @@ class A {
|
|
|
643
643
|
if (s.actions !== void 0) {
|
|
644
644
|
let o = t.element.querySelector(".editora-toast-actions");
|
|
645
645
|
s.actions && s.actions.length > 0 ? (o ? o.innerHTML = "" : (o = document.createElement("div"), o.className = "editora-toast-actions", t.element.appendChild(o)), o && s.actions.forEach((a) => {
|
|
646
|
-
const
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}, o.appendChild(
|
|
646
|
+
const l = document.createElement("button");
|
|
647
|
+
l.className = `editora-toast-action ${a.primary ? "primary" : ""}`, l.textContent = a.label, l.onclick = (p) => {
|
|
648
|
+
p.stopPropagation(), a.onClick();
|
|
649
|
+
}, o.appendChild(l);
|
|
650
650
|
})) : o && o.remove();
|
|
651
651
|
}
|
|
652
652
|
(n = (r = t.options).onUpdate) == null || n.call(r, s);
|
|
@@ -667,43 +667,43 @@ class A {
|
|
|
667
667
|
addSwipeDismiss(t, s) {
|
|
668
668
|
let e = 0, i = 0, r = !1;
|
|
669
669
|
const n = s.options.swipeDirection || this.config.swipeDirection || "any", o = 40;
|
|
670
|
-
let a = "",
|
|
671
|
-
const
|
|
672
|
-
r = !0,
|
|
673
|
-
},
|
|
670
|
+
let a = "", l = !1;
|
|
671
|
+
const p = (d) => {
|
|
672
|
+
r = !0, l = !1, e = "touches" in d ? d.touches[0].clientX : d.clientX, i = "touches" in d ? d.touches[0].clientY : d.clientY, a = t.style.transform || "", t.style.transition = "none", t.style.cursor = "grabbing", d.preventDefault();
|
|
673
|
+
}, y = (d) => {
|
|
674
674
|
if (!r)
|
|
675
675
|
return;
|
|
676
|
-
const g = "touches" in
|
|
677
|
-
if ((Math.abs(
|
|
678
|
-
const v = Math.abs(w) > Math.abs(
|
|
679
|
-
t.style.transform = `${a} translate(${P}px, ${
|
|
676
|
+
const g = "touches" in d ? d.touches[0].clientX : d.clientX, b = "touches" in d ? d.touches[0].clientY : d.clientY, m = g - e, w = b - i, f = 5;
|
|
677
|
+
if ((Math.abs(m) > f || Math.abs(w) > f) && (l = !0), l) {
|
|
678
|
+
const v = Math.abs(w) > Math.abs(m) ? 25 : 20, P = Math.min(Math.max(m * 0.2, -v), v), H = Math.min(Math.max(w * 0.2, -v), v);
|
|
679
|
+
t.style.transform = `${a} translate(${P}px, ${H}px)`;
|
|
680
680
|
}
|
|
681
|
-
(Math.abs(w) > Math.abs(
|
|
682
|
-
}, u = (
|
|
681
|
+
(Math.abs(w) > Math.abs(m) || n === "vertical" || n === "up" || n === "down") && d.preventDefault();
|
|
682
|
+
}, u = (d) => {
|
|
683
683
|
if (!r)
|
|
684
684
|
return;
|
|
685
|
-
if (t.style.transform = a, t.style.transition = "", t.style.cursor = "", !
|
|
685
|
+
if (t.style.transform = a, t.style.transition = "", t.style.cursor = "", !l) {
|
|
686
686
|
r = !1;
|
|
687
687
|
return;
|
|
688
688
|
}
|
|
689
|
-
const g = "changedTouches" in
|
|
689
|
+
const g = "changedTouches" in d ? d.changedTouches[0].clientX : d.clientX, b = "changedTouches" in d ? d.changedTouches[0].clientY : d.clientY, m = g - e, w = b - i;
|
|
690
690
|
let f = !1;
|
|
691
691
|
const v = n === "vertical" || n === "up" || n === "down", P = v ? 35 : o;
|
|
692
692
|
switch (n) {
|
|
693
693
|
case "any":
|
|
694
|
-
f = Math.abs(
|
|
694
|
+
f = Math.abs(m) > o || Math.abs(w) > o;
|
|
695
695
|
break;
|
|
696
696
|
case "horizontal":
|
|
697
|
-
f = Math.abs(
|
|
697
|
+
f = Math.abs(m) > o;
|
|
698
698
|
break;
|
|
699
699
|
case "vertical":
|
|
700
700
|
f = Math.abs(w) > P;
|
|
701
701
|
break;
|
|
702
702
|
case "left":
|
|
703
|
-
f =
|
|
703
|
+
f = m < -o;
|
|
704
704
|
break;
|
|
705
705
|
case "right":
|
|
706
|
-
f =
|
|
706
|
+
f = m > o;
|
|
707
707
|
break;
|
|
708
708
|
case "up":
|
|
709
709
|
f = w < -P;
|
|
@@ -714,7 +714,7 @@ class A {
|
|
|
714
714
|
}
|
|
715
715
|
v && console.log(`Vertical swipe attempt: direction=${n}, deltaY=${w}, effectiveMinDistance=${P}, shouldDismiss=${f}`), f && s.dismiss(), r = !1;
|
|
716
716
|
};
|
|
717
|
-
t.addEventListener("dragstart", (
|
|
717
|
+
t.addEventListener("dragstart", (d) => d.preventDefault()), t.addEventListener("touchstart", p, { passive: !1 }), t.addEventListener("touchmove", y, { passive: !1 }), t.addEventListener("touchend", u, { passive: !1 }), t.addEventListener("mousedown", p), t.addEventListener("mousemove", y), t.addEventListener("mouseup", u), t.addEventListener("mouseleave", u);
|
|
718
718
|
}
|
|
719
719
|
// Drag dismiss (simplified)
|
|
720
720
|
addDragDismiss(t, s) {
|
|
@@ -754,7 +754,7 @@ class A {
|
|
|
754
754
|
}), this.containers.clear();
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
|
-
class
|
|
757
|
+
class F {
|
|
758
758
|
constructor() {
|
|
759
759
|
this.plugins = [], this.hooks = {
|
|
760
760
|
beforeShow: [],
|
|
@@ -864,7 +864,7 @@ class q {
|
|
|
864
864
|
});
|
|
865
865
|
}
|
|
866
866
|
}
|
|
867
|
-
const
|
|
867
|
+
const I = {
|
|
868
868
|
position: "bottom-right",
|
|
869
869
|
duration: 4e3,
|
|
870
870
|
maxVisible: 5,
|
|
@@ -884,9 +884,9 @@ const Y = {
|
|
|
884
884
|
animation: { type: "css" }
|
|
885
885
|
// Default to CSS animations
|
|
886
886
|
};
|
|
887
|
-
class
|
|
887
|
+
class C {
|
|
888
888
|
constructor(t = {}) {
|
|
889
|
-
this.idCounter = 0, this.pausedToasts = /* @__PURE__ */ new Set(), this.config = { ...
|
|
889
|
+
this.idCounter = 0, this.pausedToasts = /* @__PURE__ */ new Set(), this.config = { ...I, ...t }, this.store = new k(this.config), this.queue = new M(this.config), this.renderer = new Y(this.config), this.lifecycle = new F(), this.setupWindowFocusHandling();
|
|
890
890
|
}
|
|
891
891
|
// Core API
|
|
892
892
|
show(t) {
|
|
@@ -947,7 +947,8 @@ class S {
|
|
|
947
947
|
}
|
|
948
948
|
// Configuration
|
|
949
949
|
configure(t) {
|
|
950
|
-
|
|
950
|
+
const s = this.config.pauseOnWindowBlur;
|
|
951
|
+
this.config = { ...this.config, ...t }, this.store.updateConfig(t), this.queue.updateConfig(t), t.pauseOnWindowBlur !== void 0 && t.pauseOnWindowBlur !== s && (this.teardownWindowFocusHandling(), this.setupWindowFocusHandling());
|
|
951
952
|
}
|
|
952
953
|
getConfig() {
|
|
953
954
|
return { ...this.config };
|
|
@@ -988,9 +989,12 @@ class S {
|
|
|
988
989
|
}
|
|
989
990
|
// Window focus/blur handling
|
|
990
991
|
setupWindowFocusHandling() {
|
|
991
|
-
typeof window == "undefined" || !this.config.pauseOnWindowBlur || (this.windowBlurHandler = () => this.pauseAllToasts(), this.windowFocusHandler = () => this.resumeAllToasts(),
|
|
992
|
+
typeof window == "undefined" || typeof document == "undefined" || !this.config.pauseOnWindowBlur || (this.teardownWindowFocusHandling(), this.windowBlurHandler = () => this.pauseAllToasts(), this.windowFocusHandler = () => this.resumeAllToasts(), this.visibilityChangeHandler = () => {
|
|
992
993
|
document.hidden ? this.pauseAllToasts() : this.resumeAllToasts();
|
|
993
|
-
}));
|
|
994
|
+
}, window.addEventListener("blur", this.windowBlurHandler), window.addEventListener("focus", this.windowFocusHandler), document.addEventListener("visibilitychange", this.visibilityChangeHandler));
|
|
995
|
+
}
|
|
996
|
+
teardownWindowFocusHandling() {
|
|
997
|
+
typeof window != "undefined" && (this.windowBlurHandler && (window.removeEventListener("blur", this.windowBlurHandler), this.windowBlurHandler = void 0), this.windowFocusHandler && (window.removeEventListener("focus", this.windowFocusHandler), this.windowFocusHandler = void 0), typeof document != "undefined" && this.visibilityChangeHandler && (document.removeEventListener("visibilitychange", this.visibilityChangeHandler), this.visibilityChangeHandler = void 0));
|
|
994
998
|
}
|
|
995
999
|
pauseAllToasts() {
|
|
996
1000
|
this.store.getAllToasts().forEach((s) => {
|
|
@@ -1009,53 +1013,75 @@ class S {
|
|
|
1009
1013
|
}
|
|
1010
1014
|
// Cleanup
|
|
1011
1015
|
destroy() {
|
|
1012
|
-
this.
|
|
1016
|
+
this.teardownWindowFocusHandling(), this.clear(), this.renderer.destroy(), this.lifecycle.destroy();
|
|
1013
1017
|
}
|
|
1014
1018
|
}
|
|
1015
|
-
|
|
1016
|
-
function
|
|
1019
|
+
let T = null;
|
|
1020
|
+
function h() {
|
|
1021
|
+
return T || (T = new C()), T;
|
|
1022
|
+
}
|
|
1023
|
+
function E(c) {
|
|
1017
1024
|
return typeof document == "undefined" ? { dismiss: () => {
|
|
1018
|
-
} } : h.show(c);
|
|
1025
|
+
} } : h().show(c);
|
|
1019
1026
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1027
|
+
function $(c, t, s, e) {
|
|
1028
|
+
const i = { position: "top-right", theme: "light" };
|
|
1029
|
+
let r = {};
|
|
1030
|
+
return t && typeof t == "object" ? r = { ...t } : typeof t == "number" && (r.duration = t), s && (r.theme = s), e && (r.position = e), {
|
|
1031
|
+
message: c,
|
|
1032
|
+
...r,
|
|
1033
|
+
duration: r.duration,
|
|
1034
|
+
level: r.level || void 0,
|
|
1035
|
+
position: r.position || i.position,
|
|
1036
|
+
theme: r.theme || i.theme
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
const L = {
|
|
1040
|
+
info: (c, t, s, e) => E({ ...$(c, t, s, e), level: "info" }),
|
|
1041
|
+
success: (c, t, s, e) => E({ ...$(c, t, s, e), level: "success" }),
|
|
1042
|
+
error: (c, t, s, e) => E({ ...$(c, t, s, e), level: "error" }),
|
|
1043
|
+
warning: (c, t, s, e) => E({ ...$(c, t, s, e), level: "warning" }),
|
|
1044
|
+
loading: (c, t, s, e) => E({ ...$(c, t, s, e), level: "loading" })
|
|
1045
|
+
}, x = {
|
|
1025
1046
|
// Core methods
|
|
1026
|
-
show: (c) => h.show(c),
|
|
1027
|
-
update: (c, t) => h.update(c, t),
|
|
1028
|
-
dismiss: (c) => h.dismiss(c),
|
|
1029
|
-
clear: () => h.clear(),
|
|
1047
|
+
show: (c) => h().show(c),
|
|
1048
|
+
update: (c, t) => h().update(c, t),
|
|
1049
|
+
dismiss: (c) => h().dismiss(c),
|
|
1050
|
+
clear: () => h().clear(),
|
|
1030
1051
|
// Convenience methods
|
|
1031
|
-
info: (c, t) => h.show({ message: c, level: "info", ...t }),
|
|
1032
|
-
success: (c, t) => h.show({ message: c, level: "success", ...t }),
|
|
1033
|
-
error: (c, t) => h.show({ message: c, level: "error", ...t }),
|
|
1034
|
-
warning: (c, t) => h.show({ message: c, level: "warning", ...t }),
|
|
1035
|
-
loading: (c, t) => h.show({ message: c, level: "loading", ...t }),
|
|
1052
|
+
info: (c, t) => h().show({ message: c, level: "info", ...t }),
|
|
1053
|
+
success: (c, t) => h().show({ message: c, level: "success", ...t }),
|
|
1054
|
+
error: (c, t) => h().show({ message: c, level: "error", ...t }),
|
|
1055
|
+
warning: (c, t) => h().show({ message: c, level: "warning", ...t }),
|
|
1056
|
+
loading: (c, t) => h().show({ message: c, level: "loading", ...t }),
|
|
1036
1057
|
// Advanced features
|
|
1037
|
-
promise: (c, t) => h.promise(c, t),
|
|
1038
|
-
group: (c, t) => h.group(c, t),
|
|
1039
|
-
configure: (c) => h.configure(c),
|
|
1040
|
-
use: (c) => h.use(c),
|
|
1058
|
+
promise: (c, t) => h().promise(c, t),
|
|
1059
|
+
group: (c, t) => h().group(c, t),
|
|
1060
|
+
configure: (c) => h().configure(c),
|
|
1061
|
+
use: (c) => h().use(c),
|
|
1041
1062
|
// State queries
|
|
1042
|
-
getToasts: () => h.getToasts(),
|
|
1043
|
-
getGroups: () => h.getGroups(),
|
|
1044
|
-
getConfig: () => h.getConfig(),
|
|
1063
|
+
getToasts: () => h().getToasts(),
|
|
1064
|
+
getGroups: () => h().getGroups(),
|
|
1065
|
+
getConfig: () => h().getConfig(),
|
|
1045
1066
|
// Editor integration
|
|
1046
|
-
onEditorEvent: (c, t) => h.onEditorEvent(c, t),
|
|
1047
|
-
triggerEditorEvent: (c, t, ...s) => h.triggerEditorEvent(c, t, ...s),
|
|
1067
|
+
onEditorEvent: (c, t) => h().onEditorEvent(c, t),
|
|
1068
|
+
triggerEditorEvent: (c, t, ...s) => h().triggerEditorEvent(c, t, ...s),
|
|
1048
1069
|
// Cleanup
|
|
1049
|
-
destroy: () =>
|
|
1070
|
+
destroy: () => {
|
|
1071
|
+
T && (T.destroy(), T = null);
|
|
1072
|
+
}
|
|
1050
1073
|
};
|
|
1051
|
-
typeof window != "undefined" && typeof document != "undefined"
|
|
1052
|
-
|
|
1053
|
-
|
|
1074
|
+
if (typeof window != "undefined" && typeof document != "undefined") {
|
|
1075
|
+
const c = window;
|
|
1076
|
+
c.toast = L, c.toastAdvanced = x, c.toastPro = x, c.ToastManager = C, c.__editoraToastReady || (c.__editoraToastReady = !0, window.dispatchEvent(new CustomEvent("toastReady", {
|
|
1077
|
+
detail: { toast: L, toastAdvanced: x, toastPro: x, ToastManager: C }
|
|
1078
|
+
})));
|
|
1079
|
+
}
|
|
1054
1080
|
export {
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1081
|
+
C as ToastManager,
|
|
1082
|
+
L as default,
|
|
1083
|
+
L as toast,
|
|
1084
|
+
x as toastAdvanced,
|
|
1085
|
+
x as toastPro
|
|
1060
1086
|
};
|
|
1061
1087
|
//# sourceMappingURL=index.esm.js.map
|