@angular/cdk 10.0.2 → 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 (128) hide show
  1. package/a11y/aria-describer/aria-describer.d.ts +10 -1
  2. package/a11y/index.metadata.json +1 -1
  3. package/a11y/interactivity-checker/interactivity-checker.d.ts +11 -1
  4. package/a11y/key-manager/list-key-manager.d.ts +6 -0
  5. package/accordion/accordion.d.ts +7 -1
  6. package/accordion/index.d.ts +1 -0
  7. package/accordion/index.metadata.json +1 -1
  8. package/bundles/cdk-a11y.umd.js +63 -11
  9. package/bundles/cdk-a11y.umd.js.map +1 -1
  10. package/bundles/cdk-a11y.umd.min.js +11 -11
  11. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  12. package/bundles/cdk-accordion.umd.js +12 -4
  13. package/bundles/cdk-accordion.umd.js.map +1 -1
  14. package/bundles/cdk-accordion.umd.min.js +2 -2
  15. package/bundles/cdk-accordion.umd.min.js.map +1 -1
  16. package/bundles/cdk-drag-drop.umd.js +640 -599
  17. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  18. package/bundles/cdk-drag-drop.umd.min.js +8 -16
  19. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  20. package/bundles/cdk-overlay.umd.js +199 -42
  21. package/bundles/cdk-overlay.umd.js.map +1 -1
  22. package/bundles/cdk-overlay.umd.min.js +11 -18
  23. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  24. package/bundles/cdk-platform.umd.min.js +1 -1
  25. package/bundles/cdk-platform.umd.min.js.map +1 -1
  26. package/bundles/cdk-scrolling.umd.js +9 -1
  27. package/bundles/cdk-scrolling.umd.js.map +1 -1
  28. package/bundles/cdk-scrolling.umd.min.js +7 -0
  29. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  30. package/bundles/cdk-testing-protractor.umd.min.js +1 -1
  31. package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
  32. package/bundles/cdk-testing-testbed.umd.min.js +8 -8
  33. package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
  34. package/bundles/cdk-testing.umd.js +32 -0
  35. package/bundles/cdk-testing.umd.js.map +1 -1
  36. package/bundles/cdk-testing.umd.min.js +5 -5
  37. package/bundles/cdk-testing.umd.min.js.map +1 -1
  38. package/bundles/cdk-tree.umd.js +6 -2
  39. package/bundles/cdk-tree.umd.js.map +1 -1
  40. package/bundles/cdk-tree.umd.min.js +3 -3
  41. package/bundles/cdk-tree.umd.min.js.map +1 -1
  42. package/bundles/cdk.umd.js +1 -1
  43. package/bundles/cdk.umd.js.map +1 -1
  44. package/bundles/cdk.umd.min.js +1 -1
  45. package/bundles/cdk.umd.min.js.map +1 -1
  46. package/drag-drop/directives/drag-handle.d.ts +7 -1
  47. package/drag-drop/directives/drag-placeholder.d.ts +7 -1
  48. package/drag-drop/directives/drag-preview.d.ts +7 -1
  49. package/drag-drop/directives/drag.d.ts +3 -7
  50. package/drag-drop/directives/drop-list-group.d.ts +7 -1
  51. package/drag-drop/directives/drop-list.d.ts +7 -1
  52. package/drag-drop/index.d.ts +2 -2
  53. package/drag-drop/index.metadata.json +1 -1
  54. package/esm2015/a11y/aria-describer/aria-describer.js +20 -6
  55. package/esm2015/a11y/interactivity-checker/interactivity-checker.js +16 -3
  56. package/esm2015/a11y/key-manager/list-key-manager.js +27 -2
  57. package/esm2015/accordion/accordion-item.js +7 -7
  58. package/esm2015/accordion/accordion.js +9 -2
  59. package/esm2015/accordion/index.js +2 -1
  60. package/esm2015/drag-drop/directives/drag-handle.js +11 -4
  61. package/esm2015/drag-drop/directives/drag-placeholder.js +10 -3
  62. package/esm2015/drag-drop/directives/drag-preview.js +10 -3
  63. package/esm2015/drag-drop/directives/drag.js +19 -15
  64. package/esm2015/drag-drop/directives/drop-list-group.js +9 -2
  65. package/esm2015/drag-drop/directives/drop-list.js +11 -6
  66. package/esm2015/drag-drop/index.js +3 -2
  67. package/esm2015/layout/breakpoints-observer.js +1 -1
  68. package/esm2015/overlay/dispatchers/base-overlay-dispatcher.js +51 -0
  69. package/esm2015/overlay/dispatchers/index.js +10 -0
  70. package/esm2015/overlay/dispatchers/overlay-keyboard-dispatcher.js +79 -0
  71. package/esm2015/overlay/dispatchers/overlay-outside-click-dispatcher.js +94 -0
  72. package/esm2015/overlay/index.js +5 -4
  73. package/esm2015/overlay/overlay-config.js +5 -1
  74. package/esm2015/overlay/overlay-directives.js +17 -7
  75. package/esm2015/overlay/overlay-module.js +2 -2
  76. package/esm2015/overlay/overlay-ref.js +24 -2
  77. package/esm2015/overlay/overlay-reference.js +1 -1
  78. package/esm2015/overlay/overlay.js +10 -5
  79. package/esm2015/overlay/position/overlay-position-builder.js +1 -1
  80. package/esm2015/overlay/public-api.js +2 -2
  81. package/esm2015/scrolling/public-api.js +2 -1
  82. package/esm2015/scrolling/virtual-for-of.js +1 -1
  83. package/esm2015/scrolling/virtual-scroll-repeater.js +8 -0
  84. package/esm2015/scrolling/virtual-scroll-viewport.js +2 -2
  85. package/esm2015/testing/component-harness.js +19 -1
  86. package/esm2015/testing/harness-environment.js +7 -1
  87. package/esm2015/tree/control/nested-tree-control.js +7 -3
  88. package/esm2015/version.js +1 -1
  89. package/fesm2015/a11y.js +60 -10
  90. package/fesm2015/a11y.js.map +1 -1
  91. package/fesm2015/accordion.js +13 -6
  92. package/fesm2015/accordion.js.map +1 -1
  93. package/fesm2015/cdk.js +1 -1
  94. package/fesm2015/cdk.js.map +1 -1
  95. package/fesm2015/drag-drop.js +607 -570
  96. package/fesm2015/drag-drop.js.map +1 -1
  97. package/fesm2015/overlay.js +196 -32
  98. package/fesm2015/overlay.js.map +1 -1
  99. package/fesm2015/scrolling.js +9 -1
  100. package/fesm2015/scrolling.js.map +1 -1
  101. package/fesm2015/testing.js +25 -1
  102. package/fesm2015/testing.js.map +1 -1
  103. package/fesm2015/tree.js +6 -2
  104. package/fesm2015/tree.js.map +1 -1
  105. package/overlay/dispatchers/base-overlay-dispatcher.d.ts +28 -0
  106. package/overlay/dispatchers/index.d.ts +9 -0
  107. package/overlay/{keyboard → dispatchers}/overlay-keyboard-dispatcher.d.ts +4 -10
  108. package/overlay/dispatchers/overlay-outside-click-dispatcher.d.ts +27 -0
  109. package/overlay/index.d.ts +4 -3
  110. package/overlay/index.metadata.json +1 -1
  111. package/overlay/overlay-config.d.ts +4 -0
  112. package/overlay/overlay-directives.d.ts +4 -0
  113. package/overlay/overlay-ref.d.ts +8 -2
  114. package/overlay/overlay-reference.d.ts +1 -0
  115. package/overlay/overlay.d.ts +4 -2
  116. package/overlay/public-api.d.ts +1 -1
  117. package/package.json +1 -1
  118. package/schematics/ng-add/index.js +1 -1
  119. package/scrolling/index.metadata.json +1 -1
  120. package/scrolling/public-api.d.ts +1 -0
  121. package/scrolling/virtual-for-of.d.ts +2 -1
  122. package/scrolling/virtual-scroll-repeater.d.ts +16 -0
  123. package/scrolling/virtual-scroll-viewport.d.ts +4 -4
  124. package/testing/component-harness.d.ts +12 -0
  125. package/testing/harness-environment.d.ts +1 -0
  126. package/tree/control/nested-tree-control.d.ts +7 -2
  127. package/tree/index.metadata.json +1 -1
  128. package/esm2015/overlay/keyboard/overlay-keyboard-dispatcher.js +0 -96
