@skyux/lists 8.7.0 → 9.0.0-alpha.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 (91) hide show
  1. package/esm2022/lib/modules/filter/filter-button.component.mjs +73 -0
  2. package/{esm2020 → esm2022}/lib/modules/filter/filter-inline-item.component.mjs +4 -4
  3. package/{esm2020 → esm2022}/lib/modules/filter/filter-inline.component.mjs +4 -4
  4. package/esm2022/lib/modules/filter/filter-summary-item.component.mjs +52 -0
  5. package/{esm2020 → esm2022}/lib/modules/filter/filter-summary.component.mjs +4 -4
  6. package/{esm2020 → esm2022}/lib/modules/filter/filter.module.mjs +21 -21
  7. package/esm2022/lib/modules/infinite-scroll/infinite-scroll-dom-adapter.service.mjs +82 -0
  8. package/esm2022/lib/modules/infinite-scroll/infinite-scroll.component.mjs +116 -0
  9. package/{esm2020 → esm2022}/lib/modules/infinite-scroll/infinite-scroll.module.mjs +5 -5
  10. package/esm2022/lib/modules/paging/paging.component.mjs +122 -0
  11. package/{esm2020 → esm2022}/lib/modules/paging/paging.module.mjs +11 -11
  12. package/esm2022/lib/modules/repeater/repeater-adapter.service.mjs +75 -0
  13. package/{esm2020 → esm2022}/lib/modules/repeater/repeater-auto-scroll.service.mjs +4 -4
  14. package/{esm2020 → esm2022}/lib/modules/repeater/repeater-item-content.component.mjs +4 -4
  15. package/{esm2020 → esm2022}/lib/modules/repeater/repeater-item-context-menu.component.mjs +4 -4
  16. package/{esm2020 → esm2022}/lib/modules/repeater/repeater-item-title.component.mjs +4 -4
  17. package/esm2022/lib/modules/repeater/repeater-item.component.mjs +504 -0
  18. package/esm2022/lib/modules/repeater/repeater.component.mjs +373 -0
  19. package/{esm2020 → esm2022}/lib/modules/repeater/repeater.module.mjs +27 -27
  20. package/esm2022/lib/modules/repeater/repeater.service.mjs +86 -0
  21. package/{esm2020 → esm2022}/lib/modules/shared/sky-lists-resources.module.mjs +11 -11
  22. package/esm2022/lib/modules/sort/sort-item.component.mjs +66 -0
  23. package/{esm2020 → esm2022}/lib/modules/sort/sort-menu-heading.component.mjs +4 -4
  24. package/{esm2020 → esm2022}/lib/modules/sort/sort.component.mjs +4 -4
  25. package/{esm2020 → esm2022}/lib/modules/sort/sort.module.mjs +17 -17
  26. package/{esm2020 → esm2022}/lib/modules/sort/sort.service.mjs +4 -4
  27. package/esm2022/testing/filter/filter-fixture-button.mjs +53 -0
  28. package/esm2022/testing/filter/filter-fixture-summary.mjs +31 -0
  29. package/{esm2020 → esm2022}/testing/filter/filter-testing.module.mjs +5 -5
  30. package/esm2022/testing/infinite-scroll/infinite-scroll-fixture.mjs +31 -0
  31. package/esm2022/testing/infinite-scroll/infinite-scroll-harness.mjs +49 -0
  32. package/{esm2020 → esm2022}/testing/infinite-scroll/infinite-scroll-testing.module.mjs +5 -5
  33. package/esm2022/testing/paging/paging-fixture.mjs +95 -0
  34. package/{esm2020 → esm2022}/testing/paging/paging-testing.module.mjs +5 -5
  35. package/esm2022/testing/repeater/repeater-harness.mjs +25 -0
  36. package/esm2022/testing/repeater/repeater-item-harness.mjs +167 -0
  37. package/esm2022/testing/sort/sort-fixture.mjs +149 -0
  38. package/{esm2020 → esm2022}/testing/sort/sort-testing.module.mjs +5 -5
  39. package/fesm2022/skyux-lists-testing.mjs +664 -0
  40. package/{fesm2020 → fesm2022}/skyux-lists-testing.mjs.map +1 -1
  41. package/fesm2022/skyux-lists.mjs +1913 -0
  42. package/{fesm2020 → fesm2022}/skyux-lists.mjs.map +1 -1
  43. package/lib/modules/filter/filter-button.component.d.ts +1 -1
  44. package/lib/modules/filter/filter-summary-item.component.d.ts +1 -1
  45. package/lib/modules/infinite-scroll/infinite-scroll.component.d.ts +1 -1
  46. package/lib/modules/paging/paging.component.d.ts +1 -1
  47. package/lib/modules/repeater/repeater-item.component.d.ts +1 -1
  48. package/lib/modules/repeater/repeater.component.d.ts +1 -1
  49. package/lib/modules/sort/sort-item.component.d.ts +1 -1
  50. package/lib/modules/sort/sort.component.d.ts +1 -1
  51. package/package.json +22 -30
  52. package/esm2020/lib/modules/filter/filter-button.component.mjs +0 -75
  53. package/esm2020/lib/modules/filter/filter-summary-item.component.mjs +0 -54
  54. package/esm2020/lib/modules/infinite-scroll/infinite-scroll-dom-adapter.service.mjs +0 -84
  55. package/esm2020/lib/modules/infinite-scroll/infinite-scroll.component.mjs +0 -116
  56. package/esm2020/lib/modules/paging/paging.component.mjs +0 -123
  57. package/esm2020/lib/modules/repeater/repeater-adapter.service.mjs +0 -73
  58. package/esm2020/lib/modules/repeater/repeater-item.component.mjs +0 -492
  59. package/esm2020/lib/modules/repeater/repeater.component.mjs +0 -357
  60. package/esm2020/lib/modules/repeater/repeater.service.mjs +0 -88
  61. package/esm2020/lib/modules/sort/sort-item.component.mjs +0 -69
  62. package/esm2020/testing/filter/filter-fixture-button.mjs +0 -55
  63. package/esm2020/testing/filter/filter-fixture-summary.mjs +0 -34
  64. package/esm2020/testing/infinite-scroll/infinite-scroll-fixture.mjs +0 -34
  65. package/esm2020/testing/infinite-scroll/infinite-scroll-harness.mjs +0 -55
  66. package/esm2020/testing/paging/paging-fixture.mjs +0 -91
  67. package/esm2020/testing/repeater/repeater-harness.mjs +0 -25
  68. package/esm2020/testing/repeater/repeater-item-harness.mjs +0 -173
  69. package/esm2020/testing/sort/sort-fixture.mjs +0 -148
  70. package/fesm2015/skyux-lists-testing.mjs +0 -747
  71. package/fesm2015/skyux-lists-testing.mjs.map +0 -1
  72. package/fesm2015/skyux-lists.mjs +0 -1894
  73. package/fesm2015/skyux-lists.mjs.map +0 -1
  74. package/fesm2020/skyux-lists-testing.mjs +0 -673
  75. package/fesm2020/skyux-lists.mjs +0 -1886
  76. /package/{esm2020 → esm2022}/index.mjs +0 -0
  77. /package/{esm2020 → esm2022}/lib/modules/repeater/repeater-auto-scroll-options.mjs +0 -0
  78. /package/{esm2020 → esm2022}/lib/modules/repeater/repeater-auto-scroller.mjs +0 -0
  79. /package/{esm2020 → esm2022}/lib/modules/repeater/repeater-expand-mode-type.mjs +0 -0
  80. /package/{esm2020 → esm2022}/lib/modules/repeater/repeater-item-roles.type.mjs +0 -0
  81. /package/{esm2020 → esm2022}/lib/modules/repeater/repeater-role.type.mjs +0 -0
  82. /package/{esm2020 → esm2022}/skyux-lists.mjs +0 -0
  83. /package/{esm2020 → esm2022}/testing/filter/lists-filter-fixture-button.mjs +0 -0
  84. /package/{esm2020 → esm2022}/testing/infinite-scroll/infinite-scroll-harness-filters.mjs +0 -0
  85. /package/{esm2020 → esm2022}/testing/paging/paging-fixture-button.mjs +0 -0
  86. /package/{esm2020 → esm2022}/testing/public-api.mjs +0 -0
  87. /package/{esm2020 → esm2022}/testing/repeater/repeater-harness-filters.mjs +0 -0
  88. /package/{esm2020 → esm2022}/testing/repeater/repeater-item-harness-filters.mjs +0 -0
  89. /package/{esm2020 → esm2022}/testing/skyux-lists-testing.mjs +0 -0
  90. /package/{esm2020 → esm2022}/testing/sort/sort-fixture-menu-item.mjs +0 -0
  91. /package/{esm2020 → esm2022}/testing/sort/sort-fixture-menu.mjs +0 -0
