@angular/cdk 11.0.3 → 11.0.4
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/LICENSE +1 -1
- package/a11y/focus-monitor/focus-monitor.d.ts +6 -0
- package/a11y/index.metadata.json +1 -1
- package/bundles/cdk-a11y.umd.js +21 -9
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +1 -8
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +78 -40
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +8 -8
- package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
- package/bundles/cdk-overlay.umd.js +15 -7
- package/bundles/cdk-overlay.umd.js.map +1 -1
- package/bundles/cdk-overlay.umd.min.js +17 -24
- package/bundles/cdk-overlay.umd.min.js.map +1 -1
- package/bundles/cdk-platform.umd.js +1 -0
- package/bundles/cdk-platform.umd.js.map +1 -1
- package/bundles/cdk-platform.umd.min.js +1 -1
- package/bundles/cdk-platform.umd.min.js.map +1 -1
- package/bundles/cdk-scrolling.umd.js +9 -3
- package/bundles/cdk-scrolling.umd.js.map +1 -1
- package/bundles/cdk-scrolling.umd.min.js +2 -2
- package/bundles/cdk-scrolling.umd.min.js.map +1 -1
- package/bundles/cdk-tree.umd.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.d.ts +1 -1
- package/drag-drop/drag-drop-registry.d.ts +8 -1
- package/drag-drop/drag-ref.d.ts +2 -0
- package/drag-drop/drop-list-ref.d.ts +5 -1
- package/drag-drop/index.metadata.json +1 -1
- package/esm2015/a11y/focus-monitor/focus-monitor.js +18 -3
- package/esm2015/drag-drop/directives/drag.js +6 -4
- package/esm2015/drag-drop/drag-drop-registry.js +25 -12
- package/esm2015/drag-drop/drag-ref.js +10 -8
- package/esm2015/drag-drop/drop-list-ref.js +39 -19
- package/esm2015/overlay/scroll/block-scroll-strategy.js +13 -4
- package/esm2015/platform/features/scrolling.js +2 -1
- package/esm2015/scrolling/fixed-size-virtual-scroll.js +3 -2
- package/esm2015/scrolling/virtual-for-of.js +8 -4
- package/esm2015/tree/nested-node.js +1 -1
- package/esm2015/tree/padding.js +1 -1
- package/esm2015/tree/toggle.js +1 -1
- package/esm2015/tree/tree.js +1 -1
- package/esm2015/version.js +1 -1
- package/fesm2015/a11y.js +17 -2
- package/fesm2015/a11y.js.map +1 -1
- package/fesm2015/cdk.js +1 -1
- package/fesm2015/cdk.js.map +1 -1
- package/fesm2015/drag-drop.js +76 -39
- package/fesm2015/drag-drop.js.map +1 -1
- package/fesm2015/overlay.js +12 -4
- package/fesm2015/overlay.js.map +1 -1
- package/fesm2015/platform.js +1 -0
- package/fesm2015/platform.js.map +1 -1
- package/fesm2015/scrolling.js +9 -4
- package/fesm2015/scrolling.js.map +1 -1
- package/fesm2015/tree.js.map +1 -1
- package/overlay/index.metadata.json +1 -1
- package/package.json +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/scrolling/index.metadata.json +1 -1
- package/tree/index.metadata.json +1 -1
- package/tree/nested-node.d.ts +3 -3
- package/tree/padding.d.ts +2 -2
- package/tree/toggle.d.ts +4 -4
- package/tree/tree.d.ts +5 -5
|
@@ -389,9 +389,6 @@
|
|
|
389
389
|
};
|
|
390
390
|
/** Handler that is invoked when the user moves their pointer after they've initiated a drag. */
|
|
391
391
|
this._pointerMove = function (event) {
|
|
392
|
-
// Prevent the default action as early as possible in order to block
|
|
393
|
-
// native actions like dragging the selected text or images with the mouse.
|
|
394
|
-
event.preventDefault();
|
|
395
392
|
var pointerPosition = _this._getPointerPositionOnPage(event);
|
|
396
393
|
if (!_this._hasStartedDragging) {
|
|
397
394
|
var distanceX = Math.abs(pointerPosition.x - _this._pickupPositionOnPage.x);
|
|
@@ -426,6 +423,10 @@
|
|
|
426
423
|
_this._previewRect = (_this._preview || _this._rootElement).getBoundingClientRect();
|
|
427
424
|
}
|
|
428
425
|
}
|
|
426
|
+
// We prevent the default action down here so that we know that dragging has started. This is
|
|
427
|
+
// important for touch devices where doing this too early can unnecessarily block scrolling,
|
|
428
|
+
// if there's a dragging delay.
|
|
429
|
+
event.preventDefault();
|
|
429
430
|
var constrainedPointerPosition = _this._getConstrainedPointerPosition(pointerPosition);
|
|
430
431
|
_this._hasMoved = true;
|
|
431
432
|
_this._lastKnownPointerPosition = pointerPosition;
|
|
@@ -791,10 +792,11 @@
|
|
|
791
792
|
*/
|
|
792
793
|
DragRef.prototype._initializeDragSequence = function (referenceElement, event) {
|
|
793
794
|
var _this = this;
|
|
794
|
-
//
|
|
795
|
-
//
|
|
796
|
-
|
|
797
|
-
|
|
795
|
+
// Stop propagation if the item is inside another
|
|
796
|
+
// draggable so we don't start multiple drag sequences.
|
|
797
|
+
if (this._config.parentDragRef) {
|
|
798
|
+
event.stopPropagation();
|
|
799
|
+
}
|
|
798
800
|
var isDragging = this.isDragging();
|
|
799
801
|
var isTouchSequence = isTouchEvent(event);
|
|
800
802
|
var isAuxiliaryMouseButton = !isTouchSequence && event.button !== 0;
|
|
@@ -1768,6 +1770,8 @@
|
|
|
1768
1770
|
* overlap with the swapped item after the swapping occurred.
|
|
1769
1771
|
*/
|
|
1770
1772
|
this._previousSwap = { drag: null, delta: 0, overlaps: false };
|
|
1773
|
+
/** Draggable items in the container. */
|
|
1774
|
+
this._draggables = [];
|
|
1771
1775
|
/** Drop lists that are connected to the current one. */
|
|
1772
1776
|
this._siblings = [];
|
|
1773
1777
|
/** Direction in which the list is oriented. */
|
|
@@ -1834,19 +1838,8 @@
|
|
|
1834
1838
|
};
|
|
1835
1839
|
/** Starts dragging an item. */
|
|
1836
1840
|
DropListRef.prototype.start = function () {
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
this.beforeStarted.next();
|
|
1840
|
-
this._isDragging = true;
|
|
1841
|
-
// We need to disable scroll snapping while the user is dragging, because it breaks automatic
|
|
1842
|
-
// scrolling. The browser seems to round the value based on the snapping points which means
|
|
1843
|
-
// that we can't increment/decrement the scroll position.
|
|
1844
|
-
this._initialScrollSnap = styles.msScrollSnapType || styles.scrollSnapType || '';
|
|
1845
|
-
styles.scrollSnapType = styles.msScrollSnapType = 'none';
|
|
1846
|
-
this._cacheItems();
|
|
1847
|
-
this._siblings.forEach(function (sibling) { return sibling._startReceiving(_this); });
|
|
1848
|
-
this._viewportScrollSubscription.unsubscribe();
|
|
1849
|
-
this._listenToScrollEvents();
|
|
1841
|
+
this._draggingStarted();
|
|
1842
|
+
this._notifyReceivingSiblings();
|
|
1850
1843
|
};
|
|
1851
1844
|
/**
|
|
1852
1845
|
* Emits an event to indicate that the user moved an item into the container.
|
|
@@ -1857,7 +1850,7 @@
|
|
|
1857
1850
|
* out automatically.
|
|
1858
1851
|
*/
|
|
1859
1852
|
DropListRef.prototype.enter = function (item, pointerX, pointerY, index) {
|
|
1860
|
-
this.
|
|
1853
|
+
this._draggingStarted();
|
|
1861
1854
|
// If sorting is disabled, we want the item to return to its starting
|
|
1862
1855
|
// position if the user is returning it to its initial container.
|
|
1863
1856
|
var newIndex;
|
|
@@ -1909,6 +1902,8 @@
|
|
|
1909
1902
|
// but we need to refresh them since the amount of items has changed and also parent rects.
|
|
1910
1903
|
this._cacheItemPositions();
|
|
1911
1904
|
this._cacheParentPositions();
|
|
1905
|
+
// Notify siblings at the end so that the item has been inserted into the `activeDraggables`.
|
|
1906
|
+
this._notifyReceivingSiblings();
|
|
1912
1907
|
this.entered.next({ item: item, container: this, currentIndex: this.getItemIndex(item) });
|
|
1913
1908
|
};
|
|
1914
1909
|
/**
|
|
@@ -2032,7 +2027,7 @@
|
|
|
2032
2027
|
*/
|
|
2033
2028
|
DropListRef.prototype._sortItem = function (item, pointerX, pointerY, pointerDelta) {
|
|
2034
2029
|
// Don't sort the item if sorting is disabled or it's out of range.
|
|
2035
|
-
if (this.sortingDisabled ||
|
|
2030
|
+
if (this.sortingDisabled || !this._clientRect ||
|
|
2036
2031
|
!isPointerNearClientRect(this._clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
|
|
2037
2032
|
return;
|
|
2038
2033
|
}
|
|
@@ -2148,6 +2143,20 @@
|
|
|
2148
2143
|
DropListRef.prototype._stopScrolling = function () {
|
|
2149
2144
|
this._stopScrollTimers.next();
|
|
2150
2145
|
};
|
|
2146
|
+
/** Starts the dragging sequence within the list. */
|
|
2147
|
+
DropListRef.prototype._draggingStarted = function () {
|
|
2148
|
+
var styles = coercion.coerceElement(this.element).style;
|
|
2149
|
+
this.beforeStarted.next();
|
|
2150
|
+
this._isDragging = true;
|
|
2151
|
+
// We need to disable scroll snapping while the user is dragging, because it breaks automatic
|
|
2152
|
+
// scrolling. The browser seems to round the value based on the snapping points which means
|
|
2153
|
+
// that we can't increment/decrement the scroll position.
|
|
2154
|
+
this._initialScrollSnap = styles.msScrollSnapType || styles.scrollSnapType || '';
|
|
2155
|
+
styles.scrollSnapType = styles.msScrollSnapType = 'none';
|
|
2156
|
+
this._cacheItems();
|
|
2157
|
+
this._viewportScrollSubscription.unsubscribe();
|
|
2158
|
+
this._listenToScrollEvents();
|
|
2159
|
+
};
|
|
2151
2160
|
/** Caches the positions of the configured scrollable parents. */
|
|
2152
2161
|
DropListRef.prototype._cacheParentPositions = function () {
|
|
2153
2162
|
var element = coercion.coerceElement(this.element);
|
|
@@ -2304,7 +2313,7 @@
|
|
|
2304
2313
|
* @param y Pointer position along the Y axis.
|
|
2305
2314
|
*/
|
|
2306
2315
|
DropListRef.prototype._isOverContainer = function (x, y) {
|
|
2307
|
-
return isInsideClientRect(this._clientRect, x, y);
|
|
2316
|
+
return this._clientRect != null && isInsideClientRect(this._clientRect, x, y);
|
|
2308
2317
|
};
|
|
2309
2318
|
/**
|
|
2310
2319
|
* Figures out whether an item should be moved into a sibling
|
|
@@ -2323,7 +2332,8 @@
|
|
|
2323
2332
|
* @param y Position of the item along the Y axis.
|
|
2324
2333
|
*/
|
|
2325
2334
|
DropListRef.prototype._canReceive = function (item, x, y) {
|
|
2326
|
-
if (!isInsideClientRect(this._clientRect, x, y) ||
|
|
2335
|
+
if (!this._clientRect || !isInsideClientRect(this._clientRect, x, y) ||
|
|
2336
|
+
!this.enterPredicate(item, this)) {
|
|
2327
2337
|
return false;
|
|
2328
2338
|
}
|
|
2329
2339
|
var elementFromPoint = this._getShadowRoot().elementFromPoint(x, y);
|
|
@@ -2345,9 +2355,16 @@
|
|
|
2345
2355
|
* Called by one of the connected drop lists when a dragging sequence has started.
|
|
2346
2356
|
* @param sibling Sibling in which dragging has started.
|
|
2347
2357
|
*/
|
|
2348
|
-
DropListRef.prototype._startReceiving = function (sibling) {
|
|
2358
|
+
DropListRef.prototype._startReceiving = function (sibling, items) {
|
|
2359
|
+
var _this = this;
|
|
2349
2360
|
var activeSiblings = this._activeSiblings;
|
|
2350
|
-
if (!activeSiblings.has(sibling)) {
|
|
2361
|
+
if (!activeSiblings.has(sibling) && items.every(function (item) {
|
|
2362
|
+
// Note that we have to add an exception to the `enterPredicate` for items that started off
|
|
2363
|
+
// in this drop list. The drag ref has logic that allows an item to return to its initial
|
|
2364
|
+
// container, if it has left the initial container and none of the connected containers
|
|
2365
|
+
// allow it to enter. See `DragRef._updateActiveDropContainer` for more context.
|
|
2366
|
+
return _this.enterPredicate(item, _this) || _this._draggables.indexOf(item) > -1;
|
|
2367
|
+
})) {
|
|
2351
2368
|
activeSiblings.add(sibling);
|
|
2352
2369
|
this._cacheParentPositions();
|
|
2353
2370
|
this._listenToScrollEvents();
|
|
@@ -2409,6 +2426,12 @@
|
|
|
2409
2426
|
}
|
|
2410
2427
|
return this._cachedShadowRoot;
|
|
2411
2428
|
};
|
|
2429
|
+
/** Notifies any siblings that may potentially receive the item. */
|
|
2430
|
+
DropListRef.prototype._notifyReceivingSiblings = function () {
|
|
2431
|
+
var _this = this;
|
|
2432
|
+
var draggedItems = this._activeDraggables.filter(function (item) { return item.isDragging(); });
|
|
2433
|
+
this._siblings.forEach(function (sibling) { return sibling._startReceiving(_this, draggedItems); });
|
|
2434
|
+
};
|
|
2412
2435
|
return DropListRef;
|
|
2413
2436
|
}());
|
|
2414
2437
|
/**
|
|
@@ -2556,9 +2579,14 @@
|
|
|
2556
2579
|
/** Registered drag item instances. */
|
|
2557
2580
|
this._dragInstances = new Set();
|
|
2558
2581
|
/** Drag item instances that are currently being dragged. */
|
|
2559
|
-
this._activeDragInstances =
|
|
2582
|
+
this._activeDragInstances = [];
|
|
2560
2583
|
/** Keeps track of the event listeners that we've bound to the `document`. */
|
|
2561
2584
|
this._globalListeners = new Map();
|
|
2585
|
+
/**
|
|
2586
|
+
* Predicate function to check if an item is being dragged. Moved out into a property,
|
|
2587
|
+
* because it'll be called a lot and we don't want to create a new function every time.
|
|
2588
|
+
*/
|
|
2589
|
+
this._draggingPredicate = function (item) { return item.isDragging(); };
|
|
2562
2590
|
/**
|
|
2563
2591
|
* Emits the `touchmove` or `mousemove` events that are dispatched
|
|
2564
2592
|
* while the user is dragging a drag item instance.
|
|
@@ -2576,14 +2604,19 @@
|
|
|
2576
2604
|
* @param event Event whose default action should be prevented.
|
|
2577
2605
|
*/
|
|
2578
2606
|
this._preventDefaultWhileDragging = function (event) {
|
|
2579
|
-
if (_this._activeDragInstances.
|
|
2607
|
+
if (_this._activeDragInstances.length > 0) {
|
|
2580
2608
|
event.preventDefault();
|
|
2581
2609
|
}
|
|
2582
2610
|
};
|
|
2583
2611
|
/** Event listener for `touchmove` that is bound even if no dragging is happening. */
|
|
2584
2612
|
this._persistentTouchmoveListener = function (event) {
|
|
2585
|
-
if (_this._activeDragInstances.
|
|
2586
|
-
|
|
2613
|
+
if (_this._activeDragInstances.length > 0) {
|
|
2614
|
+
// Note that we only want to prevent the default action after dragging has actually started.
|
|
2615
|
+
// Usually this is the same time at which the item is added to the `_activeDragInstances`,
|
|
2616
|
+
// but it could be pushed back if the user has set up a drag delay or threshold.
|
|
2617
|
+
if (_this._activeDragInstances.some(_this._draggingPredicate)) {
|
|
2618
|
+
event.preventDefault();
|
|
2619
|
+
}
|
|
2587
2620
|
_this.pointerMove.next(event);
|
|
2588
2621
|
}
|
|
2589
2622
|
};
|
|
@@ -2630,11 +2663,11 @@
|
|
|
2630
2663
|
DragDropRegistry.prototype.startDragging = function (drag, event) {
|
|
2631
2664
|
var _this = this;
|
|
2632
2665
|
// Do not process the same drag twice to avoid memory leaks and redundant listeners
|
|
2633
|
-
if (this._activeDragInstances.
|
|
2666
|
+
if (this._activeDragInstances.indexOf(drag) > -1) {
|
|
2634
2667
|
return;
|
|
2635
2668
|
}
|
|
2636
|
-
this._activeDragInstances.
|
|
2637
|
-
if (this._activeDragInstances.
|
|
2669
|
+
this._activeDragInstances.push(drag);
|
|
2670
|
+
if (this._activeDragInstances.length === 1) {
|
|
2638
2671
|
var isTouchEvent = event.type.startsWith('touch');
|
|
2639
2672
|
// We explicitly bind __active__ listeners here, because newer browsers will default to
|
|
2640
2673
|
// passive ones for `mousemove` and `touchmove`. The events need to be active, because we
|
|
@@ -2675,14 +2708,17 @@
|
|
|
2675
2708
|
};
|
|
2676
2709
|
/** Stops dragging a drag item instance. */
|
|
2677
2710
|
DragDropRegistry.prototype.stopDragging = function (drag) {
|
|
2678
|
-
this._activeDragInstances.
|
|
2679
|
-
if (
|
|
2680
|
-
this.
|
|
2711
|
+
var index = this._activeDragInstances.indexOf(drag);
|
|
2712
|
+
if (index > -1) {
|
|
2713
|
+
this._activeDragInstances.splice(index, 1);
|
|
2714
|
+
if (this._activeDragInstances.length === 0) {
|
|
2715
|
+
this._clearGlobalListeners();
|
|
2716
|
+
}
|
|
2681
2717
|
}
|
|
2682
2718
|
};
|
|
2683
2719
|
/** Gets whether a drag item instance is currently being dragged. */
|
|
2684
2720
|
DragDropRegistry.prototype.isDragging = function (drag) {
|
|
2685
|
-
return this._activeDragInstances.
|
|
2721
|
+
return this._activeDragInstances.indexOf(drag) > -1;
|
|
2686
2722
|
};
|
|
2687
2723
|
DragDropRegistry.prototype.ngOnDestroy = function () {
|
|
2688
2724
|
var _this = this;
|
|
@@ -3303,7 +3339,7 @@
|
|
|
3303
3339
|
* @deprecated `_document` parameter no longer being used and will be removed.
|
|
3304
3340
|
* @breaking-change 12.0.0
|
|
3305
3341
|
*/
|
|
3306
|
-
_document, _ngZone, _viewContainerRef, config, _dir, dragDrop, _changeDetectorRef, _selfHandle) {
|
|
3342
|
+
_document, _ngZone, _viewContainerRef, config, _dir, dragDrop, _changeDetectorRef, _selfHandle, parentDrag) {
|
|
3307
3343
|
var _this = this;
|
|
3308
3344
|
this.element = element;
|
|
3309
3345
|
this.dropContainer = dropContainer;
|
|
@@ -3346,7 +3382,8 @@
|
|
|
3346
3382
|
config.dragStartThreshold : 5,
|
|
3347
3383
|
pointerDirectionChangeThreshold: config && config.pointerDirectionChangeThreshold != null ?
|
|
3348
3384
|
config.pointerDirectionChangeThreshold : 5,
|
|
3349
|
-
zIndex: config === null || config === void 0 ? void 0 : config.zIndex
|
|
3385
|
+
zIndex: config === null || config === void 0 ? void 0 : config.zIndex,
|
|
3386
|
+
parentDragRef: parentDrag === null || parentDrag === void 0 ? void 0 : parentDrag._dragRef
|
|
3350
3387
|
});
|
|
3351
3388
|
this._dragRef.data = this;
|
|
3352
3389
|
if (config) {
|
|
@@ -3609,7 +3646,8 @@
|
|
|
3609
3646
|
{ type: bidi.Directionality, decorators: [{ type: i0.Optional }] },
|
|
3610
3647
|
{ type: DragDrop },
|
|
3611
3648
|
{ type: i0.ChangeDetectorRef },
|
|
3612
|
-
{ type: CdkDragHandle, decorators: [{ type: i0.Optional }, { type: i0.Self }, { type: i0.Inject, args: [CDK_DRAG_HANDLE,] }] }
|
|
3649
|
+
{ type: CdkDragHandle, decorators: [{ type: i0.Optional }, { type: i0.Self }, { type: i0.Inject, args: [CDK_DRAG_HANDLE,] }] },
|
|
3650
|
+
{ type: CdkDrag, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }, { type: i0.Inject, args: [CDK_DRAG_PARENT,] }] }
|
|
3613
3651
|
]; };
|
|
3614
3652
|
CdkDrag.propDecorators = {
|
|
3615
3653
|
_handles: [{ type: i0.ContentChildren, args: [CDK_DRAG_HANDLE, { descendants: true },] }],
|