@italia/progress 1.0.0-alpha.7

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.
@@ -0,0 +1,1022 @@
1
+ import { BaseComponent, setAttributes } from '@italia/globals';
2
+ import { css, html } from 'lit';
3
+ import { property, customElement } from 'lit/decorators.js';
4
+ import { ifDefined } from 'lit/directives/if-defined.js';
5
+ import { styleMap } from 'lit/directives/style-map.js';
6
+ import { when } from 'lit/directives/when.js';
7
+
8
+ /******************************************************************************
9
+ Copyright (c) Microsoft Corporation.
10
+
11
+ Permission to use, copy, modify, and/or distribute this software for any
12
+ purpose with or without fee is hereby granted.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
+ PERFORMANCE OF THIS SOFTWARE.
21
+ ***************************************************************************** */
22
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
23
+
24
+
25
+ function __decorate(decorators, target, key, desc) {
26
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
27
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
28
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
29
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
30
+ }
31
+
32
+ function __metadata(metadataKey, metadataValue) {
33
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
34
+ }
35
+
36
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
37
+ var e = new Error(message);
38
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
39
+ };
40
+
41
+ class ProgressDonut {
42
+ constructor(bar) {
43
+ this._bar = bar;
44
+ }
45
+ static async create(container, config) {
46
+ const CircleConstructor = await this._loadCircleConstructor();
47
+ const bar = new CircleConstructor(container, {
48
+ color: config.color,
49
+ trailColor: config.trailColor,
50
+ strokeWidth: config.strokeWidth,
51
+ trailWidth: config.trailWidth,
52
+ easing: config.easing,
53
+ duration: config.duration,
54
+ text: {
55
+ autoStyleContainer: false,
56
+ },
57
+ step: (_state, circle) => {
58
+ const value = Math.round(circle.value() * 100);
59
+ circle.setText(`${value}%`);
60
+ config.onStep?.(value);
61
+ },
62
+ });
63
+ const instance = new ProgressDonut(bar);
64
+ instance.setValue(config.value, config.animate);
65
+ return instance;
66
+ }
67
+ setValue(value, animate = true) {
68
+ if (animate) {
69
+ this._bar.animate(value);
70
+ return;
71
+ }
72
+ this._bar.set(value);
73
+ }
74
+ destroy() {
75
+ this._bar.destroy();
76
+ }
77
+ static async _loadCircleConstructor() {
78
+ try {
79
+ const mod = await import('../circle-B1NDrCPo.js').then(function (n) { return n.c; });
80
+ return mod.default ?? mod;
81
+ }
82
+ catch {
83
+ const mod = await import('../progressbar-CWxngKQm.js').then(function (n) { return n.p; });
84
+ return (mod.default ?? mod).Circle;
85
+ }
86
+ }
87
+ }
88
+
89
+ var styles = css`/***************************** 1 ****************************************/
90
+ /***************************** 2 ****************************************/
91
+ /***************************** 1 ****************************************/
92
+ /***************************** 2 ****************************************/
93
+ /***************************** 1 ****************************************/
94
+ /***************************** 2 ****************************************/
95
+ /***************************** 3 ****************************************/
96
+ /***************************** 1 ****************************************/
97
+ /***************************** 2 ****************************************/
98
+ /***************************** 3 ****************************************/
99
+ /***************************** NEUTRAL 1 ****************************************/
100
+ /***************************** NEUTRAL 2 ****************************************/
101
+ /***************************** NEUTRAL 2 / 3 ****************************************/
102
+ *,
103
+ *::before,
104
+ *::after {
105
+ box-sizing: border-box;
106
+ }
107
+
108
+ @media (prefers-reduced-motion: no-preference) {
109
+ :root {
110
+ scroll-behavior: smooth;
111
+ }
112
+ }
113
+
114
+ body {
115
+ margin: 0;
116
+ -webkit-text-size-adjust: 100%;
117
+ -webkit-tap-highlight-color: hsla(0, 0%, 0%, 0);
118
+ }
119
+
120
+ hr {
121
+ margin: 1rem 0;
122
+ color: inherit;
123
+ border: 0;
124
+ border-top: 1px solid;
125
+ opacity: 0.25;
126
+ }
127
+
128
+ p {
129
+ margin-top: 0;
130
+ margin-bottom: var(--bsi-paragraph-spacing);
131
+ }
132
+
133
+ abbr[title] {
134
+ text-decoration: underline dotted;
135
+ cursor: help;
136
+ text-decoration-skip-ink: none;
137
+ }
138
+
139
+ address {
140
+ margin-bottom: var(--bsi-spacing-s);
141
+ font-style: normal;
142
+ line-height: inherit;
143
+ }
144
+
145
+ ol,
146
+ ul {
147
+ padding-left: var(--bsi-spacing-l);
148
+ }
149
+
150
+ ol,
151
+ ul,
152
+ dl {
153
+ margin-top: 0;
154
+ margin-bottom: var(--bsi-spacing-s);
155
+ }
156
+
157
+ ol ol,
158
+ ul ul,
159
+ ol ul,
160
+ ul ol {
161
+ margin-bottom: 0;
162
+ }
163
+
164
+ dt {
165
+ font-weight: var(--bsi-font-weight-strong);
166
+ }
167
+
168
+ dd {
169
+ margin-bottom: var(--bsi-spacing-xxs);
170
+ margin-left: 0;
171
+ }
172
+
173
+ blockquote {
174
+ margin: 0 0 var(--bsi-spacing-s);
175
+ }
176
+
177
+ sub,
178
+ sup {
179
+ position: relative;
180
+ font-size: var(--bsi-font-size-1);
181
+ line-height: 0;
182
+ vertical-align: baseline;
183
+ }
184
+
185
+ sub {
186
+ bottom: -0.25em;
187
+ }
188
+
189
+ sup {
190
+ top: -0.5em;
191
+ }
192
+
193
+ a {
194
+ color: var(--bsi-color-link);
195
+ text-decoration: underline;
196
+ text-decoration-skip-ink: auto;
197
+ text-underline-offset: 2px;
198
+ }
199
+ a:hover {
200
+ color: var(--bsi-color-link-hover);
201
+ cursor: pointer;
202
+ }
203
+
204
+ pre,
205
+ code,
206
+ kbd,
207
+ samp {
208
+ font-size: 1em;
209
+ }
210
+
211
+ pre {
212
+ display: block;
213
+ margin-top: 0;
214
+ margin-bottom: var(--bsi-paragraph-spacing);
215
+ overflow: auto;
216
+ }
217
+ pre code {
218
+ word-break: normal;
219
+ }
220
+
221
+ a > code {
222
+ color: inherit;
223
+ }
224
+
225
+ figure {
226
+ margin: 0 0 1rem;
227
+ }
228
+
229
+ img,
230
+ svg {
231
+ vertical-align: middle;
232
+ }
233
+
234
+ table {
235
+ caption-side: bottom;
236
+ border-collapse: collapse;
237
+ }
238
+
239
+ caption {
240
+ padding-top: 0.5rem;
241
+ padding-bottom: 0.5rem;
242
+ color: hsl(210, 17%, 44%);
243
+ text-align: left;
244
+ }
245
+
246
+ th {
247
+ text-align: inherit;
248
+ text-align: -webkit-match-parent;
249
+ }
250
+
251
+ thead,
252
+ tbody,
253
+ tfoot,
254
+ tr,
255
+ td,
256
+ th {
257
+ border-color: inherit;
258
+ border-style: solid;
259
+ border-width: 0;
260
+ }
261
+
262
+ label {
263
+ display: inline-block;
264
+ }
265
+
266
+ button {
267
+ border-radius: 0;
268
+ }
269
+
270
+ button:focus:not(:focus-visible) {
271
+ outline: 0;
272
+ }
273
+
274
+ input,
275
+ button,
276
+ select,
277
+ optgroup,
278
+ textarea {
279
+ margin: 0;
280
+ font-family: inherit;
281
+ font-size: inherit;
282
+ line-height: inherit;
283
+ }
284
+
285
+ button,
286
+ select {
287
+ text-transform: none;
288
+ }
289
+
290
+ [role=button] {
291
+ cursor: pointer;
292
+ }
293
+
294
+ select {
295
+ word-wrap: normal;
296
+ }
297
+ select:disabled {
298
+ opacity: 1;
299
+ }
300
+
301
+ [list]:not([type=date]):not([type=datetime-local]):not([type=month]):not([type=week]):not([type=time])::-webkit-calendar-picker-indicator {
302
+ display: none !important;
303
+ }
304
+
305
+ button,
306
+ [type=button],
307
+ [type=reset],
308
+ [type=submit] {
309
+ -webkit-appearance: button;
310
+ }
311
+ button:not(:disabled),
312
+ [type=button]:not(:disabled),
313
+ [type=reset]:not(:disabled),
314
+ [type=submit]:not(:disabled) {
315
+ cursor: pointer;
316
+ }
317
+
318
+ ::-moz-focus-inner {
319
+ padding: 0;
320
+ border-style: none;
321
+ }
322
+
323
+ textarea {
324
+ resize: vertical;
325
+ }
326
+
327
+ fieldset {
328
+ min-width: 0;
329
+ padding: 0;
330
+ margin: 0;
331
+ border: 0;
332
+ }
333
+
334
+ ::-webkit-datetime-edit-fields-wrapper,
335
+ ::-webkit-datetime-edit-text,
336
+ ::-webkit-datetime-edit-minute,
337
+ ::-webkit-datetime-edit-hour-field,
338
+ ::-webkit-datetime-edit-day-field,
339
+ ::-webkit-datetime-edit-month-field,
340
+ ::-webkit-datetime-edit-year-field {
341
+ padding: 0;
342
+ }
343
+
344
+ ::-webkit-inner-spin-button {
345
+ height: auto;
346
+ }
347
+
348
+ [type=search] {
349
+ outline-offset: -2px;
350
+ -webkit-appearance: textfield;
351
+ }
352
+
353
+ /* rtl:raw:
354
+ [type="tel"],
355
+ [type="url"],
356
+ [type="email"],
357
+ [type="number"] {
358
+ direction: ltr;
359
+ }
360
+ */
361
+ ::-webkit-search-decoration {
362
+ -webkit-appearance: none;
363
+ }
364
+
365
+ ::-webkit-color-swatch-wrapper {
366
+ padding: 0;
367
+ }
368
+
369
+ ::file-selector-button {
370
+ font: inherit;
371
+ -webkit-appearance: button;
372
+ }
373
+
374
+ output {
375
+ display: inline-block;
376
+ }
377
+
378
+ iframe {
379
+ border: 0;
380
+ }
381
+
382
+ summary {
383
+ display: list-item;
384
+ cursor: pointer;
385
+ }
386
+
387
+ progress {
388
+ vertical-align: baseline;
389
+ }
390
+
391
+ [hidden] {
392
+ display: none !important;
393
+ }
394
+
395
+ .visually-hidden,
396
+ .visually-hidden-focusable:not(:focus):not(:focus-within) {
397
+ position: absolute !important;
398
+ width: 1px !important;
399
+ height: 1px !important;
400
+ padding: 0 !important;
401
+ margin: -1px !important;
402
+ overflow: hidden !important;
403
+ clip: rect(0, 0, 0, 0) !important;
404
+ white-space: nowrap !important;
405
+ border: 0 !important;
406
+ }
407
+
408
+ .progress-spinner, .progress {
409
+ --bsi-progress-bg: var(--bsi-color-background-secondary-lighter);
410
+ --bsi-progress-border-radius: var(--bsi-radius-smooth);
411
+ --bsi-progress-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.075);
412
+ --bsi-progress-label-color: var(--bsi-color-text-secondary);
413
+ --bsi-progress-label-font-size: var(--bsi-label-font-size-xs);
414
+ --bsi-progress-bar-transition: width 0.5s ease;
415
+ --bsi-progress-bar-bg: var(--bsi-color-background-secondary);
416
+ --bsi-progress-height: 4px;
417
+ }
418
+
419
+ .progress-bar-striped {
420
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
421
+ background-size: var(--bsi-progress-height) var(--bsi-progress-height);
422
+ }
423
+
424
+ .progress-bar-animated {
425
+ animation: 1s linear infinite progress-bar-stripes;
426
+ }
427
+ @media (prefers-reduced-motion: reduce) {
428
+ .progress-bar-animated {
429
+ animation: none;
430
+ }
431
+ }
432
+
433
+ @keyframes progress-bar-stripes {
434
+ 0% {
435
+ background-position-x: 16px;
436
+ }
437
+ }
438
+ @keyframes progressBarIndeterminate {
439
+ 0% {
440
+ left: -5%;
441
+ }
442
+ 50% {
443
+ width: 66%;
444
+ }
445
+ 100% {
446
+ left: 100%;
447
+ width: 33%;
448
+ }
449
+ }
450
+ .progress {
451
+ display: flex;
452
+ overflow: hidden;
453
+ background-color: var(--bsi-progress-bg);
454
+ border-radius: var(--bsi-progress-border-radius);
455
+ height: var(--bsi-progress-height);
456
+ box-shadow: none;
457
+ }
458
+ .progress.progress-indeterminate {
459
+ position: relative;
460
+ }
461
+ .progress.progress-indeterminate .progress-bar {
462
+ width: 0;
463
+ animation: progressBarIndeterminate 1.4s cubic-bezier(0.77, 0, 0.175, 1) infinite forwards;
464
+ position: absolute;
465
+ top: 0;
466
+ bottom: 0;
467
+ }
468
+
469
+ .progress-bar {
470
+ display: flex;
471
+ flex-direction: column;
472
+ justify-content: center;
473
+ overflow: hidden;
474
+ text-align: center;
475
+ white-space: nowrap;
476
+ transition: var(--bsi-progress-bar-transition);
477
+ }
478
+ @media (prefers-reduced-motion: reduce) {
479
+ .progress-bar {
480
+ transition: none;
481
+ }
482
+ }
483
+ .progress-bar {
484
+ background-color: var(--bsi-progress-bar-bg);
485
+ }
486
+
487
+ .progress-bar-label {
488
+ text-align: right;
489
+ font-size: var(--bsi-progress-label-font-size);
490
+ color: var(--bsi-progress-label-color);
491
+ font-weight: 500;
492
+ }
493
+
494
+ .btn-progress .progress {
495
+ display: block;
496
+ position: absolute;
497
+ bottom: 0;
498
+ width: 100%;
499
+ left: 0;
500
+ border-radius: 0 0 var(--bsi-progress-border-radius) var(--bsi-progress-border-radius);
501
+ }
502
+ .btn-progress .progress-bar {
503
+ height: var(--bsi-progress-height);
504
+ }
505
+
506
+ .progress-donut-wrapper {
507
+ position: relative;
508
+ width: 128px;
509
+ height: 128px;
510
+ }
511
+ .progress-donut-wrapper .progressbar-text {
512
+ z-index: 3;
513
+ color: var(--bsi-progress-label-color);
514
+ font-weight: var(--bsi-font-weight-solid);
515
+ }
516
+ .progress-donut-wrapper svg {
517
+ position: relative;
518
+ }
519
+ .progress-donut-wrapper svg path:first-child {
520
+ display: none;
521
+ }
522
+ .progress-donut-wrapper:after {
523
+ position: absolute;
524
+ top: 50%;
525
+ left: 50%;
526
+ z-index: 1;
527
+ content: "";
528
+ width: 67px;
529
+ height: 67px;
530
+ border-radius: var(--bsi-radius-circle);
531
+ background: var(--bsi-color-background-inverse);
532
+ transform: translateX(-50%) translateY(-50%);
533
+ }
534
+ .progress-donut-wrapper:before {
535
+ position: absolute;
536
+ top: 50%;
537
+ left: 50%;
538
+ z-index: 0;
539
+ content: "";
540
+ width: 110px;
541
+ height: 110px;
542
+ border-radius: 50%;
543
+ background: var(--bsi-color-background-secondary-lighter);
544
+ transform: translateX(-50%) translateY(-50%);
545
+ }
546
+
547
+ @media (min-width: 768px) {
548
+ .progress-donut-wrapper {
549
+ width: 180px;
550
+ height: 180px;
551
+ }
552
+ .progress-donut-wrapper:after {
553
+ width: 94px;
554
+ height: 94px;
555
+ }
556
+ .progress-donut-wrapper:before {
557
+ content: "";
558
+ width: 150px;
559
+ height: 150px;
560
+ }
561
+ }
562
+ .progress-spinner {
563
+ --bsi-progress-spinner-bg: var(--bsi-color-border-secondary);
564
+ --bsi-progress-spinner-size: 48px;
565
+ --bsi-progress-spinner-size-sm: 32px;
566
+ --bsi-progress-spinner-size-lg: 64px;
567
+ --bsi-progress-spinner-size-xl: 80px;
568
+ --bsi-progress-spinner-border-width: 4px;
569
+ --bsi-progress-spinner-animation-duration: 0.75s;
570
+ }
571
+
572
+ @keyframes spinnerAnim {
573
+ 0% {
574
+ transform: rotate(0);
575
+ }
576
+ 100% {
577
+ transform: rotate(360deg);
578
+ }
579
+ }
580
+ @keyframes spinnerAnimInner1 {
581
+ 0% {
582
+ transform: rotate(60deg);
583
+ }
584
+ 100% {
585
+ transform: rotate(205deg);
586
+ }
587
+ }
588
+ @keyframes spinnerAnimInner2 {
589
+ 0% {
590
+ transform: rotate(30deg);
591
+ }
592
+ 100% {
593
+ transform: rotate(-105deg);
594
+ }
595
+ }
596
+ /* stylelint-disable-next-line no-duplicate-selectors */
597
+ .progress-spinner {
598
+ display: block;
599
+ width: var(--bsi-progress-spinner-size);
600
+ height: var(--bsi-progress-spinner-size);
601
+ border-radius: 50%;
602
+ border: var(--bsi-progress-spinner-border-width) solid var(--bsi-progress-bg);
603
+ }
604
+ .progress-spinner.progress-spinner-active {
605
+ animation: spinnerAnim 0.75s linear infinite;
606
+ }
607
+ .progress-spinner.progress-spinner-active:not(.progress-spinner-double) {
608
+ border-color: hsl(210, 17%, 44%);
609
+ border-bottom-color: var(--bsi-progress-bg);
610
+ }
611
+ .progress-spinner.size-sm {
612
+ width: var(--bsi-progress-spinner-size-sm);
613
+ height: var(--bsi-progress-spinner-size-sm);
614
+ }
615
+ .progress-spinner.size-lg {
616
+ width: var(--bsi-progress-spinner-size-lg);
617
+ height: var(--bsi-progress-spinner-size-lg);
618
+ }
619
+ .progress-spinner.size-xl {
620
+ width: var(--bsi-progress-spinner-size-xl);
621
+ height: var(--bsi-progress-spinner-size-xl);
622
+ }
623
+ .progress-spinner.progress-spinner-double {
624
+ display: inline-block;
625
+ }
626
+ .progress-spinner.progress-spinner-double.size-sm {
627
+ width: var(--bsi-progress-spinner-size-sm);
628
+ height: var(--bsi-progress-spinner-size-sm);
629
+ }
630
+ .progress-spinner.progress-spinner-double.size-sm .progress-spinner-inner {
631
+ width: var(--bsi-progress-spinner-size-sm);
632
+ height: calc(var(--bsi-progress-spinner-size-sm) / 2);
633
+ }
634
+ .progress-spinner.progress-spinner-double.size-lg {
635
+ width: var(--bsi-progress-spinner-size-lg);
636
+ height: var(--bsi-progress-spinner-size-lg);
637
+ }
638
+ .progress-spinner.progress-spinner-double.size-lg .progress-spinner-inner {
639
+ width: var(--bsi-progress-spinner-size-lg);
640
+ height: calc(var(--bsi-progress-spinner-size-lg) / 2);
641
+ }
642
+ .progress-spinner.progress-spinner-double.size-xl {
643
+ width: var(--bsi-progress-spinner-size-xl);
644
+ height: var(--bsi-progress-spinner-size-xl);
645
+ }
646
+ .progress-spinner.progress-spinner-double.size-xl .progress-spinner-inner {
647
+ width: var(--bsi-progress-spinner-size-xl);
648
+ height: calc(var(--bsi-progress-spinner-size-xl) / 2);
649
+ }
650
+ .progress-spinner.progress-spinner-double.progress-spinner-active .progress-spinner-inner {
651
+ opacity: 1;
652
+ }
653
+ .progress-spinner.progress-spinner-double .progress-spinner-inner {
654
+ width: var(--bsi-progress-spinner-size);
655
+ height: calc(var(--bsi-progress-spinner-size) / 2);
656
+ overflow: hidden;
657
+ margin-left: calc(var(--bsi-progress-spinner-border-width) * -1);
658
+ opacity: 0;
659
+ transition: opacity 0.3s;
660
+ }
661
+ .progress-spinner.progress-spinner-double .progress-spinner-inner:nth-child(1) {
662
+ margin-top: calc(var(--bsi-progress-spinner-border-width) * -1);
663
+ }
664
+ .progress-spinner.progress-spinner-double .progress-spinner-inner:nth-child(2) {
665
+ transform: rotate(180deg);
666
+ }
667
+ .progress-spinner.progress-spinner-double .progress-spinner-inner:nth-child(2):after {
668
+ animation-name: spinnerAnimInner2;
669
+ }
670
+ .progress-spinner.progress-spinner-double .progress-spinner-inner:after {
671
+ content: "";
672
+ display: inline-block;
673
+ transform: rotate(45deg);
674
+ border-radius: 50%;
675
+ border: 4px solid var(--bsi-color-border-secondary);
676
+ border-right: var(--bsi-progress-spinner-border-width) solid transparent;
677
+ border-bottom: var(--bsi-progress-spinner-border-width) solid transparent;
678
+ width: 100%;
679
+ height: 200%;
680
+ animation: spinnerAnimInner1 0.75s cubic-bezier(0.25, 0.1, 0.5, 1) infinite alternate;
681
+ }
682
+
683
+ .bg-primary {
684
+ --bsi-bg-opacity: 1;
685
+ background-color: rgba(var(--bsi-primary-rgb), var(--bsi-bg-opacity)) !important;
686
+ }
687
+
688
+ .bg-secondary {
689
+ --bsi-bg-opacity: 1;
690
+ background-color: rgba(var(--bsi-secondary-rgb), var(--bsi-bg-opacity)) !important;
691
+ }
692
+
693
+ .bg-success {
694
+ --bsi-bg-opacity: 1;
695
+ background-color: rgba(var(--bsi-success-rgb), var(--bsi-bg-opacity)) !important;
696
+ }
697
+
698
+ .bg-info {
699
+ --bsi-bg-opacity: 1;
700
+ background-color: rgba(var(--bsi-info-rgb), var(--bsi-bg-opacity)) !important;
701
+ }
702
+
703
+ .bg-warning {
704
+ --bsi-bg-opacity: 1;
705
+ background-color: rgba(var(--bsi-warning-rgb), var(--bsi-bg-opacity)) !important;
706
+ }
707
+
708
+ .bg-danger {
709
+ --bsi-bg-opacity: 1;
710
+ background-color: rgba(var(--bsi-danger-rgb), var(--bsi-bg-opacity)) !important;
711
+ }
712
+
713
+ .bg-light {
714
+ --bsi-bg-opacity: 1;
715
+ background-color: rgba(var(--bsi-light-rgb), var(--bsi-bg-opacity)) !important;
716
+ }
717
+
718
+ .bg-dark {
719
+ --bsi-bg-opacity: 1;
720
+ background-color: rgba(var(--bsi-dark-rgb), var(--bsi-bg-opacity)) !important;
721
+ }
722
+
723
+ .bg-black {
724
+ --bsi-bg-opacity: 1;
725
+ background-color: rgba(var(--bsi-black-rgb), var(--bsi-bg-opacity)) !important;
726
+ }
727
+
728
+ .bg-white {
729
+ --bsi-bg-opacity: 1;
730
+ background-color: rgba(var(--bsi-white-rgb), var(--bsi-bg-opacity)) !important;
731
+ }
732
+
733
+ .bg-100 {
734
+ --bsi-bg-opacity: 1;
735
+ background-color: rgba(var(--bsi-100-rgb), var(--bsi-bg-opacity)) !important;
736
+ }
737
+
738
+ .bg-200 {
739
+ --bsi-bg-opacity: 1;
740
+ background-color: rgba(var(--bsi-200-rgb), var(--bsi-bg-opacity)) !important;
741
+ }
742
+
743
+ .bg-300 {
744
+ --bsi-bg-opacity: 1;
745
+ background-color: rgba(var(--bsi-300-rgb), var(--bsi-bg-opacity)) !important;
746
+ }
747
+
748
+ .bg-400 {
749
+ --bsi-bg-opacity: 1;
750
+ background-color: rgba(var(--bsi-400-rgb), var(--bsi-bg-opacity)) !important;
751
+ }
752
+
753
+ .bg-500 {
754
+ --bsi-bg-opacity: 1;
755
+ background-color: rgba(var(--bsi-500-rgb), var(--bsi-bg-opacity)) !important;
756
+ }
757
+
758
+ .bg-600 {
759
+ --bsi-bg-opacity: 1;
760
+ background-color: rgba(var(--bsi-600-rgb), var(--bsi-bg-opacity)) !important;
761
+ }
762
+
763
+ .bg-700 {
764
+ --bsi-bg-opacity: 1;
765
+ background-color: rgba(var(--bsi-700-rgb), var(--bsi-bg-opacity)) !important;
766
+ }
767
+
768
+ .bg-800 {
769
+ --bsi-bg-opacity: 1;
770
+ background-color: rgba(var(--bsi-800-rgb), var(--bsi-bg-opacity)) !important;
771
+ }
772
+
773
+ .bg-900 {
774
+ --bsi-bg-opacity: 1;
775
+ background-color: rgba(var(--bsi-900-rgb), var(--bsi-bg-opacity)) !important;
776
+ }
777
+
778
+ .bg-body {
779
+ --bsi-bg-opacity: 1;
780
+ background-color: rgba(var(--bsi-body-bg-rgb), var(--bsi-bg-opacity)) !important;
781
+ }
782
+
783
+ .bg-transparent {
784
+ --bsi-bg-opacity: 1;
785
+ background-color: transparent !important;
786
+ }`;
787
+
788
+ var ItProgress_1;
789
+ let ItProgress = ItProgress_1 = class ItProgress extends BaseComponent {
790
+ constructor() {
791
+ super(...arguments);
792
+ this.type = 'bar';
793
+ this.value = 0;
794
+ this.itAriaLabel = 'Caricamento';
795
+ this.showValue = false;
796
+ this.label = '';
797
+ this.indeterminate = false;
798
+ this.color = 'default';
799
+ this.trailColor = '#D4E9FF';
800
+ this.strokeWidth = 24;
801
+ this.trailWidth = 12;
802
+ this.easing = 'easeInOut';
803
+ this.duration = 1400;
804
+ this.animated = true;
805
+ this.active = false;
806
+ this.double = false;
807
+ this.size = 'md';
808
+ this._bar = null;
809
+ this._donutContainer = null;
810
+ }
811
+ firstUpdated() {
812
+ if (this.type === 'donut') {
813
+ this._initDonutBar();
814
+ }
815
+ }
816
+ updated(changedProperties) {
817
+ super.updated?.(changedProperties);
818
+ if (changedProperties.has('type')) {
819
+ if (this.type !== 'donut' && this._bar) {
820
+ this._bar.destroy();
821
+ this._bar = null;
822
+ }
823
+ }
824
+ if (this.type === 'donut') {
825
+ const configChanged = changedProperties.has('color') ||
826
+ changedProperties.has('trailColor') ||
827
+ changedProperties.has('strokeWidth') ||
828
+ changedProperties.has('trailWidth') ||
829
+ changedProperties.has('easing') ||
830
+ changedProperties.has('duration') ||
831
+ changedProperties.has('type');
832
+ if (configChanged && this._bar) {
833
+ this._bar.destroy();
834
+ this._bar = null;
835
+ this.updateComplete.then(() => this._initDonutBar());
836
+ }
837
+ else if (changedProperties.has('value') && this._bar) {
838
+ this._setDonutProgress(this.value);
839
+ }
840
+ }
841
+ }
842
+ disconnectedCallback() {
843
+ super.disconnectedCallback?.();
844
+ if (this._bar) {
845
+ this._bar.destroy();
846
+ this._bar = null;
847
+ }
848
+ }
849
+ set(progress) {
850
+ this.value = progress;
851
+ }
852
+ static _isBarColorVariant(color) {
853
+ return ['default', 'success', 'info', 'warning', 'danger'].includes(color);
854
+ }
855
+ get _barColorClass() {
856
+ if (!ItProgress_1._isBarColorVariant(this.color))
857
+ return '';
858
+ return this.color === 'default' ? '' : `bg-${this.color}`;
859
+ }
860
+ get _displayLabel() {
861
+ return this.label || html `<span aria-hidden="true">${this.value}%</span>`;
862
+ }
863
+ _setDonutProgress(progress) {
864
+ if (!this._bar)
865
+ return;
866
+ this._bar.setValue(progress / 100, this.animated);
867
+ }
868
+ async _initDonutBar() {
869
+ if (!this.shadowRoot || this.type !== 'donut')
870
+ return;
871
+ this._donutContainer = this.shadowRoot.querySelector('.progress-donut');
872
+ if (!this._donutContainer)
873
+ return;
874
+ this._donutContainer.setAttribute('aria-label', this.itAriaLabel);
875
+ this._donutContainer.setAttribute('aria-valuenow', this.value.toString());
876
+ this._donutContainer.setAttribute('aria-valuemin', '0');
877
+ this._donutContainer.setAttribute('aria-valuemax', '100');
878
+ this._donutContainer.setAttribute('role', 'progressbar');
879
+ this._bar = await ProgressDonut.create(this._donutContainer, {
880
+ color: ItProgress_1._isBarColorVariant(this.color) ? 'var(--bsi-secondary)' : this.color,
881
+ trailColor: this.trailColor,
882
+ strokeWidth: this.strokeWidth,
883
+ trailWidth: this.trailWidth,
884
+ easing: this.easing,
885
+ duration: this.duration,
886
+ animate: this.animated,
887
+ value: this.value / 100,
888
+ onStep: (value) => {
889
+ this._donutContainer?.setAttribute('aria-valuenow', String(value));
890
+ if (this.value === value) {
891
+ this.dispatchEvent(new CustomEvent('it-donut-updated', {
892
+ detail: { value, el: this._donutContainer },
893
+ bubbles: true,
894
+ composed: true,
895
+ }));
896
+ }
897
+ },
898
+ });
899
+ }
900
+ _renderBar() {
901
+ const progressClasses = this.composeClass('progress', this.indeterminate && 'progress-indeterminate');
902
+ const barClasses = this.composeClass('progress-bar', this._barColorClass);
903
+ const barStyle = this.indeterminate ? {} : { width: `${this.value}%` };
904
+ const bar = html `
905
+ <div class="${progressClasses}" part="progress">
906
+ <div
907
+ class="${barClasses}"
908
+ role="progressbar"
909
+ style="${styleMap(barStyle)}"
910
+ ${setAttributes(this._ariaAttributes)}
911
+ aria-label="${ifDefined(this.itAriaLabel || undefined)}"
912
+ aria-valuenow="${ifDefined(this.indeterminate ? undefined : this.value)}"
913
+ aria-valuemin="0"
914
+ aria-valuemax="100"
915
+ part="progress-bar"
916
+ id="${this._id}"
917
+ ></div>
918
+ </div>
919
+ `;
920
+ return when(this.showValue || this.label, () => html `
921
+ <div class="progress-bar-wrapper">
922
+ <div class="progress-bar-label" aria-describedby="${this._id}" part="progress-bar-label">
923
+ ${this._displayLabel}
924
+ </div>
925
+ ${bar}
926
+ </div>
927
+ `, () => bar);
928
+ }
929
+ _renderDonut() {
930
+ return html `
931
+ <div class="progress-donut-wrapper" part="donut-wrapper">
932
+ <div
933
+ class="progress-donut"
934
+ ${setAttributes(this._ariaAttributes)}
935
+ aria-label="${ifDefined(this.itAriaLabel || undefined)}"
936
+ aria-valuenow="${this.value}"
937
+ aria-valuemin="0"
938
+ aria-valuemax="100"
939
+ role="progressbar"
940
+ part="donut"
941
+ ></div>
942
+ </div>
943
+ `;
944
+ }
945
+ _renderSpinner() {
946
+ const classes = this.composeClass('progress-spinner', this.active && 'progress-spinner-active', this.double && 'progress-spinner-double', this.size === 'sm' && 'size-sm', this.size === 'lg' && 'size-lg', this.size === 'xl' && 'size-xl');
947
+ return html `
948
+ <div
949
+ class="${classes}"
950
+ part="spinner"
951
+ role="progressbar"
952
+ aria-label="${ifDefined(this.itAriaLabel || undefined)}"
953
+ aria-valuetext="${ifDefined(this.itAriaLabel || undefined)}"
954
+ aria-valuemin="0"
955
+ aria-valuemax="100"
956
+ >
957
+ ${this.double
958
+ ? html `
959
+ <div class="progress-spinner-inner"></div>
960
+ <div class="progress-spinner-inner"></div>
961
+ `
962
+ : ''}
963
+ </div>
964
+ `;
965
+ }
966
+ render() {
967
+ if (this.type === 'donut') {
968
+ return this._renderDonut();
969
+ }
970
+ if (this.type === 'spinner') {
971
+ return this._renderSpinner();
972
+ }
973
+ return this._renderBar();
974
+ }
975
+ };
976
+ ItProgress.styles = styles;
977
+ __decorate([
978
+ property({ type: String, reflect: true }),
979
+ __metadata("design:type", String)
980
+ ], ItProgress.prototype, "type", void 0);
981
+ __decorate([
982
+ property({ type: Number, reflect: true }),
983
+ __metadata("design:type", Object)
984
+ ], ItProgress.prototype, "value", void 0);
985
+ __decorate([
986
+ property({ type: String, reflect: true, attribute: 'it-aria-label' }),
987
+ __metadata("design:type", Object)
988
+ ], ItProgress.prototype, "itAriaLabel", void 0);
989
+ __decorate([
990
+ property({ type: Boolean, reflect: true, attribute: 'show-value' }),
991
+ __metadata("design:type", Object)
992
+ ], ItProgress.prototype, "showValue", void 0);
993
+ __decorate([
994
+ property({ type: String, reflect: true, attribute: 'label' }),
995
+ __metadata("design:type", Object)
996
+ ], ItProgress.prototype, "label", void 0);
997
+ __decorate([
998
+ property({ type: Boolean, reflect: true }),
999
+ __metadata("design:type", Object)
1000
+ ], ItProgress.prototype, "indeterminate", void 0);
1001
+ __decorate([
1002
+ property({ type: String, reflect: true }),
1003
+ __metadata("design:type", String)
1004
+ ], ItProgress.prototype, "color", void 0);
1005
+ __decorate([
1006
+ property({ type: Boolean, reflect: true }),
1007
+ __metadata("design:type", Object)
1008
+ ], ItProgress.prototype, "active", void 0);
1009
+ __decorate([
1010
+ property({ type: Boolean, reflect: true }),
1011
+ __metadata("design:type", Object)
1012
+ ], ItProgress.prototype, "double", void 0);
1013
+ __decorate([
1014
+ property({ type: String, reflect: true }),
1015
+ __metadata("design:type", String)
1016
+ ], ItProgress.prototype, "size", void 0);
1017
+ ItProgress = ItProgress_1 = __decorate([
1018
+ customElement('it-progress')
1019
+ ], ItProgress);
1020
+
1021
+ export { ItProgress };
1022
+ //# sourceMappingURL=it-progress.js.map