@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
@@ -1,387 +1,238 @@
1
1
  import { ComponentHarness, HarnessPredicate, ContentContainerComponentHarness, TestKey, parallel } from '@angular/cdk/testing';
2
2
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
3
3
 
4
- /** Harness for interacting with a standard Material chip avatar in tests. */
5
4
  class MatChipAvatarHarness extends ComponentHarness {
6
- static hostSelector = '.mat-mdc-chip-avatar';
7
- /**
8
- * Gets a `HarnessPredicate` that can be used to search for a chip avatar with specific
9
- * attributes.
10
- * @param options Options for filtering which input instances are considered a match.
11
- * @return a `HarnessPredicate` configured with the given options.
12
- */
13
- static with(options = {}) {
14
- return new HarnessPredicate(this, options);
15
- }
5
+ static hostSelector = '.mat-mdc-chip-avatar';
6
+ static with(options = {}) {
7
+ return new HarnessPredicate(this, options);
8
+ }
16
9
  }
17
10
 
18
- /** Harness for interacting with a standard Material chip edit button in tests. */
19
11
  class MatChipEditHarness extends ComponentHarness {
20
- static hostSelector = '.mat-mdc-chip-edit';
21
- /**
22
- * Gets a `HarnessPredicate` that can be used to search for a chip edit with specific
23
- * attributes.
24
- * @param options Options for filtering which input instances are considered a match.
25
- * @return a `HarnessPredicate` configured with the given options.
26
- */
27
- static with(options = {}) {
28
- return new HarnessPredicate(this, options);
29
- }
30
- /** Clicks the edit button. */
31
- async click() {
32
- return (await this.host()).click();
33
- }
12
+ static hostSelector = '.mat-mdc-chip-edit';
13
+ static with(options = {}) {
14
+ return new HarnessPredicate(this, options);
15
+ }
16
+ async click() {
17
+ return (await this.host()).click();
18
+ }
34
19
  }
35
20
 
36
- /** Harness for interacting with a standard Material chip remove button in tests. */
37
21
  class MatChipRemoveHarness extends ComponentHarness {
38
- static hostSelector = '.mat-mdc-chip-remove';
39
- /**
40
- * Gets a `HarnessPredicate` that can be used to search for a chip remove with specific
41
- * attributes.
42
- * @param options Options for filtering which input instances are considered a match.
43
- * @return a `HarnessPredicate` configured with the given options.
44
- */
45
- static with(options = {}) {
46
- return new HarnessPredicate(this, options);
47
- }
48
- /** Clicks the remove button. */
49
- async click() {
50
- return (await this.host()).click();
51
- }
22
+ static hostSelector = '.mat-mdc-chip-remove';
23
+ static with(options = {}) {
24
+ return new HarnessPredicate(this, options);
25
+ }
26
+ async click() {
27
+ return (await this.host()).click();
28
+ }
52
29
  }
53
30
 