@@ -2621,126 +2621,46 @@
2621
2621
  * found in the LICENSE file at https://angular.io/license
2622
2622
  */
2623
2623
  /**
2624
- * Injection token that can be used for a `CdkDrag` to provide itself as a parent to the
2625
- * drag-specific child directive (`CdkDragHandle`, `CdkDragPreview` etc.). Used primarily
2626
- * to avoid circular imports.
2627
- * @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.
2628
2627
  */
2629
- var CDK_DRAG_PARENT = new i0.InjectionToken('CDK_DRAG_PARENT');
2630
-
2628
+ var CDK_DROP_LIST_GROUP = new i0.InjectionToken('CdkDropListGroup');
2631
2629
  /**
2632
- * @license
2633
- * Copyright Google LLC All Rights Reserved.
2634
- *
2635
- * Use of this source code is governed by an MIT-style license that can be
2636
- * 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`.
2637
2634
  */
2638
- /** Handle that can be used to drag and CdkDrag instance. */
2639
- var CdkDragHandle = /** @class */ (function () {
2640
- function CdkDragHandle(element, parentDrag) {
2641
- this.element = element;
2642
- /** Emits when the state of the handle has changed. */
2643
- 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();
2644
2639
  this._disabled = false;
2645
- this._parentDrag = parentDrag;
2646
- toggleNativeDragInteractions(element.nativeElement, false);
2647
2640
  }
2648
- Object.defineProperty(CdkDragHandle.prototype, "disabled", {
2649
- /** 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. */
2650
2643
  get: function () { return this._disabled; },
2651
2644
  set: function (value) {
2652
2645
  this._disabled = coercion.coerceBooleanProperty(value);
2653
- this._stateChanges.next(this);
2654
2646
  },
2655
2647
  enumerable: false,
2656
2648
  configurable: true
2657
2649
  });
2658
- CdkDragHandle.prototype.ngOnDestroy = function () {
2659
- this._stateChanges.complete();
2660
- };
2661
- CdkDragHandle.decorators = [
2662
- { type: i0.Directive, args: [{
2663
- selector: '[cdkDragHandle]',
2664
- host: {
2665
- 'class': 'cdk-drag-handle'
2666
- }
2667
- },] }
2668
- ];
2669
- CdkDragHandle.ctorParameters = function () { return [
2670
- { type: i0.ElementRef },
2671
- { type: undefined, decorators: [{ type: i0.Inject, args: [CDK_DRAG_PARENT,] }, { type: i0.Optional }] }
2672
- ]; };
2673
- CdkDragHandle.propDecorators = {
2674
- disabled: [{ type: i0.Input, args: ['cdkDragHandleDisabled',] }]
2675
- };
2676
- return CdkDragHandle;
2677
- }());
2678
-
2679
- /**
2680
- * @license
2681
- * Copyright Google LLC All Rights Reserved.
2682
- *
2683
- * Use of this source code is governed by an MIT-style license that can be
2684
- * found in the LICENSE file at https://angular.io/license
2685
- */
2686
- /**
2687
- * Element that will be used as a template for the placeholder of a CdkDrag when
2688
- * it is being dragged. The placeholder is displayed in place of the element being dragged.
2689
- */
2690
- var CdkDragPlaceholder = /** @class */ (function () {
2691
- function CdkDragPlaceholder(templateRef) {
2692
- this.templateRef = templateRef;
2693
- }
2694
- CdkDragPlaceholder.decorators = [
2695
- { type: i0.Directive, args: [{
2696
- selector: 'ng-template[cdkDragPlaceholder]'
2697
- },] }
2698
- ];
2699
- CdkDragPlaceholder.ctorParameters = function () { return [
2700
- { type: i0.TemplateRef }
2701
- ]; };
2702
- CdkDragPlaceholder.propDecorators = {
2703
- data: [{ type: i0.Input }]
2650
+ CdkDropListGroup.prototype.ngOnDestroy = function () {
2651
+ this._items.clear();
2704
2652
  };
2705
- return CdkDragPlaceholder;
2706
- }());
2707
-
2708
- /**
2709
- * @license
2710
- * Copyright Google LLC All Rights Reserved.
2711
- *
2712
- * Use of this source code is governed by an MIT-style license that can be
2713
- * found in the LICENSE file at https://angular.io/license
2714
- */
2715
- /**
2716
- * Element that will be used as a template for the preview
2717
- * of a CdkDrag when it is being dragged.
2718
- */
2719
- var CdkDragPreview = /** @class */ (function () {
2720
- function CdkDragPreview(templateRef) {
2721
- this.templateRef = templateRef;
2722
- this._matchSize = false;
2723
- }
2724
- Object.defineProperty(CdkDragPreview.prototype, "matchSize", {
2725
- /** Whether the preview should preserve the same size as the item that is being dragged. */
2726
- get: function () { return this._matchSize; },
2727
- set: function (value) { this._matchSize = coercion.coerceBooleanProperty(value); },
2728
- enumerable: false,
2729
- configurable: true
2730
- });
2731
- CdkDragPreview.decorators = [
2653
+ CdkDropListGroup.decorators = [
2732
2654
  { type: i0.Directive, args: [{
2733
- selector: 'ng-template[cdkDragPreview]'
2655
+ selector: '[cdkDropListGroup]',
2656
+ exportAs: 'cdkDropListGroup',
2657
+ providers: [{ provide: CDK_DROP_LIST_GROUP, useExisting: CdkDropListGroup }],
2734
2658
  },] }
2735
2659
  ];
2736
- CdkDragPreview.ctorParameters = function () { return [
2737
- { type: i0.TemplateRef }
2738
- ]; };
2739
- CdkDragPreview.propDecorators = {
2740
- data: [{ type: i0.Input }],
2741
- matchSize: [{ type: i0.Input }]
2660
+ CdkDropListGroup.propDecorators = {
2661
+ disabled: [{ type: i0.Input, args: ['cdkDropListGroupDisabled',] }]
2742
2662
  };
2743
- return CdkDragPreview;
2663
+ return CdkDropListGroup;
2744
2664
  }());
2745
2665
 
2746
2666
  /**
@@ -2763,258 +2683,205 @@
2763
2683
  * Use of this source code is governed by an MIT-style license that can be
2764
2684
  * found in the LICENSE file at https://angular.io/license
2765
2685
  */
2686
+ /** Counter used to generate unique ids for drop zones. */
2687
+ var _uniqueIdCounter = 0;
2766
2688
  /**
2767
- * Injection token that is used to provide a CdkDropList instance to CdkDrag.
2768
- * 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.
2769
2692
  */
2770
- var CDK_DROP_LIST = new i0.InjectionToken('CDK_DROP_LIST');
2771
- /** Element that can be moved inside a CdkDropList container. */
2772
- var CdkDrag = /** @class */ (function () {
2773
- function CdkDrag(
2774
- /** Element that the draggable is attached to. */
2775
- element,
2776
- /** Droppable container that the draggable is a part of. */
2777
- 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) {
2778
2705
  var _this = this;
2779
2706
  this.element = element;
2780
- this.dropContainer = dropContainer;
2781
- this._document = _document;
2782
- this._ngZone = _ngZone;
2783
- this._viewContainerRef = _viewContainerRef;
2784
- this._dir = _dir;
2785
2707
  this._changeDetectorRef = _changeDetectorRef;
2708
+ this._dir = _dir;
2709
+ this._group = _group;
2710
+ this._scrollDispatcher = _scrollDispatcher;
2711
+ /** Emits when the list has been destroyed. */
2786
2712
  this._destroyed = new rxjs.Subject();
2787
- /** Emits when the user starts dragging the item. */
2788
- this.started = new i0.EventEmitter();
2789
- /** Emits when the user has released a drag item, before any animations have started. */
2790
- this.released = new i0.EventEmitter();
2791
- /** Emits when the user stops dragging an item in the container. */
2792
- this.ended = new i0.EventEmitter();
2793
- /** 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
+ */
2794
2734
  this.entered = new i0.EventEmitter();
2795
- /** 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
+ */
2796
2739
  this.exited = new i0.EventEmitter();
2797
- /** Emits when the user drops the item inside a container. */
2798
- this.dropped = new i0.EventEmitter();
2740
+ /** Emits as the user is swapping items while actively dragging. */
2741
+ this.sorted = new i0.EventEmitter();
2799
2742
  /**
2800
- * Emits as the user is dragging the item. Use with caution,
2801
- * 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.
2802
2748
  */
2803
- this.moved = new rxjs.Observable(function (observer) {
2804
- var subscription = _this._dragRef.moved.pipe(operators.map(function (movedEvent) { return ({
2805
- source: _this,
2806
- pointerPosition: movedEvent.pointerPosition,
2807
- event: movedEvent.event,
2808
- delta: movedEvent.delta,
2809
- distance: movedEvent.distance
2810
- }); })).subscribe(observer);
2811
- return function () {
2812
- subscription.unsubscribe();
2813
- };
2814
- });
2815
- this._dragRef = dragDrop.createDrag(element, {
2816
- dragStartThreshold: config && config.dragStartThreshold != null ?
2817
- config.dragStartThreshold : 5,
2818
- pointerDirectionChangeThreshold: config && config.pointerDirectionChangeThreshold != null ?
2819
- config.pointerDirectionChangeThreshold : 5,
2820
- zIndex: config === null || config === void 0 ? void 0 : config.zIndex
2821
- });
2822
- this._dragRef.data = this;
2749
+ this._unsortedItems = new Set();
2750
+ this._dropListRef = dragDrop.createDropList(element);
2751
+ this._dropListRef.data = this;
2823
2752
  if (config) {
2824
2753
  this._assignDefaults(config);
2825
2754
  }
2826
- // Note that usually the container is assigned when the drop list is picks up the item, but in
2827
- // some cases (mainly transplanted views with OnPush, see #18341) we may end up in a situation
2828
- // where there are no items on the first change detection pass, but the items get picked up as
2829
- // soon as the user triggers another pass by dragging. This is a problem, because the item would
2830
- // have to switch from standalone mode to drag mode in the middle of the dragging sequence which
2831
- // is too late since the two modes save different kinds of information. We work around it by
2832
- // assigning the drop container both from here and the list.
2833
- if (dropContainer) {
2834
- this._dragRef._withDropContainer(dropContainer._dropListRef);
2835
- 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);
2836
2763
  }
2837
- this._syncInputs(this._dragRef);
2838
- this._handleEvents(this._dragRef);
2839
2764
  }
2840
- Object.defineProperty(CdkDrag.prototype, "disabled", {
2841
- /** 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. */
2842
2767
  get: function () {
2843
- return this._disabled || (this.dropContainer && this.dropContainer.disabled);
2768
+ return this._disabled || (!!this._group && this._group.disabled);
2844
2769
  },
2845
2770
  set: function (value) {
2846
- this._disabled = coercion.coerceBooleanProperty(value);
2847
- this._dragRef.disabled = this._disabled;
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);
2848
2776
  },
2849
2777
  enumerable: false,
2850
2778
  configurable: true
2851
2779
  });
2852
- /**
2853
- * Returns the element that is being used as a placeholder
2854
- * while the current element is being dragged.
2855
- */
2856
- CdkDrag.prototype.getPlaceholderElement = function () {
2857
- return this._dragRef.getPlaceholderElement();
2858
- };
2859
- /** Returns the root draggable element. */
2860
- CdkDrag.prototype.getRootElement = function () {
2861
- return this._dragRef.getRootElement();
2862
- };
2863
- /** Resets a standalone drag item to its initial position. */
2864
- CdkDrag.prototype.reset = function () {
2865
- 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
+ }
2866
2786
  };
2867
- /**
2868
- * Gets the pixel coordinates of the draggable outside of a drop container.
2869
- */
2870
- CdkDrag.prototype.getFreeDragPosition = function () {
2871
- 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
+ }
2872
2793
  };
2873
- CdkDrag.prototype.ngAfterViewInit = function () {
2874
- var _this = this;
2875
- // We need to wait for the zone to stabilize, in order for the reference
2876
- // element to be in the proper place in the DOM. This is mostly relevant
2877
- // for draggable elements inside portals since they get stamped out in
2878
- // their original DOM position and then they get transferred to the portal.
2879
- this._ngZone.onStable.asObservable()
2880
- .pipe(operators.take(1), operators.takeUntil(this._destroyed))
2881
- .subscribe(function () {
2882
- _this._updateRootElement();
2883
- // Listen for any newly-added handles.
2884
- _this._handles.changes.pipe(operators.startWith(_this._handles),
2885
- // Sync the new handles with the DragRef.
2886
- operators.tap(function (handles) {
2887
- var childHandleElements = handles
2888
- .filter(function (handle) { return handle._parentDrag === _this; })
2889
- .map(function (handle) { return handle.element; });
2890
- _this._dragRef.withHandles(childHandleElements);
2891
- }),
2892
- // Listen if the state of any of the handles changes.
2893
- operators.switchMap(function (handles) {
2894
- return rxjs.merge.apply(void 0, __spread(handles.map(function (item) {
2895
- return item._stateChanges.pipe(operators.startWith(item));
2896
- })));
2897
- }), operators.takeUntil(_this._destroyed)).subscribe(function (handleInstance) {
2898
- // Enabled/disable the handle that changed in the DragRef.
2899
- var dragRef = _this._dragRef;
2900
- var handle = handleInstance.element.nativeElement;
2901
- handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
2902
- });
2903
- if (_this.freeDragPosition) {
2904
- _this._dragRef.setFreeDragPosition(_this.freeDragPosition);
2905
- }
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;
2906
2802
  });
2907
2803
  };
2908
- CdkDrag.prototype.ngOnChanges = function (changes) {
2909
- var rootSelectorChange = changes['rootElementSelector'];
2910
- var positionChange = changes['freeDragPosition'];
2911
- // We don't have to react to the first change since it's being
2912
- // handled in `ngAfterViewInit` where it needs to be deferred.
2913
- if (rootSelectorChange && !rootSelectorChange.firstChange) {
2914
- this._updateRootElement();
2915
- }
2916
- // Skip the first change since it's being handled in `ngAfterViewInit`.
2917
- if (positionChange && !positionChange.firstChange && this.freeDragPosition) {
2918
- 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);
2919
2808
  }
2920
- };
2921
- CdkDrag.prototype.ngOnDestroy = function () {
2922
- if (this.dropContainer) {
2923
- this.dropContainer.removeItem(this);
2809
+ if (this._group) {
2810
+ this._group._items.delete(this);
2924
2811
  }
2812
+ this._unsortedItems.clear();
2813
+ this._dropListRef.dispose();
2925
2814
  this._destroyed.next();
2926
2815
  this._destroyed.complete();
2927
- this._dragRef.dispose();
2928
2816
  };
2929
- /** Syncs the root element with the `DragRef`. */
2930
- CdkDrag.prototype._updateRootElement = function () {
2931
- var element = this.element.nativeElement;
2932
- var rootElement = this.rootElementSelector ?
2933
- getClosestMatchingAncestor(element, this.rootElementSelector) : element;
2934
- if (rootElement && rootElement.nodeType !== this._document.ELEMENT_NODE) {
2935
- throw Error("cdkDrag must be attached to an element node. " +
2936
- ("Currently attached to \"" + rootElement.nodeName + "\"."));
2937
- }
2938
- this._dragRef.withRootElement(rootElement || element);
2939
- };
2940
- /** Gets the boundary element, based on the `boundaryElement` value. */
2941
- CdkDrag.prototype._getBoundaryElement = function () {
2942
- var boundary = this.boundaryElement;
2943
- if (!boundary) {
2944
- return null;
2945
- }
2946
- if (typeof boundary === 'string') {
2947
- return getClosestMatchingAncestor(this.element.nativeElement, boundary);
2948
- }
2949
- var element = coercion.coerceElement(boundary);
2950
- if (i0.isDevMode() && !element.contains(this.element.nativeElement)) {
2951
- throw Error('Draggable element is not inside of the node passed into cdkDragBoundary.');
2952
- }
2953
- return element;
2954
- };
2955
- /** Syncs the inputs of the CdkDrag with the options of the underlying DragRef. */
2956
- 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) {
2957
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
+ }
2958
2825
  ref.beforeStarted.subscribe(function () {
2959
- if (!ref.isDragging()) {
2960
- var dir = _this._dir;
2961
- var dragStartDelay = _this.dragStartDelay;
2962
- var placeholder = _this._placeholderTemplate ? {
2963
- template: _this._placeholderTemplate.templateRef,
2964
- context: _this._placeholderTemplate.data,
2965
- viewContainer: _this._viewContainerRef
2966
- } : null;
2967
- var preview = _this._previewTemplate ? {
2968
- template: _this._previewTemplate.templateRef,
2969
- context: _this._previewTemplate.data,
2970
- matchSize: _this._previewTemplate.matchSize,
2971
- viewContainer: _this._viewContainerRef
2972
- } : null;
2973
- ref.disabled = _this.disabled;
2974
- ref.lockAxis = _this.lockAxis;
2975
- ref.dragStartDelay = (typeof dragStartDelay === 'object' && dragStartDelay) ?
2976
- dragStartDelay : coercion.coerceNumberProperty(dragStartDelay);
2977
- ref.constrainPosition = _this.constrainPosition;
2978
- ref.previewClass = _this.previewClass;
2979
- ref
2980
- .withBoundaryElement(_this._getBoundaryElement())
2981
- .withPlaceholderTemplate(placeholder)
2982
- .withPreviewTemplate(preview);
2983
- if (dir) {
2984
- ref.withDirection(dir.value);
2985
- }
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;
2986
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);
2987
2856
  });
