@angular/cdk 8.1.4 → 8.2.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 (162) hide show
  1. package/a11y/typings/index.metadata.json +1 -1
  2. package/a11y/typings/key-manager/focus-key-manager.d.ts +1 -1
  3. package/bundles/cdk-a11y.umd.js +10 -2
  4. package/bundles/cdk-a11y.umd.js.map +1 -1
  5. package/bundles/cdk-a11y.umd.min.js +1 -1
  6. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  7. package/bundles/cdk-drag-drop.umd.js +239 -36
  8. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  9. package/bundles/cdk-drag-drop.umd.min.js +2 -2
  10. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  11. package/bundles/cdk-overlay.umd.js +15 -8
  12. package/bundles/cdk-overlay.umd.js.map +1 -1
  13. package/bundles/cdk-overlay.umd.min.js +2 -2
  14. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  15. package/bundles/cdk-platform.umd.js +21 -0
  16. package/bundles/cdk-platform.umd.js.map +1 -1
  17. package/bundles/cdk-platform.umd.min.js +1 -1
  18. package/bundles/cdk-platform.umd.min.js.map +1 -1
  19. package/bundles/cdk-scrolling.umd.js +1 -1
  20. package/bundles/cdk-scrolling.umd.js.map +1 -1
  21. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  22. package/bundles/cdk-stepper.umd.js +46 -40
  23. package/bundles/cdk-stepper.umd.js.map +1 -1
  24. package/bundles/cdk-stepper.umd.min.js +1 -1
  25. package/bundles/cdk-stepper.umd.min.js.map +1 -1
  26. package/bundles/cdk-table.umd.js +4 -4
  27. package/bundles/cdk-table.umd.js.map +1 -1
  28. package/bundles/cdk-table.umd.min.js.map +1 -1
  29. package/bundles/cdk-testing.umd.js +404 -0
  30. package/bundles/cdk-testing.umd.js.map +1 -0
  31. package/bundles/cdk-testing.umd.min.js +9 -0
  32. package/bundles/cdk-testing.umd.min.js.map +1 -0
  33. package/bundles/cdk-text-field.umd.js +3 -3
  34. package/bundles/cdk-text-field.umd.js.map +1 -1
  35. package/bundles/cdk-text-field.umd.min.js.map +1 -1
  36. package/bundles/cdk.umd.js +1 -1
  37. package/bundles/cdk.umd.js.map +1 -1
  38. package/bundles/cdk.umd.min.js +1 -1
  39. package/bundles/cdk.umd.min.js.map +1 -1
  40. package/drag-drop/typings/drag-ref.d.ts +9 -0
  41. package/drag-drop/typings/drop-list-ref.d.ts +7 -1
  42. package/drag-drop/typings/index.metadata.json +1 -1
  43. package/esm2015/a11y.js +10 -2
  44. package/esm2015/a11y.js.map +1 -1
  45. package/esm2015/cdk.js +1 -1
  46. package/esm2015/cdk.js.map +1 -1
  47. package/esm2015/drag-drop.js +212 -37
  48. package/esm2015/drag-drop.js.map +1 -1
  49. package/esm2015/overlay.js +13 -6
  50. package/esm2015/overlay.js.map +1 -1
  51. package/esm2015/platform.js +21 -1
  52. package/esm2015/platform.js.map +1 -1
  53. package/esm2015/scrolling.js +1 -1
  54. package/esm2015/scrolling.js.map +1 -1
  55. package/esm2015/stepper.js +51 -45
  56. package/esm2015/stepper.js.map +1 -1
  57. package/esm2015/table.js +4 -4
  58. package/esm2015/table.js.map +1 -1
  59. package/esm2015/testing.js +370 -0
  60. package/esm2015/testing.js.map +1 -0
  61. package/esm2015/text-field.js +1 -1
  62. package/esm2015/text-field.js.map +1 -1
  63. package/esm5/a11y.es5.js +10 -2
  64. package/esm5/a11y.es5.js.map +1 -1
  65. package/esm5/cdk.es5.js +1 -1
  66. package/esm5/cdk.es5.js.map +1 -1
  67. package/esm5/drag-drop.es5.js +241 -38
  68. package/esm5/drag-drop.es5.js.map +1 -1
  69. package/esm5/overlay.es5.js +15 -8
  70. package/esm5/overlay.es5.js.map +1 -1
  71. package/esm5/platform.es5.js +21 -1
  72. package/esm5/platform.es5.js.map +1 -1
  73. package/esm5/scrolling.es5.js +1 -1
  74. package/esm5/scrolling.es5.js.map +1 -1
  75. package/esm5/stepper.es5.js +49 -43
  76. package/esm5/stepper.es5.js.map +1 -1
  77. package/esm5/table.es5.js +4 -4
  78. package/esm5/table.es5.js.map +1 -1
  79. package/esm5/testing.es5.js +390 -0
  80. package/esm5/testing.es5.js.map +1 -0
  81. package/esm5/text-field.es5.js +3 -3
  82. package/esm5/text-field.es5.js.map +1 -1
  83. package/overlay/typings/index.metadata.json +1 -1
  84. package/overlay/typings/position/flexible-connected-position-strategy.d.ts +5 -2
  85. package/overlay/typings/public-api.d.ts +1 -1
  86. package/package.json +4 -4
  87. package/platform/typings/features/shadow-dom.d.ts +9 -0
  88. package/platform/typings/index.metadata.json +1 -1
  89. package/platform/typings/public-api.d.ts +1 -0
  90. package/schematics/ng-update/index.js +2 -2
  91. package/schematics/ng-update/index.js.map +1 -1
  92. package/schematics/ng-update/test-cases/misc/global-stylesheets-test.css +1 -0
  93. package/schematics/ng-update/upgrade-rules/class-inheritance-rule.js +3 -3
  94. package/schematics/ng-update/upgrade-rules/class-inheritance-rule.js.map +1 -1
  95. package/schematics/tsconfig.tsbuildinfo +2898 -2898
  96. package/schematics/update-tool/index.js +9 -5
  97. package/schematics/update-tool/index.js.map +1 -1
  98. package/scrolling/typings/virtual-scroll-viewport.d.ts +1 -1
  99. package/stepper/typings/index.metadata.json +1 -1
  100. package/stepper/typings/stepper.d.ts +3 -3
  101. package/table/typings/table.d.ts +4 -4
  102. package/testing/index.d.ts +8 -0
  103. package/testing/index.metadata.json +12 -0
  104. package/testing/package.json +8 -0
  105. package/testing/typings/dispatch-events.d.ts +33 -0
  106. package/testing/typings/element-focus.d.ts +18 -0
  107. package/testing/typings/event-objects.d.ts +34 -0
  108. package/testing/typings/index.d.ts +4 -0
  109. package/testing/typings/index.metadata.json +1 -0
  110. package/testing/typings/public-api.d.ts +11 -0
  111. package/testing/typings/type-in-element.d.ts +41 -0
  112. package/testing.d.ts +8 -0
  113. package/testing.metadata.json +12 -0
  114. package/text-field/typings/autosize.d.ts +1 -1
  115. package/typings/a11y/index.metadata.json +1 -1
  116. package/typings/a11y/key-manager/focus-key-manager.d.ts +1 -1
  117. package/typings/drag-drop/drag-ref.d.ts +9 -0
  118. package/typings/drag-drop/drop-list-ref.d.ts +7 -1
  119. package/typings/drag-drop/index.metadata.json +1 -1
  120. package/typings/esm5/a11y/index.metadata.json +1 -1
  121. package/typings/esm5/a11y/key-manager/focus-key-manager.d.ts +1 -1
  122. package/typings/esm5/drag-drop/drag-ref.d.ts +9 -0
  123. package/typings/esm5/drag-drop/drop-list-ref.d.ts +7 -1
  124. package/typings/esm5/drag-drop/index.metadata.json +1 -1
  125. package/typings/esm5/index.metadata.json +1 -1
  126. package/typings/esm5/overlay/index.metadata.json +1 -1
  127. package/typings/esm5/overlay/position/flexible-connected-position-strategy.d.ts +5 -2
  128. package/typings/esm5/overlay/public-api.d.ts +1 -1
  129. package/typings/esm5/platform/features/shadow-dom.d.ts +9 -0
  130. package/typings/esm5/platform/index.metadata.json +1 -1
  131. package/typings/esm5/platform/public-api.d.ts +1 -0
  132. package/typings/esm5/scrolling/virtual-scroll-viewport.d.ts +1 -1
  133. package/typings/esm5/stepper/index.metadata.json +1 -1
  134. package/typings/esm5/stepper/stepper.d.ts +3 -3
  135. package/typings/esm5/table/table.d.ts +4 -4
  136. package/typings/esm5/testing/dispatch-events.d.ts +33 -0
  137. package/typings/esm5/testing/element-focus.d.ts +18 -0
  138. package/typings/esm5/testing/event-objects.d.ts +34 -0
  139. package/typings/esm5/testing/index.d.ts +4 -0
  140. package/typings/esm5/testing/index.metadata.json +1 -0
  141. package/typings/esm5/testing/public-api.d.ts +11 -0
  142. package/typings/esm5/testing/type-in-element.d.ts +41 -0
  143. package/typings/esm5/text-field/autosize.d.ts +1 -1
  144. package/typings/index.metadata.json +1 -1
  145. package/typings/overlay/index.metadata.json +1 -1
  146. package/typings/overlay/position/flexible-connected-position-strategy.d.ts +5 -2
  147. package/typings/overlay/public-api.d.ts +1 -1
  148. package/typings/platform/features/shadow-dom.d.ts +9 -0
  149. package/typings/platform/index.metadata.json +1 -1
  150. package/typings/platform/public-api.d.ts +1 -0
  151. package/typings/scrolling/virtual-scroll-viewport.d.ts +1 -1
  152. package/typings/stepper/index.metadata.json +1 -1
  153. package/typings/stepper/stepper.d.ts +3 -3
  154. package/typings/table/table.d.ts +4 -4
  155. package/typings/testing/dispatch-events.d.ts +33 -0
  156. package/typings/testing/element-focus.d.ts +18 -0
  157. package/typings/testing/event-objects.d.ts +34 -0
  158. package/typings/testing/index.d.ts +4 -0
  159. package/typings/testing/index.metadata.json +1 -0
  160. package/typings/testing/public-api.d.ts +11 -0
  161. package/typings/testing/type-in-element.d.ts +41 -0
  162. package/typings/text-field/autosize.d.ts +1 -1