54
- /** Harness for interacting with a mat-chip in tests. */
55
31
  class MatChipHarness extends ContentContainerComponentHarness {
56
- _primaryAction = this.locatorFor('.mdc-evolution-chip__action--primary');
57
- static hostSelector = '.mat-mdc-basic-chip, .mat-mdc-chip';
58
- /**
59
- * Gets a `HarnessPredicate` that can be used to search for a chip with specific attributes.
60
- * @param options Options for narrowing the search.
61
- * @return a `HarnessPredicate` configured with the given options.
62
- */
63
- static with(options = {}) {
64
- return new HarnessPredicate(this, options)
65
- .addOption('text', options.text, (harness, label) => {
66
- return HarnessPredicate.stringMatches(harness.getText(), label);
67
- })
68
- .addOption('disabled', options.disabled, async (harness, disabled) => {
69
- return (await harness.isDisabled()) === disabled;
70
- });
71
- }
72
- /** Gets a promise for the text content the option. */
73
- async getText() {
74
- return (await this.host()).text({
75
- exclude: '.mat-mdc-chip-avatar, .mat-mdc-chip-trailing-icon, .mat-icon',
76
- });
77
- }
78
- /** Whether the chip is disabled. */
79
- async isDisabled() {
80
- return (await this.host()).hasClass('mat-mdc-chip-disabled');
81
- }
82
- /** Delete a chip from the set. */
83
- async remove() {
84
- const hostEl = await this.host();
85
- await hostEl.sendKeys(TestKey.DELETE);
86
- }
87
- /**
88
- * Gets the edit button inside of a chip.
89
- * @param filter Optionally filters which chips are included.
90
- */
91
- async geEditButton(filter = {}) {
92
- return this.locatorFor(MatChipEditHarness.with(filter))();
93
- }
94
- /**
95
- * Gets the remove button inside of a chip.
96
- * @param filter Optionally filters which chips are included.
97
- */
98
- async getRemoveButton(filter = {}) {
99
- return this.locatorFor(MatChipRemoveHarness.with(filter))();
100
- }
101
- /**
102
- * Gets the avatar inside a chip.
103
- * @param filter Optionally filters which avatars are included.
104
- */
105
- async getAvatar(filter = {}) {
106
- return this.locatorForOptional(MatChipAvatarHarness.with(filter))();
107
- }
32
+ _primaryAction = this.locatorFor('.mdc-evolution-chip__action--primary');
33
+ static hostSelector = '.mat-mdc-basic-chip, .mat-mdc-chip';
34
+ static with(options = {}) {
35
+ return new HarnessPredicate(this, options).addOption('text', options.text, (harness, label) => {
36
+ return HarnessPredicate.stringMatches(harness.getText(), label);
37
+ }).addOption('disabled', options.disabled, async (harness, disabled) => {
38
+ return (await harness.isDisabled()) === disabled;
39
+ });
40
+ }
41
+ async getText() {
42
+ return (await this.host()).text({
43
+ exclude: '.mat-mdc-chip-avatar, .mat-mdc-chip-trailing-icon, .mat-icon'
44
+ });
45
+ }
46
+ async isDisabled() {
47
+ return (await this.host()).hasClass('mat-mdc-chip-disabled');
48
+ }
49
+ async remove() {
50
+ const hostEl = await this.host();
51
+ await hostEl.sendKeys(TestKey.DELETE);
52
+ }
53
+ async geEditButton(filter = {}) {
54
+ return this.locatorFor(MatChipEditHarness.with(filter))();
55
+ }
56
+ async getRemoveButton(filter = {}) {
57
+ return this.locatorFor(MatChipRemoveHarness.with(filter))();
58
+ }
59
+ async getAvatar(filter = {}) {
60
+ return this.locatorForOptional(MatChipAvatarHarness.with(filter))();
61
+ }
108
62
  }
109
63
 
