@angular/cdk 11.0.3 → 11.1.1

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 (142) hide show
  1. package/LICENSE +1 -1
  2. package/a11y/aria-describer/aria-describer.d.ts +9 -14
  3. package/a11y/focus-monitor/focus-monitor.d.ts +6 -0
  4. package/a11y/index.metadata.json +1 -1
  5. package/bundles/cdk-a11y.umd.js +83 -66
  6. package/bundles/cdk-a11y.umd.js.map +1 -1
  7. package/bundles/cdk-a11y.umd.min.js +13 -21
  8. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  9. package/bundles/cdk-accordion.umd.js.map +1 -1
  10. package/bundles/cdk-bidi.umd.js.map +1 -1
  11. package/bundles/cdk-coercion.umd.js +9 -1
  12. package/bundles/cdk-coercion.umd.js.map +1 -1
  13. package/bundles/cdk-coercion.umd.min.js.map +1 -1
  14. package/bundles/cdk-collections.umd.js +9 -1
  15. package/bundles/cdk-collections.umd.js.map +1 -1
  16. package/bundles/cdk-collections.umd.min.js +1 -1
  17. package/bundles/cdk-collections.umd.min.js.map +1 -1
  18. package/bundles/cdk-drag-drop.umd.js +136 -53
  19. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  20. package/bundles/cdk-drag-drop.umd.min.js +8 -8
  21. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  22. package/bundles/cdk-overlay.umd.js +49 -11
  23. package/bundles/cdk-overlay.umd.js.map +1 -1
  24. package/bundles/cdk-overlay.umd.min.js +18 -25
  25. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  26. package/bundles/cdk-platform.umd.js +1 -0
  27. package/bundles/cdk-platform.umd.js.map +1 -1
  28. package/bundles/cdk-platform.umd.min.js +1 -1
  29. package/bundles/cdk-platform.umd.min.js.map +1 -1
  30. package/bundles/cdk-portal.umd.js +9 -1
  31. package/bundles/cdk-portal.umd.js.map +1 -1
  32. package/bundles/cdk-portal.umd.min.js +2 -2
  33. package/bundles/cdk-portal.umd.min.js.map +1 -1
  34. package/bundles/cdk-scrolling.umd.js +25 -11
  35. package/bundles/cdk-scrolling.umd.js.map +1 -1
  36. package/bundles/cdk-scrolling.umd.min.js +4 -4
  37. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  38. package/bundles/cdk-table.umd.js +99 -30
  39. package/bundles/cdk-table.umd.js.map +1 -1
  40. package/bundles/cdk-table.umd.min.js +7 -7
  41. package/bundles/cdk-table.umd.min.js.map +1 -1
  42. package/bundles/cdk-testing-protractor.umd.js +59 -13
  43. package/bundles/cdk-testing-protractor.umd.js.map +1 -1
  44. package/bundles/cdk-testing-protractor.umd.min.js +2 -2
  45. package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
  46. package/bundles/cdk-testing-testbed.umd.js +40 -15
  47. package/bundles/cdk-testing-testbed.umd.js.map +1 -1
  48. package/bundles/cdk-testing-testbed.umd.min.js +7 -7
  49. package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
  50. package/bundles/cdk-testing.umd.js +11 -10
  51. package/bundles/cdk-testing.umd.js.map +1 -1
  52. package/bundles/cdk-testing.umd.min.js +2 -2
  53. package/bundles/cdk-testing.umd.min.js.map +1 -1
  54. package/bundles/cdk-tree.umd.js +9 -1
  55. package/bundles/cdk-tree.umd.js.map +1 -1
  56. package/bundles/cdk-tree.umd.min.js +5 -5
  57. package/bundles/cdk-tree.umd.min.js.map +1 -1
  58. package/bundles/cdk.umd.js +1 -1
  59. package/bundles/cdk.umd.js.map +1 -1
  60. package/bundles/cdk.umd.min.js +1 -1
  61. package/bundles/cdk.umd.min.js.map +1 -1
  62. package/drag-drop/directives/drag.d.ts +3 -1
  63. package/drag-drop/directives/drop-list.d.ts +4 -1
  64. package/drag-drop/drag-drop-registry.d.ts +8 -1
  65. package/drag-drop/drag-ref.d.ts +6 -0
  66. package/drag-drop/drop-list-ref.d.ts +7 -1
  67. package/drag-drop/index.metadata.json +1 -1
  68. package/esm2015/a11y/aria-describer/aria-describer.js +50 -55
  69. package/esm2015/a11y/focus-monitor/focus-monitor.js +18 -3
  70. package/esm2015/drag-drop/directives/drag.js +39 -5
  71. package/esm2015/drag-drop/directives/drop-list.js +4 -2
  72. package/esm2015/drag-drop/drag-drop-registry.js +25 -12
  73. package/esm2015/drag-drop/drag-ref.js +17 -10
  74. package/esm2015/drag-drop/drop-list-ref.js +46 -28
  75. package/esm2015/overlay/overlay-ref.js +2 -2
  76. package/esm2015/overlay/position/flexible-connected-position-strategy.js +25 -3
  77. package/esm2015/overlay/scroll/block-scroll-strategy.js +13 -4
  78. package/esm2015/platform/features/scrolling.js +2 -1
  79. package/esm2015/scrolling/fixed-size-virtual-scroll.js +3 -2
  80. package/esm2015/scrolling/scroll-dispatcher.js +9 -8
  81. package/esm2015/scrolling/virtual-for-of.js +8 -4
  82. package/esm2015/scrolling/virtual-scroll-viewport.js +1 -1
  83. package/esm2015/table/public-api.js +2 -1
  84. package/esm2015/table/sticky-position-listener.js +11 -0
  85. package/esm2015/table/sticky-styler.js +60 -14
  86. package/esm2015/table/table.js +9 -4
  87. package/esm2015/testing/change-detection.js +1 -8
  88. package/esm2015/testing/harness-environment.js +3 -3
  89. package/esm2015/testing/protractor/protractor-element.js +29 -13
  90. package/esm2015/testing/test-element.js +1 -1
  91. package/esm2015/testing/testbed/fake-events/dispatch-events.js +3 -3
  92. package/esm2015/testing/testbed/fake-events/event-objects.js +6 -6
  93. package/esm2015/testing/testbed/unit-test-element.js +21 -9
  94. package/esm2015/tree/nested-node.js +1 -1
  95. package/esm2015/tree/padding.js +1 -1
  96. package/esm2015/tree/toggle.js +1 -1
  97. package/esm2015/tree/tree.js +1 -1
  98. package/esm2015/version.js +1 -1
  99. package/fesm2015/a11y.js +67 -55
  100. package/fesm2015/a11y.js.map +1 -1
  101. package/fesm2015/accordion.js.map +1 -1
  102. package/fesm2015/bidi.js.map +1 -1
  103. package/fesm2015/cdk.js +1 -1
  104. package/fesm2015/cdk.js.map +1 -1
  105. package/fesm2015/drag-drop.js +125 -51
  106. package/fesm2015/drag-drop.js.map +1 -1
  107. package/fesm2015/overlay.js +37 -7
  108. package/fesm2015/overlay.js.map +1 -1
  109. package/fesm2015/platform.js +1 -0
  110. package/fesm2015/platform.js.map +1 -1
  111. package/fesm2015/scrolling.js +17 -12
  112. package/fesm2015/scrolling.js.map +1 -1
  113. package/fesm2015/table.js +77 -17
  114. package/fesm2015/table.js.map +1 -1
  115. package/fesm2015/testing/protractor.js +27 -11
  116. package/fesm2015/testing/protractor.js.map +1 -1
  117. package/fesm2015/testing/testbed.js +25 -13
  118. package/fesm2015/testing/testbed.js.map +1 -1
  119. package/fesm2015/testing.js +2 -9
  120. package/fesm2015/testing.js.map +1 -1
  121. package/fesm2015/tree.js.map +1 -1
  122. package/overlay/index.metadata.json +1 -1
  123. package/package.json +1 -1
  124. package/schematics/ng-add/index.js +1 -1
  125. package/scrolling/index.metadata.json +1 -1
  126. package/scrolling/scroll-dispatcher.d.ts +3 -3
  127. package/table/index.metadata.json +1 -1
  128. package/table/public-api.d.ts +1 -0
  129. package/table/sticky-position-listener.d.ts +28 -0
  130. package/table/sticky-styler.d.ts +7 -2
  131. package/table/table.d.ts +4 -2
  132. package/testing/change-detection.d.ts +44 -1
  133. package/testing/protractor/protractor-element.d.ts +12 -4
  134. package/testing/test-element.d.ts +11 -5
  135. package/testing/testbed/fake-events/dispatch-events.d.ts +1 -1
  136. package/testing/testbed/fake-events/event-objects.d.ts +1 -1
  137. package/testing/testbed/unit-test-element.d.ts +12 -4
  138. package/tree/index.metadata.json +1 -1
  139. package/tree/nested-node.d.ts +3 -3
  140. package/tree/padding.d.ts +2 -2
  141. package/tree/toggle.d.ts +4 -4
  142. package/tree/tree.d.ts +5 -5
