@angular/cdk 19.1.0-next.2 → 19.1.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/a11y/index.d.ts +4 -3
  2. package/dialog/index.d.ts +1 -0
  3. package/drag-drop/index.d.ts +34 -3
  4. package/fesm2022/a11y.mjs +82 -81
  5. package/fesm2022/a11y.mjs.map +1 -1
  6. package/fesm2022/accordion.mjs +10 -10
  7. package/fesm2022/bidi.mjs +10 -10
  8. package/fesm2022/cdk.mjs +1 -1
  9. package/fesm2022/cdk.mjs.map +1 -1
  10. package/fesm2022/clipboard.mjs +10 -10
  11. package/fesm2022/collections.mjs +3 -3
  12. package/fesm2022/dialog.mjs +16 -15
  13. package/fesm2022/dialog.mjs.map +1 -1
  14. package/fesm2022/drag-drop.mjs +153 -114
  15. package/fesm2022/drag-drop.mjs.map +1 -1
  16. package/fesm2022/layout.mjs +10 -10
  17. package/fesm2022/listbox.mjs +23 -29
  18. package/fesm2022/listbox.mjs.map +1 -1
  19. package/fesm2022/menu.mjs +131 -114
  20. package/fesm2022/menu.mjs.map +1 -1
  21. package/fesm2022/observers/private.mjs +8 -8
  22. package/fesm2022/observers/private.mjs.map +1 -1
  23. package/fesm2022/observers.mjs +13 -13
  24. package/fesm2022/overlay.mjs +89 -106
  25. package/fesm2022/overlay.mjs.map +1 -1
  26. package/fesm2022/platform.mjs +30 -9
  27. package/fesm2022/platform.mjs.map +1 -1
  28. package/fesm2022/portal.mjs +16 -16
  29. package/fesm2022/private.mjs +6 -6
  30. package/fesm2022/scrolling.mjs +64 -86
  31. package/fesm2022/scrolling.mjs.map +1 -1
  32. package/fesm2022/stepper.mjs +22 -22
  33. package/fesm2022/table.mjs +76 -76
  34. package/fesm2022/testing/testbed.mjs +83 -40
  35. package/fesm2022/testing/testbed.mjs.map +1 -1
  36. package/fesm2022/text-field.mjs +42 -52
  37. package/fesm2022/text-field.mjs.map +1 -1
  38. package/fesm2022/tree.mjs +25 -25
  39. package/listbox/index.d.ts +1 -5
  40. package/menu/index.d.ts +18 -19
  41. package/observers/private/index.d.ts +1 -0
  42. package/overlay/index.d.ts +12 -6
  43. package/package.json +1 -1
  44. package/platform/index.d.ts +10 -0
  45. package/schematics/ng-add/index.js +1 -1
  46. package/schematics/ng-add/index.mjs +1 -1
  47. package/scrolling/index.d.ts +7 -14
  48. package/text-field/index.d.ts +4 -4
