@angular/material 21.0.0-next.9 → 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/core/tokens/_classes.scss +1 -1
- package/core/tokens/m2/_md-sys-color.scss +17 -17
- package/fesm2022/_animation-chunk.mjs +10 -16
- package/fesm2022/_animation-chunk.mjs.map +1 -1
- package/fesm2022/_date-formats-chunk.mjs +68 -164
- package/fesm2022/_date-formats-chunk.mjs.map +1 -1
- package/fesm2022/_date-range-input-harness-chunk.mjs +284 -463
- package/fesm2022/_date-range-input-harness-chunk.mjs.map +1 -1
- package/fesm2022/_error-options-chunk.mjs +56 -19
- package/fesm2022/_error-options-chunk.mjs.map +1 -1
- package/fesm2022/_error-state-chunk.mjs +24 -31
- package/fesm2022/_error-state-chunk.mjs.map +1 -1
- package/fesm2022/_form-field-chunk.mjs +1224 -1017
- package/fesm2022/_form-field-chunk.mjs.map +1 -1
- package/fesm2022/_icon-button-chunk.mjs +243 -187
- package/fesm2022/_icon-button-chunk.mjs.map +1 -1
- package/fesm2022/_icon-registry-chunk.mjs +350 -575
- package/fesm2022/_icon-registry-chunk.mjs.map +1 -1
- package/fesm2022/_input-harness-chunk.mjs +56 -107
- package/fesm2022/_input-harness-chunk.mjs.map +1 -1
- package/fesm2022/_input-value-accessor-chunk.mjs +0 -6
- package/fesm2022/_input-value-accessor-chunk.mjs.map +1 -1
- package/fesm2022/_internal-form-field-chunk.mjs +59 -19
- package/fesm2022/_internal-form-field-chunk.mjs.map +1 -1
- package/fesm2022/_line-chunk.mjs +83 -43
- package/fesm2022/_line-chunk.mjs.map +1 -1
- package/fesm2022/_option-chunk.mjs +348 -311
- package/fesm2022/_option-chunk.mjs.map +1 -1
- package/fesm2022/_option-harness-chunk.mjs +23 -39
- package/fesm2022/_option-harness-chunk.mjs.map +1 -1
- package/fesm2022/_option-module-chunk.mjs +36 -10
- package/fesm2022/_option-module-chunk.mjs.map +1 -1
- package/fesm2022/_pseudo-checkbox-chunk.mjs +79 -44
- package/fesm2022/_pseudo-checkbox-chunk.mjs.map +1 -1
- package/fesm2022/_pseudo-checkbox-module-chunk.mjs +36 -10
- package/fesm2022/_pseudo-checkbox-module-chunk.mjs.map +1 -1
- package/fesm2022/_public-api-chunk.mjs +71 -134
- package/fesm2022/_public-api-chunk.mjs.map +1 -1
- package/fesm2022/_ripple-chunk.mjs +504 -600
- package/fesm2022/_ripple-chunk.mjs.map +1 -1
- package/fesm2022/_ripple-loader-chunk.mjs +120 -138
- package/fesm2022/_ripple-loader-chunk.mjs.map +1 -1
- package/fesm2022/_ripple-module-chunk.mjs +36 -10
- package/fesm2022/_ripple-module-chunk.mjs.map +1 -1
- package/fesm2022/_structural-styles-chunk.mjs +37 -10
- package/fesm2022/_structural-styles-chunk.mjs.map +1 -1
- package/fesm2022/_tooltip-chunk.mjs +810 -888
- package/fesm2022/_tooltip-chunk.mjs.map +1 -1
- package/fesm2022/autocomplete-testing.mjs +62 -86
- package/fesm2022/autocomplete-testing.mjs.map +1 -1
- package/fesm2022/autocomplete.mjs +965 -1126
- package/fesm2022/autocomplete.mjs.map +1 -1
- package/fesm2022/badge-testing.mjs +38 -54
- package/fesm2022/badge-testing.mjs.map +1 -1
- package/fesm2022/badge.mjs +321 -272
- package/fesm2022/badge.mjs.map +1 -1
- package/fesm2022/bottom-sheet-testing.mjs +10 -24
- package/fesm2022/bottom-sheet-testing.mjs.map +1 -1
- package/fesm2022/bottom-sheet.mjs +349 -344
- package/fesm2022/bottom-sheet.mjs.map +1 -1
- package/fesm2022/button-testing.mjs +60 -94
- package/fesm2022/button-testing.mjs.map +1 -1
- package/fesm2022/button-toggle-testing.mjs +76 -125
- package/fesm2022/button-toggle-testing.mjs.map +1 -1
- package/fesm2022/button-toggle.mjs +752 -662
- package/fesm2022/button-toggle.mjs.map +1 -1
- package/fesm2022/button.mjs +263 -158
- package/fesm2022/button.mjs.map +1 -1
- package/fesm2022/card-testing.mjs +19 -33
- package/fesm2022/card-testing.mjs.map +1 -1
- package/fesm2022/card.mjs +576 -272
- package/fesm2022/card.mjs.map +1 -1
- package/fesm2022/checkbox-testing.mjs +71 -123
- package/fesm2022/checkbox-testing.mjs.map +1 -1
- package/fesm2022/checkbox.mjs +515 -477
- package/fesm2022/checkbox.mjs.map +1 -1
- package/fesm2022/chips-testing.mjs +201 -344
- package/fesm2022/chips-testing.mjs.map +1 -1
- package/fesm2022/chips.mjs +2552 -2289
- package/fesm2022/chips.mjs.map +1 -1
- package/fesm2022/core-testing.mjs +14 -28
- package/fesm2022/core-testing.mjs.map +1 -1
- package/fesm2022/core.mjs +357 -328
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/datepicker-testing.mjs +15 -25
- package/fesm2022/datepicker-testing.mjs.map +1 -1
- package/fesm2022/datepicker.mjs +4826 -4563
- package/fesm2022/datepicker.mjs.map +1 -1
- package/fesm2022/dialog-testing.mjs +93 -129
- package/fesm2022/dialog-testing.mjs.map +1 -1
- package/fesm2022/dialog.mjs +810 -829
- package/fesm2022/dialog.mjs.map +1 -1
- package/fesm2022/divider-testing.mjs +10 -11
- package/fesm2022/divider-testing.mjs.map +1 -1
- package/fesm2022/divider.mjs +119 -43
- package/fesm2022/divider.mjs.map +1 -1
- package/fesm2022/expansion-testing.mjs +74 -130
- package/fesm2022/expansion-testing.mjs.map +1 -1
- package/fesm2022/expansion.mjs +703 -515
- package/fesm2022/expansion.mjs.map +1 -1
- package/fesm2022/form-field-testing-control.mjs +16 -33
- package/fesm2022/form-field-testing-control.mjs.map +1 -1
- package/fesm2022/form-field-testing.mjs +118 -179
- package/fesm2022/form-field-testing.mjs.map +1 -1
- package/fesm2022/form-field.mjs +36 -10
- package/fesm2022/form-field.mjs.map +1 -1
- package/fesm2022/grid-list-testing.mjs +65 -113
- package/fesm2022/grid-list-testing.mjs.map +1 -1
- package/fesm2022/grid-list.mjs +559 -494
- package/fesm2022/grid-list.mjs.map +1 -1
- package/fesm2022/icon-testing.mjs +148 -127
- package/fesm2022/icon-testing.mjs.map +1 -1
- package/fesm2022/icon.mjs +325 -351
- package/fesm2022/icon.mjs.map +1 -1
- package/fesm2022/input-testing.mjs +59 -99
- package/fesm2022/input-testing.mjs.map +1 -1
- package/fesm2022/input.mjs +457 -520
- package/fesm2022/input.mjs.map +1 -1
- package/fesm2022/list-testing.mjs +251 -434
- package/fesm2022/list-testing.mjs.map +1 -1
- package/fesm2022/list.mjs +1522 -1204
- package/fesm2022/list.mjs.map +1 -1
- package/fesm2022/material.mjs +0 -5
- package/fesm2022/material.mjs.map +1 -1
- package/fesm2022/menu-testing.mjs +159 -228
- package/fesm2022/menu-testing.mjs.map +1 -1
- package/fesm2022/menu.mjs +1338 -1343
- package/fesm2022/menu.mjs.map +1 -1
- package/fesm2022/paginator-testing.mjs +55 -79
- package/fesm2022/paginator-testing.mjs.map +1 -1
- package/fesm2022/paginator.mjs +381 -309
- package/fesm2022/paginator.mjs.map +1 -1
- package/fesm2022/progress-bar-testing.mjs +12 -21
- package/fesm2022/progress-bar-testing.mjs.map +1 -1
- package/fesm2022/progress-bar.mjs +224 -169
- package/fesm2022/progress-bar.mjs.map +1 -1
- package/fesm2022/progress-spinner-testing.mjs +13 -23
- package/fesm2022/progress-spinner-testing.mjs.map +1 -1
- package/fesm2022/progress-spinner.mjs +235 -160
- package/fesm2022/progress-spinner.mjs.map +1 -1
- package/fesm2022/radio-testing.mjs +133 -208
- package/fesm2022/radio-testing.mjs.map +1 -1
- package/fesm2022/radio.mjs +712 -679
- package/fesm2022/radio.mjs.map +1 -1
- package/fesm2022/select-testing.mjs +83 -117
- package/fesm2022/select-testing.mjs.map +1 -1
- package/fesm2022/select.mjs +1116 -1246
- package/fesm2022/select.mjs.map +1 -1
- package/fesm2022/sidenav-testing.mjs +54 -120
- package/fesm2022/sidenav-testing.mjs.map +1 -1
- package/fesm2022/sidenav.mjs +1078 -995
- package/fesm2022/sidenav.mjs.map +1 -1
- package/fesm2022/slide-toggle-testing.mjs +57 -92
- package/fesm2022/slide-toggle-testing.mjs.map +1 -1
- package/fesm2022/slide-toggle.mjs +369 -279
- package/fesm2022/slide-toggle.mjs.map +1 -1
- package/fesm2022/slider-testing.mjs +90 -138
- package/fesm2022/slider-testing.mjs.map +1 -1
- package/fesm2022/slider.mjs +1651 -1716
- package/fesm2022/slider.mjs.map +1 -1
- package/fesm2022/snack-bar-testing.mjs +40 -87
- package/fesm2022/snack-bar-testing.mjs.map +1 -1
- package/fesm2022/snack-bar.mjs +763 -714
- package/fesm2022/snack-bar.mjs.map +1 -1
- package/fesm2022/sort-testing.mjs +45 -66
- package/fesm2022/sort-testing.mjs.map +1 -1
- package/fesm2022/sort.mjs +419 -344
- package/fesm2022/sort.mjs.map +1 -1
- package/fesm2022/stepper-testing.mjs +78 -154
- package/fesm2022/stepper-testing.mjs.map +1 -1
- package/fesm2022/stepper.mjs +790 -498
- package/fesm2022/stepper.mjs.map +1 -1
- package/fesm2022/table-testing.mjs +120 -213
- package/fesm2022/table-testing.mjs.map +1 -1
- package/fesm2022/table.mjs +1026 -684
- package/fesm2022/table.mjs.map +1 -1
- package/fesm2022/tabs-testing.mjs +125 -197
- package/fesm2022/tabs-testing.mjs.map +1 -1
- package/fesm2022/tabs.mjs +2351 -2028
- package/fesm2022/tabs.mjs.map +1 -1
- package/fesm2022/timepicker-testing.mjs +113 -172
- package/fesm2022/timepicker-testing.mjs.map +1 -1
- package/fesm2022/timepicker.mjs +1019 -826
- package/fesm2022/timepicker.mjs.map +1 -1
- package/fesm2022/toolbar-testing.mjs +16 -27
- package/fesm2022/toolbar-testing.mjs.map +1 -1
- package/fesm2022/toolbar.mjs +163 -78
- package/fesm2022/toolbar.mjs.map +1 -1
- package/fesm2022/tooltip-testing.mjs +41 -52
- package/fesm2022/tooltip-testing.mjs.map +1 -1
- package/fesm2022/tooltip.mjs +36 -10
- package/fesm2022/tooltip.mjs.map +1 -1
- package/fesm2022/tree-testing.mjs +86 -162
- package/fesm2022/tree-testing.mjs.map +1 -1
- package/fesm2022/tree.mjs +638 -466
- package/fesm2022/tree.mjs.map +1 -1
- package/package.json +2 -2
- package/schematics/ng-add/index.js +1 -1
- package/types/expansion.d.ts +4 -2
- package/types/menu-testing.d.ts +2 -0
- package/types/select.d.ts +1 -1
- package/types/timepicker.d.ts +1 -0
|
@@ -1,179 +1,103 @@
|
|
|
1
1
|
import { ContentContainerComponentHarness, HarnessPredicate, ComponentHarness, parallel } from '@angular/cdk/testing';
|
|
2
2
|
import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
|
|
3
3
|
|
|
4
|
-
/** Harness for interacting with a standard Angular Material tree node. */
|
|
5
4
|
class MatTreeNodeHarness extends ContentContainerComponentHarness {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
static hostSelector = '.mat-tree-node, .mat-nested-tree-node';
|
|
6
|
+
_toggle = this.locatorForOptional('[matTreeNodeToggle]');
|
|
7
|
+
static with(options = {}) {
|
|
8
|
+
return getNodePredicate(MatTreeNodeHarness, options);
|
|
9
|
+
}
|
|
10
|
+
async isExpanded() {
|
|
11
|
+
return coerceBooleanProperty(await (await this.host()).getAttribute('aria-expanded'));
|
|
12
|
+
}
|
|
13
|
+
async isExpandable() {
|
|
14
|
+
return (await (await this.host()).getAttribute('aria-expanded')) !== null;
|
|
15
|
+
}
|
|
16
|
+
async isDisabled() {
|
|
17
|
+
return coerceBooleanProperty(await (await this.host()).getProperty('aria-disabled'));
|
|
18
|
+
}
|
|
19
|
+
async getLevel() {
|
|
20
|
+
return coerceNumberProperty(await (await this.host()).getAttribute('aria-level'));
|
|
21
|
+
}
|
|
22
|
+
async getText() {
|
|
23
|
+
return (await this.host()).text({
|
|
24
|
+
exclude: '.mat-tree-node, .mat-nested-tree-node, button'
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async toggle() {
|
|
28
|
+
const toggle = await this._toggle();
|
|
29
|
+
if (toggle) {
|
|
30
|
+
return toggle.click();
|
|
16
31
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
}
|
|
33
|
+
async expand() {
|
|
34
|
+
if (!(await this.isExpanded())) {
|
|
35
|
+
await this.toggle();
|
|
20
36
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/** Whether the tree node is disabled. */
|
|
26
|
-
async isDisabled() {
|
|
27
|
-
return coerceBooleanProperty(await (await this.host()).getProperty('aria-disabled'));
|
|
28
|
-
}
|
|
29
|
-
/** Gets the level of the tree node. Note that this gets the aria-level and is 1 indexed. */
|
|
30
|
-
async getLevel() {
|
|
31
|
-
return coerceNumberProperty(await (await this.host()).getAttribute('aria-level'));
|
|
32
|
-
}
|
|
33
|
-
/** Gets the tree node's text. */
|
|
34
|
-
async getText() {
|
|
35
|
-
return (await this.host()).text({ exclude: '.mat-tree-node, .mat-nested-tree-node, button' });
|
|
36
|
-
}
|
|
37
|
-
/** Toggles node between expanded/collapsed. Only works when node is not disabled. */
|
|
38
|
-
async toggle() {
|
|
39
|
-
const toggle = await this._toggle();
|
|
40
|
-
if (toggle) {
|
|
41
|
-
return toggle.click();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/** Expands the node if it is collapsed. Only works when node is not disabled. */
|
|
45
|
-
async expand() {
|
|
46
|
-
if (!(await this.isExpanded())) {
|
|
47
|
-
await this.toggle();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/** Collapses the node if it is expanded. Only works when node is not disabled. */
|
|
51
|
-
async collapse() {
|
|
52
|
-
if (await this.isExpanded()) {
|
|
53
|
-
await this.toggle();
|
|
54
|
-
}
|
|
37
|
+
}
|
|
38
|
+
async collapse() {
|
|
39
|
+
if (await this.isExpanded()) {
|
|
40
|
+
await this.toggle();
|
|
55
41
|
}
|
|
42
|
+
}
|
|
56
43
|
}
|
|
57
44
|
function getNodePredicate(type, options) {
|
|
58
|
-
|
|
59
|
-
.addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text))
|
|
60
|
-
.addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled)
|
|
61
|
-
.addOption('expanded', options.expanded, async (harness, expanded) => (await harness.isExpanded()) === expanded)
|
|
62
|
-
.addOption('level', options.level, async (harness, level) => (await harness.getLevel()) === level);
|
|
45
|
+
return new HarnessPredicate(type, options).addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text)).addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled).addOption('expanded', options.expanded, async (harness, expanded) => (await harness.isExpanded()) === expanded).addOption('level', options.level, async (harness, level) => (await harness.getLevel()) === level);
|
|
63
46
|
}
|
|
64
47
|
|
|
65
|
-
/** Harness for interacting with a standard mat-tree in tests. */
|
|
66
48
|
class MatTreeHarness extends ComponentHarness {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
* <mat-tree>
|
|
88
|
-
* <mat-tree-node>Node 1<mat-tree-node>
|
|
89
|
-
* <mat-nested-tree-node>
|
|
90
|
-
* Node 2
|
|
91
|
-
* <mat-nested-tree-node>
|
|
92
|
-
* Node 2.1
|
|
93
|
-
* <mat-tree-node>
|
|
94
|
-
* Node 2.1.1
|
|
95
|
-
* <mat-tree-node>
|
|
96
|
-
* <mat-nested-tree-node>
|
|
97
|
-
* <mat-tree-node>
|
|
98
|
-
* Node 2.2
|
|
99
|
-
* <mat-tree-node>
|
|
100
|
-
* <mat-nested-tree-node>
|
|
101
|
-
* </mat-tree>`
|
|
102
|
-
*
|
|
103
|
-
* Tree structure:
|
|
104
|
-
* {
|
|
105
|
-
* children: [
|
|
106
|
-
* {
|
|
107
|
-
* text: 'Node 1',
|
|
108
|
-
* children: [
|
|
109
|
-
* {
|
|
110
|
-
* text: 'Node 2',
|
|
111
|
-
* children: [
|
|
112
|
-
* {
|
|
113
|
-
* text: 'Node 2.1',
|
|
114
|
-
* children: [{text: 'Node 2.1.1'}]
|
|
115
|
-
* },
|
|
116
|
-
* {text: 'Node 2.2'}
|
|
117
|
-
* ]
|
|
118
|
-
* }
|
|
119
|
-
* ]
|
|
120
|
-
* }
|
|
121
|
-
* ]
|
|
122
|
-
* };
|
|
123
|
-
*/
|
|
124
|
-
async getTreeStructure() {
|
|
125
|
-
const nodes = await this.getNodes();
|
|
126
|
-
const nodeInformation = await parallel(() => nodes.map(node => {
|
|
127
|
-
return parallel(() => [node.getLevel(), node.getText(), node.isExpanded()]);
|
|
128
|
-
}));
|
|
129
|
-
return this._getTreeStructure(nodeInformation, 1, true);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Recursively collect the structured text of the tree nodes.
|
|
133
|
-
* @param nodes A list of tree nodes
|
|
134
|
-
* @param level The level of nodes that are being accounted for during this iteration
|
|
135
|
-
* @param parentExpanded Whether the parent of the first node in param nodes is expanded
|
|
136
|
-
*/
|
|
137
|
-
_getTreeStructure(nodes, level, parentExpanded) {
|
|
138
|
-
const result = {};
|
|
139
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
140
|
-
const [nodeLevel, text, expanded] = nodes[i];
|
|
141
|
-
const nextNodeLevel = nodes[i + 1]?.[0] ?? -1;
|
|
142
|
-
// Return the accumulated value for the current level once we reach a shallower level node
|
|
143
|
-
if (nodeLevel < level) {
|
|
144
|
-
return result;
|
|
145
|
-
}
|
|
146
|
-
// Skip deeper level nodes during this iteration, they will be picked up in a later iteration
|
|
147
|
-
if (nodeLevel > level) {
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
// Only add to representation if it is visible (parent is expanded)
|
|
151
|
-
if (parentExpanded) {
|
|
152
|
-
// Collect the data under this node according to the following rules:
|
|
153
|
-
// 1. If the next node in the list is a sibling of the current node add it to the child list
|
|
154
|
-
// 2. If the next node is a child of the current node, get the sub-tree structure for the
|
|
155
|
-
// child and add it under this node
|
|
156
|
-
// 3. If the next node has a shallower level, we've reached the end of the child nodes for
|
|
157
|
-
// the current parent.
|
|
158
|
-
if (nextNodeLevel === level) {
|
|
159
|
-
this._addChildToNode(result, { text });
|
|
160
|
-
}
|
|
161
|
-
else if (nextNodeLevel > level) {
|
|
162
|
-
let children = this._getTreeStructure(nodes.slice(i + 1), nextNodeLevel, expanded)?.children;
|
|
163
|
-
let child = children ? { text, children } : { text };
|
|
164
|
-
this._addChildToNode(result, child);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
this._addChildToNode(result, { text });
|
|
168
|
-
return result;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
49
|
+
static hostSelector = '.mat-tree';
|
|
50
|
+
static with(options = {}) {
|
|
51
|
+
return new HarnessPredicate(MatTreeHarness, options);
|
|
52
|
+
}
|
|
53
|
+
async getNodes(filter = {}) {
|
|
54
|
+
return this.locatorForAll(MatTreeNodeHarness.with(filter))();
|
|
55
|
+
}
|
|
56
|
+
async getTreeStructure() {
|
|
57
|
+
const nodes = await this.getNodes();
|
|
58
|
+
const nodeInformation = await parallel(() => nodes.map(node => {
|
|
59
|
+
return parallel(() => [node.getLevel(), node.getText(), node.isExpanded()]);
|
|
60
|
+
}));
|
|
61
|
+
return this._getTreeStructure(nodeInformation, 1, true);
|
|
62
|
+
}
|
|
63
|
+
_getTreeStructure(nodes, level, parentExpanded) {
|
|
64
|
+
const result = {};
|
|
65
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
66
|
+
const [nodeLevel, text, expanded] = nodes[i];
|
|
67
|
+
const nextNodeLevel = nodes[i + 1]?.[0] ?? -1;
|
|
68
|
+
if (nodeLevel < level) {
|
|
172
69
|
return result;
|
|
70
|
+
}
|
|
71
|
+
if (nodeLevel > level) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (parentExpanded) {
|
|
75
|
+
if (nextNodeLevel === level) {
|
|
76
|
+
this._addChildToNode(result, {
|
|
77
|
+
text
|
|
78
|
+
});
|
|
79
|
+
} else if (nextNodeLevel > level) {
|
|
80
|
+
let children = this._getTreeStructure(nodes.slice(i + 1), nextNodeLevel, expanded)?.children;
|
|
81
|
+
let child = children ? {
|
|
82
|
+
text,
|
|
83
|
+
children
|
|
84
|
+
} : {
|
|
85
|
+
text
|
|
86
|
+
};
|
|
87
|
+
this._addChildToNode(result, child);
|
|
88
|
+
} else {
|
|
89
|
+
this._addChildToNode(result, {
|
|
90
|
+
text
|
|
91
|
+
});
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
173
95
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
_addChildToNode(result, child) {
|
|
99
|
+
result.children ? result.children.push(child) : result.children = [child];
|
|
100
|
+
}
|
|
177
101
|
}
|
|
178
102
|
|
|
179
103
|
export { MatTreeHarness, MatTreeNodeHarness };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-testing.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/src/material/tree/testing/node-harness.ts","../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/src/material/tree/testing/tree-harness.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n ComponentHarnessConstructor,\n ContentContainerComponentHarness,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport {TreeNodeHarnessFilters} from './tree-harness-filters';\nimport {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion';\n\n/** Harness for interacting with a standard Angular Material tree node. */\nexport class MatTreeNodeHarness extends ContentContainerComponentHarness<string> {\n /** The selector of the host element of a `MatTreeNode` instance. */\n static hostSelector = '.mat-tree-node, .mat-nested-tree-node';\n\n _toggle = this.locatorForOptional('[matTreeNodeToggle]');\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a tree node with specific attributes.\n * @param options Options for narrowing the search\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(options: TreeNodeHarnessFilters = {}): HarnessPredicate<MatTreeNodeHarness> {\n return getNodePredicate(MatTreeNodeHarness, options);\n }\n\n /** Whether the tree node is expanded. */\n async isExpanded(): Promise<boolean> {\n return coerceBooleanProperty(await (await this.host()).getAttribute('aria-expanded'));\n }\n\n /** Whether the tree node is expandable. */\n async isExpandable(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-expanded')) !== null;\n }\n\n /** Whether the tree node is disabled. */\n async isDisabled(): Promise<boolean> {\n return coerceBooleanProperty(await (await this.host()).getProperty('aria-disabled'));\n }\n\n /** Gets the level of the tree node. Note that this gets the aria-level and is 1 indexed. */\n async getLevel(): Promise<number> {\n return coerceNumberProperty(await (await this.host()).getAttribute('aria-level'));\n }\n\n /** Gets the tree node's text. */\n async getText(): Promise<string> {\n return (await this.host()).text({exclude: '.mat-tree-node, .mat-nested-tree-node, button'});\n }\n\n /** Toggles node between expanded/collapsed. Only works when node is not disabled. */\n async toggle(): Promise<void> {\n const toggle = await this._toggle();\n if (toggle) {\n return toggle.click();\n }\n }\n\n /** Expands the node if it is collapsed. Only works when node is not disabled. */\n async expand(): Promise<void> {\n if (!(await this.isExpanded())) {\n await this.toggle();\n }\n }\n\n /** Collapses the node if it is expanded. Only works when node is not disabled. */\n async collapse(): Promise<void> {\n if (await this.isExpanded()) {\n await this.toggle();\n }\n }\n}\n\nfunction getNodePredicate<T extends MatTreeNodeHarness>(\n type: ComponentHarnessConstructor<T>,\n options: TreeNodeHarnessFilters,\n): HarnessPredicate<T> {\n return new HarnessPredicate(type, options)\n .addOption('text', options.text, (harness, text) =>\n HarnessPredicate.stringMatches(harness.getText(), text),\n )\n .addOption(\n 'disabled',\n options.disabled,\n async (harness, disabled) => (await harness.isDisabled()) === disabled,\n )\n .addOption(\n 'expanded',\n options.expanded,\n async (harness, expanded) => (await harness.isExpanded()) === expanded,\n )\n .addOption(\n 'level',\n options.level,\n async (harness, level) => (await harness.getLevel()) === level,\n );\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ComponentHarness, HarnessPredicate, parallel} from '@angular/cdk/testing';\nimport {MatTreeNodeHarness} from './node-harness';\nimport {TreeHarnessFilters, TreeNodeHarnessFilters} from './tree-harness-filters';\n\nexport type TextTree = {\n text?: string;\n children?: TextTree[];\n};\n\n/** Harness for interacting with a standard mat-tree in tests. */\nexport class MatTreeHarness extends ComponentHarness {\n /** The selector for the host element of a `MatTableHarness` instance. */\n static hostSelector = '.mat-tree';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a tree with specific attributes.\n * @param options Options for narrowing the search\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(options: TreeHarnessFilters = {}): HarnessPredicate<MatTreeHarness> {\n return new HarnessPredicate(MatTreeHarness, options);\n }\n\n /** Gets all of the nodes in the tree. */\n async getNodes(filter: TreeNodeHarnessFilters = {}): Promise<MatTreeNodeHarness[]> {\n return this.locatorForAll(MatTreeNodeHarness.with(filter))();\n }\n\n /**\n * Gets an object representation for the visible tree structure\n * If a node is under an unexpanded node it will not be included.\n * Eg.\n * Tree (all nodes expanded):\n * `\n * <mat-tree>\n * <mat-tree-node>Node 1<mat-tree-node>\n * <mat-nested-tree-node>\n * Node 2\n * <mat-nested-tree-node>\n * Node 2.1\n * <mat-tree-node>\n * Node 2.1.1\n * <mat-tree-node>\n * <mat-nested-tree-node>\n * <mat-tree-node>\n * Node 2.2\n * <mat-tree-node>\n * <mat-nested-tree-node>\n * </mat-tree>`\n *\n * Tree structure:\n * {\n * children: [\n * {\n * text: 'Node 1',\n * children: [\n * {\n * text: 'Node 2',\n * children: [\n * {\n * text: 'Node 2.1',\n * children: [{text: 'Node 2.1.1'}]\n * },\n * {text: 'Node 2.2'}\n * ]\n * }\n * ]\n * }\n * ]\n * };\n */\n async getTreeStructure(): Promise<TextTree> {\n const nodes = await this.getNodes();\n const nodeInformation = await parallel(() =>\n nodes.map(node => {\n return parallel(() => [node.getLevel(), node.getText(), node.isExpanded()]);\n }),\n );\n return this._getTreeStructure(nodeInformation, 1, true);\n }\n\n /**\n * Recursively collect the structured text of the tree nodes.\n * @param nodes A list of tree nodes\n * @param level The level of nodes that are being accounted for during this iteration\n * @param parentExpanded Whether the parent of the first node in param nodes is expanded\n */\n private _getTreeStructure(\n nodes: [number, string, boolean][],\n level: number,\n parentExpanded: boolean,\n ): TextTree {\n const result: TextTree = {};\n for (let i = 0; i < nodes.length; i++) {\n const [nodeLevel, text, expanded] = nodes[i];\n const nextNodeLevel = nodes[i + 1]?.[0] ?? -1;\n\n // Return the accumulated value for the current level once we reach a shallower level node\n if (nodeLevel < level) {\n return result;\n }\n // Skip deeper level nodes during this iteration, they will be picked up in a later iteration\n if (nodeLevel > level) {\n continue;\n }\n // Only add to representation if it is visible (parent is expanded)\n if (parentExpanded) {\n // Collect the data under this node according to the following rules:\n // 1. If the next node in the list is a sibling of the current node add it to the child list\n // 2. If the next node is a child of the current node, get the sub-tree structure for the\n // child and add it under this node\n // 3. If the next node has a shallower level, we've reached the end of the child nodes for\n // the current parent.\n if (nextNodeLevel === level) {\n this._addChildToNode(result, {text});\n } else if (nextNodeLevel > level) {\n let children = this._getTreeStructure(\n nodes.slice(i + 1),\n nextNodeLevel,\n expanded,\n )?.children;\n let child = children ? {text, children} : {text};\n this._addChildToNode(result, child);\n } else {\n this._addChildToNode(result, {text});\n return result;\n }\n }\n }\n return result;\n }\n\n private _addChildToNode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,EAAC,CAAC;;AAC/B,qBAAA,IAAI,aAAa,GAAG,KAAK,EAAE;oBAChC,IAAI,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CACnC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAClB,aAAa,EACb,QAAQ,CACT,EAAE,QAAQ;AACX,oBAAA,IAAI,KAAK,GAAG,QAAQ,GAAG,EAAC,IAAI,EAAE,QAAQ,EAAC,GAAG,EAAC,IAAI,EAAC;AAChD,oBAAA,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC;;qBAC9B;oBACL,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,EAAC,IAAI,EAAC,CAAC;AACpC,oBAAA,OAAO,MAAM;;;;AAInB,QAAA,OAAO,MAAM;;IAGP,eAAe,CAAC,MAAgB,EAAE,KAAe,EAAA;QACvD,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC;;;;;;"}
|
|
1
|
+
{"version":3,"file":"tree-testing.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/src/material/tree/testing/node-harness.ts","../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/src/material/tree/testing/tree-harness.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n ComponentHarnessConstructor,\n ContentContainerComponentHarness,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport {TreeNodeHarnessFilters} from './tree-harness-filters';\nimport {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion';\n\n/** Harness for interacting with a standard Angular Material tree node. */\nexport class MatTreeNodeHarness extends ContentContainerComponentHarness<string> {\n /** The selector of the host element of a `MatTreeNode` instance. */\n static hostSelector = '.mat-tree-node, .mat-nested-tree-node';\n\n _toggle = this.locatorForOptional('[matTreeNodeToggle]');\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a tree node with specific attributes.\n * @param options Options for narrowing the search\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(options: TreeNodeHarnessFilters = {}): HarnessPredicate<MatTreeNodeHarness> {\n return getNodePredicate(MatTreeNodeHarness, options);\n }\n\n /** Whether the tree node is expanded. */\n async isExpanded(): Promise<boolean> {\n return coerceBooleanProperty(await (await this.host()).getAttribute('aria-expanded'));\n }\n\n /** Whether the tree node is expandable. */\n async isExpandable(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-expanded')) !== null;\n }\n\n /** Whether the tree node is disabled. */\n async isDisabled(): Promise<boolean> {\n return coerceBooleanProperty(await (await this.host()).getProperty('aria-disabled'));\n }\n\n /** Gets the level of the tree node. Note that this gets the aria-level and is 1 indexed. */\n async getLevel(): Promise<number> {\n return coerceNumberProperty(await (await this.host()).getAttribute('aria-level'));\n }\n\n /** Gets the tree node's text. */\n async getText(): Promise<string> {\n return (await this.host()).text({exclude: '.mat-tree-node, .mat-nested-tree-node, button'});\n }\n\n /** Toggles node between expanded/collapsed. Only works when node is not disabled. */\n async toggle(): Promise<void> {\n const toggle = await this._toggle();\n if (toggle) {\n return toggle.click();\n }\n }\n\n /** Expands the node if it is collapsed. Only works when node is not disabled. */\n async expand(): Promise<void> {\n if (!(await this.isExpanded())) {\n await this.toggle();\n }\n }\n\n /** Collapses the node if it is expanded. Only works when node is not disabled. */\n async collapse(): Promise<void> {\n if (await this.isExpanded()) {\n await this.toggle();\n }\n }\n}\n\nfunction getNodePredicate<T extends MatTreeNodeHarness>(\n type: ComponentHarnessConstructor<T>,\n options: TreeNodeHarnessFilters,\n): HarnessPredicate<T> {\n return new HarnessPredicate(type, options)\n .addOption('text', options.text, (harness, text) =>\n HarnessPredicate.stringMatches(harness.getText(), text),\n )\n .addOption(\n 'disabled',\n options.disabled,\n async (harness, disabled) => (await harness.isDisabled()) === disabled,\n )\n .addOption(\n 'expanded',\n options.expanded,\n async (harness, expanded) => (await harness.isExpanded()) === expanded,\n )\n .addOption(\n 'level',\n options.level,\n async (harness, level) => (await harness.getLevel()) === level,\n );\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ComponentHarness, HarnessPredicate, parallel} from '@angular/cdk/testing';\nimport {MatTreeNodeHarness} from './node-harness';\nimport {TreeHarnessFilters, TreeNodeHarnessFilters} from './tree-harness-filters';\n\nexport type TextTree = {\n text?: string;\n children?: TextTree[];\n};\n\n/** Harness for interacting with a standard mat-tree in tests. */\nexport class MatTreeHarness extends ComponentHarness {\n /** The selector for the host element of a `MatTableHarness` instance. */\n static hostSelector = '.mat-tree';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a tree with specific attributes.\n * @param options Options for narrowing the search\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(options: TreeHarnessFilters = {}): HarnessPredicate<MatTreeHarness> {\n return new HarnessPredicate(MatTreeHarness, options);\n }\n\n /** Gets all of the nodes in the tree. */\n async getNodes(filter: TreeNodeHarnessFilters = {}): Promise<MatTreeNodeHarness[]> {\n return this.locatorForAll(MatTreeNodeHarness.with(filter))();\n }\n\n /**\n * Gets an object representation for the visible tree structure\n * If a node is under an unexpanded node it will not be included.\n * Eg.\n * Tree (all nodes expanded):\n * `\n * <mat-tree>\n * <mat-tree-node>Node 1<mat-tree-node>\n * <mat-nested-tree-node>\n * Node 2\n * <mat-nested-tree-node>\n * Node 2.1\n * <mat-tree-node>\n * Node 2.1.1\n * <mat-tree-node>\n * <mat-nested-tree-node>\n * <mat-tree-node>\n * Node 2.2\n * <mat-tree-node>\n * <mat-nested-tree-node>\n * </mat-tree>`\n *\n * Tree structure:\n * {\n * children: [\n * {\n * text: 'Node 1',\n * children: [\n * {\n * text: 'Node 2',\n * children: [\n * {\n * text: 'Node 2.1',\n * children: [{text: 'Node 2.1.1'}]\n * },\n * {text: 'Node 2.2'}\n * ]\n * }\n * ]\n * }\n * ]\n * };\n */\n async getTreeStructure(): Promise<TextTree> {\n const nodes = await this.getNodes();\n const nodeInformation = await parallel(() =>\n nodes.map(node => {\n return parallel(() => [node.getLevel(), node.getText(), node.isExpanded()]);\n }),\n );\n return this._getTreeStructure(nodeInformation, 1, true);\n }\n\n /**\n * Recursively collect the structured text of the tree nodes.\n * @param nodes A list of tree nodes\n * @param level The level of nodes that are being accounted for during this iteration\n * @param parentExpanded Whether the parent of the first node in param nodes is expanded\n */\n private _getTreeStructure(\n nodes: [number, string, boolean][],\n level: number,\n parentExpanded: boolean,\n ): TextTree {\n const result: TextTree = {};\n for (let i = 0; i < nodes.length; i++) {\n const [nodeLevel, text, expanded] = nodes[i];\n const nextNodeLevel = nodes[i + 1]?.[0] ?? -1;\n\n // Return the accumulated value for the current level once we reach a shallower level node\n if (nodeLevel < level) {\n return result;\n }\n // Skip deeper level nodes during this iteration, they will be picked up in a later iteration\n if (nodeLevel > level) {\n continue;\n }\n // Only add to representation if it is visible (parent is expanded)\n if (parentExpanded) {\n // Collect the data under this node according to the following rules:\n // 1. If the next node in the list is a sibling of the current node add it to the child list\n // 2. If the next node is a child of the current node, get the sub-tree structure for the\n // child and add it under this node\n // 3. If the next node has a shallower level, we've reached the end of the child nodes for\n // the current parent.\n if (nextNodeLevel === level) {\n this._addChildToNode(result, {text});\n } else if (nextNodeLevel > level) {\n let children = this._getTreeStructure(\n nodes.slice(i + 1),\n nextNodeLevel,\n expanded,\n )?.children;\n let child = children ? {text, children} : {text};\n this._addChildToNode(result, child);\n } else {\n this._addChildToNode(result, {text});\n return result;\n }\n }\n }\n return result;\n }\n\n private _addChildToNode(result: TextTree, child: TextTree) {\n result.children ? result.children.push(child) : (result.children = [child]);\n }\n}\n"],"names":["_toggle","locatorForOptional","with","options","getNodePredicate","MatTreeNodeHarness","isExpandable","isDisabled","getLevel","getText","host","text","exclude","toggle","click","expand","isExpanded","level"],"mappings":";;;;;AAqBEA,EAAAA,OAAA,QAAAC,kBAAA,CAAA,qBAAA,CAAA;SAgB2CC,IAAAA,CAAAC,OAAA,GAAA,EAAA,EAAA;AAEzC,IAAA,OAAAC,gBAAc,CAAAC,kBAAgB,EAAAF,OAAiB,CAAA;;;;;AAU/CG,EAAAA,MAAAA,YAAAA,GAAA;;AAIF;AAEAC,EAAAA,MAAAA,UAAAA,GAAA;;AAIE;AAEEC,EAAAA,MAAAA,QAAAA,GAAA;;;eAMEC,GAAA;IACF,OAAAC,CAAAA,MAAAA,IAAAA,CAAAA,IAAA,IAAAC,IAAA,CAAA;MAAAC,OAAA,EAAA;AAAA,KAAA,CAAA;;AAKJC,EAAAA,MAAAA,MAAcA,GAAA;IACZ,MAAAA,MAAA,cAAAb,OAAA,EAAA;;MAGF,OAAAa,MAAA,CAAAC,KAAA,EAAA;;AAGF;cAQcC,GAAA;QAKA,EAAA,MAAA,IACR,CAAAC,UAAU,EAAA,CAAA,EAAA;YAIF,IAAA,CAAAH,MAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuBN,QAAA;AAQE;sBAEFI,KAAA,EAAA;;AAEE;wBAEJ,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|