@italia/checkbox 1.0.0-alpha.5 → 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.
@@ -1,1210 +1,19 @@
1
- import { _ as __decorate, a as __metadata, F as FormControl, b as FormControlController } from '../index-CHPuow63.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';
1
+ import { ItCheckboxGroupBase } from './it-checkbox-group-base.js';
2
+ import '../index-D4nFbRry.js';
6
3
  import 'lit/directive.js';
4
+ import 'lit';
5
+ import 'lit/decorators.js';
6
+ import 'lit/directives/when.js';
7
+ import 'lit/directives/if-defined.js';
7
8
 
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(--bsi-color-border-inverse), 0 0 0 5px var(--bsi-color-outline-focus) !important;
25
- outline: 3px solid transparent !important;
26
- outline-offset: 3px !important;
9
+ /**
10
+ * @element it-checkbox-group
11
+ */
12
+ class ItCheckboxGroup extends ItCheckboxGroupBase {
27
13
  }
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(--bsi-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(--bsi-spacing-s);
75
- font-style: normal;
76
- line-height: inherit;
77
- }
78
-
79
- ol,
80
- ul {
81
- padding-left: var(--bsi-spacing-l);
82
- }
83
-
84
- ol,
85
- ul,
86
- dl {
87
- margin-top: 0;
88
- margin-bottom: var(--bsi-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(--bsi-font-weight-strong);
100
- }
101
-
102
- dd {
103
- margin-bottom: var(--bsi-spacing-xxs);
104
- margin-left: 0;
105
- }
106
-
107
- blockquote {
108
- margin: 0 0 var(--bsi-spacing-s);
109
- }
110
-
111
- sub,
112
- sup {
113
- position: relative;
114
- font-size: var(--bsi-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(--bsi-color-link);
129
- text-decoration: underline;
130
- text-decoration-skip-ink: auto;
131
- text-underline-offset: 2px;
132
- }
133
- a:hover {
134
- color: var(--bsi-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(--bsi-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
- --bsi-form-control-height: 2.5rem;
343
- --bsi-form-control-spacing: var(--bsi-spacing-xxs);
344
- --bsi-form-control-background-color: var(--bsi-color-background-inverse);
345
- --bsi-form-control-border-color: var(--bsi-color-border-secondary);
346
- --bsi-form-control-border-radius: var(--bsi-radius-smooth);
347
- --bsi-form-control-placeholder-color: var(--bsi-color-text-muted);
348
- --bsi-form-control-label-color: var(--bsi-color-text-base);
349
- --bsi-form-control-text-color: var(--bsi-color-text-secondary);
350
- --bsi-form-control-font-size: var(--bsi-body-font-size);
351
- --bsi-form-group-spacing-y: var(--bsi-spacing-m);
352
- --bsi-form-checkbox-border-color: var(--bsi-color-border-secondary);
353
- --bsi-form-checkbox-border-radius: var(--bsi-radius-smooth);
354
- --bsi-form-checked-color: var(--bsi-color-background-primary);
355
- }
356
-
357
- input[readonly],
358
- textarea[readonly],
359
- select[readonly] {
360
- --bsi-form-control-border-color: var(--bsi-color-border-subtle);
361
- --bsi-form-control-background-color: var(--bsi-color-background-muted);
362
- cursor: not-allowed;
363
- }
364
-
365
- input,
366
- textarea,
367
- select {
368
- display: block;
369
- width: 100%;
370
- padding: var(--bsi-form-control-spacing);
371
- border: 1px solid var(--bsi-form-control-border-color);
372
- border-radius: var(--bsi-form-control-border-radius);
373
- background-color: var(--bsi-form-control-background-color);
374
- color: var(--bsi-form-control-text-color);
375
- font-size: var(--bsi-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(--bsi-color-border-disabled);
383
- opacity: 1;
384
- background-color: var(--bsi-color-background-disabled);
385
- color: var(--bsi-color-text-disabled);
386
- }
387
-
388
- /* stylelint-disable-next-line no-duplicate-selectors */
389
- input:focus,
390
- textarea:focus {
391
- outline: 3px solid transparent;
392
- outline-offset: 3px;
393
- box-shadow: 0 0 0 2px var(--bsi-color-border-inverse), 0 0 0 5px var(--bsi-color-outline-focus) !important;
394
- }
395
-
396
- input::file-selector-button {
397
- margin: -0.375rem -0.75rem;
398
- padding: 0.375rem 0.75rem;
399
- border-width: 0;
400
- border-style: solid;
401
- border-radius: 0;
402
- border-color: inherit;
403
- color: hsl(0, 0%, 10%);
404
- pointer-events: none;
405
- margin-inline-end: 0.75rem;
406
- border-inline-end-width: 0;
407
- background-color: hsl(0, 0%, 100%);
408
- 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;
409
- }
410
- @media (prefers-reduced-motion: reduce) {
411
- input::file-selector-button {
412
- transition: none;
413
- }
414
- }
415
- input:hover:not(:disabled):not([readonly])::file-selector-button {
416
- background-color: rgb(242.25, 242.25, 242.25);
417
- }
418
- input[type=file] {
419
- overflow: hidden;
420
- }
421
- input[type=file]:not(:disabled):not([readonly]) {
422
- cursor: pointer;
423
- }
424
- input::-webkit-date-and-time-value {
425
- height: 1.5em;
426
- }
427
-
428
- select {
429
- 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");
430
- background-repeat: no-repeat;
431
- background-position: right var(--bsi-form-control-spacing) center;
432
- background-size: 16px 12px;
433
- appearance: none;
434
- }
435
- select:focus {
436
- border-color: hsl(210, 17%, 44%);
437
- outline: 0;
438
- box-shadow: 0 0 0 0.25rem rgba(0, 102, 204, 0.25);
439
- }
440
- select[multiple], select[size]:not([size="1"]) {
441
- padding-right: 0.75rem;
442
- background-image: none;
443
- }
444
- select:disabled {
445
- background-color: hsl(0, 0%, 90%);
446
- }
447
- select:disabled:hover {
448
- cursor: not-allowed;
449
- }
450
- select:-moz-focusring {
451
- color: transparent;
452
- text-shadow: 0 0 0 hsl(0, 0%, 10%);
453
- }
454
- select option {
455
- font-weight: normal;
456
- }
457
- select {
458
- /* stylelint-disable-next-line no-duplicate-selectors */ /* TO DO check these styles */
14
+ if (!customElements.get('it-checkbox-group')) {
15
+ customElements.define('it-checkbox-group', ItCheckboxGroup);
459
16
  }
460
- select:disabled {
461
- opacity: 1;
462
- background-color: hsl(210, 3%, 85%);
463
- }
464
-
465
- textarea {
466
- height: auto;
467
- font-size: var(--bsi-body-font-size);
468
- line-height: 1.5;
469
- }
470
-
471
- label {
472
- display: inline-block;
473
- width: auto;
474
- max-width: 100%;
475
- margin-bottom: var(--bsi-spacing-xxs);
476
- color: var(--bsi-form-control-label-color);
477
- font-size: var(--bsi-label-font-size-s);
478
- font-weight: var(--bsi-font-weight-solid);
479
- line-height: var(--bsi-label-leading);
480
- }
481
-
482
- /* stylelint-disable-next-line no-duplicate-selectors */
483
- input,
484
- textarea {
485
- outline: 0;
486
- box-shadow: none;
487
- transition: none;
488
- appearance: none;
489
- }
490
-
491
- input[type=date],
492
- input[type=datetime-local],
493
- input[type=time] {
494
- display: flex;
495
- }
496
-
497
- fieldset legend {
498
- margin-bottom: var(--bsi-spacing-s);
499
- padding: 0 var(--bsi-form-input-spacing-x);
500
- background-color: transparent;
501
- color: var(--bsi-form-control-text-color);
502
- font-size: var(--bsi-label-sm);
503
- font-weight: var(--bsi-font-weight-solid);
504
- }
505
-
506
- ::placeholder {
507
- color: var(--bsi-form-control-placeholder-color);
508
- }
509
-
510
- input::-webkit-datetime-edit {
511
- background-color: var(--bsi-color-background-primary-lighter);
512
- color: var(--bsi-form-contro-text-color);
513
- }
514
-
515
- .form-group {
516
- position: relative;
517
- margin-bottom: var(--bsi-form-group-spacing-y);
518
- }
519
- .form-group label.input-symbol-label:not(.active) {
520
- left: 2.25rem;
521
- }
522
- .form-group small.form-text {
523
- margin: 0;
524
- font-size: 0.875rem;
525
- }
526
- .form-group input[type=time] ~ label {
527
- font-size: 0.875rem;
528
- }
529
-
530
- .form-text {
531
- margin: var(--bsi-spacing-xxs) 0;
532
- color: var(--bsi-color-text-secondary);
533
- }
534
-
535
- .form-group.active .form-file-name {
536
- padding-bottom: 1.95rem;
537
- }
538
-
539
- .warning-feedback {
540
- display: none;
541
- width: 100%;
542
- margin-top: 0.25rem;
543
- color: var(--bsi-color-text-warning);
544
- font-size: 0.75rem;
545
- }
546
-
547
- .valid-feedback,
548
- .invalid-feedback,
549
- .warning-feedback {
550
- margin-left: 0.5rem;
551
- }
552
-
553
- .input-group .input-group-text .btn {
554
- border-radius: var(--bsi-form-control-border-radius) 0 0 var(--bsi-form-control-border-radius);
555
- }
556
- .input-group .input-group-append {
557
- margin-left: 0;
558
- }
559
- .input-group .input-group-append .btn {
560
- height: 100%;
561
- padding-top: 0;
562
- padding-bottom: 0;
563
- border-bottom: 1px solid hsl(210, 17%, 44%);
564
- border-radius: 0 var(--bsi-form-control-border-radius) var(--bsi-form-control-border-radius) 0;
565
- }
566
-
567
- .form-check {
568
- position: relative;
569
- }
570
- .form-check + .form-check {
571
- margin-top: var(--bsi-spacing-s);
572
- }
573
- .form-check [type=checkbox],
574
- .form-check [type=radio] {
575
- position: absolute;
576
- top: 9px;
577
- left: 9px;
578
- width: auto;
579
- margin-top: 0;
580
- margin-left: 0;
581
- opacity: 0;
582
- }
583
- .form-check [type=checkbox] + label,
584
- .form-check [type=radio] + label {
585
- position: relative;
586
- margin-bottom: 0;
587
- padding-left: 28px;
588
- font-size: var(--bsi-label-font-size);
589
- font-weight: var(--bsi-font-weight-solid);
590
- cursor: pointer;
591
- user-select: none;
592
- }
593
- @media (min-width: 576px) {
594
- .form-check [type=checkbox] + label,
595
- .form-check [type=radio] + label {
596
- font-size: var(--bsi-label-font-size-l);
597
- }
598
- }
599
- .form-check input[type=checkbox] + label::after,
600
- .form-check input[type=checkbox] + label::before {
601
- position: absolute;
602
- left: 0;
603
- z-index: 1;
604
- content: "";
605
- border-width: 2px;
606
- border-style: solid;
607
- transition: all var(--bsi-transition-instant) ease-out;
608
- }
609
- .form-check input[type=checkbox] + label::after {
610
- top: 0;
611
- width: 20px;
612
- height: 20px;
613
- border-radius: var(--bsi-form-control-border-radius);
614
- }
615
- .form-check input[type=checkbox]:checked + label::before {
616
- top: 3px;
617
- left: 3px;
618
- width: 6px;
619
- height: 12px;
620
- border-width: 2px;
621
- border-style: solid;
622
- border-color: transparent var(--bsi-color-border-inverse) var(--bsi-color-border-inverse) transparent;
623
- opacity: 1;
624
- transform: rotate(40deg);
625
- transform-origin: 100% 100%;
626
- backface-visibility: hidden;
627
- }
628
- .form-check input[type=checkbox]:checked + label::after {
629
- z-index: 0;
630
- border-color: var(--bsi-form-checked-color);
631
- background-color: var(--bsi-form-checked-color);
632
- }
633
- .form-check input[type=checkbox]:not(:checked) + label::after {
634
- z-index: 0;
635
- border-color: var(--bsi-form-checkbox-border-color);
636
- background-color: transparent;
637
- }
638
- .form-check input[type=checkbox]:not(:checked) + label::before {
639
- top: 10px;
640
- left: 6px;
641
- width: 0;
642
- height: 0;
643
- border-color: transparent;
644
- }
645
- .form-check input[type=checkbox]:disabled + label {
646
- opacity: 1;
647
- cursor: not-allowed;
648
- }
649
- .form-check input[type=checkbox]:disabled:not(:checked) + label::after {
650
- border-color: var(--bsi-color-border-disabled);
651
- background-color: transparent;
652
- }
653
- .form-check input[type=checkbox]:disabled:checked + label::after {
654
- border-color: var(--bsi-color-border-disabled);
655
- background-color: var(--bsi-color-border-disabled);
656
- }
657
- .form-check input[type=radio] + label::after, .form-check input[type=radio] + label::before {
658
- position: absolute;
659
- top: 0;
660
- left: 0;
661
- z-index: 0;
662
- content: "";
663
- width: 20px;
664
- height: 20px;
665
- border-width: 2px;
666
- border-style: solid;
667
- border-radius: var(--bsi-radius-rounded);
668
- transition: all var(--bsi-transition-instant) ease-out;
669
- }
670
- .form-check input[type=radio]:not(:checked) + label::after, .form-check input[type=radio]:not(:checked) + label::before {
671
- border-color: var(--bsi-form-checkbox-border-color);
672
- }
673
- .form-check input[type=radio]:not(:checked) + label:after {
674
- z-index: -1;
675
- transform: scale(0);
676
- }
677
- .form-check input[type=radio]:checked + label::after {
678
- z-index: 0;
679
- border-color: var(--bsi-form-checked-color);
680
- background-color: var(--bsi-form-checked-color);
681
- transform: scale(0.64);
682
- }
683
- .form-check input[type=radio]:checked + label::before {
684
- border-color: var(--bsi-form-checked-color);
685
- }
686
- .form-check input[type=radio]:disabled + label {
687
- cursor: not-allowed;
688
- }
689
- .form-check input[type=radio]:disabled:not(:checked) + label::after, .form-check input[type=radio]:disabled:not(:checked) + label::before {
690
- border-color: var(--bsi-color-border-disabled);
691
- }
692
- .form-check input[type=radio]:disabled:checked + label::after {
693
- border-color: var(--bsi-color-border-disabled);
694
- background-color: var(--bsi-color-border-disabled);
695
- }
696
- .form-check input[type=radio]:disabled:checked + label::before {
697
- border-color: var(--bsi-color-border-disabled);
698
- }
699
- .form-check.form-check-group {
700
- margin-bottom: 1rem;
701
- padding: 0 0 1rem 0;
702
- box-shadow: inset 0 -1px 0 0 rgba(1, 1, 1, 0.1);
703
- }
704
- .form-check.form-check-group input[type=checkbox] + label,
705
- .form-check.form-check-group input[type=radio] + label {
706
- position: static;
707
- padding-right: 3.25rem;
708
- padding-left: 0;
709
- }
710
- .form-check.form-check-group input[type=checkbox] + label::after, .form-check.form-check-group input[type=checkbox] + label::before,
711
- .form-check.form-check-group input[type=radio] + label::after,
712
- .form-check.form-check-group input[type=radio] + label::before {
713
- right: 0;
714
- left: auto;
715
- }
716
- .form-check.form-check-group input[type=checkbox]:checked + label::before {
717
- right: 11px;
718
- }
719
- .form-check.form-check-group input[type=radio]:checked + label::before {
720
- right: 0;
721
- }
722
- .form-check.form-check-group .form-text {
723
- display: block;
724
- margin-bottom: 0.5rem;
725
- padding-right: 3.25rem;
726
- }
727
- .form-check.form-check-group input.semi-checked:not(:checked) + label::before {
728
- right: 4px;
729
- left: auto;
730
- }
731
- .form-check input.semi-checked:not(:checked) + label::before {
732
- top: 12px;
733
- left: 4px;
734
- width: 12px;
735
- height: 2px;
736
- border-width: 0;
737
- border-style: none;
738
- border-color: transparent;
739
- opacity: 1;
740
- background: var(--bsi-color-background-inverse);
741
- transform: none;
742
- backface-visibility: hidden;
743
- }
744
- .form-check input.semi-checked:not(:checked) + label::after {
745
- z-index: 0;
746
- border-color: var(--bsi-form-checked-color);
747
- background-color: var(--bsi-form-checked-color);
748
- }
749
-
750
- .form-check-inline {
751
- display: inline-block;
752
- }
753
- .form-check-inline:not(:last-child) {
754
- margin-right: var(--bsi-spacing-m);
755
- }
756
-
757
- @media (prefers-reduced-motion: reduce) {
758
- fieldset legend,
759
- .form-group label,
760
- textarea,
761
- .form-check [type=checkbox],
762
- .form-check [type=radio],
763
- .form-check [type=checkbox] + label::after,
764
- .form-check [type=checkbox] + label::before,
765
- .form-check [type=radio] + label::after,
766
- .form-check [type=radio] + label::before,
767
- .toggles label input[type=checkbox] + .lever::before,
768
- .toggles label input[type=checkbox] + .lever::after {
769
- transition: none !important;
770
- }
771
- }
772
- .form-check [type=checkbox]:focus + label,
773
- .form-check [type=radio]:focus + label {
774
- border-color: hsl(0, 0%, 0%) !important;
775
- box-shadow: 0 0 0 2px var(--bsi-color-border-inverse), 0 0 0 5px var(--bsi-color-outline-focus) !important;
776
- outline: 3px solid transparent !important;
777
- outline-offset: 3px !important;
778
- }
779
-
780
- .form-check [type=checkbox]:focus[data-focus-mouse=true] + label,
781
- .form-check [type=radio]:focus[data-focus-mouse=true] + label {
782
- border-color: inherit !important;
783
- box-shadow: none !important;
784
- outline: none !important;
785
- }
786
-
787
- .form-control-plaintext {
788
- border: 0;
789
- --bsi-form-control-border-color: transparent;
790
- --bsi-form-control-border-radius: 0;
791
- --bsi-form-control-background-color: transparent;
792
- --bsi-form-control-spacing: 0;
793
- }
794
- .form-control-plaintext:focus {
795
- outline: 0;
796
- box-shadow: none !important;
797
- }
798
- .form-control-plaintext + label {
799
- cursor: text;
800
- }
801
-
802
- .form-control {
803
- background-repeat: no-repeat;
804
- background-position: center right;
805
- background-size: 45px 30%;
806
- }
807
- .form-control:disabled {
808
- cursor: not-allowed;
809
- background: var(--bsi-color-background-disabled);
810
- border: 0;
811
- color: var(--bsi-color-text-disabled);
812
- }
813
- .was-validated .form-control:valid, .form-control.is-valid {
814
- 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");
815
- }
816
- .was-validated .form-control:invalid, .form-control.is-invalid {
817
- 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");
818
- border-color: var(--bsi-color-border-danger);
819
- }
820
- .form-control.warning {
821
- 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;
822
- border-color: var(--bsi-color-border-warning);
823
- }
824
- .form-control.is-valid ~ .warning-feedback {
825
- display: block;
826
- }
827
-
828
- .form-control-sm {
829
- --bsi-form-control-spacing: var(--bsi-spacing-xxs) var(--bsi-spacing-3xs);
830
- --bsi-form-control-font-size: var(--bsi-label-font-size);
831
- }
832
- .form-control-sm::file-selector-button {
833
- padding: 0.25rem 0.5rem;
834
- margin: -0.25rem -0.5rem;
835
- margin-inline-end: 0.5rem;
836
- }
837
-
838
- .form-control-lg {
839
- --bsi-form-control-font-size: var(--bsi-lead-font-size);
840
- }
841
- .form-control-lg::file-selector-button {
842
- padding: 0.5rem 1rem;
843
- margin: -0.5rem -1rem;
844
- margin-inline-end: 1rem;
845
- }
846
-
847
- textarea.form-control {
848
- min-height: 2.5rem;
849
- border: 1px solid hsl(210, 17%, 44%);
850
- }
851
- textarea.form-control-sm {
852
- min-height: calc(1.5em + 0.5rem);
853
- }
854
- textarea.form-control-lg {
855
- min-height: calc(1.5em + 1rem);
856
- }
857
-
858
- .form-control-color {
859
- width: 3rem;
860
- height: 2.5rem;
861
- padding: 0.375rem;
862
- }
863
- .form-control-color:not(:disabled):not([readonly]) {
864
- cursor: pointer;
865
- }
866
- .form-control-color::-moz-color-swatch {
867
- border: 0 !important;
868
- border-radius: 0;
869
- }
870
- .form-control-color::-webkit-color-swatch {
871
- border-radius: 0;
872
- }
873
- .form-control-color.form-control-sm {
874
- height: calc(1.5em + 0.5rem);
875
- }
876
- .form-control-color.form-control-lg {
877
- height: calc(1.5em + 1rem);
878
- }
879
-
880
- .form-feedback {
881
- width: 100%;
882
- margin-top: 0.25rem;
883
- font-size: 0.75rem;
884
- }
885
- .form-feedback.just-validate-error-label {
886
- color: var(--bsi-color-text-danger);
887
- }
888
-
889
- .input-group-text:has(~ [data-focus-mouse=true]:not(.btn)),
890
- [data-focus-mouse=true]:not(.btn) ~ .input-group-text,
891
- button:has(~ [data-focus-mouse=true]:not(.btn)),
892
- [data-focus-mouse=true]:not(.btn) + button {
893
- border-color: inherit !important;
894
- box-shadow: none !important;
895
- outline: none !important;
896
- }
897
-
898
- .input-group-text:has(~ .is-invalid),
899
- .is-invalid ~ .input-group-text,
900
- button:has(~ .is-invalid),
901
- .is-invalid + button {
902
- border-color: var(--bsi-color-border-danger) !important;
903
- }
904
-
905
- .sr-only-justvalidate-bi {
906
- display: none;
907
- }
908
-
909
- .just-validate-success-field {
910
- border-color: var(--bsi-color-border-success) !important;
911
- padding-right: calc(1.5em + 0.75rem) !important;
912
- 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");
913
- }
914
-
915
- .input-group-text:has(~ .just-validate-success-field),
916
- .just-validate-success-field ~ .input-group-text,
917
- button:has(~ .just-validate-success-field),
918
- .just-validate-success-field + button {
919
- border-color: var(--bsi-color-border-success);
920
- }
921
-
922
- .just-validate-success-field + .input-group-text.align-buttons,
923
- .is-invalid + .input-group-text.align-buttons {
924
- right: 30px;
925
- }
926
-
927
- .is-invalid + .input-group-text.align-buttons {
928
- bottom: 22px;
929
- }
930
-
931
- .autocomplete__wrapper .form-feedback.just-validate-error-label {
932
- position: absolute;
933
- }
934
-
935
- textarea.form-control {
936
- background-position: top 0.3em right 0.3em !important;
937
- background-size: 37px 30% !important;
938
- }
939
- textarea.is-invalid {
940
- border-bottom-style: solid;
941
- border-bottom-width: 1px;
942
- }
943
- textarea.just-validate-success-field {
944
- border-bottom-style: solid;
945
- border-bottom-width: 1px;
946
- }
947
-
948
- input[type=checkbox].is-invalid,
949
- input[type=radio].is-invalid {
950
- --bsi-form-checkbox-border-color: var(--bsi-color-border-danger);
951
- }
952
-
953
- select.is-invalid {
954
- border: 1px solid var(--bsi-color-border-danger);
955
- }
956
- select.just-validate-success-field {
957
- border: 1px solid var(--bsi-color-border-success);
958
- }`;
959
-
960
- let ItCheckboxGroup = class ItCheckboxGroup extends FormControl {
961
- constructor() {
962
- super(...arguments);
963
- this.required = false;
964
- /** Draws checkboxes inline, side by side. */
965
- this.inline = false;
966
- /** Draws checkboxes in groups. */
967
- this.group = false;
968
- this.name = ''; // Il name del gruppo
969
- // Override del controller per usare le funzioni di validazione di gruppo
970
- this.formControlController = new FormControlController(this, {
971
- // Il valore è un array dei valori delle checkbox selezionate
972
- value: (control) => control.checkboxes.filter((cb) => cb.checked).map((cb) => cb.value || 'true'),
973
- // Il name è quello del gruppo
974
- name: (control) => control.name,
975
- // La validità è gestita da noi con checkValidity di gruppo
976
- checkValidity: (control) => control.checkValidity(),
977
- reportValidity: (control) => control.reportValidity(),
978
- // Non implementiamo setValue qui, gestito dalle singole checkbox
979
- setValue: () => { },
980
- // Ascoltiamo l'input su tutti i cambi di stato delle checkbox
981
- assumeInteractionOn: ['it-change'],
982
- });
983
- // Questo state servirà per forzare il re-render del messaggio di errore
984
- this._groupValid = true;
985
- }
986
- get selectedValues() {
987
- if (!this.value)
988
- return [];
989
- try {
990
- return JSON.parse(this.value);
991
- }
992
- catch {
993
- return [];
994
- }
995
- }
996
- set selectedValues(vals) {
997
- this.value = JSON.stringify(vals);
998
- }
999
- has(v) {
1000
- return this.selectedValues.indexOf(v) >= 0;
1001
- }
1002
- connectedCallback() {
1003
- super.connectedCallback?.();
1004
- this.addEventListener('it-change', this._handleGroupChange);
1005
- }
1006
- disconnectedCallback() {
1007
- super.disconnectedCallback?.();
1008
- this.removeEventListener('it-change', this._handleGroupChange);
1009
- }
1010
- /**
1011
- * Override: Custom validity check for radio group
1012
- */
1013
- get validity() {
1014
- // Fallback: create a custom ValidityState-like object
1015
- const valid = !this.required || !!this.value;
1016
- return {
1017
- valid,
1018
- valueMissing: this.required && !this.value,
1019
- typeMismatch: false,
1020
- patternMismatch: false,
1021
- tooLong: false,
1022
- tooShort: false,
1023
- rangeUnderflow: false,
1024
- rangeOverflow: false,
1025
- stepMismatch: false,
1026
- badInput: false,
1027
- customError: this.customValidation && this.validationText?.length > 0,
1028
- };
1029
- }
1030
- // Ascolta gli 'it-change' bubblati dalle singole checkbox
1031
- _handleGroupChange() {
1032
- // Aggiorna this.value con l'array corrente delle checkbox selezionate
1033
- const selected = this.checkboxes.filter((cb) => cb.checked).map((cb) => cb.value || 'true');
1034
- this.value = JSON.stringify(selected);
1035
- // Quando qualcosa cambia, ricalcola la validità
1036
- this.handleValidationMessages();
1037
- this.requestUpdate(); // Aggiorna la vista
1038
- }
1039
- /**
1040
- * Override di checkValidity per la logica di gruppo.
1041
- */
1042
- checkValidity() {
1043
- if (!this.required) {
1044
- return true; // Non è obbligatorio
1045
- }
1046
- // Almeno una checkbox deve essere selezionata
1047
- const atLeastOneChecked = this.checkboxes.some((cb) => cb.checked);
1048
- // Aggiorna lo stato di validità del gruppo
1049
- this._groupValid = atLeastOneChecked;
1050
- return atLeastOneChecked;
1051
- }
1052
- /**
1053
- * Override di reportValidity per mostrare l'errore a livello di gruppo.
1054
- */
1055
- reportValidity() {
1056
- // Chiama la logica di validazione personalizzata
1057
- const isValid = this.checkValidity();
1058
- // Aggiorna il messaggio di validazione se invalido
1059
- if (!isValid) {
1060
- this.validationMessage = this.$t('validityGroupRequired'); // Usa la tua chiave di traduzione per "Campo obbligatorio"
1061
- }
1062
- else {
1063
- this.validationMessage = '';
1064
- }
1065
- // Forzare l'aggiornamento di FormControlController che gestirà data-invalid/data-valid
1066
- this.formControlController.updateValidity();
1067
- this.requestUpdate();
1068
- return isValid;
1069
- }
1070
- /**
1071
- * Il tuo FormControl ha già un handleValidationMessages che
1072
- * setta this.validationMessage. Aggiorniamolo per la logica di gruppo.
1073
- */
1074
- handleValidationMessages() {
1075
- if (!this.customValidation && this.formControlController.submittedOnce) {
1076
- this.validationMessage = this.checkValidity() ? '' : this.$t('validityGroupRequired');
1077
- }
1078
- if (this.customValidation) {
1079
- this.validationMessage = this.inputElement.validationMessage;
1080
- }
1081
- }
1082
- /**
1083
- * Sync group state (name, grouped, inline, required, disabled, checked) to child checkboxes
1084
- * This replaces the need for requestUpdate() calls
1085
- */
1086
- _syncGroupStateToChildren() {
1087
- if (!this.checkboxes || this.checkboxes.length === 0) {
1088
- return;
1089
- }
1090
- this.checkboxes.forEach((cb) => {
1091
- // eslint-disable-next-line no-param-reassign
1092
- cb.name = this.name;
1093
- // eslint-disable-next-line no-param-reassign
1094
- cb.group = this.group || !this.inline;
1095
- // eslint-disable-next-line no-param-reassign
1096
- cb.inline = this.inline;
1097
- // eslint-disable-next-line no-param-reassign
1098
- cb.required = this.required;
1099
- if (this.disabled) {
1100
- // eslint-disable-next-line no-param-reassign
1101
- cb.disabled = this.disabled;
1102
- }
1103
- if (!cb.hasAttribute('checked')) {
1104
- // eslint-disable-next-line no-param-reassign
1105
- cb.checked = this.has(cb.value);
1106
- }
1107
- });
1108
- }
1109
- updated(changed) {
1110
- super.updated(changed);
1111
- // Update radios when value or name changes
1112
- if (changed.has('value') || (changed.has('validationText') && this.customValidation)) {
1113
- // Re-validate after value change (for native validation) only if validation was already triggered
1114
- this.handleValidationMessages();
1115
- }
1116
- // If relevant group properties changed, sync to child checkboxes
1117
- const relevant = ['group', 'inline', 'name', 'required', 'disabled', 'value'];
1118
- const hasChanged = Array.from(changed.keys()).some((k) => relevant.includes(String(k)));
1119
- if (hasChanged && this.checkboxes?.length) {
1120
- this._syncGroupStateToChildren();
1121
- }
1122
- }
1123
- // Render per mostrare l'errore (usa la tua logica di rendering dell'errore)
1124
- // All'interno di ItCheckboxGroup (metodo render)
1125
- render() {
1126
- const showValidation = this.formControlController.submittedOnce || this.customValidation; // true; // this._touched || this.customValidation;
1127
- const validityMessage = (showValidation ? this.validationMessage : '') ?? '';
1128
- // Determina lo stato di invalidità in base alla validazione di gruppo
1129
- const invalid = validityMessage?.length > 0 || !this._groupValid;
1130
- const errorId = `invalid-feedback-${this._id}`;
1131
- // Messaggio di validazione per il gruppo
1132
- const validityMessageRender = html `<div
1133
- role="alert"
1134
- id="${errorId}"
1135
- class="form-feedback just-validate-error-label"
1136
- ?hidden=${!(validityMessage?.length > 0)}
1137
- >
1138
- <span class="visually-hidden">${this._label?.[0]?.textContent || ''}: </span>
1139
- ${validityMessage}
1140
- </div>`;
1141
- // il pattern per errori nel form è stato preso da qui https://design-system.w3.org/styles/form-errors.html
1142
- return html `
1143
- <fieldset
1144
- class="it-checkbox-group it-form__control"
1145
- id="${this._id}"
1146
- aria-describedby=${ifDefined(invalid ? errorId : undefined)}
1147
- aria-required=${ifDefined(this.required ? 'true' : undefined)}
1148
- part="fieldset"
1149
- >
1150
- <legend part="legend">
1151
- <slot name="legend"></slot>
1152
- </legend>
1153
-
1154
- <slot @slotchange=${this._handleSlotChange}></slot>
1155
- ${when(invalid, () => validityMessageRender)}
1156
- </fieldset>
1157
- `;
1158
- }
1159
- setCustomValidity(message) {
1160
- if (!this.customValidation) {
1161
- this.inputElement.setCustomValidity(message);
1162
- this.validationMessage = this.inputElement.validationMessage;
1163
- }
1164
- else {
1165
- this.validationMessage = message;
1166
- }
1167
- this.formControlController.updateValidity();
1168
- }
1169
- // Metodo per gestire l'assegnazione iniziale e re-assegnazione delle checkbox
1170
- _handleSlotChange() {
1171
- // Dopo l'assegnazione, forziamo un controllo di validità per inizializzare _groupValid
1172
- this.handleValidationMessages();
1173
- this.requestUpdate();
1174
- }
1175
- };
1176
- ItCheckboxGroup.styles = styles;
1177
- __decorate([
1178
- property({ type: Boolean, reflect: true }),
1179
- __metadata("design:type", Object)
1180
- ], ItCheckboxGroup.prototype, "required", void 0);
1181
- __decorate([
1182
- property({ type: Boolean, reflect: true }),
1183
- __metadata("design:type", Object)
1184
- ], ItCheckboxGroup.prototype, "inline", void 0);
1185
- __decorate([
1186
- property({ type: Boolean, reflect: true }),
1187
- __metadata("design:type", Object)
1188
- ], ItCheckboxGroup.prototype, "group", void 0);
1189
- __decorate([
1190
- property({ type: String, reflect: true }),
1191
- __metadata("design:type", Object)
1192
- ], ItCheckboxGroup.prototype, "name", void 0);
1193
- __decorate([
1194
- queryAssignedElements({ selector: 'it-checkbox' }),
1195
- __metadata("design:type", Array)
1196
- ], ItCheckboxGroup.prototype, "checkboxes", void 0);
1197
- __decorate([
1198
- queryAssignedElements({ slot: 'legend' }),
1199
- __metadata("design:type", Array)
1200
- ], ItCheckboxGroup.prototype, "_label", void 0);
1201
- __decorate([
1202
- state(),
1203
- __metadata("design:type", Object)
1204
- ], ItCheckboxGroup.prototype, "_groupValid", void 0);
1205
- ItCheckboxGroup = __decorate([
1206
- customElement('it-checkbox-group')
1207
- ], ItCheckboxGroup);
1208
17
 
1209
18
  export { ItCheckboxGroup };
1210
19
  //# sourceMappingURL=it-checkbox-group.js.map