package/a11y/index.d.ts CHANGED
@@ -318,6 +318,8 @@ export declare class FocusKeyManager<T> extends ListKeyManager<FocusableOption &
318
318
  export declare class FocusMonitor implements OnDestroy {
319
319
  private _ngZone;
320
320
  private _platform;
321
+ private _renderer;
322
+ private _cleanupWindowFocus;
321
323
  private readonly _inputModalityDetector;
322
324
  /** The focus origin that the next focus event is a result of. */
323
325
  private _origin;
@@ -344,7 +346,7 @@ export declare class FocusMonitor implements OnDestroy {
344
346
  * handlers differently from the rest of the events, because the browser won't emit events
345
347
  * to the document when focus moves inside of a shadow root.
346
348
  */
347
- private _rootNodeFocusListenerCount;
349
+ private _rootNodeFocusListeners;
348
350
  /**
349
351
  * The specified detection mode, used for attributing the origin of a focus
350
352
  * event.
@@ -408,8 +410,6 @@ export declare class FocusMonitor implements OnDestroy {
408
410
  ngOnDestroy(): void;
409
411
  /** Access injected document if available or fallback to global document reference */
410
412
  private _getDocument;
411
- /** Use defaultView of injected document if available or fallback to global window reference */
412
- private _getWindow;
413
413
  private _getFocusOrigin;
414
414
  /**
415
415
  * Returns whether the focus event should be attributed to touch. Recall that in IMMEDIATE mode, a
@@ -788,6 +788,7 @@ export declare type InputModality = 'keyboard' | 'mouse' | 'touch' | null;
788
788
  */
789
789
  export declare class InputModalityDetector implements OnDestroy {
790
790
  private readonly _platform;
791
+ private readonly _listenerCleanups;
791
792
  /** Emits whenever an input modality is detected. */
792
793
  readonly modalityDetected: Observable<InputModality>;
793
794
  /** Emits when the input modality changes. */
package/dialog/index.d.ts CHANGED
@@ -45,6 +45,7 @@ export declare class CdkDialogContainer<C extends DialogConfig = DialogConfig> e
45
45
  protected _ngZone: NgZone;
46
46
  private _overlayRef;
47
47
  private _focusMonitor;
48
+ private _renderer;
48
49
  private _platform;
49
50
  protected _document: Document;
50
51
  /** The portal outlet inside of this container into which the dialog content will be loaded. */
@@ -10,6 +10,7 @@ import { NumberInput } from '@angular/cdk/coercion';
10
10
  import { Observable } from 'rxjs';
11
11
  import { OnChanges } from '@angular/core';
12
12
  import { OnDestroy } from '@angular/core';
13
+ import { Renderer2 } from '@angular/core';
13
14
  import { SimpleChanges } from '@angular/core';
14
15
  import { Subject } from 'rxjs';
15
16
  import { TemplateRef } from '@angular/core';
@@ -75,8 +76,8 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDes
75
76
  private _changeDetectorRef;
76
77
  private _selfHandle;
77
78
  private _parentDrag;
79
+ private _dragDropRegistry;
78
80
  private readonly _destroyed;
79
- private static _dragInstances;
80
81
  private _handles;
81
82
  private _previewTemplate;
82
83
  private _placeholderTemplate;
@@ -273,9 +274,10 @@ export declare interface CdkDragExit<T = any, I = T> {
273
274
  }
274
275
 
275
276
  /** Handle that can be used to drag a CdkDrag instance. */
276
- export declare class CdkDragHandle implements OnDestroy {
277
+ export declare class CdkDragHandle implements AfterViewInit, OnDestroy {
277
278
  element: ElementRef<HTMLElement>;
278
279
  private _parentDrag;
280
+ private _dragDropRegistry;
279
281
  /** Emits when the state of the handle has changed. */
280
282
  readonly _stateChanges: Subject<CdkDragHandle>;
281
283
  /** Whether starting to drag through this handle is disabled. */
@@ -283,6 +285,7 @@ export declare class CdkDragHandle implements OnDestroy {
283
285
  set disabled(value: boolean);
284
286
  private _disabled;
285
287
  constructor(...args: unknown[]);
288
+ ngAfterViewInit(): void;
286
289
  ngOnDestroy(): void;
287
290
  static ɵfac: i0.ɵɵFactoryDeclaration<CdkDragHandle, never>;
288
291
  static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDragHandle, "[cdkDragHandle]", never, { "disabled": { "alias": "cdkDragHandleDisabled"; "required": false; }; }, {}, never, never, true, never>;
@@ -528,6 +531,7 @@ export declare class DragDrop {
528
531
  private _ngZone;
529
532
  private _viewportRuler;
530
533
  private _dragDropRegistry;
534
+ private _renderer;
531
535
  constructor(...args: unknown[]);
532
536
  /**
533
537
  * Turns an element into a draggable item.
@@ -578,6 +582,8 @@ export declare class DragDropRegistry<_ = unknown, __ = unknown> implements OnDe
578
582
  private _ngZone;
579
583
  private _document;
580
584
  private _styleLoader;
585
+ private _renderer;
586
+ private _cleanupDocumentTouchmove;
581
587
  /** Registered drop container instances. */
582
588
  private _dropInstances;
583
589
  /** Registered drag item instances. */
@@ -591,6 +597,12 @@ export declare class DragDropRegistry<_ = unknown, __ = unknown> implements OnDe
591
597
  * because it'll be called a lot and we don't want to create a new function every time.
592
598
  */
593
599
  private _draggingPredicate;
600
+ /**
601
+ * Map tracking DOM nodes and their corresponding drag directives. Note that this is different
602
+ * from looking through the `_dragInstances` and getting their root node, because the root node
603
+ * isn't necessarily the node that the directive is set on.
604
+ */
605
+ private _domNodesToDirectives;
594
606
  /**
595
607
  * Emits the `touchmove` or `mousemove` events that are dispatched
596
608
  * while the user is dragging a drag item instance.
@@ -634,6 +646,22 @@ export declare class DragDropRegistry<_ = unknown, __ = unknown> implements OnDe
634
646
  * be used to include an additional top-level listener at the shadow root level.
635
647
  */
636
648
  scrolled(shadowRoot?: DocumentOrShadowRoot | null): Observable<Event>;
649
+ /**
650
+ * Tracks the DOM node which has a draggable directive.
651
+ * @param node Node to track.
652
+ * @param dragRef Drag directive set on the node.
653
+ */
654
+ registerDirectiveNode(node: Node, dragRef: CdkDrag): void;
655
+ /**
656
+ * Stops tracking a draggable directive node.
657
+ * @param node Node to stop tracking.
658
+ */
659
+ removeDirectiveNode(node: Node): void;
660
+ /**
661
+ * Gets the drag directive corresponding to a specific DOM node, if any.
662
+ * @param node Node for which to do the lookup.
663
+ */
664
+ getDragDirectiveForNode(node: Node): CdkDrag | null;
637
665
  ngOnDestroy(): void;
638
666
  /**
639
667
  * Event listener that will prevent the default browser action while the user is dragging.
@@ -672,6 +700,9 @@ export declare class DragRef<T = any> {
672
700
  private _ngZone;
673
701
  private _viewportRuler;
674
702
  private _dragDropRegistry;
703
+ private _renderer;
704
+ private _rootElementCleanups;
705
+ private _cleanupShadowRootSelectStart;
675
706
  /** Element displayed next to the user's pointer while the element is dragged. */
676
707
  private _preview;
677
708
  /** Container into which to insert the preview. */
@@ -870,7 +901,7 @@ export declare class DragRef<T = any> {
870
901
  * Should return a point describing where the item should be rendered.
871
902
  */
872
903
  constrainPosition?: (userPointerPosition: Point, dragRef: DragRef, dimensions: DOMRect, pickupPositionInElement: Point) => Point;
873
- constructor(element: ElementRef<HTMLElement> | HTMLElement, _config: DragRefConfig, _document: Document, _ngZone: NgZone, _viewportRuler: ViewportRuler, _dragDropRegistry: DragDropRegistry);
904
+ constructor(element: ElementRef<HTMLElement> | HTMLElement, _config: DragRefConfig, _document: Document, _ngZone: NgZone, _viewportRuler: ViewportRuler, _dragDropRegistry: DragDropRegistry, _renderer: Renderer2);
874
905
  /**
875
906
  * Returns the element that is being used as a placeholder
876
907
  * while the current element is being dragged.
package/fesm2022/a11y.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { DOCUMENT } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { inject, APP_ID, Injectable, signal, QueryList, isSignal, effect, InjectionToken, afterNextRender, NgZone, Injector, ElementRef, booleanAttribute, Directive, Input, EventEmitter, Output, NgModule } from '@angular/core';
4
- import { Platform, _getFocusedElementPierceShadowDom, normalizePassiveListenerOptions, _getEventTarget, _getShadowRoot } from '@angular/cdk/platform';
3
+ import { inject, APP_ID, Injectable, signal, QueryList, isSignal, effect, InjectionToken, afterNextRender, NgZone, Injector, ElementRef, booleanAttribute, Directive, Input, RendererFactory2, EventEmitter, Output, NgModule } from '@angular/core';
4
+ import { Platform, _getFocusedElementPierceShadowDom, _getEventTarget, _bindEventWithOptions, _getShadowRoot } from '@angular/cdk/platform';
5
5
  import { _CdkPrivateStyleLoader, _VisuallyHiddenLoader } from '@angular/cdk/private';
6
6
  import { A, Z, ZERO, NINE, hasModifierKey, PAGE_DOWN, PAGE_UP, END, HOME, LEFT_ARROW, RIGHT_ARROW, UP_ARROW, DOWN_ARROW, TAB, ALT, CONTROL, MAC_META, META, SHIFT } from '@angular/cdk/keycodes';
7
7
  import { Subject, Subscription, isObservable, of, BehaviorSubject } from 'rxjs';
@@ -244,10 +244,10 @@ class AriaDescriber {
244
244
  _isElementNode(element) {
245
245
  return element.nodeType === this._document.ELEMENT_NODE;
246
246
  }
247
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: AriaDescriber, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
248
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: AriaDescriber, providedIn: 'root' });
247
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: AriaDescriber, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
248
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: AriaDescriber, providedIn: 'root' });
249
249
  }
250
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: AriaDescriber, decorators: [{
250
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: AriaDescriber, decorators: [{
251
251
  type: Injectable,
252
252
  args: [{ providedIn: 'root' }]
253
253
  }], ctorParameters: () => [] });
@@ -1276,10 +1276,10 @@ class InteractivityChecker {
1276
1276
  !this.isDisabled(element) &&
1277
1277
  (config?.ignoreVisibility || this.isVisible(element)));
1278
1278
  }
1279
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: InteractivityChecker, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1280
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: InteractivityChecker, providedIn: 'root' });
1279
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: InteractivityChecker, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1280
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: InteractivityChecker, providedIn: 'root' });
1281
1281
  }
1282
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: InteractivityChecker, decorators: [{
1282
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: InteractivityChecker, decorators: [{
1283
1283
  type: Injectable,
1284
1284
  args: [{ providedIn: 'root' }]
1285
1285
  }], ctorParameters: () => [] });
@@ -1678,10 +1678,10 @@ class FocusTrapFactory {
1678
1678
  create(element, deferCaptureElements = false) {
1679
1679
  return new FocusTrap(element, this._checker, this._ngZone, this._document, deferCaptureElements, this._injector);
1680
1680
  }
1681
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: FocusTrapFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1682
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: FocusTrapFactory, providedIn: 'root' });
1681
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: FocusTrapFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1682
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: FocusTrapFactory, providedIn: 'root' });
1683
1683
  }
1684
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: FocusTrapFactory, decorators: [{
1684
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: FocusTrapFactory, decorators: [{
1685
1685
  type: Injectable,
1686
1686
  args: [{ providedIn: 'root' }]
1687
1687
  }], ctorParameters: () => [] });
@@ -1746,10 +1746,10 @@ class CdkTrapFocus {
1746
1746
  this._previouslyFocusedElement = _getFocusedElementPierceShadowDom();
1747
1747
  this.focusTrap?.focusInitialElementWhenReady();
1748
1748
  }
1749
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: CdkTrapFocus, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1750
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "19.1.0-next.2", type: CdkTrapFocus, isStandalone: true, selector: "[cdkTrapFocus]", inputs: { enabled: ["cdkTrapFocus", "enabled", booleanAttribute], autoCapture: ["cdkTrapFocusAutoCapture", "autoCapture", booleanAttribute] }, exportAs: ["cdkTrapFocus"], usesOnChanges: true, ngImport: i0 });
1749
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: CdkTrapFocus, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1750
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "19.1.0-next.3", type: CdkTrapFocus, isStandalone: true, selector: "[cdkTrapFocus]", inputs: { enabled: ["cdkTrapFocus", "enabled", booleanAttribute], autoCapture: ["cdkTrapFocusAutoCapture", "autoCapture", booleanAttribute] }, exportAs: ["cdkTrapFocus"], usesOnChanges: true, ngImport: i0 });
1751
1751
  }
1752
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: CdkTrapFocus, decorators: [{
1752
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: CdkTrapFocus, decorators: [{
1753
1753
  type: Directive,
1754
1754
  args: [{
1755
1755
  selector: '[cdkTrapFocus]',
@@ -1897,10 +1897,10 @@ class FocusTrapManager {
1897
1897
  }
1898
1898
  }
1899
1899
  }
1900
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: FocusTrapManager, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1901
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: FocusTrapManager, providedIn: 'root' });
1900
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: FocusTrapManager, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1901
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: FocusTrapManager, providedIn: 'root' });
1902
1902
  }
1903
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: FocusTrapManager, decorators: [{
1903
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: FocusTrapManager, decorators: [{
1904
1904
  type: Injectable,
1905
1905
  args: [{ providedIn: 'root' }]
1906
1906
  }] });
@@ -1928,10 +1928,10 @@ class ConfigurableFocusTrapFactory {
1928
1928
  }
1929
1929
  return new ConfigurableFocusTrap(element, this._checker, this._ngZone, this._document, this._focusTrapManager, this._inertStrategy, configObject, this._injector);
1930
1930
  }
1931
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: ConfigurableFocusTrapFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1932
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: ConfigurableFocusTrapFactory, providedIn: 'root' });
1931
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: ConfigurableFocusTrapFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1932
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: ConfigurableFocusTrapFactory, providedIn: 'root' });
1933
1933
  }
1934
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: ConfigurableFocusTrapFactory, decorators: [{
1934
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: ConfigurableFocusTrapFactory, decorators: [{
1935
1935
  type: Injectable,
1936
1936
  args: [{ providedIn: 'root' }]
1937
1937
  }], ctorParameters: () => [] });
@@ -1994,10 +1994,10 @@ const TOUCH_BUFFER_MS = 650;
1994
1994
  * Event listener options that enable capturing and also mark the listener as passive if the browser
1995
1995
  * supports it.
1996
1996
  */
1997
- const modalityEventListenerOptions = normalizePassiveListenerOptions({
1997
+ const modalityEventListenerOptions = {
1998
1998
  passive: true,
1999
1999
  capture: true,
2000
- });
2000
+ };
2001
2001
  /**
2002
2002
  * Service that detects the user's input modality.
2003
2003
  *
@@ -2014,6 +2014,7 @@ const modalityEventListenerOptions = normalizePassiveListenerOptions({
2014
2014
  */
2015
2015
  class InputModalityDetector {
2016
2016
  _platform = inject(Platform);
2017
+ _listenerCleanups;
2017
2018
  /** Emits whenever an input modality is detected. */
2018
2019
  modalityDetected;
2019
2020
  /** Emits when the input modality changes. */
@@ -2096,25 +2097,24 @@ class InputModalityDetector {
2096
2097
  // If we're not in a browser, this service should do nothing, as there's no relevant input
2097
2098
  // modality to detect.
2098
2099
  if (this._platform.isBrowser) {
2099
- ngZone.runOutsideAngular(() => {
2100
- document.addEventListener('keydown', this._onKeydown, modalityEventListenerOptions);
2101
- document.addEventListener('mousedown', this._onMousedown, modalityEventListenerOptions);
2102
- document.addEventListener('touchstart', this._onTouchstart, modalityEventListenerOptions);
2100
+ const renderer = inject(RendererFactory2).createRenderer(null, null);
2101
+ this._listenerCleanups = ngZone.runOutsideAngular(() => {
2102
+ return [
2103
+ _bindEventWithOptions(renderer, document, 'keydown', this._onKeydown, modalityEventListenerOptions),
2104
+ _bindEventWithOptions(renderer, document, 'mousedown', this._onMousedown, modalityEventListenerOptions),
2105
+ _bindEventWithOptions(renderer, document, 'touchstart', this._onTouchstart, modalityEventListenerOptions),
2106
+ ];
2103
2107
  });
2104
2108
  }
2105
2109
  }
2106
2110
  ngOnDestroy() {
2107
2111
  this._modality.complete();
2108
- if (this._platform.isBrowser) {
2109
- document.removeEventListener('keydown', this._onKeydown, modalityEventListenerOptions);
2110
- document.removeEventListener('mousedown', this._onMousedown, modalityEventListenerOptions);
2111
- document.removeEventListener('touchstart', this._onTouchstart, modalityEventListenerOptions);
2112
- }
2112
+ this._listenerCleanups?.forEach(cleanup => cleanup());
2113
2113
  }
2114
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: InputModalityDetector, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2115
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: InputModalityDetector, providedIn: 'root' });
2114
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: InputModalityDetector, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2115
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: InputModalityDetector, providedIn: 'root' });
2116
2116
  }
2117
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: InputModalityDetector, decorators: [{
2117
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: InputModalityDetector, decorators: [{
2118
2118
  type: Injectable,
2119
2119
  args: [{ providedIn: 'root' }]
2120
2120
  }], ctorParameters: () => [] });
@@ -2249,10 +2249,10 @@ class LiveAnnouncer {
2249
2249
  }
2250
2250
  }
2251
2251
  }
2252
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: LiveAnnouncer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2253
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: LiveAnnouncer, providedIn: 'root' });
2252
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: LiveAnnouncer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2253
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: LiveAnnouncer, providedIn: 'root' });
2254
2254
  }
