overview-components 0.9.0 → 1.0.1

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 (136) hide show
  1. package/dist/assets/generated/locales/de.d.ts +9 -0
  2. package/dist/assets/generated/locales/de.d.ts.map +1 -1
  3. package/dist/assets/generated/locales/de.js +9 -0
  4. package/dist/assets/generated/locales/de.js.map +1 -1
  5. package/dist/assets/generated/locales/en.d.ts +17 -8
  6. package/dist/assets/generated/locales/en.d.ts.map +1 -1
  7. package/dist/assets/generated/locales/en.js +18 -9
  8. package/dist/assets/generated/locales/en.js.map +1 -1
  9. package/dist/assets/generated/locales/pl.d.ts +9 -0
  10. package/dist/assets/generated/locales/pl.d.ts.map +1 -1
  11. package/dist/assets/generated/locales/pl.js +9 -0
  12. package/dist/assets/generated/locales/pl.js.map +1 -1
  13. package/dist/assets/generated/locales/sk.d.ts +9 -0
  14. package/dist/assets/generated/locales/sk.d.ts.map +1 -1
  15. package/dist/assets/generated/locales/sk.js +9 -0
  16. package/dist/assets/generated/locales/sk.js.map +1 -1
  17. package/dist/assets/ilustration/no-content.d.ts +6 -0
  18. package/dist/assets/ilustration/no-content.d.ts.map +1 -0
  19. package/dist/assets/ilustration/no-content.js +167 -0
  20. package/dist/assets/ilustration/no-content.js.map +1 -0
  21. package/dist/assets/ilustration/no-preview.d.ts +1 -0
  22. package/dist/assets/ilustration/no-preview.d.ts.map +1 -1
  23. package/dist/assets/ilustration/no-preview.js +116 -114
  24. package/dist/assets/ilustration/no-preview.js.map +1 -1
  25. package/dist/assets/ilustration/not-found.d.ts +1 -0
  26. package/dist/assets/ilustration/not-found.d.ts.map +1 -1
  27. package/dist/assets/ilustration/not-found.js +89 -86
  28. package/dist/assets/ilustration/not-found.js.map +1 -1
  29. package/dist/components/lit-attachments-tab.d.ts +29 -15
  30. package/dist/components/lit-attachments-tab.d.ts.map +1 -1
  31. package/dist/components/lit-attachments-tab.js +352 -318
  32. package/dist/components/lit-attachments-tab.js.map +1 -1
  33. package/dist/components/lit-case-variables-tab.d.ts +4 -23
  34. package/dist/components/lit-case-variables-tab.d.ts.map +1 -1
  35. package/dist/components/lit-case-variables-tab.js +148 -224
  36. package/dist/components/lit-case-variables-tab.js.map +1 -1
  37. package/dist/components/lit-chart.d.ts +46 -0
  38. package/dist/components/lit-chart.d.ts.map +1 -0
  39. package/dist/components/lit-chart.js +423 -0
  40. package/dist/components/lit-chart.js.map +1 -0
  41. package/dist/components/lit-data-grid-tanstack.d.ts +56 -7
  42. package/dist/components/lit-data-grid-tanstack.d.ts.map +1 -1
  43. package/dist/components/lit-data-grid-tanstack.js +748 -564
  44. package/dist/components/lit-data-grid-tanstack.js.map +1 -1
  45. package/dist/components/lit-section-tab.d.ts +22 -0
  46. package/dist/components/lit-section-tab.d.ts.map +1 -0
  47. package/dist/components/lit-section-tab.js +70 -0
  48. package/dist/components/lit-section-tab.js.map +1 -0
  49. package/dist/components/lit-tabs-overview.d.ts +33 -0
  50. package/dist/components/lit-tabs-overview.d.ts.map +1 -0
  51. package/dist/components/lit-tabs-overview.js +143 -0
  52. package/dist/components/lit-tabs-overview.js.map +1 -0
  53. package/dist/components/react-wrappers/chart.d.ts +3 -0
  54. package/dist/components/react-wrappers/chart.d.ts.map +1 -0
  55. package/dist/components/react-wrappers/chart.js +9 -0
  56. package/dist/components/react-wrappers/chart.js.map +1 -0
  57. package/dist/components/react-wrappers/section-tab.d.ts +3 -0
  58. package/dist/components/react-wrappers/section-tab.d.ts.map +1 -0
  59. package/dist/components/react-wrappers/section-tab.js +9 -0
  60. package/dist/components/react-wrappers/section-tab.js.map +1 -0
  61. package/dist/components/react-wrappers/tabs-overview.d.ts +3 -0
  62. package/dist/components/react-wrappers/tabs-overview.d.ts.map +1 -0
  63. package/dist/components/react-wrappers/tabs-overview.js +9 -0
  64. package/dist/components/react-wrappers/tabs-overview.js.map +1 -0
  65. package/dist/index.d.ts +4 -0
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +4 -0
  68. package/dist/index.js.map +1 -1
  69. package/dist/scripts/translate-locales.js +1 -0
  70. package/dist/scripts/translate-locales.js.map +1 -1
  71. package/dist/shared/filter-inputs.d.ts +14 -4
  72. package/dist/shared/filter-inputs.d.ts.map +1 -1
  73. package/dist/shared/filter-inputs.js +207 -51
  74. package/dist/shared/filter-inputs.js.map +1 -1
  75. package/dist/shared/lit-button.js +2 -2
  76. package/dist/shared/lit-case-variables-tab-cell.d.ts +58 -0
  77. package/dist/shared/lit-case-variables-tab-cell.d.ts.map +1 -0
  78. package/dist/shared/lit-case-variables-tab-cell.js +224 -0
  79. package/dist/shared/lit-case-variables-tab-cell.js.map +1 -0
  80. package/dist/shared/lit-custom-popper.d.ts.map +1 -1
  81. package/dist/shared/lit-custom-popper.js +31 -31
  82. package/dist/shared/lit-custom-popper.js.map +1 -1
  83. package/dist/shared/lit-data-grid-action-buttons-popover.d.ts +14 -5
  84. package/dist/shared/lit-data-grid-action-buttons-popover.d.ts.map +1 -1
  85. package/dist/shared/lit-data-grid-action-buttons-popover.js +197 -102
  86. package/dist/shared/lit-data-grid-action-buttons-popover.js.map +1 -1
  87. package/dist/shared/lit-data-grid-density-popover.d.ts +18 -0
  88. package/dist/shared/lit-data-grid-density-popover.d.ts.map +1 -0
  89. package/dist/shared/lit-data-grid-density-popover.js +102 -0
  90. package/dist/shared/lit-data-grid-density-popover.js.map +1 -0
  91. package/dist/shared/lit-data-grid-export-popover.d.ts +3 -0
  92. package/dist/shared/lit-data-grid-export-popover.d.ts.map +1 -1
  93. package/dist/shared/lit-data-grid-export-popover.js +41 -46
  94. package/dist/shared/lit-data-grid-export-popover.js.map +1 -1
  95. package/dist/shared/lit-loader.d.ts +7 -0
  96. package/dist/shared/lit-loader.d.ts.map +1 -0
  97. package/dist/shared/lit-loader.js +51 -0
  98. package/dist/shared/lit-loader.js.map +1 -0
  99. package/dist/shared/lit-loading-bar.d.ts +20 -0
  100. package/dist/shared/lit-loading-bar.d.ts.map +1 -0
  101. package/dist/shared/lit-loading-bar.js +92 -0
  102. package/dist/shared/lit-loading-bar.js.map +1 -0
  103. package/dist/shared/lit-menu-item.d.ts +24 -0
  104. package/dist/shared/lit-menu-item.d.ts.map +1 -0
  105. package/dist/shared/lit-menu-item.js +77 -0
  106. package/dist/shared/lit-menu-item.js.map +1 -0
  107. package/dist/shared/lit-menu.d.ts +6 -0
  108. package/dist/shared/lit-menu.d.ts.map +1 -0
  109. package/dist/shared/lit-menu.js +38 -0
  110. package/dist/shared/lit-menu.js.map +1 -0
  111. package/dist/shared/lit-overflow-tooltip.d.ts +16 -0
  112. package/dist/shared/lit-overflow-tooltip.d.ts.map +1 -0
  113. package/dist/shared/lit-overflow-tooltip.js +86 -0
  114. package/dist/shared/lit-overflow-tooltip.js.map +1 -0
  115. package/dist/shared/lit-select.d.ts +24 -3
  116. package/dist/shared/lit-select.d.ts.map +1 -1
  117. package/dist/shared/lit-select.js +234 -130
  118. package/dist/shared/lit-select.js.map +1 -1
  119. package/dist/shared/lit-tooltip.d.ts.map +1 -1
  120. package/dist/shared/lit-tooltip.js +4 -3
  121. package/dist/shared/lit-tooltip.js.map +1 -1
  122. package/dist/utils/custom-filters.d.ts +3 -0
  123. package/dist/utils/custom-filters.d.ts.map +1 -0
  124. package/dist/{components → utils}/custom-filters.js +6 -0
  125. package/dist/utils/custom-filters.js.map +1 -0
  126. package/dist/utils/date.d.ts +1 -1
  127. package/dist/utils/date.d.ts.map +1 -1
  128. package/dist/utils/date.js +6 -3
  129. package/dist/utils/date.js.map +1 -1
  130. package/dist/utils/localization.d.ts.map +1 -1
  131. package/dist/utils/localization.js +195 -5
  132. package/dist/utils/localization.js.map +1 -1
  133. package/package.json +3 -3
  134. package/dist/components/custom-filters.d.ts +0 -2
  135. package/dist/components/custom-filters.d.ts.map +0 -1
  136. package/dist/components/custom-filters.js.map +0 -1