@@ -0,0 +1,664 @@
1
+ import * as i0 from '@angular/core';
2
+ import { NgModule } from '@angular/core';
3
+ import { SkyFilterModule, SkyPagingModule, SkySortModule, SkyInfiniteScrollModule } from '@skyux/lists';
4
+ import { SkyAppTestUtility } from '@skyux-sdk/testing';
5
+ import { By } from '@angular/platform-browser';
6
+ import { SkyComponentHarness } from '@skyux/core/testing';
7
+ import { HarnessPredicate } from '@angular/cdk/testing';
8
+ import { SkyCheckboxHarness } from '@skyux/forms/testing';
9
+ import { SkyChevronHarness } from '@skyux/indicators/testing';
10
+ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
11
+
12
+ /**
13
+ * @internal
14
+ */
15
+ class SkyFilterTestingModule {
16
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SkyFilterTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
17
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: SkyFilterTestingModule, exports: [SkyFilterModule] }); }
18
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SkyFilterTestingModule, imports: [SkyFilterModule] }); }
19
+ }
20
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SkyFilterTestingModule, decorators: [{
21
+ type: NgModule,
22
+ args: [{
23
+ exports: [SkyFilterModule],
24
+ }]
25
+ }] });
26
+
27
+ /**
28
+ * Provides information for and interaction with a SKY UX filter summary component.
29
+ * By using the fixture API, a test insulates itself against updates to the internals
30
+ * of a component, such as changing its DOM structure.
31
+ * @internal
32
+ */
33
+ class SkyFilterFixtureSummary {
34
+ #debugElement;
35
+ #fixture;
36
+ constructor(fixture, skyTestId) {
37
+ this.#fixture = fixture;
38
+ this.#debugElement = SkyAppTestUtility.getDebugElementByTestId(this.#fixture, skyTestId, 'sky-filter-summary');
39
+ }
40
+ async filterCloseClick(index) {
41
+ const summaryItems = this.#debugElement.nativeElement.querySelectorAll('sky-filter-summary-item');
42
+ if (summaryItems.length > index) {
43
+ const summaryItem = summaryItems[index];
44
+ if (summaryItem instanceof HTMLElement) {
45
+ const closeButton = summaryItem.querySelector('.sky-token-btn-close');
46
+ if (closeButton instanceof HTMLElement) {
47
+ closeButton.click();
48
+ this.#fixture.detectChanges();
49
+ return this.#fixture.whenStable();
50
+ }
51
+ }
52
+ }
53
+ throw new Error(`Unable to click close for a filter index ${index}`);
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Provides information for and interaction with a SKY UX filter button component.
59
+ * By using the fixture API, a test insulates itself against updates to the internals
60
+ * of a component, such as changing its DOM structure.
61
+ * @internal
62
+ */
63
+ class SkyFilterFixtureButton {
64
+ #debugElement;
65
+ #fixture;
66
+ constructor(fixture, skyTestId) {
67
+ this.#fixture = fixture;
68
+ this.#debugElement = SkyAppTestUtility.getDebugElementByTestId(fixture, skyTestId, 'sky-filter-button');
69
+ }
70
+ /**
71
+ * Click the button to apply the filter.
72
+ */
73
+ async clickFilterButton() {
74
+ const button = this.#getButtonElement();
75
+ if (button instanceof HTMLButtonElement && !button.disabled) {
76
+ button.click();
77
+ }
78
+ this.#fixture.detectChanges();
79
+ return this.#fixture.whenStable();
80
+ }
81
+ get button() {
82
+ const buttonElement = this.#getButtonElement();
83
+ return {
84
+ ariaControls: buttonElement?.getAttribute('aria-controls') ?? undefined,
85
+ ariaExpanded: buttonElement?.getAttribute('aria-expanded') === 'true',
86
+ disabled: !!buttonElement?.disabled,
87
+ id: buttonElement?.id,
88
+ };
89
+ }
90
+ /**
91
+ * Get the button text.
92
+ */
93
+ get buttonText() {
94
+ const text = this.#getButtonElement()?.innerText;
95
+ return this.#normalizeText(text);
96
+ }
97
+ #getButtonElement() {
98
+ return this.#debugElement.nativeElement.querySelector('.sky-filter-btn');
99
+ }
100
+ #normalizeText(text) {
101
+ let retVal = '';
102
+ if (text) {
103
+ retVal = text?.trim().replace(/\s+/g, ' ');
104
+ }
105
+ return retVal;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * @internal
111
+ */
112
+ class SkyPagingTestingModule {
113
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SkyPagingTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
114
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: SkyPagingTestingModule, exports: [SkyPagingModule] }); }
115
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SkyPagingTestingModule, imports: [SkyPagingModule] }); }
116
+ }
117
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SkyPagingTestingModule, decorators: [{
118
+ type: NgModule,
119
+ args: [{
120
+ exports: [SkyPagingModule],
121
+ }]
122
+ }] });
123
+
124
+ /**
125
+ * Provides information for and interaction with a SKY UX paging component.
126
+ * By using the fixture API, a test insulates itself against updates to the internals
127
+ * of a component, such as changing its DOM structure.
128
+ * @internal
129
+ */
130
+ class SkyPagingFixture {
131
+ #_debugEl;
132
+ /**
133
+ * The id of the active page, if available.
134
+ */
135
+ get activePageId() {
136
+ return this.#getPageId(this.#activePageButton);
137
+ }
138
+ /**
139
+ * Properties of the page links displayed in the paging component.
140
+ */
141
+ get pageLinks() {
142
+ return this.#pagingLinks.map((page) => {
143
+ return {
144
+ id: this.#getPageId(page.nativeElement),
145
+ isActive: page.nativeElement.classList.contains('sky-paging-current'),
146
+ isEnabled: !page.nativeElement.disabled,
147
+ };
148
+ });
149
+ }
150
+ #fixture;
151
+ constructor(fixture, skyTestId) {
152
+ this.#fixture = fixture;
153
+ this.#_debugEl = SkyAppTestUtility.getDebugElementByTestId(fixture, skyTestId, 'sky-paging');
154
+ this.#waitForComponentInitialization();
155
+ }
156
+ /**
157
+ * Selects the specified page by id, if it is enabled.
158
+ */
159
+ async selectPage(id) {
160
+ const pageButton = this.#getPageLink(id.toString());
161
+ if (pageButton !== undefined && !pageButton.disabled) {
162
+ pageButton.click();
163
+ this.#fixture.detectChanges();
164
+ return this.#fixture.whenStable();
165
+ }
166
+ }
167
+ /**
168
+ * Clicks the next page button, if it is enabled.
169
+ */
170
+ async selectNextPage() {
171
+ const nextButton = this.#nextPageButton;
172
+ if (nextButton !== undefined && !nextButton.disabled) {
173
+ nextButton.click();
174
+ this.#fixture.detectChanges();
175
+ return this.#fixture.whenStable();
176
+ }
177
+ }
178
+ /**
179
+ * Clicks the previous page button, if it is enabled.
180
+ */
181
+ async selectPreviousPage() {
182
+ const previousButton = this.#previousPageButton;
183
+ if (previousButton !== undefined && !previousButton.disabled) {
184
+ previousButton.click();
185
+ this.#fixture.detectChanges();
186
+ return this.#fixture.whenStable();
187
+ }
188
+ }
189
+ //#region helpers
190
+ get #activePageButton() {
191
+ return this.#_debugEl.query(By.css('.sky-list-paging-link .sky-paging-current'))?.nativeElement;
192
+ }
193
+ get #nextPageButton() {
194
+ return this.#_debugEl.query(By.css('.sky-paging-btn[sky-cmp-id="next"]'))
195
+ ?.nativeElement;
196
+ }
197
+ get #previousPageButton() {
198
+ return this.#_debugEl.query(By.css('.sky-paging-btn[sky-cmp-id="previous"]'))?.nativeElement;
199
+ }
200
+ get #pagingLinks() {
201
+ return this.#_debugEl.queryAll(By.css('.sky-list-paging-link button'));
202
+ }
203
+ #getPageLink(id) {
204
+ return this.#_debugEl.query(By.css(`.sky-list-paging-link button[sky-cmp-id="${id}"]`))?.nativeElement;
205
+ }
206
+ #getPageId(page) {
207
+ return page?.getAttribute('sky-cmp-id') ?? '';
208
+ }
209
+ async #waitForComponentInitialization() {
210
+ this.#fixture.detectChanges();
211
+ await this.#fixture.whenStable();
212
+ this.#fixture.detectChanges();
213
+ return this.#fixture.whenStable();
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Harness for interacting with a repeater item component in tests.
219
+ */
220
+ class SkyRepeaterItemHarness extends SkyComponentHarness {
221
+ /**
222
+ * @internal
223
+ */
224
+ static { this.hostSelector = 'sky-repeater-item'; }
225
+ #getBackToTop = this.locatorForOptional('button.sky-repeater-item-reorder-top');
226
+ #getCheckbox = this.locatorForOptional(SkyCheckboxHarness);
227
+ #getChevron = this.locatorForOptional(SkyChevronHarness);
228
+ #getContent = this.locatorFor('.sky-repeater-item-content');
229
+ #getItem = this.locatorFor('.sky-repeater-item');
230
+ #getReorderHandle = this.locatorForOptional('button.sky-repeater-item-grab-handle');
231
+ #getTitle = this.locatorFor('.sky-repeater-item-title');
232
+ /**
233
+ * Gets a `HarnessPredicate` that can be used to search for a
234
+ * `SkyRepeaterItemHarness` that meets certain criteria.
235
+ */
236
+ static with(filters) {
237
+ return SkyRepeaterItemHarness.getDataSkyIdPredicate(filters)
238
+ .addOption('contentText', filters.contentText, async (harness, text) => HarnessPredicate.stringMatches(await harness.getContentText(), text))
239
+ .addOption('titleText', filters.titleText, async (harness, text) => HarnessPredicate.stringMatches(await harness.getTitleText(), text));
240
+ }
241
+ /**
242
+ * Returns a child harness.
243
+ */
244
+ async queryHarness(query) {
245
+ return this.locatorForOptional(query)();
246
+ }
247
+ /**
248
+ * Returns child harnesses.
249
+ */
250
+ async queryHarnesses(harness) {
251
+ return this.locatorForAll(harness)();
252
+ }
253
+ /**
254
+ * Returns a child test element.
255
+ */
256
+ async querySelector(selector) {
257
+ return this.locatorForOptional(selector)();
258
+ }
259
+ /**
260
+ * Returns child test elements.
261
+ */
262
+ async querySelectorAll(selector) {
263
+ return this.locatorForAll(selector)();
264
+ }
265
+ /**
266
+ * Clicks on the repeater item.
267
+ */
268
+ async click() {
269
+ await (await this.#getItem()).click();
270
+ }
271
+ /**
272
+ * Whether the repeater item is selectable.
273
+ */
274
+ async isSelectable() {
275
+ return !!(await this.#getCheckbox());
276
+ }
277
+ /**
278
+ * Whether the repeater item is selected.
279
+ */
280
+ async isSelected() {
281
+ const checkbox = await this.#getCheckbox();
282
+ if (!checkbox) {
283
+ throw new Error('Could not determine if repeater item is selected because it is not selectable.');
284
+ }
285
+ return checkbox.isChecked();
286
+ }
287
+ /**
288
+ * Selects the repeater item.
289
+ */
290
+ async select() {
291
+ const checkbox = await this.#getCheckbox();
292
+ if (!checkbox) {
293
+ throw new Error('Could not select the repeater item because it is not selectable.');
294
+ }
295
+ await checkbox.check();
296
+ }
297
+ /**
298
+ * Deselects the repeater item.
299
+ */
300
+ async deselect() {
301
+ const checkbox = await this.#getCheckbox();
302
+ if (!checkbox) {
303
+ throw new Error('Could not deselect the repeater item because it is not selectable.');
304
+ }
305
+ await checkbox.uncheck();
306
+ }
307
+ /**
308
+ * Gets the text of the repeater item content.
309
+ */
310
+ async getContentText() {
311
+ return (await this.#getContent()).text();
312
+ }
313
+ /**
314
+ * Gets the text of the repeater item title.
315
+ */
316
+ async getTitleText() {
317
+ return (await this.#getTitle()).text();
318
+ }
319
+ /**
320
+ * Whether the repeater item is collapsible.
321
+ */
322
+ async isCollapsible() {
323
+ return !!(await this.#getChevron());
324
+ }
325
+ /**
326
+ * Whether the repeater item is expanded, or throws an error informing of the lack of collapsibility.
327
+ */
328
+ async isExpanded() {
329
+ const chevron = await this.#getChevron();
330
+ if (chevron) {
331
+ return (await chevron.getDirection()) === 'up';
332
+ }
333
+ throw new Error('Could not determine if repeater item is expanded because it is not collapsible.');
334
+ }
335
+ /**
336
+ * Expands the repeater item, or does nothing if already expanded.
337
+ */
338
+ async expand() {
339
+ const chevron = await this.#getChevron();
340
+ if (chevron) {
341
+ if ((await chevron.getDirection()) === 'down') {
342
+ await chevron.toggle();
343
+ }
344
+ return;
345
+ }
346
+ throw new Error('Could not expand the repeater item because it is not collapsible.');
347
+ }
348
+ /**
349
+ * Collapses the repeater item, or does nothing if already collapsed.
350
+ */
351
+ async collapse() {
352
+ const chevron = await this.#getChevron();
353
+ if (chevron) {
354
+ if ((await chevron.getDirection()) === 'up') {
355
+ await chevron.toggle();
356
+ }
357
+ return;
358
+ }
359
+ throw new Error('Could not collapse the repeater item because it is not collapsible.');
360
+ }
361
+ /**
362
+ * Whether the repeater item is reorderable.
363
+ */
364
+ async isReorderable() {
365
+ return !!(await this.#getReorderHandle());
366
+ }
367
+ /**
368
+ * Moves the repeater item to the top of the list
369
+ */
370
+ async sendToTop() {
371
+ if (await this.isReorderable()) {
372
+ await (await this.#getBackToTop())?.click();
373
+ }
374
+ else {
375
+ throw new Error('Could not send to top because the repeater is not reorderable.');
376
+ }
377
+ }
378
+ }
379
+
380
+ /**
381
+ * Harness for interacting with a repeater component in tests.
382
+ */
383
+ class SkyRepeaterHarness extends SkyComponentHarness {
384
+ /**
385
+ * @internal
386
+ */
387
+ static { this.hostSelector = 'sky-repeater'; }
388
+ /**
389
+ * Gets a `HarnessPredicate` that can be used to search for a
390
+ * `SkyRepeaterHarness` that meets certain criteria.
391
+ */
392
+ static with(filters) {
393
+ return SkyRepeaterHarness.getDataSkyIdPredicate(filters);
394
+ }
395
+ /**
396
+ * Gets a list of child repeater items.
397
+ */
398
+ async getRepeaterItems(filters) {
399
+ return this.locatorForAll(SkyRepeaterItemHarness.with(filters || {}))();
400
+ }
401
+ }
402
+
403
+ /**
404
+ * @internal
405
+ */
406
+ class SkySortTestingModule {
407
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SkySortTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
408
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: SkySortTestingModule, imports: [NoopAnimationsModule], exports: [SkySortModule] }); }
409
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SkySortTestingModule, imports: [NoopAnimationsModule, SkySortModule] }); }
410
+ }
411
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SkySortTestingModule, decorators: [{
412
+ type: NgModule,
413
+ args: [{
414
+ imports: [NoopAnimationsModule],
415
+ exports: [SkySortModule],
416
+ }]
417
+ }] });
418
+
419
+ /**
420
+ * Provides information for and interaction with a SKY UX sort component.
421
+ * By using the fixture API, a test insulates itself against updates to the internals
422
+ * of a component, such as changing its DOM structure.
423
+ * @internal
424
+ */
425
+ class SkySortFixture {
426
+ /**
427
+ * The active sort menu item, if one exists. Menu items are only available when the menu dropdown
428
+ * is open. If the menu dropdown is closed, this property will be undefined.
429
+ */
430
+ get activeMenuItem() {
431
+ return this.menuItems?.find((x) => x.isActive);
432
+ }
433
+ /**
434
+ * The sort menu's properties.
435
+ */
436
+ get menu() {
437
+ /* istanbul ignore next */
438
+ const buttonText = SkyAppTestUtility.getText(this.#getSortButtonTextEl()) || '';
439
+ return {
440
+ buttonText,
441
+ isOpen: this.#getDropdownMenuEl() !== null,
442
+ };
443
+ }
444
+ /**
445
+ * The properties of each sort menu item. Menu items are only available when the menu dropdown
446
+ * is open. If the menu dropdown is closed, this property will be undefined.
447
+ */
448
+ get menuItems() {
449
+ // Return undefined when we can't determine what the options are.
450
+ // We do this to avoid any confusion with an empty set of options.
451
+ if (!this.menu.isOpen) {
452
+ return;
453
+ }
454
+ return this.#getSortItems().map((item, i) => {
455
+ const itemButton = item.querySelector('button');
456
+ return {
457
+ index: i,
458
+ isActive: item.classList.contains('sky-sort-item-selected'),
459
+ text: SkyAppTestUtility.getText(itemButton),
460
+ };
461
+ });
462
+ }
463
+ #debugEl;
464
+ #fixture;
465
+ constructor(fixture, skyTestId) {
466
+ this.#fixture = fixture;
467
+ this.#debugEl = SkyAppTestUtility.getDebugElementByTestId(fixture, skyTestId, 'sky-sort');
468
+ }
469
+ /**
470
+ * Closes the sort dropdown menu if it isn't closed already.
471
+ */
472
+ async closeMenu() {
473
+ // if the menu is already closed, do nothing
474
+ if (!this.menu.isOpen) {
475
+ return;
476
+ }
477
+ const menu = this.#getDropdownButtonEl();
478
+ if (menu !== undefined && !menu.disabled) {
479
+ menu.click();
480
+ this.#fixture.detectChanges();
481
+ await this.#fixture.whenStable();
482
+ this.#fixture.detectChanges();
483
+ return this.#fixture.whenStable();
484
+ }
485
+ }
486
+ /**
487
+ * Opens the sort dropdown menu if it isn't open already.
488
+ */
489
+ async openMenu() {
490
+ // if the menu is already open, do nothing
491
+ if (this.menu.isOpen) {
492
+ return;
493
+ }
494
+ const menu = this.#getDropdownButtonEl();
495
+ if (menu !== undefined && !menu.disabled) {
496
+ menu.click();
497
+ this.#fixture.detectChanges();
498
+ await this.#fixture.whenStable();
499
+ this.#fixture.detectChanges();
500
+ return this.#fixture.whenStable();
501
+ }
502
+ }
503
+ /**
504
+ * Ensures the sort menu is open and selects the menu item with the specified index, if it exists.
505
+ * @param menuItemIndex The index of the menu item to select.
506
+ */
507
+ async selectMenuItemByIndex(menuItemIndex) {
508
+ return this.#selectMenuItem((_item, index) => {
509
+ return index === menuItemIndex;
510
+ });
511
+ }
512
+ /**
513
+ * Ensures the sort menu is open and selects the menu item with the specified text,
514
+ * if a matching item is available.
515
+ * @param menuItemText The text of the menu item to select.
516
+ */
517
+ async selectMenuItemByText(menuItemText) {
518
+ /* istanbul ignore else */
519
+ if (menuItemText) {
520
+ return this.#selectMenuItem((item) => {
521
+ return SkyAppTestUtility.getText(item) === menuItemText;
522
+ });
523
+ }
524
+ else {
525
+ return;
526
+ }
527
+ }
528
+ //#region helpers
529
+ #getDropdownButtonEl() {
530
+ return this.#debugEl.query(By.css('.sky-dropdown-button')).nativeElement;
531
+ }
532
+ #getDropdownMenuEl() {
533
+ return document.querySelector('sky-overlay .sky-dropdown-menu');
534
+ }
535
+ #getSortButtonTextEl() {
536
+ return this.#debugEl.query(By.css('.sky-sort-btn-text')).nativeElement;
537
+ }
538
+ #getSortItems() {
539
+ const resultNodes = document.querySelectorAll('sky-overlay .sky-sort-item');
540
+ return Array.prototype.slice.call(resultNodes);
541
+ }
542
+ /**
543
+ * Ensures the sort menu is open and selects the menu item via a selection predicate,
544
+ * if a matching item is available.
545
+ * @param selectionPredicate The menu item selector method to use.
546
+ */
547
+ async #selectMenuItem(selectionPredicate) {
548
+ // make sure the sort menu is open
549
+ if (!this.menu.isOpen) {
550
+ await this.openMenu();
551
+ }
552
+ // find the requested menu item using the selectionPredicate parameter
553
+ const items = this.#getSortItems();
554
+ const targetItem = items.find((item, index) => selectionPredicate(item, index));
555
+ // if we found the item, select it
556
+ if (targetItem) {
557
+ // we've got the '.sky-sort-item' div, but we want to click it's child button element
558
+ const targetButton = targetItem.querySelector('button');
559
+ targetButton?.click();
560
+ this.#fixture.detectChanges();
561
+ return this.#fixture.whenStable();
562
+ }
563
+ }
564
+ }
565
+
566
+ /**
567
+ * @internal
568
+ */
569
+ class SkyInfiniteScrollTestingModule {
570
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SkyInfiniteScrollTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
571
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: SkyInfiniteScrollTestingModule, exports: [SkyInfiniteScrollModule] }); }
572
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SkyInfiniteScrollTestingModule, imports: [SkyInfiniteScrollModule] }); }
573
+ }
574
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: SkyInfiniteScrollTestingModule, decorators: [{
575
+ type: NgModule,
576
+ args: [{
577
+ exports: [SkyInfiniteScrollModule],
578
+ }]
579
+ }] });
580
+
581
+ /**
582
+ * Provides information for and interaction with a SKY UX infinite scroll component.
583
+ * By using the fixture API, a test insulates itself against updates to the internals
584
+ * of a component, such as changing its DOM structure.
585
+ * @deprecated Use `SkyInfiniteScrollHarness` instead.
586
+ * @internal
587
+ */
588
+ class SkyInfiniteScrollFixture {
589
+ #debugElement;
590
+ #fixture;
591
+ constructor(fixture, skyTestId) {
592
+ this.#fixture = fixture;
593
+ this.#debugElement = SkyAppTestUtility.getDebugElementByTestId(fixture, skyTestId, 'sky-infinite-scroll');
594
+ }
595
+ get loadMoreButtonIsVisible() {
596
+ return this.#getButton() instanceof HTMLButtonElement;
597
+ }
598
+ async clickLoadMoreButton() {
599
+ const button = this.#getButton();
600
+ if (button instanceof HTMLButtonElement) {
601
+ button.click();
602
+ }
603
+ this.#fixture.detectChanges();
604
+ return this.#fixture.whenStable();
605
+ }
606
+ #getButton() {
607
+ return this.#debugElement.nativeElement.querySelector('.sky-infinite-scroll .sky-btn');
608
+ }
609
+ }
610
+
611
+ /**
612
+ * Harness for interacting with an infinite scroll component in tests.
613
+ * @internal
614
+ */
615
+ class SkyInfiniteScrollHarness extends SkyComponentHarness {
616
+ /**
617
+ * @internal
618
+ */
619
+ static { this.hostSelector = 'sky-infinite-scroll'; }
620
+ #showMoreButton = this.locatorForOptional('button.sky-infinite-scroll-load-more-button');
621
+ /**
622
+ * Gets a `HarnessPredicate` that can be used to search for a
623
+ * `SkyInfiniteScrollHarness` that meets certain criteria.
624
+ */
625
+ static with(filters) {
626
+ return this.getDataSkyIdPredicate(filters);
627
+ }
628
+ /**
629
+ * Whether the infinite scroll is enabled.
630
+ */
631
+ async isEnabled() {
632
+ return (await this.locatorForOptional('.sky-infinite-scroll')()) !== null;
633
+ }
634
+ /**
635
+ * Whether the infinite scroll is loading.
636
+ */
637
+ async isLoading() {
638
+ return (await this.isEnabled()) && (await this.#showMoreButton()) === null;
639
+ }
640
+ /**
641
+ * Clicks the "Load more" button.
642
+ */
643
+ async loadMore() {
644
+ const button = await this.#showMoreButton();
645
+ if (button) {
646
+ await button.click();
647
+ }
648
+ else {
649
+ if (!(await this.isEnabled())) {
650
+ throw new Error('Unable to click the "Load more" button because the infinite scroll is not enabled.');
651
+ }
652
+ else {
653
+ throw new Error('Unable to click the "Load more" button because the infinite scroll is loading.');
654
+ }
655
+ }
656
+ }
657
+ }
658
+
659
+ /**
660
+ * Generated bundle index. Do not edit.
661
+ */
662
+
663
+ export { SkyFilterFixtureButton, SkyFilterFixtureSummary, SkyFilterTestingModule, SkyInfiniteScrollFixture, SkyInfiniteScrollHarness, SkyInfiniteScrollTestingModule, SkyPagingFixture, SkyPagingTestingModule, SkyRepeaterHarness, SkyRepeaterItemHarness, SkySortFixture, SkySortTestingModule };
664
+ //# sourceMappingURL=skyux-lists-testing.mjs.map