@angular/cdk 7.2.1 → 7.2.2

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 (122) hide show
  1. package/a11y/typings/index.metadata.json +1 -1
  2. package/bundles/cdk-a11y.umd.js +2 -1
  3. package/bundles/cdk-a11y.umd.js.map +1 -1
  4. package/bundles/cdk-a11y.umd.min.js +1 -1
  5. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  6. package/bundles/cdk-drag-drop.umd.js +274 -126
  7. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  8. package/bundles/cdk-drag-drop.umd.min.js +2 -2
  9. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  10. package/bundles/cdk-observers.umd.js +1 -1
  11. package/bundles/cdk-observers.umd.js.map +1 -1
  12. package/bundles/cdk-observers.umd.min.js +1 -1
  13. package/bundles/cdk-observers.umd.min.js.map +1 -1
  14. package/bundles/cdk-overlay.umd.js +13 -12
  15. package/bundles/cdk-overlay.umd.js.map +1 -1
  16. package/bundles/cdk-overlay.umd.min.js +2 -2
  17. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  18. package/bundles/cdk-portal.umd.js +3 -3
  19. package/bundles/cdk-portal.umd.js.map +1 -1
  20. package/bundles/cdk-portal.umd.min.js.map +1 -1
  21. package/bundles/cdk-scrolling.umd.js +9 -6
  22. package/bundles/cdk-scrolling.umd.js.map +1 -1
  23. package/bundles/cdk-scrolling.umd.min.js +1 -1
  24. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  25. package/bundles/cdk-stepper.umd.js +23 -11
  26. package/bundles/cdk-stepper.umd.js.map +1 -1
  27. package/bundles/cdk-stepper.umd.min.js +1 -1
  28. package/bundles/cdk-stepper.umd.min.js.map +1 -1
  29. package/bundles/cdk-table.umd.js +8 -4
  30. package/bundles/cdk-table.umd.js.map +1 -1
  31. package/bundles/cdk-table.umd.min.js +1 -1
  32. package/bundles/cdk-table.umd.min.js.map +1 -1
  33. package/bundles/cdk-text-field.umd.js +1 -1
  34. package/bundles/cdk-text-field.umd.min.js +1 -1
  35. package/bundles/cdk-text-field.umd.min.js.map +1 -1
  36. package/bundles/cdk.umd.js +1 -1
  37. package/bundles/cdk.umd.js.map +1 -1
  38. package/bundles/cdk.umd.min.js +1 -1
  39. package/bundles/cdk.umd.min.js.map +1 -1
  40. package/drag-drop/typings/directives/drag-handle.d.ts +6 -2
  41. package/drag-drop/typings/directives/drag.d.ts +3 -2
  42. package/drag-drop/typings/directives/drop-list.d.ts +2 -5
  43. package/drag-drop/typings/drag-ref.d.ts +27 -19
  44. package/drag-drop/typings/drop-list-ref.d.ts +28 -14
  45. package/drag-drop/typings/index.metadata.json +1 -1
  46. package/esm2015/a11y.js +2 -1
  47. package/esm2015/a11y.js.map +1 -1
  48. package/esm2015/cdk.js +1 -1
  49. package/esm2015/cdk.js.map +1 -1
  50. package/esm2015/drag-drop.js +192 -108
  51. package/esm2015/drag-drop.js.map +1 -1
  52. package/esm2015/observers.js +1 -1
  53. package/esm2015/observers.js.map +1 -1
  54. package/esm2015/overlay.js +11 -10
  55. package/esm2015/overlay.js.map +1 -1
  56. package/esm2015/portal.js +1 -1
  57. package/esm2015/portal.js.map +1 -1
  58. package/esm2015/scrolling.js +9 -6
  59. package/esm2015/scrolling.js.map +1 -1
  60. package/esm2015/stepper.js +18 -11
  61. package/esm2015/stepper.js.map +1 -1
  62. package/esm2015/table.js +8 -4
  63. package/esm2015/table.js.map +1 -1
  64. package/esm5/a11y.es5.js +2 -1
  65. package/esm5/a11y.es5.js.map +1 -1
  66. package/esm5/cdk.es5.js +1 -1
  67. package/esm5/cdk.es5.js.map +1 -1
  68. package/esm5/drag-drop.es5.js +276 -128
  69. package/esm5/drag-drop.es5.js.map +1 -1
  70. package/esm5/observers.es5.js +1 -1
  71. package/esm5/observers.es5.js.map +1 -1
  72. package/esm5/overlay.es5.js +13 -12
  73. package/esm5/overlay.es5.js.map +1 -1
  74. package/esm5/portal.es5.js +3 -3
  75. package/esm5/portal.es5.js.map +1 -1
  76. package/esm5/scrolling.es5.js +9 -6
  77. package/esm5/scrolling.es5.js.map +1 -1
  78. package/esm5/stepper.es5.js +23 -11
  79. package/esm5/stepper.es5.js.map +1 -1
  80. package/esm5/table.es5.js +8 -4
  81. package/esm5/table.es5.js.map +1 -1
  82. package/overlay/typings/index.metadata.json +1 -1
  83. package/overlay/typings/overlay-ref.d.ts +1 -1
  84. package/package.json +3 -3
  85. package/portal/typings/portal.d.ts +1 -1
  86. package/schematics/migration.json +5 -0
  87. package/schematics/ng-update/index.d.ts +2 -0
  88. package/schematics/ng-update/index.js +5 -0
  89. package/schematics/ng-update/index.js.map +1 -1
  90. package/schematics/ng-update/target-version.d.ts +7 -1
  91. package/schematics/ng-update/target-version.js +10 -0
  92. package/schematics/ng-update/target-version.js.map +1 -1
  93. package/stepper/typings/index.metadata.json +1 -1
  94. package/stepper/typings/stepper.d.ts +7 -1
  95. package/typings/a11y/index.metadata.json +1 -1
  96. package/typings/drag-drop/directives/drag-handle.d.ts +6 -2
  97. package/typings/drag-drop/directives/drag.d.ts +3 -2
  98. package/typings/drag-drop/directives/drop-list.d.ts +2 -5
  99. package/typings/drag-drop/drag-ref.d.ts +27 -19
  100. package/typings/drag-drop/drop-list-ref.d.ts +28 -14
  101. package/typings/drag-drop/index.metadata.json +1 -1
  102. package/typings/esm5/a11y/index.metadata.json +1 -1
  103. package/typings/esm5/drag-drop/directives/drag-handle.d.ts +6 -2
  104. package/typings/esm5/drag-drop/directives/drag.d.ts +3 -2
  105. package/typings/esm5/drag-drop/directives/drop-list.d.ts +2 -5
  106. package/typings/esm5/drag-drop/drag-ref.d.ts +27 -19
  107. package/typings/esm5/drag-drop/drop-list-ref.d.ts +28 -14
  108. package/typings/esm5/drag-drop/index.metadata.json +1 -1
  109. package/typings/esm5/index.metadata.json +1 -1
  110. package/typings/esm5/overlay/index.metadata.json +1 -1
  111. package/typings/esm5/overlay/overlay-ref.d.ts +1 -1
  112. package/typings/esm5/portal/portal.d.ts +1 -1
  113. package/typings/esm5/stepper/index.metadata.json +1 -1
  114. package/typings/esm5/stepper/stepper.d.ts +7 -1
  115. package/typings/index.metadata.json +1 -1
  116. package/typings/overlay/index.metadata.json +1 -1
  117. package/typings/overlay/overlay-ref.d.ts +1 -1
  118. package/typings/portal/portal.d.ts +1 -1
  119. package/typings/schematics/ng-update/index.d.ts +2 -0
  120. package/typings/schematics/ng-update/target-version.d.ts +7 -1
  121. package/typings/stepper/index.metadata.json +1 -1
  122. package/typings/stepper/stepper.d.ts +7 -1
