@angular/cdk 10.1.2 → 10.1.3

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 (115) hide show
  1. package/bundles/cdk-a11y.umd.js +425 -373
  2. package/bundles/cdk-a11y.umd.js.map +1 -1
  3. package/bundles/cdk-a11y.umd.min.js +34 -10
  4. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  5. package/bundles/cdk-accordion.umd.js +40 -40
  6. package/bundles/cdk-accordion.umd.js.map +1 -1
  7. package/bundles/cdk-accordion.umd.min.js +10 -2
  8. package/bundles/cdk-accordion.umd.min.js.map +1 -1
  9. package/bundles/cdk-bidi.umd.js +25 -25
  10. package/bundles/cdk-bidi.umd.js.map +1 -1
  11. package/bundles/cdk-bidi.umd.min.js +5 -4
  12. package/bundles/cdk-bidi.umd.min.js.map +1 -1
  13. package/bundles/cdk-clipboard.umd.js +31 -31
  14. package/bundles/cdk-clipboard.umd.js.map +1 -1
  15. package/bundles/cdk-clipboard.umd.min.js +10 -2
  16. package/bundles/cdk-clipboard.umd.min.js.map +1 -1
  17. package/bundles/cdk-coercion.umd.js.map +1 -1
  18. package/bundles/cdk-collections.umd.js +303 -237
  19. package/bundles/cdk-collections.umd.js.map +1 -1
  20. package/bundles/cdk-collections.umd.min.js +3 -9
  21. package/bundles/cdk-collections.umd.min.js.map +1 -1
  22. package/bundles/cdk-drag-drop.umd.js +484 -425
  23. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  24. package/bundles/cdk-drag-drop.umd.min.js +68 -5
  25. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  26. package/bundles/cdk-keycodes.umd.js.map +1 -1
  27. package/bundles/cdk-layout.umd.js +18 -18
  28. package/bundles/cdk-layout.umd.js.map +1 -1
  29. package/bundles/cdk-layout.umd.min.js +6 -5
  30. package/bundles/cdk-layout.umd.min.js.map +1 -1
  31. package/bundles/cdk-observers.umd.js +34 -34
  32. package/bundles/cdk-observers.umd.js.map +1 -1
  33. package/bundles/cdk-observers.umd.min.js +2 -2
  34. package/bundles/cdk-observers.umd.min.js.map +1 -1
  35. package/bundles/cdk-overlay.umd.js +442 -383
  36. package/bundles/cdk-overlay.umd.js.map +1 -1
  37. package/bundles/cdk-overlay.umd.min.js +57 -11
  38. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  39. package/bundles/cdk-platform.umd.js +10 -10
  40. package/bundles/cdk-platform.umd.js.map +1 -1
  41. package/bundles/cdk-platform.umd.min.js +3 -10
  42. package/bundles/cdk-platform.umd.min.js.map +1 -1
  43. package/bundles/cdk-portal.umd.js +351 -299
  44. package/bundles/cdk-portal.umd.js.map +1 -1
  45. package/bundles/cdk-portal.umd.min.js +4 -5
  46. package/bundles/cdk-portal.umd.min.js.map +1 -1
  47. package/bundles/cdk-scrolling.umd.js +432 -378
  48. package/bundles/cdk-scrolling.umd.js.map +1 -1
  49. package/bundles/cdk-scrolling.umd.min.js +20 -19
  50. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  51. package/bundles/cdk-stepper.umd.js +117 -117
  52. package/bundles/cdk-stepper.umd.js.map +1 -1
  53. package/bundles/cdk-stepper.umd.min.js +11 -2
  54. package/bundles/cdk-stepper.umd.min.js.map +1 -1
  55. package/bundles/cdk-table.umd.js +684 -588
  56. package/bundles/cdk-table.umd.js.map +1 -1
  57. package/bundles/cdk-table.umd.min.js +7 -14
  58. package/bundles/cdk-table.umd.min.js.map +1 -1
  59. package/bundles/cdk-testing-protractor.umd.js +300 -241
  60. package/bundles/cdk-testing-protractor.umd.js.map +1 -1
  61. package/bundles/cdk-testing-protractor.umd.min.js +2 -9
  62. package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
  63. package/bundles/cdk-testing-testbed.umd.js +301 -256
  64. package/bundles/cdk-testing-testbed.umd.js.map +1 -1
  65. package/bundles/cdk-testing-testbed.umd.min.js +7 -30
  66. package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
  67. package/bundles/cdk-testing.umd.js +326 -270
  68. package/bundles/cdk-testing.umd.js.map +1 -1
  69. package/bundles/cdk-testing.umd.min.js +1 -16
  70. package/bundles/cdk-testing.umd.min.js.map +1 -1
  71. package/bundles/cdk-text-field.umd.js +51 -51
  72. package/bundles/cdk-text-field.umd.js.map +1 -1
  73. package/bundles/cdk-text-field.umd.min.js +10 -2
  74. package/bundles/cdk-text-field.umd.min.js.map +1 -1
  75. package/bundles/cdk-tree.umd.js +443 -394
  76. package/bundles/cdk-tree.umd.js.map +1 -1
  77. package/bundles/cdk-tree.umd.min.js +28 -3
  78. package/bundles/cdk-tree.umd.min.js.map +1 -1
  79. package/bundles/cdk.umd.js +1 -1
  80. package/bundles/cdk.umd.js.map +1 -1
  81. package/bundles/cdk.umd.min.js +1 -1
  82. package/bundles/cdk.umd.min.js.map +1 -1
  83. package/esm2015/a11y/focus-trap/configurable-focus-trap-factory.js +3 -3
  84. package/esm2015/a11y/focus-trap/focus-trap.js +1 -1
  85. package/esm2015/a11y/live-announcer/live-announcer.js +1 -1
  86. package/esm2015/bidi/directionality.js +1 -1
  87. package/esm2015/overlay/position/flexible-connected-position-strategy.js +3 -3
  88. package/esm2015/scrolling/scrolling-module.js +4 -1
  89. package/esm2015/table/cell.js +18 -3
  90. package/esm2015/table/coalesced-style-scheduler.js +21 -10
  91. package/esm2015/table/sticky-styler.js +21 -7
  92. package/esm2015/table/table.js +8 -2
  93. package/esm2015/tree/tree.js +9 -23
  94. package/esm2015/version.js +1 -1
  95. package/fesm2015/cdk.js +1 -1
  96. package/fesm2015/cdk.js.map +1 -1
  97. package/fesm2015/overlay.js +2 -2
  98. package/fesm2015/overlay.js.map +1 -1
  99. package/fesm2015/scrolling.js +3 -0
  100. package/fesm2015/scrolling.js.map +1 -1
  101. package/fesm2015/table.js +65 -19
  102. package/fesm2015/table.js.map +1 -1
  103. package/fesm2015/tree.js +7 -21
  104. package/fesm2015/tree.js.map +1 -1
  105. package/package.json +1 -1
  106. package/schematics/ng-add/index.js +1 -1
  107. package/scrolling/index.metadata.json +1 -1
  108. package/scrolling/scrolling-module.d.ts +3 -0
  109. package/table/cell.d.ts +13 -0
  110. package/table/coalesced-style-scheduler.d.ts +1 -0
  111. package/table/index.metadata.json +1 -1
  112. package/table/sticky-styler.d.ts +5 -1
  113. package/table/table.d.ts +6 -0
  114. package/tree/index.metadata.json +1 -1
  115. package/tree/tree.d.ts +2 -4
