@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
@@ -389,9 +389,6 @@
389
389
  };
390
390
  /** Handler that is invoked when the user moves their pointer after they've initiated a drag. */
391
391
  this._pointerMove = function (event) {
392
- // Prevent the default action as early as possible in order to block
393
- // native actions like dragging the selected text or images with the mouse.
394
- event.preventDefault();
395
392
  var pointerPosition = _this._getPointerPositionOnPage(event);
396
393
  if (!_this._hasStartedDragging) {
397
394
  var distanceX = Math.abs(pointerPosition.x - _this._pickupPositionOnPage.x);
@@ -426,6 +423,10 @@
426
423
  _this._previewRect = (_this._preview || _this._rootElement).getBoundingClientRect();
427
424
  }
428
425
  }
426
+ // We prevent the default action down here so that we know that dragging has started. This is
427
+ // important for touch devices where doing this too early can unnecessarily block scrolling,
428
+ // if there's a dragging delay.
429
+ event.preventDefault();
429
430
  var constrainedPointerPosition = _this._getConstrainedPointerPosition(pointerPosition);
430
431
  _this._hasMoved = true;
431
432
  _this._lastKnownPointerPosition = pointerPosition;
@@ -465,7 +466,7 @@
465
466
  this._pointerUp = function (event) {
466
467
  _this._endDragSequence(event);
467
468
  };
468
- this.withRootElement(element);
469
+ this.withRootElement(element).withParent(_config.parentDragRef || null);
469
470
  this._parentPositions = new ParentPositionTracker(_document, _viewportRuler);
470
471
  _dragDropRegistry.registerDragItem(this);
471
472
  }
@@ -576,6 +577,11 @@
576
577
  }
577
578
  return this;
578
579
  };
580
+ /** Sets the parent ref that the ref is nested in. */
581
+ DragRef.prototype.withParent = function (parent) {
582
+ this._parentDragRef = parent;
583
+ return this;
584
+ };
579
585
  /** Removes the dragging functionality from the DOM element. */
580
586
  DragRef.prototype.dispose = function () {
581
587
  this._removeRootElementListeners(this._rootElement);
@@ -605,7 +611,7 @@
605
611
  this._resizeSubscription.unsubscribe();
606
612
  this._parentPositions.clear();
607
613
  this._boundaryElement = this._rootElement = this._ownerSVGElement = this._placeholderTemplate =
608
- this._previewTemplate = this._anchor = null;
614
+ this._previewTemplate = this._anchor = this._parentDragRef = null;
609
615
  };
610
616
  /** Checks whether the element is currently being dragged. */
611
617
  DragRef.prototype.isDragging = function () {
@@ -791,10 +797,11 @@
791
797
  */
792
798
  DragRef.prototype._initializeDragSequence = function (referenceElement, event) {
793
799
  var _this = this;
794
- // Always stop propagation for the event that initializes
795
- // the dragging sequence, in order to prevent it from potentially
796
- // starting another sequence for a draggable parent somewhere up the DOM tree.
797
- event.stopPropagation();
800
+ // Stop propagation if the item is inside another
801
+ // draggable so we don't start multiple drag sequences.
802
+ if (this._parentDragRef) {
803
+ event.stopPropagation();
804
+ }
798
805
  var isDragging = this.isDragging();
799
806
  var isTouchSequence = isTouchEvent(event);
800
807
  var isAuxiliaryMouseButton = !isTouchSequence && event.button !== 0;
@@ -1366,6 +1373,8 @@
1366
1373
  return extendStatics(d, b);
1367
1374
  };
1368
1375
  function __extends(d, b) {
1376
+ if (typeof b !== "function" && b !== null)
1377
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1369
1378
  extendStatics(d, b);
1370
1379
  function __() { this.constructor = d; }
1371
1380
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -1551,11 +1560,13 @@
1551
1560
  }
1552
1561
  return ar;
1553
1562
  }
1563
+ /** @deprecated */
1554
1564
  function __spread() {
1555
1565
  for (var ar = [], i = 0; i < arguments.length; i++)
1556
1566
  ar = ar.concat(__read(arguments[i]));
1557
1567
  return ar;
1558
1568
  }
1569
+ /** @deprecated */
1559
1570
  function __spreadArrays() {
1560
1571
  for (var s = 0, i = 0, il = arguments.length; i < il; i++)
1561
1572
  s += arguments[i].length;
@@ -1564,7 +1575,11 @@
1564
1575
  r[k] = a[j];
1565
1576
  return r;
1566
1577
  }