2988
2857
  };
2989
- /** Handles the events from the underlying `DragRef`. */
2990
- CdkDrag.prototype._handleEvents = function (ref) {
2858
+ /** Handles events from the underlying DropListRef. */
2859
+ CdkDropList.prototype._handleEvents = function (ref) {
2991
2860
  var _this = this;
2992
- ref.started.subscribe(function () {
2993
- _this.started.emit({ source: _this });
2994
- // Since all of these events run outside of change detection,
2995
- // we need to ensure that everything is marked correctly.
2996
- _this._changeDetectorRef.markForCheck();
2997
- });
2998
- ref.released.subscribe(function () {
2999
- _this.released.emit({ source: _this });
3000
- });
3001
- ref.ended.subscribe(function (event) {
3002
- _this.ended.emit({ source: _this, distance: event.distance });
3003
- // Since all of these events run outside of change detection,
3004
- // we need to ensure that everything is marked correctly.
2861
+ ref.beforeStarted.subscribe(function () {
2862
+ _this._syncItemsWithRef();
3005
2863
  _this._changeDetectorRef.markForCheck();
3006
2864
  });
3007
2865
  ref.entered.subscribe(function (event) {
3008
2866
  _this.entered.emit({
3009
- container: event.container.data,
3010
- item: _this,
2867
+ container: _this,
2868
+ item: event.item.data,
3011
2869
  currentIndex: event.currentIndex
3012
2870
  });
3013
2871
  });
3014
2872
  ref.exited.subscribe(function (event) {
3015
2873
  _this.exited.emit({
3016
- container: event.container.data,
3017
- 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
3018
2885
  });
3019
2886
  });
3020
2887
  ref.dropped.subscribe(function (event) {
@@ -3023,92 +2890,182 @@
3023
2890
  currentIndex: event.currentIndex,
3024
2891
  previousContainer: event.previousContainer.data,
3025
2892
  container: event.container.data,
2893
+ item: event.item.data,
3026
2894
  isPointerOverContainer: event.isPointerOverContainer,
3027
- item: _this,
3028
2895
  distance: event.distance
3029
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();
3030
2900
  });
3031
2901
  };
3032
2902
  /** Assigns the default input values based on a provided config object. */
3033
- CdkDrag.prototype._assignDefaults = function (config) {
3034
- 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;
3035
2905
  this.disabled = draggingDisabled == null ? false : draggingDisabled;
3036
- this.dragStartDelay = dragStartDelay || 0;
2906
+ this.sortingDisabled = sortingDisabled == null ? false : sortingDisabled;
2907
+ this.autoScrollDisabled = listAutoScrollDisabled == null ? false : listAutoScrollDisabled;
2908
+ this.orientation = listOrientation || 'vertical';
3037
2909
  if (lockAxis) {
3038
2910
  this.lockAxis = lockAxis;
3039
2911
  }
3040
- if (constrainPosition) {
3041
- this.constrainPosition = constrainPosition;
3042
- }
3043
- if (previewClass) {
3044
- this.previewClass = previewClass;
3045
- }
3046
- if (boundaryElement) {
3047
- this.boundaryElement = boundaryElement;
3048
- }
3049
- if (rootElementSelector) {
3050
- this.rootElementSelector = rootElementSelector;
3051
- }
3052
2912
  };
3053
- 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 = [
3054
2920
  { type: i0.Directive, args: [{
3055
- selector: '[cdkDrag]',
3056
- 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
+ ],
3057
2928
  host: {
3058
- 'class': 'cdk-drag',
3059
- '[class.cdk-drag-disabled]': 'disabled',
3060
- '[class.cdk-drag-dragging]': '_dragRef.isDragging()',
3061
- },
3062
- 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
+ }
3063
2935
  },] }
3064
2936
  ];
3065
- CdkDrag.ctorParameters = function () { return [
2937
+ CdkDropList.ctorParameters = function () { return [
3066
2938
  { type: i0.ElementRef },
3067
- { type: undefined, decorators: [{ type: i0.Inject, args: [CDK_DROP_LIST,] }, { type: i0.Optional }, { type: i0.SkipSelf }] },
3068
- { type: undefined, decorators: [{ type: i0.Inject, args: [i1.DOCUMENT,] }] },
3069
- { type: i0.NgZone },
3070
- { type: i0.ViewContainerRef },
3071
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [CDK_DRAG_CONFIG,] }] },
3072
- { type: bidi.Directionality, decorators: [{ type: i0.Optional }] },
3073
2939
  { type: DragDrop },
3074
- { 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,] }] }
3075
2945
  ]; };
