@italia/toggle 1.0.0-alpha.9 → 1.0.0-beta.1

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.
package/README.md CHANGED
@@ -1,77 +1,11 @@
1
- # \<it-toggle>
1
+ # <it-toggle>
2
2
 
3
- This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
3
+ This package is part of [dev-kit-italia](https://italia.github.io/dev-kit-italia), a Web Components kit for the **.italia** design-system.
4
4
 
5
- ## Installation
5
+ ## Installation and usage
6
6
 
7
- ```bash
8
- npm i @italia/toggle
9
- ```
7
+ Most users want to install the full kit by installing [`@italia/dev-kit-italia`](https://npmjs.com/package/@italia/dev-kit-italia), but you have the option of installing this single Web Component separately if needed. Please find detailed installation and usage instructions in the [official documentation](https://italia.github.io/dev-kit-italia/?path=/docs/introduzione--documentazione).
10
8
 
11
- ## Usage
9
+ ## Documentation
12
10
 
13
- ```html
14
- <script type="module">
15
- import '@italia/toggle';
16
- </script>
17
-
18
- <it-toggle>
19
- <span slot="label">Toggle label</span>
20
- </it-toggle>
21
- ```
22
-
23
- ## Linting and formatting
24
-
25
- To scan the project for linting and formatting errors, run
26
-
27
- ```bash
28
- npm run lint
29
- ```
30
-
31
- To automatically fix linting and formatting errors, run
32
-
33
- ```bash
34
- npm run format
35
- ```
36
-
37
- ## Testing with Web Test Runner
38
-
39
- To execute a single test run:
40
-
41
- ```bash
42
- npm run test
43
- ```
44
-
45
- To run the tests in interactive watch mode run:
46
-
47
- ```bash
48
- npm run test:watch
49
- ```
50
-
51
- ## Demoing with Storybook
52
-
53
- To run a local instance of Storybook for your component, run
54
-
55
- ```bash
56
- npm run storybook
57
- ```
58
-
59
- To build a production version of Storybook, run
60
-
61
- ```bash
62
- npm run storybook:build
63
- ```
64
-
65
- ## Tooling configs
66
-
67
- For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
68
-
69
- If you customize the configuration a lot, you can consider moving them to individual files.
70
-
71
- ## Local Demo with `web-dev-server`
72
-
73
- ```bash
74
- npm start
75
- ```
76
-
77
- To run a local development server that serves the basic demo located in `demo/index.html`
11
+ Find the usage instructions for this specific component in its [dedicated documentation page](https://italia.github.io/dev-kit-italia/?path=/docs/componenti-form-toggle--documentazione).
@@ -121,7 +121,7 @@
121
121
  {
122
122
  "kind": "variable",
123
123
  "name": "meta",
124
- "default": "{ title: 'Componenti/Form/Toggle', tags: ['alpha', 'a11y-ok', 'web-component'], component: 'it-toggle', args: { id: '', label: \"Label dell'interruttore\", name: 'toggle-esempio', value: undefined, checked: false, disabled: false, form: undefined, customValidation: false, validityMessage: '', required: false, inline: false, group: false, supportText: '', }, argTypes: { id: { control: 'text', description: 'ID del campo', type: 'string', }, label: { control: 'text', description: 'Etichetta del campo', type: 'string', }, name: { control: 'text', description: 'Nome del campo nel form', type: 'string', }, value: { control: 'text', description: 'Valore del campo', type: 'string', }, checked: { control: 'boolean', type: 'boolean', table: { defaultValue: { summary: 'false' } }, }, disabled: { control: 'boolean', type: 'boolean', table: { defaultValue: { summary: 'false' } }, }, form: { control: 'text', type: 'string', description: \"ID html del form a cui è associato il campo, se il campo non si trova all'interno di una form \", }, customValidation: { name: 'custom-validation', control: 'boolean', type: 'boolean', table: { defaultValue: { summary: 'false' } }, description: 'Se la validazione del campo è fatta esternamente (lato server o con plugin js - validazione custom), impostare questo attributo a `true`.', }, validityMessage: { name: 'validity-message', control: 'text', type: 'string', description: \"Messaggio da mostrare quando il campo è invalido nel caso di validazione esterna (validazione custom). Se impostato a '' (stringa vuota) il campo viene considerato valido.\", }, required: { control: 'boolean', type: 'boolean', table: { defaultValue: { summary: 'false' } }, }, inline: { control: 'boolean', type: 'boolean', description: 'Allinea i toggle orizzontalmente', table: { defaultValue: { summary: 'false' } }, }, group: { control: 'boolean', type: 'boolean', description: 'Raggruppa visivamente i toggle', table: { defaultValue: { summary: 'false' } }, }, supportText: { name: 'support-text', control: 'text', description: 'Testo di supporto/aiuto sotto il toggle', type: 'string', }, }, } satisfies Meta<ToggleProps>"
124
+ "default": "{ title: 'Componenti/Form/Toggle', tags: ['a11y-ok', 'web-component'], component: 'it-toggle', args: { id: '', label: \"Label dell'interruttore\", name: 'toggle-esempio', value: undefined, checked: false, disabled: false, form: undefined, customValidation: false, validityMessage: '', required: false, inline: false, group: false, supportText: '', }, argTypes: { id: { control: 'text', description: 'ID del campo', type: 'string', }, label: { control: 'text', description: 'Etichetta del campo', type: 'string', }, name: { control: 'text', description: 'Nome del campo nel form', type: 'string', }, value: { control: 'text', description: 'Valore del campo', type: 'string', }, checked: { control: 'boolean', type: 'boolean', table: { defaultValue: { summary: 'false' } }, }, disabled: { control: 'boolean', type: 'boolean', table: { defaultValue: { summary: 'false' } }, }, form: { control: 'text', type: 'string', description: \"ID html del form a cui è associato il campo, se il campo non si trova all'interno di una form \", }, customValidation: { name: 'custom-validation', control: 'boolean', type: 'boolean', table: { defaultValue: { summary: 'false' } }, description: 'Se la validazione del campo è fatta esternamente (lato server o con plugin js - validazione custom), impostare questo attributo a `true`.', }, validityMessage: { name: 'validity-message', control: 'text', type: 'string', description: \"Messaggio da mostrare quando il campo è invalido nel caso di validazione esterna (validazione custom). Se impostato a '' (stringa vuota) il campo viene considerato valido.\", }, required: { control: 'boolean', type: 'boolean', table: { defaultValue: { summary: 'false' } }, }, inline: { control: 'boolean', type: 'boolean', description: 'Allinea i toggle orizzontalmente', table: { defaultValue: { summary: 'false' } }, }, group: { control: 'boolean', type: 'boolean', description: 'Raggruppa visivamente i toggle', table: { defaultValue: { summary: 'false' } }, }, supportText: { name: 'support-text', control: 'text', description: 'Testo di supporto/aiuto sotto il toggle', type: 'string', }, }, } satisfies Meta<ToggleProps>"
125
125
  },
126
126
  {
127
127
  "kind": "variable",
@@ -3,35 +3,7 @@ import { customElement } from 'lit/decorators.js';
3
3
  import { css, html } from 'lit';
4
4
  import { ItCheckboxBase } from '@italia/checkbox/it-checkbox-base.js';
5
5
 
6
- var styles = css`/***************************** 1 ****************************************/
7
- /***************************** 2 ****************************************/
8
- /***************************** 1 ****************************************/
9
- /***************************** 2 ****************************************/
10
- /***************************** 1 ****************************************/
11
- /***************************** 2 ****************************************/
12
- /***************************** 3 ****************************************/
13
- /***************************** 1 ****************************************/
14
- /***************************** 2 ****************************************/
15
- /***************************** 3 ****************************************/
16
- /***************************** NEUTRAL 1 ****************************************/
17
- /***************************** NEUTRAL 2 ****************************************/
18
- /***************************** NEUTRAL 2 / 3 ****************************************/
19
- .toggles label:has(input[type=checkbox]:focus-visible), .toggles label input[type=checkbox]:focus + .lever, .form-check [type=checkbox]:focus + label,
20
- .form-check [type=radio]:focus + label {
21
- border-color: hsl(0, 0%, 0%) !important;
22
- box-shadow: 0 0 0 2px var(--bsi-color-border-inverse), 0 0 0 5px var(--bsi-color-outline-focus) !important;
23
- outline: 3px solid transparent !important;
24
- outline-offset: 3px !important;
25
- }
26
-
27
- .toggles label input[type=checkbox]:focus[data-focus-mouse=true] + .lever, .form-check [type=checkbox]:focus[data-focus-mouse=true] + label,
28
- .form-check [type=radio]:focus[data-focus-mouse=true] + label {
29
- border-color: inherit !important;
30
- box-shadow: none !important;
31
- outline: none !important;
32
- }
33
-
34
- *,
6
+ var styles = css`*,
35
7
  *::before,
36
8
  *::after {
37
9
  box-sizing: border-box;
@@ -425,7 +397,7 @@ input::-webkit-date-and-time-value {
425
397
  }
426
398
 
427
399
  select {
428
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='hsl%280, 0%, 15%%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
400
+ 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%, 32%%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
429
401
  background-repeat: no-repeat;
430
402
  background-position: right var(--bsi-form-control-spacing) center;
431
403
  background-size: 16px 12px;
@@ -438,7 +410,6 @@ select:focus {
438
410
  }
439
411
  select[multiple], select[size]:not([size="1"]) {
440
412
  padding-right: 0.75rem;
441
- background-image: none;
442
413
  }
443
414
  select:disabled {
444
415
  background-color: hsl(0, 0%, 90%);
@@ -572,8 +543,8 @@ input::-webkit-datetime-edit {
572
543
  .form-check [type=checkbox],
573
544
  .form-check [type=radio] {
574
545
  position: absolute;
575
- top: 9px;
576
- left: 9px;
546
+ top: 0;
547
+ left: 0;
577
548
  width: auto;
578
549
  margin-top: 0;
579
550
  margin-left: 0;
@@ -595,6 +566,19 @@ input::-webkit-datetime-edit {
595
566
  font-size: var(--bsi-label-font-size-l);
596
567
  }
597
568
  }
569
+ .form-check [type=checkbox]:focus + label,
570
+ .form-check [type=radio]:focus + label {
571
+ border-color: hsl(0, 0%, 0%) !important;
572
+ box-shadow: 0 0 0 2px var(--bsi-color-border-inverse), 0 0 0 5px var(--bsi-color-outline-focus) !important;
573
+ outline: 3px solid transparent !important;
574
+ outline-offset: 3px !important;
575
+ }
576
+ .form-check [type=checkbox]:focus[data-focus-mouse=true] + label,
577
+ .form-check [type=radio]:focus[data-focus-mouse=true] + label {
578
+ border-color: inherit !important;
579
+ box-shadow: none !important;
580
+ outline: none !important;
581
+ }
598
582
  .form-check input[type=checkbox] + label::after,
599
583
  .form-check input[type=checkbox] + label::before {
600
584
  position: absolute;
@@ -641,6 +625,9 @@ input::-webkit-datetime-edit {
641
625
  height: 0;
642
626
  border-color: transparent;
643
627
  }
628
+ .form-check input[type=checkbox] + label:hover::after {
629
+ border-color: var(--bsi-color-border-secondary-hover);
630
+ }
644
631
  .form-check input[type=checkbox]:disabled + label {
645
632
  opacity: 1;
646
633
  cursor: not-allowed;
@@ -682,6 +669,9 @@ input::-webkit-datetime-edit {
682
669
  .form-check input[type=radio]:checked + label::before {
683
670
  border-color: var(--bsi-form-checked-color);
684
671
  }
672
+ .form-check input[type=radio] + label:hover::before {
673
+ border-color: var(--bsi-color-border-secondary-hover);
674
+ }
685
675
  .form-check input[type=radio]:disabled + label {
686
676
  cursor: not-allowed;
687
677
  }
@@ -768,21 +758,6 @@ input::-webkit-datetime-edit {
768
758
  transition: none !important;
769
759
  }
770
760
  }
771
- .toggles label:has(input[type=checkbox]:focus-visible), .toggles label input[type=checkbox]:focus + .lever, .form-check [type=checkbox]:focus + label,
772
- .form-check [type=radio]:focus + label {
773
- border-color: hsl(0, 0%, 0%) !important;
774
- box-shadow: 0 0 0 2px var(--bsi-color-border-inverse), 0 0 0 5px var(--bsi-color-outline-focus) !important;
775
- outline: 3px solid transparent !important;
776
- outline-offset: 3px !important;
777
- }
778
-
779
- .toggles label input[type=checkbox]:focus[data-focus-mouse=true] + .lever, .form-check [type=checkbox]:focus[data-focus-mouse=true] + label,
780
- .form-check [type=radio]:focus[data-focus-mouse=true] + label {
781
- border-color: inherit !important;
782
- box-shadow: none !important;
783
- outline: none !important;
784
- }
785
-
786
761
  .form-control-plaintext {
787
762
  border: 0;
788
763
  --bsi-form-control-border-color: transparent;
@@ -801,7 +776,7 @@ input::-webkit-datetime-edit {
801
776
  .form-control {
802
777
  background-repeat: no-repeat;
803
778
  background-position: center right;
804
- background-size: 45px 30%;
779
+ background-size: 45px 20px;
805
780
  }
806
781
  .form-control:disabled {
807
782
  cursor: not-allowed;
@@ -809,20 +784,6 @@ input::-webkit-datetime-edit {
809
784
  border: 0;
810
785
  color: var(--bsi-color-text-disabled);
811
786
  }
812
- .was-validated .form-control:valid, .form-control.is-valid {
813
- 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");
814
- }
815
- .was-validated .form-control:invalid, .form-control.is-invalid {
816
- 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");
817
- border-color: var(--bsi-color-border-danger);
818
- }
819
- .form-control.warning {
820
- 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;
821
- border-color: var(--bsi-color-border-warning);
822
- }
823
- .form-control.is-valid ~ .warning-feedback {
824
- display: block;
825
- }
826
787
 
827
788
  .form-control-sm {
828
789
  --bsi-form-control-spacing: var(--bsi-spacing-xxs) var(--bsi-spacing-3xs);
@@ -919,15 +880,15 @@ textarea.form-control-lg {
919
880
  border-color: hsl(210, 100%, 40%);
920
881
  }
921
882
  .form-check-input:checked[type=checkbox] {
922
- 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");
883
+ background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path fill='none' stroke='hsl(0, 0%, 100%)' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/></svg>"));
923
884
  }
924
885
  .form-check-input:checked[type=radio] {
925
- 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");
886
+ background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='2' fill='hsl(0, 0%, 100%)'/></svg>"));
926
887
  }
927
888
  .form-check-input[type=checkbox]:indeterminate {
928
889
  background-color: hsl(210, 100%, 40%);
929
890
  border-color: hsl(210, 100%, 40%);
930
- 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");
891
+ background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path fill='none' stroke='hsl(0, 0%, 100%)' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/></svg>"));
931
892
  }
932
893
  .form-check-input:disabled {
933
894
  pointer-events: none;
@@ -945,7 +906,7 @@ textarea.form-control-lg {
945
906
  .form-switch .form-check-input {
946
907
  width: 2em;
947
908
  margin-left: -2.5em;
948
- 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");
909
+ background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='rgba(0, 0, 0, 0.25)'/></svg>"));
949
910
  background-position: left center;
950
911
  border-radius: 2em;
951
912
  transition: background-position 0.15s ease-in-out;
@@ -956,11 +917,11 @@ textarea.form-control-lg {
956
917
  }
957
918
  }
958
919
  .form-switch .form-check-input:focus {
959
- 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");
920
+ background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='hsl(210, 17%, 44%)'/></svg>"));
960
921
  }
961
922
  .form-switch .form-check-input:checked {
962
923
  background-position: right center;
963
- 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");
924
+ background-image: escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='hsl(0, 0%, 100%)'/></svg>"));
964
925
  }
965
926
  .form-switch.form-check-reverse {
966
927
  padding-right: 2.5em;
@@ -1035,6 +996,17 @@ textarea.form-control-lg {
1035
996
  top: 0;
1036
997
  left: 0;
1037
998
  }
999
+ .toggles label input[type=checkbox]:focus + .lever {
1000
+ border-color: hsl(0, 0%, 0%) !important;
1001
+ box-shadow: 0 0 0 2px var(--bsi-color-border-inverse), 0 0 0 5px var(--bsi-color-outline-focus) !important;
1002
+ outline: 3px solid transparent !important;
1003
+ outline-offset: 3px !important;
1004
+ }
1005
+ .toggles label input[type=checkbox]:focus[data-focus-mouse=true] + .lever {
1006
+ border-color: inherit !important;
1007
+ box-shadow: none !important;
1008
+ outline: none !important;
1009
+ }
1038
1010
  .toggles label input[type=checkbox] + .lever {
1039
1011
  position: relative;
1040
1012
  content: "";
@@ -1084,9 +1056,6 @@ textarea.form-control-lg {
1084
1056
  margin-top: 0.25rem;
1085
1057
  font-size: 0.75rem;
1086
1058
  }
1087
- .form-feedback.just-validate-error-label {
1088
- color: var(--bsi-color-text-danger);
1089
- }
1090
1059
 
1091
1060
  .input-group-text:has(~ [data-focus-mouse=true]:not(.btn)),
1092
1061
  [data-focus-mouse=true]:not(.btn) ~ .input-group-text,
@@ -1108,20 +1077,44 @@ button:has(~ .is-invalid),
1108
1077
  display: none;
1109
1078
  }
1110
1079
 
1111
- .just-validate-success-field {
1112
- border-color: var(--bsi-color-border-success) !important;
1080
+ .is-valid,
1081
+ .is-invalid {
1113
1082
  padding-right: calc(1.5em + 0.75rem) !important;
1114
- 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");
1083
+ }
1084
+ .is-valid[type=number],
1085
+ .is-invalid[type=number] {
1086
+ padding-right: calc(1.5em + 0.75rem + var(--bsi-form-control-spacing) + 1rem) !important;
1115
1087
  }
1116
1088
 
1117
- .input-group-text:has(~ .just-validate-success-field),
1118
- .just-validate-success-field ~ .input-group-text,
1119
- button:has(~ .just-validate-success-field),
1120
- .just-validate-success-field + button {
1089
+ .was-validated &:valid,
1090
+ .is-valid {
1091
+ border-color: var(--bsi-color-border-success) !important;
1092
+ background-image: url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="%23008055" xmlns="http://www.w3.org/2000/svg"><path d="M9.6,16.9L4,11.4l0.8-0.7l4.8,4.8l8.5-8.4l0.7,0.7L9.6,16.9z" /></svg>');
1093
+ }
1094
+ .was-validated &:valid ~ .warning-feedback,
1095
+ .is-valid ~ .warning-feedback {
1096
+ display: block;
1097
+ }
1098
+
1099
+ .was-validated &:invalid,
1100
+ .is-invalid {
1101
+ border-color: var(--bsi-color-border-danger) !important;
1102
+ background-image: url('data:image/svg+xml,<svg width="24" fill="%23cc334d" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12.7,12l6.7,6.6l-0.8,0.8L12,12.7l-6.6,6.7l-0.8-0.8l6.7-6.6L4.6,5.4l0.8-0.8l6.6,6.7l6.6-6.7l0.8,0.8L12.7,12z" /></svg>');
1103
+ }
1104
+
1105
+ .form-control.warning {
1106
+ border-color: var(--bsi-color-border-warning) !important;
1107
+ background-image: url('data:image/svg+xml,<svg width="24" height="24" fill="%23995c00" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12.5,17h-1V2h1V17z M12.5,20h-1v2h1V20z" /></svg>');
1108
+ }
1109
+
1110
+ .input-group-text:has(~ .is-valid),
1111
+ .is-valid ~ .input-group-text,
1112
+ button:has(~ .is-valid),
1113
+ .is-valid + button {
1121
1114
  border-color: var(--bsi-color-border-success);
1122
1115
  }
1123
1116
 
1124
- .just-validate-success-field + .input-group-text.align-buttons,
1117
+ .is-valid + .input-group-text.align-buttons,
1125
1118
  .is-invalid + .input-group-text.align-buttons {
1126
1119
  right: 30px;
1127
1120
  }
@@ -1130,33 +1123,12 @@ button:has(~ .just-validate-success-field),
1130
1123
  bottom: 22px;
1131
1124
  }
1132
1125
 
1133
- .autocomplete__wrapper .form-feedback.just-validate-error-label {
1126
+ .autocomplete__wrapper .form-feedback {
1134
1127
  position: absolute;
1135
1128
  }
1136
1129
 
1137
1130
  textarea.form-control {
1138
- background-position: top 0.3em right 0.3em !important;
1139
- background-size: 37px 30% !important;
1140
- }
1141
- textarea.is-invalid {
1142
- border-bottom-style: solid;
1143
- border-bottom-width: 1px;
1144
- }
1145
- textarea.just-validate-success-field {
1146
- border-bottom-style: solid;
1147
- border-bottom-width: 1px;
1148
- }
1149
-
1150
- input[type=checkbox].is-invalid,
1151
- input[type=radio].is-invalid {
1152
- --bsi-form-checkbox-border-color: var(--bsi-color-border-danger);
1153
- }
1154
-
1155
- select.is-invalid {
1156
- border: 1px solid var(--bsi-color-border-danger);
1157
- }
1158
- select.just-validate-success-field {
1159
- border: 1px solid var(--bsi-color-border-success);
1131
+ background-position: top 0.5em right !important;
1160
1132
  }
1161
1133
 
1162
1134
  ::part(checkbox):focus:focus-visible {
@@ -1176,6 +1148,12 @@ select.just-validate-success-field {
1176
1148
  box-shadow: none !important;
1177
1149
  outline: none !important;
1178
1150
  }
1151
+ .toggles label:has(input[type=checkbox]:focus-visible) {
1152
+ border-color: hsl(0, 0%, 0%) !important;
1153
+ box-shadow: 0 0 0 2px var(--bsi-color-border-inverse), 0 0 0 5px var(--bsi-color-outline-focus) !important;
1154
+ outline: 3px solid transparent !important;
1155
+ outline-offset: 3px !important;
1156
+ }
1179
1157
  .toggles label:has(input[type=checkbox]:focus-visible) input,
1180
1158
  .toggles label:has(input[type=checkbox]:focus-visible) .lever {
1181
1159
  border-color: inherit !important;
@@ -1 +1 @@
1
- {"version":3,"file":"it-toggle.js","sources":["../../../src/it-toggle.ts"],"sourcesContent":["import { customElement } from 'lit/decorators.js';\nimport { html } from 'lit';\nimport { ItCheckboxBase } from '@italia/checkbox/it-checkbox-base.js';\n\nimport styles from './toggle.scss';\n\n/**\n * @element it-toggle\n */\n@customElement('it-toggle')\nexport class ItToggle extends ItCheckboxBase {\n static override styles = [ItCheckboxBase.styles, styles];\n\n type = 'checkbox'; // Toggle is still a checkbox input type\n\n override render() {\n const supportTextId = `${this._id}-support-text`;\n\n const supportTextRender = this.getSupportTextRender(supportTextId);\n\n const showValidation = this.formControlController.submittedOnce || this.customValidation; // true; // this._touched || this.customValidation ;\n const validityMessage = (showValidation ? (this.validationMessage ?? '') : '') ?? '';\n\n const invalid =\n validityMessage?.length > 0 || (!this.customValidation && this.inputElement?.checkValidity() === false);\n\n const validityMessageRender = this.getValidityMessageRender(validityMessage);\n\n const wrapperClasses = this.getWrapperClasses();\n return html`\n <div class=\"${wrapperClasses}\" part=\"toggle-wrapper input-wrapper\">\n <div class=\"toggles\">\n <label for=\"${this._id}\" part=\"label focusable\">\n <slot name=\"label\"></slot>\n ${this._renderInput(supportTextId, invalid, validityMessage)}\n <span class=\"lever\"></span>\n </label>\n </div>\n ${validityMessageRender} ${supportTextRender}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'it-toggle': ItToggle;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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a,IAAI,IAAI,CAAC,gBAAgB;QACxF,MAAM,eAAe,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,iBAAiB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE;QAEpF,MAAM,OAAO,GACX,eAAe,EAAE,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,YAAY,EAAE,aAAa,EAAE,KAAK,KAAK,CAAC;QAEzG,MAAM,qBAAqB,GAAG,IAAI,CAAC,wBAAwB,CAAC,eAAe,CAAC;AAE5E,QAAA,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE;AAC/C,QAAA,OAAO,IAAI,CAAA;oBACK,cAAc,CAAA;;AAEV,sBAAA,EAAA,IAAI,CAAC,GAAG,CAAA;;cAElB,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC;;;;AAI9D,QAAA,EAAA,qBAAqB,IAAI,iBAAiB;;KAE/C;IACH;;AA9BgB,QAAA,CAAA,MAAM,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAjC;AADX,QAAQ,GAAA,UAAA,CAAA;IADpB,aAAa,CAAC,WAAW;AACb,CAAA,EAAA,QAAQ,CAgCpB;;;;"}
1
+ {"version":3,"file":"it-toggle.js","sources":["../../../src/it-toggle.ts"],"sourcesContent":["import { customElement } from 'lit/decorators.js';\nimport { html } from 'lit';\nimport { ItCheckboxBase } from '@italia/checkbox/it-checkbox-base.js';\n\nimport styles from './toggle.scss';\n\n/**\n * @element it-toggle\n */\n@customElement('it-toggle')\nexport class ItToggle extends ItCheckboxBase {\n static override styles = [ItCheckboxBase.styles, styles];\n\n type = 'checkbox'; // Toggle is still a checkbox input type\n\n override render() {\n const supportTextId = `${this._id}-support-text`;\n\n const supportTextRender = this.getSupportTextRender(supportTextId);\n\n const showValidation = this.formControlController.submittedOnce || this.customValidation; // true; // this._touched || this.customValidation ;\n const validityMessage = (showValidation ? (this.validationMessage ?? '') : '') ?? '';\n\n const invalid =\n validityMessage?.length > 0 || (!this.customValidation && this.inputElement?.checkValidity() === false);\n\n const validityMessageRender = this.getValidityMessageRender(validityMessage);\n\n const wrapperClasses = this.getWrapperClasses();\n return html`\n <div class=\"${wrapperClasses}\" part=\"toggle-wrapper input-wrapper\">\n <div class=\"toggles\">\n <label for=\"${this._id}\" part=\"label focusable\">\n <slot name=\"label\"></slot>\n ${this._renderInput(supportTextId, invalid, validityMessage)}\n <span class=\"lever\"></span>\n </label>\n </div>\n ${validityMessageRender} ${supportTextRender}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'it-toggle': ItToggle;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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qBAAqB,GAAG,IAAI,CAAC,wBAAwB,CAAC,eAAe,CAAC;AAE5E,QAAA,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE;AAC/C,QAAA,OAAO,IAAI,CAAA;oBACK,cAAc,CAAA;;AAEV,sBAAA,EAAA,IAAI,CAAC,GAAG,CAAA;;cAElB,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC;;;;AAI9D,QAAA,EAAA,qBAAqB,IAAI,iBAAiB;;KAE/C;IACH;;AA9BgB,QAAA,CAAA,MAAM,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAjC;AADX,QAAQ,GAAA,UAAA,CAAA;IADpB,aAAa,CAAC,WAAW;AACb,CAAA,EAAA,QAAQ,CAgCpB;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@italia/toggle",
3
3
  "description": "Web component it-toggle del Design system .italia",
4
- "version": "1.0.0-alpha.9",
4
+ "version": "1.0.0-beta.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -34,37 +34,37 @@
34
34
  "custom-elements.json",
35
35
  "styles"
36
36
  ],
37
+ "scripts": {
38
+ "analyze": "cem analyze --litelement --exclude dist",
39
+ "build": "rollup --config rollup.config.js",
40
+ "clean": "rimraf node_modules .turbo .rollup.cache dist coverage",
41
+ "prepublish": "pnpm build",
42
+ "lint": "eslint --ext .ts \"src/**/*.ts\" \"stories/**/*.ts\" \"test/**/*.ts\" && stylelint \"src/**/*.scss\" && prettier \"src/**/*.ts\" \"stories/**/*.ts\" \"test/**/*.ts\" --check",
43
+ "format": "eslint --ext .ts \"src/**/*.ts\" \"stories/**/*.ts\" \"test/**/*.ts\" --fix && stylelint \"src/**/*.scss\" --fix && prettier \"src/**/*.ts\" \"stories/**/*.ts\" \"test/**/*.ts\" --write",
44
+ "test": "wtr --coverage --node-resolve --config web-test-runner.config.js"
45
+ },
37
46
  "dependencies": {
38
- "bootstrap-italia": "3.0.0-alpha.9",
39
- "lit": "^3.3.0",
40
- "@italia/checkbox": "^1.0.0-alpha.9",
41
- "@italia/globals": "^1.0.0-alpha.9",
42
- "@italia/i18n": "^1.0.0-alpha.9"
47
+ "@italia/checkbox": "workspace:^",
48
+ "@italia/globals": "workspace:^",
49
+ "@italia/i18n": "workspace:^",
50
+ "bootstrap-italia": "catalog:",
51
+ "lit": "catalog:"
43
52
  },
44
53
  "devDependencies": {
45
54
  "@custom-elements-manifest/analyzer": "^0.10.3",
46
- "@open-wc/testing": "^4.0.0",
55
+ "@italia/test-config": "workspace:^",
56
+ "@italia/typescript-config": "workspace:^",
57
+ "@open-wc/testing": "catalog:",
47
58
  "@rollup/plugin-node-resolve": "^16.0.1",
48
59
  "@rollup/plugin-typescript": "^12.1.2",
49
- "@types/mocha": "^10.0.10",
50
- "@web/test-runner": "^0.18.2",
60
+ "@types/mocha": "catalog:",
61
+ "@web/test-runner": "catalog:",
51
62
  "rimraf": "^6.0.1",
52
63
  "rollup": "^4.42.0",
53
64
  "rollup-plugin-scss-lit": "^2.1.0",
54
- "sass": "^1.89.0",
65
+ "sass": "catalog:",
55
66
  "tslib": "^2.6.3",
56
- "typescript": "^5.5.3",
57
- "@italia/test-config": "^0.0.0",
58
- "@italia/typescript-config": "^0.0.0"
67
+ "typescript": "catalog:"
59
68
  },
60
- "customElements": "custom-elements.json",
61
- "scripts": {
62
- "analyze": "cem analyze --litelement --exclude dist",
63
- "build": "rollup --config rollup.config.js",
64
- "clean": "rimraf node_modules .turbo .rollup.cache dist coverage",
65
- "prepublish": "pnpm build",
66
- "lint": "eslint --ext .ts \"src/**/*.ts\" \"stories/**/*.ts\" \"test/**/*.ts\" && stylelint \"src/**/*.scss\" && prettier \"src/**/*.ts\" \"stories/**/*.ts\" \"test/**/*.ts\" --check",
67
- "format": "eslint --ext .ts \"src/**/*.ts\" \"stories/**/*.ts\" \"test/**/*.ts\" --fix && stylelint \"src/**/*.scss\" --fix && prettier \"src/**/*.ts\" \"stories/**/*.ts\" \"test/**/*.ts\" --write",
68
- "test": "wtr --coverage --node-resolve --config web-test-runner.config.js"
69
- }
70
- }
69
+ "customElements": "custom-elements.json"
70
+ }
@@ -1,3 +1,4 @@
1
+ @use 'bootstrap-italia/src/scss/base/config' as *;
1
2
  it-toggle {
2
3
  --it-host-display: block;
3
4
  display: var(--it-host-display);