@angular/cdk 13.2.2 → 13.2.5

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 (71) hide show
  1. package/a11y/a11y-module.d.ts +2 -3
  2. package/drag-drop/drag-ref.d.ts +3 -1
  3. package/drag-drop/parent-position-tracker.d.ts +11 -3
  4. package/esm2020/a11y/a11y-module.mjs +4 -5
  5. package/esm2020/drag-drop/drag-ref.mjs +27 -17
  6. package/esm2020/drag-drop/drop-list-ref.mjs +2 -2
  7. package/esm2020/drag-drop/parent-position-tracker.mjs +13 -5
  8. package/esm2020/overlay/dispatchers/overlay-keyboard-dispatcher.mjs +24 -6
  9. package/esm2020/overlay/dispatchers/overlay-outside-click-dispatcher.mjs +31 -10
  10. package/esm2020/scrolling/scrolling-module.mjs +4 -5
  11. package/esm2020/testing/protractor/protractor-element.mjs +8 -3
  12. package/esm2020/testing/public-api.mjs +2 -1
  13. package/esm2020/testing/selenium-webdriver/selenium-web-driver-element.mjs +8 -3
  14. package/esm2020/testing/test-element-errors.mjs +15 -0
  15. package/esm2020/testing/test-element.mjs +1 -1
  16. package/esm2020/testing/testbed/fake-events/type-in-element.mjs +12 -3
  17. package/esm2020/testing/testbed/unit-test-element.mjs +19 -5
  18. package/esm2020/text-field/text-field-module.mjs +3 -5
  19. package/esm2020/version.mjs +1 -1
  20. package/fesm2015/a11y.mjs +4 -4
  21. package/fesm2015/a11y.mjs.map +1 -1
  22. package/fesm2015/cdk.mjs +1 -1
  23. package/fesm2015/cdk.mjs.map +1 -1
  24. package/fesm2015/drag-drop.mjs +40 -21
  25. package/fesm2015/drag-drop.mjs.map +1 -1
  26. package/fesm2015/overlay.mjs +52 -13
  27. package/fesm2015/overlay.mjs.map +1 -1
  28. package/fesm2015/scrolling.mjs +4 -4
  29. package/fesm2015/scrolling.mjs.map +1 -1
  30. package/fesm2015/testing/protractor.mjs +7 -2
  31. package/fesm2015/testing/protractor.mjs.map +1 -1
  32. package/fesm2015/testing/selenium-webdriver.mjs +7 -2
  33. package/fesm2015/testing/selenium-webdriver.mjs.map +1 -1
  34. package/fesm2015/testing/testbed.mjs +29 -7
  35. package/fesm2015/testing/testbed.mjs.map +1 -1
  36. package/fesm2015/testing.mjs +16 -1
  37. package/fesm2015/testing.mjs.map +1 -1
  38. package/fesm2015/text-field.mjs +3 -4
  39. package/fesm2015/text-field.mjs.map +1 -1
  40. package/fesm2020/a11y.mjs +4 -4
  41. package/fesm2020/a11y.mjs.map +1 -1
  42. package/fesm2020/cdk.mjs +1 -1
  43. package/fesm2020/cdk.mjs.map +1 -1
  44. package/fesm2020/drag-drop.mjs +39 -21
  45. package/fesm2020/drag-drop.mjs.map +1 -1
  46. package/fesm2020/overlay.mjs +52 -13
  47. package/fesm2020/overlay.mjs.map +1 -1
  48. package/fesm2020/scrolling.mjs +4 -4
  49. package/fesm2020/scrolling.mjs.map +1 -1
  50. package/fesm2020/testing/protractor.mjs +7 -2
  51. package/fesm2020/testing/protractor.mjs.map +1 -1
  52. package/fesm2020/testing/selenium-webdriver.mjs +7 -2
  53. package/fesm2020/testing/selenium-webdriver.mjs.map +1 -1
  54. package/fesm2020/testing/testbed.mjs +29 -7
  55. package/fesm2020/testing/testbed.mjs.map +1 -1
  56. package/fesm2020/testing.mjs +16 -1
  57. package/fesm2020/testing.mjs.map +1 -1
  58. package/fesm2020/text-field.mjs +3 -4
  59. package/fesm2020/text-field.mjs.map +1 -1
  60. package/overlay/dispatchers/overlay-keyboard-dispatcher.d.ts +7 -2
  61. package/overlay/dispatchers/overlay-outside-click-dispatcher.d.ts +8 -2
  62. package/package.json +1 -1
  63. package/schematics/ng-add/index.js +1 -1
  64. package/schematics/ng-add/index.mjs +1 -1
  65. package/scrolling/scrolling-module.d.ts +1 -2
  66. package/testing/public-api.d.ts +1 -0
  67. package/testing/test-element-errors.d.ts +12 -0
  68. package/testing/test-element.d.ts +4 -2
  69. package/testing/testbed/fake-events/type-in-element.d.ts +2 -2
  70. package/testing/testbed/unit-test-element.d.ts +4 -1
  71. package/text-field/text-field-module.d.ts +1 -2