3076
- CdkDrag.propDecorators = {
3077
- _handles: [{ type: i0.ContentChildren, args: [CdkDragHandle, { descendants: true },] }],
3078
- _previewTemplate: [{ type: i0.ContentChild, args: [CdkDragPreview,] }],
3079
- _placeholderTemplate: [{ type: i0.ContentChild, args: [CdkDragPlaceholder,] }],
3080
- data: [{ type: i0.Input, args: ['cdkDragData',] }],
3081
- lockAxis: [{ type: i0.Input, args: ['cdkDragLockAxis',] }],
3082
- rootElementSelector: [{ type: i0.Input, args: ['cdkDragRootElement',] }],
3083
- boundaryElement: [{ type: i0.Input, args: ['cdkDragBoundary',] }],
3084
- dragStartDelay: [{ type: i0.Input, args: ['cdkDragStartDelay',] }],
3085
- freeDragPosition: [{ type: i0.Input, args: ['cdkDragFreeDragPosition',] }],
3086
- disabled: [{ type: i0.Input, args: ['cdkDragDisabled',] }],
3087
- constrainPosition: [{ type: i0.Input, args: ['cdkDragConstrainPosition',] }],
3088
- previewClass: [{ type: i0.Input, args: ['cdkDragPreviewClass',] }],
3089
- started: [{ type: i0.Output, args: ['cdkDragStarted',] }],
3090
- released: [{ type: i0.Output, args: ['cdkDragReleased',] }],
3091
- ended: [{ type: i0.Output, args: ['cdkDragEnded',] }],
3092
- entered: [{ type: i0.Output, args: ['cdkDragEntered',] }],
3093
- exited: [{ type: i0.Output, args: ['cdkDragExited',] }],
3094
- dropped: [{ type: i0.Output, args: ['cdkDragDropped',] }],
3095
- 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',] }]
3096
2960
  };
