@italia/checkbox 1.0.0-alpha.4

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,1206 @@
1
+ import { _ as __decorate, a as __metadata, F as FormControl, b as FormControlController } from '../index-BQ40QKAy.js';
2
+ import { css, html } from 'lit';
3
+ import { property, queryAssignedElements, state, customElement } from 'lit/decorators.js';
4
+ import { when } from 'lit/directives/when.js';
5
+ import { ifDefined } from 'lit/directives/if-defined.js';
6
+ import 'lit/directive.js';
7
+
8
+ var styles = css`/***************************** 1 ****************************************/
9
+ /***************************** 2 ****************************************/
10
+ /***************************** 1 ****************************************/
11
+ /***************************** 2 ****************************************/
12
+ /***************************** 1 ****************************************/
13
+ /***************************** 2 ****************************************/
14
+ /***************************** 3 ****************************************/
15
+ /***************************** 1 ****************************************/
16
+ /***************************** 2 ****************************************/
17
+ /***************************** 3 ****************************************/
18
+ /***************************** NEUTRAL 1 ****************************************/
19
+ /***************************** NEUTRAL 2 ****************************************/
20
+ /***************************** NEUTRAL 2 / 3 ****************************************/
21
+ .form-check [type=checkbox]:focus + label,
22
+ .form-check [type=radio]:focus + label {
23
+ border-color: hsl(0, 0%, 0%) !important;
24
+ box-shadow: 0 0 0 2px var(--bs-color-border-inverse), 0 0 0 5px var(--bs-color-outline-focus) !important;
25
+ outline: 3px solid transparent !important;
26
+ outline-offset: 3px !important;
27
+ }
28
+
29
+ .form-check [type=checkbox]:focus[data-focus-mouse=true] + label,
30
+ .form-check [type=radio]:focus[data-focus-mouse=true] + label {
31
+ border-color: inherit !important;
32
+ box-shadow: none !important;
33
+ outline: none !important;
34
+ }
35
+
36
+ *,
37
+ *::before,
38
+ *::after {
39
+ box-sizing: border-box;
40
+ }
41
+
42
+ @media (prefers-reduced-motion: no-preference) {
43
+ :root {
44
+ scroll-behavior: smooth;
45
+ }
46
+ }
47
+
48
+ body {
49
+ margin: 0;
50
+ -webkit-text-size-adjust: 100%;
51
+ -webkit-tap-highlight-color: hsla(0, 0%, 0%, 0);
52
+ }
53
+
54
+ hr {
55
+ margin: 1rem 0;
56
+ color: inherit;
57
+ border: 0;
58
+ border-top: 1px solid;
59
+ opacity: 0.25;
60
+ }
61
+
62
+ p {
63
+ margin-top: 0;
64
+ margin-bottom: var(--bs-paragraph-spacing);
65
+ }
66
+
67
+ abbr[title] {
68
+ text-decoration: underline dotted;
69
+ cursor: help;
70
+ text-decoration-skip-ink: none;
71
+ }
72
+
73
+ address {
74
+ margin-bottom: var(--bs-spacing-s);
75
+ font-style: normal;
76
+ line-height: inherit;
77
+ }
78
+
79
+ ol,
80
+ ul {
81
+ padding-left: var(--bs-spacing-l);
82
+ }
83
+
84
+ ol,
85
+ ul,
86
+ dl {
87
+ margin-top: 0;
88
+ margin-bottom: var(--bs-spacing-s);
89
+ }
90
+
91
+ ol ol,
92
+ ul ul,
93
+ ol ul,
94
+ ul ol {
95
+ margin-bottom: 0;
96
+ }
97
+
98
+ dt {
99
+ font-weight: var(--bs-font-weight-strong);
100
+ }
101
+
102
+ dd {
103
+ margin-bottom: var(--bs-spacing-xxs);
104
+ margin-left: 0;
105
+ }
106
+
107
+ blockquote {
108
+ margin: 0 0 var(--bs-spacing-s);
109
+ }
110
+
111
+ sub,
112
+ sup {
113
+ position: relative;
114
+ font-size: var(--bs-font-size-1);
115
+ line-height: 0;
116
+ vertical-align: baseline;
117
+ }
118
+
119
+ sub {
120
+ bottom: -0.25em;
121
+ }
122
+
123
+ sup {
124
+ top: -0.5em;
125
+ }
126
+
127
+ a {
128
+ color: var(--bs-color-link);
129
+ text-decoration: underline;
130
+ text-decoration-skip-ink: auto;
131
+ text-underline-offset: 2px;
132
+ }
133
+ a:hover {
134
+ color: var(--bs-color-link-hover);
135
+ }
136
+
137
+ pre,
138
+ code,
139
+ kbd,
140
+ samp {
141
+ font-size: 1em;
142
+ }
143
+
144
+ pre {
145
+ display: block;
146
+ margin-top: 0;
147
+ margin-bottom: var(--bs-paragraph-spacing);
148
+ overflow: auto;
149
+ }
150
+ pre code {
151
+ word-break: normal;
152
+ }
153
+
154
+ a > code {
155
+ color: inherit;
156
+ }
157
+
158
+ figure {
159
+ margin: 0 0 1rem;
160
+ }
161
+
162
+ img,
163
+ svg {
164
+ vertical-align: middle;
165
+ }
166
+
167
+ table {
168
+ caption-side: bottom;
169
+ border-collapse: collapse;
170
+ }
171
+
172
+ caption {
173
+ padding-top: 0.5rem;
174
+ padding-bottom: 0.5rem;
175
+ color: hsl(210, 17%, 44%);
176
+ text-align: left;
177
+ }
178
+
179
+ th {
180
+ text-align: inherit;
181
+ text-align: -webkit-match-parent;
182
+ }
183
+
184
+ thead,
185
+ tbody,
186
+ tfoot,
187
+ tr,
188
+ td,
189
+ th {
190
+ border-color: inherit;
191
+ border-style: solid;
192
+ border-width: 0;
193
+ }
194
+
195
+ label {
196
+ display: inline-block;
197
+ }
198
+
199
+ button {
200
+ border-radius: 0;
201
+ }
202
+
203
+ button:focus:not(:focus-visible) {
204
+ outline: 0;
205
+ }
206
+
207
+ input,
208
+ button,
209
+ select,
210
+ optgroup,
211
+ textarea {
212
+ margin: 0;
213
+ font-family: inherit;
214
+ font-size: inherit;
215
+ line-height: inherit;
216
+ }
217
+
218
+ button,
219
+ select {
220
+ text-transform: none;
221
+ }
222
+
223
+ [role=button] {
224
+ cursor: pointer;
225
+ }
226
+
227
+ select {
228
+ word-wrap: normal;
229
+ }
230
+ select:disabled {
231
+ opacity: 1;
232
+ }
233
+
234
+ [list]:not([type=date]):not([type=datetime-local]):not([type=month]):not([type=week]):not([type=time])::-webkit-calendar-picker-indicator {
235
+ display: none !important;
236
+ }
237
+
238
+ button,
239
+ [type=button],
240
+ [type=reset],
241
+ [type=submit] {
242
+ -webkit-appearance: button;
243
+ }
244
+ button:not(:disabled),
245
+ [type=button]:not(:disabled),
246
+ [type=reset]:not(:disabled),
247
+ [type=submit]:not(:disabled) {
248
+ cursor: pointer;
249
+ }
250
+
251
+ ::-moz-focus-inner {
252
+ padding: 0;
253
+ border-style: none;
254
+ }
255
+
256
+ textarea {
257
+ resize: vertical;
258
+ }
259
+
260
+ fieldset {
261
+ min-width: 0;
262
+ padding: 0;
263
+ margin: 0;
264
+ border: 0;
265
+ }
266
+
267
+ ::-webkit-datetime-edit-fields-wrapper,
268
+ ::-webkit-datetime-edit-text,
269
+ ::-webkit-datetime-edit-minute,
270
+ ::-webkit-datetime-edit-hour-field,
271
+ ::-webkit-datetime-edit-day-field,
272
+ ::-webkit-datetime-edit-month-field,
273
+ ::-webkit-datetime-edit-year-field {
274
+ padding: 0;
275
+ }
276
+
277
+ ::-webkit-inner-spin-button {
278
+ height: auto;
279
+ }
280
+
281
+ [type=search] {
282
+ outline-offset: -2px;
283
+ -webkit-appearance: textfield;
284
+ }
285
+
286
+ /* rtl:raw:
287
+ [type="tel"],
288
+ [type="url"],
289
+ [type="email"],
290
+ [type="number"] {
291
+ direction: ltr;
292
+ }
293
+ */
294
+ ::-webkit-search-decoration {
295
+ -webkit-appearance: none;
296
+ }
297
+
298
+ ::-webkit-color-swatch-wrapper {
299
+ padding: 0;
300
+ }
301
+
302
+ ::file-selector-button {
303
+ font: inherit;
304
+ -webkit-appearance: button;
305
+ }
306
+
307
+ output {
308
+ display: inline-block;
309
+ }
310
+
311
+ iframe {
312
+ border: 0;
313
+ }
314
+
315
+ summary {
316
+ display: list-item;
317
+ cursor: pointer;
318
+ }
319
+
320
+ progress {
321
+ vertical-align: baseline;
322
+ }
323
+
324
+ [hidden] {
325
+ display: none !important;
326
+ }
327
+
328
+ .visually-hidden,
329
+ .visually-hidden-focusable:not(:focus):not(:focus-within) {
330
+ position: absolute !important;
331
+ width: 1px !important;
332
+ height: 1px !important;
333
+ padding: 0 !important;
334
+ margin: -1px !important;
335
+ overflow: hidden !important;
336
+ clip: rect(0, 0, 0, 0) !important;
337
+ white-space: nowrap !important;
338
+ border: 0 !important;
339
+ }
340
+
341
+ :root {
342
+ --bs-form-control-height: 2.5rem;
343
+ --bs-form-control-spacing: var(--bs-spacing-xxs);
344
+ --bs-form-control-background-color: var(--bs-color-background-inverse);
345
+ --bs-form-control-border-color: var(--bs-color-border-secondary);
346
+ --bs-form-control-border-radius: var(--bs-radius-smooth);
347
+ --bs-form-control-placeholder-color: var(--bs-color-text-muted);
348
+ --bs-form-control-label-color: var(--bs-color-text-base);
349
+ --bs-form-control-text-color: var(--bs-color-text-secondary);
350
+ --bs-form-control-font-size: var(--bs-body-font-size);
351
+ --bs-form-group-spacing-y: var(--bs-spacing-m);
352
+ --bs-form-checkbox-border-color: var(--bs-color-border-secondary);
353
+ --bs-form-checkbox-border-radius: var(--bs-radius-smooth);
354
+ --bs-form-checked-color: var(--bs-color-background-primary);
355
+ }
356
+
357
+ input[readonly],
358
+ textarea[readonly],
359
+ select[readonly] {
360
+ --bs-form-control-border-color: var(--bs-color-border-subtle);
361
+ --bs-form-control-background-color: var(--bs-color-background-muted);
362
+ cursor: not-allowed;
363
+ }
364
+
365
+ input,
366
+ textarea,
367
+ select {
368
+ display: block;
369
+ width: 100%;
370
+ padding: var(--bs-form-control-spacing);
371
+ border: 1px solid var(--bs-form-control-border-color);
372
+ border-radius: var(--bs-form-control-border-radius);
373
+ background-color: var(--bs-form-control-background-color);
374
+ color: var(--bs-form-control-text-color);
375
+ font-size: var(--bs-form-control-font-size);
376
+ }
377
+ input.disabled, input:disabled,
378
+ textarea.disabled,
379
+ textarea:disabled,
380
+ select.disabled,
381
+ select:disabled {
382
+ border-color: var(--bs-color-border-disabled);
383
+ opacity: 1;
384
+ background-color: var(--bs-color-background-disabled);
385
+ color: var(--bs-color-text-disabled);
386
+ }
387
+
388
+ input:focus,
389
+ textarea:focus {
390
+ outline: 3px solid transparent;
391
+ outline-offset: 3px;
392
+ box-shadow: 0 0 0 2px var(--bs-color-border-inverse), 0 0 0 5px var(--bs-color-outline-focus) !important;
393
+ }
394
+
395
+ input::file-selector-button {
396
+ margin: -0.375rem -0.75rem;
397
+ padding: 0.375rem 0.75rem;
398
+ border-width: 0;
399
+ border-style: solid;
400
+ border-radius: 0;
401
+ border-color: inherit;
402
+ color: hsl(0, 0%, 10%);
403
+ pointer-events: none;
404
+ margin-inline-end: 0.75rem;
405
+ border-inline-end-width: 0;
406
+ background-color: hsl(0, 0%, 100%);
407
+ transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
408
+ }
409
+ @media (prefers-reduced-motion: reduce) {
410
+ input::file-selector-button {
411
+ transition: none;
412
+ }
413
+ }
414
+ input:hover:not(:disabled):not([readonly])::file-selector-button {
415
+ background-color: rgb(242.25, 242.25, 242.25);
416
+ }
417
+ input[type=file] {
418
+ overflow: hidden;
419
+ }
420
+ input[type=file]:not(:disabled):not([readonly]) {
421
+ cursor: pointer;
422
+ }
423
+ input::-webkit-date-and-time-value {
424
+ height: 1.5em;
425
+ }
426
+
427
+ select {
428
+ background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='hsl%280, 0%, 15%%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
429
+ background-repeat: no-repeat;
430
+ background-position: right var(--bs-form-control-spacing) center;
431
+ background-size: 16px 12px;
432
+ appearance: none;
433
+ }
434
+ select:focus {
435
+ border-color: hsl(210, 17%, 44%);
436
+ outline: 0;
437
+ box-shadow: 0 0 0 0.25rem rgba(0, 102, 204, 0.25);
438
+ }
439
+ select[multiple], select[size]:not([size="1"]) {
440
+ padding-right: 0.75rem;
441
+ background-image: none;
442
+ }
443
+ select:disabled {
444
+ background-color: hsl(0, 0%, 90%);
445
+ }
446
+ select:disabled:hover {
447
+ cursor: not-allowed;
448
+ }
449
+ select:-moz-focusring {
450
+ color: transparent;
451
+ text-shadow: 0 0 0 hsl(0, 0%, 10%);
452
+ }
453
+ select option {
454
+ font-weight: normal;
455
+ }
456
+ select:disabled {
457
+ opacity: 1;
458
+ background-color: hsl(210, 3%, 85%);
459
+ }
460
+
461
+ textarea {
462
+ height: auto;
463
+ font-size: var(--bs-body-font-size);
464
+ line-height: 1.5;
465
+ }
466
+
467
+ label {
468
+ display: inline-block;
469
+ width: auto;
470
+ max-width: 100%;
471
+ margin-bottom: var(--bs-spacing-xxs);
472
+ color: var(--bs-form-control-label-color);
473
+ font-size: var(--bs-label-font-size-s);
474
+ font-weight: var(--bs-font-weight-solid);
475
+ line-height: var(--bs-label-line-height);
476
+ }
477
+
478
+ input,
479
+ textarea {
480
+ outline: 0;
481
+ box-shadow: none;
482
+ transition: none;
483
+ appearance: none;
484
+ }
485
+
486
+ input[type=date],
487
+ input[type=datetime-local],
488
+ input[type=time] {
489
+ display: flex;
490
+ }
491
+
492
+ fieldset legend {
493
+ margin-bottom: var(--bs-spacing-s);
494
+ padding: 0 var(--bs-form-input-spacing-x);
495
+ background-color: transparent;
496
+ color: var(--bs-form-control-text-color);
497
+ font-size: var(--bs-label-sm);
498
+ font-weight: var(--bs-font-weight-solid);
499
+ }
500
+
501
+ ::placeholder {
502
+ color: var(--bs-form-control-placeholder-color);
503
+ }
504
+
505
+ input::-webkit-datetime-edit {
506
+ background-color: var(--bs-color-background-primary-lighter);
507
+ color: var(--bs-form-contro-text-color);
508
+ }
509
+
510
+ .form-group {
511
+ position: relative;
512
+ margin-bottom: var(--bs-form-group-spacing-y);
513
+ }
514
+ .form-group label.input-symbol-label:not(.active) {
515
+ left: 2.25rem;
516
+ }
517
+ .form-group small.form-text {
518
+ margin: 0;
519
+ font-size: 0.875rem;
520
+ }
521
+ .form-group input[type=time] ~ label {
522
+ font-size: 0.875rem;
523
+ }
524
+
525
+ .form-text {
526
+ margin: var(--bs-spacing-xxs) 0;
527
+ color: var(--bs-color-text-secondary);
528
+ }
529
+
530
+ .form-group.active .form-file-name {
531
+ padding-bottom: 1.95rem;
532
+ }
533
+
534
+ .warning-feedback {
535
+ display: none;
536
+ width: 100%;
537
+ margin-top: 0.25rem;
538
+ color: var(--bs-color-text-warning);
539
+ font-size: 0.75rem;
540
+ }
541
+
542
+ .valid-feedback,
543
+ .invalid-feedback,
544
+ .warning-feedback {
545
+ margin-left: 0.5rem;
546
+ }
547
+
548
+ .input-group .input-group-text .btn {
549
+ border-radius: var(--bs-form-control-border-radius) 0 0 var(--bs-form-control-border-radius);
550
+ }
551
+ .input-group .input-group-append {
552
+ margin-left: 0;
553
+ }
554
+ .input-group .input-group-append .btn {
555
+ height: 100%;
556
+ padding-top: 0;
557
+ padding-bottom: 0;
558
+ border-bottom: 1px solid hsl(210, 17%, 44%);
559
+ border-radius: 0 var(--bs-form-control-border-radius) var(--bs-form-control-border-radius) 0;
560
+ }
561
+
562
+ .form-check {
563
+ position: relative;
564
+ padding-left: 0;
565
+ align-items: center;
566
+ }
567
+ .form-check + .form-check {
568
+ margin-top: var(--bs-spacing-s);
569
+ }
570
+ .form-check [type=checkbox],
571
+ .form-check [type=radio] {
572
+ position: absolute;
573
+ height: 100%;
574
+ margin-top: 0;
575
+ margin-left: 0;
576
+ opacity: 0;
577
+ }
578
+ .form-check [type=checkbox] + label,
579
+ .form-check [type=radio] + label {
580
+ position: relative;
581
+ display: flex;
582
+ align-items: center;
583
+ padding-left: 28px;
584
+ font-size: var(--bs-label-font-size);
585
+ font-weight: var(--bs-font-weight-solid);
586
+ cursor: pointer;
587
+ margin-bottom: 0;
588
+ user-select: none;
589
+ }
590
+ @media (min-width: 576px) {
591
+ .form-check [type=checkbox] + label,
592
+ .form-check [type=radio] + label {
593
+ font-size: var(--bs-label-font-size-m);
594
+ }
595
+ }
596
+ .form-check input[type=checkbox] + label::after,
597
+ .form-check input[type=checkbox] + label::before {
598
+ position: absolute;
599
+ left: 0;
600
+ z-index: 1;
601
+ content: "";
602
+ border-width: 2px;
603
+ border-style: solid;
604
+ transition: all var(--bs-transition-instant) ease-out;
605
+ }
606
+ .form-check input[type=checkbox] + label::after {
607
+ top: 0;
608
+ width: 20px;
609
+ height: 20px;
610
+ border-radius: var(--bs-form-control-border-radius);
611
+ }
612
+ .form-check input[type=checkbox]:checked + label::before {
613
+ top: 3px;
614
+ left: 3px;
615
+ width: 6px;
616
+ height: 12px;
617
+ border-width: 2px;
618
+ border-style: solid;
619
+ border-color: transparent var(--bs-color-border-inverse) var(--bs-color-border-inverse) transparent;
620
+ opacity: 1;
621
+ transform: rotate(40deg);
622
+ transform-origin: 100% 100%;
623
+ backface-visibility: hidden;
624
+ }
625
+ .form-check input[type=checkbox]:checked + label::after {
626
+ z-index: 0;
627
+ border-color: var(--bs-form-checked-color);
628
+ background-color: var(--bs-form-checked-color);
629
+ }
630
+ .form-check input[type=checkbox]:not(:checked) + label::after {
631
+ z-index: 0;
632
+ border-color: var(--bs-form-checkbox-border-color);
633
+ background-color: transparent;
634
+ }
635
+ .form-check input[type=checkbox]:not(:checked) + label::before {
636
+ top: 10px;
637
+ left: 6px;
638
+ width: 0;
639
+ height: 0;
640
+ border-color: transparent;
641
+ }
642
+ .form-check input[type=checkbox]:disabled + label {
643
+ opacity: 1;
644
+ cursor: not-allowed;
645
+ }
646
+ .form-check input[type=checkbox]:disabled:not(:checked) + label::after {
647
+ border-color: var(--bs-color-border-disabled);
648
+ background-color: transparent;
649
+ }
650
+ .form-check input[type=checkbox]:disabled:checked + label::after {
651
+ border-color: var(--bs-color-border-disabled);
652
+ background-color: var(--bs-color-border-disabled);
653
+ }
654
+ .form-check input[type=radio] + label::after, .form-check input[type=radio] + label::before {
655
+ position: absolute;
656
+ top: 0;
657
+ left: 0;
658
+ z-index: 0;
659
+ content: "";
660
+ width: 20px;
661
+ height: 20px;
662
+ border-width: 2px;
663
+ border-style: solid;
664
+ border-radius: var(--bs-radius-rounded);
665
+ transition: all var(--bs-transition-instant) ease-out;
666
+ }
667
+ .form-check input[type=radio]:not(:checked) + label::after, .form-check input[type=radio]:not(:checked) + label::before {
668
+ border-color: var(--bs-form-checkbox-border-color);
669
+ }
670
+ .form-check input[type=radio]:not(:checked) + label:after {
671
+ z-index: -1;
672
+ transform: scale(0);
673
+ }
674
+ .form-check input[type=radio]:checked + label::after {
675
+ z-index: 0;
676
+ border-color: var(--bs-form-checked-color);
677
+ background-color: var(--bs-form-checked-color);
678
+ transform: scale(0.64);
679
+ }
680
+ .form-check input[type=radio]:checked + label::before {
681
+ border-color: var(--bs-form-checked-color);
682
+ }
683
+ .form-check input[type=radio]:disabled + label {
684
+ cursor: not-allowed;
685
+ }
686
+ .form-check input[type=radio]:disabled:not(:checked) + label::after, .form-check input[type=radio]:disabled:not(:checked) + label::before {
687
+ border-color: var(--bs-color-border-disabled);
688
+ }
689
+ .form-check input[type=radio]:disabled:checked + label::after {
690
+ border-color: var(--bs-color-border-disabled);
691
+ background-color: var(--bs-color-border-disabled);
692
+ }
693
+ .form-check input[type=radio]:disabled:checked + label::before {
694
+ border-color: var(--bs-color-border-disabled);
695
+ }
696
+ .form-check.form-check-group {
697
+ margin-bottom: 1rem;
698
+ padding: 0 0 1rem 0;
699
+ box-shadow: inset 0 -1px 0 0 rgba(1, 1, 1, 0.1);
700
+ }
701
+ .form-check.form-check-group input[type=checkbox] + label,
702
+ .form-check.form-check-group input[type=radio] + label {
703
+ padding-right: 3.25rem;
704
+ padding-left: 0;
705
+ }
706
+ .form-check.form-check-group input[type=checkbox] + label::after, .form-check.form-check-group input[type=checkbox] + label::before,
707
+ .form-check.form-check-group input[type=radio] + label::after,
708
+ .form-check.form-check-group input[type=radio] + label::before {
709
+ right: 0;
710
+ left: auto;
711
+ }
712
+ .form-check.form-check-group input[type=checkbox]:checked + label::before {
713
+ right: 11px;
714
+ }
715
+ .form-check.form-check-group input[type=radio]:checked + label::before {
716
+ right: 0;
717
+ }
718
+ .form-check.form-check-group .form-text {
719
+ display: block;
720
+ margin-bottom: 0.5rem;
721
+ padding-right: 3.25rem;
722
+ }
723
+ .form-check.form-check-group input.semi-checked:not(:checked) + label::before {
724
+ right: 4px;
725
+ left: auto;
726
+ }
727
+ .form-check input.semi-checked:not(:checked) + label::before {
728
+ top: 9px;
729
+ left: 4px;
730
+ width: 12px;
731
+ height: 2px;
732
+ border-width: 0;
733
+ border-style: none;
734
+ border-color: transparent;
735
+ opacity: 1;
736
+ background: var(--bs-color-background-inverse);
737
+ transform: none;
738
+ backface-visibility: hidden;
739
+ }
740
+ .form-check input.semi-checked:not(:checked) + label::after {
741
+ z-index: 0;
742
+ border-color: var(--bs-form-checked-color);
743
+ background-color: var(--bs-form-checked-color);
744
+ }
745
+
746
+ .form-check-inline {
747
+ display: inline-block;
748
+ }
749
+ .form-check-inline:not(:last-child) {
750
+ margin-right: var(--bs-spacing-m);
751
+ }
752
+
753
+ @media (prefers-reduced-motion: reduce) {
754
+ fieldset legend,
755
+ .form-group label,
756
+ textarea,
757
+ .form-check [type=checkbox],
758
+ .form-check [type=radio],
759
+ .form-check [type=checkbox] + label::after,
760
+ .form-check [type=checkbox] + label::before,
761
+ .form-check [type=radio] + label::after,
762
+ .form-check [type=radio] + label::before,
763
+ .toggles label input[type=checkbox] + .lever::before,
764
+ .toggles label input[type=checkbox] + .lever::after {
765
+ transition: none !important;
766
+ }
767
+ }
768
+ .form-check [type=checkbox]:focus + label,
769
+ .form-check [type=radio]:focus + label {
770
+ border-color: hsl(0, 0%, 0%) !important;
771
+ box-shadow: 0 0 0 2px var(--bs-color-border-inverse), 0 0 0 5px var(--bs-color-outline-focus) !important;
772
+ outline: 3px solid transparent !important;
773
+ outline-offset: 3px !important;
774
+ }
775
+
776
+ .form-check [type=checkbox]:focus[data-focus-mouse=true] + label,
777
+ .form-check [type=radio]:focus[data-focus-mouse=true] + label {
778
+ border-color: inherit !important;
779
+ box-shadow: none !important;
780
+ outline: none !important;
781
+ }
782
+
783
+ .form-control-plaintext {
784
+ border: 0;
785
+ --bs-form-control-border-color: transparent;
786
+ --bs-form-control-border-radius: 0;
787
+ --bs-form-control-background-color: transparent;
788
+ --bs-form-control-spacing: 0;
789
+ }
790
+ .form-control-plaintext:focus {
791
+ outline: 0;
792
+ box-shadow: none !important;
793
+ }
794
+ .form-control-plaintext + label {
795
+ cursor: text;
796
+ }
797
+
798
+ .form-control {
799
+ background-repeat: no-repeat;
800
+ background-position: center right;
801
+ background-size: 45px 30%;
802
+ }
803
+ .form-control:disabled {
804
+ cursor: not-allowed;
805
+ background: var(--bs-color-background-disabled);
806
+ border: 0;
807
+ color: var(--bs-color-text-disabled);
808
+ }
809
+ .was-validated .form-control:valid, .form-control.is-valid {
810
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23008055' viewBox='0 0 192 512'%3E%3Cpath d='M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z'/%3E%3C/svg%3E");
811
+ }
812
+ .was-validated .form-control:invalid, .form-control.is-invalid {
813
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23cc334d' viewBox='0 0 384 512'%3E%3Cpath d='M231.6 256l130.1-130.1c4.7-4.7 4.7-12.3 0-17l-22.6-22.6c-4.7-4.7-12.3-4.7-17 0L192 216.4 61.9 86.3c-4.7-4.7-12.3-4.7-17 0l-22.6 22.6c-4.7 4.7-4.7 12.3 0 17L152.4 256 22.3 386.1c-4.7 4.7-4.7 12.3 0 17l22.6 22.6c4.7 4.7 12.3 4.7 17 0L192 295.6l130.1 130.1c4.7 4.7 12.3 4.7 17 0l22.6-22.6c4.7-4.7 4.7-12.3 0-17L231.6 256z'/%3E%3C/svg%3E");
814
+ border-color: var(--bs-color-border-danger);
815
+ }
816
+ .form-control.warning {
817
+ background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%0A%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M2%2012C2%206.47715%206.47715%202%2012%202C14.6522%202%2017.1957%203.05357%2019.0711%204.92893C20.9464%206.8043%2022%209.34784%2022%2012C22%2017.5228%2017.5228%2022%2012%2022C6.47715%2022%202%2017.5228%202%2012ZM3%2012C3%2016.9706%207.02944%2021%2012%2021C16.9706%2021%2021%2016.9706%2021%2012C21%207.02944%2016.9706%203%2012%203C7.02944%203%203%207.02944%203%2012ZM11.5%2014.2V5.7H12.7V14.2H11.5ZM12.6%2018.3V16.5H11.4V18.3H12.6Z%22/%3E%0A%3C/svg%3E") no-repeat;
818
+ border-color: var(--bs-color-border-warning);
819
+ }
820
+ .form-control.is-valid ~ .warning-feedback {
821
+ display: block;
822
+ }
823
+
824
+ .form-control-sm {
825
+ --bs-form-control-spacing: var(--bs-spacing-xxs) var(--bs-spacing-3xs);
826
+ --bs-form-control-font-size: var(--bs-label-font-size);
827
+ }
828
+ .form-control-sm::file-selector-button {
829
+ padding: 0.25rem 0.5rem;
830
+ margin: -0.25rem -0.5rem;
831
+ margin-inline-end: 0.5rem;
832
+ }
833
+
834
+ .form-control-lg {
835
+ --bs-form-control-font-size: var(--bs-lead-font-size);
836
+ }
837
+ .form-control-lg::file-selector-button {
838
+ padding: 0.5rem 1rem;
839
+ margin: -0.5rem -1rem;
840
+ margin-inline-end: 1rem;
841
+ }
842
+
843
+ textarea.form-control {
844
+ min-height: 2.5rem;
845
+ border: 1px solid hsl(210, 17%, 44%);
846
+ }
847
+ textarea.form-control-sm {
848
+ min-height: calc(1.5em + 0.5rem);
849
+ }
850
+ textarea.form-control-lg {
851
+ min-height: calc(1.5em + 1rem);
852
+ }
853
+
854
+ .form-control-color {
855
+ width: 3rem;
856
+ height: 2.5rem;
857
+ padding: 0.375rem;
858
+ }
859
+ .form-control-color:not(:disabled):not([readonly]) {
860
+ cursor: pointer;
861
+ }
862
+ .form-control-color::-moz-color-swatch {
863
+ border: 0 !important;
864
+ border-radius: 0;
865
+ }
866
+ .form-control-color::-webkit-color-swatch {
867
+ border-radius: 0;
868
+ }
869
+ .form-control-color.form-control-sm {
870
+ height: calc(1.5em + 0.5rem);
871
+ }
872
+ .form-control-color.form-control-lg {
873
+ height: calc(1.5em + 1rem);
874
+ }
875
+
876
+ .form-feedback {
877
+ width: 100%;
878
+ margin-top: 0.25rem;
879
+ font-size: 0.75rem;
880
+ }
881
+ .form-feedback.just-validate-error-label {
882
+ color: var(--bs-color-text-danger);
883
+ }
884
+
885
+ .input-group-text:has(~ [data-focus-mouse=true]:not(.btn)),
886
+ [data-focus-mouse=true]:not(.btn) ~ .input-group-text,
887
+ button:has(~ [data-focus-mouse=true]:not(.btn)),
888
+ [data-focus-mouse=true]:not(.btn) + button {
889
+ border-color: inherit !important;
890
+ box-shadow: none !important;
891
+ outline: none !important;
892
+ }
893
+
894
+ .input-group-text:has(~ .is-invalid),
895
+ .is-invalid ~ .input-group-text,
896
+ button:has(~ .is-invalid),
897
+ .is-invalid + button {
898
+ border-color: var(--bs-color-border-danger) !important;
899
+ }
900
+
901
+ .sr-only-justvalidate-bi {
902
+ display: none;
903
+ }
904
+
905
+ .just-validate-success-field {
906
+ border-color: var(--bs-color-border-success) !important;
907
+ padding-right: calc(1.5em + 0.75rem) !important;
908
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23008055' viewBox='0 0 192 512'%3E%3Cpath d='M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z'/%3E%3C/svg%3E");
909
+ }
910
+
911
+ .input-group-text:has(~ .just-validate-success-field),
912
+ .just-validate-success-field ~ .input-group-text,
913
+ button:has(~ .just-validate-success-field),
914
+ .just-validate-success-field + button {
915
+ border-color: var(--bs-color-border-success);
916
+ }
917
+
918
+ .just-validate-success-field + .input-group-text.align-buttons,
919
+ .is-invalid + .input-group-text.align-buttons {
920
+ right: 30px;
921
+ }
922
+
923
+ .is-invalid + .input-group-text.align-buttons {
924
+ bottom: 22px;
925
+ }
926
+
927
+ .autocomplete__wrapper .form-feedback.just-validate-error-label {
928
+ position: absolute;
929
+ }
930
+
931
+ textarea.form-control {
932
+ background-position: top 0.3em right 0.3em !important;
933
+ background-size: 37px 30% !important;
934
+ }
935
+ textarea.is-invalid {
936
+ border-bottom-style: solid;
937
+ border-bottom-width: 1px;
938
+ }
939
+ textarea.just-validate-success-field {
940
+ border-bottom-style: solid;
941
+ border-bottom-width: 1px;
942
+ }
943
+
944
+ input[type=checkbox].is-invalid,
945
+ input[type=radio].is-invalid {
946
+ --bs-form-checkbox-border-color: var(--bs-color-border-danger);
947
+ }
948
+
949
+ select.is-invalid {
950
+ border: 1px solid var(--bs-color-border-danger);
951
+ }
952
+ select.just-validate-success-field {
953
+ border: 1px solid var(--bs-color-border-success);
954
+ }`;
955
+
956
+ let ItCheckboxGroup = class ItCheckboxGroup extends FormControl {
957
+ constructor() {
958
+ super(...arguments);
959
+ this.required = false;
960
+ /** Draws checkboxes inline, side by side. */
961
+ this.inline = false;
962
+ /** Draws checkboxes in groups. */
963
+ this.group = false;
964
+ this.name = ''; // Il name del gruppo
965
+ // Override del controller per usare le funzioni di validazione di gruppo
966
+ this.formControlController = new FormControlController(this, {
967
+ // Il valore è un array dei valori delle checkbox selezionate
968
+ value: (control) => control.checkboxes.filter((cb) => cb.checked).map((cb) => cb.value || 'true'),
969
+ // Il name è quello del gruppo
970
+ name: (control) => control.name,
971
+ // La validità è gestita da noi con checkValidity di gruppo
972
+ checkValidity: (control) => control.checkValidity(),
973
+ reportValidity: (control) => control.reportValidity(),
974
+ // Non implementiamo setValue qui, gestito dalle singole checkbox
975
+ setValue: () => { },
976
+ // Ascoltiamo l'input su tutti i cambi di stato delle checkbox
977
+ assumeInteractionOn: ['it-change'],
978
+ });
979
+ // Questo state servirà per forzare il re-render del messaggio di errore
980
+ this._groupValid = true;
981
+ }
982
+ get selectedValues() {
983
+ if (!this.value)
984
+ return [];
985
+ try {
986
+ return JSON.parse(this.value);
987
+ }
988
+ catch {
989
+ return [];
990
+ }
991
+ }
992
+ set selectedValues(vals) {
993
+ this.value = JSON.stringify(vals);
994
+ }
995
+ has(v) {
996
+ return this.selectedValues.indexOf(v) >= 0;
997
+ }
998
+ connectedCallback() {
999
+ super.connectedCallback?.();
1000
+ this.addEventListener('it-change', this._handleGroupChange);
1001
+ }
1002
+ disconnectedCallback() {
1003
+ super.disconnectedCallback?.();
1004
+ this.removeEventListener('it-change', this._handleGroupChange);
1005
+ }
1006
+ /**
1007
+ * Override: Custom validity check for radio group
1008
+ */
1009
+ get validity() {
1010
+ // Fallback: create a custom ValidityState-like object
1011
+ const valid = !this.required || !!this.value;
1012
+ return {
1013
+ valid,
1014
+ valueMissing: this.required && !this.value,
1015
+ typeMismatch: false,
1016
+ patternMismatch: false,
1017
+ tooLong: false,
1018
+ tooShort: false,
1019
+ rangeUnderflow: false,
1020
+ rangeOverflow: false,
1021
+ stepMismatch: false,
1022
+ badInput: false,
1023
+ customError: this.customValidation && this.validationText?.length > 0,
1024
+ };
1025
+ }
1026
+ // Ascolta gli 'it-change' bubblati dalle singole checkbox
1027
+ _handleGroupChange() {
1028
+ // Aggiorna this.value con l'array corrente delle checkbox selezionate
1029
+ const selected = this.checkboxes.filter((cb) => cb.checked).map((cb) => cb.value || 'true');
1030
+ this.value = JSON.stringify(selected);
1031
+ // Quando qualcosa cambia, ricalcola la validità
1032
+ this.handleValidationMessages();
1033
+ this.requestUpdate(); // Aggiorna la vista
1034
+ }
1035
+ /**
1036
+ * Override di checkValidity per la logica di gruppo.
1037
+ */
1038
+ checkValidity() {
1039
+ if (!this.required) {
1040
+ return true; // Non è obbligatorio
1041
+ }
1042
+ // Almeno una checkbox deve essere selezionata
1043
+ const atLeastOneChecked = this.checkboxes.some((cb) => cb.checked);
1044
+ // Aggiorna lo stato di validità del gruppo
1045
+ this._groupValid = atLeastOneChecked;
1046
+ return atLeastOneChecked;
1047
+ }
1048
+ /**
1049
+ * Override di reportValidity per mostrare l'errore a livello di gruppo.
1050
+ */
1051
+ reportValidity() {
1052
+ // Chiama la logica di validazione personalizzata
1053
+ const isValid = this.checkValidity();
1054
+ // Aggiorna il messaggio di validazione se invalido
1055
+ if (!isValid) {
1056
+ this.validationMessage = this.$t('validityGroupRequired'); // Usa la tua chiave di traduzione per "Campo obbligatorio"
1057
+ }
1058
+ else {
1059
+ this.validationMessage = '';
1060
+ }
1061
+ // Forzare l'aggiornamento di FormControlController che gestirà data-invalid/data-valid
1062
+ this.formControlController.updateValidity();
1063
+ this.requestUpdate();
1064
+ return isValid;
1065
+ }
1066
+ /**
1067
+ * Il tuo FormControl ha già un handleValidationMessages che
1068
+ * setta this.validationMessage. Aggiorniamolo per la logica di gruppo.
1069
+ */
1070
+ handleValidationMessages() {
1071
+ if (!this.customValidation && this.formControlController.submittedOnce) {
1072
+ this.validationMessage = this.checkValidity() ? '' : this.$t('validityGroupRequired');
1073
+ }
1074
+ if (this.customValidation) {
1075
+ this.validationMessage = this.inputElement.validationMessage;
1076
+ }
1077
+ }
1078
+ /**
1079
+ * Sync group state (name, grouped, inline, required, disabled, checked) to child checkboxes
1080
+ * This replaces the need for requestUpdate() calls
1081
+ */
1082
+ _syncGroupStateToChildren() {
1083
+ if (!this.checkboxes || this.checkboxes.length === 0) {
1084
+ return;
1085
+ }
1086
+ this.checkboxes.forEach((cb) => {
1087
+ // eslint-disable-next-line no-param-reassign
1088
+ cb.name = this.name;
1089
+ // eslint-disable-next-line no-param-reassign
1090
+ cb.group = this.group || !this.inline;
1091
+ // eslint-disable-next-line no-param-reassign
1092
+ cb.inline = this.inline;
1093
+ // eslint-disable-next-line no-param-reassign
1094
+ cb.required = this.required;
1095
+ if (this.disabled) {
1096
+ // eslint-disable-next-line no-param-reassign
1097
+ cb.disabled = this.disabled;
1098
+ }
1099
+ if (!cb.hasAttribute('checked')) {
1100
+ // eslint-disable-next-line no-param-reassign
1101
+ cb.checked = this.has(cb.value);
1102
+ }
1103
+ });
1104
+ }
1105
+ updated(changed) {
1106
+ super.updated(changed);
1107
+ // Update radios when value or name changes
1108
+ if (changed.has('value') || (changed.has('validationText') && this.customValidation)) {
1109
+ // Re-validate after value change (for native validation) only if validation was already triggered
1110
+ this.handleValidationMessages();
1111
+ }
1112
+ // If relevant group properties changed, sync to child checkboxes
1113
+ const relevant = ['group', 'inline', 'name', 'required', 'disabled', 'value'];
1114
+ const hasChanged = Array.from(changed.keys()).some((k) => relevant.includes(String(k)));
1115
+ if (hasChanged && this.checkboxes?.length) {
1116
+ this._syncGroupStateToChildren();
1117
+ }
1118
+ }
1119
+ // Render per mostrare l'errore (usa la tua logica di rendering dell'errore)
1120
+ // All'interno di ItCheckboxGroup (metodo render)
1121
+ render() {
1122
+ const showValidation = this.formControlController.submittedOnce || this.customValidation; // true; // this._touched || this.customValidation;
1123
+ const validityMessage = (showValidation ? this.validationMessage : '') ?? '';
1124
+ // Determina lo stato di invalidità in base alla validazione di gruppo
1125
+ const invalid = validityMessage?.length > 0 || !this._groupValid;
1126
+ const errorId = `invalid-feedback-${this._id}`;
1127
+ // Messaggio di validazione per il gruppo
1128
+ const validityMessageRender = html `<div
1129
+ role="alert"
1130
+ id="${errorId}"
1131
+ class="form-feedback just-validate-error-label"
1132
+ ?hidden=${!(validityMessage?.length > 0)}
1133
+ >
1134
+ <span class="visually-hidden">${this._label?.[0]?.textContent || ''}: </span>
1135
+ ${validityMessage}
1136
+ </div>`;
1137
+ // il pattern per errori nel form è stato preso da qui https://design-system.w3.org/styles/form-errors.html
1138
+ return html `
1139
+ <fieldset
1140
+ class="it-checkbox-group it-form__control"
1141
+ id="${this._id}"
1142
+ aria-describedby=${ifDefined(invalid ? errorId : undefined)}
1143
+ aria-required=${ifDefined(this.required ? 'true' : undefined)}
1144
+ part="fieldset"
1145
+ >
1146
+ <legend part="legend">
1147
+ <slot name="legend"></slot>
1148
+ </legend>
1149
+
1150
+ <slot @slotchange=${this._handleSlotChange}></slot>
1151
+ ${when(invalid, () => validityMessageRender)}
1152
+ </fieldset>
1153
+ `;
1154
+ }
1155
+ setCustomValidity(message) {
1156
+ if (!this.customValidation) {
1157
+ this.inputElement.setCustomValidity(message);
1158
+ this.validationMessage = this.inputElement.validationMessage;
1159
+ }
1160
+ else {
1161
+ this.validationMessage = message;
1162
+ }
1163
+ this.formControlController.updateValidity();
1164
+ }
1165
+ // Metodo per gestire l'assegnazione iniziale e re-assegnazione delle checkbox
1166
+ _handleSlotChange() {
1167
+ // Dopo l'assegnazione, forziamo un controllo di validità per inizializzare _groupValid
1168
+ this.handleValidationMessages();
1169
+ this.requestUpdate();
1170
+ }
1171
+ };
1172
+ ItCheckboxGroup.styles = styles;
1173
+ __decorate([
1174
+ property({ type: Boolean, reflect: true }),
1175
+ __metadata("design:type", Object)
1176
+ ], ItCheckboxGroup.prototype, "required", void 0);
1177
+ __decorate([
1178
+ property({ type: Boolean, reflect: true }),
1179
+ __metadata("design:type", Object)
1180
+ ], ItCheckboxGroup.prototype, "inline", void 0);
1181
+ __decorate([
1182
+ property({ type: Boolean, reflect: true }),
1183
+ __metadata("design:type", Object)
1184
+ ], ItCheckboxGroup.prototype, "group", void 0);
1185
+ __decorate([
1186
+ property({ type: String, reflect: true }),
1187
+ __metadata("design:type", Object)
1188
+ ], ItCheckboxGroup.prototype, "name", void 0);
1189
+ __decorate([
1190
+ queryAssignedElements({ selector: 'it-checkbox' }),
1191
+ __metadata("design:type", Array)
1192
+ ], ItCheckboxGroup.prototype, "checkboxes", void 0);
1193
+ __decorate([
1194
+ queryAssignedElements({ slot: 'legend' }),
1195
+ __metadata("design:type", Array)
1196
+ ], ItCheckboxGroup.prototype, "_label", void 0);
1197
+ __decorate([
1198
+ state(),
1199
+ __metadata("design:type", Object)
1200
+ ], ItCheckboxGroup.prototype, "_groupValid", void 0);
1201
+ ItCheckboxGroup = __decorate([
1202
+ customElement('it-checkbox-group')
1203
+ ], ItCheckboxGroup);
1204
+
1205
+ export { ItCheckboxGroup };
1206
+ //# sourceMappingURL=it-checkbox-group.js.map