@angular/cdk 11.0.4 → 11.1.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 (122) hide show
  1. package/a11y/aria-describer/aria-describer.d.ts +9 -14
  2. package/a11y/index.metadata.json +1 -1
  3. package/bundles/cdk-a11y.umd.js +62 -57
  4. package/bundles/cdk-a11y.umd.js.map +1 -1
  5. package/bundles/cdk-a11y.umd.min.js +13 -14
  6. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  7. package/bundles/cdk-accordion.umd.js.map +1 -1
  8. package/bundles/cdk-bidi.umd.js.map +1 -1
  9. package/bundles/cdk-coercion.umd.js +9 -1
  10. package/bundles/cdk-coercion.umd.js.map +1 -1
  11. package/bundles/cdk-coercion.umd.min.js.map +1 -1
  12. package/bundles/cdk-collections.umd.js +11 -6
  13. package/bundles/cdk-collections.umd.js.map +1 -1
  14. package/bundles/cdk-collections.umd.min.js +1 -1
  15. package/bundles/cdk-collections.umd.min.js.map +1 -1
  16. package/bundles/cdk-drag-drop.umd.js +61 -16
  17. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  18. package/bundles/cdk-drag-drop.umd.min.js +8 -8
  19. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  20. package/bundles/cdk-overlay.umd.js +34 -4
  21. package/bundles/cdk-overlay.umd.js.map +1 -1
  22. package/bundles/cdk-overlay.umd.min.js +11 -11
  23. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  24. package/bundles/cdk-portal.umd.js +9 -1
  25. package/bundles/cdk-portal.umd.js.map +1 -1
  26. package/bundles/cdk-portal.umd.min.js +2 -2
  27. package/bundles/cdk-portal.umd.min.js.map +1 -1
  28. package/bundles/cdk-scrolling.umd.js +16 -8
  29. package/bundles/cdk-scrolling.umd.js.map +1 -1
  30. package/bundles/cdk-scrolling.umd.min.js +3 -3
  31. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  32. package/bundles/cdk-table.umd.js +99 -30
  33. package/bundles/cdk-table.umd.js.map +1 -1
  34. package/bundles/cdk-table.umd.min.js +7 -7
  35. package/bundles/cdk-table.umd.min.js.map +1 -1
  36. package/bundles/cdk-testing-protractor.umd.js +59 -13
  37. package/bundles/cdk-testing-protractor.umd.js.map +1 -1
  38. package/bundles/cdk-testing-protractor.umd.min.js +2 -2
  39. package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
  40. package/bundles/cdk-testing-testbed.umd.js +40 -15
  41. package/bundles/cdk-testing-testbed.umd.js.map +1 -1
  42. package/bundles/cdk-testing-testbed.umd.min.js +7 -7
  43. package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
  44. package/bundles/cdk-testing.umd.js +11 -10
  45. package/bundles/cdk-testing.umd.js.map +1 -1
  46. package/bundles/cdk-testing.umd.min.js +2 -2
  47. package/bundles/cdk-testing.umd.min.js.map +1 -1
  48. package/bundles/cdk-tree.umd.js +9 -1
  49. package/bundles/cdk-tree.umd.js.map +1 -1
  50. package/bundles/cdk-tree.umd.min.js +5 -5
  51. package/bundles/cdk-tree.umd.min.js.map +1 -1
  52. package/bundles/cdk.umd.js +1 -1
  53. package/bundles/cdk.umd.js.map +1 -1
  54. package/bundles/cdk.umd.min.js +1 -1
  55. package/bundles/cdk.umd.min.js.map +1 -1
  56. package/collections/index.metadata.json +1 -1
  57. package/collections/recycle-view-repeater-strategy.d.ts +0 -2
  58. package/drag-drop/directives/drag.d.ts +3 -1
  59. package/drag-drop/directives/drop-list.d.ts +4 -1
  60. package/drag-drop/drag-ref.d.ts +4 -0
  61. package/drag-drop/drop-list-ref.d.ts +2 -0
  62. package/drag-drop/index.metadata.json +1 -1
  63. package/esm2015/a11y/aria-describer/aria-describer.js +50 -55
  64. package/esm2015/collections/recycle-view-repeater-strategy.js +4 -7
  65. package/esm2015/drag-drop/directives/drag.js +36 -4
  66. package/esm2015/drag-drop/directives/drop-list.js +4 -2
  67. package/esm2015/drag-drop/drag-ref.js +9 -4
  68. package/esm2015/drag-drop/drop-list-ref.js +8 -10
  69. package/esm2015/overlay/overlay-ref.js +2 -2
  70. package/esm2015/overlay/position/flexible-connected-position-strategy.js +25 -3
  71. package/esm2015/scrolling/scroll-dispatcher.js +9 -8
  72. package/esm2015/scrolling/virtual-for-of.js +1 -1
  73. package/esm2015/scrolling/virtual-scroll-viewport.js +1 -1
  74. package/esm2015/table/public-api.js +2 -1
  75. package/esm2015/table/sticky-position-listener.js +11 -0
  76. package/esm2015/table/sticky-styler.js +60 -14
  77. package/esm2015/table/table.js +9 -4
  78. package/esm2015/testing/change-detection.js +1 -8
  79. package/esm2015/testing/harness-environment.js +3 -3
  80. package/esm2015/testing/protractor/protractor-element.js +29 -13
  81. package/esm2015/testing/test-element.js +1 -1
  82. package/esm2015/testing/testbed/fake-events/dispatch-events.js +3 -3
  83. package/esm2015/testing/testbed/fake-events/event-objects.js +6 -6
  84. package/esm2015/testing/testbed/unit-test-element.js +21 -9
  85. package/esm2015/version.js +1 -1
  86. package/fesm2015/a11y.js +50 -53
  87. package/fesm2015/a11y.js.map +1 -1
  88. package/fesm2015/accordion.js.map +1 -1
  89. package/fesm2015/bidi.js.map +1 -1
  90. package/fesm2015/cdk.js +1 -1
  91. package/fesm2015/cdk.js.map +1 -1
  92. package/fesm2015/collections.js +3 -6
  93. package/fesm2015/collections.js.map +1 -1
  94. package/fesm2015/drag-drop.js +52 -15
  95. package/fesm2015/drag-drop.js.map +1 -1
  96. package/fesm2015/overlay.js +25 -3
  97. package/fesm2015/overlay.js.map +1 -1
  98. package/fesm2015/scrolling.js +8 -8
  99. package/fesm2015/scrolling.js.map +1 -1
  100. package/fesm2015/table.js +77 -17
  101. package/fesm2015/table.js.map +1 -1
  102. package/fesm2015/testing/protractor.js +27 -11
  103. package/fesm2015/testing/protractor.js.map +1 -1
  104. package/fesm2015/testing/testbed.js +25 -13
  105. package/fesm2015/testing/testbed.js.map +1 -1
  106. package/fesm2015/testing.js +2 -9
  107. package/fesm2015/testing.js.map +1 -1
  108. package/package.json +1 -1
  109. package/schematics/ng-add/index.js +1 -1
  110. package/scrolling/index.metadata.json +1 -1
  111. package/scrolling/scroll-dispatcher.d.ts +3 -3
  112. package/table/index.metadata.json +1 -1
  113. package/table/public-api.d.ts +1 -0
  114. package/table/sticky-position-listener.d.ts +29 -0
  115. package/table/sticky-styler.d.ts +7 -2
  116. package/table/table.d.ts +4 -2
  117. package/testing/change-detection.d.ts +44 -1
  118. package/testing/protractor/protractor-element.d.ts +12 -4
  119. package/testing/test-element.d.ts +11 -5
  120. package/testing/testbed/fake-events/dispatch-events.d.ts +1 -1
  121. package/testing/testbed/fake-events/event-objects.d.ts +1 -1
  122. package/testing/testbed/unit-test-element.d.ts +12 -4
