@italia/globals 0.1.0-alpha.1 → 1.0.0-alpha.4

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.
Files changed (58) hide show
  1. package/custom-elements.json +1655 -168
  2. package/dist/src/base-component/base-component.d.ts +28 -13
  3. package/dist/src/base-component/base-component.d.ts.map +1 -1
  4. package/dist/src/base-component/base-component.js +27 -17
  5. package/dist/src/base-component/base-component.js.map +1 -1
  6. package/dist/src/controllers/aria-keyboard-accordion-controller.d.ts +15 -0
  7. package/dist/src/controllers/aria-keyboard-accordion-controller.d.ts.map +1 -0
  8. package/dist/src/controllers/aria-keyboard-accordion-controller.js +52 -0
  9. package/dist/src/controllers/aria-keyboard-accordion-controller.js.map +1 -0
  10. package/dist/src/controllers/aria-keyboard-list-controller.d.ts +18 -0
  11. package/dist/src/controllers/aria-keyboard-list-controller.d.ts.map +1 -0
  12. package/dist/src/controllers/aria-keyboard-list-controller.js +58 -0
  13. package/dist/src/controllers/aria-keyboard-list-controller.js.map +1 -0
  14. package/dist/src/controllers/collapse-controller.d.ts +12 -0
  15. package/dist/src/controllers/collapse-controller.d.ts.map +1 -0
  16. package/dist/src/controllers/collapse-controller.js +95 -0
  17. package/dist/src/controllers/collapse-controller.js.map +1 -0
  18. package/dist/src/controllers/roving-tabindex-controller.d.ts +85 -0
  19. package/dist/src/controllers/roving-tabindex-controller.d.ts.map +1 -0
  20. package/dist/src/controllers/roving-tabindex-controller.js +200 -0
  21. package/dist/src/controllers/roving-tabindex-controller.js.map +1 -0
  22. package/dist/src/form/form-control.d.ts +61 -0
  23. package/dist/src/form/form-control.d.ts.map +1 -0
  24. package/dist/src/form/form-control.js +259 -0
  25. package/dist/src/form/form-control.js.map +1 -0
  26. package/dist/src/form/form-controller.d.ts +68 -0
  27. package/dist/src/form/form-controller.d.ts.map +1 -0
  28. package/dist/src/form/form-controller.js +398 -0
  29. package/dist/src/form/form-controller.js.map +1 -0
  30. package/dist/src/form/locales/it.d.ts +4 -0
  31. package/dist/src/form/locales/it.d.ts.map +1 -0
  32. package/dist/src/form/locales/it.js +12 -0
  33. package/dist/src/form/locales/it.js.map +1 -0
  34. package/dist/src/index.d.ts +20 -4
  35. package/dist/src/index.d.ts.map +1 -1
  36. package/dist/src/index.js +18 -4
  37. package/dist/src/index.js.map +1 -1
  38. package/dist/src/mixins/validity.d.ts +19 -19
  39. package/dist/src/mixins/validity.d.ts.map +1 -1
  40. package/dist/src/mixins/validity.js +6 -68
  41. package/dist/src/mixins/validity.js.map +1 -1
  42. package/dist/src/stories/formControlReusableStories.d.ts +19 -0
  43. package/dist/src/stories/formControlReusableStories.d.ts.map +1 -0
  44. package/dist/src/stories/formControlReusableStories.js +64 -0
  45. package/dist/src/stories/formControlReusableStories.js.map +1 -0
  46. package/dist/src/stories/reusableUsageGuidelinesStories.d.ts +13 -0
  47. package/dist/src/stories/reusableUsageGuidelinesStories.d.ts.map +1 -0
  48. package/dist/src/stories/reusableUsageGuidelinesStories.js +39 -0
  49. package/dist/src/stories/reusableUsageGuidelinesStories.js.map +1 -0
  50. package/dist/src/window-manager.d.ts +20 -0
  51. package/dist/src/window-manager.d.ts.map +1 -0
  52. package/dist/src/window-manager.js +47 -0
  53. package/dist/src/window-manager.js.map +1 -0
  54. package/package.json +10 -8
  55. package/dist/src/mixins/form.d.ts +0 -363
  56. package/dist/src/mixins/form.d.ts.map +0 -1
  57. package/dist/src/mixins/form.js +0 -36
  58. package/dist/src/mixins/form.js.map +0 -1
@@ -30,11 +30,7 @@ export declare enum VALIDATION_STATUS {
30
30
  /**
31
31
  * One indicating that the value is shorter than the minimum length.
32
32
  */
33
- MINLENGTH = "minlength",
34
- /**
35
- * One indicating that the value is less than the maximum length.
36
- */
37
- MAXLENGTH = "maxlength"
33
+ MINLENGTH = "minlength"
38
34
  }
39
35
  /**
40
36
  * @param Base The base class.
@@ -83,10 +79,6 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
83
79
  * External validation.
84
80
  */
85
81
  customValidation: boolean;
86
- /**
87
- * Field is touched
88
- */
89
- _touched: boolean;
90
82
  /**
91
83
  * Checks if the value meets the constraints.
92
84
  *
@@ -99,13 +91,10 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
99
91
  * @param validityMessage The custom validity message
100
92
  */
101
93
  setCustomValidity(validityMessage: string): void;
102
- _handleBlur(): void;
103
- _handleFocus(): void;
104
- _handleClick(): void;
105
- _handleChange(e: Event): void;
106
94
  accessKey: string;
107
95
  readonly accessKeyLabel: string;
108
96
  autocapitalize: string;
97
+ autocorrect: boolean;
109
98
  dir: string;
110
99
  draggable: boolean;
111
100
  hidden: boolean;
@@ -213,6 +202,8 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
213
202
  setPointerCapture(pointerId: number): void;
214
203
  toggleAttribute(qualifiedName: string, force?: boolean): boolean;
215
204
  webkitMatchesSelector(selectors: string): boolean;
205
+ get textContent(): string;
206
+ set textContent(value: string | null);
216
207
  readonly baseURI: string;
217
208
  readonly childNodes: NodeListOf<ChildNode>;
218
209
  readonly firstChild: ChildNode | null;
@@ -225,7 +216,6 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
225
216
  readonly parentElement: HTMLElement | null;
226
217
  readonly parentNode: ParentNode | null;
227
218
  readonly previousSibling: ChildNode | null;
228
- textContent: string | null;
229
219
  appendChild<T_1 extends Node>(node: T_1): T_1;
230
220
  cloneNode(subtree?: boolean): Node;
231
221
  compareDocumentPosition(other: Node): number;
