@angular/material 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.
Files changed (204) hide show
  1. package/core/tokens/_classes.scss +1 -1
  2. package/core/tokens/m2/_md-sys-color.scss +17 -17
  3. package/fesm2022/_animation-chunk.mjs +10 -16
  4. package/fesm2022/_animation-chunk.mjs.map +1 -1
  5. package/fesm2022/_date-formats-chunk.mjs +68 -164
  6. package/fesm2022/_date-formats-chunk.mjs.map +1 -1
  7. package/fesm2022/_date-range-input-harness-chunk.mjs +284 -463
  8. package/fesm2022/_date-range-input-harness-chunk.mjs.map +1 -1
  9. package/fesm2022/_error-options-chunk.mjs +56 -19
  10. package/fesm2022/_error-options-chunk.mjs.map +1 -1
  11. package/fesm2022/_error-state-chunk.mjs +24 -31
  12. package/fesm2022/_error-state-chunk.mjs.map +1 -1
  13. package/fesm2022/_form-field-chunk.mjs +1224 -1017
  14. package/fesm2022/_form-field-chunk.mjs.map +1 -1
  15. package/fesm2022/_icon-button-chunk.mjs +243 -187
  16. package/fesm2022/_icon-button-chunk.mjs.map +1 -1
  17. package/fesm2022/_icon-registry-chunk.mjs +350 -575
  18. package/fesm2022/_icon-registry-chunk.mjs.map +1 -1
  19. package/fesm2022/_input-harness-chunk.mjs +56 -107
  20. package/fesm2022/_input-harness-chunk.mjs.map +1 -1
  21. package/fesm2022/_input-value-accessor-chunk.mjs +0 -6
  22. package/fesm2022/_input-value-accessor-chunk.mjs.map +1 -1
  23. package/fesm2022/_internal-form-field-chunk.mjs +59 -19
  24. package/fesm2022/_internal-form-field-chunk.mjs.map +1 -1
  25. package/fesm2022/_line-chunk.mjs +83 -43
  26. package/fesm2022/_line-chunk.mjs.map +1 -1
  27. package/fesm2022/_option-chunk.mjs +348 -311
  28. package/fesm2022/_option-chunk.mjs.map +1 -1
  29. package/fesm2022/_option-harness-chunk.mjs +23 -39
  30. package/fesm2022/_option-harness-chunk.mjs.map +1 -1
  31. package/fesm2022/_option-module-chunk.mjs +36 -10
  32. package/fesm2022/_option-module-chunk.mjs.map +1 -1
  33. package/fesm2022/_pseudo-checkbox-chunk.mjs +79 -44
  34. package/fesm2022/_pseudo-checkbox-chunk.mjs.map +1 -1
  35. package/fesm2022/_pseudo-checkbox-module-chunk.mjs +36 -10
  36. package/fesm2022/_pseudo-checkbox-module-chunk.mjs.map +1 -1
  37. package/fesm2022/_public-api-chunk.mjs +71 -134
  38. package/fesm2022/_public-api-chunk.mjs.map +1 -1
  39. package/fesm2022/_ripple-chunk.mjs +504 -600
  40. package/fesm2022/_ripple-chunk.mjs.map +1 -1
  41. package/fesm2022/_ripple-loader-chunk.mjs +120 -138
  42. package/fesm2022/_ripple-loader-chunk.mjs.map +1 -1
  43. package/fesm2022/_ripple-module-chunk.mjs +36 -10
  44. package/fesm2022/_ripple-module-chunk.mjs.map +1 -1
  45. package/fesm2022/_structural-styles-chunk.mjs +37 -10
  46. package/fesm2022/_structural-styles-chunk.mjs.map +1 -1
  47. package/fesm2022/_tooltip-chunk.mjs +810 -888
  48. package/fesm2022/_tooltip-chunk.mjs.map +1 -1
  49. package/fesm2022/autocomplete-testing.mjs +62 -86
  50. package/fesm2022/autocomplete-testing.mjs.map +1 -1
  51. package/fesm2022/autocomplete.mjs +965 -1126
  52. package/fesm2022/autocomplete.mjs.map +1 -1
  53. package/fesm2022/badge-testing.mjs +38 -54
  54. package/fesm2022/badge-testing.mjs.map +1 -1
  55. package/fesm2022/badge.mjs +321 -272
  56. package/fesm2022/badge.mjs.map +1 -1
  57. package/fesm2022/bottom-sheet-testing.mjs +10 -24
  58. package/fesm2022/bottom-sheet-testing.mjs.map +1 -1
  59. package/fesm2022/bottom-sheet.mjs +349 -344
  60. package/fesm2022/bottom-sheet.mjs.map +1 -1
  61. package/fesm2022/button-testing.mjs +60 -94
  62. package/fesm2022/button-testing.mjs.map +1 -1
  63. package/fesm2022/button-toggle-testing.mjs +76 -125
  64. package/fesm2022/button-toggle-testing.mjs.map +1 -1
  65. package/fesm2022/button-toggle.mjs +752 -662
  66. package/fesm2022/button-toggle.mjs.map +1 -1
  67. package/fesm2022/button.mjs +263 -158
  68. package/fesm2022/button.mjs.map +1 -1
  69. package/fesm2022/card-testing.mjs +19 -33
  70. package/fesm2022/card-testing.mjs.map +1 -1
  71. package/fesm2022/card.mjs +576 -272
  72. package/fesm2022/card.mjs.map +1 -1
  73. package/fesm2022/checkbox-testing.mjs +71 -123
  74. package/fesm2022/checkbox-testing.mjs.map +1 -1
  75. package/fesm2022/checkbox.mjs +515 -477
  76. package/fesm2022/checkbox.mjs.map +1 -1
  77. package/fesm2022/chips-testing.mjs +201 -350
  78. package/fesm2022/chips-testing.mjs.map +1 -1
  79. package/fesm2022/chips.mjs +2552 -2289
  80. package/fesm2022/chips.mjs.map +1 -1
  81. package/fesm2022/core-testing.mjs +14 -28
  82. package/fesm2022/core-testing.mjs.map +1 -1
  83. package/fesm2022/core.mjs +357 -328
  84. package/fesm2022/core.mjs.map +1 -1
  85. package/fesm2022/datepicker-testing.mjs +15 -25
  86. package/fesm2022/datepicker-testing.mjs.map +1 -1
  87. package/fesm2022/datepicker.mjs +4826 -4563
  88. package/fesm2022/datepicker.mjs.map +1 -1
  89. package/fesm2022/dialog-testing.mjs +93 -129
  90. package/fesm2022/dialog-testing.mjs.map +1 -1
  91. package/fesm2022/dialog.mjs +810 -829
  92. package/fesm2022/dialog.mjs.map +1 -1
  93. package/fesm2022/divider-testing.mjs +10 -11
  94. package/fesm2022/divider-testing.mjs.map +1 -1
  95. package/fesm2022/divider.mjs +119 -43
  96. package/fesm2022/divider.mjs.map +1 -1
  97. package/fesm2022/expansion-testing.mjs +74 -130
  98. package/fesm2022/expansion-testing.mjs.map +1 -1
  99. package/fesm2022/expansion.mjs +703 -515
  100. package/fesm2022/expansion.mjs.map +1 -1
  101. package/fesm2022/form-field-testing-control.mjs +16 -33
  102. package/fesm2022/form-field-testing-control.mjs.map +1 -1
  103. package/fesm2022/form-field-testing.mjs +118 -179
  104. package/fesm2022/form-field-testing.mjs.map +1 -1
  105. package/fesm2022/form-field.mjs +36 -10
  106. package/fesm2022/form-field.mjs.map +1 -1
  107. package/fesm2022/grid-list-testing.mjs +65 -113
  108. package/fesm2022/grid-list-testing.mjs.map +1 -1
  109. package/fesm2022/grid-list.mjs +559 -494
  110. package/fesm2022/grid-list.mjs.map +1 -1
  111. package/fesm2022/icon-testing.mjs +148 -127
  112. package/fesm2022/icon-testing.mjs.map +1 -1
  113. package/fesm2022/icon.mjs +325 -351
  114. package/fesm2022/icon.mjs.map +1 -1
  115. package/fesm2022/input-testing.mjs +59 -99
  116. package/fesm2022/input-testing.mjs.map +1 -1
  117. package/fesm2022/input.mjs +457 -520
  118. package/fesm2022/input.mjs.map +1 -1
  119. package/fesm2022/list-testing.mjs +251 -434
  120. package/fesm2022/list-testing.mjs.map +1 -1
  121. package/fesm2022/list.mjs +1522 -1204
  122. package/fesm2022/list.mjs.map +1 -1
  123. package/fesm2022/material.mjs +0 -5
  124. package/fesm2022/material.mjs.map +1 -1
  125. package/fesm2022/menu-testing.mjs +159 -228
  126. package/fesm2022/menu-testing.mjs.map +1 -1
  127. package/fesm2022/menu.mjs +1338 -1343
  128. package/fesm2022/menu.mjs.map +1 -1
  129. package/fesm2022/paginator-testing.mjs +55 -79
  130. package/fesm2022/paginator-testing.mjs.map +1 -1
  131. package/fesm2022/paginator.mjs +381 -309
  132. package/fesm2022/paginator.mjs.map +1 -1
  133. package/fesm2022/progress-bar-testing.mjs +12 -21
  134. package/fesm2022/progress-bar-testing.mjs.map +1 -1
  135. package/fesm2022/progress-bar.mjs +224 -169
  136. package/fesm2022/progress-bar.mjs.map +1 -1
  137. package/fesm2022/progress-spinner-testing.mjs +13 -23
  138. package/fesm2022/progress-spinner-testing.mjs.map +1 -1
  139. package/fesm2022/progress-spinner.mjs +235 -160
  140. package/fesm2022/progress-spinner.mjs.map +1 -1
  141. package/fesm2022/radio-testing.mjs +133 -208
  142. package/fesm2022/radio-testing.mjs.map +1 -1
  143. package/fesm2022/radio.mjs +712 -679
  144. package/fesm2022/radio.mjs.map +1 -1
  145. package/fesm2022/select-testing.mjs +83 -117
  146. package/fesm2022/select-testing.mjs.map +1 -1
  147. package/fesm2022/select.mjs +1116 -1246
  148. package/fesm2022/select.mjs.map +1 -1
  149. package/fesm2022/sidenav-testing.mjs +54 -120
  150. package/fesm2022/sidenav-testing.mjs.map +1 -1
  151. package/fesm2022/sidenav.mjs +1078 -995
  152. package/fesm2022/sidenav.mjs.map +1 -1
  153. package/fesm2022/slide-toggle-testing.mjs +57 -92
  154. package/fesm2022/slide-toggle-testing.mjs.map +1 -1
  155. package/fesm2022/slide-toggle.mjs +369 -279
  156. package/fesm2022/slide-toggle.mjs.map +1 -1
  157. package/fesm2022/slider-testing.mjs +90 -138
  158. package/fesm2022/slider-testing.mjs.map +1 -1
  159. package/fesm2022/slider.mjs +1651 -1716
  160. package/fesm2022/slider.mjs.map +1 -1
  161. package/fesm2022/snack-bar-testing.mjs +40 -87
  162. package/fesm2022/snack-bar-testing.mjs.map +1 -1
  163. package/fesm2022/snack-bar.mjs +763 -714
  164. package/fesm2022/snack-bar.mjs.map +1 -1
  165. package/fesm2022/sort-testing.mjs +45 -66
  166. package/fesm2022/sort-testing.mjs.map +1 -1
  167. package/fesm2022/sort.mjs +419 -344
  168. package/fesm2022/sort.mjs.map +1 -1
  169. package/fesm2022/stepper-testing.mjs +78 -154
  170. package/fesm2022/stepper-testing.mjs.map +1 -1
  171. package/fesm2022/stepper.mjs +790 -498
  172. package/fesm2022/stepper.mjs.map +1 -1
  173. package/fesm2022/table-testing.mjs +125 -186
  174. package/fesm2022/table-testing.mjs.map +1 -1
  175. package/fesm2022/table.mjs +1026 -684
  176. package/fesm2022/table.mjs.map +1 -1
  177. package/fesm2022/tabs-testing.mjs +125 -197
  178. package/fesm2022/tabs-testing.mjs.map +1 -1
  179. package/fesm2022/tabs.mjs +2351 -2028
  180. package/fesm2022/tabs.mjs.map +1 -1
  181. package/fesm2022/timepicker-testing.mjs +113 -172
  182. package/fesm2022/timepicker-testing.mjs.map +1 -1
  183. package/fesm2022/timepicker.mjs +1019 -826
  184. package/fesm2022/timepicker.mjs.map +1 -1
  185. package/fesm2022/toolbar-testing.mjs +16 -27
  186. package/fesm2022/toolbar-testing.mjs.map +1 -1
  187. package/fesm2022/toolbar.mjs +163 -78
  188. package/fesm2022/toolbar.mjs.map +1 -1
  189. package/fesm2022/tooltip-testing.mjs +41 -52
  190. package/fesm2022/tooltip-testing.mjs.map +1 -1
  191. package/fesm2022/tooltip.mjs +36 -10
  192. package/fesm2022/tooltip.mjs.map +1 -1
  193. package/fesm2022/tree-testing.mjs +86 -162
  194. package/fesm2022/tree-testing.mjs.map +1 -1
  195. package/fesm2022/tree.mjs +638 -466
  196. package/fesm2022/tree.mjs.map +1 -1
  197. package/package.json +2 -2
  198. package/schematics/ng-add/index.js +1 -1
  199. package/types/expansion.d.ts +4 -2
  200. package/types/menu-testing.d.ts +2 -0
  201. package/types/select.d.ts +1 -1
  202. package/types/sort.d.ts +1 -1
  203. package/types/table-testing.d.ts +27 -1
  204. package/types/timepicker.d.ts +148 -128