package/esm5/cdk.es5.js CHANGED
@@ -15,7 +15,7 @@ import { Version } from '@angular/core';
15
15
  * Current version of the Angular Component Development Kit.
16
16
  * @type {?}
17
17
  */
18
- var VERSION = new Version('8.1.4');
18
+ var VERSION = new Version('8.2.3');
19
19
 
20
20
  /**
21
21
  * @fileoverview added by tsickle
@@ -1 +1 @@
1
- {"version":3,"file":"cdk.es5.js","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.io/license\n */\n\nimport {Version} from '@angular/core';\n\n/** Current version of the Angular Component Development Kit. */\nexport const VERSION = new Version('8.1.4');\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAWA,AAAA,IAAa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB,CAAC;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"cdk.es5.js","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.io/license\n */\n\nimport {Version} from '@angular/core';\n\n/** Current version of the Angular Component Development Kit. */\nexport const VERSION = new Version('8.2.3');\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAWA,AAAA,IAAa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB,CAAC;;;;;;;;;;;;;;"}
@@ -5,11 +5,11 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { normalizePassiveListenerOptions } from '@angular/cdk/platform';
8
+ import { normalizePassiveListenerOptions, _supportsShadowDom } from '@angular/cdk/platform';
9
9
  import { coerceBooleanProperty, coerceElement, coerceNumberProperty, coerceArray } from '@angular/cdk/coercion';
