@angular/cdk 9.2.0 → 9.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/a11y/focus-monitor/focus-monitor.d.ts +6 -0
  2. package/a11y/index.metadata.json +1 -1
  3. package/bundles/cdk-a11y.umd.js +71 -64
  4. package/bundles/cdk-a11y.umd.js.map +1 -1
  5. package/bundles/cdk-a11y.umd.min.js +8 -8
  6. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  7. package/bundles/cdk-drag-drop.umd.js +108 -79
  8. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  9. package/bundles/cdk-drag-drop.umd.min.js +15 -8
  10. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  11. package/bundles/cdk-tree.umd.js +8 -4
  12. package/bundles/cdk-tree.umd.js.map +1 -1
  13. package/bundles/cdk-tree.umd.min.js +1 -1
  14. package/bundles/cdk-tree.umd.min.js.map +1 -1
  15. package/bundles/cdk.umd.js +1 -1
  16. package/bundles/cdk.umd.js.map +1 -1
  17. package/bundles/cdk.umd.min.js +1 -1
  18. package/bundles/cdk.umd.min.js.map +1 -1
  19. package/drag-drop/client-rect.d.ts +31 -0
  20. package/drag-drop/directives/config.d.ts +1 -0
  21. package/drag-drop/directives/drop-list.d.ts +4 -3
  22. package/drag-drop/drag-ref.d.ts +4 -0
  23. package/drag-drop/index.metadata.json +1 -1
  24. package/esm2015/a11y/focus-monitor/focus-monitor.js +71 -65
  25. package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +8 -4
  26. package/esm2015/drag-drop/client-rect.js +75 -0
  27. package/esm2015/drag-drop/directives/config.js +3 -1
  28. package/esm2015/drag-drop/directives/drag.js +3 -2
  29. package/esm2015/drag-drop/directives/drop-list.js +24 -18
  30. package/esm2015/drag-drop/drag-ref.js +55 -21
  31. package/esm2015/drag-drop/drop-list-ref.js +5 -64
  32. package/esm2015/tree/padding.js +9 -10
  33. package/esm2015/version.js +1 -1
  34. package/esm5/a11y/focus-monitor/focus-monitor.js +49 -44
  35. package/esm5/a11y/high-contrast-mode/high-contrast-mode-detector.js +7 -4
  36. package/esm5/drag-drop/client-rect.js +60 -0
  37. package/esm5/drag-drop/directives/config.js +1 -1
  38. package/esm5/drag-drop/directives/drag.js +3 -2
  39. package/esm5/drag-drop/directives/drop-list.js +13 -10
  40. package/esm5/drag-drop/drag-ref.js +33 -17
  41. package/esm5/drag-drop/drop-list-ref.js +5 -54
  42. package/esm5/tree/padding.js +9 -5
  43. package/esm5/version.js +1 -1
  44. package/fesm2015/a11y.js +101 -92
  45. package/fesm2015/a11y.js.map +1 -1
  46. package/fesm2015/cdk.js +1 -1
  47. package/fesm2015/cdk.js.map +1 -1
  48. package/fesm2015/drag-drop.js +158 -101
  49. package/fesm2015/drag-drop.js.map +1 -1
  50. package/fesm2015/tree.js +8 -9
  51. package/fesm2015/tree.js.map +1 -1
  52. package/fesm5/a11y.js +71 -64
  53. package/fesm5/a11y.js.map +1 -1
  54. package/fesm5/cdk.js +1 -1
  55. package/fesm5/cdk.js.map +1 -1
  56. package/fesm5/drag-drop.js +108 -79
  57. package/fesm5/drag-drop.js.map +1 -1
  58. package/fesm5/tree.js +8 -4
  59. package/fesm5/tree.js.map +1 -1
  60. package/package.json +1 -1
  61. package/schematics/ng-add/index.js +1 -1
  62. package/tree/index.metadata.json +1 -1
  63. package/tree/padding.d.ts +6 -2
package/fesm5/cdk.js CHANGED
@@ -8,7 +8,7 @@ import { Version } from '@angular/core';
8
8
  * found in the LICENSE file at https://angular.io/license
9
9
  */
10
10
  /** Current version of the Angular Component Development Kit. */
11
- var VERSION = new Version('9.2.0');
11
+ var VERSION = new Version('9.2.1');
12
12
 