1567
- ;
1578
+ function __spreadArray(to, from) {
1579
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
1580
+ to[j] = from[i];
1581
+ return to;
1582
+ }
1568
1583
  function __await(v) {
1569
1584
  return this instanceof __await ? (this.v = v, this) : new __await(v);
1570
1585
  }
@@ -1713,11 +1728,6 @@
1713
1728
  * viewport. The value comes from trying it out manually until it feels right.
1714
1729
  */
1715
1730
  var SCROLL_PROXIMITY_THRESHOLD = 0.05;
1716
- /**
1717
- * Number of pixels to scroll for each frame when auto-scrolling an element.
1718
- * The value comes from trying it out manually until it feels right.
1719
- */
1720
- var AUTO_SCROLL_STEP = 2;
1721
1731
  /**
1722
1732
  * Reference to a drop list. Used to manipulate or dispose of the container.
1723
1733
  */
@@ -1736,6 +1746,8 @@
1736
1746
  * moves their pointer close to the edges is disabled.
1737
1747
  */
1738
1748
  this.autoScrollDisabled = false;
1749
+ /** Number of pixels to scroll for each frame when auto-scrolling an element. */
1750
+ this.autoScrollStep = 2;
1739
1751
  /**
1740
1752
  * Function that is used to determine whether an item
1741
1753
  * is allowed to be moved into a drop container.
@@ -1768,6 +1780,8 @@
1768
1780
  * overlap with the swapped item after the swapping occurred.
1769
1781
  */
1770
1782
  this._previousSwap = { drag: null, delta: 0, overlaps: false };
1783
+ /** Draggable items in the container. */
1784
+ this._draggables = [];
1771
1785
  /** Drop lists that are connected to the current one. */
1772
1786
  this._siblings = [];
1773
1787
  /** Direction in which the list is oriented. */
@@ -1793,17 +1807,18 @@
1793
1807
  .pipe(operators.takeUntil(_this._stopScrollTimers))
1794
1808
  .subscribe(function () {
1795
1809
  var node = _this._scrollNode;
1810
+ var scrollStep = _this.autoScrollStep;
1796
1811
  if (_this._verticalScrollDirection === 1 /* UP */) {
1797
- incrementVerticalScroll(node, -AUTO_SCROLL_STEP);
1812
+ incrementVerticalScroll(node, -scrollStep);
1798
1813
  }
1799
1814
  else if (_this._verticalScrollDirection === 2 /* DOWN */) {
1800
- incrementVerticalScroll(node, AUTO_SCROLL_STEP);
1815
+ incrementVerticalScroll(node, scrollStep);
1801
1816
  }
1802
1817
  if (_this._horizontalScrollDirection === 1 /* LEFT */) {
1803
- incrementHorizontalScroll(node, -AUTO_SCROLL_STEP);
1818
+ incrementHorizontalScroll(node, -scrollStep);
1804
1819
  }
1805
1820
  else if (_this._horizontalScrollDirection === 2 /* RIGHT */) {
1806
- incrementHorizontalScroll(node, AUTO_SCROLL_STEP);
1821
+ incrementHorizontalScroll(node, scrollStep);
1807
1822
  }
1808
1823
  });
1809
1824
  };
@@ -1834,19 +1849,8 @@
1834
1849
  };
1835
1850
  /** Starts dragging an item. */
1836
1851
  DropListRef.prototype.start = function () {
1837
- var _this = this;
1838
- var styles = coercion.coerceElement(this.element).style;
1839
- this.beforeStarted.next();
1840
- this._isDragging = true;
1841
- // We need to disable scroll snapping while the user is dragging, because it breaks automatic
1842
- // scrolling. The browser seems to round the value based on the snapping points which means
1843
- // that we can't increment/decrement the scroll position.
1844
- this._initialScrollSnap = styles.msScrollSnapType || styles.scrollSnapType || '';
1845
- styles.scrollSnapType = styles.msScrollSnapType = 'none';
1846
- this._cacheItems();
1847
- this._siblings.forEach(function (sibling) { return sibling._startReceiving(_this); });
1848
- this._viewportScrollSubscription.unsubscribe();
1849
- this._listenToScrollEvents();
1852
+ this._draggingStarted();
1853
+ this._notifyReceivingSiblings();
1850
1854
  };
