@angular/cdk 12.1.3 → 12.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 (69) hide show
  1. package/bundles/cdk-a11y.umd.js +10 -4
  2. package/bundles/cdk-a11y.umd.js.map +1 -1
  3. package/bundles/cdk-coercion.umd.js +10 -4
  4. package/bundles/cdk-coercion.umd.js.map +1 -1
  5. package/bundles/cdk-collections.umd.js +10 -4
  6. package/bundles/cdk-collections.umd.js.map +1 -1
  7. package/bundles/cdk-drag-drop.umd.js +69 -44
  8. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  9. package/bundles/cdk-overlay.umd.js +10 -4
  10. package/bundles/cdk-overlay.umd.js.map +1 -1
  11. package/bundles/cdk-portal.umd.js +10 -4
  12. package/bundles/cdk-portal.umd.js.map +1 -1
  13. package/bundles/cdk-scrolling.umd.js +29 -4
  14. package/bundles/cdk-scrolling.umd.js.map +1 -1
  15. package/bundles/cdk-table.umd.js +18 -4
  16. package/bundles/cdk-table.umd.js.map +1 -1
  17. package/bundles/cdk-testing-protractor.umd.js +12 -5
  18. package/bundles/cdk-testing-protractor.umd.js.map +1 -1
  19. package/bundles/cdk-testing-selenium-webdriver.umd.js +12 -5
  20. package/bundles/cdk-testing-selenium-webdriver.umd.js.map +1 -1
  21. package/bundles/cdk-testing-testbed.umd.js +11 -6
  22. package/bundles/cdk-testing-testbed.umd.js.map +1 -1
  23. package/bundles/cdk-testing.umd.js +10 -4
  24. package/bundles/cdk-testing.umd.js.map +1 -1
  25. package/bundles/cdk-text-field.umd.js +29 -8
  26. package/bundles/cdk-text-field.umd.js.map +1 -1
  27. package/bundles/cdk-tree.umd.js +10 -4
  28. package/bundles/cdk-tree.umd.js.map +1 -1
  29. package/bundles/cdk.umd.js +1 -1
  30. package/bundles/cdk.umd.js.map +1 -1
  31. package/drag-drop/directives/drag.d.ts +2 -0
  32. package/drag-drop/drag-events.d.ts +2 -2
  33. package/drag-drop/index.metadata.json +1 -1
  34. package/esm2015/drag-drop/directives/drag.js +50 -39
  35. package/esm2015/drag-drop/drag-events.js +1 -1
  36. package/esm2015/drag-drop/drag-ref.js +6 -2
  37. package/esm2015/drag-drop/drag-styling.js +4 -2
  38. package/esm2015/overlay/overlay-reference.js +1 -1
  39. package/esm2015/scrolling/fixed-size-virtual-scroll.js +1 -1
  40. package/esm2015/scrolling/virtual-scroll-viewport.js +17 -1
  41. package/esm2015/table/table.js +10 -2
  42. package/esm2015/testing/protractor/protractor-element.js +3 -2
  43. package/esm2015/testing/selenium-webdriver/selenium-web-driver-element.js +3 -2
  44. package/esm2015/text-field/autosize.js +29 -9
  45. package/esm2015/version.js +1 -1
  46. package/fesm2015/cdk.js +1 -1
  47. package/fesm2015/cdk.js.map +1 -1
  48. package/fesm2015/drag-drop.js +57 -40
  49. package/fesm2015/drag-drop.js.map +1 -1
  50. package/fesm2015/scrolling.js +16 -1
  51. package/fesm2015/scrolling.js.map +1 -1
  52. package/fesm2015/table.js +9 -1
  53. package/fesm2015/table.js.map +1 -1
  54. package/fesm2015/testing/protractor.js +2 -1
  55. package/fesm2015/testing/protractor.js.map +1 -1
  56. package/fesm2015/testing/selenium-webdriver.js +2 -1
  57. package/fesm2015/testing/selenium-webdriver.js.map +1 -1
  58. package/fesm2015/text-field.js +28 -8
  59. package/fesm2015/text-field.js.map +1 -1
  60. package/overlay/overlay-reference.d.ts +9 -1
  61. package/package.json +2 -5
  62. package/schematics/ng-add/index.js +1 -1
  63. package/schematics/ng-add/index.mjs +1 -1
  64. package/scrolling/index.metadata.json +1 -1
  65. package/scrolling/virtual-scroll-viewport.d.ts +9 -0
  66. package/table/index.metadata.json +1 -1
  67. package/table/table.d.ts +6 -1
  68. package/text-field/autosize.d.ts +3 -2
  69. package/text-field/index.metadata.json +1 -1