package/fesm2015/table.js CHANGED
@@ -5,8 +5,8 @@ export { DataSource } from '@angular/cdk/collections';
5
5
  import { Platform } from '@angular/cdk/platform';
6
6
  import { DOCUMENT } from '@angular/common';
7
7
  import { InjectionToken, Directive, TemplateRef, Inject, Optional, Input, ContentChild, ElementRef, Injectable, NgZone, IterableDiffers, ViewContainerRef, Component, ChangeDetectionStrategy, ViewEncapsulation, EmbeddedViewRef, isDevMode, ChangeDetectorRef, Attribute, ViewChild, ContentChildren, NgModule } from '@angular/core';
8
- import { Subject, BehaviorSubject, isObservable, of } from 'rxjs';
9
- import { take, takeUntil } from 'rxjs/operators';
8
+ import { Subject, from, BehaviorSubject, isObservable, of } from 'rxjs';
9
+ import { takeUntil, take } from 'rxjs/operators';
10
10
 
11
11
  /**
12
12
  * @license
@@ -141,6 +141,7 @@ class CdkColumnDef extends _CdkColumnDefBase {
141
141
  if (name) {
142
142
  this._name = name;
143
143
  this.cssClassFriendlyName = name.replace(/[^a-z0-9_-]/ig, '-');
144
+ this._updateColumnCssClassName();
144
145
  }
145
146
  }
146
147
  /**
@@ -156,6 +157,16 @@ class CdkColumnDef extends _CdkColumnDefBase {
156
157
  this._stickyEnd = coerceBooleanProperty(v);
157
158
  this._hasStickyChanged = prevValue !== this._stickyEnd;
158
159
  }
160
+ /**
161
+ * Overridable method that sets the css classes that will be added to every cell in this
162
+ * column.
163
+ * In the future, columnCssClassName will change from type string[] to string and this
164
+ * will set a single string value.
165
+ * @docs-private
166
+ */
167
+ _updateColumnCssClassName() {
168
+ this._columnCssClassName = [`cdk-column-${this.cssClassFriendlyName}`];
169
+ }
159
170
  }