@@ -4,7 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
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
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import * as XLSX from 'xlsx';
8
7
  import { css, html, LitElement } from 'lit';
9
8
  import { msg } from '@lit/localize';
10
9
  import { customElement, property, state } from 'lit/decorators.js';
@@ -23,10 +22,13 @@ import '../shared/lit-tooltip.js';
23
22
  import '../shared/lit-data-grid-export-popover.js';
24
23
  import '../shared/lit-data-grid-action-buttons-popover.js';
25
24
  import '../assets/ilustration/not-found.js';
25
+ import '../shared/lit-overflow-tooltip.js';
26
+ import '../shared/lit-data-grid-density-popover.js';
27
+ import '../shared/lit-loading-bar.js';
26
28
  // utils
27
29
  import { formatDate } from '../utils/date.js';
28
- import { dateFilterFn } from './custom-filters.js';
29
- import { setLocale } from '../utils/localization.js';
30
+ import { dateFilterFn, multiselectFilterFn } from '../utils/custom-filters.js';
31
+ import { setLocale, getLocale } from '../utils/localization.js';
30
32
  let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
31
33
  constructor() {
32
34
  super(...arguments);
@@ -46,11 +48,22 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
46
48
  this.userLang = 'cs';
47
49
  this.dateFormat = null;
48
50
  this.isLoading = false;
51
+ this.enableRowSelectionOnClick = false;
52
+ this.initialFiltering = [];
53
+ this.server = false;
54
+ this.onColumnFiltersChanged = (filterModel) => { };
55
+ this.onColumnSortChanged = (sortModel) => { };
56
+ this.scrollEndThreshold = 100;
57
+ this.rowDensity = 'standard';
49
58
  this.rowsCount = 0;
59
+ this.selectedRowId = null;
50
60
  this.isScrollable = false;
51
61
  this.disableScrollLeft = true;
52
62
  this.disableScrollRight = false;
53
- this.tableController = new TableController(this);
63
+ this.filters = [];
64
+ this.sorting = [];
65
+ this.rowHeight = 31;
66
+ this.scrollToEnd = false;
54
67
  this.tableContainerRef = createRef();
55
68
  this.scrollInterval = null;
56
69
  this.getCellBackgroundColor = (cell) => {
@@ -78,53 +91,157 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
78
91
  }
79
92
  };
80
93
  }
94
+ get rows() {
95
+ return [...(this.row || [])];
96
+ }
97
+ get getColumns() {
98
+ return [...(this.columns || [])];
99
+ }
100
+ // lifecycle
81
101
  connectedCallback() {
82
- this.setLanguage();
102
+ super.connectedCallback();
83
103
  this.initRowVirtualizer();
84
104
  this.initColumnVirtualizer();
85
- super.connectedCallback();
105
+ this.initTable();
86
106
  window.addEventListener('resize', this.updateScrollState);
107
+ document.addEventListener('keydown', this.handleKeyDown.bind(this));
87
108
  }
88
109
  disconnectedCallback() {
89
110
  super.disconnectedCallback();
90
111
  window.removeEventListener('resize', this.updateScrollState);
112
+ document.removeEventListener('keydown', this.handleKeyDown.bind(this));
113
+ }
114
+ updated(changedProperties) {
115
+ if ((changedProperties.has('rowsCount') || changedProperties.has('rowDensity')) &&
116
+ this.enableRowVirtualization) {
117
+ this.scrollToEnd = false;
118
+ this.initRowVirtualizer();
119
+ this.requestUpdate();
120
+ }
121
+ if (changedProperties.has('columns') && this.enableColumnVirtualization) {
122
+ this.initColumnVirtualizer();
123
+ this.requestUpdate();
124
+ }
125
+ if (changedProperties.has('initialFiltering')) {
126
+ this.filters = [...(this.initialFiltering || [])];
127
+ }
128
+ if (changedProperties.has('initialSorting')) {
129
+ this.sorting = [...(this.initialSorting || [])];
130
+ }
131
+ if (changedProperties.has('rowDensity')) {
132
+ this.rowHeight = this.getRowHeight();
133
+ }
134
+ if (changedProperties.has('row') || changedProperties.has('columns')) {
135
+ this.initTable();
136
+ this.requestUpdate();
137
+ }
138
+ }
139
+ firstUpdated() {
140
+ const grid = this.tableContainerRef.value;
141
+ if (grid) {
142
+ grid.addEventListener('scroll', this.updateScrollState);
143
+ }
144
+ this.updateScrollState();
145
+ }
146
+ async loadXLSX() {
147
+ if (!window.XLSX) {
148
+ await new Promise((resolve) => {
149
+ const script = document.createElement('script');
150
+ script.src = '../../public/libs/xlsx.mini.min.js';
151
+ script.onload = resolve;
152
+ document.head.appendChild(script);
153
+ });
154
+ }
155
+ }
156
+ // row density
157
+ getRowHeight() {
158
+ switch (this.rowDensity) {
159
+ case 'compact':
160
+ return 31;
161
+ case 'standard':
162
+ return 38;
163
+ case 'comfort':
164
+ return 50;
165
+ default:
166
+ return 38;
167
+ }
168
+ }
169
+ getButtonSize() {
170
+ switch (this.rowDensity) {
171
+ case 'compact':
172
+ return 'small';
173
+ case 'standard':
174
+ return 'medium';
175
+ case 'comfort':
176
+ return 'large';
177
+ default:
178
+ return 'medium';
179
+ }
180
+ }
181
+ handleSetDensity(density) {
182
+ this.rowDensity = density;
183
+ }
184
+ // scroll by keyboard arrows
185
+ handleKeyDown(event) {
186
+ if (!this.enableRowSelectionOnClick)
187
+ return;
188
+ const rows = this.table.getRowModel().rows;
189
+ const currentIndex = rows.findIndex((row) => row.id === this.selectedRowId);
190
+ if (event.key === 'ArrowDown') {
191
+ if (!this.selectedRowId) {
192
+ // this.selectedRowId = rows[0]?.id; // Select first row if none selected
193
+ return;
194
+ }
195
+ const nextIndex = Math.min(currentIndex + 1, (rows.length ?? 0) - 1);
196
+ this.selectedRowId = rows[nextIndex].id;
197
+ }
198
+ else if (event.key === 'ArrowUp') {
199
+ if (!this.selectedRowId) {
200
+ // this.selectedRowId = rows[0]?.id; // Select first row if none selected
201
+ return;
202
+ }
203
+ const prevIndex = Math.max(currentIndex - 1, 0);
204
+ this.selectedRowId = rows[prevIndex].id;
205
+ }
206
+ else if (event.key === 'Enter' && this.selectedRowId) {
207
+ const selectedRow = rows.find((row) => row.id === this.selectedRowId);
208
+ if (selectedRow) {
209
+ this.handleRowDoubleClick(selectedRow);
210
+ }
211
+ }
91
212
  }