@@ -466,7 +466,7 @@
466
466
  this._pointerUp = function (event) {
467
467
  _this._endDragSequence(event);
468
468
  };
469
- this.withRootElement(element);
469
+ this.withRootElement(element).withParent(_config.parentDragRef || null);
470
470
  this._parentPositions = new ParentPositionTracker(_document, _viewportRuler);
471
471
  _dragDropRegistry.registerDragItem(this);
472
472
  }
@@ -577,6 +577,11 @@
577
577
  }
578
578
  return this;
579
579
  };
580
+ /** Sets the parent ref that the ref is nested in. */
581
+ DragRef.prototype.withParent = function (parent) {
582
+ this._parentDragRef = parent;
583
+ return this;
584
+ };
580
585
  /** Removes the dragging functionality from the DOM element. */
581
586
  DragRef.prototype.dispose = function () {
582
587
  this._removeRootElementListeners(this._rootElement);
@@ -606,7 +611,7 @@
606
611
  this._resizeSubscription.unsubscribe();
607
612
  this._parentPositions.clear();
608
613
  this._boundaryElement = this._rootElement = this._ownerSVGElement = this._placeholderTemplate =
609
- this._previewTemplate = this._anchor = null;
614
+ this._previewTemplate = this._anchor = this._parentDragRef = null;
610
615
  };
