@angular/cdk 18.2.1 → 18.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.
package/fesm2022/tree.mjs CHANGED
@@ -4,7 +4,8 @@ import { take, filter, takeUntil, startWith, tap, switchMap, map, reduce, concat
4
4
  import * as i0 from '@angular/core';
5
5
  import { InjectionToken, Directive, Inject, Optional, inject, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, ViewChild, ContentChildren, EventEmitter, ChangeDetectorRef, booleanAttribute, Output, numberAttribute, NgModule } from '@angular/core';
6
6
  import { TREE_KEY_MANAGER } from '@angular/cdk/a11y';
7
- import * as i1 from '@angular/cdk/bidi';
7
+ import * as i2 from '@angular/cdk/bidi';
8
+ import { Directionality } from '@angular/cdk/bidi';
8
9
  import { coerceObservable } from '@angular/cdk/coercion/private';
9
10
 
10
11
  /**
@@ -280,10 +281,10 @@ class CdkTree {
280
281
  this._switchDataSource(dataSource);
281
282
  }
282
283
  }
283
- constructor(_differs, _changeDetectorRef, _dir) {
284
+ constructor(_differs, _changeDetectorRef) {
284
285
  this._differs = _differs;
285
286
  this._changeDetectorRef = _changeDetectorRef;
286
- this._dir = _dir;
287
+ this._dir = inject(Directionality);
287
288
  /** Subject that emits when the component has been destroyed. */
288
289
  this._onDestroy = new Subject();
289
290
  /** Level of nodes */
@@ -1026,7 +1027,7 @@ class CdkTree {
1026
1027
  this._ariaSets.set(parentKey, group);
1027
1028
  }
1028
1029
  }
1029
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0-next.2", ngImport: i0, type: CdkTree, deps: [{ token: i0.IterableDiffers }, { token: i0.ChangeDetectorRef }, { token: i1.Directionality }], target: i0.ɵɵFactoryTarget.Component }); }
1030
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0-next.2", ngImport: i0, type: CdkTree, deps: [{ token: i0.IterableDiffers }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
1030
1031
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0-next.2", type: CdkTree, isStandalone: true, selector: "cdk-tree", inputs: { dataSource: "dataSource", treeControl: "treeControl", levelAccessor: "levelAccessor", childrenAccessor: "childrenAccessor", trackBy: "trackBy", expansionKey: "expansionKey" }, host: { attributes: { "role": "tree" }, listeners: { "keydown": "_sendKeydownToKeyManager($event)" }, classAttribute: "cdk-tree" }, queries: [{ propertyName: "_nodeDefs", predicate: CdkTreeNodeDef, descendants: true }], viewQueries: [{ propertyName: "_nodeOutlet", first: true, predicate: CdkTreeNodeOutlet, descendants: true, static: true }], exportAs: ["cdkTree"], ngImport: i0, template: `<ng-container cdkTreeNodeOutlet></ng-container>`, isInline: true, dependencies: [{ kind: "directive", type: CdkTreeNodeOutlet, selector: "[cdkTreeNodeOutlet]" }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None }); }
1031
1032
  }
1032
1033
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0-next.2", ngImport: i0, type: CdkTree, decorators: [{
@@ -1049,7 +1050,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0-next.2",
1049
1050
  standalone: true,
1050
1051
  imports: [CdkTreeNodeOutlet],
1051
1052
  }]
1052
- }], ctorParameters: () => [{ type: i0.IterableDiffers }, { type: i0.ChangeDetectorRef }, { type: i1.Directionality }], propDecorators: { dataSource: [{
1053
+ }], ctorParameters: () => [{ type: i0.IterableDiffers }, { type: i0.ChangeDetectorRef }], propDecorators: { dataSource: [{
1053
1054
  type: Input
1054
1055
  }], treeControl: [{
1055
1056
  type: Input
@@ -1100,11 +1101,23 @@ class CdkTreeNode {
1100
1101
  }
1101
1102
  set isExpandable(isExpandable) {
1102
1103
  this._inputIsExpandable = isExpandable;
1104
+ if ((this.data && !this._isExpandable) || !this._inputIsExpandable) {
1105
+ return;
1106
+ }
1107
+ // If the node is being set to expandable, ensure that the status of the
1108
+ // node is propagated
1109
+ if (this._inputIsExpanded) {
1110
+ this.expand();
1111
+ }
1112
+ else if (this._inputIsExpanded === false) {
1113
+ this.collapse();
1114
+ }
1103
1115
  }
1104
1116
  get isExpanded() {
1105
1117
  return this._tree.isExpanded(this._data);
1106
1118
  }
1107
1119
  set isExpanded(isExpanded) {
1120
+ this._inputIsExpanded = isExpanded;
1108
1121
  if (isExpanded) {
1109
1122
  this.expand();
1110
1123
  }
@@ -1202,6 +1215,7 @@ class CdkTreeNode {
1202
1215
  /** Emits when the node's data has changed. */
1203
1216
  this._dataChanges = new Subject();
1204
1217
  this._inputIsExpandable = false;
1218
+ this._inputIsExpanded = undefined;
1205
1219
  /**
1206
1220
  * Flag used to determine whether or not we should be focusing the actual element based on
1207
1221
  * some user interaction (click or focus). On click, we don't forcibly focus the element
@@ -1271,6 +1285,11 @@ class CdkTreeNode {
1271
1285
  this._tree.expand(this._data);
1272
1286
  }
1273
1287
  }
1288
+ /** Makes the node focusable. Implemented for TreeKeyManagerItem. */
1289
+ makeFocusable() {
1290
+ this._tabindex = 0;
1291
+ this._changeDetectorRef.markForCheck();
1292
+ }
1274
1293
  _focusItem() {
1275
1294
  if (this.isDisabled) {
1276
1295
  return;
@@ -1538,7 +1557,7 @@ class CdkTreeNodePadding {
1538
1557
  this._indent = numberAttribute(value);
1539
1558
  this._setPadding();
1540
1559
  }
1541
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0-next.2", ngImport: i0, type: CdkTreeNodePadding, deps: [{ token: CdkTreeNode }, { token: CdkTree }, { token: i0.ElementRef }, { token: i1.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
1560
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0-next.2", ngImport: i0, type: CdkTreeNodePadding, deps: [{ token: CdkTreeNode }, { token: CdkTree }, { token: i0.ElementRef }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
1542
1561
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "18.2.0-next.2", type: CdkTreeNodePadding, isStandalone: true, selector: "[cdkTreeNodePadding]", inputs: { level: ["cdkTreeNodePadding", "level", numberAttribute], indent: ["cdkTreeNodePaddingIndent", "indent"] }, ngImport: i0 }); }
1543
1562
  }
1544
1563
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0-next.2", ngImport: i0, type: CdkTreeNodePadding, decorators: [{
@@ -1547,7 +1566,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0-next.2",
1547
1566
  selector: '[cdkTreeNodePadding]',
1548
1567
  standalone: true,
1549
1568
  }]
1550
- }], ctorParameters: () => [{ type: CdkTreeNode }, { type: CdkTree }, { type: i0.ElementRef }, { type: i1.Directionality, decorators: [{
1569
+ }], ctorParameters: () => [{ type: CdkTreeNode }, { type: CdkTree }, { type: i0.ElementRef }, { type: i2.Directionality, decorators: [{
1551
1570
  type: Optional
1552
1571
  }] }], propDecorators: { level: [{
1553
1572
  type: Input,