overview-components 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/assets/icons/iconGlyphs.d.ts +875 -0
  2. package/dist/assets/icons/iconGlyphs.d.ts.map +1 -0
  3. package/dist/assets/icons/iconGlyphs.js +663 -0
  4. package/dist/assets/icons/iconGlyphs.js.map +1 -0
  5. package/dist/assets/ilustration/not-found.d.ts +5 -0
  6. package/dist/assets/ilustration/not-found.d.ts.map +1 -0
  7. package/dist/assets/ilustration/not-found.js +103 -0
  8. package/dist/assets/ilustration/not-found.js.map +1 -0
  9. package/dist/components/custom-filters.d.ts +2 -0
  10. package/dist/components/custom-filters.d.ts.map +1 -0
  11. package/dist/components/custom-filters.js +19 -0
  12. package/dist/components/custom-filters.js.map +1 -0
  13. package/dist/components/lit-case-variables-tab.d.ts +77 -0
  14. package/dist/components/lit-case-variables-tab.d.ts.map +1 -0
  15. package/dist/components/lit-case-variables-tab.js +298 -0
  16. package/dist/components/lit-case-variables-tab.js.map +1 -0
  17. package/dist/components/lit-data-grid-tanstack.d.ts +110 -0
  18. package/dist/components/lit-data-grid-tanstack.d.ts.map +1 -0
  19. package/dist/components/lit-data-grid-tanstack.js +1085 -0
  20. package/dist/components/lit-data-grid-tanstack.js.map +1 -0
  21. package/dist/components/react-wrappers/case-variables-tab.d.ts +3 -0
  22. package/dist/components/react-wrappers/case-variables-tab.d.ts.map +1 -0
  23. package/dist/components/react-wrappers/case-variables-tab.js +9 -0
  24. package/dist/components/react-wrappers/case-variables-tab.js.map +1 -0
  25. package/dist/components/react-wrappers/data-grid-tanstack.d.ts +3 -0
  26. package/dist/components/react-wrappers/data-grid-tanstack.d.ts.map +1 -0
  27. package/dist/components/react-wrappers/data-grid-tanstack.js +9 -0
  28. package/dist/components/react-wrappers/data-grid-tanstack.js.map +1 -0
  29. package/dist/data/translations.d.ts +2 -0
  30. package/dist/data/translations.d.ts.map +1 -0
  31. package/dist/data/translations.js +2763 -0
  32. package/dist/data/translations.js.map +1 -0
  33. package/dist/index.d.ts +5 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +7 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/shared/filter-inputs.d.ts +36 -0
  38. package/dist/shared/filter-inputs.d.ts.map +1 -0
  39. package/dist/shared/filter-inputs.js +442 -0
  40. package/dist/shared/filter-inputs.js.map +1 -0
  41. package/dist/shared/lit-button.d.ts +24 -0
  42. package/dist/shared/lit-button.d.ts.map +1 -0
  43. package/dist/shared/lit-button.js +113 -0
  44. package/dist/shared/lit-button.js.map +1 -0
  45. package/dist/shared/lit-custom-popper.d.ts +19 -0
  46. package/dist/shared/lit-custom-popper.d.ts.map +1 -0
  47. package/dist/shared/lit-custom-popper.js +117 -0
  48. package/dist/shared/lit-custom-popper.js.map +1 -0
  49. package/dist/shared/lit-data-grid-export-popover.d.ts +15 -0
  50. package/dist/shared/lit-data-grid-export-popover.d.ts.map +1 -0
  51. package/dist/shared/lit-data-grid-export-popover.js +95 -0
  52. package/dist/shared/lit-data-grid-export-popover.js.map +1 -0
  53. package/dist/shared/lit-icon-button.d.ts +18 -0
  54. package/dist/shared/lit-icon-button.d.ts.map +1 -0
  55. package/dist/shared/lit-icon-button.js +81 -0
  56. package/dist/shared/lit-icon-button.js.map +1 -0
  57. package/dist/shared/lit-icon.d.ts +17 -0
  58. package/dist/shared/lit-icon.d.ts.map +1 -0
  59. package/dist/shared/lit-icon.js +284 -0
  60. package/dist/shared/lit-icon.js.map +1 -0
  61. package/dist/shared/lit-pill.d.ts +13 -0
  62. package/dist/shared/lit-pill.d.ts.map +1 -0
  63. package/dist/shared/lit-pill.js +88 -0
  64. package/dist/shared/lit-pill.js.map +1 -0
  65. package/dist/shared/lit-responsive-button.d.ts +27 -0
  66. package/dist/shared/lit-responsive-button.d.ts.map +1 -0
  67. package/dist/shared/lit-responsive-button.js +94 -0
  68. package/dist/shared/lit-responsive-button.js.map +1 -0
  69. package/dist/shared/lit-select.d.ts +25 -0
  70. package/dist/shared/lit-select.d.ts.map +1 -0
  71. package/dist/shared/lit-select.js +177 -0
  72. package/dist/shared/lit-select.js.map +1 -0
  73. package/dist/shared/lit-tooltip.d.ts +20 -0
  74. package/dist/shared/lit-tooltip.d.ts.map +1 -0
  75. package/dist/shared/lit-tooltip.js +122 -0
  76. package/dist/shared/lit-tooltip.js.map +1 -0
  77. package/dist/shared/styles/button-shared-styles.d.ts +3 -0
  78. package/dist/shared/styles/button-shared-styles.d.ts.map +1 -0
  79. package/dist/shared/styles/button-shared-styles.js +66 -0
  80. package/dist/shared/styles/button-shared-styles.js.map +1 -0
  81. package/dist/styles.d.ts +3 -0
  82. package/dist/styles.d.ts.map +1 -0
  83. package/dist/styles.js +169 -0
  84. package/dist/styles.js.map +1 -0
  85. package/dist/utils/date.d.ts +2 -0
  86. package/dist/utils/date.d.ts.map +1 -0
  87. package/dist/utils/date.js +19 -0
  88. package/dist/utils/date.js.map +1 -0
  89. package/dist/utils/getOverviewValue.d.ts +5 -0
  90. package/dist/utils/getOverviewValue.d.ts.map +1 -0
  91. package/dist/utils/getOverviewValue.js +178 -0
  92. package/dist/utils/getOverviewValue.js.map +1 -0
  93. package/package.json +50 -0