package/fesm2020/cdk.mjs 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
- const VERSION = new Version('13.2.2');
11
+ const VERSION = new Version('13.2.5');
12
12
 
13
13
  /**
14
14
  * @license
@@ -1 +1 @@
1
- {"version":3,"file":"cdk.mjs","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('13.2.2');\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;;;;;;;AAUA;MACa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB;;ACXtD;;;;;;;;ACAA;;;;;;;;;;"}
1
+ {"version":3,"file":"cdk.mjs","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('13.2.5');\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;;;;;;;AAUA;MACa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB;;ACXtD;;;;;;;;ACAA;;;;;;;;;;"}
@@ -188,9 +188,8 @@ function isPointerNearClientRect(rect, threshold, pointerX, pointerY) {
188
188
  */
189
189
  /** Keeps track of the scroll position and dimensions of the parents of an element. */
190
190
  class ParentPositionTracker {
191
- constructor(_document, _viewportRuler) {
191
+ constructor(_document) {
192
192
  this._document = _document;
193
- this._viewportRuler = _viewportRuler;
194
193
  /** Cached positions of the scrollable parent elements. */
195
194
  this.positions = new Map();
196
195
  }
@@ -202,7 +201,7 @@ class ParentPositionTracker {
202
201
  cache(elements) {
203
202
  this.clear();
204
203
  this.positions.set(this._document, {
205
- scrollPosition: this._viewportRuler.getViewportScrollPosition(),
204
+ scrollPosition: this.getViewportScrollPosition(),
206
205
  });
207
206
  elements.forEach(element => {
208
207
  this.positions.set(element, {
@@ -222,7 +221,7 @@ class ParentPositionTracker {
222
221
  let newTop;
223
222
  let newLeft;
224
223
  if (target === this._document) {
225
- const viewportScrollPosition = this._viewportRuler.getViewportScrollPosition();
224
+ const viewportScrollPosition = this.getViewportScrollPosition();
226
225
  newTop = viewportScrollPosition.top;
227
226
  newLeft = viewportScrollPosition.left;
228
227
  }
@@ -243,6 +242,15 @@ class ParentPositionTracker {
243
242
  scrollPosition.left = newLeft;
244
243
  return { top: topDifference, left: leftDifference };
245
244
  }
245
+ /**
246
+ * Gets the scroll position of the viewport. Note that we use the scrollX and scrollY directly,
247
+ * instead of going through the `ViewportRuler`, because the first value the ruler looks at is
248
+ * the top/left offset of the `document.documentElement` which works for most cases, but breaks
249
+ * if the element is offset by something like the `BlockScrollStrategy`.
250
+ */
251
+ getViewportScrollPosition() {
252
+ return { top: window.scrollY, left: window.scrollX };
253
+ }
246
254
  }
247
255
 
248
256
  /**
@@ -449,14 +457,6 @@ class DragRef {
449
457
  }
450
458
  return;
451
459
  }
452
- // We only need the preview dimensions if we have a boundary element.
453
- if (this._boundaryElement) {
454
- // Cache the preview element rect if we haven't cached it already or if
455
- // we cached it too early before the element dimensions were computed.
456
- if (!this._previewRect || (!this._previewRect.width && !this._previewRect.height)) {
457
- this._previewRect = (this._preview || this._rootElement).getBoundingClientRect();
458
- }
459
- }
460
460
  // We prevent the default action down here so that we know that dragging has started. This is
461
461
  // important for touch devices where doing this too early can unnecessarily block scrolling,
462
462
  // if there's a dragging delay.
@@ -496,7 +496,7 @@ class DragRef {
496
496
  this._endDragSequence(event);
497
497
  };
498
498
  this.withRootElement(element).withParent(_config.parentDragRef || null);
499
- this._parentPositions = new ParentPositionTracker(_document, _viewportRuler);
499
+ this._parentPositions = new ParentPositionTracker(_document);
500
500
  _dragDropRegistry.registerDragItem(this);
501
501
  }
502
502
  /** Whether starting to drag this element is disabled. */
@@ -577,6 +577,9 @@ class DragRef {
577
577
  this._ngZone.runOutsideAngular(() => {
578
578
  element.addEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
579
579
  element.addEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
580
+ // Usually this isn't necessary since the we prevent the default action in `pointerDown`,
581
+ // but some cases like dragging of links can slip through (see #24403).
582
+ element.addEventListener('dragstart', preventDefault, activeEventListenerOptions);
580
583
  });
581
584
  this._initialTransform = undefined;
582
585
  this._rootElement = element;
@@ -1081,6 +1084,9 @@ class DragRef {
1081
1084
  else {
1082
1085
  placeholder = deepCloneNode(this._rootElement);
1083
1086
  }
1087
+ // Stop pointer events on the preview so the user can't
1088
+ // interact with it while the preview is animating.
1089
+ placeholder.style.pointerEvents = 'none';
1084
1090
  placeholder.classList.add('cdk-drag-placeholder');
1085
1091
  return placeholder;
1086
1092
  }
@@ -1143,11 +1149,11 @@ class DragRef {
1143
1149
  if (this._boundaryRect) {
1144
1150
  const { x: pickupX, y: pickupY } = this._pickupPositionInElement;
1145
1151
  const boundaryRect = this._boundaryRect;
1146
- const previewRect = this._previewRect;
1152
+ const { width: previewWidth, height: previewHeight } = this._getPreviewRect();
1147
1153
  const minY = boundaryRect.top + pickupY;
1148
- const maxY = boundaryRect.bottom - (previewRect.height - pickupY);
1154
+ const maxY = boundaryRect.bottom - (previewHeight - pickupY);
1149
1155
  const minX = boundaryRect.left + pickupX;
1150
- const maxX = boundaryRect.right - (previewRect.width - pickupX);
1156
+ const maxX = boundaryRect.right - (previewWidth - pickupX);
1151
1157
  x = clamp$1(x, minX, maxX);
1152
1158
  y = clamp$1(y, minY, maxY);
1153
1159
  }
@@ -1190,6 +1196,7 @@ class DragRef {
1190
1196
  _removeRootElementListeners(element) {
1191
1197
  element.removeEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
1192
1198
  element.removeEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
1199
+ element.removeEventListener('dragstart', preventDefault, activeEventListenerOptions);
1193
1200
  }
1194
1201
  /**
1195
1202
  * Applies a `transform` to the root element, taking into account any existing transforms on it.
@@ -1326,10 +1333,8 @@ class DragRef {
1326
1333
  }
1327
1334
  /** Gets the scroll position of the viewport. */
1328
1335
  _getViewportScrollPosition() {
1329
- const cachedPosition = this._parentPositions.positions.get(this._document);
1330
- return cachedPosition
1331
- ? cachedPosition.scrollPosition
1332
- : this._viewportRuler.getViewportScrollPosition();
1336
+ return (this._parentPositions.positions.get(this._document)?.scrollPosition ||
1337
+ this._parentPositions.getViewportScrollPosition());
1333
1338
  }
1334
1339
  /**
1335
1340
  * Lazily resolves and returns the shadow root of the element. We do this in a function, rather
@@ -1363,6 +1368,15 @@ class DragRef {
1363
1368
  }
1364
1369
  return coerceElement(previewContainer);
1365
1370
  }
1371
+ /** Lazily resolves and returns the dimensions of the preview. */
1372
+ _getPreviewRect() {
1373
+ // Cache the preview element rect if we haven't cached it already or if
1374
+ // we cached it too early before the element dimensions were computed.
1375
+ if (!this._previewRect || (!this._previewRect.width && !this._previewRect.height)) {
1376
+ this._previewRect = (this._preview || this._rootElement).getBoundingClientRect();
1377
+ }
1378
+ return this._previewRect;
1379
+ }
1366
1380
  }
1367
1381
  /**
1368
1382
  * Gets a 3d `transform` that can be applied to an element.
@@ -1408,6 +1422,10 @@ function matchElementSize(target, sourceRect) {
1408
1422
  target.style.height = `${sourceRect.height}px`;
1409
1423
  target.style.transform = getTransform(sourceRect.left, sourceRect.top);
1410
1424
  }
1425
+ /** Utility to prevent the default action of an event. */
1426
+ function preventDefault(event) {
1427
+ event.preventDefault();
1428
+ }
1411
1429
 
1412
1430
  /**
1413
1431
  * @license
@@ -1583,7 +1601,7 @@ class DropListRef {
1583
1601
  this._document = _document;
1584
1602
  this.withScrollableParents([this.element]);
1585
1603
  _dragDropRegistry.registerDropContainer(this);
1586
- this._parentPositions = new ParentPositionTracker(_document, _viewportRuler);
1604
+ this._parentPositions = new ParentPositionTracker(_document);
1587
1605
  }
1588
1606
  /** Removes the drop list functionality from the DOM element. */
1589
1607
  dispose() {