@digital-realty/ix-grid 1.0.37 → 2.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.
- package/dist/IxGrid.d.ts +55 -55
- package/dist/IxGrid.js +219 -219
- package/dist/components/IxGridColumnFilter.d.ts +28 -28
- package/dist/components/IxGridColumnFilter.js +152 -152
- package/dist/components/IxGridDownloadMenu.d.ts +12 -12
- package/dist/components/IxGridDownloadMenu.js +35 -35
- package/dist/components/IxGridNav.d.ts +15 -15
- package/dist/components/IxGridNav.js +20 -20
- package/dist/components/IxGridRowFilter.d.ts +40 -40
- package/dist/components/IxGridRowFilter.js +188 -188
- 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 +2 -2
- 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-nav.d.ts +1 -1
- package/dist/components/ix-grid-nav.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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/ix-grid-copy.d.ts +10 -10
- package/dist/ix-grid-copy.js +10 -10
- package/dist/ix-grid.d.ts +1 -1
- package/dist/ix-grid.js +2 -2
- package/dist/ix-grid.min.js +1 -1
- package/dist/react/IxGridNav.d.ts +2 -2
- package/dist/react/IxGridNav.js +8 -8
- 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 +1 -1
- package/dist/test/ix-grid.test.js +42 -42
- package/dist/test/ix-pagination.test.d.ts +1 -1
- package/dist/test/ix-pagination.test.js +21 -21
- package/package.json +2 -3
- package/src/components/grid-row-filter-styles.ts +1 -1
package/dist/IxGrid.d.ts
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
import '@vaadin/grid';
|
|
3
|
-
import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
4
|
-
import '@digital-realty/ix-icon/ix-icon.js';
|
|
5
|
-
import './components/IxGridDownloadMenu.js';
|
|
6
|
-
import './components/IxPagination.js';
|
|
7
|
-
import './components/IxGridColumnFilter.js';
|
|
8
|
-
import './components/IxGridRowFilter.js';
|
|
9
|
-
export interface Row {
|
|
10
|
-
[key: string]: string;
|
|
11
|
-
}
|
|
12
|
-
export interface Column {
|
|
13
|
-
name: string;
|
|
14
|
-
header: string;
|
|
15
|
-
bodyRenderer: (row: Row) => any;
|
|
16
|
-
width?: string;
|
|
17
|
-
sortable?: boolean;
|
|
18
|
-
filterable?: boolean;
|
|
19
|
-
hidden?: boolean;
|
|
20
|
-
frozenToEnd?: boolean;
|
|
21
|
-
}
|
|
22
|
-
export declare class IxGrid extends LitElement {
|
|
23
|
-
static readonly styles: import("lit").CSSResult[];
|
|
24
|
-
grid: HTMLElement;
|
|
25
|
-
columns: Column[];
|
|
26
|
-
rows: Row[];
|
|
27
|
-
defaultEmptyText: string;
|
|
28
|
-
sortedColumn: string;
|
|
29
|
-
sortDirection: string;
|
|
30
|
-
hideHeader: boolean;
|
|
31
|
-
hideFilters: boolean;
|
|
32
|
-
rowLimit: number;
|
|
33
|
-
page: number;
|
|
34
|
-
pageSize: number;
|
|
35
|
-
pageSizes: number[];
|
|
36
|
-
recordCount: number;
|
|
37
|
-
localStorageID: string | undefined;
|
|
38
|
-
showDownload: boolean;
|
|
39
|
-
addParamsToURL: boolean;
|
|
40
|
-
private filters;
|
|
41
|
-
_columns: Column[];
|
|
42
|
-
isLoading: boolean;
|
|
43
|
-
isExpanded: boolean;
|
|
44
|
-
get columnNames(): string[];
|
|
45
|
-
private updatePage;
|
|
46
|
-
handleSort(column?: string): void;
|
|
47
|
-
private renderColumnHeader;
|
|
48
|
-
connectedCallback(): void;
|
|
49
|
-
reorderColumnsFromTable(): Promise<void>;
|
|
50
|
-
reorderColumnsFromFilter(e: CustomEvent): Promise<void>;
|
|
51
|
-
private renderHeader;
|
|
52
|
-
private renderRowLimitControls;
|
|
53
|
-
private renderPaginationControls;
|
|
54
|
-
render(): import("lit").TemplateResult<1>;
|
|
55
|
-
}
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import '@vaadin/grid';
|
|
3
|
+
import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
4
|
+
import '@digital-realty/ix-icon/ix-icon.js';
|
|
5
|
+
import './components/IxGridDownloadMenu.js';
|
|
6
|
+
import './components/IxPagination.js';
|
|
7
|
+
import './components/IxGridColumnFilter.js';
|
|
8
|
+
import './components/IxGridRowFilter.js';
|
|
9
|
+
export interface Row {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
}
|
|
12
|
+
export interface Column {
|
|
13
|
+
name: string;
|
|
14
|
+
header: string;
|
|
15
|
+
bodyRenderer: (row: Row) => any;
|
|
16
|
+
width?: string;
|
|
17
|
+
sortable?: boolean;
|
|
18
|
+
filterable?: boolean;
|
|
19
|
+
hidden?: boolean;
|
|
20
|
+
frozenToEnd?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare class IxGrid extends LitElement {
|
|
23
|
+
static readonly styles: import("lit").CSSResult[];
|
|
24
|
+
grid: HTMLElement;
|
|
25
|
+
columns: Column[];
|
|
26
|
+
rows: Row[];
|
|
27
|
+
defaultEmptyText: string;
|
|
28
|
+
sortedColumn: string;
|
|
29
|
+
sortDirection: string;
|
|
30
|
+
hideHeader: boolean;
|
|
31
|
+
hideFilters: boolean;
|
|
32
|
+
rowLimit: number;
|
|
33
|
+
page: number;
|
|
34
|
+
pageSize: number;
|
|
35
|
+
pageSizes: number[];
|
|
36
|
+
recordCount: number;
|
|
37
|
+
localStorageID: string | undefined;
|
|
38
|
+
showDownload: boolean;
|
|
39
|
+
addParamsToURL: boolean;
|
|
40
|
+
private filters;
|
|
41
|
+
_columns: Column[];
|
|
42
|
+
isLoading: boolean;
|
|
43
|
+
isExpanded: boolean;
|
|
44
|
+
get columnNames(): string[];
|
|
45
|
+
private updatePage;
|
|
46
|
+
handleSort(column?: string): void;
|
|
47
|
+
private renderColumnHeader;
|
|
48
|
+
connectedCallback(): void;
|
|
49
|
+
reorderColumnsFromTable(): Promise<void>;
|
|
50
|
+
reorderColumnsFromFilter(e: CustomEvent): Promise<void>;
|
|
51
|
+
private renderHeader;
|
|
52
|
+
private renderRowLimitControls;
|
|
53
|
+
private renderPaginationControls;
|
|
54
|
+
render(): import("lit").TemplateResult<1>;
|
|
55
|
+
}
|
package/dist/IxGrid.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
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.columns = [];
|
|
19
|
-
this.rows = [];
|
|
20
|
-
this.defaultEmptyText = 'No data to display';
|
|
21
|
-
this.sortedColumn = '';
|
|
22
|
-
this.sortDirection = '';
|
|
23
|
-
this.hideHeader = false;
|
|
24
|
-
this.hideFilters = false;
|
|
25
|
-
this.rowLimit = 0;
|
|
26
|
-
this.page = 1;
|
|
27
|
-
this.pageSize = 10;
|
|
28
|
-
this.pageSizes = [5, 10, 25, 100];
|
|
29
|
-
this.recordCount = 0;
|
|
30
|
-
this.localStorageID = undefined;
|
|
31
|
-
this.showDownload = true;
|
|
32
|
-
this.addParamsToURL = true;
|
|
33
|
-
this.filters = [];
|
|
34
|
-
this._columns = [];
|
|
35
|
-
this.isLoading = false;
|
|
36
|
-
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.columns = [];
|
|
19
|
+
this.rows = [];
|
|
20
|
+
this.defaultEmptyText = 'No data to display';
|
|
21
|
+
this.sortedColumn = '';
|
|
22
|
+
this.sortDirection = '';
|
|
23
|
+
this.hideHeader = false;
|
|
24
|
+
this.hideFilters = false;
|
|
25
|
+
this.rowLimit = 0;
|
|
26
|
+
this.page = 1;
|
|
27
|
+
this.pageSize = 10;
|
|
28
|
+
this.pageSizes = [5, 10, 25, 100];
|
|
29
|
+
this.recordCount = 0;
|
|
30
|
+
this.localStorageID = undefined;
|
|
31
|
+
this.showDownload = true;
|
|
32
|
+
this.addParamsToURL = true;
|
|
33
|
+
this.filters = [];
|
|
34
|
+
this._columns = [];
|
|
35
|
+
this.isLoading = false;
|
|
36
|
+
this.isExpanded = false;
|
|
37
37
|
this.renderColumnHeader = (column) => html `
|
|
38
38
|
<div
|
|
39
39
|
@click=${() => column.sortable && this.handleSort(column.name)}
|
|
@@ -41,41 +41,41 @@ export class IxGrid extends LitElement {
|
|
|
41
41
|
class="header"
|
|
42
42
|
>
|
|
43
43
|
${column.header}
|
|
44
|
-
${column.sortable
|
|
44
|
+
${column.sortable
|
|
45
45
|
? html `<ix-icon title="Sort" class="header-sort-icon"
|
|
46
|
-
>${this.sortDirection === 'desc' &&
|
|
47
|
-
this.sortedColumn === column.name
|
|
48
|
-
? `arrow_upward`
|
|
46
|
+
>${this.sortDirection === 'desc' &&
|
|
47
|
+
this.sortedColumn === column.name
|
|
48
|
+
? `arrow_upward`
|
|
49
49
|
: `arrow_downward`}</ix-icon
|
|
50
|
-
>`
|
|
50
|
+
>`
|
|
51
51
|
: nothing}
|
|
52
52
|
</div>
|
|
53
|
-
`;
|
|
53
|
+
`;
|
|
54
54
|
this.renderHeader = () => html `
|
|
55
55
|
<div class="grid-header">
|
|
56
56
|
<slot name="header"><div class="empty"></div></slot>
|
|
57
|
-
${this.hideFilters
|
|
58
|
-
? nothing
|
|
57
|
+
${this.hideFilters
|
|
58
|
+
? nothing
|
|
59
59
|
: html `<div class="grid-menu">
|
|
60
60
|
<ix-grid-column-filter
|
|
61
61
|
.columns=${this._columns}
|
|
62
62
|
localStorageID=${ifDefined(this.localStorageID)}
|
|
63
|
-
@columnFilter=${(e) => {
|
|
64
|
-
e.detail.columns.forEach((column, id) => {
|
|
65
|
-
this._columns[id].hidden = column.hidden;
|
|
66
|
-
});
|
|
67
|
-
this.updatePage();
|
|
63
|
+
@columnFilter=${(e) => {
|
|
64
|
+
e.detail.columns.forEach((column, id) => {
|
|
65
|
+
this._columns[id].hidden = column.hidden;
|
|
66
|
+
});
|
|
67
|
+
this.updatePage();
|
|
68
68
|
}}
|
|
69
69
|
@reorderColumns=${this.reorderColumnsFromFilter}
|
|
70
70
|
></ix-grid-column-filter>
|
|
71
|
-
${this.showDownload
|
|
72
|
-
? html `<ix-grid-download-menu></ix-grid-download-menu>`
|
|
71
|
+
${this.showDownload
|
|
72
|
+
? html `<ix-grid-download-menu></ix-grid-download-menu>`
|
|
73
73
|
: nothing}
|
|
74
74
|
<ix-grid-row-filter
|
|
75
75
|
.columns=${this._columns}
|
|
76
|
-
@rowFilter=${(e) => {
|
|
77
|
-
this.filters = e.detail.filters;
|
|
78
|
-
this.updatePage();
|
|
76
|
+
@rowFilter=${(e) => {
|
|
77
|
+
this.filters = e.detail.filters;
|
|
78
|
+
this.updatePage();
|
|
79
79
|
}}
|
|
80
80
|
></ix-grid-row-filter>
|
|
81
81
|
</div>`}
|
|
@@ -83,16 +83,16 @@ export class IxGrid extends LitElement {
|
|
|
83
83
|
<div class="touch-edge">
|
|
84
84
|
<slot name="under-header"></slot>
|
|
85
85
|
</div>
|
|
86
|
-
`;
|
|
87
|
-
this.renderRowLimitControls = () => {
|
|
88
|
-
if (this.rows.length <= this.rowLimit)
|
|
89
|
-
return nothing;
|
|
86
|
+
`;
|
|
87
|
+
this.renderRowLimitControls = () => {
|
|
88
|
+
if (this.rows.length <= this.rowLimit)
|
|
89
|
+
return nothing;
|
|
90
90
|
return html `
|
|
91
91
|
<div class="row-limit">
|
|
92
92
|
<ix-button
|
|
93
93
|
appearance="text"
|
|
94
|
-
@click=${() => {
|
|
95
|
-
this.isExpanded = !this.isExpanded;
|
|
94
|
+
@click=${() => {
|
|
95
|
+
this.isExpanded = !this.isExpanded;
|
|
96
96
|
}}
|
|
97
97
|
has-icon
|
|
98
98
|
>
|
|
@@ -100,114 +100,114 @@ export class IxGrid extends LitElement {
|
|
|
100
100
|
<ix-icon slot="icon">${this.isExpanded ? 'remove' : 'add'}</ix-icon>
|
|
101
101
|
</ix-button>
|
|
102
102
|
</div>
|
|
103
|
-
`;
|
|
104
|
-
};
|
|
103
|
+
`;
|
|
104
|
+
};
|
|
105
105
|
this.renderPaginationControls = () => html `
|
|
106
106
|
<ix-pagination
|
|
107
107
|
.page=${this.page}
|
|
108
108
|
.pageSize=${this.pageSize}
|
|
109
109
|
.pageSizes=${this.pageSizes}
|
|
110
110
|
.recordCount=${this.recordCount}
|
|
111
|
-
@updatePagination=${(e) => {
|
|
112
|
-
this.page = e.detail.page;
|
|
113
|
-
this.pageSize = e.detail.pageSize;
|
|
114
|
-
this.updatePage();
|
|
111
|
+
@updatePagination=${(e) => {
|
|
112
|
+
this.page = e.detail.page;
|
|
113
|
+
this.pageSize = e.detail.pageSize;
|
|
114
|
+
this.updatePage();
|
|
115
115
|
}}
|
|
116
116
|
></ix-pagination>
|
|
117
|
-
`;
|
|
118
|
-
}
|
|
119
|
-
get columnNames() {
|
|
120
|
-
return this._columns.map((column) => column.name);
|
|
121
|
-
}
|
|
122
|
-
async updatePage() {
|
|
123
|
-
const filters = this.filters.reduce((columnFilters, { columnField, value }) => ({
|
|
124
|
-
...columnFilters,
|
|
125
|
-
[columnField]: value,
|
|
126
|
-
}), {});
|
|
127
|
-
if (this.addParamsToURL) {
|
|
128
|
-
const urlParams = {
|
|
129
|
-
sort: this.sortedColumn,
|
|
130
|
-
order: this.sortDirection,
|
|
131
|
-
page: this.page.toString(),
|
|
132
|
-
size: this.pageSize.toString(),
|
|
133
|
-
...filters,
|
|
134
|
-
};
|
|
135
|
-
const url = new URL(window.location.href);
|
|
136
|
-
const searchParams = new URLSearchParams(urlParams);
|
|
137
|
-
url.search = searchParams.toString();
|
|
138
|
-
window.history.replaceState(null, '', url.toString());
|
|
139
|
-
}
|
|
140
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
141
|
-
detail: {
|
|
142
|
-
columnName: this.sortedColumn,
|
|
143
|
-
sortOrder: this.sortDirection,
|
|
144
|
-
page: this.page,
|
|
145
|
-
pageSize: this.pageSize,
|
|
146
|
-
filters,
|
|
147
|
-
},
|
|
148
|
-
bubbles: true,
|
|
149
|
-
composed: true,
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
152
|
-
handleSort(column = '') {
|
|
153
|
-
if (this.sortedColumn !== column) {
|
|
154
|
-
this.sortDirection = 'asc';
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
|
158
|
-
}
|
|
159
|
-
this.sortedColumn = column;
|
|
160
|
-
this.updatePage();
|
|
161
|
-
}
|
|
162
|
-
connectedCallback() {
|
|
163
|
-
super.connectedCallback();
|
|
164
|
-
this._columns = this.columns;
|
|
165
|
-
}
|
|
166
|
-
async reorderColumnsFromTable() {
|
|
167
|
-
var _a, _b;
|
|
168
|
-
// calulate column order from table header flex order
|
|
169
|
-
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')) || []);
|
|
170
|
-
if (headerNodes.length) {
|
|
171
|
-
const columnOrder = headerNodes
|
|
172
|
-
.map((el, id) => ({ id, flexPosition: Number(el.style.order) }))
|
|
173
|
-
.sort((a, b) => a.flexPosition - b.flexPosition)
|
|
174
|
-
.map(el => el.id);
|
|
175
|
-
headerNodes.forEach((el, id) => {
|
|
176
|
-
this._columns[id].width = el.style.width;
|
|
177
|
-
});
|
|
178
|
-
const columnsCorrectlyOrdered = columnOrder.every((x, i) => i === 0 || x > columnOrder[i - 1]);
|
|
179
|
-
if (!columnsCorrectlyOrdered) {
|
|
180
|
-
const reorderedColumns = columnOrder.map(id => this._columns[id]);
|
|
181
|
-
this._columns = [...reorderedColumns];
|
|
182
|
-
this.isLoading = true;
|
|
183
|
-
await this.updateComplete;
|
|
184
|
-
this.isLoading = false;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
async reorderColumnsFromFilter(e) {
|
|
189
|
-
this._columns = [...e.detail.reorderedColumns];
|
|
190
|
-
this.isLoading = true;
|
|
191
|
-
await this.updateComplete;
|
|
192
|
-
this.isLoading = false;
|
|
193
|
-
}
|
|
194
|
-
render() {
|
|
195
|
-
var _a;
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
get columnNames() {
|
|
120
|
+
return this._columns.map((column) => column.name);
|
|
121
|
+
}
|
|
122
|
+
async updatePage() {
|
|
123
|
+
const filters = this.filters.reduce((columnFilters, { columnField, value }) => ({
|
|
124
|
+
...columnFilters,
|
|
125
|
+
[columnField]: value,
|
|
126
|
+
}), {});
|
|
127
|
+
if (this.addParamsToURL) {
|
|
128
|
+
const urlParams = {
|
|
129
|
+
sort: this.sortedColumn,
|
|
130
|
+
order: this.sortDirection,
|
|
131
|
+
page: this.page.toString(),
|
|
132
|
+
size: this.pageSize.toString(),
|
|
133
|
+
...filters,
|
|
134
|
+
};
|
|
135
|
+
const url = new URL(window.location.href);
|
|
136
|
+
const searchParams = new URLSearchParams(urlParams);
|
|
137
|
+
url.search = searchParams.toString();
|
|
138
|
+
window.history.replaceState(null, '', url.toString());
|
|
139
|
+
}
|
|
140
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
141
|
+
detail: {
|
|
142
|
+
columnName: this.sortedColumn,
|
|
143
|
+
sortOrder: this.sortDirection,
|
|
144
|
+
page: this.page,
|
|
145
|
+
pageSize: this.pageSize,
|
|
146
|
+
filters,
|
|
147
|
+
},
|
|
148
|
+
bubbles: true,
|
|
149
|
+
composed: true,
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
handleSort(column = '') {
|
|
153
|
+
if (this.sortedColumn !== column) {
|
|
154
|
+
this.sortDirection = 'asc';
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
|
158
|
+
}
|
|
159
|
+
this.sortedColumn = column;
|
|
160
|
+
this.updatePage();
|
|
161
|
+
}
|
|
162
|
+
connectedCallback() {
|
|
163
|
+
super.connectedCallback();
|
|
164
|
+
this._columns = this.columns;
|
|
165
|
+
}
|
|
166
|
+
async reorderColumnsFromTable() {
|
|
167
|
+
var _a, _b;
|
|
168
|
+
// calulate column order from table header flex order
|
|
169
|
+
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')) || []);
|
|
170
|
+
if (headerNodes.length) {
|
|
171
|
+
const columnOrder = headerNodes
|
|
172
|
+
.map((el, id) => ({ id, flexPosition: Number(el.style.order) }))
|
|
173
|
+
.sort((a, b) => a.flexPosition - b.flexPosition)
|
|
174
|
+
.map(el => el.id);
|
|
175
|
+
headerNodes.forEach((el, id) => {
|
|
176
|
+
this._columns[id].width = el.style.width;
|
|
177
|
+
});
|
|
178
|
+
const columnsCorrectlyOrdered = columnOrder.every((x, i) => i === 0 || x > columnOrder[i - 1]);
|
|
179
|
+
if (!columnsCorrectlyOrdered) {
|
|
180
|
+
const reorderedColumns = columnOrder.map(id => this._columns[id]);
|
|
181
|
+
this._columns = [...reorderedColumns];
|
|
182
|
+
this.isLoading = true;
|
|
183
|
+
await this.updateComplete;
|
|
184
|
+
this.isLoading = false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async reorderColumnsFromFilter(e) {
|
|
189
|
+
this._columns = [...e.detail.reorderedColumns];
|
|
190
|
+
this.isLoading = true;
|
|
191
|
+
await this.updateComplete;
|
|
192
|
+
this.isLoading = false;
|
|
193
|
+
}
|
|
194
|
+
render() {
|
|
195
|
+
var _a;
|
|
196
196
|
return html `
|
|
197
197
|
<div class=${`grid-container ${this.isLoading ? 'loading' : ''}`}>
|
|
198
198
|
${this.hideHeader ? nothing : this.renderHeader()}
|
|
199
|
-
${!this.isLoading
|
|
199
|
+
${!this.isLoading
|
|
200
200
|
? html `<vaadin-grid
|
|
201
|
-
.items=${this.rowLimit > 0 && !this.isExpanded
|
|
202
|
-
? this.rows.slice(0, this.rowLimit)
|
|
201
|
+
.items=${this.rowLimit > 0 && !this.isExpanded
|
|
202
|
+
? this.rows.slice(0, this.rowLimit)
|
|
203
203
|
: this.rows}
|
|
204
204
|
all-rows-visible
|
|
205
205
|
column-reordering-allowed
|
|
206
206
|
theme="no-border"
|
|
207
207
|
@mouseup=${this.reorderColumnsFromTable}
|
|
208
208
|
>
|
|
209
|
-
${this._columns.some(col => !col.hidden)
|
|
210
|
-
? (_a = this._columns) === null || _a === void 0 ? void 0 : _a.map((column) => column.name
|
|
209
|
+
${this._columns.some(col => !col.hidden)
|
|
210
|
+
? (_a = this._columns) === null || _a === void 0 ? void 0 : _a.map((column) => column.name
|
|
211
211
|
? html `<vaadin-grid-column
|
|
212
212
|
${columnHeaderRenderer(() => this.renderColumnHeader(column), this.sortDirection)}
|
|
213
213
|
${columnBodyRenderer(column.bodyRenderer, [])}
|
|
@@ -215,79 +215,79 @@ export class IxGrid extends LitElement {
|
|
|
215
215
|
width=${ifDefined(column.width)}
|
|
216
216
|
?hidden=${column.hidden}
|
|
217
217
|
?frozen-to-end=${column.frozenToEnd}
|
|
218
|
-
></vaadin-grid-column>`
|
|
219
|
-
: nothing)
|
|
218
|
+
></vaadin-grid-column>`
|
|
219
|
+
: nothing)
|
|
220
220
|
: html `<vaadin-grid-column></vaadin-grid-column>`}
|
|
221
|
-
</vaadin-grid>`
|
|
221
|
+
</vaadin-grid>`
|
|
222
222
|
: nothing}
|
|
223
|
-
${this.rowLimit > 0
|
|
224
|
-
? this.renderRowLimitControls()
|
|
223
|
+
${this.rowLimit > 0
|
|
224
|
+
? this.renderRowLimitControls()
|
|
225
225
|
: this.renderPaginationControls()}
|
|
226
226
|
|
|
227
227
|
<slot name="footer"></slot>
|
|
228
228
|
</div>
|
|
229
|
-
`;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
IxGrid.styles = [IxGridViewStyles];
|
|
233
|
-
__decorate([
|
|
234
|
-
query('vaadin-grid')
|
|
235
|
-
], IxGrid.prototype, "grid", void 0);
|
|
236
|
-
__decorate([
|
|
237
|
-
property({ type: Array })
|
|
238
|
-
], IxGrid.prototype, "columns", void 0);
|
|
239
|
-
__decorate([
|
|
240
|
-
property({ type: Array })
|
|
241
|
-
], IxGrid.prototype, "rows", void 0);
|
|
242
|
-
__decorate([
|
|
243
|
-
property({ type: String })
|
|
244
|
-
], IxGrid.prototype, "defaultEmptyText", void 0);
|
|
245
|
-
__decorate([
|
|
246
|
-
property({ type: String })
|
|
247
|
-
], IxGrid.prototype, "sortedColumn", void 0);
|
|
248
|
-
__decorate([
|
|
249
|
-
property({ type: String })
|
|
250
|
-
], IxGrid.prototype, "sortDirection", void 0);
|
|
251
|
-
__decorate([
|
|
252
|
-
property({ type: Boolean })
|
|
253
|
-
], IxGrid.prototype, "hideHeader", void 0);
|
|
254
|
-
__decorate([
|
|
255
|
-
property({ type: Boolean, attribute: 'hide-filters' })
|
|
256
|
-
], IxGrid.prototype, "hideFilters", void 0);
|
|
257
|
-
__decorate([
|
|
258
|
-
property({ type: Number })
|
|
259
|
-
], IxGrid.prototype, "rowLimit", void 0);
|
|
260
|
-
__decorate([
|
|
261
|
-
property({ type: Number })
|
|
262
|
-
], IxGrid.prototype, "page", void 0);
|
|
263
|
-
__decorate([
|
|
264
|
-
property({ type: Number })
|
|
265
|
-
], IxGrid.prototype, "pageSize", void 0);
|
|
266
|
-
__decorate([
|
|
267
|
-
property({ type: Array })
|
|
268
|
-
], IxGrid.prototype, "pageSizes", void 0);
|
|
269
|
-
__decorate([
|
|
270
|
-
property({ type: Number })
|
|
271
|
-
], IxGrid.prototype, "recordCount", void 0);
|
|
272
|
-
__decorate([
|
|
273
|
-
property({ type: String })
|
|
274
|
-
], IxGrid.prototype, "localStorageID", void 0);
|
|
275
|
-
__decorate([
|
|
276
|
-
property({ type: Boolean })
|
|
277
|
-
], IxGrid.prototype, "showDownload", void 0);
|
|
278
|
-
__decorate([
|
|
279
|
-
property({ type: Boolean, attribute: 'add-params-to-url' })
|
|
280
|
-
], IxGrid.prototype, "addParamsToURL", void 0);
|
|
281
|
-
__decorate([
|
|
282
|
-
state()
|
|
283
|
-
], IxGrid.prototype, "filters", void 0);
|
|
284
|
-
__decorate([
|
|
285
|
-
state()
|
|
286
|
-
], IxGrid.prototype, "_columns", void 0);
|
|
287
|
-
__decorate([
|
|
288
|
-
state()
|
|
289
|
-
], IxGrid.prototype, "isLoading", void 0);
|
|
290
|
-
__decorate([
|
|
291
|
-
state()
|
|
292
|
-
], IxGrid.prototype, "isExpanded", void 0);
|
|
229
|
+
`;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
IxGrid.styles = [IxGridViewStyles];
|
|
233
|
+
__decorate([
|
|
234
|
+
query('vaadin-grid')
|
|
235
|
+
], IxGrid.prototype, "grid", void 0);
|
|
236
|
+
__decorate([
|
|
237
|
+
property({ type: Array })
|
|
238
|
+
], IxGrid.prototype, "columns", void 0);
|
|
239
|
+
__decorate([
|
|
240
|
+
property({ type: Array })
|
|
241
|
+
], IxGrid.prototype, "rows", void 0);
|
|
242
|
+
__decorate([
|
|
243
|
+
property({ type: String })
|
|
244
|
+
], IxGrid.prototype, "defaultEmptyText", void 0);
|
|
245
|
+
__decorate([
|
|
246
|
+
property({ type: String })
|
|
247
|
+
], IxGrid.prototype, "sortedColumn", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
property({ type: String })
|
|
250
|
+
], IxGrid.prototype, "sortDirection", void 0);
|
|
251
|
+
__decorate([
|
|
252
|
+
property({ type: Boolean })
|
|
253
|
+
], IxGrid.prototype, "hideHeader", void 0);
|
|
254
|
+
__decorate([
|
|
255
|
+
property({ type: Boolean, attribute: 'hide-filters' })
|
|
256
|
+
], IxGrid.prototype, "hideFilters", void 0);
|
|
257
|
+
__decorate([
|
|
258
|
+
property({ type: Number })
|
|
259
|
+
], IxGrid.prototype, "rowLimit", void 0);
|
|
260
|
+
__decorate([
|
|
261
|
+
property({ type: Number })
|
|
262
|
+
], IxGrid.prototype, "page", void 0);
|
|
263
|
+
__decorate([
|
|
264
|
+
property({ type: Number })
|
|
265
|
+
], IxGrid.prototype, "pageSize", void 0);
|
|
266
|
+
__decorate([
|
|
267
|
+
property({ type: Array })
|
|
268
|
+
], IxGrid.prototype, "pageSizes", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
property({ type: Number })
|
|
271
|
+
], IxGrid.prototype, "recordCount", void 0);
|
|
272
|
+
__decorate([
|
|
273
|
+
property({ type: String })
|
|
274
|
+
], IxGrid.prototype, "localStorageID", void 0);
|
|
275
|
+
__decorate([
|
|
276
|
+
property({ type: Boolean })
|
|
277
|
+
], IxGrid.prototype, "showDownload", void 0);
|
|
278
|
+
__decorate([
|
|
279
|
+
property({ type: Boolean, attribute: 'add-params-to-url' })
|
|
280
|
+
], IxGrid.prototype, "addParamsToURL", void 0);
|
|
281
|
+
__decorate([
|
|
282
|
+
state()
|
|
283
|
+
], IxGrid.prototype, "filters", void 0);
|
|
284
|
+
__decorate([
|
|
285
|
+
state()
|
|
286
|
+
], IxGrid.prototype, "_columns", void 0);
|
|
287
|
+
__decorate([
|
|
288
|
+
state()
|
|
289
|
+
], IxGrid.prototype, "isLoading", void 0);
|
|
290
|
+
__decorate([
|
|
291
|
+
state()
|
|
292
|
+
], IxGrid.prototype, "isExpanded", void 0);
|
|
293
293
|
//# sourceMappingURL=IxGrid.js.map
|