110
- /** Harness for interacting with a grid's chip input in tests. */
111
64
  class MatChipInputHarness extends ComponentHarness {
112
- static hostSelector = '.mat-mdc-chip-input';
113
- /**
114
- * Gets a `HarnessPredicate` that can be used to search for a chip input with specific
115
- * attributes.
116
- * @param options Options for filtering which input instances are considered a match.
117
- * @return a `HarnessPredicate` configured with the given options.
118
- */
119
- static with(options = {}) {
120
- return new HarnessPredicate(this, options)
121
- .addOption('value', options.value, async (harness, value) => {
122
- return (await harness.getValue()) === value;
123
- })
124
- .addOption('placeholder', options.placeholder, async (harness, placeholder) => {
125
- return (await harness.getPlaceholder()) === placeholder;
126
- })
127
- .addOption('disabled', options.disabled, async (harness, disabled) => {
128
- return (await harness.isDisabled()) === disabled;
129
- });
130
- }
131
- /** Whether the input is disabled. */
132
- async isDisabled() {
133
- const host = await this.host();
134
- const disabled = await host.getAttribute('disabled');
135
- if (disabled !== null) {
136
- return coerceBooleanProperty(disabled);
137
- }
138
- return (await host.getAttribute('aria-disabled')) === 'true';
139
- }
140
- /** Whether the input is required. */
141
- async isRequired() {
142
- return (await this.host()).getProperty('required');
143
- }
144
- /** Gets the value of the input. */
145
- async getValue() {
146
- // The "value" property of the native input is never undefined.
147
- return await (await this.host()).getProperty('value');
148
- }
149
- /** Gets the placeholder of the input. */
150
- async getPlaceholder() {
151
- return await (await this.host()).getProperty('placeholder');
152
- }
153
- /**
154
- * Focuses the input and returns a promise that indicates when the
155
- * action is complete.
156
- */
157
- async focus() {
158
- return (await this.host()).focus();
159
- }
160
- /**
161
- * Blurs the input and returns a promise that indicates when the
162
- * action is complete.
163
- */
164
- async blur() {
165
- return (await this.host()).blur();
166
- }
167
- /** Whether the input is focused. */
168
- async isFocused() {
169
- return (await this.host()).isFocused();
170
- }
171
- /**
172
- * Sets the value of the input. The value will be set by simulating
173
- * keypresses that correspond to the given value.
174
- */
175
- async setValue(newValue) {
176
- const inputEl = await this.host();
177
- await inputEl.clear();
178
- // We don't want to send keys for the value if the value is an empty
179
- // string in order to clear the value. Sending keys with an empty string
180
- // still results in unnecessary focus events.
181
- if (newValue) {
182
- await inputEl.sendKeys(newValue);
183
- }
184
- }
185
- /** Sends a chip separator key to the input element. */
186
- async sendSeparatorKey(key) {
187
- const inputEl = await this.host();
188
- return inputEl.sendKeys(key);
189
- }
65
+ static hostSelector = '.mat-mdc-chip-input';
66
+ static with(options = {}) {
67
+ return new HarnessPredicate(this, options).addOption('value', options.value, async (harness, value) => {
68
+ return (await harness.getValue()) === value;
69
+ }).addOption('placeholder', options.placeholder, async (harness, placeholder) => {
70
+ return (await harness.getPlaceholder()) === placeholder;
71
+ }).addOption('disabled', options.disabled, async (harness, disabled) => {
72
+ return (await harness.isDisabled()) === disabled;
73
+ });
74
+ }
75
+ async isDisabled() {
76
+ const host = await this.host();
77
+ const disabled = await host.getAttribute('disabled');
78
+ if (disabled !== null) {
79
+ return coerceBooleanProperty(disabled);
80
+ }
81
+ return (await host.getAttribute('aria-disabled')) === 'true';
82
+ }
83
+ async isRequired() {
84
+ return (await this.host()).getProperty('required');
85
+ }
86
+ async getValue() {
87
+ return await (await this.host()).getProperty('value');
88
+ }
89
+ async getPlaceholder() {
90
+ return await (await this.host()).getProperty('placeholder');
91
+ }
92
+ async focus() {
93
+ return (await this.host()).focus();
94
+ }
95
+ async blur() {
96
+ return (await this.host()).blur();
97
+ }
98
+ async isFocused() {
99
+ return (await this.host()).isFocused();
100
+ }
101
+ async setValue(newValue) {
102
+ const inputEl = await this.host();
103
+ await inputEl.clear();
104
+ if (newValue) {
105
+ await inputEl.sendKeys(newValue);
106
+ }
107
+ }
108
+ async sendSeparatorKey(key) {
109
+ const inputEl = await this.host();
110
+ return inputEl.sendKeys(key);
111
+ }
190
112
  }
191
113
 