@@ -3,9 +3,9 @@ export { CdkScrollable, ScrollDispatcher, ViewportRuler } from '@angular/cdk/scr
3
3
  import { DOCUMENT, Location } from '@angular/common';
4
4
  import { ɵɵdefineInjectable, ɵɵinject, NgZone, Injectable, Inject, Optional, ElementRef, ApplicationRef, ComponentFactoryResolver, Injector, InjectionToken, Directive, EventEmitter, TemplateRef, ViewContainerRef, Input, Output, NgModule } from '@angular/core';
5
5
  import { coerceCssPixelValue, coerceArray, coerceBooleanProperty } from '@angular/cdk/coercion';
6
+ import { supportsScrollBehavior, Platform } from '@angular/cdk/platform';
6
7
  import { Directionality, BidiModule } from '@angular/cdk/bidi';
7
8
  import { DomPortalOutlet, TemplatePortal, PortalModule } from '@angular/cdk/portal';
8
- import { Platform } from '@angular/cdk/platform';
9
9
  import { Subject, Subscription, merge } from 'rxjs';
10
10
  import { take, takeUntil, takeWhile } from 'rxjs/operators';
11
11
  import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
@@ -17,6 +17,7 @@ import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
17
17
  * Use of this source code is governed by an MIT-style license that can be
