@angular/cdk 10.0.0-rc.3 → 10.1.0

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 (242) hide show
  1. package/a11y/aria-describer/aria-describer.d.ts +10 -1
  2. package/a11y/focus-trap/focus-trap.d.ts +4 -2
  3. package/a11y/index.metadata.json +1 -1
  4. package/a11y/interactivity-checker/interactivity-checker.d.ts +11 -1
  5. package/a11y/key-manager/list-key-manager.d.ts +6 -0
  6. package/accordion/accordion.d.ts +7 -1
  7. package/accordion/index.d.ts +1 -0
  8. package/accordion/index.metadata.json +1 -1
  9. package/bundles/cdk-a11y.umd.js +78 -15
  10. package/bundles/cdk-a11y.umd.js.map +1 -1
  11. package/bundles/cdk-a11y.umd.min.js +11 -11
  12. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  13. package/bundles/cdk-accordion.umd.js +12 -4
  14. package/bundles/cdk-accordion.umd.js.map +1 -1
  15. package/bundles/cdk-accordion.umd.min.js +2 -2
  16. package/bundles/cdk-accordion.umd.min.js.map +1 -1
  17. package/bundles/cdk-drag-drop.umd.js +717 -641
  18. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  19. package/bundles/cdk-drag-drop.umd.min.js +8 -16
  20. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  21. package/bundles/cdk-overlay.umd.js +199 -42
  22. package/bundles/cdk-overlay.umd.js.map +1 -1
  23. package/bundles/cdk-overlay.umd.min.js +11 -18
  24. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  25. package/bundles/cdk-platform.umd.js +0 -1
  26. package/bundles/cdk-platform.umd.js.map +1 -1
  27. package/bundles/cdk-platform.umd.min.js +2 -2
  28. package/bundles/cdk-platform.umd.min.js.map +1 -1
  29. package/bundles/cdk-scrolling.umd.js +26 -4
  30. package/bundles/cdk-scrolling.umd.js.map +1 -1
  31. package/bundles/cdk-scrolling.umd.min.js +11 -4
  32. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  33. package/bundles/cdk-testing-protractor.umd.min.js +1 -1
  34. package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
  35. package/bundles/cdk-testing-testbed.umd.min.js +8 -8
  36. package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
  37. package/bundles/cdk-testing.umd.js +32 -0
  38. package/bundles/cdk-testing.umd.js.map +1 -1
  39. package/bundles/cdk-testing.umd.min.js +5 -5
  40. package/bundles/cdk-testing.umd.min.js.map +1 -1
  41. package/bundles/cdk-tree.umd.js +6 -2
  42. package/bundles/cdk-tree.umd.js.map +1 -1
  43. package/bundles/cdk-tree.umd.min.js +3 -3
  44. package/bundles/cdk-tree.umd.min.js.map +1 -1
  45. package/bundles/cdk.umd.js +1 -1
  46. package/bundles/cdk.umd.js.map +1 -1
  47. package/bundles/cdk.umd.min.js +1 -1
  48. package/bundles/cdk.umd.min.js.map +1 -1
  49. package/drag-drop/directives/drag-handle.d.ts +7 -1
  50. package/drag-drop/directives/drag-placeholder.d.ts +7 -1
  51. package/drag-drop/directives/drag-preview.d.ts +7 -1
  52. package/drag-drop/directives/drag.d.ts +4 -14
  53. package/drag-drop/directives/drop-list-group.d.ts +7 -1
  54. package/drag-drop/directives/drop-list.d.ts +7 -1
  55. package/drag-drop/drag-ref.d.ts +6 -0
  56. package/drag-drop/drop-list-ref.d.ts +3 -2
  57. package/drag-drop/index.d.ts +2 -2
  58. package/drag-drop/index.metadata.json +1 -1
  59. package/esm2015/a11y/a11y-module.js +15 -19
  60. package/esm2015/a11y/aria-describer/aria-describer.js +177 -167
  61. package/esm2015/a11y/focus-monitor/focus-monitor.js +337 -345
  62. package/esm2015/a11y/focus-trap/configurable-focus-trap-factory.js +30 -34
  63. package/esm2015/a11y/focus-trap/focus-trap-manager.js +36 -40
  64. package/esm2015/a11y/focus-trap/focus-trap.js +85 -82
  65. package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +56 -60
  66. package/esm2015/a11y/interactivity-checker/interactivity-checker.js +113 -104
  67. package/esm2015/a11y/key-manager/list-key-manager.js +29 -4
  68. package/esm2015/a11y/live-announcer/live-announcer.js +138 -146
  69. package/esm2015/accordion/accordion-item.js +119 -123
  70. package/esm2015/accordion/accordion-module.js +9 -13
  71. package/esm2015/accordion/accordion.js +49 -46
  72. package/esm2015/accordion/index.js +2 -1
  73. package/esm2015/bidi/bidi-module.js +9 -13
  74. package/esm2015/bidi/dir.js +41 -45
  75. package/esm2015/bidi/directionality.js +27 -31
  76. package/esm2015/clipboard/clipboard-module.js +9 -13
  77. package/esm2015/clipboard/clipboard.js +36 -40
  78. package/esm2015/clipboard/copy-to-clipboard.js +71 -75
  79. package/esm2015/collections/unique-selection-dispatcher.js +33 -37
  80. package/esm2015/drag-drop/directives/drag-handle.js +42 -39
  81. package/esm2015/drag-drop/directives/drag-placeholder.js +24 -21
  82. package/esm2015/drag-drop/directives/drag-preview.js +29 -26
  83. package/esm2015/drag-drop/directives/drag.js +313 -319
  84. package/esm2015/drag-drop/directives/drop-list-group.js +32 -29
  85. package/esm2015/drag-drop/directives/drop-list.js +251 -250
  86. package/esm2015/drag-drop/drag-drop-module.js +27 -31
  87. package/esm2015/drag-drop/drag-drop-registry.js +139 -143
  88. package/esm2015/drag-drop/drag-drop.js +33 -37
  89. package/esm2015/drag-drop/drag-ref.js +59 -25
  90. package/esm2015/drag-drop/drop-list-ref.js +15 -9
  91. package/esm2015/drag-drop/index.js +3 -2
  92. package/esm2015/layout/breakpoints-observer.js +81 -85
  93. package/esm2015/layout/layout-module.js +6 -10
  94. package/esm2015/layout/media-matcher.js +28 -32
  95. package/esm2015/observers/observe-content.js +147 -163
  96. package/esm2015/overlay/dispatchers/base-overlay-dispatcher.js +51 -0
  97. package/esm2015/overlay/dispatchers/index.js +10 -0
  98. package/esm2015/overlay/dispatchers/overlay-keyboard-dispatcher.js +79 -0
  99. package/esm2015/overlay/dispatchers/overlay-outside-click-dispatcher.js +94 -0
  100. package/esm2015/overlay/fullscreen-overlay-container.js +70 -74
  101. package/esm2015/overlay/index.js +5 -4
  102. package/esm2015/overlay/overlay-config.js +5 -1
  103. package/esm2015/overlay/overlay-container.js +69 -73
  104. package/esm2015/overlay/overlay-directives.js +245 -243
  105. package/esm2015/overlay/overlay-module.js +15 -19
  106. package/esm2015/overlay/overlay-ref.js +24 -2
  107. package/esm2015/overlay/overlay-reference.js +1 -1
  108. package/esm2015/overlay/overlay.js +93 -92
  109. package/esm2015/overlay/position/connected-position.js +14 -18
  110. package/esm2015/overlay/position/overlay-position-builder.js +43 -47
  111. package/esm2015/overlay/public-api.js +2 -2
  112. package/esm2015/overlay/scroll/scroll-strategy-options.js +33 -37
  113. package/esm2015/platform/features/scrolling.js +1 -2
  114. package/esm2015/platform/platform-module.js +6 -10
  115. package/esm2015/platform/platform.js +48 -52
  116. package/esm2015/portal/portal-directives.js +181 -201
  117. package/esm2015/scrolling/fixed-size-virtual-scroll.js +57 -47
  118. package/esm2015/scrolling/public-api.js +2 -1
  119. package/esm2015/scrolling/scroll-dispatcher.js +139 -143
  120. package/esm2015/scrolling/scrollable.js +135 -139
  121. package/esm2015/scrolling/scrolling-module.js +32 -40
  122. package/esm2015/scrolling/viewport-ruler.js +105 -109
  123. package/esm2015/scrolling/virtual-for-of.js +264 -268
  124. package/esm2015/scrolling/virtual-scroll-repeater.js +8 -0
  125. package/esm2015/scrolling/virtual-scroll-viewport.js +318 -322
  126. package/esm2015/stepper/step-header.js +20 -24
  127. package/esm2015/stepper/step-label.js +13 -17
  128. package/esm2015/stepper/stepper-button.js +59 -67
  129. package/esm2015/stepper/stepper-module.js +24 -28
  130. package/esm2015/stepper/stepper.js +313 -321
  131. package/esm2015/table/cell.js +129 -157
  132. package/esm2015/table/row.js +183 -219
  133. package/esm2015/table/table-module.js +9 -13
  134. package/esm2015/table/table.js +765 -785
  135. package/esm2015/table/text-column.js +85 -89
  136. package/esm2015/testing/component-harness.js +19 -1
  137. package/esm2015/testing/harness-environment.js +7 -1
  138. package/esm2015/text-field/autofill.js +89 -97
  139. package/esm2015/text-field/autosize.js +225 -229
  140. package/esm2015/text-field/text-field-module.js +10 -14
  141. package/esm2015/tree/control/nested-tree-control.js +7 -3
  142. package/esm2015/tree/nested-node.js +79 -83
  143. package/esm2015/tree/node.js +17 -21
  144. package/esm2015/tree/outlet.js +15 -19
  145. package/esm2015/tree/padding.js +88 -92
  146. package/esm2015/tree/toggle.js +32 -36
  147. package/esm2015/tree/tree-module.js +10 -14
  148. package/esm2015/tree/tree.js +266 -274
  149. package/esm2015/version.js +1 -1
  150. package/fesm2015/a11y.js +1021 -996
  151. package/fesm2015/a11y.js.map +1 -1
  152. package/fesm2015/accordion.js +173 -175
  153. package/fesm2015/accordion.js.map +1 -1
  154. package/fesm2015/bidi.js +74 -83
  155. package/fesm2015/bidi.js.map +1 -1
  156. package/fesm2015/cdk.js +1 -1
  157. package/fesm2015/cdk.js.map +1 -1
  158. package/fesm2015/clipboard.js +113 -122
  159. package/fesm2015/clipboard.js.map +1 -1
  160. package/fesm2015/collections.js +32 -35
  161. package/fesm2015/collections.js.map +1 -1
  162. package/fesm2015/drag-drop.js +1005 -961
  163. package/fesm2015/drag-drop.js.map +1 -1
  164. package/fesm2015/layout.js +111 -120
  165. package/fesm2015/layout.js.map +1 -1
  166. package/fesm2015/observers.js +146 -158
  167. package/fesm2015/observers.js.map +1 -1
  168. package/fesm2015/overlay.js +793 -659
  169. package/fesm2015/overlay.js.map +1 -1
  170. package/fesm2015/platform.js +52 -59
  171. package/fesm2015/platform.js.map +1 -1
  172. package/fesm2015/portal.js +180 -195
  173. package/fesm2015/portal.js.map +1 -1
  174. package/fesm2015/scrolling.js +1058 -1060
  175. package/fesm2015/scrolling.js.map +1 -1
  176. package/fesm2015/stepper.js +424 -445
  177. package/fesm2015/stepper.js.map +1 -1
  178. package/fesm2015/table.js +1178 -1247
  179. package/fesm2015/table.js.map +1 -1
  180. package/fesm2015/testing.js +25 -1
  181. package/fesm2015/testing.js.map +1 -1
  182. package/fesm2015/text-field.js +318 -330
  183. package/fesm2015/text-field.js.map +1 -1
  184. package/fesm2015/tree.js +517 -537
  185. package/fesm2015/tree.js.map +1 -1
  186. package/overlay/dispatchers/base-overlay-dispatcher.d.ts +28 -0
  187. package/overlay/dispatchers/index.d.ts +9 -0
  188. package/overlay/{keyboard → dispatchers}/overlay-keyboard-dispatcher.d.ts +4 -10
  189. package/overlay/dispatchers/overlay-outside-click-dispatcher.d.ts +27 -0
  190. package/overlay/index.d.ts +4 -3
  191. package/overlay/index.metadata.json +1 -1
  192. package/overlay/overlay-config.d.ts +4 -0
  193. package/overlay/overlay-directives.d.ts +4 -0
  194. package/overlay/overlay-ref.d.ts +8 -2
  195. package/overlay/overlay-reference.d.ts +1 -0
  196. package/overlay/overlay.d.ts +4 -2
  197. package/overlay/public-api.d.ts +1 -1
  198. package/package.json +3 -3
  199. package/schematics/index.js +1 -1
  200. package/schematics/migration.json +5 -0
  201. package/schematics/ng-add/index.js +1 -1
  202. package/schematics/ng-update/data/index.js +1 -1
  203. package/schematics/ng-update/devkit-file-system.d.ts +5 -5
  204. package/schematics/ng-update/devkit-file-system.js +21 -16
  205. package/schematics/ng-update/devkit-migration-rule.js +13 -20
  206. package/schematics/ng-update/devkit-migration.d.ts +0 -2
  207. package/schematics/ng-update/devkit-migration.js +1 -1
  208. package/schematics/ng-update/find-stylesheets.d.ts +10 -0
  209. package/schematics/ng-update/find-stylesheets.js +31 -0
  210. package/schematics/ng-update/index.d.ts +2 -0
  211. package/schematics/ng-update/index.js +7 -2
  212. package/schematics/ng-update/migrations/attribute-selectors.js +3 -3
  213. package/schematics/ng-update/migrations/css-selectors.js +3 -3
  214. package/schematics/ng-update/migrations/element-selectors.js +3 -3
  215. package/schematics/ng-update/public-api.js +1 -1
  216. package/schematics/update-tool/component-resource-collector.d.ts +1 -1
  217. package/schematics/update-tool/component-resource-collector.js +18 -14
  218. package/schematics/update-tool/file-system.d.ts +19 -14
  219. package/schematics/update-tool/file-system.js +1 -1
  220. package/schematics/update-tool/index.d.ts +21 -3
  221. package/schematics/update-tool/index.js +29 -23
  222. package/schematics/update-tool/public-api.js +1 -1
  223. package/schematics/update-tool/target-version.d.ts +2 -1
  224. package/schematics/update-tool/target-version.js +5 -3
  225. package/schematics/update-tool/utils/parse-tsconfig.d.ts +2 -1
  226. package/schematics/update-tool/utils/parse-tsconfig.js +6 -10
  227. package/schematics/update-tool/utils/virtual-host.d.ts +34 -0
  228. package/schematics/update-tool/utils/virtual-host.js +62 -0
  229. package/schematics/update-tool/version-changes.js +4 -6
  230. package/schematics/utils/index.js +1 -1
  231. package/schematics/utils/project-tsconfig-paths.d.ts +2 -1
  232. package/schematics/utils/project-tsconfig-paths.js +1 -1
  233. package/scrolling/index.metadata.json +1 -1
  234. package/scrolling/public-api.d.ts +1 -0
  235. package/scrolling/virtual-for-of.d.ts +2 -1
  236. package/scrolling/virtual-scroll-repeater.d.ts +16 -0
  237. package/scrolling/virtual-scroll-viewport.d.ts +4 -4
  238. package/testing/component-harness.d.ts +12 -0
  239. package/testing/harness-environment.d.ts +1 -0
  240. package/tree/control/nested-tree-control.d.ts +7 -2
  241. package/tree/index.metadata.json +1 -1
  242. package/esm2015/overlay/keyboard/overlay-keyboard-dispatcher.js +0 -100
