@italia/toggle 1.0.0-beta.0 → 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",
@@ -543,8 +543,8 @@ input::-webkit-datetime-edit {
543
543
  .form-check [type=checkbox],
544
544
  .form-check [type=radio] {
545
545
  position: absolute;
546
- top: 9px;
547
- left: 9px;
546
+ top: 0;
547
+ left: 0;
548
548
  width: auto;
549
549
  margin-top: 0;
550
550
  margin-left: 0;
@@ -625,6 +625,9 @@ input::-webkit-datetime-edit {
625
625
  height: 0;
626
626
  border-color: transparent;
627
627
  }
628
+ .form-check input[type=checkbox] + label:hover::after {
629
+ border-color: var(--bsi-color-border-secondary-hover);
630
+ }
628
631
  .form-check input[type=checkbox]:disabled + label {
629
632
  opacity: 1;
630
633
  cursor: not-allowed;
@@ -666,6 +669,9 @@ input::-webkit-datetime-edit {
666
669
  .form-check input[type=radio]:checked + label::before {
667
670
  border-color: var(--bsi-form-checked-color);
668
671
  }
672
+ .form-check input[type=radio] + label:hover::before {
673
+ border-color: var(--bsi-color-border-secondary-hover);
674
+ }
669
675
  .form-check input[type=radio]:disabled + label {
670
676
  cursor: not-allowed;
671
677
  }
@@ -770,7 +776,7 @@ input::-webkit-datetime-edit {
770
776
  .form-control {
771
777
  background-repeat: no-repeat;
772
778
  background-position: center right;
773
- background-size: 45px 30%;
779
+ background-size: 45px 20px;
774
780
  }
775
781
  .form-control:disabled {
776
782
  cursor: not-allowed;
@@ -778,20 +784,6 @@ input::-webkit-datetime-edit {
778
784
  border: 0;
779
785
  color: var(--bsi-color-text-disabled);
780
786
  }
781
- .was-validated .form-control:valid, .form-control.is-valid {
782
- 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");
783
- }
784
- .was-validated .form-control:invalid, .form-control.is-invalid {
785
- 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");
786
- border-color: var(--bsi-color-border-danger);
787
- }
788
- .form-control.warning {
789
- 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;
790
- border-color: var(--bsi-color-border-warning);
791
- }
792
- .form-control.is-valid ~ .warning-feedback {
793
- display: block;
794
- }
795
787
 
796
788
  .form-control-sm {
797
789
  --bsi-form-control-spacing: var(--bsi-spacing-xxs) var(--bsi-spacing-3xs);
@@ -1064,9 +1056,6 @@ textarea.form-control-lg {
1064
1056
  margin-top: 0.25rem;
1065
1057
  font-size: 0.75rem;
1066
1058
  }
1067
- .form-feedback.just-validate-error-label {
1068
- color: var(--bsi-color-text-danger);
1069
- }
1070
1059
 
1071
1060
  .input-group-text:has(~ [data-focus-mouse=true]:not(.btn)),
1072
1061
  [data-focus-mouse=true]:not(.btn) ~ .input-group-text,
@@ -1088,20 +1077,44 @@ button:has(~ .is-invalid),
1088
1077
  display: none;
1089
1078
  }
1090
1079
 
1091
- .just-validate-success-field {
1092
- border-color: var(--bsi-color-border-success) !important;
1080
+ .is-valid,
1081
+ .is-invalid {
1093
1082
  padding-right: calc(1.5em + 0.75rem) !important;
1094
- 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;
1095
1087
  }
1096
1088
 
1097
- .input-group-text:has(~ .just-validate-success-field),
1098
- .just-validate-success-field ~ .input-group-text,
1099
- button:has(~ .just-validate-success-field),
1100
- .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 {
1101
1114
  border-color: var(--bsi-color-border-success);
1102
1115
  }
1103
1116
 
1104
- .just-validate-success-field + .input-group-text.align-buttons,
1117
+ .is-valid + .input-group-text.align-buttons,
1105
1118
  .is-invalid + .input-group-text.align-buttons {
1106
1119
  right: 30px;
1107
1120
  }
@@ -1110,33 +1123,12 @@ button:has(~ .just-validate-success-field),
1110
1123
  bottom: 22px;
1111
1124
  }
1112
1125
 
1113
- .autocomplete__wrapper .form-feedback.just-validate-error-label {
1126
+ .autocomplete__wrapper .form-feedback {
1114
1127
  position: absolute;
1115
1128
  }
1116
1129
 
1117
1130
  textarea.form-control {
1118
- background-position: top 0.3em right 0.3em !important;
1119
- background-size: 37px 30% !important;
1120
- }
1121
- textarea.is-invalid {
1122
- border-bottom-style: solid;
1123
- border-bottom-width: 1px;
1124
- }
1125
- textarea.just-validate-success-field {
1126
- border-bottom-style: solid;
1127
- border-bottom-width: 1px;
1128
- }
1129
-
1130
- input[type=checkbox].is-invalid,
1131
- input[type=radio].is-invalid {
1132
- --bsi-form-checkbox-border-color: var(--bsi-color-border-danger);
1133
- }
1134
-
1135
- select.is-invalid {
1136
- border: 1px solid var(--bsi-color-border-danger);
1137
- }
1138
- select.just-validate-success-field {
1139
- border: 1px solid var(--bsi-color-border-success);
1131
+ background-position: top 0.5em right !important;
1140
1132
  }
1141
1133
 
1142
1134
  ::part(checkbox):focus:focus-visible {
@@ -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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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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oB,CAAC,aAAa,CAAC;QAElE,MAAM,cAAc,GAAG,IAAI,CAAC,qBAAqB,CAAC,aAAa,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;;;;"}
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-beta.0",
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-beta.1",
39
- "lit": "^3.3.0",
40
- "@italia/checkbox": "^1.0.0-beta.0",
41
- "@italia/globals": "^1.0.0-beta.0",
42
- "@italia/i18n": "^1.0.0-beta.0"
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": "^1.0.0-beta.0",
58
- "@italia/typescript-config": "^1.0.0-beta.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
+ }