@digital-realty/ix-grid 1.0.50-alpha.1 → 1.0.51
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 +74 -74
- package/dist/IxGrid.js +280 -280
- package/dist/{react/IxGridNav.d.ts → IxGridNav.d.ts} +2 -2
- package/dist/{react/IxGridNav.js → IxGridNav.js} +8 -8
- package/dist/IxGridNav.js.map +1 -0
- package/dist/components/IxGridColumnFilter.d.ts +29 -29
- package/dist/components/IxGridColumnFilter.js +162 -159
- package/dist/components/IxGridColumnFilter.js.map +1 -1
- package/dist/components/IxGridDownloadMenu.d.ts +15 -15
- package/dist/components/IxGridDownloadMenu.js +51 -51
- package/dist/components/IxGridNav.d.ts +15 -15
- package/dist/components/IxGridNav.js +20 -20
- package/dist/components/IxGridNoRows.d.ts +10 -9
- package/dist/components/IxGridNoRows.js +50 -37
- package/dist/components/IxGridNoRows.js.map +1 -1
- package/dist/components/IxGridRowFilter.d.ts +41 -41
- package/dist/components/IxGridRowFilter.js +201 -201
- package/dist/components/IxPagination.d.ts +13 -13
- package/dist/components/IxPagination.js +59 -59
- package/dist/components/grid-column-filter-styles.d.ts +1 -1
- package/dist/components/grid-column-filter-styles.js +32 -31
- package/dist/components/grid-column-filter-styles.js.map +1 -1
- package/dist/components/grid-download-menu-styles.d.ts +1 -1
- package/dist/components/grid-download-menu-styles.js +2 -2
- package/dist/components/grid-row-filter-styles.d.ts +1 -1
- package/dist/components/grid-row-filter-styles.js +3 -3
- package/dist/components/grid-row-filter-styles.js.map +1 -1
- package/dist/components/ix-grid-no-rows.d.ts +1 -1
- package/dist/components/ix-grid-no-rows.js +2 -2
- package/dist/components/pagination-styles.d.ts +1 -1
- package/dist/components/pagination-styles.js +2 -2
- package/dist/grid-view-styles.d.ts +1 -1
- package/dist/grid-view-styles.js +3 -3
- package/dist/grid-view-styles.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/ix-grid-copy.d.ts +10 -10
- package/dist/ix-grid-copy.js +10 -10
- package/dist/ix-grid-nav.d.ts +1 -1
- package/dist/ix-grid-nav.js +2 -2
- package/dist/ix-grid-no-rows.d.ts +1 -1
- package/dist/ix-grid-no-rows.js +2 -2
- package/dist/ix-grid.d.ts +1 -1
- package/dist/ix-grid.js +2 -2
- package/dist/ix-grid.min.js +4 -4
- package/dist/models/IxGridDownloadMenuItemModel.d.ts +7 -7
- package/dist/models/IxGridDownloadMenuItemModel.js +1 -1
- package/dist/test/ix-grid-column-filter.test.d.ts +1 -1
- package/dist/test/ix-grid-column-filter.test.js +35 -35
- package/dist/test/ix-grid-row-filter.test.d.ts +1 -1
- package/dist/test/ix-grid-row-filter.test.js +36 -36
- package/dist/test/ix-grid.test.d.ts +2 -2
- package/dist/test/ix-grid.test.js +49 -49
- package/dist/test/ix-pagination.test.d.ts +1 -1
- package/dist/test/ix-pagination.test.js +21 -21
- package/package.json +4 -3
- package/src/{react/IxGridNav.ts → IxGridNav.ts} +1 -1
- package/src/components/IxGridColumnFilter.ts +6 -2
- package/src/components/IxGridNoRows.ts +22 -11
- package/src/components/grid-column-filter-styles.ts +30 -29
- package/src/components/grid-row-filter-styles.ts +1 -1
- package/src/components/ix-grid-no-rows.ts +3 -0
- package/src/grid-view-styles.ts +1 -1
- package/dist/components/ix-grid-nav.d.ts +0 -1
- package/dist/components/ix-grid-nav.js +0 -3
- package/dist/components/ix-grid-nav.js.map +0 -1
- package/dist/react/IxGridNav.js.map +0 -1
package/dist/IxGrid.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { html, LitElement, nothing } from 'lit';
|
|
3
|
-
import { property, state, query } from 'lit/decorators.js';
|
|
4
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
|
-
import '@vaadin/grid';
|
|
6
|
-
import { columnBodyRenderer, columnHeaderRenderer } from '@vaadin/grid/lit.js';
|
|
7
|
-
import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
8
|
-
import '@digital-realty/ix-icon/ix-icon.js';
|
|
9
|
-
import './components/IxGridDownloadMenu.js';
|
|
10
|
-
import './components/IxPagination.js';
|
|
11
|
-
import './components/IxGridColumnFilter.js';
|
|
12
|
-
import './components/IxGridRowFilter.js';
|
|
13
|
-
import { IxGridViewStyles } from './grid-view-styles.js';
|
|
14
|
-
import { copy } from './ix-grid-copy.js';
|
|
15
|
-
export class IxGrid extends LitElement {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(...arguments);
|
|
18
|
-
this.variantClass = '';
|
|
19
|
-
this.columns = [];
|
|
20
|
-
this.rows = [];
|
|
21
|
-
this.defaultEmptyText = 'No data to display';
|
|
22
|
-
this.sortedColumn = '';
|
|
23
|
-
this.sortDirection = '';
|
|
24
|
-
this.hideHeader = false;
|
|
25
|
-
this.hideFilters = false;
|
|
26
|
-
this.rowLimit = 0;
|
|
27
|
-
this.page = 1;
|
|
28
|
-
this.pageSize = 10;
|
|
29
|
-
this.pageSizes = [5, 10, 25, 100];
|
|
30
|
-
this.recordCount = 0;
|
|
31
|
-
this.localStorageID = undefined;
|
|
32
|
-
this.showDownload = true;
|
|
33
|
-
this.downloadMenuItems = [];
|
|
34
|
-
this.addParamsToURL = true;
|
|
35
|
-
this.filters = [];
|
|
36
|
-
this.isLoading = false;
|
|
37
|
-
this.isExpanded = false;
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, LitElement, nothing } from 'lit';
|
|
3
|
+
import { property, state, query } from 'lit/decorators.js';
|
|
4
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
|
+
import '@vaadin/grid';
|
|
6
|
+
import { columnBodyRenderer, columnHeaderRenderer } from '@vaadin/grid/lit.js';
|
|
7
|
+
import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
8
|
+
import '@digital-realty/ix-icon/ix-icon.js';
|
|
9
|
+
import './components/IxGridDownloadMenu.js';
|
|
10
|
+
import './components/IxPagination.js';
|
|
11
|
+
import './components/IxGridColumnFilter.js';
|
|
12
|
+
import './components/IxGridRowFilter.js';
|
|
13
|
+
import { IxGridViewStyles } from './grid-view-styles.js';
|
|
14
|
+
import { copy } from './ix-grid-copy.js';
|
|
15
|
+
export class IxGrid extends LitElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.variantClass = '';
|
|
19
|
+
this.columns = [];
|
|
20
|
+
this.rows = [];
|
|
21
|
+
this.defaultEmptyText = 'No data to display';
|
|
22
|
+
this.sortedColumn = '';
|
|
23
|
+
this.sortDirection = '';
|
|
24
|
+
this.hideHeader = false;
|
|
25
|
+
this.hideFilters = false;
|
|
26
|
+
this.rowLimit = 0;
|
|
27
|
+
this.page = 1;
|
|
28
|
+
this.pageSize = 10;
|
|
29
|
+
this.pageSizes = [5, 10, 25, 100];
|
|
30
|
+
this.recordCount = 0;
|
|
31
|
+
this.localStorageID = undefined;
|
|
32
|
+
this.showDownload = true;
|
|
33
|
+
this.downloadMenuItems = [];
|
|
34
|
+
this.addParamsToURL = true;
|
|
35
|
+
this.filters = [];
|
|
36
|
+
this.isLoading = false;
|
|
37
|
+
this.isExpanded = false;
|
|
38
38
|
this.renderColumnHeader = (column) => html `
|
|
39
39
|
<div
|
|
40
40
|
@click=${() => column.sortable && this.handleSort(column.name)}
|
|
@@ -42,21 +42,21 @@ export class IxGrid extends LitElement {
|
|
|
42
42
|
class="header"
|
|
43
43
|
>
|
|
44
44
|
${column.header}
|
|
45
|
-
${column.sortable
|
|
45
|
+
${column.sortable
|
|
46
46
|
? html `<ix-icon title="Sort" class="header-sort-icon"
|
|
47
|
-
>${this.sortDirection === 'desc' &&
|
|
48
|
-
this.sortedColumn === column.name
|
|
49
|
-
? `arrow_upward`
|
|
47
|
+
>${this.sortDirection === 'desc' &&
|
|
48
|
+
this.sortedColumn === column.name
|
|
49
|
+
? `arrow_upward`
|
|
50
50
|
: `arrow_downward`}</ix-icon
|
|
51
|
-
>`
|
|
51
|
+
>`
|
|
52
52
|
: nothing}
|
|
53
53
|
</div>
|
|
54
|
-
`;
|
|
54
|
+
`;
|
|
55
55
|
this.renderHeader = () => html `
|
|
56
56
|
<div class="grid-header">
|
|
57
57
|
<slot name="header"><div class="empty"></div></slot>
|
|
58
|
-
${this.hideFilters
|
|
59
|
-
? nothing
|
|
58
|
+
${this.hideFilters
|
|
59
|
+
? nothing
|
|
60
60
|
: html `<div class="grid-menu">
|
|
61
61
|
<ix-grid-column-filter
|
|
62
62
|
.columns=${this.arrangedColumns}
|
|
@@ -64,16 +64,16 @@ export class IxGrid extends LitElement {
|
|
|
64
64
|
@columnFilter=${(e) => this.handleOnColumnFilter(e)}
|
|
65
65
|
@reorderColumns=${this.reorderColumnsFromFilter}
|
|
66
66
|
></ix-grid-column-filter>
|
|
67
|
-
${this.showDownload
|
|
67
|
+
${this.showDownload
|
|
68
68
|
? html `<ix-grid-download-menu
|
|
69
69
|
.items=${this.downloadMenuItems}
|
|
70
|
-
></ix-grid-download-menu>`
|
|
70
|
+
></ix-grid-download-menu>`
|
|
71
71
|
: nothing}
|
|
72
72
|
<ix-grid-row-filter
|
|
73
73
|
.columns=${this.columns}
|
|
74
|
-
@rowFilter=${(e) => {
|
|
75
|
-
this.filters = e.detail.filters;
|
|
76
|
-
this.updatePage();
|
|
74
|
+
@rowFilter=${(e) => {
|
|
75
|
+
this.filters = e.detail.filters;
|
|
76
|
+
this.updatePage();
|
|
77
77
|
}}
|
|
78
78
|
></ix-grid-row-filter>
|
|
79
79
|
</div>`}
|
|
@@ -81,16 +81,16 @@ export class IxGrid extends LitElement {
|
|
|
81
81
|
<div class="touch-edge">
|
|
82
82
|
<slot name="under-header"></slot>
|
|
83
83
|
</div>
|
|
84
|
-
`;
|
|
85
|
-
this.renderRowLimitControls = () => {
|
|
86
|
-
if (this.rows.length <= this.rowLimit)
|
|
87
|
-
return nothing;
|
|
84
|
+
`;
|
|
85
|
+
this.renderRowLimitControls = () => {
|
|
86
|
+
if (this.rows.length <= this.rowLimit)
|
|
87
|
+
return nothing;
|
|
88
88
|
return html `
|
|
89
89
|
<div class="row-limit">
|
|
90
90
|
<ix-button
|
|
91
91
|
appearance="text"
|
|
92
|
-
@click=${() => {
|
|
93
|
-
this.isExpanded = !this.isExpanded;
|
|
92
|
+
@click=${() => {
|
|
93
|
+
this.isExpanded = !this.isExpanded;
|
|
94
94
|
}}
|
|
95
95
|
has-icon
|
|
96
96
|
>
|
|
@@ -98,157 +98,157 @@ export class IxGrid extends LitElement {
|
|
|
98
98
|
<ix-icon slot="icon">${this.isExpanded ? 'remove' : 'add'}</ix-icon>
|
|
99
99
|
</ix-button>
|
|
100
100
|
</div>
|
|
101
|
-
`;
|
|
102
|
-
};
|
|
101
|
+
`;
|
|
102
|
+
};
|
|
103
103
|
this.renderPaginationControls = () => html `
|
|
104
104
|
<ix-pagination
|
|
105
105
|
.page=${this.page}
|
|
106
106
|
.pageSize=${this.pageSize}
|
|
107
107
|
.pageSizes=${this.pageSizes}
|
|
108
108
|
.recordCount=${this.recordCount}
|
|
109
|
-
@updatePagination=${(e) => {
|
|
110
|
-
this.page = e.detail.page;
|
|
111
|
-
this.pageSize = e.detail.pageSize;
|
|
112
|
-
this.updatePage();
|
|
109
|
+
@updatePagination=${(e) => {
|
|
110
|
+
this.page = e.detail.page;
|
|
111
|
+
this.pageSize = e.detail.pageSize;
|
|
112
|
+
this.updatePage();
|
|
113
113
|
}}
|
|
114
114
|
></ix-pagination>
|
|
115
|
-
`;
|
|
116
|
-
}
|
|
117
|
-
get isPersistable() {
|
|
118
|
-
if (this.localStorageID)
|
|
119
|
-
return true;
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
get columnNames() {
|
|
123
|
-
return this.columns.map((column) => column.name);
|
|
124
|
-
}
|
|
125
|
-
get columnsLocalStorageKey() {
|
|
126
|
-
return `ix-grid-${this.localStorageID}-columns`;
|
|
127
|
-
}
|
|
128
|
-
get arrangedColumns() {
|
|
129
|
-
let colums = [];
|
|
130
|
-
if (this.isPersistable) {
|
|
131
|
-
const preservedColumns = JSON.parse(localStorage.getItem(this.columnsLocalStorageKey) || '[]');
|
|
132
|
-
if (preservedColumns.length > 0)
|
|
133
|
-
colums = preservedColumns.map((c) => {
|
|
134
|
-
const column = this.columns.find((col) => col.name === c.name);
|
|
135
|
-
return {
|
|
136
|
-
...column,
|
|
137
|
-
hidden: c.hidden,
|
|
138
|
-
frozenToEnd: c.frozenToEnd,
|
|
139
|
-
width: !c.width ? undefined : c.width,
|
|
140
|
-
};
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
if (colums.length === 0)
|
|
144
|
-
colums = [...this.columns];
|
|
145
|
-
return colums
|
|
146
|
-
.filter(col => col)
|
|
147
|
-
.map((column) => ({
|
|
148
|
-
...column,
|
|
149
|
-
width: !column.width ? undefined : column.width,
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
152
|
-
async updatePage() {
|
|
153
|
-
const filters = this.filters.reduce((columnFilters, { columnField, value }) => ({
|
|
154
|
-
...columnFilters,
|
|
155
|
-
[columnField]: value,
|
|
156
|
-
}), {});
|
|
157
|
-
if (this.addParamsToURL) {
|
|
158
|
-
const urlParams = {
|
|
159
|
-
sort: this.sortedColumn,
|
|
160
|
-
order: this.sortDirection,
|
|
161
|
-
page: this.page.toString(),
|
|
162
|
-
size: this.pageSize.toString(),
|
|
163
|
-
...filters,
|
|
164
|
-
};
|
|
165
|
-
const url = new URL(window.location.href);
|
|
166
|
-
const searchParams = new URLSearchParams(urlParams);
|
|
167
|
-
url.search = searchParams.toString();
|
|
168
|
-
window.history.replaceState(null, '', url.toString());
|
|
169
|
-
}
|
|
170
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
171
|
-
detail: {
|
|
172
|
-
columnName: this.sortedColumn,
|
|
173
|
-
sortOrder: this.sortDirection,
|
|
174
|
-
page: this.page,
|
|
175
|
-
pageSize: this.pageSize,
|
|
176
|
-
filters,
|
|
177
|
-
filtersOperators: this.filters.map((f) => ({
|
|
178
|
-
columnField: f.columnField,
|
|
179
|
-
operator: f.operatorValue,
|
|
180
|
-
})),
|
|
181
|
-
},
|
|
182
|
-
bubbles: true,
|
|
183
|
-
composed: true,
|
|
184
|
-
}));
|
|
185
|
-
}
|
|
186
|
-
handleSort(column = '') {
|
|
187
|
-
if (this.sortedColumn !== column) {
|
|
188
|
-
this.sortDirection = 'asc';
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
|
192
|
-
}
|
|
193
|
-
this.sortedColumn = column;
|
|
194
|
-
this.updatePage();
|
|
195
|
-
}
|
|
196
|
-
setColumnsToLocalStorage(columns) {
|
|
197
|
-
if (this.isPersistable) {
|
|
198
|
-
localStorage.setItem(this.columnsLocalStorageKey, JSON.stringify(columns));
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
async reorderColumnsFromTable() {
|
|
202
|
-
var _a, _b;
|
|
203
|
-
const visibleColumns = this.arrangedColumns.filter((column) => column.hidden !== true);
|
|
204
|
-
const hiddenColumns = this.arrangedColumns.filter((column) => column.hidden === true);
|
|
205
|
-
const frozenColumns = this.arrangedColumns.filter((column) => column.frozenToEnd === true);
|
|
206
|
-
const allColumns = [
|
|
207
|
-
...visibleColumns.filter(column => (column === null || column === void 0 ? void 0 : column.frozenToEnd) !== true),
|
|
208
|
-
...hiddenColumns.filter(column => (column === null || column === void 0 ? void 0 : column.frozenToEnd) !== true),
|
|
209
|
-
...frozenColumns,
|
|
210
|
-
];
|
|
211
|
-
// calulate column order from table header flex order
|
|
212
|
-
const headerNodes = Array.from(((_b = (_a = this.grid) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('th')) || []);
|
|
213
|
-
if (headerNodes.length) {
|
|
214
|
-
const columnOrder = headerNodes
|
|
215
|
-
.map((el, id) => ({ id, flexPosition: Number(el.style.order) }))
|
|
216
|
-
.sort((a, b) => a.flexPosition - b.flexPosition)
|
|
217
|
-
.map(el => el.id);
|
|
218
|
-
const columnsCorrectlyOrdered = columnOrder.every((x, i) => i === 0 || x > columnOrder[i - 1]);
|
|
219
|
-
let reorderedColumns = [];
|
|
220
|
-
if (!columnsCorrectlyOrdered) {
|
|
221
|
-
reorderedColumns = columnOrder.map(id => allColumns[id]);
|
|
222
|
-
this.columns = [
|
|
223
|
-
...reorderedColumns.filter(column => column.hidden !== true && (column === null || column === void 0 ? void 0 : column.frozenToEnd) !== true),
|
|
224
|
-
...hiddenColumns.filter(column => (column === null || column === void 0 ? void 0 : column.frozenToEnd) !== true),
|
|
225
|
-
...frozenColumns,
|
|
226
|
-
];
|
|
227
|
-
this.isLoading = true;
|
|
228
|
-
await this.updateComplete;
|
|
229
|
-
this.isLoading = false;
|
|
230
|
-
}
|
|
231
|
-
this.setColumnsToLocalStorage(reorderedColumns.length > 0 ? [...this.columns] : [...allColumns]);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
async reorderColumnsFromFilter(e) {
|
|
235
|
-
this.columns = [...e.detail.reorderedColumns];
|
|
236
|
-
this.setColumnsToLocalStorage([...this.columns]);
|
|
237
|
-
this.isLoading = true;
|
|
238
|
-
await this.updateComplete;
|
|
239
|
-
this.isLoading = false;
|
|
240
|
-
}
|
|
241
|
-
handleOnColumnFilter(e) {
|
|
242
|
-
e.detail.columns.forEach((column, id) => {
|
|
243
|
-
this.columns[id].hidden = column === null || column === void 0 ? void 0 : column.hidden;
|
|
244
|
-
});
|
|
245
|
-
this.updatePage();
|
|
246
|
-
}
|
|
247
|
-
renderColumns() {
|
|
248
|
-
if (this.arrangedColumns.length > 0) {
|
|
249
|
-
return html `${this.arrangedColumns.map((column) => {
|
|
250
|
-
if (column.hidden === true)
|
|
251
|
-
return nothing;
|
|
115
|
+
`;
|
|
116
|
+
}
|
|
117
|
+
get isPersistable() {
|
|
118
|
+
if (this.localStorageID)
|
|
119
|
+
return true;
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
get columnNames() {
|
|
123
|
+
return this.columns.map((column) => column.name);
|
|
124
|
+
}
|
|
125
|
+
get columnsLocalStorageKey() {
|
|
126
|
+
return `ix-grid-${this.localStorageID}-columns`;
|
|
127
|
+
}
|
|
128
|
+
get arrangedColumns() {
|
|
129
|
+
let colums = [];
|
|
130
|
+
if (this.isPersistable) {
|
|
131
|
+
const preservedColumns = JSON.parse(localStorage.getItem(this.columnsLocalStorageKey) || '[]');
|
|
132
|
+
if (preservedColumns.length > 0)
|
|
133
|
+
colums = preservedColumns.map((c) => {
|
|
134
|
+
const column = this.columns.find((col) => col.name === c.name);
|
|
135
|
+
return {
|
|
136
|
+
...column,
|
|
137
|
+
hidden: c.hidden,
|
|
138
|
+
frozenToEnd: c.frozenToEnd,
|
|
139
|
+
width: !c.width ? undefined : c.width,
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
if (colums.length === 0)
|
|
144
|
+
colums = [...this.columns];
|
|
145
|
+
return colums
|
|
146
|
+
.filter(col => col)
|
|
147
|
+
.map((column) => ({
|
|
148
|
+
...column,
|
|
149
|
+
width: !column.width ? undefined : column.width,
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
async updatePage() {
|
|
153
|
+
const filters = this.filters.reduce((columnFilters, { columnField, value }) => ({
|
|
154
|
+
...columnFilters,
|
|
155
|
+
[columnField]: value,
|
|
156
|
+
}), {});
|
|
157
|
+
if (this.addParamsToURL) {
|
|
158
|
+
const urlParams = {
|
|
159
|
+
sort: this.sortedColumn,
|
|
160
|
+
order: this.sortDirection,
|
|
161
|
+
page: this.page.toString(),
|
|
162
|
+
size: this.pageSize.toString(),
|
|
163
|
+
...filters,
|
|
164
|
+
};
|
|
165
|
+
const url = new URL(window.location.href);
|
|
166
|
+
const searchParams = new URLSearchParams(urlParams);
|
|
167
|
+
url.search = searchParams.toString();
|
|
168
|
+
window.history.replaceState(null, '', url.toString());
|
|
169
|
+
}
|
|
170
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
171
|
+
detail: {
|
|
172
|
+
columnName: this.sortedColumn,
|
|
173
|
+
sortOrder: this.sortDirection,
|
|
174
|
+
page: this.page,
|
|
175
|
+
pageSize: this.pageSize,
|
|
176
|
+
filters,
|
|
177
|
+
filtersOperators: this.filters.map((f) => ({
|
|
178
|
+
columnField: f.columnField,
|
|
179
|
+
operator: f.operatorValue,
|
|
180
|
+
})),
|
|
181
|
+
},
|
|
182
|
+
bubbles: true,
|
|
183
|
+
composed: true,
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
handleSort(column = '') {
|
|
187
|
+
if (this.sortedColumn !== column) {
|
|
188
|
+
this.sortDirection = 'asc';
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
|
192
|
+
}
|
|
193
|
+
this.sortedColumn = column;
|
|
194
|
+
this.updatePage();
|
|
195
|
+
}
|
|
196
|
+
setColumnsToLocalStorage(columns) {
|
|
197
|
+
if (this.isPersistable) {
|
|
198
|
+
localStorage.setItem(this.columnsLocalStorageKey, JSON.stringify(columns));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async reorderColumnsFromTable() {
|
|
202
|
+
var _a, _b;
|
|
203
|
+
const visibleColumns = this.arrangedColumns.filter((column) => column.hidden !== true);
|
|
204
|
+
const hiddenColumns = this.arrangedColumns.filter((column) => column.hidden === true);
|
|
205
|
+
const frozenColumns = this.arrangedColumns.filter((column) => column.frozenToEnd === true);
|
|
206
|
+
const allColumns = [
|
|
207
|
+
...visibleColumns.filter(column => (column === null || column === void 0 ? void 0 : column.frozenToEnd) !== true),
|
|
208
|
+
...hiddenColumns.filter(column => (column === null || column === void 0 ? void 0 : column.frozenToEnd) !== true),
|
|
209
|
+
...frozenColumns,
|
|
210
|
+
];
|
|
211
|
+
// calulate column order from table header flex order
|
|
212
|
+
const headerNodes = Array.from(((_b = (_a = this.grid) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('th')) || []);
|
|
213
|
+
if (headerNodes.length) {
|
|
214
|
+
const columnOrder = headerNodes
|
|
215
|
+
.map((el, id) => ({ id, flexPosition: Number(el.style.order) }))
|
|
216
|
+
.sort((a, b) => a.flexPosition - b.flexPosition)
|
|
217
|
+
.map(el => el.id);
|
|
218
|
+
const columnsCorrectlyOrdered = columnOrder.every((x, i) => i === 0 || x > columnOrder[i - 1]);
|
|
219
|
+
let reorderedColumns = [];
|
|
220
|
+
if (!columnsCorrectlyOrdered) {
|
|
221
|
+
reorderedColumns = columnOrder.map(id => allColumns[id]);
|
|
222
|
+
this.columns = [
|
|
223
|
+
...reorderedColumns.filter(column => column.hidden !== true && (column === null || column === void 0 ? void 0 : column.frozenToEnd) !== true),
|
|
224
|
+
...hiddenColumns.filter(column => (column === null || column === void 0 ? void 0 : column.frozenToEnd) !== true),
|
|
225
|
+
...frozenColumns,
|
|
226
|
+
];
|
|
227
|
+
this.isLoading = true;
|
|
228
|
+
await this.updateComplete;
|
|
229
|
+
this.isLoading = false;
|
|
230
|
+
}
|
|
231
|
+
this.setColumnsToLocalStorage(reorderedColumns.length > 0 ? [...this.columns] : [...allColumns]);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
async reorderColumnsFromFilter(e) {
|
|
235
|
+
this.columns = [...e.detail.reorderedColumns];
|
|
236
|
+
this.setColumnsToLocalStorage([...this.columns]);
|
|
237
|
+
this.isLoading = true;
|
|
238
|
+
await this.updateComplete;
|
|
239
|
+
this.isLoading = false;
|
|
240
|
+
}
|
|
241
|
+
handleOnColumnFilter(e) {
|
|
242
|
+
e.detail.columns.forEach((column, id) => {
|
|
243
|
+
this.columns[id].hidden = column === null || column === void 0 ? void 0 : column.hidden;
|
|
244
|
+
});
|
|
245
|
+
this.updatePage();
|
|
246
|
+
}
|
|
247
|
+
renderColumns() {
|
|
248
|
+
if (this.arrangedColumns.length > 0) {
|
|
249
|
+
return html `${this.arrangedColumns.map((column) => {
|
|
250
|
+
if (column.hidden === true)
|
|
251
|
+
return nothing;
|
|
252
252
|
return html `<vaadin-grid-column
|
|
253
253
|
${columnHeaderRenderer(() => this.renderColumnHeader(column), this.sortDirection)}
|
|
254
254
|
${columnBodyRenderer(column.bodyRenderer, [])}
|
|
@@ -257,21 +257,21 @@ export class IxGrid extends LitElement {
|
|
|
257
257
|
?hidden=${column.hidden}
|
|
258
258
|
?frozen-to-end=${column.frozenToEnd}
|
|
259
259
|
path=${column.name}
|
|
260
|
-
></vaadin-grid-column>`;
|
|
261
|
-
})}`;
|
|
262
|
-
}
|
|
263
|
-
return html `<vaadin-grid-column></vaadin-grid-column>`;
|
|
264
|
-
}
|
|
265
|
-
render() {
|
|
260
|
+
></vaadin-grid-column>`;
|
|
261
|
+
})}`;
|
|
262
|
+
}
|
|
263
|
+
return html `<vaadin-grid-column></vaadin-grid-column>`;
|
|
264
|
+
}
|
|
265
|
+
render() {
|
|
266
266
|
return html `
|
|
267
267
|
<div
|
|
268
268
|
class=${`grid-container ${this.isLoading ? 'loading' : ''} ${this.variantClass}`}
|
|
269
269
|
>
|
|
270
270
|
${this.hideHeader ? nothing : this.renderHeader()}
|
|
271
|
-
${!this.isLoading
|
|
271
|
+
${!this.isLoading
|
|
272
272
|
? html `<vaadin-grid
|
|
273
|
-
.items=${this.rowLimit > 0 && !this.isExpanded
|
|
274
|
-
? this.rows.slice(0, this.rowLimit)
|
|
273
|
+
.items=${this.rowLimit > 0 && !this.isExpanded
|
|
274
|
+
? this.rows.slice(0, this.rowLimit)
|
|
275
275
|
: this.rows}
|
|
276
276
|
all-rows-visible
|
|
277
277
|
column-reordering-allowed
|
|
@@ -280,81 +280,81 @@ export class IxGrid extends LitElement {
|
|
|
280
280
|
>
|
|
281
281
|
${this.renderColumns()}
|
|
282
282
|
</vaadin-grid>
|
|
283
|
-
${this.rows.length === 0 && !this.isLoading
|
|
284
|
-
? html `<slot name="no-rows"></slot>`
|
|
285
|
-
: nothing}`
|
|
283
|
+
${this.rows.length === 0 && !this.isLoading
|
|
284
|
+
? html `<slot name="no-rows"></slot>`
|
|
285
|
+
: nothing}`
|
|
286
286
|
: nothing}
|
|
287
|
-
${this.rowLimit > 0
|
|
288
|
-
? this.renderRowLimitControls()
|
|
287
|
+
${this.rowLimit > 0
|
|
288
|
+
? this.renderRowLimitControls()
|
|
289
289
|
: this.renderPaginationControls()}
|
|
290
290
|
|
|
291
291
|
<slot name="footer"></slot>
|
|
292
292
|
</div>
|
|
293
|
-
`;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
IxGrid.styles = [IxGridViewStyles];
|
|
297
|
-
__decorate([
|
|
298
|
-
query('vaadin-grid')
|
|
299
|
-
], IxGrid.prototype, "grid", void 0);
|
|
300
|
-
__decorate([
|
|
301
|
-
property({ type: String })
|
|
302
|
-
], IxGrid.prototype, "variantClass", void 0);
|
|
303
|
-
__decorate([
|
|
304
|
-
property({ type: Array })
|
|
305
|
-
], IxGrid.prototype, "columns", void 0);
|
|
306
|
-
__decorate([
|
|
307
|
-
property({ type: Array })
|
|
308
|
-
], IxGrid.prototype, "rows", void 0);
|
|
309
|
-
__decorate([
|
|
310
|
-
property({ type: String })
|
|
311
|
-
], IxGrid.prototype, "defaultEmptyText", void 0);
|
|
312
|
-
__decorate([
|
|
313
|
-
property({ type: String })
|
|
314
|
-
], IxGrid.prototype, "sortedColumn", void 0);
|
|
315
|
-
__decorate([
|
|
316
|
-
property({ type: String })
|
|
317
|
-
], IxGrid.prototype, "sortDirection", void 0);
|
|
318
|
-
__decorate([
|
|
319
|
-
property({ type: Boolean })
|
|
320
|
-
], IxGrid.prototype, "hideHeader", void 0);
|
|
321
|
-
__decorate([
|
|
322
|
-
property({ type: Boolean, attribute: 'hide-filters' })
|
|
323
|
-
], IxGrid.prototype, "hideFilters", void 0);
|
|
324
|
-
__decorate([
|
|
325
|
-
property({ type: Number })
|
|
326
|
-
], IxGrid.prototype, "rowLimit", void 0);
|
|
327
|
-
__decorate([
|
|
328
|
-
property({ type: Number })
|
|
329
|
-
], IxGrid.prototype, "page", void 0);
|
|
330
|
-
__decorate([
|
|
331
|
-
property({ type: Number })
|
|
332
|
-
], IxGrid.prototype, "pageSize", void 0);
|
|
333
|
-
__decorate([
|
|
334
|
-
property({ type: Array })
|
|
335
|
-
], IxGrid.prototype, "pageSizes", void 0);
|
|
336
|
-
__decorate([
|
|
337
|
-
property({ type: Number })
|
|
338
|
-
], IxGrid.prototype, "recordCount", void 0);
|
|
339
|
-
__decorate([
|
|
340
|
-
property({ type: String })
|
|
341
|
-
], IxGrid.prototype, "localStorageID", void 0);
|
|
342
|
-
__decorate([
|
|
343
|
-
property({ type: Boolean })
|
|
344
|
-
], IxGrid.prototype, "showDownload", void 0);
|
|
345
|
-
__decorate([
|
|
346
|
-
property({ type: Array })
|
|
347
|
-
], IxGrid.prototype, "downloadMenuItems", void 0);
|
|
348
|
-
__decorate([
|
|
349
|
-
property({ type: Boolean, attribute: 'add-params-to-url' })
|
|
350
|
-
], IxGrid.prototype, "addParamsToURL", void 0);
|
|
351
|
-
__decorate([
|
|
352
|
-
state()
|
|
353
|
-
], IxGrid.prototype, "filters", void 0);
|
|
354
|
-
__decorate([
|
|
355
|
-
state()
|
|
356
|
-
], IxGrid.prototype, "isLoading", void 0);
|
|
357
|
-
__decorate([
|
|
358
|
-
state()
|
|
359
|
-
], IxGrid.prototype, "isExpanded", void 0);
|
|
293
|
+
`;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
IxGrid.styles = [IxGridViewStyles];
|
|
297
|
+
__decorate([
|
|
298
|
+
query('vaadin-grid')
|
|
299
|
+
], IxGrid.prototype, "grid", void 0);
|
|
300
|
+
__decorate([
|
|
301
|
+
property({ type: String })
|
|
302
|
+
], IxGrid.prototype, "variantClass", void 0);
|
|
303
|
+
__decorate([
|
|
304
|
+
property({ type: Array })
|
|
305
|
+
], IxGrid.prototype, "columns", void 0);
|
|
306
|
+
__decorate([
|
|
307
|
+
property({ type: Array })
|
|
308
|
+
], IxGrid.prototype, "rows", void 0);
|
|
309
|
+
__decorate([
|
|
310
|
+
property({ type: String })
|
|
311
|
+
], IxGrid.prototype, "defaultEmptyText", void 0);
|
|
312
|
+
__decorate([
|
|
313
|
+
property({ type: String })
|
|
314
|
+
], IxGrid.prototype, "sortedColumn", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
property({ type: String })
|
|
317
|
+
], IxGrid.prototype, "sortDirection", void 0);
|
|
318
|
+
__decorate([
|
|
319
|
+
property({ type: Boolean })
|
|
320
|
+
], IxGrid.prototype, "hideHeader", void 0);
|
|
321
|
+
__decorate([
|
|
322
|
+
property({ type: Boolean, attribute: 'hide-filters' })
|
|
323
|
+
], IxGrid.prototype, "hideFilters", void 0);
|
|
324
|
+
__decorate([
|
|
325
|
+
property({ type: Number })
|
|
326
|
+
], IxGrid.prototype, "rowLimit", void 0);
|
|
327
|
+
__decorate([
|
|
328
|
+
property({ type: Number })
|
|
329
|
+
], IxGrid.prototype, "page", void 0);
|
|
330
|
+
__decorate([
|
|
331
|
+
property({ type: Number })
|
|
332
|
+
], IxGrid.prototype, "pageSize", void 0);
|
|
333
|
+
__decorate([
|
|
334
|
+
property({ type: Array })
|
|
335
|
+
], IxGrid.prototype, "pageSizes", void 0);
|
|
336
|
+
__decorate([
|
|
337
|
+
property({ type: Number })
|
|
338
|
+
], IxGrid.prototype, "recordCount", void 0);
|
|
339
|
+
__decorate([
|
|
340
|
+
property({ type: String })
|
|
341
|
+
], IxGrid.prototype, "localStorageID", void 0);
|
|
342
|
+
__decorate([
|
|
343
|
+
property({ type: Boolean })
|
|
344
|
+
], IxGrid.prototype, "showDownload", void 0);
|
|
345
|
+
__decorate([
|
|
346
|
+
property({ type: Array })
|
|
347
|
+
], IxGrid.prototype, "downloadMenuItems", void 0);
|
|
348
|
+
__decorate([
|
|
349
|
+
property({ type: Boolean, attribute: 'add-params-to-url' })
|
|
350
|
+
], IxGrid.prototype, "addParamsToURL", void 0);
|
|
351
|
+
__decorate([
|
|
352
|
+
state()
|
|
353
|
+
], IxGrid.prototype, "filters", void 0);
|
|
354
|
+
__decorate([
|
|
355
|
+
state()
|
|
356
|
+
], IxGrid.prototype, "isLoading", void 0);
|
|
357
|
+
__decorate([
|
|
358
|
+
state()
|
|
359
|
+
], IxGrid.prototype, "isExpanded", void 0);
|
|
360
360
|
//# sourceMappingURL=IxGrid.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IxGridNavigation } from '
|
|
2
|
-
export declare const IxGridNav: import("@lit/react").ReactWebComponent<IxGridNavigation, {}>;
|
|
1
|
+
import { IxGridNavigation } from './components/IxGridNav.js';
|
|
2
|
+
export declare const IxGridNav: import("@lit/react").ReactWebComponent<IxGridNavigation, {}>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { createComponent } from '@lit/react';
|
|
3
|
-
import { IxGridNavigation } from '
|
|
4
|
-
export const IxGridNav = createComponent({
|
|
5
|
-
tagName: 'ix-grid-nav',
|
|
6
|
-
elementClass: IxGridNavigation,
|
|
7
|
-
react: React,
|
|
8
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import { IxGridNavigation } from './components/IxGridNav.js';
|
|
4
|
+
export const IxGridNav = createComponent({
|
|
5
|
+
tagName: 'ix-grid-nav',
|
|
6
|
+
elementClass: IxGridNavigation,
|
|
7
|
+
react: React,
|
|
8
|
+
});
|
|
9
9
|
//# sourceMappingURL=IxGridNav.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IxGridNav.js","sourceRoot":"","sources":["../src/IxGridNav.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAC;IACvC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,gBAAgB;IAC9B,KAAK,EAAE,KAAK;CACb,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { createComponent } from '@lit/react';\nimport { IxGridNavigation } from './components/IxGridNav.js';\n\nexport const IxGridNav = createComponent({\n tagName: 'ix-grid-nav',\n elementClass: IxGridNavigation,\n react: React,\n});\n"]}
|