@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
@@ -8,11 +8,11 @@
8
8
  import { InjectionToken, Injectable, NgZone, Inject, NgModule, ContentChildren, ElementRef, EventEmitter, forwardRef, Input, Output, Optional, Directive, ChangeDetectorRef, SkipSelf, ContentChild, ViewContainerRef, TemplateRef, defineInjectable, inject } from '@angular/core';
9
9
  import { DOCUMENT } from '@angular/common';
10
10
  import { normalizePassiveListenerOptions } from '@angular/cdk/platform';
11
- import { Subject, Subscription, Observable } from 'rxjs';
12
- import { coerceBooleanProperty, coerceArray } from '@angular/cdk/coercion';
11
+ import { Subject, Subscription, Observable, merge } from 'rxjs';
12
+ import { coerceBooleanProperty, coerceElement, coerceArray } from '@angular/cdk/coercion';
13
13
  import { Directionality } from '@angular/cdk/bidi';
14
14
  import { ViewportRuler } from '@angular/cdk/scrolling';
15
- import { startWith, take, map } from 'rxjs/operators';
15
+ import { startWith, take, map, takeUntil, switchMap, tap } from 'rxjs/operators';
16
16
 
17
17
  /**
18
18
  * @fileoverview added by tsickle
@@ -474,6 +474,10 @@ function toggleNativeDragInteractions(element, enable) {
474
474
  var CdkDragHandle = /** @class */ (function () {
475
475
  function CdkDragHandle(element, parentDrag) {
476
476
  this.element = element;
477
+ /**
478
+ * Emits when the state of the handle has changed.
479
+ */
480
+ this._stateChanges = new Subject();
477
481
  this._disabled = false;
478
482
  this._parentDrag = parentDrag;
479
483
  toggleNativeDragInteractions(element.nativeElement, false);
@@ -491,10 +495,20 @@ var CdkDragHandle = /** @class */ (function () {
491
495
  */
492
496
  function (value) {
493
497
  this._disabled = coerceBooleanProperty(value);
498
+ this._stateChanges.next(this);
494
499
  },
495
500
  enumerable: true,
496
501
  configurable: true
497
502
  });
503
+ /**
504
+ * @return {?}
505
+ */
506
+ CdkDragHandle.prototype.ngOnDestroy = /**
507
+ * @return {?}
508
+ */
509
+ function () {
510
+ this._stateChanges.complete();
511
+ };
498
512
  CdkDragHandle.decorators = [
499
513
  { type: Directive, args: [{
500
514
  selector: '[cdkDragHandle]',
@@ -708,6 +722,10 @@ DragRef = /** @class */ (function () {
708
722
  * Elements that can be used to drag the draggable item.
709
723
  */
710
724
  this._handles = [];
725
+ /**
726
+ * Registered handles that are currently disabled.
727
+ */
728
+ this._disabledHandles = new Set();
711
729
  this._disabled = false;
712
730
  /**
713
731
  * Emits as the drag sequence is being prepared.
@@ -741,7 +759,7 @@ DragRef = /** @class */ (function () {
741
759
  * Emits as the user is dragging the item. Use with caution,
742
760
  * because this event will fire for every pixel that the user has dragged.
743
761
  */
744
- this.moved = Observable.create(function (observer) {
762
+ this.moved = new Observable(function (observer) {
745
763
  /** @type {?} */
746
764
  var subscription = _this._moveEvents.subscribe(observer);
747
765
  _this._moveEventSubscriptions++;
@@ -759,14 +777,12 @@ DragRef = /** @class */ (function () {
759
777
  if (_this._handles.length) {
760
778
  /** @type {?} */
761
779
  var targetHandle = _this._handles.find(function (handle) {
762
- /** @type {?} */
763
- var element = handle.element.nativeElement;
764
780
  /** @type {?} */
765
781
  var target = event.target;
766
- return !!target && (target === element || element.contains((/** @type {?} */ (target))));
782
+ return !!target && (target === handle || handle.contains((/** @type {?} */ (target))));
767
783
  });
768
- if (targetHandle && !targetHandle.disabled && !_this.disabled) {
769
- _this._initializeDragSequence(targetHandle.element.nativeElement, event);
784
+ if (targetHandle && !_this._disabledHandles.has(targetHandle) && !_this.disabled) {
785
+ _this._initializeDragSequence(targetHandle, event);
770
786
  }
771
787
  }
772
788
  else if (!_this.disabled) {
@@ -819,9 +835,11 @@ DragRef = /** @class */ (function () {
819
835
  constrainedPointerPosition.y - _this._pickupPositionOnPage.y + _this._passiveTransform.y;
820
836
  /** @type {?} */
821
837
  var transform = getTransform(activeTransform.x, activeTransform.y);
822
- // Preserve the previous `transform` value, if there was one.
838
+ // Preserve the previous `transform` value, if there was one. Note that we apply our own
839
+ // transform before the user's, because things like rotation can affect which direction
840
+ // the element will be translated towards.
823
841
  _this._rootElement.style.transform = _this._initialTransform ?
824
- _this._initialTransform + ' ' + transform : transform;
842
+ transform + ' ' + _this._initialTransform : transform;
825
843
  // Apply transform as attribute if dragging and svg element to work for IE
826
844
  if (typeof SVGElement !== 'undefined' && _this._rootElement instanceof SVGElement) {
827
845
  /** @type {?} */
@@ -950,50 +968,59 @@ DragRef = /** @class */ (function () {
950
968
  * @return {THIS}
951
969
  */
952
970
  function (handles) {
953
- // TODO(crisbeto): have this accept HTMLElement[] | ElementRef<HTMLElement>[]
954
- (/** @type {?} */ (this))._handles = handles;
955
- handles.forEach(function (handle) { return toggleNativeDragInteractions(handle.element.nativeElement, false); });
971
+ (/** @type {?} */ (this))._handles = handles.map(function (handle) { return coerceElement(handle); });
972
+ (/** @type {?} */ (this))._handles.forEach(function (handle) { return toggleNativeDragInteractions(handle, false); });
956
973
  (/** @type {?} */ (this))._toggleNativeDragInteractions();
957
974
  return (/** @type {?} */ (this));
958
975
  };
959
- /** Registers the template that should be used for the drag preview. */
976
+ /**
977
+ * Registers the template that should be used for the drag preview.
978
+ * @param template Template that from which to stamp out the preview.
979
+ * @param context Variables to add to the template's context.
980
+ */
960
981
  /**
961
982
  * Registers the template that should be used for the drag preview.
962
983
  * @template THIS
963
984
  * @this {THIS}
964
- * @param {?} template
985
+ * @param {?} template Template that from which to stamp out the preview.
986
+ * @param {?=} context Variables to add to the template's context.
965
987
  * @return {THIS}
966
988
  */
967
989
  DragRef.prototype.withPreviewTemplate = /**
968
990
  * Registers the template that should be used for the drag preview.
969
991
  * @template THIS
970
992
  * @this {THIS}
971
- * @param {?} template
993
+ * @param {?} template Template that from which to stamp out the preview.
994
+ * @param {?=} context Variables to add to the template's context.
972
995
  * @return {THIS}
973
996
  */
974
- function (template) {
975
- // TODO(crisbeto): have this accept a TemplateRef
976
- (/** @type {?} */ (this))._previewTemplate = template;
997
+ function (template, context) {
998
+ (/** @type {?} */ (this))._previewTemplate = { template: template, context: context };
977
999
  return (/** @type {?} */ (this));
978
1000
  };
979
- /** Registers the template that should be used for the drag placeholder. */
1001
+ /**
1002
+ * Registers the template that should be used for the drag placeholder.
1003
+ * @param template Template that from which to stamp out the placeholder.
1004
+ * @param context Variables to add to the template's context.
1005
+ */
980
1006
  /**
981
1007
  * Registers the template that should be used for the drag placeholder.
982
1008
  * @template THIS
983
1009
  * @this {THIS}
984
- * @param {?} template
1010
+ * @param {?} template Template that from which to stamp out the placeholder.
1011
+ * @param {?=} context Variables to add to the template's context.
985
1012
  * @return {THIS}
986
1013
  */
987
1014
  DragRef.prototype.withPlaceholderTemplate = /**
988
1015
  * Registers the template that should be used for the drag placeholder.
989
1016
  * @template THIS
990
1017
  * @this {THIS}
991
- * @param {?} template
1018
+ * @param {?} template Template that from which to stamp out the placeholder.
1019
+ * @param {?=} context Variables to add to the template's context.
992
1020
  * @return {THIS}
993
1021
  */
994
- function (template) {
995
- // TODO(crisbeto): have this accept a TemplateRef
996
- (/** @type {?} */ (this))._placeholderTemplate = template;
1022
+ function (template, context) {
1023
+ (/** @type {?} */ (this))._placeholderTemplate = { template: template, context: context };
997
1024
  return (/** @type {?} */ (this));
998
1025
  };
999
1026
  /**
@@ -1021,13 +1048,14 @@ DragRef = /** @class */ (function () {
1021
1048
  */
1022
1049
  function (rootElement) {
1023
1050
  /** @type {?} */
1024
- var element = rootElement instanceof ElementRef ? rootElement.nativeElement : rootElement;
1051
+ var element = coerceElement(rootElement);
1025
1052
  if (element !== (/** @type {?} */ (this))._rootElement) {
1026
1053
  if ((/** @type {?} */ (this))._rootElement) {
1027
1054
  (/** @type {?} */ (this))._removeRootElementListeners((/** @type {?} */ (this))._rootElement);
1028
1055
  }
1029
1056
  element.addEventListener('mousedown', (/** @type {?} */ (this))._pointerDown, activeEventListenerOptions);
1030
1057
  element.addEventListener('touchstart', (/** @type {?} */ (this))._pointerDown, passiveEventListenerOptions);
1058
+ (/** @type {?} */ (this))._initialTransform = undefined;
1031
1059
  (/** @type {?} */ (this))._rootElement = element;
1032
1060
  }
1033
1061
  return (/** @type {?} */ (this));
@@ -1050,8 +1078,7 @@ DragRef = /** @class */ (function () {
1050
1078
  * @return {THIS}
1051
1079
  */
1052
1080
  function (boundaryElement) {
1053
- (/** @type {?} */ (this))._boundaryElement = boundaryElement instanceof ElementRef ?
1054
- boundaryElement.nativeElement : boundaryElement;
1081
+ (/** @type {?} */ (this))._boundaryElement = boundaryElement ? coerceElement(boundaryElement) : null;
1055
1082
  return (/** @type {?} */ (this));
1056
1083
  };
1057
1084
  /** Removes the dragging functionality from the DOM element. */
@@ -1085,6 +1112,7 @@ DragRef = /** @class */ (function () {
1085
1112
  this.dropped.complete();
1086
1113
  this._moveEvents.complete();
1087
1114
  this._handles = [];
1115
+ this._disabledHandles.clear();
1088
1116
  this._boundaryElement = this._rootElement = this._placeholderTemplate =
1089
1117
  this._previewTemplate = this._nextSibling = (/** @type {?} */ (null));
1090
1118
  };
@@ -1110,10 +1138,46 @@ DragRef = /** @class */ (function () {
1110
1138
  * @return {?}
1111
1139
  */
1112
1140
  function () {
1113
- this._rootElement.style.transform = '';
1141
+ this._rootElement.style.transform = this._initialTransform || '';
1114
1142
  this._activeTransform = { x: 0, y: 0 };
1115
1143
  this._passiveTransform = { x: 0, y: 0 };
1116
1144
  };
1145
+ /**
1146
+ * Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.
1147
+ * @param handle Handle element that should be disabled.
1148
+ */
1149
+ /**
1150
+ * Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.
1151
+ * @param {?} handle Handle element that should be disabled.
1152
+ * @return {?}
1153
+ */
1154
+ DragRef.prototype.disableHandle = /**
1155
+ * Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.
1156
+ * @param {?} handle Handle element that should be disabled.
1157
+ * @return {?}
1158
+ */
1159
+ function (handle) {
1160
+ if (this._handles.indexOf(handle) > -1) {
1161
+ this._disabledHandles.add(handle);
1162
+ }
1163
+ };
1164
+ /**
1165
+ * Enables a handle, if it has been disabled.
1166
+ * @param handle Handle element to be enabled.
1167
+ */
1168
+ /**
1169
+ * Enables a handle, if it has been disabled.
1170
+ * @param {?} handle Handle element to be enabled.
1171
+ * @return {?}
1172
+ */
1173
+ DragRef.prototype.enableHandle = /**
1174
+ * Enables a handle, if it has been disabled.
1175
+ * @param {?} handle Handle element to be enabled.
1176
+ * @return {?}
1177
+ */
1178
+ function (handle) {
1179
+ this._disabledHandles.delete(handle);
1180
+ };
1117
1181
  /** Unsubscribes from the global subscriptions. */
1118
1182
  /**
1119
1183
  * Unsubscribes from the global subscriptions.
@@ -1281,7 +1345,8 @@ DragRef = /** @class */ (function () {
1281
1345
  }
1282
1346
  // If we have a custom preview template, the element won't be visible anyway so we avoid the
1283
1347
  // extra `getBoundingClientRect` calls and just move the preview next to the cursor.
1284
- this._pickupPositionInElement = this._previewTemplate ? { x: 0, y: 0 } :
1348
+ this._pickupPositionInElement = this._previewTemplate && this._previewTemplate.template ?
1349
+ { x: 0, y: 0 } :
1285
1350
  this._getPointerPositionInElement(referenceElement, event);
1286
1351
  /** @type {?} */
1287
1352
  var pointerPosition = this._pickupPositionOnPage = this._getPointerPositionOnPage(event);
@@ -1363,7 +1428,8 @@ DragRef = /** @class */ (function () {
1363
1428
  var x = _a.x, y = _a.y;
1364
1429
  // Drop container that draggable has been moved into.
1365
1430
  /** @type {?} */
1366
- var newContainer = (/** @type {?} */ (this.dropContainer))._getSiblingContainerFromPosition(this, x, y);
1431
+ var newContainer = (/** @type {?} */ (this.dropContainer))._getSiblingContainerFromPosition(this, x, y) ||
1432
+ this._initialContainer._getSiblingContainerFromPosition(this, x, y);
1367
1433
  // If we couldn't find a new container to move the item into, and the item has left it's
1368
1434
  // initial container, check whether the it's over the initial container. This handles the
1369
1435
  // case where two containers are connected one way and the user tries to undo dragging an
@@ -1372,7 +1438,7 @@ DragRef = /** @class */ (function () {
1372
1438
  this._initialContainer._isOverContainer(x, y)) {
1373
1439
  newContainer = this._initialContainer;
1374
1440
  }
1375
- if (newContainer) {
1441
+ if (newContainer && newContainer !== this.dropContainer) {
1376
1442
  this._ngZone.run(function () {
1377
1443
  // Notify the old container that the item has left.
1378
1444
  _this.exited.next({ item: _this, container: (/** @type {?} */ (_this.dropContainer)) });
@@ -1404,11 +1470,13 @@ DragRef = /** @class */ (function () {
1404
1470
  * @return {?}
1405
1471
  */
1406
1472
  function () {
1473
+ /** @type {?} */
1474
+ var previewTemplate = this._previewTemplate;
1407
1475
  /** @type {?} */
1408
1476
  var preview;
1409
- if (this._previewTemplate) {
1477
+ if (previewTemplate && previewTemplate.template) {
1410
1478
  /** @type {?} */
1411
- var viewRef = this._viewContainerRef.createEmbeddedView(this._previewTemplate.templateRef, this._previewTemplate.data);
1479
+ var viewRef = this._viewContainerRef.createEmbeddedView(previewTemplate.template, previewTemplate.context);
1412
1480
  preview = viewRef.rootNodes[0];
1413
1481
  this._previewRef = viewRef;
1414
1482
  preview.style.transform =
@@ -1504,10 +1572,12 @@ DragRef = /** @class */ (function () {
1504
1572
  * @return {?}
1505
1573
  */
1506
1574
  function () {
1575
+ /** @type {?} */
1576
+ var placeholderTemplate = this._placeholderTemplate;
1507
1577
  /** @type {?} */
1508
1578
  var placeholder;
1509
- if (this._placeholderTemplate) {
1510
- this._placeholderRef = this._viewContainerRef.createEmbeddedView(this._placeholderTemplate.templateRef, this._placeholderTemplate.data);
1579
+ if (placeholderTemplate && placeholderTemplate.template) {
1580
+ this._placeholderRef = this._viewContainerRef.createEmbeddedView(placeholderTemplate.template, placeholderTemplate.context);
1511
1581
  placeholder = this._placeholderRef.rootNodes[0];
1512
1582
  }
1513
1583
  else {
@@ -1784,10 +1854,7 @@ var CdkDrag = /** @class */ (function () {
1784
1854
  this._dragDropRegistry = _dragDropRegistry;
1785
1855
  this._config = _config;
1786
1856
  this._dir = _dir;
1787
- /**
1788
- * Subscription to the stream that initializes the root element.
1789
- */
1790
- this._rootElementInitSubscription = Subscription.EMPTY;
1857
+ this._destroyed = new Subject();
1791
1858
  this._disabled = false;
1792
1859
  /**
1793
1860
  * Emits when the user starts dragging the item.
@@ -1817,7 +1884,7 @@ var CdkDrag = /** @class */ (function () {
1817
1884
  * Emits as the user is dragging the item. Use with caution,
1818
1885
  * because this event will fire for every pixel that the user has dragged.
1819
1886
  */
1820
- this.moved = Observable.create(function (observer) {
1887
+ this.moved = new Observable(function (observer) {
1821
1888
  /** @type {?} */
1822
1889
  var subscription = _this._dragRef.moved.pipe(map(function (movedEvent) { return ({
1823
1890
  source: _this,
@@ -1832,16 +1899,7 @@ var CdkDrag = /** @class */ (function () {
1832
1899
  /** @type {?} */
1833
1900
  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);
1834
1901
  ref.data = this;
1835
- ref.beforeStarted.subscribe(function () {
1836
- if (!ref.isDragging()) {
1837
- ref.disabled = _this.disabled;
1838
- ref.lockAxis = _this.lockAxis;
1839
- ref
1840
- .withBoundaryElement(_this._getBoundaryElement())
1841
- .withPlaceholderTemplate(_this._placeholderTemplate)
1842
- .withPreviewTemplate(_this._previewTemplate);
1843
- }
1844
- });
1902
+ this._syncInputs(ref);
1845
1903
  this._proxyEvents(ref);
1846
1904
  }
1847
1905
  Object.defineProperty(CdkDrag.prototype, "disabled", {
@@ -1917,14 +1975,30 @@ var CdkDrag = /** @class */ (function () {
1917
1975
  // element to be in the proper place in the DOM. This is mostly relevant
1918
1976
  // for draggable elements inside portals since they get stamped out in
1919
1977
  // their original DOM position and then they get transferred to the portal.
1920
- this._rootElementInitSubscription = this._ngZone.onStable.asObservable()
1921
- .pipe(take(1))
1978
+ this._ngZone.onStable.asObservable()
1979
+ .pipe(take(1), takeUntil(this._destroyed))
1922
1980
  .subscribe(function () {
1923
1981
  _this._updateRootElement();
1924
- _this._handles.changes
1925
- .pipe(startWith(_this._handles))
1926
- .subscribe(function (handleList) {
1927
- _this._dragRef.withHandles(handleList.filter(function (handle) { return handle._parentDrag === _this; }));
1982
+ // Listen for any newly-added handles.
1983
+ _this._handles.changes.pipe(startWith(_this._handles),
1984
+ // Sync the new handles with the DragRef.
1985
+ tap(function (handles) {
1986
+ /** @type {?} */
1987
+ var childHandleElements = handles
1988
+ .filter(function (handle) { return handle._parentDrag === _this; })
1989
+ .map(function (handle) { return handle.element; });
1990
+ _this._dragRef.withHandles(childHandleElements);
1991
+ }),
1992
+ // Listen if the state of any of the handles changes.
1993
+ switchMap(function (handles) {
1994
+ return merge.apply(void 0, handles.map(function (item) { return item._stateChanges; }));
1995
+ }), takeUntil(_this._destroyed)).subscribe(function (handleInstance) {
1996
+ // Enabled/disable the handle that changed in the DragRef.
1997
+ /** @type {?} */
1998
+ var dragRef = _this._dragRef;
1999
+ /** @type {?} */
2000
+ var handle = handleInstance.element.nativeElement;
2001
+ handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
1928
2002
  });
1929
2003
  });
1930
2004
  };
@@ -1952,7 +2026,8 @@ var CdkDrag = /** @class */ (function () {
1952
2026
  * @return {?}
1953
2027
  */
1954
2028
  function () {
1955
- this._rootElementInitSubscription.unsubscribe();
2029
+ this._destroyed.next();
2030
+ this._destroyed.complete();
1956
2031
  this._dragRef.dispose();
1957
2032
  };
1958
2033
  /** Syncs the root element with the `DragRef`. */
@@ -1994,6 +2069,34 @@ var CdkDrag = /** @class */ (function () {
1994
2069
  var selector = this.boundaryElementSelector;
1995
2070
  return selector ? getClosestMatchingAncestor(this.element.nativeElement, selector) : null;
1996
2071
  };
2072
+ /** Syncs the inputs of the CdkDrag with the options of the underlying DragRef. */
2073
+ /**
2074
+ * Syncs the inputs of the CdkDrag with the options of the underlying DragRef.
2075
+ * @private
2076
+ * @param {?} ref
2077
+ * @return {?}
2078
+ */
2079
+ CdkDrag.prototype._syncInputs = /**
2080
+ * Syncs the inputs of the CdkDrag with the options of the underlying DragRef.
2081
+ * @private
2082
+ * @param {?} ref
2083
+ * @return {?}
2084
+ */
2085
+ function (ref) {
2086
+ var _this = this;
2087
+ ref.beforeStarted.subscribe(function () {
2088
+ if (!ref.isDragging()) {
2089
+ var _a = _this, placeholder = _a._placeholderTemplate, preview = _a._previewTemplate;
2090
+ ref.disabled = _this.disabled;
2091
+ ref.lockAxis = _this.lockAxis;
2092
+ ref.withBoundaryElement(_this._getBoundaryElement());
2093
+ placeholder ? ref.withPlaceholderTemplate(placeholder.templateRef, placeholder.data) :
2094
+ ref.withPlaceholderTemplate(null);
2095
+ preview ? ref.withPreviewTemplate(preview.templateRef, preview.data) :
2096
+ ref.withPreviewTemplate(null);
2097
+ }
2098
+ });
2099
+ };
1997
2100
  /**
1998
2101
  * Proxies the events from a DragRef to events that
1999
2102
  * match the interfaces of the CdkDrag outputs.
@@ -2236,23 +2339,26 @@ DropListRef = /** @class */ (function () {
2236
2339
  */
2237
2340
  this._isDragging = false;
2238
2341
  /**
2239
- * Cache of the dimensions of all the items and the sibling containers.
2342
+ * Cache of the dimensions of all the items inside the container.
2240
2343
  */
2241
- this._positionCache = { items: [], siblings: [], self: (/** @type {?} */ ({})) };
2344
+ this._itemPositions = [];
2242
2345
  /**
2243
2346
  * Keeps track of the item that was last swapped with the dragged item, as
2244
2347
  * well as what direction the pointer was moving in when the swap occured.
2245
2348
  */
2246
2349
  this._previousSwap = { drag: (/** @type {?} */ (null)), delta: 0 };
2350
+ /**
2351
+ * Drop lists that are connected to the current one.
2352
+ */
2247
2353
  this._siblings = [];
2248
2354
  /**
2249
2355
  * Direction in which the list is oriented.
2250
2356
  */
2251
2357
  this._orientation = 'vertical';
2252
2358
  /**
2253
- * Amount of connected siblings that currently have a dragged item.
2359
+ * Connected siblings that currently have a dragged item.
2254
2360
  */
2255
- this._activeSiblings = 0;
2361
+ this._activeSiblings = new Set();
2256
2362
  _dragDropRegistry.registerDropContainer(this);
2257
2363
  this._document = _document;
2258
2364
  }
@@ -2271,6 +2377,7 @@ DropListRef = /** @class */ (function () {
2271
2377
  this.exited.complete();
2272
2378
  this.dropped.complete();
2273
2379
  this.sorted.complete();
2380
+ this._activeSiblings.clear();
2274
2381
  this._dragDropRegistry.removeDropContainer(this);
2275
2382
  };
2276
2383
  /** Whether an item from this list is currently being dragged. */
@@ -2295,11 +2402,13 @@ DropListRef = /** @class */ (function () {
2295
2402
  * @return {?}
2296
2403
  */
2297
2404
  function () {
2405
+ var _this = this;
2298
2406
  this.beforeStarted.next();
2299
2407
  this._isDragging = true;
2300
2408
  this._activeDraggables = this._draggables.slice();
2301
- this._cachePositions();
2302
- this._positionCache.siblings.forEach(function (sibling) { return sibling.drop._toggleIsReceiving(true); });
2409
+ this._cacheOwnPosition();
2410
+ this._cacheItemPositions();
2411
+ this._siblings.forEach(function (sibling) { return sibling._startReceiving(_this); });
2303
2412
  };
2304
2413
  /**
2305
2414
  * Emits an event to indicate that the user moved an item into the container.
@@ -2355,7 +2464,7 @@ DropListRef = /** @class */ (function () {
2355
2464
  placeholder.style.transform = '';
2356
2465
  // Note that the positions were already cached when we called `start` above,
2357
2466
  // but we need to refresh them since the amount of items has changed.
2358
- this._cachePositions();
2467
+ this._cacheItemPositions();
2359
2468
  };
2360
2469
  /**
2361
2470
  * Removes an item from the container after it was dragged into another container by the user.
@@ -2504,7 +2613,7 @@ DropListRef = /** @class */ (function () {
2504
2613
  // we need to invert the array when determining the index.
2505
2614
  /** @type {?} */
2506
2615
  var items = this._orientation === 'horizontal' && this._dir && this._dir.value === 'rtl' ?
2507
- this._positionCache.items.slice().reverse() : this._positionCache.items;
2616
+ this._itemPositions.slice().reverse() : this._itemPositions;
2508
2617
  return findIndex(items, function (currentItem) { return currentItem.drag === item; });
2509
2618
  };
2510
2619
  /**
@@ -2522,7 +2631,7 @@ DropListRef = /** @class */ (function () {
2522
2631
  * @return {?}
2523
2632
  */
2524
2633
  function () {
2525
- return this._activeSiblings > 0;
2634
+ return this._activeSiblings.size > 0;
2526
2635
  };
2527
2636
  /**
2528
2637
  * Sorts an item inside the container based on its position.
@@ -2553,7 +2662,7 @@ DropListRef = /** @class */ (function () {
2553
2662
  return;
2554
2663
  }
2555
2664
  /** @type {?} */
2556
- var siblings = this._positionCache.items;
2665
+ var siblings = this._itemPositions;
2557
2666
  /** @type {?} */
2558
2667
  var newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY, pointerDelta);
2559
2668
  if (newIndex === -1 && siblings.length > 0) {
@@ -2621,13 +2730,27 @@ DropListRef = /** @class */ (function () {
2621
2730
  }
2622
2731
  });
2623
2732
  };
2733
+ /** Caches the position of the drop list. */
2734
+ /**
2735
+ * Caches the position of the drop list.
2736
+ * @private
2737
+ * @return {?}
2738
+ */
2739
+ DropListRef.prototype._cacheOwnPosition = /**
2740
+ * Caches the position of the drop list.
2741
+ * @private
2742
+ * @return {?}
2743
+ */
2744
+ function () {
2745
+ this._clientRect = this.element.nativeElement.getBoundingClientRect();
2746
+ };
2624
2747
  /** Refreshes the position cache of the items and sibling containers. */
2625
2748
  /**
2626
2749
  * Refreshes the position cache of the items and sibling containers.
2627
2750
  * @private
2628
2751
  * @return {?}
2629
2752
  */
2630
- DropListRef.prototype._cachePositions = /**
2753
+ DropListRef.prototype._cacheItemPositions = /**
2631
2754
  * Refreshes the position cache of the items and sibling containers.
2632
2755
  * @private
2633
2756
  * @return {?}
@@ -2636,9 +2759,7 @@ DropListRef = /** @class */ (function () {
2636
2759
  var _this = this;
2637
2760
  /** @type {?} */
2638
2761
  var isHorizontal = this._orientation === 'horizontal';
2639
- this._positionCache.self = this.element.nativeElement.getBoundingClientRect();
2640
- this._positionCache.items = this._activeDraggables
2641
- .map(function (drag) {
2762
+ this._itemPositions = this._activeDraggables.map(function (drag) {
2642
2763
  /** @type {?} */
2643
2764
  var elementToMeasure = _this._dragDropRegistry.isDragging(drag) ?
2644
2765
  // If the element is being dragged, we have to measure the
@@ -2663,34 +2784,10 @@ DropListRef = /** @class */ (function () {
2663
2784
  height: clientRect.height
2664
2785
  }
2665
2786
  };
2666
- })
2667
- .sort(function (a, b) {
2787
+ }).sort(function (a, b) {
2668
2788
  return isHorizontal ? a.clientRect.left - b.clientRect.left :
2669
2789
  a.clientRect.top - b.clientRect.top;
2670
2790
  });
2671
- this._positionCache.siblings = this._siblings.map(function (drop) { return ({
2672
- drop: drop,
2673
- clientRect: drop.element.nativeElement.getBoundingClientRect()
2674
- }); });
2675
- };
2676
- /**
2677
- * Toggles whether the list can receive the item that is currently being dragged.
2678
- * Usually called by a sibling that initiated the dragging.
2679
- */
2680
- /**
2681
- * Toggles whether the list can receive the item that is currently being dragged.
2682
- * Usually called by a sibling that initiated the dragging.
2683
- * @param {?} isDragging
2684
- * @return {?}
2685
- */
2686
- DropListRef.prototype._toggleIsReceiving = /**
2687
- * Toggles whether the list can receive the item that is currently being dragged.
2688
- * Usually called by a sibling that initiated the dragging.
2689
- * @param {?} isDragging
2690
- * @return {?}
2691
- */
2692
- function (isDragging) {
2693
- this._activeSiblings = Math.max(0, this._activeSiblings + (isDragging ? 1 : -1));
2694
2791
  };
2695
2792
  /** Resets the container to its initial state. */
2696
2793
  /**
@@ -2704,13 +2801,13 @@ DropListRef = /** @class */ (function () {
2704
2801
  * @return {?}
2705
2802
  */
2706
2803
  function () {
2804
+ var _this = this;
2707
2805
  this._isDragging = false;
2708
2806
  // TODO(crisbeto): may have to wait for the animations to finish.
2709
2807
  this._activeDraggables.forEach(function (item) { return item.getRootElement().style.transform = ''; });
2710
- this._positionCache.siblings.forEach(function (sibling) { return sibling.drop._toggleIsReceiving(false); });
2808
+ this._siblings.forEach(function (sibling) { return sibling._stopReceiving(_this); });
2711
2809
  this._activeDraggables = [];
2712
- this._positionCache.items = [];
2713
- this._positionCache.siblings = [];
2810
+ this._itemPositions = [];
2714
2811
  this._previousSwap.drag = null;
2715
2812
  this._previousSwap.delta = 0;
2716
2813
  };
@@ -2783,7 +2880,7 @@ DropListRef = /** @class */ (function () {
2783
2880
  * @return {?}
2784
2881
  */
2785
2882
  function (pointerX, pointerY) {
2786
- var _a = this._positionCache.self, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
2883
+ var _a = this._clientRect, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
2787
2884
  /** @type {?} */
2788
2885
  var xThreshold = width * DROP_PROXIMITY_THRESHOLD;
2789
2886
  /** @type {?} */
@@ -2855,7 +2952,7 @@ DropListRef = /** @class */ (function () {
2855
2952
  var _this = this;
2856
2953
  /** @type {?} */
2857
2954
  var isHorizontal = this._orientation === 'horizontal';
2858
- return findIndex(this._positionCache.items, function (_a, _, array) {
2955
+ return findIndex(this._itemPositions, function (_a, _, array) {
2859
2956
  var drag = _a.drag, clientRect = _a.clientRect;
2860
2957
  if (drag === item) {
2861
2958
  // If there's only one item left in the container, it must be
@@ -2896,7 +2993,7 @@ DropListRef = /** @class */ (function () {
2896
2993
  * @return {?}
2897
2994
  */
2898
2995
  function (x, y) {
2899
- return isInsideClientRect(this._positionCache.self, x, y);
2996
+ return isInsideClientRect(this._clientRect, x, y);
2900
2997
  };
2901
2998
  /**
2902
2999
  * Figures out whether an item should be moved into a sibling
@@ -2922,34 +3019,87 @@ DropListRef = /** @class */ (function () {
2922
3019
  * @return {?}
2923
3020
  */
2924
3021
  function (item, x, y) {
2925
- /** @type {?} */
2926
- var results = this._positionCache.siblings.filter(function (sibling) {
2927
- return isInsideClientRect(sibling.clientRect, x, y);
2928
- });
2929
- // No drop containers are intersecting with the pointer.
2930
- if (!results.length) {
2931
- return null;
3022
+ return this._siblings.find(function (sibling) { return sibling._canReceive(item, x, y); });
3023
+ };
3024
+ /**
3025
+ * Checks whether the drop list can receive the passed-in item.
3026
+ * @param item Item that is being dragged into the list.
3027
+ * @param x Position of the item along the X axis.
3028
+ * @param y Position of the item along the Y axis.
3029
+ */
3030
+ /**
3031
+ * Checks whether the drop list can receive the passed-in item.
3032
+ * @param {?} item Item that is being dragged into the list.
3033
+ * @param {?} x Position of the item along the X axis.
3034
+ * @param {?} y Position of the item along the Y axis.
3035
+ * @return {?}
3036
+ */
3037
+ DropListRef.prototype._canReceive = /**
3038
+ * Checks whether the drop list can receive the passed-in item.
3039
+ * @param {?} item Item that is being dragged into the list.
3040
+ * @param {?} x Position of the item along the X axis.
3041
+ * @param {?} y Position of the item along the Y axis.
3042
+ * @return {?}
3043
+ */
3044
+ function (item, x, y) {
3045
+ if (!this.enterPredicate(item, this) || !isInsideClientRect(this._clientRect, x, y)) {
3046
+ return false;
2932
3047
  }
2933
3048
  /** @type {?} */
2934
3049
  var elementFromPoint = this._document.elementFromPoint(x, y);
2935
3050
  // If there's no element at the pointer position, then
2936
3051
  // the client rect is probably scrolled out of the view.
2937
3052
  if (!elementFromPoint) {
2938
- return null;
3053
+ return false;
2939
3054
  }
3055
+ /** @type {?} */
3056
+ var element = this.element.nativeElement;
2940
3057
  // The `ClientRect`, that we're using to find the container over which the user is
2941
3058
  // hovering, doesn't give us any information on whether the element has been scrolled
2942
3059
  // out of the view or whether it's overlapping with other containers. This means that
2943
3060
  // we could end up transferring the item into a container that's invisible or is positioned
2944
3061
  // below another one. We use the result from `elementFromPoint` to get the top-most element
2945
3062
  // at the pointer position and to find whether it's one of the intersecting drop containers.
3063
+ return elementFromPoint === element || element.contains(elementFromPoint);
3064
+ };
3065
+ /**
3066
+ * Called by one of the connected drop lists when a dragging sequence has started.
3067
+ * @param sibling Sibling in which dragging has started.
3068
+ */
3069
+ /**
3070
+ * Called by one of the connected drop lists when a dragging sequence has started.
3071
+ * @param {?} sibling Sibling in which dragging has started.
3072
+ * @return {?}
3073
+ */
3074
+ DropListRef.prototype._startReceiving = /**
3075
+ * Called by one of the connected drop lists when a dragging sequence has started.
3076
+ * @param {?} sibling Sibling in which dragging has started.
3077
+ * @return {?}
3078
+ */
3079
+ function (sibling) {
2946
3080
  /** @type {?} */
2947
- var result = results.find(function (sibling) {
2948
- /** @type {?} */
2949
- var element = sibling.drop.element.nativeElement;
2950
- return element === elementFromPoint || element.contains(elementFromPoint);
2951
- });
2952
- return result && result.drop.enterPredicate(item, result.drop) ? result.drop : null;
3081
+ var activeSiblings = this._activeSiblings;
3082
+ if (!activeSiblings.has(sibling)) {
3083
+ activeSiblings.add(sibling);
3084
+ this._cacheOwnPosition();
3085
+ }
3086
+ };
3087
+ /**
3088
+ * Called by a connected drop list when dragging has stopped.
3089
+ * @param sibling Sibling whose dragging has stopped.
3090
+ */
3091
+ /**
3092
+ * Called by a connected drop list when dragging has stopped.
3093
+ * @param {?} sibling Sibling whose dragging has stopped.
3094
+ * @return {?}
3095
+ */
3096
+ DropListRef.prototype._stopReceiving = /**
3097
+ * Called by a connected drop list when dragging has stopped.
3098
+ * @param {?} sibling Sibling whose dragging has stopped.
3099
+ * @return {?}
3100
+ */
3101
+ function (sibling) {
3102
+ this._activeSiblings.delete(sibling);
2953
3103
  };
2954
3104
  return DropListRef;
2955
3105
  }());
@@ -3065,7 +3215,7 @@ var CdkDropList = /** @class */ (function () {
3065
3215
  return _this.enterPredicate(drag.data, drop.data);
3066
3216
  };
3067
3217
  this._syncInputs(ref);
3068
- this._proxyEvents(ref);
3218
+ this._handleEvents(ref);
3069
3219
  CdkDropList._dropLists.push(this);
3070
3220
  if (_group) {
3071
3221
  _group._items.add(this);
@@ -3314,20 +3464,15 @@ var CdkDropList = /** @class */ (function () {
3314
3464
  .withItems(_this._draggables.map(function (drag) { return drag._dragRef; }));
3315
3465
  });
3316
3466
  };
3467
+ /** Handles events from the underlying DropListRef. */
3317
3468
  /**
3318
- * Proxies the events from a DropListRef to events that
3319
- * match the interfaces of the CdkDropList outputs.
3320
- */
3321
- /**
3322
- * Proxies the events from a DropListRef to events that
3323
- * match the interfaces of the CdkDropList outputs.
3469
+ * Handles events from the underlying DropListRef.
3324
3470
  * @private
3325
3471
  * @param {?} ref
3326
3472
  * @return {?}
3327
3473
  */
3328
- CdkDropList.prototype._proxyEvents = /**
3329
- * Proxies the events from a DropListRef to events that
3330
- * match the interfaces of the CdkDropList outputs.
3474
+ CdkDropList.prototype._handleEvents = /**
3475
+ * Handles events from the underlying DropListRef.
3331
3476
  * @private
3332
3477
  * @param {?} ref
3333
3478
  * @return {?}
@@ -3366,6 +3511,9 @@ var CdkDropList = /** @class */ (function () {
3366
3511
  item: event.item.data,
3367
3512
  isPointerOverContainer: event.isPointerOverContainer
3368
3513
  });
3514
+ // Mark for check since all of these events run outside of change
3515
+ // detection and we're not guaranteed for something else to have triggered it.
3516
+ _this._changeDetectorRef.markForCheck();
3369
3517
  });
3370
3518
  };
3371
3519
  /**