18
18
  * found in the LICENSE file at https://angular.io/license
19
19
  */
20
+ const scrollBehaviorSupported = supportsScrollBehavior();
20
21
  /**
21
22
  * Strategy that will prevent the user from scrolling while the overlay is visible.
22
23
  */
@@ -60,10 +61,17 @@ class BlockScrollStrategy {
60
61
  html.classList.remove('cdk-global-scrollblock');
61
62
  // Disable user-defined smooth scrolling temporarily while we restore the scroll position.
62
63
  // See https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior
63
- htmlStyle.scrollBehavior = bodyStyle.scrollBehavior = 'auto';
64
+ // Note that we don't mutate the property if the browser doesn't support `scroll-behavior`,
65
+ // because it can throw off feature detections in `supportsScrollBehavior` which
66
+ // checks for `'scrollBehavior' in documentElement.style`.
67
+ if (scrollBehaviorSupported) {
68
+ htmlStyle.scrollBehavior = bodyStyle.scrollBehavior = 'auto';
69
+ }
64
70
  window.scroll(this._previousScrollPosition.left, this._previousScrollPosition.top);
65
- htmlStyle.scrollBehavior = previousHtmlScrollBehavior;
66
- bodyStyle.scrollBehavior = previousBodyScrollBehavior;
71
+ if (scrollBehaviorSupported) {
72
+ htmlStyle.scrollBehavior = previousHtmlScrollBehavior;
73
+ bodyStyle.scrollBehavior = previousBodyScrollBehavior;
74
+ }
67
75
  }