10
10
  import { Subscription, Subject, interval, animationFrameScheduler, Observable, merge } from 'rxjs';
11
11
  import { startWith, takeUntil, take, map, switchMap, tap } from 'rxjs/operators';
12
- import { ElementRef, Injectable, NgZone, Inject, InjectionToken, NgModule, ContentChildren, EventEmitter, forwardRef, Input, Output, Optional, Directive, ChangeDetectorRef, SkipSelf, ContentChild, ViewContainerRef, isDevMode, TemplateRef, ɵɵdefineInjectable, ɵɵinject } from '@angular/core';
12
+ import { Injectable, NgZone, Inject, InjectionToken, NgModule, ContentChildren, ElementRef, EventEmitter, forwardRef, Input, Output, Optional, Directive, ChangeDetectorRef, SkipSelf, ContentChild, ViewContainerRef, isDevMode, TemplateRef, ɵɵdefineInjectable, ɵɵinject } from '@angular/core';
13
13
  import { DOCUMENT } from '@angular/common';
14
14
  import { ViewportRuler } from '@angular/cdk/scrolling';
15
15
  import { Directionality } from '@angular/cdk/bidi';
@@ -28,7 +28,7 @@ import { Directionality } from '@angular/cdk/bidi';
28
28
  function extendStyles(dest, source) {
29
29
  for (var key in source) {
30
30
  if (source.hasOwnProperty(key)) {
31
- dest[(/** @type {?} */ (key))] = source[(/** @type {?} */ (key))];
31
+ dest[key] = (/** @type {?} */ (source[key]));
32
32
  }
33
33
  }
34
34
  return dest;
@@ -184,6 +184,10 @@ DragRef = /** @class */ (function () {
184
184
  * Subscription to the viewport being scrolled.
185
185
  */
186
186
  this._scrollSubscription = Subscription.EMPTY;
187
+ /**
188
+ * Subscription to the viewport being resized.
189
+ */
190
+ this._resizeSubscription = Subscription.EMPTY;
187
191
  /**
188
192
  * Cached reference to the boundary element.
189
193
  */
@@ -556,7 +560,17 @@ DragRef = /** @class */ (function () {
556
560
  * @return {THIS}
557
561
  */
558
562
  function (boundaryElement) {
563
+ var _this = this;
559
564
  (/** @type {?} */ (this))._boundaryElement = boundaryElement ? coerceElement(boundaryElement) : null;
565
+ (/** @type {?} */ (this))._resizeSubscription.unsubscribe();
566
+ if (boundaryElement) {
567
+ (/** @type {?} */ (this))._resizeSubscription = (/** @type {?} */ (this))._viewportRuler
568
+ .change(10)
569
+ .subscribe((/**
570
+ * @return {?}
571
+ */
572
+ function () { return (/** @type {?} */ (_this))._containInsideBoundaryOnResize(); }));
573
+ }
560
574
  return (/** @type {?} */ (this));
561
575
  };
562
576
  /** Removes the dragging functionality from the DOM element. */
@@ -832,6 +846,7 @@ DragRef = /** @class */ (function () {
832
846
  }
833
847
  this._removeSubscriptions();
834
848
  this._dragDropRegistry.stopDragging(this);
849
+ this._toggleNativeDragInteractions();
835
850
  if (this._handles) {
836
851
  this._rootElement.style.webkitTapHighlightColor = this._rootElementTapHighlight;
837
852
  }
@@ -847,6 +862,7 @@ DragRef = /** @class */ (function () {
847
862
  */
848
863
  function () {
849
864
  _this._cleanupDragArtifacts(event);
865
+ _this._cleanupCachedDimensions();
850
866
  _this._dragDropRegistry.stopDragging(_this);
851
867
  }));
852
868
  }
@@ -865,6 +881,7 @@ DragRef = /** @class */ (function () {
865
881
  distance: _this._getDragDistance(_this._getPointerPositionOnPage(event))
866
882
  });
867
883
  }));
884
+ this._cleanupCachedDimensions();
868
885
  this._dragDropRegistry.stopDragging(this);
869
886
  }
870
887
  };
