wj-elements 0.3.8 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-path.js +16 -2
- package/dist/base-path.js.map +1 -1
- package/dist/dark.css +9 -0
- package/dist/{icon-DVyMc4Wv.js → icon-CReYMzAK.js} +2 -2
- package/dist/{icon-DVyMc4Wv.js.map → icon-CReYMzAK.js.map} +1 -1
- package/dist/light.css +9 -0
- package/dist/packages/utils/permissions.d.ts +9 -9
- package/dist/packages/wje-accordion/accordion.element.d.ts +3 -6
- package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +27 -6
- package/dist/packages/wje-animation/animation.element.d.ts +10 -2
- package/dist/packages/wje-aside/aside.element.d.ts +10 -6
- package/dist/packages/wje-avatar/avatar.element.d.ts +19 -11
- package/dist/packages/wje-carousel/carousel.element.d.ts +78 -3
- package/dist/packages/wje-carousel-item/carousel-item.element.d.ts +5 -0
- package/dist/packages/wje-input/input.element.d.ts +2 -0
- package/dist/packages/wje-textarea/textarea.element.d.ts +2 -0
- package/dist/packages/wje-toast/toast.element.d.ts +80 -10
- package/dist/permissions.js +7 -7
- package/dist/permissions.js.map +1 -1
- package/dist/styles.css +58 -5
- package/dist/wje-accordion-item.js +18 -18
- package/dist/wje-accordion-item.js.map +1 -1
- package/dist/wje-accordion.js.map +1 -1
- package/dist/wje-animation.js +2 -2
- package/dist/wje-animation.js.map +1 -1
- package/dist/wje-aside.js +1 -1
- package/dist/wje-aside.js.map +1 -1
- package/dist/wje-avatar.js.map +1 -1
- package/dist/wje-button.js +1 -1
- package/dist/wje-carousel-item.js +19 -1
- package/dist/wje-carousel-item.js.map +1 -1
- package/dist/wje-carousel.js +208 -57
- package/dist/wje-carousel.js.map +1 -1
- package/dist/wje-element.js +4 -4
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-file-upload-item.js +1 -1
- package/dist/wje-icon.js +1 -1
- package/dist/wje-img-comparer.js +1 -1
- package/dist/wje-input.js +14 -3
- package/dist/wje-input.js.map +1 -1
- package/dist/wje-master.js +1 -1
- package/dist/wje-option.js +1 -1
- package/dist/wje-pagination.js +1 -1
- package/dist/wje-select.js +2 -2
- package/dist/wje-textarea.js +1 -1
- package/dist/wje-textarea.js.map +1 -1
- package/dist/wje-toast.js +383 -11
- package/dist/wje-toast.js.map +1 -1
- package/package.json +4 -3
package/dist/wje-toast.js
CHANGED
|
@@ -4,7 +4,55 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4
4
|
import WJElement from "./wje-element.js";
|
|
5
5
|
import { WjElementUtils } from "./element-utils.js";
|
|
6
6
|
import { event } from "./event.js";
|
|
7
|
-
const styles = "/*\n[ WJ Toast ]\n*/\n\n:host {\n position: relative;\n z-index:
|
|
7
|
+
const styles = "/*\n[ WJ Toast ]\n*/\n\n:host {\n --wje-toast-stack-z: 9999;\n --wje-toast-stack-host-margin-top: 0.5rem;\n --wje-toast-stack-host-margin-bottom: 0.5rem;\n --wje-toast-stack-layout-duration: 0.2s;\n --wje-toast-stack-visual-duration: 0.2s;\n --wje-toast-stack-opacity: 1;\n --wje-toast-stack-shift: 0px;\n --wje-toast-enter-offset: 0px;\n --wje-toast-stack-scale: 1;\n --wje-toast-stack-origin: center top;\n position: relative;\n z-index: var(--wje-toast-stack-z);\n width: 300px;\n max-width: min(100%, calc(100vw - 1rem));\n margin: var(--wje-toast-stack-host-margin-top) 0 var(--wje-toast-stack-host-margin-bottom);\n display: none;\n transition:\n margin-top var(--wje-toast-stack-layout-duration) ease,\n margin-bottom var(--wje-toast-stack-layout-duration) ease;\n}\n\n:host([open]) {\n display: block;\n}\n\n.native-toast {\n display: flex;\n align-items: center;\n padding: 1rem;\n overflow: hidden;\n margin: 0;\n border-width: 1px;\n border-style: solid;\n border-radius: var(--wje-border-radius-large);\n position: relative;\n opacity: var(--wje-toast-stack-opacity);\n transform: translateY(calc(var(--wje-toast-stack-shift) + var(--wje-toast-enter-offset))) scale(var(--wje-toast-stack-scale));\n transform-origin: var(--wje-toast-stack-origin);\n transition:\n transform var(--wje-toast-stack-visual-duration) ease,\n opacity var(--wje-toast-stack-visual-duration) ease;\n\n &.has-media slot[name='media'] {\n flex: 0 0 1.5rem;\n width: 1.5rem;\n display: flex;\n margin-right: 0.5rem;\n justify-content: center;\n }\n\n .content {\n font-size: var(--wje-font-size-small);\n .headline {\n font-size: var(--wje-font-size);\n font-weight: var(--wje-font-weight-bold);\n }\n }\n\n wje-button {\n --wje-button-margin-inline: auto 0;\n margin-left: auto !important;\n }\n\n .countdown {\n position: absolute;\n left: 0;\n bottom: 0;\n width: 100%;\n height: 4px;\n .countdown-bar {\n height: 100%;\n }\n }\n}\n\n:host([position='top']) {\n animation: slideDown 0.3s ease-out forwards;\n top: 1rem;\n left: auto;\n right: auto;\n}\n\n:host::part(icon) {\n margin-right: 0.5rem;\n}\n\n@keyframes slideDown {\n 0% {\n transform: translateY(-100%);\n }\n 100% {\n transform: translateY(0);\n }\n}\n\n/*PRIMARY*/\n:host([color='primary']) .native-toast {\n background-color: var(--wje-color-primary-1);\n color: var(--wje-color-primary-9);\n border-color: var(--wje-color-primary-3);\n}\n\n/*COMPLETE*/\n:host([color='complete']) .native-toast {\n background-color: var(--wje-color-complete-1);\n color: var(--wje-color-complete-9);\n border-color: var(--wje-color-complete-3);\n}\n\n/*SUCCESS*/\n:host([color='success']) .native-toast {\n background-color: var(--wje-color-success-1);\n color: var(--wje-color-success-9);\n border-color: var(--wje-color-success-3);\n}\n\n/*WARNING*/\n:host([color='warning']) .native-toast {\n background-color: var(--wje-color-warning-1);\n color: var(--wje-color-warning-11);\n border-color: var(--wje-color-warning-3);\n}\n\n/*DANGER*/\n:host([color='danger']) .native-toast {\n background-color: var(--wje-color-danger-1);\n color: var(--wje-color-danger-9);\n border-color: var(--wje-color-danger-3);\n}\n\n/*INFO*/\n:host([color='info']) .native-toast {\n background-color: var(--wje-color-info-1);\n color: var(--wje-color-info-11);\n border-color: var(--wje-color-info-4);\n}\n\n/*CONTRAST*/\n:host([color='contrast']) .native-toast {\n background-color: var(--wje-color-contrast-2);\n color: var(--wje-color-contrast-9);\n border-color: var(--wje-color-contrast-3);\n}\n\n/*PRIMARY*/\n:host([color='primary']) .countdown-bar {\n background-color: var(--wje-color-primary-9);\n}\n\n/*COMPLETE*/\n:host([color='complete']) .countdown-bar {\n background-color: var(--wje-color-complete-9);\n}\n\n/*SUCCESS*/\n:host([color='success']) .countdown-bar {\n background-color: var(--wje-color-success-9);\n}\n\n/*WARNING*/\n:host([color='warning']) .countdown-bar {\n background-color: var(--wje-color-warning-9);\n}\n\n/*DANGER*/\n:host([color='danger']) .countdown-bar {\n background-color: var(--wje-color-danger-9);\n}\n\n/*INFO*/\n:host([color='info']) .countdown-bar {\n background-color: var(--wje-color-info-9);\n}\n\n/*CONTRAST*/\n:host([color='contrast']) .countdown-bar {\n background-color: var(--wje-color-contrast-9);\n}\n";
|
|
8
|
+
const DEFAULT_STACK_POSITION = "top-end";
|
|
9
|
+
const DEFAULT_STACK_DEPTH = 3;
|
|
10
|
+
const VALID_STACK_POSITIONS = /* @__PURE__ */ new Set([
|
|
11
|
+
"top-start",
|
|
12
|
+
"top-center",
|
|
13
|
+
"top-end",
|
|
14
|
+
"bottom-start",
|
|
15
|
+
"bottom-center",
|
|
16
|
+
"bottom-end"
|
|
17
|
+
]);
|
|
18
|
+
const STACKED_SCALE_STEP = 0.04;
|
|
19
|
+
const STACKED_MIN_SCALE = 0.88;
|
|
20
|
+
const STACKED_MIN_OPACITY = 0.72;
|
|
21
|
+
const STACKED_VISIBLE_SLICE = 16;
|
|
22
|
+
const STACKED_EXPANDED_MARGIN = "0.5rem";
|
|
23
|
+
const STACKED_PADDING = "1rem";
|
|
24
|
+
const STACKED_ENTER_OFFSET = 24;
|
|
25
|
+
const toggleStackExpanded = (stack, expanded) => {
|
|
26
|
+
if (expanded) {
|
|
27
|
+
stack.dataset.expanded = "true";
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
delete stack.dataset.expanded;
|
|
31
|
+
};
|
|
32
|
+
const syncExpandedStackToasts = (stack, expanded) => {
|
|
33
|
+
Array.from(stack.children).filter((child) => child.tagName === "WJE-TOAST").forEach((toast) => {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
if (expanded) {
|
|
36
|
+
(_a = toast.pause) == null ? void 0 : _a.call(toast);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
(_b = toast.resume) == null ? void 0 : _b.call(toast);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const setStackExpandedState = (stack, expanded) => {
|
|
43
|
+
var _a;
|
|
44
|
+
let shouldExpand = stack.dataset.stacked === "true" && expanded;
|
|
45
|
+
let isExpanded = stack.dataset.expanded === "true";
|
|
46
|
+
if (shouldExpand === isExpanded) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
toggleStackExpanded(stack, shouldExpand);
|
|
50
|
+
syncExpandedStackToasts(stack, shouldExpand);
|
|
51
|
+
(_a = stack.updateToastLayout) == null ? void 0 : _a.call(stack);
|
|
52
|
+
};
|
|
53
|
+
const syncStackExpandedState = (stack) => {
|
|
54
|
+
setStackExpandedState(stack, stack.matches(":hover") || stack.matches(":focus-within"));
|
|
55
|
+
};
|
|
8
56
|
class Toast extends WJElement {
|
|
9
57
|
/**
|
|
10
58
|
* Creates an instance of Toast.
|
|
@@ -54,8 +102,11 @@ class Toast extends WJElement {
|
|
|
54
102
|
* Resumes the countdown animation and resumes the timer.
|
|
55
103
|
*/
|
|
56
104
|
__publicField(this, "resume", () => {
|
|
57
|
-
var _a;
|
|
58
|
-
(_a = this.
|
|
105
|
+
var _a, _b;
|
|
106
|
+
if (((_a = this.toastStack) == null ? void 0 : _a.dataset.expanded) === "true") {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
(_b = this.countdownAnimation) == null ? void 0 : _b.play();
|
|
59
110
|
this.resumeTimer();
|
|
60
111
|
});
|
|
61
112
|
/**
|
|
@@ -67,19 +118,50 @@ class Toast extends WJElement {
|
|
|
67
118
|
*/
|
|
68
119
|
__publicField(this, "start", () => {
|
|
69
120
|
return new Promise((resolve) => {
|
|
70
|
-
|
|
121
|
+
var _a;
|
|
122
|
+
let stack = document.body.querySelector(`.wje-toast-stack[data-stack-key="${this.getToastStackKey()}"]`);
|
|
71
123
|
if (stack) {
|
|
72
124
|
this.toastStack = stack;
|
|
125
|
+
} else {
|
|
126
|
+
this.toastStack = this.createToastStack();
|
|
73
127
|
}
|
|
128
|
+
this.syncToastStack(this.toastStack);
|
|
74
129
|
if (this.toastStack.parentElement === null) {
|
|
75
130
|
document.body.append(this.toastStack);
|
|
76
131
|
}
|
|
77
132
|
this.toastStack.append(this);
|
|
78
|
-
this.
|
|
133
|
+
if (this.stacked) {
|
|
134
|
+
this.toastStack.style.setProperty("--wje-toast-stack-layout-duration", "0s");
|
|
135
|
+
this.toastStack.style.setProperty("--wje-toast-stack-visual-duration", "0s");
|
|
136
|
+
this.style.setProperty(
|
|
137
|
+
"--wje-toast-enter-offset",
|
|
138
|
+
this.stackPosition.startsWith("bottom") ? `${STACKED_ENTER_OFFSET}px` : `-${STACKED_ENTER_OFFSET}px`
|
|
139
|
+
);
|
|
140
|
+
this.style.visibility = "hidden";
|
|
141
|
+
this.show();
|
|
142
|
+
this.updateToastStack(this.toastStack);
|
|
143
|
+
} else {
|
|
144
|
+
this.updateToastStack(this.toastStack);
|
|
145
|
+
this.show();
|
|
146
|
+
}
|
|
147
|
+
if (this.toastStack.dataset.expanded === "true") {
|
|
148
|
+
this.pause();
|
|
149
|
+
}
|
|
150
|
+
requestAnimationFrame(() => {
|
|
151
|
+
this.updateToastStack(this.toastStack);
|
|
152
|
+
if (this.stacked) {
|
|
153
|
+
this.style.removeProperty("visibility");
|
|
154
|
+
this.toastStack.style.removeProperty("--wje-toast-stack-layout-duration");
|
|
155
|
+
this.toastStack.style.removeProperty("--wje-toast-stack-visual-duration");
|
|
156
|
+
requestAnimationFrame(() => this.style.setProperty("--wje-toast-enter-offset", "0px"));
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
(_a = this.updateComplete) == null ? void 0 : _a.then(() => this.updateToastStack(this.toastStack));
|
|
79
160
|
this.addEventListener("wje-toast:after-hide", this.removeChildAndStack);
|
|
161
|
+
resolve(this);
|
|
80
162
|
});
|
|
81
163
|
});
|
|
82
|
-
this.toastStack =
|
|
164
|
+
this.toastStack = this.createToastStack();
|
|
83
165
|
}
|
|
84
166
|
/**
|
|
85
167
|
* Set headline value of the toast.
|
|
@@ -166,6 +248,67 @@ class Toast extends WJElement {
|
|
|
166
248
|
get countdown() {
|
|
167
249
|
return this.hasAttribute("countdown");
|
|
168
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Set stacked value of the toast.
|
|
253
|
+
* @param value
|
|
254
|
+
*/
|
|
255
|
+
set stacked(value) {
|
|
256
|
+
this.toggleAttribute("stacked", WjElementUtils.stringToBoolean(value));
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get stacked value of the toast.
|
|
260
|
+
* @returns {boolean}
|
|
261
|
+
*/
|
|
262
|
+
get stacked() {
|
|
263
|
+
return this.hasAttribute("stacked");
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Set stack depth of the toast.
|
|
267
|
+
* @param value
|
|
268
|
+
*/
|
|
269
|
+
set stackDepth(value) {
|
|
270
|
+
if (value === null || value === void 0 || value === "") {
|
|
271
|
+
this.removeAttribute("stack-depth");
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
this.setAttribute("stack-depth", value);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Get stack depth of the toast.
|
|
278
|
+
* @returns {number}
|
|
279
|
+
*/
|
|
280
|
+
get stackDepth() {
|
|
281
|
+
let value = Number.parseInt(this.getAttribute("stack-depth"), 10);
|
|
282
|
+
if (Number.isFinite(value) && value > 0) {
|
|
283
|
+
return value;
|
|
284
|
+
}
|
|
285
|
+
return DEFAULT_STACK_DEPTH;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Set stack position of the toast.
|
|
289
|
+
* @param value
|
|
290
|
+
*/
|
|
291
|
+
set stackPosition(value) {
|
|
292
|
+
if (!value) {
|
|
293
|
+
this.removeAttribute("stack-position");
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
this.setAttribute("stack-position", value);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Get stack position of the toast.
|
|
300
|
+
* @returns {string}
|
|
301
|
+
*/
|
|
302
|
+
get stackPosition() {
|
|
303
|
+
let value = this.getAttribute("stack-position");
|
|
304
|
+
if (VALID_STACK_POSITIONS.has(value)) {
|
|
305
|
+
return value;
|
|
306
|
+
}
|
|
307
|
+
if (this.getAttribute("position") === "bottom") {
|
|
308
|
+
return "bottom-end";
|
|
309
|
+
}
|
|
310
|
+
return DEFAULT_STACK_POSITION;
|
|
311
|
+
}
|
|
169
312
|
/**
|
|
170
313
|
* Set icon value of the toast.
|
|
171
314
|
* @param value
|
|
@@ -180,6 +323,222 @@ class Toast extends WJElement {
|
|
|
180
323
|
get icon() {
|
|
181
324
|
return this.getAttribute("icon");
|
|
182
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* Creates a toast stack container.
|
|
328
|
+
* @returns {HTMLDivElement}
|
|
329
|
+
*/
|
|
330
|
+
createToastStack() {
|
|
331
|
+
let stack = Object.assign(document.createElement("div"), { className: "wje-toast-stack" });
|
|
332
|
+
stack.addEventListener("mouseenter", () => setStackExpandedState(stack, true));
|
|
333
|
+
stack.addEventListener("mouseleave", () => requestAnimationFrame(() => syncStackExpandedState(stack)));
|
|
334
|
+
stack.addEventListener("focusin", () => setStackExpandedState(stack, true));
|
|
335
|
+
stack.addEventListener("focusout", () => requestAnimationFrame(() => syncStackExpandedState(stack)));
|
|
336
|
+
this.syncToastStack(stack);
|
|
337
|
+
return stack;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Returns the key of the toast stack.
|
|
341
|
+
* @returns {string}
|
|
342
|
+
*/
|
|
343
|
+
getToastStackKey() {
|
|
344
|
+
return `${this.stackPosition}:${this.stacked ? `stacked:${this.stackDepth}` : "default"}`;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Applies the stack placement directly on the element so demo/app layout CSS cannot override it accidentally.
|
|
348
|
+
* @param {HTMLDivElement} stack
|
|
349
|
+
*/
|
|
350
|
+
applyToastStackPlacement(stack = this.toastStack) {
|
|
351
|
+
const positions = {
|
|
352
|
+
"top-start": {
|
|
353
|
+
top: "0",
|
|
354
|
+
bottom: "auto",
|
|
355
|
+
left: "0",
|
|
356
|
+
right: "auto",
|
|
357
|
+
transform: "none",
|
|
358
|
+
margin: "0.5rem"
|
|
359
|
+
},
|
|
360
|
+
"top-center": {
|
|
361
|
+
top: "0",
|
|
362
|
+
bottom: "auto",
|
|
363
|
+
left: "50%",
|
|
364
|
+
right: "auto",
|
|
365
|
+
transform: "translateX(-50%)",
|
|
366
|
+
margin: "0.5rem 0 0"
|
|
367
|
+
},
|
|
368
|
+
"top-end": {
|
|
369
|
+
top: "0",
|
|
370
|
+
bottom: "auto",
|
|
371
|
+
left: "auto",
|
|
372
|
+
right: "0",
|
|
373
|
+
transform: "none",
|
|
374
|
+
margin: "0.5rem"
|
|
375
|
+
},
|
|
376
|
+
"bottom-start": {
|
|
377
|
+
top: "auto",
|
|
378
|
+
bottom: "0",
|
|
379
|
+
left: "0",
|
|
380
|
+
right: "auto",
|
|
381
|
+
transform: "none",
|
|
382
|
+
margin: "0 0.5rem 0.5rem"
|
|
383
|
+
},
|
|
384
|
+
"bottom-center": {
|
|
385
|
+
top: "auto",
|
|
386
|
+
bottom: "0",
|
|
387
|
+
left: "50%",
|
|
388
|
+
right: "auto",
|
|
389
|
+
transform: "translateX(-50%)",
|
|
390
|
+
margin: "0 0 0.5rem"
|
|
391
|
+
},
|
|
392
|
+
"bottom-end": {
|
|
393
|
+
top: "auto",
|
|
394
|
+
bottom: "0",
|
|
395
|
+
left: "auto",
|
|
396
|
+
right: "0",
|
|
397
|
+
transform: "none",
|
|
398
|
+
margin: "0 0.5rem 0.5rem"
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
stack.style.removeProperty("inset-inline");
|
|
402
|
+
stack.style.removeProperty("inset-inline-start");
|
|
403
|
+
stack.style.removeProperty("inset-inline-end");
|
|
404
|
+
Object.assign(stack.style, positions[this.stackPosition] || positions[DEFAULT_STACK_POSITION]);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Applies the current toast stack configuration to a stack element.
|
|
408
|
+
* @param {HTMLDivElement} stack
|
|
409
|
+
*/
|
|
410
|
+
syncToastStack(stack = this.toastStack) {
|
|
411
|
+
stack.dataset.position = this.stackPosition;
|
|
412
|
+
stack.dataset.stackKey = this.getToastStackKey();
|
|
413
|
+
stack.updateToastLayout = () => this.updateToastStack(stack);
|
|
414
|
+
stack.style.display = "flex";
|
|
415
|
+
stack.style.alignItems = "stretch";
|
|
416
|
+
stack.style.width = "min(var(--wje-toast-stack-width, 300px), calc(100vw - 1rem))";
|
|
417
|
+
stack.style.maxWidth = "calc(100vw - 1rem)";
|
|
418
|
+
stack.style.maxHeight = "calc(100vh - 1rem)";
|
|
419
|
+
stack.style.zIndex = "9999";
|
|
420
|
+
this.applyToastStackPlacement(stack);
|
|
421
|
+
if (this.stacked) {
|
|
422
|
+
stack.dataset.stacked = "true";
|
|
423
|
+
stack.dataset.stackDepth = String(this.stackDepth);
|
|
424
|
+
} else {
|
|
425
|
+
delete stack.dataset.stacked;
|
|
426
|
+
delete stack.dataset.stackDepth;
|
|
427
|
+
delete stack.dataset.expanded;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Clears transient stack styling from a toast.
|
|
432
|
+
* @param {Toast} toast
|
|
433
|
+
*/
|
|
434
|
+
clearStackItemStyles(toast) {
|
|
435
|
+
[
|
|
436
|
+
"--wje-toast-stack-scale",
|
|
437
|
+
"--wje-toast-stack-shift",
|
|
438
|
+
"--wje-toast-stack-opacity",
|
|
439
|
+
"--wje-toast-stack-z",
|
|
440
|
+
"--wje-toast-stack-origin",
|
|
441
|
+
"--wje-toast-stack-host-margin-top",
|
|
442
|
+
"--wje-toast-stack-host-margin-bottom",
|
|
443
|
+
"order",
|
|
444
|
+
"position",
|
|
445
|
+
"top",
|
|
446
|
+
"left",
|
|
447
|
+
"right",
|
|
448
|
+
"width",
|
|
449
|
+
"margin",
|
|
450
|
+
"margin-top",
|
|
451
|
+
"margin-bottom"
|
|
452
|
+
].forEach((property) => toast.style.removeProperty(property));
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Measures the rendered height of a toast for stack overlap calculations.
|
|
456
|
+
* @param {Toast} toast
|
|
457
|
+
* @returns {number}
|
|
458
|
+
*/
|
|
459
|
+
getToastVisualHeight(toast) {
|
|
460
|
+
var _a, _b;
|
|
461
|
+
let hostHeight = toast.getBoundingClientRect().height;
|
|
462
|
+
let nativeHeight = ((_b = (_a = toast.shadowRoot) == null ? void 0 : _a.querySelector(".native-toast")) == null ? void 0 : _b.getBoundingClientRect().height) || 0;
|
|
463
|
+
return Math.max(hostHeight, nativeHeight, toast.offsetHeight || 0);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Recomputes the visual order of toasts inside the stack.
|
|
467
|
+
* @param {HTMLDivElement} stack
|
|
468
|
+
*/
|
|
469
|
+
updateToastStack(stack = this.toastStack) {
|
|
470
|
+
var _a, _b;
|
|
471
|
+
let toasts = Array.from(stack.children).filter((child) => child.tagName === "WJE-TOAST");
|
|
472
|
+
let isStacked = stack.dataset.stacked === "true";
|
|
473
|
+
let isExpanded = stack.dataset.expanded === "true";
|
|
474
|
+
let isBottomStack = (_a = stack.dataset.position) == null ? void 0 : _a.startsWith("bottom");
|
|
475
|
+
let transformOrigin = ((_b = stack.dataset.position) == null ? void 0 : _b.startsWith("bottom")) ? "center bottom" : "center top";
|
|
476
|
+
let stackHeight = 0;
|
|
477
|
+
stack.dataset.count = String(toasts.length);
|
|
478
|
+
stack.style.gap = "var(--wje-spacing-x-small)";
|
|
479
|
+
stack.style.flexDirection = "column";
|
|
480
|
+
stack.style.overflow = isStacked ? isExpanded ? "auto" : "visible" : "auto";
|
|
481
|
+
if (isStacked) {
|
|
482
|
+
stack.style.paddingTop = isExpanded ? isBottomStack ? STACKED_PADDING : "0px" : STACKED_PADDING;
|
|
483
|
+
stack.style.paddingBottom = isExpanded ? isBottomStack ? "0px" : STACKED_PADDING : STACKED_PADDING;
|
|
484
|
+
} else {
|
|
485
|
+
stack.style.removeProperty("padding-top");
|
|
486
|
+
stack.style.removeProperty("padding-bottom");
|
|
487
|
+
}
|
|
488
|
+
if (!isStacked || isExpanded) {
|
|
489
|
+
stack.style.removeProperty("height");
|
|
490
|
+
}
|
|
491
|
+
toasts.forEach((toast, index) => {
|
|
492
|
+
this.clearStackItemStyles(toast);
|
|
493
|
+
toast.style.setProperty("--wje-toast-stack-z", String(index + 1));
|
|
494
|
+
if (!isStacked) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
if (isExpanded) {
|
|
498
|
+
let visualOrder = isBottomStack ? index : toasts.length - index - 1;
|
|
499
|
+
let isVisualFirst = visualOrder === 0;
|
|
500
|
+
let isVisualLast = visualOrder === toasts.length - 1;
|
|
501
|
+
toast.style.setProperty("--wje-toast-stack-scale", "1.000");
|
|
502
|
+
toast.style.setProperty("--wje-toast-stack-shift", "0px");
|
|
503
|
+
toast.style.setProperty("--wje-toast-stack-opacity", "1.000");
|
|
504
|
+
toast.style.setProperty("--wje-toast-stack-origin", transformOrigin);
|
|
505
|
+
toast.style.order = String(visualOrder);
|
|
506
|
+
toast.style.width = "100%";
|
|
507
|
+
toast.style.setProperty(
|
|
508
|
+
"--wje-toast-stack-host-margin-top",
|
|
509
|
+
isBottomStack && !isVisualFirst ? STACKED_EXPANDED_MARGIN : "0px"
|
|
510
|
+
);
|
|
511
|
+
toast.style.setProperty(
|
|
512
|
+
"--wje-toast-stack-host-margin-bottom",
|
|
513
|
+
!isBottomStack && !isVisualLast ? STACKED_EXPANDED_MARGIN : "0px"
|
|
514
|
+
);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
let toastHeight = this.getToastVisualHeight(toast);
|
|
518
|
+
let maxDepth = Math.max(0, this.stackDepth - 1);
|
|
519
|
+
let visibleLevels = Math.min(toasts.length, this.stackDepth);
|
|
520
|
+
let depth = Math.min(toasts.length - index - 1, maxDepth);
|
|
521
|
+
let visibleIndex = Math.max(0, index - Math.max(0, toasts.length - this.stackDepth));
|
|
522
|
+
let targetTop = isBottomStack ? visibleIndex * STACKED_VISIBLE_SLICE : (visibleLevels - 1 - visibleIndex) * STACKED_VISIBLE_SLICE;
|
|
523
|
+
let scale = Math.max(STACKED_MIN_SCALE, 1 - depth * STACKED_SCALE_STEP);
|
|
524
|
+
let opacity = Math.max(STACKED_MIN_OPACITY, 1 - depth * 0.08);
|
|
525
|
+
toast.style.setProperty("--wje-toast-stack-scale", scale.toFixed(3));
|
|
526
|
+
toast.style.setProperty("--wje-toast-stack-shift", "0px");
|
|
527
|
+
toast.style.setProperty("--wje-toast-stack-opacity", opacity.toFixed(3));
|
|
528
|
+
toast.style.setProperty("--wje-toast-stack-origin", transformOrigin);
|
|
529
|
+
toast.style.position = "absolute";
|
|
530
|
+
toast.style.top = `${targetTop}px`;
|
|
531
|
+
toast.style.left = "0";
|
|
532
|
+
toast.style.right = "0";
|
|
533
|
+
toast.style.width = "100%";
|
|
534
|
+
toast.style.setProperty("--wje-toast-stack-host-margin-top", "0px");
|
|
535
|
+
toast.style.setProperty("--wje-toast-stack-host-margin-bottom", "0px");
|
|
536
|
+
stackHeight = Math.max(stackHeight, targetTop + toastHeight);
|
|
537
|
+
});
|
|
538
|
+
if (isStacked && !isExpanded) {
|
|
539
|
+
stack.style.height = `${stackHeight}px`;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
183
542
|
/**
|
|
184
543
|
* Returns the CSS stylesheet for the component.
|
|
185
544
|
* @static
|
|
@@ -294,6 +653,7 @@ class Toast extends WJElement {
|
|
|
294
653
|
if (this.timeoutID) {
|
|
295
654
|
clearTimeout(this.timeoutID);
|
|
296
655
|
}
|
|
656
|
+
this.isTimerPaused = false;
|
|
297
657
|
this.timeoutID = window.setTimeout(() => {
|
|
298
658
|
this.hide();
|
|
299
659
|
}, this.remainingTime);
|
|
@@ -304,11 +664,14 @@ class Toast extends WJElement {
|
|
|
304
664
|
* The method is called when the toast notification is paused.
|
|
305
665
|
*/
|
|
306
666
|
stopTimer() {
|
|
307
|
-
if (this.timeoutID) {
|
|
308
|
-
|
|
667
|
+
if (!this.timeoutID || this.isTimerPaused) {
|
|
668
|
+
return;
|
|
309
669
|
}
|
|
670
|
+
window.clearTimeout(this.timeoutID);
|
|
671
|
+
this.timeoutID = null;
|
|
310
672
|
const elapsedTime = Date.now() - this.startTime;
|
|
311
|
-
this.remainingTime
|
|
673
|
+
this.remainingTime = Math.max(0, this.remainingTime - elapsedTime);
|
|
674
|
+
this.isTimerPaused = true;
|
|
312
675
|
}
|
|
313
676
|
/**
|
|
314
677
|
* Resumes the timer.
|
|
@@ -316,7 +679,7 @@ class Toast extends WJElement {
|
|
|
316
679
|
* than zero. The method is called when the toast notification is resumed.
|
|
317
680
|
*/
|
|
318
681
|
resumeTimer() {
|
|
319
|
-
if (this.remainingTime > 0) {
|
|
682
|
+
if (this.isTimerPaused && this.remainingTime > 0) {
|
|
320
683
|
this.startTimer();
|
|
321
684
|
}
|
|
322
685
|
}
|
|
@@ -328,7 +691,16 @@ class Toast extends WJElement {
|
|
|
328
691
|
* empty.
|
|
329
692
|
*/
|
|
330
693
|
removeChildAndStack() {
|
|
331
|
-
this.toastStack
|
|
694
|
+
if (this.parentElement === this.toastStack) {
|
|
695
|
+
this.toastStack.removeChild(this);
|
|
696
|
+
}
|
|
697
|
+
this.toastStack.style.setProperty("--wje-toast-stack-layout-duration", "0s");
|
|
698
|
+
this.toastStack.style.setProperty("--wje-toast-stack-visual-duration", "0s");
|
|
699
|
+
this.updateToastStack(this.toastStack);
|
|
700
|
+
requestAnimationFrame(() => {
|
|
701
|
+
this.toastStack.style.removeProperty("--wje-toast-stack-layout-duration");
|
|
702
|
+
this.toastStack.style.removeProperty("--wje-toast-stack-visual-duration");
|
|
703
|
+
});
|
|
332
704
|
if (this.toastStack.querySelector("wje-toast") === null) {
|
|
333
705
|
this.toastStack.remove();
|
|
334
706
|
}
|
package/dist/wje-toast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-toast.js","sources":["../packages/wje-toast/toast.element.js","../packages/wje-toast/toast.js"],"sourcesContent":["import { default as WJElement, WjElementUtils, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Toast` is a custom web component that represents a toast notification.\n * @summary This element represents a toast notification.\n * @documentation https://elements.webjet.sk/components/toast\n * @status stable\n * @augments {WJElement}\n * @csspart native - The native part\n * @cssproperty {string} headline - Specifies the headline text of the toast. Represents the main title or heading displayed in the toast.\n * @cssproperty {boolean} open - Indicates whether the toast is currently open (visible). A value of `true` shows the toast, while `false` hides it.\n * @cssproperty {number} duration - Determines the duration (in milliseconds) for which the toast is displayed. After this time, the toast will automatically close unless it is manually closed.\n * @cssproperty {boolean} closable - Specifies whether the toast can be manually closed by the user. If `true`, the toast will include a close button or mechanism.\n * @cssproperty {string} color - Defines the color of the toast. Accepts any valid CSS color value such as `hex`, `RGB`, or named colors.\n * @cssproperty {boolean} countdown - Indicates whether a countdown is displayed in the toast. When `true`, a visual countdown timer is shown to indicate the remaining time before the toast closes.\n * @slot - The content of the toast.\n * @slot media - The media of the toast.\n * // @fires wje-toast:after-show - Fired after the toast is shown.\n * // @fires wje-toast:after-hide - Fired after the toast is hidden.\n */\n\nexport default class Toast extends WJElement {\n /**\n * Creates an instance of Toast.\n */\n constructor() {\n super();\n\n this.toastStack = Object.assign(document.createElement('div'), { className: 'wje-toast-stack' });\n }\n\n /**\n * Set headline value of the toast.\n * @param value\n */\n set headline(value) {\n this.setAttribute('headline', value);\n }\n\n /**\n * Get headline value of the toast.\n * @returns {string}\n */\n get headline() {\n return this.getAttribute('headline');\n }\n\n /**\n * Set open value of the toast.\n * @param value\n */\n set open(value) {\n this.removeAttribute('open');\n\n if (WjElementUtils.stringToBoolean(value)) this.setAttribute('open', value);\n }\n\n /**\n * Get open value of the toast.\n * @returns {boolean}\n */\n get open() {\n return this.hasAttribute('open');\n }\n\n /**\n * Set duration value of the toast.\n * @param value\n */\n set duration(value) {\n this.setAttribute('duration', value);\n }\n\n /**\n * Get duration value of the toast.\n * @returns {number}\n */\n get duration() {\n return +this.getAttribute('duration');\n }\n\n /**\n * Set closable value of the toast.\n * @param value\n */\n set closable(value) {\n this.setAttribute('closable', value || '');\n }\n\n /**\n * Get closable value of the toast.\n * @returns {boolean}\n */\n get closable() {\n return this.hasAttribute('closable');\n }\n\n /**\n * Set color value of the toast.\n * @param value\n */\n set color(value) {\n this.setAttribute('color', value);\n }\n\n /**\n * Get color value of the toast.\n * @returns {string}\n */\n get color() {\n return this.getAttribute('color');\n }\n\n /**\n * Set countdown value of the toast.\n * @param value\n */\n set countdown(value) {\n if (value) this.setAttribute('countdown', value);\n }\n\n /**\n * Get countdown value of the toast.\n * @returns {boolean}\n */\n get countdown() {\n return this.hasAttribute('countdown');\n }\n\n /**\n * Set icon value of the toast.\n * @param value\n */\n set icon(value) {\n this.setAttribute('icon', value);\n }\n\n /**\n * Get icon value of the toast.\n * @returns {string}\n */\n get icon() {\n return this.getAttribute('icon');\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Toast';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Setup attributes for the Button element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({\n role: 'status',\n });\n }\n\n /**\n * Draw method for the toast notification.\n * @returns {object} Document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-toast');\n\n let mediaSlot = document.createElement('slot');\n mediaSlot.setAttribute('name', 'media');\n mediaSlot.classList.add('media');\n mediaSlot.addEventListener('slotchange', () => {\n if (WjElementUtils.hasSlotContent(this.context, 'media')) {\n mediaSlot.parentElement.classList.add('has-media');\n } else {\n mediaSlot.parentElement.classList.remove('has-media');\n }\n });\n\n let content = document.createElement('div');\n content.classList.add('content');\n content.innerHTML = `<div class=\"headline\">${this.headline}</div><div class=\"message\"><slot></slot></div>`;\n\n let iconX = document.createElement('wje-icon');\n iconX.setAttribute('name', 'x');\n\n let closeBtn = document.createElement('wje-button');\n closeBtn.setAttribute('fill', 'link');\n closeBtn.setAttribute('color', this.color);\n closeBtn.setAttribute('size', 'small');\n closeBtn.classList.add('close');\n closeBtn.setAttribute('aria-label', 'Close');\n\n let countdownEl = document.createElement('div');\n countdownEl.classList.add('countdown');\n\n let countdownBar = document.createElement('div');\n countdownBar.classList.add('countdown-bar');\n\n closeBtn.appendChild(iconX);\n countdownEl.appendChild(countdownBar);\n\n if (this.hasAttribute('icon') && this.icon) {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', this.icon);\n icon.setAttribute('color', this.color);\n icon.setAttribute('slot', 'media');\n icon.setAttribute('part', 'icon');\n\n this.appendChild(icon);\n }\n\n native.appendChild(mediaSlot);\n native.appendChild(content);\n\n if (this.closable) native.appendChild(closeBtn);\n\n if (this.hasAttribute('countdown')) native.appendChild(countdownEl);\n\n fragment.appendChild(native);\n\n this.closeBtn = closeBtn;\n this.countdownBar = countdownBar;\n\n return fragment;\n }\n\n /**\n * After draw method for the toast notification.\n */\n afterDraw() {\n this.closeBtn.addEventListener('wje-button:click', this.hide);\n this.addEventListener('mouseenter', this.pause);\n this.addEventListener('mouseleave', this.resume);\n\n if (this.hasAttribute('countdown')) {\n const startWidth = '100%';\n const endWidth = '0';\n\n this.countdownAnimation = this.countdownBar.animate([{ width: startWidth }, { width: endWidth }], {\n duration: this.duration,\n easing: 'linear',\n });\n }\n\n if (this.duration > 0) {\n this.remainingTime = this.duration;\n this.startTimer();\n }\n }\n\n /**\n * Before disconnect method\n * This method is called before the element is disconnected from the document.\n */\n beforeDisconnect() {\n this.closeBtn?.removeEventListener('wje-button:click', this.hide);\n this.removeEventListener('wje-toast:after-hide', this.removeChildAndStack);\n this.removeEventListener('mouseenter', this.pause);\n this.removeEventListener('mouseleave', this.resume);\n\n clearTimeout(this.timeoutID);\n }\n\n /**\n * Starts the timer.\n * This method sets the `startTime` property to the current time and sets\n * the `timeoutID` property to the ID of the timeout. The method also\n * dispatches the `wje-toast:after-hide` custom event when the timeout\n * expires.\n */\n startTimer() {\n this.startTime = Date.now();\n if (this.timeoutID) {\n clearTimeout(this.timeoutID);\n }\n this.timeoutID = window.setTimeout(() => {\n this.hide();\n }, this.remainingTime);\n }\n\n /**\n * Stops the timer.\n * This method clears the timeout and calculates the remaining time.\n * The method is called when the toast notification is paused.\n */\n stopTimer() {\n if (this.timeoutID) {\n window.clearTimeout(this.timeoutID);\n }\n const elapsedTime = Date.now() - this.startTime;\n this.remainingTime -= elapsedTime;\n }\n\n /**\n * Resumes the timer.\n * This method resumes the timer if the remaining time is greater\n * than zero. The method is called when the toast notification is resumed.\n */\n resumeTimer() {\n if (this.remainingTime > 0) {\n this.startTimer();\n }\n }\n\n /**\n * Asynchronously shows the toast notification.\n * This method sets the `open` property to `true` and dispatches the\n * `wje-toast:after-show` custom event. If the toast is already open,\n * the method returns `undefined`.\n */\n show = () => {\n if (this.open) {\n return;\n }\n\n this.open = true;\n event.dispatchCustomEvent(this, 'wje-toast:after-show');\n };\n\n /**\n * Asynchronously hides the toast notification.\n * This method sets the `open` property to `false` and dispatches the\n * `wje-toast:after-hide` custom event. If the toast is already hidden,\n * the method returns `undefined`.\n */\n hide = () => {\n if (!this.open) {\n return;\n }\n\n this.open = false;\n event.dispatchCustomEvent(this, 'wje-toast:after-hide');\n };\n\n /**\n * Pauses the countdown animation and stops the timer.\n */\n pause = () => {\n this.countdownAnimation?.pause();\n this.stopTimer();\n };\n\n /**\n * Resumes the countdown animation and resumes the timer.\n */\n resume = () => {\n this.countdownAnimation?.play();\n this.resumeTimer();\n };\n\n /**\n * Removes the toast notification and the toast stack.\n *\n * This method removes the toast notification from the toast stack and\n * removes the toast stack from the document body if the toast stack is\n * empty.\n */\n removeChildAndStack() {\n this.toastStack.removeChild(this);\n\n if (this.toastStack.querySelector('wje-toast') === null) {\n this.toastStack.remove();\n }\n }\n\n /**\n * Asynchronously starts the toast notification.\n * This method appends the toast notification to the document body and\n * shows the toast notification. The method returns a promise that\n * resolves when the toast notification is shown.\n * @returns {Promise<unknown>}\n */\n start = () => {\n return new Promise((resolve) => {\n let stack = document.body.querySelector('.wje-toast-stack');\n if (stack) {\n this.toastStack = stack;\n }\n\n if (this.toastStack.parentElement === null) {\n document.body.append(this.toastStack);\n }\n\n this.toastStack.append(this);\n\n this.show();\n\n this.addEventListener('wje-toast:after-hide', this.removeChildAndStack);\n });\n };\n}\n","import Toast from './toast.element.js';\n\nexport default Toast;\n\nToast.define('wje-toast', Toast);\n"],"names":[],"mappings":";;;;;;;AAsBe,MAAM,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA,EAIzC,cAAc;AACV,UAAK;AA2HT;AAAA;AAAA;AAAA;AAAA,qCAAY;AA+KZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAO,MAAM;AACT,UAAI,KAAK,MAAM;AACX;AAAA,MACJ;AAEA,WAAK,OAAO;AACZ,YAAM,oBAAoB,MAAM,sBAAsB;AAAA,IAC1D;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAO,MAAM;AACT,UAAI,CAAC,KAAK,MAAM;AACZ;AAAA,MACJ;AAEA,WAAK,OAAO;AACZ,YAA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AChB,aAAO,aAAa,KAAK,SAAS;AAAA,IACtC;AACA,UAAM,cAAc,KAAK,IAAG,IAAK,KAAK;AACtC,SAAK,iBAAiB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,cAAc;AACV,QAAI,KAAK,gBAAgB,GAAG;AACxB,WAAK,WAAU;AAAA,IACnB;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuDA,sBAAsB;AAClB,SAAK,WAAW,YAAY,IAAI;AAEhC,QAAI,KAAK,WAAW,cAAc,WAAW,MAAM,MAAM;AACrD,WAAK,WAAW,OAAM;AAAA,IAC1B;AAAA,EACJ;AA2BJ;ACjZA,MAAM,OAAO,aAAa,KAAK;"}
|
|
1
|
+
{"version":3,"file":"wje-toast.js","sources":["../packages/wje-toast/toast.element.js","../packages/wje-toast/toast.js"],"sourcesContent":["import { default as WJElement, WjElementUtils, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\nconst DEFAULT_STACK_POSITION = 'top-end';\nconst DEFAULT_STACK_DEPTH = 3;\nconst VALID_STACK_POSITIONS = new Set([\n 'top-start',\n 'top-center',\n 'top-end',\n 'bottom-start',\n 'bottom-center',\n 'bottom-end',\n]);\nconst STACKED_SCALE_STEP = 0.04;\nconst STACKED_MIN_SCALE = 0.88;\nconst STACKED_MIN_OPACITY = 0.72;\nconst STACKED_VISIBLE_SLICE = 16;\nconst STACKED_EXPANDED_MARGIN = '0.5rem';\nconst STACKED_PADDING = '1rem';\nconst STACKED_ENTER_OFFSET = 24;\n\nconst toggleStackExpanded = (stack, expanded) => {\n if (expanded) {\n stack.dataset.expanded = 'true';\n return;\n }\n\n delete stack.dataset.expanded;\n};\n\nconst syncExpandedStackToasts = (stack, expanded) => {\n Array.from(stack.children)\n .filter((child) => child.tagName === 'WJE-TOAST')\n .forEach((toast) => {\n if (expanded) {\n toast.pause?.();\n return;\n }\n\n toast.resume?.();\n });\n};\n\nconst setStackExpandedState = (stack, expanded) => {\n let shouldExpand = stack.dataset.stacked === 'true' && expanded;\n let isExpanded = stack.dataset.expanded === 'true';\n\n if (shouldExpand === isExpanded) {\n return;\n }\n\n toggleStackExpanded(stack, shouldExpand);\n syncExpandedStackToasts(stack, shouldExpand);\n stack.updateToastLayout?.();\n};\n\nconst syncStackExpandedState = (stack) => {\n setStackExpandedState(stack, stack.matches(':hover') || stack.matches(':focus-within'));\n};\n\n/**\n * `Toast` is a custom web component that represents a toast notification.\n * @summary This element represents a toast notification.\n * @documentation https://elements.webjet.sk/components/toast\n * @status stable\n * @augments {WJElement}\n * @csspart native - The native part\n * @slot - The content of the toast.\n * @slot media - The media of the toast.\n * @attribute {string} headline - Specifies the headline text of the toast. Represents the main title or heading displayed in the toast.\n * @attribute {boolean} open - Indicates whether the toast is currently open (visible). A value of `true` shows the toast, while `false` hides it.\n * @attribute {number} duration - Determines the duration (in milliseconds) for which the toast is displayed. After this time, the toast will automatically close unless it is manually closed.\n * @attribute {boolean} closable - Specifies whether the toast can be manually closed by the user. If `true`, the toast will include a close button or mechanism.\n * @attribute {string} color - Defines the color variant of the toast. Supports values such as `primary`, `complete`, `success`, `warning`, `danger`, `info`, and `contrast`.\n * @attribute {boolean} countdown - Indicates whether a countdown is displayed in the toast. When `true`, a visual countdown timer is shown to indicate the remaining time before the toast closes.\n * @attribute {boolean} stacked - Enables a layered toast stack where the newest toast stays visually on top while older ones shrink behind it.\n * @attribute {string} stack-position - Defines where the toast stack is placed on the screen. Supports `top-start`, `top-center`, `top-end`, `bottom-start`, `bottom-center`, and `bottom-end`.\n * @attribute {number} stack-depth - Defines how many visual levels the collapsed stacked toast can show. Older toasts beyond this limit stay at the last reduced level. Default is `3`.\n * @attribute {string} icon - Adds a leading icon into the `media` slot by icon name.\n * @cssproperty [--wje-toast-stack-width=300px] - Defines the width of the toast stack container. Useful for centered stacked toasts and demo layouts.\n * // @fires wje-toast:after-show - Fired after the toast is shown.\n * // @fires wje-toast:after-hide - Fired after the toast is hidden.\n */\n\nexport default class Toast extends WJElement {\n /**\n * Creates an instance of Toast.\n */\n constructor() {\n super();\n\n this.toastStack = this.createToastStack();\n }\n\n /**\n * Set headline value of the toast.\n * @param value\n */\n set headline(value) {\n this.setAttribute('headline', value);\n }\n\n /**\n * Get headline value of the toast.\n * @returns {string}\n */\n get headline() {\n return this.getAttribute('headline');\n }\n\n /**\n * Set open value of the toast.\n * @param value\n */\n set open(value) {\n this.removeAttribute('open');\n\n if (WjElementUtils.stringToBoolean(value)) this.setAttribute('open', value);\n }\n\n /**\n * Get open value of the toast.\n * @returns {boolean}\n */\n get open() {\n return this.hasAttribute('open');\n }\n\n /**\n * Set duration value of the toast.\n * @param value\n */\n set duration(value) {\n this.setAttribute('duration', value);\n }\n\n /**\n * Get duration value of the toast.\n * @returns {number}\n */\n get duration() {\n return +this.getAttribute('duration');\n }\n\n /**\n * Set closable value of the toast.\n * @param value\n */\n set closable(value) {\n this.setAttribute('closable', value || '');\n }\n\n /**\n * Get closable value of the toast.\n * @returns {boolean}\n */\n get closable() {\n return this.hasAttribute('closable');\n }\n\n /**\n * Set color value of the toast.\n * @param value\n */\n set color(value) {\n this.setAttribute('color', value);\n }\n\n /**\n * Get color value of the toast.\n * @returns {string}\n */\n get color() {\n return this.getAttribute('color');\n }\n\n /**\n * Set countdown value of the toast.\n * @param value\n */\n set countdown(value) {\n if (value) this.setAttribute('countdown', value);\n }\n\n /**\n * Get countdown value of the toast.\n * @returns {boolean}\n */\n get countdown() {\n return this.hasAttribute('countdown');\n }\n\n /**\n * Set stacked value of the toast.\n * @param value\n */\n set stacked(value) {\n this.toggleAttribute('stacked', WjElementUtils.stringToBoolean(value));\n }\n\n /**\n * Get stacked value of the toast.\n * @returns {boolean}\n */\n get stacked() {\n return this.hasAttribute('stacked');\n }\n\n /**\n * Set stack depth of the toast.\n * @param value\n */\n set stackDepth(value) {\n if (value === null || value === undefined || value === '') {\n this.removeAttribute('stack-depth');\n return;\n }\n\n this.setAttribute('stack-depth', value);\n }\n\n /**\n * Get stack depth of the toast.\n * @returns {number}\n */\n get stackDepth() {\n let value = Number.parseInt(this.getAttribute('stack-depth'), 10);\n\n if (Number.isFinite(value) && value > 0) {\n return value;\n }\n\n return DEFAULT_STACK_DEPTH;\n }\n\n /**\n * Set stack position of the toast.\n * @param value\n */\n set stackPosition(value) {\n if (!value) {\n this.removeAttribute('stack-position');\n return;\n }\n\n this.setAttribute('stack-position', value);\n }\n\n /**\n * Get stack position of the toast.\n * @returns {string}\n */\n get stackPosition() {\n let value = this.getAttribute('stack-position');\n\n if (VALID_STACK_POSITIONS.has(value)) {\n return value;\n }\n\n if (this.getAttribute('position') === 'bottom') {\n return 'bottom-end';\n }\n\n return DEFAULT_STACK_POSITION;\n }\n\n /**\n * Set icon value of the toast.\n * @param value\n */\n set icon(value) {\n this.setAttribute('icon', value);\n }\n\n /**\n * Get icon value of the toast.\n * @returns {string}\n */\n get icon() {\n return this.getAttribute('icon');\n }\n\n /**\n * Creates a toast stack container.\n * @returns {HTMLDivElement}\n */\n createToastStack() {\n let stack = Object.assign(document.createElement('div'), { className: 'wje-toast-stack' });\n\n stack.addEventListener('mouseenter', () => setStackExpandedState(stack, true));\n stack.addEventListener('mouseleave', () => requestAnimationFrame(() => syncStackExpandedState(stack)));\n stack.addEventListener('focusin', () => setStackExpandedState(stack, true));\n stack.addEventListener('focusout', () => requestAnimationFrame(() => syncStackExpandedState(stack)));\n\n this.syncToastStack(stack);\n\n return stack;\n }\n\n /**\n * Returns the key of the toast stack.\n * @returns {string}\n */\n getToastStackKey() {\n return `${this.stackPosition}:${this.stacked ? `stacked:${this.stackDepth}` : 'default'}`;\n }\n\n /**\n * Applies the stack placement directly on the element so demo/app layout CSS cannot override it accidentally.\n * @param {HTMLDivElement} stack\n */\n applyToastStackPlacement(stack = this.toastStack) {\n const positions = {\n 'top-start': {\n top: '0',\n bottom: 'auto',\n left: '0',\n right: 'auto',\n transform: 'none',\n margin: '0.5rem',\n },\n 'top-center': {\n top: '0',\n bottom: 'auto',\n left: '50%',\n right: 'auto',\n transform: 'translateX(-50%)',\n margin: '0.5rem 0 0',\n },\n 'top-end': {\n top: '0',\n bottom: 'auto',\n left: 'auto',\n right: '0',\n transform: 'none',\n margin: '0.5rem',\n },\n 'bottom-start': {\n top: 'auto',\n bottom: '0',\n left: '0',\n right: 'auto',\n transform: 'none',\n margin: '0 0.5rem 0.5rem',\n },\n 'bottom-center': {\n top: 'auto',\n bottom: '0',\n left: '50%',\n right: 'auto',\n transform: 'translateX(-50%)',\n margin: '0 0 0.5rem',\n },\n 'bottom-end': {\n top: 'auto',\n bottom: '0',\n left: 'auto',\n right: '0',\n transform: 'none',\n margin: '0 0.5rem 0.5rem',\n },\n };\n\n stack.style.removeProperty('inset-inline');\n stack.style.removeProperty('inset-inline-start');\n stack.style.removeProperty('inset-inline-end');\n Object.assign(stack.style, positions[this.stackPosition] || positions[DEFAULT_STACK_POSITION]);\n }\n\n /**\n * Applies the current toast stack configuration to a stack element.\n * @param {HTMLDivElement} stack\n */\n syncToastStack(stack = this.toastStack) {\n stack.dataset.position = this.stackPosition;\n stack.dataset.stackKey = this.getToastStackKey();\n stack.updateToastLayout = () => this.updateToastStack(stack);\n stack.style.display = 'flex';\n stack.style.alignItems = 'stretch';\n stack.style.width = 'min(var(--wje-toast-stack-width, 300px), calc(100vw - 1rem))';\n stack.style.maxWidth = 'calc(100vw - 1rem)';\n stack.style.maxHeight = 'calc(100vh - 1rem)';\n stack.style.zIndex = '9999';\n this.applyToastStackPlacement(stack);\n\n if (this.stacked) {\n stack.dataset.stacked = 'true';\n stack.dataset.stackDepth = String(this.stackDepth);\n } else {\n delete stack.dataset.stacked;\n delete stack.dataset.stackDepth;\n delete stack.dataset.expanded;\n }\n }\n\n /**\n * Clears transient stack styling from a toast.\n * @param {Toast} toast\n */\n clearStackItemStyles(toast) {\n [\n '--wje-toast-stack-scale',\n '--wje-toast-stack-shift',\n '--wje-toast-stack-opacity',\n '--wje-toast-stack-z',\n '--wje-toast-stack-origin',\n '--wje-toast-stack-host-margin-top',\n '--wje-toast-stack-host-margin-bottom',\n 'order',\n 'position',\n 'top',\n 'left',\n 'right',\n 'width',\n 'margin',\n 'margin-top',\n 'margin-bottom',\n ].forEach((property) => toast.style.removeProperty(property));\n }\n\n /**\n * Measures the rendered height of a toast for stack overlap calculations.\n * @param {Toast} toast\n * @returns {number}\n */\n getToastVisualHeight(toast) {\n let hostHeight = toast.getBoundingClientRect().height;\n let nativeHeight = toast.shadowRoot?.querySelector('.native-toast')?.getBoundingClientRect().height || 0;\n\n return Math.max(hostHeight, nativeHeight, toast.offsetHeight || 0);\n }\n\n /**\n * Recomputes the visual order of toasts inside the stack.\n * @param {HTMLDivElement} stack\n */\n updateToastStack(stack = this.toastStack) {\n let toasts = Array.from(stack.children).filter((child) => child.tagName === 'WJE-TOAST');\n let isStacked = stack.dataset.stacked === 'true';\n let isExpanded = stack.dataset.expanded === 'true';\n let isBottomStack = stack.dataset.position?.startsWith('bottom');\n let transformOrigin = stack.dataset.position?.startsWith('bottom') ? 'center bottom' : 'center top';\n let stackHeight = 0;\n\n stack.dataset.count = String(toasts.length);\n stack.style.gap = 'var(--wje-spacing-x-small)';\n stack.style.flexDirection = 'column';\n stack.style.overflow = isStacked ? (isExpanded ? 'auto' : 'visible') : 'auto';\n\n if (isStacked) {\n stack.style.paddingTop = isExpanded ? (isBottomStack ? STACKED_PADDING : '0px') : STACKED_PADDING;\n stack.style.paddingBottom = isExpanded ? (isBottomStack ? '0px' : STACKED_PADDING) : STACKED_PADDING;\n } else {\n stack.style.removeProperty('padding-top');\n stack.style.removeProperty('padding-bottom');\n }\n\n if (!isStacked || isExpanded) {\n stack.style.removeProperty('height');\n }\n\n toasts.forEach((toast, index) => {\n this.clearStackItemStyles(toast);\n\n toast.style.setProperty('--wje-toast-stack-z', String(index + 1));\n\n if (!isStacked) {\n return;\n }\n\n if (isExpanded) {\n let visualOrder = isBottomStack ? index : toasts.length - index - 1;\n let isVisualFirst = visualOrder === 0;\n let isVisualLast = visualOrder === toasts.length - 1;\n\n toast.style.setProperty('--wje-toast-stack-scale', '1.000');\n toast.style.setProperty('--wje-toast-stack-shift', '0px');\n toast.style.setProperty('--wje-toast-stack-opacity', '1.000');\n toast.style.setProperty('--wje-toast-stack-origin', transformOrigin);\n toast.style.order = String(visualOrder);\n toast.style.width = '100%';\n toast.style.setProperty(\n '--wje-toast-stack-host-margin-top',\n isBottomStack && !isVisualFirst ? STACKED_EXPANDED_MARGIN : '0px'\n );\n toast.style.setProperty(\n '--wje-toast-stack-host-margin-bottom',\n !isBottomStack && !isVisualLast ? STACKED_EXPANDED_MARGIN : '0px'\n );\n return;\n }\n\n let toastHeight = this.getToastVisualHeight(toast);\n let maxDepth = Math.max(0, this.stackDepth - 1);\n let visibleLevels = Math.min(toasts.length, this.stackDepth);\n let depth = Math.min(toasts.length - index - 1, maxDepth);\n let visibleIndex = Math.max(0, index - Math.max(0, toasts.length - this.stackDepth));\n let targetTop = isBottomStack\n ? visibleIndex * STACKED_VISIBLE_SLICE\n : (visibleLevels - 1 - visibleIndex) * STACKED_VISIBLE_SLICE;\n let scale = Math.max(STACKED_MIN_SCALE, 1 - depth * STACKED_SCALE_STEP);\n let opacity = Math.max(STACKED_MIN_OPACITY, 1 - depth * 0.08);\n\n toast.style.setProperty('--wje-toast-stack-scale', scale.toFixed(3));\n toast.style.setProperty('--wje-toast-stack-shift', '0px');\n toast.style.setProperty('--wje-toast-stack-opacity', opacity.toFixed(3));\n toast.style.setProperty('--wje-toast-stack-origin', transformOrigin);\n toast.style.position = 'absolute';\n toast.style.top = `${targetTop}px`;\n toast.style.left = '0';\n toast.style.right = '0';\n toast.style.width = '100%';\n toast.style.setProperty('--wje-toast-stack-host-margin-top', '0px');\n toast.style.setProperty('--wje-toast-stack-host-margin-bottom', '0px');\n\n stackHeight = Math.max(stackHeight, targetTop + toastHeight);\n });\n\n if (isStacked && !isExpanded) {\n stack.style.height = `${stackHeight}px`;\n }\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Toast';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Setup attributes for the Button element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({\n role: 'status',\n });\n }\n\n /**\n * Draw method for the toast notification.\n * @returns {object} Document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-toast');\n\n let mediaSlot = document.createElement('slot');\n mediaSlot.setAttribute('name', 'media');\n mediaSlot.classList.add('media');\n mediaSlot.addEventListener('slotchange', () => {\n if (WjElementUtils.hasSlotContent(this.context, 'media')) {\n mediaSlot.parentElement.classList.add('has-media');\n } else {\n mediaSlot.parentElement.classList.remove('has-media');\n }\n });\n\n let content = document.createElement('div');\n content.classList.add('content');\n content.innerHTML = `<div class=\"headline\">${this.headline}</div><div class=\"message\"><slot></slot></div>`;\n\n let iconX = document.createElement('wje-icon');\n iconX.setAttribute('name', 'x');\n\n let closeBtn = document.createElement('wje-button');\n closeBtn.setAttribute('fill', 'link');\n closeBtn.setAttribute('color', this.color);\n closeBtn.setAttribute('size', 'small');\n closeBtn.classList.add('close');\n closeBtn.setAttribute('aria-label', 'Close');\n\n let countdownEl = document.createElement('div');\n countdownEl.classList.add('countdown');\n\n let countdownBar = document.createElement('div');\n countdownBar.classList.add('countdown-bar');\n\n closeBtn.appendChild(iconX);\n countdownEl.appendChild(countdownBar);\n\n if (this.hasAttribute('icon') && this.icon) {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', this.icon);\n icon.setAttribute('color', this.color);\n icon.setAttribute('slot', 'media');\n icon.setAttribute('part', 'icon');\n\n this.appendChild(icon);\n }\n\n native.appendChild(mediaSlot);\n native.appendChild(content);\n\n if (this.closable) native.appendChild(closeBtn);\n\n if (this.hasAttribute('countdown')) native.appendChild(countdownEl);\n\n fragment.appendChild(native);\n\n this.closeBtn = closeBtn;\n this.countdownBar = countdownBar;\n\n return fragment;\n }\n\n /**\n * After draw method for the toast notification.\n */\n afterDraw() {\n this.closeBtn.addEventListener('wje-button:click', this.hide);\n this.addEventListener('mouseenter', this.pause);\n this.addEventListener('mouseleave', this.resume);\n\n if (this.hasAttribute('countdown')) {\n const startWidth = '100%';\n const endWidth = '0';\n\n this.countdownAnimation = this.countdownBar.animate([{ width: startWidth }, { width: endWidth }], {\n duration: this.duration,\n easing: 'linear',\n });\n }\n\n if (this.duration > 0) {\n this.remainingTime = this.duration;\n this.startTimer();\n }\n }\n\n /**\n * Before disconnect method\n * This method is called before the element is disconnected from the document.\n */\n beforeDisconnect() {\n this.closeBtn?.removeEventListener('wje-button:click', this.hide);\n this.removeEventListener('wje-toast:after-hide', this.removeChildAndStack);\n this.removeEventListener('mouseenter', this.pause);\n this.removeEventListener('mouseleave', this.resume);\n\n clearTimeout(this.timeoutID);\n }\n\n /**\n * Starts the timer.\n * This method sets the `startTime` property to the current time and sets\n * the `timeoutID` property to the ID of the timeout. The method also\n * dispatches the `wje-toast:after-hide` custom event when the timeout\n * expires.\n */\n startTimer() {\n this.startTime = Date.now();\n if (this.timeoutID) {\n clearTimeout(this.timeoutID);\n }\n this.isTimerPaused = false;\n this.timeoutID = window.setTimeout(() => {\n this.hide();\n }, this.remainingTime);\n }\n\n /**\n * Stops the timer.\n * This method clears the timeout and calculates the remaining time.\n * The method is called when the toast notification is paused.\n */\n stopTimer() {\n if (!this.timeoutID || this.isTimerPaused) {\n return;\n }\n\n window.clearTimeout(this.timeoutID);\n this.timeoutID = null;\n const elapsedTime = Date.now() - this.startTime;\n this.remainingTime = Math.max(0, this.remainingTime - elapsedTime);\n this.isTimerPaused = true;\n }\n\n /**\n * Resumes the timer.\n * This method resumes the timer if the remaining time is greater\n * than zero. The method is called when the toast notification is resumed.\n */\n resumeTimer() {\n if (this.isTimerPaused && this.remainingTime > 0) {\n this.startTimer();\n }\n }\n\n /**\n * Asynchronously shows the toast notification.\n * This method sets the `open` property to `true` and dispatches the\n * `wje-toast:after-show` custom event. If the toast is already open,\n * the method returns `undefined`.\n */\n show = () => {\n if (this.open) {\n return;\n }\n\n this.open = true;\n event.dispatchCustomEvent(this, 'wje-toast:after-show');\n };\n\n /**\n * Asynchronously hides the toast notification.\n * This method sets the `open` property to `false` and dispatches the\n * `wje-toast:after-hide` custom event. If the toast is already hidden,\n * the method returns `undefined`.\n */\n hide = () => {\n if (!this.open) {\n return;\n }\n\n this.open = false;\n event.dispatchCustomEvent(this, 'wje-toast:after-hide');\n };\n\n /**\n * Pauses the countdown animation and stops the timer.\n */\n pause = () => {\n this.countdownAnimation?.pause();\n this.stopTimer();\n };\n\n /**\n * Resumes the countdown animation and resumes the timer.\n */\n resume = () => {\n if (this.toastStack?.dataset.expanded === 'true') {\n return;\n }\n\n this.countdownAnimation?.play();\n this.resumeTimer();\n };\n\n /**\n * Removes the toast notification and the toast stack.\n *\n * This method removes the toast notification from the toast stack and\n * removes the toast stack from the document body if the toast stack is\n * empty.\n */\n removeChildAndStack() {\n if (this.parentElement === this.toastStack) {\n this.toastStack.removeChild(this);\n }\n\n this.toastStack.style.setProperty('--wje-toast-stack-layout-duration', '0s');\n this.toastStack.style.setProperty('--wje-toast-stack-visual-duration', '0s');\n this.updateToastStack(this.toastStack);\n\n requestAnimationFrame(() => {\n this.toastStack.style.removeProperty('--wje-toast-stack-layout-duration');\n this.toastStack.style.removeProperty('--wje-toast-stack-visual-duration');\n });\n\n if (this.toastStack.querySelector('wje-toast') === null) {\n this.toastStack.remove();\n }\n }\n\n /**\n * Asynchronously starts the toast notification.\n * This method appends the toast notification to the document body and\n * shows the toast notification. The method returns a promise that\n * resolves when the toast notification is shown.\n * @returns {Promise<unknown>}\n */\n start = () => {\n return new Promise((resolve) => {\n let stack = document.body.querySelector(`.wje-toast-stack[data-stack-key=\"${this.getToastStackKey()}\"]`);\n if (stack) {\n this.toastStack = stack;\n } else {\n this.toastStack = this.createToastStack();\n }\n\n this.syncToastStack(this.toastStack);\n\n if (this.toastStack.parentElement === null) {\n document.body.append(this.toastStack);\n }\n\n this.toastStack.append(this);\n if (this.stacked) {\n this.toastStack.style.setProperty('--wje-toast-stack-layout-duration', '0s');\n this.toastStack.style.setProperty('--wje-toast-stack-visual-duration', '0s');\n this.style.setProperty(\n '--wje-toast-enter-offset',\n this.stackPosition.startsWith('bottom') ? `${STACKED_ENTER_OFFSET}px` : `-${STACKED_ENTER_OFFSET}px`\n );\n this.style.visibility = 'hidden';\n this.show();\n this.updateToastStack(this.toastStack);\n } else {\n this.updateToastStack(this.toastStack);\n this.show();\n }\n\n if (this.toastStack.dataset.expanded === 'true') {\n this.pause();\n }\n\n requestAnimationFrame(() => {\n this.updateToastStack(this.toastStack);\n\n if (this.stacked) {\n this.style.removeProperty('visibility');\n this.toastStack.style.removeProperty('--wje-toast-stack-layout-duration');\n this.toastStack.style.removeProperty('--wje-toast-stack-visual-duration');\n\n requestAnimationFrame(() => this.style.setProperty('--wje-toast-enter-offset', '0px'));\n }\n });\n this.updateComplete?.then(() => this.updateToastStack(this.toastStack));\n\n this.addEventListener('wje-toast:after-hide', this.removeChildAndStack);\n\n resolve(this);\n });\n };\n}\n","import Toast from './toast.element.js';\n\nexport default Toast;\n\nToast.define('wje-toast', Toast);\n"],"names":[],"mappings":";;;;;;;AAGA,MAAM,yBAAyB;AAC/B,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB,oBAAI,IAAI;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AACD,MAAM,qBAAqB;AAC3B,MAAM,oBAAoB;AAC1B,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAC9B,MAAM,0BAA0B;AAChC,MAAM,kBAAkB;AACxB,MAAM,uBAAuB;AAE7B,MAAM,sBAAsB,CAAC,OAAO,aAAa;AAC7C,MAAI,UAAU;AACV,UAAM,QAAQ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,EAOA,cAAc;AACV,QAAI,KAAK,iBAAiB,KAAK,gBAAgB,GAAG;AAC9C,WAAK,WAAU;AAAA,IACnB;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2DA,sBAAsB;AAClB,QAAI,KAAK,kBAAkB,KAAK,YAAY;AACxC,WAAK,WAAW,YAAY,IAAI;AAAA,IACpC;AAEA,SAAK,WAAW,MAAM,YAAY,qCAAqC,IAAI;AAC3E,SAAK,WAAW,MAAM,YAAY,qCAAqC,IAAI;AAC3E,SAAK,iBAAiB,KAAK,UAAU;AAErC,0BAAsB,MAAM;AACxB,WAAK,WAAW,MAAM,eAAe,mCAAmC;AACxE,WAAK,WAAW,MAAM,eAAe,mCAAmC;AAAA,IAC5E,CAAC;AAED,QAAI,KAAK,WAAW,cAAc,WAAW,MAAM,MAAM;AACrD,WAAK,WAAW,OAAM;AAAA,IAC1B;AAAA,EACJ;AA8DJ;ACj0BA,MAAM,OAAO,aAAa,KAAK;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wj-elements",
|
|
3
3
|
"description": "WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.1",
|
|
5
5
|
"homepage": "https://github.com/lencys/wj-elements",
|
|
6
6
|
"author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -50,8 +50,9 @@
|
|
|
50
50
|
"test:badge": "web-test-runner --files packages/wje-badge/badge.test.js",
|
|
51
51
|
"test:breadcrumbs": "web-test-runner --files packages/wje-breadcrumbs/breadcrumbs.test.js",
|
|
52
52
|
"test:button": "web-test-runner --files packages/wje-button/button.test.js",
|
|
53
|
-
"test:
|
|
53
|
+
"test:carousel": "web-test-runner --files packages/wje-carousel/carousel.test.js",
|
|
54
54
|
"test:checkbox": "web-test-runner --files packages/wje-checkbox/checkbox.test.js",
|
|
55
|
+
"test:chip": "web-test-runner --files packages/wje-chip/chip.test.js",
|
|
55
56
|
"test:color-picker": "web-test-runner --files packages/wje-color-picker/color-picker.test.js",
|
|
56
57
|
"test:dialog": "web-test-runner --files packages/wje-dialog/dialog.test.js",
|
|
57
58
|
"test:dropdown": "web-test-runner --files packages/wje-dropdown/dropdown.test.js",
|
|
@@ -138,4 +139,4 @@
|
|
|
138
139
|
"vite-plugin-dts": "^4.5.0",
|
|
139
140
|
"vite-plugin-javascript-obfuscator": "^3.1.0"
|
|
140
141
|
}
|
|
141
|
-
}
|
|
142
|
+
}
|