@angular/cdk 12.1.0-next.0 → 12.1.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 (132) hide show
  1. package/a11y/focus-monitor/focus-monitor.d.ts +25 -31
  2. package/a11y/index.metadata.json +1 -1
  3. package/a11y/input-modality/input-modality-detector.d.ts +105 -0
  4. package/a11y/public-api.d.ts +1 -0
  5. package/bundles/cdk-a11y.umd.js +282 -146
  6. package/bundles/cdk-a11y.umd.js.map +1 -1
  7. package/bundles/cdk-drag-drop.umd.js +64 -20
  8. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  9. package/bundles/cdk-overlay.umd.js +7 -3
  10. package/bundles/cdk-overlay.umd.js.map +1 -1
  11. package/bundles/cdk-portal.umd.js.map +1 -1
  12. package/bundles/cdk-scrolling.umd.js.map +1 -1
  13. package/bundles/cdk-stepper.umd.js +11 -7
  14. package/bundles/cdk-stepper.umd.js.map +1 -1
  15. package/bundles/cdk-table.umd.js.map +1 -1
  16. package/bundles/cdk-tree.umd.js +3 -5
  17. package/bundles/cdk-tree.umd.js.map +1 -1
  18. package/bundles/cdk.umd.js +1 -1
  19. package/bundles/cdk.umd.js.map +1 -1
  20. package/drag-drop/drag-drop-registry.d.ts +14 -2
  21. package/drag-drop/index.metadata.json +1 -1
  22. package/drag-drop/parent-position-tracker.d.ts +2 -0
  23. package/esm2015/a11y/focus-monitor/focus-monitor.js +81 -121
  24. package/esm2015/a11y/focus-trap/configurable-focus-trap.js +1 -1
  25. package/esm2015/a11y/input-modality/input-modality-detector.js +179 -0
  26. package/esm2015/a11y/key-manager/activedescendant-key-manager.js +1 -1
  27. package/esm2015/a11y/key-manager/focus-key-manager.js +1 -1
  28. package/esm2015/a11y/public-api.js +2 -1
  29. package/esm2015/drag-drop/drag-drop-registry.js +37 -3
  30. package/esm2015/drag-drop/drag-ref.js +22 -12
  31. package/esm2015/drag-drop/drop-list-ref.js +4 -2
  32. package/esm2015/drag-drop/parent-position-tracker.js +6 -2
  33. package/esm2015/overlay/dispatchers/overlay-keyboard-dispatcher.js +1 -1
  34. package/esm2015/overlay/dispatchers/overlay-outside-click-dispatcher.js +1 -1
  35. package/esm2015/overlay/fullscreen-overlay-container.js +1 -1
  36. package/esm2015/overlay/overlay-container.js +8 -4
  37. package/esm2015/portal/dom-portal-outlet.js +1 -1
  38. package/esm2015/portal/portal-directives.js +1 -1
  39. package/esm2015/portal/portal.js +1 -1
  40. package/esm2015/scrolling/virtual-scroll-viewport.js +1 -1
  41. package/esm2015/stepper/stepper.js +9 -4
  42. package/esm2015/table/row.js +1 -1
  43. package/esm2015/tree/control/flat-tree-control.js +1 -1
  44. package/esm2015/tree/control/nested-tree-control.js +1 -1
  45. package/esm2015/tree/nested-node.js +4 -6
  46. package/esm2015/version.js +1 -1
  47. package/fesm2015/a11y.js +276 -149
  48. package/fesm2015/a11y.js.map +1 -1
  49. package/fesm2015/cdk.js +1 -1
  50. package/fesm2015/cdk.js.map +1 -1
  51. package/fesm2015/drag-drop.js +63 -13
  52. package/fesm2015/drag-drop.js.map +1 -1
  53. package/fesm2015/overlay.js +7 -3
  54. package/fesm2015/overlay.js.map +1 -1
  55. package/fesm2015/portal.js.map +1 -1
  56. package/fesm2015/scrolling.js.map +1 -1
  57. package/fesm2015/stepper.js +8 -3
  58. package/fesm2015/stepper.js.map +1 -1
  59. package/fesm2015/table.js.map +1 -1
  60. package/fesm2015/tree.js +3 -5
  61. package/fesm2015/tree.js.map +1 -1
  62. package/overlay/index.metadata.json +1 -1
  63. package/package.json +1 -1
  64. package/schematics/migration.json +5 -0
  65. package/schematics/ng-add/index.js +1 -1
  66. package/schematics/ng-add/index.mjs +1 -1
  67. package/schematics/ng-add/package-config.js +5 -2
  68. package/schematics/ng-add/package-config.mjs +5 -2
  69. package/schematics/ng-update/devkit-file-system.d.ts +2 -2
  70. package/schematics/ng-update/devkit-file-system.js +20 -21
  71. package/schematics/ng-update/devkit-file-system.mjs +20 -21
  72. package/schematics/ng-update/find-stylesheets.js +2 -2
  73. package/schematics/ng-update/find-stylesheets.mjs +2 -2
  74. package/schematics/ng-update/html-parsing/elements.d.ts +2 -1
  75. package/schematics/ng-update/html-parsing/elements.js +5 -4
  76. package/schematics/ng-update/html-parsing/elements.mjs +5 -4
  77. package/schematics/ng-update/index.d.ts +2 -0
  78. package/schematics/ng-update/index.js +7 -2
  79. package/schematics/ng-update/index.mjs +7 -2
  80. package/schematics/ng-update/migrations/attribute-selectors.d.ts +3 -2
  81. package/schematics/ng-update/migrations/attribute-selectors.js +1 -1
  82. package/schematics/ng-update/migrations/attribute-selectors.mjs +1 -1
  83. package/schematics/ng-update/migrations/class-inheritance.js +1 -1
  84. package/schematics/ng-update/migrations/class-inheritance.mjs +1 -1
  85. package/schematics/ng-update/migrations/class-names.js +1 -1
  86. package/schematics/ng-update/migrations/class-names.mjs +1 -1
  87. package/schematics/ng-update/migrations/constructor-signature.js +1 -1
  88. package/schematics/ng-update/migrations/constructor-signature.mjs +1 -1
  89. package/schematics/ng-update/migrations/css-selectors.js +1 -1
  90. package/schematics/ng-update/migrations/css-selectors.mjs +1 -1
  91. package/schematics/ng-update/migrations/element-selectors.d.ts +3 -2
  92. package/schematics/ng-update/migrations/element-selectors.js +1 -1
  93. package/schematics/ng-update/migrations/element-selectors.mjs +1 -1
  94. package/schematics/ng-update/migrations/input-names.js +1 -1
  95. package/schematics/ng-update/migrations/input-names.mjs +1 -1
  96. package/schematics/ng-update/migrations/method-call-arguments.js +1 -1
  97. package/schematics/ng-update/migrations/method-call-arguments.mjs +1 -1
  98. package/schematics/ng-update/migrations/misc-template.js +1 -1
  99. package/schematics/ng-update/migrations/misc-template.mjs +1 -1
  100. package/schematics/ng-update/migrations/output-names.js +1 -1
  101. package/schematics/ng-update/migrations/output-names.mjs +1 -1
  102. package/schematics/ng-update/migrations/property-names.js +1 -1
  103. package/schematics/ng-update/migrations/property-names.mjs +1 -1
  104. package/schematics/tsconfig.json +5 -0
  105. package/schematics/update-tool/component-resource-collector.js +2 -2
  106. package/schematics/update-tool/component-resource-collector.mjs +2 -2
  107. package/schematics/update-tool/file-system.d.ts +4 -2
  108. package/schematics/update-tool/file-system.js +1 -1
  109. package/schematics/update-tool/file-system.mjs +1 -1
  110. package/schematics/update-tool/target-version.d.ts +2 -1
  111. package/schematics/update-tool/target-version.js +2 -1
  112. package/schematics/update-tool/target-version.mjs +2 -1
  113. package/schematics/update-tool/utils/virtual-host.js +3 -3
  114. package/schematics/update-tool/utils/virtual-host.mjs +3 -3
  115. package/schematics/utils/build-component.js +7 -3
  116. package/schematics/utils/build-component.mjs +7 -3
  117. package/schematics/utils/html-manipulation.d.ts +2 -2
  118. package/schematics/utils/html-manipulation.js +1 -1
  119. package/schematics/utils/html-manipulation.mjs +1 -1
  120. package/schematics/utils/parse5-element.d.ts +2 -2
  121. package/schematics/utils/parse5-element.js +2 -2
  122. package/schematics/utils/parse5-element.mjs +2 -2
  123. package/schematics/utils/schematic-options.d.ts +2 -6
  124. package/schematics/utils/schematic-options.js +3 -2
  125. package/schematics/utils/schematic-options.mjs +3 -2
  126. package/schematics/utils/vendored-ast-utils/index.js +8 -7
  127. package/schematics/utils/vendored-ast-utils/index.mjs +8 -7
  128. package/scrolling/index.metadata.json +1 -1
  129. package/stepper/index.metadata.json +1 -1
  130. package/stepper/stepper.d.ts +6 -2
  131. package/tree/index.metadata.json +1 -1
  132. package/tree/nested-node.d.ts +1 -3