1851
1855
  /**
1852
1856
  * Emits an event to indicate that the user moved an item into the container.
@@ -1857,7 +1861,7 @@
1857
1861
  * out automatically.
1858
1862
  */
1859
1863
  DropListRef.prototype.enter = function (item, pointerX, pointerY, index) {
1860
- this.start();
1864
+ this._draggingStarted();
1861
1865
  // If sorting is disabled, we want the item to return to its starting
1862
1866
  // position if the user is returning it to its initial container.
1863
1867
  var newIndex;
@@ -1909,6 +1913,8 @@
1909
1913
  // but we need to refresh them since the amount of items has changed and also parent rects.
1910
1914
  this._cacheItemPositions();
1911
1915
  this._cacheParentPositions();
1916
+ // Notify siblings at the end so that the item has been inserted into the `activeDraggables`.
1917
+ this._notifyReceivingSiblings();
1912
1918
  this.entered.next({ item: item, container: this, currentIndex: this.getItemIndex(item) });
1913
1919
  };
1914
1920
  /**
@@ -2032,7 +2038,7 @@
2032
2038
  */
2033
2039
  DropListRef.prototype._sortItem = function (item, pointerX, pointerY, pointerDelta) {
2034
2040
  // Don't sort the item if sorting is disabled or it's out of range.
2035
- if (this.sortingDisabled ||
2041
+ if (this.sortingDisabled || !this._clientRect ||
2036
2042
  !isPointerNearClientRect(this._clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
2037
2043
  return;
2038
2044
  }
@@ -2148,6 +2154,20 @@
2148
2154
  DropListRef.prototype._stopScrolling = function () {
2149
2155
  this._stopScrollTimers.next();
2150
2156
  };
2157
+ /** Starts the dragging sequence within the list. */
2158
+ DropListRef.prototype._draggingStarted = function () {
2159
+ var styles = coercion.coerceElement(this.element).style;
2160
+ this.beforeStarted.next();
2161
+ this._isDragging = true;
2162
+ // We need to disable scroll snapping while the user is dragging, because it breaks automatic
2163
+ // scrolling. The browser seems to round the value based on the snapping points which means
2164
+ // that we can't increment/decrement the scroll position.
2165
+ this._initialScrollSnap = styles.msScrollSnapType || styles.scrollSnapType || '';
2166
+ styles.scrollSnapType = styles.msScrollSnapType = 'none';
2167
+ this._cacheItems();
2168
+ this._viewportScrollSubscription.unsubscribe();
2169
+ this._listenToScrollEvents();
2170
+ };
2151
2171
  /** Caches the positions of the configured scrollable parents. */
2152
2172
  DropListRef.prototype._cacheParentPositions = function () {
2153
2173
  var element = coercion.coerceElement(this.element);
@@ -2304,7 +2324,7 @@
2304
2324
  * @param y Pointer position along the Y axis.
2305
2325
  */
2306
2326
  DropListRef.prototype._isOverContainer = function (x, y) {
2307
- return isInsideClientRect(this._clientRect, x, y);
2327
+ return this._clientRect != null && isInsideClientRect(this._clientRect, x, y);
2308
2328
  };
2309
2329
  /**
2310
2330
  * Figures out whether an item should be moved into a sibling
@@ -2323,7 +2343,8 @@
2323
2343
  * @param y Position of the item along the Y axis.
2324
2344
  */
2325
2345
  DropListRef.prototype._canReceive = function (item, x, y) {
2326
- if (!isInsideClientRect(this._clientRect, x, y) || !this.enterPredicate(item, this)) {
2346
+ if (!this._clientRect || !isInsideClientRect(this._clientRect, x, y) ||
2347
+ !this.enterPredicate(item, this)) {
2327
2348
  return false;
2328
2349
  }
2329
2350
  var elementFromPoint = this._getShadowRoot().elementFromPoint(x, y);
@@ -2345,9 +2366,16 @@
2345
2366
  * Called by one of the connected drop lists when a dragging sequence has started.
2346
2367
  * @param sibling Sibling in which dragging has started.
2347
2368
  */
2348
- DropListRef.prototype._startReceiving = function (sibling) {
2369
+ DropListRef.prototype._startReceiving = function (sibling, items) {
2370
+ var _this = this;
2349
2371
  var activeSiblings = this._activeSiblings;
2350
- if (!activeSiblings.has(sibling)) {
2372
+ if (!activeSiblings.has(sibling) && items.every(function (item) {
2373
+ // Note that we have to add an exception to the `enterPredicate` for items that started off
2374
+ // in this drop list. The drag ref has logic that allows an item to return to its initial
2375
+ // container, if it has left the initial container and none of the connected containers
2376
+ // allow it to enter. See `DragRef._updateActiveDropContainer` for more context.
2377
+ return _this.enterPredicate(item, _this) || _this._draggables.indexOf(item) > -1;
2378
+ })) {
2351
2379
  activeSiblings.add(sibling);
2352
2380
  this._cacheParentPositions();
2353
2381
  this._listenToScrollEvents();
@@ -2409,6 +2437,12 @@
2409
2437
  }
2410
2438
  return this._cachedShadowRoot;
2411
2439
  };
2440
+ /** Notifies any siblings that may potentially receive the item. */
2441
+ DropListRef.prototype._notifyReceivingSiblings = function () {
2442
+ var _this = this;
2443
+ var draggedItems = this._activeDraggables.filter(function (item) { return item.isDragging(); });
2444
+ this._siblings.forEach(function (sibling) { return sibling._startReceiving(_this, draggedItems); });
2445
+ };
2412
2446
  return DropListRef;
2413
2447
  }());
2414
2448
  /**
@@ -2556,9 +2590,14 @@
2556
2590
  /** Registered drag item instances. */
2557
2591
  this._dragInstances = new Set();
2558
2592
  /** Drag item instances that are currently being dragged. */
2559
- this._activeDragInstances = new Set();
2593
+ this._activeDragInstances = [];
2560
2594
  /** Keeps track of the event listeners that we've bound to the `document`. */
2561
2595
  this._globalListeners = new Map();
2596
+ /**
2597
+ * Predicate function to check if an item is being dragged. Moved out into a property,
2598
+ * because it'll be called a lot and we don't want to create a new function every time.
2599
+ */
2600
+ this._draggingPredicate = function (item) { return item.isDragging(); };
2562
2601
  /**
2563
2602
  * Emits the `touchmove` or `mousemove` events that are dispatched
2564
2603
  * while the user is dragging a drag item instance.
@@ -2576,14 +2615,19 @@
2576
2615
  * @param event Event whose default action should be prevented.
2577
2616
  */
2578
2617
  this._preventDefaultWhileDragging = function (event) {
2579
- if (_this._activeDragInstances.size) {
2618
+ if (_this._activeDragInstances.length > 0) {
2580
2619
  event.preventDefault();
2581
2620
  }
2582
2621
  };
2583
2622
  /** Event listener for `touchmove` that is bound even if no dragging is happening. */
2584
2623
  this._persistentTouchmoveListener = function (event) {
2585
- if (_this._activeDragInstances.size) {
2586
- event.preventDefault();
2624
+ if (_this._activeDragInstances.length > 0) {
2625
+ // Note that we only want to prevent the default action after dragging has actually started.
2626
+ // Usually this is the same time at which the item is added to the `_activeDragInstances`,
2627
+ // but it could be pushed back if the user has set up a drag delay or threshold.
2628
+ if (_this._activeDragInstances.some(_this._draggingPredicate)) {
2629
+ event.preventDefault();
2630
+ }
2587
2631
  _this.pointerMove.next(event);
2588
2632
  }
2589
2633
  };
@@ -2630,11 +2674,11 @@
2630
2674
  DragDropRegistry.prototype.startDragging = function (drag, event) {
2631
2675
  var _this = this;
2632
2676
  // Do not process the same drag twice to avoid memory leaks and redundant listeners
2633
- if (this._activeDragInstances.has(drag)) {
2677
+ if (this._activeDragInstances.indexOf(drag) > -1) {
2634
2678
  return;
2635
2679
  }
2636
- this._activeDragInstances.add(drag);
2637
- if (this._activeDragInstances.size === 1) {
2680
+ this._activeDragInstances.push(drag);
2681
+ if (this._activeDragInstances.length === 1) {
2638
2682
  var isTouchEvent = event.type.startsWith('touch');
2639
2683
  // We explicitly bind __active__ listeners here, because newer browsers will default to
2640
2684
  // passive ones for `mousemove` and `touchmove`. The events need to be active, because we
@@ -2675,14 +2719,17 @@
2675
2719
  };
2676
2720
  /** Stops dragging a drag item instance. */
2677
2721
  DragDropRegistry.prototype.stopDragging = function (drag) {
2678
- this._activeDragInstances.delete(drag);
2679
- if (this._activeDragInstances.size === 0) {
2680
- this._clearGlobalListeners();
2722
+ var index = this._activeDragInstances.indexOf(drag);
2723
+ if (index > -1) {
2724
+ this._activeDragInstances.splice(index, 1);
2725
+ if (this._activeDragInstances.length === 0) {
2726
+ this._clearGlobalListeners();
2727
+ }
2681
2728
  }
2682
2729
  };
2683
2730
  /** Gets whether a drag item instance is currently being dragged. */
2684
2731
  DragDropRegistry.prototype.isDragging = function (drag) {
2685
- return this._activeDragInstances.has(drag);
2732
+ return this._activeDragInstances.indexOf(drag) > -1;
2686
2733
  };
2687
2734
  DragDropRegistry.prototype.ngOnDestroy = function () {
2688
2735
  var _this = this;
@@ -3042,6 +3089,7 @@
3042
3089
  ref.lockAxis = _this.lockAxis;
3043
3090
  ref.sortingDisabled = coercion.coerceBooleanProperty(_this.sortingDisabled);
3044
3091
  ref.autoScrollDisabled = coercion.coerceBooleanProperty(_this.autoScrollDisabled);
3092
+ ref.autoScrollStep = coercion.coerceNumberProperty(_this.autoScrollStep, 2);
3045
3093
  ref
3046
3094
  .connectedTo(siblings.filter(function (drop) { return drop && drop !== _this; }).map(function (list) { return list._dropListRef; }))
3047
3095
  .withOrientation(_this.orientation);
@@ -3148,6 +3196,7 @@
3148
3196
  enterPredicate: [{ type: i0.Input, args: ['cdkDropListEnterPredicate',] }],
3149
3197
  sortPredicate: [{ type: i0.Input, args: ['cdkDropListSortPredicate',] }],
3150
3198
  autoScrollDisabled: [{ type: i0.Input, args: ['cdkDropListAutoScrollDisabled',] }],
3199
+ autoScrollStep: [{ type: i0.Input, args: ['cdkDropListAutoScrollStep',] }],
3151
3200
  dropped: [{ type: i0.Output, args: ['cdkDropListDropped',] }],
3152
3201
  entered: [{ type: i0.Output, args: ['cdkDropListEntered',] }],
3153
3202
  exited: [{ type: i0.Output, args: ['cdkDropListExited',] }],
@@ -3292,6 +3341,7 @@
3292
3341
  matchSize: [{ type: i0.Input }]
3293
3342
  };
3294
3343
 
3344
+ var DRAG_HOST_CLASS = 'cdk-drag';
3295
3345
  /** Element that can be moved inside a CdkDropList container. */
3296
3346
  var CdkDrag = /** @class */ (function () {
3297
3347
  function CdkDrag(
@@ -3303,7 +3353,7 @@
3303
3353
  * @deprecated `_document` parameter no longer being used and will be removed.
3304
3354
  * @breaking-change 12.0.0
3305
3355
  */
3306
- _document, _ngZone, _viewContainerRef, config, _dir, dragDrop, _changeDetectorRef, _selfHandle) {
3356
+ _document, _ngZone, _viewContainerRef, config, _dir, dragDrop, _changeDetectorRef, _selfHandle, _parentDrag) {
3307
3357
  var _this = this;
3308
3358
  this.element = element;
3309
3359
  this.dropContainer = dropContainer;
@@ -3312,6 +3362,7 @@
3312
3362
  this._dir = _dir;
3313
3363
  this._changeDetectorRef = _changeDetectorRef;
3314
3364
  this._selfHandle = _selfHandle;
3365
+ this._parentDrag = _parentDrag;
3315
3366
  this._destroyed = new rxjs.Subject();
3316
3367
  /** Emits when the user starts dragging the item. */
3317
3368
  this.started = new i0.EventEmitter();
@@ -3346,9 +3397,13 @@
3346
3397
  config.dragStartThreshold : 5,
3347
3398
  pointerDirectionChangeThreshold: config && config.pointerDirectionChangeThreshold != null ?
3348
3399
  config.pointerDirectionChangeThreshold : 5,
3349
- zIndex: config === null || config === void 0 ? void 0 : config.zIndex
3400
+ zIndex: config === null || config === void 0 ? void 0 : config.zIndex,
3350
3401
  });
3351
3402
  this._dragRef.data = this;
3403
+ // We have to keep track of the drag instances in order to be able to match an element to
3404
+ // a drag instance. We can't go through the global registry of `DragRef`, because the root
3405
+ // element could be different.
3406
+ CdkDrag._dragInstances.push(this);
3352
3407
  if (config) {
3353
3408
  this._assignDefaults(config);
3354
3409
  }
@@ -3457,6 +3512,10 @@
3457
3512
  if (this.dropContainer) {
3458
3513
  this.dropContainer.removeItem(this);
3459
3514
  }
3515
+ var index = CdkDrag._dragInstances.indexOf(this);
3516
+ if (index > -1) {
3517
+ CdkDrag._dragInstances.splice(index, -1);
3518
+ }
3460
3519
  this._destroyed.next();
3461
3520
  this._destroyed.complete();
3462
3521
  this._dragRef.dispose();
@@ -3520,6 +3579,28 @@
3520
3579
  }
3521
3580
  }
3522
3581
  });
3582
+ // This only needs to be resolved once.
3583
+ ref.beforeStarted.pipe(operators.take(1)).subscribe(function () {
3584
+ var _a, _b;
3585
+ // If we managed to resolve a parent through DI, use it.
3586
+ if (_this._parentDrag) {
3587
+ ref.withParent(_this._parentDrag._dragRef);
3588
+ return;
3589
+ }
3590
+ // Otherwise fall back to resolving the parent by looking up the DOM. This can happen if
3591
+ // the item was projected into another item by something like `ngTemplateOutlet`.
3592
+ var parent = _this.element.nativeElement.parentElement;
3593
+ while (parent) {
3594
+ // `classList` needs to be null checked, because IE doesn't have it on some elements.
3595
+ if ((_a = parent.classList) === null || _a === void 0 ? void 0 : _a.contains(DRAG_HOST_CLASS)) {
3596
+ ref.withParent(((_b = CdkDrag._dragInstances.find(function (drag) {
3597
+ return drag.element.nativeElement === parent;
3598
+ })) === null || _b === void 0 ? void 0 : _b._dragRef) || null);
3599
+ break;
3600
+ }
3601
+ parent = parent.parentElement;
3602
+ }
3603
+ });
3523
3604
  };
3524
3605
  /** Handles the events from the underlying `DragRef`. */
3525
3606
  CdkDrag.prototype._handleEvents = function (ref) {
@@ -3587,12 +3668,13 @@
3587
3668
  };
3588
3669
  return CdkDrag;
3589
3670
  }());
3671
+ CdkDrag._dragInstances = [];
3590
3672
  CdkDrag.decorators = [
3591
3673
  { type: i0.Directive, args: [{
3592
3674
  selector: '[cdkDrag]',
3593
3675
  exportAs: 'cdkDrag',
3594
3676
  host: {
3595
- 'class': 'cdk-drag',
3677
+ 'class': DRAG_HOST_CLASS,
3596
3678
  '[class.cdk-drag-disabled]': 'disabled',
3597
3679
  '[class.cdk-drag-dragging]': '_dragRef.isDragging()',
3598
3680
  },
@@ -3609,7 +3691,8 @@
3609
3691
  { type: bidi.Directionality, decorators: [{ type: i0.Optional }] },
3610
3692
  { type: DragDrop },
3611
3693
  { type: i0.ChangeDetectorRef },
3612
- { type: CdkDragHandle, decorators: [{ type: i0.Optional }, { type: i0.Self }, { type: i0.Inject, args: [CDK_DRAG_HANDLE,] }] }
3694
+ { type: CdkDragHandle, decorators: [{ type: i0.Optional }, { type: i0.Self }, { type: i0.Inject, args: [CDK_DRAG_HANDLE,] }] },
3695
+ { type: CdkDrag, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }, { type: i0.Inject, args: [CDK_DRAG_PARENT,] }] }
3613
3696
  ]; };
3614
3697
  CdkDrag.propDecorators = {
3615
3698
  _handles: [{ type: i0.ContentChildren, args: [CDK_DRAG_HANDLE, { descendants: true },] }],