92
- initRowVirtualizer(count) {
93
- console.log('rc', count);
94
- this.rowVirtualizerController ??= new VirtualizerController(this, {
95
- count: count || this.row?.length || 0,
213
+ // virtualization
214
+ initRowVirtualizer() {
215
+ this.rowVirtualizerController = new VirtualizerController(this, {
216
+ count: this.table?.getRowModel()?.rows.length || this.row?.length || 1,
96
217
  getScrollElement: () => this.tableContainerRef.value,
97
- estimateSize: () => 38,
218
+ estimateSize: () => this.rowHeight,
98
219
  overscan: 5,
99
220
  });
100
221
  }
101
- initColumnVirtualizer(table) {
102
- this.columnVirtualizerController ??= new VirtualizerController(this, {
222
+ initTable() {
223
+ this.tableController = new TableController(this);
224
+ }
225
+ initColumnVirtualizer() {
226
+ this.columnVirtualizerController = new VirtualizerController(this, {
103
227
  horizontal: true,
104
- count: table ? table.getVisibleLeafColumns().length : this.columns.length,
228
+ count: this.table?.getVisibleLeafColumns().length || this.columns.length || 1,
105
229
  getScrollElement: () => this.tableContainerRef.value,
106
- estimateSize: (index) => (table ? table.getVisibleLeafColumns()[index].getSize() : 200),
230
+ estimateSize: (index) => this.table.getVisibleLeafColumns()[index].getSize() || 200,
107
231
  overscan: 5,
108
232
  });
109
233
  }
110
- setLanguage() {
111
- const lang = this.userLang || localStorage.getItem('userLang');
112
- if (lang) {
113
- setLocale(lang);
234
+ handleRowClick(row) {
235
+ if (this.onRowClick) {
236
+ this.onRowClick(row);
114
237
  }
238
+ if (!this.enableRowSelectionOnClick)
239
+ return;
240
+ this.selectedRowId = row.id;
115
241
  }
116
- updated(changedProperties) {
117
- // console.log('changedProperties', changedProperties);
118
- // Check if `table` has changed and update the virtualizer if needed
119
- if (changedProperties.has('rowsCount') || changedProperties.has('table')) {
120
- if (this.enableRowVirtualization) {
121
- this.initRowVirtualizer(this.rowsCount);
122
- this.requestUpdate();
123
- }
124
- if (this.enableColumnVirtualization) {
125
- this.initColumnVirtualizer(this.table);
126
- this.requestUpdate();
127
- }
242
+ handleRowDoubleClick(row) {
243
+ if (this.onRowDoubleClick) {
244
+ this.onRowDoubleClick(row);
128
245
  }
129
246
  }
130
247
  getTanstackColumns(columns) {
@@ -139,19 +256,25 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
139
256
  const value = props.getValue();
140
257
  const isGrouped = props.row.getIsGrouped?.();
141
258
  const isAggregated = props.row.getIsAggregated?.();
142
- if (isGrouped && column.type !== 'date') {
259
+ if (isGrouped) {
260
+ if (column.type === 'date') {
261
+ return formatDate(value, this.userLang || 'cs', undefined, this.dateFormat);
262
+ }
263
+ if (column.type === 'dateTime') {
264
+ return formatDate(value, this.userLang || 'cs', true, this.dateFormat);
265
+ }
143
266
  return value;
144
267
  }
145
- if (isGrouped && column.type === 'date') {
146
- return formatDate(value, this.userLang || 'cs', this.dateFormat);
147
- }
148
268
  if (isAggregated) {
149
269
  return value;
150
270
  }
151
271
  if (column.type === 'date' && value) {
152
- return formatDate(value, this.userLang || 'cs', this.dateFormat);
272
+ return formatDate(value, this.userLang || 'cs', undefined, this.dateFormat);
273
+ }
274
+ if (column.type === 'dateTime' && value) {
275
+ return formatDate(value, this.userLang || 'cs', true, this.dateFormat);
153
276
  }
154
- return column.cell ? column.cell(props) : value;
277
+ return column.cell ? column.cell(props, html) : value;
155
278
  },
156
279
  filterFn: (() => {
157
280
  switch (column.type) {
@@ -159,12 +282,14 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
159
282
  return filterFns.inNumberRange;
160
283
  case 'select':
161
284
  return filterFns.weakEquals;
285
+ case 'multiselect':
286
+ return multiselectFilterFn;
162
287
  case 'number':
163
288
  return filterFns.weakEquals;
164
289
  case 'date':
290
+ case 'dateTime':
165
291
  return dateFilterFn;
166
292
  case 'string':
167
- return filterFns.includesString;
168
293
  default:
169
294
  return filterFns.includesString;
170
295
  }
@@ -200,6 +325,7 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
200
325
  header.column.pin('left'); // Pripnutie doľava
201
326
  }
202
327
  }
328
+ // export to excel and csv
203
329
  exportDataToCsv() {
204
330
  const rows = this.getAllRowsIncludingGrouped(this.table.getRowModel().rows); // Získanie všetkých riadkov vrátane skupín
205
331
  if (!rows || rows.length === 0) {
@@ -242,7 +368,9 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
242
368
  link.click();
243
369
  URL.revokeObjectURL(url);
244
370
  }
245
- exportDataToExcel() {
371
+ async exportDataToExcel() {
372
+ await this.loadXLSX(); // Ensure XLSX is loaded
373
+ const XLSX = window.XLSX;
246
374
  const rows = this.getAllRowsIncludingGrouped(this.table.getRowModel().rows); // Získanie všetkých riadkov vrátane skupín
247
375
  if (!rows || rows.length === 0) {
248
376
  console.warn('No data to export');
@@ -303,13 +431,6 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
303
431
  });
304
432
  return allRows.filter((row, index, self) => index === self.findIndex((r) => r.id === row.id));
305
433
  }
306
- firstUpdated() {
307
- const grid = this.tableContainerRef.value;
308
- if (grid) {
309
- grid.addEventListener('scroll', this.updateScrollState);
310
- }
311
- this.updateScrollState();
312
- }
313
434
  startScroll(direction) {
314
435
  const grid = this.tableContainerRef.value;
315
436
  if (!grid)
@@ -328,18 +449,33 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
328
449
  this.scrollInterval = null;
329
450
  }
330
451
  }
452
+ handleScroll(event) {
453
+ const container = event.target;
454
+ if (container.scrollTop + container.clientHeight >=
455
+ container.scrollHeight - (this.scrollEndThreshold || 100) &&
456
+ this.onRowsScrollEnd &&
457
+ !this.isLoading &&
458
+ !this.scrollToEnd) {
459
+ this.scrollToEnd = true;
460
+ this.onRowsScrollEnd();
461
+ }
462
+ }
331
463
  render() {
464
+ if (getLocale() !== this.userLang) {
465
+ setLocale(this.userLang || 'cs');
466
+ }
332
467
  this.table = this.tableController.table({
333
- data: this.row || [],
334
- columns: this.getTanstackColumns(this.columns),
468
+ data: this.rows || [],
469
+ columns: this.getTanstackColumns(this.getColumns),
335
470
  columnResizeMode: 'onChange',
336
471
  columnResizeDirection: 'ltr',
337
472
  defaultColumn: {
338
- size: this.columnDefaultSize || 250, //starting column size
473
+ size: this.columnDefaultSize || undefined, //starting column size
339
474
  minSize: this.columnDefaultMinSize || 100, //enforced during column resizing
340
475
  maxSize: this.columnDefaultMaxSize || 500, //enforced during column resizing
341
476
  },
342
477
  initialState: {
478
+ // columnFilters: [...(this.initialFiltering || [])],
343
479
  sorting: [...(this.initialSorting || [])],
344
480
  grouping: [...(this.initialGroups || [])],
345
481
  columnVisibility: { ...this.initialColumnVisibility },
@@ -348,11 +484,19 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
348
484
  right: [...(this.rightPinnedColumns || [])],
349
485
  },
350
486
  },
487
+ state: {
488
+ columnFilters: this.filters,
489
+ sorting: this.sorting,
490
+ },
351
491
  filterFns: {
352
492
  dateFilterFn: dateFilterFn,
493
+ multiselectFilterFn: multiselectFilterFn,
353
494
  },
495
+ // debugTable: true,
354
496
  enableColumnPinning: this.enableColumnPinning,
355
497
  enableGrouping: this.enableGrouping,
498
+ manualFiltering: this.server,
499
+ getRowId: (row, index) => index.toString(),
356
500
  // groupedColumnMode: 'reorder',
357
501
  getCoreRowModel: getCoreRowModel(),
358
502
  getSortedRowModel: getSortedRowModel(),
@@ -361,6 +505,24 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
361
505
  getGroupedRowModel: getGroupedRowModel(),
362
506
  getExpandedRowModel: getExpandedRowModel(),
363
507
  getFacetedUniqueValues: getFacetedUniqueValues(),
508
+ onColumnFiltersChange: (updaterOrValue) => {
509
+ const filtersState = typeof updaterOrValue === 'function'
510
+ ? updaterOrValue(this.table.getState().columnFilters)
511
+ : updaterOrValue;
512
+ this.filters = filtersState;
513
+ if (this.onColumnFiltersChanged) {
514
+ this.onColumnFiltersChanged(filtersState);
515
+ }
516
+ },
517
+ onSortingChange: (updaterOrValue) => {
518
+ const sortingState = typeof updaterOrValue === 'function'
519
+ ? updaterOrValue(this.table.getState().sorting)
520
+ : updaterOrValue;
521
+ this.sorting = sortingState;
522
+ if (this.onColumnSortChanged) {
523
+ this.onColumnSortChanged(sortingState);
524
+ }
525
+ },
364
526
  });
365
527
  this.rowsCount = this.table.getRowModel().rows.length;
366
528
  // Ak virtualizácia nie je povolená, použijeme celý zoznam riadkov alebo stĺpcov
@@ -379,9 +541,9 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
379
541
  : rows.map((_, index) => ({
380
542
  key: index,
381
543
  index,
382
- start: index * 38,
383
- end: (index + 1) * 38,
384
- size: 38,
544
+ start: index * this.rowHeight,
545
+ end: (index + 1) * this.rowHeight,
546
+ size: this.rowHeight,
385
547
  lane: 0,
386
548
  }));
387
549
  // console.log('rowItems', rowItems);
@@ -395,37 +557,37 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
395
557
  (virtualColumns[virtualColumns.length - 1]?.end ?? 0);
396
558
  }
397
559
  let isMobile = window.matchMedia('(max-width: 600px)').matches;
398
- return html `
399
- <div class="data-grid__wrapper">
560
+ return html `
561
+ <div class="data-grid__wrapper">
400
562
  ${this.isScrollable && !isMobile
401
- ? html `
402
- <lit-icon-button
403
- class="scroll-button left"
404
- .disabled="${this.disableScrollLeft}"
405
- @pointerdown="${() => this.startScroll('left')}"
406
- @pointerup="${this.stopScroll}"
407
- @pointerleave="${this.stopScroll}"
408
- size="small"
409
- variant="contained"
410
- icon="arrowLeft"
411
- >
412
- </lit-icon-button>
413
- <lit-icon-button
414
- class="scroll-button right"
415
- .disabled="${this.disableScrollRight}"
416
- @pointerdown="${() => this.startScroll('right')}"
417
- @pointerup="${this.stopScroll}"
418
- @pointerleave="${this.stopScroll}"
419
- size="small"
420
- variant="contained"
421
- icon="arrowRight"
422
- >
423
- </lit-icon-button>
563
+ ? html `
564
+ <lit-icon-button
565
+ class="scroll-button left"
566
+ .disabled="${this.disableScrollLeft}"
567
+ @pointerdown="${() => this.startScroll('left')}"
568
+ @pointerup="${this.stopScroll}"
569
+ @pointerleave="${this.stopScroll}"
570
+ size="small"
571
+ variant="contained"
572
+ icon="arrowLeft"
573
+ >
574
+ </lit-icon-button>
575
+ <lit-icon-button
576
+ class="scroll-button right"
577
+ .disabled="${this.disableScrollRight}"
578
+ @pointerdown="${() => this.startScroll('right')}"
579
+ @pointerup="${this.stopScroll}"
580
+ @pointerleave="${this.stopScroll}"
581
+ size="small"
582
+ variant="contained"
583
+ icon="arrowRight"
584
+ >
585
+ </lit-icon-button>
424
586
  `
425
- : null}
426
- <div class="grid" ${ref(this.tableContainerRef)}>
427
- <table style="width: ${this.table.getCenterTotalSize()}px">
428
- <thead style="height: ${this.enableFiltering ? '4rem' : '1.625rem'};">
587
+ : null}
588
+ <div class="grid" ${ref(this.tableContainerRef)} @scroll="${this.handleScroll}">
589
+ <table style="width: ${this.table.getCenterTotalSize()}px">
590
+ <thead style="height: ${this.enableFiltering ? '4rem' : '1.625rem'};">
429
591
  ${repeat(this.table.getHeaderGroups(), (headerGroup) => headerGroup.id, (headerGroup) => {
430
592
  const headerColumns = this.enableColumnVirtualization
431
593
  ? virtualColumns.map((vc) => headerGroup.headers[vc.index])
@@ -436,37 +598,38 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
436
598
  ...headerColumns.filter((hc) => !hc.column.getIsPinned()),
437
599
  ]
438
600
  : headerColumns;
439
- return html `
440
- <tr class="head" data-index="${headerGroup.id}">
601
+ return html `
602
+ <tr class="head" data-index="${headerGroup.id}">
441
603
  ${virtualPaddingLeft
442
- ? html `
443
- <th
444
- style=" display: flex; width: ${virtualPaddingLeft}px;"
445
- ></th>
604
+ ? html `
605
+ <th
606
+ style=" display: flex; width: ${virtualPaddingLeft}px;"
607
+ ></th>
446
608
  `
447
- : ''}
609
+ : ''}
448
610
  ${repeat(newHeaderColumns, (header) => header.id, (header, index) => {
449
611
  const column = header.column;
450
612
  const style = {
451
613
  ...this.getCommonPinningStyles(header.column),
452
614
  width: `${column.getSize()}px`,
615
+ flexGrow: `${column.columnDef.size === undefined ? 1 : 'unset'}`,
453
616
  };
454
- return html `
455
- <th
456
- class="head"
457
- style="${styleMap(style)}"
458
- colspan="${header.colSpan}"
459
- data-index="${header.id}"
460
- >
617
+ return html `
618
+ <th
619
+ class="head"
620
+ style="${styleMap(style)}"
621
+ colspan="${header.colSpan}"
622
+ data-index="${header.id}"
623
+ >
461
624
  ${header.isPlaceholder
462
625
  ? ''
463
- : html `
464
- <div
626
+ : html `
627
+ <div
465
628
  class="resizer ${this
466
629
  .table.options
467
630
  .columnResizeDirection} ${header.column.getIsResizing()
468
631
  ? 'is-resizing'
469
- : ''}"
632
+ : ''}"
470
633
  style="transform: ${this
471
634
  .table.options
472
635
  .columnResizeMode ===
@@ -482,156 +645,166 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
482
645
  .columnSizingInfo
483
646
  .deltaOffset ??
484
647
  0)}px)`
485
- : ''}"
486
- >
487
- <div
488
- style="display: flex; align-items: center; justify-content: space-between; height: 100%"
489
- >
490
- <div
491
- class="column-header"
492
- @click=${header.column.getToggleSortingHandler()}
493
- >
494
- ${header.column
648
+ : ''}"
649
+ >
650
+ <div
651
+ style="display: flex; align-items: center; height: 100%;"
652
+ >
653
+ <div
654
+ class="column-header"
655
+ @click=${header.column.getToggleSortingHandler()}
656
+ >
657
+ <lit-overflow-tooltip
658
+ label="${header
659
+ .column
495
660
  .columnDef
496
- .header}
661
+ .header}"
662
+ >
663
+ ${header
664
+ .column
665
+ .columnDef
666
+ .header}
667
+ </lit-overflow-tooltip>
668
+ </div>
669
+
670
+ <div
671
+ class="icons-group-pin"
672
+ >
497
673
  ${header.column.getIsSorted()
498
674
  ? header.column.getIsSorted() ===
499
675
  'asc'
500
- ? html `<slot
501
- name="iconSortUp"
502
- ><lit-icon
503
- size="0.75rem"
504
- icon="chevronUpFilled"
505
- ></lit-icon
676
+ ? html `<slot
677
+ name="iconSortUp"
678
+ ><lit-icon
679
+ size="0.75rem"
680
+ icon="chevronUpFilled"
681
+ ></lit-icon
506
682
  ></slot>`
507
- : html `<slot
508
- name="iconSortDown"
509
- >
510
- <lit-icon
511
- size="0.75rem"
512
- icon="chevronDownFilled"
513
- ></lit-icon>
514
- </slot>`
515
- : ''}
516
- </div>
517
-
518
- <span
519
- style="display: flex; height: 100%"
520
- >
521
- ${!this
683
+ : html `<slothea
684
+ name="iconSortDown"
685
+ >
686
+ <lit-icon
687
+ size="0.75rem"
688
+ icon="chevronDownFilled"
689
+ ></lit-icon>
690
+ </slothea>`
691
+ : html `<div></div>`}
692
+ <div class="flex">
693
+ ${!this
522
694
  .actionButtonsInMenu
523
- ? html `
524
- ${header.column.getCanPin()
525
- ? html `
526
- <lit-tooltip
527
- label="${header.column.getIsPinned()
695
+ ? html `
696
+ ${header.column.getCanPin()
697
+ ? html `
698
+ <lit-tooltip
699
+ label="${header.column.getIsPinned()
528
700
  ? msg('Zrušit připnutí sloupce')
529
- : msg('Připnout sloupec vlevo')}"
530
- variant="bottom"
531
- >
532
- <lit-icon-button
533
- @click="${() => this.togglePin(header)}"
534
- size="small"
535
- variant="text"
536
- icon="pin"
537
- .active="${header.column.getIsPinned()}"
538
- >
539
- </lit-icon-button>
540
- </lit-tooltip>
541
- `
542
- : ''}
543
- ${header.column.getCanGroup()
544
- ? html `
545
- <lit-tooltip
546
- label="${header.column.getIsGrouped()
701
+ : msg('Připnout sloupec vlevo')}"
702
+ variant="bottom"
703
+ >
704
+ <lit-icon-button
705
+ @click="${() => this.togglePin(header)}"
706
+ size="small"
707
+ variant="text"
708
+ icon="pin"
709
+ .active="${header.column.getIsPinned()}"
710
+ >
711
+ </lit-icon-button>
712
+ </lit-tooltip>
713
+ `
714
+ : ''}
715
+ ${header.column.getCanGroup()
716
+ ? html `
717
+ <lit-tooltip
718
+ label="${header.column.getIsGrouped()
547
719
  ? msg('Zrušit seskupení')
548
- : msg('Seskupit sloupec')}"
549
- variant="bottom"
550
- >
551
- <lit-icon-button
552
- @click="${header.column.getToggleGroupingHandler()}"
553
- size="small"
554
- variant="text"
555
- .active="${header.column.getIsGrouped()}"
556
- icon="agregation"
557
- >
558
- </lit-icon-button>
559
- </lit-tooltip>
560
- `
561
- : ''}
562
- `
563
- : html `
564
- <lit-data-grid-action-buttons-popover
565
- .group="${header.column.getToggleGroupingHandler()}"
566
- .pin="${() => this.togglePin(header)}"
567
- .header="${header}"
568
- .table="${this
569
- .table}"
570
- ></lit-data-grid-action-buttons-popover>
571
- `}
572
- </span>
573
- </div>
574
- </div>
720
+ : msg('Seskupit sloupec')}"
721
+ variant="bottom"
722
+ >
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
+ `
733
+ : ''}
734
+ `
735
+ : html `
736
+ <lit-data-grid-action-buttons-popover
737
+ .group="${header.column.getToggleGroupingHandler()}"
738
+ .pin="${() => this.togglePin(header)}"
739
+ .header="${header}"
740
+ .table="${this
741
+ .table}"
742
+ ></lit-data-grid-action-buttons-popover>
743
+ `}
744
+ </div>
745
+ </div>
746
+ </div>
747
+ </div>
575
748
  ${header.column.getCanFilter()
576
- ? html `
577
- <div>
578
- <filter-inputs
579
- .column=${header.column}
749
+ ? html `
750
+ <div>
751
+ <filter-inputs
752
+ .column=${header.column}
580
753
  .dateFormat=${this
581
- .dateFormat}
754
+ .dateFormat}
582
755
  .userLang=${this
583
- .userLang}
584
- ></filter-inputs>
585
- </div>
756
+ .userLang}
757
+ ></filter-inputs>
758
+ </div>
586
759
  `
587
- : null}
588
- `}
589
- <div
590
- class="resize-handle"
760
+ : null}
761
+ `}
762
+ <div
763
+ class="resize-handle"
591
764
  @dblclick="${(event) => {
592
765
  if (event.target.classList.contains('resize-handle')) {
593
766
  header.column.resetSize();
594
767
  }
595
- }}"
768
+ }}"
596
769
  @mousedown="${(event) => {
597
770
  if (event.target.classList.contains('resize-handle')) {
598
771
  header.getResizeHandler()(event);
599
772
  }
600
- }}"
773
+ }}"
601
774
  @touchstart="${(event) => {
602
775
  if (event.target.classList.contains('resize-handle')) {
603
776
  header.getResizeHandler()(event);
604
777
  }
605
- }}"
606
- ></div>
607
- </th>
778
+ }}"
779
+ ></div>
780
+ </th>
608
781
  `;