@@ -260,6 +250,7 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
260
250
  readonly DOCUMENT_POSITION_CONTAINED_BY: 16;
261
251
  readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32;
262
252
  dispatchEvent(event: Event): boolean;
253
+ ariaActiveDescendantElement: Element | null;
263
254
  ariaAtomic: string | null;
264
255
  ariaAutoComplete: string | null;
265
256
  ariaBrailleLabel: string | null;
@@ -270,21 +261,28 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
270
261
  ariaColIndex: string | null;
271
262
  ariaColIndexText: string | null;
272
263
  ariaColSpan: string | null;
264
+ ariaControlsElements: ReadonlyArray<Element> | null;
273
265
  ariaCurrent: string | null;
266
+ ariaDescribedByElements: ReadonlyArray<Element> | null;
274
267
  ariaDescription: string | null;
268
+ ariaDetailsElements: ReadonlyArray<Element> | null;
275
269
  ariaDisabled: string | null;
270
+ ariaErrorMessageElements: ReadonlyArray<Element> | null;
276
271
  ariaExpanded: string | null;
272
+ ariaFlowToElements: ReadonlyArray<Element> | null;
277
273
  ariaHasPopup: string | null;
278
274
  ariaHidden: string | null;
279
275
  ariaInvalid: string | null;
280
276
  ariaKeyShortcuts: string | null;
281
277
  ariaLabel: string | null;
278
+ ariaLabelledByElements: ReadonlyArray<Element> | null;
282
279
  ariaLevel: string | null;
283
280
  ariaLive: string | null;
284
281
  ariaModal: string | null;
285
282
  ariaMultiLine: string | null;
286
283
  ariaMultiSelectable: string | null;
287
284
  ariaOrientation: string | null;
285
+ ariaOwnsElements: ReadonlyArray<Element> | null;
288
286
  ariaPlaceholder: string | null;
289
287
  ariaPosInSet: string | null;
290
288
  ariaPressed: string | null;
@@ -342,18 +340,19 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
342
340
  onanimationend: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
343
341
  onanimationiteration: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
344
342
  onanimationstart: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
345
- onauxclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
343
+ onauxclick: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
346
344
  onbeforeinput: ((this: GlobalEventHandlers, ev: InputEvent) => any) | null;
347
- onbeforetoggle: ((this: GlobalEventHandlers, ev: Event) => any) | null;
345
+ onbeforematch: ((this: GlobalEventHandlers, ev: Event) => any) | null;
346
+ onbeforetoggle: ((this: GlobalEventHandlers, ev: ToggleEvent) => any) | null;
348
347
  onblur: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
349
348
  oncancel: ((this: GlobalEventHandlers, ev: Event) => any) | null;
350
349
  oncanplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
351
350
  oncanplaythrough: ((this: GlobalEventHandlers, ev: Event) => any) | null;
352
351
  onchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
353
- onclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
352
+ onclick: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
354
353
  onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null;
355
354
  oncontextlost: ((this: GlobalEventHandlers, ev: Event) => any) | null;
356
- oncontextmenu: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
355
+ oncontextmenu: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
357
356
  oncontextrestored: ((this: GlobalEventHandlers, ev: Event) => any) | null;
358
357
  oncopy: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
359
358
  oncuechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
@@ -401,6 +400,7 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
401
400
  onpointermove: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
402
401
  onpointerout: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
403
402
  onpointerover: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
403
+ onpointerrawupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
404
404
  onpointerup: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
405
405
  onprogress: ((this: GlobalEventHandlers, ev: ProgressEvent) => any) | null;
406
406
  onratechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
@@ -419,7 +419,7 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
419
419
  onsubmit: ((this: GlobalEventHandlers, ev: SubmitEvent) => any) | null;
420
420
  onsuspend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
421
421
  ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
422
- ontoggle: ((this: GlobalEventHandlers, ev: Event) => any) | null;
422
+ ontoggle: ((this: GlobalEventHandlers, ev: ToggleEvent) => any) | null;
423
423
  ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
424
424
  ontouchend?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
425
425
  ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"validity.d.ts","sourceRoot":"","sources":["../../../src/mixins/validity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C;;;;;;;GAOG;AAEH;;GAEG;AACH,oBAAY,iBAAiB;IAC3B;;OAEG;IACH,QAAQ,KAAK;IAEb;;OAEG;IACH,OAAO,YAAY;IAEnB;;OAEG;IACH,cAAc,aAAa;IAC3B;;OAEG;IACH,OAAO,YAAY;IAEnB;;OAEG;IACH,SAAS,cAAc;IACvB;;OAEG;IACH,SAAS,cAAc;CACxB;AAED;;;GAGG;AACH,QAAA,MAAM,aAAa,GAAI,CAAC,SAAS,WAAW,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAI9D;;;;OAIG;+BACwB,MAAM,gBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAiBvE;;OAEG;aACe,OAAO;IAEzB;;OAEG;cACgB,OAAO;IAE1B;;OAEG;qBACuB,MAAM;IAEhC;;OAEG;YACc,MAAM;IAEvB;;OAEG;cACgB,MAAM;IAEzB;;OAEG;cACgB,OAAO;IAE1B;;OAEG;eACiB,MAAM;IAE1B;;OAEG;eACiB,MAAM;IAE1B;;OA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hC;;OAEG;YACc,MAAM;IAEvB;;OAEG;cACgB,MAAM;IAEzB;;OAEG;cACgB,OAAO;IAE1B;;OAEG;eACiB,MAAM;IAE1B;;OAEG;eACiB,MAAM;IAE1B;;OAEG;sBACwB,OAAO;IAElC;;;;OAIG;iCAC0B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAgB,OAAO,GAAU,OAAO,GAAG,SAAS;IAmCvG;;;;OAIG;uCACgC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAM5C,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -31,10 +31,6 @@ export var VALIDATION_STATUS;
31
31
  * One indicating that the value is shorter than the minimum length.
32
32
  */
33
33
  VALIDATION_STATUS["MINLENGTH"] = "minlength";
34
- /**
35
- * One indicating that the value is less than the maximum length.
36
- */
37
- VALIDATION_STATUS["MAXLENGTH"] = "maxlength";
38
34
  })(VALIDATION_STATUS || (VALIDATION_STATUS = {}));
39
35
  /**
40
36
  * @param Base The base class.
@@ -42,13 +38,6 @@ export var VALIDATION_STATUS;
42
38
  */
