@angular/cdk 21.0.0-next.8 → 21.0.0-rc.0
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/_adev_assets/cdk_drag_drop.json +13 -12
- package/_adev_assets/cdk_testing.json +15 -25
- package/_adev_assets/cdk_testing_protractor.json +1 -1
- package/_adev_assets/cdk_testing_selenium_webdriver.json +1 -1
- package/_adev_assets/cdk_testing_testbed.json +1 -1
- package/fesm2022/_a11y-module-chunk.mjs +755 -869
- package/fesm2022/_a11y-module-chunk.mjs.map +1 -1
- package/fesm2022/_activedescendant-key-manager-chunk.mjs +8 -8
- package/fesm2022/_activedescendant-key-manager-chunk.mjs.map +1 -1
- package/fesm2022/_array-chunk.mjs +1 -1
- package/fesm2022/_array-chunk.mjs.map +1 -1
- package/fesm2022/_breakpoints-observer-chunk.mjs +149 -152
- package/fesm2022/_breakpoints-observer-chunk.mjs.map +1 -1
- package/fesm2022/_css-pixel-value-chunk.mjs +4 -5
- package/fesm2022/_css-pixel-value-chunk.mjs.map +1 -1
- package/fesm2022/_data-source-chunk.mjs +2 -8
- package/fesm2022/_data-source-chunk.mjs.map +1 -1
- package/fesm2022/_directionality-chunk.mjs +54 -54
- package/fesm2022/_directionality-chunk.mjs.map +1 -1
- package/fesm2022/_dispose-view-repeater-strategy-chunk.mjs +25 -36
- package/fesm2022/_dispose-view-repeater-strategy-chunk.mjs.map +1 -1
- package/fesm2022/_element-chunk.mjs +6 -17
- package/fesm2022/_element-chunk.mjs.map +1 -1
- package/fesm2022/_fake-event-detection-chunk.mjs +3 -17
- package/fesm2022/_fake-event-detection-chunk.mjs.map +1 -1
- package/fesm2022/_focus-key-manager-chunk.mjs +10 -14
- package/fesm2022/_focus-key-manager-chunk.mjs.map +1 -1
- package/fesm2022/_focus-monitor-chunk.mjs +376 -566
- package/fesm2022/_focus-monitor-chunk.mjs.map +1 -1
- package/fesm2022/_id-generator-chunk.mjs +36 -27
- package/fesm2022/_id-generator-chunk.mjs.map +1 -1
- package/fesm2022/_keycodes-chunk.mjs +9 -9
- package/fesm2022/_keycodes-chunk.mjs.map +1 -1
- package/fesm2022/_list-key-manager-chunk.mjs +248 -336
- package/fesm2022/_list-key-manager-chunk.mjs.map +1 -1
- package/fesm2022/_overlay-module-chunk.mjs +2534 -2948
- package/fesm2022/_overlay-module-chunk.mjs.map +1 -1
- package/fesm2022/_passive-listeners-chunk.mjs +10 -22
- package/fesm2022/_passive-listeners-chunk.mjs.map +1 -1
- package/fesm2022/_platform-chunk.mjs +42 -65
- package/fesm2022/_platform-chunk.mjs.map +1 -1
- package/fesm2022/_recycle-view-repeater-strategy-chunk.mjs +78 -134
- package/fesm2022/_recycle-view-repeater-strategy-chunk.mjs.map +1 -1
- package/fesm2022/_scrolling-chunk.mjs +44 -85
- package/fesm2022/_scrolling-chunk.mjs.map +1 -1
- package/fesm2022/_selection-model-chunk.mjs +138 -209
- package/fesm2022/_selection-model-chunk.mjs.map +1 -1
- package/fesm2022/_shadow-dom-chunk.mjs +21 -35
- package/fesm2022/_shadow-dom-chunk.mjs.map +1 -1
- package/fesm2022/_style-loader-chunk.mjs +50 -37
- package/fesm2022/_style-loader-chunk.mjs.map +1 -1
- package/fesm2022/_test-environment-chunk.mjs +2 -14
- package/fesm2022/_test-environment-chunk.mjs.map +1 -1
- package/fesm2022/_tree-key-manager-chunk.mjs +229 -308
- package/fesm2022/_tree-key-manager-chunk.mjs.map +1 -1
- package/fesm2022/_typeahead-chunk.mjs +52 -74
- package/fesm2022/_typeahead-chunk.mjs.map +1 -1
- package/fesm2022/_unique-selection-dispatcher-chunk.mjs +43 -40
- package/fesm2022/_unique-selection-dispatcher-chunk.mjs.map +1 -1
- package/fesm2022/a11y.mjs +351 -449
- package/fesm2022/a11y.mjs.map +1 -1
- package/fesm2022/accordion.mjs +254 -192
- package/fesm2022/accordion.mjs.map +1 -1
- package/fesm2022/bidi.mjs +121 -64
- package/fesm2022/bidi.mjs.map +1 -1
- package/fesm2022/cdk.mjs +1 -2
- package/fesm2022/cdk.mjs.map +1 -1
- package/fesm2022/clipboard.mjs +208 -186
- package/fesm2022/clipboard.mjs.map +1 -1
- package/fesm2022/coercion-private.mjs +4 -8
- package/fesm2022/coercion-private.mjs.map +1 -1
- package/fesm2022/coercion.mjs +11 -29
- package/fesm2022/coercion.mjs.map +1 -1
- package/fesm2022/dialog.mjs +660 -808
- package/fesm2022/dialog.mjs.map +1 -1
- package/fesm2022/drag-drop.mjs +3347 -4286
- package/fesm2022/drag-drop.mjs.map +1 -1
- package/fesm2022/keycodes.mjs +4 -8
- package/fesm2022/keycodes.mjs.map +1 -1
- package/fesm2022/layout.mjs +44 -26
- package/fesm2022/layout.mjs.map +1 -1
- package/fesm2022/listbox.mjs +841 -895
- package/fesm2022/listbox.mjs.map +1 -1
- package/fesm2022/menu.mjs +1942 -1858
- package/fesm2022/menu.mjs.map +1 -1
- package/fesm2022/observers-private.mjs +88 -106
- package/fesm2022/observers-private.mjs.map +1 -1
- package/fesm2022/observers.mjs +262 -184
- package/fesm2022/observers.mjs.map +1 -1
- package/fesm2022/overlay.mjs +72 -68
- package/fesm2022/overlay.mjs.map +1 -1
- package/fesm2022/platform.mjs +43 -54
- package/fesm2022/platform.mjs.map +1 -1
- package/fesm2022/portal.mjs +402 -560
- package/fesm2022/portal.mjs.map +1 -1
- package/fesm2022/private.mjs +38 -10
- package/fesm2022/private.mjs.map +1 -1
- package/fesm2022/scrolling.mjs +1323 -1400
- package/fesm2022/scrolling.mjs.map +1 -1
- package/fesm2022/stepper.mjs +758 -590
- package/fesm2022/stepper.mjs.map +1 -1
- package/fesm2022/table.mjs +2327 -2319
- package/fesm2022/table.mjs.map +1 -1
- package/fesm2022/testing-selenium-webdriver.mjs +252 -325
- package/fesm2022/testing-selenium-webdriver.mjs.map +1 -1
- package/fesm2022/testing-testbed.mjs +592 -709
- package/fesm2022/testing-testbed.mjs.map +1 -1
- package/fesm2022/testing.mjs +368 -889
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/text-field.mjs +459 -388
- package/fesm2022/text-field.mjs.map +1 -1
- package/fesm2022/tree.mjs +1483 -1731
- package/fesm2022/tree.mjs.map +1 -1
- package/overlay/_index.scss +28 -0
- package/overlay-prebuilt.css +1 -1
- package/package.json +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/types/_harness-environment-chunk.d.ts +1 -2
- package/types/_overlay-module-chunk.d.ts +59 -7
- package/types/_portal-directives-chunk.d.ts +2 -18
- package/types/accordion.d.ts +3 -1
- package/types/dialog.d.ts +1 -1
- package/types/overlay.d.ts +6 -2
- package/types/portal.d.ts +1 -1
package/fesm2022/tree.mjs
CHANGED
|
@@ -10,1791 +10,1543 @@ import { coerceObservable } from './coercion-private.mjs';
|
|
|
10
10
|
import './_typeahead-chunk.mjs';
|
|
11
11
|
import './_keycodes-chunk.mjs';
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* Base tree control. It has basic toggle/expand/collapse operations on a single data node.
|
|
15
|
-
*
|
|
16
|
-
* @deprecated Use one of levelAccessor or childrenAccessor. To be removed in a future version.
|
|
17
|
-
* @breaking-change 21.0.0
|
|
18
|
-
*/
|
|
19
13
|
class BaseTreeControl {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
toggleDescendants(dataNode) {
|
|
58
|
-
this.expansionModel.isSelected(this._trackByValue(dataNode))
|
|
59
|
-
? this.collapseDescendants(dataNode)
|
|
60
|
-
: this.expandDescendants(dataNode);
|
|
61
|
-
}
|
|
62
|
-
/** Collapse all dataNodes in the tree. */
|
|
63
|
-
collapseAll() {
|
|
64
|
-
this.expansionModel.clear();
|
|
65
|
-
}
|
|
66
|
-
/** Expands a subtree rooted at given data node recursively. */
|
|
67
|
-
expandDescendants(dataNode) {
|
|
68
|
-
let toBeProcessed = [dataNode];
|
|
69
|
-
toBeProcessed.push(...this.getDescendants(dataNode));
|
|
70
|
-
this.expansionModel.select(...toBeProcessed.map(value => this._trackByValue(value)));
|
|
71
|
-
}
|
|
72
|
-
/** Collapses a subtree rooted at given data node recursively. */
|
|
73
|
-
collapseDescendants(dataNode) {
|
|
74
|
-
let toBeProcessed = [dataNode];
|
|
75
|
-
toBeProcessed.push(...this.getDescendants(dataNode));
|
|
76
|
-
this.expansionModel.deselect(...toBeProcessed.map(value => this._trackByValue(value)));
|
|
77
|
-
}
|
|
78
|
-
_trackByValue(value) {
|
|
79
|
-
return this.trackBy ? this.trackBy(value) : value;
|
|
80
|
-
}
|
|
14
|
+
dataNodes;
|
|
15
|
+
expansionModel = new SelectionModel(true);
|
|
16
|
+
trackBy;
|
|
17
|
+
getLevel;
|
|
18
|
+
isExpandable;
|
|
19
|
+
getChildren;
|
|
20
|
+
toggle(dataNode) {
|
|
21
|
+
this.expansionModel.toggle(this._trackByValue(dataNode));
|
|
22
|
+
}
|
|
23
|
+
expand(dataNode) {
|
|
24
|
+
this.expansionModel.select(this._trackByValue(dataNode));
|
|
25
|
+
}
|
|
26
|
+
collapse(dataNode) {
|
|
27
|
+
this.expansionModel.deselect(this._trackByValue(dataNode));
|
|
28
|
+
}
|
|
29
|
+
isExpanded(dataNode) {
|
|
30
|
+
return this.expansionModel.isSelected(this._trackByValue(dataNode));
|
|
31
|
+
}
|
|
32
|
+
toggleDescendants(dataNode) {
|
|
33
|
+
this.expansionModel.isSelected(this._trackByValue(dataNode)) ? this.collapseDescendants(dataNode) : this.expandDescendants(dataNode);
|
|
34
|
+
}
|
|
35
|
+
collapseAll() {
|
|
36
|
+
this.expansionModel.clear();
|
|
37
|
+
}
|
|
38
|
+
expandDescendants(dataNode) {
|
|
39
|
+
let toBeProcessed = [dataNode];
|
|
40
|
+
toBeProcessed.push(...this.getDescendants(dataNode));
|
|
41
|
+
this.expansionModel.select(...toBeProcessed.map(value => this._trackByValue(value)));
|
|
42
|
+
}
|
|
43
|
+
collapseDescendants(dataNode) {
|
|
44
|
+
let toBeProcessed = [dataNode];
|
|
45
|
+
toBeProcessed.push(...this.getDescendants(dataNode));
|
|
46
|
+
this.expansionModel.deselect(...toBeProcessed.map(value => this._trackByValue(value)));
|
|
47
|
+
}
|
|
48
|
+
_trackByValue(value) {
|
|
49
|
+
return this.trackBy ? this.trackBy(value) : value;
|
|
50
|
+
}
|
|
81
51
|
}
|
|
82
52
|
|
|
83
|
-
/**
|
|
84
|
-
* Flat tree control. Able to expand/collapse a subtree recursively for flattened tree.
|
|
85
|
-
*
|
|
86
|
-
* @deprecated Use one of levelAccessor or childrenAccessor instead. To be removed in a future
|
|
87
|
-
* version.
|
|
88
|
-
* @breaking-change 21.0.0
|
|
89
|
-
*/
|
|
90
53
|
class FlatTreeControl extends BaseTreeControl {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// The level of descendants of a tree node must be greater than the level of the given
|
|
115
|
-
// tree node.
|
|
116
|
-
// If we reach a node whose level is equal to the level of the tree node, we hit a sibling.
|
|
117
|
-
// If we reach a node whose level is greater than the level of the tree node, we hit a
|
|
118
|
-
// sibling of an ancestor.
|
|
119
|
-
for (let i = startIndex + 1; i < this.dataNodes.length && this.getLevel(dataNode) < this.getLevel(this.dataNodes[i]); i++) {
|
|
120
|
-
results.push(this.dataNodes[i]);
|
|
121
|
-
}
|
|
122
|
-
return results;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Expands all data nodes in the tree.
|
|
126
|
-
*
|
|
127
|
-
* To make this working, the `dataNodes` variable of the TreeControl must be set to all flattened
|
|
128
|
-
* data nodes of the tree.
|
|
129
|
-
*/
|
|
130
|
-
expandAll() {
|
|
131
|
-
this.expansionModel.select(...this.dataNodes.map(node => this._trackByValue(node)));
|
|
132
|
-
}
|
|
54
|
+
getLevel;
|
|
55
|
+
isExpandable;
|
|
56
|
+
options;
|
|
57
|
+
constructor(getLevel, isExpandable, options) {
|
|
58
|
+
super();
|
|
59
|
+
this.getLevel = getLevel;
|
|
60
|
+
this.isExpandable = isExpandable;
|
|
61
|
+
this.options = options;
|
|
62
|
+
if (this.options) {
|
|
63
|
+
this.trackBy = this.options.trackBy;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
getDescendants(dataNode) {
|
|
67
|
+
const startIndex = this.dataNodes.indexOf(dataNode);
|
|
68
|
+
const results = [];
|
|
69
|
+
for (let i = startIndex + 1; i < this.dataNodes.length && this.getLevel(dataNode) < this.getLevel(this.dataNodes[i]); i++) {
|
|
70
|
+
results.push(this.dataNodes[i]);
|
|
71
|
+
}
|
|
72
|
+
return results;
|
|
73
|
+
}
|
|
74
|
+
expandAll() {
|
|
75
|
+
this.expansionModel.select(...this.dataNodes.map(node => this._trackByValue(node)));
|
|
76
|
+
}
|
|
133
77
|
}
|
|
134
78
|
|
|
135
|
-
/**
|
|
136
|
-
* Nested tree control. Able to expand/collapse a subtree recursively for NestedNode type.
|
|
137
|
-
*
|
|
138
|
-
* @deprecated Use one of levelAccessor or childrenAccessor instead. To be removed in a future
|
|
139
|
-
* version.
|
|
140
|
-
* @breaking-change 21.0.0
|
|
141
|
-
*/
|
|
142
79
|
class NestedTreeControl extends BaseTreeControl {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (Array.isArray(childrenNodes)) {
|
|
180
|
-
childrenNodes.forEach((child) => this._getDescendants(descendants, child));
|
|
181
|
-
}
|
|
182
|
-
else if (isObservable(childrenNodes)) {
|
|
183
|
-
// TypeScript as of version 3.5 doesn't seem to treat `Boolean` like a function that
|
|
184
|
-
// returns a `boolean` specifically in the context of `filter`, so we manually clarify that.
|
|
185
|
-
childrenNodes.pipe(take(1), filter(Boolean)).subscribe(children => {
|
|
186
|
-
for (const child of children) {
|
|
187
|
-
this._getDescendants(descendants, child);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
80
|
+
getChildren;
|
|
81
|
+
options;
|
|
82
|
+
constructor(getChildren, options) {
|
|
83
|
+
super();
|
|
84
|
+
this.getChildren = getChildren;
|
|
85
|
+
this.options = options;
|
|
86
|
+
if (this.options) {
|
|
87
|
+
this.trackBy = this.options.trackBy;
|
|
88
|
+
}
|
|
89
|
+
if (this.options?.isExpandable) {
|
|
90
|
+
this.isExpandable = this.options.isExpandable;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
expandAll() {
|
|
94
|
+
this.expansionModel.clear();
|
|
95
|
+
const allNodes = this.dataNodes.reduce((accumulator, dataNode) => [...accumulator, ...this.getDescendants(dataNode), dataNode], []);
|
|
96
|
+
this.expansionModel.select(...allNodes.map(node => this._trackByValue(node)));
|
|
97
|
+
}
|
|
98
|
+
getDescendants(dataNode) {
|
|
99
|
+
const descendants = [];
|
|
100
|
+
this._getDescendants(descendants, dataNode);
|
|
101
|
+
return descendants.splice(1);
|
|
102
|
+
}
|
|
103
|
+
_getDescendants(descendants, dataNode) {
|
|
104
|
+
descendants.push(dataNode);
|
|
105
|
+
const childrenNodes = this.getChildren(dataNode);
|
|
106
|
+
if (Array.isArray(childrenNodes)) {
|
|
107
|
+
childrenNodes.forEach(child => this._getDescendants(descendants, child));
|
|
108
|
+
} else if (isObservable(childrenNodes)) {
|
|
109
|
+
childrenNodes.pipe(take(1), filter(Boolean)).subscribe(children => {
|
|
110
|
+
for (const child of children) {
|
|
111
|
+
this._getDescendants(descendants, child);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
192
116
|
}
|
|
193
117
|
|
|
194
|
-
/**
|
|
195
|
-
* Injection token used to provide a `CdkTreeNode` to its outlet.
|
|
196
|
-
* Used primarily to avoid circular imports.
|
|
197
|
-
* @docs-private
|
|
198
|
-
*/
|
|
199
118
|
const CDK_TREE_NODE_OUTLET_NODE = new InjectionToken('CDK_TREE_NODE_OUTLET_NODE');
|
|
200
|
-
/**
|
|
201
|
-
* Outlet for nested CdkNode. Put `[cdkTreeNodeOutlet]` on a tag to place children dataNodes
|
|
202
|
-
* inside the outlet.
|
|
203
|
-
*/
|
|
204
119
|
class CdkTreeNodeOutlet {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
120
|
+
viewContainer = inject(ViewContainerRef);
|
|
121
|
+
_node = inject(CDK_TREE_NODE_OUTLET_NODE, {
|
|
122
|
+
optional: true
|
|
123
|
+
});
|
|
124
|
+
constructor() {}
|
|
125
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
126
|
+
minVersion: "12.0.0",
|
|
127
|
+
version: "20.2.0-next.2",
|
|
128
|
+
ngImport: i0,
|
|
129
|
+
type: CdkTreeNodeOutlet,
|
|
130
|
+
deps: [],
|
|
131
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
132
|
+
});
|
|
133
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
134
|
+
minVersion: "14.0.0",
|
|
135
|
+
version: "20.2.0-next.2",
|
|
136
|
+
type: CdkTreeNodeOutlet,
|
|
137
|
+
isStandalone: true,
|
|
138
|
+
selector: "[cdkTreeNodeOutlet]",
|
|
139
|
+
ngImport: i0
|
|
140
|
+
});
|
|
210
141
|
}
|
|
211
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
142
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
143
|
+
minVersion: "12.0.0",
|
|
144
|
+
version: "20.2.0-next.2",
|
|
145
|
+
ngImport: i0,
|
|
146
|
+
type: CdkTreeNodeOutlet,
|
|
147
|
+
decorators: [{
|
|
148
|
+
type: Directive,
|
|
149
|
+
args: [{
|
|
150
|
+
selector: '[cdkTreeNodeOutlet]'
|
|
151
|
+
}]
|
|
152
|
+
}],
|
|
153
|
+
ctorParameters: () => []
|
|
154
|
+
});
|
|
217
155
|
|
|
218
|
-
/** Context provided to the tree node component. */
|
|
219
156
|
class CdkTreeNodeOutletContext {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
count;
|
|
228
|
-
constructor(data) {
|
|
229
|
-
this.$implicit = data;
|
|
230
|
-
}
|
|
157
|
+
$implicit;
|
|
158
|
+
level;
|
|
159
|
+
index;
|
|
160
|
+
count;
|
|
161
|
+
constructor(data) {
|
|
162
|
+
this.$implicit = data;
|
|
163
|
+
}
|
|
231
164
|
}
|
|
232
|
-
/**
|
|
233
|
-
* Data node definition for the CdkTree.
|
|
234
|
-
* Captures the node's template and a when predicate that describes when this node should be used.
|
|
235
|
-
*/
|
|
236
165
|
class CdkTreeNodeDef {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
166
|
+
template = inject(TemplateRef);
|
|
167
|
+
when;
|
|
168
|
+
constructor() {}
|
|
169
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
170
|
+
minVersion: "12.0.0",
|
|
171
|
+
version: "20.2.0-next.2",
|
|
172
|
+
ngImport: i0,
|
|
173
|
+
type: CdkTreeNodeDef,
|
|
174
|
+
deps: [],
|
|
175
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
176
|
+
});
|
|
177
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
178
|
+
minVersion: "14.0.0",
|
|
179
|
+
version: "20.2.0-next.2",
|
|
180
|
+
type: CdkTreeNodeDef,
|
|
181
|
+
isStandalone: true,
|
|
182
|
+
selector: "[cdkTreeNodeDef]",
|
|
183
|
+
inputs: {
|
|
184
|
+
when: ["cdkTreeNodeDefWhen", "when"]
|
|
185
|
+
},
|
|
186
|
+
ngImport: i0
|
|
187
|
+
});
|
|
250
188
|
}
|
|
251
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
189
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
190
|
+
minVersion: "12.0.0",
|
|
191
|
+
version: "20.2.0-next.2",
|
|
192
|
+
ngImport: i0,
|
|
193
|
+
type: CdkTreeNodeDef,
|
|
194
|
+
decorators: [{
|
|
195
|
+
type: Directive,
|
|
196
|
+
args: [{
|
|
197
|
+
selector: '[cdkTreeNodeDef]',
|
|
198
|
+
inputs: [{
|
|
199
|
+
name: 'when',
|
|
200
|
+
alias: 'cdkTreeNodeDefWhen'
|
|
201
|
+
}]
|
|
202
|
+
}]
|
|
203
|
+
}],
|
|
204
|
+
ctorParameters: () => []
|
|
205
|
+
});
|
|
258
206
|
|
|
259
|
-
/**
|
|
260
|
-
* Returns an error to be thrown when there is no usable data.
|
|
261
|
-
* @docs-private
|
|
262
|
-
*/
|
|
263
207
|
function getTreeNoValidDataSourceError() {
|
|
264
|
-
|
|
208
|
+
return Error(`A valid data source must be provided.`);
|
|
265
209
|
}
|
|
266
|
-
/**
|
|
267
|
-
* Returns an error to be thrown when there are multiple nodes that are missing a when function.
|
|
268
|
-
* @docs-private
|
|
269
|
-
*/
|
|
270
210
|
function getTreeMultipleDefaultNodeDefsError() {
|
|
271
|
-
|
|
211
|
+
return Error(`There can only be one default row without a when predicate function.`);
|
|
272
212
|
}
|
|
273
|
-
/**
|
|
274
|
-
* Returns an error to be thrown when there are no matching node defs for a particular set of data.
|
|
275
|
-
* @docs-private
|
|
276
|
-
*/
|
|
277
213
|
function getTreeMissingMatchingNodeDefError() {
|
|
278
|
-
|
|
214
|
+
return Error(`Could not find a matching node definition for the provided node data.`);
|
|
279
215
|
}
|
|
280
|
-
/**
|
|
281
|
-
* Returns an error to be thrown when there is no tree control.
|
|
282
|
-
* @docs-private
|
|
283
|
-
*/
|
|
284
216
|
function getTreeControlMissingError() {
|
|
285
|
-
|
|
217
|
+
return Error(`Could not find a tree control, levelAccessor, or childrenAccessor for the tree.`);
|
|
286
218
|
}
|
|
287
|
-
/**
|
|
288
|
-
* Returns an error to be thrown when there are multiple ways of specifying children or level
|
|
289
|
-
* provided to the tree.
|
|
290
|
-
* @docs-private
|
|
291
|
-
*/
|
|
292
219
|
function getMultipleTreeControlsError() {
|
|
293
|
-
|
|
220
|
+
return Error(`More than one of tree control, levelAccessor, or childrenAccessor were provided.`);
|
|
294
221
|
}
|
|
295
222
|
|
|
296
|
-
/**
|
|
297
|
-
* CDK tree component that connects with a data source to retrieve data of type `T` and renders
|
|
298
|
-
* dataNodes with hierarchy. Updates the dataNodes when new data is provided by the data source.
|
|
299
|
-
*/
|
|
300
223
|
class CdkTree {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
224
|
+
_differs = inject(IterableDiffers);
|
|
225
|
+
_changeDetectorRef = inject(ChangeDetectorRef);
|
|
226
|
+
_elementRef = inject(ElementRef);
|
|
227
|
+
_dir = inject(Directionality);
|
|
228
|
+
_onDestroy = new Subject();
|
|
229
|
+
_dataDiffer;
|
|
230
|
+
_defaultNodeDef;
|
|
231
|
+
_dataSubscription;
|
|
232
|
+
_levels = new Map();
|
|
233
|
+
_parents = new Map();
|
|
234
|
+
_ariaSets = new Map();
|
|
235
|
+
get dataSource() {
|
|
236
|
+
return this._dataSource;
|
|
237
|
+
}
|
|
238
|
+
set dataSource(dataSource) {
|
|
239
|
+
if (this._dataSource !== dataSource) {
|
|
240
|
+
this._switchDataSource(dataSource);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
_dataSource;
|
|
244
|
+
treeControl;
|
|
245
|
+
levelAccessor;
|
|
246
|
+
childrenAccessor;
|
|
247
|
+
trackBy;
|
|
248
|
+
expansionKey;
|
|
249
|
+
_nodeOutlet;
|
|
250
|
+
_nodeDefs;
|
|
251
|
+
viewChange = new BehaviorSubject({
|
|
252
|
+
start: 0,
|
|
253
|
+
end: Number.MAX_VALUE
|
|
254
|
+
});
|
|
255
|
+
_expansionModel;
|
|
256
|
+
_flattenedNodes = new BehaviorSubject([]);
|
|
257
|
+
_nodeType = new BehaviorSubject(null);
|
|
258
|
+
_nodes = new BehaviorSubject(new Map());
|
|
259
|
+
_keyManagerNodes = new BehaviorSubject([]);
|
|
260
|
+
_keyManagerFactory = inject(TREE_KEY_MANAGER);
|
|
261
|
+
_keyManager;
|
|
262
|
+
_viewInit = false;
|
|
263
|
+
constructor() {}
|
|
264
|
+
ngAfterContentInit() {
|
|
265
|
+
this._initializeKeyManager();
|
|
266
|
+
}
|
|
267
|
+
ngAfterContentChecked() {
|
|
268
|
+
this._updateDefaultNodeDefinition();
|
|
269
|
+
this._subscribeToDataChanges();
|
|
270
|
+
}
|
|
271
|
+
ngOnDestroy() {
|
|
272
|
+
this._nodeOutlet.viewContainer.clear();
|
|
273
|
+
this._nodes.complete();
|
|
274
|
+
this._keyManagerNodes.complete();
|
|
275
|
+
this._nodeType.complete();
|
|
276
|
+
this._flattenedNodes.complete();
|
|
277
|
+
this.viewChange.complete();
|
|
278
|
+
this._onDestroy.next();
|
|
279
|
+
this._onDestroy.complete();
|
|
280
|
+
if (this._dataSource && typeof this._dataSource.disconnect === 'function') {
|
|
281
|
+
this.dataSource.disconnect(this);
|
|
282
|
+
}
|
|
283
|
+
if (this._dataSubscription) {
|
|
284
|
+
this._dataSubscription.unsubscribe();
|
|
285
|
+
this._dataSubscription = null;
|
|
286
|
+
}
|
|
287
|
+
this._keyManager?.destroy();
|
|
288
|
+
}
|
|
289
|
+
ngOnInit() {
|
|
290
|
+
this._checkTreeControlUsage();
|
|
291
|
+
this._initializeDataDiffer();
|
|
292
|
+
}
|
|
293
|
+
ngAfterViewInit() {
|
|
294
|
+
this._viewInit = true;
|
|
295
|
+
}
|
|
296
|
+
_updateDefaultNodeDefinition() {
|
|
297
|
+
const defaultNodeDefs = this._nodeDefs.filter(def => !def.when);
|
|
298
|
+
if (defaultNodeDefs.length > 1 && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
299
|
+
throw getTreeMultipleDefaultNodeDefsError();
|
|
300
|
+
}
|
|
301
|
+
this._defaultNodeDef = defaultNodeDefs[0];
|
|
302
|
+
}
|
|
303
|
+
_setNodeTypeIfUnset(newType) {
|
|
304
|
+
const currentType = this._nodeType.value;
|
|
305
|
+
if (currentType === null) {
|
|
306
|
+
this._nodeType.next(newType);
|
|
307
|
+
} else if ((typeof ngDevMode === 'undefined' || ngDevMode) && currentType !== newType) {
|
|
308
|
+
console.warn(`Tree is using conflicting node types which can cause unexpected behavior. ` + `Please use tree nodes of the same type (e.g. only flat or only nested). ` + `Current node type: "${currentType}", new node type "${newType}".`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
_switchDataSource(dataSource) {
|
|
312
|
+
if (this._dataSource && typeof this._dataSource.disconnect === 'function') {
|
|
313
|
+
this.dataSource.disconnect(this);
|
|
314
|
+
}
|
|
315
|
+
if (this._dataSubscription) {
|
|
316
|
+
this._dataSubscription.unsubscribe();
|
|
317
|
+
this._dataSubscription = null;
|
|
318
|
+
}
|
|
319
|
+
if (!dataSource) {
|
|
320
|
+
this._nodeOutlet.viewContainer.clear();
|
|
321
|
+
}
|
|
322
|
+
this._dataSource = dataSource;
|
|
323
|
+
if (this._nodeDefs) {
|
|
324
|
+
this._subscribeToDataChanges();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
_getExpansionModel() {
|
|
328
|
+
if (!this.treeControl) {
|
|
329
|
+
this._expansionModel ??= new SelectionModel(true);
|
|
330
|
+
return this._expansionModel;
|
|
331
|
+
}
|
|
332
|
+
return this.treeControl.expansionModel;
|
|
333
|
+
}
|
|
334
|
+
_subscribeToDataChanges() {
|
|
335
|
+
if (this._dataSubscription) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
let dataStream;
|
|
339
|
+
if (isDataSource(this._dataSource)) {
|
|
340
|
+
dataStream = this._dataSource.connect(this);
|
|
341
|
+
} else if (isObservable(this._dataSource)) {
|
|
342
|
+
dataStream = this._dataSource;
|
|
343
|
+
} else if (Array.isArray(this._dataSource)) {
|
|
344
|
+
dataStream = of(this._dataSource);
|
|
345
|
+
}
|
|
346
|
+
if (!dataStream) {
|
|
347
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
348
|
+
throw getTreeNoValidDataSourceError();
|
|
349
|
+
}
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
this._dataSubscription = this._getRenderData(dataStream).pipe(takeUntil(this._onDestroy)).subscribe(renderingData => {
|
|
353
|
+
this._renderDataChanges(renderingData);
|
|
386
354
|
});
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
_nodes = new BehaviorSubject(new Map());
|
|
399
|
-
/**
|
|
400
|
-
* Synchronous cache of nodes for the `TreeKeyManager`. This is separate
|
|
401
|
-
* from `_flattenedNodes` so they can be independently updated at different
|
|
402
|
-
* times.
|
|
403
|
-
*/
|
|
404
|
-
_keyManagerNodes = new BehaviorSubject([]);
|
|
405
|
-
_keyManagerFactory = inject(TREE_KEY_MANAGER);
|
|
406
|
-
/** The key manager for this tree. Handles focus and activation based on user keyboard input. */
|
|
407
|
-
_keyManager;
|
|
408
|
-
_viewInit = false;
|
|
409
|
-
constructor() { }
|
|
410
|
-
ngAfterContentInit() {
|
|
411
|
-
this._initializeKeyManager();
|
|
412
|
-
}
|
|
413
|
-
ngAfterContentChecked() {
|
|
414
|
-
this._updateDefaultNodeDefinition();
|
|
415
|
-
this._subscribeToDataChanges();
|
|
416
|
-
}
|
|
417
|
-
ngOnDestroy() {
|
|
418
|
-
this._nodeOutlet.viewContainer.clear();
|
|
419
|
-
this._nodes.complete();
|
|
420
|
-
this._keyManagerNodes.complete();
|
|
421
|
-
this._nodeType.complete();
|
|
422
|
-
this._flattenedNodes.complete();
|
|
423
|
-
this.viewChange.complete();
|
|
424
|
-
this._onDestroy.next();
|
|
425
|
-
this._onDestroy.complete();
|
|
426
|
-
if (this._dataSource && typeof this._dataSource.disconnect === 'function') {
|
|
427
|
-
this.dataSource.disconnect(this);
|
|
428
|
-
}
|
|
429
|
-
if (this._dataSubscription) {
|
|
430
|
-
this._dataSubscription.unsubscribe();
|
|
431
|
-
this._dataSubscription = null;
|
|
432
|
-
}
|
|
433
|
-
// In certain tests, the tree might be destroyed before this is initialized
|
|
434
|
-
// in `ngAfterContentInit`.
|
|
435
|
-
this._keyManager?.destroy();
|
|
436
|
-
}
|
|
437
|
-
ngOnInit() {
|
|
438
|
-
this._checkTreeControlUsage();
|
|
439
|
-
this._initializeDataDiffer();
|
|
440
|
-
}
|
|
441
|
-
ngAfterViewInit() {
|
|
442
|
-
this._viewInit = true;
|
|
443
|
-
}
|
|
444
|
-
_updateDefaultNodeDefinition() {
|
|
445
|
-
const defaultNodeDefs = this._nodeDefs.filter(def => !def.when);
|
|
446
|
-
if (defaultNodeDefs.length > 1 && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
447
|
-
throw getTreeMultipleDefaultNodeDefsError();
|
|
448
|
-
}
|
|
449
|
-
this._defaultNodeDef = defaultNodeDefs[0];
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* Sets the node type for the tree, if it hasn't been set yet.
|
|
453
|
-
*
|
|
454
|
-
* This will be called by the first node that's rendered in order for the tree
|
|
455
|
-
* to determine what data transformations are required.
|
|
456
|
-
*/
|
|
457
|
-
_setNodeTypeIfUnset(newType) {
|
|
458
|
-
const currentType = this._nodeType.value;
|
|
459
|
-
if (currentType === null) {
|
|
460
|
-
this._nodeType.next(newType);
|
|
461
|
-
}
|
|
462
|
-
else if ((typeof ngDevMode === 'undefined' || ngDevMode) && currentType !== newType) {
|
|
463
|
-
console.warn(`Tree is using conflicting node types which can cause unexpected behavior. ` +
|
|
464
|
-
`Please use tree nodes of the same type (e.g. only flat or only nested). ` +
|
|
465
|
-
`Current node type: "${currentType}", new node type "${newType}".`);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* Switch to the provided data source by resetting the data and unsubscribing from the current
|
|
470
|
-
* render change subscription if one exists. If the data source is null, interpret this by
|
|
471
|
-
* clearing the node outlet. Otherwise start listening for new data.
|
|
472
|
-
*/
|
|
473
|
-
_switchDataSource(dataSource) {
|
|
474
|
-
if (this._dataSource && typeof this._dataSource.disconnect === 'function') {
|
|
475
|
-
this.dataSource.disconnect(this);
|
|
476
|
-
}
|
|
477
|
-
if (this._dataSubscription) {
|
|
478
|
-
this._dataSubscription.unsubscribe();
|
|
479
|
-
this._dataSubscription = null;
|
|
480
|
-
}
|
|
481
|
-
// Remove the all dataNodes if there is now no data source
|
|
482
|
-
if (!dataSource) {
|
|
483
|
-
this._nodeOutlet.viewContainer.clear();
|
|
484
|
-
}
|
|
485
|
-
this._dataSource = dataSource;
|
|
486
|
-
if (this._nodeDefs) {
|
|
487
|
-
this._subscribeToDataChanges();
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
_getExpansionModel() {
|
|
491
|
-
if (!this.treeControl) {
|
|
492
|
-
this._expansionModel ??= new SelectionModel(true);
|
|
493
|
-
return this._expansionModel;
|
|
494
|
-
}
|
|
495
|
-
return this.treeControl.expansionModel;
|
|
496
|
-
}
|
|
497
|
-
/** Set up a subscription for the data provided by the data source. */
|
|
498
|
-
_subscribeToDataChanges() {
|
|
499
|
-
if (this._dataSubscription) {
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
let dataStream;
|
|
503
|
-
if (isDataSource(this._dataSource)) {
|
|
504
|
-
dataStream = this._dataSource.connect(this);
|
|
505
|
-
}
|
|
506
|
-
else if (isObservable(this._dataSource)) {
|
|
507
|
-
dataStream = this._dataSource;
|
|
508
|
-
}
|
|
509
|
-
else if (Array.isArray(this._dataSource)) {
|
|
510
|
-
dataStream = of(this._dataSource);
|
|
511
|
-
}
|
|
512
|
-
if (!dataStream) {
|
|
513
|
-
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
514
|
-
throw getTreeNoValidDataSourceError();
|
|
515
|
-
}
|
|
516
|
-
return;
|
|
517
|
-
}
|
|
518
|
-
this._dataSubscription = this._getRenderData(dataStream)
|
|
519
|
-
.pipe(takeUntil(this._onDestroy))
|
|
520
|
-
.subscribe(renderingData => {
|
|
521
|
-
this._renderDataChanges(renderingData);
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
/** Given an Observable containing a stream of the raw data, returns an Observable containing the RenderingData */
|
|
525
|
-
_getRenderData(dataStream) {
|
|
526
|
-
const expansionModel = this._getExpansionModel();
|
|
527
|
-
return combineLatest([
|
|
528
|
-
dataStream,
|
|
529
|
-
this._nodeType,
|
|
530
|
-
// We don't use the expansion data directly, however we add it here to essentially
|
|
531
|
-
// trigger data rendering when expansion changes occur.
|
|
532
|
-
expansionModel.changed.pipe(startWith(null), tap(expansionChanges => {
|
|
533
|
-
this._emitExpansionChanges(expansionChanges);
|
|
534
|
-
})),
|
|
535
|
-
]).pipe(switchMap(([data, nodeType]) => {
|
|
536
|
-
if (nodeType === null) {
|
|
537
|
-
return of({ renderNodes: data, flattenedNodes: null, nodeType });
|
|
538
|
-
}
|
|
539
|
-
// If we're here, then we know what our node type is, and therefore can
|
|
540
|
-
// perform our usual rendering pipeline, which necessitates converting the data
|
|
541
|
-
return this._computeRenderingData(data, nodeType).pipe(map(convertedData => ({ ...convertedData, nodeType })));
|
|
542
|
-
}));
|
|
543
|
-
}
|
|
544
|
-
_renderDataChanges(data) {
|
|
545
|
-
if (data.nodeType === null) {
|
|
546
|
-
this.renderNodeChanges(data.renderNodes);
|
|
547
|
-
return;
|
|
548
|
-
}
|
|
549
|
-
// If we're here, then we know what our node type is, and therefore can
|
|
550
|
-
// perform our usual rendering pipeline.
|
|
551
|
-
this._updateCachedData(data.flattenedNodes);
|
|
552
|
-
this.renderNodeChanges(data.renderNodes);
|
|
553
|
-
this._updateKeyManagerItems(data.flattenedNodes);
|
|
554
|
-
}
|
|
555
|
-
_emitExpansionChanges(expansionChanges) {
|
|
556
|
-
if (!expansionChanges) {
|
|
557
|
-
return;
|
|
558
|
-
}
|
|
559
|
-
const nodes = this._nodes.value;
|
|
560
|
-
for (const added of expansionChanges.added) {
|
|
561
|
-
const node = nodes.get(added);
|
|
562
|
-
node?._emitExpansionState(true);
|
|
563
|
-
}
|
|
564
|
-
for (const removed of expansionChanges.removed) {
|
|
565
|
-
const node = nodes.get(removed);
|
|
566
|
-
node?._emitExpansionState(false);
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
_initializeKeyManager() {
|
|
570
|
-
const items = combineLatest([this._keyManagerNodes, this._nodes]).pipe(map(([keyManagerNodes, renderNodes]) => keyManagerNodes.reduce((items, data) => {
|
|
571
|
-
const node = renderNodes.get(this._getExpansionKey(data));
|
|
572
|
-
if (node) {
|
|
573
|
-
items.push(node);
|
|
574
|
-
}
|
|
575
|
-
return items;
|
|
576
|
-
}, [])));
|
|
577
|
-
const keyManagerOptions = {
|
|
578
|
-
trackBy: node => this._getExpansionKey(node.data),
|
|
579
|
-
skipPredicate: node => !!node.isDisabled,
|
|
580
|
-
typeAheadDebounceInterval: true,
|
|
581
|
-
horizontalOrientation: this._dir.value,
|
|
582
|
-
};
|
|
583
|
-
this._keyManager = this._keyManagerFactory(items, keyManagerOptions);
|
|
584
|
-
}
|
|
585
|
-
_initializeDataDiffer() {
|
|
586
|
-
// Provide a default trackBy based on `_getExpansionKey` if one isn't provided.
|
|
587
|
-
const trackBy = this.trackBy ?? ((_index, item) => this._getExpansionKey(item));
|
|
588
|
-
this._dataDiffer = this._differs.find([]).create(trackBy);
|
|
589
|
-
}
|
|
590
|
-
_checkTreeControlUsage() {
|
|
591
|
-
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
592
|
-
// Verify that Tree follows API contract of using one of TreeControl, levelAccessor or
|
|
593
|
-
// childrenAccessor. Throw an appropriate error if contract is not met.
|
|
594
|
-
let numTreeControls = 0;
|
|
595
|
-
if (this.treeControl) {
|
|
596
|
-
numTreeControls++;
|
|
597
|
-
}
|
|
598
|
-
if (this.levelAccessor) {
|
|
599
|
-
numTreeControls++;
|
|
600
|
-
}
|
|
601
|
-
if (this.childrenAccessor) {
|
|
602
|
-
numTreeControls++;
|
|
603
|
-
}
|
|
604
|
-
if (!numTreeControls) {
|
|
605
|
-
throw getTreeControlMissingError();
|
|
606
|
-
}
|
|
607
|
-
else if (numTreeControls > 1) {
|
|
608
|
-
throw getMultipleTreeControlsError();
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
/** Check for changes made in the data and render each change (node added/removed/moved). */
|
|
613
|
-
renderNodeChanges(data, dataDiffer = this._dataDiffer, viewContainer = this._nodeOutlet.viewContainer, parentData) {
|
|
614
|
-
const changes = dataDiffer.diff(data);
|
|
615
|
-
// Some tree consumers expect change detection to propagate to nodes
|
|
616
|
-
// even when the array itself hasn't changed; we explicitly detect changes
|
|
617
|
-
// anyways in order for nodes to update their data.
|
|
618
|
-
//
|
|
619
|
-
// However, if change detection is called while the component's view is
|
|
620
|
-
// still initing, then the order of child views initing will be incorrect;
|
|
621
|
-
// to prevent this, we only exit early if the view hasn't initialized yet.
|
|
622
|
-
if (!changes && !this._viewInit) {
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
changes?.forEachOperation((item, adjustedPreviousIndex, currentIndex) => {
|
|
626
|
-
if (item.previousIndex == null) {
|
|
627
|
-
this.insertNode(data[currentIndex], currentIndex, viewContainer, parentData);
|
|
628
|
-
}
|
|
629
|
-
else if (currentIndex == null) {
|
|
630
|
-
viewContainer.remove(adjustedPreviousIndex);
|
|
631
|
-
}
|
|
632
|
-
else {
|
|
633
|
-
const view = viewContainer.get(adjustedPreviousIndex);
|
|
634
|
-
viewContainer.move(view, currentIndex);
|
|
635
|
-
}
|
|
636
|
-
});
|
|
637
|
-
// If the data itself changes, but keeps the same trackBy, we need to update the templates'
|
|
638
|
-
// context to reflect the new object.
|
|
639
|
-
changes?.forEachIdentityChange((record) => {
|
|
640
|
-
const newData = record.item;
|
|
641
|
-
if (record.currentIndex != undefined) {
|
|
642
|
-
const view = viewContainer.get(record.currentIndex);
|
|
643
|
-
view.context.$implicit = newData;
|
|
644
|
-
}
|
|
355
|
+
}
|
|
356
|
+
_getRenderData(dataStream) {
|
|
357
|
+
const expansionModel = this._getExpansionModel();
|
|
358
|
+
return combineLatest([dataStream, this._nodeType, expansionModel.changed.pipe(startWith(null), tap(expansionChanges => {
|
|
359
|
+
this._emitExpansionChanges(expansionChanges);
|
|
360
|
+
}))]).pipe(switchMap(([data, nodeType]) => {
|
|
361
|
+
if (nodeType === null) {
|
|
362
|
+
return of({
|
|
363
|
+
renderNodes: data,
|
|
364
|
+
flattenedNodes: null,
|
|
365
|
+
nodeType
|
|
645
366
|
});
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
return !!(this.treeControl?.isExpanded(dataNode) ||
|
|
710
|
-
this._expansionModel?.isSelected(this._getExpansionKey(dataNode)));
|
|
711
|
-
}
|
|
712
|
-
/** If the data node is currently expanded, collapse it. Otherwise, expand it. */
|
|
713
|
-
toggle(dataNode) {
|
|
714
|
-
if (this.treeControl) {
|
|
715
|
-
this.treeControl.toggle(dataNode);
|
|
716
|
-
}
|
|
717
|
-
else if (this._expansionModel) {
|
|
718
|
-
this._expansionModel.toggle(this._getExpansionKey(dataNode));
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
/** Expand the data node. If it is already expanded, does nothing. */
|
|
722
|
-
expand(dataNode) {
|
|
723
|
-
if (this.treeControl) {
|
|
724
|
-
this.treeControl.expand(dataNode);
|
|
725
|
-
}
|
|
726
|
-
else if (this._expansionModel) {
|
|
727
|
-
this._expansionModel.select(this._getExpansionKey(dataNode));
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
/** Collapse the data node. If it is already collapsed, does nothing. */
|
|
731
|
-
collapse(dataNode) {
|
|
732
|
-
if (this.treeControl) {
|
|
733
|
-
this.treeControl.collapse(dataNode);
|
|
734
|
-
}
|
|
735
|
-
else if (this._expansionModel) {
|
|
736
|
-
this._expansionModel.deselect(this._getExpansionKey(dataNode));
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* If the data node is currently expanded, collapse it and all its descendants.
|
|
741
|
-
* Otherwise, expand it and all its descendants.
|
|
742
|
-
*/
|
|
743
|
-
toggleDescendants(dataNode) {
|
|
744
|
-
if (this.treeControl) {
|
|
745
|
-
this.treeControl.toggleDescendants(dataNode);
|
|
746
|
-
}
|
|
747
|
-
else if (this._expansionModel) {
|
|
748
|
-
if (this.isExpanded(dataNode)) {
|
|
749
|
-
this.collapseDescendants(dataNode);
|
|
750
|
-
}
|
|
751
|
-
else {
|
|
752
|
-
this.expandDescendants(dataNode);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
/**
|
|
757
|
-
* Expand the data node and all its descendants. If they are already expanded, does nothing.
|
|
758
|
-
*/
|
|
759
|
-
expandDescendants(dataNode) {
|
|
760
|
-
if (this.treeControl) {
|
|
761
|
-
this.treeControl.expandDescendants(dataNode);
|
|
762
|
-
}
|
|
763
|
-
else if (this._expansionModel) {
|
|
764
|
-
const expansionModel = this._expansionModel;
|
|
765
|
-
expansionModel.select(this._getExpansionKey(dataNode));
|
|
766
|
-
this._getDescendants(dataNode)
|
|
767
|
-
.pipe(take(1), takeUntil(this._onDestroy))
|
|
768
|
-
.subscribe(children => {
|
|
769
|
-
expansionModel.select(...children.map(child => this._getExpansionKey(child)));
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
/** Collapse the data node and all its descendants. If it is already collapsed, does nothing. */
|
|
774
|
-
collapseDescendants(dataNode) {
|
|
775
|
-
if (this.treeControl) {
|
|
776
|
-
this.treeControl.collapseDescendants(dataNode);
|
|
777
|
-
}
|
|
778
|
-
else if (this._expansionModel) {
|
|
779
|
-
const expansionModel = this._expansionModel;
|
|
780
|
-
expansionModel.deselect(this._getExpansionKey(dataNode));
|
|
781
|
-
this._getDescendants(dataNode)
|
|
782
|
-
.pipe(take(1), takeUntil(this._onDestroy))
|
|
783
|
-
.subscribe(children => {
|
|
784
|
-
expansionModel.deselect(...children.map(child => this._getExpansionKey(child)));
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
/** Expands all data nodes in the tree. */
|
|
789
|
-
expandAll() {
|
|
790
|
-
if (this.treeControl) {
|
|
791
|
-
this.treeControl.expandAll();
|
|
792
|
-
}
|
|
793
|
-
else if (this._expansionModel) {
|
|
794
|
-
this._forEachExpansionKey(keys => this._expansionModel?.select(...keys));
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
/** Collapse all data nodes in the tree. */
|
|
798
|
-
collapseAll() {
|
|
799
|
-
if (this.treeControl) {
|
|
800
|
-
this.treeControl.collapseAll();
|
|
801
|
-
}
|
|
802
|
-
else if (this._expansionModel) {
|
|
803
|
-
this._forEachExpansionKey(keys => this._expansionModel?.deselect(...keys));
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
/** Level accessor, used for compatibility between the old Tree and new Tree */
|
|
807
|
-
_getLevelAccessor() {
|
|
808
|
-
return this.treeControl?.getLevel?.bind(this.treeControl) ?? this.levelAccessor;
|
|
809
|
-
}
|
|
810
|
-
/** Children accessor, used for compatibility between the old Tree and new Tree */
|
|
811
|
-
_getChildrenAccessor() {
|
|
812
|
-
return this.treeControl?.getChildren?.bind(this.treeControl) ?? this.childrenAccessor;
|
|
813
|
-
}
|
|
814
|
-
/**
|
|
815
|
-
* Gets the direct children of a node; used for compatibility between the old tree and the
|
|
816
|
-
* new tree.
|
|
817
|
-
*/
|
|
818
|
-
_getDirectChildren(dataNode) {
|
|
819
|
-
const levelAccessor = this._getLevelAccessor();
|
|
820
|
-
const expansionModel = this._expansionModel ?? this.treeControl?.expansionModel;
|
|
821
|
-
if (!expansionModel) {
|
|
822
|
-
return of([]);
|
|
823
|
-
}
|
|
824
|
-
const key = this._getExpansionKey(dataNode);
|
|
825
|
-
const isExpanded = expansionModel.changed.pipe(switchMap(changes => {
|
|
826
|
-
if (changes.added.includes(key)) {
|
|
827
|
-
return of(true);
|
|
828
|
-
}
|
|
829
|
-
else if (changes.removed.includes(key)) {
|
|
830
|
-
return of(false);
|
|
831
|
-
}
|
|
832
|
-
return EMPTY;
|
|
833
|
-
}), startWith(this.isExpanded(dataNode)));
|
|
834
|
-
if (levelAccessor) {
|
|
835
|
-
return combineLatest([isExpanded, this._flattenedNodes]).pipe(map(([expanded, flattenedNodes]) => {
|
|
836
|
-
if (!expanded) {
|
|
837
|
-
return [];
|
|
838
|
-
}
|
|
839
|
-
return this._findChildrenByLevel(levelAccessor, flattenedNodes, dataNode, 1);
|
|
840
|
-
}));
|
|
841
|
-
}
|
|
842
|
-
const childrenAccessor = this._getChildrenAccessor();
|
|
843
|
-
if (childrenAccessor) {
|
|
844
|
-
return coerceObservable(childrenAccessor(dataNode) ?? []);
|
|
845
|
-
}
|
|
367
|
+
}
|
|
368
|
+
return this._computeRenderingData(data, nodeType).pipe(map(convertedData => ({
|
|
369
|
+
...convertedData,
|
|
370
|
+
nodeType
|
|
371
|
+
})));
|
|
372
|
+
}));
|
|
373
|
+
}
|
|
374
|
+
_renderDataChanges(data) {
|
|
375
|
+
if (data.nodeType === null) {
|
|
376
|
+
this.renderNodeChanges(data.renderNodes);
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
this._updateCachedData(data.flattenedNodes);
|
|
380
|
+
this.renderNodeChanges(data.renderNodes);
|
|
381
|
+
this._updateKeyManagerItems(data.flattenedNodes);
|
|
382
|
+
}
|
|
383
|
+
_emitExpansionChanges(expansionChanges) {
|
|
384
|
+
if (!expansionChanges) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
const nodes = this._nodes.value;
|
|
388
|
+
for (const added of expansionChanges.added) {
|
|
389
|
+
const node = nodes.get(added);
|
|
390
|
+
node?._emitExpansionState(true);
|
|
391
|
+
}
|
|
392
|
+
for (const removed of expansionChanges.removed) {
|
|
393
|
+
const node = nodes.get(removed);
|
|
394
|
+
node?._emitExpansionState(false);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
_initializeKeyManager() {
|
|
398
|
+
const items = combineLatest([this._keyManagerNodes, this._nodes]).pipe(map(([keyManagerNodes, renderNodes]) => keyManagerNodes.reduce((items, data) => {
|
|
399
|
+
const node = renderNodes.get(this._getExpansionKey(data));
|
|
400
|
+
if (node) {
|
|
401
|
+
items.push(node);
|
|
402
|
+
}
|
|
403
|
+
return items;
|
|
404
|
+
}, [])));
|
|
405
|
+
const keyManagerOptions = {
|
|
406
|
+
trackBy: node => this._getExpansionKey(node.data),
|
|
407
|
+
skipPredicate: node => !!node.isDisabled,
|
|
408
|
+
typeAheadDebounceInterval: true,
|
|
409
|
+
horizontalOrientation: this._dir.value
|
|
410
|
+
};
|
|
411
|
+
this._keyManager = this._keyManagerFactory(items, keyManagerOptions);
|
|
412
|
+
}
|
|
413
|
+
_initializeDataDiffer() {
|
|
414
|
+
const trackBy = this.trackBy ?? ((_index, item) => this._getExpansionKey(item));
|
|
415
|
+
this._dataDiffer = this._differs.find([]).create(trackBy);
|
|
416
|
+
}
|
|
417
|
+
_checkTreeControlUsage() {
|
|
418
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
419
|
+
let numTreeControls = 0;
|
|
420
|
+
if (this.treeControl) {
|
|
421
|
+
numTreeControls++;
|
|
422
|
+
}
|
|
423
|
+
if (this.levelAccessor) {
|
|
424
|
+
numTreeControls++;
|
|
425
|
+
}
|
|
426
|
+
if (this.childrenAccessor) {
|
|
427
|
+
numTreeControls++;
|
|
428
|
+
}
|
|
429
|
+
if (!numTreeControls) {
|
|
846
430
|
throw getTreeControlMissingError();
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
if (
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
|
|
431
|
+
} else if (numTreeControls > 1) {
|
|
432
|
+
throw getMultipleTreeControlsError();
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
renderNodeChanges(data, dataDiffer = this._dataDiffer, viewContainer = this._nodeOutlet.viewContainer, parentData) {
|
|
437
|
+
const changes = dataDiffer.diff(data);
|
|
438
|
+
if (!changes && !this._viewInit) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
changes?.forEachOperation((item, adjustedPreviousIndex, currentIndex) => {
|
|
442
|
+
if (item.previousIndex == null) {
|
|
443
|
+
this.insertNode(data[currentIndex], currentIndex, viewContainer, parentData);
|
|
444
|
+
} else if (currentIndex == null) {
|
|
445
|
+
viewContainer.remove(adjustedPreviousIndex);
|
|
446
|
+
} else {
|
|
447
|
+
const view = viewContainer.get(adjustedPreviousIndex);
|
|
448
|
+
viewContainer.move(view, currentIndex);
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
changes?.forEachIdentityChange(record => {
|
|
452
|
+
const newData = record.item;
|
|
453
|
+
if (record.currentIndex != undefined) {
|
|
454
|
+
const view = viewContainer.get(record.currentIndex);
|
|
455
|
+
view.context.$implicit = newData;
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
if (parentData) {
|
|
459
|
+
this._changeDetectorRef.markForCheck();
|
|
460
|
+
} else {
|
|
461
|
+
this._changeDetectorRef.detectChanges();
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
_getNodeDef(data, i) {
|
|
465
|
+
if (this._nodeDefs.length === 1) {
|
|
466
|
+
return this._nodeDefs.first;
|
|
467
|
+
}
|
|
468
|
+
const nodeDef = this._nodeDefs.find(def => def.when && def.when(i, data)) || this._defaultNodeDef;
|
|
469
|
+
if (!nodeDef && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
470
|
+
throw getTreeMissingMatchingNodeDefError();
|
|
471
|
+
}
|
|
472
|
+
return nodeDef;
|
|
473
|
+
}
|
|
474
|
+
insertNode(nodeData, index, viewContainer, parentData) {
|
|
475
|
+
const levelAccessor = this._getLevelAccessor();
|
|
476
|
+
const node = this._getNodeDef(nodeData, index);
|
|
477
|
+
const key = this._getExpansionKey(nodeData);
|
|
478
|
+
const context = new CdkTreeNodeOutletContext(nodeData);
|
|
479
|
+
context.index = index;
|
|
480
|
+
parentData ??= this._parents.get(key) ?? undefined;
|
|
481
|
+
if (levelAccessor) {
|
|
482
|
+
context.level = levelAccessor(nodeData);
|
|
483
|
+
} else if (parentData !== undefined && this._levels.has(this._getExpansionKey(parentData))) {
|
|
484
|
+
context.level = this._levels.get(this._getExpansionKey(parentData)) + 1;
|
|
485
|
+
} else {
|
|
486
|
+
context.level = 0;
|
|
487
|
+
}
|
|
488
|
+
this._levels.set(key, context.level);
|
|
489
|
+
const container = viewContainer ? viewContainer : this._nodeOutlet.viewContainer;
|
|
490
|
+
container.createEmbeddedView(node.template, context, index);
|
|
491
|
+
if (CdkTreeNode.mostRecentTreeNode) {
|
|
492
|
+
CdkTreeNode.mostRecentTreeNode.data = nodeData;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
isExpanded(dataNode) {
|
|
496
|
+
return !!(this.treeControl?.isExpanded(dataNode) || this._expansionModel?.isSelected(this._getExpansionKey(dataNode)));
|
|
497
|
+
}
|
|
498
|
+
toggle(dataNode) {
|
|
499
|
+
if (this.treeControl) {
|
|
500
|
+
this.treeControl.toggle(dataNode);
|
|
501
|
+
} else if (this._expansionModel) {
|
|
502
|
+
this._expansionModel.toggle(this._getExpansionKey(dataNode));
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
expand(dataNode) {
|
|
506
|
+
if (this.treeControl) {
|
|
507
|
+
this.treeControl.expand(dataNode);
|
|
508
|
+
} else if (this._expansionModel) {
|
|
509
|
+
this._expansionModel.select(this._getExpansionKey(dataNode));
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
collapse(dataNode) {
|
|
513
|
+
if (this.treeControl) {
|
|
514
|
+
this.treeControl.collapse(dataNode);
|
|
515
|
+
} else if (this._expansionModel) {
|
|
516
|
+
this._expansionModel.deselect(this._getExpansionKey(dataNode));
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
toggleDescendants(dataNode) {
|
|
520
|
+
if (this.treeControl) {
|
|
521
|
+
this.treeControl.toggleDescendants(dataNode);
|
|
522
|
+
} else if (this._expansionModel) {
|
|
523
|
+
if (this.isExpanded(dataNode)) {
|
|
524
|
+
this.collapseDescendants(dataNode);
|
|
525
|
+
} else {
|
|
526
|
+
this.expandDescendants(dataNode);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
expandDescendants(dataNode) {
|
|
531
|
+
if (this.treeControl) {
|
|
532
|
+
this.treeControl.expandDescendants(dataNode);
|
|
533
|
+
} else if (this._expansionModel) {
|
|
534
|
+
const expansionModel = this._expansionModel;
|
|
535
|
+
expansionModel.select(this._getExpansionKey(dataNode));
|
|
536
|
+
this._getDescendants(dataNode).pipe(take(1), takeUntil(this._onDestroy)).subscribe(children => {
|
|
537
|
+
expansionModel.select(...children.map(child => this._getExpansionKey(child)));
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
collapseDescendants(dataNode) {
|
|
542
|
+
if (this.treeControl) {
|
|
543
|
+
this.treeControl.collapseDescendants(dataNode);
|
|
544
|
+
} else if (this._expansionModel) {
|
|
545
|
+
const expansionModel = this._expansionModel;
|
|
546
|
+
expansionModel.deselect(this._getExpansionKey(dataNode));
|
|
547
|
+
this._getDescendants(dataNode).pipe(take(1), takeUntil(this._onDestroy)).subscribe(children => {
|
|
548
|
+
expansionModel.deselect(...children.map(child => this._getExpansionKey(child)));
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
expandAll() {
|
|
553
|
+
if (this.treeControl) {
|
|
554
|
+
this.treeControl.expandAll();
|
|
555
|
+
} else if (this._expansionModel) {
|
|
556
|
+
this._forEachExpansionKey(keys => this._expansionModel?.select(...keys));
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
collapseAll() {
|
|
560
|
+
if (this.treeControl) {
|
|
561
|
+
this.treeControl.collapseAll();
|
|
562
|
+
} else if (this._expansionModel) {
|
|
563
|
+
this._forEachExpansionKey(keys => this._expansionModel?.deselect(...keys));
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
_getLevelAccessor() {
|
|
567
|
+
return this.treeControl?.getLevel?.bind(this.treeControl) ?? this.levelAccessor;
|
|
568
|
+
}
|
|
569
|
+
_getChildrenAccessor() {
|
|
570
|
+
return this.treeControl?.getChildren?.bind(this.treeControl) ?? this.childrenAccessor;
|
|
571
|
+
}
|
|
572
|
+
_getDirectChildren(dataNode) {
|
|
573
|
+
const levelAccessor = this._getLevelAccessor();
|
|
574
|
+
const expansionModel = this._expansionModel ?? this.treeControl?.expansionModel;
|
|
575
|
+
if (!expansionModel) {
|
|
576
|
+
return of([]);
|
|
577
|
+
}
|
|
578
|
+
const key = this._getExpansionKey(dataNode);
|
|
579
|
+
const isExpanded = expansionModel.changed.pipe(switchMap(changes => {
|
|
580
|
+
if (changes.added.includes(key)) {
|
|
581
|
+
return of(true);
|
|
582
|
+
} else if (changes.removed.includes(key)) {
|
|
583
|
+
return of(false);
|
|
584
|
+
}
|
|
585
|
+
return EMPTY;
|
|
586
|
+
}), startWith(this.isExpanded(dataNode)));
|
|
587
|
+
if (levelAccessor) {
|
|
588
|
+
return combineLatest([isExpanded, this._flattenedNodes]).pipe(map(([expanded, flattenedNodes]) => {
|
|
589
|
+
if (!expanded) {
|
|
590
|
+
return [];
|
|
591
|
+
}
|
|
592
|
+
return this._findChildrenByLevel(levelAccessor, flattenedNodes, dataNode, 1);
|
|
593
|
+
}));
|
|
594
|
+
}
|
|
595
|
+
const childrenAccessor = this._getChildrenAccessor();
|
|
596
|
+
if (childrenAccessor) {
|
|
597
|
+
return coerceObservable(childrenAccessor(dataNode) ?? []);
|
|
598
|
+
}
|
|
599
|
+
throw getTreeControlMissingError();
|
|
600
|
+
}
|
|
601
|
+
_findChildrenByLevel(levelAccessor, flattenedNodes, dataNode, levelDelta) {
|
|
602
|
+
const key = this._getExpansionKey(dataNode);
|
|
603
|
+
const startIndex = flattenedNodes.findIndex(node => this._getExpansionKey(node) === key);
|
|
604
|
+
const dataNodeLevel = levelAccessor(dataNode);
|
|
605
|
+
const expectedLevel = dataNodeLevel + levelDelta;
|
|
606
|
+
const results = [];
|
|
607
|
+
for (let i = startIndex + 1; i < flattenedNodes.length; i++) {
|
|
608
|
+
const currentLevel = levelAccessor(flattenedNodes[i]);
|
|
609
|
+
if (currentLevel <= dataNodeLevel) {
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
if (currentLevel <= expectedLevel) {
|
|
613
|
+
results.push(flattenedNodes[i]);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
return results;
|
|
617
|
+
}
|
|
618
|
+
_registerNode(node) {
|
|
619
|
+
this._nodes.value.set(this._getExpansionKey(node.data), node);
|
|
620
|
+
this._nodes.next(this._nodes.value);
|
|
621
|
+
}
|
|
622
|
+
_unregisterNode(node) {
|
|
623
|
+
this._nodes.value.delete(this._getExpansionKey(node.data));
|
|
624
|
+
this._nodes.next(this._nodes.value);
|
|
625
|
+
}
|
|
626
|
+
_getLevel(node) {
|
|
627
|
+
return this._levels.get(this._getExpansionKey(node));
|
|
628
|
+
}
|
|
629
|
+
_getSetSize(dataNode) {
|
|
630
|
+
const set = this._getAriaSet(dataNode);
|
|
631
|
+
return set.length;
|
|
632
|
+
}
|
|
633
|
+
_getPositionInSet(dataNode) {
|
|
634
|
+
const set = this._getAriaSet(dataNode);
|
|
635
|
+
const key = this._getExpansionKey(dataNode);
|
|
636
|
+
return set.findIndex(node => this._getExpansionKey(node) === key) + 1;
|
|
637
|
+
}
|
|
638
|
+
_getNodeParent(node) {
|
|
639
|
+
const parent = this._parents.get(this._getExpansionKey(node.data));
|
|
640
|
+
return parent && this._nodes.value.get(this._getExpansionKey(parent));
|
|
641
|
+
}
|
|
642
|
+
_getNodeChildren(node) {
|
|
643
|
+
return this._getDirectChildren(node.data).pipe(map(children => children.reduce((nodes, child) => {
|
|
644
|
+
const value = this._nodes.value.get(this._getExpansionKey(child));
|
|
645
|
+
if (value) {
|
|
646
|
+
nodes.push(value);
|
|
647
|
+
}
|
|
648
|
+
return nodes;
|
|
649
|
+
}, [])));
|
|
650
|
+
}
|
|
651
|
+
_sendKeydownToKeyManager(event) {
|
|
652
|
+
if (event.target === this._elementRef.nativeElement) {
|
|
653
|
+
this._keyManager.onKeydown(event);
|
|
654
|
+
} else {
|
|
655
|
+
const nodes = this._nodes.getValue();
|
|
656
|
+
for (const [, node] of nodes) {
|
|
657
|
+
if (event.target === node._elementRef.nativeElement) {
|
|
658
|
+
this._keyManager.onKeydown(event);
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
_getDescendants(dataNode) {
|
|
665
|
+
if (this.treeControl) {
|
|
666
|
+
return of(this.treeControl.getDescendants(dataNode));
|
|
667
|
+
}
|
|
668
|
+
if (this.levelAccessor) {
|
|
669
|
+
const results = this._findChildrenByLevel(this.levelAccessor, this._flattenedNodes.value, dataNode, Infinity);
|
|
670
|
+
return of(results);
|
|
671
|
+
}
|
|
672
|
+
if (this.childrenAccessor) {
|
|
673
|
+
return this._getAllChildrenRecursively(dataNode).pipe(reduce((allChildren, nextChildren) => {
|
|
674
|
+
allChildren.push(...nextChildren);
|
|
675
|
+
return allChildren;
|
|
676
|
+
}, []));
|
|
677
|
+
}
|
|
678
|
+
throw getTreeControlMissingError();
|
|
679
|
+
}
|
|
680
|
+
_getAllChildrenRecursively(dataNode) {
|
|
681
|
+
if (!this.childrenAccessor) {
|
|
682
|
+
return of([]);
|
|
683
|
+
}
|
|
684
|
+
return coerceObservable(this.childrenAccessor(dataNode)).pipe(take(1), switchMap(children => {
|
|
685
|
+
for (const child of children) {
|
|
686
|
+
this._parents.set(this._getExpansionKey(child), dataNode);
|
|
687
|
+
}
|
|
688
|
+
return of(...children).pipe(concatMap(child => concat(of([child]), this._getAllChildrenRecursively(child))));
|
|
689
|
+
}));
|
|
690
|
+
}
|
|
691
|
+
_getExpansionKey(dataNode) {
|
|
692
|
+
return this.expansionKey?.(dataNode) ?? dataNode;
|
|
693
|
+
}
|
|
694
|
+
_getAriaSet(node) {
|
|
695
|
+
const key = this._getExpansionKey(node);
|
|
696
|
+
const parent = this._parents.get(key);
|
|
697
|
+
const parentKey = parent ? this._getExpansionKey(parent) : null;
|
|
698
|
+
const set = this._ariaSets.get(parentKey);
|
|
699
|
+
return set ?? [node];
|
|
700
|
+
}
|
|
701
|
+
_findParentForNode(node, index, cachedNodes) {
|
|
702
|
+
if (!cachedNodes.length) {
|
|
703
|
+
return null;
|
|
704
|
+
}
|
|
705
|
+
const currentLevel = this._levels.get(this._getExpansionKey(node)) ?? 0;
|
|
706
|
+
for (let parentIndex = index - 1; parentIndex >= 0; parentIndex--) {
|
|
707
|
+
const parentNode = cachedNodes[parentIndex];
|
|
708
|
+
const parentLevel = this._levels.get(this._getExpansionKey(parentNode)) ?? 0;
|
|
709
|
+
if (parentLevel < currentLevel) {
|
|
710
|
+
return parentNode;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return null;
|
|
714
|
+
}
|
|
715
|
+
_flattenNestedNodesWithExpansion(nodes, level = 0) {
|
|
716
|
+
const childrenAccessor = this._getChildrenAccessor();
|
|
717
|
+
if (!childrenAccessor) {
|
|
718
|
+
return of([...nodes]);
|
|
719
|
+
}
|
|
720
|
+
return of(...nodes).pipe(concatMap(node => {
|
|
721
|
+
const parentKey = this._getExpansionKey(node);
|
|
722
|
+
if (!this._parents.has(parentKey)) {
|
|
723
|
+
this._parents.set(parentKey, null);
|
|
724
|
+
}
|
|
725
|
+
this._levels.set(parentKey, level);
|
|
726
|
+
const children = coerceObservable(childrenAccessor(node));
|
|
727
|
+
return concat(of([node]), children.pipe(take(1), tap(childNodes => {
|
|
728
|
+
this._ariaSets.set(parentKey, [...(childNodes ?? [])]);
|
|
729
|
+
for (const child of childNodes ?? []) {
|
|
730
|
+
const childKey = this._getExpansionKey(child);
|
|
731
|
+
this._parents.set(childKey, node);
|
|
732
|
+
this._levels.set(childKey, level + 1);
|
|
733
|
+
}
|
|
734
|
+
}), switchMap(childNodes => {
|
|
735
|
+
if (!childNodes) {
|
|
736
|
+
return of([]);
|
|
737
|
+
}
|
|
738
|
+
return this._flattenNestedNodesWithExpansion(childNodes, level + 1).pipe(map(nestedNodes => this.isExpanded(node) ? nestedNodes : []));
|
|
739
|
+
})));
|
|
740
|
+
}), reduce((results, children) => {
|
|
741
|
+
results.push(...children);
|
|
742
|
+
return results;
|
|
743
|
+
}, []));
|
|
744
|
+
}
|
|
745
|
+
_computeRenderingData(nodes, nodeType) {
|
|
746
|
+
if (this.childrenAccessor && nodeType === 'flat') {
|
|
747
|
+
this._clearPreviousCache();
|
|
748
|
+
this._ariaSets.set(null, [...nodes]);
|
|
749
|
+
return this._flattenNestedNodesWithExpansion(nodes).pipe(map(flattenedNodes => ({
|
|
750
|
+
renderNodes: flattenedNodes,
|
|
751
|
+
flattenedNodes
|
|
752
|
+
})));
|
|
753
|
+
} else if (this.levelAccessor && nodeType === 'nested') {
|
|
754
|
+
const levelAccessor = this.levelAccessor;
|
|
755
|
+
return of(nodes.filter(node => levelAccessor(node) === 0)).pipe(map(rootNodes => ({
|
|
756
|
+
renderNodes: rootNodes,
|
|
757
|
+
flattenedNodes: nodes
|
|
758
|
+
})), tap(({
|
|
759
|
+
flattenedNodes
|
|
760
|
+
}) => {
|
|
761
|
+
this._calculateParents(flattenedNodes);
|
|
762
|
+
}));
|
|
763
|
+
} else if (nodeType === 'flat') {
|
|
764
|
+
return of({
|
|
765
|
+
renderNodes: nodes,
|
|
766
|
+
flattenedNodes: nodes
|
|
767
|
+
}).pipe(tap(({
|
|
768
|
+
flattenedNodes
|
|
769
|
+
}) => {
|
|
770
|
+
this._calculateParents(flattenedNodes);
|
|
771
|
+
}));
|
|
772
|
+
} else {
|
|
773
|
+
this._clearPreviousCache();
|
|
774
|
+
this._ariaSets.set(null, [...nodes]);
|
|
775
|
+
return this._flattenNestedNodesWithExpansion(nodes).pipe(map(flattenedNodes => ({
|
|
776
|
+
renderNodes: nodes,
|
|
777
|
+
flattenedNodes
|
|
778
|
+
})));
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
_updateCachedData(flattenedNodes) {
|
|
782
|
+
this._flattenedNodes.next(flattenedNodes);
|
|
783
|
+
}
|
|
784
|
+
_updateKeyManagerItems(flattenedNodes) {
|
|
785
|
+
this._keyManagerNodes.next(flattenedNodes);
|
|
786
|
+
}
|
|
787
|
+
_calculateParents(flattenedNodes) {
|
|
788
|
+
const levelAccessor = this._getLevelAccessor();
|
|
789
|
+
if (!levelAccessor) {
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
this._clearPreviousCache();
|
|
793
|
+
for (let index = 0; index < flattenedNodes.length; index++) {
|
|
794
|
+
const dataNode = flattenedNodes[index];
|
|
795
|
+
const key = this._getExpansionKey(dataNode);
|
|
796
|
+
this._levels.set(key, levelAccessor(dataNode));
|
|
797
|
+
const parent = this._findParentForNode(dataNode, index, flattenedNodes);
|
|
798
|
+
this._parents.set(key, parent);
|
|
799
|
+
const parentKey = parent ? this._getExpansionKey(parent) : null;
|
|
800
|
+
const group = this._ariaSets.get(parentKey) ?? [];
|
|
801
|
+
group.splice(index, 0, dataNode);
|
|
802
|
+
this._ariaSets.set(parentKey, group);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
_forEachExpansionKey(callback) {
|
|
806
|
+
const toToggle = [];
|
|
807
|
+
const observables = [];
|
|
808
|
+
this._nodes.value.forEach(node => {
|
|
809
|
+
toToggle.push(this._getExpansionKey(node.data));
|
|
810
|
+
observables.push(this._getDescendants(node.data));
|
|
811
|
+
});
|
|
812
|
+
if (observables.length > 0) {
|
|
813
|
+
combineLatest(observables).pipe(take(1), takeUntil(this._onDestroy)).subscribe(results => {
|
|
814
|
+
results.forEach(inner => inner.forEach(r => toToggle.push(this._getExpansionKey(r))));
|
|
815
|
+
callback(toToggle);
|
|
816
|
+
});
|
|
817
|
+
} else {
|
|
818
|
+
callback(toToggle);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
_clearPreviousCache() {
|
|
822
|
+
this._parents.clear();
|
|
823
|
+
this._levels.clear();
|
|
824
|
+
this._ariaSets.clear();
|
|
825
|
+
}
|
|
826
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
827
|
+
minVersion: "12.0.0",
|
|
828
|
+
version: "20.2.0-next.2",
|
|
829
|
+
ngImport: i0,
|
|
830
|
+
type: CdkTree,
|
|
831
|
+
deps: [],
|
|
832
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
833
|
+
});
|
|
834
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
835
|
+
minVersion: "14.0.0",
|
|
836
|
+
version: "20.2.0-next.2",
|
|
837
|
+
type: CdkTree,
|
|
838
|
+
isStandalone: true,
|
|
839
|
+
selector: "cdk-tree",
|
|
840
|
+
inputs: {
|
|
841
|
+
dataSource: "dataSource",
|
|
842
|
+
treeControl: "treeControl",
|
|
843
|
+
levelAccessor: "levelAccessor",
|
|
844
|
+
childrenAccessor: "childrenAccessor",
|
|
845
|
+
trackBy: "trackBy",
|
|
846
|
+
expansionKey: "expansionKey"
|
|
847
|
+
},
|
|
848
|
+
host: {
|
|
849
|
+
attributes: {
|
|
850
|
+
"role": "tree"
|
|
851
|
+
},
|
|
852
|
+
listeners: {
|
|
853
|
+
"keydown": "_sendKeydownToKeyManager($event)"
|
|
854
|
+
},
|
|
855
|
+
classAttribute: "cdk-tree"
|
|
856
|
+
},
|
|
857
|
+
queries: [{
|
|
858
|
+
propertyName: "_nodeDefs",
|
|
859
|
+
predicate: CdkTreeNodeDef,
|
|
860
|
+
descendants: true
|
|
861
|
+
}],
|
|
862
|
+
viewQueries: [{
|
|
863
|
+
propertyName: "_nodeOutlet",
|
|
864
|
+
first: true,
|
|
865
|
+
predicate: CdkTreeNodeOutlet,
|
|
866
|
+
descendants: true,
|
|
867
|
+
static: true
|
|
868
|
+
}],
|
|
869
|
+
exportAs: ["cdkTree"],
|
|
870
|
+
ngImport: i0,
|
|
871
|
+
template: `<ng-container cdkTreeNodeOutlet></ng-container>`,
|
|
872
|
+
isInline: true,
|
|
873
|
+
dependencies: [{
|
|
874
|
+
kind: "directive",
|
|
875
|
+
type: CdkTreeNodeOutlet,
|
|
876
|
+
selector: "[cdkTreeNodeOutlet]"
|
|
877
|
+
}],
|
|
878
|
+
changeDetection: i0.ChangeDetectionStrategy.Default,
|
|
879
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
880
|
+
});
|
|
1172
881
|
}
|
|
1173
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
882
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
883
|
+
minVersion: "12.0.0",
|
|
884
|
+
version: "20.2.0-next.2",
|
|
885
|
+
ngImport: i0,
|
|
886
|
+
type: CdkTree,
|
|
887
|
+
decorators: [{
|
|
888
|
+
type: Component,
|
|
889
|
+
args: [{
|
|
890
|
+
selector: 'cdk-tree',
|
|
891
|
+
exportAs: 'cdkTree',
|
|
892
|
+
template: `<ng-container cdkTreeNodeOutlet></ng-container>`,
|
|
893
|
+
host: {
|
|
894
|
+
'class': 'cdk-tree',
|
|
895
|
+
'role': 'tree',
|
|
896
|
+
'(keydown)': '_sendKeydownToKeyManager($event)'
|
|
897
|
+
},
|
|
898
|
+
encapsulation: ViewEncapsulation.None,
|
|
899
|
+
changeDetection: ChangeDetectionStrategy.Default,
|
|
900
|
+
imports: [CdkTreeNodeOutlet]
|
|
901
|
+
}]
|
|
902
|
+
}],
|
|
903
|
+
ctorParameters: () => [],
|
|
904
|
+
propDecorators: {
|
|
905
|
+
dataSource: [{
|
|
906
|
+
type: Input
|
|
907
|
+
}],
|
|
908
|
+
treeControl: [{
|
|
909
|
+
type: Input
|
|
910
|
+
}],
|
|
911
|
+
levelAccessor: [{
|
|
912
|
+
type: Input
|
|
913
|
+
}],
|
|
914
|
+
childrenAccessor: [{
|
|
915
|
+
type: Input
|
|
916
|
+
}],
|
|
917
|
+
trackBy: [{
|
|
918
|
+
type: Input
|
|
919
|
+
}],
|
|
920
|
+
expansionKey: [{
|
|
921
|
+
type: Input
|
|
922
|
+
}],
|
|
923
|
+
_nodeOutlet: [{
|
|
924
|
+
type: ViewChild,
|
|
925
|
+
args: [CdkTreeNodeOutlet, {
|
|
926
|
+
static: true
|
|
927
|
+
}]
|
|
928
|
+
}],
|
|
929
|
+
_nodeDefs: [{
|
|
930
|
+
type: ContentChildren,
|
|
931
|
+
args: [CdkTreeNodeDef, {
|
|
932
|
+
descendants: true
|
|
933
|
+
}]
|
|
934
|
+
}]
|
|
935
|
+
}
|
|
936
|
+
});
|
|
1218
937
|
class CdkTreeNode {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
* in `CdkTree` and set the data to it.
|
|
1291
|
-
*/
|
|
1292
|
-
static mostRecentTreeNode = null;
|
|
1293
|
-
/** Subject that emits when the component has been destroyed. */
|
|
1294
|
-
_destroyed = new Subject();
|
|
1295
|
-
/** Emits when the node's data has changed. */
|
|
1296
|
-
_dataChanges = new Subject();
|
|
1297
|
-
_inputIsExpandable = false;
|
|
1298
|
-
_inputIsExpanded = undefined;
|
|
1299
|
-
/**
|
|
1300
|
-
* Flag used to determine whether or not we should be focusing the actual element based on
|
|
1301
|
-
* some user interaction (click or focus). On click, we don't forcibly focus the element
|
|
1302
|
-
* since the click could trigger some other component that wants to grab its own focus
|
|
1303
|
-
* (e.g. menu, dialog).
|
|
1304
|
-
*/
|
|
1305
|
-
_shouldFocus = true;
|
|
1306
|
-
_parentNodeAriaLevel;
|
|
1307
|
-
/** The tree node's data. */
|
|
1308
|
-
get data() {
|
|
1309
|
-
return this._data;
|
|
1310
|
-
}
|
|
1311
|
-
set data(value) {
|
|
1312
|
-
if (value !== this._data) {
|
|
1313
|
-
this._data = value;
|
|
1314
|
-
this._dataChanges.next();
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1317
|
-
_data;
|
|
1318
|
-
/* If leaf node, return true to not assign aria-expanded attribute */
|
|
1319
|
-
get isLeafNode() {
|
|
1320
|
-
// If flat tree node data returns false for expandable property, it's a leaf node
|
|
1321
|
-
if (this._tree.treeControl?.isExpandable !== undefined &&
|
|
1322
|
-
!this._tree.treeControl.isExpandable(this._data)) {
|
|
1323
|
-
return true;
|
|
1324
|
-
// If nested tree node data returns 0 descendants, it's a leaf node
|
|
1325
|
-
}
|
|
1326
|
-
else if (this._tree.treeControl?.isExpandable === undefined &&
|
|
1327
|
-
this._tree.treeControl?.getDescendants(this._data).length === 0) {
|
|
1328
|
-
return true;
|
|
1329
|
-
}
|
|
938
|
+
_elementRef = inject(ElementRef);
|
|
939
|
+
_tree = inject(CdkTree);
|
|
940
|
+
_tabindex = -1;
|
|
941
|
+
_type = 'flat';
|
|
942
|
+
get role() {
|
|
943
|
+
return 'treeitem';
|
|
944
|
+
}
|
|
945
|
+
set role(_role) {}
|
|
946
|
+
get isExpandable() {
|
|
947
|
+
return this._isExpandable();
|
|
948
|
+
}
|
|
949
|
+
set isExpandable(isExpandable) {
|
|
950
|
+
this._inputIsExpandable = isExpandable;
|
|
951
|
+
if (this.data && !this._isExpandable || !this._inputIsExpandable) {
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
if (this._inputIsExpanded) {
|
|
955
|
+
this.expand();
|
|
956
|
+
} else if (this._inputIsExpanded === false) {
|
|
957
|
+
this.collapse();
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
get isExpanded() {
|
|
961
|
+
return this._tree.isExpanded(this._data);
|
|
962
|
+
}
|
|
963
|
+
set isExpanded(isExpanded) {
|
|
964
|
+
this._inputIsExpanded = isExpanded;
|
|
965
|
+
if (isExpanded) {
|
|
966
|
+
this.expand();
|
|
967
|
+
} else {
|
|
968
|
+
this.collapse();
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
isDisabled;
|
|
972
|
+
typeaheadLabel;
|
|
973
|
+
getLabel() {
|
|
974
|
+
return this.typeaheadLabel || this._elementRef.nativeElement.textContent?.trim() || '';
|
|
975
|
+
}
|
|
976
|
+
activation = new EventEmitter();
|
|
977
|
+
expandedChange = new EventEmitter();
|
|
978
|
+
static mostRecentTreeNode = null;
|
|
979
|
+
_destroyed = new Subject();
|
|
980
|
+
_dataChanges = new Subject();
|
|
981
|
+
_inputIsExpandable = false;
|
|
982
|
+
_inputIsExpanded = undefined;
|
|
983
|
+
_shouldFocus = true;
|
|
984
|
+
_parentNodeAriaLevel;
|
|
985
|
+
get data() {
|
|
986
|
+
return this._data;
|
|
987
|
+
}
|
|
988
|
+
set data(value) {
|
|
989
|
+
if (value !== this._data) {
|
|
990
|
+
this._data = value;
|
|
991
|
+
this._dataChanges.next();
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
_data;
|
|
995
|
+
get isLeafNode() {
|
|
996
|
+
if (this._tree.treeControl?.isExpandable !== undefined && !this._tree.treeControl.isExpandable(this._data)) {
|
|
997
|
+
return true;
|
|
998
|
+
} else if (this._tree.treeControl?.isExpandable === undefined && this._tree.treeControl?.getDescendants(this._data).length === 0) {
|
|
999
|
+
return true;
|
|
1000
|
+
}
|
|
1001
|
+
return false;
|
|
1002
|
+
}
|
|
1003
|
+
get level() {
|
|
1004
|
+
return this._tree._getLevel(this._data) ?? this._parentNodeAriaLevel;
|
|
1005
|
+
}
|
|
1006
|
+
_isExpandable() {
|
|
1007
|
+
if (this._tree.treeControl) {
|
|
1008
|
+
if (this.isLeafNode) {
|
|
1330
1009
|
return false;
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
}
|
|
1377
|
-
_changeDetectorRef
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1010
|
+
}
|
|
1011
|
+
return true;
|
|
1012
|
+
}
|
|
1013
|
+
return this._inputIsExpandable;
|
|
1014
|
+
}
|
|
1015
|
+
_getAriaExpanded() {
|
|
1016
|
+
if (!this._isExpandable()) {
|
|
1017
|
+
return null;
|
|
1018
|
+
}
|
|
1019
|
+
return String(this.isExpanded);
|
|
1020
|
+
}
|
|
1021
|
+
_getSetSize() {
|
|
1022
|
+
return this._tree._getSetSize(this._data);
|
|
1023
|
+
}
|
|
1024
|
+
_getPositionInSet() {
|
|
1025
|
+
return this._tree._getPositionInSet(this._data);
|
|
1026
|
+
}
|
|
1027
|
+
_changeDetectorRef = inject(ChangeDetectorRef);
|
|
1028
|
+
constructor() {
|
|
1029
|
+
CdkTreeNode.mostRecentTreeNode = this;
|
|
1030
|
+
}
|
|
1031
|
+
ngOnInit() {
|
|
1032
|
+
this._parentNodeAriaLevel = getParentNodeAriaLevel(this._elementRef.nativeElement);
|
|
1033
|
+
this._tree._getExpansionModel().changed.pipe(map(() => this.isExpanded), distinctUntilChanged(), takeUntil(this._destroyed)).pipe(takeUntil(this._destroyed)).subscribe(() => this._changeDetectorRef.markForCheck());
|
|
1034
|
+
this._tree._setNodeTypeIfUnset(this._type);
|
|
1035
|
+
this._tree._registerNode(this);
|
|
1036
|
+
}
|
|
1037
|
+
ngOnDestroy() {
|
|
1038
|
+
if (CdkTreeNode.mostRecentTreeNode === this) {
|
|
1039
|
+
CdkTreeNode.mostRecentTreeNode = null;
|
|
1040
|
+
}
|
|
1041
|
+
this._dataChanges.complete();
|
|
1042
|
+
this._destroyed.next();
|
|
1043
|
+
this._destroyed.complete();
|
|
1044
|
+
}
|
|
1045
|
+
getParent() {
|
|
1046
|
+
return this._tree._getNodeParent(this) ?? null;
|
|
1047
|
+
}
|
|
1048
|
+
getChildren() {
|
|
1049
|
+
return this._tree._getNodeChildren(this);
|
|
1050
|
+
}
|
|
1051
|
+
focus() {
|
|
1052
|
+
this._tabindex = 0;
|
|
1053
|
+
if (this._shouldFocus) {
|
|
1054
|
+
this._elementRef.nativeElement.focus();
|
|
1055
|
+
}
|
|
1056
|
+
this._changeDetectorRef.markForCheck();
|
|
1057
|
+
}
|
|
1058
|
+
unfocus() {
|
|
1059
|
+
this._tabindex = -1;
|
|
1060
|
+
this._changeDetectorRef.markForCheck();
|
|
1061
|
+
}
|
|
1062
|
+
activate() {
|
|
1063
|
+
if (this.isDisabled) {
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
this.activation.next(this._data);
|
|
1067
|
+
}
|
|
1068
|
+
collapse() {
|
|
1069
|
+
if (this.isExpandable) {
|
|
1070
|
+
this._tree.collapse(this._data);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
expand() {
|
|
1074
|
+
if (this.isExpandable) {
|
|
1075
|
+
this._tree.expand(this._data);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
makeFocusable() {
|
|
1079
|
+
this._tabindex = 0;
|
|
1080
|
+
this._changeDetectorRef.markForCheck();
|
|
1081
|
+
}
|
|
1082
|
+
_focusItem() {
|
|
1083
|
+
if (this.isDisabled) {
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
this._tree._keyManager.focusItem(this);
|
|
1087
|
+
}
|
|
1088
|
+
_setActiveItem() {
|
|
1089
|
+
if (this.isDisabled) {
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
this._shouldFocus = false;
|
|
1093
|
+
this._tree._keyManager.focusItem(this);
|
|
1094
|
+
this._shouldFocus = true;
|
|
1095
|
+
}
|
|
1096
|
+
_emitExpansionState(expanded) {
|
|
1097
|
+
this.expandedChange.emit(expanded);
|
|
1098
|
+
}
|
|
1099
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1100
|
+
minVersion: "12.0.0",
|
|
1101
|
+
version: "20.2.0-next.2",
|
|
1102
|
+
ngImport: i0,
|
|
1103
|
+
type: CdkTreeNode,
|
|
1104
|
+
deps: [],
|
|
1105
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
1106
|
+
});
|
|
1107
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
1108
|
+
minVersion: "16.1.0",
|
|
1109
|
+
version: "20.2.0-next.2",
|
|
1110
|
+
type: CdkTreeNode,
|
|
1111
|
+
isStandalone: true,
|
|
1112
|
+
selector: "cdk-tree-node",
|
|
1113
|
+
inputs: {
|
|
1114
|
+
role: "role",
|
|
1115
|
+
isExpandable: ["isExpandable", "isExpandable", booleanAttribute],
|
|
1116
|
+
isExpanded: "isExpanded",
|
|
1117
|
+
isDisabled: ["isDisabled", "isDisabled", booleanAttribute],
|
|
1118
|
+
typeaheadLabel: ["cdkTreeNodeTypeaheadLabel", "typeaheadLabel"]
|
|
1119
|
+
},
|
|
1120
|
+
outputs: {
|
|
1121
|
+
activation: "activation",
|
|
1122
|
+
expandedChange: "expandedChange"
|
|
1123
|
+
},
|
|
1124
|
+
host: {
|
|
1125
|
+
attributes: {
|
|
1126
|
+
"role": "treeitem"
|
|
1127
|
+
},
|
|
1128
|
+
listeners: {
|
|
1129
|
+
"click": "_setActiveItem()",
|
|
1130
|
+
"focus": "_focusItem()"
|
|
1131
|
+
},
|
|
1132
|
+
properties: {
|
|
1133
|
+
"attr.aria-expanded": "_getAriaExpanded()",
|
|
1134
|
+
"attr.aria-level": "level + 1",
|
|
1135
|
+
"attr.aria-posinset": "_getPositionInSet()",
|
|
1136
|
+
"attr.aria-setsize": "_getSetSize()",
|
|
1137
|
+
"tabindex": "_tabindex"
|
|
1138
|
+
},
|
|
1139
|
+
classAttribute: "cdk-tree-node"
|
|
1140
|
+
},
|
|
1141
|
+
exportAs: ["cdkTreeNode"],
|
|
1142
|
+
ngImport: i0
|
|
1143
|
+
});
|
|
1463
1144
|
}
|
|
1464
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1145
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1146
|
+
minVersion: "12.0.0",
|
|
1147
|
+
version: "20.2.0-next.2",
|
|
1148
|
+
ngImport: i0,
|
|
1149
|
+
type: CdkTreeNode,
|
|
1150
|
+
decorators: [{
|
|
1151
|
+
type: Directive,
|
|
1152
|
+
args: [{
|
|
1153
|
+
selector: 'cdk-tree-node',
|
|
1154
|
+
exportAs: 'cdkTreeNode',
|
|
1155
|
+
host: {
|
|
1156
|
+
'class': 'cdk-tree-node',
|
|
1157
|
+
'[attr.aria-expanded]': '_getAriaExpanded()',
|
|
1158
|
+
'[attr.aria-level]': 'level + 1',
|
|
1159
|
+
'[attr.aria-posinset]': '_getPositionInSet()',
|
|
1160
|
+
'[attr.aria-setsize]': '_getSetSize()',
|
|
1161
|
+
'[tabindex]': '_tabindex',
|
|
1162
|
+
'role': 'treeitem',
|
|
1163
|
+
'(click)': '_setActiveItem()',
|
|
1164
|
+
'(focus)': '_focusItem()'
|
|
1165
|
+
}
|
|
1166
|
+
}]
|
|
1167
|
+
}],
|
|
1168
|
+
ctorParameters: () => [],
|
|
1169
|
+
propDecorators: {
|
|
1170
|
+
role: [{
|
|
1171
|
+
type: Input
|
|
1172
|
+
}],
|
|
1173
|
+
isExpandable: [{
|
|
1174
|
+
type: Input,
|
|
1175
|
+
args: [{
|
|
1176
|
+
transform: booleanAttribute
|
|
1177
|
+
}]
|
|
1178
|
+
}],
|
|
1179
|
+
isExpanded: [{
|
|
1180
|
+
type: Input
|
|
1181
|
+
}],
|
|
1182
|
+
isDisabled: [{
|
|
1183
|
+
type: Input,
|
|
1184
|
+
args: [{
|
|
1185
|
+
transform: booleanAttribute
|
|
1186
|
+
}]
|
|
1187
|
+
}],
|
|
1188
|
+
typeaheadLabel: [{
|
|
1189
|
+
type: Input,
|
|
1190
|
+
args: ['cdkTreeNodeTypeaheadLabel']
|
|
1191
|
+
}],
|
|
1192
|
+
activation: [{
|
|
1193
|
+
type: Output
|
|
1194
|
+
}],
|
|
1195
|
+
expandedChange: [{
|
|
1196
|
+
type: Output
|
|
1197
|
+
}]
|
|
1198
|
+
}
|
|
1199
|
+
});
|
|
1499
1200
|
function getParentNodeAriaLevel(nodeElement) {
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
else {
|
|
1516
|
-
// The ancestor element is the cdk-tree itself
|
|
1517
|
-
return 0;
|
|
1518
|
-
}
|
|
1201
|
+
let parent = nodeElement.parentElement;
|
|
1202
|
+
while (parent && !isNodeElement(parent)) {
|
|
1203
|
+
parent = parent.parentElement;
|
|
1204
|
+
}
|
|
1205
|
+
if (!parent) {
|
|
1206
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
1207
|
+
throw Error('Incorrect tree structure containing detached node.');
|
|
1208
|
+
} else {
|
|
1209
|
+
return -1;
|
|
1210
|
+
}
|
|
1211
|
+
} else if (parent.classList.contains('cdk-nested-tree-node')) {
|
|
1212
|
+
return numberAttribute(parent.getAttribute('aria-level'));
|
|
1213
|
+
} else {
|
|
1214
|
+
return 0;
|
|
1215
|
+
}
|
|
1519
1216
|
}
|
|
1520
1217
|
function isNodeElement(element) {
|
|
1521
|
-
|
|
1522
|
-
|
|
1218
|
+
const classList = element.classList;
|
|
1219
|
+
return !!(classList?.contains('cdk-nested-tree-node') || classList?.contains('cdk-tree'));
|
|
1523
1220
|
}
|
|
1524
1221
|
|
|
1525
|
-
/**
|
|
1526
|
-
* Nested node is a child of `<cdk-tree>`. It works with nested tree.
|
|
1527
|
-
* By using `cdk-nested-tree-node` component in tree node template, children of the parent node will
|
|
1528
|
-
* be added in the `cdkTreeNodeOutlet` in tree node template.
|
|
1529
|
-
* The children of node will be automatically added to `cdkTreeNodeOutlet`.
|
|
1530
|
-
*/
|
|
1531
1222
|
class CdkNestedTreeNode extends CdkTreeNode {
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1223
|
+
_type = 'nested';
|
|
1224
|
+
_differs = inject(IterableDiffers);
|
|
1225
|
+
_dataDiffer;
|
|
1226
|
+
_children;
|
|
1227
|
+
nodeOutlet;
|
|
1228
|
+
constructor() {
|
|
1229
|
+
super();
|
|
1230
|
+
}
|
|
1231
|
+
ngAfterContentInit() {
|
|
1232
|
+
this._dataDiffer = this._differs.find([]).create(this._tree.trackBy);
|
|
1233
|
+
this._tree._getDirectChildren(this.data).pipe(takeUntil(this._destroyed)).subscribe(result => this.updateChildrenNodes(result));
|
|
1234
|
+
this.nodeOutlet.changes.pipe(takeUntil(this._destroyed)).subscribe(() => this.updateChildrenNodes());
|
|
1235
|
+
}
|
|
1236
|
+
ngOnDestroy() {
|
|
1237
|
+
this._clear();
|
|
1238
|
+
super.ngOnDestroy();
|
|
1239
|
+
}
|
|
1240
|
+
updateChildrenNodes(children) {
|
|
1241
|
+
const outlet = this._getNodeOutlet();
|
|
1242
|
+
if (children) {
|
|
1243
|
+
this._children = children;
|
|
1244
|
+
}
|
|
1245
|
+
if (outlet && this._children) {
|
|
1246
|
+
const viewContainer = outlet.viewContainer;
|
|
1247
|
+
this._tree.renderNodeChanges(this._children, this._dataDiffer, viewContainer, this._data);
|
|
1248
|
+
} else {
|
|
1249
|
+
this._dataDiffer.diff([]);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
_clear() {
|
|
1253
|
+
const outlet = this._getNodeOutlet();
|
|
1254
|
+
if (outlet) {
|
|
1255
|
+
outlet.viewContainer.clear();
|
|
1256
|
+
this._dataDiffer.diff([]);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
_getNodeOutlet() {
|
|
1260
|
+
const outlets = this.nodeOutlet;
|
|
1261
|
+
return outlets && outlets.find(outlet => !outlet._node || outlet._node === this);
|
|
1262
|
+
}
|
|
1263
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1264
|
+
minVersion: "12.0.0",
|
|
1265
|
+
version: "20.2.0-next.2",
|
|
1266
|
+
ngImport: i0,
|
|
1267
|
+
type: CdkNestedTreeNode,
|
|
1268
|
+
deps: [],
|
|
1269
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
1270
|
+
});
|
|
1271
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
1272
|
+
minVersion: "14.0.0",
|
|
1273
|
+
version: "20.2.0-next.2",
|
|
1274
|
+
type: CdkNestedTreeNode,
|
|
1275
|
+
isStandalone: true,
|
|
1276
|
+
selector: "cdk-nested-tree-node",
|
|
1277
|
+
host: {
|
|
1278
|
+
classAttribute: "cdk-nested-tree-node"
|
|
1279
|
+
},
|
|
1280
|
+
providers: [{
|
|
1281
|
+
provide: CdkTreeNode,
|
|
1282
|
+
useExisting: CdkNestedTreeNode
|
|
1283
|
+
}, {
|
|
1284
|
+
provide: CDK_TREE_NODE_OUTLET_NODE,
|
|
1285
|
+
useExisting: CdkNestedTreeNode
|
|
1286
|
+
}],
|
|
1287
|
+
queries: [{
|
|
1288
|
+
propertyName: "nodeOutlet",
|
|
1289
|
+
predicate: CdkTreeNodeOutlet,
|
|
1290
|
+
descendants: true
|
|
1291
|
+
}],
|
|
1292
|
+
exportAs: ["cdkNestedTreeNode"],
|
|
1293
|
+
usesInheritance: true,
|
|
1294
|
+
ngImport: i0
|
|
1295
|
+
});
|
|
1592
1296
|
}
|
|
1593
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1297
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1298
|
+
minVersion: "12.0.0",
|
|
1299
|
+
version: "20.2.0-next.2",
|
|
1300
|
+
ngImport: i0,
|
|
1301
|
+
type: CdkNestedTreeNode,
|
|
1302
|
+
decorators: [{
|
|
1303
|
+
type: Directive,
|
|
1304
|
+
args: [{
|
|
1305
|
+
selector: 'cdk-nested-tree-node',
|
|
1306
|
+
exportAs: 'cdkNestedTreeNode',
|
|
1307
|
+
providers: [{
|
|
1308
|
+
provide: CdkTreeNode,
|
|
1309
|
+
useExisting: CdkNestedTreeNode
|
|
1310
|
+
}, {
|
|
1311
|
+
provide: CDK_TREE_NODE_OUTLET_NODE,
|
|
1312
|
+
useExisting: CdkNestedTreeNode
|
|
1313
|
+
}],
|
|
1314
|
+
host: {
|
|
1315
|
+
'class': 'cdk-nested-tree-node'
|
|
1316
|
+
}
|
|
1317
|
+
}]
|
|
1318
|
+
}],
|
|
1319
|
+
ctorParameters: () => [],
|
|
1320
|
+
propDecorators: {
|
|
1321
|
+
nodeOutlet: [{
|
|
1322
|
+
type: ContentChildren,
|
|
1323
|
+
args: [CdkTreeNodeOutlet, {
|
|
1324
|
+
descendants: true
|
|
1325
|
+
}]
|
|
1326
|
+
}]
|
|
1327
|
+
}
|
|
1328
|
+
});
|
|
1614
1329
|
|
|
1615
|
-
/** Regex used to split a string on its CSS units. */
|
|
1616
1330
|
const cssUnitPattern = /([A-Za-z%]+)$/;
|
|
1617
|
-
/**
|
|
1618
|
-
* Indent for the children tree dataNodes.
|
|
1619
|
-
* This directive will add left-padding to the node to show hierarchy.
|
|
1620
|
-
*/
|
|
1621
1331
|
class CdkTreeNodePadding {
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
}
|
|
1707
|
-
this.indentUnits = units;
|
|
1708
|
-
this._indent = numberAttribute(value);
|
|
1709
|
-
this._setPadding();
|
|
1710
|
-
}
|
|
1711
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: CdkTreeNodePadding, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1712
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "20.2.0-next.2", type: CdkTreeNodePadding, isStandalone: true, selector: "[cdkTreeNodePadding]", inputs: { level: ["cdkTreeNodePadding", "level", numberAttribute], indent: ["cdkTreeNodePaddingIndent", "indent"] }, ngImport: i0 });
|
|
1332
|
+
_treeNode = inject(CdkTreeNode);
|
|
1333
|
+
_tree = inject(CdkTree);
|
|
1334
|
+
_element = inject(ElementRef);
|
|
1335
|
+
_dir = inject(Directionality, {
|
|
1336
|
+
optional: true
|
|
1337
|
+
});
|
|
1338
|
+
_currentPadding;
|
|
1339
|
+
_destroyed = new Subject();
|
|
1340
|
+
indentUnits = 'px';
|
|
1341
|
+
get level() {
|
|
1342
|
+
return this._level;
|
|
1343
|
+
}
|
|
1344
|
+
set level(value) {
|
|
1345
|
+
this._setLevelInput(value);
|
|
1346
|
+
}
|
|
1347
|
+
_level;
|
|
1348
|
+
get indent() {
|
|
1349
|
+
return this._indent;
|
|
1350
|
+
}
|
|
1351
|
+
set indent(indent) {
|
|
1352
|
+
this._setIndentInput(indent);
|
|
1353
|
+
}
|
|
1354
|
+
_indent = 40;
|
|
1355
|
+
constructor() {
|
|
1356
|
+
this._setPadding();
|
|
1357
|
+
this._dir?.change.pipe(takeUntil(this._destroyed)).subscribe(() => this._setPadding(true));
|
|
1358
|
+
this._treeNode._dataChanges.subscribe(() => this._setPadding());
|
|
1359
|
+
}
|
|
1360
|
+
ngOnDestroy() {
|
|
1361
|
+
this._destroyed.next();
|
|
1362
|
+
this._destroyed.complete();
|
|
1363
|
+
}
|
|
1364
|
+
_paddingIndent() {
|
|
1365
|
+
const nodeLevel = (this._treeNode.data && this._tree._getLevel(this._treeNode.data)) ?? null;
|
|
1366
|
+
const level = this._level == null ? nodeLevel : this._level;
|
|
1367
|
+
return typeof level === 'number' ? `${level * this._indent}${this.indentUnits}` : null;
|
|
1368
|
+
}
|
|
1369
|
+
_setPadding(forceChange = false) {
|
|
1370
|
+
const padding = this._paddingIndent();
|
|
1371
|
+
if (padding !== this._currentPadding || forceChange) {
|
|
1372
|
+
const element = this._element.nativeElement;
|
|
1373
|
+
const paddingProp = this._dir && this._dir.value === 'rtl' ? 'paddingRight' : 'paddingLeft';
|
|
1374
|
+
const resetProp = paddingProp === 'paddingLeft' ? 'paddingRight' : 'paddingLeft';
|
|
1375
|
+
element.style[paddingProp] = padding || '';
|
|
1376
|
+
element.style[resetProp] = '';
|
|
1377
|
+
this._currentPadding = padding;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
_setLevelInput(value) {
|
|
1381
|
+
this._level = isNaN(value) ? null : value;
|
|
1382
|
+
this._setPadding();
|
|
1383
|
+
}
|
|
1384
|
+
_setIndentInput(indent) {
|
|
1385
|
+
let value = indent;
|
|
1386
|
+
let units = 'px';
|
|
1387
|
+
if (typeof indent === 'string') {
|
|
1388
|
+
const parts = indent.split(cssUnitPattern);
|
|
1389
|
+
value = parts[0];
|
|
1390
|
+
units = parts[1] || units;
|
|
1391
|
+
}
|
|
1392
|
+
this.indentUnits = units;
|
|
1393
|
+
this._indent = numberAttribute(value);
|
|
1394
|
+
this._setPadding();
|
|
1395
|
+
}
|
|
1396
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1397
|
+
minVersion: "12.0.0",
|
|
1398
|
+
version: "20.2.0-next.2",
|
|
1399
|
+
ngImport: i0,
|
|
1400
|
+
type: CdkTreeNodePadding,
|
|
1401
|
+
deps: [],
|
|
1402
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
1403
|
+
});
|
|
1404
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
1405
|
+
minVersion: "16.1.0",
|
|
1406
|
+
version: "20.2.0-next.2",
|
|
1407
|
+
type: CdkTreeNodePadding,
|
|
1408
|
+
isStandalone: true,
|
|
1409
|
+
selector: "[cdkTreeNodePadding]",
|
|
1410
|
+
inputs: {
|
|
1411
|
+
level: ["cdkTreeNodePadding", "level", numberAttribute],
|
|
1412
|
+
indent: ["cdkTreeNodePaddingIndent", "indent"]
|
|
1413
|
+
},
|
|
1414
|
+
ngImport: i0
|
|
1415
|
+
});
|
|
1713
1416
|
}
|
|
1714
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1417
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1418
|
+
minVersion: "12.0.0",
|
|
1419
|
+
version: "20.2.0-next.2",
|
|
1420
|
+
ngImport: i0,
|
|
1421
|
+
type: CdkTreeNodePadding,
|
|
1422
|
+
decorators: [{
|
|
1423
|
+
type: Directive,
|
|
1424
|
+
args: [{
|
|
1425
|
+
selector: '[cdkTreeNodePadding]'
|
|
1426
|
+
}]
|
|
1427
|
+
}],
|
|
1428
|
+
ctorParameters: () => [],
|
|
1429
|
+
propDecorators: {
|
|
1430
|
+
level: [{
|
|
1431
|
+
type: Input,
|
|
1432
|
+
args: [{
|
|
1433
|
+
alias: 'cdkTreeNodePadding',
|
|
1434
|
+
transform: numberAttribute
|
|
1435
|
+
}]
|
|
1436
|
+
}],
|
|
1437
|
+
indent: [{
|
|
1438
|
+
type: Input,
|
|
1439
|
+
args: ['cdkTreeNodePaddingIndent']
|
|
1440
|
+
}]
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1726
1443
|
|
|
1727
|
-
/**
|
|
1728
|
-
* Node toggle to expand and collapse the node.
|
|
1729
|
-
*/
|
|
1730
1444
|
class CdkTreeNodeToggle {
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1445
|
+
_tree = inject(CdkTree);
|
|
1446
|
+
_treeNode = inject(CdkTreeNode);
|
|
1447
|
+
recursive = false;
|
|
1448
|
+
constructor() {}
|
|
1449
|
+
_toggle() {
|
|
1450
|
+
this.recursive ? this._tree.toggleDescendants(this._treeNode.data) : this._tree.toggle(this._treeNode.data);
|
|
1451
|
+
this._tree._keyManager.focusItem(this._treeNode);
|
|
1452
|
+
}
|
|
1453
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1454
|
+
minVersion: "12.0.0",
|
|
1455
|
+
version: "20.2.0-next.2",
|
|
1456
|
+
ngImport: i0,
|
|
1457
|
+
type: CdkTreeNodeToggle,
|
|
1458
|
+
deps: [],
|
|
1459
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
1460
|
+
});
|
|
1461
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
1462
|
+
minVersion: "16.1.0",
|
|
1463
|
+
version: "20.2.0-next.2",
|
|
1464
|
+
type: CdkTreeNodeToggle,
|
|
1465
|
+
isStandalone: true,
|
|
1466
|
+
selector: "[cdkTreeNodeToggle]",
|
|
1467
|
+
inputs: {
|
|
1468
|
+
recursive: ["cdkTreeNodeToggleRecursive", "recursive", booleanAttribute]
|
|
1469
|
+
},
|
|
1470
|
+
host: {
|
|
1471
|
+
attributes: {
|
|
1472
|
+
"tabindex": "-1"
|
|
1473
|
+
},
|
|
1474
|
+
listeners: {
|
|
1475
|
+
"click": "_toggle(); $event.stopPropagation();",
|
|
1476
|
+
"keydown.Enter": "_toggle(); $event.preventDefault();",
|
|
1477
|
+
"keydown.Space": "_toggle(); $event.preventDefault();"
|
|
1478
|
+
}
|
|
1479
|
+
},
|
|
1480
|
+
ngImport: i0
|
|
1481
|
+
});
|
|
1748
1482
|
}
|
|
1749
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1483
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1484
|
+
minVersion: "12.0.0",
|
|
1485
|
+
version: "20.2.0-next.2",
|
|
1486
|
+
ngImport: i0,
|
|
1487
|
+
type: CdkTreeNodeToggle,
|
|
1488
|
+
decorators: [{
|
|
1489
|
+
type: Directive,
|
|
1490
|
+
args: [{
|
|
1491
|
+
selector: '[cdkTreeNodeToggle]',
|
|
1492
|
+
host: {
|
|
1493
|
+
'(click)': '_toggle(); $event.stopPropagation();',
|
|
1494
|
+
'(keydown.Enter)': '_toggle(); $event.preventDefault();',
|
|
1495
|
+
'(keydown.Space)': '_toggle(); $event.preventDefault();',
|
|
1496
|
+
'tabindex': '-1'
|
|
1497
|
+
}
|
|
1498
|
+
}]
|
|
1499
|
+
}],
|
|
1500
|
+
ctorParameters: () => [],
|
|
1501
|
+
propDecorators: {
|
|
1502
|
+
recursive: [{
|
|
1503
|
+
type: Input,
|
|
1504
|
+
args: [{
|
|
1505
|
+
alias: 'cdkTreeNodeToggleRecursive',
|
|
1506
|
+
transform: booleanAttribute
|
|
1507
|
+
}]
|
|
1508
|
+
}]
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1764
1511
|
|
|
1765
|
-
const EXPORTED_DECLARATIONS = [
|
|
1766
|
-
CdkNestedTreeNode,
|
|
1767
|
-
CdkTreeNodeDef,
|
|
1768
|
-
CdkTreeNodePadding,
|
|
1769
|
-
CdkTreeNodeToggle,
|
|
1770
|
-
CdkTree,
|
|
1771
|
-
CdkTreeNode,
|
|
1772
|
-
CdkTreeNodeOutlet,
|
|
1773
|
-
];
|
|
1512
|
+
const EXPORTED_DECLARATIONS = [CdkNestedTreeNode, CdkTreeNodeDef, CdkTreeNodePadding, CdkTreeNodeToggle, CdkTree, CdkTreeNode, CdkTreeNodeOutlet];
|
|
1774
1513
|
class CdkTreeModule {
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1514
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1515
|
+
minVersion: "12.0.0",
|
|
1516
|
+
version: "20.2.0-next.2",
|
|
1517
|
+
ngImport: i0,
|
|
1518
|
+
type: CdkTreeModule,
|
|
1519
|
+
deps: [],
|
|
1520
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
1521
|
+
});
|
|
1522
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({
|
|
1523
|
+
minVersion: "14.0.0",
|
|
1524
|
+
version: "20.2.0-next.2",
|
|
1525
|
+
ngImport: i0,
|
|
1526
|
+
type: CdkTreeModule,
|
|
1527
|
+
imports: [CdkNestedTreeNode, CdkTreeNodeDef, CdkTreeNodePadding, CdkTreeNodeToggle, CdkTree, CdkTreeNode, CdkTreeNodeOutlet],
|
|
1528
|
+
exports: [CdkNestedTreeNode, CdkTreeNodeDef, CdkTreeNodePadding, CdkTreeNodeToggle, CdkTree, CdkTreeNode, CdkTreeNodeOutlet]
|
|
1529
|
+
});
|
|
1530
|
+
static ɵinj = i0.ɵɵngDeclareInjector({
|
|
1531
|
+
minVersion: "12.0.0",
|
|
1532
|
+
version: "20.2.0-next.2",
|
|
1533
|
+
ngImport: i0,
|
|
1534
|
+
type: CdkTreeModule
|
|
1535
|
+
});
|
|
1790
1536
|
}
|
|
1791
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1537
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1538
|
+
minVersion: "12.0.0",
|
|
1539
|
+
version: "20.2.0-next.2",
|
|
1540
|
+
ngImport: i0,
|
|
1541
|
+
type: CdkTreeModule,
|
|
1542
|
+
decorators: [{
|
|
1543
|
+
type: NgModule,
|
|
1544
|
+
args: [{
|
|
1545
|
+
imports: EXPORTED_DECLARATIONS,
|
|
1546
|
+
exports: EXPORTED_DECLARATIONS
|
|
1547
|
+
}]
|
|
1548
|
+
}]
|
|
1549
|
+
});
|
|
1798
1550
|
|
|
1799
1551
|
export { BaseTreeControl, CDK_TREE_NODE_OUTLET_NODE, CdkNestedTreeNode, CdkTree, CdkTreeModule, CdkTreeNode, CdkTreeNodeDef, CdkTreeNodeOutlet, CdkTreeNodeOutletContext, CdkTreeNodePadding, CdkTreeNodeToggle, FlatTreeControl, NestedTreeControl, getMultipleTreeControlsError, getTreeControlMissingError, getTreeMissingMatchingNodeDefError, getTreeMultipleDefaultNodeDefsError, getTreeNoValidDataSourceError };
|
|
1800
1552
|
//# sourceMappingURL=tree.mjs.map
|