611
616
  /** Checks whether the element is currently being dragged. */
612
617
  DragRef.prototype.isDragging = function () {
@@ -794,7 +799,7 @@
794
799
  var _this = this;
795
800
  // Stop propagation if the item is inside another
796
801
  // draggable so we don't start multiple drag sequences.
797
- if (this._config.parentDragRef) {
802
+ if (this._parentDragRef) {
798
803
  event.stopPropagation();
799
804
  }
800
805
  var isDragging = this.isDragging();
@@ -1368,6 +1373,8 @@
1368
1373
  return extendStatics(d, b);
1369
1374
  };
1370
1375
  function __extends(d, b) {
1376
+ if (typeof b !== "function" && b !== null)
1377
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1371
1378
  extendStatics(d, b);
1372
1379
  function __() { this.constructor = d; }
1373
1380
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -1553,11 +1560,13 @@
1553
1560
  }
1554
1561
  return ar;
1555
1562
  }
1563
+ /** @deprecated */
1556
1564
  function __spread() {
1557
1565
  for (var ar = [], i = 0; i < arguments.length; i++)
1558
1566
  ar = ar.concat(__read(arguments[i]));
1559
1567
  return ar;
1560
1568
  }
1569
+ /** @deprecated */
1561
1570
  function __spreadArrays() {
1562
1571
  for (var s = 0, i = 0, il = arguments.length; i < il; i++)
1563
1572
  s += arguments[i].length;
@@ -1566,7 +1575,11 @@
1566
1575
  r[k] = a[j];
1567
1576
  return r;
1568
1577
  }
1569
- ;
1578
+ function __spreadArray(to, from) {
1579
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
1580
+ to[j] = from[i];
1581
+ return to;
1582
+ }
1570
1583
  function __await(v) {
1571
1584
  return this instanceof __await ? (this.v = v, this) : new __await(v);
1572
1585
  }
@@ -1715,11 +1728,6 @@
1715
1728
  * viewport. The value comes from trying it out manually until it feels right.
1716
1729
  */
1717
1730
  var SCROLL_PROXIMITY_THRESHOLD = 0.05;
1718
- /**
1719
- * Number of pixels to scroll for each frame when auto-scrolling an element.
1720
- * The value comes from trying it out manually until it feels right.
1721
- */
1722
- var AUTO_SCROLL_STEP = 2;
1723
1731
  /**
1724
1732
  * Reference to a drop list. Used to manipulate or dispose of the container.
1725
1733
  */
@@ -1738,6 +1746,8 @@
1738
1746
  * moves their pointer close to the edges is disabled.
1739
1747
  */
1740
1748
  this.autoScrollDisabled = false;