@@ -350,9 +350,10 @@
350
350
  }
351
351
  var constrainedPointerPosition = _this._getConstrainedPointerPosition(pointerPosition);
352
352
  _this._hasMoved = true;
353
+ _this._lastKnownPointerPosition = pointerPosition;
353
354
  _this._updatePointerDirectionDelta(constrainedPointerPosition);
354
355
  if (_this._dropContainer) {
355
- _this._updateActiveDropContainer(constrainedPointerPosition);
356
+ _this._updateActiveDropContainer(constrainedPointerPosition, pointerPosition);
356
357
  }
357
358
  else {
358
359
  var activeTransform = _this._activeTransform;
@@ -465,6 +466,9 @@
465
466
  this._initialTransform = undefined;
466
467
  this._rootElement = element;
467
468
  }
469
+ if (typeof SVGElement !== 'undefined' && this._rootElement instanceof SVGElement) {
470
+ this._ownerSVGElement = this._rootElement.ownerSVGElement;
471
+ }
468
472
  return this;
469
473
  };
470
474
  /**
@@ -509,7 +513,7 @@
509
513
  this._dropContainer = undefined;
510
514
  this._resizeSubscription.unsubscribe();
511
515
  this._parentPositions.clear();
512
- this._boundaryElement = this._rootElement = this._placeholderTemplate =
516
+ this._boundaryElement = this._rootElement = this._ownerSVGElement = this._placeholderTemplate =
513
517
  this._previewTemplate = this._anchor = null;
514
518
  };
515
519
  /** Checks whether the element is currently being dragged. */
@@ -569,9 +573,9 @@
569
573
  };
570
574
  /** Updates the item's sort order based on the last-known pointer position. */
571
575
  DragRef.prototype._sortFromLastPointerPosition = function () {
572
- var position = this._pointerPositionAtLastDirectionChange;
576
+ var position = this._lastKnownPointerPosition;
573
577
  if (position && this._dropContainer) {
574
- this._updateActiveDropContainer(this._getConstrainedPointerPosition(position));
578
+ this._updateActiveDropContainer(this._getConstrainedPointerPosition(position), position);
575
579
  }
576
580
  };
577
581
  /** Unsubscribes from the global subscriptions. */
@@ -650,8 +654,6 @@
650
654
  };
651
655
  /** Starts the dragging sequence. */
652
656
  DragRef.prototype._startDragSequence = function (event) {
653
- // Emit the event on the item before the one on the container.
654
- this.started.next({ source: this });
655
657
  if (isTouchEvent(event)) {
656
658
  this._lastTouchEventTime = Date.now();
657
659
  }
@@ -671,11 +673,13 @@
671
673
  element.style.display = 'none';
672
674
  this._document.body.appendChild(parent_1.replaceChild(placeholder, element));
673
675
  getPreviewInsertionPoint(this._document).appendChild(preview);
676
+ this.started.next({ source: this }); // Emit before notifying the container.
674
677
  dropContainer.start();
675
678
  this._initialContainer = dropContainer;
676
679
  this._initialIndex = dropContainer.getItemIndex(this);
677
680
  }
678
681
  else {
682
+ this.started.next({ source: this });
679
683
  this._initialContainer = this._initialIndex = undefined;
680
684
  }
681
685
  // Important to run after we've called `start` on the parent container
@@ -739,7 +743,8 @@
739
743
  this._pickupPositionInElement = previewTemplate && previewTemplate.template &&
740
744
  !previewTemplate.matchSize ? { x: 0, y: 0 } :
741
745
  this._getPointerPositionInElement(referenceElement, event);
742
- var pointerPosition = this._pickupPositionOnPage = this._getPointerPositionOnPage(event);
746
+ var pointerPosition = this._pickupPositionOnPage = this._lastKnownPointerPosition =
747
+ this._getPointerPositionOnPage(event);
743
748
  this._pointerDirectionDelta = { x: 0, y: 0 };
744
749
  this._pointerPositionAtLastDirectionChange = { x: pointerPosition.x, y: pointerPosition.y };
745
750
  this._dragStartTime = Date.now();
@@ -782,9 +787,10 @@
782
787
  * Updates the item's position in its drop container, or moves it
783
788
  * into a new one, depending on its current drag position.
784
789
  */
785
- DragRef.prototype._updateActiveDropContainer = function (_a) {
790
+ DragRef.prototype._updateActiveDropContainer = function (_a, _b) {
786
791
  var _this = this;
787
792
  var x = _a.x, y = _a.y;
793
+ var rawX = _b.x, rawY = _b.y;
788
794
  // Drop container that draggable has been moved into.
789
795
  var newContainer = this._initialContainer._getSiblingContainerFromPosition(this, x, y);
790
796
  // If we couldn't find a new container to move the item into, and the item has left its
@@ -813,7 +819,7 @@
813
819
  });
814
820
  });
815
821
  }
816
- this._dropContainer._startScrollingIfNecessary(x, y);
822
+ this._dropContainer._startScrollingIfNecessary(rawX, rawY);
817
823
  this._dropContainer._sortItem(this, x, y, this._pointerDirectionDelta);
818
824
  this._preview.style.transform =
819
825
  getTransform(x - this._pickupPositionInElement.x, y - this._pickupPositionInElement.y);
@@ -958,33 +964,43 @@
958
964
  // breaks inside a developer tool and the value is only used for secondary information,
959
965
  // we can get away with it. See https://bugzilla.mozilla.org/show_bug.cgi?id=1615824.
960
966
  (event.touches[0] || event.changedTouches[0] || { pageX: 0, pageY: 0 }) : event;
961
- return {
962
- x: point.pageX - scrollPosition.left,
963
- y: point.pageY - scrollPosition.top
964
- };
967
+ var x = point.pageX - scrollPosition.left;
968
+ var y = point.pageY - scrollPosition.top;
969
+ // if dragging SVG element, try to convert from the screen coordinate system to the SVG
970
+ // coordinate system
971
+ if (this._ownerSVGElement) {
972
+ var svgMatrix = this._ownerSVGElement.getScreenCTM();
973
+ if (svgMatrix) {
974
+ var svgPoint = this._ownerSVGElement.createSVGPoint();
975
+ svgPoint.x = x;
976
+ svgPoint.y = y;
977
+ return svgPoint.matrixTransform(svgMatrix.inverse());
978
+ }
979
+ }
980
+ return { x: x, y: y };
965
981
  };
966
982
  /** Gets the pointer position on the page, accounting for any position constraints. */
967
983
  DragRef.prototype._getConstrainedPointerPosition = function (point) {
968
- var constrainedPoint = this.constrainPosition ? this.constrainPosition(point, this) : point;
969
984
  var dropContainerLock = this._dropContainer ? this._dropContainer.lockAxis : null;
985
+ var _a = this.constrainPosition ? this.constrainPosition(point, this) : point, x = _a.x, y = _a.y;
970
986
  if (this.lockAxis === 'x' || dropContainerLock === 'x') {
971
- constrainedPoint.y = this._pickupPositionOnPage.y;
987
+ y = this._pickupPositionOnPage.y;
972
988
  }
973
989
  else if (this.lockAxis === 'y' || dropContainerLock === 'y') {
974
- constrainedPoint.x = this._pickupPositionOnPage.x;
990
+ x = this._pickupPositionOnPage.x;
975
991
  }
976
992
  if (this._boundaryRect) {
977
- var _a = this._pickupPositionInElement, pickupX = _a.x, pickupY = _a.y;
993
+ var _b = this._pickupPositionInElement, pickupX = _b.x, pickupY = _b.y;
978
994
  var boundaryRect = this._boundaryRect;
979
995
  var previewRect = this._previewRect;
980
996
  var minY = boundaryRect.top + pickupY;
981
997
  var maxY = boundaryRect.bottom - (previewRect.height - pickupY);
982
998
  var minX = boundaryRect.left + pickupX;
983
999
  var maxX = boundaryRect.right - (previewRect.width - pickupX);
984
- constrainedPoint.x = clamp(constrainedPoint.x, minX, maxX);
985
- constrainedPoint.y = clamp(constrainedPoint.y, minY, maxY);
1000
+ x = clamp(x, minX, maxX);
1001
+ y = clamp(y, minY, maxY);
986
1002
  }
987
- return constrainedPoint;
1003
+ return { x: x, y: y };
988
1004
  };
989
1005
  /** Updates the current drag delta, based on the user's current pointer position on the page. */
990
1006
  DragRef.prototype._updatePointerDirectionDelta = function (pointerPositionOnPage) {
@@ -1123,10 +1139,24 @@
1123
1139
  /** Updates the internal state of the draggable element when scrolling has occurred. */
1124
1140
  DragRef.prototype._updateOnScroll = function (event) {
1125
1141
  var scrollDifference = this._parentPositions.handleScroll(event);
1126
- // ClientRect dimensions are based on the page's scroll position so
1127
- // we have to update the cached boundary ClientRect if the user has scrolled.
1128
- if (this._boundaryRect && scrollDifference) {
1129
- adjustClientRect(this._boundaryRect, scrollDifference.top, scrollDifference.left);
1142
+ if (scrollDifference) {
1143
+ var target = event.target;
1144
+ // ClientRect dimensions are based on the scroll position of the page and its parent node so
1145
+ // we have to update the cached boundary ClientRect if the user has scrolled. Check for
1146
+ // the `document` specifically since IE doesn't support `contains` on it.
1147
+ if (this._boundaryRect && (target === this._document ||
1148
+ (target !== this._boundaryElement && target.contains(this._boundaryElement)))) {
1149
+ adjustClientRect(this._boundaryRect, scrollDifference.top, scrollDifference.left);
1150
+ }
1151
+ this._pickupPositionOnPage.x += scrollDifference.left;
1152
+ this._pickupPositionOnPage.y += scrollDifference.top;
1153
+ // If we're in free drag mode, we have to update the active transform, because
1154
+ // it isn't relative to the viewport like the preview inside a drop list.
1155
+ if (!this._dropContainer) {
1156
+ this._activeTransform.x -= scrollDifference.left;
1157
+ this._activeTransform.y -= scrollDifference.top;
1158
+ this._applyRootElementTransform(this._activeTransform.x, this._activeTransform.y);
1159
+ }
1130
1160
  }
1131
1161
  };
1132
1162
  /** Gets the scroll position of the viewport. */
@@ -1164,7 +1194,12 @@
1164
1194
  for (var i = 0; i < descendantCanvases.length; i++) {
1165
1195
  var correspondingCloneContext = cloneCanvases[i].getContext('2d');
1166
1196
  if (correspondingCloneContext) {
1167
- correspondingCloneContext.drawImage(descendantCanvases[i], 0, 0);
1197
+ // In some cases `drawImage` can throw (e.g. if the canvas size is 0x0).
1198
+ // We can't do much about it so just ignore the error.
1199
+ try {
1200
+ correspondingCloneContext.drawImage(descendantCanvases[i], 0, 0);
1201
+ }
1202
+ catch (_a) { }
1168
1203
  }
1169
1204
  }
1170
1205
  }
@@ -1578,10 +1613,11 @@
1578
1613
  /** Cache of the dimensions of all the items inside the container. */
1579
1614
  this._itemPositions = [];
1580
1615
  /**
1581
- * Keeps track of the item that was last swapped with the dragged item, as
1582
- * well as what direction the pointer was moving in when the swap occured.
1616
+ * Keeps track of the item that was last swapped with the dragged item, as well as what direction
1617
+ * the pointer was moving in when the swap occured and whether the user's pointer continued to
1618
+ * overlap with the swapped item after the swapping occurred.
1583
1619
  */
1584
- this._previousSwap = { drag: null, delta: 0 };
1620
+ this._previousSwap = { drag: null, delta: 0, overlaps: false };
1585
1621
  /** Drop lists that are connected to the current one. */
1586
1622
  this._siblings = [];
1587
1623
  /** Direction in which the list is oriented. */
@@ -1864,8 +1900,6 @@
1864
1900
  var currentPosition = siblings[currentIndex].clientRect;
1865
1901
  var newPosition = siblingAtNewPosition.clientRect;
1866
1902
  var delta = currentIndex > newIndex ? 1 : -1;
1867
- this._previousSwap.drag = siblingAtNewPosition.drag;
1868
- this._previousSwap.delta = isHorizontal ? pointerDelta.x : pointerDelta.y;
1869
1903
  // How many pixels the item's placeholder should be offset.
1870
1904
  var itemOffset = this._getItemOffsetPx(currentPosition, newPosition, delta);
1871
1905
  // How many pixels all the other items should be offset.
@@ -1907,6 +1941,10 @@
1907
1941
  adjustClientRect(sibling.clientRect, offset, 0);
1908
1942
  }