609
- })}
782
+ })}
610
783
  ${virtualPaddingRight
611
- ? html `
612
- <th
613
- style=" display: flex; width: ${virtualPaddingRight}px;"
614
- ></th>
784
+ ? html `
785
+ <th
786
+ style=" display: flex; width: ${virtualPaddingRight}px;"
787
+ ></th>
615
788
  `
616
- : ''}
617
- </tr>
789
+ : ''}
790
+ </tr>
618
791
  `;
619
- })}
620
- </thead>
621
- ${this.isLoading
622
- ? html `
623
- <div class="progress-root">
624
- <div class="bar bar1Indeterminate"></div>
625
- <div class="bar bar2Indeterminate"></div>
626
- </div>
627
- `
628
- : ''}
629
- <tbody
792
+ })}
793
+ ${this.isLoading
794
+ ? html `
795
+ <div style="position: absolute; bottom: 0px; width: 100%;">
796
+ <lit-loading-bar></lit-loading-bar>
797
+ </div>
798
+ `
799
+ : ''}
800
+ </thead>
801
+
802
+ <tbody
630
803
  style="height: ${rowVirtualizer &&
631
804
  this.table.getRowModel().rows.length > 0
632
805
  ? rowVirtualizer.getTotalSize() + 'px'
633
- : 'auto'};"
634
- >
806
+ : 'auto'};"
807
+ >
635
808
  ${rows.length > 0
636
809
  ? repeat(rowItems, (item) => item.key, (item) => {
637
810
  const row = rows[item.index];
@@ -644,20 +817,24 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
644
817
  const newBodyColumns = this.enableColumnVirtualization
645
818
  ? [...new Set([...pinnedColumns, ...bodyColumns])]
646
819
  : bodyColumns;
647
- const tbodyStyle = {
820
+ const rowStyle = {
648
821
  transform: rowVirtualizer
649
822
  ? `translateY(${item.start}px)`
650
823
  : 'none',
651
- height: '38px',
652
- lineHeight: '38px',
824
+ height: `${this.rowHeight}px`,
825
+ lineHeight: `${this.rowHeight}px`,
653
826
  position: rowVirtualizer ? 'absolute' : 'relative',
654
827
  };
655
828
  return row
656
- ? html `
657
- <tr
658
- class="body"
659
- data-index="${item.index}"
660
- style="${styleMap(tbodyStyle)}"
829
+ ? html `
830
+ <tr
831
+ class="${this.selectedRowId === row.id
832
+ ? 'selected body'
833
+ : 'body'}"
834
+ data-index="${item.index}"
835
+ @click="${() => this.handleRowClick(row)}"
836
+ @dblclick="${() => this.handleRowDoubleClick(row)}"
837
+ style="${styleMap(rowStyle)}"
661
838
  ${ref((node) => {
662
839
  if (node &&
663
840
  this.enableRowVirtualization &&
@@ -665,65 +842,68 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
665
842
  // Only measure element if virtualization is enabled
666
843
  rowVirtualizer.measureElement(node);
667
844
  }
668
- })}
669
- >
845
+ })}
846
+ >
670
847
  ${virtualPaddingLeft
671
- ? html `
672
- <th
673
- style=" display: flex; width: ${virtualPaddingLeft}px;"
674
- ></th>
848
+ ? html `
849
+ <th
850
+ style=" display: flex; width: ${virtualPaddingLeft}px;"
851
+ ></th>
675
852
  `
676
- : ''}
677
- <!-- Cells for each row -->
853
+ : ''}
854
+ <!-- Cells for each row -->
678
855
  ${repeat(newBodyColumns, (cell) => cell.key, (cell) => {
856
+ const buttonSize = this.getButtonSize();
679
857
  const { column } = cell;
680
858
  const style = {
681
859
  ...this.getCommonPinningStyles(cell.column),
682
860
  width: `${cell.column.getSize()}px`,
861
+ flexGrow: `${column.columnDef.size === undefined ? 1 : 'unset'}`,
683
862
  background: this.getCellBackgroundColor(cell),
684
- lineHeight: '2.3125rem', // správny zápis reťazca
863
+ lineHeight: `${this.rowHeight}px`,
685
864
  };
686
- return html `
687
- <td style="${styleMap(style)}">
865
+ return html `
866
+ <td style="${styleMap(style)}">
688
867
  ${cell.getIsGrouped()
689
- ? html `
690
- <lit-button
691
- @click="${row.getToggleExpandedHandler()}"
692
- variant="inherit"
868
+ ? html `
869
+ <lit-button
870
+ @click="${row.getToggleExpandedHandler()}"
871
+ variant="inherit"
872
+ size="${buttonSize}"
693
873
  count="${row
694
874
  .subRows
695
- .length}"
875
+ .length}"
696
876
  label="${flexRender(cell
697
877
  .column
698
878
  .columnDef
699
- .cell, cell.getContext())}"
879
+ .cell, cell.getContext())}"
700
880
  icon="${row.getIsExpanded()
701
881
  ? 'chevronDownFilled'
702
- : 'chevron'}"
703
- >
882
+ : 'chevron'}"
883
+ >
704
884
  <!-- ${row.getIsExpanded()
705
- ? html `<slot
706
- name="groupedIcon-expanded"
707
- slot="start-icon"
885
+ ? html `<slot
886
+ name="groupedIcon-expanded"
887
+ slot="start-icon"
708
888
  ></slot>`
709
- : html `<slot
710
- name="groupedIcon"
711
- slot="start-icon"
712
- ></slot>`} -->
713
- }
889
+ : html `<slot
890
+ name="groupedIcon"
891
+ slot="start-icon"
892
+ ></slot>`} -->
893
+ }
714
894
  ${row.subRows
715
- .length}
895
+ .length}
716
896
  ${flexRender(cell
717
897
  .column
718
898
  .columnDef
719
- .cell, cell.getContext())}
720
- </lit-button>
899
+ .cell, cell.getContext())}
900
+ </lit-button>
721
901
  `
722
902
  : cell.getIsAggregated()
723
- ? html `
724
- <div
725
- style="display: flex; flex-direction: row; align-items: center;"
726
- >
903
+ ? html `
904
+ <div
905
+ style="display: flex; flex-direction: row; align-items: center;"
906
+ >
727
907
  ${flexRender(cell
728
908
  .column
729
909
  .columnDef
@@ -731,333 +911,292 @@ let LitDataGridTanstack = class LitDataGridTanstack extends LitElement {
731
911
  cell
732
912
  .column
733
913
  .columnDef
734
- .cell, cell.getContext())}
735
- </div>
914
+ .cell, cell.getContext())}
915
+ </div>
736
916
  `
