@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
|
@@ -3,475 +3,292 @@ import { MatDividerHarness } from './divider-testing.mjs';
|
|
|
3
3
|
|
|
4
4
|
const iconSelector = '.mat-mdc-list-item-icon';
|
|
5
5
|
const avatarSelector = '.mat-mdc-list-item-avatar';
|
|
6
|
-
/**
|
|
7
|
-
* Gets a `HarnessPredicate` that applies the given `BaseListItemHarnessFilters` to the given
|
|
8
|
-
* list item harness.
|
|
9
|
-
* @template H The type of list item harness to create a predicate for.
|
|
10
|
-
* @param harnessType A constructor for a list item harness.
|
|
11
|
-
* @param options An instance of `BaseListItemHarnessFilters` to apply.
|
|
12
|
-
* @return A `HarnessPredicate` for the given harness type with the given options applied.
|
|
13
|
-
*/
|
|
14
6
|
function getListItemPredicate(harnessType, options) {
|
|
15
|
-
|
|
16
|
-
.addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text))
|
|
17
|
-
.addOption('fullText', options.fullText, (harness, fullText) => HarnessPredicate.stringMatches(harness.getFullText(), fullText))
|
|
18
|
-
.addOption('title', options.title, (harness, title) => HarnessPredicate.stringMatches(harness.getTitle(), title))
|
|
19
|
-
.addOption('secondaryText', options.secondaryText, (harness, secondaryText) => HarnessPredicate.stringMatches(harness.getSecondaryText(), secondaryText))
|
|
20
|
-
.addOption('tertiaryText', options.tertiaryText, (harness, tertiaryText) => HarnessPredicate.stringMatches(harness.getTertiaryText(), tertiaryText));
|
|
7
|
+
return new HarnessPredicate(harnessType, options).addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text)).addOption('fullText', options.fullText, (harness, fullText) => HarnessPredicate.stringMatches(harness.getFullText(), fullText)).addOption('title', options.title, (harness, title) => HarnessPredicate.stringMatches(harness.getTitle(), title)).addOption('secondaryText', options.secondaryText, (harness, secondaryText) => HarnessPredicate.stringMatches(harness.getSecondaryText(), secondaryText)).addOption('tertiaryText', options.tertiaryText, (harness, tertiaryText) => HarnessPredicate.stringMatches(harness.getTertiaryText(), tertiaryText));
|
|
21
8
|
}
|
|
22
|
-
/** Harness for interacting with a list subheader. */
|
|
23
9
|
class MatSubheaderHarness extends ComponentHarness {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
10
|
+
static hostSelector = '.mat-mdc-subheader';
|
|
11
|
+
static with(options = {}) {
|
|
12
|
+
return new HarnessPredicate(MatSubheaderHarness, options).addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text));
|
|
13
|
+
}
|
|
14
|
+
async getText() {
|
|
15
|
+
return (await this.host()).text();
|
|
16
|
+
}
|
|
32
17
|
}
|
|
33
|
-
/** Selectors for the various list item sections that may contain user content. */
|
|
34
18
|
var MatListItemSection;
|
|
35
19
|
(function (MatListItemSection) {
|
|
36
|
-
|
|
20
|
+
MatListItemSection["CONTENT"] = ".mdc-list-item__content";
|
|
37
21
|
})(MatListItemSection || (MatListItemSection = {}));
|
|
38
|
-
/** Enum describing the possible variants of a list item. */
|
|
39
22
|
var MatListItemType;
|
|
40
23
|
(function (MatListItemType) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
MatListItemType[MatListItemType["ONE_LINE_ITEM"] = 0] = "ONE_LINE_ITEM";
|
|
25
|
+
MatListItemType[MatListItemType["TWO_LINE_ITEM"] = 1] = "TWO_LINE_ITEM";
|
|
26
|
+
MatListItemType[MatListItemType["THREE_LINE_ITEM"] = 2] = "THREE_LINE_ITEM";
|
|
44
27
|
})(MatListItemType || (MatListItemType = {}));
|
|
45
|
-
/**
|
|
46
|
-
* Shared behavior among the harnesses for the various `MatListItem` flavors.
|
|
47
|
-
* @docs-private
|
|
48
|
-
*/
|
|
49
28
|
class MatListItemHarnessBase extends ContentContainerComponentHarness {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// is rendered as the secondary text (with potential text wrapping enabled).
|
|
112
|
-
if (lines.length >= 1) {
|
|
113
|
-
return lines[0].text();
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
return unscopedTextContent.text();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Gets the tertiary line text of the list item. Null if the list item
|
|
121
|
-
* does not have a tertiary line.
|
|
122
|
-
*/
|
|
123
|
-
async getTertiaryText() {
|
|
124
|
-
const type = await this.getType();
|
|
125
|
-
if (type !== MatListItemType.THREE_LINE_ITEM) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
const [lines, unscopedTextContent] = await parallel(() => [
|
|
129
|
-
this._lines(),
|
|
130
|
-
this._unscopedTextContent(),
|
|
131
|
-
]);
|
|
132
|
-
// First we check if there is an explicit line for the tertiary text. If so, we return it.
|
|
133
|
-
// If there is at least an explicit secondary line though, then we know that the unscoped
|
|
134
|
-
// text content corresponds to the tertiary line. If there are no explicit lines at all,
|
|
135
|
-
// we know that the unscoped text content from the secondary text just wraps into the third
|
|
136
|
-
// line, but there *no* actual dedicated tertiary text.
|
|
137
|
-
if (lines.length === 2) {
|
|
138
|
-
return lines[1].text();
|
|
139
|
-
}
|
|
140
|
-
else if (lines.length === 1) {
|
|
141
|
-
return unscopedTextContent.text();
|
|
142
|
-
}
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
/** Whether this list item has an avatar. */
|
|
146
|
-
async hasAvatar() {
|
|
147
|
-
return !!(await this._avatar());
|
|
148
|
-
}
|
|
149
|
-
/** Whether this list item has an icon. */
|
|
150
|
-
async hasIcon() {
|
|
151
|
-
return !!(await this._icon());
|
|
152
|
-
}
|
|
29
|
+
_lines = this.locatorForAll('.mat-mdc-list-item-line');
|
|
30
|
+
_primaryText = this.locatorFor('.mdc-list-item__primary-text');
|
|
31
|
+
_avatar = this.locatorForOptional('.mat-mdc-list-item-avatar');
|
|
32
|
+
_icon = this.locatorForOptional('.mat-mdc-list-item-icon');
|
|
33
|
+
_unscopedTextContent = this.locatorFor('.mat-mdc-list-item-unscoped-content');
|
|
34
|
+
async getType() {
|
|
35
|
+
const host = await this.host();
|
|
36
|
+
const [isOneLine, isTwoLine] = await parallel(() => [host.hasClass('mdc-list-item--with-one-line'), host.hasClass('mdc-list-item--with-two-lines')]);
|
|
37
|
+
if (isOneLine) {
|
|
38
|
+
return MatListItemType.ONE_LINE_ITEM;
|
|
39
|
+
} else if (isTwoLine) {
|
|
40
|
+
return MatListItemType.TWO_LINE_ITEM;
|
|
41
|
+
} else {
|
|
42
|
+
return MatListItemType.THREE_LINE_ITEM;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async getText() {
|
|
46
|
+
return this.getFullText();
|
|
47
|
+
}
|
|
48
|
+
async getFullText() {
|
|
49
|
+
return (await this.host()).text({
|
|
50
|
+
exclude: `${iconSelector}, ${avatarSelector}`
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async getTitle() {
|
|
54
|
+
return (await this._primaryText()).text();
|
|
55
|
+
}
|
|
56
|
+
async isDisabled() {
|
|
57
|
+
return (await this.host()).hasClass('mdc-list-item--disabled');
|
|
58
|
+
}
|
|
59
|
+
async getSecondaryText() {
|
|
60
|
+
const type = await this.getType();
|
|
61
|
+
if (type === MatListItemType.ONE_LINE_ITEM) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const [lines, unscopedTextContent] = await parallel(() => [this._lines(), this._unscopedTextContent()]);
|
|
65
|
+
if (lines.length >= 1) {
|
|
66
|
+
return lines[0].text();
|
|
67
|
+
} else {
|
|
68
|
+
return unscopedTextContent.text();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async getTertiaryText() {
|
|
72
|
+
const type = await this.getType();
|
|
73
|
+
if (type !== MatListItemType.THREE_LINE_ITEM) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const [lines, unscopedTextContent] = await parallel(() => [this._lines(), this._unscopedTextContent()]);
|
|
77
|
+
if (lines.length === 2) {
|
|
78
|
+
return lines[1].text();
|
|
79
|
+
} else if (lines.length === 1) {
|
|
80
|
+
return unscopedTextContent.text();
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
async hasAvatar() {
|
|
85
|
+
return !!(await this._avatar());
|
|
86
|
+
}
|
|
87
|
+
async hasIcon() {
|
|
88
|
+
return !!(await this._icon());
|
|
89
|
+
}
|
|
153
90
|
}
|
|
154
91
|
|
|
155
|
-
/**
|
|
156
|
-
* Shared behavior among the harnesses for the various `MatList` flavors.
|
|
157
|
-
* @template T A constructor type for a list item harness type used by this list harness.
|
|
158
|
-
* @template C The list item harness type that `T` constructs.
|
|
159
|
-
* @template F The filter type used filter list item harness of type `C`.
|
|
160
|
-
* @docs-private
|
|
161
|
-
*/
|
|
162
92
|
class MatListHarnessBase extends ComponentHarness {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
let currentSection = { items: [] };
|
|
181
|
-
const itemsAndSubheaders = await this.getItemsWithSubheadersAndDividers({
|
|
182
|
-
item: filters,
|
|
183
|
-
divider: false,
|
|
184
|
-
});
|
|
185
|
-
for (const itemOrSubheader of itemsAndSubheaders) {
|
|
186
|
-
if (itemOrSubheader instanceof MatSubheaderHarness) {
|
|
187
|
-
if (currentSection.heading !== undefined || currentSection.items.length) {
|
|
188
|
-
listSections.push(currentSection);
|
|
189
|
-
}
|
|
190
|
-
currentSection = { heading: itemOrSubheader.getText(), items: [] };
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
currentSection.items.push(itemOrSubheader);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if (currentSection.heading !== undefined ||
|
|
197
|
-
currentSection.items.length ||
|
|
198
|
-
!listSections.length) {
|
|
199
|
-
listSections.push(currentSection);
|
|
200
|
-
}
|
|
201
|
-
// Concurrently wait for all sections to resolve their heading if present.
|
|
202
|
-
return parallel(() => listSections.map(async (s) => ({ items: s.items, heading: await s.heading })));
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Gets a list of sub-lists representing the list items grouped by dividers. If the list has no
|
|
206
|
-
* dividers it is represented as a list with a single sub-list.
|
|
207
|
-
* @param filters Optional filters used to narrow which list item harnesses are included
|
|
208
|
-
* @return The list of items matching the given filters, grouped into sub-lists by divider.
|
|
209
|
-
*/
|
|
210
|
-
async getItemsGroupedByDividers(filters) {
|
|
211
|
-
const listSections = [[]];
|
|
212
|
-
const itemsAndDividers = await this.getItemsWithSubheadersAndDividers({
|
|
213
|
-
item: filters,
|
|
214
|
-
subheader: false,
|
|
215
|
-
});
|
|
216
|
-
for (const itemOrDivider of itemsAndDividers) {
|
|
217
|
-
if (itemOrDivider instanceof MatDividerHarness) {
|
|
218
|
-
listSections.push([]);
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
listSections[listSections.length - 1].push(itemOrDivider);
|
|
222
|
-
}
|
|
93
|
+
_itemHarness;
|
|
94
|
+
async getItems(filters) {
|
|
95
|
+
return this.locatorForAll(this._itemHarness.with(filters))();
|
|
96
|
+
}
|
|
97
|
+
async getItemsGroupedBySubheader(filters) {
|
|
98
|
+
const listSections = [];
|
|
99
|
+
let currentSection = {
|
|
100
|
+
items: []
|
|
101
|
+
};
|
|
102
|
+
const itemsAndSubheaders = await this.getItemsWithSubheadersAndDividers({
|
|
103
|
+
item: filters,
|
|
104
|
+
divider: false
|
|
105
|
+
});
|
|
106
|
+
for (const itemOrSubheader of itemsAndSubheaders) {
|
|
107
|
+
if (itemOrSubheader instanceof MatSubheaderHarness) {
|
|
108
|
+
if (currentSection.heading !== undefined || currentSection.items.length) {
|
|
109
|
+
listSections.push(currentSection);
|
|
223
110
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
111
|
+
currentSection = {
|
|
112
|
+
heading: itemOrSubheader.getText(),
|
|
113
|
+
items: []
|
|
114
|
+
};
|
|
115
|
+
} else {
|
|
116
|
+
currentSection.items.push(itemOrSubheader);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (currentSection.heading !== undefined || currentSection.items.length || !listSections.length) {
|
|
120
|
+
listSections.push(currentSection);
|
|
121
|
+
}
|
|
122
|
+
return parallel(() => listSections.map(async s => ({
|
|
123
|
+
items: s.items,
|
|
124
|
+
heading: await s.heading
|
|
125
|
+
})));
|
|
126
|
+
}
|
|
127
|
+
async getItemsGroupedByDividers(filters) {
|
|
128
|
+
const listSections = [[]];
|
|
129
|
+
const itemsAndDividers = await this.getItemsWithSubheadersAndDividers({
|
|
130
|
+
item: filters,
|
|
131
|
+
subheader: false
|
|
132
|
+
});
|
|
133
|
+
for (const itemOrDivider of itemsAndDividers) {
|
|
134
|
+
if (itemOrDivider instanceof MatDividerHarness) {
|
|
135
|
+
listSections.push([]);
|
|
136
|
+
} else {
|
|
137
|
+
listSections[listSections.length - 1].push(itemOrDivider);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return listSections;
|
|
141
|
+
}
|
|
142
|
+
async getItemsWithSubheadersAndDividers(filters = {}) {
|
|
143
|
+
const query = [];
|
|
144
|
+
if (filters.item !== false) {
|
|
145
|
+
query.push(this._itemHarness.with(filters.item || {}));
|
|
146
|
+
}
|
|
147
|
+
if (filters.subheader !== false) {
|
|
148
|
+
query.push(MatSubheaderHarness.with(filters.subheader));
|
|
149
|
+
}
|
|
150
|
+
if (filters.divider !== false) {
|
|
151
|
+
query.push(MatDividerHarness.with(filters.divider));
|
|
152
|
+
}
|
|
153
|
+
return this.locatorForAll(...query)();
|
|
154
|
+
}
|
|
239
155
|
}
|
|
240
156
|
|
|
241
|
-
/** Harness for interacting with a action-list in tests. */
|
|
242
157
|
class MatActionListHarness extends MatListHarnessBase {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
* @param options Options for filtering which action list instances are considered a match.
|
|
249
|
-
* @return a `HarnessPredicate` configured with the given options.
|
|
250
|
-
*/
|
|
251
|
-
static with(options = {}) {
|
|
252
|
-
return new HarnessPredicate(this, options);
|
|
253
|
-
}
|
|
254
|
-
_itemHarness = MatActionListItemHarness;
|
|
158
|
+
static hostSelector = '.mat-mdc-action-list';
|
|
159
|
+
static with(options = {}) {
|
|
160
|
+
return new HarnessPredicate(this, options);
|
|
161
|
+
}
|
|
162
|
+
_itemHarness = MatActionListItemHarness;
|
|
255
163
|
}
|
|
256
|
-
/** Harness for interacting with an action list item. */
|
|
257
164
|
class MatActionListItemHarness extends MatListItemHarnessBase {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
async focus() {
|
|
275
|
-
return (await this.host()).focus();
|
|
276
|
-
}
|
|
277
|
-
/** Blurs the action list item. */
|
|
278
|
-
async blur() {
|
|
279
|
-
return (await this.host()).blur();
|
|
280
|
-
}
|
|
281
|
-
/** Whether the action list item is focused. */
|
|
282
|
-
async isFocused() {
|
|
283
|
-
return (await this.host()).isFocused();
|
|
284
|
-
}
|
|
165
|
+
static hostSelector = `${MatActionListHarness.hostSelector} .mat-mdc-list-item`;
|
|
166
|
+
static with(options = {}) {
|
|
167
|
+
return getListItemPredicate(this, options);
|
|
168
|
+
}
|
|
169
|
+
async click() {
|
|
170
|
+
return (await this.host()).click();
|
|
171
|
+
}
|
|
172
|
+
async focus() {
|
|
173
|
+
return (await this.host()).focus();
|
|
174
|
+
}
|
|
175
|
+
async blur() {
|
|
176
|
+
return (await this.host()).blur();
|
|
177
|
+
}
|
|
178
|
+
async isFocused() {
|
|
179
|
+
return (await this.host()).isFocused();
|
|
180
|
+
}
|
|
285
181
|
}
|
|
286
182
|
|
|
287
|
-
/** Harness for interacting with a list in tests. */
|
|
288
183
|
class MatListHarness extends MatListHarnessBase {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
* @return a `HarnessPredicate` configured with the given options.
|
|
295
|
-
*/
|
|
296
|
-
static with(options = {}) {
|
|
297
|
-
return new HarnessPredicate(this, options);
|
|
298
|
-
}
|
|
299
|
-
_itemHarness = MatListItemHarness;
|
|
184
|
+
static hostSelector = '.mat-mdc-list';
|
|
185
|
+
static with(options = {}) {
|
|
186
|
+
return new HarnessPredicate(this, options);
|
|
187
|
+
}
|
|
188
|
+
_itemHarness = MatListItemHarness;
|
|
300
189
|
}
|
|
301
|
-
/** Harness for interacting with a list item. */
|
|
302
190
|
class MatListItemHarness extends MatListItemHarnessBase {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
* @param options Options for filtering which list item instances are considered a match.
|
|
308
|
-
* @return a `HarnessPredicate` configured with the given options.
|
|
309
|
-
*/
|
|
310
|
-
static with(options = {}) {
|
|
311
|
-
return getListItemPredicate(this, options);
|
|
312
|
-
}
|
|
191
|
+
static hostSelector = `${MatListHarness.hostSelector} .mat-mdc-list-item`;
|
|
192
|
+
static with(options = {}) {
|
|
193
|
+
return getListItemPredicate(this, options);
|
|
194
|
+
}
|
|
313
195
|
}
|
|
314
196
|
|
|
315
|
-
/** Harness for interacting with a mat-nav-list in tests. */
|
|
316
197
|
class MatNavListHarness extends MatListHarnessBase {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
* @param options Options for filtering which nav list instances are considered a match.
|
|
323
|
-
* @return a `HarnessPredicate` configured with the given options.
|
|
324
|
-
*/
|
|
325
|
-
static with(options = {}) {
|
|
326
|
-
return new HarnessPredicate(this, options);
|
|
327
|
-
}
|
|
328
|
-
_itemHarness = MatNavListItemHarness;
|
|
198
|
+
static hostSelector = '.mat-mdc-nav-list';
|
|
199
|
+
static with(options = {}) {
|
|
200
|
+
return new HarnessPredicate(this, options);
|
|
201
|
+
}
|
|
202
|
+
_itemHarness = MatNavListItemHarness;
|
|
329
203
|
}
|
|
330
|
-
/** Harness for interacting with a nav-list item. */
|
|
331
204
|
class MatNavListItemHarness extends MatListItemHarnessBase {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
async focus() {
|
|
355
|
-
return (await this.host()).focus();
|
|
356
|
-
}
|
|
357
|
-
/** Blurs the nav list item. */
|
|
358
|
-
async blur() {
|
|
359
|
-
return (await this.host()).blur();
|
|
360
|
-
}
|
|
361
|
-
/** Whether the nav list item is focused. */
|
|
362
|
-
async isFocused() {
|
|
363
|
-
return (await this.host()).isFocused();
|
|
364
|
-
}
|
|
365
|
-
/** Whether the list item is activated. Should only be used for nav list items. */
|
|
366
|
-
async isActivated() {
|
|
367
|
-
return (await this.host()).hasClass('mdc-list-item--activated');
|
|
368
|
-
}
|
|
205
|
+
static hostSelector = `${MatNavListHarness.hostSelector} .mat-mdc-list-item`;
|
|
206
|
+
static with(options = {}) {
|
|
207
|
+
return getListItemPredicate(this, options).addOption('href', options.href, async (harness, href) => HarnessPredicate.stringMatches(harness.getHref(), href)).addOption('activated', options.activated, async (harness, activated) => (await harness.isActivated()) === activated);
|
|
208
|
+
}
|
|
209
|
+
async getHref() {
|
|
210
|
+
return (await this.host()).getAttribute('href');
|
|
211
|
+
}
|
|
212
|
+
async click() {
|
|
213
|
+
return (await this.host()).click();
|
|
214
|
+
}
|
|
215
|
+
async focus() {
|
|
216
|
+
return (await this.host()).focus();
|
|
217
|
+
}
|
|
218
|
+
async blur() {
|
|
219
|
+
return (await this.host()).blur();
|
|
220
|
+
}
|
|
221
|
+
async isFocused() {
|
|
222
|
+
return (await this.host()).isFocused();
|
|
223
|
+
}
|
|
224
|
+
async isActivated() {
|
|
225
|
+
return (await this.host()).hasClass('mdc-list-item--activated');
|
|
226
|
+
}
|
|
369
227
|
}
|
|
370
228
|
|
|
371
|
-
/** Harness for interacting with a selection-list in tests. */
|
|
372
229
|
class MatSelectionListHarness extends MatListHarnessBase {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Deselects all items matching any of the given filters.
|
|
399
|
-
* @param filters Filters that specify which items should be deselected.
|
|
400
|
-
*/
|
|
401
|
-
async deselectItems(...filters) {
|
|
402
|
-
const items = await this._getItems(filters);
|
|
403
|
-
await parallel(() => items.map(item => item.deselect()));
|
|
404
|
-
}
|
|
405
|
-
/** Gets all items matching the given list of filters. */
|
|
406
|
-
async _getItems(filters) {
|
|
407
|
-
if (!filters.length) {
|
|
408
|
-
return this.getItems();
|
|
409
|
-
}
|
|
410
|
-
const matches = await parallel(() => filters.map(filter => this.locatorForAll(MatListOptionHarness.with(filter))()));
|
|
411
|
-
return matches.reduce((result, current) => [...result, ...current], []);
|
|
412
|
-
}
|
|
230
|
+
static hostSelector = '.mat-mdc-selection-list';
|
|
231
|
+
static with(options = {}) {
|
|
232
|
+
return new HarnessPredicate(this, options);
|
|
233
|
+
}
|
|
234
|
+
_itemHarness = MatListOptionHarness;
|
|
235
|
+
async isDisabled() {
|
|
236
|
+
return (await (await this.host()).getAttribute('aria-disabled')) === 'true';
|
|
237
|
+
}
|
|
238
|
+
async selectItems(...filters) {
|
|
239
|
+
const items = await this._getItems(filters);
|
|
240
|
+
await parallel(() => items.map(item => item.select()));
|
|
241
|
+
}
|
|
242
|
+
async deselectItems(...filters) {
|
|
243
|
+
const items = await this._getItems(filters);
|
|
244
|
+
await parallel(() => items.map(item => item.deselect()));
|
|
245
|
+
}
|
|
246
|
+
async _getItems(filters) {
|
|
247
|
+
if (!filters.length) {
|
|
248
|
+
return this.getItems();
|
|
249
|
+
}
|
|
250
|
+
const matches = await parallel(() => filters.map(filter => this.locatorForAll(MatListOptionHarness.with(filter))()));
|
|
251
|
+
return matches.reduce((result, current) => [...result, ...current], []);
|
|
252
|
+
}
|
|
413
253
|
}
|
|
414
|
-
/** Harness for interacting with a list option. */
|
|
415
254
|
class MatListOptionHarness extends MatListItemHarnessBase {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
/** Toggles the checked state of the checkbox. */
|
|
454
|
-
async toggle() {
|
|
455
|
-
return (await this.host()).click();
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* Puts the list option in a checked state by toggling it if it is currently
|
|
459
|
-
* unchecked, or doing nothing if it is already checked.
|
|
460
|
-
*/
|
|
461
|
-
async select() {
|
|
462
|
-
if (!(await this.isSelected())) {
|
|
463
|
-
return this.toggle();
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Puts the list option in an unchecked state by toggling it if it is currently
|
|
468
|
-
* checked, or doing nothing if it is already unchecked.
|
|
469
|
-
*/
|
|
470
|
-
async deselect() {
|
|
471
|
-
if (await this.isSelected()) {
|
|
472
|
-
return this.toggle();
|
|
473
|
-
}
|
|
474
|
-
}
|
|
255
|
+
static hostSelector = '.mat-mdc-list-option';
|
|
256
|
+
static with(options = {}) {
|
|
257
|
+
return getListItemPredicate(this, options).addOption('is selected', options.selected, async (harness, selected) => (await harness.isSelected()) === selected);
|
|
258
|
+
}
|
|
259
|
+
_beforeCheckbox = this.locatorForOptional('.mdc-list-item__start .mdc-checkbox');
|
|
260
|
+
_beforeRadio = this.locatorForOptional('.mdc-list-item__start .mdc-radio');
|
|
261
|
+
async getCheckboxPosition() {
|
|
262
|
+
return (await this._beforeCheckbox()) !== null ? 'before' : 'after';
|
|
263
|
+
}
|
|
264
|
+
async getRadioPosition() {
|
|
265
|
+
return (await this._beforeRadio()) !== null ? 'before' : 'after';
|
|
266
|
+
}
|
|
267
|
+
async isSelected() {
|
|
268
|
+
return (await (await this.host()).getAttribute('aria-selected')) === 'true';
|
|
269
|
+
}
|
|
270
|
+
async focus() {
|
|
271
|
+
return (await this.host()).focus();
|
|
272
|
+
}
|
|
273
|
+
async blur() {
|
|
274
|
+
return (await this.host()).blur();
|
|
275
|
+
}
|
|
276
|
+
async isFocused() {
|
|
277
|
+
return (await this.host()).isFocused();
|
|
278
|
+
}
|
|
279
|
+
async toggle() {
|
|
280
|
+
return (await this.host()).click();
|
|
281
|
+
}
|
|
282
|
+
async select() {
|
|
283
|
+
if (!(await this.isSelected())) {
|
|
284
|
+
return this.toggle();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async deselect() {
|
|
288
|
+
if (await this.isSelected()) {
|
|
289
|
+
return this.toggle();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
475
292
|
}
|
|
476
293
|
|
|
477
294
|
export { MatActionListHarness, MatActionListItemHarness, MatListHarness, MatListItemHarness, MatListItemSection, MatListItemType, MatListOptionHarness, MatNavListHarness, MatNavListItemHarness, MatSelectionListHarness, MatSubheaderHarness };
|