@angular/cdk 19.1.0-next.3 → 19.1.0-rc.0

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/fesm2022/cdk.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Version } from '@angular/core';
2
2
 
3
3
  /** Current version of the Angular Component Development Kit. */
4
- const VERSION = new Version('19.1.0-next.3');
4
+ const VERSION = new Version('19.1.0-rc.0');
5
5
 
6
6
  export { VERSION };
7
7
  //# sourceMappingURL=cdk.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cdk.mjs","sources":["../../../../../../src/cdk/version.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Version} from '@angular/core';\n\n/** Current version of the Angular Component Development Kit. */\nexport const VERSION = new Version('19.1.0-next.3');\n"],"names":[],"mappings":";;AAUA;MACa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB;;;;"}
1
+ {"version":3,"file":"cdk.mjs","sources":["../../../../../../src/cdk/version.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Version} from '@angular/core';\n\n/** Current version of the Angular Component Development Kit. */\nexport const VERSION = new Version('19.1.0-rc.0');\n"],"names":[],"mappings":";;AAUA;MACa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB;;;;"}
@@ -1,10 +1,10 @@
1
1
  import * as i0 from '@angular/core';
2
- import { signal, Component, ViewEncapsulation, ChangeDetectionStrategy, inject, NgZone, RendererFactory2, Injectable, InjectionToken, ElementRef, booleanAttribute, Directive, Input, ViewContainerRef, ChangeDetectorRef, EventEmitter, Injector, afterNextRender, numberAttribute, Output, TemplateRef, NgModule } from '@angular/core';
2
+ import { signal, Component, ViewEncapsulation, ChangeDetectionStrategy, inject, NgZone, Injectable, RendererFactory2, InjectionToken, ElementRef, booleanAttribute, Directive, Input, ViewContainerRef, ChangeDetectorRef, EventEmitter, Injector, afterNextRender, numberAttribute, Output, TemplateRef, NgModule } from '@angular/core';
3
3
  import { DOCUMENT } from '@angular/common';
4
4
  import { ViewportRuler, ScrollDispatcher, CdkScrollableModule } from '@angular/cdk/scrolling';
5
5
  import { isFakeTouchstartFromScreenReader, isFakeMousedownFromScreenReader, _IdGenerator } from '@angular/cdk/a11y';
6
6
  import { coerceElement, coerceNumberProperty, coerceArray } from '@angular/cdk/coercion';
7
- import { _getEventTarget, _bindEventWithOptions, _getShadowRoot } from '@angular/cdk/platform';
7
+ import { _getEventTarget, normalizePassiveListenerOptions, _getShadowRoot } from '@angular/cdk/platform';
8
8
  import { Subject, Subscription, interval, animationFrameScheduler, Observable, merge, BehaviorSubject } from 'rxjs';
9
9
  import { takeUntil, map, take, tap, switchMap, startWith } from 'rxjs/operators';
10
10
  import { _CdkPrivateStyleLoader } from '@angular/cdk/private';
@@ -445,14 +445,14 @@ function supportsPopover(element) {
445
445
  }
446
446
 
447
447
  /** Options that can be used to bind a passive event listener. */
448
- const passiveEventListenerOptions = { passive: true };
448
+ const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true });
449
449
  /** Options that can be used to bind an active event listener. */
450
- const activeEventListenerOptions = { passive: false };
450
+ const activeEventListenerOptions = normalizePassiveListenerOptions({ passive: false });
451
451
  /** Event options that can be used to bind an active, capturing event. */
452
- const activeCapturingEventOptions$1 = {
452
+ const activeCapturingEventOptions$1 = normalizePassiveListenerOptions({
453
453
  passive: false,
454
454
  capture: true,
455
- };
455
+ });
456
456
  /**
457
457
  * Time in milliseconds for which to ignore mouse events, after
458
458
  * receiving a touch event. Used to avoid doing double work for
@@ -475,8 +475,6 @@ class DragRef {
475
475
  _viewportRuler;
476
476
  _dragDropRegistry;
477
477
  _renderer;
478
- _rootElementCleanups;
479
- _cleanupShadowRootSelectStart;
480
478
  /** Element displayed next to the user's pointer while the element is dragged. */
