@angular/cdk 14.0.1 → 14.0.4

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 (194) hide show
  1. package/a11y/index.d.ts +3 -1
  2. package/drag-drop/index.d.ts +12 -58
  3. package/esm2020/a11y/a11y-module.mjs +5 -5
  4. package/esm2020/a11y/aria-describer/aria-describer.mjs +4 -4
  5. package/esm2020/a11y/focus-monitor/focus-monitor.mjs +7 -7
  6. package/esm2020/a11y/focus-trap/configurable-focus-trap-factory.mjs +4 -4
  7. package/esm2020/a11y/focus-trap/focus-trap-manager.mjs +4 -4
  8. package/esm2020/a11y/focus-trap/focus-trap.mjs +7 -7
  9. package/esm2020/a11y/high-contrast-mode/high-contrast-mode-detector.mjs +17 -5
  10. package/esm2020/a11y/input-modality/input-modality-detector.mjs +4 -4
  11. package/esm2020/a11y/interactivity-checker/interactivity-checker.mjs +4 -4
  12. package/esm2020/a11y/live-announcer/live-announcer.mjs +7 -7
  13. package/esm2020/accordion/accordion-item.mjs +4 -4
  14. package/esm2020/accordion/accordion-module.mjs +5 -5
  15. package/esm2020/accordion/accordion.mjs +4 -4
  16. package/esm2020/bidi/bidi-module.mjs +5 -5
  17. package/esm2020/bidi/dir.mjs +4 -4
  18. package/esm2020/bidi/directionality.mjs +4 -4
  19. package/esm2020/clipboard/clipboard-module.mjs +5 -5
  20. package/esm2020/clipboard/clipboard.mjs +4 -4
  21. package/esm2020/clipboard/copy-to-clipboard.mjs +4 -4
  22. package/esm2020/collections/unique-selection-dispatcher.mjs +4 -4
  23. package/esm2020/dialog/dialog-container.mjs +4 -4
  24. package/esm2020/dialog/dialog-module.mjs +5 -5
  25. package/esm2020/dialog/dialog.mjs +4 -4
  26. package/esm2020/drag-drop/directives/drag-handle.mjs +4 -4
  27. package/esm2020/drag-drop/directives/drag-placeholder.mjs +4 -4
  28. package/esm2020/drag-drop/directives/drag-preview.mjs +4 -4
  29. package/esm2020/drag-drop/directives/drag.mjs +4 -4
  30. package/esm2020/drag-drop/directives/drop-list-group.mjs +4 -4
  31. package/esm2020/drag-drop/directives/drop-list.mjs +4 -4
  32. package/esm2020/drag-drop/dom/client-rect.mjs +64 -0
  33. package/esm2020/drag-drop/dom/clone-node.mjs +65 -0
  34. package/esm2020/drag-drop/dom/parent-position-tracker.mjs +76 -0
  35. package/esm2020/drag-drop/dom/styling.mjs +69 -0
  36. package/esm2020/drag-drop/dom/transition-duration.mjs +36 -0
  37. package/esm2020/drag-drop/drag-drop-module.mjs +5 -5
  38. package/esm2020/drag-drop/drag-drop-registry.mjs +4 -4
  39. package/esm2020/drag-drop/drag-drop.mjs +4 -4
  40. package/esm2020/drag-drop/drag-ref.mjs +36 -22
  41. package/esm2020/drag-drop/drop-list-ref.mjs +36 -295
  42. package/esm2020/drag-drop/sorting/drop-list-sort-strategy.mjs +9 -0
  43. package/esm2020/drag-drop/sorting/single-axis-sort-strategy.mjs +341 -0
  44. package/esm2020/layout/breakpoints-observer.mjs +4 -4
  45. package/esm2020/layout/layout-module.mjs +5 -5
  46. package/esm2020/layout/media-matcher.mjs +4 -4
  47. package/esm2020/menu/context-menu-trigger.mjs +7 -7
  48. package/esm2020/menu/menu-aim.mjs +7 -7
  49. package/esm2020/menu/menu-bar.mjs +4 -4
  50. package/esm2020/menu/menu-base.mjs +4 -4
  51. package/esm2020/menu/menu-group.mjs +4 -4
  52. package/esm2020/menu/menu-item-checkbox.mjs +4 -4
  53. package/esm2020/menu/menu-item-radio.mjs +4 -4
  54. package/esm2020/menu/menu-item-selectable.mjs +4 -4
  55. package/esm2020/menu/menu-item.mjs +4 -4
  56. package/esm2020/menu/menu-module.mjs +5 -5
  57. package/esm2020/menu/menu-stack.mjs +4 -4
  58. package/esm2020/menu/menu-trigger-base.mjs +4 -4
  59. package/esm2020/menu/menu-trigger.mjs +4 -4
  60. package/esm2020/menu/menu.mjs +4 -4
  61. package/esm2020/observers/observe-content.mjs +14 -14
  62. package/esm2020/overlay/dispatchers/base-overlay-dispatcher.mjs +4 -4
  63. package/esm2020/overlay/dispatchers/overlay-keyboard-dispatcher.mjs +4 -4
  64. package/esm2020/overlay/dispatchers/overlay-outside-click-dispatcher.mjs +4 -4
  65. package/esm2020/overlay/fullscreen-overlay-container.mjs +4 -4
  66. package/esm2020/overlay/overlay-container.mjs +4 -4
  67. package/esm2020/overlay/overlay-directives.mjs +7 -7
  68. package/esm2020/overlay/overlay-module.mjs +5 -5
  69. package/esm2020/overlay/overlay.mjs +4 -4
  70. package/esm2020/overlay/position/overlay-position-builder.mjs +4 -4
  71. package/esm2020/overlay/scroll/scroll-strategy-options.mjs +4 -4
  72. package/esm2020/platform/platform-module.mjs +5 -5
  73. package/esm2020/platform/platform.mjs +4 -4
  74. package/esm2020/portal/portal-directives.mjs +17 -17
  75. package/esm2020/scrolling/fixed-size-virtual-scroll.mjs +4 -4
  76. package/esm2020/scrolling/scroll-dispatcher.mjs +4 -4
  77. package/esm2020/scrolling/scrollable.mjs +4 -4
  78. package/esm2020/scrolling/scrolling-module.mjs +9 -9
  79. package/esm2020/scrolling/viewport-ruler.mjs +4 -4
  80. package/esm2020/scrolling/virtual-for-of.mjs +4 -4
  81. package/esm2020/scrolling/virtual-scroll-viewport.mjs +6 -6
  82. package/esm2020/stepper/step-header.mjs +4 -4
  83. package/esm2020/stepper/step-label.mjs +4 -4
  84. package/esm2020/stepper/stepper-button.mjs +7 -7
  85. package/esm2020/stepper/stepper-module.mjs +5 -5
  86. package/esm2020/stepper/stepper.mjs +7 -7
  87. package/esm2020/table/cell.mjs +22 -22
  88. package/esm2020/table/coalesced-style-scheduler.mjs +4 -4
  89. package/esm2020/table/row.mjs +28 -28
  90. package/esm2020/table/table-module.mjs +5 -5
  91. package/esm2020/table/table.mjs +19 -19
  92. package/esm2020/table/text-column.mjs +4 -4
  93. package/esm2020/testing/testbed/fake-events/dispatch-events.mjs +5 -5
  94. package/esm2020/testing/testbed/fake-events/event-objects.mjs +17 -6
  95. package/esm2020/testing/testbed/unit-test-element.mjs +17 -12
  96. package/esm2020/text-field/autofill.mjs +7 -7
  97. package/esm2020/text-field/autosize.mjs +4 -4
  98. package/esm2020/text-field/text-field-module.mjs +5 -5
  99. package/esm2020/tree/nested-node.mjs +4 -4
  100. package/esm2020/tree/node.mjs +4 -4
  101. package/esm2020/tree/outlet.mjs +4 -4
  102. package/esm2020/tree/padding.mjs +4 -4
  103. package/esm2020/tree/toggle.mjs +4 -4
  104. package/esm2020/tree/tree-module.mjs +5 -5
  105. package/esm2020/tree/tree.mjs +7 -7
  106. package/esm2020/version.mjs +1 -1
  107. package/fesm2015/a11y.mjs +59 -40
  108. package/fesm2015/a11y.mjs.map +1 -1
  109. package/fesm2015/accordion.mjs +10 -10
  110. package/fesm2015/accordion.mjs.map +1 -1
  111. package/fesm2015/bidi.mjs +10 -10
  112. package/fesm2015/bidi.mjs.map +1 -1
  113. package/fesm2015/cdk.mjs +1 -1
  114. package/fesm2015/cdk.mjs.map +1 -1
  115. package/fesm2015/clipboard.mjs +10 -10
  116. package/fesm2015/clipboard.mjs.map +1 -1
  117. package/fesm2015/collections.mjs +3 -3
  118. package/fesm2015/collections.mjs.map +1 -1
  119. package/fesm2015/dialog.mjs +10 -10
  120. package/fesm2015/dialog.mjs.map +1 -1
  121. package/fesm2015/drag-drop.mjs +552 -459
  122. package/fesm2015/drag-drop.mjs.map +1 -1
  123. package/fesm2015/layout.mjs +10 -10
  124. package/fesm2015/layout.mjs.map +1 -1
  125. package/fesm2015/menu.mjs +49 -49
  126. package/fesm2015/menu.mjs.map +1 -1
  127. package/fesm2015/observers.mjs +13 -13
  128. package/fesm2015/observers.mjs.map +1 -1
  129. package/fesm2015/overlay.mjs +34 -34
  130. package/fesm2015/overlay.mjs.map +1 -1
  131. package/fesm2015/platform.mjs +7 -7
  132. package/fesm2015/platform.mjs.map +1 -1
  133. package/fesm2015/portal.mjs +16 -16
  134. package/fesm2015/portal.mjs.map +1 -1
  135. package/fesm2015/scrolling.mjs +28 -28
  136. package/fesm2015/scrolling.mjs.map +1 -1
  137. package/fesm2015/stepper.mjs +22 -22
  138. package/fesm2015/stepper.mjs.map +1 -1
  139. package/fesm2015/table.mjs +76 -76
  140. package/fesm2015/table.mjs.map +1 -1
  141. package/fesm2015/testing/testbed.mjs +36 -20
  142. package/fesm2015/testing/testbed.mjs.map +1 -1
  143. package/fesm2015/text-field.mjs +13 -13
  144. package/fesm2015/text-field.mjs.map +1 -1
  145. package/fesm2015/tree.mjs +25 -25
  146. package/fesm2015/tree.mjs.map +1 -1
  147. package/fesm2020/a11y.mjs +52 -40
  148. package/fesm2020/a11y.mjs.map +1 -1
  149. package/fesm2020/accordion.mjs +10 -10
  150. package/fesm2020/accordion.mjs.map +1 -1
  151. package/fesm2020/bidi.mjs +10 -10
  152. package/fesm2020/bidi.mjs.map +1 -1
  153. package/fesm2020/cdk.mjs +1 -1
  154. package/fesm2020/cdk.mjs.map +1 -1
  155. package/fesm2020/clipboard.mjs +10 -10
  156. package/fesm2020/clipboard.mjs.map +1 -1
  157. package/fesm2020/collections.mjs +3 -3
  158. package/fesm2020/collections.mjs.map +1 -1
  159. package/fesm2020/dialog.mjs +10 -10
  160. package/fesm2020/dialog.mjs.map +1 -1
  161. package/fesm2020/drag-drop.mjs +552 -459
  162. package/fesm2020/drag-drop.mjs.map +1 -1
  163. package/fesm2020/layout.mjs +10 -10
  164. package/fesm2020/layout.mjs.map +1 -1
  165. package/fesm2020/menu.mjs +49 -49
  166. package/fesm2020/menu.mjs.map +1 -1
  167. package/fesm2020/observers.mjs +13 -13
  168. package/fesm2020/observers.mjs.map +1 -1
  169. package/fesm2020/overlay.mjs +34 -34
  170. package/fesm2020/overlay.mjs.map +1 -1
  171. package/fesm2020/platform.mjs +7 -7
  172. package/fesm2020/platform.mjs.map +1 -1
  173. package/fesm2020/portal.mjs +16 -16
  174. package/fesm2020/portal.mjs.map +1 -1
  175. package/fesm2020/scrolling.mjs +28 -28
  176. package/fesm2020/scrolling.mjs.map +1 -1
  177. package/fesm2020/stepper.mjs +22 -22
  178. package/fesm2020/stepper.mjs.map +1 -1
  179. package/fesm2020/table.mjs +76 -76
  180. package/fesm2020/table.mjs.map +1 -1
  181. package/fesm2020/testing/testbed.mjs +36 -20
  182. package/fesm2020/testing/testbed.mjs.map +1 -1
  183. package/fesm2020/text-field.mjs +13 -13
  184. package/fesm2020/text-field.mjs.map +1 -1
  185. package/fesm2020/tree.mjs +25 -25
  186. package/fesm2020/tree.mjs.map +1 -1
  187. package/package.json +1 -1
  188. package/schematics/ng-add/index.js +1 -1
  189. package/schematics/ng-add/index.mjs +1 -1
  190. package/esm2020/drag-drop/client-rect.mjs +0 -64
  191. package/esm2020/drag-drop/clone-node.mjs +0 -65
  192. package/esm2020/drag-drop/drag-styling.mjs +0 -69
  193. package/esm2020/drag-drop/parent-position-tracker.mjs +0 -76
  194. package/esm2020/drag-drop/transition-duration.mjs +0 -36