3097
- return CdkDrag;
2961
+ return CdkDropList;
3098
2962
  }());
3099
- /** Gets the closest ancestor of an element that matches a selector. */
3100
- function getClosestMatchingAncestor(element, selector) {
3101
- var currentElement = element.parentElement;
3102
- while (currentElement) {
3103
- // IE doesn't support `matches` so we have to fall back to `msMatchesSelector`.
3104
- if (currentElement.matches ? currentElement.matches(selector) :
3105
- currentElement.msMatchesSelector(selector)) {
3106
- return currentElement;
3107
- }
3108
- 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);
3109
3001
  }
3110
- return null;
3111
- }
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
+ }());
3112
3069
 
3113
3070
  /**
3114
3071
  * @license
@@ -3118,39 +3075,41 @@
3118
3075
  * found in the LICENSE file at https://angular.io/license
3119
3076
  */
3120
3077
  /**
3121
- * Declaratively connects sibling `cdkDropList` instances together. All of the `cdkDropList`
3122
- * elements that are placed inside a `cdkDropListGroup` will be connected to each other
3123
- * automatically. Can be used as an alternative to the `cdkDropListConnectedTo` input
3124
- * 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.
3125
3081
  */
3126
- var CdkDropListGroup = /** @class */ (function () {
3127
- function CdkDropListGroup() {
3128
- /** Drop lists registered inside the group. */
3129
- this._items = new Set();
3130
- 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;
3131
3091
  }
3132
- Object.defineProperty(CdkDropListGroup.prototype, "disabled", {
3133
- /** Whether starting a dragging sequence from inside this group is disabled. */
3134
- get: function () { return this._disabled; },
3135
- set: function (value) {
3136
- this._disabled = coercion.coerceBooleanProperty(value);
3137
- },
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); },
3138
3096
  enumerable: false,
3139
3097
  configurable: true
3140
3098
  });
