@italia/globals 0.1.0-alpha.2 → 1.0.0-alpha.11
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/custom-elements.json +680 -166
- package/dist/src/base-component/base-component.d.ts +19 -7
- package/dist/src/base-component/base-component.d.ts.map +1 -1
- package/dist/src/controllers/focus-trap-controller.d.ts +92 -0
- package/dist/src/controllers/focus-trap-controller.d.ts.map +1 -0
- package/dist/src/controllers/focus-trap-controller.js +497 -0
- package/dist/src/controllers/focus-trap-controller.js.map +1 -0
- package/dist/src/controllers/roving-tabindex-controller.d.ts +9 -2
- package/dist/src/controllers/roving-tabindex-controller.d.ts.map +1 -1
- package/dist/src/controllers/roving-tabindex-controller.js +11 -5
- package/dist/src/controllers/roving-tabindex-controller.js.map +1 -1
- package/dist/src/form/form-control.d.ts +2 -1
- package/dist/src/form/form-control.d.ts.map +1 -1
- package/dist/src/form/form-control.js +15 -7
- package/dist/src/form/form-control.js.map +1 -1
- package/dist/src/form/form-controller.d.ts +2 -0
- package/dist/src/form/form-controller.d.ts.map +1 -1
- package/dist/src/form/form-controller.js +45 -1
- package/dist/src/form/form-controller.js.map +1 -1
- package/dist/src/form/locales/it.d.ts.map +1 -1
- package/dist/src/form/locales/it.js +1 -0
- package/dist/src/form/locales/it.js.map +1 -1
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +8 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/mixins/validity.d.ts +18 -6
- package/dist/src/mixins/validity.d.ts.map +1 -1
- package/dist/src/stories/formControlReusableStories.d.ts.map +1 -1
- package/dist/src/stories/formControlReusableStories.js +5 -4
- package/dist/src/stories/formControlReusableStories.js.map +1 -1
- package/dist/src/window-manager.d.ts +13 -0
- package/dist/src/window-manager.d.ts.map +1 -1
- package/dist/src/window-manager.js +31 -0
- package/dist/src/window-manager.js.map +1 -1
- package/package.json +2 -2
|
@@ -94,6 +94,7 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
|
|
|
94
94
|
accessKey: string;
|
|
95
95
|
readonly accessKeyLabel: string;
|
|
96
96
|
autocapitalize: string;
|
|
97
|
+
autocorrect: boolean;
|
|
97
98
|
dir: string;
|
|
98
99
|
draggable: boolean;
|
|
99
100
|
hidden: boolean;
|
|
@@ -201,6 +202,8 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
|
|
|
201
202
|
setPointerCapture(pointerId: number): void;
|
|
202
203
|
toggleAttribute(qualifiedName: string, force?: boolean): boolean;
|
|
203
204
|
webkitMatchesSelector(selectors: string): boolean;
|
|
205
|
+
get textContent(): string;
|
|
206
|
+
set textContent(value: string | null);
|
|
204
207
|
readonly baseURI: string;
|
|
205
208
|
readonly childNodes: NodeListOf<ChildNode>;
|
|
206
209
|
readonly firstChild: ChildNode | null;
|
|
@@ -213,7 +216,6 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
|
|
|
213
216
|
readonly parentElement: HTMLElement | null;
|
|
214
217
|
readonly parentNode: ParentNode | null;
|
|
215
218
|
readonly previousSibling: ChildNode | null;
|
|
216
|
-
textContent: string | null;
|
|
217
219
|
appendChild<T_1 extends Node>(node: T_1): T_1;
|
|
218
220
|
cloneNode(subtree?: boolean): Node;
|
|
219
221
|
compareDocumentPosition(other: Node): number;
|
|
@@ -248,6 +250,7 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
|
|
|
248
250
|
readonly DOCUMENT_POSITION_CONTAINED_BY: 16;
|
|
249
251
|
readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32;
|
|
250
252
|
dispatchEvent(event: Event): boolean;
|
|
253
|
+
ariaActiveDescendantElement: Element | null;
|
|
251
254
|
ariaAtomic: string | null;
|
|
252
255
|
ariaAutoComplete: string | null;
|
|
253
256
|
ariaBrailleLabel: string | null;
|
|
@@ -258,21 +261,28 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
|
|
|
258
261
|
ariaColIndex: string | null;
|
|
259
262
|
ariaColIndexText: string | null;
|
|
260
263
|
ariaColSpan: string | null;
|
|
264
|
+
ariaControlsElements: ReadonlyArray<Element> | null;
|
|
261
265
|
ariaCurrent: string | null;
|
|
266
|
+
ariaDescribedByElements: ReadonlyArray<Element> | null;
|
|
262
267
|
ariaDescription: string | null;
|
|
268
|
+
ariaDetailsElements: ReadonlyArray<Element> | null;
|
|
263
269
|
ariaDisabled: string | null;
|
|
270
|
+
ariaErrorMessageElements: ReadonlyArray<Element> | null;
|
|
264
271
|
ariaExpanded: string | null;
|
|
272
|
+
ariaFlowToElements: ReadonlyArray<Element> | null;
|
|
265
273
|
ariaHasPopup: string | null;
|
|
266
274
|
ariaHidden: string | null;
|
|
267
275
|
ariaInvalid: string | null;
|
|
268
276
|
ariaKeyShortcuts: string | null;
|
|
269
277
|
ariaLabel: string | null;
|
|
278
|
+
ariaLabelledByElements: ReadonlyArray<Element> | null;
|
|
270
279
|
ariaLevel: string | null;
|
|
271
280
|
ariaLive: string | null;
|
|
272
281
|
ariaModal: string | null;
|
|
273
282
|
ariaMultiLine: string | null;
|
|
274
283
|
ariaMultiSelectable: string | null;
|
|
275
284
|
ariaOrientation: string | null;
|
|
285
|
+
ariaOwnsElements: ReadonlyArray<Element> | null;
|
|
276
286
|
ariaPlaceholder: string | null;
|
|
277
287
|
ariaPosInSet: string | null;
|
|
278
288
|
ariaPressed: string | null;
|
|
@@ -330,18 +340,19 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
|
|
|
330
340
|
onanimationend: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
|
|
331
341
|
onanimationiteration: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
|
|
332
342
|
onanimationstart: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
|
|
333
|
-
onauxclick: ((this: GlobalEventHandlers, ev:
|
|
343
|
+
onauxclick: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
334
344
|
onbeforeinput: ((this: GlobalEventHandlers, ev: InputEvent) => any) | null;
|
|
335
|
-
|
|
345
|
+
onbeforematch: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
346
|
+
onbeforetoggle: ((this: GlobalEventHandlers, ev: ToggleEvent) => any) | null;
|
|
336
347
|
onblur: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
|
|
337
348
|
oncancel: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
338
349
|
oncanplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
339
350
|
oncanplaythrough: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
340
351
|
onchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
341
|
-
onclick: ((this: GlobalEventHandlers, ev:
|
|
352
|
+
onclick: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
342
353
|
onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
343
354
|
oncontextlost: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
344
|
-
oncontextmenu: ((this: GlobalEventHandlers, ev:
|
|
355
|
+
oncontextmenu: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
345
356
|
oncontextrestored: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
346
357
|
oncopy: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
347
358
|
oncuechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
@@ -389,6 +400,7 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
|
|
|
389
400
|
onpointermove: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
390
401
|
onpointerout: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
391
402
|
onpointerover: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
403
|
+
onpointerrawupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
392
404
|
onpointerup: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
|
|
393
405
|
onprogress: ((this: GlobalEventHandlers, ev: ProgressEvent) => any) | null;
|
|
394
406
|
onratechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
@@ -407,7 +419,7 @@ declare const ValidityMixin: <T extends Constructor<HTMLElement>>(Base: T) => (a
|
|
|
407
419
|
onsubmit: ((this: GlobalEventHandlers, ev: SubmitEvent) => any) | null;
|
|
408
420
|
onsuspend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
409
421
|
ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
410
|
-
ontoggle: ((this: GlobalEventHandlers, ev:
|
|
422
|
+
ontoggle: ((this: GlobalEventHandlers, ev: ToggleEvent) => any) | null;
|
|
411
423
|
ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
412
424
|
ontouchend?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
413
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;CACxB;AAED;;;GAGG;AACH,QAAA,MAAM,aAAa,GAAI,CAAC,SAAS,WAAW,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAI9D;;;;OAI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MAAM,CAAC,iBAAgB,OAAO,GAAU,OAAO,GAAG,SAAS;IAmCvG;;;;OAIG;uCACgC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAM5C,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formControlReusableStories.d.ts","sourceRoot":"","sources":["../../../src/stories/formControlReusableStories.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,8BAA8B,GAAI;;;;;CAK9C;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"formControlReusableStories.d.ts","sourceRoot":"","sources":["../../../src/stories/formControlReusableStories.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,8BAA8B,GAAI;;;;;CAK9C;;;;;;;;;;;;CA4DA,CAAC"}
|
|
@@ -9,7 +9,8 @@ export const StoryFormControlMethodAndProps = ({ otherProps = '', otherMethods =
|
|
|
9
9
|
viewMode: 'docs', // assicura che si apra la tab Docs anziché Canvas
|
|
10
10
|
docs: {
|
|
11
11
|
description: {
|
|
12
|
-
story: `
|
|
12
|
+
story: `
|
|
13
|
+
Il componente espone delle proprietà, metodi, ed eventi, utili per eventuali interazioni via js.
|
|
13
14
|
|
|
14
15
|
\`\`\`html
|
|
15
16
|
<${componentName} ... id="myinput"></${componentName}>
|
|
@@ -27,14 +28,14 @@ myInput.setCustomValidity("Messaggio di errore");
|
|
|
27
28
|
\`\`\`
|
|
28
29
|
|
|
29
30
|
<br/>
|
|
30
|
-
<
|
|
31
|
+
<h3>Proprietà accessibili dall'esterno</h3>
|
|
31
32
|
| Nome | Descrizione |
|
|
32
33
|
|------|-------------|
|
|
33
34
|
|\`validity\`| Ritorna l'oggetto di validazione effettuata dal browser.|
|
|
34
35
|
|\`validationMessage\`| Ritorna il messaggio di errore in caso di validazione fallita.|
|
|
35
36
|
${otherProps}
|
|
36
37
|
|
|
37
|
-
<
|
|
38
|
+
<h3>Metodi</h3>
|
|
38
39
|
| Nome | Descrizione | Argomenti |
|
|
39
40
|
|------|-------------|-----------|
|
|
40
41
|
|\`getForm()\`| Ritorna l'elemento del DOM corrispondente alla form di riferimento dell'input. | - |
|
|
@@ -44,7 +45,7 @@ ${otherProps}
|
|
|
44
45
|
${otherMethods}
|
|
45
46
|
|
|
46
47
|
|
|
47
|
-
<
|
|
48
|
+
<h3>Eventi</h3>
|
|
48
49
|
| Nome | Descrizione |
|
|
49
50
|
|------|-------------|
|
|
50
51
|
|\`it-input-ready\`| Quando il componente è montato e l'elemento input interno è pronto. |
|
|
@@ -1 +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
|
|
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<h3>Proprietà accessibili dall'esterno</h3>\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<h3>Metodi</h3>\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<h3>Eventi</h3>\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"]}
|
|
@@ -11,10 +11,23 @@ export declare class WindowManager {
|
|
|
11
11
|
private static lastWidth;
|
|
12
12
|
private static lastHeight;
|
|
13
13
|
private static ticking;
|
|
14
|
+
private static scrollLockCount;
|
|
15
|
+
private static scrollbarWidth;
|
|
14
16
|
static init(): void;
|
|
15
17
|
private static requestTick;
|
|
16
18
|
private static tick;
|
|
17
19
|
static subscribe(cb: ScrollCallback): void;
|
|
18
20
|
static unsubscribe(cb: ScrollCallback): void;
|
|
21
|
+
/**
|
|
22
|
+
* Blocca lo scroll del body. Usa ref counting per gestire modal nested.
|
|
23
|
+
* Chiamare unlockBodyScroll() per ogni lockBodyScroll().
|
|
24
|
+
*/
|
|
25
|
+
static lockBodyScroll(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Sblocca lo scroll del body. Rimuove il lock solo quando tutti i consumer hanno chiamato unlock.
|
|
28
|
+
*/
|
|
29
|
+
static unlockBodyScroll(): void;
|
|
30
|
+
/** Ritorna la larghezza della scrollbar (utile per compensazioni) */
|
|
31
|
+
static getScrollbarWidth(): number;
|
|
19
32
|
}
|
|
20
33
|
//# sourceMappingURL=window-manager.d.ts.map
|
|
@@ -1 +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;
|
|
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;IAG/B,OAAO,CAAC,MAAM,CAAC,eAAe,CAAK;IAEnC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAK;IAElC,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;IAIrC;;;OAGG;IACH,MAAM,CAAC,cAAc,IAAI,IAAI;IAU7B;;OAEG;IACH,MAAM,CAAC,gBAAgB,IAAI,IAAI;IAS/B,qEAAqE;IACrE,MAAM,CAAC,iBAAiB,IAAI,MAAM;CAGnC"}
|
|
@@ -37,6 +37,34 @@ export class WindowManager {
|
|
|
37
37
|
static unsubscribe(cb) {
|
|
38
38
|
this.subscribers.delete(cb);
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Blocca lo scroll del body. Usa ref counting per gestire modal nested.
|
|
42
|
+
* Chiamare unlockBodyScroll() per ogni lockBodyScroll().
|
|
43
|
+
*/
|
|
44
|
+
static lockBodyScroll() {
|
|
45
|
+
this.scrollLockCount += 1;
|
|
46
|
+
if (this.scrollLockCount === 1) {
|
|
47
|
+
this.scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
48
|
+
document.body.classList.add('modal-open');
|
|
49
|
+
document.body.style.overflow = 'hidden';
|
|
50
|
+
document.body.style.paddingRight = `${this.scrollbarWidth}px`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Sblocca lo scroll del body. Rimuove il lock solo quando tutti i consumer hanno chiamato unlock.
|
|
55
|
+
*/
|
|
56
|
+
static unlockBodyScroll() {
|
|
57
|
+
this.scrollLockCount = Math.max(0, this.scrollLockCount - 1);
|
|
58
|
+
if (this.scrollLockCount === 0) {
|
|
59
|
+
document.body.classList.remove('modal-open');
|
|
60
|
+
document.body.style.overflow = '';
|
|
61
|
+
document.body.style.paddingRight = '';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** Ritorna la larghezza della scrollbar (utile per compensazioni) */
|
|
65
|
+
static getScrollbarWidth() {
|
|
66
|
+
return this.scrollbarWidth || window.innerWidth - document.documentElement.clientWidth;
|
|
67
|
+
}
|
|
40
68
|
}
|
|
41
69
|
WindowManager.initialized = false;
|
|
42
70
|
WindowManager.subscribers = new Set();
|
|
@@ -44,4 +72,7 @@ WindowManager.lastScrollY = 0;
|
|
|
44
72
|
WindowManager.lastWidth = 0;
|
|
45
73
|
WindowManager.lastHeight = 0;
|
|
46
74
|
WindowManager.ticking = false;
|
|
75
|
+
// Body scroll lock (ref counting per modal nested)
|
|
76
|
+
WindowManager.scrollLockCount = 0;
|
|
77
|
+
WindowManager.scrollbarWidth = 0;
|
|
47
78
|
//# sourceMappingURL=window-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window-manager.js","sourceRoot":"","sources":["../../src/window-manager.ts"],"names":[],"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AAK,CAAC,QAAQ,GAAG,EAAE,CAAC;YAClC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,EAAE,CAAC;QACxC,CAAC;IACH,CAAC;IAED,qEAAqE;IACrE,MAAM,CAAC,iBAAiB;QACtB,OAAO,IAAI,CAAC,cAAc,IAAI,MAAM,CAAC,UAAU,GAAG,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC;IACzF,CAAC;;AA5Fc,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;AAE/B,mDAAmD;AACpC,6BAAe,GAAG,CAAC,CAAC;AAEpB,4BAAc,GAAG,CAAC,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 // Body scroll lock (ref counting per modal nested)\n private static scrollLockCount = 0;\n\n private static scrollbarWidth = 0;\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 /**\n * Blocca lo scroll del body. Usa ref counting per gestire modal nested.\n * Chiamare unlockBodyScroll() per ogni lockBodyScroll().\n */\n static lockBodyScroll(): void {\n this.scrollLockCount += 1;\n if (this.scrollLockCount === 1) {\n this.scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;\n document.body.classList.add('modal-open');\n document.body.style.overflow = 'hidden';\n document.body.style.paddingRight = `${this.scrollbarWidth}px`;\n }\n }\n\n /**\n * Sblocca lo scroll del body. Rimuove il lock solo quando tutti i consumer hanno chiamato unlock.\n */\n static unlockBodyScroll(): void {\n this.scrollLockCount = Math.max(0, this.scrollLockCount - 1);\n if (this.scrollLockCount === 0) {\n document.body.classList.remove('modal-open');\n document.body.style.overflow = '';\n document.body.style.paddingRight = '';\n }\n }\n\n /** Ritorna la larghezza della scrollbar (utile per compensazioni) */\n static getScrollbarWidth(): number {\n return this.scrollbarWidth || window.innerWidth - document.documentElement.clientWidth;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@italia/globals",
|
|
3
3
|
"description": "Utilities per i Web components del Design System .italia",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.0.0-alpha.11",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@floating-ui/dom": "^1.7.1",
|
|
36
36
|
"clsx": "^2.1.1",
|
|
37
37
|
"lit": "^3.3.0",
|
|
38
|
-
"@italia/i18n": "^
|
|
38
|
+
"@italia/i18n": "^1.0.0-alpha.11"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@custom-elements-manifest/analyzer": "^0.10.3",
|