43
39
  const ValidityMixin = (Base) => {
44
40
  class ValidityMixinImpl extends Base {
45
- constructor() {
46
- super(...arguments);
47
- /**
48
- * Field is touched
49
- */
50
- this._touched = false;
51
- }
52
41
  // Not using TypeScript `protected` due to: microsoft/TypeScript#17744
53
42
  // Using `string` instead of `VALIDATION_STATUS` until we can require TypeScript 3.8
54
43
  /**
@@ -59,11 +48,10 @@ const ValidityMixin = (Base) => {
59
48
  _getValidityMessage(state, translations) {
60
49
  return {
61
50
  [VALIDATION_STATUS.NO_ERROR]: '',
62
- [VALIDATION_STATUS.INVALID]: translations[VALIDATION_STATUS.INVALID],
63
- [VALIDATION_STATUS.ERROR_REQUIRED]: translations[VALIDATION_STATUS.ERROR_REQUIRED],
64
- [VALIDATION_STATUS.PATTERN]: translations[VALIDATION_STATUS.PATTERN],
65
- [VALIDATION_STATUS.MINLENGTH]: translations[VALIDATION_STATUS.MINLENGTH].replace('{minlength}', this.minlength.toString()),
66
- [VALIDATION_STATUS.MAXLENGTH]: translations[VALIDATION_STATUS.MAXLENGTH].replace('{maxlength}', this.maxlength.toString()),
51
+ [VALIDATION_STATUS.INVALID]: translations.validityInvalid,
52
+ [VALIDATION_STATUS.ERROR_REQUIRED]: translations.validityRequired,
53
+ [VALIDATION_STATUS.PATTERN]: translations.validityPattern,
54
+ [VALIDATION_STATUS.MINLENGTH]: translations.validityMinlength.replace('{minlength}', this.minlength.toString()),
67
55
  }[state];
68
56
  }
69
57
  /**
@@ -80,7 +68,7 @@ const ValidityMixin = (Base) => {
80
68
  let message = validity
81
69
  ? this._getValidityMessage(VALIDATION_STATUS.NO_ERROR, translations)
82
70
  : this._getValidityMessage(VALIDATION_STATUS.INVALID, translations);
83
- if (this.required || (this._value && (this.pattern || this.minlength > 0 || this.maxlength > 0))) {
71
+ if (this.required || (this._value && this.pattern)) {
84
72
  if (this.pattern) {
85
73
  const regex = new RegExp(`^${this.pattern}$`, 'u');
86
74
  validity = regex.test(this._value.toString());
@@ -88,18 +76,12 @@ const ValidityMixin = (Base) => {
88
76
  message = this._getValidityMessage(VALIDATION_STATUS.PATTERN, translations);
89
77
  }
90
78
  }
91
- if (typeof this.minlength !== 'undefined' && this.minlength > 0) {
79
+ if (typeof this.minlength !== 'undefined') {
92
80
  validity = validity && this._value.toString().length >= this.minlength;
93
81
  if (!validity) {
94
82
  message = this._getValidityMessage(VALIDATION_STATUS.MINLENGTH, translations);
95
83
  }
96
84
  }
97
- if (typeof this.maxlength !== 'undefined' && this.maxlength > 0) {
98
- validity = validity && this._value.toString().length <= this.maxlength;
99
- if (!validity) {
100
- message = this._getValidityMessage(VALIDATION_STATUS.MAXLENGTH, translations);
101
- }
102
- }
103
85
  if (this.required && !this._value) {
104
86
  validity = false;
105
87
  message = this._getValidityMessage(VALIDATION_STATUS.ERROR_REQUIRED, translations);
@@ -118,50 +100,6 @@ const ValidityMixin = (Base) => {
118
100
  this.invalid = Boolean(validityMessage);
119
101
  this.validityMessage = validityMessage;
120
102
  }
121
- _handleBlur() {
122
- this._touched = true;
123
- this.dispatchEvent(new FocusEvent('blur', { bubbles: true, composed: true }));
124
- }
125
- _handleFocus() {
126
- this.dispatchEvent(new FocusEvent('focus', { bubbles: true, composed: true }));
127
- }
128
- _handleClick() {
129
- this.dispatchEvent(new MouseEvent('click', { bubbles: true, composed: true }));
130
- }
131
- _handleChange(e) {
132
- const target = e.target;
133
- let value;
134
- if (target instanceof HTMLInputElement) {
135
- switch (target.type) {
136
- case 'checkbox':
137
- case 'radio':
138
- value = target.checked;
139
- break;
140
- case 'file':
141
- value = target.files; // FileList
142
- break;
143
- default:
144
- value = target.value;
145
- }
146
- }
147
- else if (target instanceof HTMLSelectElement) {
148
- if (target.multiple) {
149
- value = Array.from(target.selectedOptions).map((o) => o.value);
150
- }
151
- else {
152
- value = target.value;
153
- }
154
- }
155
- else {
156
- // textarea o altri input con value
157
- value = target.value;
158
- }
159
- this.dispatchEvent(new CustomEvent('change', {
160
- detail: { value, el: target },
161
- bubbles: true,
162
- composed: true,
163
- }));
164
- }
165
103
  }
166
104
  return ValidityMixinImpl;
167
105
  };
@@ -1 +1 @@
1
- {"version":3,"file":"validity.js","sourceRoot":"","sources":["../../../src/mixins/validity.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAA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O,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;aACf,CAAC,CACH,CAAC;QACJ,CAAC;KACF;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { Constructor } from '../index.js';\n/**\n * @license\n *\n * Copyright IBM Corp. 2020, 2022\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * Form validation status.\n */\nexport enum VALIDATION_STATUS {\n /**\n * One indicating no validation error.\n */\n NO_ERROR = '',\n\n /**\n * One indicating that the value is invalid (generic).\n */\n INVALID = 'invalid',\n\n /**\n * One indicating missing required value.\n */\n ERROR_REQUIRED = 'required',\n /**\n * One indicating that the value does not match the pattern.\n */\n PATTERN = 'pattern',\n\n /**\n * One indicating that the value is shorter than the minimum length.\n */\n MINLENGTH = 'minlength',\n /**\n * One indicating that the value is less than the maximum length.\n */\n MAXLENGTH = 'maxlength',\n}\n\n/**\n * @param Base The base class.\n * @returns A mix-in implementing `.setCustomValidity()` method.\n */\nconst ValidityMixin = <T extends Constructor<HTMLElement>>(Base: T) => {\n abstract class ValidityMixinImpl extends Base {\n // Not using TypeScript `protected` due to: microsoft/TypeScript#17744\n // Using `string` instead of `VALIDATION_STATUS` until we can require TypeScript 3.8\n /**\n * @param state The form validation status.\n * @returns The form validation error mesasages associated with the given status.\n * @protected\n */\n _getValidityMessage(state: string, translations: Record<string, string>) {\n return {\n [VALIDATION_STATUS.NO_ERROR]: '',\n [VALIDATION_STATUS.INVALID]: translations[VALIDATION_STATUS.INVALID],\n [VALIDATION_STATUS.ERROR_REQUIRED]: translations[VALIDATION_STATUS.ERROR_REQUIRED],\n [VALIDATION_STATUS.PATTERN]: translations[VALIDATION_STATUS.PATTERN],\n [VALIDATION_STATUS.MINLENGTH]: translations[VALIDATION_STATUS.MINLENGTH].replace(\n '{minlength}',\n this.minlength.toString(),\n ),\n [VALIDATION_STATUS.MAXLENGTH]: translations[VALIDATION_STATUS.MAXLENGTH].replace(\n '{maxlength}',\n this.maxlength.toString(),\n ),\n }[state];\n }\n\n /**\n * `true` to show the UI of the invalid state.\n */\n abstract invalid: boolean;\n\n /**\n * `true` if the value is required.\n */\n abstract required: boolean;\n\n /**\n * The validity message.\n */\n abstract validityMessage: string;\n\n /**\n * The value.\n */\n abstract _value: string;\n\n /**\n * The pattern to match to be valid.\n */\n abstract pattern?: string;\n\n /**\n * `true` if the element is disabled.\n */\n abstract disabled: boolean;\n\n /**\n * The minimum length of the value.\n */\n abstract minlength: number;\n\n /**\n * The maximum length of the value.\n */\n abstract maxlength: number;\n\n /**\n * External validation.\n */\n abstract customValidation: boolean;\n\n /**\n * Field is touched\n */\n _touched: boolean = false;\n\n /**\n * Checks if the value meets the constraints.\n *\n * @returns `true` if the value meets the constraints. `false` otherwise.\n */\n _checkValidity(translations: Record<string, string>, htmlValidity: boolean = true): boolean | undefined {\n // htmlValidity = this.inputElement.checkValidity(); //check browser validity\n if (this.customValidation) {\n return undefined;\n }\n let validity = htmlValidity;\n let message: string = validity\n ? (this._getValidityMessage(VALIDATION_STATUS.NO_ERROR, translations) as string)\n : (this._getValidityMessage(VALIDATION_STATUS.INVALID, translations) as string);\n\n if (this.required || (this._value && (this.pattern || this.minlength > 0 || this.maxlength > 0))) {\n if (this.pattern) {\n const regex = new RegExp(`^${this.pattern}$`, 'u');\n validity = regex.test(this._value.toString());\n if (!validity) {\n message = this._getValidityMessage(VALIDATION_STATUS.PATTERN, translations) as string;\n }\n }\n if (typeof this.minlength !== 'undefined' && this.minlength > 0) {\n validity = validity && this._value.toString().length >= this.minlength;\n if (!validity) {\n message = this._getValidityMessage(VALIDATION_STATUS.MINLENGTH, translations) as string;\n }\n }\n if (typeof this.maxlength !== 'undefined' && this.maxlength > 0) {\n validity = validity && this._value.toString().length <= this.maxlength;\n if (!validity) {\n message = this._getValidityMessage(VALIDATION_STATUS.MAXLENGTH, translations) as string;\n }\n }\n if (this.required && !this._value) {\n validity = false;\n message = this._getValidityMessage(VALIDATION_STATUS.ERROR_REQUIRED, translations) as string;\n }\n }\n\n this.invalid = !validity;\n this.validityMessage = message;\n return validity;\n }\n\n /**\n * Sets the given custom validity message.\n *\n * @param validityMessage The custom validity message\n */\n setCustomValidity(validityMessage: string) {\n this.invalid = Boolean(validityMessage);\n this.validityMessage = validityMessage;\n }\n\n _handleBlur() {\n this._touched = true;\n this.dispatchEvent(new FocusEvent('blur', { bubbles: true, composed: true }));\n }\n\n _handleFocus() {\n this.dispatchEvent(new FocusEvent('focus', { bubbles: true, composed: true }));\n }\n\n _handleClick() {\n this.dispatchEvent(new MouseEvent('click', { bubbles: true, composed: true }));\n }\n\n _handleChange(e: Event) {\n const target = e.target as HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n let value: unknown;\n\n if (target instanceof HTMLInputElement) {\n switch (target.type) {\n case 'checkbox':\n case 'radio':\n value = target.checked;\n break;\n case 'file':\n value = target.files; // FileList\n break;\n default:\n value = target.value;\n }\n } else if (target instanceof HTMLSelectElement) {\n if (target.multiple) {\n value = Array.from(target.selectedOptions).map((o) => o.value);\n } else {\n value = target.value;\n }\n } else {\n // textarea o altri input con value\n value = (target as any).value;\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: { value, el: target },\n bubbles: true,\n composed: true,\n }),\n );\n }\n }\n return ValidityMixinImpl;\n};\n\nexport default ValidityMixin;\n"]}
1
+ {"version":3,"file":"validity.js","sourceRoot":"","sources":["../../../src/mixins/validity.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,CAAN,IAAY,iBAwBX;AAxBD,WAAY,iBAAiB;IAC3B;;OAEG;IACH,kCAAa,CAAA;IAEb;;OAEG;IACH,wCAAmB,CAAA;IAEnB;;OAEG;IACH,gDAA2B,CAAA;IAC3B;;OAEG;IACH,wCAAmB,CAAA;IAEnB;;OAEG;IACH,4CAAuB,CAAA;AACzB,CAAC,EAxBW,iBAAiB,KAAjB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js';\n/**\n * @license\n *\n * Copyright IBM Corp. 2020, 2022\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * Form validation status.\n */\nexport enum VALIDATION_STATUS {\n /**\n * One indicating no validation error.\n */\n NO_ERROR = '',\n\n /**\n * One indicating that the value is invalid (generic).\n */\n INVALID = 'invalid',\n\n /**\n * One indicating missing required value.\n */\n ERROR_REQUIRED = 'required',\n /**\n * One indicating that the value does not match the pattern.\n */\n PATTERN = 'pattern',\n\n /**\n * One indicating that the value is shorter than the minimum length.\n */\n MINLENGTH = 'minlength',\n}\n\n/**\n * @param Base The base class.\n * @returns A mix-in implementing `.setCustomValidity()` method.\n */\nconst ValidityMixin = <T extends Constructor<HTMLElement>>(Base: T) => {\n abstract class ValidityMixinImpl extends Base {\n // Not using TypeScript `protected` due to: microsoft/TypeScript#17744\n // Using `string` instead of `VALIDATION_STATUS` until we can require TypeScript 3.8\n /**\n * @param state The form validation status.\n * @returns The form validation error mesasages associated with the given status.\n * @protected\n */\n _getValidityMessage(state: string, translations: Record<string, string>) {\n return {\n [VALIDATION_STATUS.NO_ERROR]: '',\n [VALIDATION_STATUS.INVALID]: translations.validityInvalid,\n [VALIDATION_STATUS.ERROR_REQUIRED]: translations.validityRequired,\n [VALIDATION_STATUS.PATTERN]: translations.validityPattern,\n [VALIDATION_STATUS.MINLENGTH]: translations.validityMinlength.replace('{minlength}', this.minlength.toString()),\n }[state];\n }\n\n /**\n * `true` to show the UI of the invalid state.\n */\n abstract invalid: boolean;\n\n /**\n * `true` if the value is required.\n */\n abstract required: boolean;\n\n /**\n * The validity message.\n */\n abstract validityMessage: string;\n\n /**\n * The value.\n */\n abstract _value: string;\n\n /**\n * The pattern to match to be valid.\n */\n abstract pattern?: string;\n\n /**\n * `true` if the element is disabled.\n */\n abstract disabled: boolean;\n\n /**\n * The minimum length of the value.\n */\n abstract minlength: number;\n\n /**\n * The maximum length of the value.\n */\n abstract maxlength: number;\n\n /**\n * External validation.\n */\n abstract customValidation: boolean;\n\n /**\n * Checks if the value meets the constraints.\n *\n * @returns `true` if the value meets the constraints. `false` otherwise.\n */\n _checkValidity(translations: Record<string, string>, htmlValidity: boolean = true): boolean | undefined {\n // htmlValidity = this.inputElement.checkValidity(); //check browser validity\n if (this.customValidation) {\n return undefined;\n }\n let validity = htmlValidity;\n let message: string = validity\n ? (this._getValidityMessage(VALIDATION_STATUS.NO_ERROR, translations) as string)\n : (this._getValidityMessage(VALIDATION_STATUS.INVALID, translations) as string);\n\n if (this.required || (this._value && this.pattern)) {\n if (this.pattern) {\n const regex = new RegExp(`^${this.pattern}$`, 'u');\n validity = regex.test(this._value.toString());\n if (!validity) {\n message = this._getValidityMessage(VALIDATION_STATUS.PATTERN, translations) as string;\n }\n }\n if (typeof this.minlength !== 'undefined') {\n validity = validity && this._value.toString().length >= this.minlength;\n if (!validity) {\n message = this._getValidityMessage(VALIDATION_STATUS.MINLENGTH, translations) as string;\n }\n }\n if (this.required && !this._value) {\n validity = false;\n message = this._getValidityMessage(VALIDATION_STATUS.ERROR_REQUIRED, translations) as string;\n }\n }\n\n this.invalid = !validity;\n this.validityMessage = message;\n return validity;\n }\n\n /**\n * Sets the given custom validity message.\n *\n * @param validityMessage The custom validity message\n */\n setCustomValidity(validityMessage: string) {\n this.invalid = Boolean(validityMessage);\n this.validityMessage = validityMessage;\n }\n }\n return ValidityMixinImpl;\n};\n\nexport default ValidityMixin;\n"]}
@@ -0,0 +1,19 @@
1
+ export declare const StoryFormControlMethodAndProps: ({ otherProps, otherMethods, otherEvents, componentName, }: {
2
+ otherProps?: string | undefined;
3
+ otherMethods?: string | undefined;
4
+ otherEvents?: string | undefined;
5
+ componentName?: string | undefined;
6
+ }) => {
7
+ name: string;
8
+ tags: string[];
9
+ render: () => import("lit").TemplateResult<1>;
10
+ parameters: {
11
+ viewMode: string;
12
+ docs: {
13
+ description: {
14
+ story: string;
15
+ };
16
+ };
17
+ };
18
+ };
19
+ //# sourceMappingURL=formControlReusableStories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formControlReusableStories.d.ts","sourceRoot":"","sources":["../../../src/stories/formControlReusableStories.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,8BAA8B,GAAI;;;;;CAK9C;;;;;;;;;;;;CA4DA,CAAC"}
@@ -0,0 +1,64 @@
1
+ /* eslint-disable arrow-body-style */
2
+ import { html } from 'lit';
3
+ export const StoryFormControlMethodAndProps = ({ otherProps = '', otherMethods = '', otherEvents = '', componentName = 'it-input', }) => {
4
+ return {
5
+ name: 'Proprietà, Metodi, ed Eventi accessibili via js',
6
+ tags: ['!dev'],
7
+ render: () => html `<div class="hide-preview"></div>`,
8
+ parameters: {
9
+ viewMode: 'docs', // assicura che si apra la tab Docs anziché Canvas
10
+ docs: {
11
+ description: {
12
+ story: `
13
+ Il componente espone delle proprietà, metodi, ed eventi, utili per eventuali interazioni via js.
14
+
15
+ \`\`\`html
16
+ <${componentName} ... id="myinput"></${componentName}>
17
+ \`\`\`
18
+
19
+ \`\`\`js
20
+ const myInput = document.getElementById("myInput");
21
+ const validity = myInput.validity;
22
+ const validationMessage = myInput.validationMessage;
23
+
24
+ const form = myInput.getForm();
25
+ myInput.checkValidity();
26
+ myInput.reportValidity();
27
+ myInput.setCustomValidity("Messaggio di errore");
28
+ \`\`\`
29
+
30
+ <br/>
31
+ <h4>Proprietà accessibili dall'esterno</h4>
32
+ | Nome | Descrizione |
33
+ |------|-------------|
34
+ |\`validity\`| Ritorna l'oggetto di validazione effettuata dal browser.|
35
+ |\`validationMessage\`| Ritorna il messaggio di errore in caso di validazione fallita.|
36
+ ${otherProps}
37
+
38
+ <h4>Metodi</h4>
39
+ | Nome | Descrizione | Argomenti |
40
+ |------|-------------|-----------|
41
+ |\`getForm()\`| Ritorna l'elemento del DOM corrispondente alla form di riferimento dell'input. | - |
42
+ |\`checkValidity()\`| Triggera la validazione nativa del browser sul campo, e restituisce true o false a seconda che l'input sia valido o meno. | - |
43
+ |\`reportValidity()\`| Controlla se l'elemento è valido secondo le regole di validazione del browser. Se non è valido, mostra un messaggio di errore (tooltip nativo del browser) e restituisce \`false\`. Se è valido, restituisce \`true\`. | - |
44
+ |\`setCustomValidity('')\`| Permette di impostare un messaggio di errore personalizzato passato come parametro. Se il messaggio non è vuoto, rende invalido l'elemento. Se invece il messaggio è vuoto (''), rende valido l'elemento. | message: String |
45
+ ${otherMethods}
46
+
47
+
48
+ <h4>Eventi</h4>
49
+ | Nome | Descrizione |
50
+ |------|-------------|
51
+ |\`it-input-ready\`| Quando il componente è montato e l'elemento input interno è pronto. |
52
+ |\`it-input\`| Ogni volta che il valore di input cambia per interazione da parte dell'utente |
53
+ |\`it-blur\`| Quando l'input perde il focus (blur) |
54
+ |\`it-focus\`| Quando l'input riceve il focus (focus) |
55
+ |\`it-click\`| Quando l'utente fa click sull'input |
56
+ |\`it-change\`| Quando il valore dell’input viene modificato e il browser emette \`change\` |
57
+ |\`invalid\`| Emesso dal browser quando la validazione fallisce.|
58
+ ${otherEvents}`,
59
+ },
60
+ },
61
+ },
62
+ };
63
+ };
64
+ //# sourceMappingURL=formControlReusableStories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formControlReusableStories.js","sourceRoot":"","sources":["../../../src/stories/formControlReusableStories.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,EAC7C,UAAU,GAAG,EAAE,EACf,YAAY,GAAG,EAAE,EACjB,WAAW,GAAG,EAAE,EAChB,aAAa,GAAG,UAAU,GAC3B,EAAE,EAAE;IACH,OAAO;QACL,IAAI,EAAE,iDAAiD;QACvD,IAAI,EAAE,CAAC,MAAM,CAAC;QACd,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAA,kCAAkC;QACpD,UAAU,EAAE;YACV,QAAQ,EAAE,MAAM,EAAE,kDAAkD;YACpE,IAAI,EAAE;gBACJ,WAAW,EAAE;oBACX,KAAK,EAAE;;;;GAId,aAAa,uBAAuB,aAAa;;;;;;;;;;;;;;;;;;;;EAoBlD,UAAU;;;;;;;;;EASV,YAAY;;;;;;;;;;;;;EAaZ,WAAW,EAAE;iBACN;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable arrow-body-style */\nimport { html } from 'lit';\n\nexport const StoryFormControlMethodAndProps = ({\n otherProps = '',\n otherMethods = '',\n otherEvents = '',\n componentName = 'it-input',\n}) => {\n return {\n name: 'Proprietà, Metodi, ed Eventi accessibili via js',\n tags: ['!dev'],\n render: () => html`<div class=\"hide-preview\"></div>`,\n parameters: {\n viewMode: 'docs', // assicura che si apra la tab Docs anziché Canvas\n docs: {\n description: {\n story: `\nIl componente espone delle proprietà, metodi, ed eventi, utili per eventuali interazioni via js.\n\n\\`\\`\\`html\n<${componentName} ... id=\"myinput\"></${componentName}>\n\\`\\`\\`\n\n\\`\\`\\`js\nconst myInput = document.getElementById(\"myInput\");\nconst validity = myInput.validity;\nconst validationMessage = myInput.validationMessage;\n\nconst form = myInput.getForm();\nmyInput.checkValidity();\nmyInput.reportValidity();\nmyInput.setCustomValidity(\"Messaggio di errore\");\n\\`\\`\\`\n\n<br/>\n<h4>Proprietà accessibili dall'esterno</h4>\n| Nome | Descrizione |\n|------|-------------|\n|\\`validity\\`| Ritorna l'oggetto di validazione effettuata dal browser.|\n|\\`validationMessage\\`| Ritorna il messaggio di errore in caso di validazione fallita.|\n${otherProps}\n\n<h4>Metodi</h4>\n| Nome | Descrizione | Argomenti |\n|------|-------------|-----------|\n|\\`getForm()\\`| Ritorna l'elemento del DOM corrispondente alla form di riferimento dell'input. | - |\n|\\`checkValidity()\\`| Triggera la validazione nativa del browser sul campo, e restituisce true o false a seconda che l'input sia valido o meno. | - |\n|\\`reportValidity()\\`| Controlla se l'elemento è valido secondo le regole di validazione del browser. Se non è valido, mostra un messaggio di errore (tooltip nativo del browser) e restituisce \\`false\\`. Se è valido, restituisce \\`true\\`. | - |\n|\\`setCustomValidity('')\\`| Permette di impostare un messaggio di errore personalizzato passato come parametro. Se il messaggio non è vuoto, rende invalido l'elemento. Se invece il messaggio è vuoto (''), rende valido l'elemento. | message: String |\n${otherMethods}\n\n\n<h4>Eventi</h4>\n| Nome | Descrizione |\n|------|-------------|\n|\\`it-input-ready\\`| Quando il componente è montato e l'elemento input interno è pronto. |\n|\\`it-input\\`| Ogni volta che il valore di input cambia per interazione da parte dell'utente |\n|\\`it-blur\\`| Quando l'input perde il focus (blur) |\n|\\`it-focus\\`| Quando l'input riceve il focus (focus) |\n|\\`it-click\\`| Quando l'utente fa click sull'input |\n|\\`it-change\\`| Quando il valore dell’input viene modificato e il browser emette \\`change\\` |\n|\\`invalid\\`| Emesso dal browser quando la validazione fallisce.|\n${otherEvents}`,\n },\n },\n },\n };\n};\n"]}
@@ -0,0 +1,13 @@
1
+ export declare const CollapsibleOrHiddenContentGuidelines: () => {
2
+ name: string;
3
+ tags: string[];
4
+ render: () => import("lit").TemplateResult<1>;
5
+ parameters: {
6
+ docs: {
7
+ description: {
8
+ story: string;
9
+ };
10
+ };
11
+ };
12
+ };
13
+ //# sourceMappingURL=reusableUsageGuidelinesStories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reusableUsageGuidelinesStories.d.ts","sourceRoot":"","sources":["../../../src/stories/reusableUsageGuidelinesStories.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oCAAoC;;;;;;;;;;;CAmChD,CAAC"}
@@ -0,0 +1,39 @@
1
+ /* eslint-disable arrow-body-style */
2
+ import { html } from 'lit';
3
+ export const CollapsibleOrHiddenContentGuidelines = () => {
4
+ return {
5
+ name: 'Differenza tra Collapse, Accordion e Tabs',
6
+ tags: ['!dev', '!autodocs'],
7
+ render: () => html `<div class="hide-preview"></div>`,
8
+ parameters: {
9
+ // viewMode: 'docs', // assicura che si apra la tab Docs anziché Canvas
10
+ docs: {
11
+ description: {
12
+ story: `
13
+ #### Differenza tra Collapse, Accordion e Tabs
14
+ I componenti Accordion, Tabs e Collapse funzionano tutti nascondendo sezioni di contenuto che l'utente può scegliere di visualizzare. Evitare di usare questi componenti l'uno all'interno dell'altro.
15
+
16
+ Se decidi di usare uno di questi componenti, considera quanto segue:
17
+
18
+ - L'utente ha bisogno di visualizzare più di una sezione alla volta? L'accordion può mostrare più sezioni contemporaneamente, a differenza dei tabs.
19
+
20
+ - L'utente deve passare rapidamente tra le sezioni? I tabs permettono di cambiare contenuto senza spostare le altre sezioni nella pagina, a differenza dell'accordion.
21
+
22
+ - Ci sono molte sezioni di contenuto? L'accordion può contenere più sezioni perché sono disposte verticalmente, mentre i tabs sono disposti orizzontalmente.
23
+
24
+ - Ci sono solo uno o due contenuti brevi e meno importanti? Il componente Collapse è più adatto perché visivamente più piccolo e meno prominente rispetto a un accordion o ai tabs.
25
+
26
+ <br/>
27
+
28
+ | Componente | Contenuti multipli | Visibilità | Esclusività | Uso tipico | Esempi |
29
+ |----------|--------------------|-------------|--------------|-------------|---------|
30
+ | **Collapse** | No | Singolo contenuto mostrato o nascosto | N/A | Mostrare o nascondere dettagli secondari | "Mostra dettagli", "Visualizza termini" |
31
+ | **Accordion** | Sì | Più sezioni espandibili | Solo una aperta alla volta *(consigliato)* | Raggruppare contenuti correlati in blocchi espandibili | FAQ, elenchi informativi |
32
+ | **Tabs** | Sì | Una sezione visibile alla volta | Sempre esclusiva | Organizzare viste equivalenti o alternative | Schede di impostazioni, pannelli di dati |
33
+ `,
34
+ },
35
+ },
36
+ },
37
+ };
38
+ };
39
+ //# sourceMappingURL=reusableUsageGuidelinesStories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reusableUsageGuidelinesStories.js","sourceRoot":"","sources":["../../../src/stories/reusableUsageGuidelinesStories.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,MAAM,CAAC,MAAM,oCAAoC,GAAG,GAAG,EAAE;IACvD,OAAO;QACL,IAAI,EAAE,2CAA2C;QACjD,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;QAC3B,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAA,kCAAkC;QACpD,UAAU,EAAE;YACV,uEAAuE;YACvE,IAAI,EAAE;gBACJ,WAAW,EAAE;oBACX,KAAK,EAAE;;;;;;;;;;;;;;;;;;;;;CAqBhB;iBACQ;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable arrow-body-style */\nimport { html } from 'lit';\n\nexport const CollapsibleOrHiddenContentGuidelines = () => {\n return {\n name: 'Differenza tra Collapse, Accordion e Tabs',\n tags: ['!dev', '!autodocs'],\n render: () => html`<div class=\"hide-preview\"></div>`,\n parameters: {\n // viewMode: 'docs', // assicura che si apra la tab Docs anziché Canvas\n docs: {\n description: {\n story: `\n#### Differenza tra Collapse, Accordion e Tabs\nI componenti Accordion, Tabs e Collapse funzionano tutti nascondendo sezioni di contenuto che l'utente può scegliere di visualizzare. Evitare di usare questi componenti l'uno all'interno dell'altro.\n\nSe decidi di usare uno di questi componenti, considera quanto segue:\n\n- L'utente ha bisogno di visualizzare più di una sezione alla volta? L'accordion può mostrare più sezioni contemporaneamente, a differenza dei tabs.\n\n- L'utente deve passare rapidamente tra le sezioni? I tabs permettono di cambiare contenuto senza spostare le altre sezioni nella pagina, a differenza dell'accordion.\n\n- Ci sono molte sezioni di contenuto? L'accordion può contenere più sezioni perché sono disposte verticalmente, mentre i tabs sono disposti orizzontalmente.\n\n- Ci sono solo uno o due contenuti brevi e meno importanti? Il componente Collapse è più adatto perché visivamente più piccolo e meno prominente rispetto a un accordion o ai tabs.\n\n<br/>\n\n| Componente | Contenuti multipli | Visibilità | Esclusività | Uso tipico | Esempi |\n|----------|--------------------|-------------|--------------|-------------|---------|\n| **Collapse** | No | Singolo contenuto mostrato o nascosto | N/A | Mostrare o nascondere dettagli secondari | \"Mostra dettagli\", \"Visualizza termini\" |\n| **Accordion** | Sì | Più sezioni espandibili | Solo una aperta alla volta *(consigliato)* | Raggruppare contenuti correlati in blocchi espandibili | FAQ, elenchi informativi |\n| **Tabs** | Sì | Una sezione visibile alla volta | Sempre esclusiva | Organizzare viste equivalenti o alternative | Schede di impostazioni, pannelli di dati |\n`,\n },\n },\n },\n };\n};\n"]}
@@ -0,0 +1,20 @@
1
+ export type ScrollState = {
2
+ scrollY: number;
3
+ width: number;
4
+ height: number;
5
+ };
6
+ export type ScrollCallback = (state: ScrollState, forceRecalc?: boolean) => void;
7
+ export declare class WindowManager {
8
+ private static initialized;
9
+ private static subscribers;
10
+ private static lastScrollY;
11
+ private static lastWidth;
12
+ private static lastHeight;
13
+ private static ticking;
14
+ static init(): void;
15
+ private static requestTick;
16
+ private static tick;
17
+ static subscribe(cb: ScrollCallback): void;
18
+ static unsubscribe(cb: ScrollCallback): void;
19
+ }
20
+ //# sourceMappingURL=window-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window-manager.d.ts","sourceRoot":"","sources":["../../src/window-manager.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAC7E,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;AAEjF,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAS;IAEnC,OAAO,CAAC,MAAM,CAAC,WAAW,CAA6B;IAEvD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAK;IAE/B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAK;IAE7B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAK;IAE9B,OAAO,CAAC,MAAM,CAAC,OAAO,CAAS;IAE/B,MAAM,CAAC,IAAI;IAqBX,OAAO,CAAC,MAAM,CAAC,WAAW;IAO1B,OAAO,CAAC,MAAM,CAAC,IAAI;IAUnB,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,cAAc;IAInC,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,cAAc;CAGtC"}
@@ -0,0 +1,47 @@
1
+ export class WindowManager {
2
+ static init() {
3
+ if (this.initialized)
4
+ return;
5
+ this.lastScrollY = window.scrollY;
6
+ this.lastWidth = window.innerWidth;
7
+ this.lastHeight = window.innerHeight;
8
+ window.addEventListener('scroll', () => {
9
+ this.lastScrollY = window.scrollY;
10
+ this.requestTick();
11
+ });
12
+ window.addEventListener('resize', () => {
13
+ this.lastWidth = window.innerWidth;
14
+ this.lastHeight = window.innerHeight;
15
+ this.requestTick(true); // force recalculation
16
+ });
17
+ this.initialized = true;
18
+ }
19
+ static requestTick(forceRecalc = false) {
20
+ if (!this.ticking) {
21
+ requestAnimationFrame(() => this.tick(forceRecalc));
22
+ this.ticking = true;
23
+ }
24
+ }
25
+ static tick(forceRecalc) {
26
+ this.ticking = false;
27
+ const state = {
28
+ scrollY: this.lastScrollY,
29
+ width: this.lastWidth,
30
+ height: this.lastHeight,
31
+ };
32
+ this.subscribers.forEach((cb) => cb(state, forceRecalc));
33
+ }
34
+ static subscribe(cb) {
35
+ this.subscribers.add(cb);
36
+ }
37
+ static unsubscribe(cb) {
38
+ this.subscribers.delete(cb);
39
+ }
40
+ }
41
+ WindowManager.initialized = false;
42
+ WindowManager.subscribers = new Set();
43
+ WindowManager.lastScrollY = 0;
44
+ WindowManager.lastWidth = 0;
45
+ WindowManager.lastHeight = 0;
46
+ WindowManager.ticking = false;
47
+ //# sourceMappingURL=window-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window-manager.js","sourceRoot":"","sources":["../../src/window-manager.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,aAAa;IAaxB,MAAM,CAAC,IAAI;QACT,IAAI,IAAI,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AAE,WAAW,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,EAAkB;QACjC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,EAAkB;QACnC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;;AAxDc,yBAAW,GAAG,KAAK,CAAC;AAEpB,yBAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;AAExC,yBAAW,GAAG,CAAC,CAAC;AAEhB,uBAAS,GAAG,CAAC,CAAC;AAEd,wBAAU,GAAG,CAAC,CAAC;AAEf,qBAAO,GAAG,KAAK,CAAC","sourcesContent":["export type ScrollState = { scrollY: number; width: number; height: number };\nexport type ScrollCallback = (state: ScrollState, forceRecalc?: boolean) => void;\n\nexport class WindowManager {\n private static initialized = false;\n\n private static subscribers = new Set<ScrollCallback>();\n\n private static lastScrollY = 0;\n\n private static lastWidth = 0;\n\n private static lastHeight = 0;\n\n private static ticking = false;\n\n static init() {\n if (this.initialized) return;\n\n this.lastScrollY = window.scrollY;\n this.lastWidth = window.innerWidth;\n this.lastHeight = window.innerHeight;\n\n window.addEventListener('scroll', () => {\n this.lastScrollY = window.scrollY;\n this.requestTick();\n });\n\n window.addEventListener('resize', () => {\n this.lastWidth = window.innerWidth;\n this.lastHeight = window.innerHeight;\n this.requestTick(true); // force recalculation\n });\n\n this.initialized = true;\n }\n\n private static requestTick(forceRecalc = false) {\n if (!this.ticking) {\n requestAnimationFrame(() => this.tick(forceRecalc));\n this.ticking = true;\n }\n }\n\n private static tick(forceRecalc: boolean) {\n this.ticking = false;\n const state: ScrollState = {\n scrollY: this.lastScrollY,\n width: this.lastWidth,\n height: this.lastHeight,\n };\n this.subscribers.forEach((cb) => cb(state, forceRecalc));\n }\n\n static subscribe(cb: ScrollCallback) {\n this.subscribers.add(cb);\n }\n\n static unsubscribe(cb: ScrollCallback) {\n this.subscribers.delete(cb);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@italia/globals",
3
3
  "description": "Utilities per i Web components del Design System .italia",
4
- "version": "0.1.0-alpha.1",
4
+ "version": "1.0.0-alpha.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "license": "BSD-3-Clause",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/italia/design-web-components.git",
11
+ "url": "https://github.com/italia/dev-kit-italia.git",
12
12
  "directory": "packages/button"
13
13
  },
14
14
  "author": "Presidenza del Consiglio dei Ministri",
15
- "homepage": "https://italia.github.io/design-web-components",
15
+ "homepage": "https://italia.github.io/dev-kit-italia",
16
16
  "bugs": {
17
- "url": "https://github.com/italia/design-web-components/issues"
17
+ "url": "https://github.com/italia/dev-kit-italia/issues"
18
18
  },
19
19
  "type": "module",
20
20
  "main": "./dist/src/index.js",
@@ -32,8 +32,10 @@
32
32
  "custom-elements.json"
33
33
  ],
34
34
  "dependencies": {
35
+ "@floating-ui/dom": "^1.7.1",
36
+ "clsx": "^2.1.1",
35
37
  "lit": "^3.3.0",
36
- "@italia/i18n": "^0.1.0-alpha.1"
38
+ "@italia/i18n": "^1.0.0-alpha.4"
37
39
  },
38
40
  "devDependencies": {
39
41
  "@custom-elements-manifest/analyzer": "^0.10.3",
@@ -50,9 +52,9 @@
50
52
  "scripts": {
51
53
  "analyze": "cem analyze --litelement --exclude dist",
52
54
  "build": "tsc --build tsconfig.build.json",
53
- "clean": "rimraf node_modules .turbo",
55
+ "clean": "rimraf node_modules .turbo dist",
56
+ "prepublish": "pnpm build",
54
57
  "lint": "eslint --ext .ts \"src/**/*.ts\" && prettier \"src/**/*.ts\" --check",
55
- "format": "eslint --ext .ts \"src/**/*.ts\" --fix && prettier \"src/**/*.ts\" --write",
56
- "test-disabled": "wtr --coverage --node-resolve --config web-test-runner.config.js"
58
+ "format": "eslint --ext .ts \"src/**/*.ts\" --fix && prettier \"src/**/*.ts\" --write"
57
59
  }
58
60
  }