@angular/cdk 17.2.0 → 17.2.2

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 (44) hide show
  1. package/drag-drop/index.d.ts +19 -14
  2. package/esm2022/dialog/dialog-container.mjs +1 -1
  3. package/esm2022/drag-drop/directives/drag-handle.mjs +5 -3
  4. package/esm2022/drag-drop/directives/drag-placeholder.mjs +8 -2
  5. package/esm2022/drag-drop/directives/drag-preview.mjs +8 -2
  6. package/esm2022/drag-drop/directives/drag.mjs +43 -27
  7. package/esm2022/drag-drop/drag-parent.mjs +1 -1
  8. package/esm2022/listbox/listbox.mjs +1 -1
  9. package/esm2022/menu/context-menu-trigger.mjs +4 -4
  10. package/esm2022/menu/menu-trigger.mjs +4 -4
  11. package/esm2022/overlay/overlay-directives.mjs +4 -3
  12. package/esm2022/overlay/position/flexible-connected-position-strategy.mjs +24 -7
  13. package/esm2022/portal/portal-directives.mjs +7 -5
  14. package/esm2022/scrolling/virtual-scroll-viewport.mjs +1 -1
  15. package/esm2022/table/can-stick.mjs +3 -1
  16. package/esm2022/table/cell.mjs +28 -11
  17. package/esm2022/table/row.mjs +64 -22
  18. package/esm2022/table/table.mjs +1 -1
  19. package/esm2022/table/text-column.mjs +1 -1
  20. package/esm2022/tree/node.mjs +2 -2
  21. package/esm2022/version.mjs +1 -1
  22. package/fesm2022/cdk.mjs +1 -1
  23. package/fesm2022/cdk.mjs.map +1 -1
  24. package/fesm2022/dialog.mjs.map +1 -1
  25. package/fesm2022/drag-drop.mjs +118 -88
  26. package/fesm2022/drag-drop.mjs.map +1 -1
  27. package/fesm2022/listbox.mjs.map +1 -1
  28. package/fesm2022/menu.mjs +6 -6
  29. package/fesm2022/menu.mjs.map +1 -1
  30. package/fesm2022/overlay.mjs +26 -8
  31. package/fesm2022/overlay.mjs.map +1 -1
  32. package/fesm2022/portal.mjs +6 -4
  33. package/fesm2022/portal.mjs.map +1 -1
  34. package/fesm2022/scrolling.mjs.map +1 -1
  35. package/fesm2022/table.mjs +128 -65
  36. package/fesm2022/table.mjs.map +1 -1
  37. package/fesm2022/tree.mjs +1 -1
  38. package/fesm2022/tree.mjs.map +1 -1
  39. package/listbox/index.d.ts +1 -1
  40. package/overlay/index.d.ts +3 -0
  41. package/package.json +1 -1
  42. package/schematics/ng-add/index.js +1 -1
  43. package/schematics/ng-add/index.mjs +1 -1
  44. package/table/index.d.ts +36 -24
@@ -4,7 +4,7 @@ export { CdkScrollable, ScrollDispatcher, ViewportRuler } from '@angular/cdk/scr
4
4
  import * as i6 from '@angular/common';
5
5
  import { DOCUMENT } from '@angular/common';
6
6
  import * as i0 from '@angular/core';
7
- import { Injectable, Inject, Optional, ElementRef, ApplicationRef, ANIMATION_MODULE_TYPE, InjectionToken, inject, Directive, EventEmitter, booleanAttribute, Input, Output, NgModule } from '@angular/core';
7
+ import { Injectable, Inject, Optional, ElementRef, ApplicationRef, ANIMATION_MODULE_TYPE, InjectionToken, inject, Directive, NgZone, EventEmitter, booleanAttribute, Input, Output, NgModule } from '@angular/core';
8
8
  import { coerceCssPixelValue, coerceArray } from '@angular/cdk/coercion';
9
9
  import * as i1$1 from '@angular/cdk/platform';
10
10
  import { supportsScrollBehavior, _getEventTarget, _isTestEnvironment } from '@angular/cdk/platform';