@@ -467,11 +467,12 @@ class DragRef {
467
467
  this._updateActiveDropContainer(constrainedPointerPosition, pointerPosition);
468
468
  }
469
469
  else {
470
+ // If there's a position constraint function, we want the element's top/left to be at the
471
+ // specific position on the page. Use the initial position as a reference if that's the case.
472
+ const offset = this.constrainPosition ? this._initialClientRect : this._pickupPositionOnPage;
470
473
  const activeTransform = this._activeTransform;
471
- activeTransform.x =
472
- constrainedPointerPosition.x - this._pickupPositionOnPage.x + this._passiveTransform.x;
473
- activeTransform.y =
474
- constrainedPointerPosition.y - this._pickupPositionOnPage.y + this._passiveTransform.y;
474
+ activeTransform.x = constrainedPointerPosition.x - offset.x + this._passiveTransform.x;
475
+ activeTransform.y = constrainedPointerPosition.y - offset.y + this._passiveTransform.y;
475
476
  this._applyRootElementTransform(activeTransform.x, activeTransform.y);
476
477
  }
477
478
  // Since this event gets fired for every pixel while dragging, we only
@@ -886,6 +887,7 @@ class DragRef {
886
887
  // Avoid multiple subscriptions and memory leaks when multi touch
887
888
  // (isDragging check above isn't enough because of possible temporal and/or dimensional delays)
888
889
  this._removeSubscriptions();
890
+ this._initialClientRect = this._rootElement.getBoundingClientRect();
889
891
  this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
890
892
  this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
891
893
  this._scrollSubscription = this._dragDropRegistry
@@ -901,7 +903,7 @@ class DragRef {
901
903
  this._pickupPositionInElement =
902
904
  previewTemplate && previewTemplate.template && !previewTemplate.matchSize
903
905
  ? { x: 0, y: 0 }
904
- : this._getPointerPositionInElement(referenceElement, event);
906
+ : this._getPointerPositionInElement(this._initialClientRect, referenceElement, event);
905
907
  const pointerPosition = (this._pickupPositionOnPage =
906
908
  this._lastKnownPointerPosition =
907
909
  this._getPointerPositionOnPage(event));
@@ -920,7 +922,11 @@ class DragRef {
920
922
  this._anchor.parentNode.replaceChild(this._rootElement, this._anchor);
921
923
  this._destroyPreview();
922
924
  this._destroyPlaceholder();
923
- this._boundaryRect = this._previewRect = this._initialTransform = undefined;
925
+ this._initialClientRect =
926
+ this._boundaryRect =
927
+ this._previewRect =
928
+ this._initialTransform =
929
+ undefined;
924
930
  // Re-enter the NgZone since we bound `document` events on the outside.
925
931
  this._ngZone.run(() => {
926
932
  const container = this._dropContainer;
@@ -984,7 +990,12 @@ class DragRef {
984
990
  if (this.isDragging()) {
985
991
  this._dropContainer._startScrollingIfNecessary(rawX, rawY);
986
992
  this._dropContainer._sortItem(this, x, y, this._pointerDirectionDelta);
987
- this._applyPreviewTransform(x - this._pickupPositionInElement.x, y - this._pickupPositionInElement.y);
993
+ if (this.constrainPosition) {
994
+ this._applyPreviewTransform(x, y);
995
+ }
996
+ else {
997
+ this._applyPreviewTransform(x - this._pickupPositionInElement.x, y - this._pickupPositionInElement.y);
998
+ }
988
999
  }
989
1000
  }
990
1001
  /**
@@ -999,7 +1010,7 @@ class DragRef {
999
1010
  if (previewTemplate && previewConfig) {
1000
1011
  // Measure the element before we've inserted the preview
1001
1012
  // since the insertion could throw off the measurement.
1002
- const rootRect = previewConfig.matchSize ? this._rootElement.getBoundingClientRect() : null;
1013
+ const rootRect = previewConfig.matchSize ? this._initialClientRect : null;
1003
1014
  const viewRef = previewConfig.viewContainer.createEmbeddedView(previewTemplate, previewConfig.context);
1004
1015
  viewRef.detectChanges();
1005
1016
  preview = getRootNode(viewRef, this._document);
@@ -1012,9 +1023,8 @@ class DragRef {
1012
1023
  }
1013
1024
  }
1014
1025
  else {
1015
- const element = this._rootElement;
1016
- preview = deepCloneNode(element);
1017
- matchElementSize(preview, element.getBoundingClientRect());
1026
+ preview = deepCloneNode(this._rootElement);
1027
+ matchElementSize(preview, this._initialClientRect);
1018
1028
  if (this._initialTransform) {
1019
1029
  preview.style.transform = this._initialTransform;
1020
1030
  }
@@ -1107,8 +1117,7 @@ class DragRef {
1107
1117
  * @param referenceElement Element that initiated the dragging.
1108
1118
  * @param event Event that initiated the dragging.
1109
1119
  */
1110
- _getPointerPositionInElement(referenceElement, event) {
1111
- const elementRect = this._rootElement.getBoundingClientRect();
1120
+ _getPointerPositionInElement(elementRect, referenceElement, event) {
1112
1121
  const handleElement = referenceElement === this._rootElement ? null : referenceElement;
1113
1122
  const referenceRect = handleElement ? handleElement.getBoundingClientRect() : elementRect;
1114
1123
  const point = isTouchEvent(event) ? event.targetTouches[0] : event;
@@ -1151,7 +1160,9 @@ class DragRef {
1151
1160
  /** Gets the pointer position on the page, accounting for any position constraints. */
1152
1161
  _getConstrainedPointerPosition(point) {
1153
1162
  const dropContainerLock = this._dropContainer ? this._dropContainer.lockAxis : null;
1154
- let { x, y } = this.constrainPosition ? this.constrainPosition(point, this) : point;
1163
+ let { x, y } = this.constrainPosition
1164
+ ? this.constrainPosition(point, this, this._initialClientRect)
1165
+ : point;
1155
1166
  if (this.lockAxis === 'x' || dropContainerLock === 'x') {
1156
1167
  y = this._pickupPositionOnPage.y;
1157
1168
  }
@@ -1267,8 +1278,9 @@ class DragRef {
1267
1278
  if ((x === 0 && y === 0) || this.isDragging() || !this._boundaryElement) {
1268
1279
  return;
1269
1280
  }
1270
- const boundaryRect = this._boundaryElement.getBoundingClientRect();
1281
+ // Note: don't use `_clientRectAtStart` here, because we want the latest position.
1271
1282
  const elementRect = this._rootElement.getBoundingClientRect();
1283
+ const boundaryRect = this._boundaryElement.getBoundingClientRect();
1272
1284
  // It's possible that the element got hidden away after dragging (e.g. by switching to a
1273
1285
  // different tab). Don't do anything in this case so we don't clear the user's position.
1274
1286
  if ((boundaryRect.width === 0 && boundaryRect.height === 0) ||
@@ -1385,7 +1397,9 @@ class DragRef {
1385
1397
  // Cache the preview element rect if we haven't cached it already or if
1386
1398
  // we cached it too early before the element dimensions were computed.
1387
1399
  if (!this._previewRect || (!this._previewRect.width && !this._previewRect.height)) {
1388
- this._previewRect = (this._preview || this._rootElement).getBoundingClientRect();
1400
+ this._previewRect = this._preview
1401
+ ? this._preview.getBoundingClientRect()
1402
+ : this._initialClientRect;
1389
1403
  }
1390
1404
  return this._previewRect;
1391
1405
  }
@@ -1509,140 +1523,99 @@ function clamp(value, max) {
1509
1523
  * found in the LICENSE file at https://angular.io/license
1510
1524
  */
1511
1525
  /**
1512
- * Proximity, as a ratio to width/height, at which a
1513
- * dragged item will affect the drop container.
1514
- */
1515
- const DROP_PROXIMITY_THRESHOLD = 0.05;
1516
- /**
1517
- * Proximity, as a ratio to width/height at which to start auto-scrolling the drop list or the
1518
- * viewport. The value comes from trying it out manually until it feels right.
1519
- */
1520
- const SCROLL_PROXIMITY_THRESHOLD = 0.05;
1521
- /**
1522
- * Reference to a drop list. Used to manipulate or dispose of the container.
1526
+ * Strategy that only supports sorting along a single axis.
1527
+ * Items are reordered using CSS transforms which allows for sorting to be animated.
1528
+ * @docs-private
1523
1529
  */
1524
- class DropListRef {
1525
- constructor(element, _dragDropRegistry, _document, _ngZone, _viewportRuler) {
1530
+ class SingleAxisSortStrategy {
1531
+ constructor(_element, _dragDropRegistry) {
1532
+ this._element = _element;
1526
1533
  this._dragDropRegistry = _dragDropRegistry;
1527
- this._ngZone = _ngZone;
1528
- this._viewportRuler = _viewportRuler;
1529
- /** Whether starting a dragging sequence from this container is disabled. */
1530
- this.disabled = false;
1531
- /** Whether sorting items within the list is disabled. */
1532
- this.sortingDisabled = false;
1533
- /**
1534
- * Whether auto-scrolling the view when the user
1535
- * moves their pointer close to the edges is disabled.
1536
- */
1537
- this.autoScrollDisabled = false;
1538
- /** Number of pixels to scroll for each frame when auto-scrolling an element. */
1539
- this.autoScrollStep = 2;
1540
- /**
1541
- * Function that is used to determine whether an item
1542
- * is allowed to be moved into a drop container.
1543
- */
1544
- this.enterPredicate = () => true;
1545
- /** Functions that is used to determine whether an item can be sorted into a particular index. */
1546
- this.sortPredicate = () => true;
1547
- /** Emits right before dragging has started. */
1548
- this.beforeStarted = new Subject();
1549
- /**
1550
- * Emits when the user has moved a new drag item into this container.
1551
- */
1552
- this.entered = new Subject();
1553
- /**
1554
- * Emits when the user removes an item from the container
1555
- * by dragging it into another container.
1556
- */
1557
- this.exited = new Subject();
1558
- /** Emits when the user drops an item inside the container. */
1559
- this.dropped = new Subject();
1560
- /** Emits as the user is swapping items while actively dragging. */
1561
- this.sorted = new Subject();
1562
- /** Whether an item in the list is being dragged. */
1563
- this._isDragging = false;
1564
1534
  /** Cache of the dimensions of all the items inside the container. */
1565
1535
  this._itemPositions = [];
1536
+ /** Direction in which the list is oriented. */
1537
+ this.orientation = 'vertical';
1566
1538
  /**
1567
1539
  * Keeps track of the item that was last swapped with the dragged item, as well as what direction
1568
1540
  * the pointer was moving in when the swap occured and whether the user's pointer continued to
1569
1541
  * overlap with the swapped item after the swapping occurred.
1570
1542
  */
1571
- this._previousSwap = { drag: null, delta: 0, overlaps: false };
1572
- /** Draggable items in the container. */
1573
- this._draggables = [];
1574
- /** Drop lists that are connected to the current one. */
1575
- this._siblings = [];
1576
- /** Direction in which the list is oriented. */
1577
- this._orientation = 'vertical';
1578
- /** Connected siblings that currently have a dragged item. */
1579
- this._activeSiblings = new Set();
1580
- /** Layout direction of the drop list. */
1581
- this._direction = 'ltr';
1582
- /** Subscription to the window being scrolled. */
1583
- this._viewportScrollSubscription = Subscription.EMPTY;
1584
- /** Vertical direction in which the list is currently scrolling. */
1585
- this._verticalScrollDirection = 0 /* AutoScrollVerticalDirection.NONE */;
1586
- /** Horizontal direction in which the list is currently scrolling. */
1587
- this._horizontalScrollDirection = 0 /* AutoScrollHorizontalDirection.NONE */;
1588
- /** Used to signal to the current auto-scroll sequence when to stop. */
1589
- this._stopScrollTimers = new Subject();
1590
- /** Shadow root of the current element. Necessary for `elementFromPoint` to resolve correctly. */
1591
- this._cachedShadowRoot = null;
1592
- /** Starts the interval that'll auto-scroll the element. */
1593
- this._startScrollInterval = () => {
1594
- this._stopScrolling();
1595
- interval(0, animationFrameScheduler)
1596
- .pipe(takeUntil(this._stopScrollTimers))
1597
- .subscribe(() => {
1598
- const node = this._scrollNode;
1599
- const scrollStep = this.autoScrollStep;
1600
- if (this._verticalScrollDirection === 1 /* AutoScrollVerticalDirection.UP */) {
1601
- node.scrollBy(0, -scrollStep);
1602
- }
1603
- else if (this._verticalScrollDirection === 2 /* AutoScrollVerticalDirection.DOWN */) {
1604
- node.scrollBy(0, scrollStep);
1605
- }
1606
- if (this._horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */) {
1607
- node.scrollBy(-scrollStep, 0);
1608
- }
1609
- else if (this._horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */) {
1610
- node.scrollBy(scrollStep, 0);
1611
- }
1612
- });
1543
+ this._previousSwap = {
1544
+ drag: null,
1545
+ delta: 0,
1546
+ overlaps: false,
1613
1547
  };
1614
- this.element = coerceElement(element);
1615
- this._document = _document;
1616
- this.withScrollableParents([this.element]);
1617
- _dragDropRegistry.registerDropContainer(this);
1618
- this._parentPositions = new ParentPositionTracker(_document);
1619
- }
1620
- /** Removes the drop list functionality from the DOM element. */
1621
- dispose() {
1622
- this._stopScrolling();
1623
- this._stopScrollTimers.complete();
1624
- this._viewportScrollSubscription.unsubscribe();
1625
- this.beforeStarted.complete();
1626
- this.entered.complete();
1627
- this.exited.complete();
1628
- this.dropped.complete();
1629
- this.sorted.complete();
1630
- this._activeSiblings.clear();
1631
- this._scrollNode = null;
1632
- this._parentPositions.clear();
1633
- this._dragDropRegistry.removeDropContainer(this);
1634
1548
  }
1635
- /** Whether an item from this list is currently being dragged. */
1636
- isDragging() {
1637
- return this._isDragging;
1549
+ /**
1550
+ * To be called when the drag sequence starts.
1551
+ * @param items Items that are currently in the list.
1552
+ */
1553
+ start(items) {
1554
+ this.withItems(items);
1638
1555
  }
1639
- /** Starts dragging an item. */
1640
- start() {
1641
- this._draggingStarted();
1642
- this._notifyReceivingSiblings();
1556
+ /**
1557
+ * To be called when an item is being sorted.
1558
+ * @param item Item to be sorted.
1559
+ * @param pointerX Position of the item along the X axis.
1560
+ * @param pointerY Position of the item along the Y axis.
1561
+ * @param pointerDelta Direction in which the pointer is moving along each axis.
1562
+ */
1563
+ sort(item, pointerX, pointerY, pointerDelta) {
1564
+ const siblings = this._itemPositions;
1565
+ const newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY, pointerDelta);
1566
+ if (newIndex === -1 && siblings.length > 0) {
1567
+ return null;
1568
+ }
1569
+ const isHorizontal = this.orientation === 'horizontal';
1570
+ const currentIndex = siblings.findIndex(currentItem => currentItem.drag === item);
1571
+ const siblingAtNewPosition = siblings[newIndex];
1572
+ const currentPosition = siblings[currentIndex].clientRect;
1573
+ const newPosition = siblingAtNewPosition.clientRect;
1574
+ const delta = currentIndex > newIndex ? 1 : -1;
1575
+ // How many pixels the item's placeholder should be offset.
1576
+ const itemOffset = this._getItemOffsetPx(currentPosition, newPosition, delta);
1577
+ // How many pixels all the other items should be offset.
1578
+ const siblingOffset = this._getSiblingOffsetPx(currentIndex, siblings, delta);
1579
+ // Save the previous order of the items before moving the item to its new index.
1580
+ // We use this to check whether an item has been moved as a result of the sorting.
1581
+ const oldOrder = siblings.slice();
1582
+ // Shuffle the array in place.
1583
+ moveItemInArray(siblings, currentIndex, newIndex);
1584
+ siblings.forEach((sibling, index) => {
1585
+ // Don't do anything if the position hasn't changed.
1586
+ if (oldOrder[index] === sibling) {
1587
+ return;
1588
+ }
1589
+ const isDraggedItem = sibling.drag === item;
1590
+ const offset = isDraggedItem ? itemOffset : siblingOffset;
1591
+ const elementToOffset = isDraggedItem
1592
+ ? item.getPlaceholderElement()
1593
+ : sibling.drag.getRootElement();
1594
+ // Update the offset to reflect the new position.
1595
+ sibling.offset += offset;
1596
+ // Since we're moving the items with a `transform`, we need to adjust their cached
1597
+ // client rects to reflect their new position, as well as swap their positions in the cache.
1598
+ // Note that we shouldn't use `getBoundingClientRect` here to update the cache, because the
1599
+ // elements may be mid-animation which will give us a wrong result.
1600
+ if (isHorizontal) {
1601
+ // Round the transforms since some browsers will
1602
+ // blur the elements, for sub-pixel transforms.
1603
+ elementToOffset.style.transform = combineTransforms(`translate3d(${Math.round(sibling.offset)}px, 0, 0)`, sibling.initialTransform);
1604
+ adjustClientRect(sibling.clientRect, 0, offset);
1605
+ }
1606
+ else {
1607
+ elementToOffset.style.transform = combineTransforms(`translate3d(0, ${Math.round(sibling.offset)}px, 0)`, sibling.initialTransform);
1608
+ adjustClientRect(sibling.clientRect, offset, 0);
1609
+ }
1610
+ });
1611
+ // Note that it's important that we do this after the client rects have been adjusted.
1612
+ this._previousSwap.overlaps = isInsideClientRect(newPosition, pointerX, pointerY);
1613
+ this._previousSwap.drag = siblingAtNewPosition.drag;
1614
+ this._previousSwap.delta = isHorizontal ? pointerDelta.x : pointerDelta.y;
1615
+ return { previousIndex: currentIndex, currentIndex: newIndex };
1643
1616
  }
1644
1617
  /**
1645
- * Emits an event to indicate that the user moved an item into the container.
1618
+ * Called when an item is being moved into the container.
1646
1619
  * @param item Item that was moved into the container.
1647
1620
  * @param pointerX Position of the item along the X axis.
1648
1621
  * @param pointerY Position of the item along the Y axis.
@@ -1650,21 +1623,11 @@ class DropListRef {
1650
1623
  * out automatically.
1651
1624
  */
1652
1625
  enter(item, pointerX, pointerY, index) {
1653
- this._draggingStarted();
1654
- // If sorting is disabled, we want the item to return to its starting
1655
- // position if the user is returning it to its initial container.
1656
- let newIndex;
1657
- if (index == null) {
1658
- newIndex = this.sortingDisabled ? this._draggables.indexOf(item) : -1;
1659
- if (newIndex === -1) {
1660
- // We use the coordinates of where the item entered the drop
1626
+ const newIndex = index == null || index < 0
1627
+ ? // We use the coordinates of where the item entered the drop
1661
1628
  // zone to figure out at which index it should be inserted.
1662
- newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY);
1663
- }
1664
- }
1665
- else {
1666
- newIndex = index;
1667
- }
1629
+ this._getItemIndexFromPointerPosition(item, pointerX, pointerY)
1630
+ : index;
1668
1631
  const activeDraggables = this._activeDraggables;
1669
1632
  const currentIndex = activeDraggables.indexOf(item);
1670
1633
  const placeholder = item.getPlaceholderElement();
@@ -1695,78 +1658,412 @@ class DropListRef {
1695
1658
  activeDraggables.splice(newIndex, 0, item);
1696
1659
  }
1697
1660
  else {
1698
- coerceElement(this.element).appendChild(placeholder);
1661
+ coerceElement(this._element).appendChild(placeholder);
1699
1662
  activeDraggables.push(item);
1700
1663
  }
1701
1664
  // The transform needs to be cleared so it doesn't throw off the measurements.
1702
1665
  placeholder.style.transform = '';
1703
- // Note that the positions were already cached when we called `start` above,
1704
- // but we need to refresh them since the amount of items has changed and also parent rects.
1666
+ // Note that usually `start` is called together with `enter` when an item goes into a new
1667
+ // container. This will cache item positions, but we need to refresh them since the amount
1668
+ // of items has changed.
1705
1669
  this._cacheItemPositions();
1706
- this._cacheParentPositions();
1707
- // Notify siblings at the end so that the item has been inserted into the `activeDraggables`.
1708
- this._notifyReceivingSiblings();
1709
- this.entered.next({ item, container: this, currentIndex: this.getItemIndex(item) });
1710
1670
  }
1711
- /**
1712
- * Removes an item from the container after it was dragged into another container by the user.
1713
- * @param item Item that was dragged out.
1714
- */
1715
- exit(item) {
1716
- this._reset();
1717
- this.exited.next({ item, container: this });
1671
+ /** Sets the items that are currently part of the list. */
1672
+ withItems(items) {
1673
+ this._activeDraggables = items.slice();
1674
+ this._cacheItemPositions();
1718
1675
  }
1719
- /**
1720
- * Drops an item into this container.
1721
- * @param item Item being dropped into the container.
1722
- * @param currentIndex Index at which the item should be inserted.
1723
- * @param previousIndex Index of the item when dragging started.
1724
- * @param previousContainer Container from which the item got dragged in.
1725
- * @param isPointerOverContainer Whether the user's pointer was over the
1726
- * container when the item was dropped.
1727
- * @param distance Distance the user has dragged since the start of the dragging sequence.
1728
- * @param event Event that triggered the dropping sequence.
1729
- *
1730
- * @breaking-change 15.0.0 `previousIndex` and `event` parameters to become required.
1731
- */
1732
- drop(item, currentIndex, previousIndex, previousContainer, isPointerOverContainer, distance, dropPoint, event = {}) {
1733
- this._reset();
1734
- this.dropped.next({
1735
- item,
1736
- currentIndex,
1737
- previousIndex,
1738
- container: this,
1739
- previousContainer,
1740
- isPointerOverContainer,
1741
- distance,
1742
- dropPoint,
1743
- event,
1676
+ /** Assigns a sort predicate to the strategy. */
1677
+ withSortPredicate(predicate) {
1678
+ this._sortPredicate = predicate;
1679
+ }
1680
+ /** Resets the strategy to its initial state before dragging was started. */
1681
+ reset() {
1682
+ // TODO(crisbeto): may have to wait for the animations to finish.
1683
+ this._activeDraggables.forEach(item => {
1684
+ const rootElement = item.getRootElement();
1685
+ if (rootElement) {
1686
+ const initialTransform = this._itemPositions.find(p => p.drag === item)?.initialTransform;
1687
+ rootElement.style.transform = initialTransform || '';
1688
+ }
1744
1689
  });
1690
+ this._itemPositions = [];
1691
+ this._activeDraggables = [];
1692
+ this._previousSwap.drag = null;
1693
+ this._previousSwap.delta = 0;
1694
+ this._previousSwap.overlaps = false;
1745
1695
  }
1746
1696
  /**
1747
- * Sets the draggable items that are a part of this list.
1748
- * @param items Items that are a part of this list.
1697
+ * Gets a snapshot of items currently in the list.
1698
+ * Can include items that we dragged in from another list.
1749
1699
  */
1750
- withItems(items) {
1751
- const previousItems = this._draggables;
1752
- this._draggables = items;
1753
- items.forEach(item => item._withDropContainer(this));
1754
- if (this.isDragging()) {
1755
- const draggedItems = previousItems.filter(item => item.isDragging());
1756
- // If all of the items being dragged were removed
1757
- // from the list, abort the current drag sequence.
1758
- if (draggedItems.every(item => items.indexOf(item) === -1)) {
1759
- this._reset();
1760
- }
1761
- else {
1762
- this._cacheItems();
1763
- }
1700
+ getActiveItemsSnapshot() {
1701
+ return this._activeDraggables;
1702
+ }
1703
+ /** Gets the index of a specific item. */
1704
+ getItemIndex(item) {
1705
+ // Items are sorted always by top/left in the cache, however they flow differently in RTL.
1706
+ // The rest of the logic still stands no matter what orientation we're in, however
1707
+ // we need to invert the array when determining the index.
1708
+ const items = this.orientation === 'horizontal' && this.direction === 'rtl'
1709
+ ? this._itemPositions.slice().reverse()
1710
+ : this._itemPositions;
1711
+ return items.findIndex(currentItem => currentItem.drag === item);
1712
+ }
1713
+ /** Used to notify the strategy that the scroll position has changed. */
1714
+ updateOnScroll(topDifference, leftDifference) {
1715
+ // Since we know the amount that the user has scrolled we can shift all of the
1716
+ // client rectangles ourselves. This is cheaper than re-measuring everything and
1717
+ // we can avoid inconsistent behavior where we might be measuring the element before
1718
+ // its position has changed.
1719
+ this._itemPositions.forEach(({ clientRect }) => {
1720
+ adjustClientRect(clientRect, topDifference, leftDifference);
1721
+ });
1722
+ // We need two loops for this, because we want all of the cached
1723
+ // positions to be up-to-date before we re-sort the item.
1724
+ this._itemPositions.forEach(({ drag }) => {
1725
+ if (this._dragDropRegistry.isDragging(drag)) {
1726
+ // We need to re-sort the item manually, because the pointer move
1727
+ // events won't be dispatched while the user is scrolling.
1728
+ drag._sortFromLastPointerPosition();
1729
+ }
1730
+ });
1731
+ }
1732
+ /** Refreshes the position cache of the items and sibling containers. */
1733
+ _cacheItemPositions() {
1734
+ const isHorizontal = this.orientation === 'horizontal';
1735
+ this._itemPositions = this._activeDraggables
1736
+ .map(drag => {
1737
+ const elementToMeasure = drag.getVisibleElement();
1738
+ return {
1739
+ drag,
1740
+ offset: 0,
1741
+ initialTransform: elementToMeasure.style.transform || '',
1742
+ clientRect: getMutableClientRect(elementToMeasure),
1743
+ };
1744
+ })
1745
+ .sort((a, b) => {
1746
+ return isHorizontal
1747
+ ? a.clientRect.left - b.clientRect.left
1748
+ : a.clientRect.top - b.clientRect.top;
1749
+ });
1750
+ }
1751
+ /**
1752
+ * Gets the offset in pixels by which the item that is being dragged should be moved.
1753
+ * @param currentPosition Current position of the item.
1754
+ * @param newPosition Position of the item where the current item should be moved.
1755
+ * @param delta Direction in which the user is moving.
1756
+ */
1757
+ _getItemOffsetPx(currentPosition, newPosition, delta) {
1758
+ const isHorizontal = this.orientation === 'horizontal';
1759
+ let itemOffset = isHorizontal
1760
+ ? newPosition.left - currentPosition.left
1761
+ : newPosition.top - currentPosition.top;
1762
+ // Account for differences in the item width/height.
1763
+ if (delta === -1) {
1764
+ itemOffset += isHorizontal
1765
+ ? newPosition.width - currentPosition.width
1766
+ : newPosition.height - currentPosition.height;
1767
+ }
1768
+ return itemOffset;
1769
+ }
1770
+ /**
1771
+ * Gets the offset in pixels by which the items that aren't being dragged should be moved.
1772
+ * @param currentIndex Index of the item currently being dragged.
1773
+ * @param siblings All of the items in the list.
1774
+ * @param delta Direction in which the user is moving.
1775
+ */
1776
+ _getSiblingOffsetPx(currentIndex, siblings, delta) {
1777
+ const isHorizontal = this.orientation === 'horizontal';
1778
+ const currentPosition = siblings[currentIndex].clientRect;
1779
+ const immediateSibling = siblings[currentIndex + delta * -1];
1780
+ let siblingOffset = currentPosition[isHorizontal ? 'width' : 'height'] * delta;
1781
+ if (immediateSibling) {
1782
+ const start = isHorizontal ? 'left' : 'top';
1783
+ const end = isHorizontal ? 'right' : 'bottom';
1784
+ // Get the spacing between the start of the current item and the end of the one immediately
1785
+ // after it in the direction in which the user is dragging, or vice versa. We add it to the
1786
+ // offset in order to push the element to where it will be when it's inline and is influenced
1787
+ // by the `margin` of its siblings.
1788
+ if (delta === -1) {
1789
+ siblingOffset -= immediateSibling.clientRect[start] - currentPosition[end];
1790
+ }
1791
+ else {
1792
+ siblingOffset += currentPosition[start] - immediateSibling.clientRect[end];
1793
+ }
1794
+ }
1795
+ return siblingOffset;
1796
+ }
1797
+ /**
1798
+ * Checks if pointer is entering in the first position
1799
+ * @param pointerX Position of the user's pointer along the X axis.
1800
+ * @param pointerY Position of the user's pointer along the Y axis.
1801
+ */
1802
+ _shouldEnterAsFirstChild(pointerX, pointerY) {
1803
+ if (!this._activeDraggables.length) {
1804
+ return false;
1805
+ }
1806
+ const itemPositions = this._itemPositions;
1807
+ const isHorizontal = this.orientation === 'horizontal';
1808
+ // `itemPositions` are sorted by position while `activeDraggables` are sorted by child index
1809
+ // check if container is using some sort of "reverse" ordering (eg: flex-direction: row-reverse)
1810
+ const reversed = itemPositions[0].drag !== this._activeDraggables[0];
1811
+ if (reversed) {
1812
+ const lastItemRect = itemPositions[itemPositions.length - 1].clientRect;
1813
+ return isHorizontal ? pointerX >= lastItemRect.right : pointerY >= lastItemRect.bottom;
1814
+ }
1815
+ else {
1816
+ const firstItemRect = itemPositions[0].clientRect;
1817
+ return isHorizontal ? pointerX <= firstItemRect.left : pointerY <= firstItemRect.top;
1818
+ }
1819
+ }
1820
+ /**
1821
+ * Gets the index of an item in the drop container, based on the position of the user's pointer.
1822
+ * @param item Item that is being sorted.
1823
+ * @param pointerX Position of the user's pointer along the X axis.
1824
+ * @param pointerY Position of the user's pointer along the Y axis.
1825
+ * @param delta Direction in which the user is moving their pointer.
1826
+ */
1827
+ _getItemIndexFromPointerPosition(item, pointerX, pointerY, delta) {
1828
+ const isHorizontal = this.orientation === 'horizontal';
1829
+ const index = this._itemPositions.findIndex(({ drag, clientRect }) => {
1830
+ // Skip the item itself.
1831
+ if (drag === item) {
1832
+ return false;
1833
+ }
1834
+ if (delta) {
1835
+ const direction = isHorizontal ? delta.x : delta.y;
1836
+ // If the user is still hovering over the same item as last time, their cursor hasn't left
1837
+ // the item after we made the swap, and they didn't change the direction in which they're
1838
+ // dragging, we don't consider it a direction swap.
1839
+ if (drag === this._previousSwap.drag &&
1840
+ this._previousSwap.overlaps &&
1841
+ direction === this._previousSwap.delta) {
1842
+ return false;
1843
+ }
1844
+ }
1845
+ return isHorizontal
1846
+ ? // Round these down since most browsers report client rects with
1847
+ // sub-pixel precision, whereas the pointer coordinates are rounded to pixels.
1848
+ pointerX >= Math.floor(clientRect.left) && pointerX < Math.floor(clientRect.right)
1849
+ : pointerY >= Math.floor(clientRect.top) && pointerY < Math.floor(clientRect.bottom);
1850
+ });
1851
+ return index === -1 || !this._sortPredicate(index, item) ? -1 : index;
1852
+ }
1853
+ }
1854
+
1855
+ /**
1856
+ * @license
1857
+ * Copyright Google LLC All Rights Reserved.
1858
+ *
1859
+ * Use of this source code is governed by an MIT-style license that can be
1860
+ * found in the LICENSE file at https://angular.io/license
1861
+ */
1862
+ /**
1863
+ * Proximity, as a ratio to width/height, at which a
1864
+ * dragged item will affect the drop container.
1865
+ */
1866
+ const DROP_PROXIMITY_THRESHOLD = 0.05;
1867
+ /**
1868
+ * Proximity, as a ratio to width/height at which to start auto-scrolling the drop list or the
1869
+ * viewport. The value comes from trying it out manually until it feels right.
1870
+ */
1871
+ const SCROLL_PROXIMITY_THRESHOLD = 0.05;
1872
+ /**
1873
+ * Reference to a drop list. Used to manipulate or dispose of the container.
1874
+ */
1875
+ class DropListRef {
1876
+ constructor(element, _dragDropRegistry, _document, _ngZone, _viewportRuler) {
1877
+ this._dragDropRegistry = _dragDropRegistry;
1878
+ this._ngZone = _ngZone;
1879
+ this._viewportRuler = _viewportRuler;
1880
+ /** Whether starting a dragging sequence from this container is disabled. */
1881
+ this.disabled = false;
1882
+ /** Whether sorting items within the list is disabled. */
1883
+ this.sortingDisabled = false;
1884
+ /**
1885
+ * Whether auto-scrolling the view when the user
1886
+ * moves their pointer close to the edges is disabled.
1887
+ */
1888
+ this.autoScrollDisabled = false;
1889
+ /** Number of pixels to scroll for each frame when auto-scrolling an element. */
1890
+ this.autoScrollStep = 2;
1891
+ /**
1892
+ * Function that is used to determine whether an item
1893
+ * is allowed to be moved into a drop container.
1894
+ */
1895
+ this.enterPredicate = () => true;
1896
+ /** Function that is used to determine whether an item can be sorted into a particular index. */
1897
+ this.sortPredicate = () => true;
1898
+ /** Emits right before dragging has started. */
1899
+ this.beforeStarted = new Subject();
1900
+ /**
1901
+ * Emits when the user has moved a new drag item into this container.
1902
+ */
1903
+ this.entered = new Subject();
1904
+ /**
1905
+ * Emits when the user removes an item from the container
1906
+ * by dragging it into another container.
1907
+ */
1908
+ this.exited = new Subject();
1909
+ /** Emits when the user drops an item inside the container. */
1910
+ this.dropped = new Subject();
1911
+ /** Emits as the user is swapping items while actively dragging. */
1912
+ this.sorted = new Subject();
1913
+ /** Whether an item in the list is being dragged. */
1914
+ this._isDragging = false;
1915
+ /** Draggable items in the container. */
1916
+ this._draggables = [];
1917
+ /** Drop lists that are connected to the current one. */
1918
+ this._siblings = [];
1919
+ /** Connected siblings that currently have a dragged item. */
1920
+ this._activeSiblings = new Set();
1921
+ /** Subscription to the window being scrolled. */
1922
+ this._viewportScrollSubscription = Subscription.EMPTY;
1923
+ /** Vertical direction in which the list is currently scrolling. */
1924
+ this._verticalScrollDirection = 0 /* AutoScrollVerticalDirection.NONE */;
1925
+ /** Horizontal direction in which the list is currently scrolling. */
1926
+ this._horizontalScrollDirection = 0 /* AutoScrollHorizontalDirection.NONE */;
1927
+ /** Used to signal to the current auto-scroll sequence when to stop. */
1928
+ this._stopScrollTimers = new Subject();
1929
+ /** Shadow root of the current element. Necessary for `elementFromPoint` to resolve correctly. */
1930
+ this._cachedShadowRoot = null;
1931
+ /** Starts the interval that'll auto-scroll the element. */
1932
+ this._startScrollInterval = () => {
1933
+ this._stopScrolling();
1934
+ interval(0, animationFrameScheduler)
1935
+ .pipe(takeUntil(this._stopScrollTimers))
1936
+ .subscribe(() => {
1937
+ const node = this._scrollNode;
1938
+ const scrollStep = this.autoScrollStep;
1939
+ if (this._verticalScrollDirection === 1 /* AutoScrollVerticalDirection.UP */) {
1940
+ node.scrollBy(0, -scrollStep);
1941
+ }
1942
+ else if (this._verticalScrollDirection === 2 /* AutoScrollVerticalDirection.DOWN */) {
1943
+ node.scrollBy(0, scrollStep);
1944
+ }
1945
+ if (this._horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */) {
1946
+ node.scrollBy(-scrollStep, 0);
1947
+ }
1948
+ else if (this._horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */) {
1949
+ node.scrollBy(scrollStep, 0);
1950
+ }
1951
+ });
1952
+ };
1953
+ this.element = coerceElement(element);
1954
+ this._document = _document;
1955
+ this.withScrollableParents([this.element]);
1956
+ _dragDropRegistry.registerDropContainer(this);
1957
+ this._parentPositions = new ParentPositionTracker(_document);
1958
+ this._sortStrategy = new SingleAxisSortStrategy(this.element, _dragDropRegistry);
1959
+ this._sortStrategy.withSortPredicate((index, item) => this.sortPredicate(index, item, this));
1960
+ }
1961
+ /** Removes the drop list functionality from the DOM element. */
1962
+ dispose() {
1963
+ this._stopScrolling();
1964
+ this._stopScrollTimers.complete();
1965
+ this._viewportScrollSubscription.unsubscribe();
1966
+ this.beforeStarted.complete();
1967
+ this.entered.complete();
1968
+ this.exited.complete();
1969
+ this.dropped.complete();
1970
+ this.sorted.complete();
1971
+ this._activeSiblings.clear();
1972
+ this._scrollNode = null;
1973
+ this._parentPositions.clear();
1974
+ this._dragDropRegistry.removeDropContainer(this);
1975
+ }
1976
+ /** Whether an item from this list is currently being dragged. */
1977
+ isDragging() {
1978
+ return this._isDragging;
1979
+ }
1980
+ /** Starts dragging an item. */
1981
+ start() {
1982
+ this._draggingStarted();
1983
+ this._notifyReceivingSiblings();
1984
+ }
1985
+ /**
1986
+ * Attempts to move an item into the container.
1987
+ * @param item Item that was moved into the container.
1988
+ * @param pointerX Position of the item along the X axis.
1989
+ * @param pointerY Position of the item along the Y axis.
1990
+ * @param index Index at which the item entered. If omitted, the container will try to figure it
1991
+ * out automatically.
1992
+ */
1993
+ enter(item, pointerX, pointerY, index) {
1994
+ this._draggingStarted();
1995
+ // If sorting is disabled, we want the item to return to its starting
1996
+ // position if the user is returning it to its initial container.
1997
+ if (index == null && this.sortingDisabled) {
1998
+ index = this._draggables.indexOf(item);
1999
+ }
2000
+ this._sortStrategy.enter(item, pointerX, pointerY, index);
2001
+ // Note that this usually happens inside `_draggingStarted` as well, but the dimensions
2002
+ // can change when the sort strategy moves the item around inside `enter`.
2003
+ this._cacheParentPositions();
2004
+ // Notify siblings at the end so that the item has been inserted into the `activeDraggables`.
2005
+ this._notifyReceivingSiblings();
2006
+ this.entered.next({ item, container: this, currentIndex: this.getItemIndex(item) });
2007
+ }
2008
+ /**
2009
+ * Removes an item from the container after it was dragged into another container by the user.
2010
+ * @param item Item that was dragged out.
2011
+ */
2012
+ exit(item) {
2013
+ this._reset();
2014
+ this.exited.next({ item, container: this });
2015
+ }
2016
+ /**
2017
+ * Drops an item into this container.
2018
+ * @param item Item being dropped into the container.
2019
+ * @param currentIndex Index at which the item should be inserted.
2020
+ * @param previousIndex Index of the item when dragging started.
2021
+ * @param previousContainer Container from which the item got dragged in.
2022
+ * @param isPointerOverContainer Whether the user's pointer was over the
2023
+ * container when the item was dropped.
2024
+ * @param distance Distance the user has dragged since the start of the dragging sequence.
2025
+ * @param event Event that triggered the dropping sequence.
2026
+ *
2027
+ * @breaking-change 15.0.0 `previousIndex` and `event` parameters to become required.
2028
+ */
2029
+ drop(item, currentIndex, previousIndex, previousContainer, isPointerOverContainer, distance, dropPoint, event = {}) {
2030
+ this._reset();
2031
+ this.dropped.next({
2032
+ item,
2033
+ currentIndex,
2034
+ previousIndex,
2035
+ container: this,
2036
+ previousContainer,
2037
+ isPointerOverContainer,
2038
+ distance,
2039
+ dropPoint,
2040
+ event,
2041
+ });
2042
+ }
2043
+ /**
2044
+ * Sets the draggable items that are a part of this list.
2045
+ * @param items Items that are a part of this list.
2046
+ */
2047
+ withItems(items) {
2048
+ const previousItems = this._draggables;
2049
+ this._draggables = items;
2050
+ items.forEach(item => item._withDropContainer(this));
2051
+ if (this.isDragging()) {
2052
+ const draggedItems = previousItems.filter(item => item.isDragging());
2053
+ // If all of the items being dragged were removed
2054
+ // from the list, abort the current drag sequence.
2055
+ if (draggedItems.every(item => items.indexOf(item) === -1)) {
2056
+ this._reset();
2057
+ }
2058
+ else {
2059
+ this._sortStrategy.withItems(this._draggables);
2060
+ }
1764
2061
  }
1765
2062
  return this;
1766
2063
  }
1767
2064
  /** Sets the layout direction of the drop list. */
1768
2065
  withDirection(direction) {
1769
- this._direction = direction;
2066
+ this._sortStrategy.direction = direction;
1770
2067
  return this;
1771
2068
  }
1772
2069
  /**
@@ -1783,7 +2080,9 @@ class DropListRef {
1783
2080
  * @param orientation New orientation for the container.
1784
2081
  */
1785
2082
  withOrientation(orientation) {
1786
- this._orientation = orientation;
2083
+ // TODO(crisbeto): eventually we should be constructing the new sort strategy here based on
2084
+ // the new orientation. For now we can assume that it'll always be `SingleAxisSortStrategy`.
2085
+ this._sortStrategy.orientation = orientation;
1787
2086
  return this;
1788
2087
  }
1789
2088
  /**
@@ -1807,16 +2106,9 @@ class DropListRef {
1807
2106
  * @param item Item whose index should be determined.
1808
2107
  */
1809
2108
  getItemIndex(item) {
1810
- if (!this._isDragging) {
1811
- return this._draggables.indexOf(item);
1812
- }
1813
- // Items are sorted always by top/left in the cache, however they flow differently in RTL.
1814
- // The rest of the logic still stands no matter what orientation we're in, however
1815
- // we need to invert the array when determining the index.
1816
- const items = this._orientation === 'horizontal' && this._direction === 'rtl'
1817
- ? this._itemPositions.slice().reverse()
1818
- : this._itemPositions;
1819
- return items.findIndex(currentItem => currentItem.drag === item);
2109
+ return this._isDragging
2110
+ ? this._sortStrategy.getItemIndex(item)
2111
+ : this._draggables.indexOf(item);
1820
2112
  }
1821
2113
  /**
1822
2114
  * Whether the list is able to receive the item that
@@ -1839,63 +2131,15 @@ class DropListRef {
1839
2131
  !isPointerNearClientRect(this._clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
1840
2132
  return;
1841
2133
  }
1842
- const siblings = this._itemPositions;
1843
- const newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY, pointerDelta);
1844
- if (newIndex === -1 && siblings.length > 0) {
1845
- return;
2134
+ const result = this._sortStrategy.sort(item, pointerX, pointerY, pointerDelta);
2135
+ if (result) {
2136
+ this.sorted.next({
2137
+ previousIndex: result.previousIndex,
2138
+ currentIndex: result.currentIndex,
2139
+ container: this,
2140
+ item,
2141
+ });
1846
2142
  }
1847
- const isHorizontal = this._orientation === 'horizontal';
1848
- const currentIndex = siblings.findIndex(currentItem => currentItem.drag === item);
1849
- const siblingAtNewPosition = siblings[newIndex];
1850
- const currentPosition = siblings[currentIndex].clientRect;
1851
- const newPosition = siblingAtNewPosition.clientRect;
1852
- const delta = currentIndex > newIndex ? 1 : -1;
1853
- // How many pixels the item's placeholder should be offset.
1854
- const itemOffset = this._getItemOffsetPx(currentPosition, newPosition, delta);
1855
- // How many pixels all the other items should be offset.
1856
- const siblingOffset = this._getSiblingOffsetPx(currentIndex, siblings, delta);
1857
- // Save the previous order of the items before moving the item to its new index.
1858
- // We use this to check whether an item has been moved as a result of the sorting.
1859
- const oldOrder = siblings.slice();
1860
- // Shuffle the array in place.
1861
- moveItemInArray(siblings, currentIndex, newIndex);
1862
- this.sorted.next({
1863
- previousIndex: currentIndex,
1864
- currentIndex: newIndex,
1865
- container: this,
1866
- item,
1867
- });
1868
- siblings.forEach((sibling, index) => {
1869
- // Don't do anything if the position hasn't changed.
1870
- if (oldOrder[index] === sibling) {
1871
- return;
1872
- }
1873
- const isDraggedItem = sibling.drag === item;
1874
- const offset = isDraggedItem ? itemOffset : siblingOffset;
1875
- const elementToOffset = isDraggedItem
1876
- ? item.getPlaceholderElement()
1877
- : sibling.drag.getRootElement();
1878
- // Update the offset to reflect the new position.
1879
- sibling.offset += offset;
1880
- // Since we're moving the items with a `transform`, we need to adjust their cached
1881
- // client rects to reflect their new position, as well as swap their positions in the cache.
1882
- // Note that we shouldn't use `getBoundingClientRect` here to update the cache, because the
1883
- // elements may be mid-animation which will give us a wrong result.
1884
- if (isHorizontal) {
1885
- // Round the transforms since some browsers will
1886
- // blur the elements, for sub-pixel transforms.
1887
- elementToOffset.style.transform = combineTransforms(`translate3d(${Math.round(sibling.offset)}px, 0, 0)`, sibling.initialTransform);
1888
- adjustClientRect(sibling.clientRect, 0, offset);
1889
- }
1890
- else {
1891
- elementToOffset.style.transform = combineTransforms(`translate3d(0, ${Math.round(sibling.offset)}px, 0)`, sibling.initialTransform);
1892
- adjustClientRect(sibling.clientRect, offset, 0);
1893
- }
1894
- });
1895
- // Note that it's important that we do this after the client rects have been adjusted.
1896
- this._previousSwap.overlaps = isInsideClientRect(newPosition, pointerX, pointerY);
1897
- this._previousSwap.drag = siblingAtNewPosition.drag;
1898
- this._previousSwap.delta = isHorizontal ? pointerDelta.x : pointerDelta.y;
1899
2143
  }
1900
2144
  /**
1901
2145
  * Checks whether the user's pointer is close to the edges of either the
@@ -1968,7 +2212,8 @@ class DropListRef {
1968
2212
  // that we can't increment/decrement the scroll position.
1969
2213
  this._initialScrollSnap = styles.msScrollSnapType || styles.scrollSnapType || '';
1970
2214
  styles.scrollSnapType = styles.msScrollSnapType = 'none';
1971
- this._cacheItems();
2215
+ this._sortStrategy.start(this._draggables);
2216
+ this._cacheParentPositions();
1972
2217
  this._viewportScrollSubscription.unsubscribe();
1973
2218
  this._listenToScrollEvents();
1974
2219
  }
@@ -1980,156 +2225,17 @@ class DropListRef {
1980
2225
  // so we can take advantage of the cached `ClientRect`.
1981
2226
  this._clientRect = this._parentPositions.positions.get(element).clientRect;
1982
2227
  }
1983
- /** Refreshes the position cache of the items and sibling containers. */
1984
- _cacheItemPositions() {
1985
- const isHorizontal = this._orientation === 'horizontal';
1986
- this._itemPositions = this._activeDraggables
1987
- .map(drag => {
1988
- const elementToMeasure = drag.getVisibleElement();
1989
- return {
1990
- drag,
1991
- offset: 0,
1992
- initialTransform: elementToMeasure.style.transform || '',
1993
- clientRect: getMutableClientRect(elementToMeasure),
1994
- };
1995
- })
1996
- .sort((a, b) => {
1997
- return isHorizontal
1998
- ? a.clientRect.left - b.clientRect.left
1999
- : a.clientRect.top - b.clientRect.top;
2000
- });
2001
- }
2002
2228
  /** Resets the container to its initial state. */
2003
2229
  _reset() {
2004
2230
  this._isDragging = false;
2005
2231
  const styles = coerceElement(this.element).style;
2006
2232
  styles.scrollSnapType = styles.msScrollSnapType = this._initialScrollSnap;
2007
- // TODO(crisbeto): may have to wait for the animations to finish.
2008
- this._activeDraggables.forEach(item => {
2009
- const rootElement = item.getRootElement();
2010
- if (rootElement) {
2011
- const initialTransform = this._itemPositions.find(current => current.drag === item)?.initialTransform;
2012
- rootElement.style.transform = initialTransform || '';
2013
- }
2014
- });
2015
2233
  this._siblings.forEach(sibling => sibling._stopReceiving(this));
2016
- this._activeDraggables = [];
2017
- this._itemPositions = [];
2018
- this._previousSwap.drag = null;
2019
- this._previousSwap.delta = 0;
2020
- this._previousSwap.overlaps = false;
2234
+ this._sortStrategy.reset();
2021
2235
  this._stopScrolling();
2022
2236
  this._viewportScrollSubscription.unsubscribe();
2023
2237
  this._parentPositions.clear();
2024
2238
  }
2025
- /**
2026
- * Gets the offset in pixels by which the items that aren't being dragged should be moved.
2027
- * @param currentIndex Index of the item currently being dragged.
2028
- * @param siblings All of the items in the list.
2029
- * @param delta Direction in which the user is moving.
2030
- */
2031
- _getSiblingOffsetPx(currentIndex, siblings, delta) {
2032
- const isHorizontal = this._orientation === 'horizontal';
2033
- const currentPosition = siblings[currentIndex].clientRect;
2034
- const immediateSibling = siblings[currentIndex + delta * -1];
2035
- let siblingOffset = currentPosition[isHorizontal ? 'width' : 'height'] * delta;
2036
- if (immediateSibling) {
2037
- const start = isHorizontal ? 'left' : 'top';
2038
- const end = isHorizontal ? 'right' : 'bottom';
2039
- // Get the spacing between the start of the current item and the end of the one immediately
2040
- // after it in the direction in which the user is dragging, or vice versa. We add it to the
2041
- // offset in order to push the element to where it will be when it's inline and is influenced
2042
- // by the `margin` of its siblings.
2043
- if (delta === -1) {
2044
- siblingOffset -= immediateSibling.clientRect[start] - currentPosition[end];
2045
- }
2046
- else {
2047
- siblingOffset += currentPosition[start] - immediateSibling.clientRect[end];
2048
- }
2049
- }
2050
- return siblingOffset;
2051
- }
2052
- /**
2053
- * Gets the offset in pixels by which the item that is being dragged should be moved.
2054
- * @param currentPosition Current position of the item.
2055
- * @param newPosition Position of the item where the current item should be moved.
2056
- * @param delta Direction in which the user is moving.
2057
- */
2058
- _getItemOffsetPx(currentPosition, newPosition, delta) {
2059
- const isHorizontal = this._orientation === 'horizontal';
2060
- let itemOffset = isHorizontal
2061
- ? newPosition.left - currentPosition.left
2062
- : newPosition.top - currentPosition.top;
2063
- // Account for differences in the item width/height.
2064
- if (delta === -1) {
2065
- itemOffset += isHorizontal
2066
- ? newPosition.width - currentPosition.width
2067
- : newPosition.height - currentPosition.height;
2068
- }
2069
- return itemOffset;
2070
- }
2071
- /**
2072
- * Checks if pointer is entering in the first position
2073
- * @param pointerX Position of the user's pointer along the X axis.
2074
- * @param pointerY Position of the user's pointer along the Y axis.
2075
- */
2076
- _shouldEnterAsFirstChild(pointerX, pointerY) {
2077
- if (!this._activeDraggables.length) {
2078
- return false;
2079
- }
2080
- const itemPositions = this._itemPositions;
2081
- const isHorizontal = this._orientation === 'horizontal';
2082
- // `itemPositions` are sorted by position while `activeDraggables` are sorted by child index
2083
- // check if container is using some sort of "reverse" ordering (eg: flex-direction: row-reverse)
2084
- const reversed = itemPositions[0].drag !== this._activeDraggables[0];
2085
- if (reversed) {
2086
- const lastItemRect = itemPositions[itemPositions.length - 1].clientRect;
2087
- return isHorizontal ? pointerX >= lastItemRect.right : pointerY >= lastItemRect.bottom;
2088
- }
2089
- else {
2090
- const firstItemRect = itemPositions[0].clientRect;
2091
- return isHorizontal ? pointerX <= firstItemRect.left : pointerY <= firstItemRect.top;
2092
- }
2093
- }
2094
- /**
2095
- * Gets the index of an item in the drop container, based on the position of the user's pointer.
2096
- * @param item Item that is being sorted.
2097
- * @param pointerX Position of the user's pointer along the X axis.
2098
- * @param pointerY Position of the user's pointer along the Y axis.
2099
- * @param delta Direction in which the user is moving their pointer.
2100
- */
2101
- _getItemIndexFromPointerPosition(item, pointerX, pointerY, delta) {
2102
- const isHorizontal = this._orientation === 'horizontal';
2103
- const index = this._itemPositions.findIndex(({ drag, clientRect }) => {
2104
- // Skip the item itself.
2105
- if (drag === item) {
2106
- return false;
2107
- }
2108
- if (delta) {
2109
- const direction = isHorizontal ? delta.x : delta.y;
2110
- // If the user is still hovering over the same item as last time, their cursor hasn't left
2111
- // the item after we made the swap, and they didn't change the direction in which they're
2112
- // dragging, we don't consider it a direction swap.
2113
- if (drag === this._previousSwap.drag &&
2114
- this._previousSwap.overlaps &&
2115
- direction === this._previousSwap.delta) {
2116
- return false;
2117
- }
2118
- }
2119
- return isHorizontal
2120
- ? // Round these down since most browsers report client rects with
2121
- // sub-pixel precision, whereas the pointer coordinates are rounded to pixels.
2122
- pointerX >= Math.floor(clientRect.left) && pointerX < Math.floor(clientRect.right)
2123
- : pointerY >= Math.floor(clientRect.top) && pointerY < Math.floor(clientRect.bottom);
2124
- });
2125
- return index === -1 || !this.sortPredicate(index, item, this) ? -1 : index;
2126
- }
2127
- /** Caches the current items in the list and their positions. */
2128
- _cacheItems() {
2129
- this._activeDraggables = this._draggables.slice();
2130
- this._cacheItemPositions();
2131
- this._cacheParentPositions();
2132
- }
2133
2239
  /**
2134
2240
  * Checks whether the user's pointer is positioned over the container.
2135
2241
  * @param x Pointer position along the X axis.
@@ -2213,22 +2319,7 @@ class DropListRef {
2213
2319
  if (this.isDragging()) {
2214
2320
  const scrollDifference = this._parentPositions.handleScroll(event);
2215
2321
  if (scrollDifference) {
2216
- // Since we know the amount that the user has scrolled we can shift all of the
2217
- // client rectangles ourselves. This is cheaper than re-measuring everything and
2218
- // we can avoid inconsistent behavior where we might be measuring the element before
2219
- // its position has changed.
2220
- this._itemPositions.forEach(({ clientRect }) => {
2221
- adjustClientRect(clientRect, scrollDifference.top, scrollDifference.left);
2222
- });
2223
- // We need two loops for this, because we want all of the cached
2224
- // positions to be up-to-date before we re-sort the item.
2225
- this._itemPositions.forEach(({ drag }) => {
2226
- if (this._dragDropRegistry.isDragging(drag)) {
2227
- // We need to re-sort the item manually, because the pointer move
2228
- // events won't be dispatched while the user is scrolling.
2229
- drag._sortFromLastPointerPosition();
2230
- }
2231
- });
2322
+ this._sortStrategy.updateOnScroll(scrollDifference.top, scrollDifference.left);
2232
2323
  }
2233
2324
  }
2234
2325
  else if (this.isReceiving()) {
@@ -2251,7 +2342,9 @@ class DropListRef {
2251
2342
  }
2252
2343
  /** Notifies any siblings that may potentially receive the item. */
2253
2344
  _notifyReceivingSiblings() {
2254
- const draggedItems = this._activeDraggables.filter(item => item.isDragging());
2345
+ const draggedItems = this._sortStrategy
2346
+ .getActiveItemsSnapshot()
2347
+ .filter(item => item.isDragging());
2255
2348
  this._siblings.forEach(sibling => sibling._startReceiving(this, draggedItems));
2256
2349
  }
2257
2350
  }
@@ -2545,9 +2638,9 @@ class DragDropRegistry {
2545
2638
  this._globalListeners.clear();
2546
2639
  }
2547
2640
  }
2548
- DragDropRegistry.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: DragDropRegistry, deps: [{ token: i0.NgZone }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
2549
- DragDropRegistry.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: DragDropRegistry, providedIn: 'root' });
2550
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: DragDropRegistry, decorators: [{
2641
+ DragDropRegistry.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: DragDropRegistry, deps: [{ token: i0.NgZone }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
2642
+ DragDropRegistry.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: DragDropRegistry, providedIn: 'root' });
2643
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: DragDropRegistry, decorators: [{
2551
2644
  type: Injectable,
2552
2645
  args: [{ providedIn: 'root' }]
2553
2646
  }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: undefined, decorators: [{
@@ -2593,9 +2686,9 @@ class DragDrop {
2593
2686
  return new DropListRef(element, this._dragDropRegistry, this._document, this._ngZone, this._viewportRuler);
2594
2687
  }
2595
2688
  }
2596
- DragDrop.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: DragDrop, deps: [{ token: DOCUMENT }, { token: i0.NgZone }, { token: i1.ViewportRuler }, { token: DragDropRegistry }], target: i0.ɵɵFactoryTarget.Injectable });
2597
- DragDrop.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: DragDrop, providedIn: 'root' });
2598
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: DragDrop, decorators: [{
2689
+ DragDrop.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: DragDrop, deps: [{ token: DOCUMENT }, { token: i0.NgZone }, { token: i1.ViewportRuler }, { token: DragDropRegistry }], target: i0.ɵɵFactoryTarget.Injectable });
2690
+ DragDrop.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: DragDrop, providedIn: 'root' });
2691
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: DragDrop, decorators: [{
2599
2692
  type: Injectable,
2600
2693
  args: [{ providedIn: 'root' }]
2601
2694
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
@@ -2662,9 +2755,9 @@ class CdkDropListGroup {
2662
2755
  this._items.clear();
2663
2756
  }
2664
2757
  }
2665
- CdkDropListGroup.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: CdkDropListGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2666
- CdkDropListGroup.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.0-rc.1", type: CdkDropListGroup, selector: "[cdkDropListGroup]", inputs: { disabled: ["cdkDropListGroupDisabled", "disabled"] }, providers: [{ provide: CDK_DROP_LIST_GROUP, useExisting: CdkDropListGroup }], exportAs: ["cdkDropListGroup"], ngImport: i0 });
2667
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: CdkDropListGroup, decorators: [{
2758
+ CdkDropListGroup.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: CdkDropListGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2759
+ CdkDropListGroup.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: CdkDropListGroup, selector: "[cdkDropListGroup]", inputs: { disabled: ["cdkDropListGroupDisabled", "disabled"] }, providers: [{ provide: CDK_DROP_LIST_GROUP, useExisting: CdkDropListGroup }], exportAs: ["cdkDropListGroup"], ngImport: i0 });
2760
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: CdkDropListGroup, decorators: [{
2668
2761
  type: Directive,
2669
2762
  args: [{
2670
2763
  selector: '[cdkDropListGroup]',
@@ -2953,13 +3046,13 @@ class CdkDropList {
2953
3046
  }
2954
3047
  /** Keeps track of the drop lists that are currently on the page. */
2955
3048
  CdkDropList._dropLists = [];
2956
- CdkDropList.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: CdkDropList, deps: [{ token: i0.ElementRef }, { token: DragDrop }, { token: i0.ChangeDetectorRef }, { token: i1.ScrollDispatcher }, { token: i3.Directionality, optional: true }, { token: CDK_DROP_LIST_GROUP, optional: true, skipSelf: true }, { token: CDK_DRAG_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
2957
- CdkDropList.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.0-rc.1", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: { connectedTo: ["cdkDropListConnectedTo", "connectedTo"], data: ["cdkDropListData", "data"], orientation: ["cdkDropListOrientation", "orientation"], id: "id", lockAxis: ["cdkDropListLockAxis", "lockAxis"], disabled: ["cdkDropListDisabled", "disabled"], sortingDisabled: ["cdkDropListSortingDisabled", "sortingDisabled"], enterPredicate: ["cdkDropListEnterPredicate", "enterPredicate"], sortPredicate: ["cdkDropListSortPredicate", "sortPredicate"], autoScrollDisabled: ["cdkDropListAutoScrollDisabled", "autoScrollDisabled"], autoScrollStep: ["cdkDropListAutoScrollStep", "autoScrollStep"] }, outputs: { dropped: "cdkDropListDropped", entered: "cdkDropListEntered", exited: "cdkDropListExited", sorted: "cdkDropListSorted" }, host: { properties: { "attr.id": "id", "class.cdk-drop-list-disabled": "disabled", "class.cdk-drop-list-dragging": "_dropListRef.isDragging()", "class.cdk-drop-list-receiving": "_dropListRef.isReceiving()" }, classAttribute: "cdk-drop-list" }, providers: [
3049
+ CdkDropList.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: CdkDropList, deps: [{ token: i0.ElementRef }, { token: DragDrop }, { token: i0.ChangeDetectorRef }, { token: i1.ScrollDispatcher }, { token: i3.Directionality, optional: true }, { token: CDK_DROP_LIST_GROUP, optional: true, skipSelf: true }, { token: CDK_DRAG_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
3050
+ CdkDropList.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: { connectedTo: ["cdkDropListConnectedTo", "connectedTo"], data: ["cdkDropListData", "data"], orientation: ["cdkDropListOrientation", "orientation"], id: "id", lockAxis: ["cdkDropListLockAxis", "lockAxis"], disabled: ["cdkDropListDisabled", "disabled"], sortingDisabled: ["cdkDropListSortingDisabled", "sortingDisabled"], enterPredicate: ["cdkDropListEnterPredicate", "enterPredicate"], sortPredicate: ["cdkDropListSortPredicate", "sortPredicate"], autoScrollDisabled: ["cdkDropListAutoScrollDisabled", "autoScrollDisabled"], autoScrollStep: ["cdkDropListAutoScrollStep", "autoScrollStep"] }, outputs: { dropped: "cdkDropListDropped", entered: "cdkDropListEntered", exited: "cdkDropListExited", sorted: "cdkDropListSorted" }, host: { properties: { "attr.id": "id", "class.cdk-drop-list-disabled": "disabled", "class.cdk-drop-list-dragging": "_dropListRef.isDragging()", "class.cdk-drop-list-receiving": "_dropListRef.isReceiving()" }, classAttribute: "cdk-drop-list" }, providers: [
2958
3051
  // Prevent child drop lists from picking up the same group as their parent.
2959
3052
  { provide: CDK_DROP_LIST_GROUP, useValue: undefined },
2960
3053
  { provide: CDK_DROP_LIST, useExisting: CdkDropList },
2961
3054
  ], exportAs: ["cdkDropList"], ngImport: i0 });
2962
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: CdkDropList, decorators: [{
3055
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: CdkDropList, decorators: [{
2963
3056
  type: Directive,
2964
3057
  args: [{
2965
3058
  selector: '[cdkDropList], cdk-drop-list',
@@ -3074,9 +3167,9 @@ class CdkDragHandle {
3074
3167
  this._stateChanges.complete();
3075
3168
  }
3076
3169
  }
3077
- CdkDragHandle.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: CdkDragHandle, deps: [{ token: i0.ElementRef }, { token: CDK_DRAG_PARENT, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
3078
- CdkDragHandle.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.0-rc.1", type: CdkDragHandle, selector: "[cdkDragHandle]", inputs: { disabled: ["cdkDragHandleDisabled", "disabled"] }, host: { classAttribute: "cdk-drag-handle" }, providers: [{ provide: CDK_DRAG_HANDLE, useExisting: CdkDragHandle }], ngImport: i0 });
3079
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: CdkDragHandle, decorators: [{
3170
+ CdkDragHandle.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: CdkDragHandle, deps: [{ token: i0.ElementRef }, { token: CDK_DRAG_PARENT, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
3171
+ CdkDragHandle.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: CdkDragHandle, selector: "[cdkDragHandle]", inputs: { disabled: ["cdkDragHandleDisabled", "disabled"] }, host: { classAttribute: "cdk-drag-handle" }, providers: [{ provide: CDK_DRAG_HANDLE, useExisting: CdkDragHandle }], ngImport: i0 });
3172
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: CdkDragHandle, decorators: [{
3080
3173
  type: Directive,
3081
3174
  args: [{
3082
3175
  selector: '[cdkDragHandle]',
@@ -3119,9 +3212,9 @@ class CdkDragPlaceholder {
3119
3212
  this.templateRef = templateRef;
3120
3213
  }
3121
3214
  }
3122
- CdkDragPlaceholder.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: CdkDragPlaceholder, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
3123
- CdkDragPlaceholder.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.0-rc.1", type: CdkDragPlaceholder, selector: "ng-template[cdkDragPlaceholder]", inputs: { data: "data" }, providers: [{ provide: CDK_DRAG_PLACEHOLDER, useExisting: CdkDragPlaceholder }], ngImport: i0 });
3124
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: CdkDragPlaceholder, decorators: [{
3215
+ CdkDragPlaceholder.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: CdkDragPlaceholder, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
3216
+ CdkDragPlaceholder.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: CdkDragPlaceholder, selector: "ng-template[cdkDragPlaceholder]", inputs: { data: "data" }, providers: [{ provide: CDK_DRAG_PLACEHOLDER, useExisting: CdkDragPlaceholder }], ngImport: i0 });
3217
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: CdkDragPlaceholder, decorators: [{
3125
3218
  type: Directive,
3126
3219
  args: [{
3127
3220
  selector: 'ng-template[cdkDragPlaceholder]',
@@ -3161,9 +3254,9 @@ class CdkDragPreview {
3161
3254
  this._matchSize = coerceBooleanProperty(value);
3162
3255
  }
3163
3256
  }
3164
- CdkDragPreview.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: CdkDragPreview, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
3165
- CdkDragPreview.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.0-rc.1", type: CdkDragPreview, selector: "ng-template[cdkDragPreview]", inputs: { data: "data", matchSize: "matchSize" }, providers: [{ provide: CDK_DRAG_PREVIEW, useExisting: CdkDragPreview }], ngImport: i0 });
3166
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: CdkDragPreview, decorators: [{
3257
+ CdkDragPreview.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: CdkDragPreview, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
3258
+ CdkDragPreview.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: CdkDragPreview, selector: "ng-template[cdkDragPreview]", inputs: { data: "data", matchSize: "matchSize" }, providers: [{ provide: CDK_DRAG_PREVIEW, useExisting: CdkDragPreview }], ngImport: i0 });
3259
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: CdkDragPreview, decorators: [{
3167
3260
  type: Directive,
3168
3261
  args: [{
3169
3262
  selector: 'ng-template[cdkDragPreview]',
@@ -3537,9 +3630,9 @@ class CdkDrag {
3537
3630
  }
3538
3631
  }
3539
3632
  CdkDrag._dragInstances = [];
3540
- CdkDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: CdkDrag, deps: [{ token: i0.ElementRef }, { token: CDK_DROP_LIST, optional: true, skipSelf: true }, { token: DOCUMENT }, { token: i0.NgZone }, { token: i0.ViewContainerRef }, { token: CDK_DRAG_CONFIG, optional: true }, { token: i3.Directionality, optional: true }, { token: DragDrop }, { token: i0.ChangeDetectorRef }, { token: CDK_DRAG_HANDLE, optional: true, self: true }, { token: CDK_DRAG_PARENT, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
3541
- CdkDrag.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.0-rc.1", type: CdkDrag, selector: "[cdkDrag]", inputs: { data: ["cdkDragData", "data"], lockAxis: ["cdkDragLockAxis", "lockAxis"], rootElementSelector: ["cdkDragRootElement", "rootElementSelector"], boundaryElement: ["cdkDragBoundary", "boundaryElement"], dragStartDelay: ["cdkDragStartDelay", "dragStartDelay"], freeDragPosition: ["cdkDragFreeDragPosition", "freeDragPosition"], disabled: ["cdkDragDisabled", "disabled"], constrainPosition: ["cdkDragConstrainPosition", "constrainPosition"], previewClass: ["cdkDragPreviewClass", "previewClass"], previewContainer: ["cdkDragPreviewContainer", "previewContainer"] }, outputs: { started: "cdkDragStarted", released: "cdkDragReleased", ended: "cdkDragEnded", entered: "cdkDragEntered", exited: "cdkDragExited", dropped: "cdkDragDropped", moved: "cdkDragMoved" }, host: { properties: { "class.cdk-drag-disabled": "disabled", "class.cdk-drag-dragging": "_dragRef.isDragging()" }, classAttribute: "cdk-drag" }, providers: [{ provide: CDK_DRAG_PARENT, useExisting: CdkDrag }], queries: [{ propertyName: "_previewTemplate", first: true, predicate: CDK_DRAG_PREVIEW, descendants: true }, { propertyName: "_placeholderTemplate", first: true, predicate: CDK_DRAG_PLACEHOLDER, descendants: true }, { propertyName: "_handles", predicate: CDK_DRAG_HANDLE, descendants: true }], exportAs: ["cdkDrag"], usesOnChanges: true, ngImport: i0 });
3542
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: CdkDrag, decorators: [{
3633
+ CdkDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: CdkDrag, deps: [{ token: i0.ElementRef }, { token: CDK_DROP_LIST, optional: true, skipSelf: true }, { token: DOCUMENT }, { token: i0.NgZone }, { token: i0.ViewContainerRef }, { token: CDK_DRAG_CONFIG, optional: true }, { token: i3.Directionality, optional: true }, { token: DragDrop }, { token: i0.ChangeDetectorRef }, { token: CDK_DRAG_HANDLE, optional: true, self: true }, { token: CDK_DRAG_PARENT, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
3634
+ CdkDrag.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: CdkDrag, selector: "[cdkDrag]", inputs: { data: ["cdkDragData", "data"], lockAxis: ["cdkDragLockAxis", "lockAxis"], rootElementSelector: ["cdkDragRootElement", "rootElementSelector"], boundaryElement: ["cdkDragBoundary", "boundaryElement"], dragStartDelay: ["cdkDragStartDelay", "dragStartDelay"], freeDragPosition: ["cdkDragFreeDragPosition", "freeDragPosition"], disabled: ["cdkDragDisabled", "disabled"], constrainPosition: ["cdkDragConstrainPosition", "constrainPosition"], previewClass: ["cdkDragPreviewClass", "previewClass"], previewContainer: ["cdkDragPreviewContainer", "previewContainer"] }, outputs: { started: "cdkDragStarted", released: "cdkDragReleased", ended: "cdkDragEnded", entered: "cdkDragEntered", exited: "cdkDragExited", dropped: "cdkDragDropped", moved: "cdkDragMoved" }, host: { properties: { "class.cdk-drag-disabled": "disabled", "class.cdk-drag-dragging": "_dragRef.isDragging()" }, classAttribute: "cdk-drag" }, providers: [{ provide: CDK_DRAG_PARENT, useExisting: CdkDrag }], queries: [{ propertyName: "_previewTemplate", first: true, predicate: CDK_DRAG_PREVIEW, descendants: true }, { propertyName: "_placeholderTemplate", first: true, predicate: CDK_DRAG_PLACEHOLDER, descendants: true }, { propertyName: "_handles", predicate: CDK_DRAG_HANDLE, descendants: true }], exportAs: ["cdkDrag"], usesOnChanges: true, ngImport: i0 });
3635
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: CdkDrag, decorators: [{
3543
3636
  type: Directive,
3544
3637
  args: [{
3545
3638
  selector: '[cdkDrag]',
@@ -3653,8 +3746,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ng
3653
3746
  */
3654
3747
  class DragDropModule {
3655
3748
  }
3656
- DragDropModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: DragDropModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3657
- DragDropModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.0-rc.1", ngImport: i0, type: DragDropModule, declarations: [CdkDropList,
3749
+ DragDropModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: DragDropModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3750
+ DragDropModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.1", ngImport: i0, type: DragDropModule, declarations: [CdkDropList,
3658
3751
  CdkDropListGroup,
3659
3752
  CdkDrag,
3660
3753
  CdkDragHandle,
@@ -3666,8 +3759,8 @@ DragDropModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
3666
3759
  CdkDragHandle,
3667
3760
  CdkDragPreview,
3668
3761
  CdkDragPlaceholder] });
3669
- DragDropModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: DragDropModule, providers: [DragDrop], imports: [CdkScrollableModule] });
3670
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-rc.1", ngImport: i0, type: DragDropModule, decorators: [{
3762
+ DragDropModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: DragDropModule, providers: [DragDrop], imports: [CdkScrollableModule] });
3763
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: DragDropModule, decorators: [{
3671
3764
  type: NgModule,
3672
3765
  args: [{
3673
3766
  declarations: [