@@ -7,7 +7,7 @@
7
7
  */
8
8
  (function (global, factory) {
9
9
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/cdk/platform'), require('rxjs'), require('@angular/cdk/coercion'), require('@angular/cdk/bidi'), require('@angular/cdk/scrolling'), require('rxjs/operators')) :
10
- typeof define === 'function' && define.amd ? define('@angular/cdk/dragDrop', ['exports', '@angular/core', '@angular/common', '@angular/cdk/platform', 'rxjs', '@angular/cdk/coercion', '@angular/cdk/bidi', '@angular/cdk/scrolling', 'rxjs/operators'], factory) :
10
+ typeof define === 'function' && define.amd ? define('@angular/cdk/drag-drop', ['exports', '@angular/core', '@angular/common', '@angular/cdk/platform', 'rxjs', '@angular/cdk/coercion', '@angular/cdk/bidi', '@angular/cdk/scrolling', 'rxjs/operators'], factory) :
11
11
  (factory((global.ng = global.ng || {}, global.ng.cdk = global.ng.cdk || {}, global.ng.cdk.dragDrop = {}),global.ng.core,global.ng.common,global.ng.cdk.platform,global.rxjs,global.ng.cdk.coercion,global.ng.cdk.bidi,global.ng.cdk.scrolling,global.rxjs.operators));
12
12
  }(this, (function (exports,core,common,platform,rxjs,coercion,bidi,scrolling,operators) { 'use strict';
13
13
 
@@ -471,6 +471,10 @@ function toggleNativeDragInteractions(element, enable) {
471
471
  var CdkDragHandle = /** @class */ (function () {
472
472
  function CdkDragHandle(element, parentDrag) {
473
473
  this.element = element;
474
+ /**
475
+ * Emits when the state of the handle has changed.
476
+ */
477
+ this._stateChanges = new rxjs.Subject();
474
478
  this._disabled = false;
475
479
  this._parentDrag = parentDrag;
476
480
  toggleNativeDragInteractions(element.nativeElement, false);
@@ -488,10 +492,20 @@ var CdkDragHandle = /** @class */ (function () {
488
492
  */
489
493
  function (value) {
490
494
  this._disabled = coercion.coerceBooleanProperty(value);
495
+ this._stateChanges.next(this);
491
496
  },
492
497
  enumerable: true,
493
498
  configurable: true
494
499
  });
500
+ /**
501
+ * @return {?}
502
+ */
503
+ CdkDragHandle.prototype.ngOnDestroy = /**
504
+ * @return {?}
505
+ */
506
+ function () {
507
+ this._stateChanges.complete();
508
+ };
495
509
  CdkDragHandle.decorators = [
496
510
  { type: core.Directive, args: [{
497
511
  selector: '[cdkDragHandle]',
@@ -705,6 +719,10 @@ DragRef = /** @class */ (function () {
705
719
  * Elements that can be used to drag the draggable item.
706
720
  */
707
721
  this._handles = [];
722
+ /**
723
+ * Registered handles that are currently disabled.
724
+ */
725
+ this._disabledHandles = new Set();
708
726
  this._disabled = false;
709
727
  /**
710
728
  * Emits as the drag sequence is being prepared.
@@ -738,7 +756,7 @@ DragRef = /** @class */ (function () {
738
756
  * Emits as the user is dragging the item. Use with caution,
739
757
  * because this event will fire for every pixel that the user has dragged.
740
758
  */
741
- this.moved = rxjs.Observable.create(function (observer) {
759
+ this.moved = new rxjs.Observable(function (observer) {
742
760
  /** @type {?} */
743
761
  var subscription = _this._moveEvents.subscribe(observer);
744
762
  _this._moveEventSubscriptions++;
@@ -756,14 +774,12 @@ DragRef = /** @class */ (function () {
756
774
  if (_this._handles.length) {
757
775
  /** @type {?} */
758
776
  var targetHandle = _this._handles.find(function (handle) {
759
- /** @type {?} */
760
- var element = handle.element.nativeElement;
761
777
  /** @type {?} */
762
778
  var target = event.target;
763
- return !!target && (target === element || element.contains((/** @type {?} */ (target))));
779
+ return !!target && (target === handle || handle.contains((/** @type {?} */ (target))));
764
780
  });
765
- if (targetHandle && !targetHandle.disabled && !_this.disabled) {
766
- _this._initializeDragSequence(targetHandle.element.nativeElement, event);
781
+ if (targetHandle && !_this._disabledHandles.has(targetHandle) && !_this.disabled) {
782
+ _this._initializeDragSequence(targetHandle, event);
767
783
  }
768
784
  }
769
785
  else if (!_this.disabled) {
@@ -816,9 +832,11 @@ DragRef = /** @class */ (function () {
816
832
  constrainedPointerPosition.y - _this._pickupPositionOnPage.y + _this._passiveTransform.y;
817
833
  /** @type {?} */
818
834
  var transform = getTransform(activeTransform.x, activeTransform.y);
819
- // Preserve the previous `transform` value, if there was one.
835
+ // Preserve the previous `transform` value, if there was one. Note that we apply our own
836
+ // transform before the user's, because things like rotation can affect which direction
837
+ // the element will be translated towards.
820
838
  _this._rootElement.style.transform = _this._initialTransform ?
821
- _this._initialTransform + ' ' + transform : transform;
839
+ transform + ' ' + _this._initialTransform : transform;
822
840
  // Apply transform as attribute if dragging and svg element to work for IE
823
841
  if (typeof SVGElement !== 'undefined' && _this._rootElement instanceof SVGElement) {
824
842
  /** @type {?} */
@@ -947,50 +965,59 @@ DragRef = /** @class */ (function () {
947
965
  * @return {THIS}
948
966
  */
949
967
  function (handles) {
950
- // TODO(crisbeto): have this accept HTMLElement[] | ElementRef<HTMLElement>[]
951
- (/** @type {?} */ (this))._handles = handles;
952
- handles.forEach(function (handle) { return toggleNativeDragInteractions(handle.element.nativeElement, false); });
968
+ (/** @type {?} */ (this))._handles = handles.map(function (handle) { return coercion.coerceElement(handle); });
969
+ (/** @type {?} */ (this))._handles.forEach(function (handle) { return toggleNativeDragInteractions(handle, false); });
953
970
  (/** @type {?} */ (this))._toggleNativeDragInteractions();
954
971
  return (/** @type {?} */ (this));
955
972
  };
956
- /** Registers the template that should be used for the drag preview. */
973
+ /**
974
+ * Registers the template that should be used for the drag preview.
975
+ * @param template Template that from which to stamp out the preview.
976
+ * @param context Variables to add to the template's context.
977
+ */
957
978
  /**
958
979
  * Registers the template that should be used for the drag preview.
959
980
  * @template THIS
960
981
  * @this {THIS}
961
- * @param {?} template
982
+ * @param {?} template Template that from which to stamp out the preview.
983
+ * @param {?=} context Variables to add to the template's context.
962
984
  * @return {THIS}
963
985
  */
964
986
  DragRef.prototype.withPreviewTemplate = /**
965
987
  * Registers the template that should be used for the drag preview.
966
988
  * @template THIS
967
989
  * @this {THIS}
968
- * @param {?} template
990
+ * @param {?} template Template that from which to stamp out the preview.
991
+ * @param {?=} context Variables to add to the template's context.
969
992
  * @return {THIS}
970
993
  */
971
- function (template) {
972
- // TODO(crisbeto): have this accept a TemplateRef
973
- (/** @type {?} */ (this))._previewTemplate = template;
994
+ function (template, context) {
995
+ (/** @type {?} */ (this))._previewTemplate = { template: template, context: context };
974
996
  return (/** @type {?} */ (this));
975
997
  };
976
- /** Registers the template that should be used for the drag placeholder. */
998
+ /**
999
+ * Registers the template that should be used for the drag placeholder.
1000
+ * @param template Template that from which to stamp out the placeholder.
1001
+ * @param context Variables to add to the template's context.
1002
+ */
977
1003
  /**
978
1004
  * Registers the template that should be used for the drag placeholder.
979
1005
  * @template THIS
980
1006
  * @this {THIS}
981
- * @param {?} template
1007
+ * @param {?} template Template that from which to stamp out the placeholder.
1008
+ * @param {?=} context Variables to add to the template's context.
982
1009
  * @return {THIS}
983
1010
  */
984
1011
  DragRef.prototype.withPlaceholderTemplate = /**
985
1012
  * Registers the template that should be used for the drag placeholder.
986
1013
  * @template THIS
987
1014
  * @this {THIS}
988
- * @param {?} template
1015
+ * @param {?} template Template that from which to stamp out the placeholder.
1016
+ * @param {?=} context Variables to add to the template's context.
989
1017
  * @return {THIS}
990
1018
  */
991
- function (template) {
992
- // TODO(crisbeto): have this accept a TemplateRef
993
- (/** @type {?} */ (this))._placeholderTemplate = template;
1019
+ function (template, context) {
1020
+ (/** @type {?} */ (this))._placeholderTemplate = { template: template, context: context };
994
1021
  return (/** @type {?} */ (this));
995
1022
  };
996
1023
  /**
@@ -1018,13 +1045,14 @@ DragRef = /** @class */ (function () {
1018
1045
  */
1019
1046
  function (rootElement) {
1020
1047
  /** @type {?} */
1021
- var element = rootElement instanceof core.ElementRef ? rootElement.nativeElement : rootElement;
1048
+ var element = coercion.coerceElement(rootElement);
1022
1049
  if (element !== (/** @type {?} */ (this))._rootElement) {
1023
1050
  if ((/** @type {?} */ (this))._rootElement) {
1024
1051
  (/** @type {?} */ (this))._removeRootElementListeners((/** @type {?} */ (this))._rootElement);
1025
1052
  }
1026
1053
  element.addEventListener('mousedown', (/** @type {?} */ (this))._pointerDown, activeEventListenerOptions);
1027
1054
  element.addEventListener('touchstart', (/** @type {?} */ (this))._pointerDown, passiveEventListenerOptions);
1055
+ (/** @type {?} */ (this))._initialTransform = undefined;
1028
1056
  (/** @type {?} */ (this))._rootElement = element;
1029
1057
  }
1030
1058
  return (/** @type {?} */ (this));
@@ -1047,8 +1075,7 @@ DragRef = /** @class */ (function () {
1047
1075
  * @return {THIS}
1048
1076
  */
1049
1077
  function (boundaryElement) {
1050
- (/** @type {?} */ (this))._boundaryElement = boundaryElement instanceof core.ElementRef ?
1051
- boundaryElement.nativeElement : boundaryElement;
1078
+ (/** @type {?} */ (this))._boundaryElement = boundaryElement ? coercion.coerceElement(boundaryElement) : null;
1052
1079
  return (/** @type {?} */ (this));
1053
1080
  };
1054
1081
  /** Removes the dragging functionality from the DOM element. */
@@ -1082,6 +1109,7 @@ DragRef = /** @class */ (function () {
1082
1109
  this.dropped.complete();
1083
1110
  this._moveEvents.complete();
1084
1111
  this._handles = [];
1112
+ this._disabledHandles.clear();
1085
1113
  this._boundaryElement = this._rootElement = this._placeholderTemplate =
1086
1114
  this._previewTemplate = this._nextSibling = (/** @type {?} */ (null));
1087
1115
  };
@@ -1107,10 +1135,46 @@ DragRef = /** @class */ (function () {
1107
1135
  * @return {?}
1108
1136
  */
1109
1137
  function () {
1110
- this._rootElement.style.transform = '';
1138
+ this._rootElement.style.transform = this._initialTransform || '';
1111
1139
  this._activeTransform = { x: 0, y: 0 };
1112
1140
  this._passiveTransform = { x: 0, y: 0 };
1113
1141
  };
1142
+ /**
1143
+ * Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.
1144
+ * @param handle Handle element that should be disabled.
1145
+ */
1146
+ /**
1147
+ * Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.
1148
+ * @param {?} handle Handle element that should be disabled.
1149
+ * @return {?}
1150
+ */
1151
+ DragRef.prototype.disableHandle = /**
1152
+ * Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.
1153
+ * @param {?} handle Handle element that should be disabled.
1154
+ * @return {?}
1155
+ */
1156
+ function (handle) {
1157
+ if (this._handles.indexOf(handle) > -1) {
1158
+ this._disabledHandles.add(handle);
1159
+ }
1160
+ };
1161
+ /**
1162
+ * Enables a handle, if it has been disabled.
1163
+ * @param handle Handle element to be enabled.
1164
+ */
1165
+ /**
1166
+ * Enables a handle, if it has been disabled.
1167
+ * @param {?} handle Handle element to be enabled.
1168
+ * @return {?}
1169
+ */
1170
+ DragRef.prototype.enableHandle = /**
1171
+ * Enables a handle, if it has been disabled.
1172
+ * @param {?} handle Handle element to be enabled.
1173
+ * @return {?}
1174
+ */
1175
+ function (handle) {
1176
+ this._disabledHandles.delete(handle);
1177
+ };
1114
1178
  /** Unsubscribes from the global subscriptions. */
1115
1179
  /**
1116
1180
  * Unsubscribes from the global subscriptions.
@@ -1278,7 +1342,8 @@ DragRef = /** @class */ (function () {
1278
1342
  }
1279
1343
  // If we have a custom preview template, the element won't be visible anyway so we avoid the
1280
1344
  // extra `getBoundingClientRect` calls and just move the preview next to the cursor.
1281
- this._pickupPositionInElement = this._previewTemplate ? { x: 0, y: 0 } :
1345
+ this._pickupPositionInElement = this._previewTemplate && this._previewTemplate.template ?
1346
+ { x: 0, y: 0 } :
1282
1347
  this._getPointerPositionInElement(referenceElement, event);
1283
1348
  /** @type {?} */
1284
1349
  var pointerPosition = this._pickupPositionOnPage = this._getPointerPositionOnPage(event);
@@ -1360,7 +1425,8 @@ DragRef = /** @class */ (function () {
1360
1425
  var x = _a.x, y = _a.y;
1361
1426
  // Drop container that draggable has been moved into.
1362
1427
  /** @type {?} */
1363
- var newContainer = (/** @type {?} */ (this.dropContainer))._getSiblingContainerFromPosition(this, x, y);
1428
+ var newContainer = (/** @type {?} */ (this.dropContainer))._getSiblingContainerFromPosition(this, x, y) ||
1429
+ this._initialContainer._getSiblingContainerFromPosition(this, x, y);
1364
1430
  // If we couldn't find a new container to move the item into, and the item has left it's
1365
1431
  // initial container, check whether the it's over the initial container. This handles the
1366
1432
  // case where two containers are connected one way and the user tries to undo dragging an
@@ -1369,7 +1435,7 @@ DragRef = /** @class */ (function () {
1369
1435
  this._initialContainer._isOverContainer(x, y)) {
1370
1436
  newContainer = this._initialContainer;
1371
1437
  }
1372
- if (newContainer) {
1438
+ if (newContainer && newContainer !== this.dropContainer) {
1373
1439
  this._ngZone.run(function () {
1374
1440
  // Notify the old container that the item has left.
1375
1441
  _this.exited.next({ item: _this, container: (/** @type {?} */ (_this.dropContainer)) });
@@ -1401,11 +1467,13 @@ DragRef = /** @class */ (function () {
1401
1467
  * @return {?}
1402
1468
  */
1403
1469
  function () {
1470
+ /** @type {?} */
1471
+ var previewTemplate = this._previewTemplate;
1404
1472
  /** @type {?} */
1405
1473
  var preview;
1406
- if (this._previewTemplate) {
1474
+ if (previewTemplate && previewTemplate.template) {
1407
1475
  /** @type {?} */
1408
- var viewRef = this._viewContainerRef.createEmbeddedView(this._previewTemplate.templateRef, this._previewTemplate.data);
1476
+ var viewRef = this._viewContainerRef.createEmbeddedView(previewTemplate.template, previewTemplate.context);
1409
1477
  preview = viewRef.rootNodes[0];
1410
1478
  this._previewRef = viewRef;
1411
1479
  preview.style.transform =
@@ -1501,10 +1569,12 @@ DragRef = /** @class */ (function () {
1501
1569
  * @return {?}
1502
1570
  */
1503
1571
  function () {
1572
+ /** @type {?} */
1573
+ var placeholderTemplate = this._placeholderTemplate;
1504
1574
  /** @type {?} */
1505
1575
  var placeholder;
1506
- if (this._placeholderTemplate) {
1507
- this._placeholderRef = this._viewContainerRef.createEmbeddedView(this._placeholderTemplate.templateRef, this._placeholderTemplate.data);
1576
+ if (placeholderTemplate && placeholderTemplate.template) {
1577
+ this._placeholderRef = this._viewContainerRef.createEmbeddedView(placeholderTemplate.template, placeholderTemplate.context);
1508
1578
  placeholder = this._placeholderRef.rootNodes[0];
1509
1579
  }
1510
1580
  else {
@@ -1781,10 +1851,7 @@ var CdkDrag = /** @class */ (function () {
1781
1851
  this._dragDropRegistry = _dragDropRegistry;
1782
1852
  this._config = _config;
1783
1853
  this._dir = _dir;
1784
- /**
1785
- * Subscription to the stream that initializes the root element.
1786
- */
1787
- this._rootElementInitSubscription = rxjs.Subscription.EMPTY;
1854
+ this._destroyed = new rxjs.Subject();
1788
1855
  this._disabled = false;
1789
1856
  /**
1790
1857
  * Emits when the user starts dragging the item.
@@ -1814,7 +1881,7 @@ var CdkDrag = /** @class */ (function () {
1814
1881
  * Emits as the user is dragging the item. Use with caution,
1815
1882
  * because this event will fire for every pixel that the user has dragged.
1816
1883
  */
1817
- this.moved = rxjs.Observable.create(function (observer) {
1884
+ this.moved = new rxjs.Observable(function (observer) {
1818
1885
  /** @type {?} */
1819
1886
  var subscription = _this._dragRef.moved.pipe(operators.map(function (movedEvent) { return ({
1820
1887
  source: _this,
@@ -1829,16 +1896,7 @@ var CdkDrag = /** @class */ (function () {
1829
1896
  /** @type {?} */
1830
1897
  var ref = this._dragRef = new DragRef(element, this._document, this._ngZone, this._viewContainerRef, this._viewportRuler, this._dragDropRegistry, this._config, this.dropContainer ? this.dropContainer._dropListRef : undefined, this._dir);
1831
1898
  ref.data = this;
1832
- ref.beforeStarted.subscribe(function () {
1833
- if (!ref.isDragging()) {
1834
- ref.disabled = _this.disabled;
1835
- ref.lockAxis = _this.lockAxis;
1836
- ref
1837
- .withBoundaryElement(_this._getBoundaryElement())
1838
- .withPlaceholderTemplate(_this._placeholderTemplate)
1839
- .withPreviewTemplate(_this._previewTemplate);
1840
- }
1841
- });
1899
+ this._syncInputs(ref);
1842
1900
  this._proxyEvents(ref);
1843
1901
  }
1844
1902
  Object.defineProperty(CdkDrag.prototype, "disabled", {
@@ -1914,14 +1972,30 @@ var CdkDrag = /** @class */ (function () {
1914
1972
  // element to be in the proper place in the DOM. This is mostly relevant
1915
1973
  // for draggable elements inside portals since they get stamped out in
1916
1974
  // their original DOM position and then they get transferred to the portal.
1917
- this._rootElementInitSubscription = this._ngZone.onStable.asObservable()
1918
- .pipe(operators.take(1))
1975
+ this._ngZone.onStable.asObservable()
1976
+ .pipe(operators.take(1), operators.takeUntil(this._destroyed))
1919
1977
  .subscribe(function () {
1920
1978
  _this._updateRootElement();
1921
- _this._handles.changes
1922
- .pipe(operators.startWith(_this._handles))
1923
- .subscribe(function (handleList) {
1924
- _this._dragRef.withHandles(handleList.filter(function (handle) { return handle._parentDrag === _this; }));
1979
+ // Listen for any newly-added handles.
1980
+ _this._handles.changes.pipe(operators.startWith(_this._handles),
1981
+ // Sync the new handles with the DragRef.
1982
+ operators.tap(function (handles) {
1983
+ /** @type {?} */
1984
+ var childHandleElements = handles
1985
+ .filter(function (handle) { return handle._parentDrag === _this; })
1986
+ .map(function (handle) { return handle.element; });
1987
+ _this._dragRef.withHandles(childHandleElements);
1988
+ }),
1989
+ // Listen if the state of any of the handles changes.
1990
+ operators.switchMap(function (handles) {
1991
+ return rxjs.merge.apply(void 0, handles.map(function (item) { return item._stateChanges; }));
1992
+ }), operators.takeUntil(_this._destroyed)).subscribe(function (handleInstance) {
1993
+ // Enabled/disable the handle that changed in the DragRef.
1994
+ /** @type {?} */
1995
+ var dragRef = _this._dragRef;
1996
+ /** @type {?} */
1997
+ var handle = handleInstance.element.nativeElement;
1998
+ handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
1925
1999
  });
1926
2000
  });
1927
2001
  };
@@ -1949,7 +2023,8 @@ var CdkDrag = /** @class */ (function () {
1949
2023
  * @return {?}
1950
2024
  */
1951
2025
  function () {
1952
- this._rootElementInitSubscription.unsubscribe();
2026
+ this._destroyed.next();
2027
+ this._destroyed.complete();
1953
2028
  this._dragRef.dispose();
1954
2029
  };
1955
2030
  /** Syncs the root element with the `DragRef`. */
@@ -1991,6 +2066,34 @@ var CdkDrag = /** @class */ (function () {
1991
2066
  var selector = this.boundaryElementSelector;
1992
2067
  return selector ? getClosestMatchingAncestor(this.element.nativeElement, selector) : null;
1993
2068
  };
2069
+ /** Syncs the inputs of the CdkDrag with the options of the underlying DragRef. */
2070
+ /**
2071
+ * Syncs the inputs of the CdkDrag with the options of the underlying DragRef.
2072
+ * @private
2073
+ * @param {?} ref
2074
+ * @return {?}
2075
+ */
2076
+ CdkDrag.prototype._syncInputs = /**
2077
+ * Syncs the inputs of the CdkDrag with the options of the underlying DragRef.
2078
+ * @private
2079
+ * @param {?} ref
2080
+ * @return {?}
2081
+ */
2082
+ function (ref) {
2083
+ var _this = this;
2084
+ ref.beforeStarted.subscribe(function () {
2085
+ if (!ref.isDragging()) {
2086
+ var _a = _this, placeholder = _a._placeholderTemplate, preview = _a._previewTemplate;
2087
+ ref.disabled = _this.disabled;
2088
+ ref.lockAxis = _this.lockAxis;
2089
+ ref.withBoundaryElement(_this._getBoundaryElement());
2090
+ placeholder ? ref.withPlaceholderTemplate(placeholder.templateRef, placeholder.data) :
2091
+ ref.withPlaceholderTemplate(null);
2092
+ preview ? ref.withPreviewTemplate(preview.templateRef, preview.data) :
2093
+ ref.withPreviewTemplate(null);
2094
+ }
2095
+ });
2096
+ };
1994
2097
  /**
1995
2098
  * Proxies the events from a DragRef to events that
1996
2099
  * match the interfaces of the CdkDrag outputs.
@@ -2233,23 +2336,26 @@ DropListRef = /** @class */ (function () {
2233
2336
  */
2234
2337
  this._isDragging = false;
2235
2338
  /**
2236
- * Cache of the dimensions of all the items and the sibling containers.
2339
+ * Cache of the dimensions of all the items inside the container.
2237
2340
  */
2238
- this._positionCache = { items: [], siblings: [], self: (/** @type {?} */ ({})) };
2341
+ this._itemPositions = [];
2239
2342
  /**
2240
2343
  * Keeps track of the item that was last swapped with the dragged item, as
2241
2344
  * well as what direction the pointer was moving in when the swap occured.
2242
2345
  */
2243
2346
  this._previousSwap = { drag: (/** @type {?} */ (null)), delta: 0 };
2347
+ /**
2348
+ * Drop lists that are connected to the current one.
2349
+ */
2244
2350
  this._siblings = [];
2245
2351
  /**
2246
2352
  * Direction in which the list is oriented.
2247
2353
  */
2248
2354
  this._orientation = 'vertical';
2249
2355
  /**
2250
- * Amount of connected siblings that currently have a dragged item.
2356
+ * Connected siblings that currently have a dragged item.
2251
2357
  */
2252
- this._activeSiblings = 0;
2358
+ this._activeSiblings = new Set();
2253
2359
  _dragDropRegistry.registerDropContainer(this);
2254
2360
  this._document = _document;
2255
2361
  }
@@ -2268,6 +2374,7 @@ DropListRef = /** @class */ (function () {
2268
2374
  this.exited.complete();
2269
2375
  this.dropped.complete();
2270
2376
  this.sorted.complete();
2377
+ this._activeSiblings.clear();
2271
2378
  this._dragDropRegistry.removeDropContainer(this);
2272
2379
  };
2273
2380
  /** Whether an item from this list is currently being dragged. */
@@ -2292,11 +2399,13 @@ DropListRef = /** @class */ (function () {
2292
2399
  * @return {?}
2293
2400
  */
2294
2401
  function () {
2402
+ var _this = this;
2295
2403
  this.beforeStarted.next();
2296
2404
  this._isDragging = true;
2297
2405
  this._activeDraggables = this._draggables.slice();
2298
- this._cachePositions();
2299
- this._positionCache.siblings.forEach(function (sibling) { return sibling.drop._toggleIsReceiving(true); });
2406
+ this._cacheOwnPosition();
2407
+ this._cacheItemPositions();
2408
+ this._siblings.forEach(function (sibling) { return sibling._startReceiving(_this); });
2300
2409
  };
2301
2410
  /**
2302
2411
  * Emits an event to indicate that the user moved an item into the container.
@@ -2352,7 +2461,7 @@ DropListRef = /** @class */ (function () {
2352
2461
  placeholder.style.transform = '';
2353
2462
  // Note that the positions were already cached when we called `start` above,
2354
2463
  // but we need to refresh them since the amount of items has changed.
2355
- this._cachePositions();
2464
+ this._cacheItemPositions();
2356
2465
  };
2357
2466
  /**
2358
2467
  * Removes an item from the container after it was dragged into another container by the user.
@@ -2501,7 +2610,7 @@ DropListRef = /** @class */ (function () {
2501
2610
  // we need to invert the array when determining the index.
2502
2611
  /** @type {?} */
2503
2612
  var items = this._orientation === 'horizontal' && this._dir && this._dir.value === 'rtl' ?
2504
- this._positionCache.items.slice().reverse() : this._positionCache.items;
2613
+ this._itemPositions.slice().reverse() : this._itemPositions;
2505
2614
  return findIndex(items, function (currentItem) { return currentItem.drag === item; });
2506
2615
  };
2507
2616
  /**
@@ -2519,7 +2628,7 @@ DropListRef = /** @class */ (function () {
2519
2628
  * @return {?}
2520
2629
  */
2521
2630
  function () {
2522
- return this._activeSiblings > 0;
2631
+ return this._activeSiblings.size > 0;
2523
2632
  };
2524
2633
  /**
2525
2634
  * Sorts an item inside the container based on its position.
@@ -2550,7 +2659,7 @@ DropListRef = /** @class */ (function () {
2550
2659
  return;
2551
2660
  }
2552
2661
  /** @type {?} */
2553
- var siblings = this._positionCache.items;
2662
+ var siblings = this._itemPositions;
2554
2663
  /** @type {?} */
2555
2664
  var newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY, pointerDelta);
2556
2665
  if (newIndex === -1 && siblings.length > 0) {
@@ -2618,13 +2727,27 @@ DropListRef = /** @class */ (function () {
2618
2727
  }
2619
2728
  });
2620
2729
  };
2730
+ /** Caches the position of the drop list. */
2731
+ /**
2732
+ * Caches the position of the drop list.
2733
+ * @private
2734
+ * @return {?}
2735
+ */
2736
+ DropListRef.prototype._cacheOwnPosition = /**
2737
+ * Caches the position of the drop list.
2738
+ * @private
2739
+ * @return {?}
2740
+ */
2741
+ function () {
2742
+ this._clientRect = this.element.nativeElement.getBoundingClientRect();
2743
+ };
2621
2744
  /** Refreshes the position cache of the items and sibling containers. */
2622
2745
  /**
2623
2746
  * Refreshes the position cache of the items and sibling containers.
2624
2747
  * @private
2625
2748
  * @return {?}
2626
2749
  */
2627
- DropListRef.prototype._cachePositions = /**
2750
+ DropListRef.prototype._cacheItemPositions = /**
2628
2751
  * Refreshes the position cache of the items and sibling containers.
2629
2752
  * @private
2630
2753
  * @return {?}
@@ -2633,9 +2756,7 @@ DropListRef = /** @class */ (function () {
2633
2756
  var _this = this;
2634
2757
  /** @type {?} */
2635
2758
  var isHorizontal = this._orientation === 'horizontal';
2636
- this._positionCache.self = this.element.nativeElement.getBoundingClientRect();
2637
- this._positionCache.items = this._activeDraggables
2638
- .map(function (drag) {
2759
+ this._itemPositions = this._activeDraggables.map(function (drag) {
2639
2760
  /** @type {?} */
2640
2761
  var elementToMeasure = _this._dragDropRegistry.isDragging(drag) ?
2641
2762
  // If the element is being dragged, we have to measure the
@@ -2660,34 +2781,10 @@ DropListRef = /** @class */ (function () {
2660
2781
  height: clientRect.height
2661
2782
  }
2662
2783
  };
2663
- })
2664
- .sort(function (a, b) {
2784
+ }).sort(function (a, b) {
2665
2785
  return isHorizontal ? a.clientRect.left - b.clientRect.left :
2666
2786
  a.clientRect.top - b.clientRect.top;
2667
2787
  });
2668
- this._positionCache.siblings = this._siblings.map(function (drop) { return ({
2669
- drop: drop,
2670
- clientRect: drop.element.nativeElement.getBoundingClientRect()
2671
- }); });
2672
- };
2673
- /**
2674
- * Toggles whether the list can receive the item that is currently being dragged.
2675
- * Usually called by a sibling that initiated the dragging.
2676
- */
2677
- /**
2678
- * Toggles whether the list can receive the item that is currently being dragged.
2679
- * Usually called by a sibling that initiated the dragging.
2680
- * @param {?} isDragging
2681
- * @return {?}
2682
- */
2683
- DropListRef.prototype._toggleIsReceiving = /**
2684
- * Toggles whether the list can receive the item that is currently being dragged.
2685
- * Usually called by a sibling that initiated the dragging.
2686
- * @param {?} isDragging
2687
- * @return {?}
2688
- */
2689
- function (isDragging) {
2690
- this._activeSiblings = Math.max(0, this._activeSiblings + (isDragging ? 1 : -1));
2691
2788
  };
2692
2789
  /** Resets the container to its initial state. */
2693
2790
  /**
@@ -2701,13 +2798,13 @@ DropListRef = /** @class */ (function () {
2701
2798
  * @return {?}
2702
2799
  */
2703
2800
  function () {
2801
+ var _this = this;
2704
2802
  this._isDragging = false;
2705
2803
  // TODO(crisbeto): may have to wait for the animations to finish.
2706
2804
  this._activeDraggables.forEach(function (item) { return item.getRootElement().style.transform = ''; });
2707
- this._positionCache.siblings.forEach(function (sibling) { return sibling.drop._toggleIsReceiving(false); });
2805
+ this._siblings.forEach(function (sibling) { return sibling._stopReceiving(_this); });
2708
2806
  this._activeDraggables = [];
2709
- this._positionCache.items = [];
2710
- this._positionCache.siblings = [];
2807
+ this._itemPositions = [];
2711
2808
  this._previousSwap.drag = null;
2712
2809
  this._previousSwap.delta = 0;
2713
2810
  };
@@ -2780,7 +2877,7 @@ DropListRef = /** @class */ (function () {
2780
2877
  * @return {?}
2781
2878
  */
2782
2879
  function (pointerX, pointerY) {
2783
- var _a = this._positionCache.self, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
2880
+ var _a = this._clientRect, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
2784
2881
  /** @type {?} */
2785
2882
  var xThreshold = width * DROP_PROXIMITY_THRESHOLD;
2786
2883
  /** @type {?} */
@@ -2852,7 +2949,7 @@ DropListRef = /** @class */ (function () {
2852
2949
  var _this = this;
2853
2950
  /** @type {?} */
2854
2951
  var isHorizontal = this._orientation === 'horizontal';
2855
- return findIndex(this._positionCache.items, function (_a, _, array) {
2952
+ return findIndex(this._itemPositions, function (_a, _, array) {
2856
2953
  var drag = _a.drag, clientRect = _a.clientRect;
2857
2954
  if (drag === item) {
2858
2955
  // If there's only one item left in the container, it must be
@@ -2893,7 +2990,7 @@ DropListRef = /** @class */ (function () {
2893
2990
  * @return {?}
2894
2991
  */
2895
2992
  function (x, y) {
2896
- return isInsideClientRect(this._positionCache.self, x, y);
2993
+ return isInsideClientRect(this._clientRect, x, y);
2897
2994
  };
2898
2995
  /**
2899
2996
  * Figures out whether an item should be moved into a sibling
@@ -2919,34 +3016,87 @@ DropListRef = /** @class */ (function () {
2919
3016
  * @return {?}
2920
3017
  */
2921
3018
  function (item, x, y) {
2922
- /** @type {?} */
2923
- var results = this._positionCache.siblings.filter(function (sibling) {
2924
- return isInsideClientRect(sibling.clientRect, x, y);
2925
- });
2926
- // No drop containers are intersecting with the pointer.
2927
- if (!results.length) {
2928
- return null;
3019
+ return this._siblings.find(function (sibling) { return sibling._canReceive(item, x, y); });
3020
+ };
3021
+ /**
3022
+ * Checks whether the drop list can receive the passed-in item.
3023
+ * @param item Item that is being dragged into the list.
3024
+ * @param x Position of the item along the X axis.
3025
+ * @param y Position of the item along the Y axis.
3026
+ */
3027
+ /**
3028
+ * Checks whether the drop list can receive the passed-in item.
3029
+ * @param {?} item Item that is being dragged into the list.
3030
+ * @param {?} x Position of the item along the X axis.
3031
+ * @param {?} y Position of the item along the Y axis.
3032
+ * @return {?}
3033
+ */
3034
+ DropListRef.prototype._canReceive = /**
3035
+ * Checks whether the drop list can receive the passed-in item.
3036
+ * @param {?} item Item that is being dragged into the list.
3037
+ * @param {?} x Position of the item along the X axis.
3038
+ * @param {?} y Position of the item along the Y axis.
3039
+ * @return {?}
3040
+ */
3041
+ function (item, x, y) {
3042
+ if (!this.enterPredicate(item, this) || !isInsideClientRect(this._clientRect, x, y)) {
3043
+ return false;
2929
3044
  }
2930
3045
  /** @type {?} */
2931
3046
  var elementFromPoint = this._document.elementFromPoint(x, y);
2932
3047
  // If there's no element at the pointer position, then
2933
3048
  // the client rect is probably scrolled out of the view.
2934
3049
  if (!elementFromPoint) {
2935
- return null;
3050
+ return false;
2936
3051
  }
3052
+ /** @type {?} */
3053
+ var element = this.element.nativeElement;
2937
3054
  // The `ClientRect`, that we're using to find the container over which the user is
2938
3055
  // hovering, doesn't give us any information on whether the element has been scrolled
2939
3056
  // out of the view or whether it's overlapping with other containers. This means that
2940
3057
  // we could end up transferring the item into a container that's invisible or is positioned
2941
3058
  // below another one. We use the result from `elementFromPoint` to get the top-most element
2942
3059
  // at the pointer position and to find whether it's one of the intersecting drop containers.
3060
+ return elementFromPoint === element || element.contains(elementFromPoint);
3061
+ };
3062
+ /**
3063
+ * Called by one of the connected drop lists when a dragging sequence has started.
3064
+ * @param sibling Sibling in which dragging has started.
3065
+ */
3066
+ /**
3067
+ * Called by one of the connected drop lists when a dragging sequence has started.
3068
+ * @param {?} sibling Sibling in which dragging has started.
3069
+ * @return {?}
3070
+ */
3071
+ DropListRef.prototype._startReceiving = /**
3072
+ * Called by one of the connected drop lists when a dragging sequence has started.
3073
+ * @param {?} sibling Sibling in which dragging has started.
3074
+ * @return {?}
3075
+ */
3076
+ function (sibling) {
2943
3077
  /** @type {?} */
2944
- var result = results.find(function (sibling) {
2945
- /** @type {?} */
2946
- var element = sibling.drop.element.nativeElement;
2947
- return element === elementFromPoint || element.contains(elementFromPoint);
2948
- });
2949
- return result && result.drop.enterPredicate(item, result.drop) ? result.drop : null;
3078
+ var activeSiblings = this._activeSiblings;
3079
+ if (!activeSiblings.has(sibling)) {
3080
+ activeSiblings.add(sibling);
3081
+ this._cacheOwnPosition();
3082
+ }
3083
+ };
3084
+ /**
3085
+ * Called by a connected drop list when dragging has stopped.
3086
+ * @param sibling Sibling whose dragging has stopped.
3087
+ */
3088
+ /**
3089
+ * Called by a connected drop list when dragging has stopped.
3090
+ * @param {?} sibling Sibling whose dragging has stopped.
3091
+ * @return {?}
3092
+ */
3093
+ DropListRef.prototype._stopReceiving = /**
3094
+ * Called by a connected drop list when dragging has stopped.
3095
+ * @param {?} sibling Sibling whose dragging has stopped.
3096
+ * @return {?}
3097
+ */
3098
+ function (sibling) {
3099
+ this._activeSiblings.delete(sibling);
2950
3100
  };
2951
3101
  return DropListRef;
2952
3102
  }());
@@ -3062,7 +3212,7 @@ var CdkDropList = /** @class */ (function () {
3062
3212
  return _this.enterPredicate(drag.data, drop.data);
3063
3213
  };
3064
3214
  this._syncInputs(ref);
3065
- this._proxyEvents(ref);
3215
+ this._handleEvents(ref);
3066
3216
  CdkDropList._dropLists.push(this);
3067
3217
  if (_group) {
3068
3218
  _group._items.add(this);
@@ -3311,20 +3461,15 @@ var CdkDropList = /** @class */ (function () {
3311
3461
  .withItems(_this._draggables.map(function (drag) { return drag._dragRef; }));
3312
3462
  });
3313
3463
  };
3464
+ /** Handles events from the underlying DropListRef. */
3314
3465
  /**
3315
- * Proxies the events from a DropListRef to events that
3316
- * match the interfaces of the CdkDropList outputs.
3317
- */
3318
- /**
3319
- * Proxies the events from a DropListRef to events that
3320
- * match the interfaces of the CdkDropList outputs.
3466
+ * Handles events from the underlying DropListRef.
3321
3467
  * @private
3322
3468
  * @param {?} ref
3323
3469
  * @return {?}
3324
3470
  */
3325
- CdkDropList.prototype._proxyEvents = /**
3326
- * Proxies the events from a DropListRef to events that
3327
- * match the interfaces of the CdkDropList outputs.
3471
+ CdkDropList.prototype._handleEvents = /**
3472
+ * Handles events from the underlying DropListRef.
3328
3473
  * @private
3329
3474
  * @param {?} ref
3330
3475
  * @return {?}
@@ -3363,6 +3508,9 @@ var CdkDropList = /** @class */ (function () {
3363
3508
  item: event.item.data,
3364
3509
  isPointerOverContainer: event.isPointerOverContainer
3365
3510
  });
3511
+ // Mark for check since all of these events run outside of change
3512
+ // detection and we're not guaranteed for something else to have triggered it.
3513
+ _this._changeDetectorRef.markForCheck();
3366
3514
  });
3367
3515
  };
3368
3516
  /**