overview-components 1.0.1 → 1.0.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/dist/components/lit-attachments-tab.d.ts +0 -1
- package/dist/components/lit-attachments-tab.d.ts.map +1 -1
- package/dist/components/lit-attachments-tab.js +0 -1
- package/dist/components/lit-attachments-tab.js.map +1 -1
- package/dist/components/lit-badge.d.ts +25 -0
- package/dist/components/lit-badge.d.ts.map +1 -0
- package/dist/components/lit-badge.js +95 -0
- package/dist/components/lit-badge.js.map +1 -0
- package/dist/components/lit-case-variables-tab.d.ts +1 -2
- package/dist/components/lit-case-variables-tab.d.ts.map +1 -1
- package/dist/components/lit-case-variables-tab.js +5 -11
- package/dist/components/lit-case-variables-tab.js.map +1 -1
- package/dist/components/lit-data-grid-tanstack.d.ts +41 -10
- package/dist/components/lit-data-grid-tanstack.d.ts.map +1 -1
- package/dist/components/lit-data-grid-tanstack.js +318 -67
- package/dist/components/lit-data-grid-tanstack.js.map +1 -1
- package/dist/components/lit-tabs-overview.d.ts +0 -1
- package/dist/components/lit-tabs-overview.d.ts.map +1 -1
- package/dist/components/lit-tabs-overview.js +0 -1
- package/dist/components/lit-tabs-overview.js.map +1 -1
- package/dist/components/react-wrappers/badge.d.ts +3 -0
- package/dist/components/react-wrappers/badge.d.ts.map +1 -0
- package/dist/components/react-wrappers/badge.js +9 -0
- package/dist/components/react-wrappers/badge.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/shared/filter-inputs.d.ts +5 -13
- package/dist/shared/filter-inputs.d.ts.map +1 -1
- package/dist/shared/filter-inputs.js +93 -275
- package/dist/shared/filter-inputs.js.map +1 -1
- package/dist/shared/lit-case-variables-tab-cell.d.ts +1 -1
- package/dist/shared/lit-case-variables-tab-cell.d.ts.map +1 -1
- package/dist/shared/lit-case-variables-tab-cell.js +6 -4
- package/dist/shared/lit-case-variables-tab-cell.js.map +1 -1
- package/dist/shared/lit-checkbox.d.ts +7 -0
- package/dist/shared/lit-checkbox.d.ts.map +1 -0
- package/dist/shared/lit-checkbox.js +117 -0
- package/dist/shared/lit-checkbox.js.map +1 -0
- package/dist/shared/lit-custom-popper.js +31 -31
- package/dist/shared/lit-data-grid-density-popover.d.ts +1 -4
- package/dist/shared/lit-data-grid-density-popover.d.ts.map +1 -1
- package/dist/shared/lit-data-grid-density-popover.js +34 -52
- package/dist/shared/lit-data-grid-density-popover.js.map +1 -1
- package/dist/shared/lit-data-grid-export-popover.d.ts +1 -5
- package/dist/shared/lit-data-grid-export-popover.d.ts.map +1 -1
- package/dist/shared/lit-data-grid-export-popover.js +28 -51
- package/dist/shared/lit-data-grid-export-popover.js.map +1 -1
- package/dist/shared/lit-data-grid-row-actions.d.ts +31 -0
- package/dist/shared/lit-data-grid-row-actions.d.ts.map +1 -0
- package/dist/shared/lit-data-grid-row-actions.js +71 -0
- package/dist/shared/lit-data-grid-row-actions.js.map +1 -0
- package/dist/shared/lit-date-picker.d.ts +33 -0
- package/dist/shared/lit-date-picker.d.ts.map +1 -0
- package/dist/shared/lit-date-picker.js +246 -0
- package/dist/shared/lit-date-picker.js.map +1 -0
- package/dist/shared/lit-menu-item.js +1 -1
- package/dist/shared/lit-menu-item.js.map +1 -1
- package/dist/shared/lit-overflow-tooltip.d.ts +3 -1
- package/dist/shared/lit-overflow-tooltip.d.ts.map +1 -1
- package/dist/shared/lit-overflow-tooltip.js +21 -16
- package/dist/shared/lit-overflow-tooltip.js.map +1 -1
- package/dist/shared/lit-select.d.ts +4 -1
- package/dist/shared/lit-select.d.ts.map +1 -1
- package/dist/shared/lit-select.js +15 -2
- package/dist/shared/lit-select.js.map +1 -1
- package/dist/shared/simple-popper.d.ts +36 -0
- package/dist/shared/simple-popper.d.ts.map +1 -0
- package/dist/shared/simple-popper.js +207 -0
- package/dist/shared/simple-popper.js.map +1 -0
- package/dist/shared/simple-tooltip.d.ts +35 -0
- package/dist/shared/simple-tooltip.d.ts.map +1 -0
- package/dist/shared/simple-tooltip.js +200 -0
- package/dist/shared/simple-tooltip.js.map +1 -0
- package/dist/utils/getOverviewValue.d.ts.map +1 -1
- package/dist/utils/getOverviewValue.js +0 -1
- package/dist/utils/getOverviewValue.js.map +1 -1
- package/package.json +1 -1
- package/dist/shared/lit-tooltip.d.ts +0 -20
- package/dist/shared/lit-tooltip.d.ts.map +0 -1
- package/dist/shared/lit-tooltip.js +0 -123
- package/dist/shared/lit-tooltip.js.map +0 -1
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { css, html, LitElement } from 'lit';
|
|
8
8
|
import { msg } from '@lit/localize';
|
|
9
9
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
10
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
10
11
|
import { TableController, getCoreRowModel, flexRender, getSortedRowModel, getFilteredRowModel, getFacetedRowModel, getFacetedUniqueValues, getGroupedRowModel, getExpandedRowModel, filterFns, } from '@tanstack/lit-table';
|
|
11
12
|
import { repeat } from 'lit/directives/repeat.js';
|
|
12
13
|
import { VirtualizerController } from '@tanstack/lit-virtual';
|
|
@@ -18,13 +19,16 @@ import '../shared/lit-icon.js';
|
|
|
18
19
|
import '../shared/lit-icon-button.js';
|
|
19
20
|
import '../shared/lit-button.js';
|
|
20
21
|
import '../shared/lit-responsive-button.js';
|
|
21
|
-
import '../shared/lit-tooltip.js';
|
|
22
22
|
import '../shared/lit-data-grid-export-popover.js';
|
|
23
23
|
import '../shared/lit-data-grid-action-buttons-popover.js';
|
|
24
24
|
import '../assets/ilustration/not-found.js';
|
|
25
25
|
import '../shared/lit-overflow-tooltip.js';
|
|
26
26
|
import '../shared/lit-data-grid-density-popover.js';
|
|
27
27
|
import '../shared/lit-loading-bar.js';
|
|
28
|
+
import '../shared/lit-data-grid-row-actions.js';
|
|
29
|
+
import '../shared/simple-tooltip.js';
|
|
30
|
+
import '../shared/lit-checkbox.js';
|
|
31
|
+
import '../shared/lit-overflow-tooltip.js';
|
|
28
32
|
// utils
|
|
29
33
|
import { formatDate } from '../utils/date.js';
|
|
30
34
|
import { dateFilterFn, multiselectFilterFn } from '../utils/custom-filters.js';
|
|
@@ -42,19 +46,23 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
42
46
|
this.actionButtonsInMenu = false;
|
|
43
47
|
this.id = '';
|
|
44
48
|
this.initialSorting = [];
|
|
49
|
+
this.columnSizing = {};
|
|
45
50
|
this.leftPinnedColumns = [];
|
|
46
51
|
this.rightPinnedColumns = [];
|
|
47
52
|
this.enableFiltering = true;
|
|
48
53
|
this.userLang = 'cs';
|
|
49
54
|
this.dateFormat = null;
|
|
50
55
|
this.isLoading = false;
|
|
56
|
+
this.onColumnResize = () => { };
|
|
57
|
+
this.onColumnFiltersChanged = (filterModel) => { };
|
|
58
|
+
this.onColumnSortChanged = (table, sortModel) => { };
|
|
59
|
+
this.onRowSelectionChanged = (table, selectedRows) => { };
|
|
51
60
|
this.enableRowSelectionOnClick = false;
|
|
52
61
|
this.initialFiltering = [];
|
|
53
62
|
this.server = false;
|
|
54
|
-
this.onColumnFiltersChanged = (filterModel) => { };
|
|
55
|
-
this.onColumnSortChanged = (sortModel) => { };
|
|
56
63
|
this.scrollEndThreshold = 100;
|
|
57
64
|
this.rowDensity = 'standard';
|
|
65
|
+
this.checkboxSelection = false;
|
|
58
66
|
this.rowsCount = 0;
|
|
59
67
|
this.selectedRowId = null;
|
|
60
68
|
this.isScrollable = false;
|
|
@@ -63,9 +71,12 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
63
71
|
this.filters = [];
|
|
64
72
|
this.sorting = [];
|
|
65
73
|
this.rowHeight = 31;
|
|
74
|
+
this._rowSelection = {};
|
|
75
|
+
this._columnSizing = {};
|
|
66
76
|
this.scrollToEnd = false;
|
|
67
77
|
this.tableContainerRef = createRef();
|
|
68
78
|
this.scrollInterval = null;
|
|
79
|
+
this.currentScrollTop = 0;
|
|
69
80
|
this.getCellBackgroundColor = (cell) => {
|
|
70
81
|
if (cell.getIsGrouped()) {
|
|
71
82
|
return this.columnGroupedColor ?? `var(--color-primary-light, #f0fadf)`;
|
|
@@ -88,6 +99,7 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
88
99
|
this.isScrollable = canScrollHorizontally;
|
|
89
100
|
this.disableScrollLeft = grid.scrollLeft === 0;
|
|
90
101
|
this.disableScrollRight = grid.scrollLeft + grid.clientWidth >= grid.scrollWidth;
|
|
102
|
+
this.currentScrollTop = grid.scrollTop;
|
|
91
103
|
}
|
|
92
104
|
};
|
|
93
105
|
}
|
|
@@ -135,6 +147,9 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
135
147
|
this.initTable();
|
|
136
148
|
this.requestUpdate();
|
|
137
149
|
}
|
|
150
|
+
if (changedProperties.has('columnSizing')) {
|
|
151
|
+
this._columnSizing = this.columnSizing;
|
|
152
|
+
}
|
|
138
153
|
}
|
|
139
154
|
firstUpdated() {
|
|
140
155
|
const grid = this.tableContainerRef.value;
|
|
@@ -144,7 +159,7 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
144
159
|
this.updateScrollState();
|
|
145
160
|
}
|
|
146
161
|
async loadXLSX() {
|
|
147
|
-
if (!window.XLSX) {
|
|
162
|
+
if (!window.XLSX && !this.server) {
|
|
148
163
|
await new Promise((resolve) => {
|
|
149
164
|
const script = document.createElement('script');
|
|
150
165
|
script.src = '../../public/libs/xlsx.mini.min.js';
|
|
@@ -180,9 +195,90 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
180
195
|
}
|
|
181
196
|
handleSetDensity(density) {
|
|
182
197
|
this.rowDensity = density;
|
|
198
|
+
if (this.rowDensityChange) {
|
|
199
|
+
this.rowDensityChange(this.table, density);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
handleFilterTabNavigation(event) {
|
|
203
|
+
const { direction, currentFilter } = event.detail;
|
|
204
|
+
// Získajte všetky filter-inputs elementy z DOM
|
|
205
|
+
const filterInputs = Array.from(this.shadowRoot?.querySelectorAll('filter-inputs') || []);
|
|
206
|
+
if (filterInputs.length === 0)
|
|
207
|
+
return;
|
|
208
|
+
const currentIndex = filterInputs.indexOf(currentFilter);
|
|
209
|
+
let nextIndex;
|
|
210
|
+
if (direction === 'forward') {
|
|
211
|
+
// Ak je aktuálny filter posledný vo viditeľnom zozname
|
|
212
|
+
if (currentIndex === filterInputs.length - 1) {
|
|
213
|
+
// Scroll na začiatok (ľavá strana)
|
|
214
|
+
const grid = this.shadowRoot?.querySelector('.grid');
|
|
215
|
+
if (grid) {
|
|
216
|
+
grid.scrollLeft = 0;
|
|
217
|
+
}
|
|
218
|
+
// Po vykonaní scrollu čakáme krátko a potom nastavený focus na prvý filter
|
|
219
|
+
setTimeout(() => {
|
|
220
|
+
const firstFilter = this.shadowRoot?.querySelector('filter-inputs');
|
|
221
|
+
if (firstFilter) {
|
|
222
|
+
firstFilter.focus();
|
|
223
|
+
}
|
|
224
|
+
}, 0);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
nextIndex = currentIndex + 1;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
// Podobne môžeme spracovať aj spätnú navigáciu
|
|
233
|
+
if (currentIndex === 0) {
|
|
234
|
+
const grid = this.shadowRoot?.querySelector('.grid');
|
|
235
|
+
if (grid) {
|
|
236
|
+
// Scroll na koniec (pravá strana)
|
|
237
|
+
grid.scrollLeft = grid.scrollWidth;
|
|
238
|
+
}
|
|
239
|
+
setTimeout(() => {
|
|
240
|
+
const filters = Array.from(this.shadowRoot?.querySelectorAll('filter-inputs') || []);
|
|
241
|
+
if (filters.length > 0) {
|
|
242
|
+
filters[filters.length - 1].focus();
|
|
243
|
+
}
|
|
244
|
+
}, 0);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
nextIndex = currentIndex - 1;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// Nastav focus na ďalší filter podľa smeru
|
|
252
|
+
filterInputs[nextIndex].focus();
|
|
183
253
|
}
|
|
184
254
|
// scroll by keyboard arrows
|
|
185
255
|
handleKeyDown(event) {
|
|
256
|
+
// if (event.key === 'Tab') {
|
|
257
|
+
// // Získajte aktuálne fokusovaný element v shadow DOM
|
|
258
|
+
// const active = this.shadowRoot?.activeElement;
|
|
259
|
+
// // Ak nie je focusovaný element v rámci filter-inputs
|
|
260
|
+
// if (!active || !active.closest('filter-inputs')) {
|
|
261
|
+
// const grid = this.shadowRoot?.querySelector('.grid') as HTMLElement;
|
|
262
|
+
// // Ak grid nie je úplne scrollnutý na začiatok, najprv scrollnite na začiatok
|
|
263
|
+
// if (grid && grid.scrollLeft !== 0) {
|
|
264
|
+
// grid.scrollLeft = 0;
|
|
265
|
+
// // Po krátkej oneskorení, kým sa scroll dokončí, zvoľte prvý filter
|
|
266
|
+
// setTimeout(() => {
|
|
267
|
+
// const firstFilter = this.shadowRoot?.querySelector('filter-inputs');
|
|
268
|
+
// if (firstFilter) {
|
|
269
|
+
// event.preventDefault();
|
|
270
|
+
// (firstFilter as HTMLElement).focus();
|
|
271
|
+
// }
|
|
272
|
+
// }, 0);
|
|
273
|
+
// } else {
|
|
274
|
+
// const firstFilter = this.shadowRoot?.querySelector('filter-inputs');
|
|
275
|
+
// if (firstFilter) {
|
|
276
|
+
// event.preventDefault();
|
|
277
|
+
// (firstFilter as HTMLElement).focus();
|
|
278
|
+
// }
|
|
279
|
+
// }
|
|
280
|
+
// }
|
|
281
|
+
// }
|
|
186
282
|
if (!this.enableRowSelectionOnClick)
|
|
187
283
|
return;
|
|
188
284
|
const rows = this.table.getRowModel().rows;
|
|
@@ -217,6 +313,7 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
217
313
|
getScrollElement: () => this.tableContainerRef.value,
|
|
218
314
|
estimateSize: () => this.rowHeight,
|
|
219
315
|
overscan: 5,
|
|
316
|
+
initialOffset: this.currentScrollTop,
|
|
220
317
|
});
|
|
221
318
|
}
|
|
222
319
|
initTable() {
|
|
@@ -232,16 +329,19 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
232
329
|
});
|
|
233
330
|
}
|
|
234
331
|
handleRowClick(row) {
|
|
235
|
-
if (this.onRowClick) {
|
|
236
|
-
this.onRowClick(row);
|
|
332
|
+
if (this.onRowClick && !this.checkboxSelection) {
|
|
333
|
+
this.onRowClick(this.table, row);
|
|
334
|
+
}
|
|
335
|
+
if (this.enableRowSelectionOnClick && !this.checkboxSelection) {
|
|
336
|
+
this.selectedRowId = row.id;
|
|
337
|
+
}
|
|
338
|
+
if (this.checkboxSelection) {
|
|
339
|
+
row.toggleSelected();
|
|
237
340
|
}
|
|
238
|
-
if (!this.enableRowSelectionOnClick)
|
|
239
|
-
return;
|
|
240
|
-
this.selectedRowId = row.id;
|
|
241
341
|
}
|
|
242
342
|
handleRowDoubleClick(row) {
|
|
243
|
-
if (this.onRowDoubleClick) {
|
|
244
|
-
this.onRowDoubleClick(row);
|
|
343
|
+
if (this.onRowDoubleClick && !this.checkboxSelection) {
|
|
344
|
+
this.onRowDoubleClick(this.table, row);
|
|
245
345
|
}
|
|
246
346
|
}
|
|
247
347
|
getTanstackColumns(columns) {
|
|
@@ -257,10 +357,10 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
257
357
|
const isGrouped = props.row.getIsGrouped?.();
|
|
258
358
|
const isAggregated = props.row.getIsAggregated?.();
|
|
259
359
|
if (isGrouped) {
|
|
260
|
-
if (column.type === 'date') {
|
|
360
|
+
if (column.type === 'date' && !this.server) {
|
|
261
361
|
return formatDate(value, this.userLang || 'cs', undefined, this.dateFormat);
|
|
262
362
|
}
|
|
263
|
-
if (column.type === 'dateTime') {
|
|
363
|
+
if (column.type === 'dateTime' && !this.server) {
|
|
264
364
|
return formatDate(value, this.userLang || 'cs', true, this.dateFormat);
|
|
265
365
|
}
|
|
266
366
|
return value;
|
|
@@ -268,13 +368,20 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
268
368
|
if (isAggregated) {
|
|
269
369
|
return value;
|
|
270
370
|
}
|
|
271
|
-
if (column.type === 'date' && value) {
|
|
371
|
+
if (column.type === 'date' && value && !this.server) {
|
|
272
372
|
return formatDate(value, this.userLang || 'cs', undefined, this.dateFormat);
|
|
273
373
|
}
|
|
274
|
-
if (column.type === 'dateTime' && value) {
|
|
374
|
+
if (column.type === 'dateTime' && value && !this.server) {
|
|
275
375
|
return formatDate(value, this.userLang || 'cs', true, this.dateFormat);
|
|
276
376
|
}
|
|
277
|
-
|
|
377
|
+
if (column.type === 'actions') {
|
|
378
|
+
return html `
|
|
379
|
+
<lit-data-grid-row-actions
|
|
380
|
+
.buttons=${column.getActions?.(props) || []}
|
|
381
|
+
></lit-data-grid-row-actions>
|
|
382
|
+
`;
|
|
383
|
+
}
|
|
384
|
+
return column.cell ? column.cell(props, html, unsafeHTML) : value;
|
|
278
385
|
},
|
|
279
386
|
filterFn: (() => {
|
|
280
387
|
switch (column.type) {
|
|
@@ -303,16 +410,25 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
303
410
|
},
|
|
304
411
|
aggregationFn: column.columnAggregation ?? undefined,
|
|
305
412
|
enableGrouping: column.enableGrouping ?? true,
|
|
413
|
+
sortDescFirst: column.sortDescFirst || true,
|
|
414
|
+
enableResizing: column.enableResizing ?? true,
|
|
415
|
+
enablePinning: column.enablePinning ?? true,
|
|
306
416
|
};
|
|
307
417
|
});
|
|
308
418
|
}
|
|
309
419
|
getCommonPinningStyles(column) {
|
|
310
420
|
const isPinned = column.getIsPinned();
|
|
421
|
+
if (!isPinned) {
|
|
422
|
+
return {};
|
|
423
|
+
}
|
|
311
424
|
const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
|
|
312
425
|
return {
|
|
313
426
|
position: isPinned ? 'sticky' : 'relative',
|
|
314
427
|
left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined,
|
|
315
|
-
|
|
428
|
+
right: isPinned === 'right' ? `0px` : undefined,
|
|
429
|
+
boxShadow: isLastLeftPinnedColumn && column.columnDef.type !== 'checkbox'
|
|
430
|
+
? '-4px 0 4px -4px gray inset'
|
|
431
|
+
: undefined,
|
|
316
432
|
zIndex: `${isPinned ? 1 : 'auto'}`,
|
|
317
433
|
background: isPinned ? 'var(--background-paper, #fff)' : undefined,
|
|
318
434
|
};
|
|
@@ -460,13 +576,49 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
460
576
|
this.onRowsScrollEnd();
|
|
461
577
|
}
|
|
462
578
|
}
|
|
579
|
+
handleGetTotalNumber() {
|
|
580
|
+
if (this.getTotalNumberFn) {
|
|
581
|
+
this.getTotalNumberFn();
|
|
582
|
+
}
|
|
583
|
+
}
|
|
463
584
|
render() {
|
|
585
|
+
const checkboxColumn = this.checkboxSelection
|
|
586
|
+
? [
|
|
587
|
+
{
|
|
588
|
+
id: 'checkbox',
|
|
589
|
+
type: 'checkbox',
|
|
590
|
+
minSize: 30,
|
|
591
|
+
size: 30,
|
|
592
|
+
enablePinning: false,
|
|
593
|
+
enableResizing: false,
|
|
594
|
+
header: ({ table }) => html `
|
|
595
|
+
<div style="position: absolute; left: 0; bottom: 0; margin: 0.65rem 0;">
|
|
596
|
+
<lit-checkbox
|
|
597
|
+
type="checkbox"
|
|
598
|
+
.onChange="${table.getToggleAllRowsSelectedHandler()}"
|
|
599
|
+
.checked="${table.getIsAllRowsSelected()}"
|
|
600
|
+
.indeterminate="${table.getIsSomeRowsSelected()}"
|
|
601
|
+
></lit-checkbox>
|
|
602
|
+
</div>
|
|
603
|
+
`,
|
|
604
|
+
cell: ({ row }) => html `
|
|
605
|
+
<lit-checkbox
|
|
606
|
+
type="checkbox"
|
|
607
|
+
.onChange="${row.getToggleSelectedHandler()}"
|
|
608
|
+
.checked="${row.getIsSelected()}"
|
|
609
|
+
?disabled="${!row.getCanSelect()}"
|
|
610
|
+
.indeterminate="${row.getIsSomeSelected()}"
|
|
611
|
+
></lit-checkbox>
|
|
612
|
+
`,
|
|
613
|
+
},
|
|
614
|
+
]
|
|
615
|
+
: [];
|
|
464
616
|
if (getLocale() !== this.userLang) {
|
|
465
617
|
setLocale(this.userLang || 'cs');
|
|
466
618
|
}
|
|
467
619
|
this.table = this.tableController.table({
|
|
468
620
|
data: this.rows || [],
|
|
469
|
-
columns: this.getTanstackColumns(this.getColumns),
|
|
621
|
+
columns: [...checkboxColumn, ...this.getTanstackColumns(this.getColumns)],
|
|
470
622
|
columnResizeMode: 'onChange',
|
|
471
623
|
columnResizeDirection: 'ltr',
|
|
472
624
|
defaultColumn: {
|
|
@@ -480,22 +632,26 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
480
632
|
grouping: [...(this.initialGroups || [])],
|
|
481
633
|
columnVisibility: { ...this.initialColumnVisibility },
|
|
482
634
|
columnPinning: {
|
|
483
|
-
left: [...(this.leftPinnedColumns || [])],
|
|
484
|
-
right: [
|
|
635
|
+
left: [...(this.leftPinnedColumns || []), 'checkbox'],
|
|
636
|
+
right: ['actions'],
|
|
485
637
|
},
|
|
486
638
|
},
|
|
487
639
|
state: {
|
|
488
640
|
columnFilters: this.filters,
|
|
489
641
|
sorting: this.sorting,
|
|
642
|
+
rowSelection: this._rowSelection,
|
|
643
|
+
columnSizing: this._columnSizing,
|
|
490
644
|
},
|
|
491
645
|
filterFns: {
|
|
492
646
|
dateFilterFn: dateFilterFn,
|
|
493
647
|
multiselectFilterFn: multiselectFilterFn,
|
|
494
648
|
},
|
|
495
649
|
// debugTable: true,
|
|
650
|
+
enableRowSelection: this.checkboxSelection,
|
|
496
651
|
enableColumnPinning: this.enableColumnPinning,
|
|
497
652
|
enableGrouping: this.enableGrouping,
|
|
498
653
|
manualFiltering: this.server,
|
|
654
|
+
manualSorting: this.server,
|
|
499
655
|
getRowId: (row, index) => index.toString(),
|
|
500
656
|
// groupedColumnMode: 'reorder',
|
|
501
657
|
getCoreRowModel: getCoreRowModel(),
|
|
@@ -506,21 +662,49 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
506
662
|
getExpandedRowModel: getExpandedRowModel(),
|
|
507
663
|
getFacetedUniqueValues: getFacetedUniqueValues(),
|
|
508
664
|
onColumnFiltersChange: (updaterOrValue) => {
|
|
665
|
+
this.currentScrollTop = 0;
|
|
666
|
+
const scrollElement = this.tableContainerRef.value;
|
|
667
|
+
if (scrollElement) {
|
|
668
|
+
scrollElement.scrollTop = 0;
|
|
669
|
+
}
|
|
509
670
|
const filtersState = typeof updaterOrValue === 'function'
|
|
510
671
|
? updaterOrValue(this.table.getState().columnFilters)
|
|
511
672
|
: updaterOrValue;
|
|
512
673
|
this.filters = filtersState;
|
|
513
674
|
if (this.onColumnFiltersChanged) {
|
|
514
|
-
this.onColumnFiltersChanged(filtersState);
|
|
675
|
+
this.onColumnFiltersChanged(this.table, filtersState);
|
|
515
676
|
}
|
|
516
677
|
},
|
|
517
678
|
onSortingChange: (updaterOrValue) => {
|
|
679
|
+
this.currentScrollTop = 0;
|
|
680
|
+
const scrollElement = this.tableContainerRef.value;
|
|
681
|
+
if (scrollElement) {
|
|
682
|
+
scrollElement.scrollTop = 0;
|
|
683
|
+
}
|
|
518
684
|
const sortingState = typeof updaterOrValue === 'function'
|
|
519
685
|
? updaterOrValue(this.table.getState().sorting)
|
|
520
686
|
: updaterOrValue;
|
|
521
687
|
this.sorting = sortingState;
|
|
522
688
|
if (this.onColumnSortChanged) {
|
|
523
|
-
this.onColumnSortChanged(sortingState);
|
|
689
|
+
this.onColumnSortChanged(this.table, sortingState);
|
|
690
|
+
}
|
|
691
|
+
},
|
|
692
|
+
onRowSelectionChange: (updaterOrValue) => {
|
|
693
|
+
const rowSelection = typeof updaterOrValue === 'function'
|
|
694
|
+
? updaterOrValue(this._rowSelection)
|
|
695
|
+
: updaterOrValue;
|
|
696
|
+
this._rowSelection = rowSelection;
|
|
697
|
+
if (this.onRowSelectionChanged) {
|
|
698
|
+
this.onRowSelectionChanged(this.table, rowSelection);
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
onColumnSizingChange: (updaterOrValue) => {
|
|
702
|
+
const columnSizingState = typeof updaterOrValue === 'function'
|
|
703
|
+
? updaterOrValue(this.table.getState().columnSizing)
|
|
704
|
+
: updaterOrValue;
|
|
705
|
+
this._columnSizing = columnSizingState;
|
|
706
|
+
if (this.onColumnResize) {
|
|
707
|
+
this.onColumnResize(this.table, columnSizingState);
|
|
524
708
|
}
|
|
525
709
|
},
|
|
526
710
|
});
|
|
@@ -535,7 +719,6 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
535
719
|
const virtualColumns = columnVirtualizer?.getVirtualItems() ?? [];
|
|
536
720
|
// Get table rows (either virtualized or all)
|
|
537
721
|
const { rows } = this.table.getRowModel();
|
|
538
|
-
// console.log('rows', rows);
|
|
539
722
|
const rowItems = rowVirtualizer
|
|
540
723
|
? rowVirtualizer.getVirtualItems()
|
|
541
724
|
: rows.map((_, index) => ({
|
|
@@ -546,7 +729,6 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
546
729
|
size: this.rowHeight,
|
|
547
730
|
lane: 0,
|
|
548
731
|
}));
|
|
549
|
-
// console.log('rowItems', rowItems);
|
|
550
732
|
// Calculate padding for virtualization
|
|
551
733
|
let virtualPaddingLeft;
|
|
552
734
|
let virtualPaddingRight;
|
|
@@ -610,6 +792,9 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
610
792
|
${repeat(newHeaderColumns, (header) => header.id, (header, index) => {
|
|
611
793
|
const column = header.column;
|
|
612
794
|
const style = {
|
|
795
|
+
visibility: column.columnDef.type === 'actions'
|
|
796
|
+
? 'hidden'
|
|
797
|
+
: 'visible',
|
|
613
798
|
...this.getCommonPinningStyles(header.column),
|
|
614
799
|
width: `${column.getSize()}px`,
|
|
615
800
|
flexGrow: `${column.columnDef.size === undefined ? 1 : 'unset'}`,
|
|
@@ -660,10 +845,10 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
660
845
|
.columnDef
|
|
661
846
|
.header}"
|
|
662
847
|
>
|
|
663
|
-
${header
|
|
848
|
+
${flexRender(header
|
|
664
849
|
.column
|
|
665
850
|
.columnDef
|
|
666
|
-
.header}
|
|
851
|
+
.header, header.getContext())}
|
|
667
852
|
</lit-overflow-tooltip>
|
|
668
853
|
</div>
|
|
669
854
|
|
|
@@ -695,40 +880,39 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
695
880
|
? html `
|
|
696
881
|
${header.column.getCanPin()
|
|
697
882
|
? html `
|
|
698
|
-
<lit-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
883
|
+
<lit-icon-button
|
|
884
|
+
@click="${() => this.togglePin(header)}"
|
|
885
|
+
size="small"
|
|
886
|
+
variant="text"
|
|
887
|
+
icon="pin"
|
|
888
|
+
.active="${header.column.getIsPinned()}"
|
|
703
889
|
>
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
</lit-icon-button>
|
|
712
|
-
</lit-tooltip>
|
|
890
|
+
</lit-icon-button>
|
|
891
|
+
<simple-tooltip
|
|
892
|
+
placement="bottom"
|
|
893
|
+
>${header.column.getIsPinned()
|
|
894
|
+
? msg('Zrušit připnutí sloupce')
|
|
895
|
+
: msg('Připnout sloupec vlevo')}
|
|
896
|
+
</simple-tooltip>
|
|
713
897
|
`
|
|
714
898
|
: ''}
|
|
715
899
|
${header.column.getCanGroup()
|
|
716
900
|
? html `
|
|
717
|
-
<lit-
|
|
718
|
-
|
|
901
|
+
<lit-icon-button
|
|
902
|
+
@click="${header.column.getToggleGroupingHandler()}"
|
|
903
|
+
size="small"
|
|
904
|
+
variant="text"
|
|
905
|
+
.active="${header.column.getIsGrouped()}"
|
|
906
|
+
icon="agregation"
|
|
907
|
+
>
|
|
908
|
+
</lit-icon-button>
|
|
909
|
+
<simple-tooltip
|
|
910
|
+
placement="bottom"
|
|
911
|
+
>
|
|
912
|
+
${header.column.getIsGrouped()
|
|
719
913
|
? msg('Zrušit seskupení')
|
|
720
|
-
: msg('Seskupit sloupec')}
|
|
721
|
-
variant="bottom"
|
|
914
|
+
: msg('Seskupit sloupec')}</simple-tooltip
|
|
722
915
|
>
|
|
723
|
-
<lit-icon-button
|
|
724
|
-
@click="${header.column.getToggleGroupingHandler()}"
|
|
725
|
-
size="small"
|
|
726
|
-
variant="text"
|
|
727
|
-
.active="${header.column.getIsGrouped()}"
|
|
728
|
-
icon="agregation"
|
|
729
|
-
>
|
|
730
|
-
</lit-icon-button>
|
|
731
|
-
</lit-tooltip>
|
|
732
916
|
`
|
|
733
917
|
: ''}
|
|
734
918
|
`
|
|
@@ -754,6 +938,8 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
754
938
|
.dateFormat}
|
|
755
939
|
.userLang=${this
|
|
756
940
|
.userLang}
|
|
941
|
+
@filter-tab=${this
|
|
942
|
+
.handleFilterTabNavigation}
|
|
757
943
|
></filter-inputs>
|
|
758
944
|
</div>
|
|
759
945
|
`
|
|
@@ -809,7 +995,6 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
809
995
|
? repeat(rowItems, (item) => item.key, (item) => {
|
|
810
996
|
const row = rows[item.index];
|
|
811
997
|
const visibleCells = row?.getVisibleCells();
|
|
812
|
-
// console.log('visibleCells', visibleCells);
|
|
813
998
|
const bodyColumns = this.enableColumnVirtualization
|
|
814
999
|
? virtualColumns?.map((vc) => visibleCells && visibleCells[vc.index])
|
|
815
1000
|
: visibleCells;
|
|
@@ -828,7 +1013,8 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
828
1013
|
return row
|
|
829
1014
|
? html `
|
|
830
1015
|
<tr
|
|
831
|
-
class="${this.selectedRowId === row.id
|
|
1016
|
+
class="${this.selectedRowId === row.id ||
|
|
1017
|
+
this._rowSelection[row.id]
|
|
832
1018
|
? 'selected body'
|
|
833
1019
|
: 'body'}"
|
|
834
1020
|
data-index="${item.index}"
|
|
@@ -861,6 +1047,12 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
861
1047
|
flexGrow: `${column.columnDef.size === undefined ? 1 : 'unset'}`,
|
|
862
1048
|
background: this.getCellBackgroundColor(cell),
|
|
863
1049
|
lineHeight: `${this.rowHeight}px`,
|
|
1050
|
+
padding: column.columnDef.type ===
|
|
1051
|
+
'actions' ||
|
|
1052
|
+
column.columnDef.type ===
|
|
1053
|
+
'checkbox'
|
|
1054
|
+
? '0'
|
|
1055
|
+
: '0px 14px',
|
|
864
1056
|
};
|
|
865
1057
|
return html `
|
|
866
1058
|
<td style="${styleMap(style)}">
|
|
@@ -916,9 +1108,17 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
916
1108
|
`
|
|
917
1109
|
: cell.getIsPlaceholder()
|
|
918
1110
|
? null
|
|
919
|
-
:
|
|
1111
|
+
: html `<lit-overflow-tooltip
|
|
1112
|
+
placement="right"
|
|
1113
|
+
label=${flexRender(cell
|
|
1114
|
+
.column
|
|
920
1115
|
.columnDef
|
|
921
1116
|
.cell, cell.getContext())}
|
|
1117
|
+
>${flexRender(cell
|
|
1118
|
+
.column
|
|
1119
|
+
.columnDef
|
|
1120
|
+
.cell, cell.getContext())}</lit-overflow-tooltip
|
|
1121
|
+
>`}
|
|
922
1122
|
</td>
|
|
923
1123
|
`;
|
|
924
1124
|
})}
|
|
@@ -937,9 +1137,20 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
937
1137
|
</tbody>
|
|
938
1138
|
</table>
|
|
939
1139
|
<div class="footer-container">
|
|
940
|
-
<
|
|
1140
|
+
<div class="numberCount">
|
|
941
1141
|
${msg('Počet záznamů')}: ${this.table.getRowModel().rows.length}
|
|
942
|
-
|
|
1142
|
+
<pre>/</pre>
|
|
1143
|
+
${this.server
|
|
1144
|
+
? this.totalNumberRows
|
|
1145
|
+
? this.totalNumberRows
|
|
1146
|
+
: html ` ?<lit-icon-button
|
|
1147
|
+
icon="reload"
|
|
1148
|
+
size="small"
|
|
1149
|
+
variant="text"
|
|
1150
|
+
@click="${() => this.handleGetTotalNumber()}"
|
|
1151
|
+
></lit-icon-button>`
|
|
1152
|
+
: this.table.getRowModel().rows.length}
|
|
1153
|
+
</div>
|
|
943
1154
|
<div class="right-actions">
|
|
944
1155
|
<lit-data-grid-density-popover
|
|
945
1156
|
.density="${this.rowDensity}"
|
|
@@ -956,8 +1167,12 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
|
|
|
956
1167
|
${this.exportData
|
|
957
1168
|
? html `
|
|
958
1169
|
<lit-data-grid-export-popover
|
|
959
|
-
.exportToCsv="${
|
|
960
|
-
|
|
1170
|
+
.exportToCsv="${typeof this.exportExcelFn === 'function'
|
|
1171
|
+
? () => this.exportCsvFn && this.exportCsvFn()
|
|
1172
|
+
: () => this.exportDataToCsv()}"
|
|
1173
|
+
.exportToExcel="${typeof this.exportExcelFn === 'function'
|
|
1174
|
+
? () => this.exportExcelFn && this.exportExcelFn()
|
|
1175
|
+
: () => this.exportDataToExcel()}"
|
|
961
1176
|
.disabledButtons="${this.isLoading}"
|
|
962
1177
|
>
|
|
963
1178
|
</lit-data-grid-export-popover>
|
|
@@ -1057,6 +1272,7 @@ LitDataGridTanstack.styles = [
|
|
|
1057
1272
|
width: 100%;
|
|
1058
1273
|
border-bottom: 1px solid var(--color-divider, #d0d3db);
|
|
1059
1274
|
display: flex;
|
|
1275
|
+
overflow: visible;
|
|
1060
1276
|
}
|
|
1061
1277
|
|
|
1062
1278
|
tr.body:hover {
|
|
@@ -1070,7 +1286,7 @@ LitDataGridTanstack.styles = [
|
|
|
1070
1286
|
overflow: hidden;
|
|
1071
1287
|
padding: 0px 14px;
|
|
1072
1288
|
font-weight: 500;
|
|
1073
|
-
font-size:
|
|
1289
|
+
font-size: 12px;
|
|
1074
1290
|
color: var(--text-primary, #111827);
|
|
1075
1291
|
}
|
|
1076
1292
|
|
|
@@ -1172,6 +1388,8 @@ LitDataGridTanstack.styles = [
|
|
|
1172
1388
|
font-size: 12px;
|
|
1173
1389
|
font-weight: 400;
|
|
1174
1390
|
color: var(--text-primary, #111827);
|
|
1391
|
+
display: flex;
|
|
1392
|
+
align-items: center;
|
|
1175
1393
|
}
|
|
1176
1394
|
|
|
1177
1395
|
.scroll-button {
|
|
@@ -1246,6 +1464,9 @@ __decorate([
|
|
|
1246
1464
|
__decorate([
|
|
1247
1465
|
property({ type: Object })
|
|
1248
1466
|
], LitDataGridTanstack.prototype, "initialColumnVisibility", void 0);
|
|
1467
|
+
__decorate([
|
|
1468
|
+
property({ type: Object })
|
|
1469
|
+
], LitDataGridTanstack.prototype, "columnSizing", void 0);
|
|
1249
1470
|
__decorate([
|
|
1250
1471
|
property({ type: String })
|
|
1251
1472
|
], LitDataGridTanstack.prototype, "requestUrl", void 0);
|
|
@@ -1276,6 +1497,27 @@ __decorate([
|
|
|
1276
1497
|
__decorate([
|
|
1277
1498
|
property({ type: Function })
|
|
1278
1499
|
], LitDataGridTanstack.prototype, "onRowDoubleClick", void 0);
|
|
1500
|
+
__decorate([
|
|
1501
|
+
property({ type: Function })
|
|
1502
|
+
], LitDataGridTanstack.prototype, "rowDensityChange", void 0);
|
|
1503
|
+
__decorate([
|
|
1504
|
+
property({ type: Function })
|
|
1505
|
+
], LitDataGridTanstack.prototype, "onColumnResize", void 0);
|
|
1506
|
+
__decorate([
|
|
1507
|
+
property({ type: Boolean })
|
|
1508
|
+
], LitDataGridTanstack.prototype, "onColumnFiltersChanged", void 0);
|
|
1509
|
+
__decorate([
|
|
1510
|
+
property({ type: Boolean })
|
|
1511
|
+
], LitDataGridTanstack.prototype, "onColumnSortChanged", void 0);
|
|
1512
|
+
__decorate([
|
|
1513
|
+
property({ type: Function })
|
|
1514
|
+
], LitDataGridTanstack.prototype, "onRowSelectionChanged", void 0);
|
|
1515
|
+
__decorate([
|
|
1516
|
+
property({ type: Function })
|
|
1517
|
+
], LitDataGridTanstack.prototype, "exportExcelFn", void 0);
|
|
1518
|
+
__decorate([
|
|
1519
|
+
property({ type: Function })
|
|
1520
|
+
], LitDataGridTanstack.prototype, "exportCsvFn", void 0);
|
|
1279
1521
|
__decorate([
|
|
1280
1522
|
property({ type: Boolean })
|
|
1281
1523
|
], LitDataGridTanstack.prototype, "enableRowSelectionOnClick", void 0);
|
|
@@ -1285,18 +1527,21 @@ __decorate([
|
|
|
1285
1527
|
__decorate([
|
|
1286
1528
|
property({ type: Boolean })
|
|
1287
1529
|
], LitDataGridTanstack.prototype, "server", void 0);
|
|
1288
|
-
__decorate([
|
|
1289
|
-
property({ type: Boolean })
|
|
1290
|
-
], LitDataGridTanstack.prototype, "onColumnFiltersChanged", void 0);
|
|
1291
|
-
__decorate([
|
|
1292
|
-
property({ type: Boolean })
|
|
1293
|
-
], LitDataGridTanstack.prototype, "onColumnSortChanged", void 0);
|
|
1294
1530
|
__decorate([
|
|
1295
1531
|
property({ type: Number })
|
|
1296
1532
|
], LitDataGridTanstack.prototype, "scrollEndThreshold", void 0);
|
|
1297
1533
|
__decorate([
|
|
1298
1534
|
property({ type: String })
|
|
1299
1535
|
], LitDataGridTanstack.prototype, "rowDensity", void 0);
|
|
1536
|
+
__decorate([
|
|
1537
|
+
property({ type: Boolean })
|
|
1538
|
+
], LitDataGridTanstack.prototype, "checkboxSelection", void 0);
|
|
1539
|
+
__decorate([
|
|
1540
|
+
property({ type: Function })
|
|
1541
|
+
], LitDataGridTanstack.prototype, "getTotalNumberFn", void 0);
|
|
1542
|
+
__decorate([
|
|
1543
|
+
property({ type: Number })
|
|
1544
|
+
], LitDataGridTanstack.prototype, "totalNumberRows", void 0);
|
|
1300
1545
|
__decorate([
|
|
1301
1546
|
state()
|
|
1302
1547
|
], LitDataGridTanstack.prototype, "rowsCount", void 0);
|
|
@@ -1324,6 +1569,12 @@ __decorate([
|
|
|
1324
1569
|
__decorate([
|
|
1325
1570
|
state()
|
|
1326
1571
|
], LitDataGridTanstack.prototype, "rowHeight", void 0);
|
|
1572
|
+
__decorate([
|
|
1573
|
+
state()
|
|
1574
|
+
], LitDataGridTanstack.prototype, "_rowSelection", void 0);
|
|
1575
|
+
__decorate([
|
|
1576
|
+
state()
|
|
1577
|
+
], LitDataGridTanstack.prototype, "_columnSizing", void 0);
|
|
1327
1578
|
LitDataGridTanstack = __decorate([
|
|
1328
1579
|
customElement('lit-data-grid-tanstack')
|
|
1329
1580
|
], LitDataGridTanstack);
|