3141
- CdkDropListGroup.prototype.ngOnDestroy = function () {
3142
- this._items.clear();
3143
- };
3144
- CdkDropListGroup.decorators = [
3099
+ CdkDragPreview.decorators = [
3145
3100
  { type: i0.Directive, args: [{
3146
- selector: '[cdkDropListGroup]',
3147
- exportAs: 'cdkDropListGroup',
3101
+ selector: 'ng-template[cdkDragPreview]',
3102
+ providers: [{ provide: CDK_DRAG_PREVIEW, useExisting: CdkDragPreview }],
3148
3103
  },] }
3149
3104
  ];
3150
- CdkDropListGroup.propDecorators = {
3151
- 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 }]
3152
3111
  };
3153
- return CdkDropListGroup;
3112
+ return CdkDragPreview;
3154
3113
  }());
3155
3114
 
3156
3115
  /**
@@ -3160,199 +3119,260 @@
3160
3119
  * Use of this source code is governed by an MIT-style license that can be
3161
3120
  * found in the LICENSE file at https://angular.io/license
3162
3121
  */
3163
- /** Counter used to generate unique ids for drop zones. */
3164
- var _uniqueIdCounter = 0;
3165
- var ɵ0 = undefined;
3166
- /** Container that wraps a set of draggable items. */
3167
- var CdkDropList = /** @class */ (function () {
3168
- function CdkDropList(
3169
- /** Element that the drop list is attached to. */
3170
- element, dragDrop, _changeDetectorRef, _dir, _group,
3171
- /**
3172
- * @deprecated _scrollDispatcher parameter to become required.
3173
- * @breaking-change 11.0.0
3174
- */
3175
- _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) {
3176
3129
  var _this = this;
3177
3130
  this.element = element;
3178
- this._changeDetectorRef = _changeDetectorRef;
3131
+ this.dropContainer = dropContainer;
3132
+ this._document = _document;
3133
+ this._ngZone = _ngZone;
3134
+ this._viewContainerRef = _viewContainerRef;
3179
3135
  this._dir = _dir;
3180
- this._group = _group;
3181
- this._scrollDispatcher = _scrollDispatcher;
3182
- /** Emits when the list has been destroyed. */
3136
+ this._changeDetectorRef = _changeDetectorRef;
3137
+ this._selfHandle = _selfHandle;
3183
3138
  this._destroyed = new rxjs.Subject();
3184
- /**
3185
- * Other draggable containers that this container is connected to and into which the
3186
- * container's items can be transferred. Can either be references to other drop containers,
3187
- * or their unique IDs.
3188
- */
3189
- this.connectedTo = [];
3190
- /**
3191
- * Unique ID for the drop zone. Can be used as a reference
3192
- * in the `connectedTo` of another `CdkDropList`.
3193
- */
3194
- this.id = "cdk-drop-list-" + _uniqueIdCounter++;
3195
- /**
3196
- * Function that is used to determine whether an item
3197
- * is allowed to be moved into a drop container.
3198
- */
3199
- this.enterPredicate = function () { return true; };
3200
- /** Emits when the user drops an item inside the container. */
3201
- this.dropped = new i0.EventEmitter();
3202
- /**
3203
- * Emits when the user has moved a new drag item into this container.
3204
- */
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. */
3205
3146
  this.entered = new i0.EventEmitter();
3206
- /**
3207
- * Emits when the user removes an item from the container
3208
- * by dragging it into another container.
3209
- */
3147
+ /** Emits when the user removes the item its container by dragging it into another container. */
3210
3148
  this.exited = new i0.EventEmitter();
3211
- /** Emits as the user is swapping items while actively dragging. */
3212
- this.sorted = new i0.EventEmitter();
3149
+ /** Emits when the user drops the item inside a container. */
3150
+ this.dropped = new i0.EventEmitter();
3213
3151
  /**
3214
- * Keeps track of the items that are registered with this container. Historically we used to
3215
- * do this with a `ContentChildren` query, however queries don't handle transplanted views very
3216
- * well which means that we can't handle cases like dragging the headers of a `mat-table`
3217
- * correctly. What we do instead is to have the items register themselves with the container
3218
- * 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.
3219
3154
  */
3220
- this._unsortedItems = new Set();
3221
- this._dropListRef = dragDrop.createDropList(element);
3222
- 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;
3223
3175
  if (config) {
3224
3176
  this._assignDefaults(config);
3225
3177
  }
3226
- this._dropListRef.enterPredicate = function (drag, drop) {
3227
- return _this.enterPredicate(drag.data, drop.data);
3228
- };
3229
- this._setupInputSyncSubscription(this._dropListRef);
3230
- this._handleEvents(this._dropListRef);
3231
- CdkDropList._dropLists.push(this);
3232
- if (_group) {
3233
- _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);
3234
3188
  }
3189
+ this._syncInputs(this._dragRef);
3190
+ this._handleEvents(this._dragRef);
3235
3191
  }
3236
- Object.defineProperty(CdkDropList.prototype, "disabled", {
3237
- /** 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. */
3238
3194
  get: function () {
3239
- return this._disabled || (!!this._group && this._group.disabled);
3195
+ return this._disabled || (this.dropContainer && this.dropContainer.disabled);
3240
3196
  },
3241
3197
  set: function (value) {
3242
- // Usually we sync the directive and ref state right before dragging starts, in order to have
3243
- // a single point of failure and to avoid having to use setters for everything. `disabled` is
3244
- // a special case, because it can prevent the `beforeStarted` event from firing, which can lock
3245
- // the user in a disabled state, so we also need to sync it as it's being set.
3246
- this._dropListRef.disabled = this._disabled = coercion.coerceBooleanProperty(value);
3198
+ this._disabled = coercion.coerceBooleanProperty(value);
3199
+ this._dragRef.disabled = this._disabled;
3247
3200
  },
3248
3201
  enumerable: false,
3249
3202
  configurable: true
3250
3203
  });
3251
- /** Registers an items with the drop list. */
3252
- CdkDropList.prototype.addItem = function (item) {
3253
- this._unsortedItems.add(item);
3254
- if (this._dropListRef.isDragging()) {
3255
- 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);
3256
3277
  }
3257
3278
  };