737
917
  : cell.getIsPlaceholder()
738
918
  ? null
739
919
  : flexRender(cell.column
740
920
  .columnDef
741
- .cell, cell.getContext())}
742
- </td>
921
+ .cell, cell.getContext())}
922
+ </td>
743
923
  `;
744
- })}
924
+ })}
745
925
  ${virtualPaddingRight
746
- ? html `
747
- <th
748
- style=" display: flex; width: ${virtualPaddingRight}px;"
749
- ></th>
926
+ ? html `
927
+ <th
928
+ style=" display: flex; width: ${virtualPaddingRight}px;"
929
+ ></th>
750
930
  `
751
- : ''}
752
- </tr>
931
+ : ''}
932
+ </tr>
753
933
  `
754
934
  : null;
755
935
  })
756
- : null}
757
- </tbody>
758
- </table>
759
- <div class="footer-container">
760
- <span class="numberCount">
761
- ${msg('Počet záznamů')}: ${this.table.getRowModel().rows.length}
762
- </span>
763
- <div class="right-actions">
764
- <lit-responsive-button
765
- size="small"
766
- variant="text"
767
- label=${msg('Přizpůsobit sloupce')}
768
- icon="columns"
769
- @click=${() => this.table.resetColumnSizing()}
770
- ></lit-responsive-button>
936
+ : null}
937
+ </tbody>
938
+ </table>
939
+ <div class="footer-container">
940
+ <span class="numberCount">
941
+ ${msg('Počet záznamů')}: ${this.table.getRowModel().rows.length}
942
+ </span>
943
+ <div class="right-actions">
944
+ <lit-data-grid-density-popover
945
+ .density="${this.rowDensity}"
946
+ .setDensity="${(density) => this.handleSetDensity(density)}"
947
+ >
948
+ </lit-data-grid-density-popover>
949
+ <lit-responsive-button
950
+ size="small"
951
+ variant="text"
952
+ label=${msg('Přizpůsobit sloupce')}
953
+ icon="columns"
954
+ @click=${() => this.table.resetColumnSizing()}
955
+ ></lit-responsive-button>
771
956
  ${this.exportData
772
- ? html `
773
- <lit-data-grid-export-popover
774
- .exportToCsv="${() => this.exportDataToCsv()}"
775
- .exportToExcel="${() => this.exportDataToExcel()}"
776
- >
777
- <slot slot="iconExcel" name="iconExcel"
778
- ><lit-icon icon="csv"></lit-icon
779
- ></slot>
780
- <slot slot="iconCsv" name="iconCsv"
781
- ><lit-icon icon="csv"></lit-icon
782
- ></slot>
783
- </lit-data-grid-export-popover>
957
+ ? html `
958
+ <lit-data-grid-export-popover
959
+ .exportToCsv="${() => this.exportDataToCsv()}"
960
+ .exportToExcel="${() => this.exportDataToExcel()}"
961
+ .disabledButtons="${this.isLoading}"
962
+ >
963
+ </lit-data-grid-export-popover>
784
964
  `
