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