@exmg/exm-grid 1.2.2 → 1.2.4

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