@liwe3/webcomponents 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AITextEditor.d.ts +173 -0
- package/dist/AITextEditor.d.ts.map +1 -0
- package/dist/ChunkUploader.d.ts +103 -0
- package/dist/ChunkUploader.d.ts.map +1 -0
- package/dist/ChunkUploader.js +614 -0
- package/dist/ChunkUploader.js.map +1 -0
- package/dist/ContainerBox.d.ts +112 -0
- package/dist/ContainerBox.d.ts.map +1 -0
- package/dist/ContainerBox.js +359 -0
- package/dist/ContainerBox.js.map +1 -0
- package/dist/DateSelector.d.ts +103 -0
- package/dist/DateSelector.d.ts.map +1 -0
- package/dist/DateSelector.js +372 -0
- package/dist/DateSelector.js.map +1 -0
- package/dist/Drawer.d.ts +63 -0
- package/dist/Drawer.d.ts.map +1 -0
- package/dist/Drawer.js +340 -0
- package/dist/Drawer.js.map +1 -0
- package/dist/ImageView.d.ts +42 -0
- package/dist/ImageView.d.ts.map +1 -0
- package/dist/ImageView.js +209 -0
- package/dist/ImageView.js.map +1 -0
- package/dist/PopoverMenu.d.ts +103 -0
- package/dist/PopoverMenu.d.ts.map +1 -0
- package/dist/PopoverMenu.js +312 -0
- package/dist/PopoverMenu.js.map +1 -0
- package/dist/SmartSelect.d.ts +99 -0
- package/dist/SmartSelect.d.ts.map +1 -0
- package/dist/SmartSelect.js.map +1 -1
- package/dist/Toast.d.ts +127 -0
- package/dist/Toast.d.ts.map +1 -0
- package/dist/Toast.js +507 -0
- package/dist/Toast.js.map +1 -0
- package/dist/TreeView.d.ts +84 -0
- package/dist/TreeView.d.ts.map +1 -0
- package/dist/TreeView.js +478 -0
- package/dist/TreeView.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/package.json +43 -3
- package/src/ChunkUploader.ts +921 -0
- package/src/ContainerBox.ts +570 -0
- package/src/DateSelector.ts +550 -0
- package/src/Drawer.ts +435 -0
- package/src/ImageView.ts +265 -0
- package/src/PopoverMenu.ts +595 -0
- package/src/SmartSelect.ts +231 -231
- package/src/Toast.ts +834 -0
- package/src/TreeView.ts +673 -0
- package/src/index.ts +70 -3
package/dist/Toast.js
ADDED
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
class l extends HTMLElement {
|
|
2
|
+
constructor() {
|
|
3
|
+
super(), this.config = {
|
|
4
|
+
title: "",
|
|
5
|
+
text: "",
|
|
6
|
+
type: "info",
|
|
7
|
+
closable: !0,
|
|
8
|
+
duration: 5e3
|
|
9
|
+
}, this.remainingTime = 0, this.pauseTime = 0, this.attachShadow({ mode: "open" });
|
|
10
|
+
}
|
|
11
|
+
static get observedAttributes() {
|
|
12
|
+
return ["title", "text", "type", "icon", "closable", "duration", "buttons"];
|
|
13
|
+
}
|
|
14
|
+
attributeChangedCallback(t, e, o) {
|
|
15
|
+
e !== o && this.render();
|
|
16
|
+
}
|
|
17
|
+
connectedCallback() {
|
|
18
|
+
this.render(), this.startAutoCloseTimer();
|
|
19
|
+
}
|
|
20
|
+
disconnectedCallback() {
|
|
21
|
+
this.clearAutoCloseTimer();
|
|
22
|
+
}
|
|
23
|
+
get title() {
|
|
24
|
+
const t = this.getAttribute("title"), e = this.config.title;
|
|
25
|
+
if ((!t || t.trim() === "") && (!e || e.trim() === "")) {
|
|
26
|
+
const o = this.type;
|
|
27
|
+
return o.charAt(0).toUpperCase() + o.slice(1);
|
|
28
|
+
}
|
|
29
|
+
return t || e;
|
|
30
|
+
}
|
|
31
|
+
set title(t) {
|
|
32
|
+
t && t.trim() !== "" ? (this.setAttribute("title", t), this.config.title = t) : (this.removeAttribute("title"), this.config.title = "");
|
|
33
|
+
}
|
|
34
|
+
get text() {
|
|
35
|
+
return this.getAttribute("text") || this.config.text;
|
|
36
|
+
}
|
|
37
|
+
set text(t) {
|
|
38
|
+
this.setAttribute("text", t), this.config.text = t;
|
|
39
|
+
}
|
|
40
|
+
get type() {
|
|
41
|
+
return this.getAttribute("type") || this.config.type || "info";
|
|
42
|
+
}
|
|
43
|
+
set type(t) {
|
|
44
|
+
this.setAttribute("type", t), this.config.type = t;
|
|
45
|
+
}
|
|
46
|
+
get icon() {
|
|
47
|
+
return this.getAttribute("icon") || this.config.icon;
|
|
48
|
+
}
|
|
49
|
+
set icon(t) {
|
|
50
|
+
t ? (this.setAttribute("icon", t), this.config.icon = t) : (this.removeAttribute("icon"), this.config.icon = void 0);
|
|
51
|
+
}
|
|
52
|
+
get closable() {
|
|
53
|
+
return this.hasAttribute("closable") ? this.getAttribute("closable") !== "false" : this.config.closable !== !1;
|
|
54
|
+
}
|
|
55
|
+
set closable(t) {
|
|
56
|
+
t ? this.setAttribute("closable", "true") : this.setAttribute("closable", "false"), this.config.closable = t;
|
|
57
|
+
}
|
|
58
|
+
get duration() {
|
|
59
|
+
const t = this.getAttribute("duration");
|
|
60
|
+
return t ? parseInt(t, 10) : this.config.duration ?? 5e3;
|
|
61
|
+
}
|
|
62
|
+
set duration(t) {
|
|
63
|
+
this.setAttribute("duration", t.toString()), this.config.duration = t;
|
|
64
|
+
}
|
|
65
|
+
get buttons() {
|
|
66
|
+
const t = this.getAttribute("buttons");
|
|
67
|
+
if (t)
|
|
68
|
+
try {
|
|
69
|
+
return JSON.parse(t);
|
|
70
|
+
} catch (e) {
|
|
71
|
+
return console.error("Invalid buttons format:", e), [];
|
|
72
|
+
}
|
|
73
|
+
return this.config.buttons || [];
|
|
74
|
+
}
|
|
75
|
+
set buttons(t) {
|
|
76
|
+
this.setAttribute("buttons", JSON.stringify(t)), this.config.buttons = t;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Shows the toast with the given configuration
|
|
80
|
+
*/
|
|
81
|
+
show(t) {
|
|
82
|
+
this.config = { ...this.config, ...t }, t.buttons && t.buttons.length > 0 && (this.config.duration = 0), t.title && t.title.trim() !== "" ? this.title = t.title : (this.removeAttribute("title"), this.config.title = ""), this.text = t.text, t.type && (this.type = t.type), t.icon !== void 0 && (this.icon = t.icon), t.closable !== void 0 && (this.closable = t.closable), t.buttons && t.buttons.length > 0 ? this.duration = 0 : t.duration !== void 0 && (this.duration = t.duration), t.buttons && (this.buttons = t.buttons), this.render(), this.startAutoCloseTimer();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Closes the toast
|
|
86
|
+
*/
|
|
87
|
+
close() {
|
|
88
|
+
this.clearAutoCloseTimer();
|
|
89
|
+
const t = this.shadowRoot.querySelector(".toast-container");
|
|
90
|
+
if (t) {
|
|
91
|
+
requestAnimationFrame(() => {
|
|
92
|
+
t.classList.add("closing");
|
|
93
|
+
});
|
|
94
|
+
const e = () => {
|
|
95
|
+
t.removeEventListener("animationend", e);
|
|
96
|
+
const o = this, i = o.offsetHeight;
|
|
97
|
+
o.style.height = `${i}px`, o.style.marginBottom = "12px", o.offsetHeight, o.style.height = "0px", o.style.marginBottom = "0px", o.style.opacity = "0", setTimeout(() => {
|
|
98
|
+
this.dispatchEvent(new CustomEvent("close")), this.config.onClose && this.config.onClose(), this.remove();
|
|
99
|
+
}, 300);
|
|
100
|
+
};
|
|
101
|
+
t.addEventListener("animationend", e), setTimeout(() => {
|
|
102
|
+
this.isConnected && e();
|
|
103
|
+
}, 350);
|
|
104
|
+
} else
|
|
105
|
+
this.dispatchEvent(new CustomEvent("close")), this.config.onClose && this.config.onClose(), this.remove();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Starts the auto-close timer if duration is set
|
|
109
|
+
*/
|
|
110
|
+
startAutoCloseTimer() {
|
|
111
|
+
this.clearAutoCloseTimer(), this.duration > 0 && (this.remainingTime = this.duration, this.pauseTime = Date.now(), this.autoCloseTimer = window.setTimeout(() => {
|
|
112
|
+
this.close();
|
|
113
|
+
}, this.duration), this.startProgressBarAnimation());
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Pauses the auto-close timer
|
|
117
|
+
*/
|
|
118
|
+
pauseAutoCloseTimer() {
|
|
119
|
+
this.autoCloseTimer && this.duration > 0 && (clearTimeout(this.autoCloseTimer), this.autoCloseTimer = void 0, this.remainingTime -= Date.now() - this.pauseTime, this.pauseProgressBarAnimation());
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Resumes the auto-close timer
|
|
123
|
+
*/
|
|
124
|
+
resumeAutoCloseTimer() {
|
|
125
|
+
!this.autoCloseTimer && this.remainingTime > 0 && (this.pauseTime = Date.now(), this.autoCloseTimer = window.setTimeout(() => {
|
|
126
|
+
this.close();
|
|
127
|
+
}, this.remainingTime), this.resumeProgressBarAnimation());
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Clears the auto-close timer
|
|
131
|
+
*/
|
|
132
|
+
clearAutoCloseTimer() {
|
|
133
|
+
this.autoCloseTimer && (clearTimeout(this.autoCloseTimer), this.autoCloseTimer = void 0);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Starts the progress bar animation
|
|
137
|
+
*/
|
|
138
|
+
startProgressBarAnimation() {
|
|
139
|
+
!this.progressBar || this.duration <= 0 || (this.progressBar.style.animation = "none", this.progressBar.offsetWidth, this.progressBar.style.animation = `shrinkProgress ${this.duration}ms linear forwards`);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Pauses the progress bar animation
|
|
143
|
+
*/
|
|
144
|
+
pauseProgressBarAnimation() {
|
|
145
|
+
if (!this.progressBar) return;
|
|
146
|
+
const e = window.getComputedStyle(this.progressBar).width, o = this.progressBar.parentElement?.offsetWidth || 1, i = parseFloat(e) / o * 100;
|
|
147
|
+
this.progressBar.style.animation = "none", this.progressBar.style.width = `${i}%`;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Resumes the progress bar animation
|
|
151
|
+
*/
|
|
152
|
+
resumeProgressBarAnimation() {
|
|
153
|
+
if (!this.progressBar || this.remainingTime <= 0) return;
|
|
154
|
+
const e = window.getComputedStyle(this.progressBar).width, o = this.progressBar.parentElement?.offsetWidth || 1, i = parseFloat(e) / o * 100, r = this.remainingTime, a = `shrinkProgress-${Date.now()}`, n = this.shadowRoot.styleSheets[0], c = `
|
|
155
|
+
@keyframes ${a} {
|
|
156
|
+
from {
|
|
157
|
+
width: ${i}%;
|
|
158
|
+
}
|
|
159
|
+
to {
|
|
160
|
+
width: 0%;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
`;
|
|
164
|
+
n && n.insertRule(c, n.cssRules.length), this.progressBar.style.animation = `${a} ${r}ms linear forwards`;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Gets the color scheme for the toast type
|
|
168
|
+
*/
|
|
169
|
+
getTypeColors() {
|
|
170
|
+
switch (this.type) {
|
|
171
|
+
case "success":
|
|
172
|
+
return {
|
|
173
|
+
background: "var(--toast-success-background, #d4edda)",
|
|
174
|
+
border: "var(--toast-success-border, #c3e6cb)",
|
|
175
|
+
icon: "var(--toast-success-icon, #155724)"
|
|
176
|
+
};
|
|
177
|
+
case "error":
|
|
178
|
+
return {
|
|
179
|
+
background: "var(--toast-error-background, #f8d7da)",
|
|
180
|
+
border: "var(--toast-error-border, #f5c6cb)",
|
|
181
|
+
icon: "var(--toast-error-icon, #721c24)"
|
|
182
|
+
};
|
|
183
|
+
case "warning":
|
|
184
|
+
return {
|
|
185
|
+
background: "var(--toast-warning-background, #fff3cd)",
|
|
186
|
+
border: "var(--toast-warning-border, #ffeaa7)",
|
|
187
|
+
icon: "var(--toast-warning-icon, #856404)"
|
|
188
|
+
};
|
|
189
|
+
case "info":
|
|
190
|
+
default:
|
|
191
|
+
return {
|
|
192
|
+
background: "var(--toast-info-background, #d1ecf1)",
|
|
193
|
+
border: "var(--toast-info-border, #bee5eb)",
|
|
194
|
+
icon: "var(--toast-info-icon, #0c5460)"
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Gets the default icon for the toast type
|
|
200
|
+
*/
|
|
201
|
+
getDefaultIcon() {
|
|
202
|
+
switch (this.type) {
|
|
203
|
+
case "success":
|
|
204
|
+
return "✓";
|
|
205
|
+
case "error":
|
|
206
|
+
return "✕";
|
|
207
|
+
case "warning":
|
|
208
|
+
return "⚠";
|
|
209
|
+
case "info":
|
|
210
|
+
default:
|
|
211
|
+
return "ℹ";
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Binds all event listeners
|
|
216
|
+
*/
|
|
217
|
+
bindEvents() {
|
|
218
|
+
this.shadowRoot.addEventListener("click", (e) => {
|
|
219
|
+
const o = e.target;
|
|
220
|
+
if (o.closest(".close-button"))
|
|
221
|
+
this.close();
|
|
222
|
+
else if (o.closest(".toast-button")) {
|
|
223
|
+
const i = o.closest(".toast-button").dataset.index;
|
|
224
|
+
if (i !== void 0) {
|
|
225
|
+
const r = this.buttons[parseInt(i, 10)];
|
|
226
|
+
r && r.onClick && r.onClick();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
const t = this.shadowRoot.querySelector(".toast-container");
|
|
231
|
+
t && (t.addEventListener("mouseenter", () => {
|
|
232
|
+
this.pauseAutoCloseTimer();
|
|
233
|
+
}), t.addEventListener("mouseleave", () => {
|
|
234
|
+
this.resumeAutoCloseTimer();
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Renders the component
|
|
239
|
+
*/
|
|
240
|
+
render() {
|
|
241
|
+
const t = this.getTypeColors(), e = this.icon ? `<img src="${this.icon}" alt="Toast icon" class="toast-icon-img" />` : `<span class="toast-icon-default">${this.getDefaultIcon()}</span>`;
|
|
242
|
+
this.shadowRoot.innerHTML = `
|
|
243
|
+
<style>
|
|
244
|
+
:host {
|
|
245
|
+
display: block;
|
|
246
|
+
font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
|
|
247
|
+
font-size: var(--font-size, 14px);
|
|
248
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.toast-container {
|
|
252
|
+
display: flex;
|
|
253
|
+
flex-direction: column;
|
|
254
|
+
min-width: 300px;
|
|
255
|
+
max-width: 500px;
|
|
256
|
+
padding: 16px;
|
|
257
|
+
background: ${t.background};
|
|
258
|
+
border: 1px solid ${t.border};
|
|
259
|
+
border-radius: var(--toast-border-radius, 8px);
|
|
260
|
+
box-shadow: var(--toast-shadow, 0 4px 12px rgba(0, 0, 0, 0.15));
|
|
261
|
+
animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
|
|
262
|
+
position: relative;
|
|
263
|
+
will-change: transform, opacity;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.toast-container.closing {
|
|
267
|
+
animation: slideOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
@keyframes slideIn {
|
|
271
|
+
from {
|
|
272
|
+
opacity: 0;
|
|
273
|
+
transform: translateY(-20px) scale(0.95);
|
|
274
|
+
}
|
|
275
|
+
to {
|
|
276
|
+
opacity: 1;
|
|
277
|
+
transform: translateY(0) scale(1);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
@keyframes slideOut {
|
|
282
|
+
from {
|
|
283
|
+
opacity: 1;
|
|
284
|
+
transform: translateY(0) scale(1);
|
|
285
|
+
}
|
|
286
|
+
to {
|
|
287
|
+
opacity: 0;
|
|
288
|
+
transform: translateY(-20px) scale(0.95);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.toast-header {
|
|
293
|
+
display: flex;
|
|
294
|
+
align-items: flex-start;
|
|
295
|
+
gap: 12px;
|
|
296
|
+
margin-bottom: 8px;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.toast-icon {
|
|
300
|
+
flex-shrink: 0;
|
|
301
|
+
width: 24px;
|
|
302
|
+
height: 24px;
|
|
303
|
+
display: flex;
|
|
304
|
+
align-items: center;
|
|
305
|
+
justify-content: center;
|
|
306
|
+
color: ${t.icon};
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.toast-icon-img {
|
|
310
|
+
width: 100%;
|
|
311
|
+
height: 100%;
|
|
312
|
+
object-fit: contain;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.toast-icon-default {
|
|
316
|
+
font-size: 20px;
|
|
317
|
+
font-weight: bold;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.toast-content {
|
|
321
|
+
flex: 1;
|
|
322
|
+
min-width: 0;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.toast-title {
|
|
326
|
+
font-weight: 600;
|
|
327
|
+
font-size: 16px;
|
|
328
|
+
margin: 0 0 4px 0;
|
|
329
|
+
color: var(--toast-title-color, #333);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.toast-text {
|
|
333
|
+
margin: 0;
|
|
334
|
+
color: var(--toast-text-color, #555);
|
|
335
|
+
line-height: 1.5;
|
|
336
|
+
word-wrap: break-word;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.close-button {
|
|
340
|
+
position: absolute;
|
|
341
|
+
top: 8px;
|
|
342
|
+
right: 8px;
|
|
343
|
+
width: 24px;
|
|
344
|
+
height: 24px;
|
|
345
|
+
display: flex;
|
|
346
|
+
align-items: center;
|
|
347
|
+
justify-content: center;
|
|
348
|
+
background: transparent;
|
|
349
|
+
border: none;
|
|
350
|
+
cursor: pointer;
|
|
351
|
+
font-size: 20px;
|
|
352
|
+
color: var(--toast-close-color, #666);
|
|
353
|
+
border-radius: 4px;
|
|
354
|
+
transition: background-color 0.2s, color 0.2s;
|
|
355
|
+
padding: 0;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.close-button:hover {
|
|
359
|
+
background-color: var(--toast-close-hover-background, rgba(0, 0, 0, 0.1));
|
|
360
|
+
color: var(--toast-close-hover-color, #333);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.toast-buttons {
|
|
364
|
+
display: flex;
|
|
365
|
+
gap: 8px;
|
|
366
|
+
justify-content: flex-end;
|
|
367
|
+
margin-top: 12px;
|
|
368
|
+
padding-top: 12px;
|
|
369
|
+
border-top: 1px solid var(--toast-button-border, rgba(0, 0, 0, 0.1));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.toast-button {
|
|
373
|
+
padding: 6px 16px;
|
|
374
|
+
border: 1px solid var(--toast-button-border-color, #ccc);
|
|
375
|
+
border-radius: var(--toast-button-border-radius, 4px);
|
|
376
|
+
background: var(--toast-button-background, white);
|
|
377
|
+
color: var(--toast-button-color, #333);
|
|
378
|
+
font-size: 14px;
|
|
379
|
+
cursor: pointer;
|
|
380
|
+
transition: background-color 0.2s, border-color 0.2s;
|
|
381
|
+
font-family: inherit;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.toast-button:hover {
|
|
385
|
+
background-color: var(--toast-button-hover-background, #f8f9fa);
|
|
386
|
+
border-color: var(--toast-button-hover-border-color, #999);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
.toast-button:active {
|
|
390
|
+
background-color: var(--toast-button-active-background, #e9ecef);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
.toast-progress-bar {
|
|
394
|
+
position: absolute;
|
|
395
|
+
bottom: 0;
|
|
396
|
+
left: 0;
|
|
397
|
+
height: 4px;
|
|
398
|
+
width: 100%;
|
|
399
|
+
background: var(--toast-progress-bar-color, rgba(0, 0, 0, 0.3));
|
|
400
|
+
border-bottom-left-radius: var(--toast-border-radius, 8px);
|
|
401
|
+
border-bottom-right-radius: var(--toast-border-radius, 8px);
|
|
402
|
+
transform-origin: left;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
@keyframes shrinkProgress {
|
|
406
|
+
from {
|
|
407
|
+
width: 100%;
|
|
408
|
+
}
|
|
409
|
+
to {
|
|
410
|
+
width: 0%;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
</style>
|
|
414
|
+
|
|
415
|
+
<div class="toast-container">
|
|
416
|
+
${this.closable ? '<button class="close-button" aria-label="Close">×</button>' : ""}
|
|
417
|
+
|
|
418
|
+
<div class="toast-header">
|
|
419
|
+
<div class="toast-icon">
|
|
420
|
+
${e}
|
|
421
|
+
</div>
|
|
422
|
+
<div class="toast-content">
|
|
423
|
+
<h4 class="toast-title">${this.title}</h4>
|
|
424
|
+
<p class="toast-text">${this.text}</p>
|
|
425
|
+
</div>
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
${this.buttons.length > 0 ? `
|
|
429
|
+
<div class="toast-buttons">
|
|
430
|
+
${this.buttons.map((o, i) => `
|
|
431
|
+
<button class="toast-button" data-index="${i}">
|
|
432
|
+
${o.label}
|
|
433
|
+
</button>
|
|
434
|
+
`).join("")}
|
|
435
|
+
</div>
|
|
436
|
+
` : ""}
|
|
437
|
+
|
|
438
|
+
${this.duration > 0 ? '<div class="toast-progress-bar"></div>' : ""}
|
|
439
|
+
</div>
|
|
440
|
+
`, this.progressBar = this.shadowRoot.querySelector(".toast-progress-bar"), this.bindEvents();
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
const d = (s = "liwe3-toast") => {
|
|
444
|
+
typeof window < "u" && !window.customElements.get(s) && customElements.define(s, l);
|
|
445
|
+
};
|
|
446
|
+
d();
|
|
447
|
+
const h = "liwe3-toast-container", u = (s) => {
|
|
448
|
+
switch (s) {
|
|
449
|
+
case "TL":
|
|
450
|
+
return { top: "20px", left: "20px", alignItems: "flex-start" };
|
|
451
|
+
case "T":
|
|
452
|
+
return { top: "20px", left: "50%", alignItems: "center" };
|
|
453
|
+
case "TR":
|
|
454
|
+
return { top: "20px", right: "20px", alignItems: "flex-end" };
|
|
455
|
+
case "BL":
|
|
456
|
+
return { bottom: "20px", left: "20px", alignItems: "flex-start" };
|
|
457
|
+
case "B":
|
|
458
|
+
return { bottom: "20px", left: "50%", alignItems: "center" };
|
|
459
|
+
case "BR":
|
|
460
|
+
return { bottom: "20px", right: "20px", alignItems: "flex-end" };
|
|
461
|
+
default:
|
|
462
|
+
return { top: "20px", right: "20px", alignItems: "flex-end" };
|
|
463
|
+
}
|
|
464
|
+
}, m = (s = "TR") => {
|
|
465
|
+
const t = `${h}-${s.toLowerCase()}`;
|
|
466
|
+
let e = document.getElementById(t);
|
|
467
|
+
if (!e) {
|
|
468
|
+
e = document.createElement("div"), e.id = t, e.style.position = "fixed", e.style.zIndex = "99999", e.style.display = "flex", e.style.flexDirection = "column", e.style.maxWidth = "400px", e.style.pointerEvents = "none";
|
|
469
|
+
const o = u(s);
|
|
470
|
+
o.top && (e.style.top = o.top), o.bottom && (e.style.bottom = o.bottom), o.left && (e.style.left = o.left), o.right && (e.style.right = o.right), e.style.alignItems = o.alignItems, (s === "T" || s === "B") && (e.style.transform = "translateX(-50%)");
|
|
471
|
+
const i = `${t}-styles`;
|
|
472
|
+
if (!document.getElementById(i)) {
|
|
473
|
+
const r = document.createElement("style");
|
|
474
|
+
r.id = i, r.textContent = `
|
|
475
|
+
#${t} > * {
|
|
476
|
+
margin-bottom: 12px;
|
|
477
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
478
|
+
overflow: hidden;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
#${t} > *:last-child {
|
|
482
|
+
margin-bottom: 0;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
@media (max-width: 768px) {
|
|
486
|
+
#${t} {
|
|
487
|
+
left: 20px !important;
|
|
488
|
+
right: 20px !important;
|
|
489
|
+
max-width: none !important;
|
|
490
|
+
transform: none !important;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
`, document.head.appendChild(r);
|
|
494
|
+
}
|
|
495
|
+
document.body.appendChild(e);
|
|
496
|
+
}
|
|
497
|
+
return e;
|
|
498
|
+
}, p = (s) => {
|
|
499
|
+
const t = s.position || "TR", e = m(t), o = document.createElement("liwe3-toast");
|
|
500
|
+
return o.style.pointerEvents = "auto", o.show(s), e.appendChild(o), o;
|
|
501
|
+
};
|
|
502
|
+
export {
|
|
503
|
+
l as ToastElement,
|
|
504
|
+
d as defineToast,
|
|
505
|
+
p as toastAdd
|
|
506
|
+
};
|
|
507
|
+
//# sourceMappingURL=Toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.js","sources":["../src/Toast.ts"],"sourcesContent":["/**\n * Toast Web Component\n * A customizable toast notification system with multiple types, icons, buttons, and auto-dismiss\n */\n\nexport type ToastType = 'info' | 'warning' | 'error' | 'success';\n\nexport type ToastPosition = 'TL' | 'T' | 'TR' | 'BL' | 'B' | 'BR';\n\nexport type ToastButton = {\n label: string;\n onClick: () => void;\n};\n\nexport type ToastConfig = {\n title: string;\n text: string;\n type?: ToastType;\n icon?: string; // URL to icon/image\n buttons?: ToastButton[];\n closable?: boolean; // Show close X button\n duration?: number; // Auto-dismiss after x milliseconds (0 = no auto-dismiss, default: 5000ms)\n position?: ToastPosition; // Toast container position (default: 'TR')\n onClose?: () => void;\n};\n\nexport class ToastElement extends HTMLElement {\n declare shadowRoot: ShadowRoot;\n private config: ToastConfig = {\n title: '',\n text: '',\n type: 'info',\n closable: true,\n duration: 5000\n };\n private autoCloseTimer?: number;\n private remainingTime: number = 0;\n private pauseTime: number = 0;\n private progressBar?: HTMLElement;\n\n constructor () {\n super();\n this.attachShadow( { mode: 'open' } );\n }\n\n static get observedAttributes (): string[] {\n return [ 'title', 'text', 'type', 'icon', 'closable', 'duration', 'buttons' ];\n }\n\n attributeChangedCallback ( _name: string, oldValue: string | null, newValue: string | null ): void {\n if ( oldValue !== newValue ) {\n this.render();\n }\n }\n\n connectedCallback (): void {\n this.render();\n this.startAutoCloseTimer();\n }\n\n disconnectedCallback (): void {\n this.clearAutoCloseTimer();\n }\n\n get title (): string {\n const attrTitle = this.getAttribute( 'title' );\n const configTitle = this.config.title;\n\n // If no title is provided or empty, use capitalized type\n if ( ( !attrTitle || attrTitle.trim() === '' ) && ( !configTitle || configTitle.trim() === '' ) ) {\n const type = this.type;\n return type.charAt( 0 ).toUpperCase() + type.slice( 1 );\n }\n\n return attrTitle || configTitle;\n }\n\n set title ( value: string ) {\n if ( value && value.trim() !== '' ) {\n this.setAttribute( 'title', value );\n this.config.title = value;\n } else {\n this.removeAttribute( 'title' );\n this.config.title = '';\n }\n }\n\n get text (): string {\n return this.getAttribute( 'text' ) || this.config.text;\n }\n\n set text ( value: string ) {\n this.setAttribute( 'text', value );\n this.config.text = value;\n }\n\n get type (): ToastType {\n const attr = this.getAttribute( 'type' );\n return ( attr as ToastType ) || this.config.type || 'info';\n }\n\n set type ( value: ToastType ) {\n this.setAttribute( 'type', value );\n this.config.type = value;\n }\n\n get icon (): string | undefined {\n return this.getAttribute( 'icon' ) || this.config.icon;\n }\n\n set icon ( value: string | undefined ) {\n if ( value ) {\n this.setAttribute( 'icon', value );\n this.config.icon = value;\n } else {\n this.removeAttribute( 'icon' );\n this.config.icon = undefined;\n }\n }\n\n get closable (): boolean {\n if ( this.hasAttribute( 'closable' ) ) {\n return this.getAttribute( 'closable' ) !== 'false';\n }\n return this.config.closable !== false;\n }\n\n set closable ( value: boolean ) {\n if ( value ) {\n this.setAttribute( 'closable', 'true' );\n } else {\n this.setAttribute( 'closable', 'false' );\n }\n this.config.closable = value;\n }\n\n get duration (): number {\n const attr = this.getAttribute( 'duration' );\n if ( attr ) {\n return parseInt( attr, 10 );\n }\n return this.config.duration ?? 5000;\n }\n\n set duration ( value: number ) {\n this.setAttribute( 'duration', value.toString() );\n this.config.duration = value;\n }\n\n get buttons (): ToastButton[] {\n const attr = this.getAttribute( 'buttons' );\n if ( attr ) {\n try {\n return JSON.parse( attr );\n } catch ( e ) {\n console.error( 'Invalid buttons format:', e );\n return [];\n }\n }\n return this.config.buttons || [];\n }\n\n set buttons ( value: ToastButton[] ) {\n this.setAttribute( 'buttons', JSON.stringify( value ) );\n this.config.buttons = value;\n }\n\n /**\n * Shows the toast with the given configuration\n */\n show ( config: ToastConfig ): void {\n this.config = { ...this.config, ...config };\n\n // If buttons are present, force duration to 0 (user must interact to close)\n if ( config.buttons && config.buttons.length > 0 ) {\n this.config.duration = 0;\n }\n\n // Sync config to attributes\n if ( config.title && config.title.trim() !== '' ) {\n this.title = config.title;\n } else {\n // Clear title if not provided or empty\n this.removeAttribute( 'title' );\n this.config.title = '';\n }\n this.text = config.text;\n if ( config.type ) this.type = config.type;\n if ( config.icon !== undefined ) this.icon = config.icon;\n if ( config.closable !== undefined ) this.closable = config.closable;\n if ( config.buttons && config.buttons.length > 0 ) {\n // Force duration to 0 when buttons are present\n this.duration = 0;\n } else if ( config.duration !== undefined ) {\n this.duration = config.duration;\n }\n if ( config.buttons ) this.buttons = config.buttons;\n\n this.render();\n this.startAutoCloseTimer();\n }\n\n /**\n * Closes the toast\n */\n close (): void {\n this.clearAutoCloseTimer();\n\n // Add closing animation\n const container = this.shadowRoot.querySelector( '.toast-container' ) as HTMLElement;\n if ( container ) {\n // Use requestAnimationFrame to ensure smooth animation\n requestAnimationFrame( () => {\n container.classList.add( 'closing' );\n } );\n\n // Listen for animation end event for smoother transition\n const handleAnimationEnd = () => {\n container.removeEventListener( 'animationend', handleAnimationEnd );\n\n // Animate the host element collapsing (height and margin to 0)\n const hostElement = this as unknown as HTMLElement;\n const currentHeight = hostElement.offsetHeight;\n\n // Set explicit height for animation\n hostElement.style.height = `${ currentHeight }px`;\n hostElement.style.marginBottom = '12px';\n\n // Force reflow\n void hostElement.offsetHeight;\n\n // Animate to 0\n hostElement.style.height = '0px';\n hostElement.style.marginBottom = '0px';\n hostElement.style.opacity = '0';\n\n // Wait for transition to complete, then remove\n setTimeout( () => {\n this.dispatchEvent( new CustomEvent( 'close' ) );\n if ( this.config.onClose ) {\n this.config.onClose();\n }\n this.remove();\n }, 300 );\n };\n\n container.addEventListener( 'animationend', handleAnimationEnd );\n\n // Fallback timeout in case animationend doesn't fire\n setTimeout( () => {\n if ( this.isConnected ) {\n handleAnimationEnd();\n }\n }, 350 );\n } else {\n this.dispatchEvent( new CustomEvent( 'close' ) );\n if ( this.config.onClose ) {\n this.config.onClose();\n }\n this.remove();\n }\n }\n\n /**\n * Starts the auto-close timer if duration is set\n */\n private startAutoCloseTimer (): void {\n this.clearAutoCloseTimer();\n\n if ( this.duration > 0 ) {\n this.remainingTime = this.duration;\n this.pauseTime = Date.now();\n this.autoCloseTimer = window.setTimeout( () => {\n this.close();\n }, this.duration );\n\n // Start progress bar animation\n this.startProgressBarAnimation();\n }\n }\n\n /**\n * Pauses the auto-close timer\n */\n private pauseAutoCloseTimer (): void {\n if ( this.autoCloseTimer && this.duration > 0 ) {\n clearTimeout( this.autoCloseTimer );\n this.autoCloseTimer = undefined;\n this.remainingTime -= Date.now() - this.pauseTime;\n\n // Pause progress bar animation\n this.pauseProgressBarAnimation();\n }\n }\n\n /**\n * Resumes the auto-close timer\n */\n private resumeAutoCloseTimer (): void {\n if ( !this.autoCloseTimer && this.remainingTime > 0 ) {\n this.pauseTime = Date.now();\n this.autoCloseTimer = window.setTimeout( () => {\n this.close();\n }, this.remainingTime );\n\n // Resume progress bar animation\n this.resumeProgressBarAnimation();\n }\n }\n\n /**\n * Clears the auto-close timer\n */\n private clearAutoCloseTimer (): void {\n if ( this.autoCloseTimer ) {\n clearTimeout( this.autoCloseTimer );\n this.autoCloseTimer = undefined;\n }\n }\n\n /**\n * Starts the progress bar animation\n */\n private startProgressBarAnimation (): void {\n if ( !this.progressBar || this.duration <= 0 ) return;\n\n // Reset and start the animation\n this.progressBar.style.animation = 'none';\n // Force a reflow to reset the animation\n void this.progressBar.offsetWidth;\n this.progressBar.style.animation = `shrinkProgress ${ this.duration }ms linear forwards`;\n }\n\n /**\n * Pauses the progress bar animation\n */\n private pauseProgressBarAnimation (): void {\n if ( !this.progressBar ) return;\n\n // Get the current computed width as a percentage of the container\n const computedStyle = window.getComputedStyle( this.progressBar );\n const currentWidth = computedStyle.width;\n const containerWidth = this.progressBar.parentElement?.offsetWidth || 1;\n const widthPercent = ( parseFloat( currentWidth ) / containerWidth ) * 100;\n\n // Stop the animation and set the width directly\n this.progressBar.style.animation = 'none';\n this.progressBar.style.width = `${ widthPercent }%`;\n }\n\n /**\n * Resumes the progress bar animation\n */\n private resumeProgressBarAnimation (): void {\n if ( !this.progressBar || this.remainingTime <= 0 ) return;\n\n // Get current width as starting point\n const computedStyle = window.getComputedStyle( this.progressBar );\n const currentWidth = computedStyle.width;\n const containerWidth = this.progressBar.parentElement?.offsetWidth || 1;\n const currentPercent = ( parseFloat( currentWidth ) / containerWidth ) * 100;\n\n // Calculate the duration based on the remaining percentage and remaining time\n // The animation should take exactly remainingTime to go from currentPercent to 0\n const adjustedDuration = this.remainingTime;\n\n // Create a new keyframe animation from current position to 0\n const animationName = `shrinkProgress-${ Date.now() }`;\n const styleSheet = this.shadowRoot.styleSheets[ 0 ];\n const keyframes = `\n @keyframes ${ animationName } {\n from {\n width: ${ currentPercent }%;\n }\n to {\n width: 0%;\n }\n }\n `;\n\n // Add the new keyframe rule\n if ( styleSheet ) {\n styleSheet.insertRule( keyframes, styleSheet.cssRules.length );\n }\n\n // Apply the animation\n this.progressBar.style.animation = `${ animationName } ${ adjustedDuration }ms linear forwards`;\n }\n\n /**\n * Gets the color scheme for the toast type\n */\n private getTypeColors (): { background: string; border: string; icon: string } {\n const type = this.type;\n\n switch ( type ) {\n case 'success':\n return {\n background: 'var(--toast-success-background, #d4edda)',\n border: 'var(--toast-success-border, #c3e6cb)',\n icon: 'var(--toast-success-icon, #155724)'\n };\n case 'error':\n return {\n background: 'var(--toast-error-background, #f8d7da)',\n border: 'var(--toast-error-border, #f5c6cb)',\n icon: 'var(--toast-error-icon, #721c24)'\n };\n case 'warning':\n return {\n background: 'var(--toast-warning-background, #fff3cd)',\n border: 'var(--toast-warning-border, #ffeaa7)',\n icon: 'var(--toast-warning-icon, #856404)'\n };\n case 'info':\n default:\n return {\n background: 'var(--toast-info-background, #d1ecf1)',\n border: 'var(--toast-info-border, #bee5eb)',\n icon: 'var(--toast-info-icon, #0c5460)'\n };\n }\n }\n\n /**\n * Gets the default icon for the toast type\n */\n private getDefaultIcon (): string {\n const type = this.type;\n\n switch ( type ) {\n case 'success':\n return '✓';\n case 'error':\n return '✕';\n case 'warning':\n return '⚠';\n case 'info':\n default:\n return 'ℹ';\n }\n }\n\n /**\n * Binds all event listeners\n */\n private bindEvents (): void {\n // Handle close button click and button clicks\n this.shadowRoot.addEventListener( 'click', ( e ) => {\n const target = e.target as HTMLElement;\n\n if ( target.closest( '.close-button' ) ) {\n this.close();\n } else if ( target.closest( '.toast-button' ) ) {\n const buttonIndex = ( target.closest( '.toast-button' ) as HTMLElement ).dataset.index;\n if ( buttonIndex !== undefined ) {\n const button = this.buttons[ parseInt( buttonIndex, 10 ) ];\n if ( button && button.onClick ) {\n button.onClick();\n }\n }\n }\n } );\n\n // Handle mouse enter/leave to pause/resume timer\n const container = this.shadowRoot.querySelector( '.toast-container' );\n if ( container ) {\n container.addEventListener( 'mouseenter', () => {\n this.pauseAutoCloseTimer();\n } );\n\n container.addEventListener( 'mouseleave', () => {\n this.resumeAutoCloseTimer();\n } );\n }\n }\n\n /**\n * Renders the component\n */\n private render (): void {\n const colors = this.getTypeColors();\n const iconContent = this.icon\n ? `<img src=\"${ this.icon }\" alt=\"Toast icon\" class=\"toast-icon-img\" />`\n : `<span class=\"toast-icon-default\">${ this.getDefaultIcon() }</span>`;\n\n this.shadowRoot.innerHTML = `\n <style>\n :host {\n display: block;\n font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);\n font-size: var(--font-size, 14px);\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n }\n\n .toast-container {\n display: flex;\n flex-direction: column;\n min-width: 300px;\n max-width: 500px;\n padding: 16px;\n background: ${ colors.background };\n border: 1px solid ${ colors.border };\n border-radius: var(--toast-border-radius, 8px);\n box-shadow: var(--toast-shadow, 0 4px 12px rgba(0, 0, 0, 0.15));\n animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);\n position: relative;\n will-change: transform, opacity;\n }\n\n .toast-container.closing {\n animation: slideOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;\n }\n\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translateY(-20px) scale(0.95);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n }\n\n @keyframes slideOut {\n from {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n to {\n opacity: 0;\n transform: translateY(-20px) scale(0.95);\n }\n }\n\n .toast-header {\n display: flex;\n align-items: flex-start;\n gap: 12px;\n margin-bottom: 8px;\n }\n\n .toast-icon {\n flex-shrink: 0;\n width: 24px;\n height: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: ${ colors.icon };\n }\n\n .toast-icon-img {\n width: 100%;\n height: 100%;\n object-fit: contain;\n }\n\n .toast-icon-default {\n font-size: 20px;\n font-weight: bold;\n }\n\n .toast-content {\n flex: 1;\n min-width: 0;\n }\n\n .toast-title {\n font-weight: 600;\n font-size: 16px;\n margin: 0 0 4px 0;\n color: var(--toast-title-color, #333);\n }\n\n .toast-text {\n margin: 0;\n color: var(--toast-text-color, #555);\n line-height: 1.5;\n word-wrap: break-word;\n }\n\n .close-button {\n position: absolute;\n top: 8px;\n right: 8px;\n width: 24px;\n height: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n background: transparent;\n border: none;\n cursor: pointer;\n font-size: 20px;\n color: var(--toast-close-color, #666);\n border-radius: 4px;\n transition: background-color 0.2s, color 0.2s;\n padding: 0;\n }\n\n .close-button:hover {\n background-color: var(--toast-close-hover-background, rgba(0, 0, 0, 0.1));\n color: var(--toast-close-hover-color, #333);\n }\n\n .toast-buttons {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n margin-top: 12px;\n padding-top: 12px;\n border-top: 1px solid var(--toast-button-border, rgba(0, 0, 0, 0.1));\n }\n\n .toast-button {\n padding: 6px 16px;\n border: 1px solid var(--toast-button-border-color, #ccc);\n border-radius: var(--toast-button-border-radius, 4px);\n background: var(--toast-button-background, white);\n color: var(--toast-button-color, #333);\n font-size: 14px;\n cursor: pointer;\n transition: background-color 0.2s, border-color 0.2s;\n font-family: inherit;\n }\n\n .toast-button:hover {\n background-color: var(--toast-button-hover-background, #f8f9fa);\n border-color: var(--toast-button-hover-border-color, #999);\n }\n\n .toast-button:active {\n background-color: var(--toast-button-active-background, #e9ecef);\n }\n\n .toast-progress-bar {\n position: absolute;\n bottom: 0;\n left: 0;\n height: 4px;\n width: 100%;\n background: var(--toast-progress-bar-color, rgba(0, 0, 0, 0.3));\n border-bottom-left-radius: var(--toast-border-radius, 8px);\n border-bottom-right-radius: var(--toast-border-radius, 8px);\n transform-origin: left;\n }\n\n @keyframes shrinkProgress {\n from {\n width: 100%;\n }\n to {\n width: 0%;\n }\n }\n </style>\n\n <div class=\"toast-container\">\n ${ this.closable ? '<button class=\"close-button\" aria-label=\"Close\">×</button>' : '' }\n\n <div class=\"toast-header\">\n <div class=\"toast-icon\">\n ${ iconContent }\n </div>\n <div class=\"toast-content\">\n <h4 class=\"toast-title\">${ this.title }</h4>\n <p class=\"toast-text\">${ this.text }</p>\n </div>\n </div>\n\n ${ this.buttons.length > 0 ? `\n <div class=\"toast-buttons\">\n ${ this.buttons.map( ( button, index ) => `\n <button class=\"toast-button\" data-index=\"${ index }\">\n ${ button.label }\n </button>\n `).join( '' ) }\n </div>\n ` : '' }\n\n ${ this.duration > 0 ? '<div class=\"toast-progress-bar\"></div>' : '' }\n </div>\n `;\n\n // Store reference to progress bar\n this.progressBar = this.shadowRoot.querySelector( '.toast-progress-bar' ) as HTMLElement;\n\n this.bindEvents();\n }\n}\n\n/**\n * Conditionally defines the custom element if in a browser environment.\n */\nconst defineToast = ( tagName: string = 'liwe3-toast' ): void => {\n if ( typeof window !== 'undefined' && !window.customElements.get( tagName ) ) {\n customElements.define( tagName, ToastElement );\n }\n};\n\n// Auto-register with default tag name\ndefineToast();\n\n/**\n * Base container ID prefix for toast notifications\n */\nconst CONTAINER_ID_PREFIX = 'liwe3-toast-container';\n\n/**\n * Gets the container positioning styles based on position\n */\nconst getContainerStyles = ( position: ToastPosition ): { top?: string; bottom?: string; left?: string; right?: string; alignItems: string } => {\n switch ( position ) {\n case 'TL':\n return { top: '20px', left: '20px', alignItems: 'flex-start' };\n case 'T':\n return { top: '20px', left: '50%', alignItems: 'center' };\n case 'TR':\n return { top: '20px', right: '20px', alignItems: 'flex-end' };\n case 'BL':\n return { bottom: '20px', left: '20px', alignItems: 'flex-start' };\n case 'B':\n return { bottom: '20px', left: '50%', alignItems: 'center' };\n case 'BR':\n return { bottom: '20px', right: '20px', alignItems: 'flex-end' };\n default:\n return { top: '20px', right: '20px', alignItems: 'flex-end' };\n }\n};\n\n/**\n * Creates or gets the toast container element for the specified position\n */\nconst getToastContainer = ( position: ToastPosition = 'TR' ): HTMLElement => {\n const containerId = `${ CONTAINER_ID_PREFIX }-${ position.toLowerCase() }`;\n let container = document.getElementById( containerId );\n\n if ( !container ) {\n container = document.createElement( 'div' );\n container.id = containerId;\n container.style.position = 'fixed';\n container.style.zIndex = '99999';\n container.style.display = 'flex';\n container.style.flexDirection = 'column';\n container.style.maxWidth = '400px';\n container.style.pointerEvents = 'none';\n\n // Apply position-specific styles\n const styles = getContainerStyles( position );\n if ( styles.top ) container.style.top = styles.top;\n if ( styles.bottom ) container.style.bottom = styles.bottom;\n if ( styles.left ) container.style.left = styles.left;\n if ( styles.right ) container.style.right = styles.right;\n container.style.alignItems = styles.alignItems;\n\n // For centered positions, apply transform to center horizontally\n if ( position === 'T' || position === 'B' ) {\n container.style.transform = 'translateX(-50%)';\n }\n\n // Add media query styles for mobile and smooth transitions\n const styleId = `${ containerId }-styles`;\n if ( !document.getElementById( styleId ) ) {\n const style = document.createElement( 'style' );\n style.id = styleId;\n style.textContent = `\n #${ containerId } > * {\n margin-bottom: 12px;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n }\n\n #${ containerId } > *:last-child {\n margin-bottom: 0;\n }\n\n @media (max-width: 768px) {\n #${ containerId } {\n left: 20px !important;\n right: 20px !important;\n max-width: none !important;\n transform: none !important;\n }\n }\n `;\n document.head.appendChild( style );\n }\n\n document.body.appendChild( container );\n }\n\n return container;\n};\n\n/**\n * Shows a toast notification with the given configuration.\n * This is the recommended way to display toasts.\n *\n * @param config - The toast configuration\n * @returns The toast element instance\n *\n * @example\n * ```typescript\n * import { toastAdd } from '@liwe3/webcomponents';\n *\n * toastAdd({\n * title: 'Success!',\n * text: 'Your changes have been saved.',\n * type: 'success',\n * duration: 5000,\n * position: 'TR' // Optional: top-right (default)\n * });\n * ```\n */\nconst toastAdd = ( config: ToastConfig ): ToastElement => {\n const position = config.position || 'TR';\n const container = getToastContainer( position );\n const toast = document.createElement( 'liwe3-toast' ) as ToastElement;\n\n // Allow pointer events on individual toasts\n toast.style.pointerEvents = 'auto';\n\n // Show the toast with the provided config\n toast.show( config );\n\n // Add to container\n container.appendChild( toast );\n\n return toast;\n};\n\nexport { defineToast, toastAdd };\n"],"names":["ToastElement","_name","oldValue","newValue","attrTitle","configTitle","type","value","attr","config","container","handleAnimationEnd","hostElement","currentHeight","currentWidth","containerWidth","widthPercent","currentPercent","adjustedDuration","animationName","styleSheet","keyframes","target","buttonIndex","button","colors","iconContent","index","defineToast","tagName","CONTAINER_ID_PREFIX","getContainerStyles","position","getToastContainer","containerId","styles","styleId","style","toastAdd","toast"],"mappings":"AA0BO,MAAMA,UAAqB,YAAY;AAAA,EAc5C,cAAe;AACb,UAAA,GAbF,KAAQ,SAAsB;AAAA,MAC5B,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,UAAU;AAAA,IAAA,GAGZ,KAAQ,gBAAwB,GAChC,KAAQ,YAAoB,GAK1B,KAAK,aAAc,EAAE,MAAM,OAAA,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|
+
export type TreeNode = {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
children?: TreeNode[];
|
|
9
|
+
icon?: string;
|
|
10
|
+
customIcon?: string;
|
|
11
|
+
selected?: boolean;
|
|
12
|
+
expanded?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare class TreeViewElement extends HTMLElement {
|
|
15
|
+
shadowRoot: ShadowRoot;
|
|
16
|
+
private treeData;
|
|
17
|
+
private selectedIds;
|
|
18
|
+
private expandedIds;
|
|
19
|
+
private indentWidth;
|
|
20
|
+
private showBorder;
|
|
21
|
+
constructor();
|
|
22
|
+
static get observedAttributes(): string[];
|
|
23
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
24
|
+
get data(): TreeNode[];
|
|
25
|
+
set data(value: TreeNode[]);
|
|
26
|
+
get selectedNodeIds(): string[];
|
|
27
|
+
set selectedNodeIds(ids: string[]);
|
|
28
|
+
get showBorderEnabled(): boolean;
|
|
29
|
+
set showBorderEnabled(value: boolean);
|
|
30
|
+
/**
|
|
31
|
+
* Initialize expanded state from the data
|
|
32
|
+
*/
|
|
33
|
+
private initializeExpandedState;
|
|
34
|
+
/**
|
|
35
|
+
* Toggle node expansion
|
|
36
|
+
*/
|
|
37
|
+
toggleExpansion(nodeId: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Toggle node selection
|
|
40
|
+
*/
|
|
41
|
+
toggleSelection(nodeId: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Select all nodes recursively
|
|
44
|
+
*/
|
|
45
|
+
selectAll(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Deselect all nodes
|
|
48
|
+
*/
|
|
49
|
+
deselectAll(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Expand all nodes
|
|
52
|
+
*/
|
|
53
|
+
expandAll(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Collapse all nodes
|
|
56
|
+
*/
|
|
57
|
+
collapseAll(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Get node by ID
|
|
60
|
+
*/
|
|
61
|
+
private findNode;
|
|
62
|
+
/**
|
|
63
|
+
* Get the default folder icon
|
|
64
|
+
*/
|
|
65
|
+
private getDefaultIcon;
|
|
66
|
+
/**
|
|
67
|
+
* Render a single tree node
|
|
68
|
+
*/
|
|
69
|
+
private renderNode;
|
|
70
|
+
/**
|
|
71
|
+
* Bind event listeners
|
|
72
|
+
*/
|
|
73
|
+
private bindEvents;
|
|
74
|
+
/**
|
|
75
|
+
* Render the component
|
|
76
|
+
*/
|
|
77
|
+
private render;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Conditionally defines the custom element if in a browser environment.
|
|
81
|
+
*/
|
|
82
|
+
declare const defineTreeView: (tagName?: string) => void;
|
|
83
|
+
export { defineTreeView };
|
|
84
|
+
//# sourceMappingURL=TreeView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeView.d.ts","sourceRoot":"","sources":["../src/TreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,qBAAa,eAAgB,SAAQ,WAAW;IACtC,UAAU,EAAE,UAAU,CAAC;IAC/B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,UAAU,CAAQ;;IAS1B,MAAM,KAAK,kBAAkB,IAAK,MAAM,EAAE,CAEzC;IAED,wB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