@digital-realty/ix-grid 1.4.1-alpha.1 → 1.4.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/dist/IxGrid.d.ts +13 -0
- package/dist/IxGrid.js +107 -19
- package/dist/IxGrid.js.map +1 -1
- package/dist/components/IxGridNav.js +0 -1
- package/dist/components/IxGridNav.js.map +1 -1
- package/dist/components/IxGridNoRows.js +3 -1
- package/dist/components/IxGridNoRows.js.map +1 -1
- package/dist/components/IxGridRowFilter.d.ts +2 -0
- package/dist/components/IxGridRowFilter.js +40 -18
- package/dist/components/IxGridRowFilter.js.map +1 -1
- package/dist/components/IxPagination.d.ts +1 -0
- package/dist/components/IxPagination.js +10 -4
- package/dist/components/IxPagination.js.map +1 -1
- package/dist/components/grid-row-filter-styles.js +8 -2
- package/dist/components/grid-row-filter-styles.js.map +1 -1
- package/dist/components/pagination-styles.js +8 -0
- package/dist/components/pagination-styles.js.map +1 -1
- package/dist/grid-view-styles.js +16 -10
- package/dist/grid-view-styles.js.map +1 -1
- package/dist/ix-grid.min.js +1210 -19
- package/dist/test/a11y.test.d.ts +2 -0
- package/dist/test/a11y.test.js +18 -0
- package/dist/test/a11y.test.js.map +1 -0
- package/dist/test/ix-grid-row-filter.test.js +63 -0
- package/dist/test/ix-grid-row-filter.test.js.map +1 -1
- package/dist/test/ix-grid.test.js +42 -1
- package/dist/test/ix-grid.test.js.map +1 -1
- package/dist/test/mockData.d.ts +10 -0
- package/dist/test/mockData.js +36 -0
- package/dist/test/mockData.js.map +1 -0
- package/package.json +21 -26
- package/rollup.config.mjs +4 -16
- package/src/IxGrid.ts +119 -15
- package/src/components/IxGridNav.ts +0 -1
- package/src/components/IxGridNoRows.ts +3 -1
- package/src/components/IxGridRowFilter.ts +43 -24
- package/src/components/IxPagination.ts +8 -4
- package/src/components/grid-row-filter-styles.ts +8 -2
- package/src/components/pagination-styles.ts +8 -0
- package/src/grid-view-styles.ts +16 -10
- package/src/test/a11y.test.ts +25 -0
- package/src/test/ix-grid-row-filter.test.ts +85 -0
- package/src/test/ix-grid.test.ts +64 -1
- package/src/test/mockData.ts +37 -0
- package/web-test-runner.config.mjs +4 -0
package/src/test/ix-grid.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-restricted-globals */
|
|
2
|
-
import { expect, fixture, oneEvent } from '@open-wc/testing';
|
|
2
|
+
import { elementUpdated, expect, fixture, oneEvent } from '@open-wc/testing';
|
|
3
3
|
import { html } from 'lit';
|
|
4
|
+
|
|
4
5
|
import { IxGrid } from '../IxGrid.js';
|
|
5
6
|
import { IxGridRowFilter } from '../components/IxGridRowFilter.js';
|
|
6
7
|
import '../ix-grid-no-rows.js';
|
|
@@ -42,7 +43,13 @@ const columns = [
|
|
|
42
43
|
},
|
|
43
44
|
];
|
|
44
45
|
|
|
46
|
+
const sessionStorageKey = 'test-session-key';
|
|
47
|
+
|
|
45
48
|
describe('IxGrid', () => {
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
sessionStorage.clear();
|
|
51
|
+
});
|
|
52
|
+
|
|
46
53
|
it('renders a grid', async () => {
|
|
47
54
|
const el = await fixture<IxGrid>(html`<ix-grid></ix-grid>`);
|
|
48
55
|
|
|
@@ -87,6 +94,7 @@ describe('IxGrid', () => {
|
|
|
87
94
|
|
|
88
95
|
it('resets pagination upon filter change', async () => {
|
|
89
96
|
const el = await fixture<IxGrid>(html`<ix-grid
|
|
97
|
+
session-storage-key=${sessionStorageKey}
|
|
90
98
|
.columns=${columns}
|
|
91
99
|
.rows=${rows}
|
|
92
100
|
></ix-grid>`);
|
|
@@ -105,6 +113,7 @@ describe('IxGrid', () => {
|
|
|
105
113
|
expect(el.page).to.equal(2);
|
|
106
114
|
|
|
107
115
|
const rowFilter = el.shadowRoot?.querySelector('ix-grid-row-filter');
|
|
116
|
+
const changeEvent = oneEvent(el, 'change');
|
|
108
117
|
rowFilter!.dispatchEvent(
|
|
109
118
|
new CustomEvent('rowFilter', {
|
|
110
119
|
detail: {
|
|
@@ -114,7 +123,10 @@ describe('IxGrid', () => {
|
|
|
114
123
|
composed: true,
|
|
115
124
|
})
|
|
116
125
|
);
|
|
126
|
+
const event = await changeEvent;
|
|
117
127
|
expect(el.page).to.equal(1);
|
|
128
|
+
expect(event.detail.filters).to.deep.equal({});
|
|
129
|
+
expect(event.detail.filtersOperators).to.deep.equal([]);
|
|
118
130
|
});
|
|
119
131
|
|
|
120
132
|
it('should read and set sort, order, page and page size from URL if readParamsFromURL is set to true', async () => {
|
|
@@ -122,8 +134,11 @@ describe('IxGrid', () => {
|
|
|
122
134
|
.columns=${columns}
|
|
123
135
|
.rows=${rows}
|
|
124
136
|
.readParamsFromURL=${true}
|
|
137
|
+
session-storage-key=${sessionStorageKey}
|
|
125
138
|
></ix-grid>`);
|
|
126
139
|
|
|
140
|
+
sessionStorage.removeItem(`urlPageSizeRead`);
|
|
141
|
+
|
|
127
142
|
const url = '?sort=lastName&order=asc&page=2&size=5';
|
|
128
143
|
|
|
129
144
|
history.pushState(null, '', `${location.pathname}${url}`);
|
|
@@ -135,6 +150,52 @@ describe('IxGrid', () => {
|
|
|
135
150
|
expect(el.sortDirection).to.be.eq('asc');
|
|
136
151
|
});
|
|
137
152
|
|
|
153
|
+
it('sessionStorage sets the URL', async () => {
|
|
154
|
+
sessionStorage.setItem(
|
|
155
|
+
`grid-${sessionStorageKey}`,
|
|
156
|
+
JSON.stringify({
|
|
157
|
+
pageSize: 25,
|
|
158
|
+
})
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const el = await fixture<IxGrid>(html`<ix-grid
|
|
162
|
+
.columns=${columns}
|
|
163
|
+
.rows=${rows}
|
|
164
|
+
session-storage-key=${sessionStorageKey}
|
|
165
|
+
></ix-grid>`);
|
|
166
|
+
|
|
167
|
+
await elementUpdated(el);
|
|
168
|
+
|
|
169
|
+
expect(location.href).to.contain('size=25');
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('page and page size from URL sets sessionStorage', async () => {
|
|
173
|
+
sessionStorage.setItem(
|
|
174
|
+
`grid-${sessionStorageKey}`,
|
|
175
|
+
JSON.stringify({
|
|
176
|
+
pageSize: 10,
|
|
177
|
+
})
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const el = await fixture<IxGrid>(html`<ix-grid
|
|
181
|
+
.columns=${columns}
|
|
182
|
+
.rows=${rows}
|
|
183
|
+
.readParamsFromURL=${true}
|
|
184
|
+
session-storage-key=${sessionStorageKey}
|
|
185
|
+
></ix-grid>`);
|
|
186
|
+
|
|
187
|
+
const url = '?sort=lastName&order=asc&page=2&size=25';
|
|
188
|
+
|
|
189
|
+
history.pushState(null, '', `${location.pathname}${url}`);
|
|
190
|
+
await elementUpdated(el);
|
|
191
|
+
|
|
192
|
+
const sessionData = JSON.parse(
|
|
193
|
+
sessionStorage.getItem(`grid-${sessionStorageKey}`) || '{}'
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
expect(sessionData.pageSize).to.be.eq(25);
|
|
197
|
+
});
|
|
198
|
+
|
|
138
199
|
it('should set sort, order, page, page size and filters in the URL when addParamsToURL is set to true', async () => {
|
|
139
200
|
const columnsWithFilters = [
|
|
140
201
|
{
|
|
@@ -166,6 +227,7 @@ describe('IxGrid', () => {
|
|
|
166
227
|
const el = await fixture<IxGrid>(html`<ix-grid
|
|
167
228
|
.columns=${columnsWithFilters}
|
|
168
229
|
.addParamsToURL=${true}
|
|
230
|
+
session-storage-key=${sessionStorageKey}
|
|
169
231
|
></ix-grid>`);
|
|
170
232
|
|
|
171
233
|
const rowFilter = el.shadowRoot?.querySelector('ix-grid-row-filter');
|
|
@@ -230,6 +292,7 @@ describe('IxGrid', () => {
|
|
|
230
292
|
.rows=${[]}
|
|
231
293
|
.addParamsToURL=${true}
|
|
232
294
|
.preservedQueryParamKeys=${['userId', 'token']}
|
|
295
|
+
session-storage-key=${sessionStorageKey}
|
|
233
296
|
></ix-grid>
|
|
234
297
|
`);
|
|
235
298
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
|
|
3
|
+
export const rows = [
|
|
4
|
+
{
|
|
5
|
+
name: 'one',
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
name: 'two',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: 'three',
|
|
12
|
+
},
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
export const columns = [
|
|
16
|
+
{
|
|
17
|
+
name: 'one',
|
|
18
|
+
header: 'one',
|
|
19
|
+
bodyRenderer: row => html` <span>${row.name}</span>`,
|
|
20
|
+
filterable: true,
|
|
21
|
+
filterOperators: ['equals'],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'two',
|
|
25
|
+
header: 'one',
|
|
26
|
+
bodyRenderer: row => html` <span>${row.name}</span>`,
|
|
27
|
+
filterable: true,
|
|
28
|
+
filterOperators: ['equals', 'contains'],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'three',
|
|
32
|
+
header: 'one',
|
|
33
|
+
bodyRenderer: row => html` <span>${row.name}</span>`,
|
|
34
|
+
filterable: true,
|
|
35
|
+
filterOperators: ['equals', 'contains'],
|
|
36
|
+
},
|
|
37
|
+
];
|
|
@@ -31,6 +31,10 @@ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
|
31
31
|
|
|
32
32
|
port: 8030,
|
|
33
33
|
|
|
34
|
+
coverageConfig: {
|
|
35
|
+
exclude: ['**/node_modules/**', '**/__wds-outside-root__/**'],
|
|
36
|
+
},
|
|
37
|
+
|
|
34
38
|
/** Filter out lit dev mode logs */
|
|
35
39
|
filterBrowserLogs(log) {
|
|
36
40
|
for (const arg of log.args) {
|