@@ -216,7 +216,7 @@
216
216
  };
217
217
  /** Handles scrolling while a drag is taking place. */
218
218
  ParentPositionTracker.prototype.handleScroll = function (event) {
219
- var target = event.target;
219
+ var target = getEventTarget(event);
220
220
  var cachedPosition = this.positions.get(target);
221
221
  if (!cachedPosition) {
222
222
  return null;
@@ -252,6 +252,10 @@
252
252
  };
253
253
  return ParentPositionTracker;
254
254
  }());
255
+ /** Gets the target of an event while accounting for shadow dom. */
256
+ function getEventTarget(event) {
257
+ return (event.composedPath ? event.composedPath()[0] : event.target);
258
+ }
255
259
 
256
260
  /**
257
261
  * @license
@@ -356,6 +360,11 @@
356
360
  this._passiveTransform = { x: 0, y: 0 };
357
361
  /** CSS `transform` that is applied to the element while it's being dragged. */
358
362
  this._activeTransform = { x: 0, y: 0 };
363
+ /**
364
+ * Whether the dragging sequence has been started. Doesn't
365
+ * necessarily mean that the element has been moved.
366
+ */
367
+ this._hasStartedDragging = false;
359
368
  /** Emits when the item is being moved. */
360
369
  this._moveEvents = new rxjs.Subject();
