@skyux/data-grid 0.0.1-alpha.0 → 14.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/fesm2022/skyux-data-grid-testing.mjs +100 -0
- package/fesm2022/skyux-data-grid-testing.mjs.map +1 -0
- package/fesm2022/skyux-data-grid.mjs +833 -0
- package/fesm2022/skyux-data-grid.mjs.map +1 -0
- package/package.json +30 -4
- package/types/skyux-data-grid-testing.d.ts +67 -0
- package/types/skyux-data-grid.d.ts +278 -0
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @skyux/data-grid
|
|
2
|
+
|
|
3
|
+
`@skyux/data-grid` provides a declarative, signal-based data grid for displaying
|
|
4
|
+
tabular data. You supply a `data` array and one `<sky-data-grid-column>` for each
|
|
5
|
+
column, and the grid handles sorting, paging, multiselect, loading states, column
|
|
6
|
+
sizing, templates, and inline help. It is a simpler, higher-level alternative to the
|
|
7
|
+
deprecated `@skyux/grids` and `@skyux/list-builder` grid view, and to building directly
|
|
8
|
+
on the lower-level `@skyux/ag-grid` wrapper.
|
|
9
|
+
|
|
10
|
+
## When to use
|
|
11
|
+
|
|
12
|
+
- Reach for **`@skyux/data-grid`** when you want a straightforward grid driven by inputs
|
|
13
|
+
and column declarations, with the common features (sorting, paging, selection, loading)
|
|
14
|
+
built in.
|
|
15
|
+
- Reach for **`@skyux/ag-grid`** when you need direct access to AG Grid's full
|
|
16
|
+
configuration and APIs for advanced scenarios this component does not cover.
|
|
17
|
+
|
|
18
|
+
## Documentation
|
|
19
|
+
|
|
20
|
+
See the [data grid documentation](https://developer.blackbaud.com/skyux/components/data-grid)
|
|
21
|
+
on the SKY UX developer center for the full API reference, demos, and code examples.
|
|
22
|
+
|
|
23
|
+
## Running unit tests
|
|
24
|
+
|
|
25
|
+
Run `nx test data-grid` to execute the unit tests.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { SkyAgGridWrapperHarness } from '@skyux/ag-grid/testing';
|
|
2
|
+
import { SkyQueryableComponentHarness } from '@skyux/core/testing';
|
|
3
|
+
import { SkyWaitHarness } from '@skyux/indicators/testing';
|
|
4
|
+
import { SkyPagingHarness } from '@skyux/lists/testing';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Harness for interacting with SKY UX data grid components in tests.
|
|
8
|
+
* @preview
|
|
9
|
+
*/
|
|
10
|
+
class SkyDataGridHarness extends SkyQueryableComponentHarness {
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
static { this.hostSelector = 'sky-data-grid'; }
|
|
15
|
+
/**
|
|
16
|
+
* Gets a `HarnessPredicate` that can be used to search for a
|
|
17
|
+
* `SkyDataGridHarness` that meets certain criteria
|
|
18
|
+
*/
|
|
19
|
+
static with(filters) {
|
|
20
|
+
return SkyDataGridHarness.getDataSkyIdPredicate(filters);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Checks whether the grid is ready.
|
|
24
|
+
*/
|
|
25
|
+
async isGridReady() {
|
|
26
|
+
return await this.#getGridWrapper()
|
|
27
|
+
.then(async (grid) => await grid.isGridReady())
|
|
28
|
+
.catch(() => false);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Checks whether the grid is loading.
|
|
32
|
+
*/
|
|
33
|
+
async isLoading() {
|
|
34
|
+
const waits = await this.queryHarnesses(SkyWaitHarness);
|
|
35
|
+
return await Promise.all(waits.map(async (wait) => await wait.isWaiting())).then((loadingStates) => loadingStates.some((isLoading) => isLoading));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the IDs of the currently displayed columns.
|
|
39
|
+
*/
|
|
40
|
+
async getDisplayedColumnIds() {
|
|
41
|
+
return await this.#getGridWrapper()
|
|
42
|
+
.then(async (grid) => await grid.getDisplayedColumnIds())
|
|
43
|
+
.catch(() => Promise.reject(new Error('Unable to retrieve displayed column IDs.')));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves the header names of the currently displayed columns.
|
|
47
|
+
*/
|
|
48
|
+
async getDisplayedColumnHeaderNames() {
|
|
49
|
+
return await this.#getGridWrapper()
|
|
50
|
+
.then(async (grid) => await grid.getDisplayedColumnHeaderNames())
|
|
51
|
+
.catch(() => Promise.reject(new Error('Unable to retrieve displayed column header names.')));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves the total number of displayed rows.
|
|
55
|
+
*/
|
|
56
|
+
async getDisplayedRowCount() {
|
|
57
|
+
return await this.#getGridWrapper()
|
|
58
|
+
.then(async (grid) => (await grid.getGridApi()).getDisplayedRowCount())
|
|
59
|
+
.catch(() => Promise.reject(new Error('Unable to retrieve total number of displayed rows.')));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Clicks the column header sort button.
|
|
63
|
+
*/
|
|
64
|
+
async clickColumnSortButton(column) {
|
|
65
|
+
const btn = await this.locatorFor(`.ag-header-cell.ag-header-cell-sortable[col-id="${column}"] button.ag-header-cell-label-sortable`)();
|
|
66
|
+
await btn.click();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Gets the paging harness for the data grid. Throws if the grid is not paged.
|
|
70
|
+
*/
|
|
71
|
+
async getPaging() {
|
|
72
|
+
const paging = await this.getPagingOrNull();
|
|
73
|
+
if (paging === null) {
|
|
74
|
+
throw new Error('Unable to retrieve paging. The data grid is not paged.');
|
|
75
|
+
}
|
|
76
|
+
return paging;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Gets the paging harness for the data grid, or `null` if the grid is not paged.
|
|
80
|
+
*/
|
|
81
|
+
async getPagingOrNull() {
|
|
82
|
+
return await this.queryHarnessOrNull(SkyPagingHarness);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Gets the wait harness for the data grid.
|
|
86
|
+
*/
|
|
87
|
+
async getWait() {
|
|
88
|
+
return await this.queryHarness(SkyWaitHarness);
|
|
89
|
+
}
|
|
90
|
+
async #getGridWrapper() {
|
|
91
|
+
return await this.queryHarness(SkyAgGridWrapperHarness);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Generated bundle index. Do not edit.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
export { SkyDataGridHarness };
|
|
100
|
+
//# sourceMappingURL=skyux-data-grid-testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skyux-data-grid-testing.mjs","sources":["../../../../../libs/components/data-grid/testing/src/modules/data-grid/data-grid-harness.ts","../../../../../libs/components/data-grid/testing/src/skyux-data-grid-testing.ts"],"sourcesContent":["import { HarnessPredicate } from '@angular/cdk/testing';\nimport { SkyAgGridWrapperHarness } from '@skyux/ag-grid/testing';\nimport { SkyQueryableComponentHarness } from '@skyux/core/testing';\nimport { SkyWaitHarness } from '@skyux/indicators/testing';\nimport { SkyPagingHarness } from '@skyux/lists/testing';\n\nimport { SkyDataGridHarnessFilters } from './data-grid-harness.filters';\n\n/**\n * Harness for interacting with SKY UX data grid components in tests.\n * @preview\n */\nexport class SkyDataGridHarness extends SkyQueryableComponentHarness {\n /**\n * @internal\n */\n public static hostSelector = 'sky-data-grid';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a\n * `SkyDataGridHarness` that meets certain criteria\n */\n public static with(\n filters: SkyDataGridHarnessFilters,\n ): HarnessPredicate<SkyDataGridHarness> {\n return SkyDataGridHarness.getDataSkyIdPredicate(filters);\n }\n\n /**\n * Checks whether the grid is ready.\n */\n public async isGridReady(): Promise<boolean> {\n return await this.#getGridWrapper()\n .then(async (grid) => await grid.isGridReady())\n .catch(() => false);\n }\n\n /**\n * Checks whether the grid is loading.\n */\n public async isLoading(): Promise<boolean> {\n const waits = await this.queryHarnesses(SkyWaitHarness);\n return await Promise.all(\n waits.map(async (wait): Promise<boolean> => await wait.isWaiting()),\n ).then((loadingStates) => loadingStates.some((isLoading) => isLoading));\n }\n\n /**\n * Retrieves the IDs of the currently displayed columns.\n */\n public async getDisplayedColumnIds(): Promise<string[]> {\n return await this.#getGridWrapper()\n .then(async (grid) => await grid.getDisplayedColumnIds())\n .catch(() =>\n Promise.reject(new Error('Unable to retrieve displayed column IDs.')),\n );\n }\n\n /**\n * Retrieves the header names of the currently displayed columns.\n */\n public async getDisplayedColumnHeaderNames(): Promise<string[]> {\n return await this.#getGridWrapper()\n .then(async (grid) => await grid.getDisplayedColumnHeaderNames())\n .catch(() =>\n Promise.reject(\n new Error('Unable to retrieve displayed column header names.'),\n ),\n );\n }\n\n /**\n * Retrieves the total number of displayed rows.\n */\n public async getDisplayedRowCount(): Promise<number> {\n return await this.#getGridWrapper()\n .then(async (grid) => (await grid.getGridApi()).getDisplayedRowCount())\n .catch(() =>\n Promise.reject(\n new Error('Unable to retrieve total number of displayed rows.'),\n ),\n );\n }\n\n /**\n * Clicks the column header sort button.\n */\n public async clickColumnSortButton(column: string): Promise<void> {\n const btn = await this.locatorFor(\n `.ag-header-cell.ag-header-cell-sortable[col-id=\"${column}\"] button.ag-header-cell-label-sortable`,\n )();\n await btn.click();\n }\n\n /**\n * Gets the paging harness for the data grid. Throws if the grid is not paged.\n */\n public async getPaging(): Promise<SkyPagingHarness> {\n const paging = await this.getPagingOrNull();\n\n if (paging === null) {\n throw new Error('Unable to retrieve paging. The data grid is not paged.');\n }\n\n return paging;\n }\n\n /**\n * Gets the paging harness for the data grid, or `null` if the grid is not paged.\n */\n public async getPagingOrNull(): Promise<SkyPagingHarness | null> {\n return await this.queryHarnessOrNull(SkyPagingHarness);\n }\n\n /**\n * Gets the wait harness for the data grid.\n */\n public async getWait(): Promise<SkyWaitHarness> {\n return await this.queryHarness(SkyWaitHarness);\n }\n\n async #getGridWrapper(): Promise<SkyAgGridWrapperHarness> {\n return await this.queryHarness(SkyAgGridWrapperHarness);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-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