1749
+ /** Number of pixels to scroll for each frame when auto-scrolling an element. */
1750
+ this.autoScrollStep = 2;
1741
1751
  /**
1742
1752
  * Function that is used to determine whether an item
1743
1753
  * is allowed to be moved into a drop container.
@@ -1797,17 +1807,18 @@
1797
1807
  .pipe(operators.takeUntil(_this._stopScrollTimers))
1798
1808
  .subscribe(function () {
1799
1809
  var node = _this._scrollNode;
1810
+ var scrollStep = _this.autoScrollStep;
1800
1811
  if (_this._verticalScrollDirection === 1 /* UP */) {
1801
- incrementVerticalScroll(node, -AUTO_SCROLL_STEP);
1812
+ incrementVerticalScroll(node, -scrollStep);
1802
1813
  }
1803
1814
  else if (_this._verticalScrollDirection === 2 /* DOWN */) {
1804
- incrementVerticalScroll(node, AUTO_SCROLL_STEP);
1815
+ incrementVerticalScroll(node, scrollStep);
1805
1816
  }
1806
1817
  if (_this._horizontalScrollDirection === 1 /* LEFT */) {
1807
- incrementHorizontalScroll(node, -AUTO_SCROLL_STEP);
1818
+ incrementHorizontalScroll(node, -scrollStep);
1808
1819
  }
1809
1820
  else if (_this._horizontalScrollDirection === 2 /* RIGHT */) {
1810
- incrementHorizontalScroll(node, AUTO_SCROLL_STEP);
1821
+ incrementHorizontalScroll(node, scrollStep);
1811
1822
  }
1812
1823
  });
1813
1824
  };
@@ -3078,6 +3089,7 @@
3078
3089
  ref.lockAxis = _this.lockAxis;
3079
3090
  ref.sortingDisabled = coercion.coerceBooleanProperty(_this.sortingDisabled);
3080
3091
  ref.autoScrollDisabled = coercion.coerceBooleanProperty(_this.autoScrollDisabled);
3092
+ ref.autoScrollStep = coercion.coerceNumberProperty(_this.autoScrollStep, 2);
3081
3093
  ref
3082
3094
  .connectedTo(siblings.filter(function (drop) { return drop && drop !== _this; }).map(function (list) { return list._dropListRef; }))
3083
3095
  .withOrientation(_this.orientation);
@@ -3184,6 +3196,7 @@
3184
3196
  enterPredicate: [{ type: i0.Input, args: ['cdkDropListEnterPredicate',] }],
3185
3197
  sortPredicate: [{ type: i0.Input, args: ['cdkDropListSortPredicate',] }],
3186
3198
  autoScrollDisabled: [{ type: i0.Input, args: ['cdkDropListAutoScrollDisabled',] }],
3199
+ autoScrollStep: [{ type: i0.Input, args: ['cdkDropListAutoScrollStep',] }],
3187
3200
  dropped: [{ type: i0.Output, args: ['cdkDropListDropped',] }],
3188
3201
  entered: [{ type: i0.Output, args: ['cdkDropListEntered',] }],
3189
3202
  exited: [{ type: i0.Output, args: ['cdkDropListExited',] }],
@@ -3328,6 +3341,7 @@
3328
3341
  matchSize: [{ type: i0.Input }]
3329
3342
  };
3330
3343
 
3344
+ var DRAG_HOST_CLASS = 'cdk-drag';
3331
3345
  /** Element that can be moved inside a CdkDropList container. */