361
370
  /** Subscription to pointer movement events. */
@@ -407,7 +416,7 @@
407
416
  // Delegate the event based on whether it started from a handle or the element itself.
408
417
  if (_this._handles.length) {
409
418
  var targetHandle = _this._handles.find(function (handle) {
410
- var target = event.target;
419
+ var target = getEventTarget(event);
411
420
  return !!target && (target === handle || handle.contains(target));
412
421
  });
413
422
  if (targetHandle && !_this._disabledHandles.has(targetHandle) && !_this.disabled) {
@@ -855,6 +864,7 @@
855
864
  var isTouchSequence = isTouchEvent(event);
856
865
  var isAuxiliaryMouseButton = !isTouchSequence && event.button !== 0;
857
866
  var rootElement = this._rootElement;
867
+ var target = getEventTarget(event);
858
868
  var isSyntheticEvent = !isTouchSequence && this._lastTouchEventTime &&
859
869
  this._lastTouchEventTime + MOUSE_EVENT_IGNORE_TIME > Date.now();
860
870
  // If the event started from an element with the native HTML drag&drop, it'll interfere
@@ -863,7 +873,7 @@
863
873
  // it's flaky and it fails if the user drags it away quickly. Also note that we only want
864
874
  // to do this for `mousedown` since doing the same for `touchstart` will stop any `click`
865
875
  // events from firing on touch devices.
866
- if (event.target && event.target.draggable && event.type === 'mousedown') {
876
+ if (target && target.draggable && event.type === 'mousedown') {
867
877
  event.preventDefault();
868
878
  }
869
879
  // Abort if the user is already dragging or is using a mouse button other than the primary one.
@@ -883,9 +893,9 @@
883
893
  this._removeSubscriptions();
884
894
  this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
885
895
  this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
886
- this._scrollSubscription = this._dragDropRegistry.scroll.subscribe(function (scrollEvent) {
887
- _this._updateOnScroll(scrollEvent);
888
- });
896
+ this._scrollSubscription = this._dragDropRegistry
897
+ .scrolled(this._getShadowRoot())
898
+ .subscribe(function (scrollEvent) { return _this._updateOnScroll(scrollEvent); });
889
899
  if (this._boundaryElement) {
890
900
  this._boundaryRect = getMutableClientRect(this._boundaryElement);
891
901
  }
@@ -973,9 +983,12 @@
973
983
  });
974
984
  });
975
985
  }
976
- this._dropContainer._startScrollingIfNecessary(rawX, rawY);
977
- this._dropContainer._sortItem(this, x, y, this._pointerDirectionDelta);
978
- this._applyPreviewTransform(x - this._pickupPositionInElement.x, y - this._pickupPositionInElement.y);
986
+ // Dragging may have been interrupted as a result of the events above.
987
+ if (this.isDragging()) {
988
+ this._dropContainer._startScrollingIfNecessary(rawX, rawY);
989
+ this._dropContainer._sortItem(this, x, y, this._pointerDirectionDelta);
990
+ this._applyPreviewTransform(x - this._pickupPositionInElement.x, y - this._pickupPositionInElement.y);
991
+ }
979
992
  };