3258
- /** Removes an item from the drop list. */
3259
- CdkDropList.prototype.removeItem = function (item) {
3260
- this._unsortedItems.delete(item);
3261
- if (this._dropListRef.isDragging()) {
3262
- this._syncItemsWithRef();
3279
+ CdkDrag.prototype.ngOnDestroy = function () {
3280
+ if (this.dropContainer) {
3281
+ this.dropContainer.removeItem(this);
3263
3282
  }
3283
+ this._destroyed.next();
3284
+ this._destroyed.complete();
3285
+ this._dragRef.dispose();
3264
3286
  };
3265
- /** Gets the registered items in the list, sorted by their position in the DOM. */
3266
- CdkDropList.prototype.getSortedItems = function () {
3267
- return Array.from(this._unsortedItems).sort(function (a, b) {
3268
- var documentPosition = a._dragRef.getVisibleElement().compareDocumentPosition(b._dragRef.getVisibleElement());
3269
- // `compareDocumentPosition` returns a bitmask so we have to use a bitwise operator.
3270
- // https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
3271
- // tslint:disable-next-line:no-bitwise
3272
- return documentPosition & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
3273
- });
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);
3274
3297
  };
3275
- CdkDropList.prototype.ngOnDestroy = function () {
3276
- var index = CdkDropList._dropLists.indexOf(this);
3277
- if (index > -1) {
3278
- 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;
3279
3303
  }
3280
- if (this._group) {
3281
- this._group._items.delete(this);
3304
+ if (typeof boundary === 'string') {
3305
+ return getClosestMatchingAncestor(this.element.nativeElement, boundary);
3282
3306
  }
3283
- this._unsortedItems.clear();
3284
- this._dropListRef.dispose();
3285
- this._destroyed.next();
3286
- 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;
3287
3312
  };
3288
- /** Syncs the inputs of the CdkDropList with the options of the underlying DropListRef. */
3289
- 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) {
3290
3315
  var _this = this;
3291
- if (this._dir) {
3292
- this._dir.change
3293
- .pipe(operators.startWith(this._dir.value), operators.takeUntil(this._destroyed))
3294
- .subscribe(function (value) { return ref.withDirection(value); });
3295
- }
3296
3316
  ref.beforeStarted.subscribe(function () {
3297
- var siblings = coercion.coerceArray(_this.connectedTo).map(function (drop) {
3298
- return typeof drop === 'string' ?
3299
- CdkDropList._dropLists.find(function (list) { return list.id === drop; }) : drop;
3300
- });
3301
- if (_this._group) {
3302
- _this._group._items.forEach(function (drop) {
3303
- if (siblings.indexOf(drop) === -1) {
3304
- siblings.push(drop);
3305
- }
3306
- });
3307
- }
3308
- // Note that we resolve the scrollable parents here so that we delay the resolution
3309
- // as long as possible, ensuring that the element is in its final place in the DOM.
3310
- // @breaking-change 11.0.0 Remove null check for _scrollDispatcher once it's required.
3311
- if (!_this._scrollableParentsResolved && _this._scrollDispatcher) {
3312
- var scrollableParents = _this._scrollDispatcher
3313
- .getAncestorScrollContainers(_this.element)
3314
- .map(function (scrollable) { return scrollable.getElementRef().nativeElement; });
3315
- _this._dropListRef.withScrollableParents(scrollableParents);
3316
- // Only do this once since it involves traversing the DOM and the parents
3317
- // shouldn't be able to change without the drop list being destroyed.
3318
- _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
+ }
3319
3344
  }
3320
- ref.disabled = _this.disabled;
3321
- ref.lockAxis = _this.lockAxis;
3322
- ref.sortingDisabled = coercion.coerceBooleanProperty(_this.sortingDisabled);
3323
- ref.autoScrollDisabled = coercion.coerceBooleanProperty(_this.autoScrollDisabled);
3324
- ref
3325
- .connectedTo(siblings.filter(function (drop) { return drop && drop !== _this; }).map(function (list) { return list._dropListRef; }))
3326
- .withOrientation(_this.orientation);
3327
3345
  });
3328
3346
  };