@@ -0,0 +1,1085 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import * as XLSX from 'xlsx';
8
+ import { css, html, LitElement } from 'lit';
9
+ import { msg } from '@lit/localize';
10
+ import { customElement, property, state } from 'lit/decorators.js';
11
+ import { TableController, getCoreRowModel, flexRender, getSortedRowModel, getFilteredRowModel, getFacetedRowModel, getFacetedUniqueValues, getGroupedRowModel, getExpandedRowModel, filterFns, } from '@tanstack/lit-table';
12
+ import { repeat } from 'lit/directives/repeat.js';
13
+ import { VirtualizerController } from '@tanstack/lit-virtual';
14
+ import { createRef, ref } from 'lit/directives/ref.js';
15
+ import { styleMap } from 'lit/directives/style-map.js';
16
+ // components
17
+ import '../shared/filter-inputs.js';
18
+ import '../shared/lit-icon.js';
19
+ import '../shared/lit-icon-button.js';
20
+ import '../shared/lit-button.js';
21
+ import '../shared/lit-responsive-button.js';
22
+ import '../shared/lit-tooltip.js';
23
+ import '../shared/lit-data-grid-export-popover.js';
24
+ import '../assets/ilustration/not-found.js';
25
+ // utils
26
+ import { formatDate } from '../utils/date.js';
27
+ import { dateFilterFn } from './custom-filters';
28
+ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.row = [];
32
+ this.columns = [];
33
+ this.enableRowVirtualization = false;
34
+ this.enableColumnVirtualization = false;
35
+ this.enableColumnPinning = true;
36
+ this.enableGrouping = true;
37
+ this.exportData = true;
38
+ this.id = '';
39
+ this.initialSorting = [];
40
+ this.leftPinnedColumns = [];
41
+ this.rightPinnedColumns = [];
42
+ this.enableFiltering = true;
43
+ this.locale = 'cs-CZ';
44
+ this.tableController = new TableController(this);
45
+ this.tableContainerRef = createRef();
46
+ this.rowsCount = 0;
47
+ // @state() grouping: any = this.initialGroups;
48
+ this.isScrollable = false;
49
+ this.disableScrollLeft = true;
50
+ this.disableScrollRight = false;
51
+ this.isLoading = true;
52
+ this.scrollInterval = null;
53
+ this.getCellBackgroundColor = (cell) => {
54
+ if (cell.getIsGrouped()) {
55
+ return this.columnGroupedColor ?? `var(--color-primary-light, #f0fadf)`;
56
+ }
57
+ if (cell.getIsAggregated()) {
58
+ return this.rowAggregationColor ?? `var(--color-warning-light, #ffe1a8)`;
59
+ }
60
+ if (cell.getIsPlaceholder()) {
61
+ return `var(--background-default, #eff3f4)`;
62
+ }
63
+ if (cell.column.getIsPinned()) {
64
+ return `var(--background-paper, #fff)`;
65
+ }
66
+ return 'transparent';
67
+ };
68
+ this.updateScrollState = () => {
69
+ const grid = this.tableContainerRef.value;
70
+ if (grid) {
71
+ const canScrollHorizontally = grid.scrollWidth > grid.clientWidth;
72
+ this.isScrollable = canScrollHorizontally;
73
+ this.disableScrollLeft = grid.scrollLeft === 0;
74
+ this.disableScrollRight = grid.scrollLeft + grid.clientWidth >= grid.scrollWidth;
75
+ }
76
+ };
77
+ }
78
+ connectedCallback() {
79
+ this.table.setGrouping([...(this.initialGroups || [])]);
80
+ if (this.enableRowVirtualization && this.table) {
81
+ this.initializeVirtualizer();
82
+ }
83
+ if (this.enableColumnVirtualization) {
84
+ // Inicializácia columnVirtualizerController (stĺpcová virtualizácia)
85
+ this.columnVirtualizerController = new VirtualizerController(this, {
86
+ horizontal: true,
87
+ count: this.table.getVisibleLeafColumns().length,
88
+ getScrollElement: () => this.tableContainerRef.value,
89
+ estimateSize: (index) => this.table.getVisibleLeafColumns()[index].getSize(),
90
+ overscan: 5,
91
+ });
92
+ }
93
+ super.connectedCallback();
94
+ window.addEventListener('resize', this.updateScrollState);
95
+ }
96
+ disconnectedCallback() {
97
+ super.disconnectedCallback();
98
+ window.removeEventListener('resize', this.updateScrollState);
99
+ }
100
+ initializeVirtualizer() {
101
+ this.rowVirtualizerController = new VirtualizerController(this, {
102
+ count: this.table.getRowModel().rows.length, // number of rows
103
+ getScrollElement: () => this.tableContainerRef.value,
104
+ estimateSize: () => 38, // estimate row height for accurate scrollbar dragging
105
+ overscan: 5, // buffer to render more rows for smoother scrolling
106
+ });
107
+ }
108
+ updated(changedProperties) {
109
+ // console.log('changedProperties', changedProperties);
110
+ // Check if `table` has changed and update the virtualizer if needed
111
+ if (changedProperties.has('rowsCount')) {
112
+ if (this.enableRowVirtualization && this.table) {
113
+ this.initializeVirtualizer();
114
+ this.requestUpdate();
115
+ }
116
+ }
117
+ if (changedProperties.has('row')) {
118
+ this.isLoading = !(this.row && this.row.length > 0);
119
+ }
120
+ }
121
+ // format date by dynamic by locale props
122
+ formatDate(date, locale) {
123
+ return new Date(date).toLocaleDateString(locale, {
124
+ year: 'numeric',
125
+ month: '2-digit',
126
+ day: '2-digit',
127
+ });
128
+ }
129
+ getTanstackColumns(columns) {
130
+ return columns.map((column) => {
131
+ return {
132
+ id: column.field,
133
+ accessorKey: column.field,
134
+ accessorFn: column.accessorFn ?? ((originalRow) => originalRow[column.field]),
135
+ type: column.type,
136
+ header: column.headerName,
137
+ cell: (props) => column.cell
138
+ ? column.cell(props)
139
+ : column.type === 'date'
140
+ ? formatDate(props.getValue(), this.locale)
141
+ : props.getValue(),
142
+ filterFn: (() => {
143
+ switch (column.type) {
144
+ case 'range':
145
+ return filterFns.inNumberRange;
146
+ case 'select':
147
+ return filterFns.weakEquals;
148
+ case 'number':
149
+ return filterFns.weakEquals;
150
+ case 'date':
151
+ return dateFilterFn;
152
+ case 'string':
153
+ return filterFns.includesString;
154
+ default:
155
+ return filterFns.includesString;
156
+ }
157
+ })(),
158
+ enableColumnFilter: this.enableFiltering && (column.columnFilter ?? true),
159
+ size: column.size || this.columnDefaultSize || undefined,
160
+ maxSize: column.maxSize || this.columnDefaultMaxSize || 800,
161
+ minSize: column.minSize || this.columnDefaultMinSize || 50,
162
+ meta: {
163
+ filterVariant: column.type ?? 'string',
164
+ },
165
+ aggregationFn: column.columnAggregation ?? undefined,
166
+ enableGrouping: column.enableGrouping ?? true,
167
+ };
168
+ });
169
+ }
170
+ get table() {
171
+ return this.tableController.table({
172
+ data: this.row || [],
173
+ columns: this.getTanstackColumns(this.columns),
174
+ columnResizeMode: 'onChange',
175
+ columnResizeDirection: 'ltr',
176
+ defaultColumn: {
177
+ size: this.columnDefaultSize || 250, //starting column size
178
+ minSize: this.columnDefaultMinSize || 100, //enforced during column resizing
179
+ maxSize: this.columnDefaultMaxSize || 500, //enforced during column resizing
180
+ },
181
+ initialState: {
182
+ sorting: [...(this.initialSorting || [])],
183
+ columnVisibility: { ...this.initialColumnVisibility },
184
+ columnPinning: {
185
+ left: [...(this.leftPinnedColumns || [])],
186
+ right: [...(this.rightPinnedColumns || [])],
187
+ },
188
+ },
189
+ filterFns: {
190
+ dateFilterFn: dateFilterFn,
191
+ },
192
+ enableColumnPinning: this.enableColumnPinning,
193
+ enableGrouping: this.enableGrouping,
194
+ // groupedColumnMode: 'reorder',
195
+ getCoreRowModel: getCoreRowModel(),
196
+ getSortedRowModel: getSortedRowModel(),
197
+ getFilteredRowModel: getFilteredRowModel(),
198
+ getFacetedRowModel: getFacetedRowModel(),
199
+ getGroupedRowModel: getGroupedRowModel(),
200
+ getExpandedRowModel: getExpandedRowModel(),
201
+ getFacetedUniqueValues: getFacetedUniqueValues(),
202
+ });
203
+ }
204
+ getCommonPinningStyles(column) {
205
+ const isPinned = column.getIsPinned();
206
+ const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
207
+ return {
208
+ position: isPinned ? 'sticky' : 'relative',
209
+ left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined,
210
+ boxShadow: isLastLeftPinnedColumn ? '-4px 0 4px -4px gray inset' : undefined,
211
+ zIndex: isPinned ? 1 : 0,
212
+ background: isPinned ? 'var(--background-paper, #fff)' : undefined,
213
+ };
214
+ }
215
+ togglePin(header) {
216
+ if (header.column.getIsPinned()) {
217
+ header.column.pin(false); // Odpinovanie
218
+ }
219
+ else {
220
+ header.column.pin('left'); // Pripnutie doľava
221
+ }
222
+ }
223
+ exportDataToCsv() {
224
+ const rows = this.getAllRowsIncludingGrouped(this.table.getRowModel().rows); // Získanie všetkých riadkov vrátane skupín
225
+ if (!rows || rows.length === 0) {
226
+ console.warn('No data to export');
227
+ return;
228
+ }
229
+ // Generovanie hlavičky CSV zo stĺpcov
230
+ const header = this.columns
231
+ .map((col) => col.headerName || '') // Získanie názvov stĺpcov
232
+ .join(',');
233
+ // Generovanie dát pre CSV
234
+ const csvRows = rows.map((row) => {
235
+ return this.columns
236
+ .map((col) => {
237
+ const accessor = col.field; // Získanie kľúča pre hodnotu
238
+ if (row.getIsGrouped?.()) {
239
+ // Ak je skupinový riadok, pridaj počet záznamov do prvej bunky
240
+ if (col.field === row.groupingColumnId) {
241
+ return `"${row.getValue(col.field)} (${row.subRows.length})"`;
242
+ }
243
+ return ''; // Ostatné stĺpce v skupinovom riadku prázdne
244
+ }
245
+ const value = accessor ? row.original?.[accessor] || '' : ''; // Získanie hodnoty pre normálny riadok
246
+ return typeof value === 'string'
247
+ ? `"${value.replace(/"/g, '""')}"` // Ošetrenie dvojitých úvodzoviek
248
+ : value;
249
+ })
250
+ .join(',');
251
+ });
252
+ // Pridanie hlavičky na začiatok CSV
253
+ csvRows.unshift(header);
254
+ // Vytvorenie CSV súboru
255
+ const csvContent = csvRows.join('\n');
256
+ const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
257
+ // Stiahnutie CSV súboru
258
+ const url = URL.createObjectURL(blob);
259
+ const link = document.createElement('a');
260
+ link.href = url;
261
+ link.download = 'data.csv';
262
+ link.click();
263
+ URL.revokeObjectURL(url);
264
+ }
265
+ exportDataToExcel() {
266
+ const rows = this.getAllRowsIncludingGrouped(this.table.getRowModel().rows); // Získanie všetkých riadkov vrátane skupín
267
+ if (!rows || rows.length === 0) {
268
+ console.warn('No data to export');
269
+ return;
270
+ }
271
+ // Príprava dát pre Excel
272
+ const data = rows.map((row) => {
273
+ const formattedRow = {};
274
+ this.columns.forEach((col) => {
275
+ const columnName = col.headerName || ''; // Dynamický názov stĺpca
276
+ const accessor = col.field; // Dynamický kľúč pre hodnoty
277
+ if (row.getIsGrouped?.()) {
278
+ // Skupinový riadok
279
+ if (col.field === row.groupingColumnId) {
280
+ // Pridanie názvu skupiny a počtu záznamov
281
+ formattedRow[columnName] =
282
+ `${row.getValue(accessor)} (${row.subRows.length})`;
283
+ }
284
+ else {
285
+ // Ostatné stĺpce prázdne
286
+ formattedRow[columnName] = '';
287
+ }
288
+ }
289
+ else if (accessor) {
290
+ // Normálny riadok
291
+ formattedRow[columnName] =
292
+ row.original?.[accessor] || row.getValue?.(accessor) || '';
293
+ }
294
+ });
295
+ return formattedRow;
296
+ });
297
+ // Vytvorenie pracovného listu a zošita
298
+ const worksheet = XLSX.utils.json_to_sheet(data); // Konverzia dát do Excel formátu
299
+ // Automatické prispôsobenie šírky stĺpcov
300
+ const colWidths = this.columns.map((col, colIndex) => {
301
+ const maxContentLength = Math.max(col.headerName?.length || 10, // Dĺžka názvu stĺpca
302
+ ...data.map((row) => row[col.headerName || '']?.toString().length || 0));
303
+ return { wch: maxContentLength + 2 }; // Pridanie extra priestoru
304
+ });
305
+ worksheet['!cols'] = colWidths; // Nastavenie šírky stĺpcov
306
+ const workbook = XLSX.utils.book_new(); // Nový Excel zošit
307
+ XLSX.utils.book_append_sheet(workbook, worksheet, 'Data'); // Pridanie dát do zošita
308
+ // Export do súboru
309
+ XLSX.writeFile(workbook, 'data.xlsx');
310
+ }
311
+ getAllRowsIncludingGrouped(rows) {
312
+ const allRows = [];
313
+ rows.forEach((row) => {
314
+ if (row.getIsGrouped?.()) {
315
+ allRows.push(row);
316
+ if (row.subRows && row.subRows.length > 0) {
317
+ allRows.push(...this.getAllRowsIncludingGrouped(row.subRows));
318
+ }
319
+ }
320
+ else {
321
+ allRows.push(row);
322
+ }
323
+ });
324
+ return allRows.filter((row, index, self) => index === self.findIndex((r) => r.id === row.id));
325
+ }
326
+ firstUpdated() {
327
+ const grid = this.tableContainerRef.value;
328
+ if (grid) {
329
+ grid.addEventListener('scroll', this.updateScrollState);
330
+ }
331
+ this.updateScrollState();
332
+ }
333
+ startScroll(direction) {
334
+ const grid = this.tableContainerRef.value;
335
+ if (!grid)
336
+ return;
337
+ const scrollAmount = direction === 'left' ? -15 : 15;
338
+ const scroll = () => {
339
+ grid.scrollLeft += scrollAmount;
340
+ this.updateScrollState();
341
+ this.scrollInterval = requestAnimationFrame(scroll);
342
+ };
343
+ this.scrollInterval = requestAnimationFrame(scroll);
344
+ }
345
+ stopScroll() {
346
+ if (this.scrollInterval) {
347
+ cancelAnimationFrame(this.scrollInterval);
348
+ this.scrollInterval = null;
349
+ }
350
+ }
351
+ render() {
352
+ // Ak virtualizácia nie je povolená, použijeme celý zoznam riadkov alebo stĺpcov
353
+ const rowVirtualizer = this.enableRowVirtualization
354
+ ? this.rowVirtualizerController.getVirtualizer()
355
+ : null;
356
+ const columnVirtualizer = this.enableColumnVirtualization
357
+ ? this.columnVirtualizerController.getVirtualizer()
358
+ : null;
359
+ const virtualColumns = columnVirtualizer?.getVirtualItems() ?? [];
360
+ // Get table rows (either virtualized or all)
361
+ const { rows } = this.table.getRowModel();
362
+ // console.log('rows', rows);
363
+ const rowItems = rowVirtualizer
364
+ ? rowVirtualizer.getVirtualItems()
365
+ : rows.map((_, index) => ({
366
+ key: index,
367
+ index,
368
+ start: index * 38,
369
+ end: (index + 1) * 38,
370
+ size: 38,
371
+ lane: 0,
372
+ }));
373
+ // console.log('rowItems', rowItems);
374
+ // Calculate padding for virtualization
375
+ let virtualPaddingLeft;
376
+ let virtualPaddingRight;
377
+ this.rowsCount = this.table.getRowModel().rows.length;
378
+ if (columnVirtualizer && virtualColumns?.length && this.enableColumnVirtualization) {
379
+ virtualPaddingLeft = virtualColumns[0]?.start ?? 0;
380
+ virtualPaddingRight =
381
+ columnVirtualizer.getTotalSize() -
382
+ (virtualColumns[virtualColumns.length - 1]?.end ?? 0);
383
+ }
384
+ return html `
385
+ <div class="data-grid__wrapper">
386
+ ${this.isScrollable
387
+ ? html `
388
+ <lit-icon-button
389
+ class="scroll-button left"
390
+ .disabled="${this.disableScrollLeft}"
391
+ @pointerdown="${() => this.startScroll('left')}"
392
+ @pointerup="${this.stopScroll}"
393
+ @pointerleave="${this.stopScroll}"
394
+ size="small"
395
+ variant="contained"
396
+ icon="arrowLeft"
397
+ >
398
+ </lit-icon-button>
399
+ <lit-icon-button
400
+ class="scroll-button right"
401
+ .disabled="${this.disableScrollRight}"
402
+ @pointerdown="${() => this.startScroll('right')}"
403
+ @pointerup="${this.stopScroll}"
404
+ @pointerleave="${this.stopScroll}"
405
+ size="small"
406
+ variant="contained"
407
+ icon="arrowRight"
408
+ >
409
+ </lit-icon-button>
410
+ `
411
+ : null}
412
+ <div class="grid" ${ref(this.tableContainerRef)}>
413
+ <table style="width: ${this.table.getCenterTotalSize()}px">
414
+ <thead style="height: ${this.enableFiltering ? '4rem' : '1.625rem'};">
415
+ ${repeat(this.table.getHeaderGroups(), (headerGroup) => headerGroup.id, (headerGroup) => {
416
+ const headerColumns = this.enableColumnVirtualization
417
+ ? virtualColumns.map((vc) => headerGroup.headers[vc.index])
418
+ : headerGroup.headers;
419
+ const newHeaderColumns = this.enableColumnVirtualization
420
+ ? [
421
+ ...headerGroup.headers.filter((hc) => hc.column.getIsPinned()),
422
+ ...headerColumns.filter((hc) => !hc.column.getIsPinned()),
423
+ ]
424
+ : headerColumns;
425
+ return html `
426
+ <tr class="head" data-index="${headerGroup.id}">
427
+ ${virtualPaddingLeft
428
+ ? html `
429
+ <th
430
+ style=" display: flex; width: ${virtualPaddingLeft}px;"
431
+ ></th>
432
+ `
433
+ : ''}
434
+ ${repeat(newHeaderColumns, (header) => header.id, (header, index) => {
435
+ const column = header.column;
436
+ const style = {
437
+ ...this.getCommonPinningStyles(header.column),
438
+ width: `${column.getSize()}px`,
439
+ };
440
+ return html `
441
+ <th
442
+ class="head"
443
+ style="${styleMap(style)}"
444
+ colspan="${header.colSpan}"
445
+ data-index="${header.id}"
446
+ >
447
+ ${header.isPlaceholder
448
+ ? ''
449
+ : html `
450
+ <div
451
+ class="resizer ${this
452
+ .table.options
453
+ .columnResizeDirection} ${header.column.getIsResizing()
454
+ ? 'is-resizing'
455
+ : ''}"
456
+ @dblclick="${() => header.column.resetSize()}"
457
+ @mousedown="${header.getResizeHandler()}"
458
+ @touchstart="${header.getResizeHandler()}"
459
+ style="transform: ${this
460
+ .table.options
461
+ .columnResizeMode ===
462
+ 'onEnd' &&
463
+ header.column.getIsResizing()
464
+ ? `translateX(${(this.table
465
+ .options
466
+ .columnResizeDirection ===
467
+ 'rtl'
468
+ ? -1
469
+ : 1) *
470
+ (this.table.getState()
471
+ .columnSizingInfo
472
+ .deltaOffset ??
473
+ 0)}px)`
474
+ : ''}"
475
+ >
476
+ <div
477
+ style="display: flex; align-items: center; justify-content: space-between; height: 100%"
478
+ >
479
+ <div
480
+ class="column-header"
481
+ @click=${header.column.getToggleSortingHandler()}
482
+ >
483
+ ${header.column
484
+ .columnDef
485
+ .header}
486
+ ${header.column.getIsSorted()
487
+ ? header.column.getIsSorted() ===
488
+ 'asc'
489
+ ? html `<slot
490
+ name="iconSortUp"
491
+ ><lit-icon
492
+ size="0.75rem"
493
+ icon="chevronUpFilled"
494
+ ></lit-icon
495
+ ></slot>`
496
+ : html `<slot
497
+ name="iconSortDown"
498
+ >
499
+ <lit-icon
500
+ size="0.75rem"
501
+ icon="chevronDownFilled"
502
+ ></lit-icon>
503
+ </slot>`
504
+ : ''}
505
+ </div>
506
+ <span
507
+ style="display: flex"
508
+ >
509
+ ${header.column.getCanPin()
510
+ ? html `
511
+ <lit-tooltip
512
+ label="${header.column.getIsPinned()
513
+ ? msg('Zrušit připnutí sloupce')
514
+ : msg('Připnout sloupec vlevo')}"
515
+ variant="left"
516
+ >
517
+ <lit-icon-button
518
+ @click="${() => this.togglePin(header)}"
519
+ size="small"
520
+ variant="text"
521
+ icon="pin"
522
+ .active="${header.column.getIsPinned()}"
523
+ >
524
+ <!-- <slot
525
+ name="iconPin"
526
+ >
527
+ </slot> -->
528
+ </lit-icon-button>
529
+ </lit-tooltip>
530
+ `
531
+ : ''}
532
+ ${header.column.getCanGroup()
533
+ ? html `
534
+ <lit-tooltip
535
+ label="${header.column.getIsGrouped()
536
+ ? msg('Zrušit seskupení')
537
+ : msg('Seskupit sloupec')}"
538
+ variant="left"
539
+ >
540
+ <lit-icon-button
541
+ @click="${header.column.getToggleGroupingHandler()}"
542
+ size="small"
543
+ variant="text"
544
+ .active="${header.column.getIsGrouped()}"
545
+ icon="agregation"
546
+ >
547
+ <!-- <slot
548
+ name="iconGroup"
549
+ >G</slot
550
+ > -->
551
+ </lit-icon-button>
552
+ </lit-tooltip>
553
+ `
554
+ : ''}
555
+ </span>
556
+ </div>
557
+ </div>
558
+ ${header.column.getCanFilter()
559
+ ? html `
560
+ <div>
561
+ <filter-inputs
562
+ .column=${header.column}
563
+ ></filter-inputs>
564
+ </div>
565
+ `
566
+ : null}
567
+ `}
568
+ </th>
569
+ `;
570
+ })}
571
+ ${virtualPaddingRight
572
+ ? html `
573
+ <th
574
+ style=" display: flex; width: ${virtualPaddingRight}px;"
575
+ ></th>
576
+ `
577
+ : ''}
578
+ </tr>
579
+ `;
580
+ })}
581
+ </thead>
582
+ ${this.isLoading
583
+ ? html `
584
+ <div class="progress-root">
585
+ <div class="bar bar1Indeterminate"></div>
586
+ <div class="bar bar2Indeterminate"></div>
587
+ </div>
588
+ `
589
+ : ''}
590
+ <tbody
591
+ style="height: ${rowVirtualizer &&
592
+ this.table.getRowModel().rows.length > 0
593
+ ? rowVirtualizer.getTotalSize() + 'px'
594
+ : 'auto'};"
595
+ >
596
+ ${rows.length > 0
597
+ ? repeat(rowItems, (item) => item.key, (item) => {
598
+ const row = rows[item.index];
599
+ const visibleCells = row?.getVisibleCells();
600
+ // console.log('visibleCells', visibleCells);
601
+ const bodyColumns = this.enableColumnVirtualization
602
+ ? virtualColumns?.map((vc) => visibleCells && visibleCells[vc.index])
603
+ : visibleCells;
604
+ const pinnedColumns = visibleCells?.filter((bc) => bc.column.getIsPinned()) || [];
605
+ const newBodyColumns = this.enableColumnVirtualization
606
+ ? [...new Set([...pinnedColumns, ...bodyColumns])]
607
+ : bodyColumns;
608
+ const tbodyStyle = {
609
+ transform: rowVirtualizer
610
+ ? `translateY(${item.start}px)`
611
+ : 'none',
612
+ height: '38px',
613
+ lineHeight: '38px',
614
+ position: rowVirtualizer ? 'absolute' : 'relative',
615
+ };
616
+ return row
617
+ ? html `
618
+ <tr
619
+ class="body"
620
+ data-index="${item.index}"
621
+ style="${styleMap(tbodyStyle)}"
622
+ ${ref((node) => {
623
+ if (node &&
624
+ this.enableRowVirtualization &&
625
+ rowVirtualizer) {
626
+ // Only measure element if virtualization is enabled
627
+ rowVirtualizer.measureElement(node);
628
+ }
629
+ })}
630
+ >
631
+ ${virtualPaddingLeft
632
+ ? html `
633
+ <th
634
+ style=" display: flex; width: ${virtualPaddingLeft}px;"
635
+ ></th>
636
+ `
637
+ : ''}
638
+ <!-- Cells for each row -->
639
+ ${repeat(newBodyColumns, (cell) => cell.key, (cell) => {
640
+ const { column } = cell;
641
+ const style = {
642
+ ...this.getCommonPinningStyles(cell.column),
643
+ width: `${cell.column.getSize()}px`,
644
+ background: this.getCellBackgroundColor(cell),
645
+ lineHeight: '2.3125rem', // správny zápis reťazca
646
+ padding: '0px 0.75rem',
647
+ };
648
+ return html `
649
+ <td style="${styleMap(style)}">
650
+ ${cell.getIsGrouped()
651
+ ? html `
652
+ <lit-button
653
+ @click="${row.getToggleExpandedHandler()}"
654
+ variant="text"
655
+ count="${row
656
+ .subRows
657
+ .length}"
658
+ label="${flexRender(cell
659
+ .column
660
+ .columnDef
661
+ .cell, cell.getContext())}"
662
+ icon="${row.getIsExpanded()
663
+ ? 'chevronDownFilled'
664
+ : 'chevron'}"
665
+ >
666
+ <!-- ${row.getIsExpanded()
667
+ ? html `<slot
668
+ name="groupedIcon-expanded"
669
+ slot="start-icon"
670
+ ></slot>`
671
+ : html `<slot
672
+ name="groupedIcon"
673
+ slot="start-icon"
674
+ ></slot>`} -->
675
+ }
676
+ ${row.subRows
677
+ .length}
678
+ ${flexRender(cell
679
+ .column
680
+ .columnDef
681
+ .cell, cell.getContext())}
682
+ </lit-button>
683
+ `
684
+ : cell.getIsAggregated()
685
+ ? html `
686
+ <div
687
+ style="display: flex; flex-direction: row; align-items: center;"
688
+ >
689
+ ${flexRender(cell
690
+ .column
691
+ .columnDef
692
+ .aggregatedCell ??
693
+ cell
694
+ .column
695
+ .columnDef
696
+ .cell, cell.getContext())}
697
+ </div>
698
+ `
699
+ : cell.getIsPlaceholder()
700
+ ? null
701
+ : flexRender(cell.column
702
+ .columnDef
703
+ .cell, cell.getContext())}
704
+ </td>
705
+ `;
706
+ })}
707
+ ${virtualPaddingRight
708
+ ? html `
709
+ <th
710
+ style=" display: flex; width: ${virtualPaddingRight}px;"
711
+ ></th>
712
+ `
713
+ : ''}
714
+ </tr>
715
+ `
716
+ : null;
717
+ })
718
+ : null}
719
+ </tbody>
720
+ </table>
721
+ <div class="footer-container">
722
+ <span class="numberCount">
723
+ ${msg('Počet záznamů')}: ${this.table.getRowModel().rows.length}
724
+ </span>
725
+ <div class="right-actions">
726
+ <lit-responsive-button
727
+ size="small"
728
+ variant="text"
729
+ label=${msg('Přizpůsobit sloupce')}
730
+ icon="columns"
731
+ @click=${() => this.table.resetColumnSizing()}
732
+ ></lit-responsive-button>
733
+ ${this.exportData
734
+ ? html `
735
+ <lit-data-grid-export-popover
736
+ .exportToCsv="${() => this.exportDataToCsv()}"
737
+ .exportToExcel="${() => this.exportDataToExcel()}"
738
+ >
739
+ <slot slot="iconExcel" name="iconExcel"
740
+ ><lit-icon icon="csv"></lit-icon
741
+ ></slot>
742
+ <slot slot="iconCsv" name="iconCsv"
743
+ ><lit-icon icon="csv"></lit-icon
744
+ ></slot>
745
+ </lit-data-grid-export-popover>
746
+ `
747
+ : null}
748
+ </div>
749
+ </div>
750
+ </div>
751
+ ${this.table.getRowModel().rows.length < 1
752
+ ? html ` <div class="data-grid__empty">
753
+ <div style="max-height: 7.125rem; max-width: 7.125rem">
754
+ <not-found></not-found>
755
+ </div>
756
+ ${msg('Nic dalšího tu není')}
757
+ </div>`
758
+ : null}
759
+ </div>
760
+ `;
761
+ }
762
+ };
763
+ LitDataGridTanstack.styles = [
764
+ // styles,
765
+ css `
766
+ :host {
767
+ *,
768
+ *::before,
769
+ *::after {
770
+ margin: 0;
771
+ padding: 0;
772
+ box-sizing: border-box;
773
+ }
774
+
775
+ display: block;
776
+ font-family: 'Inter', sans-serif;
777
+ box-sizing: border-box;
778
+
779
+ table {
780
+ border-collapse: collapse;
781
+ border-spacing: 0;
782
+ width: 100%;
783
+ }
784
+ }
785
+
786
+ .data-grid__wrapper {
787
+ position: relative;
788
+ padding: var(--section-padding, 0.75rem 1rem);
789
+ border-radius: 0.75rem;
790
+ background-color: var(--background-paper, #fff);
791
+ }
792
+
793
+ .data-grid__empty {
794
+ position: absolute;
795
+ top: 30%;
796
+ left: 50%;
797
+ transform: translate(-50%, -50%);
798
+ font-size: 0.875rem;
799
+ text-align: center;
800
+ }
801
+
802
+ table {
803
+ height: calc(100% - 38px);
804
+ }
805
+
806
+ .grid {
807
+ overflow: auto;
808
+ position: relative;
809
+ height: 500px;
810
+ }
811
+
812
+ thead {
813
+ display: flex;
814
+ position: sticky;
815
+ top: 0;
816
+ z-index: 10;
817
+ background-color: var(--background-paper, #fff);
818
+ border-bottom: 1px solid var(--color-divider, #d0d3db);
819
+ }
820
+
821
+ tr.head {
822
+ display: flex;
823
+ width: 100%;
824
+ }
825
+
826
+ th.head {
827
+ display: block;
828
+ //flex-grow: 1;
829
+ position: relative;
830
+ padding: 0 0.375rem 0 0.125rem;
831
+ gap: 0.25rem;
832
+ }
833
+
834
+ tbody {
835
+ display: grid;
836
+ position: relative;
837
+ }
838
+
839
+ tr.body {
840
+ width: 100%;
841
+ border-bottom: 1px solid var(--color-divider, #d0d3db);
842
+ display: flex;
843
+ }
844
+
845
+ tr.body:hover {
846
+ cursor: pointer;
847
+ background-color: var(--background-default, #eff3f4);
848
+ }
849
+
850
+ td {
851
+ display: table-cell;
852
+ white-space: nowrap;
853
+ overflow: hidden;
854
+ padding: 0 0 0 0.75rem;
855
+ font-weight: 500;
856
+ font-size: 13px;
857
+ color: var(--text-primary, #111827);
858
+ }
859
+
860
+ .column-header {
861
+ font-size: 11px;
862
+ font-weight: 600;
863
+ color: var(--text-secondary, #5d6371);
864
+ cursor: pointer;
865
+ gap: 0.25rem;
866
+ display: flex;
867
+ justify-content: center;
868
+ align-items: center;
869
+ margin: 0 0.25rem;
870
+ }
871
+
872
+ .resizer {
873
+ height: 24px;
874
+ padding: 0 0 0 0.375rem;
875
+ text-align: start;
876
+ cursor: col-resize;
877
+ user-select: none;
878
+ touch-action: none;
879
+ }
880
+
881
+ .resizer.ltr {
882
+ right: 0;
883
+ }
884
+
885
+ .resizer.rtl {
886
+ left: 0;
887
+ }
888
+
889
+ .resizer.is-resizing {
890
+ opacity: 1;
891
+ }
892
+
893
+ .footer-container {
894
+ position: sticky;
895
+ left: 0;
896
+ bottom: 0;
897
+ background-color: var(--background-paper, #fff);
898
+ width: auto;
899
+ border-top: 1px solid var(--color-divider, #d0d3db);
900
+ height: 2.375rem;
901
+ display: flex;
902
+ flex-direction: row;
903
+ justify-content: space-between;
904
+ align-items: center;
905
+ padding: 0 16px;
906
+ z-index: 10;
907
+ }
908
+
909
+ .right-actions {
910
+ position: absolute;
911
+ right: 0;
912
+ display: flex;
913
+ }
914
+
915
+ .numberCount {
916
+ margin: 0.375rem 0;
917
+ font-size: 12px;
918
+ font-weight: 400;
919
+ color: var(--text-primary, #111827);
920
+ }
921
+
922
+ .scroll-button {
923
+ position: absolute;
924
+ top: 50%;
925
+ transform: translateY(-50%);
926
+ z-index: 1000;
927
+ cursor: pointer;
928
+ }
929
+
930
+ .scroll-button.left {
931
+ left: 3rem;
932
+ }
933
+
934
+ .scroll-button.right {
935
+ right: 3rem;
936
+ }
937
+
938
+ .progress-root {
939
+ position: sticky;
940
+ overflow: hidden;
941
+ display: block;
942
+ width: 100%;
943
+
944
+ height: 4px;
945
+ background-color: #e0e0e0; /* Podobná farba pozadia ako v MUI */
946
+ box-sizing: border-box;
947
+ }
948
+
949
+ .bar {
950
+ position: absolute;
951
+ height: 100%;
952
+ display: block;
953
+ background-color: #75b603; /* Podobná farba ako primary theme v MUI */
954
+ width: auto;
955
+ will-change: left, right;
956
+ box-sizing: border-box;
957
+ }
958
+
959
+ /* Prvá animovaná "vlna" */
960
+
961
+ .bar1Indeterminate {
962
+ animation: mui-indeterminate1 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
963
+ }
964
+
965
+ /* Druhá animovaná "vlna" (oneskorená) */
966
+
967
+ .bar2Indeterminate {
968
+ animation: mui-indeterminate2 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
969
+ animation-delay: 1.05s;
970
+ }
971
+
972
+ @keyframes mui-indeterminate1 {
973
+ 0% {
974
+ left: -35%;
975
+ right: 100%;
976
+ }
977
+ 60% {
978
+ left: 100%;
979
+ right: -90%;
980
+ }
981
+ 100% {
982
+ left: 100%;
983
+ right: -90%;
984
+ }
985
+ }
986
+
987
+ @keyframes mui-indeterminate2 {
988
+ 0% {
989
+ left: -200%;
990
+ right: 100%;
991
+ }
992
+ 60% {
993
+ left: 107%;
994
+ right: -8%;
995
+ }
996
+ 100% {
997
+ left: 107%;
998
+ right: -8%;
999
+ }
1000
+ }
1001
+ `,
1002
+ ];
1003
+ __decorate([
1004
+ property({ type: Array })
1005
+ ], LitDataGridTanstack.prototype, "row", void 0);
1006
+ __decorate([
1007
+ property({ type: Array })
1008
+ ], LitDataGridTanstack.prototype, "columns", void 0);
1009
+ __decorate([
1010
+ property({ type: Number })
1011
+ ], LitDataGridTanstack.prototype, "columnDefaultSize", void 0);
1012
+ __decorate([
1013
+ property({ type: Number })
1014
+ ], LitDataGridTanstack.prototype, "columnDefaultMinSize", void 0);
1015
+ __decorate([
1016
+ property({ type: Number })
1017
+ ], LitDataGridTanstack.prototype, "columnDefaultMaxSize", void 0);
1018
+ __decorate([
1019
+ property({ type: String })
1020
+ ], LitDataGridTanstack.prototype, "columnGroupedColor", void 0);
1021
+ __decorate([
1022
+ property({ type: String })
1023
+ ], LitDataGridTanstack.prototype, "rowAggregationColor", void 0);
1024
+ __decorate([
1025
+ property({ type: Boolean })
1026
+ ], LitDataGridTanstack.prototype, "enableRowVirtualization", void 0);
1027
+ __decorate([
1028
+ property({ type: Boolean })
1029
+ ], LitDataGridTanstack.prototype, "enableColumnVirtualization", void 0);
1030
+ __decorate([
1031
+ property({ type: Boolean })
1032
+ ], LitDataGridTanstack.prototype, "enableColumnPinning", void 0);
1033
+ __decorate([
1034
+ property({ type: Boolean })
1035
+ ], LitDataGridTanstack.prototype, "enableGrouping", void 0);
1036
+ __decorate([
1037
+ property({ type: Boolean })
1038
+ ], LitDataGridTanstack.prototype, "exportData", void 0);
1039
+ __decorate([
1040
+ property({ type: String })
1041
+ ], LitDataGridTanstack.prototype, "id", void 0);
1042
+ __decorate([
1043
+ property({ type: Array })
1044
+ ], LitDataGridTanstack.prototype, "initialGroups", void 0);
1045
+ __decorate([
1046
+ property({ type: Array })
1047
+ ], LitDataGridTanstack.prototype, "initialSorting", void 0);
1048
+ __decorate([
1049
+ property({ type: Object })
1050
+ ], LitDataGridTanstack.prototype, "initialColumnVisibility", void 0);
1051
+ __decorate([
1052
+ property({ type: String })
1053
+ ], LitDataGridTanstack.prototype, "requestUrl", void 0);
1054
+ __decorate([
1055
+ property({ type: Array })
1056
+ ], LitDataGridTanstack.prototype, "leftPinnedColumns", void 0);
1057
+ __decorate([
1058
+ property({ type: Array })
1059
+ ], LitDataGridTanstack.prototype, "rightPinnedColumns", void 0);
1060
+ __decorate([
1061
+ property({ type: Boolean })
1062
+ ], LitDataGridTanstack.prototype, "enableFiltering", void 0);
1063
+ __decorate([
1064
+ property({ type: String })
1065
+ ], LitDataGridTanstack.prototype, "locale", void 0);
1066
+ __decorate([
1067
+ state()
1068
+ ], LitDataGridTanstack.prototype, "rowsCount", void 0);
1069
+ __decorate([
1070
+ state()
1071
+ ], LitDataGridTanstack.prototype, "isScrollable", void 0);
1072
+ __decorate([
1073
+ state()
1074
+ ], LitDataGridTanstack.prototype, "disableScrollLeft", void 0);
1075
+ __decorate([
1076
+ state()
1077
+ ], LitDataGridTanstack.prototype, "disableScrollRight", void 0);
1078
+ __decorate([
1079
+ state()
1080
+ ], LitDataGridTanstack.prototype, "isLoading", void 0);
1081
+ LitDataGridTanstack = __decorate([
1082
+ customElement('lit-data-grid-tanstack')
1083
+ ], LitDataGridTanstack);
1084
+ export { LitDataGridTanstack };
1085
+ //# sourceMappingURL=lit-data-grid-tanstack.js.map