3332
3346
  var CdkDrag = /** @class */ (function () {
3333
3347
  function CdkDrag(
@@ -3339,7 +3353,7 @@
3339
3353
  * @deprecated `_document` parameter no longer being used and will be removed.
3340
3354
  * @breaking-change 12.0.0
3341
3355
  */
3342
- _document, _ngZone, _viewContainerRef, config, _dir, dragDrop, _changeDetectorRef, _selfHandle, parentDrag) {
3356
+ _document, _ngZone, _viewContainerRef, config, _dir, dragDrop, _changeDetectorRef, _selfHandle, _parentDrag) {
3343
3357
  var _this = this;
3344
3358
  this.element = element;
3345
3359
  this.dropContainer = dropContainer;
@@ -3348,6 +3362,7 @@
3348
3362
  this._dir = _dir;
3349
3363
  this._changeDetectorRef = _changeDetectorRef;
3350
3364
  this._selfHandle = _selfHandle;
3365
+ this._parentDrag = _parentDrag;
3351
3366
  this._destroyed = new rxjs.Subject();
3352
3367
  /** Emits when the user starts dragging the item. */
3353
3368
  this.started = new i0.EventEmitter();
@@ -3383,9 +3398,12 @@
3383
3398
  pointerDirectionChangeThreshold: config && config.pointerDirectionChangeThreshold != null ?
3384
3399
  config.pointerDirectionChangeThreshold : 5,
3385
3400
  zIndex: config === null || config === void 0 ? void 0 : config.zIndex,
3386
- parentDragRef: parentDrag === null || parentDrag === void 0 ? void 0 : parentDrag._dragRef
3387
3401
  });
3388
3402
  this._dragRef.data = this;
3403
+ // We have to keep track of the drag instances in order to be able to match an element to
3404
+ // a drag instance. We can't go through the global registry of `DragRef`, because the root
3405
+ // element could be different.
3406
+ CdkDrag._dragInstances.push(this);
3389
3407
  if (config) {
3390
3408
  this._assignDefaults(config);
3391
3409
  }
@@ -3494,6 +3512,10 @@
3494
3512
  if (this.dropContainer) {
3495
3513
  this.dropContainer.removeItem(this);
3496
3514
  }
3515
+ var index = CdkDrag._dragInstances.indexOf(this);
3516
+ if (index > -1) {
3517
+ CdkDrag._dragInstances.splice(index, -1);
3518
+ }
3497
3519
  this._destroyed.next();
3498
3520
  this._destroyed.complete();
3499
3521
  this._dragRef.dispose();
@@ -3557,6 +3579,28 @@
3557
3579
  }
3558
3580
  }
3559
3581
  });
3582
+ // This only needs to be resolved once.
3583
+ ref.beforeStarted.pipe(operators.take(1)).subscribe(function () {
3584
+ var _a, _b;
3585
+ // If we managed to resolve a parent through DI, use it.
3586
+ if (_this._parentDrag) {
3587
+ ref.withParent(_this._parentDrag._dragRef);
3588
+ return;
3589
+ }
3590
+ // Otherwise fall back to resolving the parent by looking up the DOM. This can happen if
3591
+ // the item was projected into another item by something like `ngTemplateOutlet`.
3592
+ var parent = _this.element.nativeElement.parentElement;
3593
+ while (parent) {
3594
+ // `classList` needs to be null checked, because IE doesn't have it on some elements.
3595
+ if ((_a = parent.classList) === null || _a === void 0 ? void 0 : _a.contains(DRAG_HOST_CLASS)) {
3596
+ ref.withParent(((_b = CdkDrag._dragInstances.find(function (drag) {
3597
+ return drag.element.nativeElement === parent;
3598
+ })) === null || _b === void 0 ? void 0 : _b._dragRef) || null);
3599
+ break;
3600
+ }
3601
+ parent = parent.parentElement;
3602
+ }
3603
+ });
3560
3604
  };
3561
3605
  /** Handles the events from the underlying `DragRef`. */
3562
3606
  CdkDrag.prototype._handleEvents = function (ref) {
@@ -3624,12 +3668,13 @@
3624
3668
  };
3625
3669
  return CdkDrag;
3626
3670
  }());
3671
+ CdkDrag._dragInstances = [];
3627
3672
  CdkDrag.decorators = [
3628
3673
  { type: i0.Directive, args: [{
3629
3674
  selector: '[cdkDrag]',
3630
3675
  exportAs: 'cdkDrag',
3631
3676
  host: {
3632
- 'class': 'cdk-drag',
3677
+ 'class': DRAG_HOST_CLASS,
3633
3678
  '[class.cdk-drag-disabled]': 'disabled',
3634
3679
  '[class.cdk-drag-dragging]': '_dragRef.isDragging()',
3635
3680
  },