68
76
  }
69
77
  _canBeEnabled() {
@@ -1011,7 +1019,7 @@ class OverlayRef {
1011
1019
  }
1012
1020
  /** Toggles the pointer events for the overlay pane element. */
1013
1021
  _togglePointerEvents(enablePointer) {
1014
- this._pane.style.pointerEvents = enablePointer ? 'auto' : 'none';
1022
+ this._pane.style.pointerEvents = enablePointer ? '' : 'none';
1015
1023
  }
1016
1024
  /** Attaches a backdrop for this overlay. */
1017
1025
  _attachBackdrop() {
@@ -1535,7 +1543,10 @@ class FlexibleConnectedPositionStrategy {
1535
1543
  };
1536
1544
  }
1537
1545
  /** Gets how well an overlay at the given point will fit within the viewport. */
1538
- _getOverlayFit(point, overlay, viewport, position) {
1546
+ _getOverlayFit(point, rawOverlayRect, viewport, position) {
1547
+ // Round the overlay rect when comparing against the
1548
+ // viewport, because the viewport is always rounded.
1549
+ const overlay = getRoundedBoundingClientRect(rawOverlayRect);
1539
1550
  let { x, y } = point;
1540
1551
  let offsetX = this._getOffset(position, 'x');
1541
1552
  let offsetY = this._getOffset(position, 'y');
@@ -1593,7 +1604,7 @@ class FlexibleConnectedPositionStrategy {
1593
1604
  * @returns The point at which to position the overlay after pushing. This is effectively a new
1594
1605
  * originPoint.
1595
1606
  */
1596
- _pushOverlayOnScreen(start, overlay, scrollPosition) {
1607
+ _pushOverlayOnScreen(start, rawOverlayRect, scrollPosition) {
1597
1608
  // If the position is locked and we've pushed the overlay already, reuse the previous push
1598
1609
  // amount, rather than pushing it again. If we were to continue pushing, the element would
1599
1610
  // remain in the viewport, which goes against the expectations when position locking is enabled.
@@ -1603,6 +1614,9 @@ class FlexibleConnectedPositionStrategy {
1603
1614
  y: start.y + this._previousPushAmount.y
1604
1615
  };
1605
1616
  }
1617
+ // Round the overlay rect when comparing against the
1618
+ // viewport, because the viewport is always rounded.
1619
+ const overlay = getRoundedBoundingClientRect(rawOverlayRect);
1606
1620
  const viewport = this._viewportRect;
1607
1621
  // Determine how much the overlay goes outside the viewport on each
1608
1622
  // side, which we'll use to decide which direction to push it.
@@ -2074,6 +2088,22 @@ function getPixelValue(input) {
2074
2088
  }
2075
2089
  return input || null;
2076
2090
  }
2091
+ /**
2092
+ * Gets a version of an element's bounding `ClientRect` where all the values are rounded down to
2093
+ * the nearest pixel. This allows us to account for the cases where there may be sub-pixel
2094
+ * deviations in the `ClientRect` returned by the browser (e.g. when zoomed in with a percentage
2095
+ * size, see #21350).
2096
+ */
2097
+ function getRoundedBoundingClientRect(clientRect) {
2098
+ return {
2099
+ top: Math.floor(clientRect.top),
2100
+ right: Math.floor(clientRect.right),
2101
+ bottom: Math.floor(clientRect.bottom),
2102
+ left: Math.floor(clientRect.left),
2103
+ width: Math.floor(clientRect.width),
2104
+ height: Math.floor(clientRect.height)
2105
+ };
2106
+ }
2077
2107
 
2078
2108
  /**
2079
2109
  * @license