192
- /** Harness for interacting with a mat-chip-option in tests. */
193
114
  class MatChipOptionHarness extends MatChipHarness {
194
- static hostSelector = '.mat-mdc-chip-option';
195
- /**
196
- * Gets a `HarnessPredicate` that can be used to search for a chip option with specific
197
- * attributes.
198
- * @param options Options for narrowing the search.
199
- * @return a `HarnessPredicate` configured with the given options.
200
- */
201
- static with(options = {}) {
202
- return new HarnessPredicate(MatChipOptionHarness, options)
203
- .addOption('text', options.text, (harness, label) => HarnessPredicate.stringMatches(harness.getText(), label))
204
- .addOption('selected', options.selected, async (harness, selected) => (await harness.isSelected()) === selected);
205
- }
206
- /** Whether the chip is selected. */
207
- async isSelected() {
208
- return (await this.host()).hasClass('mat-mdc-chip-selected');
209
- }
210
- /** Selects the given chip. Only applies if it's selectable. */
211
- async select() {
212
- if (!(await this.isSelected())) {
213
- await this.toggle();
214
- }
215
- }
216
- /** Deselects the given chip. Only applies if it's selectable. */
217
- async deselect() {
218
- if (await this.isSelected()) {
219
- await this.toggle();
220
- }
221
- }
222
- /** Toggles the selected state of the given chip. */
223
- async toggle() {
224
- return (await this._primaryAction()).click();
225
- }
115
+ static hostSelector = '.mat-mdc-chip-option';
116
+ static with(options = {}) {
117
+ return new HarnessPredicate(MatChipOptionHarness, options).addOption('text', options.text, (harness, label) => HarnessPredicate.stringMatches(harness.getText(), label)).addOption('selected', options.selected, async (harness, selected) => (await harness.isSelected()) === selected);
118
+ }
119
+ async isSelected() {
120
+ return (await this.host()).hasClass('mat-mdc-chip-selected');
121
+ }
122
+ async select() {
123
+ if (!(await this.isSelected())) {
124
+ await this.toggle();
125
+ }
126
+ }
127
+ async deselect() {
128
+ if (await this.isSelected()) {
129
+ await this.toggle();
130
+ }
131
+ }
132
+ async toggle() {
133
+ return (await this._primaryAction()).click();
134
+ }
226
135
  }
227
136
 
228
- /** Harness for interacting with a mat-chip-listbox in tests. */
229
137
  class MatChipListboxHarness extends ComponentHarness {
230
- static hostSelector = '.mat-mdc-chip-listbox';
231
- /**
232
- * Gets a `HarnessPredicate` that can be used to search for a chip listbox with specific
233
- * attributes.
234
- * @param options Options for narrowing the search.
235
- * @return a `HarnessPredicate` configured with the given options.
236
- */
237
- static with(options = {}) {
238
- return new HarnessPredicate(this, options).addOption('disabled', options.disabled, async (harness, disabled) => {
239
- return (await harness.isDisabled()) === disabled;
240
- });
241
- }
242
- /** Gets whether the chip listbox is disabled. */
243
- async isDisabled() {
244
- return (await (await this.host()).getAttribute('aria-disabled')) === 'true';
245
- }
246
- /** Gets whether the chip listbox is required. */
247
- async isRequired() {
248
- return (await (await this.host()).getAttribute('aria-required')) === 'true';
249
- }
250
- /** Gets whether the chip listbox is in multi selection mode. */
251
- async isMultiple() {
252
- return (await (await this.host()).getAttribute('aria-multiselectable')) === 'true';
253
- }
254
- /** Gets whether the orientation of the chip list. */
255
- async getOrientation() {
256
- const orientation = await (await this.host()).getAttribute('aria-orientation');
257
- return orientation === 'vertical' ? 'vertical' : 'horizontal';
258
- }
259
- /**
260
- * Gets the list of chips inside the chip list.
261
- * @param filter Optionally filters which chips are included.
262
- */
263
- async getChips(filter = {}) {
264
- return this.locatorForAll(MatChipOptionHarness.with(filter))();
265
- }
266
- /**
267
- * Selects a chip inside the chip list.
268
- * @param filter An optional filter to apply to the child chips.
269
- * All the chips matching the filter will be selected.
270
- */
271
- async selectChips(filter = {}) {
272
- const chips = await this.getChips(filter);
273
- if (!chips.length) {
274
- throw Error(`Cannot find chip matching filter ${JSON.stringify(filter)}`);
275
- }
276
- await parallel(() => chips.map(chip => chip.select()));
277
- }
138
+ static hostSelector = '.mat-mdc-chip-listbox';
139
+ static with(options = {}) {
140
+ return new HarnessPredicate(this, options).addOption('disabled', options.disabled, async (harness, disabled) => {
141
+ return (await harness.isDisabled()) === disabled;
142
+ });
143
+ }
144
+ async isDisabled() {
145
+ return (await (await this.host()).getAttribute('aria-disabled')) === 'true';
146
+ }
147
+ async isRequired() {
148
+ return (await (await this.host()).getAttribute('aria-required')) === 'true';
149
+ }
150
+ async isMultiple() {
151
+ return (await (await this.host()).getAttribute('aria-multiselectable')) === 'true';
152
+ }
153
+ async getOrientation() {
154
+ const orientation = await (await this.host()).getAttribute('aria-orientation');
155
+ return orientation === 'vertical' ? 'vertical' : 'horizontal';
156
+ }
157
+ async getChips(filter = {}) {
158
+ return this.locatorForAll(MatChipOptionHarness.with(filter))();
159
+ }
160
+ async selectChips(filter = {}) {
161
+ const chips = await this.getChips(filter);
162
+ if (!chips.length) {
163
+ throw Error(`Cannot find chip matching filter ${JSON.stringify(filter)}`);
164
+ }
165
+ await parallel(() => chips.map(chip => chip.select()));
166
+ }
278
167
  }
