@italia/globals 1.0.0-alpha.16 → 1.0.0-alpha.18
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 +8 -0
- package/dist/src/base-component/base-component.d.ts +2 -0
- package/dist/src/base-component/base-component.d.ts.map +1 -1
- package/dist/src/base-component/base-component.js +20 -0
- package/dist/src/base-component/base-component.js.map +1 -1
- package/dist/src/controllers/focus-trap-controller.d.ts.map +1 -1
- package/dist/src/controllers/focus-trap-controller.js +1 -0
- package/dist/src/controllers/focus-trap-controller.js.map +1 -1
- package/dist/src/directives/setAttributes.d.ts.map +1 -1
- package/dist/src/directives/setAttributes.js +69 -3
- package/dist/src/directives/setAttributes.js.map +1 -1
- package/dist/src/form/form-control.js +1 -1
- package/dist/src/form/form-control.js.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/package.json +2 -2
package/custom-elements.json
CHANGED
|
@@ -423,6 +423,14 @@
|
|
|
423
423
|
},
|
|
424
424
|
"privacy": "protected"
|
|
425
425
|
},
|
|
426
|
+
{
|
|
427
|
+
"kind": "field",
|
|
428
|
+
"name": "ariaAttributesObserver",
|
|
429
|
+
"type": {
|
|
430
|
+
"text": "MutationObserver | undefined"
|
|
431
|
+
},
|
|
432
|
+
"privacy": "protected"
|
|
433
|
+
},
|
|
426
434
|
{
|
|
427
435
|
"kind": "field",
|
|
428
436
|
"name": "_ariaAttributes",
|
|
@@ -15,6 +15,7 @@ export declare class BaseComponent extends LitElement {
|
|
|
15
15
|
protected logger: Logger;
|
|
16
16
|
protected composeClass: typeof clsx;
|
|
17
17
|
protected _id?: string;
|
|
18
|
+
protected ariaAttributesObserver?: MutationObserver;
|
|
18
19
|
constructor();
|
|
19
20
|
protected get _ariaAttributes(): Record<string, string>;
|
|
20
21
|
generateId(prefix: string): string;
|
|
@@ -23,6 +24,7 @@ export declare class BaseComponent extends LitElement {
|
|
|
23
24
|
get focusElement(): HTMLElement | null;
|
|
24
25
|
protected get prefersReducedMotion(): boolean;
|
|
25
26
|
connectedCallback(): void;
|
|
27
|
+
disconnectedCallback(): void;
|
|
26
28
|
}
|
|
27
29
|
export declare const BaseLocalizedComponent: (new (...args: any[]) => {
|
|
28
30
|
localize: import("@italia/i18n").LocalizeController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-component.d.ts","sourceRoot":"","sources":["../../../src/base-component/base-component.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAI5C,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,YAAY,EAAE,OAAO,IAAI,CAAC;CAC3B;AAED,MAAM,MAAM,iBAAiB,GAAG,OAAO,UAAU,GAAG,WAAW,CAAC,sBAAsB,CAAC,CAAC;AAExF;;;GAGG;AAEH,qBAAa,aAAc,SAAQ,UAAU;IAC3C,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAEzB,SAAS,CAAC,YAAY,cAAQ;IAE9B,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;;
|
|
1
|
+
{"version":3,"file":"base-component.d.ts","sourceRoot":"","sources":["../../../src/base-component/base-component.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAI5C,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,YAAY,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AC;UAAoD,GAAG;WAAgD,GAAG;;gBAA6E,GAAG;;;;;;;WAA4V,GAAG;YAAiD,GAAG;;;;;;;;;;;oBAAupC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAiiO,CAAC;cAA6F,CAAC;eAA8F,CAAC;gBAA+F,CAAC;;;;;;;;;;;;;;SAAulC,CAAC;;;iBAA+E,CAAC;yBADjyrB,CAAC"}
|
|
@@ -52,6 +52,26 @@ export class BaseComponent extends LitElement {
|
|
|
52
52
|
// generate internal _id
|
|
53
53
|
const prefix = this.id?.length > 0 ? this.id : this.tagName.toLowerCase();
|
|
54
54
|
this._id = this.generateId(prefix);
|
|
55
|
+
this.ariaAttributesObserver = new MutationObserver((mutations) => {
|
|
56
|
+
const shouldUpdate = mutations.some((mutation) => {
|
|
57
|
+
if (mutation.type !== 'attributes' || !mutation.attributeName) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return mutation.attributeName === 'it-role' || mutation.attributeName.startsWith('it-aria-');
|
|
61
|
+
});
|
|
62
|
+
if (shouldUpdate) {
|
|
63
|
+
this.requestUpdate();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
this.ariaAttributesObserver.observe(this, {
|
|
67
|
+
attributes: true,
|
|
68
|
+
attributeOldValue: true,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
disconnectedCallback() {
|
|
72
|
+
this.ariaAttributesObserver?.disconnect();
|
|
73
|
+
this.ariaAttributesObserver = undefined;
|
|
74
|
+
super.disconnectedCallback();
|
|
55
75
|
}
|
|
56
76
|
}
|
|
57
77
|
export const BaseLocalizedComponent = LocalizeMixin(BaseComponent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-component.js","sourceRoot":"","sources":["../../../src/base-component/base-component.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI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f,CAAC;gBAED,OAAO,QAAQ,CAAC,aAAa,KAAK,SAAS,IAAI,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAC/F,CAAC,CAAC,CAAC;YAEH,IAAI,YAAY,EAAE,CAAC;gBACjB,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,IAAI,EAAE;YACxC,UAAU,EAAE,IAAI;YAChB,iBAAiB,EAAE,IAAI;SACxB,CAAC,CAAC;IACL,CAAC;IAED,oBAAoB;QAClB,IAAI,CAAC,sBAAsB,EAAE,UAAU,EAAE,CAAC;QAC1C,IAAI,CAAC,sBAAsB,GAAG,SAAS,CAAC;QACxC,KAAK,CAAC,oBAAoB,EAAE,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC","sourcesContent":["import clsx from 'clsx';\nimport { LitElement } from 'lit';\nimport { LocalizeMixin } from '@italia/i18n';\nimport { Constructor } from '../index.js';\nimport { Logger } from '../utils/logger.js';\n\n// import TrackFocus from '../utils/track-focus.js';\n\nexport interface BaseComponentInterface {\n addFocus(element: HTMLElement): void;\n composeClass: typeof clsx;\n}\n\nexport type BaseComponentType = typeof LitElement & Constructor<BaseComponentInterface>;\n\n/**\n * Factory function per creare una base class estendibile\n * con stili personalizzati.\n */\n\nexport class BaseComponent extends LitElement {\n protected logger: Logger;\n\n protected composeClass = clsx;\n\n protected _id?: string; // id interno del componente, da usare sui veri elementi HTML\n\n protected ariaAttributesObserver?: MutationObserver;\n\n constructor() {\n super();\n this.logger = new Logger(this.tagName.toLowerCase());\n }\n\n protected get _ariaAttributes(): Record<string, string> {\n const attributes: Record<string, string> = {};\n for (const attr of this.getAttributeNames()) {\n if (attr === 'it-role') {\n attributes.role = this.getAttribute(attr)!;\n } else if (attr.startsWith('it-aria-')) {\n attributes[attr.replace(/^it-/, '')] = this.getAttribute(attr)!;\n }\n }\n return attributes;\n }\n\n // eslint-disable-next-line class-methods-use-this\n generateId(prefix: string) {\n return `${prefix}-${Math.random().toString(36).slice(2)}`;\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n addFocus(element: HTMLElement) {\n // new TrackFocus(element); // per il momento è stato disattivato perchè ci sono le pseudo classi ::focus-visible per fare quello che fa TrackFocus. Si possono aggiungere regole css in bsi-italia 3 dato che stiamo facendo una breaking release di bsi.\n }\n\n // eslint-disable-next-line class-methods-use-this\n protected getActiveElement<T extends HTMLElement>(): T | null {\n let active = document.activeElement;\n while (active && active.shadowRoot && active.shadowRoot.activeElement) {\n active = active.shadowRoot.activeElement;\n }\n return active as T | null;\n }\n\n get focusElement(): HTMLElement | null {\n return this;\n }\n\n // eslint-disable-next-line class-methods-use-this\n protected get prefersReducedMotion(): boolean {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // generate internal _id\n const prefix = this.id?.length > 0 ? this.id : this.tagName.toLowerCase();\n this._id = this.generateId(prefix);\n\n this.ariaAttributesObserver = new MutationObserver((mutations) => {\n const shouldUpdate = mutations.some((mutation) => {\n if (mutation.type !== 'attributes' || !mutation.attributeName) {\n return false;\n }\n\n return mutation.attributeName === 'it-role' || mutation.attributeName.startsWith('it-aria-');\n });\n\n if (shouldUpdate) {\n this.requestUpdate();\n }\n });\n\n this.ariaAttributesObserver.observe(this, {\n attributes: true,\n attributeOldValue: true,\n });\n }\n\n disconnectedCallback() {\n this.ariaAttributesObserver?.disconnect();\n this.ariaAttributesObserver = undefined;\n super.disconnectedCallback();\n }\n}\n\nexport const BaseLocalizedComponent = LocalizeMixin(BaseComponent);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus-trap-controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/focus-trap-controller.ts"],"names":[],"mappings":"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0B;IAC1B,4CAA4C;IAC5C,wBAAwB;IACxB,iCAAiC;CAClC,CAAC,IAAI,CAAC,GAAG,CAAC,AAPuC,CAOtC;AAEY,0CAAsB,GAAG;IAC/C,2BAA2B;IAC3B,6BAA6B;IAC7B,6BAA6B;CAC9B,CAAC,IAAI,CAAC,GAAG,CAAC,AAJmC,CAIlC;AAEY,+CAA2B,GAAG;IACpD,6BAA6B;IAC7B,6BAA6B;CAC9B,CAAC,IAAI,CAAC,GAAG,CAAC,AAHwC,CAGvC","sourcesContent":["/* eslint-disable no-continue */\nimport { ReactiveController, ReactiveControllerHost } from 'lit';\n\nexport interface FocusTrapConfig {\n /** Funzione che ritorna l'elemento contenitore del trap */\n getContainer: () => HTMLElement | ShadowRoot | null;\n /** Funzione che ritorna l'elemento trigger che ha attivato il focus trap */\n getTrigger: () => HTMLElement | ShadowRoot | null;\n /** Opzionale: funzione che ritorna l'elemento da mettere a fuoco all'apertura (può essere tabindex -1) */\n initialFocus?: () => HTMLElement | null;\n /** Callback quando viene premuto Escape */\n onEscape?: () => void;\n /** Se true, non chiude con Escape */\n disableEscape?: boolean;\n}\n\n/**\n * Safari/VoiceOver iOS workarounds catalogue — why timers exist here:\n *\n * 1. `activate()` rAF + setTimeout(50): Safari does not reliably update the VoiceOver\n * accessibility tree synchronously. rAF ensures the element is painted before we\n * attempt to focus it. setTimeout(50) yields 50ms so VoiceOver can settle its\n * accessibility tree before announcing the newly focused element.\n * Empirically, VoiceOver iOS needs 100–300ms; the animated path in it-modal already\n * provides ~316ms naturally via animation.finished, so the 50ms here only truly\n * matters for the no-animation / prefers-reduced-motion path.\n *\n * 2. `_restoreFocus()` setTimeout(0): Same settle reason on close. The caller\n * (it-modal finishHide) adds a belt-and-suspenders 20ms setTimeout; _restoreFocus\n * is skipped via { skipFocusRestore: true } in that case to avoid double-focus.\n *\n * 3. `activate()` iOS body-focus fallback: On iOS Safari, tapping a button does not\n * reliably move document.activeElement away from body. We fall back to getTrigger()\n * so _previousActiveElement is always a real DOM element to restore focus to on close.\n *\n * There is no WebKit/Safari API to detect when VoiceOver has settled its accessibility\n * tree. setTimeout-based workarounds are the same pattern used by Bootstrap 5, the\n * focus-trap npm package, and a11y-dialog.\n */\nexport class FocusTrapController implements ReactiveController {\n private host: ReactiveControllerHost & HTMLElement;\n\n private config: FocusTrapConfig;\n\n private observer: MutationObserver | null = null;\n\n private _isActive = false;\n\n private _previousActiveElement: HTMLElement | null = null;\n\n private _focusableElements: HTMLElement[] = [];\n\n private _first?: HTMLElement;\n\n private _last?: HTMLElement;\n\n /** Last known index resolved from real focusin events inside the trap.\n * Used as a fallback when assistive tech retargeting makes activeElement\n * temporarily unmappable during Tab navigation. */\n private _lastKnownFocusIndex = -1;\n\n /** Timer ID for the focus call scheduled inside activate(). Cancelled by deactivate()\n * to prevent focus firing after the trap has been torn down (fast open/close, unmount). */\n private _pendingFocusTimer: ReturnType<typeof setTimeout> | null = null;\n\n private static readonly FOCUSABLE_SELECTORS = [\n 'a[href]',\n 'button:not([disabled])',\n 'textarea:not([disabled])',\n 'input:not([disabled]):not([type=\"hidden\"])',\n 'select:not([disabled])',\n '[tabindex]',\n 'it-button:not([disabled])',\n 'it-dropdown:not([disabled])',\n 'it-megamenu:not([disabled])',\n ].join(',');\n\n private static readonly NATIVE_FOCUSABLE_SELECTORS = [\n 'a[href]',\n 'button:not([disabled])',\n 'textarea:not([disabled])',\n 'input:not([disabled]):not([type=\"hidden\"])',\n 'select:not([disabled])',\n '[tabindex]:not([tabindex=\"-1\"])',\n ].join(',');\n\n private static readonly MANAGED_HOST_SELECTORS = [\n 'it-button:not([disabled])',\n 'it-dropdown:not([disabled])',\n 'it-megamenu:not([disabled])',\n ].join(',');\n\n private static readonly MANAGED_MENU_HOST_SELECTORS = [\n 'it-dropdown:not([disabled])',\n 'it-megamenu:not([disabled])',\n ].join(',');\n\n private static getManagedHostAncestor(element: HTMLElement): HTMLElement | null {\n let current: Node | null = element;\n\n while (current) {\n const parentEl: HTMLElement | null = current instanceof HTMLElement ? current.parentElement : null;\n if (parentEl && parentEl.matches(FocusTrapController.MANAGED_HOST_SELECTORS)) return parentEl;\n\n if (parentEl) {\n current = parentEl;\n continue;\n }\n\n const rootNode: Node = current.getRootNode();\n if (rootNode instanceof ShadowRoot) {\n const hostElement: Element = rootNode.host;\n if (hostElement instanceof HTMLElement) {\n if (hostElement.matches(FocusTrapController.MANAGED_HOST_SELECTORS)) return hostElement;\n current = hostElement;\n continue;\n }\n }\n\n break;\n }\n\n return null;\n }\n\n private static isInsideManagedHost(element: HTMLElement): boolean {\n return FocusTrapController.getManagedHostAncestor(element) !== null;\n }\n\n private static getManagedMenuHostAncestor(element: HTMLElement): HTMLElement | null {\n let current: Node | null = element;\n\n while (current) {\n const parentEl: HTMLElement | null = current instanceof HTMLElement ? current.parentElement : null;\n if (parentEl && parentEl.matches(FocusTrapController.MANAGED_MENU_HOST_SELECTORS)) return parentEl;\n\n if (parentEl) {\n current = parentEl;\n continue;\n }\n\n const rootNode: Node = current.getRootNode();\n if (rootNode instanceof ShadowRoot) {\n const hostElement: Element = rootNode.host;\n if (hostElement instanceof HTMLElement) {\n if (hostElement.matches(FocusTrapController.MANAGED_MENU_HOST_SELECTORS)) return hostElement;\n current = hostElement;\n continue;\n }\n }\n\n break;\n }\n\n return null;\n }\n\n private static collectFocusableCandidates(\n root: ParentNode,\n candidates: HTMLElement[],\n trigger: HTMLElement | ShadowRoot | null,\n visited: Set<Node>,\n ): void {\n const rootAsNode = root as Node;\n if (visited.has(rootAsNode)) return;\n visited.add(rootAsNode);\n\n const elements = Array.from(root.querySelectorAll<HTMLElement>('*'));\n elements.forEach((el) => {\n if (el === trigger) return;\n\n // Keep custom host components as single tab stops: their internal light/shadow\n // descendants must not appear as separate trap candidates.\n if (FocusTrapController.isInsideManagedHost(el)) return;\n\n if (el.matches(FocusTrapController.FOCUSABLE_SELECTORS)) {\n candidates.push(el);\n // Stop here: focusCandidate() handles delegation to the inner focusable.\n // Prevent recursion into this element's shadow DOM so inner buttons/triggers\n // are not added as separate tab stops.\n if (el.shadowRoot) visited.add(el.shadowRoot);\n return;\n }\n\n if (el instanceof HTMLSlotElement) {\n el.assignedElements({ flatten: true }).forEach((assigned) => {\n if (!(assigned instanceof HTMLElement) || assigned === trigger) return;\n\n if (assigned.matches(FocusTrapController.FOCUSABLE_SELECTORS)) {\n candidates.push(assigned);\n // Same rule: don't recurse into a focusable element.\n if (assigned.shadowRoot) visited.add(assigned.shadowRoot);\n return;\n }\n\n FocusTrapController.collectFocusableCandidates(assigned, candidates, trigger, visited);\n\n if (assigned.shadowRoot) {\n FocusTrapController.collectFocusableCandidates(assigned.shadowRoot, candidates, trigger, visited);\n }\n });\n return;\n }\n\n if (el.shadowRoot) {\n FocusTrapController.collectFocusableCandidates(el.shadowRoot, candidates, trigger, visited);\n }\n });\n }\n\n private static getFirstFocusableInShadow(host: HTMLElement): HTMLElement | null {\n const visited = new Set<Node>();\n\n const walk = (root: ParentNode): HTMLElement | null => {\n const rootAsNode = root as Node;\n if (visited.has(rootAsNode)) return null;\n visited.add(rootAsNode);\n\n const direct = Array.from(root.querySelectorAll<HTMLElement>(FocusTrapController.NATIVE_FOCUSABLE_SELECTORS));\n const firstDirect = direct.find((el) => FocusTrapController.isFocusable(el));\n if (firstDirect) return firstDirect;\n\n const all = Array.from(root.querySelectorAll<HTMLElement>('*'));\n for (const el of all) {\n if (el instanceof HTMLSlotElement) {\n const assigned = el.assignedElements({ flatten: true });\n for (const assignedEl of assigned) {\n if (!(assignedEl instanceof HTMLElement)) continue;\n if (assignedEl.matches(FocusTrapController.NATIVE_FOCUSABLE_SELECTORS)) {\n if (FocusTrapController.isFocusable(assignedEl)) return assignedEl;\n }\n const nestedAssigned = walk(assignedEl);\n if (nestedAssigned) return nestedAssigned;\n if (assignedEl.shadowRoot) {\n const nestedAssignedShadow = walk(assignedEl.shadowRoot);\n if (nestedAssignedShadow) return nestedAssignedShadow;\n }\n }\n }\n\n if (el.shadowRoot) {\n const nested = walk(el.shadowRoot);\n if (nested) return nested;\n }\n }\n\n return null;\n };\n\n if (!host.shadowRoot) return null;\n return walk(host.shadowRoot);\n }\n\n private static focusCandidate(target: HTMLElement | undefined): void {\n if (!target) return;\n\n if (target.tagName.toLowerCase().startsWith('it-')) {\n const innerFocusable = FocusTrapController.getFirstFocusableInShadow(target);\n if (innerFocusable) {\n innerFocusable.focus({ preventScroll: true });\n return;\n }\n }\n\n target.focus({ preventScroll: true });\n }\n\n /**\n * Verifica se un elemento è effettivamente focusabile e tabbabile.\n * Elementi con tabindex=\"-1\" sono focusabili programmaticamente ma non tabbabili.\n */\n private static isFocusable(el: HTMLElement): boolean {\n if (typeof el.focus !== 'function') return false;\n if (el.hasAttribute('disabled') || el.hasAttribute('inert') || el.hasAttribute('it-inert')) return false;\n const tabindex = el.getAttribute('tabindex');\n if (tabindex && parseInt(tabindex, 10) < 0) return false;\n\n if (el.tagName.toLowerCase().startsWith('it-')) {\n if (tabindex && parseInt(tabindex, 10) < 0) return false;\n return true;\n }\n\n // Fix Race Condition Safari: durante l'apertura non fidarti di getClientRects o opacità\n try {\n const style = window.getComputedStyle(el);\n return style && style.display !== 'none' && style.visibility !== 'hidden';\n } catch {\n return false;\n }\n }\n\n constructor(host: ReactiveControllerHost & HTMLElement, config: FocusTrapConfig) {\n this.host = host;\n this.config = config;\n this.host.addController(this);\n }\n\n hostConnected() {\n const observerOptions = { childList: true, attributes: true, subtree: true };\n this.observer = new MutationObserver(this.updateFocusableElements.bind(this));\n this.observer.observe(this.host, observerOptions);\n }\n\n hostDisconnected() {\n this.deactivate();\n if (this.observer) {\n this.observer.disconnect();\n this.observer = null;\n }\n }\n\n get isActive(): boolean {\n return this._isActive;\n }\n\n activate(): void {\n if (this._isActive) return;\n this._isActive = true;\n\n // FIX iOS: Safari non dà focus al tap. Se activeElement è body, salviamo il trigger della config.\n const currentActive = FocusTrapController.getActiveElement();\n this._previousActiveElement =\n !currentActive || currentActive === document.body ? (this.config.getTrigger() as HTMLElement) : currentActive;\n\n // Usa document capture: cattura Tab/Escape prima di qualsiasi handler,\n // indipendentemente da shadow DOM, delegatesFocus e slot retargeting.\n document.addEventListener('keydown', this._handleKeyDown, true);\n document.addEventListener('focusin', this._handleFocusIn, true);\n this.updateFocusableElements();\n this._lastKnownFocusIndex = -1;\n // FIX Safari: trick engine\n // Diamo al browser un istante per processare il ricalcolo del layout\n requestAnimationFrame(() => {\n if (this.config.initialFocus) {\n const el = this.config.initialFocus();\n if (el) {\n // 50ms gives VoiceOver iOS time to settle its accessibility tree before\n // announcing the focused element. See class-level comment for details.\n this._pendingFocusTimer = setTimeout(() => {\n this._pendingFocusTimer = null;\n el.focus({ preventScroll: true });\n }, 50);\n }\n } else {\n console.warn(\"FocusTrap: missing 'initialFocus' callback, provide one\");\n }\n });\n }\n\n deactivate(options?: { skipFocusRestore?: boolean }): void {\n if (!this._isActive) return;\n // Cancel any in-flight focus timer so it cannot fire after the trap is torn down\n // (e.g. fast open/close cycle, component unmounted while opening).\n if (this._pendingFocusTimer !== null) {\n clearTimeout(this._pendingFocusTimer);\n this._pendingFocusTimer = null;\n }\n this._isActive = false;\n document.removeEventListener('keydown', this._handleKeyDown, true);\n document.removeEventListener('focusin', this._handleFocusIn, true);\n this._lastKnownFocusIndex = -1;\n if (!options?.skipFocusRestore) {\n this._restoreFocus();\n } else {\n this._previousActiveElement = null;\n }\n }\n\n /**\n * Aggiorna la lista degli elementi focusabili.\n * Chiamare dopo modifiche al DOM.\n */\n updateFocusableElements(): void {\n const container = this.config.getContainer();\n const trigger = this.config.getTrigger();\n if (!container) {\n this._focusableElements = [];\n this._first = undefined;\n this._last = undefined;\n return;\n }\n\n const candidates: HTMLElement[] = [];\n FocusTrapController.collectFocusableCandidates(container, candidates, trigger, new Set<Node>());\n\n // Include anche i figli light DOM dell'host (es. contenuti slottati della modale)\n Array.from(this.host.children).forEach((child) => {\n if (!(child instanceof HTMLElement) || child === trigger) return;\n\n if (child.matches(FocusTrapController.FOCUSABLE_SELECTORS)) {\n candidates.push(child);\n // Don't recurse: same stop-on-focusable rule.\n return;\n }\n\n const childVisited = new Set<Node>();\n FocusTrapController.collectFocusableCandidates(child, candidates, trigger, childVisited);\n\n if (child.shadowRoot) {\n FocusTrapController.collectFocusableCandidates(child.shadowRoot, candidates, trigger, childVisited);\n }\n });\n\n // Filtra solo elementi veramente focusabili e rimuovi duplicati\n this._focusableElements = Array.from(new Set(candidates)).filter((el) => {\n // Escludi esplicitamente il container/dialog stesso\n if (el === this.config.getContainer()) return false;\n return FocusTrapController.isFocusable(el);\n });\n\n // Aggiorna primo/ultimo\n this._first = this._focusableElements?.[0];\n this._last = this._focusableElements[this._focusableElements.length - 1];\n }\n\n /** Sposta il focus sul primo elemento focusabile */\n focusFirst(): void {\n if (this._first) this._first.focus();\n }\n\n /** Sposta il focus sull'ultimo elemento focusabile */\n focusLast(): void {\n if (this._last) {\n this._last.focus();\n }\n }\n\n /** Ritorna l'elemento attivo corrente, attraversando shadow DOM e slot */\n static getActiveElement(): HTMLElement | null {\n let active = document.activeElement;\n while (active && active.shadowRoot && active.shadowRoot.activeElement) {\n active = active.shadowRoot.activeElement;\n }\n return active as HTMLElement | null;\n }\n\n private _handleKeyDown = (event: KeyboardEvent): void => {\n if (!this._isActive) return;\n switch (event.key) {\n case 'Escape':\n if (!this.config.disableEscape && this.config.onEscape) {\n event.preventDefault();\n this.config.onEscape();\n }\n break;\n case 'Tab':\n this._handleTab(event);\n break;\n default:\n break;\n }\n };\n\n private _handleFocusIn = (event: FocusEvent): void => {\n if (!this._isActive) return;\n\n if (this._focusableElements.length === 0) {\n this.updateFocusableElements();\n if (this._focusableElements.length === 0) return;\n }\n\n const path = event.composedPath();\n let index = this._focusableElements.findIndex((candidate) => path.includes(candidate));\n\n if (index === -1) {\n const target = path[0];\n if (target instanceof HTMLElement) {\n index = this._focusableElements.indexOf(target);\n }\n }\n\n if (index === -1) {\n const active = FocusTrapController.getActiveElement();\n if (active) {\n index = this._focusableElements.findIndex((candidate) => candidate.contains(active));\n }\n }\n\n if (index !== -1) {\n this._lastKnownFocusIndex = index;\n }\n };\n\n private _handleTab(event: KeyboardEvent): void {\n const activeElement = FocusTrapController.getActiveElement();\n\n // Let native Tab behavior handle navigation inside open dropdown/megamenu.\n // This allows entering and traversing internal menu items correctly.\n if (activeElement) {\n const managedHost = FocusTrapController.getManagedMenuHostAncestor(activeElement);\n if (managedHost && managedHost.getAttribute('data-it-aria-expanded') === 'true') {\n return;\n }\n }\n\n // Ricalcola sempre al Tab: gli elementi slottati possono completare il render\n // del proprio shadow DOM dopo l'attivazione iniziale del trap.\n this.updateFocusableElements();\n if (this._focusableElements.length === 0) return; // Se è ancora vuoto, non bloccare il Tab\n\n event.preventDefault();\n let currentIndex = this._focusableElements.indexOf(activeElement as HTMLElement);\n\n if (currentIndex === -1 && activeElement) {\n // 1. Walk shadow host chain (covers delegatesFocus custom elements)\n let parent = (activeElement.getRootNode() as ShadowRoot)?.host;\n while (parent && currentIndex === -1) {\n currentIndex = this._focusableElements.indexOf(parent as HTMLElement);\n if (currentIndex === -1) parent = (parent.getRootNode() as ShadowRoot)?.host;\n }\n }\n\n if (currentIndex === -1) {\n // 2. Composed path fallback: handles focus inside nested shadow/slotted\n // content (e.g. anchors inside it-dropdown-item) by mapping the active\n // target to the first focusable host found in the event path.\n const composedPath = event.composedPath();\n currentIndex = this._focusableElements.findIndex((candidate) => composedPath.includes(candidate));\n }\n\n if (currentIndex === -1 && activeElement) {\n // 3. contains() fallback: handles focus inside an open dropdown/megamenu whose\n // items live in light DOM (not shadow DOM), so the parent-walk above doesn't\n // reach the host. Map to the host's index so Tab/Shift+Tab move to the\n // correct adjacent element.\n currentIndex = this._focusableElements.findIndex((candidate) => candidate.contains(activeElement));\n }\n\n if (currentIndex === -1) {\n // 4. AT fallback: with some screen readers, document.activeElement and/or\n // event target can be unreliable while navigating inside composite widgets.\n // If a dropdown/megamenu is currently open, use its host index as anchor\n // so forward/backward Tab continue from that position instead of wrapping.\n currentIndex = this._focusableElements.findIndex(\n (candidate) =>\n candidate.matches('it-dropdown, it-megamenu') && candidate.getAttribute('data-it-aria-expanded') === 'true',\n );\n }\n\n if (currentIndex === -1 && this._lastKnownFocusIndex >= 0) {\n // 5. Last-known fallback: if assistive tech retargeting hides the active\n // element for this key event, continue from the most recent resolved\n // focus index captured via focusin.\n currentIndex = Math.min(this._lastKnownFocusIndex, this._focusableElements.length - 1);\n }\n\n if (event.shiftKey) {\n if (currentIndex <= 0) FocusTrapController.focusCandidate(this._last);\n else FocusTrapController.focusCandidate(this._focusableElements[currentIndex - 1]);\n } else if (currentIndex === -1 || currentIndex >= this._focusableElements.length - 1)\n FocusTrapController.focusCandidate(this._first);\n else FocusTrapController.focusCandidate(this._focusableElements[currentIndex + 1]);\n }\n\n private _restoreFocus(): void {\n const target = this._previousActiveElement;\n this._previousActiveElement = null;\n if (target && typeof target.focus === 'function' && document.contains(target)) {\n // FIX Safari: blur the current element first so VoiceOver doesn't stay on the\n // modal element while the accessibility tree processes the focus change.\n FocusTrapController.getActiveElement()?.blur();\n // FIX Safari/VoiceOver iOS: defer to the next macrotask so the accessibility\n // tree has time to process the DOM mutation before announcing the restored element.\n setTimeout(() => {\n target.focus({ preventScroll: true });\n }, 0);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"focus-trap-controller.js","sourceRoot":"","sources":["../../../src/controllers/focus-trap-controller.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,mBAAmB;IA0DtB,MAAM,CAAC,sBAAsB,CAAC,OAAoB;QACxD,IAAI,OAAO,GAAgB,OAAO,CAAC;QAEnC,OAAO,OAAO,EAAE,CAAC;YACf,MAAM,QAAQ,GAAuB,OAAO,YAAY,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;YACnG,IAAI,QAAQ,IAAI,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,sBAAsB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\n\nexport interface FocusTrapConfig {\n /** Funzione che ritorna l'elemento contenitore del trap */\n getContainer: () => HTMLElement | ShadowRoot | null;\n /** Funzione che ritorna l'elemento trigger che ha attivato il focus trap */\n getTrigger: () => HTMLElement | ShadowRoot | null;\n /** Opzionale: funzione che ritorna l'elemento da mettere a fuoco all'apertura (può essere tabindex -1) */\n initialFocus?: () => HTMLElement | null;\n /** Callback quando viene premuto Escape */\n onEscape?: () => void;\n /** Se true, non chiude con Escape */\n disableEscape?: boolean;\n}\n\n/**\n * Safari/VoiceOver iOS workarounds catalogue — why timers exist here:\n *\n * 1. `activate()` rAF + setTimeout(50): Safari does not reliably update the VoiceOver\n * accessibility tree synchronously. rAF ensures the element is painted before we\n * attempt to focus it. setTimeout(50) yields 50ms so VoiceOver can settle its\n * accessibility tree before announcing the newly focused element.\n * Empirically, VoiceOver iOS needs 100–300ms; the animated path in it-modal already\n * provides ~316ms naturally via animation.finished, so the 50ms here only truly\n * matters for the no-animation / prefers-reduced-motion path.\n *\n * 2. `_restoreFocus()` setTimeout(0): Same settle reason on close. The caller\n * (it-modal finishHide) adds a belt-and-suspenders 20ms setTimeout; _restoreFocus\n * is skipped via { skipFocusRestore: true } in that case to avoid double-focus.\n *\n * 3. `activate()` iOS body-focus fallback: On iOS Safari, tapping a button does not\n * reliably move document.activeElement away from body. We fall back to getTrigger()\n * so _previousActiveElement is always a real DOM element to restore focus to on close.\n *\n * There is no WebKit/Safari API to detect when VoiceOver has settled its accessibility\n * tree. setTimeout-based workarounds are the same pattern used by Bootstrap 5, the\n * focus-trap npm package, and a11y-dialog.\n */\nexport class FocusTrapController implements ReactiveController {\n private host: ReactiveControllerHost & HTMLElement;\n\n private config: FocusTrapConfig;\n\n private observer: MutationObserver | null = null;\n\n private _isActive = false;\n\n private _previousActiveElement: HTMLElement | null = null;\n\n private _focusableElements: HTMLElement[] = [];\n\n private _first?: HTMLElement;\n\n private _last?: HTMLElement;\n\n /** Last known index resolved from real focusin events inside the trap.\n * Used as a fallback when assistive tech retargeting makes activeElement\n * temporarily unmappable during Tab navigation. */\n private _lastKnownFocusIndex = -1;\n\n /** Timer ID for the focus call scheduled inside activate(). Cancelled by deactivate()\n * to prevent focus firing after the trap has been torn down (fast open/close, unmount). */\n private _pendingFocusTimer: ReturnType<typeof setTimeout> | null = null;\n\n private static readonly FOCUSABLE_SELECTORS = [\n 'a[href]',\n 'button:not([disabled])',\n 'textarea:not([disabled])',\n 'input:not([disabled]):not([type=\"hidden\"])',\n 'select:not([disabled])',\n '[tabindex]',\n 'it-button:not([disabled])',\n 'it-dropdown:not([disabled])',\n 'it-megamenu:not([disabled])',\n ].join(',');\n\n private static readonly NATIVE_FOCUSABLE_SELECTORS = [\n 'a[href]',\n 'button:not([disabled])',\n 'textarea:not([disabled])',\n 'input:not([disabled]):not([type=\"hidden\"])',\n 'select:not([disabled])',\n '[tabindex]:not([tabindex=\"-1\"])',\n ].join(',');\n\n private static readonly MANAGED_HOST_SELECTORS = [\n 'it-button:not([disabled])',\n 'it-dropdown:not([disabled])',\n 'it-megamenu:not([disabled])',\n ].join(',');\n\n private static readonly MANAGED_MENU_HOST_SELECTORS = [\n 'it-dropdown:not([disabled])',\n 'it-megamenu:not([disabled])',\n ].join(',');\n\n private static getManagedHostAncestor(element: HTMLElement): HTMLElement | null {\n let current: Node | null = element;\n\n while (current) {\n const parentEl: HTMLElement | null = current instanceof HTMLElement ? current.parentElement : null;\n if (parentEl && parentEl.matches(FocusTrapController.MANAGED_HOST_SELECTORS)) return parentEl;\n\n if (parentEl) {\n current = parentEl;\n continue;\n }\n\n const rootNode: Node = current.getRootNode();\n if (rootNode instanceof ShadowRoot) {\n const hostElement: Element = rootNode.host;\n if (hostElement instanceof HTMLElement) {\n if (hostElement.matches(FocusTrapController.MANAGED_HOST_SELECTORS)) return hostElement;\n current = hostElement;\n continue;\n }\n }\n\n break;\n }\n\n return null;\n }\n\n private static isInsideManagedHost(element: HTMLElement): boolean {\n return FocusTrapController.getManagedHostAncestor(element) !== null;\n }\n\n private static getManagedMenuHostAncestor(element: HTMLElement): HTMLElement | null {\n let current: Node | null = element;\n\n while (current) {\n const parentEl: HTMLElement | null = current instanceof HTMLElement ? current.parentElement : null;\n if (parentEl && parentEl.matches(FocusTrapController.MANAGED_MENU_HOST_SELECTORS)) return parentEl;\n\n if (parentEl) {\n current = parentEl;\n continue;\n }\n\n const rootNode: Node = current.getRootNode();\n if (rootNode instanceof ShadowRoot) {\n const hostElement: Element = rootNode.host;\n if (hostElement instanceof HTMLElement) {\n if (hostElement.matches(FocusTrapController.MANAGED_MENU_HOST_SELECTORS)) return hostElement;\n current = hostElement;\n continue;\n }\n }\n\n break;\n }\n\n return null;\n }\n\n private static collectFocusableCandidates(\n root: ParentNode,\n candidates: HTMLElement[],\n trigger: HTMLElement | ShadowRoot | null,\n visited: Set<Node>,\n ): void {\n const rootAsNode = root as Node;\n if (visited.has(rootAsNode)) return;\n visited.add(rootAsNode);\n\n const elements = Array.from(root.querySelectorAll<HTMLElement>('*'));\n elements.forEach((el) => {\n if (el === trigger) return;\n\n // Keep custom host components as single tab stops: their internal light/shadow\n // descendants must not appear as separate trap candidates.\n if (FocusTrapController.isInsideManagedHost(el)) return;\n\n if (el.matches(FocusTrapController.FOCUSABLE_SELECTORS)) {\n candidates.push(el);\n // Stop here: focusCandidate() handles delegation to the inner focusable.\n // Prevent recursion into this element's shadow DOM so inner buttons/triggers\n // are not added as separate tab stops.\n if (el.shadowRoot) visited.add(el.shadowRoot);\n return;\n }\n\n if (el instanceof HTMLSlotElement) {\n el.assignedElements({ flatten: true }).forEach((assigned) => {\n if (!(assigned instanceof HTMLElement) || assigned === trigger) return;\n\n if (assigned.matches(FocusTrapController.FOCUSABLE_SELECTORS)) {\n candidates.push(assigned);\n // Same rule: don't recurse into a focusable element.\n if (assigned.shadowRoot) visited.add(assigned.shadowRoot);\n return;\n }\n\n FocusTrapController.collectFocusableCandidates(assigned, candidates, trigger, visited);\n\n if (assigned.shadowRoot) {\n FocusTrapController.collectFocusableCandidates(assigned.shadowRoot, candidates, trigger, visited);\n }\n });\n return;\n }\n\n if (el.shadowRoot) {\n FocusTrapController.collectFocusableCandidates(el.shadowRoot, candidates, trigger, visited);\n }\n });\n }\n\n private static getFirstFocusableInShadow(host: HTMLElement): HTMLElement | null {\n const visited = new Set<Node>();\n\n const walk = (root: ParentNode): HTMLElement | null => {\n const rootAsNode = root as Node;\n if (visited.has(rootAsNode)) return null;\n visited.add(rootAsNode);\n\n const direct = Array.from(root.querySelectorAll<HTMLElement>(FocusTrapController.NATIVE_FOCUSABLE_SELECTORS));\n const firstDirect = direct.find((el) => FocusTrapController.isFocusable(el));\n if (firstDirect) return firstDirect;\n\n const all = Array.from(root.querySelectorAll<HTMLElement>('*'));\n for (const el of all) {\n if (el instanceof HTMLSlotElement) {\n const assigned = el.assignedElements({ flatten: true });\n for (const assignedEl of assigned) {\n if (!(assignedEl instanceof HTMLElement)) continue;\n if (assignedEl.matches(FocusTrapController.NATIVE_FOCUSABLE_SELECTORS)) {\n if (FocusTrapController.isFocusable(assignedEl)) return assignedEl;\n }\n const nestedAssigned = walk(assignedEl);\n if (nestedAssigned) return nestedAssigned;\n if (assignedEl.shadowRoot) {\n const nestedAssignedShadow = walk(assignedEl.shadowRoot);\n if (nestedAssignedShadow) return nestedAssignedShadow;\n }\n }\n }\n\n if (el.shadowRoot) {\n const nested = walk(el.shadowRoot);\n if (nested) return nested;\n }\n }\n\n return null;\n };\n\n if (!host.shadowRoot) return null;\n return walk(host.shadowRoot);\n }\n\n private static focusCandidate(target: HTMLElement | undefined): void {\n if (!target) return;\n\n if (target.tagName.toLowerCase().startsWith('it-')) {\n const innerFocusable = FocusTrapController.getFirstFocusableInShadow(target);\n if (innerFocusable) {\n innerFocusable.focus({ preventScroll: true });\n return;\n }\n }\n\n target.focus({ preventScroll: true });\n }\n\n /**\n * Verifica se un elemento è effettivamente focusabile e tabbabile.\n * Elementi con tabindex=\"-1\" sono focusabili programmaticamente ma non tabbabili.\n */\n private static isFocusable(el: HTMLElement): boolean {\n if (typeof el.focus !== 'function') return false;\n if (el.hasAttribute('disabled') || el.hasAttribute('inert') || el.hasAttribute('it-inert')) return false;\n const tabindex = el.getAttribute('tabindex');\n if (tabindex && parseInt(tabindex, 10) < 0) return false;\n\n if (el.tagName.toLowerCase().startsWith('it-')) {\n if (tabindex && parseInt(tabindex, 10) < 0) return false;\n return true;\n }\n\n // Fix Race Condition Safari: durante l'apertura non fidarti di getClientRects o opacità\n try {\n const style = window.getComputedStyle(el);\n return style && style.display !== 'none' && style.visibility !== 'hidden';\n } catch {\n return false;\n }\n }\n\n constructor(host: ReactiveControllerHost & HTMLElement, config: FocusTrapConfig) {\n this.host = host;\n this.config = config;\n this.host.addController(this);\n }\n\n hostConnected() {\n const observerOptions = { childList: true, attributes: true, subtree: true };\n this.observer = new MutationObserver(this.updateFocusableElements.bind(this));\n this.observer.observe(this.host, observerOptions);\n }\n\n hostDisconnected() {\n this.deactivate();\n if (this.observer) {\n this.observer.disconnect();\n this.observer = null;\n }\n }\n\n get isActive(): boolean {\n return this._isActive;\n }\n\n activate(): void {\n if (this._isActive) return;\n this._isActive = true;\n\n // FIX iOS: Safari non dà focus al tap. Se activeElement è body, salviamo il trigger della config.\n const currentActive = FocusTrapController.getActiveElement();\n this._previousActiveElement =\n !currentActive || currentActive === document.body ? (this.config.getTrigger() as HTMLElement) : currentActive;\n\n // Usa document capture: cattura Tab/Escape prima di qualsiasi handler,\n // indipendentemente da shadow DOM, delegatesFocus e slot retargeting.\n document.addEventListener('keydown', this._handleKeyDown, true);\n document.addEventListener('focusin', this._handleFocusIn, true);\n this.updateFocusableElements();\n this._lastKnownFocusIndex = -1;\n // FIX Safari: trick engine\n // Diamo al browser un istante per processare il ricalcolo del layout\n requestAnimationFrame(() => {\n if (this.config.initialFocus) {\n const el = this.config.initialFocus();\n if (el) {\n // 50ms gives VoiceOver iOS time to settle its accessibility tree before\n // announcing the focused element. See class-level comment for details.\n this._pendingFocusTimer = setTimeout(() => {\n this._pendingFocusTimer = null;\n el.focus({ preventScroll: true });\n }, 50);\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn(\"FocusTrap: missing 'initialFocus' callback, provide one\");\n }\n });\n }\n\n deactivate(options?: { skipFocusRestore?: boolean }): void {\n if (!this._isActive) return;\n // Cancel any in-flight focus timer so it cannot fire after the trap is torn down\n // (e.g. fast open/close cycle, component unmounted while opening).\n if (this._pendingFocusTimer !== null) {\n clearTimeout(this._pendingFocusTimer);\n this._pendingFocusTimer = null;\n }\n this._isActive = false;\n document.removeEventListener('keydown', this._handleKeyDown, true);\n document.removeEventListener('focusin', this._handleFocusIn, true);\n this._lastKnownFocusIndex = -1;\n if (!options?.skipFocusRestore) {\n this._restoreFocus();\n } else {\n this._previousActiveElement = null;\n }\n }\n\n /**\n * Aggiorna la lista degli elementi focusabili.\n * Chiamare dopo modifiche al DOM.\n */\n updateFocusableElements(): void {\n const container = this.config.getContainer();\n const trigger = this.config.getTrigger();\n if (!container) {\n this._focusableElements = [];\n this._first = undefined;\n this._last = undefined;\n return;\n }\n\n const candidates: HTMLElement[] = [];\n FocusTrapController.collectFocusableCandidates(container, candidates, trigger, new Set<Node>());\n\n // Include anche i figli light DOM dell'host (es. contenuti slottati della modale)\n Array.from(this.host.children).forEach((child) => {\n if (!(child instanceof HTMLElement) || child === trigger) return;\n\n if (child.matches(FocusTrapController.FOCUSABLE_SELECTORS)) {\n candidates.push(child);\n // Don't recurse: same stop-on-focusable rule.\n return;\n }\n\n const childVisited = new Set<Node>();\n FocusTrapController.collectFocusableCandidates(child, candidates, trigger, childVisited);\n\n if (child.shadowRoot) {\n FocusTrapController.collectFocusableCandidates(child.shadowRoot, candidates, trigger, childVisited);\n }\n });\n\n // Filtra solo elementi veramente focusabili e rimuovi duplicati\n this._focusableElements = Array.from(new Set(candidates)).filter((el) => {\n // Escludi esplicitamente il container/dialog stesso\n if (el === this.config.getContainer()) return false;\n return FocusTrapController.isFocusable(el);\n });\n\n // Aggiorna primo/ultimo\n this._first = this._focusableElements?.[0];\n this._last = this._focusableElements[this._focusableElements.length - 1];\n }\n\n /** Sposta il focus sul primo elemento focusabile */\n focusFirst(): void {\n if (this._first) this._first.focus();\n }\n\n /** Sposta il focus sull'ultimo elemento focusabile */\n focusLast(): void {\n if (this._last) {\n this._last.focus();\n }\n }\n\n /** Ritorna l'elemento attivo corrente, attraversando shadow DOM e slot */\n static getActiveElement(): HTMLElement | null {\n let active = document.activeElement;\n while (active && active.shadowRoot && active.shadowRoot.activeElement) {\n active = active.shadowRoot.activeElement;\n }\n return active as HTMLElement | null;\n }\n\n private _handleKeyDown = (event: KeyboardEvent): void => {\n if (!this._isActive) return;\n switch (event.key) {\n case 'Escape':\n if (!this.config.disableEscape && this.config.onEscape) {\n event.preventDefault();\n this.config.onEscape();\n }\n break;\n case 'Tab':\n this._handleTab(event);\n break;\n default:\n break;\n }\n };\n\n private _handleFocusIn = (event: FocusEvent): void => {\n if (!this._isActive) return;\n\n if (this._focusableElements.length === 0) {\n this.updateFocusableElements();\n if (this._focusableElements.length === 0) return;\n }\n\n const path = event.composedPath();\n let index = this._focusableElements.findIndex((candidate) => path.includes(candidate));\n\n if (index === -1) {\n const target = path[0];\n if (target instanceof HTMLElement) {\n index = this._focusableElements.indexOf(target);\n }\n }\n\n if (index === -1) {\n const active = FocusTrapController.getActiveElement();\n if (active) {\n index = this._focusableElements.findIndex((candidate) => candidate.contains(active));\n }\n }\n\n if (index !== -1) {\n this._lastKnownFocusIndex = index;\n }\n };\n\n private _handleTab(event: KeyboardEvent): void {\n const activeElement = FocusTrapController.getActiveElement();\n\n // Let native Tab behavior handle navigation inside open dropdown/megamenu.\n // This allows entering and traversing internal menu items correctly.\n if (activeElement) {\n const managedHost = FocusTrapController.getManagedMenuHostAncestor(activeElement);\n if (managedHost && managedHost.getAttribute('data-it-aria-expanded') === 'true') {\n return;\n }\n }\n\n // Ricalcola sempre al Tab: gli elementi slottati possono completare il render\n // del proprio shadow DOM dopo l'attivazione iniziale del trap.\n this.updateFocusableElements();\n if (this._focusableElements.length === 0) return; // Se è ancora vuoto, non bloccare il Tab\n\n event.preventDefault();\n let currentIndex = this._focusableElements.indexOf(activeElement as HTMLElement);\n\n if (currentIndex === -1 && activeElement) {\n // 1. Walk shadow host chain (covers delegatesFocus custom elements)\n let parent = (activeElement.getRootNode() as ShadowRoot)?.host;\n while (parent && currentIndex === -1) {\n currentIndex = this._focusableElements.indexOf(parent as HTMLElement);\n if (currentIndex === -1) parent = (parent.getRootNode() as ShadowRoot)?.host;\n }\n }\n\n if (currentIndex === -1) {\n // 2. Composed path fallback: handles focus inside nested shadow/slotted\n // content (e.g. anchors inside it-dropdown-item) by mapping the active\n // target to the first focusable host found in the event path.\n const composedPath = event.composedPath();\n currentIndex = this._focusableElements.findIndex((candidate) => composedPath.includes(candidate));\n }\n\n if (currentIndex === -1 && activeElement) {\n // 3. contains() fallback: handles focus inside an open dropdown/megamenu whose\n // items live in light DOM (not shadow DOM), so the parent-walk above doesn't\n // reach the host. Map to the host's index so Tab/Shift+Tab move to the\n // correct adjacent element.\n currentIndex = this._focusableElements.findIndex((candidate) => candidate.contains(activeElement));\n }\n\n if (currentIndex === -1) {\n // 4. AT fallback: with some screen readers, document.activeElement and/or\n // event target can be unreliable while navigating inside composite widgets.\n // If a dropdown/megamenu is currently open, use its host index as anchor\n // so forward/backward Tab continue from that position instead of wrapping.\n currentIndex = this._focusableElements.findIndex(\n (candidate) =>\n candidate.matches('it-dropdown, it-megamenu') && candidate.getAttribute('data-it-aria-expanded') === 'true',\n );\n }\n\n if (currentIndex === -1 && this._lastKnownFocusIndex >= 0) {\n // 5. Last-known fallback: if assistive tech retargeting hides the active\n // element for this key event, continue from the most recent resolved\n // focus index captured via focusin.\n currentIndex = Math.min(this._lastKnownFocusIndex, this._focusableElements.length - 1);\n }\n\n if (event.shiftKey) {\n if (currentIndex <= 0) FocusTrapController.focusCandidate(this._last);\n else FocusTrapController.focusCandidate(this._focusableElements[currentIndex - 1]);\n } else if (currentIndex === -1 || currentIndex >= this._focusableElements.length - 1)\n FocusTrapController.focusCandidate(this._first);\n else FocusTrapController.focusCandidate(this._focusableElements[currentIndex + 1]);\n }\n\n private _restoreFocus(): void {\n const target = this._previousActiveElement;\n this._previousActiveElement = null;\n if (target && typeof target.focus === 'function' && document.contains(target)) {\n // FIX Safari: blur the current element first so VoiceOver doesn't stay on the\n // modal element while the accessibility tree processes the focus change.\n FocusTrapController.getActiveElement()?.blur();\n // FIX Safari/VoiceOver iOS: defer to the next macrotask so the accessibility\n // tree has time to process the DOM mutation before announcing the restored element.\n setTimeout(() => {\n target.focus({ preventScroll: true });\n }, 0);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setAttributes.d.ts","sourceRoot":"","sources":["../../../src/directives/setAttributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"setAttributes.d.ts","sourceRoot":"","sources":["../../../src/directives/setAttributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAmD5F,cAAM,sBAAuB,SAAQ,SAAS;IAC5C,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,UAAU,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;IAgCnE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAG3C;AAMD,QAAA,MAAM,aAAa,oHAAoC,CAAC;AAExD,eAAe,aAAa,CAAC"}
|
|
@@ -1,12 +1,78 @@
|
|
|
1
1
|
import { directive, Directive } from 'lit/directive.js';
|
|
2
|
+
const ARIA_IDREF_ATTRIBUTES = new Map([
|
|
3
|
+
['aria-activedescendant', 'ariaActivedescendantElement'],
|
|
4
|
+
['aria-controls', 'ariaControlsElements'],
|
|
5
|
+
['aria-describedby', 'ariaDescribedByElements'],
|
|
6
|
+
['aria-details', 'ariaDetailsElements'],
|
|
7
|
+
['aria-errormessage', 'ariaErrormessageElements'],
|
|
8
|
+
['aria-flowto', 'ariaFlowtoElements'],
|
|
9
|
+
['aria-labelledby', 'ariaLabelledByElements'],
|
|
10
|
+
['aria-owns', 'ariaOwnsElements'],
|
|
11
|
+
]);
|
|
12
|
+
function resolveAriaIdRefs(element, value) {
|
|
13
|
+
const ids = value
|
|
14
|
+
.trim()
|
|
15
|
+
.split(/\s+/)
|
|
16
|
+
.filter((id) => id.length > 0);
|
|
17
|
+
if (ids.length === 0)
|
|
18
|
+
return null;
|
|
19
|
+
const root = element.getRootNode();
|
|
20
|
+
let resolvedElements = [];
|
|
21
|
+
if (root instanceof ShadowRoot) {
|
|
22
|
+
resolvedElements = ids.map((id) => root.getElementById(id));
|
|
23
|
+
}
|
|
24
|
+
else if (root instanceof Document) {
|
|
25
|
+
resolvedElements = ids.map((id) => root.getElementById(id));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
resolvedElements = ids.map((id) => document.getElementById(id));
|
|
29
|
+
}
|
|
30
|
+
if (resolvedElements.filter((el) => el !== null).length === 0) {
|
|
31
|
+
resolvedElements = ids.map((id) => document.getElementById(id));
|
|
32
|
+
}
|
|
33
|
+
const validElements = resolvedElements.filter((el) => el !== null);
|
|
34
|
+
return validElements.length === ids.length ? validElements : null;
|
|
35
|
+
}
|
|
36
|
+
function setInternalsProperty(el, name, resolvedElements) {
|
|
37
|
+
if (name === 'aria-activedescendant') {
|
|
38
|
+
const [firstElement] = resolvedElements;
|
|
39
|
+
// eslint-disable-next-line no-param-reassign
|
|
40
|
+
el[name] = firstElement;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// eslint-disable-next-line no-param-reassign
|
|
44
|
+
el[name] = resolvedElements;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
2
47
|
class SetAttributesDirective extends Directive {
|
|
3
48
|
update(part, [attributes]) {
|
|
4
49
|
const el = part.element;
|
|
50
|
+
const internals = el.internals ?? null;
|
|
5
51
|
for (const [name, value] of Object.entries(attributes)) {
|
|
6
|
-
if (value
|
|
7
|
-
el.setAttribute(name, value);
|
|
8
|
-
else
|
|
52
|
+
if (value == null) {
|
|
9
53
|
el.removeAttribute(name);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const internalsPropertyName = ARIA_IDREF_ATTRIBUTES.get(name);
|
|
57
|
+
if (internalsPropertyName) {
|
|
58
|
+
const resolvedElements = resolveAriaIdRefs(el, String(value));
|
|
59
|
+
if (resolvedElements) {
|
|
60
|
+
if (internals) {
|
|
61
|
+
// Set on ElementInternals
|
|
62
|
+
setInternalsProperty(internals, internalsPropertyName, resolvedElements);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Set internals property on shadowdom item
|
|
66
|
+
el.setAttribute(name, String(value));
|
|
67
|
+
setInternalsProperty(el, internalsPropertyName, resolvedElements);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Non-ARIA IDREF attributes: set normally
|
|
73
|
+
el.setAttribute(name, String(value));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
10
76
|
}
|
|
11
77
|
return null;
|
|
12
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setAttributes.js","sourceRoot":"","sources":["../../../src/directives/setAttributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAsC,MAAM,kBAAkB,CAAC;AAE5F,MAAM,sBAAuB,SAAQ,SAAS;IAC5C,MAAM,CAAC,IAAmB,EAAE,CAAC,UAAU,CAA4B;QACjE,MAAM,EAAE,GAAI,IAAY,CAAC,OAAO,CAAC;QACjC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAC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EvC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YACvD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAClB,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;iBAAM,CAAC;gBACN,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC9D,IAAI,qBAAqB,EAAE,CAAC;oBAC1B,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;oBAE9D,IAAI,gBAAgB,EAAE,CAAC;wBACrB,IAAI,SAAS,EAAE,CAAC;4BACd,0BAA0B;4BAC1B,oBAAoB,CAAC,SAAS,EAAE,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;wBAC3E,CAAC;6BAAM,CAAC;4BACN,2CAA2C;4BAC3C,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;4BACrC,oBAAoB,CAAC,EAAE,EAAE,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;wBACpE,CAAC;oBACH,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,0CAA0C;oBAC1C,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvC,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6DAA6D;IAC7D,MAAM,CAAC,WAAmC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED;;;EAGE;AACF,MAAM,aAAa,GAAG,SAAS,CAAC,sBAAsB,CAAC,CAAC;AAExD,eAAe,aAAa,CAAC","sourcesContent":["import { directive, Directive, AttributePart, DirectiveParameters } from 'lit/directive.js';\n\nconst ARIA_IDREF_ATTRIBUTES = new Map([\n ['aria-activedescendant', 'ariaActivedescendantElement'],\n ['aria-controls', 'ariaControlsElements'],\n ['aria-describedby', 'ariaDescribedByElements'],\n ['aria-details', 'ariaDetailsElements'],\n ['aria-errormessage', 'ariaErrormessageElements'],\n ['aria-flowto', 'ariaFlowtoElements'],\n ['aria-labelledby', 'ariaLabelledByElements'],\n ['aria-owns', 'ariaOwnsElements'],\n]);\n\nfunction resolveAriaIdRefs(element: Element, value: string): HTMLElement[] | null {\n const ids = value\n .trim()\n .split(/\\s+/)\n .filter((id) => id.length > 0);\n\n if (ids.length === 0) return null;\n\n const root = element.getRootNode();\n let resolvedElements: (HTMLElement | null)[] = [];\n\n if (root instanceof ShadowRoot) {\n resolvedElements = ids.map((id) => root.getElementById(id) as HTMLElement | null);\n } else if (root instanceof Document) {\n resolvedElements = ids.map((id) => root.getElementById(id) as HTMLElement | null);\n } else {\n resolvedElements = ids.map((id) => document.getElementById(id) as HTMLElement | null);\n }\n\n if (resolvedElements.filter((el) => el !== null).length === 0) {\n resolvedElements = ids.map((id) => document.getElementById(id) as HTMLElement | null);\n }\n\n const validElements = resolvedElements.filter((el) => el !== null) as HTMLElement[];\n\n return validElements.length === ids.length ? validElements : null;\n}\n\nfunction setInternalsProperty(el: any, name: string, resolvedElements: HTMLElement[]) {\n if (name === 'aria-activedescendant') {\n const [firstElement] = resolvedElements;\n // eslint-disable-next-line no-param-reassign\n el[name] = firstElement;\n } else {\n // eslint-disable-next-line no-param-reassign\n el[name] = resolvedElements;\n }\n}\nclass SetAttributesDirective extends Directive {\n update(part: AttributePart, [attributes]: DirectiveParameters<this>) {\n const el = (part as any).element;\n const internals = el.internals ?? null;\n\n for (const [name, value] of Object.entries(attributes)) {\n if (value == null) {\n el.removeAttribute(name);\n } else {\n const internalsPropertyName = ARIA_IDREF_ATTRIBUTES.get(name);\n if (internalsPropertyName) {\n const resolvedElements = resolveAriaIdRefs(el, String(value));\n\n if (resolvedElements) {\n if (internals) {\n // Set on ElementInternals\n setInternalsProperty(internals, internalsPropertyName, resolvedElements);\n } else {\n // Set internals property on shadowdom item\n el.setAttribute(name, String(value));\n setInternalsProperty(el, internalsPropertyName, resolvedElements);\n }\n }\n } else {\n // Non-ARIA IDREF attributes: set normally\n el.setAttribute(name, String(value));\n }\n }\n }\n return null;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n render(_attributes: Record<string, string>) {\n return null;\n }\n}\n\n/* How to use:\n\n<textarea ${setAttributes(this._ariaAttributes)} ... />\n*/\nconst setAttributes = directive(SetAttributesDirective);\n\nexport default setAttributes;\n"]}
|
|
@@ -13,7 +13,7 @@ export class FormControl extends BaseLocalizedComponent {
|
|
|
13
13
|
});
|
|
14
14
|
// TODO: verificare se serve davvero con il fatto che usiamo form-controller
|
|
15
15
|
// static formAssociated = true;
|
|
16
|
-
//
|
|
16
|
+
// @property()
|
|
17
17
|
// internals = this.attachInternals();
|
|
18
18
|
this._touched = false;
|
|
19
19
|
/** The name of the input, submitted as a name/value pair with form data. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-control.js","sourceRoot":"","sources":["../../../src/form/form-control.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAEjC,mBAAmB,CAAC,EAAE,CAAC,CAAC;AAExB,MAAM,OAAO,WAAY,SAAQ,sBAAsB;IAAvD;;QACqB,0BAAqB,GAAG,IAAI,qBAAqB,CAAC,IAAI,EAAE;YACzE,mBAAmB,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC;SAC1D,CAAC,CAAC;QAEH,4EAA4E;QAC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B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;mDAC/B;AAI5B;IADC,QAAQ,EAAE;;4CACM;AAIjB;IADC,QAAQ,EAAE;;wCAC6B;AAIxC;IADC,QAAQ,EAAE;;wCAC6B;AAOxC;IADC,QAAQ,EAAE;;yCACkB;AAI7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CACZ;AAIf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CACZ;AAIf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,mBAAmB;;;6CAC9C;AAIP;IADT,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;8CACA;AAQrB;IADN,KAAK,EAAE;;sDACsB","sourcesContent":["import { property, query, state } from 'lit/decorators.js';\nimport { registerTranslation } from '@italia/i18n';\nimport { BaseLocalizedComponent } from '../base-component/base-component.js';\nimport { FormControlController } from './form-controller.js';\nimport it from './locales/it.js';\n\nregisterTranslation(it);\n\nexport class FormControl extends BaseLocalizedComponent {\n protected readonly formControlController = new FormControlController(this, {\n assumeInteractionOn: ['it-input', 'it-blur', 'it-change'],\n });\n\n // TODO: verificare se serve davvero con il fatto che usiamo form-controller\n // static formAssociated = true;\n\n // @property()\n // internals = this.attachInternals();\n\n @state()\n _touched = false;\n\n @query('.it-form__control')\n inputElement!: HTMLInputElement; // from FormControl\n\n /** The name of the input, submitted as a name/value pair with form data. */\n @property({ type: String, reflect: true }) // from FormControl\n name = '';\n\n /** The current value of the input, submitted as a name/value pair with form data. */\n @property({ reflect: true })\n value = '';\n\n /** If the input is disabled. */\n @property({ type: Boolean, reflect: true }) // from FormControl\n disabled = false;\n\n /**\n * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you\n * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in\n * the same document or shadow root for this to work.\n */\n @property({ reflect: true, type: String }) form = '';\n\n /** If you implement your custom validation and you won't to trigger default validation */\n @property({ type: Boolean, reflect: true, attribute: 'custom-validation' })\n customValidation = false;\n\n /** If your input is invalid from your custom validition, set this attribute with message validation */\n @property({ attribute: 'validity-message', reflect: true })\n validationText: string = '';\n\n /** Pattern the `value` must match to be valid */\n @property()\n pattern?: string;\n\n /** The input's minimum value. Only applies to date and number input types. */\n @property()\n min: number | string | Date | undefined;\n\n /** The input's maximum value. Only applies to date and number input types. */\n @property()\n max: number | string | Date | undefined;\n\n /**\n * Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is\n * implied, allowing any numeric value. Only applies to date and number input types.\n */\n @property()\n step: number | 'any' = 'any';\n\n /** The input's minimum length. */\n @property({ type: Number })\n minlength = -1;\n\n /** The input's maximum length. */\n @property({ type: Number })\n maxlength = -1;\n\n /** If the input is required. */\n @property({ type: Boolean, reflect: true }) // from FormControl\n required = false;\n\n /* For grouped input, like checkbox-group */\n @property({ type: Boolean })\n protected isInGroup = false;\n\n /** Gets the validity state object */\n public get validity(): ValidityState {\n return this.inputElement?.validity;\n }\n\n @state()\n public validationMessage = '';\n\n /** Gets the associated form, if one exists. */\n public getForm(): HTMLFormElement | null {\n return this.formControlController.getForm();\n }\n\n // Form validation methods\n public checkValidity(): boolean {\n const inputValid = this.inputElement?.checkValidity() ?? true; // this.inputElement.checkValidity() è la validazione del browser\n return inputValid;\n }\n\n /** Checks for validity and shows the browser's validation message if the control is invalid. */\n public reportValidity() {\n // const ret = this.inputElement.checkValidity();\n const ret = this.checkValidity(); // chiama la checkValidity, che se è stata overridata chiama quella\n this.handleValidationMessages();\n return ret; // this.inputElement.reportValidity();\n }\n\n /** Sets a custom validation message. Pass an empty string to restore validity. */\n public setCustomValidity(message: string) {\n this.inputElement.setCustomValidity(message);\n this.validationMessage = this.inputElement.validationMessage;\n this.formControlController.updateValidity();\n }\n\n // Handlers\n protected _handleReady() {\n requestAnimationFrame(() => {\n this.dispatchEvent(new CustomEvent('it-input-ready', { bubbles: true, detail: { el: this.inputElement } }));\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected _handleInput(e: Event) {\n this.handleValidationMessages();\n this.dispatchEvent(\n new CustomEvent('it-input', {\n detail: { value: this.inputElement.value, el: this.inputElement },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected _handleBlur(e: Event) {\n this._touched = true;\n this.handleValidationMessages();\n this.dispatchEvent(new FocusEvent('it-blur', { bubbles: true, composed: true }));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected _handleFocus(e: Event) {\n this.dispatchEvent(new FocusEvent('it-focus', { bubbles: true, composed: true }));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected _handleClick(e: Event) {\n this.dispatchEvent(new MouseEvent('it-click', { bubbles: true, composed: true }));\n }\n\n /*\n Override default browser validation messages\n */\n protected handleValidationMessages() {\n if (!this.customValidation) {\n const _v = this.inputElement.validity;\n\n const isRequiredHandledByGroup = this.isInGroup === true;\n\n if (_v.valueMissing && !isRequiredHandledByGroup) {\n this.setCustomValidity(this.$t('validityRequired'));\n } else if (_v.patternMismatch) {\n this.setCustomValidity(this.$t('validityPattern'));\n } else if (_v.tooShort) {\n this.setCustomValidity(this.$t('validityMinlength').replace('{minlength}', this.minlength.toString()));\n } else if (_v.tooLong) {\n this.setCustomValidity(this.$t('validityMaxlength').replace('{maxlength}', this.maxlength.toString()));\n } else {\n /* nothing. Usa il messaggio di errore della validazione\n di default del browser per altri errori di validità come:\n - typeMismatch\n - rangeUnderflow\n - rangeOverflow\n - stepMismatch\n - badInput */\n\n const otherConstraintErrors =\n _v.typeMismatch || _v.rangeUnderflow || _v.rangeOverflow || _v.stepMismatch || _v.badInput;\n\n if (!otherConstraintErrors) {\n this.setCustomValidity('');\n }\n }\n }\n\n this.validationMessage = this.inputElement.validationMessage;\n }\n\n protected _handleInvalid(event: Event) {\n this.formControlController.setValidity(false);\n this.formControlController.emitInvalidEvent(event);\n }\n\n protected _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('it-change', {\n detail: { value, el: target },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n override updated(changedProperties: Map<string | number | symbol, unknown>) {\n super.updated?.(changedProperties);\n\n if (this.customValidation) {\n this.setCustomValidity(this.validationText ?? '');\n } else if (this.formControlController.userInteracted()) {\n this.formControlController.updateValidity();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"form-control.js","sourceRoot":"","sources":["../../../src/form/form-control.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAEjC,mBAAmB,CAAC,EAAE,CAAC,CAAC;AAExB,MAAM,OAAO,WAAY,SAAQ,sBAAsB;IAAvD;;QACqB,0BAAqB,GAAG,IAAI,qBAAqB,CAAC,IAAI,EAAE;YACzE,mBAAmB,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC;SAC1D,CAAC,CAAC;QAEH,4EAA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AIzB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;mDAC/B;AAI5B;IADC,QAAQ,EAAE;;4CACM;AAIjB;IADC,QAAQ,EAAE;;wCAC6B;AAIxC;IADC,QAAQ,EAAE;;wCAC6B;AAOxC;IADC,QAAQ,EAAE;;yCACkB;AAI7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CACZ;AAIf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CACZ;AAIf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,mBAAmB;;;6CAC9C;AAIP;IADT,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;8CACA;AAQrB;IADN,KAAK,EAAE;;sDACsB","sourcesContent":["import { property, query, state } from 'lit/decorators.js';\nimport { registerTranslation } from '@italia/i18n';\nimport { BaseLocalizedComponent } from '../base-component/base-component.js';\nimport { FormControlController } from './form-controller.js';\nimport it from './locales/it.js';\n\nregisterTranslation(it);\n\nexport class FormControl extends BaseLocalizedComponent {\n protected readonly formControlController = new FormControlController(this, {\n assumeInteractionOn: ['it-input', 'it-blur', 'it-change'],\n });\n\n // TODO: verificare se serve davvero con il fatto che usiamo form-controller\n // static formAssociated = true;\n\n // @property()\n // internals = this.attachInternals();\n\n @state()\n _touched = false;\n\n @query('.it-form__control')\n inputElement!: HTMLInputElement; // from FormControl\n\n /** The name of the input, submitted as a name/value pair with form data. */\n @property({ type: String, reflect: true }) // from FormControl\n name = '';\n\n /** The current value of the input, submitted as a name/value pair with form data. */\n @property({ reflect: true })\n value = '';\n\n /** If the input is disabled. */\n @property({ type: Boolean, reflect: true }) // from FormControl\n disabled = false;\n\n /**\n * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you\n * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in\n * the same document or shadow root for this to work.\n */\n @property({ reflect: true, type: String }) form = '';\n\n /** If you implement your custom validation and you won't to trigger default validation */\n @property({ type: Boolean, reflect: true, attribute: 'custom-validation' })\n customValidation = false;\n\n /** If your input is invalid from your custom validition, set this attribute with message validation */\n @property({ attribute: 'validity-message', reflect: true })\n validationText: string = '';\n\n /** Pattern the `value` must match to be valid */\n @property()\n pattern?: string;\n\n /** The input's minimum value. Only applies to date and number input types. */\n @property()\n min: number | string | Date | undefined;\n\n /** The input's maximum value. Only applies to date and number input types. */\n @property()\n max: number | string | Date | undefined;\n\n /**\n * Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is\n * implied, allowing any numeric value. Only applies to date and number input types.\n */\n @property()\n step: number | 'any' = 'any';\n\n /** The input's minimum length. */\n @property({ type: Number })\n minlength = -1;\n\n /** The input's maximum length. */\n @property({ type: Number })\n maxlength = -1;\n\n /** If the input is required. */\n @property({ type: Boolean, reflect: true }) // from FormControl\n required = false;\n\n /* For grouped input, like checkbox-group */\n @property({ type: Boolean })\n protected isInGroup = false;\n\n /** Gets the validity state object */\n public get validity(): ValidityState {\n return this.inputElement?.validity;\n }\n\n @state()\n public validationMessage = '';\n\n /** Gets the associated form, if one exists. */\n public getForm(): HTMLFormElement | null {\n return this.formControlController.getForm();\n }\n\n // Form validation methods\n public checkValidity(): boolean {\n const inputValid = this.inputElement?.checkValidity() ?? true; // this.inputElement.checkValidity() è la validazione del browser\n return inputValid;\n }\n\n /** Checks for validity and shows the browser's validation message if the control is invalid. */\n public reportValidity() {\n // const ret = this.inputElement.checkValidity();\n const ret = this.checkValidity(); // chiama la checkValidity, che se è stata overridata chiama quella\n this.handleValidationMessages();\n return ret; // this.inputElement.reportValidity();\n }\n\n /** Sets a custom validation message. Pass an empty string to restore validity. */\n public setCustomValidity(message: string) {\n this.inputElement.setCustomValidity(message);\n this.validationMessage = this.inputElement.validationMessage;\n this.formControlController.updateValidity();\n }\n\n // Handlers\n protected _handleReady() {\n requestAnimationFrame(() => {\n this.dispatchEvent(new CustomEvent('it-input-ready', { bubbles: true, detail: { el: this.inputElement } }));\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected _handleInput(e: Event) {\n this.handleValidationMessages();\n this.dispatchEvent(\n new CustomEvent('it-input', {\n detail: { value: this.inputElement.value, el: this.inputElement },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected _handleBlur(e: Event) {\n this._touched = true;\n this.handleValidationMessages();\n this.dispatchEvent(new FocusEvent('it-blur', { bubbles: true, composed: true }));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected _handleFocus(e: Event) {\n this.dispatchEvent(new FocusEvent('it-focus', { bubbles: true, composed: true }));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected _handleClick(e: Event) {\n this.dispatchEvent(new MouseEvent('it-click', { bubbles: true, composed: true }));\n }\n\n /*\n Override default browser validation messages\n */\n protected handleValidationMessages() {\n if (!this.customValidation) {\n const _v = this.inputElement.validity;\n\n const isRequiredHandledByGroup = this.isInGroup === true;\n\n if (_v.valueMissing && !isRequiredHandledByGroup) {\n this.setCustomValidity(this.$t('validityRequired'));\n } else if (_v.patternMismatch) {\n this.setCustomValidity(this.$t('validityPattern'));\n } else if (_v.tooShort) {\n this.setCustomValidity(this.$t('validityMinlength').replace('{minlength}', this.minlength.toString()));\n } else if (_v.tooLong) {\n this.setCustomValidity(this.$t('validityMaxlength').replace('{maxlength}', this.maxlength.toString()));\n } else {\n /* nothing. Usa il messaggio di errore della validazione\n di default del browser per altri errori di validità come:\n - typeMismatch\n - rangeUnderflow\n - rangeOverflow\n - stepMismatch\n - badInput */\n\n const otherConstraintErrors =\n _v.typeMismatch || _v.rangeUnderflow || _v.rangeOverflow || _v.stepMismatch || _v.badInput;\n\n if (!otherConstraintErrors) {\n this.setCustomValidity('');\n }\n }\n }\n\n this.validationMessage = this.inputElement.validationMessage;\n }\n\n protected _handleInvalid(event: Event) {\n this.formControlController.setValidity(false);\n this.formControlController.emitInvalidEvent(event);\n }\n\n protected _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('it-change', {\n detail: { value, el: target },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n override updated(changedProperties: Map<string | number | symbol, unknown>) {\n super.updated?.(changedProperties);\n\n if (this.customValidation) {\n this.setCustomValidity(this.validationText ?? '');\n } else if (this.formControlController.userInteracted()) {\n this.formControlController.updateValidity();\n }\n }\n}\n"]}
|
package/dist/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@ if (typeof window !== 'undefined') {
|
|
|
6
6
|
window._itAnalytics = window._itAnalytics || {};
|
|
7
7
|
window._itAnalytics = {
|
|
8
8
|
...window._itAnalytics,
|
|
9
|
-
version: '1.0.0-alpha.
|
|
9
|
+
version: '1.0.0-alpha.18',
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
export { TrackFocus, setAttributes, AriaKeyboardListController };
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD,OAAO,aAAa,MAAM,+BAA+B,CAAC;AAC1D,OAAO,0BAA0B,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAUzF,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAClC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC;IAChD,MAAM,CAAC,YAAY,GAAG;QACpB,GAAG,MAAM,CAAC,YAAY;QACtB,OAAO,EAAE,gBAAgB;KAC1B,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,0BAA0B,EAAE,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AAEvF,OAAO,EACL,aAAa,EAGb,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,+BAA+B,GAEhC,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAwB,MAAM,wCAAwC,CAAC;AAEnG,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAgC,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACjH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAyC,MAAM,qBAAqB,CAAC;AAE3F,OAAO,EAAE,8BAA8B,EAAE,CAAC","sourcesContent":["import TrackFocus from './utils/track-focus.js';\n\nimport setAttributes from './directives/setAttributes.js';\nimport AriaKeyboardListController from './controllers/aria-keyboard-list-controller.js';\nimport { StoryFormControlMethodAndProps } from './stories/formControlReusableStories.js';\n\ndeclare global {\n interface Window {\n _itAnalytics: {\n version: string;\n };\n }\n}\n\nif (typeof window !== 'undefined') {\n window._itAnalytics = window._itAnalytics || {};\n window._itAnalytics = {\n ...window._itAnalytics,\n version: '1.0.0-alpha.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD,OAAO,aAAa,MAAM,+BAA+B,CAAC;AAC1D,OAAO,0BAA0B,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAUzF,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAClC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC;IAChD,MAAM,CAAC,YAAY,GAAG;QACpB,GAAG,MAAM,CAAC,YAAY;QACtB,OAAO,EAAE,gBAAgB;KAC1B,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,0BAA0B,EAAE,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AAEvF,OAAO,EACL,aAAa,EAGb,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,+BAA+B,GAEhC,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAwB,MAAM,wCAAwC,CAAC;AAEnG,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAgC,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACjH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAyC,MAAM,qBAAqB,CAAC;AAE3F,OAAO,EAAE,8BAA8B,EAAE,CAAC","sourcesContent":["import TrackFocus from './utils/track-focus.js';\n\nimport setAttributes from './directives/setAttributes.js';\nimport AriaKeyboardListController from './controllers/aria-keyboard-list-controller.js';\nimport { StoryFormControlMethodAndProps } from './stories/formControlReusableStories.js';\n\ndeclare global {\n interface Window {\n _itAnalytics: {\n version: string;\n };\n }\n}\n\nif (typeof window !== 'undefined') {\n window._itAnalytics = window._itAnalytics || {};\n window._itAnalytics = {\n ...window._itAnalytics,\n version: '1.0.0-alpha.18',\n };\n}\n\nexport { TrackFocus, setAttributes, AriaKeyboardListController };\nexport type { AriaKeyboardConfig } from './controllers/aria-keyboard-list-controller.js';\nexport { RovingTabindexController } from './controllers/roving-tabindex-controller.js';\nexport type { RovingTabindexConfig } from './controllers/roving-tabindex-controller.js';\nexport {\n BaseComponent,\n BaseComponentInterface,\n BaseComponentType,\n BaseLocalizedComponent,\n} from './base-component/base-component.js';\nexport {\n AriaKeyboardAccordionController,\n type AriaKeyboardAccordionConfig,\n} from './controllers/aria-keyboard-accordion-controller.js';\nexport { CollapseAnimationController } from './controllers/collapse-controller.js';\nexport { FocusTrapController, type FocusTrapConfig } from './controllers/focus-trap-controller.js';\n\nexport { FormControl } from './form/form-control.js';\nexport { formCollections, FormControlControllerOptions, FormControlController } from './form/form-controller.js';\nexport { cookies } from './utils/cookies.js';\nexport type Constructor<T = {}> = new (...args: any[]) => T;\nexport { WindowManager, type ScrollCallback, type ScrollState } from './window-manager.js';\n\nexport { StoryFormControlMethodAndProps };\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": "1.0.0-alpha.
|
|
4
|
+
"version": "1.0.0-alpha.18",
|
|
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": "^1.0.0-alpha.
|
|
38
|
+
"@italia/i18n": "^1.0.0-alpha.18"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@custom-elements-manifest/analyzer": "^0.10.3",
|