@@ -92,7 +92,9 @@
92
92
  * that exited before the base transform was applied.
93
93
  */
94
94
  function combineTransforms(transform, initialTransform) {
95
- return initialTransform ? (transform + ' ' + initialTransform) : transform;
95
+ return initialTransform && initialTransform != 'none' ?
96
+ (transform + ' ' + initialTransform) :
97
+ transform;
96
98
  }
97
99
 
98
100
  /**
@@ -1232,8 +1234,12 @@
1232
1234
  var transform = getTransform(x, y);
1233
1235
  // Cache the previous transform amount only after the first drag sequence, because
1234
1236
  // we don't want our own transforms to stack on top of each other.
1237
+ // Should be excluded none because none + translate3d(x, y, x) is invalid css
1235
1238
  if (this._initialTransform == null) {
1236
- this._initialTransform = this._rootElement.style.transform || '';
1239
+ this._initialTransform = this._rootElement.style.transform
1240
+ && this._rootElement.style.transform != 'none'
1241
+ ? this._rootElement.style.transform
1242
+ : '';
1237
1243
  }
1238
1244
  // Preserve the previous `transform` value, if there was one. Note that we apply our own
1239
1245
  // transform before the user's, because things like rotation can affect which direction
@@ -1674,10 +1680,16 @@
1674
1680
  r[k] = a[j];
1675
1681
  return r;
1676
1682
  }
1677
- function __spreadArray(to, from) {
1678
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
1679
- to[j] = from[i];
1680
- return to;
1683
+ function __spreadArray(to, from, pack) {
1684
+ if (pack || arguments.length === 2)
1685
+ for (var i = 0, l = from.length, ar; i < l; i++) {
1686
+ if (ar || !(i in from)) {
1687
+ if (!ar)
1688
+ ar = Array.prototype.slice.call(from, 0, i);
1689
+ ar[i] = from[i];
1690
+ }
1691
+ }
1692
+ return to.concat(ar || from);
1681
1693
  }
1682
1694
  function __await(v) {
1683
1695
  return this instanceof __await ? (this.v = v, this) : new __await(v);
@@ -3598,43 +3610,22 @@
3598
3610
  };
3599
3611
  CdkDrag.prototype.ngAfterViewInit = function () {
3600
3612
  var _this = this;
3601
- // We need to wait for the zone to stabilize, in order for the reference
3602
- // element to be in the proper place in the DOM. This is mostly relevant
3603
- // for draggable elements inside portals since they get stamped out in
3604
- // their original DOM position and then they get transferred to the portal.
3605
- this._ngZone.onStable
3606
- .pipe(operators.take(1), operators.takeUntil(this._destroyed))
3607
- .subscribe(function () {
3608
- _this._updateRootElement();
3609
- // Listen for any newly-added handles.
3610
- _this._handles.changes.pipe(operators.startWith(_this._handles),
3611
- // Sync the new handles with the DragRef.
3612
- operators.tap(function (handles) {
3613
- var childHandleElements = handles
3614
- .filter(function (handle) { return handle._parentDrag === _this; })
3615
- .map(function (handle) { return handle.element; });
3616
- // Usually handles are only allowed to be a descendant of the drag element, but if
3617
- // the consumer defined a different drag root, we should allow the drag element
3618
- // itself to be a handle too.
3619
- if (_this._selfHandle && _this.rootElementSelector) {
3620
- childHandleElements.push(_this.element);
3613
+ // Normally this isn't in the zone, but it can cause major performance regressions for apps
3614
+ // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
3615
+ this._ngZone.runOutsideAngular(function () {
3616
+ // We need to wait for the zone to stabilize, in order for the reference
3617
+ // element to be in the proper place in the DOM. This is mostly relevant
3618
+ // for draggable elements inside portals since they get stamped out in
3619
+ // their original DOM position and then they get transferred to the portal.
3620
+ _this._ngZone.onStable
3621
+ .pipe(operators.take(1), operators.takeUntil(_this._destroyed))
3622
+ .subscribe(function () {
3623
+ _this._updateRootElement();
3624
+ _this._setupHandlesListener();
3625
+ if (_this.freeDragPosition) {
3626
+ _this._dragRef.setFreeDragPosition(_this.freeDragPosition);
3621
3627
  }
3622
- _this._dragRef.withHandles(childHandleElements);
3623
- }),
3624
- // Listen if the state of any of the handles changes.
3625
- operators.switchMap(function (handles) {
3626
- return rxjs.merge.apply(void 0, __spreadArray([], __read(handles.map(function (item) {
3627
- return item._stateChanges.pipe(operators.startWith(item));
3628
- }))));
3629
- }), operators.takeUntil(_this._destroyed)).subscribe(function (handleInstance) {
3630
- // Enabled/disable the handle that changed in the DragRef.
3631
- var dragRef = _this._dragRef;
3632
- var handle = handleInstance.element.nativeElement;
3633
- handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
3634
3628
  });
3635
- if (_this.freeDragPosition) {
3636
- _this._dragRef.setFreeDragPosition(_this.freeDragPosition);
3637
- }
3638
3629
  });
3639
3630
  };
3640
3631
  CdkDrag.prototype.ngOnChanges = function (changes) {
@@ -3651,6 +3642,7 @@
3651
3642
  }
3652
3643
  };
3653
3644
  CdkDrag.prototype.ngOnDestroy = function () {
3645
+ var _this = this;
3654
3646
  if (this.dropContainer) {
3655
3647
  this.dropContainer.removeItem(this);
3656
3648
  }
@@ -3658,9 +3650,12 @@
3658
3650
  if (index > -1) {
3659
3651
  CdkDrag._dragInstances.splice(index, 1);
3660
3652
  }
3661
- this._destroyed.next();
3662
- this._destroyed.complete();
3663
- this._dragRef.dispose();
3653
+ // Unnecessary in most cases, but used to avoid extra change detections with `zone-paths-rxjs`.
3654
+ this._ngZone.runOutsideAngular(function () {
3655
+ _this._destroyed.next();
3656
+ _this._destroyed.complete();
3657
+ _this._dragRef.dispose();
3658
+ });
3664
3659
  };
3665
3660
  /** Syncs the root element with the `DragRef`. */