279
168
 
280
- /** Harness for interacting with an editable chip's input in tests. */
281
169
  class MatChipEditInputHarness extends ComponentHarness {
282
- static hostSelector = '.mat-chip-edit-input';
283
- /**
284
- * Gets a `HarnessPredicate` that can be used to search for a chip edit input with specific
285
- * attributes.
286
- * @param options Options for filtering which input instances are considered a match.
287
- * @return a `HarnessPredicate` configured with the given options.
288
- */
289
- static with(options = {}) {
290
- return new HarnessPredicate(this, options);
291
- }
292
- /** Sets the value of the input. */
293
- async setValue(value) {
294
- const host = await this.host();
295
- // @breaking-change 16.0.0 Remove this null check once `setContenteditableValue`
296
- // becomes a required method.
297
- if (!host.setContenteditableValue) {
298
- throw new Error('Cannot set chip edit input value, because test ' +
299
- 'element does not implement the `setContenteditableValue` method.');
300
- }
301
- return host.setContenteditableValue(value);
302
- }
170
+ static hostSelector = '.mat-chip-edit-input';
171
+ static with(options = {}) {
172
+ return new HarnessPredicate(this, options);
173
+ }
174
+ async setValue(value) {
175
+ const host = await this.host();
176
+ return host.setContenteditableValue(value);
177
+ }
303
178
  }
304
179
 
305
- /** Harness for interacting with a mat-chip-row in tests. */
306
180
  class MatChipRowHarness extends MatChipHarness {
307
- static hostSelector = '.mat-mdc-chip-row';
308
- /** Whether the chip is editable. */
309
- async isEditable() {
310
- return (await this.host()).hasClass('mat-mdc-chip-editable');
311
- }
312
- /** Whether the chip is currently being edited. */
313
- async isEditing() {
314
- return (await this.host()).hasClass('mat-mdc-chip-editing');
315
- }
316
- /** Sets the chip row into an editing state, if it is editable. */
317
- async startEditing() {
318
- if (!(await this.isEditable())) {
319
- throw new Error('Cannot begin editing a chip that is not editable.');
320
- }
321
- return (await this.host()).dispatchEvent('dblclick');
322
- }
323
- /** Stops editing the chip, if it was in the editing state. */
324
- async finishEditing() {
325
- if (await this.isEditing()) {
326
- await (await this.host()).sendKeys(TestKey.ENTER);
327
- }
328
- }
329
- /** Gets the edit input inside the chip row. */
330
- async getEditInput(filter = {}) {
331
- return this.locatorFor(MatChipEditInputHarness.with(filter))();
332
- }
181
+ static hostSelector = '.mat-mdc-chip-row';
182
+ async isEditable() {
183
+ return (await this.host()).hasClass('mat-mdc-chip-editable');
184
+ }
185
+ async isEditing() {
186
+ return (await this.host()).hasClass('mat-mdc-chip-editing');
187
+ }
188
+ async startEditing() {
189
+ if (!(await this.isEditable())) {
190
+ throw new Error('Cannot begin editing a chip that is not editable.');
191
+ }
192
+ return (await this.host()).dispatchEvent('dblclick');
193
+ }
194
+ async finishEditing() {
195
+ if (await this.isEditing()) {
196
+ await (await this.host()).sendKeys(TestKey.ENTER);
197
+ }
198
+ }
199
+ async getEditInput(filter = {}) {
200
+ return this.locatorFor(MatChipEditInputHarness.with(filter))();
201
+ }
333
202
  }