3329
- /** Handles events from the underlying DropListRef. */
3330
- CdkDropList.prototype._handleEvents = function (ref) {
3347
+ /** Handles the events from the underlying `DragRef`. */
3348
+ CdkDrag.prototype._handleEvents = function (ref) {
3331
3349
  var _this = this;
3332
- ref.beforeStarted.subscribe(function () {
3333
- _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.
3334
3363
  _this._changeDetectorRef.markForCheck();
3335
3364
  });
3336
3365
  ref.entered.subscribe(function (event) {
3337
3366
  _this.entered.emit({
3338
- container: _this,
3339
- item: event.item.data,
3367
+ container: event.container.data,
3368
+ item: _this,
3340
3369
  currentIndex: event.currentIndex
3341
3370
  });
3342
3371
  });
3343
3372
  ref.exited.subscribe(function (event) {
3344
3373
  _this.exited.emit({
3345
- container: _this,
3346
- item: event.item.data
3347
- });
3348
- _this._changeDetectorRef.markForCheck();
3349
- });
3350
- ref.sorted.subscribe(function (event) {
3351
- _this.sorted.emit({
3352
- previousIndex: event.previousIndex,
3353
- currentIndex: event.currentIndex,
3354
- container: _this,
3355
- item: event.item.data
3374
+ container: event.container.data,
3375
+ item: _this
3356
3376
  });
3357
3377
  });
3358
3378
  ref.dropped.subscribe(function (event) {
@@ -3361,76 +3381,93 @@
3361
3381
  currentIndex: event.currentIndex,
3362
3382
  previousContainer: event.previousContainer.data,
3363
3383
  container: event.container.data,
3364
- item: event.item.data,
3365
3384
  isPointerOverContainer: event.isPointerOverContainer,
3385
+ item: _this,
3366
3386
  distance: event.distance
3367
3387
  });
3368
- // Mark for check since all of these events run outside of change
3369
- // detection and we're not guaranteed for something else to have triggered it.
3370
- _this._changeDetectorRef.markForCheck();
3371
3388
  });
3372
3389
  };
3373
3390
  /** Assigns the default input values based on a provided config object. */
3374
- CdkDropList.prototype._assignDefaults = function (config) {
3375
- 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;
3376
3393
  this.disabled = draggingDisabled == null ? false : draggingDisabled;
3377
- this.sortingDisabled = sortingDisabled == null ? false : sortingDisabled;
3378
- this.autoScrollDisabled = listAutoScrollDisabled == null ? false : listAutoScrollDisabled;
3379
- this.orientation = listOrientation || 'vertical';
3394
+ this.dragStartDelay = dragStartDelay || 0;
3380
3395
  if (lockAxis) {
3381
3396
  this.lockAxis = lockAxis;
3382
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
+ }
3383
3410
  };
3384
- /** Syncs up the registered drag items with underlying drop list ref. */
3385
- CdkDropList.prototype._syncItemsWithRef = function () {
3386
- this._dropListRef.withItems(this.getSortedItems().map(function (item) { return item._dragRef; }));
3387
- };
3388
- /** Keeps track of the drop lists that are currently on the page. */
3389
- CdkDropList._dropLists = [];
3390
- CdkDropList.decorators = [
3411
+ CdkDrag.decorators = [
3391
3412
  { type: i0.Directive, args: [{
3392
- selector: '[cdkDropList], cdk-drop-list',
3393
- exportAs: 'cdkDropList',
3394
- providers: [
3395
- // Prevent child drop lists from picking up the same group as their parent.
3396
- { provide: CdkDropListGroup, useValue: ɵ0 },
3397
- { provide: CDK_DROP_LIST, useExisting: CdkDropList },
3398
- ],
3413
+ selector: '[cdkDrag]',
3414
+ exportAs: 'cdkDrag',
3399
3415
  host: {
3400
- 'class': 'cdk-drop-list',
3401
- '[id]': 'id',
3402
- '[class.cdk-drop-list-disabled]': 'disabled',
3403
- '[class.cdk-drop-list-dragging]': '_dropListRef.isDragging()',
3404
- '[class.cdk-drop-list-receiving]': '_dropListRef.isReceiving()',
3405
- }
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 }]
3406
3421
  },] }
3407
3422
  ];
3408
- CdkDropList.ctorParameters = function () { return [
3423
+ CdkDrag.ctorParameters = function () { return [
3409
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 }] },
3410
3431
  { type: DragDrop },
3411
3432
  { type: i0.ChangeDetectorRef },
3412
- { type: bidi.Directionality, decorators: [{ type: i0.Optional }] },
3413
- { type: CdkDropListGroup, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] },
3414
- { type: i2.ScrollDispatcher },
3415
- { 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,] }] }
3416
3434
  ]; };
3417
- CdkDropList.propDecorators = {
3418
- connectedTo: [{ type: i0.Input, args: ['cdkDropListConnectedTo',] }],
3419
- data: [{ type: i0.Input, args: ['cdkDropListData',] }],
3420
- orientation: [{ type: i0.Input, args: ['cdkDropListOrientation',] }],
3421
- id: [{ type: i0.Input }],
3422
- lockAxis: [{ type: i0.Input, args: ['cdkDropListLockAxis',] }],
3423
- disabled: [{ type: i0.Input, args: ['cdkDropListDisabled',] }],
3424
- sortingDisabled: [{ type: i0.Input, args: ['cdkDropListSortingDisabled',] }],
3425
- enterPredicate: [{ type: i0.Input, args: ['cdkDropListEnterPredicate',] }],
3426
- autoScrollDisabled: [{ type: i0.Input, args: ['cdkDropListAutoScrollDisabled',] }],
3427
- dropped: [{ type: i0.Output, args: ['cdkDropListDropped',] }],
3428
- entered: [{ type: i0.Output, args: ['cdkDropListEntered',] }],
3429
- exited: [{ type: i0.Output, args: ['cdkDropListExited',] }],
3430
- 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',] }]
3431
3455
  };
3432
- return CdkDropList;
3456
+ return CdkDrag;
3433
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
+ }
3434
3471
 
3435
3472
  /**
3436
3473
  * @license
@@ -3482,7 +3519,10 @@
3482
3519
  */
3483
3520
 
3484
3521
  exports.CDK_DRAG_CONFIG = CDK_DRAG_CONFIG;
3485
- 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;
3486
3526
  exports.CdkDrag = CdkDrag;
3487
3527
  exports.CdkDragHandle = CdkDragHandle;
3488
3528
  exports.CdkDragPlaceholder = CdkDragPlaceholder;
@@ -3497,7 +3537,8 @@
3497
3537
  exports.copyArrayItem = copyArrayItem;
3498
3538
  exports.moveItemInArray = moveItemInArray;
3499
3539
  exports.transferArrayItem = transferArrayItem;
3500
- 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;
3501
3542
 
3502
3543
  Object.defineProperty(exports, '__esModule', { value: true });
3503
3544