@editora/toast 2.0.5 → 2.0.6
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 +51 -31
- package/dist/core/ToastManager.d.ts +10 -1
- package/dist/core/ToastQueue.d.ts +18 -9
- package/dist/core/ToastRenderer.d.ts +6 -0
- package/dist/core/types.d.ts +35 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.esm.js +670 -513
- package/dist/index.umd.js +1 -1
- package/dist/toast.css +857 -657
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class A {
|
|
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
|
}
|
|
@@ -7,8 +7,8 @@ class k {
|
|
|
7
7
|
this.toasts.set(t.id, t), this.updateGroup(t);
|
|
8
8
|
}
|
|
9
9
|
removeToast(t) {
|
|
10
|
-
const
|
|
11
|
-
return
|
|
10
|
+
const e = this.toasts.get(t);
|
|
11
|
+
return e ? (this.toasts.delete(t), this.updateGroup(e), !0) : !1;
|
|
12
12
|
}
|
|
13
13
|
getToast(t) {
|
|
14
14
|
return this.toasts.get(t);
|
|
@@ -17,19 +17,19 @@ class k {
|
|
|
17
17
|
return Array.from(this.toasts.values());
|
|
18
18
|
}
|
|
19
19
|
getToastsByPosition(t) {
|
|
20
|
-
return this.getAllToasts().filter((
|
|
20
|
+
return this.getAllToasts().filter((e) => e.options.position === t);
|
|
21
21
|
}
|
|
22
|
-
updateToast(t,
|
|
23
|
-
const
|
|
24
|
-
return
|
|
22
|
+
updateToast(t, e) {
|
|
23
|
+
const s = this.toasts.get(t);
|
|
24
|
+
return s ? (Object.assign(s, e), this.updateGroup(s), !0) : !1;
|
|
25
25
|
}
|
|
26
26
|
// Group management
|
|
27
27
|
updateGroup(t) {
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
28
|
+
const e = t.options.group;
|
|
29
|
+
if (!e)
|
|
30
30
|
return;
|
|
31
|
-
let
|
|
32
|
-
|
|
31
|
+
let s = this.groups.get(e);
|
|
32
|
+
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
33
|
}
|
|
34
34
|
getGroup(t) {
|
|
35
35
|
return this.groups.get(t);
|
|
@@ -41,8 +41,8 @@ class k {
|
|
|
41
41
|
getContainer(t) {
|
|
42
42
|
return this.containers.get(t);
|
|
43
43
|
}
|
|
44
|
-
setContainer(t,
|
|
45
|
-
this.containers.set(t,
|
|
44
|
+
setContainer(t, e) {
|
|
45
|
+
this.containers.set(t, e);
|
|
46
46
|
}
|
|
47
47
|
removeContainer(t) {
|
|
48
48
|
return this.containers.delete(t);
|
|
@@ -77,51 +77,28 @@ class k {
|
|
|
77
77
|
}
|
|
78
78
|
class M {
|
|
79
79
|
constructor(t) {
|
|
80
|
-
this.queue = [], this.visible = [], this.config = t;
|
|
80
|
+
this.queue = [], this.visible = [], this.config = this.normalizeConfig(t);
|
|
81
81
|
}
|
|
82
|
-
// Add toast to queue
|
|
83
82
|
enqueue(t) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return i !== -1 && (this.visible.splice(i, 1), s = !0), s && this.processQueue(), s;
|
|
93
|
-
}
|
|
94
|
-
// Process queue to show toasts within limits
|
|
95
|
-
processQueue() {
|
|
96
|
-
const t = this.config.maxVisible;
|
|
97
|
-
for (; this.visible.length > t; ) {
|
|
98
|
-
const s = this.visible.pop();
|
|
99
|
-
this.hideToast(s);
|
|
83
|
+
var r;
|
|
84
|
+
const e = this.findDuplicate(t);
|
|
85
|
+
if (e && ((r = t.options.preventDuplicate) != null ? r : this.config.preventDuplicate))
|
|
86
|
+
return { show: [], hide: [], rejected: e };
|
|
87
|
+
const s = [];
|
|
88
|
+
if (t.options.important && this.visible.length >= this.maxVisible) {
|
|
89
|
+
const o = this.removeLowestPriorityVisible();
|
|
90
|
+
return this.visible.push(t), { show: [t], hide: o ? [...s, o] : s };
|
|
100
91
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
showToast(t) {
|
|
107
|
-
this.visible.push(t);
|
|
92
|
+
this.config.queueStrategy === "fifo" ? this.queue.push(t) : this.queue.unshift(t), this.sortQueue();
|
|
93
|
+
const i = this.processQueue();
|
|
94
|
+
return { show: i.show, hide: [...s, ...i.hide] };
|
|
108
95
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// Deduplicate toasts with same message and level
|
|
112
|
-
deduplicate(t) {
|
|
113
|
-
this.queue.filter(
|
|
114
|
-
(e) => e.options.message === t.options.message && e.options.level === t.options.level
|
|
115
|
-
).forEach((e) => {
|
|
116
|
-
const i = this.queue.indexOf(e);
|
|
117
|
-
i !== -1 && this.queue.splice(i, 1);
|
|
118
|
-
});
|
|
96
|
+
dequeue(t) {
|
|
97
|
+
return this.removeFromCollections(t) ? { show: this.processQueue().show, hide: [] } : { show: [], hide: [] };
|
|
119
98
|
}
|
|
120
|
-
// Update configuration
|
|
121
99
|
updateConfig(t) {
|
|
122
|
-
this.config = { ...this.config, ...t }, this.processQueue();
|
|
100
|
+
return this.config = this.normalizeConfig({ ...this.config, ...t }), this.sortQueue(), this.processQueue();
|
|
123
101
|
}
|
|
124
|
-
// Get current state
|
|
125
102
|
getQueued() {
|
|
126
103
|
return [...this.queue];
|
|
127
104
|
}
|
|
@@ -131,525 +108,614 @@ class M {
|
|
|
131
108
|
getAll() {
|
|
132
109
|
return [...this.visible, ...this.queue];
|
|
133
110
|
}
|
|
134
|
-
|
|
111
|
+
isVisible(t) {
|
|
112
|
+
return this.visible.some((e) => e.id === t);
|
|
113
|
+
}
|
|
135
114
|
clear() {
|
|
136
115
|
const t = [...this.visible, ...this.queue];
|
|
137
|
-
this.queue = [], this.visible = [], t
|
|
138
|
-
s.element && this.hideToast(s);
|
|
139
|
-
});
|
|
116
|
+
return this.queue = [], this.visible = [], t;
|
|
140
117
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const s = this.visible.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
118
|
+
processQueue() {
|
|
119
|
+
const t = [], e = [];
|
|
120
|
+
for (; this.visible.length > this.maxVisible; ) {
|
|
121
|
+
const s = this.visible.pop();
|
|
122
|
+
s && e.push(s);
|
|
123
|
+
}
|
|
124
|
+
for (; this.visible.length < this.maxVisible && this.queue.length > 0; ) {
|
|
125
|
+
const s = this.queue.shift();
|
|
126
|
+
if (!s)
|
|
127
|
+
break;
|
|
128
|
+
this.visible.push(s), t.push(s);
|
|
148
129
|
}
|
|
149
|
-
|
|
130
|
+
return { show: t, hide: e };
|
|
131
|
+
}
|
|
132
|
+
removeLowestPriorityVisible() {
|
|
133
|
+
if (this.visible.length === 0)
|
|
134
|
+
return;
|
|
135
|
+
let t = 0;
|
|
136
|
+
for (let e = 1; e < this.visible.length; e += 1)
|
|
137
|
+
(this.visible[e].options.priority || 0) < (this.visible[t].options.priority || 0) && (t = e);
|
|
138
|
+
return this.visible.splice(t, 1)[0];
|
|
139
|
+
}
|
|
140
|
+
removeFromCollections(t) {
|
|
141
|
+
const e = this.visible.findIndex((i) => i.id === t);
|
|
142
|
+
if (e !== -1)
|
|
143
|
+
return this.visible.splice(e, 1)[0];
|
|
144
|
+
const s = this.queue.findIndex((i) => i.id === t);
|
|
145
|
+
if (s !== -1)
|
|
146
|
+
return this.queue.splice(s, 1)[0];
|
|
147
|
+
}
|
|
148
|
+
findDuplicate(t) {
|
|
149
|
+
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((r) => this.getDedupeKey(r) === i);
|
|
151
|
+
}
|
|
152
|
+
getDedupeKey(t) {
|
|
153
|
+
return t.options.dedupeKey || `${t.options.level || "info"}:${t.options.title || ""}:${t.options.message || ""}:${t.options.description || ""}`;
|
|
154
|
+
}
|
|
155
|
+
sortQueue() {
|
|
156
|
+
this.queue.sort((t, e) => {
|
|
157
|
+
const s = (e.options.priority || 0) - (t.options.priority || 0);
|
|
158
|
+
return s !== 0 ? s : t.createdAt - e.createdAt;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
get maxVisible() {
|
|
162
|
+
return Math.max(1, this.config.visibleToasts || this.config.maxVisible || 1);
|
|
163
|
+
}
|
|
164
|
+
normalizeConfig(t) {
|
|
165
|
+
return {
|
|
166
|
+
...t,
|
|
167
|
+
maxVisible: t.visibleToasts || t.maxVisible
|
|
168
|
+
};
|
|
150
169
|
}
|
|
151
170
|
}
|
|
152
|
-
class
|
|
171
|
+
class q {
|
|
153
172
|
constructor(t = {}) {
|
|
154
|
-
var
|
|
173
|
+
var e, s, i, r;
|
|
155
174
|
this.config = {
|
|
156
|
-
stiffness: (
|
|
157
|
-
damping: (
|
|
175
|
+
stiffness: (e = t.stiffness) != null ? e : 100,
|
|
176
|
+
damping: (s = t.damping) != null ? s : 10,
|
|
158
177
|
mass: (i = t.mass) != null ? i : 1,
|
|
159
178
|
precision: (r = t.precision) != null ? r : 0.01
|
|
160
179
|
};
|
|
161
180
|
}
|
|
162
181
|
// Spring animation function
|
|
163
|
-
animate(t,
|
|
164
|
-
const
|
|
182
|
+
animate(t, e, s, i, r) {
|
|
183
|
+
const o = {
|
|
165
184
|
...this.config,
|
|
166
185
|
...r
|
|
167
186
|
};
|
|
168
|
-
let
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
187
|
+
let a, c = !1;
|
|
188
|
+
const d = Object.keys(e).reduce((p, l) => (p[l] = e[l].from, p), {}), h = Object.keys(e).reduce((p, l) => (p[l] = 0, p), {}), f = () => {
|
|
189
|
+
if (c)
|
|
171
190
|
return;
|
|
172
|
-
let
|
|
173
|
-
Object.keys(
|
|
174
|
-
const b =
|
|
175
|
-
|
|
191
|
+
let p = !0;
|
|
192
|
+
Object.keys(e).forEach((y) => {
|
|
193
|
+
const b = e[y].to, m = d[y], w = h[y], g = -o.stiffness * (m - b), v = -o.damping * w, E = (g + v) / o.mass;
|
|
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);
|
|
176
195
|
});
|
|
177
|
-
const
|
|
178
|
-
const m =
|
|
179
|
-
return
|
|
196
|
+
const l = Object.keys(d).reduce((y, b) => {
|
|
197
|
+
const m = e[b].unit || "px";
|
|
198
|
+
return y[b] = `${d[b]}${m}`, y;
|
|
180
199
|
}, {});
|
|
181
|
-
|
|
200
|
+
s(l), p ? (c = !0, i == null || i()) : a = requestAnimationFrame(f);
|
|
182
201
|
};
|
|
183
|
-
return
|
|
184
|
-
|
|
202
|
+
return a = requestAnimationFrame(f), () => {
|
|
203
|
+
c = !0, a && cancelAnimationFrame(a);
|
|
185
204
|
};
|
|
186
205
|
}
|
|
187
206
|
}
|
|
188
|
-
class
|
|
207
|
+
class z {
|
|
189
208
|
constructor() {
|
|
190
|
-
this.springAnimation = new
|
|
209
|
+
this.springAnimation = new q();
|
|
191
210
|
}
|
|
192
211
|
// Show toast with specified animation
|
|
193
|
-
async showToast(t,
|
|
194
|
-
switch (
|
|
212
|
+
async showToast(t, e, s) {
|
|
213
|
+
switch (s.type) {
|
|
195
214
|
case "spring":
|
|
196
|
-
await this.animateSpringShow(t,
|
|
215
|
+
await this.animateSpringShow(t, s);
|
|
197
216
|
break;
|
|
198
217
|
case "bounce":
|
|
199
|
-
await this.animateBounceShow(t,
|
|
218
|
+
await this.animateBounceShow(t, s);
|
|
200
219
|
break;
|
|
201
220
|
case "slide":
|
|
202
|
-
await this.animateSlideShow(t,
|
|
221
|
+
await this.animateSlideShow(t, s);
|
|
203
222
|
break;
|
|
204
223
|
case "zoom":
|
|
205
|
-
await this.animateZoomShow(t,
|
|
224
|
+
await this.animateZoomShow(t, s);
|
|
206
225
|
break;
|
|
207
226
|
case "flip":
|
|
208
|
-
await this.animateFlipShow(t,
|
|
227
|
+
await this.animateFlipShow(t, s);
|
|
209
228
|
break;
|
|
210
229
|
case "fade":
|
|
211
|
-
await this.animateFadeShow(t,
|
|
230
|
+
await this.animateFadeShow(t, s);
|
|
212
231
|
break;
|
|
213
232
|
case "elastic":
|
|
214
|
-
await this.animateElasticShow(t,
|
|
233
|
+
await this.animateElasticShow(t, s);
|
|
215
234
|
break;
|
|
216
235
|
case "rotate":
|
|
217
|
-
await this.animateRotateShow(t,
|
|
236
|
+
await this.animateRotateShow(t, s);
|
|
218
237
|
break;
|
|
219
238
|
case "custom":
|
|
220
|
-
|
|
239
|
+
s.show ? await Promise.resolve(s.show(t, e)) : await this.animateCssShow(t);
|
|
221
240
|
break;
|
|
222
241
|
case "css":
|
|
223
242
|
default:
|
|
224
|
-
this.animateCssShow(t);
|
|
243
|
+
await this.animateCssShow(t);
|
|
225
244
|
break;
|
|
226
245
|
}
|
|
227
246
|
}
|
|
228
247
|
// Hide toast with specified animation
|
|
229
|
-
async hideToast(t,
|
|
230
|
-
switch (
|
|
248
|
+
async hideToast(t, e, s) {
|
|
249
|
+
switch (s.type) {
|
|
231
250
|
case "spring":
|
|
232
|
-
await this.animateSpringHide(t,
|
|
251
|
+
await this.animateSpringHide(t, s);
|
|
233
252
|
break;
|
|
234
253
|
case "bounce":
|
|
235
|
-
await this.animateBounceHide(t,
|
|
254
|
+
await this.animateBounceHide(t, s);
|
|
236
255
|
break;
|
|
237
256
|
case "slide":
|
|
238
|
-
await this.animateSlideHide(t,
|
|
257
|
+
await this.animateSlideHide(t, s);
|
|
239
258
|
break;
|
|
240
259
|
case "zoom":
|
|
241
|
-
await this.animateZoomHide(t,
|
|
260
|
+
await this.animateZoomHide(t, s);
|
|
242
261
|
break;
|
|
243
262
|
case "flip":
|
|
244
|
-
await this.animateFlipHide(t,
|
|
263
|
+
await this.animateFlipHide(t, s);
|
|
245
264
|
break;
|
|
246
265
|
case "fade":
|
|
247
|
-
await this.animateFadeHide(t,
|
|
266
|
+
await this.animateFadeHide(t, s);
|
|
248
267
|
break;
|
|
249
268
|
case "elastic":
|
|
250
|
-
await this.animateElasticHide(t,
|
|
269
|
+
await this.animateElasticHide(t, s);
|
|
251
270
|
break;
|
|
252
271
|
case "rotate":
|
|
253
|
-
await this.animateRotateHide(t,
|
|
272
|
+
await this.animateRotateHide(t, s);
|
|
254
273
|
break;
|
|
255
274
|
case "custom":
|
|
256
|
-
|
|
275
|
+
s.hide ? await Promise.resolve(s.hide(t, e)) : await this.animateCssHide(t);
|
|
257
276
|
break;
|
|
258
277
|
case "css":
|
|
259
278
|
default:
|
|
260
|
-
this.animateCssHide(t);
|
|
279
|
+
await this.animateCssHide(t);
|
|
261
280
|
break;
|
|
262
281
|
}
|
|
263
282
|
}
|
|
264
283
|
// Update toast with specified animation
|
|
265
|
-
async updateToast(t,
|
|
266
|
-
i.type === "custom" && i.update && await Promise.resolve(i.update(t,
|
|
284
|
+
async updateToast(t, e, s, i) {
|
|
285
|
+
i.type === "custom" && i.update && await Promise.resolve(i.update(t, e, s));
|
|
267
286
|
}
|
|
268
287
|
// CSS-based show animation (existing behavior)
|
|
269
288
|
animateCssShow(t) {
|
|
270
|
-
|
|
271
|
-
|
|
289
|
+
return new Promise((e) => {
|
|
290
|
+
requestAnimationFrame(() => {
|
|
291
|
+
t.classList.add("show"), window.setTimeout(e, 220);
|
|
292
|
+
});
|
|
272
293
|
});
|
|
273
294
|
}
|
|
274
295
|
// CSS-based hide animation (existing behavior)
|
|
275
296
|
animateCssHide(t) {
|
|
276
|
-
|
|
297
|
+
return new Promise((e) => {
|
|
298
|
+
t.classList.remove("show"), t.classList.add("hiding"), window.setTimeout(e, 220);
|
|
299
|
+
});
|
|
277
300
|
}
|
|
278
301
|
// Spring-based show animation
|
|
279
|
-
async animateSpringShow(t,
|
|
280
|
-
return new Promise((
|
|
281
|
-
var
|
|
302
|
+
async animateSpringShow(t, e) {
|
|
303
|
+
return new Promise((s) => {
|
|
304
|
+
var o, a, c;
|
|
282
305
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important"), t.style.setProperty("-webkit-transition", "none", "important");
|
|
283
|
-
const r = ((
|
|
306
|
+
const r = ((o = t.parentElement) == null ? void 0 : o.classList.contains("editora-toast-bottom-right")) || ((a = t.parentElement) == null ? void 0 : a.classList.contains("editora-toast-bottom-left")) || ((c = t.parentElement) == null ? void 0 : c.classList.contains("editora-toast-bottom-center")) ? 20 : -20;
|
|
284
307
|
t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `translateY(${r}px) scale(0.95)`, "important"), t.offsetHeight, setTimeout(() => {
|
|
285
308
|
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(() => {
|
|
286
|
-
t.style.setProperty("transition", "none", "important"),
|
|
309
|
+
t.style.setProperty("transition", "none", "important"), s();
|
|
287
310
|
}, 800);
|
|
288
311
|
}, 16);
|
|
289
312
|
});
|
|
290
313
|
}
|
|
291
314
|
// Spring-based hide animation
|
|
292
|
-
async animateSpringHide(t,
|
|
293
|
-
return new Promise((
|
|
315
|
+
async animateSpringHide(t, e) {
|
|
316
|
+
return new Promise((s) => {
|
|
294
317
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important"), t.style.setProperty("-webkit-transition", "none", "important"), setTimeout(() => {
|
|
295
318
|
t.style.setProperty("transition", "opacity 0.4s ease, transform 0.4s ease", "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", "translateY(-10px) scale(0.95)", "important"), setTimeout(() => {
|
|
296
|
-
t.style.setProperty("transition", "none", "important"),
|
|
319
|
+
t.style.setProperty("transition", "none", "important"), s();
|
|
297
320
|
}, 400);
|
|
298
321
|
}, 16);
|
|
299
322
|
});
|
|
300
323
|
}
|
|
301
324
|
// Bounce-based show animation
|
|
302
|
-
async animateBounceShow(t,
|
|
303
|
-
return new Promise((
|
|
304
|
-
var
|
|
325
|
+
async animateBounceShow(t, e) {
|
|
326
|
+
return new Promise((s) => {
|
|
327
|
+
var h, f, p;
|
|
305
328
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
306
|
-
const i = ((
|
|
329
|
+
const i = ((h = t.parentElement) == null ? void 0 : h.classList.contains("editora-toast-bottom-right")) || ((f = t.parentElement) == null ? void 0 : f.classList.contains("editora-toast-bottom-left")) || ((p = t.parentElement) == null ? void 0 : p.classList.contains("editora-toast-bottom-center")), r = e.direction || (i ? "up" : "down"), o = e.intensity || "normal", a = e.duration || 800, c = o === "gentle" ? 0.05 : o === "strong" ? 0.15 : 0.1, d = r === "up" ? 30 : r === "down" ? -30 : r === "left" ? 30 : -30;
|
|
307
330
|
t.style.setProperty("opacity", "0", "important"), t.style.setProperty(
|
|
308
331
|
"transform",
|
|
309
|
-
r === "left" || r === "right" ? `translateX(${
|
|
332
|
+
r === "left" || r === "right" ? `translateX(${d}px) scale(${1 - c})` : `translateY(${d}px) scale(${1 - c})`,
|
|
310
333
|
"important"
|
|
311
334
|
), t.offsetHeight, setTimeout(() => {
|
|
312
335
|
t.style.setProperty(
|
|
313
336
|
"transition",
|
|
314
|
-
`opacity ${
|
|
337
|
+
`opacity ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,
|
|
315
338
|
"important"
|
|
316
339
|
), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) scale(1)", "important"), setTimeout(() => {
|
|
317
|
-
t.style.setProperty("transition", "none", "important"),
|
|
318
|
-
},
|
|
340
|
+
t.style.setProperty("transition", "none", "important"), s();
|
|
341
|
+
}, a);
|
|
319
342
|
}, 16);
|
|
320
343
|
});
|
|
321
344
|
}
|
|
322
345
|
// Bounce-based hide animation
|
|
323
|
-
async animateBounceHide(t,
|
|
324
|
-
return new Promise((
|
|
346
|
+
async animateBounceHide(t, e) {
|
|
347
|
+
return new Promise((s) => {
|
|
325
348
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
326
|
-
const i =
|
|
349
|
+
const i = e.intensity || "normal", r = i === "gentle" ? 0.05 : i === "strong" ? 0.15 : 0.1;
|
|
327
350
|
setTimeout(() => {
|
|
328
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 - r})`, "important"), setTimeout(() => {
|
|
329
|
-
t.style.setProperty("transition", "none", "important"),
|
|
352
|
+
t.style.setProperty("transition", "none", "important"), s();
|
|
330
353
|
}, 400);
|
|
331
354
|
}, 16);
|
|
332
355
|
});
|
|
333
356
|
}
|
|
334
357
|
// Slide-based show animation
|
|
335
|
-
async animateSlideShow(t,
|
|
336
|
-
return new Promise((
|
|
337
|
-
var
|
|
358
|
+
async animateSlideShow(t, e) {
|
|
359
|
+
return new Promise((s) => {
|
|
360
|
+
var h, f, p;
|
|
338
361
|
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",
|
|
341
|
-
t.style.setProperty("transition", `opacity ${
|
|
342
|
-
t.style.setProperty("transition", "none", "important"),
|
|
343
|
-
},
|
|
362
|
+
const i = ((h = t.parentElement) == null ? void 0 : h.classList.contains("editora-toast-bottom-right")) || ((f = t.parentElement) == null ? void 0 : f.classList.contains("editora-toast-bottom-left")) || ((p = t.parentElement) == null ? void 0 : p.classList.contains("editora-toast-bottom-center")), r = e.direction || (i ? "up" : "down"), o = e.distance || 100, a = e.easing || "ease-out", c = e.duration || 400, d = r === "up" ? `translateY(${o}px)` : r === "down" ? `translateY(-${o}px)` : r === "left" ? `translateX(${o}px)` : `translateX(-${o}px)`;
|
|
363
|
+
t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", d, "important"), t.offsetHeight, setTimeout(() => {
|
|
364
|
+
t.style.setProperty("transition", `opacity ${c}ms ${a}, transform ${c}ms ${a}`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) translateX(0)", "important"), setTimeout(() => {
|
|
365
|
+
t.style.setProperty("transition", "none", "important"), s();
|
|
366
|
+
}, c);
|
|
344
367
|
}, 16);
|
|
345
368
|
});
|
|
346
369
|
}
|
|
347
370
|
// Slide-based hide animation
|
|
348
|
-
async animateSlideHide(t,
|
|
349
|
-
return new Promise((
|
|
371
|
+
async animateSlideHide(t, e) {
|
|
372
|
+
return new Promise((s) => {
|
|
350
373
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
351
|
-
const i =
|
|
374
|
+
const i = e.direction || "down", r = e.distance || 100, o = e.easing || "ease-in", a = e.duration || 300, c = i === "up" ? `translateY(-${r}px)` : i === "down" ? `translateY(${r}px)` : i === "left" ? `translateX(-${r}px)` : `translateX(${r}px)`;
|
|
352
375
|
setTimeout(() => {
|
|
353
|
-
t.style.setProperty("transition", `opacity ${
|
|
354
|
-
t.style.setProperty("transition", "none", "important"),
|
|
355
|
-
},
|
|
376
|
+
t.style.setProperty("transition", `opacity ${a}ms ${o}, transform ${a}ms ${o}`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", c, "important"), setTimeout(() => {
|
|
377
|
+
t.style.setProperty("transition", "none", "important"), s();
|
|
378
|
+
}, a);
|
|
356
379
|
}, 16);
|
|
357
380
|
});
|
|
358
381
|
}
|
|
359
382
|
// Zoom-based show animation
|
|
360
|
-
async animateZoomShow(t,
|
|
361
|
-
return new Promise((
|
|
383
|
+
async animateZoomShow(t, e) {
|
|
384
|
+
return new Promise((s) => {
|
|
362
385
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
363
|
-
const i =
|
|
386
|
+
const i = e.scale || 0.3, r = e.origin || "center", o = e.easing || "ease-out", a = e.duration || 500;
|
|
364
387
|
t.style.setProperty("transform-origin", r, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${i})`, "important"), t.offsetHeight, setTimeout(() => {
|
|
365
|
-
t.style.setProperty("transition", `opacity ${
|
|
366
|
-
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"),
|
|
367
|
-
},
|
|
388
|
+
t.style.setProperty("transition", `opacity ${a}ms ${o}, transform ${a}ms ${o}`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "scale(1)", "important"), setTimeout(() => {
|
|
389
|
+
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), s();
|
|
390
|
+
}, a);
|
|
368
391
|
}, 16);
|
|
369
392
|
});
|
|
370
393
|
}
|
|
371
394
|
// Zoom-based hide animation
|
|
372
|
-
async animateZoomHide(t,
|
|
373
|
-
return new Promise((
|
|
395
|
+
async animateZoomHide(t, e) {
|
|
396
|
+
return new Promise((s) => {
|
|
374
397
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
375
|
-
const i =
|
|
398
|
+
const i = e.scale || 0.3, r = e.origin || "center", o = e.easing || "ease-in", a = e.duration || 300;
|
|
376
399
|
t.style.setProperty("transform-origin", r, "important"), setTimeout(() => {
|
|
377
|
-
t.style.setProperty("transition", `opacity ${
|
|
378
|
-
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"),
|
|
379
|
-
},
|
|
400
|
+
t.style.setProperty("transition", `opacity ${a}ms ${o}, transform ${a}ms ${o}`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${i})`, "important"), setTimeout(() => {
|
|
401
|
+
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), s();
|
|
402
|
+
}, a);
|
|
380
403
|
}, 16);
|
|
381
404
|
});
|
|
382
405
|
}
|
|
383
406
|
// Flip-based show animation
|
|
384
|
-
async animateFlipShow(t,
|
|
385
|
-
return new Promise((
|
|
407
|
+
async animateFlipShow(t, e) {
|
|
408
|
+
return new Promise((s) => {
|
|
386
409
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
387
|
-
const i =
|
|
410
|
+
const i = e.axis || "y", r = e.perspective || 1e3, o = e.direction || "forward", a = e.duration || 600;
|
|
388
411
|
t.style.setProperty("transform-style", "preserve-3d", "important"), t.parentElement.style.setProperty("perspective", `${r}px`, "important");
|
|
389
|
-
const
|
|
390
|
-
t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate${i.toUpperCase()}(${
|
|
391
|
-
t.style.setProperty("transition", `opacity ${
|
|
392
|
-
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-style", "", "important"), t.parentElement.style.setProperty("perspective", "", "important"),
|
|
393
|
-
},
|
|
412
|
+
const c = o === "forward" ? i === "x" ? -90 : 90 : i === "x" ? 90 : -90;
|
|
413
|
+
t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate${i.toUpperCase()}(${c}deg)`, "important"), t.offsetHeight, setTimeout(() => {
|
|
414
|
+
t.style.setProperty("transition", `opacity ${a}ms ease, transform ${a}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
|
+
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-style", "", "important"), t.parentElement.style.setProperty("perspective", "", "important"), s();
|
|
416
|
+
}, a);
|
|
394
417
|
}, 16);
|
|
395
418
|
});
|
|
396
419
|
}
|
|
397
420
|
// Flip-based hide animation
|
|
398
|
-
async animateFlipHide(t,
|
|
399
|
-
return new Promise((
|
|
421
|
+
async animateFlipHide(t, e) {
|
|
422
|
+
return new Promise((s) => {
|
|
400
423
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
401
|
-
const i =
|
|
424
|
+
const i = e.axis || "y", r = e.perspective || 1e3, o = e.direction || "backward", a = e.duration || 400;
|
|
402
425
|
t.style.setProperty("transform-style", "preserve-3d", "important"), t.parentElement.style.setProperty("perspective", `${r}px`, "important");
|
|
403
|
-
const
|
|
426
|
+
const c = o === "backward" ? i === "x" ? -90 : 90 : i === "x" ? 90 : -90;
|
|
404
427
|
setTimeout(() => {
|
|
405
|
-
t.style.setProperty("transition", `opacity ${
|
|
406
|
-
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-style", "", "important"), t.parentElement.style.setProperty("perspective", "", "important"),
|
|
407
|
-
},
|
|
428
|
+
t.style.setProperty("transition", `opacity ${a}ms ease, transform ${a}ms ease-in`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate${i.toUpperCase()}(${c}deg)`, "important"), setTimeout(() => {
|
|
429
|
+
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-style", "", "important"), t.parentElement.style.setProperty("perspective", "", "important"), s();
|
|
430
|
+
}, a);
|
|
408
431
|
}, 16);
|
|
409
432
|
});
|
|
410
433
|
}
|
|
411
434
|
// Fade-based show animation
|
|
412
|
-
async animateFadeShow(t,
|
|
413
|
-
return new Promise((
|
|
435
|
+
async animateFadeShow(t, e) {
|
|
436
|
+
return new Promise((s) => {
|
|
414
437
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
415
|
-
const i =
|
|
416
|
-
let
|
|
417
|
-
i !== "none" && (
|
|
418
|
-
t.style.setProperty("transition", `opacity ${
|
|
419
|
-
t.style.setProperty("transition", "none", "important"),
|
|
420
|
-
},
|
|
438
|
+
const i = e.direction || "none", r = e.distance || 20, o = e.duration || 300;
|
|
439
|
+
let a = "translateY(0) translateX(0)";
|
|
440
|
+
i !== "none" && (a = i === "up" ? `translateY(${r}px)` : i === "down" ? `translateY(-${r}px)` : i === "left" ? `translateX(${r}px)` : `translateX(-${r}px)`), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", a, "important"), t.offsetHeight, setTimeout(() => {
|
|
441
|
+
t.style.setProperty("transition", `opacity ${o}ms ease, transform ${o}ms ease`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) translateX(0)", "important"), setTimeout(() => {
|
|
442
|
+
t.style.setProperty("transition", "none", "important"), s();
|
|
443
|
+
}, o);
|
|
421
444
|
}, 16);
|
|
422
445
|
});
|
|
423
446
|
}
|
|
424
447
|
// Fade-based hide animation
|
|
425
|
-
async animateFadeHide(t,
|
|
426
|
-
return new Promise((
|
|
448
|
+
async animateFadeHide(t, e) {
|
|
449
|
+
return new Promise((s) => {
|
|
427
450
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
428
|
-
const i =
|
|
429
|
-
let
|
|
430
|
-
i !== "none" && (
|
|
431
|
-
t.style.setProperty("transition", `opacity ${
|
|
432
|
-
t.style.setProperty("transition", "none", "important"),
|
|
433
|
-
},
|
|
451
|
+
const i = e.direction || "none", r = e.distance || 20, o = e.duration || 200;
|
|
452
|
+
let a = "translateY(0) translateX(0)";
|
|
453
|
+
i !== "none" && (a = i === "up" ? `translateY(-${r}px)` : i === "down" ? `translateY(${r}px)` : i === "left" ? `translateX(-${r}px)` : `translateX(${r}px)`), setTimeout(() => {
|
|
454
|
+
t.style.setProperty("transition", `opacity ${o}ms ease, transform ${o}ms ease`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", a, "important"), setTimeout(() => {
|
|
455
|
+
t.style.setProperty("transition", "none", "important"), s();
|
|
456
|
+
}, o);
|
|
434
457
|
}, 16);
|
|
435
458
|
});
|
|
436
459
|
}
|
|
437
460
|
// Elastic-based show animation
|
|
438
|
-
async animateElasticShow(t,
|
|
439
|
-
return new Promise((
|
|
440
|
-
var
|
|
461
|
+
async animateElasticShow(t, e) {
|
|
462
|
+
return new Promise((s) => {
|
|
463
|
+
var h, f, p;
|
|
441
464
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
442
|
-
const i = ((
|
|
465
|
+
const i = ((h = t.parentElement) == null ? void 0 : h.classList.contains("editora-toast-bottom-right")) || ((f = t.parentElement) == null ? void 0 : f.classList.contains("editora-toast-bottom-left")) || ((p = t.parentElement) == null ? void 0 : p.classList.contains("editora-toast-bottom-center")), r = e.direction || (i ? "up" : "down"), o = e.intensity || "normal", a = e.duration || 1e3, c = o === "gentle" ? 0.1 : o === "strong" ? 0.3 : 0.2, d = r === "up" ? 40 : r === "down" ? -40 : r === "left" ? 40 : -40;
|
|
443
466
|
t.style.setProperty("opacity", "0", "important"), t.style.setProperty(
|
|
444
467
|
"transform",
|
|
445
|
-
r === "left" || r === "right" ? `translateX(${
|
|
468
|
+
r === "left" || r === "right" ? `translateX(${d}px) scale(${1 + c})` : `translateY(${d}px) scale(${1 + c})`,
|
|
446
469
|
"important"
|
|
447
470
|
), t.offsetHeight, setTimeout(() => {
|
|
448
471
|
t.style.setProperty(
|
|
449
472
|
"transition",
|
|
450
|
-
`opacity ${
|
|
473
|
+
`opacity ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,
|
|
451
474
|
"important"
|
|
452
475
|
), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) scale(1)", "important"), setTimeout(() => {
|
|
453
|
-
t.style.setProperty("transition", "none", "important"),
|
|
454
|
-
},
|
|
476
|
+
t.style.setProperty("transition", "none", "important"), s();
|
|
477
|
+
}, a);
|
|
455
478
|
}, 16);
|
|
456
479
|
});
|
|
457
480
|
}
|
|
458
481
|
// Elastic-based hide animation
|
|
459
|
-
async animateElasticHide(t,
|
|
460
|
-
return new Promise((
|
|
482
|
+
async animateElasticHide(t, e) {
|
|
483
|
+
return new Promise((s) => {
|
|
461
484
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
462
|
-
const i =
|
|
463
|
-
|
|
485
|
+
const i = e.intensity || "normal", r = i === "gentle" ? 0.1 : i === "strong" ? 0.3 : 0.2;
|
|
486
|
+
e.duration, setTimeout(() => {
|
|
464
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 + r})`, "important"), setTimeout(() => {
|
|
465
|
-
t.style.setProperty("transition", "none", "important"),
|
|
488
|
+
t.style.setProperty("transition", "none", "important"), s();
|
|
466
489
|
}, 400);
|
|
467
490
|
}, 16);
|
|
468
491
|
});
|
|
469
492
|
}
|
|
470
493
|
// Rotate-based show animation
|
|
471
|
-
async animateRotateShow(t,
|
|
472
|
-
return new Promise((
|
|
494
|
+
async animateRotateShow(t, e) {
|
|
495
|
+
return new Promise((s) => {
|
|
473
496
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
474
|
-
const i =
|
|
475
|
-
t.style.setProperty("transform-origin",
|
|
476
|
-
t.style.setProperty("transition", `opacity ${
|
|
477
|
-
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"),
|
|
478
|
-
},
|
|
497
|
+
const i = e.degrees || 360, r = e.direction || "clockwise", o = e.origin || "center", a = e.duration || 500, c = r === "clockwise" ? i : -i;
|
|
498
|
+
t.style.setProperty("transform-origin", o, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate(${c}deg) scale(0.8)`, "important"), t.offsetHeight, setTimeout(() => {
|
|
499
|
+
t.style.setProperty("transition", `opacity ${a}ms ease, transform ${a}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
|
+
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), s();
|
|
501
|
+
}, a);
|
|
479
502
|
}, 16);
|
|
480
503
|
});
|
|
481
504
|
}
|
|
482
505
|
// Rotate-based hide animation
|
|
483
|
-
async animateRotateHide(t,
|
|
484
|
-
return new Promise((
|
|
506
|
+
async animateRotateHide(t, e) {
|
|
507
|
+
return new Promise((s) => {
|
|
485
508
|
t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
|
|
486
|
-
const i =
|
|
487
|
-
t.style.setProperty("transform-origin",
|
|
488
|
-
t.style.setProperty("transition", `opacity ${
|
|
489
|
-
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"),
|
|
490
|
-
},
|
|
509
|
+
const i = e.degrees || 180, r = e.direction || "counterclockwise", o = e.origin || "center", a = e.duration || 300, c = r === "clockwise" ? i : -i;
|
|
510
|
+
t.style.setProperty("transform-origin", o, "important"), setTimeout(() => {
|
|
511
|
+
t.style.setProperty("transition", `opacity ${a}ms ease, transform ${a}ms ease-in`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate(${c}deg) scale(0.8)`, "important"), setTimeout(() => {
|
|
512
|
+
t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), s();
|
|
513
|
+
}, a);
|
|
491
514
|
}, 16);
|
|
492
515
|
});
|
|
493
516
|
}
|
|
494
517
|
}
|
|
495
|
-
const
|
|
496
|
-
class
|
|
518
|
+
const C = new z();
|
|
519
|
+
class O {
|
|
497
520
|
constructor(t) {
|
|
498
521
|
this.containers = /* @__PURE__ */ new Map(), this.cssInjected = !1, this.config = t;
|
|
499
522
|
}
|
|
523
|
+
updateConfig(t) {
|
|
524
|
+
this.config = t, this.containers.forEach((e, s) => {
|
|
525
|
+
this.applyContainerStyles(e, s), this.applyStackState(e);
|
|
526
|
+
});
|
|
527
|
+
}
|
|
500
528
|
// Ensure container exists for position
|
|
501
529
|
ensureContainer(t) {
|
|
502
530
|
if (this.containers.has(t))
|
|
503
531
|
return this.containers.get(t);
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
const e = {
|
|
507
|
-
position: "fixed",
|
|
508
|
-
zIndex: (this.config.zIndex || 2147483647).toString(),
|
|
509
|
-
display: "flex",
|
|
510
|
-
flexDirection: "column",
|
|
511
|
-
gap: "8px",
|
|
512
|
-
pointerEvents: "none",
|
|
513
|
-
maxWidth: "100%",
|
|
514
|
-
boxSizing: "border-box"
|
|
515
|
-
};
|
|
516
|
-
switch (t) {
|
|
517
|
-
case "top-left":
|
|
518
|
-
e.top = "16px", e.left = "16px";
|
|
519
|
-
break;
|
|
520
|
-
case "top-right":
|
|
521
|
-
e.top = "16px", e.right = "16px";
|
|
522
|
-
break;
|
|
523
|
-
case "bottom-left":
|
|
524
|
-
e.bottom = "16px", e.left = "16px";
|
|
525
|
-
break;
|
|
526
|
-
case "bottom-right":
|
|
527
|
-
e.bottom = "16px", e.right = "16px";
|
|
528
|
-
break;
|
|
529
|
-
case "center":
|
|
530
|
-
e.top = "50%", e.left = "50%", e.transform = "translate(-50%, -50%)", e.alignItems = "center";
|
|
531
|
-
break;
|
|
532
|
-
}
|
|
533
|
-
return Object.assign(s.style, e), document.body.appendChild(s), this.containers.set(t, s), this.injectCSS(), s;
|
|
532
|
+
const e = document.createElement("div");
|
|
533
|
+
return e.className = `editora-toast-container editora-toast-${t.replace("-", "-")}`, e.setAttribute("role", "region"), e.setAttribute("aria-label", "Toast notifications"), e.setAttribute("aria-live", "polite"), e.dataset.expand = String(this.config.expand), e.dataset.stack = String(this.config.stack), this.applyContainerStyles(e, t), document.body.appendChild(e), this.containers.set(t, e), this.injectCSS(), e;
|
|
534
534
|
}
|
|
535
535
|
// Create toast element
|
|
536
536
|
createToastElement(t) {
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
const i =
|
|
540
|
-
i && i !== "system" &&
|
|
541
|
-
const
|
|
542
|
-
if (
|
|
543
|
-
const a = document.createElement("span");
|
|
544
|
-
a.className = "editora-toast-icon", a.textContent = s.icon, n.appendChild(a);
|
|
545
|
-
}
|
|
546
|
-
const o = document.createElement("span");
|
|
547
|
-
if (o.className = "editora-toast-message", s.html && s.message)
|
|
548
|
-
o.innerHTML = this.sanitizeHTML(s.message);
|
|
549
|
-
else if (s.render) {
|
|
550
|
-
const a = s.render();
|
|
551
|
-
o.appendChild(a);
|
|
552
|
-
} else
|
|
553
|
-
o.textContent = s.message || "";
|
|
554
|
-
if (n.appendChild(o), s.progress) {
|
|
537
|
+
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((a) => s.classList.add(a)), 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
|
+
const i = e.theme || this.config.theme;
|
|
540
|
+
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 o = this.createContent(t);
|
|
542
|
+
if (e.progress) {
|
|
555
543
|
const a = document.createElement("div");
|
|
556
|
-
a.className = "editora-toast-progress";
|
|
557
|
-
const
|
|
558
|
-
if (
|
|
559
|
-
const
|
|
560
|
-
|
|
544
|
+
a.className = "editora-toast-progress-track", a.setAttribute("role", "progressbar"), a.setAttribute("aria-valuemin", "0"), a.setAttribute("aria-valuemax", "100"), a.setAttribute("aria-valuenow", String(Math.min(100, Math.max(0, e.progress.value))));
|
|
545
|
+
const c = document.createElement("div");
|
|
546
|
+
if (c.className = "editora-toast-progress-bar", c.style.width = `${Math.min(100, Math.max(0, e.progress.value))}%`, e.progress.showPercentage) {
|
|
547
|
+
const d = document.createElement("span");
|
|
548
|
+
d.className = "editora-toast-progress-text", d.textContent = `${Math.round(e.progress.value)}%`, a.appendChild(d);
|
|
561
549
|
}
|
|
562
|
-
a.appendChild(
|
|
550
|
+
a.appendChild(c), o.appendChild(a);
|
|
563
551
|
}
|
|
564
|
-
if (
|
|
552
|
+
if (s.appendChild(o), e.actions && e.actions.length > 0) {
|
|
565
553
|
const a = document.createElement("div");
|
|
566
|
-
a.className = "editora-toast-actions",
|
|
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
|
-
}), e.appendChild(a);
|
|
554
|
+
a.className = "editora-toast-actions", e.actions.forEach((c) => a.appendChild(this.createActionButton(c, t))), s.appendChild(a);
|
|
572
555
|
}
|
|
573
|
-
if (
|
|
556
|
+
if (e.closable || e.closeButton) {
|
|
574
557
|
const a = document.createElement("button");
|
|
575
|
-
a.className = "editora-toast-close", a.setAttribute("aria-label", "Close notification"), a.
|
|
558
|
+
a.className = "editora-toast-close", a.setAttribute("aria-label", "Close notification"), a.textContent = "×", a.onclick = () => t.dismiss(), s.appendChild(a);
|
|
576
559
|
}
|
|
577
|
-
return
|
|
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;
|
|
578
561
|
}
|
|
579
562
|
// Show toast with animation
|
|
580
563
|
async showToast(t) {
|
|
581
|
-
var r,
|
|
582
|
-
const
|
|
583
|
-
t.element =
|
|
564
|
+
var r, o;
|
|
565
|
+
const e = this.ensureContainer(t.options.position || this.config.position), s = this.createToastElement(t);
|
|
566
|
+
t.element = s, e.appendChild(s), this.applyStackState(e);
|
|
584
567
|
const i = t.options.animation || this.config.animation || { type: "css" };
|
|
585
|
-
if (await
|
|
586
|
-
const
|
|
568
|
+
if (await C.showToast(s, t, i), this.config.enableAccessibility && this.announceToast(t), (o = (r = t.options).onShow) == null || o.call(r), !t.options.persistent && t.options.duration !== 0) {
|
|
569
|
+
const a = t.options.duration || this.config.duration;
|
|
587
570
|
t.timeoutId = window.setTimeout(() => {
|
|
588
|
-
|
|
589
|
-
},
|
|
571
|
+
t.dismiss();
|
|
572
|
+
}, a);
|
|
590
573
|
}
|
|
591
574
|
}
|
|
592
575
|
// Hide toast with animation
|
|
593
576
|
async hideToast(t) {
|
|
594
|
-
var
|
|
577
|
+
var s, i;
|
|
595
578
|
if (!t.element)
|
|
596
579
|
return;
|
|
597
580
|
t.timeoutId && (clearTimeout(t.timeoutId), t.timeoutId = void 0);
|
|
598
|
-
const
|
|
599
|
-
await
|
|
581
|
+
const e = t.options.animation || this.config.animation || { type: "css" };
|
|
582
|
+
if (await C.hideToast(t.element, t, e), t.element && t.element.parentNode) {
|
|
583
|
+
const r = t.element.parentElement;
|
|
584
|
+
t.element.parentNode.removeChild(t.element), t.element = void 0, r && this.applyStackState(r);
|
|
585
|
+
}
|
|
586
|
+
(i = (s = t.options).onHide) == null || i.call(s);
|
|
600
587
|
}
|
|
601
588
|
// Update toast content
|
|
602
|
-
async updateToast(t,
|
|
603
|
-
var
|
|
589
|
+
async updateToast(t, e) {
|
|
590
|
+
var i, r;
|
|
604
591
|
if (!t.element)
|
|
605
592
|
return;
|
|
606
|
-
const
|
|
607
|
-
if (
|
|
608
|
-
await
|
|
593
|
+
const s = t.options.animation || this.config.animation || { type: "css" };
|
|
594
|
+
if (s.type === "custom" && s.update) {
|
|
595
|
+
await C.updateToast(t.element, t, e, s);
|
|
609
596
|
return;
|
|
610
597
|
}
|
|
611
|
-
Object.assign(t.options,
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
if (o) {
|
|
619
|
-
const a = t.options.render();
|
|
620
|
-
o.innerHTML = "", o.appendChild(a);
|
|
621
|
-
}
|
|
622
|
-
} else
|
|
623
|
-
i.textContent = s.message || "";
|
|
624
|
-
if (s.progress !== void 0) {
|
|
625
|
-
let o = t.element.querySelector(".editora-toast-progress");
|
|
626
|
-
if (s.progress) {
|
|
598
|
+
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 o = t.element.querySelector(".editora-toast-content"), a = this.createContent(t);
|
|
600
|
+
o == null || o.replaceWith(a);
|
|
601
|
+
}
|
|
602
|
+
if (e.progress !== void 0) {
|
|
603
|
+
let o = t.element.querySelector(".editora-toast-progress-track");
|
|
604
|
+
if (e.progress) {
|
|
627
605
|
if (!o) {
|
|
628
|
-
o = document.createElement("div"), o.className = "editora-toast-progress";
|
|
629
|
-
const
|
|
630
|
-
|
|
606
|
+
o = document.createElement("div"), o.className = "editora-toast-progress-track", o.setAttribute("role", "progressbar"), o.setAttribute("aria-valuemin", "0"), o.setAttribute("aria-valuemax", "100");
|
|
607
|
+
const c = t.element.querySelector(".editora-toast-content");
|
|
608
|
+
c && c.appendChild(o);
|
|
631
609
|
}
|
|
610
|
+
o.setAttribute("aria-valuenow", String(Math.min(100, Math.max(0, e.progress.value))));
|
|
632
611
|
const a = o.querySelector(".editora-toast-progress-bar");
|
|
633
|
-
if (a && (a.style.width = `${Math.min(100, Math.max(0,
|
|
634
|
-
let
|
|
635
|
-
|
|
612
|
+
if (a && (a.style.width = `${Math.min(100, Math.max(0, e.progress.value))}%`), e.progress.showPercentage) {
|
|
613
|
+
let c = o.querySelector(".editora-toast-progress-text");
|
|
614
|
+
c || (c = document.createElement("span"), c.className = "editora-toast-progress-text", o.insertBefore(c, o.firstChild)), c.textContent = `${Math.round(e.progress.value)}%`;
|
|
636
615
|
} else {
|
|
637
|
-
const
|
|
638
|
-
|
|
616
|
+
const c = o.querySelector(".editora-toast-progress-text");
|
|
617
|
+
c && c.remove();
|
|
639
618
|
}
|
|
640
619
|
} else
|
|
641
620
|
o && o.remove();
|
|
642
621
|
}
|
|
643
|
-
if (
|
|
622
|
+
if (e.actions !== void 0 || e.action !== void 0 || e.cancel !== void 0) {
|
|
644
623
|
let o = t.element.querySelector(".editora-toast-actions");
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
624
|
+
const a = t.options.actions || [];
|
|
625
|
+
a.length > 0 ? (o ? o.innerHTML = "" : (o = document.createElement("div"), o.className = "editora-toast-actions", t.element.appendChild(o)), o && a.forEach((c) => o.appendChild(this.createActionButton(c, t)))) : o && o.remove();
|
|
626
|
+
}
|
|
627
|
+
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 o = t.options.duration || this.config.duration;
|
|
629
|
+
t.timeoutId = window.setTimeout(() => {
|
|
630
|
+
t.dismiss();
|
|
631
|
+
}, o);
|
|
632
|
+
}
|
|
633
|
+
(r = (i = t.options).onUpdate) == null || r.call(i, e);
|
|
634
|
+
}
|
|
635
|
+
createContent(t) {
|
|
636
|
+
const e = t.options, s = document.createElement("div");
|
|
637
|
+
if (s.className = "editora-toast-content", e.icon) {
|
|
638
|
+
const r = document.createElement("span");
|
|
639
|
+
r.className = "editora-toast-icon", r.setAttribute("aria-hidden", "true"), r.textContent = e.icon, s.appendChild(r);
|
|
640
|
+
}
|
|
641
|
+
const i = document.createElement("div");
|
|
642
|
+
if (i.className = "editora-toast-body", e.render)
|
|
643
|
+
i.appendChild(e.render(t));
|
|
644
|
+
else {
|
|
645
|
+
if (e.title) {
|
|
646
|
+
const r = document.createElement("div");
|
|
647
|
+
r.className = "editora-toast-title", r.textContent = e.title, i.appendChild(r);
|
|
648
|
+
}
|
|
649
|
+
if (e.message) {
|
|
650
|
+
const r = document.createElement("div");
|
|
651
|
+
r.className = "editora-toast-message", e.html ? r.innerHTML = this.sanitizeHTML(e.message) : r.textContent = e.message, i.appendChild(r);
|
|
652
|
+
}
|
|
653
|
+
if (e.description) {
|
|
654
|
+
const r = document.createElement("div");
|
|
655
|
+
r.className = "editora-toast-description", r.textContent = e.description, i.appendChild(r);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return s.appendChild(i), s;
|
|
659
|
+
}
|
|
660
|
+
createActionButton(t, e) {
|
|
661
|
+
const s = document.createElement("button");
|
|
662
|
+
return s.className = `editora-toast-action ${t.primary ? "primary" : ""}`, s.textContent = t.label, t.altText && s.setAttribute("aria-label", t.altText), s.onclick = (i) => {
|
|
663
|
+
i.stopPropagation(), t.onClick(), t.dismissOnClick !== !1 && e.dismiss();
|
|
664
|
+
}, s;
|
|
665
|
+
}
|
|
666
|
+
applyContainerStyles(t, e) {
|
|
667
|
+
const s = this.toCssLength(this.config.offset), i = this.toCssLength(this.config.mobileOffset), r = this.toCssLength(this.config.gap);
|
|
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", r);
|
|
669
|
+
const o = {
|
|
670
|
+
position: "fixed",
|
|
671
|
+
zIndex: (this.config.zIndex || 2147483647).toString(),
|
|
672
|
+
display: "flex",
|
|
673
|
+
flexDirection: e.startsWith("top") ? "column" : "column-reverse",
|
|
674
|
+
gap: r,
|
|
675
|
+
pointerEvents: "none",
|
|
676
|
+
maxWidth: "100%",
|
|
677
|
+
boxSizing: "border-box",
|
|
678
|
+
top: "",
|
|
679
|
+
right: "",
|
|
680
|
+
bottom: "",
|
|
681
|
+
left: "",
|
|
682
|
+
transform: "",
|
|
683
|
+
alignItems: e.includes("center") ? "center" : "stretch"
|
|
684
|
+
};
|
|
685
|
+
switch (e) {
|
|
686
|
+
case "top-left":
|
|
687
|
+
o.top = `max(${s}, env(safe-area-inset-top))`, o.left = `max(${s}, env(safe-area-inset-left))`;
|
|
688
|
+
break;
|
|
689
|
+
case "top-center":
|
|
690
|
+
o.top = `max(${s}, env(safe-area-inset-top))`, o.left = "50%", o.transform = "translateX(-50%)";
|
|
691
|
+
break;
|
|
692
|
+
case "top-right":
|
|
693
|
+
o.top = `max(${s}, env(safe-area-inset-top))`, o.right = `max(${s}, env(safe-area-inset-right))`;
|
|
694
|
+
break;
|
|
695
|
+
case "bottom-left":
|
|
696
|
+
o.bottom = `max(${s}, env(safe-area-inset-bottom))`, o.left = `max(${s}, env(safe-area-inset-left))`;
|
|
697
|
+
break;
|
|
698
|
+
case "bottom-center":
|
|
699
|
+
o.bottom = `max(${s}, env(safe-area-inset-bottom))`, o.left = "50%", o.transform = "translateX(-50%)";
|
|
700
|
+
break;
|
|
701
|
+
case "bottom-right":
|
|
702
|
+
o.bottom = `max(${s}, env(safe-area-inset-bottom))`, o.right = `max(${s}, env(safe-area-inset-right))`;
|
|
703
|
+
break;
|
|
704
|
+
case "center":
|
|
705
|
+
o.top = "50%", o.left = "50%", o.transform = "translate(-50%, -50%)", o.alignItems = "center";
|
|
706
|
+
break;
|
|
651
707
|
}
|
|
652
|
-
(
|
|
708
|
+
Object.assign(t.style, o), t.style.setProperty("--editora-toast-mobile-left", i);
|
|
709
|
+
}
|
|
710
|
+
applyStackState(t) {
|
|
711
|
+
const e = Array.from(t.querySelectorAll(".editora-toast"));
|
|
712
|
+
e.forEach((s, i) => {
|
|
713
|
+
const r = e.length - i - 1;
|
|
714
|
+
s.dataset.index = String(i), s.dataset.front = String(r === 0), s.style.setProperty("--editora-toast-index", String(i)), s.style.setProperty("--editora-toast-before", String(r));
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
toCssLength(t) {
|
|
718
|
+
return typeof t == "number" ? `${t}px` : t || "16px";
|
|
653
719
|
}
|
|
654
720
|
// Pause/resume auto-dismiss
|
|
655
721
|
pauseToast(t) {
|
|
@@ -657,93 +723,97 @@ class Y {
|
|
|
657
723
|
}
|
|
658
724
|
resumeToast(t) {
|
|
659
725
|
if (!t.options.persistent && t.options.duration !== 0) {
|
|
660
|
-
const
|
|
726
|
+
const e = t.options.duration || this.config.duration;
|
|
661
727
|
t.timeoutId = window.setTimeout(() => {
|
|
662
|
-
|
|
663
|
-
},
|
|
728
|
+
t.dismiss();
|
|
729
|
+
}, e);
|
|
664
730
|
}
|
|
665
731
|
}
|
|
666
732
|
// Swipe dismiss with directional control
|
|
667
|
-
addSwipeDismiss(t,
|
|
668
|
-
let
|
|
669
|
-
const
|
|
670
|
-
let
|
|
671
|
-
const
|
|
672
|
-
r = !0,
|
|
673
|
-
},
|
|
733
|
+
addSwipeDismiss(t, e) {
|
|
734
|
+
let s = 0, i = 0, r = !1;
|
|
735
|
+
const o = e.options.swipeDirection || this.config.swipeDirection || "any", a = 40;
|
|
736
|
+
let c = "", d = !1;
|
|
737
|
+
const h = (l) => {
|
|
738
|
+
r = !0, d = !1, s = "touches" in l ? l.touches[0].clientX : l.clientX, i = "touches" in l ? l.touches[0].clientY : l.clientY, c = t.style.transform || "", t.style.transition = "none", t.style.cursor = "grabbing", l.preventDefault();
|
|
739
|
+
}, f = (l) => {
|
|
674
740
|
if (!r)
|
|
675
741
|
return;
|
|
676
|
-
const
|
|
677
|
-
if ((Math.abs(m) >
|
|
678
|
-
const v = Math.abs(w) > Math.abs(m) ? 25 : 20, P = Math.min(Math.max(m * 0.2, -v), v),
|
|
679
|
-
t.style.transform = `${
|
|
742
|
+
const y = "touches" in l ? l.touches[0].clientX : l.clientX, b = "touches" in l ? l.touches[0].clientY : l.clientY, m = y - s, w = b - i, g = 5;
|
|
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)`;
|
|
680
746
|
}
|
|
681
|
-
(Math.abs(w) > Math.abs(m) ||
|
|
682
|
-
},
|
|
747
|
+
(Math.abs(w) > Math.abs(m) || o === "vertical" || o === "up" || o === "down") && l.preventDefault();
|
|
748
|
+
}, p = (l) => {
|
|
683
749
|
if (!r)
|
|
684
750
|
return;
|
|
685
|
-
if (t.style.transform =
|
|
751
|
+
if (t.style.transform = c, t.style.transition = "", t.style.cursor = "", !d) {
|
|
686
752
|
r = !1;
|
|
687
753
|
return;
|
|
688
754
|
}
|
|
689
|
-
const
|
|
690
|
-
let
|
|
691
|
-
const
|
|
692
|
-
switch (
|
|
755
|
+
const y = "changedTouches" in l ? l.changedTouches[0].clientX : l.clientX, b = "changedTouches" in l ? l.changedTouches[0].clientY : l.clientY, m = y - s, w = b - i;
|
|
756
|
+
let g = !1;
|
|
757
|
+
const P = o === "vertical" || o === "up" || o === "down" ? 35 : a;
|
|
758
|
+
switch (o) {
|
|
693
759
|
case "any":
|
|
694
|
-
|
|
760
|
+
g = Math.abs(m) > a || Math.abs(w) > a;
|
|
695
761
|
break;
|
|
696
762
|
case "horizontal":
|
|
697
|
-
|
|
763
|
+
g = Math.abs(m) > a;
|
|
698
764
|
break;
|
|
699
765
|
case "vertical":
|
|
700
|
-
|
|
766
|
+
g = Math.abs(w) > P;
|
|
701
767
|
break;
|
|
702
768
|
case "left":
|
|
703
|
-
|
|
769
|
+
g = m < -a;
|
|
704
770
|
break;
|
|
705
771
|
case "right":
|
|
706
|
-
|
|
772
|
+
g = m > a;
|
|
707
773
|
break;
|
|
708
774
|
case "up":
|
|
709
|
-
|
|
775
|
+
g = w < -P;
|
|
710
776
|
break;
|
|
711
777
|
case "down":
|
|
712
|
-
|
|
778
|
+
g = w > P;
|
|
713
779
|
break;
|
|
714
780
|
}
|
|
715
|
-
|
|
781
|
+
g && e.dismiss(), r = !1;
|
|
716
782
|
};
|
|
717
|
-
t.addEventListener("dragstart", (
|
|
783
|
+
t.addEventListener("dragstart", (l) => l.preventDefault()), t.addEventListener("touchstart", h, { passive: !1 }), t.addEventListener("touchmove", f, { passive: !1 }), t.addEventListener("touchend", p, { passive: !1 }), t.addEventListener("mousedown", h), t.addEventListener("mousemove", f), t.addEventListener("mouseup", p), t.addEventListener("mouseleave", p);
|
|
718
784
|
}
|
|
719
785
|
// Drag dismiss (simplified)
|
|
720
|
-
addDragDismiss(t,
|
|
721
|
-
this.addSwipeDismiss(t,
|
|
786
|
+
addDragDismiss(t, e) {
|
|
787
|
+
this.addSwipeDismiss(t, e);
|
|
722
788
|
}
|
|
723
789
|
// Accessibility
|
|
724
790
|
announceToast(t) {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
791
|
+
if (t.options.ariaLive === "off")
|
|
792
|
+
return;
|
|
793
|
+
const e = document.createElement("div");
|
|
794
|
+
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
|
+
const s = [t.options.title, t.options.message, t.options.description].filter(Boolean).join(". ");
|
|
796
|
+
e.textContent = `${t.options.level || "info"}: ${s}`, document.body.appendChild(e), setTimeout(() => {
|
|
797
|
+
document.body.removeChild(e);
|
|
728
798
|
}, 1e3);
|
|
729
799
|
}
|
|
730
800
|
// Security: Basic HTML sanitization
|
|
731
801
|
sanitizeHTML(t) {
|
|
732
|
-
const
|
|
733
|
-
return
|
|
802
|
+
const e = document.createElement("div");
|
|
803
|
+
return e.textContent = t, e.innerHTML;
|
|
734
804
|
}
|
|
735
805
|
// Inject CSS
|
|
736
806
|
injectCSS() {
|
|
737
807
|
if (this.cssInjected || typeof document == "undefined")
|
|
738
808
|
return;
|
|
739
809
|
if (!Array.from(document.styleSheets).find(
|
|
740
|
-
(
|
|
741
|
-
var
|
|
742
|
-
return ((i = (
|
|
810
|
+
(e) => {
|
|
811
|
+
var s, i, r, o;
|
|
812
|
+
return ((i = (s = e.ownerNode) == null ? void 0 : s.href) == null ? void 0 : i.includes("toast.css")) || ((o = (r = e.ownerNode) == null ? void 0 : r.textContent) == null ? void 0 : o.includes("editora-toast"));
|
|
743
813
|
}
|
|
744
814
|
)) {
|
|
745
|
-
const
|
|
746
|
-
|
|
815
|
+
const e = document.createElement("style");
|
|
816
|
+
e.setAttribute("data-editora-toast-fallback", "true"), e.textContent = ".editora-toast{box-sizing:border-box;pointer-events:auto}.editora-toast-container{box-sizing:border-box;pointer-events:none}.editora-toast.show{opacity:1;transform:translateY(0) scale(1)}.editora-toast.hiding{opacity:0}", document.head.appendChild(e);
|
|
747
817
|
}
|
|
748
818
|
this.cssInjected = !0;
|
|
749
819
|
}
|
|
@@ -754,7 +824,7 @@ class Y {
|
|
|
754
824
|
}), this.containers.clear();
|
|
755
825
|
}
|
|
756
826
|
}
|
|
757
|
-
class
|
|
827
|
+
class I {
|
|
758
828
|
constructor() {
|
|
759
829
|
this.plugins = [], this.hooks = {
|
|
760
830
|
beforeShow: [],
|
|
@@ -767,41 +837,41 @@ class F {
|
|
|
767
837
|
}
|
|
768
838
|
// Plugin management
|
|
769
839
|
use(t) {
|
|
770
|
-
if (this.plugins.find((
|
|
840
|
+
if (this.plugins.find((e) => e.name === t.name)) {
|
|
771
841
|
console.warn(`Plugin "${t.name}" is already installed`);
|
|
772
842
|
return;
|
|
773
843
|
}
|
|
774
844
|
this.plugins.push(t), t.install(this);
|
|
775
845
|
}
|
|
776
846
|
remove(t) {
|
|
777
|
-
const
|
|
778
|
-
if (
|
|
847
|
+
const e = this.plugins.findIndex((i) => i.name === t);
|
|
848
|
+
if (e === -1)
|
|
779
849
|
return !1;
|
|
780
|
-
const
|
|
781
|
-
return
|
|
850
|
+
const s = this.plugins[e];
|
|
851
|
+
return s.uninstall && s.uninstall(this), this.plugins.splice(e, 1), !0;
|
|
782
852
|
}
|
|
783
853
|
getPlugins() {
|
|
784
854
|
return [...this.plugins];
|
|
785
855
|
}
|
|
786
856
|
// Hook registration
|
|
787
|
-
on(t,
|
|
788
|
-
this.hooks[t] && this.hooks[t].push(
|
|
857
|
+
on(t, e) {
|
|
858
|
+
this.hooks[t] && this.hooks[t].push(e);
|
|
789
859
|
}
|
|
790
|
-
off(t,
|
|
860
|
+
off(t, e) {
|
|
791
861
|
if (this.hooks[t]) {
|
|
792
|
-
const
|
|
793
|
-
|
|
862
|
+
const s = this.hooks[t].indexOf(e);
|
|
863
|
+
s !== -1 && this.hooks[t].splice(s, 1);
|
|
794
864
|
}
|
|
795
865
|
}
|
|
796
866
|
// Hook execution
|
|
797
|
-
async trigger(t,
|
|
867
|
+
async trigger(t, e, ...s) {
|
|
798
868
|
const i = this.hooks[t];
|
|
799
869
|
if (!(!i || i.length === 0))
|
|
800
870
|
for (const r of i)
|
|
801
871
|
try {
|
|
802
|
-
await r(
|
|
803
|
-
} catch (
|
|
804
|
-
console.error(`Error in ${t} hook:`,
|
|
872
|
+
await r(e, ...s);
|
|
873
|
+
} catch (o) {
|
|
874
|
+
console.error(`Error in ${t} hook:`, o);
|
|
805
875
|
}
|
|
806
876
|
}
|
|
807
877
|
// Convenience methods for common lifecycle events
|
|
@@ -817,43 +887,43 @@ class F {
|
|
|
817
887
|
async afterHide(t) {
|
|
818
888
|
await this.trigger("afterHide", t);
|
|
819
889
|
}
|
|
820
|
-
async beforeUpdate(t,
|
|
821
|
-
await this.trigger("beforeUpdate", t,
|
|
890
|
+
async beforeUpdate(t, e) {
|
|
891
|
+
await this.trigger("beforeUpdate", t, e);
|
|
822
892
|
}
|
|
823
|
-
async afterUpdate(t,
|
|
824
|
-
await this.trigger("afterUpdate", t,
|
|
893
|
+
async afterUpdate(t, e) {
|
|
894
|
+
await this.trigger("afterUpdate", t, e);
|
|
825
895
|
}
|
|
826
896
|
// Editor integration hooks (for RTE)
|
|
827
|
-
onEditorEvent(t,
|
|
828
|
-
const
|
|
829
|
-
this.hooks[
|
|
897
|
+
onEditorEvent(t, e) {
|
|
898
|
+
const s = `editor:${t}`;
|
|
899
|
+
this.hooks[s] || (this.hooks[s] = []), this.hooks[s].push(e);
|
|
830
900
|
}
|
|
831
|
-
triggerEditorEvent(t,
|
|
901
|
+
triggerEditorEvent(t, e, ...s) {
|
|
832
902
|
const i = `editor:${t}`;
|
|
833
|
-
this.trigger(i,
|
|
903
|
+
this.trigger(i, e, ...s);
|
|
834
904
|
}
|
|
835
905
|
// Promise lifecycle helpers
|
|
836
|
-
async handlePromise(t,
|
|
837
|
-
|
|
906
|
+
async handlePromise(t, e, s, i) {
|
|
907
|
+
e();
|
|
838
908
|
try {
|
|
839
909
|
const r = await t;
|
|
840
|
-
return
|
|
910
|
+
return s(r), r;
|
|
841
911
|
} catch (r) {
|
|
842
912
|
throw i(r), r;
|
|
843
913
|
}
|
|
844
914
|
}
|
|
845
915
|
// Batch operations
|
|
846
916
|
async batchShow(t) {
|
|
847
|
-
const
|
|
848
|
-
await Promise.all(s);
|
|
849
|
-
const e = t.map((i) => this.afterShow(i));
|
|
917
|
+
const e = t.map((i) => this.beforeShow(i));
|
|
850
918
|
await Promise.all(e);
|
|
919
|
+
const s = t.map((i) => this.afterShow(i));
|
|
920
|
+
await Promise.all(s);
|
|
851
921
|
}
|
|
852
922
|
async batchHide(t) {
|
|
853
|
-
const
|
|
854
|
-
await Promise.all(s);
|
|
855
|
-
const e = t.map((i) => this.afterHide(i));
|
|
923
|
+
const e = t.map((i) => this.beforeHide(i));
|
|
856
924
|
await Promise.all(e);
|
|
925
|
+
const s = t.map((i) => this.afterHide(i));
|
|
926
|
+
await Promise.all(s);
|
|
857
927
|
}
|
|
858
928
|
// Cleanup
|
|
859
929
|
destroy() {
|
|
@@ -864,82 +934,94 @@ class F {
|
|
|
864
934
|
});
|
|
865
935
|
}
|
|
866
936
|
}
|
|
867
|
-
const
|
|
937
|
+
const L = {
|
|
868
938
|
position: "bottom-right",
|
|
869
939
|
duration: 4e3,
|
|
870
|
-
maxVisible:
|
|
940
|
+
maxVisible: 3,
|
|
871
941
|
queueStrategy: "fifo",
|
|
872
942
|
theme: "system",
|
|
943
|
+
richColors: !1,
|
|
944
|
+
expand: !0,
|
|
945
|
+
stack: !1,
|
|
946
|
+
offset: 16,
|
|
947
|
+
mobileOffset: 16,
|
|
948
|
+
gap: 8,
|
|
873
949
|
pauseOnHover: !0,
|
|
874
950
|
pauseOnFocus: !1,
|
|
875
951
|
pauseOnWindowBlur: !1,
|
|
876
952
|
// Don't pause by default
|
|
877
|
-
swipeDismiss: !
|
|
953
|
+
swipeDismiss: !0,
|
|
878
954
|
swipeDirection: "any",
|
|
879
955
|
// Allow any direction by default
|
|
880
956
|
dragDismiss: !1,
|
|
881
957
|
rtl: !1,
|
|
882
958
|
// LTR by default
|
|
883
959
|
enableAccessibility: !0,
|
|
960
|
+
closeButton: !1,
|
|
961
|
+
preventDuplicate: !1,
|
|
962
|
+
dedupeScope: "all",
|
|
884
963
|
animation: { type: "css" }
|
|
885
964
|
// Default to CSS animations
|
|
886
965
|
};
|
|
887
|
-
class
|
|
966
|
+
class k {
|
|
888
967
|
constructor(t = {}) {
|
|
889
|
-
this.idCounter = 0, this.pausedToasts = /* @__PURE__ */ new Set(), this.config = { ...
|
|
968
|
+
this.idCounter = 0, this.pausedToasts = /* @__PURE__ */ new Set(), this.subscribers = /* @__PURE__ */ new Set(), this.config = this.normalizeConfig({ ...L, ...t }), this.store = new A(this.config), this.queue = new M(this.config), this.renderer = new O(this.config), this.lifecycle = new I(), this.setupWindowFocusHandling();
|
|
890
969
|
}
|
|
891
970
|
// Core API
|
|
892
971
|
show(t) {
|
|
893
|
-
const
|
|
894
|
-
id:
|
|
895
|
-
options: { ...this.config, ...t },
|
|
972
|
+
const e = t.id || `toast-${++this.idCounter}`, s = {
|
|
973
|
+
id: e,
|
|
974
|
+
options: this.normalizeToastOptions({ ...this.config, ...t }),
|
|
896
975
|
createdAt: Date.now(),
|
|
897
|
-
dismiss: () => this.dismiss(
|
|
898
|
-
update: (i) => this.update(
|
|
976
|
+
dismiss: () => this.dismiss(e),
|
|
977
|
+
update: (i) => this.update(e, i)
|
|
899
978
|
};
|
|
900
|
-
return this.lifecycle.beforeShow(
|
|
901
|
-
|
|
902
|
-
|
|
979
|
+
return this.lifecycle.beforeShow(s).then(async () => {
|
|
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;
|
|
903
983
|
}
|
|
904
|
-
update(t,
|
|
905
|
-
const
|
|
906
|
-
return
|
|
907
|
-
this.
|
|
984
|
+
update(t, e) {
|
|
985
|
+
const s = this.store.getToast(t);
|
|
986
|
+
return s ? (this.lifecycle.beforeUpdate(s, e).then(async () => {
|
|
987
|
+
const i = this.normalizeToastOptions({ ...s.options, ...e });
|
|
988
|
+
this.store.updateToast(t, { options: i }), this.queue.isVisible(t) && await this.renderer.updateToast(s, e), this.lifecycle.afterUpdate(s, e), this.notify();
|
|
908
989
|
}), !0) : !1;
|
|
909
990
|
}
|
|
910
991
|
dismiss(t) {
|
|
911
|
-
const
|
|
912
|
-
return
|
|
913
|
-
this.queue.
|
|
992
|
+
const e = this.store.getToast(t);
|
|
993
|
+
return e ? (this.lifecycle.beforeHide(e).then(async () => {
|
|
994
|
+
const s = this.queue.isVisible(t), i = this.queue.dequeue(t);
|
|
995
|
+
s && await this.renderer.hideToast(e), this.store.removeToast(t), this.lifecycle.afterHide(e), await this.showToasts(i.show), this.notify();
|
|
914
996
|
}), !0) : !1;
|
|
915
997
|
}
|
|
916
998
|
clear() {
|
|
917
|
-
const t = this.
|
|
918
|
-
|
|
919
|
-
this.
|
|
999
|
+
const t = this.queue.clear();
|
|
1000
|
+
Promise.all(t.map((e) => this.hideOne(e, !1))).then(() => {
|
|
1001
|
+
this.store.clear(), this.notify();
|
|
920
1002
|
});
|
|
921
1003
|
}
|
|
922
1004
|
// Promise API
|
|
923
|
-
async promise(t,
|
|
1005
|
+
async promise(t, e) {
|
|
924
1006
|
var i, r;
|
|
925
|
-
const
|
|
1007
|
+
const s = this.show(this.normalizeOptions(e.loading, "loading"));
|
|
926
1008
|
try {
|
|
927
|
-
const
|
|
928
|
-
typeof
|
|
1009
|
+
const o = await t, a = this.normalizeOptions(
|
|
1010
|
+
typeof e.success == "function" ? e.success(o) : e.success,
|
|
929
1011
|
"success"
|
|
930
1012
|
);
|
|
931
|
-
return this.update(
|
|
932
|
-
} catch (
|
|
933
|
-
const
|
|
934
|
-
typeof
|
|
1013
|
+
return a.duration === void 0 && !a.persistent && (a.duration = this.config.duration), this.update(s.id, a), (i = e.onSuccess) == null || i.call(e, o), o;
|
|
1014
|
+
} catch (o) {
|
|
1015
|
+
const a = this.normalizeOptions(
|
|
1016
|
+
typeof e.error == "function" ? e.error(o) : e.error,
|
|
935
1017
|
"error"
|
|
936
1018
|
);
|
|
937
|
-
throw this.update(
|
|
1019
|
+
throw a.duration === void 0 && !a.persistent && (a.duration = this.config.duration), this.update(s.id, a), (r = e.onError) == null || r.call(e, o), o;
|
|
938
1020
|
}
|
|
939
1021
|
}
|
|
940
1022
|
// Group API
|
|
941
|
-
group(t,
|
|
942
|
-
return this.show({ ...
|
|
1023
|
+
group(t, e) {
|
|
1024
|
+
return this.show({ ...e, group: t });
|
|
943
1025
|
}
|
|
944
1026
|
// Plugin API
|
|
945
1027
|
use(t) {
|
|
@@ -947,8 +1029,10 @@ class C {
|
|
|
947
1029
|
}
|
|
948
1030
|
// Configuration
|
|
949
1031
|
configure(t) {
|
|
950
|
-
const
|
|
951
|
-
this.config = { ...this.config, ...t }, this.store.updateConfig(
|
|
1032
|
+
const e = this.config.pauseOnWindowBlur;
|
|
1033
|
+
this.config = this.normalizeConfig({ ...this.config, ...t }), this.store.updateConfig(this.config), this.renderer.updateConfig(this.config);
|
|
1034
|
+
const s = this.queue.updateConfig(this.config);
|
|
1035
|
+
this.hideToasts(s.hide, !0).then(() => this.showToasts(s.show)).then(() => this.notify()), t.pauseOnWindowBlur !== void 0 && t.pauseOnWindowBlur !== e && (this.teardownWindowFocusHandling(), this.setupWindowFocusHandling());
|
|
952
1036
|
}
|
|
953
1037
|
getConfig() {
|
|
954
1038
|
return { ...this.config };
|
|
@@ -957,35 +1041,91 @@ class C {
|
|
|
957
1041
|
getToasts() {
|
|
958
1042
|
return this.store.getAllToasts();
|
|
959
1043
|
}
|
|
1044
|
+
getState() {
|
|
1045
|
+
return {
|
|
1046
|
+
toasts: this.store.getAllToasts(),
|
|
1047
|
+
visible: this.queue.getVisible(),
|
|
1048
|
+
queued: this.queue.getQueued(),
|
|
1049
|
+
groups: this.store.getAllGroups(),
|
|
1050
|
+
config: this.getConfig()
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
subscribe(t) {
|
|
1054
|
+
return this.subscribers.add(t), t(this.getState()), () => {
|
|
1055
|
+
this.subscribers.delete(t);
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
960
1058
|
getGroups() {
|
|
961
1059
|
return this.store.getAllGroups();
|
|
962
1060
|
}
|
|
963
1061
|
// Convenience methods for backward compatibility
|
|
964
|
-
info(t,
|
|
965
|
-
return this.show({ message: t, level: "info", duration:
|
|
1062
|
+
info(t, e) {
|
|
1063
|
+
return this.show({ message: t, level: "info", duration: e });
|
|
966
1064
|
}
|
|
967
|
-
success(t,
|
|
968
|
-
return this.show({ message: t, level: "success", duration:
|
|
1065
|
+
success(t, e) {
|
|
1066
|
+
return this.show({ message: t, level: "success", duration: e });
|
|
969
1067
|
}
|
|
970
|
-
error(t,
|
|
971
|
-
return this.show({ message: t, level: "error", duration:
|
|
1068
|
+
error(t, e) {
|
|
1069
|
+
return this.show({ message: t, level: "error", duration: e });
|
|
972
1070
|
}
|
|
973
|
-
warning(t,
|
|
974
|
-
return this.show({ message: t, level: "warning", duration:
|
|
1071
|
+
warning(t, e) {
|
|
1072
|
+
return this.show({ message: t, level: "warning", duration: e });
|
|
975
1073
|
}
|
|
976
|
-
loading(t,
|
|
977
|
-
return this.show({ message: t, level: "loading", duration:
|
|
1074
|
+
loading(t, e) {
|
|
1075
|
+
return this.show({ message: t, level: "loading", duration: e });
|
|
978
1076
|
}
|
|
979
1077
|
// Utility methods
|
|
980
|
-
normalizeOptions(t,
|
|
981
|
-
return typeof t == "string" ? { message: t, level:
|
|
1078
|
+
normalizeOptions(t, e) {
|
|
1079
|
+
return typeof t == "string" ? { message: t, level: e } : { ...t, level: t.level || e };
|
|
1080
|
+
}
|
|
1081
|
+
normalizeConfig(t) {
|
|
1082
|
+
const e = t.visibleToasts || t.maxVisible || L.maxVisible;
|
|
1083
|
+
return {
|
|
1084
|
+
...t,
|
|
1085
|
+
maxVisible: e,
|
|
1086
|
+
visibleToasts: e
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
normalizeToastOptions(t) {
|
|
1090
|
+
var r, o, a, c;
|
|
1091
|
+
const e = (o = (r = t.closeButton) != null ? r : t.closable) != null ? o : this.config.closeButton, s = t.action ? { ...t.action, primary: (a = t.action.primary) != null ? a : !0 } : void 0, i = [
|
|
1092
|
+
...s ? [s] : [],
|
|
1093
|
+
...t.cancel ? [t.cancel] : [],
|
|
1094
|
+
...t.actions || []
|
|
1095
|
+
];
|
|
1096
|
+
return {
|
|
1097
|
+
...t,
|
|
1098
|
+
closable: e,
|
|
1099
|
+
actions: i.length > 0 ? i : void 0,
|
|
1100
|
+
ariaLive: t.ariaLive || (t.level === "error" || t.important ? "assertive" : "polite"),
|
|
1101
|
+
role: t.role || (t.level === "error" || t.important ? "alert" : "status"),
|
|
1102
|
+
preventDuplicate: (c = t.preventDuplicate) != null ? c : this.config.preventDuplicate,
|
|
1103
|
+
dedupeScope: t.dedupeScope || this.config.dedupeScope
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
async showToasts(t) {
|
|
1107
|
+
for (const e of t)
|
|
1108
|
+
await this.renderer.showToast(e), await this.lifecycle.afterShow(e);
|
|
1109
|
+
}
|
|
1110
|
+
async hideToasts(t, e) {
|
|
1111
|
+
for (const s of t)
|
|
1112
|
+
await this.hideOne(s, e);
|
|
1113
|
+
}
|
|
1114
|
+
async hideOne(t, e) {
|
|
1115
|
+
await this.lifecycle.beforeHide(t), await this.renderer.hideToast(t), e && this.store.removeToast(t.id), await this.lifecycle.afterHide(t);
|
|
1116
|
+
}
|
|
1117
|
+
notify() {
|
|
1118
|
+
if (this.subscribers.size === 0)
|
|
1119
|
+
return;
|
|
1120
|
+
const t = this.getState();
|
|
1121
|
+
this.subscribers.forEach((e) => e(t));
|
|
982
1122
|
}
|
|
983
1123
|
// Editor integration (for RTE)
|
|
984
|
-
onEditorEvent(t,
|
|
985
|
-
this.lifecycle.onEditorEvent(t,
|
|
1124
|
+
onEditorEvent(t, e) {
|
|
1125
|
+
this.lifecycle.onEditorEvent(t, e);
|
|
986
1126
|
}
|
|
987
|
-
triggerEditorEvent(t,
|
|
988
|
-
this.lifecycle.triggerEditorEvent(t,
|
|
1127
|
+
triggerEditorEvent(t, e, ...s) {
|
|
1128
|
+
this.lifecycle.triggerEditorEvent(t, e, ...s);
|
|
989
1129
|
}
|
|
990
1130
|
// Window focus/blur handling
|
|
991
1131
|
setupWindowFocusHandling() {
|
|
@@ -997,17 +1137,17 @@ class C {
|
|
|
997
1137
|
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));
|
|
998
1138
|
}
|
|
999
1139
|
pauseAllToasts() {
|
|
1000
|
-
this.store.getAllToasts().forEach((
|
|
1001
|
-
|
|
1140
|
+
this.store.getAllToasts().forEach((e) => {
|
|
1141
|
+
e.timeoutId && !this.pausedToasts.has(e.id) && (clearTimeout(e.timeoutId), e.timeoutId = void 0, this.pausedToasts.add(e.id));
|
|
1002
1142
|
});
|
|
1003
1143
|
}
|
|
1004
1144
|
resumeAllToasts() {
|
|
1005
|
-
this.store.getAllToasts().forEach((
|
|
1006
|
-
if (this.pausedToasts.has(
|
|
1007
|
-
const
|
|
1008
|
-
|
|
1009
|
-
this.dismiss(
|
|
1010
|
-
},
|
|
1145
|
+
this.store.getAllToasts().forEach((e) => {
|
|
1146
|
+
if (this.pausedToasts.has(e.id) && !e.options.persistent && e.options.duration !== 0) {
|
|
1147
|
+
const s = e.options.duration || this.config.duration;
|
|
1148
|
+
e.timeoutId = window.setTimeout(() => {
|
|
1149
|
+
this.dismiss(e.id);
|
|
1150
|
+
}, s), this.pausedToasts.delete(e.id);
|
|
1011
1151
|
}
|
|
1012
1152
|
});
|
|
1013
1153
|
}
|
|
@@ -1017,71 +1157,88 @@ class C {
|
|
|
1017
1157
|
}
|
|
1018
1158
|
}
|
|
1019
1159
|
let T = null;
|
|
1020
|
-
function
|
|
1021
|
-
return T || (T = new
|
|
1160
|
+
function u() {
|
|
1161
|
+
return T || (T = new k()), T;
|
|
1022
1162
|
}
|
|
1023
|
-
function
|
|
1163
|
+
function x(n) {
|
|
1024
1164
|
return typeof document == "undefined" ? { dismiss: () => {
|
|
1025
|
-
} } :
|
|
1165
|
+
} } : u().show(n);
|
|
1026
1166
|
}
|
|
1027
|
-
function
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
message:
|
|
1032
|
-
...
|
|
1033
|
-
|
|
1034
|
-
level: r.level || void 0,
|
|
1035
|
-
position: r.position || i.position,
|
|
1036
|
-
theme: r.theme || i.theme
|
|
1167
|
+
function S(n, t, e, s) {
|
|
1168
|
+
let i = {};
|
|
1169
|
+
t && typeof t == "object" ? i = { ...t } : typeof t == "number" && (i.duration = t), e && (i.theme = e), s && (i.position = s);
|
|
1170
|
+
const r = {
|
|
1171
|
+
message: n,
|
|
1172
|
+
...i,
|
|
1173
|
+
level: i.level || void 0
|
|
1037
1174
|
};
|
|
1175
|
+
return i.duration !== void 0 && (r.duration = i.duration), i.position && (r.position = i.position), i.theme && (r.theme = i.theme), r;
|
|
1038
1176
|
}
|
|
1039
|
-
const
|
|
1040
|
-
info: (
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1177
|
+
const H = {
|
|
1178
|
+
info: (n, t, e, s) => x({
|
|
1179
|
+
...S(n, t, e, s),
|
|
1180
|
+
level: "info"
|
|
1181
|
+
}),
|
|
1182
|
+
success: (n, t, e, s) => x({
|
|
1183
|
+
...S(n, t, e, s),
|
|
1184
|
+
level: "success"
|
|
1185
|
+
}),
|
|
1186
|
+
error: (n, t, e, s) => x({
|
|
1187
|
+
...S(n, t, e, s),
|
|
1188
|
+
level: "error"
|
|
1189
|
+
}),
|
|
1190
|
+
warning: (n, t, e, s) => x({
|
|
1191
|
+
...S(n, t, e, s),
|
|
1192
|
+
level: "warning"
|
|
1193
|
+
}),
|
|
1194
|
+
loading: (n, t, e, s) => x({
|
|
1195
|
+
...S(n, t, e, s),
|
|
1196
|
+
level: "loading"
|
|
1197
|
+
})
|
|
1198
|
+
}, $ = {
|
|
1046
1199
|
// Core methods
|
|
1047
|
-
show: (
|
|
1048
|
-
update: (
|
|
1049
|
-
dismiss: (
|
|
1050
|
-
clear: () =>
|
|
1200
|
+
show: (n) => u().show(n),
|
|
1201
|
+
update: (n, t) => u().update(n, t),
|
|
1202
|
+
dismiss: (n) => u().dismiss(n),
|
|
1203
|
+
clear: () => u().clear(),
|
|
1051
1204
|
// Convenience methods
|
|
1052
|
-
info: (
|
|
1053
|
-
success: (
|
|
1054
|
-
error: (
|
|
1055
|
-
warning: (
|
|
1056
|
-
loading: (
|
|
1205
|
+
info: (n, t) => u().show({ message: n, level: "info", ...t }),
|
|
1206
|
+
success: (n, t) => u().show({ message: n, level: "success", ...t }),
|
|
1207
|
+
error: (n, t) => u().show({ message: n, level: "error", ...t }),
|
|
1208
|
+
warning: (n, t) => u().show({ message: n, level: "warning", ...t }),
|
|
1209
|
+
loading: (n, t) => u().show({ message: n, level: "loading", ...t }),
|
|
1057
1210
|
// Advanced features
|
|
1058
|
-
promise: (
|
|
1059
|
-
group: (
|
|
1060
|
-
configure: (
|
|
1061
|
-
use: (
|
|
1211
|
+
promise: (n, t) => u().promise(n, t),
|
|
1212
|
+
group: (n, t) => u().group(n, t),
|
|
1213
|
+
configure: (n) => u().configure(n),
|
|
1214
|
+
use: (n) => u().use(n),
|
|
1062
1215
|
// State queries
|
|
1063
|
-
getToasts: () =>
|
|
1064
|
-
getGroups: () =>
|
|
1065
|
-
getConfig: () =>
|
|
1216
|
+
getToasts: () => u().getToasts(),
|
|
1217
|
+
getGroups: () => u().getGroups(),
|
|
1218
|
+
getConfig: () => u().getConfig(),
|
|
1219
|
+
getState: () => u().getState(),
|
|
1220
|
+
subscribe: (n) => u().subscribe(n),
|
|
1066
1221
|
// Editor integration
|
|
1067
|
-
onEditorEvent: (
|
|
1068
|
-
triggerEditorEvent: (
|
|
1222
|
+
onEditorEvent: (n, t) => u().onEditorEvent(n, t),
|
|
1223
|
+
triggerEditorEvent: (n, t, ...e) => u().triggerEditorEvent(n, t, ...e),
|
|
1069
1224
|
// Cleanup
|
|
1070
1225
|
destroy: () => {
|
|
1071
1226
|
T && (T.destroy(), T = null);
|
|
1072
1227
|
}
|
|
1073
1228
|
};
|
|
1074
1229
|
if (typeof window != "undefined" && typeof document != "undefined") {
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1230
|
+
const n = window;
|
|
1231
|
+
n.toast = H, n.toastAdvanced = $, n.toastPro = $, n.ToastManager = k, n.__editoraToastReady || (n.__editoraToastReady = !0, window.dispatchEvent(
|
|
1232
|
+
new CustomEvent("toastReady", {
|
|
1233
|
+
detail: { toast: H, toastAdvanced: $, toastPro: $, ToastManager: k }
|
|
1234
|
+
})
|
|
1235
|
+
));
|
|
1079
1236
|
}
|
|
1080
1237
|
export {
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1238
|
+
k as ToastManager,
|
|
1239
|
+
H as default,
|
|
1240
|
+
H as toast,
|
|
1241
|
+
$ as toastAdvanced,
|
|
1242
|
+
$ as toastPro
|
|
1086
1243
|
};
|
|
1087
1244
|
//# sourceMappingURL=index.esm.js.map
|