481
479
  _preview;
482
480
  /** Container into which to insert the preview. */
@@ -711,12 +709,14 @@ class DragRef {
711
709
  withRootElement(rootElement) {
712
710
  const element = coerceElement(rootElement);
713
711
  if (element !== this._rootElement) {
714
- this._removeRootElementListeners();
715
- this._rootElementCleanups = this._ngZone.runOutsideAngular(() => [
716
- _bindEventWithOptions(this._renderer, element, 'mousedown', this._pointerDown, activeEventListenerOptions),
717
- _bindEventWithOptions(this._renderer, element, 'touchstart', this._pointerDown, passiveEventListenerOptions),
718
- _bindEventWithOptions(this._renderer, element, 'dragstart', this._nativeDragStart, activeEventListenerOptions),
719
- ]);
712
+ if (this._rootElement) {
713
+ this._removeRootElementListeners(this._rootElement);
714
+ }
715
+ this._ngZone.runOutsideAngular(() => {
716
+ element.addEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
717
+ element.addEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
718
+ element.addEventListener('dragstart', this._nativeDragStart, activeEventListenerOptions);
719
+ });
720
720
  this._initialTransform = undefined;
721
721
  this._rootElement = element;
722
722
  }
@@ -745,7 +745,7 @@ class DragRef {
745
745
  }
746
746
  /** Removes the dragging functionality from the DOM element. */
747
747
  dispose() {
748
- this._removeRootElementListeners();
748
+ this._removeRootElementListeners(this._rootElement);
749
749
  // Do this check before removing from the registry since it'll
750
750
  // stop being considered as dragged once it is removed.
751
751
  if (this.isDragging()) {
@@ -859,8 +859,7 @@ class DragRef {
859
859
  this._pointerMoveSubscription.unsubscribe();
860
860
  this._pointerUpSubscription.unsubscribe();
861
861
  this._scrollSubscription.unsubscribe();
862
- this._cleanupShadowRootSelectStart?.();
863
- this._cleanupShadowRootSelectStart = undefined;
862
+ this._getShadowRoot()?.removeEventListener('selectstart', shadowDomSelectStart, activeCapturingEventOptions$1);
864
863
  }
865
864
  /** Destroys the preview element and its ViewRef. */
866
865
  _destroyPreview() {
@@ -1025,7 +1024,7 @@ class DragRef {
1025
1024
  // In some browsers the global `selectstart` that we maintain in the `DragDropRegistry`
1026
1025
  // doesn't cross the shadow boundary so we have to prevent it at the shadow root (see #28792).
1027
1026
  this._ngZone.runOutsideAngular(() => {
1028
- this._cleanupShadowRootSelectStart = _bindEventWithOptions(this._renderer, shadowRoot, 'selectstart', shadowDomSelectStart, activeCapturingEventOptions$1);
1027
+ shadowRoot.addEventListener('selectstart', shadowDomSelectStart, activeCapturingEventOptions$1);
1029
1028
  });
1030
1029
  }
1031
1030
  if (dropContainer) {
@@ -1395,9 +1394,10 @@ class DragRef {
1395
1394
  }
1396
1395
  }
1397
1396
  /** Removes the manually-added event listeners from the root element. */
1398
- _removeRootElementListeners() {
1399
- this._rootElementCleanups?.forEach(cleanup => cleanup());
1400
- this._rootElementCleanups = undefined;
1397
+ _removeRootElementListeners(element) {
1398
+ element.removeEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
1399
+ element.removeEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
1400
+ element.removeEventListener('dragstart', this._nativeDragStart, activeEventListenerOptions);
1401
1401
  }
1402
1402
  /**
1403
1403
  * Applies a `transform` to the root element, taking into account any existing transforms on it.
@@ -2949,15 +2949,11 @@ function getElementScrollDirections(element, clientRect, direction, pointerX, po
2949
2949
  return [verticalScrollDirection, horizontalScrollDirection];
2950
2950
  }
2951
2951
 
2952
- /** Event options that can be used to bind a capturing event. */
2953
- const capturingEventOptions = {
2954
- capture: true,
2955
- };
2956
2952
  /** Event options that can be used to bind an active, capturing event. */
2957
- const activeCapturingEventOptions = {
2953
+ const activeCapturingEventOptions = normalizePassiveListenerOptions({
2958
2954
  passive: false,
2959
2955
  capture: true,
2960
- };
2956
+ });
2961
2957
  /**
2962
2958
  * Component used to load the drag&drop reset styles.
2963
2959
  * @docs-private
@@ -2980,8 +2976,6 @@ class DragDropRegistry {
2980
2976
  _ngZone = inject(NgZone);
2981
2977
  _document = inject(DOCUMENT);
2982
2978
  _styleLoader = inject(_CdkPrivateStyleLoader);
2983
- _renderer = inject(RendererFactory2).createRenderer(null, null);
2984
- _cleanupDocumentTouchmove;
2985
2979
  /** Registered drop container instances. */
2986
2980
  _dropInstances = new Set();
2987
2981
  /** Registered drag item instances. */
@@ -2989,7 +2983,7 @@ class DragDropRegistry {
2989
2983
  /** Drag item instances that are currently being dragged. */
2990
2984
  _activeDragInstances = signal([]);
2991
2985
  /** Keeps track of the event listeners that we've bound to the `document`. */
2992
- _globalListeners;
2986
+ _globalListeners = new Map();
2993
2987
  /**
2994
2988
  * Predicate function to check if an item is being dragged. Moved out into a property,
2995
2989
  * because it'll be called a lot and we don't want to create a new function every time.
@@ -3034,8 +3028,7 @@ class DragDropRegistry {
3034
3028
  this._ngZone.runOutsideAngular(() => {
3035
3029
  // The event handler has to be explicitly active,
3036
3030
  // because newer browsers make it passive by default.
3037
- this._cleanupDocumentTouchmove?.();
3038
- this._cleanupDocumentTouchmove = _bindEventWithOptions(this._renderer, this._document, 'touchmove', this._persistentTouchmoveListener, activeCapturingEventOptions);
3031
+ this._document.addEventListener('touchmove', this._persistentTouchmoveListener, activeCapturingEventOptions);
3039
3032
  });
3040
3033
  }
3041
3034
  }
@@ -3048,7 +3041,7 @@ class DragDropRegistry {
3048
3041
  this._dragInstances.delete(drag);
3049
3042
  this.stopDragging(drag);
3050
3043
  if (this._dragInstances.size === 0) {
3051
- this._cleanupDocumentTouchmove?.();
3044
+ this._document.removeEventListener('touchmove', this._persistentTouchmoveListener, activeCapturingEventOptions);
3052
3045
  }
3053
3046
  }
3054
3047
  /**
@@ -3068,34 +3061,44 @@ class DragDropRegistry {
3068
3061
  // passive ones for `mousemove` and `touchmove`. The events need to be active, because we
3069
3062
  // use `preventDefault` to prevent the page from scrolling while the user is dragging.
3070
3063
  const isTouchEvent = event.type.startsWith('touch');
3071
- const endEventHandler = (e) => this.pointerUp.next(e);
3072
- const toBind = [
3064
+ const endEventHandler = {
3065
+ handler: (e) => this.pointerUp.next(e),
3066
+ options: true,
3067
+ };
3068
+ if (isTouchEvent) {
3069
+ this._globalListeners.set('touchend', endEventHandler);
3070
+ this._globalListeners.set('touchcancel', endEventHandler);
3071
+ }
3072
+ else {
3073
+ this._globalListeners.set('mouseup', endEventHandler);
3074
+ }
3075
+ this._globalListeners
3076
+ .set('scroll', {
3077
+ handler: (e) => this.scroll.next(e),
3073
3078
  // Use capturing so that we pick up scroll changes in any scrollable nodes that aren't
3074
3079
  // the document. See https://github.com/angular/components/issues/17144.
3075
- ['scroll', (e) => this.scroll.next(e), capturingEventOptions],
3080
+ options: true,
3081
+ })
3076
3082
  // Preventing the default action on `mousemove` isn't enough to disable text selection
3077
3083
  // on Safari so we need to prevent the selection event as well. Alternatively this can
3078
3084
  // be done by setting `user-select: none` on the `body`, however it has causes a style
3079
3085
  // recalculation which can be expensive on pages with a lot of elements.
3080
- ['selectstart', this._preventDefaultWhileDragging, activeCapturingEventOptions],
3081
- ];
3082
- if (isTouchEvent) {
3083
- toBind.push(['touchend', endEventHandler, capturingEventOptions], ['touchcancel', endEventHandler, capturingEventOptions]);
3084
- }
3085
- else {
3086
- toBind.push(['mouseup', endEventHandler, capturingEventOptions]);
3087
- }
3086
+ .set('selectstart', {
3087
+ handler: this._preventDefaultWhileDragging,
3088
+ options: activeCapturingEventOptions,
3089
+ });
3088
3090
  // We don't have to bind a move event for touch drag sequences, because
3089
3091
  // we already have a persistent global one bound from `registerDragItem`.
3090
3092
  if (!isTouchEvent) {
3091
- toBind.push([
3092
- 'mousemove',
3093
- (e) => this.pointerMove.next(e),
3094
- activeCapturingEventOptions,
3095
- ]);
3093
+ this._globalListeners.set('mousemove', {
3094
+ handler: (e) => this.pointerMove.next(e),
3095
+ options: activeCapturingEventOptions,
3096
+ });
3096
3097
  }
3097
3098
  this._ngZone.runOutsideAngular(() => {
3098
- this._globalListeners = toBind.map(([name, handler, options]) => _bindEventWithOptions(this._renderer, this._document, name, handler, options));
3099
+ this._globalListeners.forEach((config, name) => {
3100
+ this._document.addEventListener(name, config.handler, config.options);
3101
+ });
3099
3102
  });
3100
3103
  }
3101
3104
  }
@@ -3132,13 +3135,15 @@ class DragDropRegistry {
3132
3135
  // `fromEvent` it'll only happen if the subscription is outside the `NgZone`.
3133
3136
  streams.push(new Observable((observer) => {
3134
3137
  return this._ngZone.runOutsideAngular(() => {
3135
- const cleanup = _bindEventWithOptions(this._renderer, shadowRoot, 'scroll', (event) => {
3138
+ const eventOptions = true;
3139
+ const callback = (event) => {
3136
3140
  if (this._activeDragInstances().length) {
3137
3141
  observer.next(event);
3138
3142
  }
3139
- }, capturingEventOptions);
3143
+ };
3144
+ shadowRoot.addEventListener('scroll', callback, eventOptions);
3140
3145
  return () => {
3141
- cleanup();
3146
+ shadowRoot.removeEventListener('scroll', callback, eventOptions);
3142
3147
  };
3143
3148
  });
3144
3149
  }));
@@ -3199,8 +3204,10 @@ class DragDropRegistry {
3199
3204
  };
3200
3205
  /** Clears out the global event listeners from the `document`. */
3201
3206
  _clearGlobalListeners() {
3202
- this._globalListeners?.forEach(cleanup => cleanup());
3203
- this._globalListeners = undefined;
3207
+ this._globalListeners.forEach((config, name) => {
3208
+ this._document.removeEventListener(name, config.handler, config.options);
3209
+ });
3210
+ this._globalListeners.clear();
3204
3211
  }
3205
3212
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: DragDropRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
3206
3213
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.0-next.3", ngImport: i0, type: DragDropRegistry, providedIn: 'root' });