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