2255
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: LiveAnnouncer, decorators: [{
2255
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: LiveAnnouncer, decorators: [{
2256
2256
  type: Injectable,
2257
2257
  args: [{ providedIn: 'root' }]
2258
2258
  }], ctorParameters: () => [] });
@@ -2305,10 +2305,10 @@ class CdkAriaLive {
2305
2305
  this._subscription.unsubscribe();
2306
2306
  }
2307
2307
  }
2308
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: CdkAriaLive, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2309
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.0-next.2", type: CdkAriaLive, isStandalone: true, selector: "[cdkAriaLive]", inputs: { politeness: ["cdkAriaLive", "politeness"], duration: ["cdkAriaLiveDuration", "duration"] }, exportAs: ["cdkAriaLive"], ngImport: i0 });
2308
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: CdkAriaLive, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2309
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.0-next.3", type: CdkAriaLive, isStandalone: true, selector: "[cdkAriaLive]", inputs: { politeness: ["cdkAriaLive", "politeness"], duration: ["cdkAriaLiveDuration", "duration"] }, exportAs: ["cdkAriaLive"], ngImport: i0 });
2310
2310
  }
2311
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: CdkAriaLive, decorators: [{
2311
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: CdkAriaLive, decorators: [{
2312
2312
  type: Directive,
2313
2313
  args: [{
2314
2314
  selector: '[cdkAriaLive]',
@@ -2343,14 +2343,16 @@ const FOCUS_MONITOR_DEFAULT_OPTIONS = new InjectionToken('cdk-focus-monitor-defa
2343
2343
  * Event listener options that enable capturing and also
2344
2344
  * mark the listener as passive if the browser supports it.
2345
2345
  */
2346
- const captureEventListenerOptions = normalizePassiveListenerOptions({
2346
+ const captureEventListenerOptions = {
2347
2347
  passive: true,
2348
2348
  capture: true,
2349
- });
2349
+ };
2350
2350
  /** Monitors mouse and keyboard events to determine the cause of focus events. */
2351
2351
  class FocusMonitor {
2352
2352
  _ngZone = inject(NgZone);
2353
2353
  _platform = inject(Platform);
2354
+ _renderer = inject(RendererFactory2).createRenderer(null, null);
2355
+ _cleanupWindowFocus;
2354
2356
  _inputModalityDetector = inject(InputModalityDetector);
2355
2357
  /** The focus origin that the next focus event is a result of. */
2356
2358
  _origin = null;
@@ -2377,7 +2379,7 @@ class FocusMonitor {
2377
2379
  * handlers differently from the rest of the events, because the browser won't emit events
2378
2380
  * to the document when focus moves inside of a shadow root.
2379
2381
  */
2380
- _rootNodeFocusListenerCount = new Map();
2382
+ _rootNodeFocusListeners = new Map();
2381
2383
  /**
2382
2384
  * The specified detection mode, used for attributing the origin of a focus
2383
2385
  * event.
@@ -2485,11 +2487,6 @@ class FocusMonitor {
2485
2487
  _getDocument() {
2486
2488
  return this._document || document;
2487
2489
  }
2488
- /** Use defaultView of injected document if available or fallback to global window reference */
2489
- _getWindow() {
2490
- const doc = this._getDocument();
2491
- return doc.defaultView || window;
2492
- }
2493
2490
  _getFocusOrigin(focusEventTarget) {
2494
2491
  if (this._origin) {
2495
2492
  // If the origin was realized via a touch interaction, we need to perform additional checks
@@ -2626,21 +2623,28 @@ class FocusMonitor {
2626
2623
  return;
2627
2624
  }
2628
2625
  const rootNode = elementInfo.rootNode;
2629
- const rootNodeFocusListeners = this._rootNodeFocusListenerCount.get(rootNode) || 0;
2630
- if (!rootNodeFocusListeners) {
2626
+ const listeners = this._rootNodeFocusListeners.get(rootNode);
2627
+ if (listeners) {
2628
+ listeners.count++;
2629
+ }
2630
+ else {
2631
2631
  this._ngZone.runOutsideAngular(() => {
2632
- rootNode.addEventListener('focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
2633
- rootNode.addEventListener('blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
2632
+ this._rootNodeFocusListeners.set(rootNode, {
2633
+ count: 1,
2634
+ cleanups: [
2635
+ _bindEventWithOptions(this._renderer, rootNode, 'focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions),
2636
+ _bindEventWithOptions(this._renderer, rootNode, 'blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions),
2637
+ ],
2638
+ });
2634
2639
  });
2635
2640
  }
2636
- this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners + 1);
2637
2641
  // Register global listeners when first element is monitored.
2638
2642
  if (++this._monitoredElementCount === 1) {
2639
2643
  // Note: we listen to events in the capture phase so we
2640
2644
  // can detect them even if the user stops propagation.
2641
2645
  this._ngZone.runOutsideAngular(() => {
2642
- const window = this._getWindow();
2643
- window.addEventListener('focus', this._windowFocusListener);
2646
+ this._cleanupWindowFocus?.();
2647
+ this._cleanupWindowFocus = this._renderer.listen('window', 'focus', this._windowFocusListener);
2644
2648
  });
2645
2649
  // The InputModalityDetector is also just a collection of global listeners.
2646
2650
  this._inputModalityDetector.modalityDetected
@@ -2651,22 +2655,19 @@ class FocusMonitor {
2651
2655
  }
2652
2656
  }
2653
2657
  _removeGlobalListeners(elementInfo) {
2654
- const rootNode = elementInfo.rootNode;
2655
- if (this._rootNodeFocusListenerCount.has(rootNode)) {
2656
- const rootNodeFocusListeners = this._rootNodeFocusListenerCount.get(rootNode);
2657
- if (rootNodeFocusListeners > 1) {
2658
- this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners - 1);
2658
+ const listeners = this._rootNodeFocusListeners.get(elementInfo.rootNode);
2659
+ if (listeners) {
2660
+ if (listeners.count > 1) {
2661
+ listeners.count--;
2659
2662
  }
2660
2663
  else {
2661
- rootNode.removeEventListener('focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
2662
- rootNode.removeEventListener('blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);
2663
- this._rootNodeFocusListenerCount.delete(rootNode);
2664
+ listeners.cleanups.forEach(cleanup => cleanup());
2665
+ this._rootNodeFocusListeners.delete(elementInfo.rootNode);
2664
2666
  }
2665
2667
  }
2666
2668
  // Unregister global listeners when last element is unmonitored.
2667
2669
  if (!--this._monitoredElementCount) {
2668
- const window = this._getWindow();
2669
- window.removeEventListener('focus', this._windowFocusListener);
2670
+ this._cleanupWindowFocus?.();
2670
2671
  // Equivalently, stop our InputModalityDetector subscription.
2671
2672
  this._stopInputModalityDetector.next();
2672
2673
  // Clear timeouts for all potentially pending timeouts to prevent the leaks.
@@ -2721,10 +2722,10 @@ class FocusMonitor {
2721
2722
  }
2722
2723
  return false;
2723
2724
  }
2724
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: FocusMonitor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2725
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: FocusMonitor, providedIn: 'root' });
2725
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: FocusMonitor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2726
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: FocusMonitor, providedIn: 'root' });
2726
2727
  }
2727
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: FocusMonitor, decorators: [{
2728
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: FocusMonitor, decorators: [{
2728
2729
  type: Injectable,
2729
2730
  args: [{ providedIn: 'root' }]
2730
2731
  }], ctorParameters: () => [] });
@@ -2762,10 +2763,10 @@ class CdkMonitorFocus {
2762
2763
  this._monitorSubscription.unsubscribe();
2763
2764
  }
2764
2765
  }
2765
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: CdkMonitorFocus, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2766
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.0-next.2", type: CdkMonitorFocus, isStandalone: true, selector: "[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]", outputs: { cdkFocusChange: "cdkFocusChange" }, exportAs: ["cdkMonitorFocus"], ngImport: i0 });
2766
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: CdkMonitorFocus, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2767
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.0-next.3", type: CdkMonitorFocus, isStandalone: true, selector: "[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]", outputs: { cdkFocusChange: "cdkFocusChange" }, exportAs: ["cdkMonitorFocus"], ngImport: i0 });
2767
2768
  }
2768
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: CdkMonitorFocus, decorators: [{
2769
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: CdkMonitorFocus, decorators: [{
2769
2770
  type: Directive,
2770
2771
  args: [{
2771
2772
  selector: '[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]',
@@ -2873,10 +2874,10 @@ class HighContrastModeDetector {
2873
2874
  }
2874
2875
  }
2875
2876
  }
2876
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: HighContrastModeDetector, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2877
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: HighContrastModeDetector, providedIn: 'root' });
2877
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: HighContrastModeDetector, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2878
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: HighContrastModeDetector, providedIn: 'root' });
2878
2879
  }
2879
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: HighContrastModeDetector, decorators: [{
2880
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: HighContrastModeDetector, decorators: [{
2880
2881
  type: Injectable,
2881
2882
  args: [{ providedIn: 'root' }]
2882
2883
  }], ctorParameters: () => [] });
@@ -2885,11 +2886,11 @@ class A11yModule {
2885
2886
  constructor() {
2886
2887
  inject(HighContrastModeDetector)._applyBodyHighContrastModeCssClasses();
2887
2888
  }
2888
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: A11yModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2889
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.0-next.2", ngImport: i0, type: A11yModule, imports: [ObserversModule, CdkAriaLive, CdkTrapFocus, CdkMonitorFocus], exports: [CdkAriaLive, CdkTrapFocus, CdkMonitorFocus] });
2890
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: A11yModule, imports: [ObserversModule] });
2889
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: A11yModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2890
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.0-next.3", ngImport: i0, type: A11yModule, imports: [ObserversModule, CdkAriaLive, CdkTrapFocus, CdkMonitorFocus], exports: [CdkAriaLive, CdkTrapFocus, CdkMonitorFocus] });
2891
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: A11yModule, imports: [ObserversModule] });
2891
2892
  }
2892
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: A11yModule, decorators: [{
2893
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: A11yModule, decorators: [{
2893
2894
  type: NgModule,
2894
2895
  args: [{
2895
2896
  imports: [ObserversModule, CdkAriaLive, CdkTrapFocus, CdkMonitorFocus],
@@ -2921,10 +2922,10 @@ class _IdGenerator {
2921
2922
  }
2922
2923
  return `${prefix}${counters[prefix]++}`;
2923
2924
  }
2924
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: _IdGenerator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2925
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: _IdGenerator, providedIn: 'root' });
2925
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: _IdGenerator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2926
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: _IdGenerator, providedIn: 'root' });
2926
2927
  }
2927
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.2", ngImport: i0, type: _IdGenerator, decorators: [{
2928
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: _IdGenerator, decorators: [{
2928
2929
  type: Injectable,
2929
2930
  args: [{ providedIn: 'root' }]
2930
2931
  }] });