1909
1943
  });
1944
+ // Note that it's important that we do this after the client rects have been adjusted.
1945
+ this._previousSwap.overlaps = isInsideClientRect(newPosition, pointerX, pointerY);
1946
+ this._previousSwap.drag = siblingAtNewPosition.drag;
1947
+ this._previousSwap.delta = isHorizontal ? pointerDelta.x : pointerDelta.y;
1910
1948
  };
1911
1949
  /**
1912
1950
  * Checks whether the user's pointer is close to the edges of either the
@@ -2000,6 +2038,7 @@
2000
2038
  this._itemPositions = [];
2001
2039
  this._previousSwap.drag = null;
2002
2040
  this._previousSwap.delta = 0;
2041
+ this._previousSwap.overlaps = false;
2003
2042
  this._stopScrolling();
2004
2043
  this._viewportScrollSubscription.unsubscribe();
2005
2044
  this._parentPositions.clear();
@@ -2090,9 +2129,11 @@
2090
2129
  }
2091
2130
  if (delta) {
2092
2131
  var direction = isHorizontal ? delta.x : delta.y;
2093
- // If the user is still hovering over the same item as last time, and they didn't change
2094
- // the direction in which they're dragging, we don't consider it a direction swap.
2095
- if (drag === _this._previousSwap.drag && direction === _this._previousSwap.delta) {
2132
+ // If the user is still hovering over the same item as last time, their cursor hasn't left
2133
+ // the item after we made the swap, and they didn't change the direction in which they're
2134
+ // dragging, we don't consider it a direction swap.
2135
+ if (drag === _this._previousSwap.drag && _this._previousSwap.overlaps &&
2136
+ direction === _this._previousSwap.delta) {
2096
2137
  return false;
2097
2138
  }
2098
2139
  }
@@ -2580,126 +2621,46 @@
2580
2621
  * found in the LICENSE file at https://angular.io/license
2581
2622
  */
2582
2623
  /**
2583
- * Injection token that can be used for a `CdkDrag` to provide itself as a parent to the
2584
- * drag-specific child directive (`CdkDragHandle`, `CdkDragPreview` etc.). Used primarily
2585
- * to avoid circular imports.
2586
- * @docs-private
2624
+ * Injection token that can be used to reference instances of `CdkDropListGroup`. It serves as
2625
+ * alternative token to the actual `CdkDropListGroup` class which could cause unnecessary
2626
+ * retention of the class and its directive metadata.
2587
2627
  */
2588
- var CDK_DRAG_PARENT = new i0.InjectionToken('CDK_DRAG_PARENT');
2589
-
2628
+ var CDK_DROP_LIST_GROUP = new i0.InjectionToken('CdkDropListGroup');
2590
2629
  /**
2591
- * @license
2592
- * Copyright Google LLC All Rights Reserved.
2593
- *
2594
- * Use of this source code is governed by an MIT-style license that can be
2595
- * found in the LICENSE file at https://angular.io/license
2630
+ * Declaratively connects sibling `cdkDropList` instances together. All of the `cdkDropList`
2631
+ * elements that are placed inside a `cdkDropListGroup` will be connected to each other
2632
+ * automatically. Can be used as an alternative to the `cdkDropListConnectedTo` input
2633
+ * from `cdkDropList`.
2596
2634
  */