13
13
  /**
14
14
  * @license
package/fesm5/cdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cdk.js","sources":["../../../../../../src/cdk/version.ts","../../../../../../src/cdk/public-api.ts","../../../../../../src/cdk/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Version} from '@angular/core';\n\n/** Current version of the Angular Component Development Kit. */\nexport const VERSION = new Version('9.2.0');\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './version';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;;;AAQA,AAEA;AACA,IAAa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB,CAAC;;ACXvD;;;;;;GAMG;;ACNH;;;;;;GAMG;;;;"}
1
+ {"version":3,"file":"cdk.js","sources":["../../../../../../src/cdk/version.ts","../../../../../../src/cdk/public-api.ts","../../../../../../src/cdk/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Version} from '@angular/core';\n\n/** Current version of the Angular Component Development Kit. */\nexport const VERSION = new Version('9.2.1');\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './version';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;;;AAQA,AAEA;AACA,IAAa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB,CAAC;;ACXvD;;;;;;GAMG;;ACNH;;;;;;GAMG;;;;"}
@@ -82,6 +82,66 @@ function parseCssPropertyValue(computedStyle, name) {
82
82
  return value.split(',').map(function (part) { return part.trim(); });
83
83
  }
84
84
 
85
+ /**
86
+ * @license
87
+ * Copyright Google LLC All Rights Reserved.
88
+ *
89
+ * Use of this source code is governed by an MIT-style license that can be
90
+ * found in the LICENSE file at https://angular.io/license
91
+ */
92
+ /** Gets a mutable version of an element's bounding `ClientRect`. */
93
+ function getMutableClientRect(element) {
94
+ var clientRect = element.getBoundingClientRect();
95
+ // We need to clone the `clientRect` here, because all the values on it are readonly
96
+ // and we need to be able to update them. Also we can't use a spread here, because
97
+ // the values on a `ClientRect` aren't own properties. See:
98
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
99
+ return {
100
+ top: clientRect.top,
101
+ right: clientRect.right,
102
+ bottom: clientRect.bottom,
103
+ left: clientRect.left,
104
+ width: clientRect.width,
105
+ height: clientRect.height
106
+ };
107
+ }
108
+ /**
109
+ * Checks whether some coordinates are within a `ClientRect`.
110
+ * @param clientRect ClientRect that is being checked.
111
+ * @param x Coordinates along the X axis.
112
+ * @param y Coordinates along the Y axis.
113
+ */
114
+ function isInsideClientRect(clientRect, x, y) {
115
+ var top = clientRect.top, bottom = clientRect.bottom, left = clientRect.left, right = clientRect.right;
116
+ return y >= top && y <= bottom && x >= left && x <= right;
117
+ }
118
+ /**
119
+ * Updates the top/left positions of a `ClientRect`, as well as their bottom/right counterparts.
120
+ * @param clientRect `ClientRect` that should be updated.
121
+ * @param top Amount to add to the `top` position.
122
+ * @param left Amount to add to the `left` position.
123
+ */
124
+ function adjustClientRect(clientRect, top, left) {
125
+ clientRect.top += top;
126
+ clientRect.bottom = clientRect.top + clientRect.height;
127
+ clientRect.left += left;
128
+ clientRect.right = clientRect.left + clientRect.width;
129
+ }
130
+ /**
131
+ * Checks whether the pointer coordinates are close to a ClientRect.
132
+ * @param rect ClientRect to check against.
133
+ * @param threshold Threshold around the ClientRect.
134
+ * @param pointerX Coordinates along the X axis.
135
+ * @param pointerY Coordinates along the Y axis.
136
+ */
137
+ function isPointerNearClientRect(rect, threshold, pointerX, pointerY) {
138
+ var top = rect.top, right = rect.right, bottom = rect.bottom, left = rect.left, width = rect.width, height = rect.height;
139
+ var xThreshold = width * threshold;
140
+ var yThreshold = height * threshold;
141
+ return pointerY > top - yThreshold && pointerY < bottom + yThreshold &&
142
+ pointerX > left - xThreshold && pointerX < right + xThreshold;
143
+ }
144
+
85
145
  /**
86
146
  * @license
87
147
  * Copyright Google LLC All Rights Reserved.
@@ -187,8 +247,8 @@ var DragRef = /** @class */ (function () {
187
247
  // Prevent the default action as early as possible in order to block
188
248
  // native actions like dragging the selected text or images with the mouse.
189
249
  event.preventDefault();
250
+ var pointerPosition = _this._getPointerPositionOnPage(event);
190
251
  if (!_this._hasStartedDragging) {
191
- var pointerPosition = _this._getPointerPositionOnPage(event);
192
252
  var distanceX = Math.abs(pointerPosition.x - _this._pickupPositionOnPage.x);
193
253
  var distanceY = Math.abs(pointerPosition.y - _this._pickupPositionOnPage.y);
194
254
  var isOverThreshold = distanceX + distanceY >= _this._config.dragStartThreshold;
@@ -220,7 +280,7 @@ var DragRef = /** @class */ (function () {
220
280
  _this._previewRect = (_this._preview || _this._rootElement).getBoundingClientRect();
221
281
  }
222
282
  }
223
- var constrainedPointerPosition = _this._getConstrainedPointerPosition(event);
283
+ var constrainedPointerPosition = _this._getConstrainedPointerPosition(pointerPosition);
224
284
  _this._hasMoved = true;
225
285
  _this._updatePointerDirectionDelta(constrainedPointerPosition);
226
286
  if (_this._dropContainer) {
@@ -323,13 +383,16 @@ var DragRef = /** @class */ (function () {
323
383
  * dragging on an element that you might not have access to.
324
384
  */
325
385
  DragRef.prototype.withRootElement = function (rootElement) {
386
+ var _this = this;
326
387
  var element = coerceElement(rootElement);
327
388
  if (element !== this._rootElement) {
328
389
  if (this._rootElement) {
329
390
  this._removeRootElementListeners(this._rootElement);
330
391
  }
331
- element.addEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
332
- element.addEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
392
+ this._ngZone.runOutsideAngular(function () {
393
+ element.addEventListener('mousedown', _this._pointerDown, activeEventListenerOptions);
394
+ element.addEventListener('touchstart', _this._pointerDown, passiveEventListenerOptions);
395
+ });
333
396
  this._initialTransform = undefined;
334
397
  this._rootElement = element;
335
398
  }
@@ -438,7 +501,7 @@ var DragRef = /** @class */ (function () {
438
501
  DragRef.prototype._sortFromLastPointerPosition = function () {
439
502
  var position = this._pointerPositionAtLastDirectionChange;
440
503
  if (position && this._dropContainer) {
441
- this._updateActiveDropContainer(position);
504
+ this._updateActiveDropContainer(this._getConstrainedPointerPosition(position));
442
505
  }
443
506
  };
444
507
  /** Unsubscribes from the global subscriptions. */
@@ -590,10 +653,10 @@ var DragRef = /** @class */ (function () {
590
653
  this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
591
654
  this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
592
655
  this._scrollSubscription = this._dragDropRegistry.scroll.pipe(startWith(null)).subscribe(function () {
593
- _this._scrollPosition = _this._viewportRuler.getViewportScrollPosition();
656
+ _this._updateOnScroll();
594
657
  });
595
658
  if (this._boundaryElement) {
596
- this._boundaryRect = this._boundaryElement.getBoundingClientRect();
659
+ this._boundaryRect = getMutableClientRect(this._boundaryElement);
597
660
  }
598
661
  // If we have a custom preview we can't know ahead of time how large it'll be so we position
599
662
  // it next to the cursor. The exception is when the consumer has opted into making the preview
@@ -717,7 +780,7 @@ var DragRef = /** @class */ (function () {
717
780
  position: 'fixed',
718
781
  top: '0',
719
782
  left: '0',
720
- zIndex: '1000'
783
+ zIndex: "" + (this._config.zIndex || 1000)
721
784
  });
722
785
  toggleNativeDragInteractions(preview, false);
723
786
  preview.classList.add('cdk-drag-preview');
@@ -815,8 +878,7 @@ var DragRef = /** @class */ (function () {
815
878
  };
816
879
  };
817
880
  /** Gets the pointer position on the page, accounting for any position constraints. */
818
- DragRef.prototype._getConstrainedPointerPosition = function (event) {
819
- var point = this._getPointerPositionOnPage(event);
881
+ DragRef.prototype._getConstrainedPointerPosition = function (point) {
820
882
  var constrainedPoint = this.constrainPosition ? this.constrainPosition(point, this) : point;
821
883
  var dropContainerLock = this._dropContainer ? this._dropContainer.lockAxis : null;
822
884
  if (this.lockAxis === 'x' || dropContainerLock === 'x') {
@@ -971,6 +1033,19 @@ var DragRef = /** @class */ (function () {
971
1033
  }
972
1034
  return value ? value.mouse : 0;
973
1035
  };
1036
+ /** Updates the internal state of the draggable element when scrolling has occurred. */
1037
+ DragRef.prototype._updateOnScroll = function () {
1038
+ var oldScrollPosition = this._scrollPosition;
1039
+ var currentScrollPosition = this._viewportRuler.getViewportScrollPosition();
1040
+ // ClientRect dimensions are based on the page's scroll position so
1041
+ // we have to update the cached boundary ClientRect if the user has scrolled.
1042
+ if (oldScrollPosition && this._boundaryRect) {
1043
+ var topDifference = oldScrollPosition.top - currentScrollPosition.top;
1044
+ var leftDifference = oldScrollPosition.left - currentScrollPosition.left;
1045
+ adjustClientRect(this._boundaryRect, topDifference, leftDifference);
1046
+ }
1047
+ this._scrollPosition = currentScrollPosition;
1048
+ };
974
1049
  return DragRef;
975
1050
  }());
976
1051
  /**
@@ -1042,13 +1117,13 @@ function getPreviewInsertionPoint(documentRef) {
1042
1117
  * If the root is not an HTML element it gets wrapped in one.
1043
1118
  */
1044
1119
  function getRootNode(viewRef, _document) {
1045
- var rootNode = viewRef.rootNodes[0];
1046
- if (rootNode.nodeType !== _document.ELEMENT_NODE) {
1047
- var wrapper = _document.createElement('div');
1048
- wrapper.appendChild(rootNode);
1049
- return wrapper;
1120
+ var rootNodes = viewRef.rootNodes;
1121
+ if (rootNodes.length === 1 && rootNodes[0].nodeType === _document.ELEMENT_NODE) {
1122
+ return rootNodes[0];
1050
1123
  }
1051
- return rootNode;
1124
+ var wrapper = _document.createElement('div');
1125
+ rootNodes.forEach(function (node) { return wrapper.appendChild(node); });
1126
+ return wrapper;
1052
1127
  }
1053
1128
  /**
1054
1129
  * Matches the target element's size to the source's size.
@@ -1442,7 +1517,8 @@ var DropListRef = /** @class */ (function () {
1442
1517
  */
1443
1518
  DropListRef.prototype._sortItem = function (item, pointerX, pointerY, pointerDelta) {
1444
1519
  // Don't sort the item if sorting is disabled or it's out of range.
1445
- if (this.sortingDisabled || !isPointerNearClientRect(this._clientRect, pointerX, pointerY)) {
1520
+ if (this.sortingDisabled ||
1521
+ !isPointerNearClientRect(this._clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
1446
1522
  return;
1447
1523
  }
1448
1524
  var siblings = this._itemPositions;
@@ -1522,7 +1598,7 @@ var DropListRef = /** @class */ (function () {
1522
1598
  if (element === _this._document || !position.clientRect || scrollNode) {
1523
1599
  return;
1524
1600
  }
1525
- if (isPointerNearClientRect(position.clientRect, pointerX, pointerY)) {
1601
+ if (isPointerNearClientRect(position.clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
1526
1602
  _a = __read(getElementScrollDirections(element, position.clientRect, pointerX, pointerY), 2), verticalScrollDirection = _a[0], horizontalScrollDirection = _a[1];
1527
1603
  if (verticalScrollDirection || horizontalScrollDirection) {
1528
1604
  scrollNode = element;
@@ -1836,31 +1912,6 @@ var DropListRef = /** @class */ (function () {
1836
1912
  };
1837
1913
  return DropListRef;
1838
1914
  }());
1839
- /**
1840
- * Updates the top/left positions of a `ClientRect`, as well as their bottom/right counterparts.
1841
- * @param clientRect `ClientRect` that should be updated.
1842
- * @param top Amount to add to the `top` position.
1843
- * @param left Amount to add to the `left` position.
1844
- */
1845
- function adjustClientRect(clientRect, top, left) {
1846
- clientRect.top += top;
1847
- clientRect.bottom = clientRect.top + clientRect.height;
1848
- clientRect.left += left;
1849
- clientRect.right = clientRect.left + clientRect.width;
1850
- }
1851
- /**
1852
- * Checks whether the pointer coordinates are close to a ClientRect.
1853
- * @param rect ClientRect to check against.
1854
- * @param pointerX Coordinates along the X axis.
1855
- * @param pointerY Coordinates along the Y axis.
1856
- */
1857
- function isPointerNearClientRect(rect, pointerX, pointerY) {
1858
- var top = rect.top, right = rect.right, bottom = rect.bottom, left = rect.left, width = rect.width, height = rect.height;
1859
- var xThreshold = width * DROP_PROXIMITY_THRESHOLD;
1860
- var yThreshold = height * DROP_PROXIMITY_THRESHOLD;
1861
- return pointerY > top - yThreshold && pointerY < bottom + yThreshold &&
1862
- pointerX > left - xThreshold && pointerX < right + xThreshold;
1863
- }
1864
1915
  /**
1865
1916
  * Finds the index of an item that matches a predicate function. Used as an equivalent
1866
1917
  * of `Array.prototype.findIndex` which isn't part of the standard Google typings.
@@ -1875,32 +1926,6 @@ function findIndex(array, predicate) {
1875
1926
  }
1876
1927
  return -1;
1877
1928
  }
1878
- /**
1879
- * Checks whether some coordinates are within a `ClientRect`.
1880
- * @param clientRect ClientRect that is being checked.
1881
- * @param x Coordinates along the X axis.
1882
- * @param y Coordinates along the Y axis.
1883
- */
1884
- function isInsideClientRect(clientRect, x, y) {
1885
- var top = clientRect.top, bottom = clientRect.bottom, left = clientRect.left, right = clientRect.right;
1886
- return y >= top && y <= bottom && x >= left && x <= right;
1887
- }
1888
- /** Gets a mutable version of an element's bounding `ClientRect`. */
1889
- function getMutableClientRect(element) {
1890
- var clientRect = element.getBoundingClientRect();
1891
- // We need to clone the `clientRect` here, because all the values on it are readonly
1892
- // and we need to be able to update them. Also we can't use a spread here, because
1893
- // the values on a `ClientRect` aren't own properties. See:
1894
- // https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
1895
- return {
1896
- top: clientRect.top,
1897
- right: clientRect.right,
1898
- bottom: clientRect.bottom,
1899
- left: clientRect.left,
1900
- width: clientRect.width,
1901
- height: clientRect.height
1902
- };
1903
- }
1904
1929
  /**
1905
1930
  * Increments the vertical scroll position of a node.
1906
1931
  * @param node Node whose scroll position should change.
@@ -2445,7 +2470,8 @@ var CdkDrag = /** @class */ (function () {
2445
2470
  dragStartThreshold: config && config.dragStartThreshold != null ?
2446
2471
  config.dragStartThreshold : 5,
2447
2472
  pointerDirectionChangeThreshold: config && config.pointerDirectionChangeThreshold != null ?
2448
- config.pointerDirectionChangeThreshold : 5
2473
+ config.pointerDirectionChangeThreshold : 5,
2474
+ zIndex: config === null || config === void 0 ? void 0 : config.zIndex
2449
2475
  });
2450
2476
  this._dragRef.data = this;
2451
2477
  if (config) {
@@ -2877,15 +2903,6 @@ var CdkDropList = /** @class */ (function () {
2877
2903
  enumerable: true,
2878
2904
  configurable: true
2879
2905
  });
2880
- CdkDropList.prototype.ngAfterContentInit = function () {
2881
- // @breaking-change 11.0.0 Remove null check for _scrollDispatcher once it's required.
2882
- if (this._scrollDispatcher) {
2883
- var scrollableParents = this._scrollDispatcher
2884
- .getAncestorScrollContainers(this.element)
2885
- .map(function (scrollable) { return scrollable.getElementRef().nativeElement; });
2886
- this._dropListRef.withScrollableParents(scrollableParents);
2887
- }
2888
- };
2889
2906
  /** Registers an items with the drop list. */
2890
2907
  CdkDropList.prototype.addItem = function (item) {
2891
2908
  this._unsortedItems.add(item);
@@ -2994,6 +3011,18 @@ var CdkDropList = /** @class */ (function () {
2994
3011
  }
2995
3012
  });
2996
3013
  }
3014
+ // Note that we resolve the scrollable parents here so that we delay the resolution
3015
+ // as long as possible, ensuring that the element is in its final place in the DOM.
3016
+ // @breaking-change 11.0.0 Remove null check for _scrollDispatcher once it's required.
3017
+ if (!_this._scrollableParentsResolved && _this._scrollDispatcher) {
3018
+ var scrollableParents = _this._scrollDispatcher
3019
+ .getAncestorScrollContainers(_this.element)
3020
+ .map(function (scrollable) { return scrollable.getElementRef().nativeElement; });
3021
+ _this._dropListRef.withScrollableParents(scrollableParents);
3022
+ // Only do this once since it involves traversing the DOM and the parents
3023
+ // shouldn't be able to change without the drop list being destroyed.
3024
+ _this._scrollableParentsResolved = true;
3025
+ }
2997
3026
  ref.disabled = _this.disabled;
2998
3027
  ref.lockAxis = _this.lockAxis;
2999
3028
  ref.sortingDisabled = coerceBooleanProperty(_this.sortingDisabled);