785
- : null}
786
- </div>
787
- </div>
788
- </div>
789
- ${this.table.getRowModel().rows.length < 1
790
- ? html ` <div class="data-grid__empty">
791
- <div style="max-height: 7.125rem; max-width: 7.125rem">
792
- <not-found></not-found>
793
- </div>
794
- ${msg('Nic dalšího tu není')}
965
+ : null}
966
+ </div>
967
+ </div>
968
+ </div>
969
+ ${this.table.getRowModel().rows.length < 1 && !this.isLoading
970
+ ? html ` <div class="data-grid__empty">
971
+ <div style="max-height: 7.125rem; max-width: 7.125rem">
972
+ <not-found></not-found>
973
+ </div>
974
+ ${msg('Nic dalšího tu není')}
795
975
  </div>`
796
- : null}
797
- </div>
976
+ : null}
977
+ </div>
798
978
  `;
799
979
  }
800
980
  };
801
981
  LitDataGridTanstack.styles = [
802
982
  // styles,
803
- css `
804
- *,
805
- *::before,
806
- *::after {
807
- margin: 0;
808
- padding: 0;
809
- box-sizing: border-box;
810
- }
811
-
812
- display: block;
813
- font-family: 'Inter', sans-serif;
814
- box-sizing: border-box;
815
-
816
- table {
817
- border-collapse: collapse;
818
- border-spacing: 0;
819
- width: 100%;
820
- }
821
- td {
822
- padding: 0px;
823
- }
824
-
825
- .data-grid__wrapper {
826
- position: relative;
827
- padding: var(--section-padding, 0.75rem 1rem);
828
- border-radius: 0.75rem;
829
- background-color: var(--background-paper, #fff);
830
- }
831
-
832
- .data-grid__empty {
833
- position: absolute;
834
- top: 30%;
835
- left: 50%;
836
- transform: translate(-50%, -50%);
837
- font-size: 0.875rem;
838
- text-align: center;
839
- }
840
-
841
- table {
842
- height: calc(100% - 38px);
843
- }
844
-
845
- .grid {
846
- overflow: auto;
847
- position: relative;
848
- height: 500px;
849
- }
850
-
851
- thead {
852
- display: flex;
853
- position: sticky;
854
- top: 0;
855
- z-index: 10;
856
- background-color: var(--background-paper, #fff);
857
- border-bottom: 1px solid var(--color-divider, #d0d3db);
858
- }
859
-
860
- tr.head {
861
- display: flex;
862
- width: 100%;
863
- }
864
-
865
- th.head {
866
- display: block;
867
- position: relative;
868
- padding: 0px 6px;
869
- gap: 0.25rem;
870
- //z-index: auto !important;
871
- }
872
-
873
- tbody {
874
- display: grid;
875
- position: relative;
876
- }
877
-
878
- tr.body {
879
- width: 100%;
880
- border-bottom: 1px solid var(--color-divider, #d0d3db);
881
- display: flex;
882
- }
883
-
884
- tr.body:hover {
885
- cursor: pointer;
886
- background-color: var(--background-default, #eff3f4);
887
- }
888
-
889
- td {
890
- display: table-cell;
891
- white-space: nowrap;
892
- overflow: hidden;
893
- padding: 0px 12px;
894
- font-weight: 500;
895
- font-size: 13px;
896
- color: var(--text-primary, #111827);
897
- }
898
-
899
- .column-header {
900
- font-size: 11px;
901
- font-weight: 600;
902
- color: var(--text-secondary, #5d6371);
903
- cursor: pointer;
904
- gap: 0.25rem;
905
- display: flex;
906
- justify-content: center;
907
- align-items: center;
908
- margin: 0 0.25rem;
909
- }
910
-
911
- .resizer {
912
- height: 23px;
913
- padding: 0 0 0 6px;
914
- text-align: start;
915
- //cursor: col-resize;
916
- user-select: none;
917
- touch-action: none;
918
- }
919
-
920
- .resize-handle {
921
- position: absolute;
922
- top: 0;
923
- right: 0px;
924
- width: 6px;
925
- height: 100%;
926
- background: transparent;
927
- cursor: col-resize;
928
- transition: background-color 0.2s ease-in-out;
929
- // border-radius: 5px;
930
- // padding-bottom: 5px;
931
- }
932
-
933
- .resize-handle:hover {
934
- border-right: 2px solid var(--color-primary-main, #75b603);
935
- }
936
-
937
- .resizer.ltr {
938
- right: 0;
939
- }
940
-
941
- .resizer.rtl {
942
- left: 0;
943
- }
944
-
945
- .resizer.is-resizing {
946
- opacity: 1;
947
- }
948
-
949
- .footer-container {
950
- position: sticky;
951
- left: 0;
952
- bottom: 0;
953
- background-color: var(--background-paper, #fff);
954
- width: auto;
955
- border-top: 1px solid var(--color-divider, #d0d3db);
956
- height: 2.375rem;
957
- display: flex;
958
- flex-direction: row;
959
- justify-content: space-between;
960
- align-items: center;
961
- padding: 0 16px;
962
- z-index: 10;
963
- }
964
-
965
- .right-actions {
966
- position: absolute;
967
- right: 0;
968
- display: flex;
969
- }
970
-
971
- .numberCount {
972
- margin: 0.375rem 0;
973
- font-size: 12px;
974
- font-weight: 400;
975
- color: var(--text-primary, #111827);
976
- }
977
-
978
- .scroll-button {
979
- position: absolute;
980
- top: 50%;
981
- transform: translateY(-50%);
982
- z-index: 1000;
983
- cursor: pointer;
984
- }
985
-
986
- .scroll-button.left {
987
- left: 3rem;
988
- }
989
-
990
- .scroll-button.right {
991
- right: 3rem;
992
- }
993
-
994
- .progress-root {
995
- position: sticky;
996
- overflow: hidden;
997
- display: block;
998
- width: 100%;
999
-
1000
- height: 4px;
1001
- background-color: #e0e0e0; /* Podobná farba pozadia ako v MUI */
1002
- box-sizing: border-box;
1003
- }
1004
-
1005
- .bar {
1006
- position: absolute;
1007
- height: 100%;
1008
- display: block;
1009
- background-color: #75b603; /* Podobná farba ako primary theme v MUI */
1010
- width: auto;
1011
- will-change: left, right;
1012
- box-sizing: border-box;
1013
- }
1014
-
1015
- /* Prvá animovaná "vlna" */
1016
-
1017
- .bar1Indeterminate {
1018
- animation: mui-indeterminate1 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
1019
- }
1020
-
1021
- /* Druhá animovaná "vlna" (oneskorená) */
1022
-
1023
- .bar2Indeterminate {
1024
- animation: mui-indeterminate2 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
1025
- animation-delay: 1.05s;
1026
- }
1027
-
1028
- @keyframes mui-indeterminate1 {
1029
- 0% {
1030
- left: -35%;
1031
- right: 100%;
1032
- }
1033
- 60% {
1034
- left: 100%;
1035
- right: -90%;
1036
- }
1037
- 100% {
1038
- left: 100%;
1039
- right: -90%;
1040
- }
1041
- }
1042
-
1043
- @keyframes mui-indeterminate2 {
1044
- 0% {
1045
- left: -200%;
1046
- right: 100%;
1047
- }
1048
- 60% {
1049
- left: 107%;
1050
- right: -8%;
1051
- }
1052
- 100% {
1053
- left: 107%;
1054
- right: -8%;
1055
- }
1056
- }
983
+ css `
984
+ *,
985
+ *::before,
986
+ *::after {
987
+ margin: 0;
988
+ padding: 0;
989
+ box-sizing: border-box;
990
+ }
991
+
992
+ display: block;
993
+ font-family: 'Inter', sans-serif;
994
+ box-sizing: border-box;
995
+
996
+ td {
997
+ padding: 0px;
998
+ }
999
+
1000
+ .data-grid__wrapper {
1001
+ position: relative;
1002
+ background-color: var(--background-paper, #fff);
1003
+ height: 100%;
1004
+ z-index: 1;
1005
+ }
1006
+
1007
+ .grid {
1008
+ overflow: auto;
1009
+ position: relative;
1010
+ height: 100%;
1011
+ }
1012
+
1013
+ .data-grid__empty {
1014
+ position: absolute;
1015
+ top: 30%;
1016
+ left: 50%;
1017
+ transform: translate(-50%, -50%);
1018
+ font-size: 0.875rem;
1019
+ text-align: center;
1020
+ }
1021
+
1022
+ table {
1023
+ border-collapse: collapse;
1024
+ border-spacing: 0;
1025
+ width: 100% !important;
1026
+ height: calc(100% - 38px);
1027
+ }
1028
+
1029
+ thead {
1030
+ display: flex;
1031
+ position: sticky;
1032
+ top: 0;
1033
+ z-index: 10;
1034
+ background-color: var(--background-paper, #fff);
1035
+ border-bottom: 1px solid var(--color-divider, #d0d3db);
1036
+ }
1037
+
1038
+ tr.head {
1039
+ display: flex;
1040
+ width: 100%;
1041
+ }
1042
+
1043
+ th.head {
1044
+ display: block;
1045
+ position: relative;
1046
+ padding: 0px 6px;
1047
+ gap: 0.25rem;
1048
+ //z-index: auto !important;
1049
+ }
1050
+
1051
+ tbody {
1052
+ display: grid;
1053
+ position: relative;
1054
+ }
1055
+
1056
+ tr.body {
1057
+ width: 100%;
1058
+ border-bottom: 1px solid var(--color-divider, #d0d3db);
1059
+ display: flex;
1060
+ }
1061
+
1062
+ tr.body:hover {
1063
+ cursor: pointer;
1064
+ background-color: var(--background-default, #eff3f4);
1065
+ }
1066
+
1067
+ td {
1068
+ display: table-cell;
1069
+ white-space: nowrap;
1070
+ overflow: hidden;
1071
+ padding: 0px 14px;
1072
+ font-weight: 500;
1073
+ font-size: 13px;
1074
+ color: var(--text-primary, #111827);
1075
+ }
1076
+
1077
+ .column-header {
1078
+ font-size: 11px;
1079
+ font-weight: 600;
1080
+ color: var(--text-secondary, #5d6371);
1081
+ cursor: pointer;
1082
+ gap: 0.25rem;
1083
+ justify-content: center;
1084
+ align-items: center;
1085
+ margin: 0 0.25rem;
1086
+ overflow: hidden;
1087
+ white-space: nowrap;
1088
+ text-overflow: ellipsis;
1089
+ height: inherit;
1090
+ display: flex;
1091
+ }
1092
+
1093
+ .ellipsis {
1094
+ overflow: hidden;
1095
+ white-space: nowrap;
1096
+ text-overflow: ellipsis;
1097
+ }
1098
+
1099
+ .icons-group-pin {
1100
+ display: flex;
1101
+ height: 100%;
1102
+ justify-content: space-between;
1103
+ flex-grow: 1;
1104
+ }
1105
+
1106
+ .flex {
1107
+ display: flex;
1108
+ }
1109
+
1110
+ .resizer {
1111
+ height: 23px;
1112
+ padding: 0 0 0 6px;
1113
+ text-align: start;
1114
+ //cursor: col-resize;
1115
+ user-select: none;
1116
+ touch-action: none;
1117
+ }
1118
+
1119
+ .resize-handle {
1120
+ position: absolute;
1121
+ top: 0;
1122
+ right: 0px;
1123
+ width: 6px;
1124
+ height: 100%;
1125
+ background: transparent;
1126
+ cursor: col-resize;
1127
+ transition: background-color 0.2s ease-in-out;
1128
+ // border-radius: 5px;
1129
+ // padding-bottom: 5px;
1130
+ }
1131
+
1132
+ .resize-handle:hover {
1133
+ border-right: 2px solid var(--color-primary-main, #75b603);
1134
+ }
1135
+
1136
+ .resizer.ltr {
1137
+ right: 0;
1138
+ }
1139
+
1140
+ .resizer.rtl {
1141
+ left: 0;
1142
+ }
1143
+
1144
+ .resizer.is-resizing {
1145
+ opacity: 1;
1146
+ }
1147
+
1148
+ .footer-container {
1149
+ position: sticky;
1150
+ left: 0;
1151
+ bottom: 0;
1152
+ background-color: var(--background-paper, #fff);
1153
+ width: auto;
1154
+ border-top: 1px solid var(--color-divider, #d0d3db);
1155
+ height: 2.375rem;
1156
+ display: flex;
1157
+ flex-direction: row;
1158
+ justify-content: space-between;
1159
+ align-items: center;
1160
+ // padding: 0 16px;
1161
+ z-index: 10;
1162
+ }
1163
+
1164
+ .right-actions {
1165
+ position: absolute;
1166
+ right: 0;
1167
+ display: flex;
1168
+ }
1169
+
1170
+ .numberCount {
1171
+ margin: 0.375rem 0;
1172
+ font-size: 12px;
1173
+ font-weight: 400;
1174
+ color: var(--text-primary, #111827);
1175
+ }
1176
+
1177
+ .scroll-button {
1178
+ position: absolute;
1179
+ top: 50%;
1180
+ transform: translateY(-50%);
1181
+ z-index: 1000;
1182
+ cursor: pointer;
1183
+ }
1184
+
1185
+ .scroll-button.left {
1186
+ left: 3rem;
1187
+ }
1188
+
1189
+ .scroll-button.right {
1190
+ right: 3rem;
1191
+ }
1192
+
1193
+ .selected {
1194
+ background-color: var(--color-primary-light, #f0fadf);
1195
+ }
1057
1196
  `,
1058
1197
  ];
1059
1198
  __decorate([
1060
- property({ type: Array })
1199
+ property({ type: Array, reflect: true })
1061
1200
  ], LitDataGridTanstack.prototype, "row", void 0);
1062
1201
  __decorate([
1063
1202
  property({ type: Array })
@@ -1128,9 +1267,42 @@ __decorate([
1128
1267
  __decorate([
1129
1268
  property({ type: Boolean })
1130
1269
  ], LitDataGridTanstack.prototype, "isLoading", void 0);
1270
+ __decorate([
1271
+ property({ type: Function })
1272
+ ], LitDataGridTanstack.prototype, "onRowClick", void 0);
1273
+ __decorate([
1274
+ property({ type: Function })
1275
+ ], LitDataGridTanstack.prototype, "onRowsScrollEnd", void 0);
1276
+ __decorate([
1277
+ property({ type: Function })
1278
+ ], LitDataGridTanstack.prototype, "onRowDoubleClick", void 0);
1279
+ __decorate([
1280
+ property({ type: Boolean })
1281
+ ], LitDataGridTanstack.prototype, "enableRowSelectionOnClick", void 0);
1282
+ __decorate([
1283
+ property({ type: Array })
1284
+ ], LitDataGridTanstack.prototype, "initialFiltering", void 0);
1285
+ __decorate([
1286
+ property({ type: Boolean })
1287
+ ], 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
+ __decorate([
1295
+ property({ type: Number })
1296
+ ], LitDataGridTanstack.prototype, "scrollEndThreshold", void 0);
1297
+ __decorate([
1298
+ property({ type: String })
1299
+ ], LitDataGridTanstack.prototype, "rowDensity", void 0);
1131
1300
  __decorate([
1132
1301
  state()
1133
1302
  ], LitDataGridTanstack.prototype, "rowsCount", void 0);
1303
+ __decorate([
1304
+ state()
1305
+ ], LitDataGridTanstack.prototype, "selectedRowId", void 0);
1134
1306
  __decorate([
1135
1307
  state()
1136
1308
  ], LitDataGridTanstack.prototype, "isScrollable", void 0);
@@ -1140,6 +1312,18 @@ __decorate([
1140
1312
  __decorate([
1141
1313
  state()
1142
1314
  ], LitDataGridTanstack.prototype, "disableScrollRight", void 0);
1315
+ __decorate([
1316
+ state()
1317
+ ], LitDataGridTanstack.prototype, "filters", void 0);
1318
+ __decorate([
1319
+ state()
1320
+ ], LitDataGridTanstack.prototype, "sorting", void 0);
1321
+ __decorate([
1322
+ state()
1323
+ ], LitDataGridTanstack.prototype, "table", void 0);
1324
+ __decorate([
1325
+ state()
1326
+ ], LitDataGridTanstack.prototype, "rowHeight", void 0);
1143
1327
  LitDataGridTanstack = __decorate([
1144
1328
  customElement('lit-data-grid-tanstack')
1145
1329
  ], LitDataGridTanstack);