@@ -1076,7 +1093,7 @@ DragRef = /** @class */ (function () {
1076
1093
  // Drop container that draggable has been moved into.
1077
1094
  /** @type {?} */
1078
1095
  var newContainer = this._initialContainer._getSiblingContainerFromPosition(this, x, y);
1079
- // If we couldn't find a new container to move the item into, and the item has left it's
1096
+ // If we couldn't find a new container to move the item into, and the item has left its
1080
1097
  // initial container, check whether the it's over the initial container. This handles the
1081
1098
  // case where two containers are connected one way and the user tries to undo dragging an
1082
1099
  // item into a new container.
@@ -1133,7 +1150,7 @@ DragRef = /** @class */ (function () {
1133
1150
  if (previewTemplate) {
1134
1151
  /** @type {?} */
1135
1152
  var viewRef = (/** @type {?} */ (previewConfig)).viewContainer.createEmbeddedView(previewTemplate, (/** @type {?} */ (previewConfig)).context);
1136
- preview = viewRef.rootNodes[0];
1153
+ preview = getRootNode(viewRef, this._document);
1137
1154
  this._previewRef = viewRef;
1138
1155
  preview.style.transform =
1139
1156
  getTransform(this._pickupPositionOnPage.x, this._pickupPositionOnPage.y);
@@ -1152,6 +1169,8 @@ DragRef = /** @class */ (function () {
1152
1169
  // It's important that we disable the pointer events on the preview, because
1153
1170
  // it can throw off the `document.elementFromPoint` calls in the `CdkDropList`.
1154
1171
  pointerEvents: 'none',
1172
+ // We have to reset the margin, because can throw off positioning relative to the viewport.
1173
+ margin: '0',
1155
1174
  position: 'fixed',
1156
1175
  top: '0',
1157
1176
  left: '0',
@@ -1247,7 +1266,7 @@ DragRef = /** @class */ (function () {
1247
1266
  var placeholder;
1248
1267
  if (placeholderTemplate) {
1249
1268
  this._placeholderRef = (/** @type {?} */ (placeholderConfig)).viewContainer.createEmbeddedView(placeholderTemplate, (/** @type {?} */ (placeholderConfig)).context);
1250
- placeholder = this._placeholderRef.rootNodes[0];
1269
+ placeholder = getRootNode(this._placeholderRef, this._document);
1251
1270
  }
1252
1271
  else {
1253
1272
  placeholder = deepCloneNode(this._rootElement);
@@ -1493,6 +1512,83 @@ DragRef = /** @class */ (function () {
1493
1512
  }
1494
1513
  return { x: 0, y: 0 };
1495
1514
  };
1515
+ /** Cleans up any cached element dimensions that we don't need after dragging has stopped. */
1516
+ /**
1517
+ * Cleans up any cached element dimensions that we don't need after dragging has stopped.
1518
+ * @private
1519
+ * @return {?}
1520
+ */
1521
+ DragRef.prototype._cleanupCachedDimensions = /**
1522
+ * Cleans up any cached element dimensions that we don't need after dragging has stopped.
1523
+ * @private
1524
+ * @return {?}
1525
+ */
1526
+ function () {
1527
+ this._boundaryRect = this._previewRect = undefined;
1528
+ };
1529
+ /**
1530
+ * Checks whether the element is still inside its boundary after the viewport has been resized.
1531
+ * If not, the position is adjusted so that the element fits again.
1532
+ */
1533
+ /**
1534
+ * Checks whether the element is still inside its boundary after the viewport has been resized.
1535
+ * If not, the position is adjusted so that the element fits again.
1536
+ * @private
1537
+ * @return {?}
1538
+ */
1539
+ DragRef.prototype._containInsideBoundaryOnResize = /**
1540
+ * Checks whether the element is still inside its boundary after the viewport has been resized.
1541
+ * If not, the position is adjusted so that the element fits again.
1542
+ * @private
1543
+ * @return {?}
1544
+ */
1545
+ function () {
1546
+ var _a = this._passiveTransform, x = _a.x, y = _a.y;
1547
+ if ((x === 0 && y === 0) || this.isDragging() || !this._boundaryElement) {
1548
+ return;
1549
+ }
1550
+ /** @type {?} */
1551
+ var boundaryRect = this._boundaryElement.getBoundingClientRect();
1552
+ /** @type {?} */
1553
+ var elementRect = this._rootElement.getBoundingClientRect();
1554
+ /** @type {?} */
1555
+ var leftOverflow = boundaryRect.left - elementRect.left;
1556
+ /** @type {?} */
1557
+ var rightOverflow = elementRect.right - boundaryRect.right;
1558
+ /** @type {?} */
1559
+ var topOverflow = boundaryRect.top - elementRect.top;
1560
+ /** @type {?} */
1561
+ var bottomOverflow = elementRect.bottom - boundaryRect.bottom;
1562
+ // If the element has become wider than the boundary, we can't
1563
+ // do much to make it fit so we just anchor it to the left.
1564
+ if (boundaryRect.width > elementRect.width) {
1565
+ if (leftOverflow > 0) {
1566
+ x += leftOverflow;
1567
+ }
1568
+ if (rightOverflow > 0) {
1569
+ x -= rightOverflow;
1570
+ }
1571
+ }
1572
+ else {
1573
+ x = 0;
1574
+ }
1575
+ // If the element has become taller than the boundary, we can't
1576
+ // do much to make it fit so we just anchor it to the top.
1577
+ if (boundaryRect.height > elementRect.height) {
1578
+ if (topOverflow > 0) {
1579
+ y += topOverflow;
1580
+ }
1581
+ if (bottomOverflow > 0) {
1582
+ y -= bottomOverflow;
1583
+ }
1584
+ }
1585
+ else {
1586
+ y = 0;
1587
+ }
1588
+ if (x !== this._passiveTransform.x || y !== this._passiveTransform.y) {
1589
+ this.setFreeDragPosition({ y: y, x: x });
1590
+ }
1591
+ };
1496
1592
  return DragRef;
1497
1593
  }());
1498
1594
  /**
@@ -1584,6 +1680,24 @@ function getPreviewInsertionPoint(documentRef) {
1584
1680
  documentRef.msFullscreenElement ||
1585
1681
  documentRef.body;
1586
1682
  }
1683
+ /**
1684
+ * Gets the root HTML element of an embedded view.
1685
+ * If the root is not an HTML element it gets wrapped in one.
1686
+ * @param {?} viewRef
1687
+ * @param {?} _document
1688
+ * @return {?}
1689
+ */
1690
+ function getRootNode(viewRef, _document) {
1691
+ /** @type {?} */
1692
+ var rootNode = viewRef.rootNodes[0];
1693
+ if (rootNode.nodeType !== _document.ELEMENT_NODE) {
1694
+ /** @type {?} */
1695
+ var wrapper = _document.createElement('div');
1696
+ wrapper.appendChild(rootNode);
1697
+ return wrapper;
1698
+ }
1699
+ return (/** @type {?} */ (rootNode));
1700
+ }
1587
1701
 
1588
1702
  /**
1589
1703
  * @fileoverview added by tsickle
@@ -1717,7 +1831,7 @@ DropListRef = /** @class */ (function () {
1717
1831
  /**
1718
1832
  * Whether sorting items within the list is disabled.
1719
1833
  */
1720
- this.sortingDisabled = true;
1834
+ this.sortingDisabled = false;
1721
1835
  /**
1722
1836
  * Whether auto-scrolling the view when the user
1723
1837
  * moves their pointer close to the edges is disabled.
@@ -1849,9 +1963,10 @@ DropListRef = /** @class */ (function () {
1849
1963
  }
1850
1964
  }));
1851
1965
  });
1966
+ /** @type {?} */
1967
+ var nativeNode = this.element = coerceElement(element);
1968
+ this._shadowRoot = getShadowRoot(nativeNode) || _document;
1852
1969
  _dragDropRegistry.registerDropContainer(this);
1853
- this._document = _document;
1854
- this.element = element instanceof ElementRef ? element.nativeElement : element;
1855
1970
  }
1856
1971
  /** Removes the drop list functionality from the DOM element. */
1857
1972
  /**
@@ -1921,17 +2036,7 @@ DropListRef = /** @class */ (function () {
1921
2036
  }
1922
2037
  // @breaking-change 9.0.0 Remove check for _viewportRuler once it's marked as a required param.
1923
2038
  if (this._viewportRuler) {
1924
- this._viewportScrollPosition = this._viewportRuler.getViewportScrollPosition();
1925
- this._viewportScrollSubscription = this._dragDropRegistry.scroll.subscribe((/**
1926
- * @return {?}
1927
- */
1928
- function () {
1929
- if (_this.isDragging()) {
1930
- /** @type {?} */
1931
- var newPosition = (/** @type {?} */ (_this._viewportRuler)).getViewportScrollPosition();
1932
- _this._updateAfterScroll(_this._viewportScrollPosition, newPosition.top, newPosition.left, _this._clientRect);
1933
- }
1934
- }));
2039
+ this._listenToScrollEvents();
1935
2040
  }
1936
2041
  };
1937
2042
  /**
@@ -2337,6 +2442,7 @@ DropListRef = /** @class */ (function () {
2337
2442
  * @return {?}
2338
2443
  */
2339
2444
  function (pointerX, pointerY) {
2445
+ var _a;
2340
2446
  if (this.autoScrollDisabled) {
2341
2447
  return;
2342
2448
  }
@@ -2346,29 +2452,25 @@ DropListRef = /** @class */ (function () {
2346
2452
  var verticalScrollDirection = 0 /* NONE */;
2347
2453
  /** @type {?} */
2348
2454
  var horizontalScrollDirection = 0 /* NONE */;
2455
+ // Check whether we should start scrolling the container.
2456
+ if (this._isPointerNearDropContainer(pointerX, pointerY)) {
2457
+ /** @type {?} */
2458
+ var element = coerceElement(this.element);
2459
+ _a = getElementScrollDirections(element, this._clientRect, pointerX, pointerY), verticalScrollDirection = _a[0], horizontalScrollDirection = _a[1];
2460
+ if (verticalScrollDirection || horizontalScrollDirection) {
2461
+ scrollNode = element;
2462
+ }
2463
+ }
2349
2464
  // @breaking-change 9.0.0 Remove null check for _viewportRuler once it's a required parameter.
2350
- // Check whether we're in range to scroll the viewport.
2351
- if (this._viewportRuler) {
2352
- var _a = this._viewportRuler.getViewportSize(), width = _a.width, height = _a.height;
2465
+ // Otherwise check if we can start scrolling the viewport.
2466
+ if (this._viewportRuler && !verticalScrollDirection && !horizontalScrollDirection) {
2467
+ var _b = this._viewportRuler.getViewportSize(), width = _b.width, height = _b.height;
2353
2468
  /** @type {?} */
2354
2469
  var clientRect = { width: width, height: height, top: 0, right: width, bottom: height, left: 0 };
2355
2470
  verticalScrollDirection = getVerticalScrollDirection(clientRect, pointerY);
2356
2471
  horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
2357
2472
  scrollNode = window;
2358
2473
  }
2359
- // If we couldn't find a scroll direction based on the
2360
- // window, try with the container, if the pointer is close by.
2361
- if (!verticalScrollDirection && !horizontalScrollDirection &&
2362
- this._isPointerNearDropContainer(pointerX, pointerY)) {
2363
- verticalScrollDirection = getVerticalScrollDirection(this._clientRect, pointerY);
2364
- horizontalScrollDirection = getHorizontalScrollDirection(this._clientRect, pointerX);
2365
- scrollNode = coerceElement(this.element);
2366
- }
2367
- // TODO(crisbeto): we also need to account for whether the view or element are scrollable in
2368
- // the first place. With the current approach we'll still try to scroll them, but it just
2369
- // won't do anything. The only case where this is relevant is that if we have a scrollable
2370
- // list close to the viewport edge where the viewport isn't scrollable. In this case the
2371
- // we'll be trying to scroll the viewport rather than the list.
2372
2474
  if (scrollNode && (verticalScrollDirection !== this._verticalScrollDirection ||
2373
2475
  horizontalScrollDirection !== this._horizontalScrollDirection ||
2374
2476
  scrollNode !== this._scrollNode)) {
@@ -2831,7 +2933,7 @@ DropListRef = /** @class */ (function () {
2831
2933
  return false;
2832
2934
  }
2833
2935
  /** @type {?} */
2834
- var elementFromPoint = (/** @type {?} */ (this._document.elementFromPoint(x, y)));
2936
+ var elementFromPoint = (/** @type {?} */ (this._shadowRoot.elementFromPoint(x, y)));
2835
2937
  // If there's no element at the pointer position, then
2836
2938
  // the client rect is probably scrolled out of the view.
2837
2939
  if (!elementFromPoint) {
@@ -2867,6 +2969,7 @@ DropListRef = /** @class */ (function () {
2867
2969
  if (!activeSiblings.has(sibling)) {
2868
2970
  activeSiblings.add(sibling);
2869
2971
  this._cacheOwnPosition();
2972
+ this._listenToScrollEvents();
2870
2973
  }
2871
2974
  };
2872
2975
  /**
@@ -2885,6 +2988,40 @@ DropListRef = /** @class */ (function () {
2885
2988
  */
2886
2989
  function (sibling) {
2887
2990
  this._activeSiblings.delete(sibling);
2991
+ this._viewportScrollSubscription.unsubscribe();
2992
+ };
2993
+ /**
2994
+ * Starts listening to scroll events on the viewport.
2995
+ * Used for updating the internal state of the list.
2996
+ */
2997
+ /**
2998
+ * Starts listening to scroll events on the viewport.
2999
+ * Used for updating the internal state of the list.
3000
+ * @private
3001
+ * @return {?}
3002
+ */
3003
+ DropListRef.prototype._listenToScrollEvents = /**
3004
+ * Starts listening to scroll events on the viewport.
3005
+ * Used for updating the internal state of the list.
3006
+ * @private
3007
+ * @return {?}
3008
+ */
3009
+ function () {
3010
+ var _this = this;
3011
+ this._viewportScrollPosition = (/** @type {?} */ (this._viewportRuler)).getViewportScrollPosition();
3012
+ this._viewportScrollSubscription = this._dragDropRegistry.scroll.subscribe((/**
3013
+ * @return {?}
3014
+ */
3015
+ function () {
3016
+ if (_this.isDragging()) {
3017
+ /** @type {?} */
3018
+ var newPosition = (/** @type {?} */ (_this._viewportRuler)).getViewportScrollPosition();
3019
+ _this._updateAfterScroll(_this._viewportScrollPosition, newPosition.top, newPosition.left, _this._clientRect);
3020
+ }
3021
+ else if (_this.isReceiving()) {
3022
+ _this._cacheOwnPosition();
3023
+ }
3024
+ }));
2888
3025
  };
2889
3026
  return DropListRef;
2890
3027
  }());
@@ -3015,6 +3152,69 @@ function getHorizontalScrollDirection(clientRect, pointerX) {
3015
3152
  }
3016
3153
  return 0 /* NONE */;
3017
3154
  }
3155
+ /**
3156
+ * Gets the directions in which an element node should be scrolled,
3157
+ * assuming that the user's pointer is already within it scrollable region.
3158
+ * @param {?} element Element for which we should calculate the scroll direction.
3159
+ * @param {?} clientRect Bounding client rectangle of the element.
3160
+ * @param {?} pointerX Position of the user's pointer along the x axis.
3161
+ * @param {?} pointerY Position of the user's pointer along the y axis.
3162
+ * @return {?}
3163
+ */
3164
+ function getElementScrollDirections(element, clientRect, pointerX, pointerY) {
3165
+ /** @type {?} */
3166
+ var computedVertical = getVerticalScrollDirection(clientRect, pointerY);
3167
+ /** @type {?} */
3168
+ var computedHorizontal = getHorizontalScrollDirection(clientRect, pointerX);
3169
+ /** @type {?} */
3170
+ var verticalScrollDirection = 0 /* NONE */;
3171
+ /** @type {?} */
3172
+ var horizontalScrollDirection = 0 /* NONE */;
3173
+ // Note that we here we do some extra checks for whether the element is actually scrollable in
3174
+ // a certain direction and we only assign the scroll direction if it is. We do this so that we
3175
+ // can allow other elements to be scrolled, if the current element can't be scrolled anymore.
3176
+ // This allows us to handle cases where the scroll regions of two scrollable elements overlap.
3177
+ if (computedVertical) {
3178
+ /** @type {?} */
3179
+ var scrollTop = element.scrollTop;
3180
+ if (computedVertical === 1 /* UP */) {
3181
+ if (scrollTop > 0) {
3182
+ verticalScrollDirection = 1 /* UP */;
3183
+ }
3184
+ }
3185
+ else if (element.scrollHeight - scrollTop > element.clientHeight) {
3186
+ verticalScrollDirection = 2 /* DOWN */;
3187
+ }
3188
+ }
3189
+ if (computedHorizontal) {
3190
+ /** @type {?} */
3191
+ var scrollLeft = element.scrollLeft;
3192
+ if (computedHorizontal === 1 /* LEFT */) {
3193
+ if (scrollLeft > 0) {
3194
+ horizontalScrollDirection = 1 /* LEFT */;
3195
+ }
3196
+ }
3197
+ else if (element.scrollWidth - scrollLeft > element.clientWidth) {
3198
+ horizontalScrollDirection = 2 /* RIGHT */;
3199
+ }
3200
+ }
3201
+ return [verticalScrollDirection, horizontalScrollDirection];
3202
+ }
3203
+ /**
3204
+ * Gets the shadow root of an element, if any.
3205
+ * @param {?} element
3206
+ * @return {?}
3207
+ */
3208
+ function getShadowRoot(element) {
3209
+ if (_supportsShadowDom()) {
3210
+ /** @type {?} */
3211
+ var rootNode = element.getRootNode ? element.getRootNode() : null;
3212
+ if (rootNode instanceof ShadowRoot) {
3213
+ return rootNode;
3214
+ }
3215
+ }
3216
+ return null;
3217
+ }
3018
3218
 
3019
3219
  /**
3020
3220
  * @fileoverview added by tsickle
@@ -3221,7 +3421,10 @@ var DragDropRegistry = /** @class */ (function () {
3221
3421
  * @param {?} e
3222
3422
  * @return {?}
3223
3423
  */
3224
- function (e) { return _this.scroll.next(e); })
3424
+ function (e) { return _this.scroll.next(e); }),
3425
+ // Use capturing so that we pick up scroll changes in any scrollable nodes that aren't
3426
+ // the document. See https://github.com/angular/components/issues/17144.
3427
+ options: true
3225
3428
  })
3226
3429
  // Preventing the default action on `mousemove` isn't enough to disable text selection
3227
3430
  // on Safari so we need to prevent the selection event as well. Alternatively this can