@konomi-app/ui 2.2.4 → 3.0.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/index.cjs ADDED
@@ -0,0 +1,763 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ ATTRIBUTE_ANIMATION: () => ATTRIBUTE_ANIMATION,
24
+ LoadingOverlay: () => LoadingOverlay,
25
+ Modal: () => Modal,
26
+ TaskListOverlay: () => TaskListOverlay,
27
+ withLoading: () => withLoading
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+
31
+ // src/overlay/style.ts
32
+ var import_css = require("@emotion/css");
33
+ var getBodyStyle = () => import_css.css`
34
+ overflow: visible;
35
+ &[${ATTRIBUTE_KEY}] {
36
+ overflow: hidden;
37
+ }
38
+ `;
39
+ var getRootStyle = () => import_css.css`
40
+ font-family: 'Yu Gothic Medium', '游ゴシック', YuGothic, 'メイリオ', 'Hiragino Kaku Gothic ProN',
41
+ Meiryo, sans-serif;
42
+ color: #356;
43
+ font-size: 14px;
44
+
45
+ overflow: hidden;
46
+ background-color: #fffb;
47
+ backdrop-filter: blur(4px);
48
+ box-sizing: content-box;
49
+
50
+ position: fixed;
51
+ inset: 0;
52
+ width: 100vw;
53
+ height: 100vh;
54
+
55
+ display: grid;
56
+ transition: all 250ms ease;
57
+ z-index: 1000;
58
+ opacity: 0;
59
+ transition: all 250ms ease;
60
+
61
+ place-items: end stretch;
62
+ @media (min-width: 640px) {
63
+ font-size: 16px;
64
+ place-items: center;
65
+ }
66
+
67
+ opacity: 0;
68
+ pointer-events: none;
69
+ &[${ATTRIBUTE_SHOWN}] {
70
+ opacity: 1;
71
+ pointer-events: all;
72
+ }
73
+ `;
74
+
75
+ // src/overlay/index.ts
76
+ var ATTRIBUTE_KEY = "data-konomi-ui-overlay";
77
+ var ATTRIBUTE_SHOWN = "data-shown";
78
+ var Overlay = class {
79
+ /**
80
+ * オーバーレイをレンダリングするルート要素。
81
+ */
82
+ #root;
83
+ /**
84
+ * オーバーレイをレンダリングするルート要素の`dataset`。
85
+ */
86
+ _rootDataset;
87
+ /**
88
+ * オーバーレイが表示されているかどうか。
89
+ */
90
+ _shown;
91
+ /**
92
+ * オーバーレイを表示中にページを離れようとした場合にアラートを表示するかどうかを設定します。
93
+ */
94
+ _disableBeforeUnload;
95
+ constructor() {
96
+ this._shown = false;
97
+ this._disableBeforeUnload = false;
98
+ this._rootDataset = {};
99
+ const root = document.createElement("div");
100
+ this.#root = root;
101
+ this.#root.classList.add(getRootStyle());
102
+ document.body.classList.add(getBodyStyle());
103
+ this.#root.setAttribute(ATTRIBUTE_KEY, "");
104
+ document.body.append(root);
105
+ }
106
+ show() {
107
+ this._shown = true;
108
+ this.#root.setAttribute(ATTRIBUTE_SHOWN, "");
109
+ document.body.setAttribute(ATTRIBUTE_KEY, "");
110
+ window.addEventListener("beforeunload", this.beforeunload);
111
+ this.render();
112
+ }
113
+ hide() {
114
+ this._shown = false;
115
+ this.#root.removeAttribute(ATTRIBUTE_SHOWN);
116
+ document.body.removeAttribute(ATTRIBUTE_KEY);
117
+ window.removeEventListener("beforeunload", this.beforeunload);
118
+ this.render();
119
+ }
120
+ render() {
121
+ }
122
+ /** JavaScript中にページを離れようとした場合にアラートを表示します */
123
+ beforeunload(event) {
124
+ event.preventDefault();
125
+ }
126
+ get root() {
127
+ return this.#root;
128
+ }
129
+ /** @deprecated このメソッドは非推奨です。代わりに`show`メソッドを使用してください。 */
130
+ start() {
131
+ this.show();
132
+ }
133
+ /** @deprecated このメソッドは非推奨です。代わりに`hide`メソッドを使用してください。 */
134
+ stop() {
135
+ this.hide();
136
+ }
137
+ };
138
+
139
+ // src/loading-overlay/style.ts
140
+ var import_css2 = require("@emotion/css");
141
+ var containerStyle = import_css2.css`
142
+ display: flex;
143
+ flex-direction: column;
144
+ align-items: center;
145
+ justify-content: center;
146
+ gap: 32px;
147
+ padding: 24px;
148
+ background-color: #fff;
149
+ border-radius: 0;
150
+ box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
151
+ border: 1px solid #f3f4f6;
152
+ min-height: 200px;
153
+ position: relative;
154
+ overflow: hidden;
155
+ transition: all 250ms ease;
156
+
157
+ @media (min-width: 640px) {
158
+ width: 400px;
159
+ max-width: 90vw;
160
+ border-radius: 4px;
161
+ padding: 32px;
162
+ }
163
+ `;
164
+ var getLoaderStyle = () => import_css2.css`
165
+ font-size: 60px;
166
+ width: 1em;
167
+ height: 1em;
168
+ border-radius: 50%;
169
+ box-shadow: inset 0 0 0 1px #3b82f633;
170
+ position: relative;
171
+
172
+ animation: none;
173
+ &[${ATTRIBUTE_ANIMATION}] {
174
+ animation: rotate 1.2s infinite linear;
175
+ }
176
+
177
+ > div {
178
+ position: absolute;
179
+ left: 50%;
180
+ top: 50%;
181
+ width: 0.5em;
182
+ height: 1em;
183
+ margin-left: -0.5em;
184
+ margin-top: -0.5em;
185
+ overflow: hidden;
186
+ transform-origin: 0.5em 0.5em;
187
+ mask-image: linear-gradient(top, #000f, #0000);
188
+ -webkit-mask-image: -webkit-linear-gradient(top, #000f, #0000);
189
+
190
+ > div {
191
+ width: 1em;
192
+ height: 1em;
193
+ border-radius: 50%;
194
+ box-shadow: inset 0 0 0 1px #3b82f6;
195
+ }
196
+ }
197
+ @keyframes rotate {
198
+ 0% {
199
+ transform: rotate(0deg);
200
+ }
201
+ 100% {
202
+ transform: rotate(360deg);
203
+ }
204
+ }
205
+ `;
206
+ var progressStyle = import_css2.css`
207
+ position: absolute;
208
+ bottom: 0px;
209
+ left: 0;
210
+ width: 0%;
211
+ height: 2px;
212
+ background-color: #2563eb;
213
+ transition: all 350ms ease;
214
+ `;
215
+
216
+ // src/loading-overlay/index.ts
217
+ var ATTRIBUTE_ANIMATION = "data-animation";
218
+ var LoadingOverlay = class extends Overlay {
219
+ #label;
220
+ #html;
221
+ #progress;
222
+ _loaderElement;
223
+ _progressElement;
224
+ _contentElement;
225
+ constructor(props = {}) {
226
+ super();
227
+ this.#label = props.label ?? "";
228
+ this.#html = "";
229
+ this.#progress = props.progress ?? null;
230
+ const container = document.createElement("div");
231
+ container.classList.add(containerStyle);
232
+ this.root.append(container);
233
+ const loaderElement = document.createElement("div");
234
+ loaderElement.innerHTML = "<div><div></div></div>";
235
+ loaderElement.classList.add(getLoaderStyle());
236
+ this._loaderElement = loaderElement;
237
+ container.append(loaderElement);
238
+ const progressElement = document.createElement("div");
239
+ progressElement.classList.add(progressStyle);
240
+ this._progressElement = progressElement;
241
+ container.append(progressElement);
242
+ const contentElement = document.createElement("div");
243
+ this._contentElement = contentElement;
244
+ container.append(contentElement);
245
+ this.render();
246
+ }
247
+ show() {
248
+ super.show();
249
+ this._loaderElement.setAttribute(ATTRIBUTE_ANIMATION, "");
250
+ }
251
+ hide() {
252
+ super.hide();
253
+ this._loaderElement.removeAttribute(ATTRIBUTE_ANIMATION);
254
+ this.#progress = 0;
255
+ this.#html = "";
256
+ this.#label = "";
257
+ }
258
+ set label(label) {
259
+ this.#label = label;
260
+ this.render();
261
+ }
262
+ set html(html) {
263
+ this.#html = html;
264
+ this.render();
265
+ }
266
+ /**
267
+ * 進捗状況を設定します。
268
+ * @param percent 進捗のパーセンテージ(0-100)
269
+ */
270
+ set progress(percent) {
271
+ this.#progress = percent;
272
+ this.render();
273
+ }
274
+ render() {
275
+ super.render();
276
+ this._progressElement.style.width = `${this.#progress}%`;
277
+ if (this.#html) {
278
+ this._contentElement.innerHTML = this.#html;
279
+ } else {
280
+ if (this.#label instanceof Array) {
281
+ this._contentElement.innerHTML = `<div>${this.#label.join("</div><div>")}</div>`;
282
+ } else {
283
+ this._contentElement.innerText = this.#label;
284
+ }
285
+ }
286
+ }
287
+ };
288
+
289
+ // src/task-list-overlay.ts
290
+ var import_css3 = require("@emotion/css");
291
+ var TaskListOverlay = class extends Overlay {
292
+ #taskList;
293
+ _contentElement;
294
+ constructor(props = {}) {
295
+ super();
296
+ this.#taskList = props.taskList ?? [];
297
+ const container = document.createElement("div");
298
+ container.classList.add(this.containerStyle);
299
+ this.root.append(container);
300
+ const contentElement = document.createElement("div");
301
+ this._contentElement = contentElement;
302
+ contentElement.classList.add(this.contentStyle);
303
+ container.append(contentElement);
304
+ this.render();
305
+ }
306
+ hide() {
307
+ this.#taskList = [];
308
+ super.hide();
309
+ }
310
+ done(key) {
311
+ const task = this.#taskList.find((t) => t.key === key);
312
+ if (task) {
313
+ task.status = "done";
314
+ this.render();
315
+ }
316
+ }
317
+ error(key) {
318
+ const task = this.#taskList.find((t) => t.key === key);
319
+ if (task) {
320
+ task.status = "error";
321
+ this.render();
322
+ }
323
+ }
324
+ inProgress(key) {
325
+ const task = this.#taskList.find((t) => t.key === key);
326
+ if (task) {
327
+ task.status = "in-progress";
328
+ this.render();
329
+ }
330
+ }
331
+ addTask(...tasks) {
332
+ this.#taskList.push(...tasks.map(({ key, label }) => ({ key, label, status: "new" })));
333
+ this.render();
334
+ }
335
+ render() {
336
+ super.render();
337
+ this._contentElement.innerHTML = `
338
+ <div class="${this.taskListContainerStyle}">
339
+ ${this.#taskList.map((task) => this.renderTask(task)).join("")}
340
+ </div>
341
+ `;
342
+ }
343
+ renderTask(task) {
344
+ const label = Array.isArray(task.label) ? task.label.join(" ") : task.label;
345
+ const status = task.status;
346
+ return `
347
+ <div class="${this.taskContainerStyle}">
348
+ <div class="${this.taskStatusStyle} status-${status}">${this.getTaskStatusElement(
349
+ task.status
350
+ )}</div>
351
+ <div class="${this.taskLabelStyle}">${label}</div>
352
+ </div>
353
+ `;
354
+ }
355
+ getTaskStatusElement(status) {
356
+ switch (status) {
357
+ case "new":
358
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="#ddd" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-minus-circle"><circle cx="12" cy="12" r="10"></circle><line x1="8" y1="12" x2="16" y2="12"></line></svg>`;
359
+ case "in-progress":
360
+ return `<div><div></div></div>`;
361
+ case "done":
362
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="#80beaf" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-check-circle"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>`;
363
+ default:
364
+ return ``;
365
+ }
366
+ }
367
+ containerStyle = import_css3.css`
368
+ display: flex;
369
+ flex-direction: column;
370
+ align-items: center;
371
+ justify-content: center;
372
+ gap: 32px;
373
+ padding: 32px 64px;
374
+ background-color: #fffc;
375
+ border-radius: 8px;
376
+ box-shadow: 0 5px 24px -6px #0002;
377
+ width: 300px;
378
+ max-width: 90vw;
379
+ min-height: 200px;
380
+ position: relative;
381
+ overflow: hidden;
382
+ transition: all 250ms ease;
383
+
384
+ @keyframes spin {
385
+ 0% {
386
+ transform: rotate(0deg);
387
+ border-radius: 1em;
388
+ }
389
+ 20% {
390
+ transform: rotate(0deg);
391
+ }
392
+ 30%,
393
+ 60% {
394
+ border-radius: 0.25em;
395
+ }
396
+ 70% {
397
+ transform: rotate(180deg);
398
+ }
399
+ 100% {
400
+ transform: rotate(180deg);
401
+ border-radius: 1em;
402
+ }
403
+ }
404
+ `;
405
+ contentStyle = import_css3.css`
406
+ width: 100%;
407
+ `;
408
+ taskListContainerStyle = import_css3.css`
409
+ display: flex;
410
+ flex-direction: column;
411
+ gap: 1em;
412
+ width: 100%;
413
+ `;
414
+ taskContainerStyle = import_css3.css`
415
+ display: flex;
416
+ align-items: center;
417
+ gap: 1em;
418
+ `;
419
+ taskLabelStyle = import_css3.css``;
420
+ taskStatusStyle = import_css3.css`
421
+ font-size: 32px;
422
+ width: 1em;
423
+ height: 1em;
424
+ display: flex;
425
+ justify-content: center;
426
+ align-items: center;
427
+
428
+ &.status-new {
429
+ }
430
+
431
+ &.status-in-progress {
432
+ border-radius: 50%;
433
+ box-shadow: inset 0 0 0 1px #3b82f633;
434
+ position: relative;
435
+ animation: rotate 1.2s infinite linear;
436
+ > div {
437
+ position: absolute;
438
+ left: 50%;
439
+ top: 50%;
440
+ width: 0.5em;
441
+ height: 1em;
442
+ margin-left: -0.5em;
443
+ margin-top: -0.5em;
444
+ overflow: hidden;
445
+ transform-origin: 0.5em 0.5em;
446
+ mask-image: linear-gradient(top, #000f, #0000);
447
+ -webkit-mask-image: -webkit-linear-gradient(top, #000f, #0000);
448
+
449
+ > div {
450
+ width: 1em;
451
+ height: 1em;
452
+ border-radius: 50%;
453
+ box-shadow: inset 0 0 0 1px #3b82f6;
454
+ }
455
+ }
456
+ @keyframes rotate {
457
+ 0% {
458
+ transform: rotate(0deg);
459
+ }
460
+ 100% {
461
+ transform: rotate(360deg);
462
+ }
463
+ }
464
+ }
465
+ `;
466
+ };
467
+
468
+ // src/modal/style.ts
469
+ var import_css4 = require("@emotion/css");
470
+ var containerStyle2 = import_css4.css`
471
+ display: grid;
472
+ gap: 2px;
473
+ padding: 24px;
474
+ background-color: #fff;
475
+ border-radius: 0;
476
+ box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
477
+ border: 1px solid #f3f4f6;
478
+ min-height: 200px;
479
+ position: relative;
480
+ overflow: hidden;
481
+ transition: all 250ms ease;
482
+
483
+ @media (min-width: 640px) {
484
+ width: 400px;
485
+ max-width: 90vw;
486
+ border-radius: 4px;
487
+ padding: 32px;
488
+ }
489
+ `;
490
+ var iconStyle = import_css4.css``;
491
+ var titleStyle = import_css4.css`
492
+ font-size: 18px;
493
+ font-weight: 600;
494
+ color: #1f2937;
495
+ text-align: center;
496
+ @media (min-width: 640px) {
497
+ text-align: left;
498
+ }
499
+ `;
500
+ var loaderStyle = import_css4.css`
501
+ font-size: 60px;
502
+ width: 1em;
503
+ height: 1em;
504
+ border-radius: 50%;
505
+ box-shadow: inset 0 0 0 1px #3b82f633;
506
+ position: relative;
507
+
508
+ animation: none;
509
+ &[data-state='loading'] {
510
+ animation: rotate 1s linear infinite;
511
+ }
512
+
513
+ > div {
514
+ position: absolute;
515
+ left: 50%;
516
+ top: 50%;
517
+ width: 0.5em;
518
+ height: 1em;
519
+ margin-left: -0.5em;
520
+ margin-top: -0.5em;
521
+ overflow: hidden;
522
+ transform-origin: 0.5em 0.5em;
523
+ mask-image: linear-gradient(top, #000f, #0000);
524
+ -webkit-mask-image: -webkit-linear-gradient(top, #000f, #0000);
525
+
526
+ > div {
527
+ width: 1em;
528
+ height: 1em;
529
+ border-radius: 50%;
530
+ box-shadow: inset 0 0 0 1px #3b82f6;
531
+ }
532
+ }
533
+ @keyframes rotate {
534
+ 0% {
535
+ transform: rotate(0deg);
536
+ }
537
+ 100% {
538
+ transform: rotate(360deg);
539
+ }
540
+ }
541
+ `;
542
+ var progressStyle2 = import_css4.css`
543
+ position: absolute;
544
+ bottom: 0px;
545
+ left: 0;
546
+ width: 0%;
547
+ height: 2px;
548
+ background-color: #2563eb;
549
+ transition: all 350ms ease;
550
+ `;
551
+ var actionsStyle = import_css4.css`
552
+ display: flex;
553
+ flex-direction: column;
554
+ justify-content: flex-end;
555
+ align-items: flex-end;
556
+ gap: 8px;
557
+
558
+ @media (min-width: 640px) {
559
+ flex-direction: row;
560
+ }
561
+ `;
562
+
563
+ // src/modal/index.ts
564
+ var Modal = class extends Overlay {
565
+ #title;
566
+ #html;
567
+ #label;
568
+ #progress;
569
+ #state;
570
+ _containerElement;
571
+ _iconElement;
572
+ _titleElement;
573
+ _loaderElement;
574
+ _progressElement;
575
+ _contentElement;
576
+ _actionsElement;
577
+ _okButtonElement;
578
+ _cancelButtonElement;
579
+ constructor(props = {}) {
580
+ super();
581
+ this.#title = "";
582
+ this.#html = "";
583
+ this.#label = props.label ?? "";
584
+ this.#progress = props.progress ?? null;
585
+ this.#state = "hidden";
586
+ const container = document.createElement("div");
587
+ container.classList.add(containerStyle2);
588
+ this._containerElement = container;
589
+ this.root.append(container);
590
+ const iconElement = document.createElement("div");
591
+ iconElement.classList.add(iconStyle);
592
+ this._iconElement = iconElement;
593
+ container.append(iconElement);
594
+ const titleElement = document.createElement("div");
595
+ titleElement.classList.add(titleStyle);
596
+ this._titleElement = titleElement;
597
+ container.append(titleElement);
598
+ const loaderElement = document.createElement("div");
599
+ loaderElement.innerHTML = "<div><div></div></div>";
600
+ loaderElement.classList.add(loaderStyle);
601
+ this._loaderElement = loaderElement;
602
+ const progressElement = document.createElement("div");
603
+ progressElement.classList.add(progressStyle2);
604
+ this._progressElement = progressElement;
605
+ container.append(progressElement);
606
+ const contentElement = document.createElement("div");
607
+ this._contentElement = contentElement;
608
+ container.append(contentElement);
609
+ const actionsElement = document.createElement("div");
610
+ actionsElement.classList.add(actionsStyle);
611
+ this._actionsElement = actionsElement;
612
+ container.append(actionsElement);
613
+ const okButtonElement = document.createElement("button");
614
+ okButtonElement.type = "button";
615
+ okButtonElement.textContent = "OK";
616
+ this._okButtonElement = okButtonElement;
617
+ actionsElement.append(okButtonElement);
618
+ const cancelButtonElement = document.createElement("button");
619
+ cancelButtonElement.type = "button";
620
+ cancelButtonElement.textContent = "\u30AD\u30E3\u30F3\u30BB\u30EB";
621
+ this._cancelButtonElement = cancelButtonElement;
622
+ actionsElement.append(cancelButtonElement);
623
+ this.render();
624
+ }
625
+ alert(params) {
626
+ const {
627
+ title = "",
628
+ text = "",
629
+ icon = "",
630
+ disableClose = false,
631
+ disableEscape = false
632
+ } = params;
633
+ this.#title = title;
634
+ this.#label = text;
635
+ this.changeState("alert");
636
+ this.show();
637
+ return new Promise((resolve) => {
638
+ this._okButtonElement.addEventListener("click", () => {
639
+ if (!disableClose) {
640
+ this.hide();
641
+ }
642
+ resolve({
643
+ isConfirmed: true
644
+ });
645
+ });
646
+ this._cancelButtonElement.addEventListener("click", () => {
647
+ if (!disableClose) {
648
+ this.hide();
649
+ }
650
+ resolve({
651
+ isConfirmed: false
652
+ });
653
+ });
654
+ this.root.addEventListener("click", (event) => {
655
+ if (event.currentTarget === event.target) {
656
+ if (!disableClose) {
657
+ this.hide();
658
+ }
659
+ resolve({
660
+ isConfirmed: false
661
+ });
662
+ }
663
+ });
664
+ this.root.addEventListener("keydown", (event) => {
665
+ if (event.key === "Escape") {
666
+ if (!disableEscape) {
667
+ this.hide();
668
+ }
669
+ resolve({
670
+ isConfirmed: false
671
+ });
672
+ }
673
+ });
674
+ });
675
+ }
676
+ loading() {
677
+ this._iconElement.append(this._loaderElement);
678
+ this.changeState("loading");
679
+ this.show();
680
+ }
681
+ hide() {
682
+ this.#progress = 0;
683
+ this.#html = "";
684
+ this.#label = "";
685
+ this.changeState("hidden");
686
+ super.hide();
687
+ }
688
+ set label(label) {
689
+ this.#label = label;
690
+ this.render();
691
+ }
692
+ set html(html) {
693
+ this.#html = html;
694
+ this.render();
695
+ }
696
+ set progress(progress) {
697
+ this.#progress = progress;
698
+ this.render();
699
+ }
700
+ changeState(state) {
701
+ this.#state = state;
702
+ const elements = [
703
+ this.root,
704
+ this._actionsElement,
705
+ this._contentElement,
706
+ this._iconElement,
707
+ this._loaderElement,
708
+ this._progressElement,
709
+ this._titleElement
710
+ ];
711
+ for (const element of elements) {
712
+ element.dataset.state = state;
713
+ }
714
+ this.render();
715
+ }
716
+ render() {
717
+ super.render();
718
+ this._progressElement.style.width = `${this.#progress}%`;
719
+ switch (this.#state) {
720
+ case "loading":
721
+ break;
722
+ case "alert":
723
+ this._iconElement.innerHTML = "";
724
+ break;
725
+ case "hidden":
726
+ default:
727
+ this._iconElement.innerHTML = "";
728
+ break;
729
+ }
730
+ this._titleElement.textContent = this.#title;
731
+ if (this.#html) {
732
+ this._contentElement.innerHTML = this.#html;
733
+ } else {
734
+ if (this.#label instanceof Array) {
735
+ this._contentElement.innerHTML = `<div>${this.#label.join("</div><div>")}</div>`;
736
+ } else {
737
+ this._contentElement.textContent = this.#label;
738
+ }
739
+ }
740
+ }
741
+ };
742
+
743
+ // src/utilities.ts
744
+ var withLoading = (fn, label = "Loading...") => {
745
+ return async (...args) => {
746
+ const overlay = new LoadingOverlay({ label });
747
+ overlay.show();
748
+ try {
749
+ return await fn(...args);
750
+ } finally {
751
+ overlay.hide();
752
+ }
753
+ };
754
+ };
755
+ // Annotate the CommonJS export names for ESM import in node:
756
+ 0 && (module.exports = {
757
+ ATTRIBUTE_ANIMATION,
758
+ LoadingOverlay,
759
+ Modal,
760
+ TaskListOverlay,
761
+ withLoading
762
+ });
763
+ //# sourceMappingURL=index.cjs.map