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