@digital-realty/ix-grid 1.4.1-alpha.2 → 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 +23 -28
- package/rollup.config.mjs +4 -42
- 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 +5 -1
- package/src/IxGrid.d.ts +0 -148
- package/src/IxGrid.js +0 -784
- package/src/IxGrid.js.map +0 -1
- package/src/IxGridNav.d.ts +0 -2
- package/src/IxGridNav.js +0 -8
- package/src/IxGridNav.js.map +0 -1
- package/src/components/IxGridColumnFilter.d.ts +0 -35
- package/src/components/IxGridColumnFilter.js +0 -249
- package/src/components/IxGridColumnFilter.js.map +0 -1
- package/src/components/IxGridDownloadMenu.d.ts +0 -17
- package/src/components/IxGridDownloadMenu.js +0 -98
- package/src/components/IxGridDownloadMenu.js.map +0 -1
- package/src/components/IxGridNav.d.ts +0 -16
- package/src/components/IxGridNav.js +0 -103
- package/src/components/IxGridNav.js.map +0 -1
- package/src/components/IxGridNoRows.d.ts +0 -10
- package/src/components/IxGridNoRows.js +0 -74
- package/src/components/IxGridNoRows.js.map +0 -1
- package/src/components/IxGridRowFilter.d.ts +0 -55
- package/src/components/IxGridRowFilter.js +0 -441
- package/src/components/IxGridRowFilter.js.map +0 -1
- package/src/components/IxPagination.d.ts +0 -14
- package/src/components/IxPagination.js +0 -107
- package/src/components/IxPagination.js.map +0 -1
- package/src/components/grid-column-filter-styles.d.ts +0 -1
- package/src/components/grid-column-filter-styles.js +0 -89
- package/src/components/grid-column-filter-styles.js.map +0 -1
- package/src/components/grid-row-filter-styles.d.ts +0 -1
- package/src/components/grid-row-filter-styles.js +0 -311
- package/src/components/grid-row-filter-styles.js.map +0 -1
- package/src/components/ix-grid-no-rows.d.ts +0 -1
- package/src/components/ix-grid-no-rows.js +0 -2
- package/src/components/ix-grid-no-rows.js.map +0 -1
- package/src/components/pagination-styles.d.ts +0 -1
- package/src/components/pagination-styles.js +0 -84
- package/src/components/pagination-styles.js.map +0 -1
- package/src/grid-view-styles.d.ts +0 -1
- package/src/grid-view-styles.js +0 -283
- package/src/grid-view-styles.js.map +0 -1
- package/src/index.d.ts +0 -3
- package/src/index.js +0 -3
- package/src/index.js.map +0 -1
- package/src/ix-grid-copy.d.ts +0 -12
- package/src/ix-grid-copy.js +0 -12
- package/src/ix-grid-copy.js.map +0 -1
- package/src/ix-grid-nav.d.ts +0 -1
- package/src/ix-grid-nav.js +0 -2
- package/src/ix-grid-nav.js.map +0 -1
- package/src/ix-grid-no-rows.d.ts +0 -1
- package/src/ix-grid-no-rows.js +0 -2
- package/src/ix-grid-no-rows.js.map +0 -1
- package/src/ix-grid.d.ts +0 -1
- package/src/ix-grid.js +0 -2
- package/src/ix-grid.js.map +0 -1
- package/src/models/IxGridDownloadMenuItemModel.d.ts +0 -7
- package/src/models/IxGridDownloadMenuItemModel.js +0 -1
- package/src/models/IxGridDownloadMenuItemModel.js.map +0 -1
- package/src/test/ix-grid-column-filter.test.js +0 -41
- package/src/test/ix-grid-row-filter.test.js +0 -281
- package/src/test/ix-grid.test.js +0 -391
- package/src/test/ix-pagination.test.js +0 -58
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent ix-grid following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Digital Realty",
|
|
6
|
-
"version": "1.4.1
|
|
6
|
+
"version": "1.4.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
".": "./dist/index.js",
|
|
12
12
|
"./ix-grid.js": "./dist/ix-grid.js",
|
|
13
13
|
"./ix-grid-nav.js": "./dist/ix-grid-nav.js",
|
|
14
|
+
"./ix-grid.min.js": "./dist/ix-grid.min.js",
|
|
14
15
|
"./ix-grid-no-rows.js": "./dist/ix-grid-no-rows.js",
|
|
15
16
|
"./IxGridNav": "./dist/IxGridNav.js"
|
|
16
17
|
},
|
|
@@ -22,21 +23,22 @@
|
|
|
22
23
|
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
23
24
|
"build": "tsc && npm run analyze -- --exclude dist && rollup -c",
|
|
24
25
|
"prepublish": "tsc && npm run analyze -- --exclude dist",
|
|
25
|
-
"lint": "eslint --ext .ts,.html .
|
|
26
|
-
"format": "eslint --ext .ts,.html . --fix
|
|
26
|
+
"lint": "eslint --ext .ts,.html . && prettier \"**/*.ts\" --check --ignore-path .gitignore",
|
|
27
|
+
"format": "eslint --ext .ts,.html . --fix && prettier \"**/*.ts\" --write --ignore-path .gitignore",
|
|
27
28
|
"test": "tsc && wtr --coverage",
|
|
28
29
|
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@digital-realty/grid": "^1.
|
|
32
|
-
"@digital-realty/ix-button": "^3.
|
|
33
|
-
"@digital-realty/ix-date": "^1.
|
|
34
|
-
"@digital-realty/ix-
|
|
35
|
-
"@digital-realty/ix-icon
|
|
36
|
-
"@digital-realty/ix-
|
|
37
|
-
"@digital-realty/ix-
|
|
38
|
-
"@digital-realty/ix-
|
|
39
|
-
"@digital-realty/ix-
|
|
32
|
+
"@digital-realty/grid": "^1.2.1",
|
|
33
|
+
"@digital-realty/ix-button": "^3.5.1",
|
|
34
|
+
"@digital-realty/ix-date": "^1.3.1",
|
|
35
|
+
"@digital-realty/ix-date-next": "^1.2.1",
|
|
36
|
+
"@digital-realty/ix-icon": "^1.3.1",
|
|
37
|
+
"@digital-realty/ix-icon-button": "^1.3.1",
|
|
38
|
+
"@digital-realty/ix-menu": "^1.3.1",
|
|
39
|
+
"@digital-realty/ix-progress": "^1.4.1",
|
|
40
|
+
"@digital-realty/ix-select": "^1.3.1",
|
|
41
|
+
"@digital-realty/ix-switch": "^2.4.1",
|
|
40
42
|
"@lit/react": "^1.0.5",
|
|
41
43
|
"date-fns": "^4.1.0",
|
|
42
44
|
"lit": "^3.2.1",
|
|
@@ -45,39 +47,31 @@
|
|
|
45
47
|
},
|
|
46
48
|
"devDependencies": {
|
|
47
49
|
"@custom-elements-manifest/analyzer": "^0.4.17",
|
|
48
|
-
"@digital-realty/ix-app-logic": "^1.2.2-alpha.25",
|
|
49
|
-
"@open-wc/eslint-config": "^9.2.1",
|
|
50
50
|
"@open-wc/testing": "^3.1.6",
|
|
51
51
|
"@rollup/plugin-alias": "^5.1.1",
|
|
52
52
|
"@rollup/plugin-replace": "^6.0.2",
|
|
53
|
-
"@rollup/plugin-
|
|
54
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
55
|
-
"@typescript-eslint/parser": "^
|
|
53
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^8.58.2",
|
|
55
|
+
"@typescript-eslint/parser": "^8.58.2",
|
|
56
56
|
"@web/dev-server": "^0.4.6",
|
|
57
57
|
"@web/dev-server-import-maps": "^0.2.1",
|
|
58
58
|
"@web/dev-server-rollup": "^0.6.4",
|
|
59
59
|
"@web/test-runner": "^0.20.2",
|
|
60
|
-
"concurrently": "^9.1
|
|
61
|
-
"eslint": "^
|
|
60
|
+
"concurrently": "^9.2.1",
|
|
61
|
+
"eslint": "^9.39.4",
|
|
62
62
|
"eslint-config-prettier": "^8.3.0",
|
|
63
63
|
"husky": "^4.3.8",
|
|
64
64
|
"lint-staged": "^10.5.4",
|
|
65
65
|
"prettier": "^2.4.1",
|
|
66
66
|
"rollup": "^4.29.1",
|
|
67
|
-
"rollup-plugin-minify-html-literals": "^1.2.6",
|
|
68
67
|
"rollup-plugin-summary": "^2.0.0",
|
|
69
|
-
"
|
|
70
|
-
"sinon": "^19.0.2",
|
|
68
|
+
"sinon": "^21.1.2",
|
|
71
69
|
"tslib": "^2.3.1",
|
|
72
|
-
"typescript": "^4.
|
|
70
|
+
"typescript": "^4.5.2"
|
|
73
71
|
},
|
|
74
72
|
"customElements": "custom-elements.json",
|
|
75
73
|
"eslintConfig": {
|
|
76
74
|
"parser": "@typescript-eslint/parser",
|
|
77
|
-
"extends": [
|
|
78
|
-
"@open-wc",
|
|
79
|
-
"prettier"
|
|
80
|
-
],
|
|
81
75
|
"plugins": [
|
|
82
76
|
"@typescript-eslint"
|
|
83
77
|
],
|
|
@@ -112,5 +106,6 @@
|
|
|
112
106
|
"eslint --fix",
|
|
113
107
|
"prettier --write"
|
|
114
108
|
]
|
|
115
|
-
}
|
|
109
|
+
},
|
|
110
|
+
"gitHead": "da06737d6707fd3d4ef898ba0fa632e7b3ed8019"
|
|
116
111
|
}
|
package/rollup.config.mjs
CHANGED
|
@@ -1,56 +1,18 @@
|
|
|
1
1
|
// Import rollup plugins
|
|
2
|
-
import pkgMinifyHTML from 'rollup-plugin-minify-html-literals';
|
|
3
|
-
const minifyHTML = pkgMinifyHTML.default;
|
|
4
2
|
import summary from 'rollup-plugin-summary';
|
|
5
|
-
import
|
|
6
|
-
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
7
|
-
import { rollUpExternals } from "@digital-realty/ix-app-logic/build_scripts/shared-deps.js";
|
|
8
|
-
import typescript from '@rollup/plugin-typescript';
|
|
9
|
-
|
|
10
|
-
// const sourceDir = './src';
|
|
11
|
-
// const outDir = './dist';
|
|
12
|
-
//
|
|
13
|
-
// export default {
|
|
14
|
-
// input: './src/index.ts',
|
|
15
|
-
// // input: {
|
|
16
|
-
// // 'ix-grid': `${sourceDir}/IxGrid.ts`,
|
|
17
|
-
// // 'ix-grid-nav': `${sourceDir}/components/IxGridNav.ts`,
|
|
18
|
-
// // 'ix-grid-no-rows': `${sourceDir}/components/IxGridNoRows.ts`,
|
|
19
|
-
// // },
|
|
20
|
-
// external: id => rollUpExternals(id),
|
|
21
|
-
// plugins: [
|
|
22
|
-
// typescript(),
|
|
23
|
-
// nodeResolve({
|
|
24
|
-
// exportConditions: ['browser', 'development'],
|
|
25
|
-
// browser: true,
|
|
26
|
-
// }),
|
|
27
|
-
// // Minify HTML template literals
|
|
28
|
-
// minifyHTML(),
|
|
29
|
-
// // Minify JS
|
|
30
|
-
// uglify(),
|
|
31
|
-
// // Print bundle summary
|
|
32
|
-
// summary(),
|
|
33
|
-
// ],
|
|
34
|
-
// output: {
|
|
35
|
-
// dir: outDir,
|
|
36
|
-
// entryFileNames: '[name].min.js',
|
|
37
|
-
// format: 'esm'
|
|
38
|
-
// },
|
|
39
|
-
// };
|
|
3
|
+
import terser from '@rollup/plugin-terser';
|
|
40
4
|
|
|
41
5
|
const target = './dist/ix-grid';
|
|
42
6
|
|
|
43
7
|
export default {
|
|
44
8
|
input: `${target}.js`,
|
|
45
9
|
plugins: [
|
|
46
|
-
// Minify HTML template literals
|
|
47
|
-
minifyHTML(),
|
|
48
10
|
// Minify JS
|
|
49
|
-
|
|
11
|
+
terser(),
|
|
50
12
|
// Print bundle summary
|
|
51
|
-
summary(),
|
|
13
|
+
summary(),
|
|
52
14
|
],
|
|
53
15
|
output: {
|
|
54
16
|
file: `${target}.min.js`,
|
|
55
17
|
},
|
|
56
|
-
};
|
|
18
|
+
};
|
package/src/IxGrid.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/no-duplicates */
|
|
2
1
|
import '@digital-realty/grid';
|
|
3
2
|
import type { GridItemModel } from '@digital-realty/grid';
|
|
4
3
|
import { columnHeaderRenderer } from '@digital-realty/grid/lit.js';
|
|
@@ -10,7 +9,7 @@ import { html, LitElement, nothing, render } from 'lit';
|
|
|
10
9
|
import { property, query, state } from 'lit/decorators.js';
|
|
11
10
|
import { classMap } from 'lit/directives/class-map.js';
|
|
12
11
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
13
|
-
import { formatDate } from 'date-fns';
|
|
12
|
+
import { formatDate } from 'date-fns/format.js';
|
|
14
13
|
import './components/IxGridColumnFilter.js';
|
|
15
14
|
import './components/IxGridDownloadMenu.js';
|
|
16
15
|
import './components/IxGridRowFilter.js';
|
|
@@ -57,6 +56,10 @@ export interface FieldOperator {
|
|
|
57
56
|
operator: FilterOperator;
|
|
58
57
|
}
|
|
59
58
|
|
|
59
|
+
export interface SessionStorageData {
|
|
60
|
+
pageSize?: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
60
63
|
export class IxGrid extends LitElement {
|
|
61
64
|
static readonly styles = [IxGridViewStyles];
|
|
62
65
|
|
|
@@ -73,6 +76,11 @@ export class IxGrid extends LitElement {
|
|
|
73
76
|
|
|
74
77
|
@property({ type: String }) variantClass = '';
|
|
75
78
|
|
|
79
|
+
@property({ type: Boolean, attribute: 'simple-pagination' })
|
|
80
|
+
hasSimplePagination = false;
|
|
81
|
+
|
|
82
|
+
@property({ type: String }) theme = 'no-border';
|
|
83
|
+
|
|
76
84
|
@property({ type: Array }) readonly columns: Column[] = [];
|
|
77
85
|
|
|
78
86
|
@property({ type: Array }) rows: Row[] = [];
|
|
@@ -135,6 +143,9 @@ export class IxGrid extends LitElement {
|
|
|
135
143
|
|
|
136
144
|
@property({ type: Boolean }) disableAddButton = false;
|
|
137
145
|
|
|
146
|
+
@property({ type: Boolean, attribute: 'show-view-more' }) showViewMore =
|
|
147
|
+
false;
|
|
148
|
+
|
|
138
149
|
@property({ type: String }) addButtonLabel: string = copy.add;
|
|
139
150
|
|
|
140
151
|
@property({ type: Function }) onAddButtonClick?: any;
|
|
@@ -147,6 +158,11 @@ export class IxGrid extends LitElement {
|
|
|
147
158
|
|
|
148
159
|
@property({ type: Function }) onRemoveAllButtonClick?: any;
|
|
149
160
|
|
|
161
|
+
@property({ type: String, attribute: 'session-storage-key' })
|
|
162
|
+
sessionStorageKey: string | undefined = undefined;
|
|
163
|
+
|
|
164
|
+
@property({ type: Boolean }) useNewDatePicker = false;
|
|
165
|
+
|
|
150
166
|
@state() private filters: Filter[] = [];
|
|
151
167
|
|
|
152
168
|
@state() isColumnsReordering = false;
|
|
@@ -155,6 +171,8 @@ export class IxGrid extends LitElement {
|
|
|
155
171
|
|
|
156
172
|
@state() displayColumns: Column[] = [];
|
|
157
173
|
|
|
174
|
+
@state() sessionStorageData: SessionStorageData | undefined = undefined;
|
|
175
|
+
|
|
158
176
|
private defaultFilterKeys = ['sort', 'order', 'page', 'size'];
|
|
159
177
|
|
|
160
178
|
private initialised = false;
|
|
@@ -208,10 +226,12 @@ export class IxGrid extends LitElement {
|
|
|
208
226
|
connectedCallback() {
|
|
209
227
|
super.connectedCallback?.();
|
|
210
228
|
window.addEventListener('popstate', this.handlePopState);
|
|
229
|
+
window.addEventListener('beforeunload', this.handleUnload);
|
|
211
230
|
}
|
|
212
231
|
|
|
213
232
|
disconnectedCallback() {
|
|
214
233
|
window.removeEventListener('popstate', this.handlePopState);
|
|
234
|
+
window.removeEventListener('beforeunload', this.handleUnload);
|
|
215
235
|
super.disconnectedCallback?.();
|
|
216
236
|
}
|
|
217
237
|
|
|
@@ -220,9 +240,15 @@ export class IxGrid extends LitElement {
|
|
|
220
240
|
this.dispatchChangeEvent();
|
|
221
241
|
};
|
|
222
242
|
|
|
243
|
+
private handleUnload = () => {
|
|
244
|
+
sessionStorage.removeItem(`urlPageSizeRead`);
|
|
245
|
+
};
|
|
246
|
+
|
|
223
247
|
private updateSearchParamsFromUri(
|
|
224
248
|
rebuildFiltersFromUri: boolean = false
|
|
225
249
|
): void {
|
|
250
|
+
// If the grid is not visible, do not update from search params
|
|
251
|
+
if (this.grid.getBoundingClientRect().width === 0) return;
|
|
226
252
|
if (this.readParamsFromURL) {
|
|
227
253
|
const url = new URL(window.location.href);
|
|
228
254
|
const searchParams = new URLSearchParams(url.search);
|
|
@@ -242,7 +268,17 @@ export class IxGrid extends LitElement {
|
|
|
242
268
|
}
|
|
243
269
|
|
|
244
270
|
if (size) {
|
|
245
|
-
|
|
271
|
+
// update pageSize with url param only on load or refresh
|
|
272
|
+
// otherwise use session storage value
|
|
273
|
+
if (
|
|
274
|
+
!this.getSessionStorageData() ||
|
|
275
|
+
(!sessionStorage.getItem(`urlPageSizeRead`) &&
|
|
276
|
+
this.grid.getBoundingClientRect().width > 0)
|
|
277
|
+
) {
|
|
278
|
+
sessionStorage.setItem(`urlPageSizeRead`, true.toString());
|
|
279
|
+
this.pageSize = parseInt(size, 10) || this.defaultPageSize;
|
|
280
|
+
this.updateSessionStorage({ pageSize: this.pageSize });
|
|
281
|
+
}
|
|
246
282
|
}
|
|
247
283
|
|
|
248
284
|
if (rebuildFiltersFromUri) {
|
|
@@ -271,7 +307,8 @@ export class IxGrid extends LitElement {
|
|
|
271
307
|
}
|
|
272
308
|
|
|
273
309
|
private dispatchChangeEvent = () => {
|
|
274
|
-
const
|
|
310
|
+
const activeFilters = this.filters ?? [];
|
|
311
|
+
const filters = activeFilters.reduce(
|
|
275
312
|
(columnFilters: { [key: string]: string }, { columnField, value }) => ({
|
|
276
313
|
...columnFilters,
|
|
277
314
|
[columnField]: value,
|
|
@@ -287,7 +324,7 @@ export class IxGrid extends LitElement {
|
|
|
287
324
|
page: this.page,
|
|
288
325
|
pageSize: this.pageSize,
|
|
289
326
|
filters,
|
|
290
|
-
filtersOperators:
|
|
327
|
+
filtersOperators: activeFilters.map(
|
|
291
328
|
(f: Filter): FieldOperator => ({
|
|
292
329
|
columnField: f.columnField,
|
|
293
330
|
operator: <FilterOperator>f.operatorValue,
|
|
@@ -306,12 +343,57 @@ export class IxGrid extends LitElement {
|
|
|
306
343
|
this.checkLocalStorageUpdate();
|
|
307
344
|
this.initialised = true;
|
|
308
345
|
}
|
|
346
|
+
|
|
347
|
+
if (
|
|
348
|
+
changedProperties.has('sessionStorageData') &&
|
|
349
|
+
this.sessionStorageData
|
|
350
|
+
) {
|
|
351
|
+
const newPageSize =
|
|
352
|
+
this.sessionStorageData.pageSize || this.defaultPageSize;
|
|
353
|
+
|
|
354
|
+
if (this.pageSize !== newPageSize) {
|
|
355
|
+
this.pageSize = newPageSize;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
309
359
|
super.update(changedProperties);
|
|
310
360
|
}
|
|
311
361
|
|
|
312
362
|
firstUpdated() {
|
|
313
363
|
this.updateSearchParamsFromUri();
|
|
314
364
|
this.removeOldLocalStorageValues();
|
|
365
|
+
this.sessionStorageData = this.getSessionStorageData();
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
private getSessionStorageData() {
|
|
369
|
+
if (this.sessionStorageKey) {
|
|
370
|
+
const sessionData = sessionStorage.getItem(
|
|
371
|
+
`grid-${this.sessionStorageKey}`
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
if (sessionData) {
|
|
375
|
+
return JSON.parse(sessionData);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return undefined;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
private updateSessionStorage(data: SessionStorageData) {
|
|
383
|
+
const sessionData = this.getSessionStorageData() || {};
|
|
384
|
+
|
|
385
|
+
if (this.sessionStorageKey && data) {
|
|
386
|
+
const updatedData = {
|
|
387
|
+
...sessionData,
|
|
388
|
+
...data,
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
sessionStorage.setItem(
|
|
392
|
+
`grid-${this.sessionStorageKey}`,
|
|
393
|
+
JSON.stringify(updatedData)
|
|
394
|
+
);
|
|
395
|
+
this.sessionStorageData = updatedData;
|
|
396
|
+
}
|
|
315
397
|
}
|
|
316
398
|
|
|
317
399
|
private checkLocalStorageUpdate(): void {
|
|
@@ -728,8 +810,9 @@ export class IxGrid extends LitElement {
|
|
|
728
810
|
.filterValueChangeDebounceTime}
|
|
729
811
|
.readParamsFromURL=${this.readParamsFromURL}
|
|
730
812
|
.maxDate=${this.filterMaxDate}
|
|
813
|
+
.useNewDatePicker=${this.useNewDatePicker}
|
|
731
814
|
@rowFilter=${(e: CustomEvent) => {
|
|
732
|
-
this.filters = e.detail.filters;
|
|
815
|
+
this.filters = e.detail.filters ?? [];
|
|
733
816
|
if (e.detail.resetPage) {
|
|
734
817
|
this.page = this.defaultPage;
|
|
735
818
|
}
|
|
@@ -758,8 +841,20 @@ export class IxGrid extends LitElement {
|
|
|
758
841
|
</ix-button>`;
|
|
759
842
|
}
|
|
760
843
|
|
|
844
|
+
renderViewMore() {
|
|
845
|
+
if (!this.showViewMore) return nothing;
|
|
846
|
+
|
|
847
|
+
return html` <div class="view-more">
|
|
848
|
+
<slot name="viewMore"></slot>
|
|
849
|
+
</div>`;
|
|
850
|
+
}
|
|
851
|
+
|
|
761
852
|
get showViewMoreLessButton() {
|
|
762
|
-
return
|
|
853
|
+
return (
|
|
854
|
+
!this.showViewMore &&
|
|
855
|
+
this.rowLimit > 0 &&
|
|
856
|
+
this.rows.length > this.rowLimit
|
|
857
|
+
);
|
|
763
858
|
}
|
|
764
859
|
|
|
765
860
|
renderViewMoreLessButton() {
|
|
@@ -812,9 +907,15 @@ export class IxGrid extends LitElement {
|
|
|
812
907
|
</div>`;
|
|
813
908
|
};
|
|
814
909
|
|
|
815
|
-
private renderPaginationControls = () =>
|
|
816
|
-
|
|
910
|
+
private renderPaginationControls = () => {
|
|
911
|
+
if (this.rowLimit > 0) {
|
|
912
|
+
return nothing;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
return html`
|
|
817
916
|
<ix-pagination
|
|
917
|
+
?simple=${this.hasSimplePagination}
|
|
918
|
+
class="pagination"
|
|
818
919
|
.page=${this.page}
|
|
819
920
|
.pageSize=${this.pageSize}
|
|
820
921
|
.pageSizes=${this.pageSizes}
|
|
@@ -822,11 +923,14 @@ export class IxGrid extends LitElement {
|
|
|
822
923
|
@updatePagination=${(e: CustomEvent) => {
|
|
823
924
|
this.page = e.detail.page;
|
|
824
925
|
this.pageSize = e.detail.pageSize;
|
|
926
|
+
this.updateSessionStorage({
|
|
927
|
+
pageSize: this.pageSize,
|
|
928
|
+
});
|
|
825
929
|
this.updatePage();
|
|
826
930
|
}}
|
|
827
931
|
></ix-pagination>
|
|
828
|
-
|
|
829
|
-
|
|
932
|
+
`;
|
|
933
|
+
};
|
|
830
934
|
|
|
831
935
|
renderColumns() {
|
|
832
936
|
const arrangedColumnsInstance = [...this.arrangedColumns];
|
|
@@ -895,8 +999,7 @@ export class IxGrid extends LitElement {
|
|
|
895
999
|
class=${this.hideColumnHeaders ? 'hide-column-headers' : ''}
|
|
896
1000
|
.items=${columnDisplayed ? displayRows : []}
|
|
897
1001
|
all-rows-visible
|
|
898
|
-
|
|
899
|
-
theme="no-border"
|
|
1002
|
+
theme=${this.theme}
|
|
900
1003
|
.cellPartNameGenerator=${this.cellPartNameGenerator}
|
|
901
1004
|
@mouseup=${this.reorderColumnsFromTable}
|
|
902
1005
|
>
|
|
@@ -914,8 +1017,9 @@ export class IxGrid extends LitElement {
|
|
|
914
1017
|
>
|
|
915
1018
|
${this.hideHeader ? nothing : this.renderHeader()}
|
|
916
1019
|
${this.renderLoading()} ${this.renderGrid()} ${this.renderRowControls()}
|
|
917
|
-
|
|
918
|
-
|
|
1020
|
+
<div class="row-controls more-pagination">
|
|
1021
|
+
${this.renderViewMore()} ${this.renderPaginationControls()}
|
|
1022
|
+
</div>
|
|
919
1023
|
<slot name="footer"></slot>
|
|
920
1024
|
</div>
|
|
921
1025
|
`;
|
|
@@ -57,7 +57,9 @@ export class IxGridNoRows extends LitElement {
|
|
|
57
57
|
return html`
|
|
58
58
|
<div class="container" style="--ix-icon-font-size: ${this.iconFontSize};">
|
|
59
59
|
<ix-icon class="icon ${this.type}">${this.icon}</ix-icon>
|
|
60
|
-
<h2 class="dlr-text-heading"
|
|
60
|
+
<h2 class="dlr-text-heading" data-testid="ix-grid-no-rows-heading">
|
|
61
|
+
${this.message}
|
|
62
|
+
</h2>
|
|
61
63
|
</div>
|
|
62
64
|
`;
|
|
63
65
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import '@digital-realty/ix-button/ix-button.js';
|
|
2
2
|
import '@digital-realty/ix-date/ix-date.js';
|
|
3
|
+
import '@digital-realty/ix-date-next/ix-date-next.js';
|
|
3
4
|
import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
4
5
|
import '@digital-realty/ix-icon/ix-icon.js';
|
|
5
6
|
import '@digital-realty/ix-select/ix-select.js';
|
|
6
|
-
import { formatDate } from 'date-fns';
|
|
7
|
+
import { format, formatDate } from 'date-fns/format.js';
|
|
7
8
|
import { LitElement, html, nothing } from 'lit';
|
|
8
9
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
9
10
|
import { repeat } from 'lit/directives/repeat.js';
|
|
@@ -29,6 +30,8 @@ export class IxGridRowFilter extends LitElement {
|
|
|
29
30
|
|
|
30
31
|
@property({ type: Boolean }) readParamsFromURL = false;
|
|
31
32
|
|
|
33
|
+
@property({ type: Boolean }) useNewDatePicker = false;
|
|
34
|
+
|
|
32
35
|
@property({ type: String }) maxDate: string = formatDate(
|
|
33
36
|
new Date(),
|
|
34
37
|
'yyyy-MM-dd'
|
|
@@ -255,12 +258,24 @@ export class IxGridRowFilter extends LitElement {
|
|
|
255
258
|
}
|
|
256
259
|
return html` <p>${this.activeFilters.length} ${copy.activeFilter}</p>
|
|
257
260
|
<ul>
|
|
258
|
-
${this.activeFilters.map(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
${this.activeFilters.map(filter => {
|
|
262
|
+
let displayValue = filter.value;
|
|
263
|
+
|
|
264
|
+
if (filter.dataType === 'dateTime' && this.useNewDatePicker) {
|
|
265
|
+
const date = this.shadowRoot?.querySelector(`ix-date-next`) as any;
|
|
266
|
+
displayValue = format(displayValue, date.format);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const column = this.filterableColumns.find(
|
|
270
|
+
c => c.name === filter.columnField
|
|
271
|
+
);
|
|
272
|
+
const columnHeader =
|
|
273
|
+
column?.header ?? this.formatCamelCaseToEnglish(filter.columnField);
|
|
274
|
+
|
|
275
|
+
return html`<li>
|
|
276
|
+
${columnHeader} ${filter.operatorValue} ${displayValue}
|
|
277
|
+
</li>`;
|
|
278
|
+
})}
|
|
264
279
|
</ul>`;
|
|
265
280
|
}
|
|
266
281
|
|
|
@@ -278,15 +293,26 @@ export class IxGridRowFilter extends LitElement {
|
|
|
278
293
|
}
|
|
279
294
|
|
|
280
295
|
private renderDateInput(value: any, index: number) {
|
|
281
|
-
return
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
296
|
+
return this.useNewDatePicker
|
|
297
|
+
? html`<ix-date-next
|
|
298
|
+
data-testid=${`filterValueInput-${index}`}
|
|
299
|
+
.value=${value.value}
|
|
300
|
+
max=${this.maxDate}
|
|
301
|
+
name="${value.columnField}-valueDate"
|
|
302
|
+
showCalendarOnMouseDown="true"
|
|
303
|
+
.errorText=${this.fromDateErrorText}
|
|
304
|
+
.onChanged=${e => this.onDatefilterValueChange(index, e)}
|
|
305
|
+
>
|
|
306
|
+
</ix-date-next>`
|
|
307
|
+
: html`<ix-date
|
|
308
|
+
data-testid=${`filterValueInput-${index}`}
|
|
309
|
+
.value=${value.value}
|
|
310
|
+
max=${this.maxDate}
|
|
311
|
+
name="${value.columnField}-valueDate"
|
|
312
|
+
.errorText=${this.fromDateErrorText}
|
|
313
|
+
.onChanged=${e => this.onDatefilterValueChange(index, e)}
|
|
314
|
+
>
|
|
315
|
+
</ix-date>`;
|
|
290
316
|
}
|
|
291
317
|
|
|
292
318
|
private renderFilterInputControl(value: any, index: number) {
|
|
@@ -362,14 +388,7 @@ export class IxGridRowFilter extends LitElement {
|
|
|
362
388
|
class="filter-form-column filter-form-column-border filterColumnField"
|
|
363
389
|
>
|
|
364
390
|
<div class="filter-form-group">
|
|
365
|
-
<label
|
|
366
|
-
class="form-group-column-label"
|
|
367
|
-
title="select: ${value.columnField}, options: ${filterOptions.map(
|
|
368
|
-
column => `value=${column.name}, selected=${
|
|
369
|
-
column.name === value.columnField
|
|
370
|
-
}, ${column.header}
|
|
371
|
-
`
|
|
372
|
-
)}"
|
|
391
|
+
<label class="form-group-column-label"
|
|
373
392
|
><span>Columns</span>
|
|
374
393
|
<select
|
|
375
394
|
data-testid=${`filterColumnInput-${index}`}
|
|
@@ -18,6 +18,8 @@ export class IxPagination extends LitElement {
|
|
|
18
18
|
|
|
19
19
|
@property({ type: Array }) pageSizes: number[] = [5, 10, 25, 100];
|
|
20
20
|
|
|
21
|
+
@property({ type: Boolean, attribute: 'simple' }) isSimple = false;
|
|
22
|
+
|
|
21
23
|
private changePage(offset: number) {
|
|
22
24
|
this.page += offset;
|
|
23
25
|
this.updatePagination();
|
|
@@ -49,9 +51,11 @@ export class IxPagination extends LitElement {
|
|
|
49
51
|
render() {
|
|
50
52
|
const back = this.page > 1;
|
|
51
53
|
const next = this.recordCount > this.page * this.pageSize;
|
|
52
|
-
return html` <div class="pagination">
|
|
53
|
-
<div>
|
|
54
|
-
<p class="rows-per-page"
|
|
54
|
+
return html` <div class="pagination ${this.isSimple ? 'simple' : ''}">
|
|
55
|
+
<div ?hidden=${this.isSimple}>
|
|
56
|
+
<p class="rows-per-page" data-testid="ix-pagination-rows-per-page">
|
|
57
|
+
${copy.rowsPerPage}:
|
|
58
|
+
</p>
|
|
55
59
|
<ix-select
|
|
56
60
|
wide-menu
|
|
57
61
|
menu-positioning="fixed"
|
|
@@ -74,7 +78,7 @@ export class IxPagination extends LitElement {
|
|
|
74
78
|
</ix-select>
|
|
75
79
|
</div>
|
|
76
80
|
<div>
|
|
77
|
-
<p>
|
|
81
|
+
<p data-testid="ix-pagination-page-of-page">
|
|
78
82
|
${this.recordCount > 0 ? (this.page - 1) * this.pageSize + 1 : 0} -
|
|
79
83
|
${this.page * this.pageSize > this.recordCount
|
|
80
84
|
? html`${this.recordCount}`
|
|
@@ -160,8 +160,14 @@ export const IxGridRowFilterStyles = css`
|
|
|
160
160
|
flex-direction: column;
|
|
161
161
|
align-items: baseline;
|
|
162
162
|
height: 54px;
|
|
163
|
-
justify-content:
|
|
163
|
+
justify-content: space-between;
|
|
164
164
|
font-family: var(--text-default-font, sans-serif);
|
|
165
|
+
white-space: wrap;
|
|
166
|
+
|
|
167
|
+
ix-date-next,
|
|
168
|
+
ix-date {
|
|
169
|
+
margin-top: 10px;
|
|
170
|
+
}
|
|
165
171
|
}
|
|
166
172
|
|
|
167
173
|
option {
|
|
@@ -215,7 +221,7 @@ export const IxGridRowFilterStyles = css`
|
|
|
215
221
|
}
|
|
216
222
|
|
|
217
223
|
.filterColumnField {
|
|
218
|
-
width: 150px;
|
|
224
|
+
width: var(--ix-grid-filter-column-width, 150px);
|
|
219
225
|
}
|
|
220
226
|
|
|
221
227
|
.filterValueField {
|
|
@@ -8,6 +8,10 @@ export const PaginationStyles = css`
|
|
|
8
8
|
);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
[hidden] {
|
|
12
|
+
display: none !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
.pagination {
|
|
12
16
|
display: flex;
|
|
13
17
|
align-items: center;
|
|
@@ -23,6 +27,10 @@ export const PaginationStyles = css`
|
|
|
23
27
|
margin: 1.25rem 0.5rem 1.25rem 1rem;
|
|
24
28
|
}
|
|
25
29
|
|
|
30
|
+
.pagination.simple {
|
|
31
|
+
margin: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
.pagination > div {
|
|
27
35
|
display: flex;
|
|
28
36
|
align-items: center;
|