@exmg/exm-grid 1.2.2 → 1.2.3
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/.rollup.cache/root/repo/packages/exm-grid/dist/index.d.ts +3 -1
- package/.rollup.cache/root/repo/packages/exm-grid/dist/index.js +3 -1
- package/.rollup.cache/root/repo/packages/exm-grid/dist/styles/exm-grid-styles-css.d.ts +1 -0
- package/.rollup.cache/root/repo/packages/exm-grid/dist/styles/exm-grid-styles-css.js +13 -0
- package/.rollup.cache/root/repo/packages/exm-grid/dist/table/exm-grid-base.d.ts +124 -0
- package/.rollup.cache/root/repo/packages/exm-grid/dist/table/exm-grid-base.js +327 -0
- package/.rollup.cache/root/repo/packages/exm-grid/dist/table/exm-grid.d.ts +2 -123
- package/.rollup.cache/root/repo/packages/exm-grid/dist/table/exm-grid.js +3 -324
- package/.rollup.cache/root/repo/packages/exm-grid/dist/table/exm-outlined-grid.d.ts +9 -0
- package/.rollup.cache/root/repo/packages/exm-grid/dist/table/exm-outlined-grid.js +12 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/styles/exm-grid-styles-css.d.ts +1 -0
- package/dist/styles/exm-grid-styles-css.js +14 -1
- package/dist/table/exm-grid-base.d.ts +124 -0
- package/dist/table/exm-grid-base.js +330 -0
- package/dist/table/exm-grid.d.ts +2 -123
- package/dist/table/exm-grid.js +3 -324
- package/dist/table/exm-outlined-grid.d.ts +9 -0
- package/dist/table/exm-outlined-grid.js +14 -0
- package/package.json +6 -4
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { EventDetailRowsOrderChanged, EventDetailRowsOrderUpdated, EventDetailSelectedRowsChange, EventDetailSortChange, SORT_DIRECTION, } from './table/types/exm-grid-types.js';
|
|
2
2
|
export { ExmGrid } from './table/exm-grid.js';
|
|
3
|
+
export { ExmGridBase } from './table/exm-grid-base.js';
|
|
4
|
+
export { ExmOutlinedGrid } from './table/exm-outlined-grid.js';
|
|
3
5
|
export { ExmGridPagination } from './table/exm-grid-pagination.js';
|
|
4
6
|
export { ExmGridBaseToolbar } from './table/exm-grid-base-toolbar.js';
|
|
5
7
|
export { ExmGridSmartToolbar } from './table/exm-grid-smart-toolbar.js';
|
|
@@ -8,7 +10,7 @@ export { ExmGridToolbar } from './table/exm-grid-toolbar.js';
|
|
|
8
10
|
export { EventDetailGridToolbarSettingChanged, Action, Filter, FilterConfigType, FilterSingleSelectConfig, BaseFilterConfig, BaseSettingConfig, Setting, SettingConfigId, SettingConfigType, SettingSelectionListConfig, SettingSelectionListItem, } from './table/types/exm-grid-toolbar-types.js';
|
|
9
11
|
export { ToolbarSearch } from './search/exm-toolbar-search.js';
|
|
10
12
|
export { ExmGridToolbarFilters, EventSelectPayload } from './table/exm-grid-toolbar-filters.js';
|
|
11
|
-
export { style as gridStyles } from './styles/exm-grid-styles-css.js';
|
|
13
|
+
export { style as gridStyles, gridOutlineStyles } from './styles/exm-grid-styles-css.js';
|
|
12
14
|
export { style as gridBaseToolbarStyles } from './styles/exm-grid-base-toolbar-styles-css.js';
|
|
13
15
|
export { style as gridCommonStyles } from './styles/exm-grid-common-styles-css.js';
|
|
14
16
|
export { style as gridPaginationStyles } from './styles/exm-grid-pagination-styles-css.js';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { ExmGrid } from './table/exm-grid.js';
|
|
2
|
+
export { ExmGridBase } from './table/exm-grid-base.js';
|
|
3
|
+
export { ExmOutlinedGrid } from './table/exm-outlined-grid.js';
|
|
2
4
|
export { ExmGridPagination } from './table/exm-grid-pagination.js';
|
|
3
5
|
export { ExmGridBaseToolbar } from './table/exm-grid-base-toolbar.js';
|
|
4
6
|
export { ExmGridSmartToolbar } from './table/exm-grid-smart-toolbar.js';
|
|
@@ -7,7 +9,7 @@ export { ExmGridToolbar } from './table/exm-grid-toolbar.js';
|
|
|
7
9
|
export { FilterConfigType, SettingConfigId, SettingConfigType, } from './table/types/exm-grid-toolbar-types.js';
|
|
8
10
|
export { ToolbarSearch } from './search/exm-toolbar-search.js';
|
|
9
11
|
export { ExmGridToolbarFilters } from './table/exm-grid-toolbar-filters.js';
|
|
10
|
-
export { style as gridStyles } from './styles/exm-grid-styles-css.js';
|
|
12
|
+
export { style as gridStyles, gridOutlineStyles } from './styles/exm-grid-styles-css.js';
|
|
11
13
|
export { style as gridBaseToolbarStyles } from './styles/exm-grid-base-toolbar-styles-css.js';
|
|
12
14
|
export { style as gridCommonStyles } from './styles/exm-grid-common-styles-css.js';
|
|
13
15
|
export { style as gridPaginationStyles } from './styles/exm-grid-pagination-styles-css.js';
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
+
export const gridOutlineStyles = css `
|
|
3
|
+
:host {
|
|
4
|
+
--exm-theme-table-surface: var(--md-sys-color-background);
|
|
5
|
+
--exm-theme-table-toolbar-background-color: var(--md-sys-color-background);
|
|
6
|
+
--exm-table-th-background-color: var(--md-sys-color-background);
|
|
7
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
8
|
+
border-radius: 1rem;
|
|
9
|
+
|
|
10
|
+
tr:nth-child(odd) {
|
|
11
|
+
background-color: #cbc9d429;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
2
15
|
export const style = css `
|
|
3
16
|
:host {
|
|
4
17
|
-moz-osx-font-smoothing: grayscale;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { ExmgElement } from '@exmg/lit-base/index.js';
|
|
2
|
+
import '@exmg/exm-sortable/exm-sortable.js';
|
|
3
|
+
import { SORT_DIRECTION } from './types/exm-grid-types.js';
|
|
4
|
+
type GenericPropertyValues<T, V = unknown> = Map<T, V>;
|
|
5
|
+
type Props = Exclude<keyof ExmGridBase, number | symbol>;
|
|
6
|
+
type SmartPropertyValue = GenericPropertyValues<Props>;
|
|
7
|
+
/**
|
|
8
|
+
* ### Styling
|
|
9
|
+
* The following custom properties and mixins are available for styling:
|
|
10
|
+
*
|
|
11
|
+
* Custom property | Description | Default
|
|
12
|
+
* ----------------|-------------|----------
|
|
13
|
+
* `--exm-arrow-upward-url` | Url to icon that is used for soring direction indicator | `url('/assets/arrow-upward.svg');`
|
|
14
|
+
* `--exm-table-card-width` | table card width | `100%;`
|
|
15
|
+
* `--exm-table-card-margin-bottom` | table bottom margin | `5px;`
|
|
16
|
+
* `--exm-table-color` | table text color | `#02182b;`
|
|
17
|
+
* `--exm-table-background-color` | table background color | `#ffffff;`
|
|
18
|
+
* `--exm-table-box-shadow` | table box shadow | `#{0px 1px 5px 0px rgba($onSurface, .2), 0px 2px 2px 0px rgba($onSurface, .14), 0px 3px 1px -2px rgba($onSurface, .12)},`
|
|
19
|
+
* `--exm-table-row-divider-color` | table rows separator color | `#dbdbdb;`
|
|
20
|
+
* `--exm-table-row-selected-color` | selected row text color | `#02182b;`
|
|
21
|
+
* `--exm-table-row-selected-background-color` | selected row background color | `#e2f1fe;`
|
|
22
|
+
* `--exm-table-row-hover-color` | row hover text color | `#02182b;`
|
|
23
|
+
* `--exm-table-row-hover-background-color` | row hover background color | `#f1f1f1;`
|
|
24
|
+
* `--exm-table-row-dragged-background-color` | sortable row background color when dragged | `#f1f1f1;`
|
|
25
|
+
* `--exm-table-rows-expanded-divider-border` | border between row and expanded row detail | `none;`
|
|
26
|
+
* `--exm-table-rows-expanded-border` | border around row and expanded row detail | `1px solid #dbdbdb;`
|
|
27
|
+
* `--exm-table-rows-expanded-background-color` | background color of row and expanded row detail | `#e2f1fe;`
|
|
28
|
+
* `--exm-table-rows-expanded-color` | text color of row and expanded row detail | `#02182b;`
|
|
29
|
+
* `--exm-table-th-color` | header text color | `#0071dc;`
|
|
30
|
+
* `--exm-table-columns-background-color` | header background color | `#ffffff;`
|
|
31
|
+
* `--exm-table-th-sortable-hover-color` | sortable header hover text color | `#02182b;`
|
|
32
|
+
* `--exm-table-th-height` | header height | `48px;`
|
|
33
|
+
* `--exm-table-th-sort-margin-left` | header margin after text but before icon | `0px;`
|
|
34
|
+
* `--exm-table-td-height` | row cell height | `48px;`
|
|
35
|
+
* `--exm-table-th-sort-icon-height` | sort icon height | `1em;`
|
|
36
|
+
* `--exm-table-th-sort-icon-width` | sort icon width | `1em;`
|
|
37
|
+
* `--exm-table-col-number-padding-right` | right padding of number column | `10px;`
|
|
38
|
+
* `--exm-table-checkbox-cell-width` | width of cell with checkbox | `24px;`
|
|
39
|
+
*/
|
|
40
|
+
export declare class ExmGridBase extends ExmgElement {
|
|
41
|
+
/**
|
|
42
|
+
* Array of data which mapped to rows
|
|
43
|
+
*/
|
|
44
|
+
items: unknown[];
|
|
45
|
+
/**
|
|
46
|
+
* Feature that turn on sort by column
|
|
47
|
+
*/
|
|
48
|
+
sortable: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Name of sort column which should be sorted by default
|
|
51
|
+
*/
|
|
52
|
+
defaultSortColumn?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Default sort direction
|
|
55
|
+
*/
|
|
56
|
+
defaultSortDirection?: SORT_DIRECTION;
|
|
57
|
+
/**
|
|
58
|
+
* Feature that allow sort rows
|
|
59
|
+
* If table has turn on feature `selectable` then it takes precedence and `rowSelectable` will be ignored
|
|
60
|
+
*/
|
|
61
|
+
rowsSortable: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Feature that allow select rows
|
|
64
|
+
*/
|
|
65
|
+
rowsSelectable: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* By default a ros is also selactable by clicking anywhere inside the row when the rowSElectable option is enabled
|
|
68
|
+
*/
|
|
69
|
+
disableRowClickSelection: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* If rows are selectable you can also pass selector to checkboxes.
|
|
72
|
+
* We can have checkboxes in thead or / and tbody.
|
|
73
|
+
*/
|
|
74
|
+
selectableCheckboxSelector?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Map of column names that should be hidden
|
|
77
|
+
*/
|
|
78
|
+
hiddenColumnNames: Record<string, string>;
|
|
79
|
+
/**
|
|
80
|
+
* Map of row id and selection state
|
|
81
|
+
* Useful for setup default selection or manipulating programmatically
|
|
82
|
+
*/
|
|
83
|
+
selectedRowIds: Record<string, boolean>;
|
|
84
|
+
/**
|
|
85
|
+
* Map of row id and expandable row state
|
|
86
|
+
* Useful for setup default expanded rows or manipulating programmatically
|
|
87
|
+
*/
|
|
88
|
+
expandedRowIds: Record<string, boolean>;
|
|
89
|
+
/**
|
|
90
|
+
* Selector to element inside row which will trigger expand / collapse action on related row detail
|
|
91
|
+
*/
|
|
92
|
+
expandableToggleSelector?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Set table layout. If fixed then text overflow will be hidden and ellipsis added.
|
|
95
|
+
*/
|
|
96
|
+
tableLayout: 'fixed' | 'auto';
|
|
97
|
+
private querySelectors?;
|
|
98
|
+
withToolbar: boolean;
|
|
99
|
+
private rowSelectableFeature?;
|
|
100
|
+
private rowExpandableFeature?;
|
|
101
|
+
private rowSortableFeature?;
|
|
102
|
+
private columnSortableFeature?;
|
|
103
|
+
private componentReady;
|
|
104
|
+
private getQuerySelectors;
|
|
105
|
+
private getTable;
|
|
106
|
+
private getTableBody;
|
|
107
|
+
private findTableBody;
|
|
108
|
+
private getColumns;
|
|
109
|
+
private getBodyRowSelector;
|
|
110
|
+
private canSortRows;
|
|
111
|
+
private rowsOrderChange;
|
|
112
|
+
private updateColumnVisibility;
|
|
113
|
+
private updateAutoColspan;
|
|
114
|
+
private observeExpandedRowIds;
|
|
115
|
+
private observeSelectedRowIds;
|
|
116
|
+
private observeItems;
|
|
117
|
+
private initGridAttributes;
|
|
118
|
+
protected firstUpdated(): Promise<void>;
|
|
119
|
+
protected updated(changedProps: SmartPropertyValue): void;
|
|
120
|
+
private renderWithoutSortable;
|
|
121
|
+
private renderWithSortable;
|
|
122
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
123
|
+
}
|
|
124
|
+
export {};
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { ExmgElement } from '@exmg/lit-base/index.js';
|
|
4
|
+
import { property, state } from 'lit/decorators.js';
|
|
5
|
+
import { cache } from 'lit/directives/cache.js';
|
|
6
|
+
import '@exmg/exm-sortable/exm-sortable.js';
|
|
7
|
+
import { ExmRowSelectable } from './featrues/exm-row-selectable.js';
|
|
8
|
+
import { ExmQuerySelectors } from './utils/exm-query-selectors.js';
|
|
9
|
+
import { ExmRowExpandable } from './featrues/exm-row-expandable.js';
|
|
10
|
+
import { ExmColumnSortable } from './featrues/exm-column-sortable.js';
|
|
11
|
+
import { ExmRowSortable } from './featrues/exm-row-sortable.js';
|
|
12
|
+
/**
|
|
13
|
+
* ### Styling
|
|
14
|
+
* The following custom properties and mixins are available for styling:
|
|
15
|
+
*
|
|
16
|
+
* Custom property | Description | Default
|
|
17
|
+
* ----------------|-------------|----------
|
|
18
|
+
* `--exm-arrow-upward-url` | Url to icon that is used for soring direction indicator | `url('/assets/arrow-upward.svg');`
|
|
19
|
+
* `--exm-table-card-width` | table card width | `100%;`
|
|
20
|
+
* `--exm-table-card-margin-bottom` | table bottom margin | `5px;`
|
|
21
|
+
* `--exm-table-color` | table text color | `#02182b;`
|
|
22
|
+
* `--exm-table-background-color` | table background color | `#ffffff;`
|
|
23
|
+
* `--exm-table-box-shadow` | table box shadow | `#{0px 1px 5px 0px rgba($onSurface, .2), 0px 2px 2px 0px rgba($onSurface, .14), 0px 3px 1px -2px rgba($onSurface, .12)},`
|
|
24
|
+
* `--exm-table-row-divider-color` | table rows separator color | `#dbdbdb;`
|
|
25
|
+
* `--exm-table-row-selected-color` | selected row text color | `#02182b;`
|
|
26
|
+
* `--exm-table-row-selected-background-color` | selected row background color | `#e2f1fe;`
|
|
27
|
+
* `--exm-table-row-hover-color` | row hover text color | `#02182b;`
|
|
28
|
+
* `--exm-table-row-hover-background-color` | row hover background color | `#f1f1f1;`
|
|
29
|
+
* `--exm-table-row-dragged-background-color` | sortable row background color when dragged | `#f1f1f1;`
|
|
30
|
+
* `--exm-table-rows-expanded-divider-border` | border between row and expanded row detail | `none;`
|
|
31
|
+
* `--exm-table-rows-expanded-border` | border around row and expanded row detail | `1px solid #dbdbdb;`
|
|
32
|
+
* `--exm-table-rows-expanded-background-color` | background color of row and expanded row detail | `#e2f1fe;`
|
|
33
|
+
* `--exm-table-rows-expanded-color` | text color of row and expanded row detail | `#02182b;`
|
|
34
|
+
* `--exm-table-th-color` | header text color | `#0071dc;`
|
|
35
|
+
* `--exm-table-columns-background-color` | header background color | `#ffffff;`
|
|
36
|
+
* `--exm-table-th-sortable-hover-color` | sortable header hover text color | `#02182b;`
|
|
37
|
+
* `--exm-table-th-height` | header height | `48px;`
|
|
38
|
+
* `--exm-table-th-sort-margin-left` | header margin after text but before icon | `0px;`
|
|
39
|
+
* `--exm-table-td-height` | row cell height | `48px;`
|
|
40
|
+
* `--exm-table-th-sort-icon-height` | sort icon height | `1em;`
|
|
41
|
+
* `--exm-table-th-sort-icon-width` | sort icon width | `1em;`
|
|
42
|
+
* `--exm-table-col-number-padding-right` | right padding of number column | `10px;`
|
|
43
|
+
* `--exm-table-checkbox-cell-width` | width of cell with checkbox | `24px;`
|
|
44
|
+
*/
|
|
45
|
+
export class ExmGridBase extends ExmgElement {
|
|
46
|
+
constructor() {
|
|
47
|
+
super(...arguments);
|
|
48
|
+
/**
|
|
49
|
+
* Array of data which mapped to rows
|
|
50
|
+
*/
|
|
51
|
+
this.items = [];
|
|
52
|
+
/**
|
|
53
|
+
* Feature that turn on sort by column
|
|
54
|
+
*/
|
|
55
|
+
this.sortable = false;
|
|
56
|
+
/**
|
|
57
|
+
* Feature that allow sort rows
|
|
58
|
+
* If table has turn on feature `selectable` then it takes precedence and `rowSelectable` will be ignored
|
|
59
|
+
*/
|
|
60
|
+
this.rowsSortable = false;
|
|
61
|
+
/**
|
|
62
|
+
* Feature that allow select rows
|
|
63
|
+
*/
|
|
64
|
+
this.rowsSelectable = false;
|
|
65
|
+
/**
|
|
66
|
+
* By default a ros is also selactable by clicking anywhere inside the row when the rowSElectable option is enabled
|
|
67
|
+
*/
|
|
68
|
+
this.disableRowClickSelection = false;
|
|
69
|
+
/**
|
|
70
|
+
* Map of column names that should be hidden
|
|
71
|
+
*/
|
|
72
|
+
this.hiddenColumnNames = {};
|
|
73
|
+
/**
|
|
74
|
+
* Map of row id and selection state
|
|
75
|
+
* Useful for setup default selection or manipulating programmatically
|
|
76
|
+
*/
|
|
77
|
+
this.selectedRowIds = {};
|
|
78
|
+
/**
|
|
79
|
+
* Map of row id and expandable row state
|
|
80
|
+
* Useful for setup default expanded rows or manipulating programmatically
|
|
81
|
+
*/
|
|
82
|
+
this.expandedRowIds = {};
|
|
83
|
+
/**
|
|
84
|
+
* Set table layout. If fixed then text overflow will be hidden and ellipsis added.
|
|
85
|
+
*/
|
|
86
|
+
this.tableLayout = 'auto';
|
|
87
|
+
this.withToolbar = false;
|
|
88
|
+
this.componentReady = false;
|
|
89
|
+
}
|
|
90
|
+
getQuerySelectors() {
|
|
91
|
+
if (!this.querySelectors) {
|
|
92
|
+
throw new Error('ExmQuerySelector not initialized yet');
|
|
93
|
+
}
|
|
94
|
+
return this.querySelectors;
|
|
95
|
+
}
|
|
96
|
+
getTable() {
|
|
97
|
+
return this.getQuerySelectors().getTable();
|
|
98
|
+
}
|
|
99
|
+
getTableBody() {
|
|
100
|
+
return this.getQuerySelectors().getTableBody();
|
|
101
|
+
}
|
|
102
|
+
findTableBody() {
|
|
103
|
+
if (this.querySelectors) {
|
|
104
|
+
return this.getTableBody() || undefined;
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
// eslint-disable-next-line
|
|
109
|
+
getColumns(selector = 'th') {
|
|
110
|
+
return this.getQuerySelectors().getColumns(selector);
|
|
111
|
+
}
|
|
112
|
+
getBodyRowSelector(selector = '') {
|
|
113
|
+
return this.getQuerySelectors().getBodyRowSelector(selector);
|
|
114
|
+
}
|
|
115
|
+
canSortRows() {
|
|
116
|
+
return !this.sortable && this.rowsSortable;
|
|
117
|
+
}
|
|
118
|
+
rowsOrderChange(e) {
|
|
119
|
+
setTimeout(() => {
|
|
120
|
+
const { sourceIndex, targetIndex } = e.detail;
|
|
121
|
+
const items = [...this.items];
|
|
122
|
+
const movedElement = items[sourceIndex];
|
|
123
|
+
items.splice(sourceIndex, 1);
|
|
124
|
+
items.splice(targetIndex, 0, movedElement);
|
|
125
|
+
this.dispatchEvent(new CustomEvent('exm-grid-rows-order-updated', {
|
|
126
|
+
composed: true,
|
|
127
|
+
bubbles: true,
|
|
128
|
+
detail: { sourceIndex, targetIndex },
|
|
129
|
+
}));
|
|
130
|
+
this.dispatchEvent(new CustomEvent('exm-grid-rows-order-changed', {
|
|
131
|
+
composed: true,
|
|
132
|
+
bubbles: true,
|
|
133
|
+
detail: { items },
|
|
134
|
+
}));
|
|
135
|
+
}, 0);
|
|
136
|
+
}
|
|
137
|
+
updateColumnVisibility(previousHiddenColumnNames = {}) {
|
|
138
|
+
let visibleColumns = 0;
|
|
139
|
+
this.getColumns().forEach((column, index) => {
|
|
140
|
+
const columnKey = column.getAttribute('data-column-key');
|
|
141
|
+
visibleColumns += this.hiddenColumnNames[columnKey || ''] ? 0 : 1;
|
|
142
|
+
if (columnKey && previousHiddenColumnNames[columnKey] !== this.hiddenColumnNames[columnKey]) {
|
|
143
|
+
const nextDisplayValue = this.hiddenColumnNames[columnKey] ? 'none' : 'table-cell';
|
|
144
|
+
column.style.display = nextDisplayValue;
|
|
145
|
+
this.getTable()
|
|
146
|
+
.querySelectorAll(`tbody.grid-data tr:not(.grid-row-detail) td:nth-child(${index + 1})`)
|
|
147
|
+
.forEach((cell) => {
|
|
148
|
+
cell.style.display = nextDisplayValue;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
this.updateAutoColspan(visibleColumns);
|
|
153
|
+
}
|
|
154
|
+
updateAutoColspan(visibleColumns) {
|
|
155
|
+
this.getTable()
|
|
156
|
+
.querySelectorAll('[data-auto-colspan]')
|
|
157
|
+
.forEach((element) => {
|
|
158
|
+
const offset = Number.parseInt(element.getAttribute('data-auto-span') || '0', 10);
|
|
159
|
+
element.setAttribute('colspan', (visibleColumns - offset).toString());
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
observeExpandedRowIds(changedProps) {
|
|
163
|
+
if (changedProps.has('expandedRowIds')) {
|
|
164
|
+
Object.entries(this.expandedRowIds).forEach(([rowId, nextExpandedState]) => {
|
|
165
|
+
const expendableToggle = this.getTableBody().querySelector(this.getBodyRowSelector(`[data-row-key="${rowId}"] ${this.expandableToggleSelector}`));
|
|
166
|
+
if (expendableToggle) {
|
|
167
|
+
const isExpanded = expendableToggle.hasAttribute('data-is-expanded');
|
|
168
|
+
if (isExpanded !== nextExpandedState) {
|
|
169
|
+
expendableToggle.dispatchEvent(new MouseEvent('click'));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
observeSelectedRowIds(changedProps) {
|
|
176
|
+
if (changedProps.has('selectedRowIds')) {
|
|
177
|
+
Object.entries(this.selectedRowIds).forEach(([rowId, nextSelectionState]) => {
|
|
178
|
+
const row = this.getTableBody().querySelector(this.getBodyRowSelector(`[data-row-key="${rowId}"]`));
|
|
179
|
+
if (row) {
|
|
180
|
+
const isSelected = row.hasAttribute('data-selected');
|
|
181
|
+
if (isSelected !== nextSelectionState) {
|
|
182
|
+
row.dispatchEvent(new MouseEvent('click'));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
observeItems(changedProps) {
|
|
189
|
+
if (changedProps.has('items') && this.rowSelectableFeature) {
|
|
190
|
+
this.rowSelectableFeature.syncSelectedItems();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async initGridAttributes() {
|
|
194
|
+
await this.updateComplete;
|
|
195
|
+
const toolbarSlot = this.shadowRoot.querySelector('slot[name="toolbar"]');
|
|
196
|
+
if (toolbarSlot && toolbarSlot.assignedNodes && toolbarSlot.assignedNodes().length) {
|
|
197
|
+
// make TS happy - this.withToolbar is declared but never read
|
|
198
|
+
this.withToolbar = this.withToolbar || true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async firstUpdated() {
|
|
202
|
+
const table = this.shadowRoot.host.querySelector('table');
|
|
203
|
+
const tableBody = table.querySelector('tbody.grid-data');
|
|
204
|
+
this.querySelectors = new ExmQuerySelectors(table, tableBody);
|
|
205
|
+
this.initGridAttributes();
|
|
206
|
+
const bodyRows = this.querySelectors.getBodyRows();
|
|
207
|
+
if (this.sortable) {
|
|
208
|
+
this.columnSortableFeature = new ExmColumnSortable(this.querySelectors, (event) => this.dispatchEvent(event), this.defaultSortColumn, this.defaultSortDirection);
|
|
209
|
+
this.columnSortableFeature.initFeature();
|
|
210
|
+
}
|
|
211
|
+
if (this.canSortRows()) {
|
|
212
|
+
this.rowSortableFeature = new ExmRowSortable(this.querySelectors);
|
|
213
|
+
this.rowSortableFeature.initFeature();
|
|
214
|
+
}
|
|
215
|
+
if (this.rowsSelectable) {
|
|
216
|
+
this.rowSelectableFeature = new ExmRowSelectable(this.querySelectors, (event) => this.dispatchEvent(event), this.disableRowClickSelection, this.selectableCheckboxSelector);
|
|
217
|
+
this.rowSelectableFeature.initFeature(bodyRows);
|
|
218
|
+
}
|
|
219
|
+
if (this.expandableToggleSelector) {
|
|
220
|
+
this.rowExpandableFeature = new ExmRowExpandable(this.querySelectors, this.expandableToggleSelector);
|
|
221
|
+
this.rowExpandableFeature.initFeature();
|
|
222
|
+
}
|
|
223
|
+
this.updateColumnVisibility();
|
|
224
|
+
bodyRows.forEach((row) => row.setAttribute('data-initialized', ''));
|
|
225
|
+
this.querySelectors.getColumns('th:not([title])').forEach((col) => col.setAttribute('title', col.innerText));
|
|
226
|
+
this.querySelectors.getTable().setAttribute('data-table-layout', this.tableLayout);
|
|
227
|
+
await this.updateComplete;
|
|
228
|
+
this.componentReady = true;
|
|
229
|
+
}
|
|
230
|
+
updated(changedProps) {
|
|
231
|
+
if (changedProps.has('hiddenColumnNames') || changedProps.has('items')) {
|
|
232
|
+
this.updateColumnVisibility(changedProps.get('hiddenColumnNames'));
|
|
233
|
+
}
|
|
234
|
+
this.observeItems(changedProps);
|
|
235
|
+
this.observeExpandedRowIds(changedProps);
|
|
236
|
+
this.observeSelectedRowIds(changedProps);
|
|
237
|
+
if (this.componentReady && changedProps.has('items')) {
|
|
238
|
+
const bodyRows = this.querySelectors.getBodyRowsNotInitialized();
|
|
239
|
+
if (this.rowSelectableFeature) {
|
|
240
|
+
this.rowSelectableFeature.updateFeature(bodyRows);
|
|
241
|
+
}
|
|
242
|
+
if (this.rowExpandableFeature) {
|
|
243
|
+
this.rowExpandableFeature.updateFeature();
|
|
244
|
+
}
|
|
245
|
+
if (this.rowSortableFeature) {
|
|
246
|
+
this.rowSortableFeature.updateFeature();
|
|
247
|
+
}
|
|
248
|
+
bodyRows.forEach((row) => row.setAttribute('data-initialized', ''));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
renderWithoutSortable() {
|
|
252
|
+
return html ` <slot></slot> `;
|
|
253
|
+
}
|
|
254
|
+
renderWithSortable() {
|
|
255
|
+
return html `
|
|
256
|
+
<exm-sortable
|
|
257
|
+
orientation="${'vertical'}"
|
|
258
|
+
animation-enabled
|
|
259
|
+
item-selector="tbody.grid-data > tr:not(.grid-row-detail)"
|
|
260
|
+
handle-selector=".grid-row-drag-handler"
|
|
261
|
+
.sortableHostNode="${this.findTableBody()}"
|
|
262
|
+
@dom-order-change="${this.rowsOrderChange}"
|
|
263
|
+
>
|
|
264
|
+
<slot></slot>
|
|
265
|
+
</exm-sortable>
|
|
266
|
+
`;
|
|
267
|
+
}
|
|
268
|
+
render() {
|
|
269
|
+
return html `
|
|
270
|
+
<div class="table-card-container">
|
|
271
|
+
<slot name="toolbar"></slot>
|
|
272
|
+
<div class="table-card">
|
|
273
|
+
<div class="table-container">
|
|
274
|
+
${cache(this.canSortRows() ? this.renderWithSortable() : this.renderWithoutSortable())}
|
|
275
|
+
</div>
|
|
276
|
+
<slot name="pagination"></slot>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
`;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
__decorate([
|
|
283
|
+
property({ type: Array })
|
|
284
|
+
], ExmGridBase.prototype, "items", void 0);
|
|
285
|
+
__decorate([
|
|
286
|
+
property({ type: Boolean, reflect: true })
|
|
287
|
+
], ExmGridBase.prototype, "sortable", void 0);
|
|
288
|
+
__decorate([
|
|
289
|
+
property({ type: String, attribute: 'default-sort-column' })
|
|
290
|
+
], ExmGridBase.prototype, "defaultSortColumn", void 0);
|
|
291
|
+
__decorate([
|
|
292
|
+
property({ type: String, attribute: 'default-sort-direction' })
|
|
293
|
+
], ExmGridBase.prototype, "defaultSortDirection", void 0);
|
|
294
|
+
__decorate([
|
|
295
|
+
property({ type: Boolean, reflect: true, attribute: 'rows-sortable' })
|
|
296
|
+
], ExmGridBase.prototype, "rowsSortable", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
property({ type: Boolean, attribute: 'rows-selectable' })
|
|
299
|
+
], ExmGridBase.prototype, "rowsSelectable", void 0);
|
|
300
|
+
__decorate([
|
|
301
|
+
property({ type: Boolean, attribute: 'disable-row-click-selection' })
|
|
302
|
+
], ExmGridBase.prototype, "disableRowClickSelection", void 0);
|
|
303
|
+
__decorate([
|
|
304
|
+
property({ type: String, attribute: 'selectable-checkbox-selector' })
|
|
305
|
+
], ExmGridBase.prototype, "selectableCheckboxSelector", void 0);
|
|
306
|
+
__decorate([
|
|
307
|
+
property({ type: Object })
|
|
308
|
+
], ExmGridBase.prototype, "hiddenColumnNames", void 0);
|
|
309
|
+
__decorate([
|
|
310
|
+
property({ type: Object })
|
|
311
|
+
], ExmGridBase.prototype, "selectedRowIds", void 0);
|
|
312
|
+
__decorate([
|
|
313
|
+
property({ type: Object })
|
|
314
|
+
], ExmGridBase.prototype, "expandedRowIds", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
property({ type: String, attribute: 'expandable-toggle-selector', reflect: true })
|
|
317
|
+
], ExmGridBase.prototype, "expandableToggleSelector", void 0);
|
|
318
|
+
__decorate([
|
|
319
|
+
property({ type: String, attribute: 'table-layout', reflect: true })
|
|
320
|
+
], ExmGridBase.prototype, "tableLayout", void 0);
|
|
321
|
+
__decorate([
|
|
322
|
+
state()
|
|
323
|
+
], ExmGridBase.prototype, "querySelectors", void 0);
|
|
324
|
+
__decorate([
|
|
325
|
+
property({ type: Boolean, reflect: true, attribute: 'data-with-toolbar' })
|
|
326
|
+
], ExmGridBase.prototype, "withToolbar", void 0);
|
|
327
|
+
//# sourceMappingURL=exm-grid-base.js.map
|
|
@@ -1,130 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { SORT_DIRECTION } from './types/exm-grid-types.js';
|
|
4
|
-
type GenericPropertyValues<T, V = unknown> = Map<T, V>;
|
|
5
|
-
type Props = Exclude<keyof ExmGrid, number | symbol>;
|
|
6
|
-
type SmartPropertyValue = GenericPropertyValues<Props>;
|
|
7
|
-
/**
|
|
8
|
-
* ### Styling
|
|
9
|
-
* The following custom properties and mixins are available for styling:
|
|
10
|
-
*
|
|
11
|
-
* Custom property | Description | Default
|
|
12
|
-
* ----------------|-------------|----------
|
|
13
|
-
* `--exm-arrow-upward-url` | Url to icon that is used for soring direction indicator | `url('/assets/arrow-upward.svg');`
|
|
14
|
-
* `--exm-table-card-width` | table card width | `100%;`
|
|
15
|
-
* `--exm-table-card-margin-bottom` | table bottom margin | `5px;`
|
|
16
|
-
* `--exm-table-color` | table text color | `#02182b;`
|
|
17
|
-
* `--exm-table-background-color` | table background color | `#ffffff;`
|
|
18
|
-
* `--exm-table-box-shadow` | table box shadow | `#{0px 1px 5px 0px rgba($onSurface, .2), 0px 2px 2px 0px rgba($onSurface, .14), 0px 3px 1px -2px rgba($onSurface, .12)},`
|
|
19
|
-
* `--exm-table-row-divider-color` | table rows separator color | `#dbdbdb;`
|
|
20
|
-
* `--exm-table-row-selected-color` | selected row text color | `#02182b;`
|
|
21
|
-
* `--exm-table-row-selected-background-color` | selected row background color | `#e2f1fe;`
|
|
22
|
-
* `--exm-table-row-hover-color` | row hover text color | `#02182b;`
|
|
23
|
-
* `--exm-table-row-hover-background-color` | row hover background color | `#f1f1f1;`
|
|
24
|
-
* `--exm-table-row-dragged-background-color` | sortable row background color when dragged | `#f1f1f1;`
|
|
25
|
-
* `--exm-table-rows-expanded-divider-border` | border between row and expanded row detail | `none;`
|
|
26
|
-
* `--exm-table-rows-expanded-border` | border around row and expanded row detail | `1px solid #dbdbdb;`
|
|
27
|
-
* `--exm-table-rows-expanded-background-color` | background color of row and expanded row detail | `#e2f1fe;`
|
|
28
|
-
* `--exm-table-rows-expanded-color` | text color of row and expanded row detail | `#02182b;`
|
|
29
|
-
* `--exm-table-th-color` | header text color | `#0071dc;`
|
|
30
|
-
* `--exm-table-columns-background-color` | header background color | `#ffffff;`
|
|
31
|
-
* `--exm-table-th-sortable-hover-color` | sortable header hover text color | `#02182b;`
|
|
32
|
-
* `--exm-table-th-height` | header height | `48px;`
|
|
33
|
-
* `--exm-table-th-sort-margin-left` | header margin after text but before icon | `0px;`
|
|
34
|
-
* `--exm-table-td-height` | row cell height | `48px;`
|
|
35
|
-
* `--exm-table-th-sort-icon-height` | sort icon height | `1em;`
|
|
36
|
-
* `--exm-table-th-sort-icon-width` | sort icon width | `1em;`
|
|
37
|
-
* `--exm-table-col-number-padding-right` | right padding of number column | `10px;`
|
|
38
|
-
* `--exm-table-checkbox-cell-width` | width of cell with checkbox | `24px;`
|
|
39
|
-
*/
|
|
40
|
-
export declare class ExmGrid extends ExmgElement {
|
|
1
|
+
import { ExmGridBase } from './exm-grid-base.js';
|
|
2
|
+
export declare class ExmGrid extends ExmGridBase {
|
|
41
3
|
static styles: import("lit").CSSResult[];
|
|
42
|
-
/**
|
|
43
|
-
* Array of data which mapped to rows
|
|
44
|
-
*/
|
|
45
|
-
items: unknown[];
|
|
46
|
-
/**
|
|
47
|
-
* Feature that turn on sort by column
|
|
48
|
-
*/
|
|
49
|
-
sortable: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Name of sort column which should be sorted by default
|
|
52
|
-
*/
|
|
53
|
-
defaultSortColumn?: string;
|
|
54
|
-
/**
|
|
55
|
-
* Default sort direction
|
|
56
|
-
*/
|
|
57
|
-
defaultSortDirection?: SORT_DIRECTION;
|
|
58
|
-
/**
|
|
59
|
-
* Feature that allow sort rows
|
|
60
|
-
* If table has turn on feature `selectable` then it takes precedence and `rowSelectable` will be ignored
|
|
61
|
-
*/
|
|
62
|
-
rowsSortable: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Feature that allow select rows
|
|
65
|
-
*/
|
|
66
|
-
rowsSelectable: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* By default a ros is also selactable by clicking anywhere inside the row when the rowSElectable option is enabled
|
|
69
|
-
*/
|
|
70
|
-
disableRowClickSelection: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* If rows are selectable you can also pass selector to checkboxes.
|
|
73
|
-
* We can have checkboxes in thead or / and tbody.
|
|
74
|
-
*/
|
|
75
|
-
selectableCheckboxSelector?: string;
|
|
76
|
-
/**
|
|
77
|
-
* Map of column names that should be hidden
|
|
78
|
-
*/
|
|
79
|
-
hiddenColumnNames: Record<string, string>;
|
|
80
|
-
/**
|
|
81
|
-
* Map of row id and selection state
|
|
82
|
-
* Useful for setup default selection or manipulating programmatically
|
|
83
|
-
*/
|
|
84
|
-
selectedRowIds: Record<string, boolean>;
|
|
85
|
-
/**
|
|
86
|
-
* Map of row id and expandable row state
|
|
87
|
-
* Useful for setup default expanded rows or manipulating programmatically
|
|
88
|
-
*/
|
|
89
|
-
expandedRowIds: Record<string, boolean>;
|
|
90
|
-
/**
|
|
91
|
-
* Selector to element inside row which will trigger expand / collapse action on related row detail
|
|
92
|
-
*/
|
|
93
|
-
expandableToggleSelector?: string;
|
|
94
|
-
/**
|
|
95
|
-
* Set table layout. If fixed then text overflow will be hidden and ellipsis added.
|
|
96
|
-
*/
|
|
97
|
-
tableLayout: 'fixed' | 'auto';
|
|
98
|
-
private querySelectors?;
|
|
99
|
-
withToolbar: boolean;
|
|
100
|
-
private rowSelectableFeature?;
|
|
101
|
-
private rowExpandableFeature?;
|
|
102
|
-
private rowSortableFeature?;
|
|
103
|
-
private columnSortableFeature?;
|
|
104
|
-
private componentReady;
|
|
105
|
-
private getQuerySelectors;
|
|
106
|
-
private getTable;
|
|
107
|
-
private getTableBody;
|
|
108
|
-
private findTableBody;
|
|
109
|
-
private getColumns;
|
|
110
|
-
private getBodyRowSelector;
|
|
111
|
-
private canSortRows;
|
|
112
|
-
private rowsOrderChange;
|
|
113
|
-
private updateColumnVisibility;
|
|
114
|
-
private updateAutoColspan;
|
|
115
|
-
private observeExpandedRowIds;
|
|
116
|
-
private observeSelectedRowIds;
|
|
117
|
-
private observeItems;
|
|
118
|
-
private initGridAttributes;
|
|
119
|
-
protected firstUpdated(): Promise<void>;
|
|
120
|
-
protected updated(changedProps: SmartPropertyValue): void;
|
|
121
|
-
private renderWithoutSortable;
|
|
122
|
-
private renderWithSortable;
|
|
123
|
-
protected render(): import("lit-html").TemplateResult<1>;
|
|
124
4
|
}
|
|
125
5
|
declare global {
|
|
126
6
|
interface HTMLElementTagNameMap {
|
|
127
7
|
'exm-grid': ExmGrid;
|
|
128
8
|
}
|
|
129
9
|
}
|
|
130
|
-
export {};
|