2597
- /** Handle that can be used to drag and CdkDrag instance. */
2598
- var CdkDragHandle = /** @class */ (function () {
2599
- function CdkDragHandle(element, parentDrag) {
2600
- this.element = element;
2601
- /** Emits when the state of the handle has changed. */
2602
- this._stateChanges = new rxjs.Subject();
2635
+ var CdkDropListGroup = /** @class */ (function () {
2636
+ function CdkDropListGroup() {
2637
+ /** Drop lists registered inside the group. */
2638
+ this._items = new Set();
2603
2639
  this._disabled = false;
2604
- this._parentDrag = parentDrag;
2605
- toggleNativeDragInteractions(element.nativeElement, false);
2606
2640
  }
2607
- Object.defineProperty(CdkDragHandle.prototype, "disabled", {
2608
- /** Whether starting to drag through this handle is disabled. */
2641
+ Object.defineProperty(CdkDropListGroup.prototype, "disabled", {
2642
+ /** Whether starting a dragging sequence from inside this group is disabled. */
2609
2643
  get: function () { return this._disabled; },
2610
2644
  set: function (value) {
2611
2645
  this._disabled = coercion.coerceBooleanProperty(value);
2612
- this._stateChanges.next(this);
2613
2646
  },
2614
2647
  enumerable: false,
2615
2648
  configurable: true
2616
2649
  });
2617
- CdkDragHandle.prototype.ngOnDestroy = function () {
2618
- this._stateChanges.complete();
2619
- };
2620
- CdkDragHandle.decorators = [
2621
- { type: i0.Directive, args: [{
2622
- selector: '[cdkDragHandle]',
2623
- host: {
2624
- 'class': 'cdk-drag-handle'
2625
- }
2626
- },] }
2627
- ];
2628
- CdkDragHandle.ctorParameters = function () { return [
2629
- { type: i0.ElementRef },
2630
- { type: undefined, decorators: [{ type: i0.Inject, args: [CDK_DRAG_PARENT,] }, { type: i0.Optional }] }
2631
- ]; };
2632
- CdkDragHandle.propDecorators = {
2633
- disabled: [{ type: i0.Input, args: ['cdkDragHandleDisabled',] }]
2634
- };
2635
- return CdkDragHandle;
2636
- }());
2637
-
2638
- /**
2639
- * @license
2640
- * Copyright Google LLC All Rights Reserved.
2641
- *
2642
- * Use of this source code is governed by an MIT-style license that can be
2643
- * found in the LICENSE file at https://angular.io/license
2644
- */
2645
- /**
2646
- * Element that will be used as a template for the placeholder of a CdkDrag when
2647
- * it is being dragged. The placeholder is displayed in place of the element being dragged.
2648
- */
2649
- var CdkDragPlaceholder = /** @class */ (function () {
2650
- function CdkDragPlaceholder(templateRef) {
2651
- this.templateRef = templateRef;
2652
- }
2653
- CdkDragPlaceholder.decorators = [
2654
- { type: i0.Directive, args: [{
2655
- selector: 'ng-template[cdkDragPlaceholder]'
2656
- },] }
2657
- ];
2658
- CdkDragPlaceholder.ctorParameters = function () { return [
2659
- { type: i0.TemplateRef }
2660
- ]; };
2661
- CdkDragPlaceholder.propDecorators = {
2662
- data: [{ type: i0.Input }]
2650
+ CdkDropListGroup.prototype.ngOnDestroy = function () {
2651
+ this._items.clear();
2663
2652
  };
2664
- return CdkDragPlaceholder;
2665
- }());
2666
-
2667
- /**
2668
- * @license
2669
- * Copyright Google LLC All Rights Reserved.
2670
- *
2671
- * Use of this source code is governed by an MIT-style license that can be
2672
- * found in the LICENSE file at https://angular.io/license
2673
- */
2674
- /**
2675
- * Element that will be used as a template for the preview
2676
- * of a CdkDrag when it is being dragged.
2677
- */
2678
- var CdkDragPreview = /** @class */ (function () {
2679
- function CdkDragPreview(templateRef) {
2680
- this.templateRef = templateRef;
2681
- this._matchSize = false;
2682
- }
2683
- Object.defineProperty(CdkDragPreview.prototype, "matchSize", {
2684
- /** Whether the preview should preserve the same size as the item that is being dragged. */
2685
- get: function () { return this._matchSize; },
2686
- set: function (value) { this._matchSize = coercion.coerceBooleanProperty(value); },
2687
- enumerable: false,
2688
- configurable: true
2689
- });
2690
- CdkDragPreview.decorators = [
2653
+ CdkDropListGroup.decorators = [
2691
2654
  { type: i0.Directive, args: [{
2692
- selector: 'ng-template[cdkDragPreview]'
2655
+ selector: '[cdkDropListGroup]',
2656
+ exportAs: 'cdkDropListGroup',
2657
+ providers: [{ provide: CDK_DROP_LIST_GROUP, useExisting: CdkDropListGroup }],
2693
2658
  },] }
2694
2659
  ];
2695
- CdkDragPreview.ctorParameters = function () { return [
2696
- { type: i0.TemplateRef }
2697
- ]; };
2698
- CdkDragPreview.propDecorators = {
2699
- data: [{ type: i0.Input }],
2700
- matchSize: [{ type: i0.Input }]
2660
+ CdkDropListGroup.propDecorators = {
2661
+ disabled: [{ type: i0.Input, args: ['cdkDropListGroupDisabled',] }]
2701
2662
  };
2702
- return CdkDragPreview;
2663
+ return CdkDropListGroup;
2703
2664
  }());
2704
2665
 
2705
2666
  /**
@@ -2722,264 +2683,205 @@
2722
2683
  * Use of this source code is governed by an MIT-style license that can be
2723
2684
  * found in the LICENSE file at https://angular.io/license
2724
2685
  */
2686
+ /** Counter used to generate unique ids for drop zones. */
2687
+ var _uniqueIdCounter = 0;
2725
2688
  /**
2726
- * Injection token that is used to provide a CdkDropList instance to CdkDrag.
2727
- * Used for avoiding circular imports.
2689
+ * Injection token that can be used to reference instances of `CdkDropList`. It serves as
2690
+ * alternative token to the actual `CdkDropList` class which could cause unnecessary
2691
+ * retention of the class and its directive metadata.
2728
2692
  */
2729
- var CDK_DROP_LIST = new i0.InjectionToken('CDK_DROP_LIST');
2730
- /** Element that can be moved inside a CdkDropList container. */
2731
- var CdkDrag = /** @class */ (function () {
2732
- function CdkDrag(
2733
- /** Element that the draggable is attached to. */
2734
- element,
2735
- /** Droppable container that the draggable is a part of. */
2736
- dropContainer, _document, _ngZone, _viewContainerRef, config, _dir, dragDrop, _changeDetectorRef) {
2693
+ var CDK_DROP_LIST = new i0.InjectionToken('CdkDropList');
2694
+ var ɵ0 = undefined;
2695
+ /** Container that wraps a set of draggable items. */
2696
+ var CdkDropList = /** @class */ (function () {
2697
+ function CdkDropList(
2698
+ /** Element that the drop list is attached to. */
2699
+ element, dragDrop, _changeDetectorRef, _dir, _group,
2700
+ /**
2701
+ * @deprecated _scrollDispatcher parameter to become required.
2702
+ * @breaking-change 11.0.0
2703
+ */
2704
+ _scrollDispatcher, config) {
2737
2705
  var _this = this;
2738
2706
  this.element = element;
2739
- this.dropContainer = dropContainer;
2740
- this._document = _document;
2741
- this._ngZone = _ngZone;
2742
- this._viewContainerRef = _viewContainerRef;
2743
- this._dir = _dir;
2744
2707
  this._changeDetectorRef = _changeDetectorRef;
2708
+ this._dir = _dir;
2709
+ this._group = _group;
2710
+ this._scrollDispatcher = _scrollDispatcher;
2711
+ /** Emits when the list has been destroyed. */
2745
2712
  this._destroyed = new rxjs.Subject();
2746
- /** Emits when the user starts dragging the item. */
2747
- this.started = new i0.EventEmitter();
2748
- /** Emits when the user has released a drag item, before any animations have started. */
2749
- this.released = new i0.EventEmitter();
2750
- /** Emits when the user stops dragging an item in the container. */
2751
- this.ended = new i0.EventEmitter();
2752
- /** Emits when the user has moved the item into a new container. */
2713
+ /**
2714
+ * Other draggable containers that this container is connected to and into which the
2715
+ * container's items can be transferred. Can either be references to other drop containers,
2716
+ * or their unique IDs.
2717
+ */
2718
+ this.connectedTo = [];
2719
+ /**
2720
+ * Unique ID for the drop zone. Can be used as a reference
2721
+ * in the `connectedTo` of another `CdkDropList`.
2722
+ */
2723
+ this.id = "cdk-drop-list-" + _uniqueIdCounter++;
2724
+ /**
2725
+ * Function that is used to determine whether an item
2726
+ * is allowed to be moved into a drop container.
2727
+ */
2728
+ this.enterPredicate = function () { return true; };
2729
+ /** Emits when the user drops an item inside the container. */
2730
+ this.dropped = new i0.EventEmitter();
2731
+ /**
2732
+ * Emits when the user has moved a new drag item into this container.
2733
+ */
2753
2734
  this.entered = new i0.EventEmitter();
2754
- /** Emits when the user removes the item its container by dragging it into another container. */
2735
+ /**
2736
+ * Emits when the user removes an item from the container
2737
+ * by dragging it into another container.
2738
+ */
2755
2739
  this.exited = new i0.EventEmitter();
2756
- /** Emits when the user drops the item inside a container. */
2757
- this.dropped = new i0.EventEmitter();
2740
+ /** Emits as the user is swapping items while actively dragging. */
2741
+ this.sorted = new i0.EventEmitter();
2758
2742
  /**
2759
- * Emits as the user is dragging the item. Use with caution,
2760
- * because this event will fire for every pixel that the user has dragged.
2743
+ * Keeps track of the items that are registered with this container. Historically we used to
2744
+ * do this with a `ContentChildren` query, however queries don't handle transplanted views very
2745
+ * well which means that we can't handle cases like dragging the headers of a `mat-table`
2746
+ * correctly. What we do instead is to have the items register themselves with the container
2747
+ * and then we sort them based on their position in the DOM.
2761
2748
  */
2762
- this.moved = new rxjs.Observable(function (observer) {
2763
- var subscription = _this._dragRef.moved.pipe(operators.map(function (movedEvent) { return ({
2764
- source: _this,
2765
- pointerPosition: movedEvent.pointerPosition,
2766
- event: movedEvent.event,
2767
- delta: movedEvent.delta,
2768
- distance: movedEvent.distance
2769
- }); })).subscribe(observer);
2770
- return function () {
2771
- subscription.unsubscribe();
2772
- };
2773
- });
2774
- this._dragRef = dragDrop.createDrag(element, {
2775
- dragStartThreshold: config && config.dragStartThreshold != null ?
2776
- config.dragStartThreshold : 5,
2777
- pointerDirectionChangeThreshold: config && config.pointerDirectionChangeThreshold != null ?
2778
- config.pointerDirectionChangeThreshold : 5,
2779
- zIndex: config === null || config === void 0 ? void 0 : config.zIndex
2780
- });
2781
- this._dragRef.data = this;
2749
+ this._unsortedItems = new Set();
2750
+ this._dropListRef = dragDrop.createDropList(element);
2751
+ this._dropListRef.data = this;
2782
2752
  if (config) {
2783
2753
  this._assignDefaults(config);
2784
2754
  }
2785
- // Note that usually the container is assigned when the drop list is picks up the item, but in
2786
- // some cases (mainly transplanted views with OnPush, see #18341) we may end up in a situation
2787
- // where there are no items on the first change detection pass, but the items get picked up as
2788
- // soon as the user triggers another pass by dragging. This is a problem, because the item would
2789
- // have to switch from standalone mode to drag mode in the middle of the dragging sequence which
2790
- // is too late since the two modes save different kinds of information. We work around it by
2791
- // assigning the drop container both from here and the list.
2792
- if (dropContainer) {
2793
- this._dragRef._withDropContainer(dropContainer._dropListRef);
2794
- dropContainer.addItem(this);
2755
+ this._dropListRef.enterPredicate = function (drag, drop) {
2756
+ return _this.enterPredicate(drag.data, drop.data);
2757
+ };
2758
+ this._setupInputSyncSubscription(this._dropListRef);
2759
+ this._handleEvents(this._dropListRef);
2760
+ CdkDropList._dropLists.push(this);
2761
+ if (_group) {
2762
+ _group._items.add(this);
2795
2763
  }
2796
- this._syncInputs(this._dragRef);
2797
- this._handleEvents(this._dragRef);
2798
2764
  }
2799
- Object.defineProperty(CdkDrag.prototype, "disabled", {
2800
- /** Whether starting to drag this element is disabled. */
2765
+ Object.defineProperty(CdkDropList.prototype, "disabled", {
2766
+ /** Whether starting a dragging sequence from this container is disabled. */
2801
2767
  get: function () {
2802
- return this._disabled || (this.dropContainer && this.dropContainer.disabled);
2768
+ return this._disabled || (!!this._group && this._group.disabled);
2803
2769
  },
2804
2770
  set: function (value) {
2805
- this._disabled = coercion.coerceBooleanProperty(value);
2806
- this._dragRef.disabled = this._disabled;
2807
- },
2808
- enumerable: false,
2809
- configurable: true
2771
+ // Usually we sync the directive and ref state right before dragging starts, in order to have
2772
+ // a single point of failure and to avoid having to use setters for everything. `disabled` is
2773
+ // a special case, because it can prevent the `beforeStarted` event from firing, which can lock
2774
+ // the user in a disabled state, so we also need to sync it as it's being set.
2775
+ this._dropListRef.disabled = this._disabled = coercion.coerceBooleanProperty(value);
2776
+ },
2777
+ enumerable: false,
2778
+ configurable: true
2810
2779
  });
2811
- /**
2812
- * Returns the element that is being used as a placeholder
2813
- * while the current element is being dragged.
2814
- * @deprecated No longer being used to be removed.
2815
- * @breaking-change 11.0.0
2816
- */
2817
- CdkDrag.prototype.getPlaceholderElement = function () {
2818
- return this._dragRef.getPlaceholderElement();
2819
- };
2820
- /**
2821
- * Returns the root draggable element.
2822
- * @deprecated No longer being used to be removed.
2823
- * @breaking-change 11.0.0
2824
- */
2825
- CdkDrag.prototype.getRootElement = function () {
2826
- return this._dragRef.getRootElement();
2827
- };
2828
- /** Resets a standalone drag item to its initial position. */
2829
- CdkDrag.prototype.reset = function () {
2830
- this._dragRef.reset();
2780
+ /** Registers an items with the drop list. */
2781
+ CdkDropList.prototype.addItem = function (item) {
2782
+ this._unsortedItems.add(item);
2783
+ if (this._dropListRef.isDragging()) {
2784
+ this._syncItemsWithRef();
2785
+ }
2831
2786
  };
2832
- /**
2833
- * Gets the pixel coordinates of the draggable outside of a drop container.
2834
- */
2835
- CdkDrag.prototype.getFreeDragPosition = function () {
2836
- return this._dragRef.getFreeDragPosition();
2787
+ /** Removes an item from the drop list. */
2788
+ CdkDropList.prototype.removeItem = function (item) {
2789
+ this._unsortedItems.delete(item);
2790
+ if (this._dropListRef.isDragging()) {
2791
+ this._syncItemsWithRef();
2792
+ }
2837
2793
  };
2838
- CdkDrag.prototype.ngAfterViewInit = function () {
2839
- var _this = this;
2840
- // We need to wait for the zone to stabilize, in order for the reference
2841
- // element to be in the proper place in the DOM. This is mostly relevant
2842
- // for draggable elements inside portals since they get stamped out in
2843
- // their original DOM position and then they get transferred to the portal.
2844
- this._ngZone.onStable.asObservable()
2845
- .pipe(operators.take(1), operators.takeUntil(this._destroyed))
2846
- .subscribe(function () {
2847
- _this._updateRootElement();
2848
- // Listen for any newly-added handles.
2849
- _this._handles.changes.pipe(operators.startWith(_this._handles),
2850
- // Sync the new handles with the DragRef.
2851
- operators.tap(function (handles) {
2852
- var childHandleElements = handles
2853
- .filter(function (handle) { return handle._parentDrag === _this; })
2854
- .map(function (handle) { return handle.element; });
2855
- _this._dragRef.withHandles(childHandleElements);
2856
- }),
2857
- // Listen if the state of any of the handles changes.
2858
- operators.switchMap(function (handles) {
2859
- return rxjs.merge.apply(void 0, __spread(handles.map(function (item) {
2860
- return item._stateChanges.pipe(operators.startWith(item));
2861
- })));
2862
- }), operators.takeUntil(_this._destroyed)).subscribe(function (handleInstance) {
2863
- // Enabled/disable the handle that changed in the DragRef.
2864
- var dragRef = _this._dragRef;
2865
- var handle = handleInstance.element.nativeElement;
2866
- handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
2867
- });
2868
- if (_this.freeDragPosition) {
2869
- _this._dragRef.setFreeDragPosition(_this.freeDragPosition);
2870
- }
2794
+ /** Gets the registered items in the list, sorted by their position in the DOM. */
2795
+ CdkDropList.prototype.getSortedItems = function () {
2796
+ return Array.from(this._unsortedItems).sort(function (a, b) {
2797
+ var documentPosition = a._dragRef.getVisibleElement().compareDocumentPosition(b._dragRef.getVisibleElement());
2798
+ // `compareDocumentPosition` returns a bitmask so we have to use a bitwise operator.
2799
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
2800
+ // tslint:disable-next-line:no-bitwise
2801
+ return documentPosition & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
2871
2802
  });
2872
2803
  };
2873
- CdkDrag.prototype.ngOnChanges = function (changes) {
2874
- var rootSelectorChange = changes['rootElementSelector'];
2875
- var positionChange = changes['freeDragPosition'];
2876
- // We don't have to react to the first change since it's being
2877
- // handled in `ngAfterViewInit` where it needs to be deferred.
2878
- if (rootSelectorChange && !rootSelectorChange.firstChange) {
2879
- this._updateRootElement();
2880
- }
2881
- // Skip the first change since it's being handled in `ngAfterViewInit`.
2882
- if (positionChange && !positionChange.firstChange && this.freeDragPosition) {
2883
- this._dragRef.setFreeDragPosition(this.freeDragPosition);
2804
+ CdkDropList.prototype.ngOnDestroy = function () {
2805
+ var index = CdkDropList._dropLists.indexOf(this);
2806
+ if (index > -1) {
2807
+ CdkDropList._dropLists.splice(index, 1);
2884
2808
  }
2885
- };
2886
- CdkDrag.prototype.ngOnDestroy = function () {
2887
- if (this.dropContainer) {
2888
- this.dropContainer.removeItem(this);
2809
+ if (this._group) {
2810
+ this._group._items.delete(this);
2889
2811
  }
2812
+ this._unsortedItems.clear();
2813
+ this._dropListRef.dispose();
2890
2814
  this._destroyed.next();
2891
2815
  this._destroyed.complete();
2892
- this._dragRef.dispose();
2893
- };
2894
- /** Syncs the root element with the `DragRef`. */
2895
- CdkDrag.prototype._updateRootElement = function () {
2896
- var element = this.element.nativeElement;
2897
- var rootElement = this.rootElementSelector ?
2898
- getClosestMatchingAncestor(element, this.rootElementSelector) : element;
2899
- if (rootElement && rootElement.nodeType !== this._document.ELEMENT_NODE) {
2900
- throw Error("cdkDrag must be attached to an element node. " +
2901
- ("Currently attached to \"" + rootElement.nodeName + "\"."));
2902
- }
2903
- this._dragRef.withRootElement(rootElement || element);
2904
2816
  };
2905
- /** Gets the boundary element, based on the `boundaryElement` value. */
2906
- CdkDrag.prototype._getBoundaryElement = function () {
2907
- var boundary = this.boundaryElement;
2908
- if (!boundary) {
2909
- return null;
2910
- }
2911
- if (typeof boundary === 'string') {
2912
- return getClosestMatchingAncestor(this.element.nativeElement, boundary);
2913
- }
2914
- var element = coercion.coerceElement(boundary);
2915
- if (i0.isDevMode() && !element.contains(this.element.nativeElement)) {
2916
- throw Error('Draggable element is not inside of the node passed into cdkDragBoundary.');
2917
- }
2918
- return element;
2919
- };
2920
- /** Syncs the inputs of the CdkDrag with the options of the underlying DragRef. */
2921
- CdkDrag.prototype._syncInputs = function (ref) {
2817
+ /** Syncs the inputs of the CdkDropList with the options of the underlying DropListRef. */
2818
+ CdkDropList.prototype._setupInputSyncSubscription = function (ref) {
2922
2819
  var _this = this;
2820
+ if (this._dir) {
2821
+ this._dir.change
2822
+ .pipe(operators.startWith(this._dir.value), operators.takeUntil(this._destroyed))
2823
+ .subscribe(function (value) { return ref.withDirection(value); });
2824
+ }
2923
2825
  ref.beforeStarted.subscribe(function () {
2924
- if (!ref.isDragging()) {
2925
- var dir = _this._dir;
2926
- var dragStartDelay = _this.dragStartDelay;
2927
- var placeholder = _this._placeholderTemplate ? {
2928
- template: _this._placeholderTemplate.templateRef,
2929
- context: _this._placeholderTemplate.data,
2930
- viewContainer: _this._viewContainerRef
2931
- } : null;
2932
- var preview = _this._previewTemplate ? {
2933
- template: _this._previewTemplate.templateRef,
2934
- context: _this._previewTemplate.data,
2935
- matchSize: _this._previewTemplate.matchSize,
2936
- viewContainer: _this._viewContainerRef
2937
- } : null;
2938
- ref.disabled = _this.disabled;
2939
- ref.lockAxis = _this.lockAxis;
2940
- ref.dragStartDelay = (typeof dragStartDelay === 'object' && dragStartDelay) ?
2941
- dragStartDelay : coercion.coerceNumberProperty(dragStartDelay);
2942
- ref.constrainPosition = _this.constrainPosition;
2943
- ref.previewClass = _this.previewClass;
2944
- ref
2945
- .withBoundaryElement(_this._getBoundaryElement())
2946
- .withPlaceholderTemplate(placeholder)
2947
- .withPreviewTemplate(preview);
2948
- if (dir) {
2949
- ref.withDirection(dir.value);
2950
- }
2826
+ var siblings = coercion.coerceArray(_this.connectedTo).map(function (drop) {
2827
+ return typeof drop === 'string' ?
2828
+ CdkDropList._dropLists.find(function (list) { return list.id === drop; }) : drop;
2829
+ });
2830
+ if (_this._group) {
2831
+ _this._group._items.forEach(function (drop) {
2832
+ if (siblings.indexOf(drop) === -1) {
2833
+ siblings.push(drop);
2834
+ }
2835
+ });
2836
+ }
2837
+ // Note that we resolve the scrollable parents here so that we delay the resolution
2838
+ // as long as possible, ensuring that the element is in its final place in the DOM.
2839
+ // @breaking-change 11.0.0 Remove null check for _scrollDispatcher once it's required.
2840
+ if (!_this._scrollableParentsResolved && _this._scrollDispatcher) {
2841
+ var scrollableParents = _this._scrollDispatcher
2842
+ .getAncestorScrollContainers(_this.element)
2843
+ .map(function (scrollable) { return scrollable.getElementRef().nativeElement; });
2844
+ _this._dropListRef.withScrollableParents(scrollableParents);
2845
+ // Only do this once since it involves traversing the DOM and the parents
2846
+ // shouldn't be able to change without the drop list being destroyed.
2847
+ _this._scrollableParentsResolved = true;
2951
2848
  }
2849
+ ref.disabled = _this.disabled;
2850
+ ref.lockAxis = _this.lockAxis;
2851
+ ref.sortingDisabled = coercion.coerceBooleanProperty(_this.sortingDisabled);
2852
+ ref.autoScrollDisabled = coercion.coerceBooleanProperty(_this.autoScrollDisabled);
2853
+ ref
2854
+ .connectedTo(siblings.filter(function (drop) { return drop && drop !== _this; }).map(function (list) { return list._dropListRef; }))
2855
+ .withOrientation(_this.orientation);
2952
2856
  });
2953
2857
  };
2954
- /** Handles the events from the underlying `DragRef`. */
2955
- CdkDrag.prototype._handleEvents = function (ref) {
2858
+ /** Handles events from the underlying DropListRef. */
2859
+ CdkDropList.prototype._handleEvents = function (ref) {
2956
2860
  var _this = this;
2957
- ref.started.subscribe(function () {
2958
- _this.started.emit({ source: _this });
2959
- // Since all of these events run outside of change detection,
2960
- // we need to ensure that everything is marked correctly.
2961
- _this._changeDetectorRef.markForCheck();
2962
- });
2963
- ref.released.subscribe(function () {
2964
- _this.released.emit({ source: _this });
2965
- });
2966
- ref.ended.subscribe(function (event) {
2967
- _this.ended.emit({ source: _this, distance: event.distance });
2968
- // Since all of these events run outside of change detection,
2969
- // we need to ensure that everything is marked correctly.
2861
+ ref.beforeStarted.subscribe(function () {
2862
+ _this._syncItemsWithRef();
2970
2863
  _this._changeDetectorRef.markForCheck();
2971
2864
  });
2972
2865
  ref.entered.subscribe(function (event) {
2973
2866
  _this.entered.emit({
2974
- container: event.container.data,
2975
- item: _this,
2867
+ container: _this,
2868
+ item: event.item.data,
2976
2869
  currentIndex: event.currentIndex
2977
2870
  });
2978
2871
  });
2979
2872
  ref.exited.subscribe(function (event) {
2980
2873
  _this.exited.emit({
2981
- container: event.container.data,
2982
- item: _this
2874
+ container: _this,
2875
+ item: event.item.data
2876
+ });
2877
+ _this._changeDetectorRef.markForCheck();
2878
+ });
2879
+ ref.sorted.subscribe(function (event) {
2880
+ _this.sorted.emit({
2881
+ previousIndex: event.previousIndex,
2882
+ currentIndex: event.currentIndex,
2883
+ container: _this,
2884
+ item: event.item.data
2983
2885
  });
2984
2886
  });
2985
2887
  ref.dropped.subscribe(function (event) {
@@ -2988,92 +2890,182 @@
2988
2890
  currentIndex: event.currentIndex,
2989
2891
  previousContainer: event.previousContainer.data,
2990
2892
  container: event.container.data,
2893
+ item: event.item.data,
2991
2894
  isPointerOverContainer: event.isPointerOverContainer,
2992
- item: _this,
2993
2895
  distance: event.distance
2994
2896
  });
2897
+ // Mark for check since all of these events run outside of change
2898
+ // detection and we're not guaranteed for something else to have triggered it.
2899
+ _this._changeDetectorRef.markForCheck();
2995
2900
  });
2996
2901
  };
2997
2902
  /** Assigns the default input values based on a provided config object. */
2998
- CdkDrag.prototype._assignDefaults = function (config) {
2999
- var lockAxis = config.lockAxis, dragStartDelay = config.dragStartDelay, constrainPosition = config.constrainPosition, previewClass = config.previewClass, boundaryElement = config.boundaryElement, draggingDisabled = config.draggingDisabled, rootElementSelector = config.rootElementSelector;
2903
+ CdkDropList.prototype._assignDefaults = function (config) {
2904
+ var lockAxis = config.lockAxis, draggingDisabled = config.draggingDisabled, sortingDisabled = config.sortingDisabled, listAutoScrollDisabled = config.listAutoScrollDisabled, listOrientation = config.listOrientation;
3000
2905
  this.disabled = draggingDisabled == null ? false : draggingDisabled;
3001
- this.dragStartDelay = dragStartDelay || 0;
2906
+ this.sortingDisabled = sortingDisabled == null ? false : sortingDisabled;
2907
+ this.autoScrollDisabled = listAutoScrollDisabled == null ? false : listAutoScrollDisabled;
2908
+ this.orientation = listOrientation || 'vertical';
3002
2909
  if (lockAxis) {
3003
2910
  this.lockAxis = lockAxis;
3004
2911
  }
3005
- if (constrainPosition) {
3006
- this.constrainPosition = constrainPosition;
3007
- }
3008
- if (previewClass) {
3009
- this.previewClass = previewClass;
3010
- }
3011
- if (boundaryElement) {
3012
- this.boundaryElement = boundaryElement;
3013
- }
3014
- if (rootElementSelector) {
3015
- this.rootElementSelector = rootElementSelector;
3016
- }
3017
2912
  };
3018
- CdkDrag.decorators = [
2913
+ /** Syncs up the registered drag items with underlying drop list ref. */
2914
+ CdkDropList.prototype._syncItemsWithRef = function () {
2915
+ this._dropListRef.withItems(this.getSortedItems().map(function (item) { return item._dragRef; }));
2916
+ };
2917
+ /** Keeps track of the drop lists that are currently on the page. */
2918
+ CdkDropList._dropLists = [];
2919
+ CdkDropList.decorators = [
3019
2920
  { type: i0.Directive, args: [{
3020
- selector: '[cdkDrag]',
3021
- exportAs: 'cdkDrag',
2921
+ selector: '[cdkDropList], cdk-drop-list',
2922
+ exportAs: 'cdkDropList',
2923
+ providers: [
2924
+ // Prevent child drop lists from picking up the same group as their parent.
2925
+ { provide: CDK_DROP_LIST_GROUP, useValue: ɵ0 },
2926
+ { provide: CDK_DROP_LIST, useExisting: CdkDropList },
2927
+ ],
3022
2928
  host: {
3023
- 'class': 'cdk-drag',
3024
- '[class.cdk-drag-disabled]': 'disabled',
3025
- '[class.cdk-drag-dragging]': '_dragRef.isDragging()',
3026
- },
3027
- providers: [{ provide: CDK_DRAG_PARENT, useExisting: CdkDrag }]
2929
+ 'class': 'cdk-drop-list',
2930
+ '[id]': 'id',
2931
+ '[class.cdk-drop-list-disabled]': 'disabled',
2932
+ '[class.cdk-drop-list-dragging]': '_dropListRef.isDragging()',
2933
+ '[class.cdk-drop-list-receiving]': '_dropListRef.isReceiving()',
2934
+ }
3028
2935
  },] }
3029
2936
  ];
3030
- CdkDrag.ctorParameters = function () { return [
2937
+ CdkDropList.ctorParameters = function () { return [
3031
2938
  { type: i0.ElementRef },
3032
- { type: undefined, decorators: [{ type: i0.Inject, args: [CDK_DROP_LIST,] }, { type: i0.Optional }, { type: i0.SkipSelf }] },
3033
- { type: undefined, decorators: [{ type: i0.Inject, args: [i1.DOCUMENT,] }] },
3034
- { type: i0.NgZone },
3035
- { type: i0.ViewContainerRef },
3036
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [CDK_DRAG_CONFIG,] }] },
3037
- { type: bidi.Directionality, decorators: [{ type: i0.Optional }] },
3038
2939
  { type: DragDrop },
3039
- { type: i0.ChangeDetectorRef }
2940
+ { type: i0.ChangeDetectorRef },
2941
+ { type: bidi.Directionality, decorators: [{ type: i0.Optional }] },
2942
+ { type: CdkDropListGroup, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [CDK_DROP_LIST_GROUP,] }, { type: i0.SkipSelf }] },
2943
+ { type: i2.ScrollDispatcher },
2944
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [CDK_DRAG_CONFIG,] }] }
3040
2945
  ]; };
3041
- CdkDrag.propDecorators = {
3042
- _handles: [{ type: i0.ContentChildren, args: [CdkDragHandle, { descendants: true },] }],
3043
- _previewTemplate: [{ type: i0.ContentChild, args: [CdkDragPreview,] }],
3044
- _placeholderTemplate: [{ type: i0.ContentChild, args: [CdkDragPlaceholder,] }],
3045
- data: [{ type: i0.Input, args: ['cdkDragData',] }],
3046
- lockAxis: [{ type: i0.Input, args: ['cdkDragLockAxis',] }],
3047
- rootElementSelector: [{ type: i0.Input, args: ['cdkDragRootElement',] }],
3048
- boundaryElement: [{ type: i0.Input, args: ['cdkDragBoundary',] }],
3049
- dragStartDelay: [{ type: i0.Input, args: ['cdkDragStartDelay',] }],
3050
- freeDragPosition: [{ type: i0.Input, args: ['cdkDragFreeDragPosition',] }],
3051
- disabled: [{ type: i0.Input, args: ['cdkDragDisabled',] }],
3052
- constrainPosition: [{ type: i0.Input, args: ['cdkDragConstrainPosition',] }],
3053
- previewClass: [{ type: i0.Input, args: ['cdkDragPreviewClass',] }],
3054
- started: [{ type: i0.Output, args: ['cdkDragStarted',] }],
3055
- released: [{ type: i0.Output, args: ['cdkDragReleased',] }],
3056
- ended: [{ type: i0.Output, args: ['cdkDragEnded',] }],
3057
- entered: [{ type: i0.Output, args: ['cdkDragEntered',] }],
3058
- exited: [{ type: i0.Output, args: ['cdkDragExited',] }],
3059
- dropped: [{ type: i0.Output, args: ['cdkDragDropped',] }],
3060
- moved: [{ type: i0.Output, args: ['cdkDragMoved',] }]
2946
+ CdkDropList.propDecorators = {
2947
+ connectedTo: [{ type: i0.Input, args: ['cdkDropListConnectedTo',] }],
2948
+ data: [{ type: i0.Input, args: ['cdkDropListData',] }],
2949
+ orientation: [{ type: i0.Input, args: ['cdkDropListOrientation',] }],
2950
+ id: [{ type: i0.Input }],
2951
+ lockAxis: [{ type: i0.Input, args: ['cdkDropListLockAxis',] }],
2952
+ disabled: [{ type: i0.Input, args: ['cdkDropListDisabled',] }],
2953
+ sortingDisabled: [{ type: i0.Input, args: ['cdkDropListSortingDisabled',] }],
2954
+ enterPredicate: [{ type: i0.Input, args: ['cdkDropListEnterPredicate',] }],
2955
+ autoScrollDisabled: [{ type: i0.Input, args: ['cdkDropListAutoScrollDisabled',] }],
2956
+ dropped: [{ type: i0.Output, args: ['cdkDropListDropped',] }],
2957
+ entered: [{ type: i0.Output, args: ['cdkDropListEntered',] }],
2958
+ exited: [{ type: i0.Output, args: ['cdkDropListExited',] }],
2959
+ sorted: [{ type: i0.Output, args: ['cdkDropListSorted',] }]
3061
2960
  };
3062
- return CdkDrag;
2961
+ return CdkDropList;
3063
2962
  }());
3064
- /** Gets the closest ancestor of an element that matches a selector. */
3065
- function getClosestMatchingAncestor(element, selector) {
3066
- var currentElement = element.parentElement;
3067
- while (currentElement) {
3068
- // IE doesn't support `matches` so we have to fall back to `msMatchesSelector`.
3069
- if (currentElement.matches ? currentElement.matches(selector) :
3070
- currentElement.msMatchesSelector(selector)) {
3071
- return currentElement;
3072
- }
3073
- currentElement = currentElement.parentElement;
2963
+
2964
+ /**
2965
+ * @license
2966
+ * Copyright Google LLC All Rights Reserved.
2967
+ *
2968
+ * Use of this source code is governed by an MIT-style license that can be
2969
+ * found in the LICENSE file at https://angular.io/license
2970
+ */
2971
+ /**
2972
+ * Injection token that can be used for a `CdkDrag` to provide itself as a parent to the
2973
+ * drag-specific child directive (`CdkDragHandle`, `CdkDragPreview` etc.). Used primarily
2974
+ * to avoid circular imports.
2975
+ * @docs-private
2976
+ */
2977
+ var CDK_DRAG_PARENT = new i0.InjectionToken('CDK_DRAG_PARENT');
2978
+
2979
+ /**
2980
+ * @license
2981
+ * Copyright Google LLC All Rights Reserved.
2982
+ *
2983
+ * Use of this source code is governed by an MIT-style license that can be
2984
+ * found in the LICENSE file at https://angular.io/license
2985
+ */
2986
+ /**
2987
+ * Injection token that can be used to reference instances of `CdkDragHandle`. It serves as
2988
+ * alternative token to the actual `CdkDragHandle` class which could cause unnecessary
2989
+ * retention of the class and its directive metadata.
2990
+ */
2991
+ var CDK_DRAG_HANDLE = new i0.InjectionToken('CdkDragHandle');
2992
+ /** Handle that can be used to drag and CdkDrag instance. */
2993
+ var CdkDragHandle = /** @class */ (function () {
2994
+ function CdkDragHandle(element, parentDrag) {
2995
+ this.element = element;
2996
+ /** Emits when the state of the handle has changed. */
2997
+ this._stateChanges = new rxjs.Subject();
2998
+ this._disabled = false;
2999
+ this._parentDrag = parentDrag;
3000
+ toggleNativeDragInteractions(element.nativeElement, false);
3074
3001
  }
3075
- return null;
3076
- }
3002
+ Object.defineProperty(CdkDragHandle.prototype, "disabled", {
3003
+ /** Whether starting to drag through this handle is disabled. */
3004
+ get: function () { return this._disabled; },
3005
+ set: function (value) {
3006
+ this._disabled = coercion.coerceBooleanProperty(value);
3007
+ this._stateChanges.next(this);
3008
+ },
3009
+ enumerable: false,
3010
+ configurable: true
3011
+ });
3012
+ CdkDragHandle.prototype.ngOnDestroy = function () {
3013
+ this._stateChanges.complete();
3014
+ };
3015
+ CdkDragHandle.decorators = [
3016
+ { type: i0.Directive, args: [{
3017
+ selector: '[cdkDragHandle]',
3018
+ host: {
3019
+ 'class': 'cdk-drag-handle'
3020
+ },
3021
+ providers: [{ provide: CDK_DRAG_HANDLE, useExisting: CdkDragHandle }],
3022
+ },] }
3023
+ ];
3024
+ CdkDragHandle.ctorParameters = function () { return [
3025
+ { type: i0.ElementRef },
3026
+ { type: undefined, decorators: [{ type: i0.Inject, args: [CDK_DRAG_PARENT,] }, { type: i0.Optional }, { type: i0.SkipSelf }] }
3027
+ ]; };
3028
+ CdkDragHandle.propDecorators = {
3029
+ disabled: [{ type: i0.Input, args: ['cdkDragHandleDisabled',] }]
3030
+ };
3031
+ return CdkDragHandle;
3032
+ }());
3033
+
3034
+ /**
3035
+ * @license
3036
+ * Copyright Google LLC All Rights Reserved.
3037
+ *
3038
+ * Use of this source code is governed by an MIT-style license that can be
3039
+ * found in the LICENSE file at https://angular.io/license
3040
+ */
3041
+ /**
3042
+ * Injection token that can be used to reference instances of `CdkDragPlaceholder`. It serves as
3043
+ * alternative token to the actual `CdkDragPlaceholder` class which could cause unnecessary
3044
+ * retention of the class and its directive metadata.
3045
+ */
3046
+ var CDK_DRAG_PLACEHOLDER = new i0.InjectionToken('CdkDragPlaceholder');
3047
+ /**
3048
+ * Element that will be used as a template for the placeholder of a CdkDrag when
3049
+ * it is being dragged. The placeholder is displayed in place of the element being dragged.
3050
+ */
3051
+ var CdkDragPlaceholder = /** @class */ (function () {
3052
+ function CdkDragPlaceholder(templateRef) {
3053
+ this.templateRef = templateRef;
3054
+ }
3055
+ CdkDragPlaceholder.decorators = [
3056
+ { type: i0.Directive, args: [{
3057
+ selector: 'ng-template[cdkDragPlaceholder]',
3058
+ providers: [{ provide: CDK_DRAG_PLACEHOLDER, useExisting: CdkDragPlaceholder }],
3059
+ },] }
3060
+ ];
3061
+ CdkDragPlaceholder.ctorParameters = function () { return [
3062
+ { type: i0.TemplateRef }
3063
+ ]; };
3064
+ CdkDragPlaceholder.propDecorators = {
3065
+ data: [{ type: i0.Input }]
3066
+ };
3067
+ return CdkDragPlaceholder;
3068
+ }());
3077
3069
 
3078
3070
  /**
3079
3071
  * @license
@@ -3083,39 +3075,41 @@
3083
3075
  * found in the LICENSE file at https://angular.io/license
3084
3076
  */
3085
3077
  /**
3086
- * Declaratively connects sibling `cdkDropList` instances together. All of the `cdkDropList`
3087
- * elements that are placed inside a `cdkDropListGroup` will be connected to each other
3088
- * automatically. Can be used as an alternative to the `cdkDropListConnectedTo` input
3089
- * from `cdkDropList`.
3078
+ * Injection token that can be used to reference instances of `CdkDragPreview`. It serves as
3079
+ * alternative token to the actual `CdkDragPreview` class which could cause unnecessary
3080
+ * retention of the class and its directive metadata.
3090
3081
  */
3091
- var CdkDropListGroup = /** @class */ (function () {
3092
- function CdkDropListGroup() {
3093
- /** Drop lists registered inside the group. */
3094
- this._items = new Set();
3095
- this._disabled = false;
3082
+ var CDK_DRAG_PREVIEW = new i0.InjectionToken('CdkDragPreview');
3083
+ /**
3084
+ * Element that will be used as a template for the preview
3085
+ * of a CdkDrag when it is being dragged.
3086
+ */
3087
+ var CdkDragPreview = /** @class */ (function () {
3088
+ function CdkDragPreview(templateRef) {
3089
+ this.templateRef = templateRef;
3090
+ this._matchSize = false;
3096
3091
  }
3097
- Object.defineProperty(CdkDropListGroup.prototype, "disabled", {
3098
- /** Whether starting a dragging sequence from inside this group is disabled. */
3099
- get: function () { return this._disabled; },
3100
- set: function (value) {
3101
- this._disabled = coercion.coerceBooleanProperty(value);
3102
- },
3092
+ Object.defineProperty(CdkDragPreview.prototype, "matchSize", {
3093
+ /** Whether the preview should preserve the same size as the item that is being dragged. */
3094
+ get: function () { return this._matchSize; },
3095
+ set: function (value) { this._matchSize = coercion.coerceBooleanProperty(value); },
3103
3096
  enumerable: false,
3104
3097
  configurable: true
3105
3098
  });
3106
- CdkDropListGroup.prototype.ngOnDestroy = function () {
3107
- this._items.clear();
3108
- };
3109
- CdkDropListGroup.decorators = [
3099
+ CdkDragPreview.decorators = [
3110
3100
  { type: i0.Directive, args: [{
3111
- selector: '[cdkDropListGroup]',
3112
- exportAs: 'cdkDropListGroup',
3101
+ selector: 'ng-template[cdkDragPreview]',
3102
+ providers: [{ provide: CDK_DRAG_PREVIEW, useExisting: CdkDragPreview }],
3113
3103
  },] }
3114
3104
  ];
3115
- CdkDropListGroup.propDecorators = {
3116
- disabled: [{ type: i0.Input, args: ['cdkDropListGroupDisabled',] }]
3105
+ CdkDragPreview.ctorParameters = function () { return [
3106
+ { type: i0.TemplateRef }
3107
+ ]; };
3108
+ CdkDragPreview.propDecorators = {
3109
+ data: [{ type: i0.Input }],
3110
+ matchSize: [{ type: i0.Input }]
3117
3111
  };
3118
- return CdkDropListGroup;
3112
+ return CdkDragPreview;
3119
3113
  }());
3120
3114
 
3121
3115
  /**
@@ -3125,199 +3119,260 @@
3125
3119
  * Use of this source code is governed by an MIT-style license that can be
3126
3120
  * found in the LICENSE file at https://angular.io/license
3127
3121
  */
3128
- /** Counter used to generate unique ids for drop zones. */
3129
- var _uniqueIdCounter = 0;
3130
- var ɵ0 = undefined;
3131
- /** Container that wraps a set of draggable items. */
3132
- var CdkDropList = /** @class */ (function () {
3133
- function CdkDropList(
3134
- /** Element that the drop list is attached to. */
3135
- element, dragDrop, _changeDetectorRef, _dir, _group,
3136
- /**
3137
- * @deprecated _scrollDispatcher parameter to become required.
3138
- * @breaking-change 11.0.0
3139
- */
3140
- _scrollDispatcher, config) {
3122
+ /** Element that can be moved inside a CdkDropList container. */
3123
+ var CdkDrag = /** @class */ (function () {
3124
+ function CdkDrag(
3125
+ /** Element that the draggable is attached to. */
3126
+ element,
3127
+ /** Droppable container that the draggable is a part of. */
3128
+ dropContainer, _document, _ngZone, _viewContainerRef, config, _dir, dragDrop, _changeDetectorRef, _selfHandle) {
3141
3129
  var _this = this;
3142
3130
  this.element = element;
3143
- this._changeDetectorRef = _changeDetectorRef;
3131
+ this.dropContainer = dropContainer;
3132
+ this._document = _document;
3133
+ this._ngZone = _ngZone;
3134
+ this._viewContainerRef = _viewContainerRef;
3144
3135
  this._dir = _dir;
3145
- this._group = _group;
3146
- this._scrollDispatcher = _scrollDispatcher;
3147
- /** Emits when the list has been destroyed. */
3136
+ this._changeDetectorRef = _changeDetectorRef;
3137
+ this._selfHandle = _selfHandle;
3148
3138
  this._destroyed = new rxjs.Subject();
3149
- /**
3150
- * Other draggable containers that this container is connected to and into which the
3151
- * container's items can be transferred. Can either be references to other drop containers,
3152
- * or their unique IDs.
3153
- */
3154
- this.connectedTo = [];
3155
- /**
3156
- * Unique ID for the drop zone. Can be used as a reference
3157
- * in the `connectedTo` of another `CdkDropList`.
3158
- */
3159
- this.id = "cdk-drop-list-" + _uniqueIdCounter++;
3160
- /**
3161
- * Function that is used to determine whether an item
3162
- * is allowed to be moved into a drop container.
3163
- */
3164
- this.enterPredicate = function () { return true; };
3165
- /** Emits when the user drops an item inside the container. */
3166
- this.dropped = new i0.EventEmitter();
3167
- /**
3168
- * Emits when the user has moved a new drag item into this container.
3169
- */
3139
+ /** Emits when the user starts dragging the item. */
3140
+ this.started = new i0.EventEmitter();
3141
+ /** Emits when the user has released a drag item, before any animations have started. */
3142
+ this.released = new i0.EventEmitter();
3143
+ /** Emits when the user stops dragging an item in the container. */
3144
+ this.ended = new i0.EventEmitter();
3145
+ /** Emits when the user has moved the item into a new container. */
3170
3146
  this.entered = new i0.EventEmitter();
3171
- /**
3172
- * Emits when the user removes an item from the container
3173
- * by dragging it into another container.
3174
- */
3147
+ /** Emits when the user removes the item its container by dragging it into another container. */
3175
3148
  this.exited = new i0.EventEmitter();
3176
- /** Emits as the user is swapping items while actively dragging. */
3177
- this.sorted = new i0.EventEmitter();
3149
+ /** Emits when the user drops the item inside a container. */
3150
+ this.dropped = new i0.EventEmitter();
3178
3151
  /**
3179
- * Keeps track of the items that are registered with this container. Historically we used to
3180
- * do this with a `ContentChildren` query, however queries don't handle transplanted views very
3181
- * well which means that we can't handle cases like dragging the headers of a `mat-table`
3182
- * correctly. What we do instead is to have the items register themselves with the container
3183
- * and then we sort them based on their position in the DOM.
3152
+ * Emits as the user is dragging the item. Use with caution,
3153
+ * because this event will fire for every pixel that the user has dragged.
3184
3154
  */
3185
- this._unsortedItems = new Set();
3186
- this._dropListRef = dragDrop.createDropList(element);
3187
- this._dropListRef.data = this;
3155
+ this.moved = new rxjs.Observable(function (observer) {
3156
+ var subscription = _this._dragRef.moved.pipe(operators.map(function (movedEvent) { return ({
3157
+ source: _this,
3158
+ pointerPosition: movedEvent.pointerPosition,
3159
+ event: movedEvent.event,
3160
+ delta: movedEvent.delta,
3161
+ distance: movedEvent.distance
3162
+ }); })).subscribe(observer);
3163
+ return function () {
3164
+ subscription.unsubscribe();
3165
+ };
3166
+ });
3167
+ this._dragRef = dragDrop.createDrag(element, {
3168
+ dragStartThreshold: config && config.dragStartThreshold != null ?
3169
+ config.dragStartThreshold : 5,
3170
+ pointerDirectionChangeThreshold: config && config.pointerDirectionChangeThreshold != null ?
3171
+ config.pointerDirectionChangeThreshold : 5,
3172
+ zIndex: config === null || config === void 0 ? void 0 : config.zIndex
3173
+ });
3174
+ this._dragRef.data = this;
3188
3175
  if (config) {
3189
3176
  this._assignDefaults(config);
3190
3177
  }
3191
- this._dropListRef.enterPredicate = function (drag, drop) {
3192
- return _this.enterPredicate(drag.data, drop.data);
3193
- };
3194
- this._setupInputSyncSubscription(this._dropListRef);
3195
- this._handleEvents(this._dropListRef);
3196
- CdkDropList._dropLists.push(this);
3197
- if (_group) {
3198
- _group._items.add(this);
3178
+ // Note that usually the container is assigned when the drop list is picks up the item, but in
3179
+ // some cases (mainly transplanted views with OnPush, see #18341) we may end up in a situation
3180
+ // where there are no items on the first change detection pass, but the items get picked up as
3181
+ // soon as the user triggers another pass by dragging. This is a problem, because the item would
3182
+ // have to switch from standalone mode to drag mode in the middle of the dragging sequence which
3183
+ // is too late since the two modes save different kinds of information. We work around it by
3184
+ // assigning the drop container both from here and the list.
3185
+ if (dropContainer) {
3186
+ this._dragRef._withDropContainer(dropContainer._dropListRef);
3187
+ dropContainer.addItem(this);
3199
3188
  }
3189
+ this._syncInputs(this._dragRef);
3190
+ this._handleEvents(this._dragRef);
3200
3191
  }
3201
- Object.defineProperty(CdkDropList.prototype, "disabled", {
3202
- /** Whether starting a dragging sequence from this container is disabled. */
3192
+ Object.defineProperty(CdkDrag.prototype, "disabled", {
3193
+ /** Whether starting to drag this element is disabled. */
3203
3194
  get: function () {
3204
- return this._disabled || (!!this._group && this._group.disabled);
3195
+ return this._disabled || (this.dropContainer && this.dropContainer.disabled);
3205
3196
  },
3206
3197
  set: function (value) {
3207
- // Usually we sync the directive and ref state right before dragging starts, in order to have
3208
- // a single point of failure and to avoid having to use setters for everything. `disabled` is
3209
- // a special case, because it can prevent the `beforeStarted` event from firing, which can lock
3210
- // the user in a disabled state, so we also need to sync it as it's being set.
3211
- this._dropListRef.disabled = this._disabled = coercion.coerceBooleanProperty(value);
3198
+ this._disabled = coercion.coerceBooleanProperty(value);
3199
+ this._dragRef.disabled = this._disabled;
3212
3200
  },
3213
3201
  enumerable: false,
3214
3202
  configurable: true
3215
3203
  });
3216
- /** Registers an items with the drop list. */
3217
- CdkDropList.prototype.addItem = function (item) {
3218
- this._unsortedItems.add(item);
3219
- if (this._dropListRef.isDragging()) {
3220
- this._syncItemsWithRef();
3204
+ /**
3205
+ * Returns the element that is being used as a placeholder
3206
+ * while the current element is being dragged.
3207
+ */
3208
+ CdkDrag.prototype.getPlaceholderElement = function () {
3209
+ return this._dragRef.getPlaceholderElement();
3210
+ };
3211
+ /** Returns the root draggable element. */
3212
+ CdkDrag.prototype.getRootElement = function () {
3213
+ return this._dragRef.getRootElement();
3214
+ };
3215
+ /** Resets a standalone drag item to its initial position. */
3216
+ CdkDrag.prototype.reset = function () {
3217
+ this._dragRef.reset();
3218
+ };
3219
+ /**
3220
+ * Gets the pixel coordinates of the draggable outside of a drop container.
3221
+ */
3222
+ CdkDrag.prototype.getFreeDragPosition = function () {
3223
+ return this._dragRef.getFreeDragPosition();
3224
+ };
3225
+ CdkDrag.prototype.ngAfterViewInit = function () {
3226
+ var _this = this;
3227
+ // We need to wait for the zone to stabilize, in order for the reference
3228
+ // element to be in the proper place in the DOM. This is mostly relevant
3229
+ // for draggable elements inside portals since they get stamped out in
3230
+ // their original DOM position and then they get transferred to the portal.
3231
+ this._ngZone.onStable.asObservable()
3232
+ .pipe(operators.take(1), operators.takeUntil(this._destroyed))
3233
+ .subscribe(function () {
3234
+ _this._updateRootElement();
3235
+ // Listen for any newly-added handles.
3236
+ _this._handles.changes.pipe(operators.startWith(_this._handles),
3237
+ // Sync the new handles with the DragRef.
3238
+ operators.tap(function (handles) {
3239
+ var childHandleElements = handles
3240
+ .filter(function (handle) { return handle._parentDrag === _this; })
3241
+ .map(function (handle) { return handle.element; });
3242
+ // Usually handles are only allowed to be a descendant of the drag element, but if
3243
+ // the consumer defined a different drag root, we should allow the drag element
3244
+ // itself to be a handle too.
3245
+ if (_this._selfHandle && _this.rootElementSelector) {
3246
+ childHandleElements.push(_this.element);
3247
+ }
3248
+ _this._dragRef.withHandles(childHandleElements);
3249
+ }),
3250
+ // Listen if the state of any of the handles changes.
3251
+ operators.switchMap(function (handles) {
3252
+ return rxjs.merge.apply(void 0, __spread(handles.map(function (item) {
3253
+ return item._stateChanges.pipe(operators.startWith(item));
3254
+ })));
3255
+ }), operators.takeUntil(_this._destroyed)).subscribe(function (handleInstance) {
3256
+ // Enabled/disable the handle that changed in the DragRef.
3257
+ var dragRef = _this._dragRef;
3258
+ var handle = handleInstance.element.nativeElement;
3259
+ handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
3260
+ });
3261
+ if (_this.freeDragPosition) {
3262
+ _this._dragRef.setFreeDragPosition(_this.freeDragPosition);
3263
+ }
3264
+ });
3265
+ };
3266
+ CdkDrag.prototype.ngOnChanges = function (changes) {
3267
+ var rootSelectorChange = changes['rootElementSelector'];
3268
+ var positionChange = changes['freeDragPosition'];
3269
+ // We don't have to react to the first change since it's being
3270
+ // handled in `ngAfterViewInit` where it needs to be deferred.
3271
+ if (rootSelectorChange && !rootSelectorChange.firstChange) {
3272
+ this._updateRootElement();
3273
+ }
3274
+ // Skip the first change since it's being handled in `ngAfterViewInit`.
3275
+ if (positionChange && !positionChange.firstChange && this.freeDragPosition) {
3276
+ this._dragRef.setFreeDragPosition(this.freeDragPosition);
3221
3277
  }
3222
3278
  };
3223
- /** Removes an item from the drop list. */
3224
- CdkDropList.prototype.removeItem = function (item) {
3225
- this._unsortedItems.delete(item);
3226
- if (this._dropListRef.isDragging()) {
3227
- this._syncItemsWithRef();
3279
+ CdkDrag.prototype.ngOnDestroy = function () {
3280
+ if (this.dropContainer) {
3281
+ this.dropContainer.removeItem(this);
3228
3282
  }
3283
+ this._destroyed.next();
3284
+ this._destroyed.complete();
3285
+ this._dragRef.dispose();
3229
3286
  };
3230
- /** Gets the registered items in the list, sorted by their position in the DOM. */
3231
- CdkDropList.prototype.getSortedItems = function () {
3232
- return Array.from(this._unsortedItems).sort(function (a, b) {
3233
- var documentPosition = a._dragRef.getVisibleElement().compareDocumentPosition(b._dragRef.getVisibleElement());
3234
- // `compareDocumentPosition` returns a bitmask so we have to use a bitwise operator.
3235
- // https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
3236
- // tslint:disable-next-line:no-bitwise
3237
- return documentPosition & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
3238
- });
3287
+ /** Syncs the root element with the `DragRef`. */
3288
+ CdkDrag.prototype._updateRootElement = function () {
3289
+ var element = this.element.nativeElement;
3290
+ var rootElement = this.rootElementSelector ?
3291
+ getClosestMatchingAncestor(element, this.rootElementSelector) : element;
3292
+ if (rootElement && rootElement.nodeType !== this._document.ELEMENT_NODE) {
3293
+ throw Error("cdkDrag must be attached to an element node. " +
3294
+ ("Currently attached to \"" + rootElement.nodeName + "\"."));
3295
+ }
3296
+ this._dragRef.withRootElement(rootElement || element);
3239
3297
  };
3240
- CdkDropList.prototype.ngOnDestroy = function () {
3241
- var index = CdkDropList._dropLists.indexOf(this);
3242
- if (index > -1) {
3243
- CdkDropList._dropLists.splice(index, 1);
3298
+ /** Gets the boundary element, based on the `boundaryElement` value. */
3299
+ CdkDrag.prototype._getBoundaryElement = function () {
3300
+ var boundary = this.boundaryElement;
3301
+ if (!boundary) {
3302
+ return null;
3244
3303
  }
3245
- if (this._group) {
3246
- this._group._items.delete(this);
3304
+ if (typeof boundary === 'string') {
3305
+ return getClosestMatchingAncestor(this.element.nativeElement, boundary);
3247
3306
  }
3248
- this._unsortedItems.clear();
3249
- this._dropListRef.dispose();
3250
- this._destroyed.next();
3251
- this._destroyed.complete();
3307
+ var element = coercion.coerceElement(boundary);
3308
+ if (i0.isDevMode() && !element.contains(this.element.nativeElement)) {
3309
+ throw Error('Draggable element is not inside of the node passed into cdkDragBoundary.');
3310
+ }
3311
+ return element;
3252
3312
  };
3253
- /** Syncs the inputs of the CdkDropList with the options of the underlying DropListRef. */
3254
- CdkDropList.prototype._setupInputSyncSubscription = function (ref) {
3313
+ /** Syncs the inputs of the CdkDrag with the options of the underlying DragRef. */
3314
+ CdkDrag.prototype._syncInputs = function (ref) {
3255
3315
  var _this = this;
3256
- if (this._dir) {
3257
- this._dir.change
3258
- .pipe(operators.startWith(this._dir.value), operators.takeUntil(this._destroyed))
3259
- .subscribe(function (value) { return ref.withDirection(value); });
3260
- }
3261
3316
  ref.beforeStarted.subscribe(function () {
3262
- var siblings = coercion.coerceArray(_this.connectedTo).map(function (drop) {
3263
- return typeof drop === 'string' ?
3264
- CdkDropList._dropLists.find(function (list) { return list.id === drop; }) : drop;
3265
- });
3266
- if (_this._group) {
3267
- _this._group._items.forEach(function (drop) {
3268
- if (siblings.indexOf(drop) === -1) {
3269
- siblings.push(drop);
3270
- }
3271
- });
3272
- }
3273
- // Note that we resolve the scrollable parents here so that we delay the resolution
3274
- // as long as possible, ensuring that the element is in its final place in the DOM.
3275
- // @breaking-change 11.0.0 Remove null check for _scrollDispatcher once it's required.
3276
- if (!_this._scrollableParentsResolved && _this._scrollDispatcher) {
3277
- var scrollableParents = _this._scrollDispatcher
3278
- .getAncestorScrollContainers(_this.element)
3279
- .map(function (scrollable) { return scrollable.getElementRef().nativeElement; });
3280
- _this._dropListRef.withScrollableParents(scrollableParents);
3281
- // Only do this once since it involves traversing the DOM and the parents
3282
- // shouldn't be able to change without the drop list being destroyed.
3283
- _this._scrollableParentsResolved = true;
3317
+ if (!ref.isDragging()) {
3318
+ var dir = _this._dir;
3319
+ var dragStartDelay = _this.dragStartDelay;
3320
+ var placeholder = _this._placeholderTemplate ? {
3321
+ template: _this._placeholderTemplate.templateRef,
3322
+ context: _this._placeholderTemplate.data,
3323
+ viewContainer: _this._viewContainerRef
3324
+ } : null;
3325
+ var preview = _this._previewTemplate ? {
3326
+ template: _this._previewTemplate.templateRef,
3327
+ context: _this._previewTemplate.data,
3328
+ matchSize: _this._previewTemplate.matchSize,
3329
+ viewContainer: _this._viewContainerRef
3330
+ } : null;
3331
+ ref.disabled = _this.disabled;
3332
+ ref.lockAxis = _this.lockAxis;
3333
+ ref.dragStartDelay = (typeof dragStartDelay === 'object' && dragStartDelay) ?
3334
+ dragStartDelay : coercion.coerceNumberProperty(dragStartDelay);
3335
+ ref.constrainPosition = _this.constrainPosition;
3336
+ ref.previewClass = _this.previewClass;
3337
+ ref
3338
+ .withBoundaryElement(_this._getBoundaryElement())
3339
+ .withPlaceholderTemplate(placeholder)
3340
+ .withPreviewTemplate(preview);
3341
+ if (dir) {
3342
+ ref.withDirection(dir.value);
3343
+ }
3284
3344
  }
3285
- ref.disabled = _this.disabled;
3286
- ref.lockAxis = _this.lockAxis;
3287
- ref.sortingDisabled = coercion.coerceBooleanProperty(_this.sortingDisabled);
3288
- ref.autoScrollDisabled = coercion.coerceBooleanProperty(_this.autoScrollDisabled);
3289
- ref
3290
- .connectedTo(siblings.filter(function (drop) { return drop && drop !== _this; }).map(function (list) { return list._dropListRef; }))
3291
- .withOrientation(_this.orientation);
3292
3345
  });
3293
3346
  };
3294
- /** Handles events from the underlying DropListRef. */
3295
- CdkDropList.prototype._handleEvents = function (ref) {
3347
+ /** Handles the events from the underlying `DragRef`. */
3348
+ CdkDrag.prototype._handleEvents = function (ref) {
3296
3349
  var _this = this;
3297
- ref.beforeStarted.subscribe(function () {
3298
- _this._syncItemsWithRef();
3350
+ ref.started.subscribe(function () {
3351
+ _this.started.emit({ source: _this });
3352
+ // Since all of these events run outside of change detection,
3353
+ // we need to ensure that everything is marked correctly.
3354
+ _this._changeDetectorRef.markForCheck();
3355
+ });
3356
+ ref.released.subscribe(function () {
3357
+ _this.released.emit({ source: _this });
3358
+ });
3359
+ ref.ended.subscribe(function (event) {
3360
+ _this.ended.emit({ source: _this, distance: event.distance });
3361
+ // Since all of these events run outside of change detection,
3362
+ // we need to ensure that everything is marked correctly.
3299
3363
  _this._changeDetectorRef.markForCheck();
3300
3364
  });
3301
3365
  ref.entered.subscribe(function (event) {
3302
3366
  _this.entered.emit({
3303
- container: _this,
3304
- item: event.item.data,
3367
+ container: event.container.data,
3368
+ item: _this,
3305
3369
  currentIndex: event.currentIndex
3306
3370
  });
3307
3371
  });
3308
3372
  ref.exited.subscribe(function (event) {
3309
3373
  _this.exited.emit({
3310
- container: _this,
3311
- item: event.item.data
3312
- });
3313
- _this._changeDetectorRef.markForCheck();
3314
- });
3315
- ref.sorted.subscribe(function (event) {
3316
- _this.sorted.emit({
3317
- previousIndex: event.previousIndex,
3318
- currentIndex: event.currentIndex,
3319
- container: _this,
3320
- item: event.item.data
3374
+ container: event.container.data,
3375
+ item: _this
3321
3376
  });
3322
3377
  });
3323
3378
  ref.dropped.subscribe(function (event) {
@@ -3326,76 +3381,93 @@
3326
3381
  currentIndex: event.currentIndex,
3327
3382
  previousContainer: event.previousContainer.data,
3328
3383
  container: event.container.data,
3329
- item: event.item.data,
3330
3384
  isPointerOverContainer: event.isPointerOverContainer,
3385
+ item: _this,
3331
3386
  distance: event.distance
3332
3387
  });
3333
- // Mark for check since all of these events run outside of change
3334
- // detection and we're not guaranteed for something else to have triggered it.
3335
- _this._changeDetectorRef.markForCheck();
3336
3388
  });
3337
3389
  };
3338
3390
  /** Assigns the default input values based on a provided config object. */
3339
- CdkDropList.prototype._assignDefaults = function (config) {
3340
- var lockAxis = config.lockAxis, draggingDisabled = config.draggingDisabled, sortingDisabled = config.sortingDisabled, listAutoScrollDisabled = config.listAutoScrollDisabled, listOrientation = config.listOrientation;
3391
+ CdkDrag.prototype._assignDefaults = function (config) {
3392
+ var lockAxis = config.lockAxis, dragStartDelay = config.dragStartDelay, constrainPosition = config.constrainPosition, previewClass = config.previewClass, boundaryElement = config.boundaryElement, draggingDisabled = config.draggingDisabled, rootElementSelector = config.rootElementSelector;
3341
3393
  this.disabled = draggingDisabled == null ? false : draggingDisabled;
3342
- this.sortingDisabled = sortingDisabled == null ? false : sortingDisabled;
3343
- this.autoScrollDisabled = listAutoScrollDisabled == null ? false : listAutoScrollDisabled;
3344
- this.orientation = listOrientation || 'vertical';
3394
+ this.dragStartDelay = dragStartDelay || 0;
3345
3395
  if (lockAxis) {
3346
3396
  this.lockAxis = lockAxis;
3347
3397
  }
3398
+ if (constrainPosition) {
3399
+ this.constrainPosition = constrainPosition;
3400
+ }
3401
+ if (previewClass) {
3402
+ this.previewClass = previewClass;
3403
+ }
3404
+ if (boundaryElement) {
3405
+ this.boundaryElement = boundaryElement;
3406
+ }
3407
+ if (rootElementSelector) {
3408
+ this.rootElementSelector = rootElementSelector;
3409
+ }
3348
3410
  };
3349
- /** Syncs up the registered drag items with underlying drop list ref. */
3350
- CdkDropList.prototype._syncItemsWithRef = function () {
3351
- this._dropListRef.withItems(this.getSortedItems().map(function (item) { return item._dragRef; }));
3352
- };
3353
- /** Keeps track of the drop lists that are currently on the page. */
3354
- CdkDropList._dropLists = [];
3355
- CdkDropList.decorators = [
3411
+ CdkDrag.decorators = [
3356
3412
  { type: i0.Directive, args: [{
3357
- selector: '[cdkDropList], cdk-drop-list',
3358
- exportAs: 'cdkDropList',
3359
- providers: [
3360
- // Prevent child drop lists from picking up the same group as their parent.
3361
- { provide: CdkDropListGroup, useValue: ɵ0 },
3362
- { provide: CDK_DROP_LIST, useExisting: CdkDropList },
3363
- ],
3413
+ selector: '[cdkDrag]',
3414
+ exportAs: 'cdkDrag',
3364
3415
  host: {
3365
- 'class': 'cdk-drop-list',
3366
- '[id]': 'id',
3367
- '[class.cdk-drop-list-disabled]': 'disabled',
3368
- '[class.cdk-drop-list-dragging]': '_dropListRef.isDragging()',
3369
- '[class.cdk-drop-list-receiving]': '_dropListRef.isReceiving()',
3370
- }
3416
+ 'class': 'cdk-drag',
3417
+ '[class.cdk-drag-disabled]': 'disabled',
3418
+ '[class.cdk-drag-dragging]': '_dragRef.isDragging()',
3419
+ },
3420
+ providers: [{ provide: CDK_DRAG_PARENT, useExisting: CdkDrag }]
3371
3421
  },] }
3372
3422
  ];
3373
- CdkDropList.ctorParameters = function () { return [
3423
+ CdkDrag.ctorParameters = function () { return [
3374
3424
  { type: i0.ElementRef },
3425
+ { type: undefined, decorators: [{ type: i0.Inject, args: [CDK_DROP_LIST,] }, { type: i0.Optional }, { type: i0.SkipSelf }] },
3426
+ { type: undefined, decorators: [{ type: i0.Inject, args: [i1.DOCUMENT,] }] },
3427
+ { type: i0.NgZone },
3428
+ { type: i0.ViewContainerRef },
3429
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [CDK_DRAG_CONFIG,] }] },
3430
+ { type: bidi.Directionality, decorators: [{ type: i0.Optional }] },
3375
3431
  { type: DragDrop },
3376
3432
  { type: i0.ChangeDetectorRef },
3377
- { type: bidi.Directionality, decorators: [{ type: i0.Optional }] },
3378
- { type: CdkDropListGroup, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] },
3379
- { type: i2.ScrollDispatcher },
3380
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [CDK_DRAG_CONFIG,] }] }
3433
+ { type: CdkDragHandle, decorators: [{ type: i0.Optional }, { type: i0.Self }, { type: i0.Inject, args: [CDK_DRAG_HANDLE,] }] }
3381
3434
  ]; };
3382
- CdkDropList.propDecorators = {
3383
- connectedTo: [{ type: i0.Input, args: ['cdkDropListConnectedTo',] }],
3384
- data: [{ type: i0.Input, args: ['cdkDropListData',] }],
3385
- orientation: [{ type: i0.Input, args: ['cdkDropListOrientation',] }],
3386
- id: [{ type: i0.Input }],
3387
- lockAxis: [{ type: i0.Input, args: ['cdkDropListLockAxis',] }],
3388
- disabled: [{ type: i0.Input, args: ['cdkDropListDisabled',] }],
3389
- sortingDisabled: [{ type: i0.Input, args: ['cdkDropListSortingDisabled',] }],
3390
- enterPredicate: [{ type: i0.Input, args: ['cdkDropListEnterPredicate',] }],
3391
- autoScrollDisabled: [{ type: i0.Input, args: ['cdkDropListAutoScrollDisabled',] }],
3392
- dropped: [{ type: i0.Output, args: ['cdkDropListDropped',] }],
3393
- entered: [{ type: i0.Output, args: ['cdkDropListEntered',] }],
3394
- exited: [{ type: i0.Output, args: ['cdkDropListExited',] }],
3395
- sorted: [{ type: i0.Output, args: ['cdkDropListSorted',] }]
3435
+ CdkDrag.propDecorators = {
3436
+ _handles: [{ type: i0.ContentChildren, args: [CDK_DRAG_HANDLE, { descendants: true },] }],
3437
+ _previewTemplate: [{ type: i0.ContentChild, args: [CDK_DRAG_PREVIEW,] }],
3438
+ _placeholderTemplate: [{ type: i0.ContentChild, args: [CDK_DRAG_PLACEHOLDER,] }],
3439
+ data: [{ type: i0.Input, args: ['cdkDragData',] }],
3440
+ lockAxis: [{ type: i0.Input, args: ['cdkDragLockAxis',] }],
3441
+ rootElementSelector: [{ type: i0.Input, args: ['cdkDragRootElement',] }],
3442
+ boundaryElement: [{ type: i0.Input, args: ['cdkDragBoundary',] }],
3443
+ dragStartDelay: [{ type: i0.Input, args: ['cdkDragStartDelay',] }],
3444
+ freeDragPosition: [{ type: i0.Input, args: ['cdkDragFreeDragPosition',] }],
3445
+ disabled: [{ type: i0.Input, args: ['cdkDragDisabled',] }],
3446
+ constrainPosition: [{ type: i0.Input, args: ['cdkDragConstrainPosition',] }],
3447
+ previewClass: [{ type: i0.Input, args: ['cdkDragPreviewClass',] }],
3448
+ started: [{ type: i0.Output, args: ['cdkDragStarted',] }],
3449
+ released: [{ type: i0.Output, args: ['cdkDragReleased',] }],
3450
+ ended: [{ type: i0.Output, args: ['cdkDragEnded',] }],
3451
+ entered: [{ type: i0.Output, args: ['cdkDragEntered',] }],
3452
+ exited: [{ type: i0.Output, args: ['cdkDragExited',] }],
3453
+ dropped: [{ type: i0.Output, args: ['cdkDragDropped',] }],
3454
+ moved: [{ type: i0.Output, args: ['cdkDragMoved',] }]
3396
3455
  };
3397
- return CdkDropList;
3456
+ return CdkDrag;
3398
3457
  }());
3458
+ /** Gets the closest ancestor of an element that matches a selector. */
3459
+ function getClosestMatchingAncestor(element, selector) {
3460
+ var currentElement = element.parentElement;
3461
+ while (currentElement) {
3462
+ // IE doesn't support `matches` so we have to fall back to `msMatchesSelector`.
3463
+ if (currentElement.matches ? currentElement.matches(selector) :
3464
+ currentElement.msMatchesSelector(selector)) {
3465
+ return currentElement;
3466
+ }
3467
+ currentElement = currentElement.parentElement;
3468
+ }
3469
+ return null;
3470
+ }
3399
3471
 
3400
3472
  /**
3401
3473
  * @license
@@ -3447,7 +3519,10 @@
3447
3519
  */
3448
3520
 
3449
3521
  exports.CDK_DRAG_CONFIG = CDK_DRAG_CONFIG;
3450
- exports.CDK_DROP_LIST = CDK_DROP_LIST;
3522
+ exports.CDK_DRAG_HANDLE = CDK_DRAG_HANDLE;
3523
+ exports.CDK_DRAG_PLACEHOLDER = CDK_DRAG_PLACEHOLDER;
3524
+ exports.CDK_DRAG_PREVIEW = CDK_DRAG_PREVIEW;
3525
+ exports.CDK_DROP_LIST_GROUP = CDK_DROP_LIST_GROUP;
3451
3526
  exports.CdkDrag = CdkDrag;
3452
3527
  exports.CdkDragHandle = CdkDragHandle;
3453
3528
  exports.CdkDragPlaceholder = CdkDragPlaceholder;
@@ -3462,7 +3537,8 @@
3462
3537
  exports.copyArrayItem = copyArrayItem;
3463
3538
  exports.moveItemInArray = moveItemInArray;
3464
3539
  exports.transferArrayItem = transferArrayItem;
3465
- exports.ɵangular_material_src_cdk_drag_drop_drag_drop_b = CDK_DRAG_PARENT;
3540
+ exports.ɵangular_material_src_cdk_drag_drop_drag_drop_b = CDK_DROP_LIST;
3541
+ exports.ɵangular_material_src_cdk_drag_drop_drag_drop_c = CDK_DRAG_PARENT;
3466
3542
 
3467
3543
  Object.defineProperty(exports, '__esModule', { value: true });
3468
3544