334
203
 
335
- /** Harness for interacting with a mat-chip-grid in tests. */
336
204
  class MatChipGridHarness extends ComponentHarness {
337
- static hostSelector = '.mat-mdc-chip-grid';
338
- /**
339
- * Gets a `HarnessPredicate` that can be used to search for a chip grid with specific attributes.
340
- * @param options Options for filtering which chip grid instances are considered a match.
341
- * @return a `HarnessPredicate` configured with the given options.
342
- */
343
- static with(options = {}) {
344
- return new HarnessPredicate(this, options).addOption('disabled', options.disabled, async (harness, disabled) => {
345
- return (await harness.isDisabled()) === disabled;
346
- });
347
- }
348
- /** Gets whether the chip grid is disabled. */
349
- async isDisabled() {
350
- return (await (await this.host()).getAttribute('aria-disabled')) === 'true';
351
- }
352
- /** Gets whether the chip grid is required. */
353
- async isRequired() {
354
- return await (await this.host()).hasClass('mat-mdc-chip-list-required');
355
- }
356
- /** Gets whether the chip grid is invalid. */
357
- async isInvalid() {
358
- return (await (await this.host()).getAttribute('aria-invalid')) === 'true';
359
- }
360
- /** Gets promise of the harnesses for the chip rows. */
361
- getRows(filter = {}) {
362
- return this.locatorForAll(MatChipRowHarness.with(filter))();
363
- }
364
- /** Gets promise of the chip text input harness. */
365
- getInput(filter = {}) {
366
- return this.locatorFor(MatChipInputHarness.with(filter))();
367
- }
205
+ static hostSelector = '.mat-mdc-chip-grid';
206
+ static with(options = {}) {
207
+ return new HarnessPredicate(this, options).addOption('disabled', options.disabled, async (harness, disabled) => {
208
+ return (await harness.isDisabled()) === disabled;
209
+ });
210
+ }
211
+ async isDisabled() {
212
+ return (await (await this.host()).getAttribute('aria-disabled')) === 'true';
213
+ }
214
+ async isRequired() {
215
+ return await (await this.host()).hasClass('mat-mdc-chip-list-required');
216
+ }
217
+ async isInvalid() {
218
+ return (await (await this.host()).getAttribute('aria-invalid')) === 'true';
219
+ }
220
+ getRows(filter = {}) {
221
+ return this.locatorForAll(MatChipRowHarness.with(filter))();
222
+ }
223
+ getInput(filter = {}) {
224
+ return this.locatorFor(MatChipInputHarness.with(filter))();
225
+ }
368
226
  }
369
227
 
370
- /** Harness for interacting with a mat-chip-set in tests. */
371
228
  class MatChipSetHarness extends ComponentHarness {
372
- static hostSelector = '.mat-mdc-chip-set';
373
- /**
374
- * Gets a `HarnessPredicate` that can be used to search for a chip set with specific attributes.
375
- * @param options Options for filtering which chip set instances are considered a match.
376
- * @return a `HarnessPredicate` configured with the given options.
377
- */
378
- static with(options = {}) {
379
- return new HarnessPredicate(this, options);
380
- }
381
- /** Gets promise of the harnesses for the chips. */
382
- async getChips(filter = {}) {
383
- return await this.locatorForAll(MatChipHarness.with(filter))();
384
- }
229
+ static hostSelector = '.mat-mdc-chip-set';
230
+ static with(options = {}) {
231
+ return new HarnessPredicate(this, options);
232
+ }
233
+ async getChips(filter = {}) {
234
+ return await this.locatorForAll(MatChipHarness.with(filter))();
235
+ }
385
236
  }
386
237
 
387
238
  export { MatChipAvatarHarness, MatChipEditHarness, MatChipEditInputHarness, MatChipGridHarness, MatChipHarness, MatChipInputHarness, MatChipListboxHarness, MatChipOptionHarness, MatChipRemoveHarness, MatChipRowHarness, MatChipSetHarness };