@@ -1655,16 +1655,23 @@ class FlexibleConnectedPositionStrategy {
1655
1655
  if (position.panelClass) {
1656
1656
  this._addPanelClasses(position.panelClass);
1657
1657
  }
1658
- // Save the last connected position in case the position needs to be re-calculated.
1659
- this._lastPosition = position;
1660
1658
  // Notify that the position has been changed along with its change properties.
1661
1659
  // We only emit if we've got any subscriptions, because the scroll visibility
1662
1660
  // calculations can be somewhat expensive.
1663
1661
  if (this._positionChanges.observers.length) {
1664
- const scrollableViewProperties = this._getScrollVisibility();
1665
- const changeEvent = new ConnectedOverlayPositionChange(position, scrollableViewProperties);
1666
- this._positionChanges.next(changeEvent);
1662
+ const scrollVisibility = this._getScrollVisibility();
1663
+ // We're recalculating on scroll, but we only want to emit if anything
1664
+ // changed since downstream code might be hitting the `NgZone`.
1665
+ if (position !== this._lastPosition ||
1666
+ !this._lastScrollVisibility ||
1667
+ !compareScrollVisibility(this._lastScrollVisibility, scrollVisibility)) {
1668
+ const changeEvent = new ConnectedOverlayPositionChange(position, scrollVisibility);
1669
+ this._positionChanges.next(changeEvent);
1670
+ }
1671
+ this._lastScrollVisibility = scrollVisibility;
1667
1672
  }
1673
+ // Save the last connected position in case the position needs to be re-calculated.
1674
+ this._lastPosition = position;
1668
1675
  this._isInitialRender = false;
1669
1676
  }
1670
1677
  /** Sets the transform origin based on the configured selector and the passed-in position. */
@@ -1729,7 +1736,7 @@ class FlexibleConnectedPositionStrategy {
1729
1736
  const isBoundedByLeftViewportEdge = (position.overlayX === 'end' && !isRtl) || (position.overlayX === 'start' && isRtl);
1730
1737
  let width, left, right;
1731
1738
  if (isBoundedByLeftViewportEdge) {
1732
- right = viewport.width - origin.x + this._viewportMargin;
1739
+ right = viewport.width - origin.x + this._viewportMargin * 2;
1733
1740
  width = origin.x - this._viewportMargin;
1734
1741
  }
1735
1742
  else if (isBoundedByRightViewportEdge) {
@@ -2091,6 +2098,16 @@ function getRoundedBoundingClientRect(clientRect) {
2091
2098
  height: Math.floor(clientRect.height),
2092
2099
  };
2093
2100
  }
2101
+ /** Returns whether two `ScrollingVisibility` objects are identical. */
2102
+ function compareScrollVisibility(a, b) {
2103
+ if (a === b) {
2104
+ return true;
2105
+ }
2106
+ return (a.isOriginClipped === b.isOriginClipped &&
2107
+ a.isOriginOutsideView === b.isOriginOutsideView &&
2108
+ a.isOverlayClipped === b.isOverlayClipped &&
2109
+ a.isOverlayOutsideView === b.isOverlayOutsideView);
2110
+ }
2094
2111
  const STANDARD_DROPDOWN_BELOW_POSITIONS = [
2095
2112
  { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },
2096
2113
  { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },
@@ -2563,6 +2580,7 @@ class CdkConnectedOverlay {
2563
2580
  this._detachSubscription = Subscription.EMPTY;
2564
2581
  this._positionSubscription = Subscription.EMPTY;
2565
2582
  this._disposeOnNavigation = false;
2583
+ this._ngZone = inject(NgZone);
2566
2584
  /** Margin between the overlay and the viewport edges. */
2567
2585
  this.viewportMargin = 0;
2568
2586
  /** Whether the overlay is open. */
@@ -2743,7 +2761,7 @@ class CdkConnectedOverlay {
2743
2761
  this._positionSubscription = this._position.positionChanges
2744
2762
  .pipe(takeWhile(() => this.positionChange.observers.length > 0))
2745
2763
  .subscribe(position => {
2746
- this.positionChange.emit(position);
2764
+ this._ngZone.run(() => this.positionChange.emit(position));
2747
2765
  if (this.positionChange.observers.length === 0) {
2748
2766
  this._positionSubscription.unsubscribe();
2749
2767
  }