/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { Platform, normalizePassiveListenerOptions, _getShadowRoot, _getEventTarget, } from '@angular/cdk/platform'; import { Directive, ElementRef, EventEmitter, Inject, Injectable, InjectionToken, NgZone, Optional, Output, } from '@angular/core'; import { of as observableOf, Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { coerceElement } from '@angular/cdk/coercion'; import { DOCUMENT } from '@angular/common'; import { InputModalityDetector, TOUCH_BUFFER_MS } from '../input-modality/input-modality-detector'; import * as i0 from "@angular/core"; import * as i1 from "@angular/cdk/platform"; import * as i2 from "../input-modality/input-modality-detector"; /** InjectionToken for FocusMonitorOptions. */ export const FOCUS_MONITOR_DEFAULT_OPTIONS = new InjectionToken('cdk-focus-monitor-default-options'); /** * Event listener options that enable capturing and also * mark the listener as passive if the browser supports it. */ const captureEventListenerOptions = normalizePassiveListenerOptions({ passive: true, capture: true, }); /** Monitors mouse and keyboard events to determine the cause of focus events. */ export class FocusMonitor { constructor(_ngZone, _platform, _inputModalityDetector, /** @breaking-change 11.0.0 make document required */ document, options) { this._ngZone = _ngZone; this._platform = _platform; this._inputModalityDetector = _inputModalityDetector; /** The focus origin that the next focus event is a result of. */ this._origin = null; /** Whether the window has just been focused. */ this._windowFocused = false; /** * Whether the origin was determined via a touch interaction. Necessary as properly attributing * focus events to touch interactions requires special logic. */ this._originFromTouchInteraction = false; /** Map of elements being monitored to their info. */ this._elementInfo = new Map(); /** The number of elements currently being monitored. */ this._monitoredElementCount = 0; /** * Keeps track of the root nodes to which we've currently bound a focus/blur handler, * as well as the number of monitored elements that they contain. We have to treat focus/blur * handlers differently from the rest of the events, because the browser won't emit events * to the document when focus moves inside of a shadow root. */ this._rootNodeFocusListenerCount = new Map(); /** * Event listener for `focus` events on the window. * Needs to be an arrow function in order to preserve the context when it gets bound. */ this._windowFocusListener = () => { // Make a note of when the window regains focus, so we can // restore the origin info for the focused element. this._windowFocused = true; this._windowFocusTimeoutId = window.setTimeout(() => (this._windowFocused = false)); }; /** Subject for stopping our InputModalityDetector subscription. */ this._stopInputModalityDetector = new Subject(); /** * Event listener for `focus` and 'blur' events on the document. * Needs to be an arrow function in order to preserve the context when it gets bound. */ this._rootNodeFocusAndBlurListener = (event) => { const target = _getEventTarget(event); // We need to walk up the ancestor chain in order to support `checkChildren`. for (let element = target; element; element = element.parentElement) { if (event.type === 'focus') { this._onFocus(event, element); } else { this._onBlur(event, element); } } }; this._document = document; this._detectionMode = options?.detectionMode || 0 /* FocusMonitorDetectionMode.IMMEDIATE */; } monitor(element, checkChildren = false) { const nativeElement = coerceElement(element); // Do nothing if we're not on the browser platform or the passed in node isn't an element. if (!this._platform.isBrowser || nativeElement.nodeType !== 1) { // Note: we don't want the observable to emit at all so we don't pass any parameters. return observableOf(); } // If the element is inside the shadow DOM, we need to bind our focus/blur listeners to // the shadow root, rather than the `document`, because the browser won't emit focus events // to the `document`, if focus is moving within the same shadow root. const rootNode = _getShadowRoot(nativeElement) || this._getDocument(); const cachedInfo = this._elementInfo.get(nativeElement); // Check if we're already monitoring this element. if (cachedInfo) { if (checkChildren) { // TODO(COMP-318): this can be problematic, because it'll turn all non-checkChildren // observers into ones that behave as if `checkChildren` was turned on. We need a more // robust solution. cachedInfo.checkChildren = true; } return cachedInfo.subject; } // Create monitored element info. const info = { checkChildren: checkChildren, subject: new Subject(), rootNode, }; this._elementInfo.set(nativeElement, info); this._registerGlobalListeners(info); return info.subject; } stopMonitoring(element) { const nativeElement = coerceElement(element); const elementInfo = this._elementInfo.get(nativeElement); if (elementInfo) { elementInfo.subject.complete(); this._setClasses(nativeElement); this._elementInfo.delete(nativeElement); this._removeGlobalListeners(elementInfo); } } focusVia(element, origin, options) { const nativeElement = coerceElement(element); const focusedElement = this._getDocument().activeElement; // If the element is focused already, calling `focus` again won't trigger the event listener // which means that the focus classes won't be updated. If that's the case, update the classes // directly without waiting for an event. if (nativeElement === focusedElement) { this._getClosestElementsInfo(nativeElement).forEach(([currentElement, info]) => this._originChanged(currentElement, origin, info)); } else { this._setOrigin(origin); // `focus` isn't available on the server if (typeof nativeElement.focus === 'function') { nativeElement.focus(options); } } } ngOnDestroy() { this._elementInfo.forEach((_info, element) => this.stopMonitoring(element)); } /** Access injected document if available or fallback to global document reference */ _getDocument() { return this._document || document; } /** Use defaultView of injected document if available or fallback to global window reference */ _getWindow() { const doc = this._getDocument(); return doc.defaultView || window; } _getFocusOrigin(focusEventTarget) { if (this._origin) { // If the origin was realized via a touch interaction, we need to perform additional checks // to determine whether the focus origin should be attributed to touch or program. if (this._originFromTouchInteraction) { return this._shouldBeAttributedToTouch(focusEventTarget) ? 'touch' : 'program'; } else { return this._origin; } } // If the window has just regained focus, we can restore the most recent origin from before the // window blurred. Otherwise, we've reached the point where we can't identify the source of the // focus. This typically means one of two things happened: // // 1) The element was programmatically focused, or // 2) The element was focused via screen reader navigation (which generally doesn't fire // events). // // Because we can't distinguish between these two cases, we default to setting `program`. if (this._windowFocused && this._lastFocusOrigin) { return this._lastFocusOrigin; } // If the interaction is coming from an input label, we consider it a mouse interactions. // This is a special case where focus moves on `click`, rather than `mousedown` which breaks // our detection, because all our assumptions are for `mousedown`. We need to handle this // special case, because it's very common for checkboxes and radio buttons. if (focusEventTarget && this._isLastInteractionFromInputLabel(focusEventTarget)) { return 'mouse'; } return 'program'; } /** * Returns whether the focus event should be attributed to touch. Recall that in IMMEDIATE mode, a * touch origin isn't immediately reset at the next tick (see _setOrigin). This means that when we * handle a focus event following a touch interaction, we need to determine whether (1) the focus * event was directly caused by the touch interaction or (2) the focus event was caused by a * subsequent programmatic focus call triggered by the touch interaction. * @param focusEventTarget The target of the focus event under examination. */ _shouldBeAttributedToTouch(focusEventTarget) { // Please note that this check is not perfect. Consider the following edge case: // //
//
//
// // Suppose there is a FocusMonitor in IMMEDIATE mode attached to #parent. When the user touches // #child, #parent is programmatically focused. This code will attribute the focus to touch // instead of program. This is a relatively minor edge-case that can be worked around by using // focusVia(parent, 'program') to focus #parent. return (this._detectionMode === 1 /* FocusMonitorDetectionMode.EVENTUAL */ || !!focusEventTarget?.contains(this._inputModalityDetector._mostRecentTarget)); } /** * Sets the focus classes on the element based on the given focus origin. * @param element The element to update the classes on. * @param origin The focus origin. */ _setClasses(element, origin) { element.classList.toggle('cdk-focused', !!origin); element.classList.toggle('cdk-touch-focused', origin === 'touch'); element.classList.toggle('cdk-keyboard-focused', origin === 'keyboard'); element.classList.toggle('cdk-mouse-focused', origin === 'mouse'); element.classList.toggle('cdk-program-focused', origin === 'program'); } /** * Updates the focus origin. If we're using immediate detection mode, we schedule an async * function to clear the origin at the end of a timeout. The duration of the timeout depends on * the origin being set. * @param origin The origin to set. * @param isFromInteraction Whether we are setting the origin from an interaction event. */ _setOrigin(origin, isFromInteraction = false) { this._ngZone.runOutsideAngular(() => { this._origin = origin; this._originFromTouchInteraction = origin === 'touch' && isFromInteraction; // If we're in IMMEDIATE mode, reset the origin at the next tick (or in `TOUCH_BUFFER_MS` ms // for a touch event). We reset the origin at the next tick because Firefox focuses one tick // after the interaction event. We wait `TOUCH_BUFFER_MS` ms before resetting the origin for // a touch event because when a touch event is fired, the associated focus event isn't yet in // the event queue. Before doing so, clear any pending timeouts. if (this._detectionMode === 0 /* FocusMonitorDetectionMode.IMMEDIATE */) { clearTimeout(this._originTimeoutId); const ms = this._originFromTouchInteraction ? TOUCH_BUFFER_MS : 1; this._originTimeoutId = setTimeout(() => (this._origin = null), ms); } }); } /** * Handles focus events on a registered element. * @param event The focus event. * @param element The monitored element. */ _onFocus(event, element) { // NOTE(mmalerba): We currently set the classes based on the focus origin of the most recent // focus event affecting the monitored element. If we want to use the origin of the first event // instead we should check for the cdk-focused class here and return if the element already has // it. (This only matters for elements that have includesChildren = true). // If we are not counting child-element-focus as focused, make sure that the event target is the // monitored element itself. const elementInfo = this._elementInfo.get(element); const focusEventTarget = _getEventTarget(event); if (!elementInfo || (!elementInfo.checkChildren && element !== focusEventTarget)) { return; } this._originChanged(element, this._getFocusOrigin(focusEventTarget), elementInfo); } /** * Handles blur events on a registered element. * @param event The blur event. * @param element The monitored element. */ _onBlur(event, element) { // If we are counting child-element-focus as focused, make sure that we aren't just blurring in // order to focus another child of the monitored element. const elementInfo = this._elementInfo.get(element); if (!elementInfo || (elementInfo.checkChildren && event.relatedTarget instanceof Node && element.contains(event.relatedTarget))) { return; } this._setClasses(element); this._emitOrigin(elementInfo, null); } _emitOrigin(info, origin) { if (info.subject.observers.length) { this._ngZone.run(() => info.subject.next(origin)); } } _registerGlobalListeners(elementInfo) { if (!this._platform.isBrowser) { return; } const rootNode = elementInfo.rootNode; const rootNodeFocusListeners = this._rootNodeFocusListenerCount.get(rootNode) || 0; if (!rootNodeFocusListeners) { this._ngZone.runOutsideAngular(() => { rootNode.addEventListener('focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions); rootNode.addEventListener('blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions); }); } this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners + 1); // Register global listeners when first element is monitored. if (++this._monitoredElementCount === 1) { // Note: we listen to events in the capture phase so we // can detect them even if the user stops propagation. this._ngZone.runOutsideAngular(() => { const window = this._getWindow(); window.addEventListener('focus', this._windowFocusListener); }); // The InputModalityDetector is also just a collection of global listeners. this._inputModalityDetector.modalityDetected .pipe(takeUntil(this._stopInputModalityDetector)) .subscribe(modality => { this._setOrigin(modality, true /* isFromInteraction */); }); } } _removeGlobalListeners(elementInfo) { const rootNode = elementInfo.rootNode; if (this._rootNodeFocusListenerCount.has(rootNode)) { const rootNodeFocusListeners = this._rootNodeFocusListenerCount.get(rootNode); if (rootNodeFocusListeners > 1) { this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners - 1); } else { rootNode.removeEventListener('focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions); rootNode.removeEventListener('blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions); this._rootNodeFocusListenerCount.delete(rootNode); } } // Unregister global listeners when last element is unmonitored. if (!--this._monitoredElementCount) { const window = this._getWindow(); window.removeEventListener('focus', this._windowFocusListener); // Equivalently, stop our InputModalityDetector subscription. this._stopInputModalityDetector.next(); // Clear timeouts for all potentially pending timeouts to prevent the leaks. clearTimeout(this._windowFocusTimeoutId); clearTimeout(this._originTimeoutId); } } /** Updates all the state on an element once its focus origin has changed. */ _originChanged(element, origin, elementInfo) { this._setClasses(element, origin); this._emitOrigin(elementInfo, origin); this._lastFocusOrigin = origin; } /** * Collects the `MonitoredElementInfo` of a particular element and * all of its ancestors that have enabled `checkChildren`. * @param element Element from which to start the search. */ _getClosestElementsInfo(element) { const results = []; this._elementInfo.forEach((info, currentElement) => { if (currentElement === element || (info.checkChildren && currentElement.contains(element))) { results.push([currentElement, info]); } }); return results; } /** * Returns whether an interaction is likely to have come from the user clicking the `label` of * an `input` or `textarea` in order to focus it. * @param focusEventTarget Target currently receiving focus. */ _isLastInteractionFromInputLabel(focusEventTarget) { const { _mostRecentTarget: mostRecentTarget, mostRecentModality } = this._inputModalityDetector; // If the last interaction used the mouse on an element contained by one of the labels // of an `input`/`textarea` that is currently focused, it is very likely that the // user redirected focus using the label. if (mostRecentModality !== 'mouse' || !mostRecentTarget || mostRecentTarget === focusEventTarget || (focusEventTarget.nodeName !== 'INPUT' && focusEventTarget.nodeName !== 'TEXTAREA') || focusEventTarget.disabled) { return false; } const labels = focusEventTarget.labels; if (labels) { for (let i = 0; i < labels.length; i++) { if (labels[i].contains(mostRecentTarget)) { return true; } } } return false; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: FocusMonitor, deps: [{ token: i0.NgZone }, { token: i1.Platform }, { token: i2.InputModalityDetector }, { token: DOCUMENT, optional: true }, { token: FOCUS_MONITOR_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: FocusMonitor, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: FocusMonitor, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: i1.Platform }, { type: i2.InputModalityDetector }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT] }] }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FOCUS_MONITOR_DEFAULT_OPTIONS] }] }]; } }); /** * Directive that determines how a particular element was focused (via keyboard, mouse, touch, or * programmatically) and adds corresponding classes to the element. * * There are two variants of this directive: * 1) cdkMonitorElementFocus: does not consider an element to be focused if one of its children is * focused. * 2) cdkMonitorSubtreeFocus: considers an element focused if it or any of its children are focused. */ export class CdkMonitorFocus { constructor(_elementRef, _focusMonitor) { this._elementRef = _elementRef; this._focusMonitor = _focusMonitor; this._focusOrigin = null; this.cdkFocusChange = new EventEmitter(); } get focusOrigin() { return this._focusOrigin; } ngAfterViewInit() { const element = this._elementRef.nativeElement; this._monitorSubscription = this._focusMonitor .monitor(element, element.nodeType === 1 && element.hasAttribute('cdkMonitorSubtreeFocus')) .subscribe(origin => { this._focusOrigin = origin; this.cdkFocusChange.emit(origin); }); } ngOnDestroy() { this._focusMonitor.stopMonitoring(this._elementRef); if (this._monitorSubscription) { this._monitorSubscription.unsubscribe(); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: CdkMonitorFocus, deps: [{ token: i0.ElementRef }, { token: FocusMonitor }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: CdkMonitorFocus, selector: "[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]", outputs: { cdkFocusChange: "cdkFocusChange" }, exportAs: ["cdkMonitorFocus"], ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: CdkMonitorFocus, decorators: [{ type: Directive, args: [{ selector: '[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]', exportAs: 'cdkMonitorFocus', }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: FocusMonitor }]; }, propDecorators: { cdkFocusChange: [{ type: Output }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9jdXMtbW9uaXRvci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9jZGsvYTExeS9mb2N1cy1tb25pdG9yL2ZvY3VzLW1vbml0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUNMLFFBQVEsRUFDUiwrQkFBK0IsRUFDL0IsY0FBYyxFQUNkLGVBQWUsR0FDaEIsTUFBTSx1QkFBdUIsQ0FBQztBQUMvQixPQUFPLEVBQ0wsU0FBUyxFQUNULFVBQVUsRUFDVixZQUFZLEVBQ1osTUFBTSxFQUNOLFVBQVUsRUFDVixjQUFjLEVBQ2QsTUFBTSxFQUVOLFFBQVEsRUFDUixNQUFNLEdBRVAsTUFBTSxlQUFlLENBQUM7QUFDdkIsT0FBTyxFQUFhLEVBQUUsSUFBSSxZQUFZLEVBQUUsT0FBTyxFQUFlLE1BQU0sTUFBTSxDQUFDO0FBQzNFLE9BQU8sRUFBQyxTQUFTLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQUN6QyxPQUFPLEVBQUMsYUFBYSxFQUFDLE1BQU0sdUJBQXVCLENBQUM7QUFDcEQsT0FBTyxFQUFDLFFBQVEsRUFBQyxNQUFNLGlCQUFpQixDQUFDO0FBQ3pDLE9BQU8sRUFBQyxxQkFBcUIsRUFBRSxlQUFlLEVBQUMsTUFBTSwyQ0FBMkMs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