@angular/cdk 12.1.4 → 12.2.2

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 (61) 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 +61 -42
  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 +10 -4
  18. package/bundles/cdk-testing-protractor.umd.js.map +1 -1
  19. package/bundles/cdk-testing-selenium-webdriver.umd.js +10 -4
  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/overlay/overlay-reference.js +1 -1
  37. package/esm2015/scrolling/fixed-size-virtual-scroll.js +1 -1
  38. package/esm2015/scrolling/virtual-scroll-viewport.js +17 -1
  39. package/esm2015/table/table.js +10 -2
  40. package/esm2015/text-field/autosize.js +29 -9
  41. package/esm2015/version.js +1 -1
  42. package/fesm2015/cdk.js +1 -1
  43. package/fesm2015/cdk.js.map +1 -1
  44. package/fesm2015/drag-drop.js +49 -38
  45. package/fesm2015/drag-drop.js.map +1 -1
  46. package/fesm2015/scrolling.js +16 -1
  47. package/fesm2015/scrolling.js.map +1 -1
  48. package/fesm2015/table.js +9 -1
  49. package/fesm2015/table.js.map +1 -1
  50. package/fesm2015/text-field.js +28 -8
  51. package/fesm2015/text-field.js.map +1 -1
  52. package/overlay/overlay-reference.d.ts +9 -1
  53. package/package.json +2 -5
  54. package/schematics/ng-add/index.js +1 -1
  55. package/schematics/ng-add/index.mjs +1 -1
  56. package/scrolling/index.metadata.json +1 -1
  57. package/scrolling/virtual-scroll-viewport.d.ts +9 -0
  58. package/table/index.metadata.json +1 -1
  59. package/table/table.d.ts +6 -1
  60. package/text-field/autosize.d.ts +3 -2
  61. package/text-field/index.metadata.json +1 -1
@@ -1680,10 +1680,16 @@
1680
1680
  r[k] = a[j];
1681
1681
  return r;
1682
1682
  }
1683
- function __spreadArray(to, from) {
1684
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
1685
- to[j] = from[i];
1686
- 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);
1687
1693
  }
1688
1694
  function __await(v) {
1689
1695
  return this instanceof __await ? (this.v = v, this) : new __await(v);
@@ -3604,43 +3610,22 @@
3604
3610
  };
3605
3611
  CdkDrag.prototype.ngAfterViewInit = function () {
3606
3612
  var _this = this;
3607
- // We need to wait for the zone to stabilize, in order for the reference
3608
- // element to be in the proper place in the DOM. This is mostly relevant
3609
- // for draggable elements inside portals since they get stamped out in
3610
- // their original DOM position and then they get transferred to the portal.
3611
- this._ngZone.onStable
3612
- .pipe(operators.take(1), operators.takeUntil(this._destroyed))
3613
- .subscribe(function () {
3614
- _this._updateRootElement();
3615
- // Listen for any newly-added handles.
3616
- _this._handles.changes.pipe(operators.startWith(_this._handles),
3617
- // Sync the new handles with the DragRef.
3618
- operators.tap(function (handles) {
3619
- var childHandleElements = handles
3620
- .filter(function (handle) { return handle._parentDrag === _this; })
3621
- .map(function (handle) { return handle.element; });
3622
- // Usually handles are only allowed to be a descendant of the drag element, but if
3623
- // the consumer defined a different drag root, we should allow the drag element
3624
- // itself to be a handle too.
3625
- if (_this._selfHandle && _this.rootElementSelector) {
3626
- 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);
3627
3627
  }
3628
- _this._dragRef.withHandles(childHandleElements);
3629
- }),
3630
- // Listen if the state of any of the handles changes.
3631
- operators.switchMap(function (handles) {
3632
- return rxjs.merge.apply(void 0, __spreadArray([], __read(handles.map(function (item) {
3633
- return item._stateChanges.pipe(operators.startWith(item));
3634
- }))));
3635
- }), operators.takeUntil(_this._destroyed)).subscribe(function (handleInstance) {
3636
- // Enabled/disable the handle that changed in the DragRef.
3637
- var dragRef = _this._dragRef;
3638
- var handle = handleInstance.element.nativeElement;
3639
- handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
3640
3628
  });
3641
- if (_this.freeDragPosition) {
3642
- _this._dragRef.setFreeDragPosition(_this.freeDragPosition);
3643
- }
3644
3629
  });
3645
3630
  };
3646
3631
  CdkDrag.prototype.ngOnChanges = function (changes) {
@@ -3657,6 +3642,7 @@
3657
3642
  }
3658
3643
  };
3659
3644
  CdkDrag.prototype.ngOnDestroy = function () {
3645
+ var _this = this;
3660
3646
  if (this.dropContainer) {
3661
3647
  this.dropContainer.removeItem(this);
3662
3648
  }
@@ -3664,9 +3650,12 @@
3664
3650
  if (index > -1) {
3665
3651
  CdkDrag._dragInstances.splice(index, 1);
3666
3652
  }
3667
- this._destroyed.next();
3668
- this._destroyed.complete();
3669
- 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
+ });
3670
3659
  };
3671
3660
  /** Syncs the root element with the `DragRef`. */
3672
3661
  CdkDrag.prototype._updateRootElement = function () {
@@ -3823,6 +3812,36 @@
3823
3812
  this.previewContainer = previewContainer;
3824
3813
  }
3825
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
+ };
3826
3845
  return CdkDrag;
3827
3846
  }());
3828
3847
  CdkDrag._dragInstances = [];