160
171
  CdkColumnDef.decorators = [
161
172
  { type: Directive, args: [{
@@ -177,8 +188,12 @@ CdkColumnDef.propDecorators = {
177
188
  /** Base class for the cells. Adds a CSS classname that identifies the column it renders in. */
178
189
  class BaseCdkCell {
179
190
  constructor(columnDef, elementRef) {
180
- const columnClassName = `cdk-column-${columnDef.cssClassFriendlyName}`;
181
- elementRef.nativeElement.classList.add(columnClassName);
191
+ // If IE 11 is dropped before we switch to setting a single class name, change to multi param
192
+ // with destructuring.
193
+ const classList = elementRef.nativeElement.classList;
194
+ for (const className of columnDef._columnCssClassName) {
195
+ classList.add(className);
196
+ }
182
197
  }
183
198
  }
184
199
  /** Header cell template container that adds the right classes and role. */
@@ -293,17 +308,28 @@ class _CoalescedStyleScheduler {
293
308
  return;
294
309
  }
295
310
  this._currentSchedule = new _Schedule();
296
- this._ngZone.onStable.pipe(take(1), takeUntil(this._destroyed)).subscribe(() => {
297
- const schedule = this._currentSchedule;
298
- this._currentSchedule = null;
299
- for (const task of schedule.tasks) {
300
- task();
301
- }
302
- for (const task of schedule.endTasks) {
303
- task();
311
+ this._getScheduleObservable().pipe(takeUntil(this._destroyed)).subscribe(() => {
312
+ while (this._currentSchedule.tasks.length || this._currentSchedule.endTasks.length) {
313
+ const schedule = this._currentSchedule;
314
+ // Capture new tasks scheduled by the current set of tasks.
315
+ this._currentSchedule = new _Schedule();
316
+ for (const task of schedule.tasks) {
317
+ task();
318
+ }
319
+ for (const task of schedule.endTasks) {
320
+ task();
321
+ }
304
322
  }
323
+ this._currentSchedule = null;
305
324
  });
306
325
  }
326
+ _getScheduleObservable() {
327
+ // Use onStable when in the context of an ongoing change detection cycle so that we
328
+ // do not accidentally trigger additional cycles.
329
+ return this._ngZone.isStable ?
330
+ from(Promise.resolve(undefined)) :
331
+ this._ngZone.onStable.pipe(take(1));
332
+ }
307
333
  }
308
334
  _CoalescedStyleScheduler.decorators = [
309
335
  { type: Injectable }
@@ -578,13 +604,17 @@ class StickyStyler {
578
604
  * @param direction The directionality context of the table (ltr/rtl); affects column positioning
579
605
  * by reversing left/right positions.
580
606
  * @param _isBrowser Whether the table is currently being rendered on the server or the client.
607
+ * @param _needsPositionStickyOnElement Whether we need to specify position: sticky on cells
608
+ * using inline styles. If false, it is assumed that position: sticky is included in
609
+ * the component stylesheet for _stickCellCss.
581
610
  */
582
- constructor(_isNativeHtmlTable, _stickCellCss, direction, _coalescedStyleScheduler, _isBrowser = true) {
611
+ constructor(_isNativeHtmlTable, _stickCellCss, direction, _coalescedStyleScheduler, _isBrowser = true, _needsPositionStickyOnElement = true) {
583
612
  this._isNativeHtmlTable = _isNativeHtmlTable;
584
613
  this._stickCellCss = _stickCellCss;
585
614
  this.direction = direction;
586
615
  this._coalescedStyleScheduler = _coalescedStyleScheduler;
587
616
  this._isBrowser = _isBrowser;
617
+ this._needsPositionStickyOnElement = _needsPositionStickyOnElement;
588
618
  }
589
619
  /**
590
620
  * Clears the sticky positioning styles from the row and its cells by resetting the `position`
@@ -729,12 +759,20 @@ class StickyStyler {
729
759
  for (const dir of stickyDirections) {
730
760
  element.style[dir] = '';
731
761
  }
732
- element.style.zIndex = this._getCalculatedZIndex(element);
733
762
  // If the element no longer has any more sticky directions, remove sticky positioning and
734
763
  // the sticky CSS class.
735
- const hasDirection = STICKY_DIRECTIONS.some(dir => !!element.style[dir]);
736
- if (!hasDirection) {
737
- element.style.position = '';
764
+ // Short-circuit checking element.style[dir] for stickyDirections as they
765
+ // were already removed above.
766
+ const hasDirection = STICKY_DIRECTIONS.some(dir => stickyDirections.indexOf(dir) === -1 && element.style[dir]);
767
+ if (hasDirection) {
768
+ element.style.zIndex = this._getCalculatedZIndex(element);
769
+ }
770
+ else {
771
+ // When not hasDirection, _getCalculatedZIndex will always return ''.
772
+ element.style.zIndex = '';
773
+ if (this._needsPositionStickyOnElement) {
774
+ element.style.position = '';
775
+ }
738
776
  element.classList.remove(this._stickCellCss);
739
777
  }
740
778
  }
@@ -746,8 +784,10 @@ class StickyStyler {
746
784
  _addStickyStyle(element, dir, dirValue) {
747
785
  element.classList.add(this._stickCellCss);
748
786
  element.style[dir] = `${dirValue}px`;
749
- element.style.cssText += 'position: -webkit-sticky; position: sticky; ';
750
787
  element.style.zIndex = this._getCalculatedZIndex(element);
788
+ if (this._needsPositionStickyOnElement) {
789
+ element.style.cssText += 'position: -webkit-sticky; position: sticky; ';
790
+ }
751
791
  }
752
792
  /**
753
793
  * Calculate what the z-index should be for the element, depending on what directions (top,
@@ -1062,6 +1102,12 @@ class CdkTable {
1062
1102
  * table subclasses.
1063
1103
  */
1064
1104
  this.stickyCssClass = 'cdk-table-sticky';
1105
+ /**
1106
+ * Whether to manually add positon: sticky to all sticky cell elements. Not needed if
1107
+ * the position is set in a selector associated with the value of stickyCssClass. May be
1108
+ * overridden by table subclasses
1109
+ */
1110
+ this.needsPositionStickyOnElement = true;
1065
1111
  /** Whether the no data row is currently showing anything. */
1066
1112
  this._isShowingNoDataRow = false;
1067
1113
  this._multiTemplateDataRows = false;
@@ -1693,7 +1739,7 @@ class CdkTable {
1693
1739
  */
1694
1740
  _setupStickyStyler() {
1695
1741
  const direction = this._dir ? this._dir.value : 'ltr';
1696
- this._stickyStyler = new StickyStyler(this._isNativeHtmlTable, this.stickyCssClass, direction, this._coalescedStyleScheduler, this._platform.isBrowser);
1742
+ this._stickyStyler = new StickyStyler(this._isNativeHtmlTable, this.stickyCssClass, direction, this._coalescedStyleScheduler, this._platform.isBrowser, this.needsPositionStickyOnElement);
1697
1743
  (this._dir ? this._dir.change : of())
1698
1744
  .pipe(takeUntil(this._onDestroy))
1699
1745
  .subscribe(value => {