@@ -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
- return new HarnessPredicate(harnessType, options)
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
- static hostSelector = '.mat-mdc-subheader';
25
- static with(options = {}) {
26
- return new HarnessPredicate(MatSubheaderHarness, options).addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text));
27
- }
28
- /** Gets the full text content of the list item (including text from any font icons). */
29
- async getText() {
30
- return (await this.host()).text();
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
- MatListItemSection["CONTENT"] = ".mdc-list-item__content";
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
- MatListItemType[MatListItemType["ONE_LINE_ITEM"] = 0] = "ONE_LINE_ITEM";
42
- MatListItemType[MatListItemType["TWO_LINE_ITEM"] = 1] = "TWO_LINE_ITEM";
43
- MatListItemType[MatListItemType["THREE_LINE_ITEM"] = 2] = "THREE_LINE_ITEM";
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
- _lines = this.locatorForAll('.mat-mdc-list-item-line');
51
- _primaryText = this.locatorFor('.mdc-list-item__primary-text');
52
- _avatar = this.locatorForOptional('.mat-mdc-list-item-avatar');
53
- _icon = this.locatorForOptional('.mat-mdc-list-item-icon');
54
- _unscopedTextContent = this.locatorFor('.mat-mdc-list-item-unscoped-content');
55
- /** Gets the type of the list item, currently describing how many lines there are. */
56
- async getType() {
57
- const host = await this.host();
58
- const [isOneLine, isTwoLine] = await parallel(() => [
59
- host.hasClass('mdc-list-item--with-one-line'),
60
- host.hasClass('mdc-list-item--with-two-lines'),
61
- ]);
62
- if (isOneLine) {
63
- return MatListItemType.ONE_LINE_ITEM;
64
- }
65
- else if (isTwoLine) {
66
- return MatListItemType.TWO_LINE_ITEM;
67
- }
68
- else {
69
- return MatListItemType.THREE_LINE_ITEM;
70
- }
71
- }
72
- /**
73
- * Gets the full text content of the list item, excluding text
74
- * from icons and avatars.
75
- *
76
- * @deprecated Use the `getFullText` method instead.
77
- * @breaking-change 16.0.0
78
- */
79
- async getText() {
80
- return this.getFullText();
81
- }
82
- /**
83
- * Gets the full text content of the list item, excluding text
84
- * from icons and avatars.
85
- */
86
- async getFullText() {
87
- return (await this.host()).text({ exclude: `${iconSelector}, ${avatarSelector}` });
88
- }
89
- /** Gets the title of the list item. */
90
- async getTitle() {
91
- return (await this._primaryText()).text();
92
- }
93
- /** Whether the list item is disabled. */
94
- async isDisabled() {
95
- return (await this.host()).hasClass('mdc-list-item--disabled');
96
- }
97
- /**
98
- * Gets the secondary line text of the list item. Null if the list item
99
- * does not have a secondary line.
100
- */
101
- async getSecondaryText() {
102
- const type = await this.getType();
103
- if (type === MatListItemType.ONE_LINE_ITEM) {
104
- return null;
105
- }
106
- const [lines, unscopedTextContent] = await parallel(() => [
107
- this._lines(),
108
- this._unscopedTextContent(),
109
- ]);
110
- // If there is no explicit line for the secondary text, the unscoped text content
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
- _itemHarness;
164
- /**
165
- * Gets a list of harnesses representing the items in this list.
166
- * @param filters Optional filters used to narrow which harnesses are included
167
- * @return The list of items matching the given filters.
168
- */
169
- async getItems(filters) {
170
- return this.locatorForAll(this._itemHarness.with(filters))();
171
- }
172
- /**
173
- * Gets a list of `ListSection` representing the list items grouped by subheaders. If the list has
174
- * no subheaders it is represented as a single `ListSection` with an undefined `heading` property.
175
- * @param filters Optional filters used to narrow which list item harnesses are included
176
- * @return The list of items matching the given filters, grouped into sections by subheader.
177
- */
178
- async getItemsGroupedBySubheader(filters) {
179
- const listSections = [];
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
- return listSections;
225
- }
226
- async getItemsWithSubheadersAndDividers(filters = {}) {
227
- const query = [];
228
- if (filters.item !== false) {
229
- query.push(this._itemHarness.with(filters.item || {}));
230
- }
231
- if (filters.subheader !== false) {
232
- query.push(MatSubheaderHarness.with(filters.subheader));
233
- }
234
- if (filters.divider !== false) {
235
- query.push(MatDividerHarness.with(filters.divider));
236
- }
237
- return this.locatorForAll(...query)();
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
- /** The selector for the host element of a `MatActionList` instance. */
244
- static hostSelector = '.mat-mdc-action-list';
245
- /**
246
- * Gets a `HarnessPredicate` that can be used to search for an action list with specific
247
- * attributes.
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
- /** The selector for the host element of a `MatListItem` instance. */
259
- static hostSelector = `${MatActionListHarness.hostSelector} .mat-mdc-list-item`;
260
- /**
261
- * Gets a `HarnessPredicate` that can be used to search for a list item with specific
262
- * attributes.
263
- * @param options Options for filtering which action list item instances are considered a match.
264
- * @return a `HarnessPredicate` configured with the given options.
265
- */
266
- static with(options = {}) {
267
- return getListItemPredicate(this, options);
268
- }
269
- /** Clicks on the action list item. */
270
- async click() {
271
- return (await this.host()).click();
272
- }
273
- /** Focuses the action list item. */
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
- /** The selector for the host element of a `MatList` instance. */
290
- static hostSelector = '.mat-mdc-list';
291
- /**
292
- * Gets a `HarnessPredicate` that can be used to search for a list with specific attributes.
293
- * @param options Options for filtering which list instances are considered a match.
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
- /** The selector for the host element of a `MatListItem` instance. */
304
- static hostSelector = `${MatListHarness.hostSelector} .mat-mdc-list-item`;
305
- /**
306
- * Gets a `HarnessPredicate` that can be used to search for a list item with specific attributes.
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
- /** The selector for the host element of a `MatNavList` instance. */
318
- static hostSelector = '.mat-mdc-nav-list';
319
- /**
320
- * Gets a `HarnessPredicate` that can be used to search for a nav list with specific
321
- * attributes.
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
- /** The selector for the host element of a `MatListItem` instance. */
333
- static hostSelector = `${MatNavListHarness.hostSelector} .mat-mdc-list-item`;
334
- /**
335
- * Gets a `HarnessPredicate` that can be used to search for a nav list item with specific
336
- * attributes.
337
- * @param options Options for filtering which nav list item instances are considered a match.
338
- * @return a `HarnessPredicate` configured with the given options.
339
- */
340
- static with(options = {}) {
341
- return getListItemPredicate(this, options)
342
- .addOption('href', options.href, async (harness, href) => HarnessPredicate.stringMatches(harness.getHref(), href))
343
- .addOption('activated', options.activated, async (harness, activated) => (await harness.isActivated()) === activated);
344
- }
345
- /** Gets the href for this nav list item. */
346
- async getHref() {
347
- return (await this.host()).getAttribute('href');
348
- }
349
- /** Clicks on the nav list item. */
350
- async click() {
351
- return (await this.host()).click();
352
- }
353
- /** Focuses the nav list item. */
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
- /** The selector for the host element of a `MatSelectionList` instance. */
374
- static hostSelector = '.mat-mdc-selection-list';
375
- /**
376
- * Gets a `HarnessPredicate` that can be used to search for a selection list with specific
377
- * attributes.
378
- * @param options Options for filtering which selection list instances are considered a match.
379
- * @return a `HarnessPredicate` configured with the given options.
380
- */
381
- static with(options = {}) {
382
- return new HarnessPredicate(this, options);
383
- }
384
- _itemHarness = MatListOptionHarness;
385
- /** Whether the selection list is disabled. */
386
- async isDisabled() {
387
- return (await (await this.host()).getAttribute('aria-disabled')) === 'true';
388
- }
389
- /**
390
- * Selects all items matching any of the given filters.
391
- * @param filters Filters that specify which items should be selected.
392
- */
393
- async selectItems(...filters) {
394
- const items = await this._getItems(filters);
395
- await parallel(() => items.map(item => item.select()));
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
- /** The selector for the host element of a `MatListOption` instance. */
417
- static hostSelector = '.mat-mdc-list-option';
418
- /**
419
- * Gets a `HarnessPredicate` that can be used to search for a list option with specific
420
- * attributes.
421
- * @param options Options for filtering which list option instances are considered a match.
422
- * @return a `HarnessPredicate` configured with the given options.
423
- */
424
- static with(options = {}) {
425
- return getListItemPredicate(this, options).addOption('is selected', options.selected, async (harness, selected) => (await harness.isSelected()) === selected);
426
- }
427
- _beforeCheckbox = this.locatorForOptional('.mdc-list-item__start .mdc-checkbox');
428
- _beforeRadio = this.locatorForOptional('.mdc-list-item__start .mdc-radio');
429
- /** Gets the position of the checkbox relative to the list option content. */
430
- async getCheckboxPosition() {
431
- return (await this._beforeCheckbox()) !== null ? 'before' : 'after';
432
- }
433
- /** Gets the position of the radio relative to the list option content. */
434
- async getRadioPosition() {
435
- return (await this._beforeRadio()) !== null ? 'before' : 'after';
436
- }
437
- /** Whether the list option is selected. */
438
- async isSelected() {
439
- return (await (await this.host()).getAttribute('aria-selected')) === 'true';
440
- }
441
- /** Focuses the list option. */
442
- async focus() {
443
- return (await this.host()).focus();
444
- }
445
- /** Blurs the list option. */
446
- async blur() {
447
- return (await this.host()).blur();
448
- }
449
- /** Whether the list option is focused. */
450
- async isFocused() {
451
- return (await this.host()).isFocused();
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 };