980
993
  /**
981
994
  * Creates the element that will be rendered next to the user's pointer
@@ -1060,7 +1073,8 @@
1060
1073
  return this._ngZone.runOutsideAngular(function () {
1061
1074
  return new Promise(function (resolve) {
1062
1075
  var handler = (function (event) {
1063
- if (!event || (event.target === _this._preview && event.propertyName === 'transform')) {
1076
+ if (!event || (getEventTarget(event) === _this._preview &&
1077
+ event.propertyName === 'transform')) {
1064
1078
  _this._preview.removeEventListener('transitionend', handler);
1065
1079
  resolve();
1066
1080
  clearTimeout(timeout);
@@ -1308,7 +1322,7 @@
1308
1322
  DragRef.prototype._updateOnScroll = function (event) {
1309
1323
  var scrollDifference = this._parentPositions.handleScroll(event);
1310
1324
  if (scrollDifference) {
1311
- var target = event.target;
1325
+ var target = getEventTarget(event);
1312
1326
  // ClientRect dimensions are based on the scroll position of the page and its parent node so
1313
1327
  // we have to update the cached boundary ClientRect if the user has scrolled. Check for
1314
1328
  // the `document` specifically since IE doesn't support `contains` on it.
@@ -2479,7 +2493,9 @@
2479
2493
  */
2480
2494
  DropListRef.prototype._listenToScrollEvents = function () {
2481
2495
  var _this = this;
2482
- this._viewportScrollSubscription = this._dragDropRegistry.scroll.subscribe(function (event) {
2496
+ this._viewportScrollSubscription = this._dragDropRegistry
2497
+ .scrolled(this._getShadowRoot())
2498
+ .subscribe(function (event) {
2483
2499
  if (_this.isDragging()) {
2484
2500
  var scrollDifference_1 = _this._parentPositions.handleScroll(event);
2485
2501
  if (scrollDifference_1) {
@@ -2645,13 +2661,6 @@
2645
2661
  return [verticalScrollDirection, horizontalScrollDirection];
2646
2662
  }
2647
2663
 
2648
- /**
2649
- * @license
2650
- * Copyright Google LLC All Rights Reserved.
2651
- *
2652
- * Use of this source code is governed by an MIT-style license that can be
2653
- * found in the LICENSE file at https://angular.io/license
2654
- */
2655
2664
  /** Event options that can be used to bind an active, capturing event. */
2656
2665
  var activeCapturingEventOptions = platform.normalizePassiveListenerOptions({
2657
2666
  passive: false,
@@ -2692,7 +2701,11 @@
2692
2701
  * while the user is dragging a drag item instance.
2693
2702
  */
2694
2703
  this.pointerUp = new rxjs.Subject();
2695
- /** Emits when the viewport has been scrolled while the user is dragging an item. */
2704
+ /**
2705
+ * Emits when the viewport has been scrolled while the user is dragging an item.
2706
+ * @deprecated To be turned into a private member. Use the `scrolled` method instead.
2707
+ * @breaking-change 13.0.0
2708
+ */
2696
2709
  this.scroll = new rxjs.Subject();
2697
2710
  /**
2698
2711
  * Event listener that will prevent the default browser action while the user is dragging.
@@ -2815,6 +2828,37 @@
2815
2828
  DragDropRegistry.prototype.isDragging = function (drag) {
2816
2829
  return this._activeDragInstances.indexOf(drag) > -1;
2817
2830
  };
2831
+ /**
2832
+ * Gets a stream that will emit when any element on the page is scrolled while an item is being
2833
+ * dragged.
2834
+ * @param shadowRoot Optional shadow root that the current dragging sequence started from.
2835
+ * Top-level listeners won't pick up events coming from the shadow DOM so this parameter can
2836
+ * be used to include an additional top-level listener at the shadow root level.
2837
+ */
2838
+ DragDropRegistry.prototype.scrolled = function (shadowRoot) {
2839
+ var _this = this;
2840
+ var streams = [this.scroll];
2841
+ if (shadowRoot && shadowRoot !== this._document) {
2842
+ // Note that this is basically the same as `fromEvent` from rjxs, but we do it ourselves,
2843
+ // because we want to guarantee that the event is bound outside of the `NgZone`. With
2844
+ // `fromEvent` it'll only happen if the subscription is outside the `NgZone`.
2845
+ streams.push(new rxjs.Observable(function (observer) {
2846
+ return _this._ngZone.runOutsideAngular(function () {
2847
+ var eventOptions = true;
2848
+ var callback = function (event) {
2849
+ if (_this._activeDragInstances.length) {
2850
+ observer.next(event);
2851
+ }
2852
+ };
2853
+ shadowRoot.addEventListener('scroll', callback, eventOptions);
2854
+ return function () {
2855
+ shadowRoot.removeEventListener('scroll', callback, eventOptions);
2856
+ };
2857
+ });
2858
+ }));
2859
+ }
2860
+ return rxjs.merge.apply(void 0, __spreadArray([], __read(streams)));
2861
+ };
2818
2862
  DragDropRegistry.prototype.ngOnDestroy = function () {
2819
2863
  var _this = this;
2820
2864
  this._dragInstances.forEach(function (instance) { return _this.removeDragItem(instance); });