3666
3661
  CdkDrag.prototype._updateRootElement = function () {
@@ -3817,6 +3812,36 @@
3817
3812
  this.previewContainer = previewContainer;
3818
3813
  }
3819
3814
  };
3815
+ /** Sets up the listener that syncs the handles with the drag ref. */
3816
+ CdkDrag.prototype._setupHandlesListener = function () {
3817
+ var _this = this;
3818
+ // Listen for any newly-added handles.
3819
+ this._handles.changes.pipe(operators.startWith(this._handles),
3820
+ // Sync the new handles with the DragRef.
3821
+ operators.tap(function (handles) {
3822
+ var childHandleElements = handles
3823
+ .filter(function (handle) { return handle._parentDrag === _this; })
3824
+ .map(function (handle) { return handle.element; });
3825
+ // Usually handles are only allowed to be a descendant of the drag element, but if
3826
+ // the consumer defined a different drag root, we should allow the drag element
3827
+ // itself to be a handle too.
3828
+ if (_this._selfHandle && _this.rootElementSelector) {
3829
+ childHandleElements.push(_this.element);
3830
+ }
3831
+ _this._dragRef.withHandles(childHandleElements);
3832
+ }),
3833
+ // Listen if the state of any of the handles changes.
3834
+ operators.switchMap(function (handles) {
3835
+ return rxjs.merge.apply(void 0, __spreadArray([], __read(handles.map(function (item) {
3836
+ return item._stateChanges.pipe(operators.startWith(item));
3837
+ }))));
3838
+ }), operators.takeUntil(this._destroyed)).subscribe(function (handleInstance) {
3839
+ // Enabled/disable the handle that changed in the DragRef.
3840
+ var dragRef = _this._dragRef;
3841
+ var handle = handleInstance.element.nativeElement;
3842
+ handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
3843
+ });
3844
+ };
3820
3845
  return CdkDrag;
3821
3846
  }());
3822
3847
  CdkDrag._dragInstances = [];