vueless 0.0.164 → 0.0.166

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,42 +1,59 @@
1
1
  <template>
2
2
  <div :data-cy="dataCy" v-bind="wrapperAttrs">
3
3
  <div
4
- v-show="isShownStickyOrActionsHeader"
5
- ref="headerStickyRow"
4
+ v-show="isHeaderSticky || isShownActionsHeader"
5
+ ref="stickyHeaderRowRef"
6
6
  :style="tableRowWidthStyle"
7
7
  v-bind="stickyHeaderAttrs"
8
8
  >
9
- <UCheckbox
10
- v-if="selectable"
11
- v-model="selectAll"
12
- size="sm"
13
- :partial="!isSelectedAllRows"
14
- :data-cy="`${dataCy}-select-all`"
15
- v-bind="selectAllCheckboxAttrs"
16
- />
9
+ <template v-if="isShownActionsHeader">
10
+ <div v-bind="stickyHeaderCellAttrs()">
11
+ <UCheckbox
12
+ v-if="selectable"
13
+ v-model="selectAll"
14
+ size="sm"
15
+ :partial="!isSelectedAllRows"
16
+ :data-cy="`${dataCy}-select-all`"
17
+ v-bind="stickyHeaderActionsCheckboxAttrs"
18
+ />
19
+ </div>
17
20
 
18
- <div
19
- v-if="selectedRows.length"
20
- v-bind="selectedRowsCountAttrs"
21
- v-text="selectedRows.length"
22
- />
21
+ <div
22
+ v-if="selectedRows.length"
23
+ v-bind="stickyHeaderActionsCounterAttrs"
24
+ v-text="selectedRows.length"
25
+ />
23
26
 
24
- <!-- @slot Use it to add actions instead table head (it appears when you select rows in table). -->
25
- <slot
26
- v-if="selectedRows.length && hasSlotContent($slots['thead-actions'])"
27
- name="thead-actions"
28
- :selected-rows="selectedRows"
29
- />
27
+ <!-- @slot Use it to add action buttons instead of table row when some rows are selected. -->
28
+ <slot name="header-actions" :selected-rows="selectedRows" />
29
+ </template>
30
30
 
31
31
  <template v-else>
32
+ <div v-bind="stickyHeaderCellAttrs()">
33
+ <UCheckbox
34
+ v-if="selectable"
35
+ v-model="selectAll"
36
+ size="sm"
37
+ :partial="!isSelectedAllRows"
38
+ :data-cy="`${dataCy}-select-all`"
39
+ v-bind="stickyHeaderCheckboxAttrs"
40
+ />
41
+
42
+ <div
43
+ v-if="selectedRows.length"
44
+ v-bind="stickyHeaderCounterAttrs"
45
+ v-text="selectedRows.length"
46
+ />
47
+ </div>
48
+
32
49
  <div
33
50
  v-for="(column, index) in columns"
34
51
  :key="index"
35
- v-bind="stickyHeaderColumnAttrs(column.thClass)"
52
+ v-bind="stickyHeaderCellAttrs(column.thClass)"
36
53
  >
37
- <template v-if="hasSlotContent($slots[`thead-${column.key}`])">
54
+ <template v-if="hasSlotContent($slots[`header-${column.key}`])">
38
55
  <!-- @slot Use it to customise table column. -->
39
- <slot :name="`thead-${column.key}`" :label="column.label" />
56
+ <slot :name="`header-${column.key}`" :column="column" />
40
57
  </template>
41
58
 
42
59
  <template v-else>
@@ -44,7 +61,7 @@
44
61
  </template>
45
62
 
46
63
  <!-- @slot Use it to add content after table column. -->
47
- <slot :name="`thead-${column.key}-after`" />
64
+ <slot :name="`header-${column.key}-after`" :column="column" />
48
65
  </div>
49
66
  </template>
50
67
 
@@ -55,21 +72,31 @@
55
72
  />
56
73
  </div>
57
74
 
58
- <div ref="tableWrapper" v-bind="tableWrapperAttrs">
75
+ <div ref="tableWrapperRef" v-bind="tableWrapperAttrs">
59
76
  <table v-bind="tableAttrs">
60
77
  <thead v-bind="headerAttrs" :style="tableRowWidthStyle">
61
- <tr v-if="hasSlotContent($slots['before-header-row'])" v-bind="headerRowAttrs">
62
- <slot name="before-header-row" />
78
+ <tr v-if="hasSlotContent($slots['before-header'])" v-bind="headerRowAttrs">
79
+ <UTableCell
80
+ v-if="hasSlotContent($slots['before-header'])"
81
+ :colspan="colsCount"
82
+ :compact="compact"
83
+ v-bind="headerCellAttrs()"
84
+ >
85
+ <!-- @slot Use it to add something before header row. -->
86
+ <slot name="before-header" :cols-count="colsCount" />
87
+ </UTableCell>
63
88
  </tr>
64
89
 
65
- <tr ref="headerRow" v-bind="headerRowCellAttrs">
66
- <th v-if="selectable" v-bind="headerCellAttrs(config.headerCheckboxWrapper)">
90
+ <tr v-if="hasSlotContent($slots['before-header'])" v-bind="headerRowAttrs"></tr>
91
+
92
+ <tr ref="headerRowRef" v-bind="headerRowAttrs">
93
+ <th v-if="selectable" v-bind="headerCellAttrs(config.headerCellCheckbox)">
67
94
  <UCheckbox
68
95
  v-model="selectAll"
69
96
  size="sm"
70
97
  :partial="!isSelectedAllRows"
71
98
  :data-cy="`${dataCy}-select-all`"
72
- v-bind="headerSelectAllCheckboxAttrs"
99
+ v-bind="headerCheckboxAttrs"
73
100
  />
74
101
  </th>
75
102
 
@@ -78,90 +105,97 @@
78
105
  :key="index"
79
106
  v-bind="headerCellAttrs(column.thClass)"
80
107
  >
81
- <template v-if="hasSlotContent($slots[`thead-${column.key}`])">
82
- <!-- @slot Use it to customise table column. -->
83
- <slot :name="`thead-${column.key}`" :label="column.label" />
84
- </template>
108
+ <!-- @slot Use it to customise table column. -->
109
+ <slot
110
+ v-if="hasSlotContent($slots[`header-${column.key}`])"
111
+ :name="`header-${column.key}`"
112
+ :column="column"
113
+ />
85
114
 
86
115
  <template v-else>
87
116
  {{ column.label }}
88
117
  </template>
89
118
 
90
119
  <!-- @slot Use it to add content after table column. -->
91
- <slot :name="`thead-${column.key}-after`" />
120
+ <slot :name="`header-${column.key}-after`" :column="column" />
92
121
  </th>
93
122
  </tr>
94
123
 
95
- <ULoaderTop v-if="resource" :resource-names="resource" v-bind="tableLoaderAttrs" />
124
+ <ULoaderTop v-if="resource" :resource-names="resource" v-bind="headerLoaderAttrs" />
96
125
  </thead>
97
126
 
98
127
  <tbody v-if="tableRows.length" v-bind="bodyAttrs">
99
128
  <template v-for="(row, rowIndex) in tableRows" :key="row.id">
100
- <tr v-if="rowIndex === firstRow" v-bind="beforeFirstRowAttrs">
129
+ <tr v-if="rowIndex === firstRow" v-bind="bodyRowBeforeAttrs">
101
130
  <UTableCell
102
131
  v-if="hasSlotContent($slots['before-first-row'])"
103
132
  :colspan="colsCount"
104
133
  :compact="compact"
105
- v-bind="beforeFirstRowCellAttrs"
134
+ v-bind="bodyRowBeforeCellAttrs"
106
135
  >
107
136
  <!-- @slot Use it to add something before first row. -->
108
137
  <slot name="before-first-row" />
109
138
  </UTableCell>
110
139
 
111
- <td v-else :colspan="colsCount" v-bind="beforeFirstRowCellAttrs" />
140
+ <td v-else :colspan="colsCount" v-bind="bodyRowBeforeCellAttrs" />
112
141
  </tr>
113
142
 
114
143
  <tr
115
144
  v-if="isShownDateSeparator(rowIndex) && row.date"
116
- v-bind="dateSeparatorRowAttrs(rowIndex)"
145
+ v-bind="bodyRowDateSeparatorAttrs(rowIndex)"
117
146
  >
118
- <td :colspan="colsCount">
147
+ <td v-bind="bodyCellDateSeparatorAttrs(rowIndex)" :colspan="colsCount">
119
148
  <UDivider
120
149
  size="xs"
121
150
  :label="getDateSeparatorLabel(row.date.separatorDate)"
122
- v-bind="dateSeparatorAttrs"
151
+ v-bind="bodyDateSeparatorAttrs"
123
152
  />
124
153
  </td>
125
154
  </tr>
126
155
 
127
156
  <tr
128
157
  v-if="!isShownRow(row)"
129
- v-bind="bodyRowAttrs(rowClass(row))"
158
+ v-bind="bodyRowAttrs(getRowClasses(row))"
130
159
  :data-cy="`${dataCy}-row`"
131
160
  @click="onClickRow(row)"
132
161
  >
133
- <td v-if="selectable" :data-id="row.id" v-bind="checkboxBodyWrapperCellAttrs">
162
+ <UTableCell
163
+ v-if="selectable"
164
+ :compact="compact"
165
+ v-bind="bodyCellAttrs(config.bodyCellCheckbox)"
166
+ >
134
167
  <UCheckbox
135
168
  v-model="selectedRows"
169
+ :data-id="row.id"
136
170
  :value="row.id"
137
171
  size="sm"
138
172
  :data-cy="`${dataCy}-table-body-checkbox`"
139
- v-bind="tableCheckboxAttrs"
173
+ v-bind="bodyCheckboxAttrs"
140
174
  @click.stop
141
175
  />
142
- </td>
176
+ </UTableCell>
143
177
 
144
178
  <UTableCell
145
179
  v-for="(value, key, index) in TableService.getFilteredRow(row, columns)"
146
180
  :key="index"
147
181
  :compact="compact"
148
- v-bind="bodyCellAttrs(getTdClass(key))"
182
+ v-bind="bodyCellAttrs(getCellClasses(key))"
149
183
  >
150
184
  <template v-if="Boolean($slots[`cell-${key}`])">
151
185
  <div
152
- :style="setLeftMargin(row.nestedLevel)"
153
- v-bind="toggleButtonWrapperAttrs(index)"
154
- @click="onClickShowItem(row)"
186
+ :style="getNestedShift(row.nestedLevel)"
187
+ v-bind="bodyCellNestedWrapperAttrs(index)"
188
+ @click="onClickNestedWrapper(row)"
155
189
  >
156
- <div v-if="isShownIcon({ index, row })" v-bind="toggleItemButtonAttrs">
190
+ <div v-if="isShownNestedIcon({ index, row })" v-bind="bodyCellNestedAttrs">
157
191
  <UIcon
158
192
  v-if="row.isHidden"
159
193
  size="xs"
160
194
  internal
161
195
  interactive
162
- :name="config.expandIconName"
163
- :color="isIconActive(row)"
164
- v-bind="expandIconAttrs"
196
+ :name="config.bodyCellNestedExpandIconName"
197
+ :color="isActiveNestedIcon(row)"
198
+ v-bind="bodyCellNestedExpandIconAttrs"
165
199
  />
166
200
 
167
201
  <UIcon
@@ -169,8 +203,8 @@
169
203
  size="xs"
170
204
  internal
171
205
  interactive
172
- :name="config.collapseIconName"
173
- v-bind="collapseIconAttrs"
206
+ :name="config.bodyCellNestedCollapseIconName"
207
+ v-bind="bodyCellNestedCollapseIconAttrs"
174
208
  />
175
209
  </div>
176
210
  <!-- @slot Use it to customise table cell item (in whole column). -->
@@ -178,26 +212,22 @@
178
212
  </div>
179
213
  </template>
180
214
 
181
- <template v-else-if="Boolean($slots['cell-other'])">
182
- <slot name="cell-other" :value="value" :row="row" />
183
- </template>
184
-
185
- <template v-else-if="value?.hasOwnProperty('secondaryRow')">
215
+ <template v-else-if="value?.hasOwnProperty('secondary')">
186
216
  <div :data-cy="`${dataCy}-${key}-cell`">
187
- {{ value.primaryRow || HYPHEN_SYMBOL }}
217
+ {{ value.primary || HYPHEN_SYMBOL }}
188
218
  </div>
189
219
 
190
- <div v-bind="secondaryRowAttrs">
191
- <template v-if="Array.isArray(value.secondaryRow)">
192
- <div v-for="(secondaryRow, idx) in value.secondaryRow" :key="idx">
193
- <span v-bind="secondaryRowEmptyAttrs">
194
- {{ secondaryRow }}
220
+ <div v-bind="bodyCellSecondaryAttrs">
221
+ <template v-if="Array.isArray(value.secondary)">
222
+ <div v-for="(secondary, idx) in value.secondary" :key="idx">
223
+ <span v-bind="bodyCellSecondaryEmptyAttrs">
224
+ {{ secondary }}
195
225
  </span>
196
226
  </div>
197
227
  </template>
198
228
 
199
229
  <template v-else>
200
- {{ value.secondaryRow }}
230
+ {{ value.secondary }}
201
231
  </template>
202
232
  </div>
203
233
  </template>
@@ -210,18 +240,18 @@
210
240
  </UTableCell>
211
241
  </tr>
212
242
 
213
- <tr v-if="rowIndex === lastRow" v-bind="afterLastRowAttrs">
243
+ <tr v-if="rowIndex === lastRow" v-bind="bodyRowAfterAttrs">
214
244
  <UTableCell
215
245
  v-if="hasSlotContent(slots['after-last-row'])"
216
246
  :compact="compact"
217
247
  :colspan="colsCount"
218
- v-bind="afterLastRowCellAttrs"
248
+ v-bind="bodyRowAfterCellAttrs"
219
249
  >
220
250
  <!-- @slot Use it to add something after last row. -->
221
251
  <slot name="after-last-row" />
222
252
  </UTableCell>
223
253
 
224
- <td v-else :colspan="colsCount" v-bind="afterLastRowCellAttrs" />
254
+ <td v-else :colspan="colsCount" v-bind="bodyRowAfterCellAttrs" />
225
255
  </tr>
226
256
  </template>
227
257
  </tbody>
@@ -229,31 +259,32 @@
229
259
  <tbody v-else>
230
260
  <tr>
231
261
  <td :colspan="colsCount">
232
- <slot name="empty-table-msg">
262
+ <!-- @slot Use it to add custom empty state. -->
263
+ <slot name="empty-state">
233
264
  <UEmpty
234
265
  size="sm"
235
266
  :description="emptyTableMsg"
236
267
  :data-cy="`${dataCy}-empty`"
237
- v-bind="emptyAttrs"
268
+ v-bind="bodyEmptyStateAttrs"
238
269
  />
239
270
  </slot>
240
271
  </td>
241
272
  </tr>
242
273
  </tbody>
243
274
 
244
- <tfoot v-if="hasSlotContent($slots['tfoot'])" v-bind="footerClassesAttrs">
245
- <tr ref="footerRow" v-bind="footerRowAttrs">
275
+ <tfoot v-if="hasSlotContent($slots['footer'])" v-bind="footerClassesAttrs">
276
+ <tr ref="footerRowRef" v-bind="footerRowAttrs">
246
277
  <UTableCell v-if="selectable" :compact="compact" v-bind="footerCellAttrs" />
247
278
 
248
279
  <!-- @slot Use it to add something in table footer. -->
249
- <slot name="tfoot" :cols-count="colsCount" />
280
+ <slot name="footer" :cols-count="colsCount" />
250
281
  </tr>
251
282
 
252
- <tr ref="footerStickyRow" :style="tableRowWidthStyle" v-bind="footerStickyRowAttrs">
283
+ <tr ref="stickyFooterRowRef" :style="tableRowWidthStyle" v-bind="stickyFooterRowAttrs">
253
284
  <UTableCell v-if="selectable" :compact="compact" v-bind="footerCellAttrs" />
254
285
 
255
286
  <!-- @slot Use it to add something in table footer. -->
256
- <slot name="tfoot" :cols-count="colsCount" />
287
+ <slot name="footer" :cols-count="colsCount" />
257
288
  </tr>
258
289
  </tfoot>
259
290
  </table>
@@ -313,7 +344,7 @@ const props = defineProps({
313
344
  },
314
345
 
315
346
  /**
316
- * Show/hide date divider or set label for specific date.
347
+ * Show date divider label.
317
348
  */
318
349
  dateDivider: {
319
350
  type: [Array, Boolean],
@@ -410,15 +441,14 @@ const tableWidth = ref(0);
410
441
  const tableHeight = ref(0);
411
442
  const pagePositionY = ref(0);
412
443
 
413
- const headerRow = ref(null);
414
- const footerRow = ref(null);
415
- const tableWrapper = ref(null);
416
- const footerStickyRow = ref(null);
417
- const headerStickyRow = ref(null);
444
+ const headerRowRef = ref(null);
445
+ const footerRowRef = ref(null);
446
+ const tableWrapperRef = ref(null);
447
+ const stickyFooterRowRef = ref(null);
448
+ const stickyHeaderRowRef = ref(null);
418
449
 
419
- const isHeaderSticky = computed(() => {
420
- return !isShownHeaderPosition.value;
421
- });
450
+ const i18nGlobal = tm(UTable);
451
+ const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
422
452
 
423
453
  const isFooterSticky = computed(
424
454
  () =>
@@ -428,9 +458,6 @@ const isFooterSticky = computed(
428
458
  isCheckedMoreOneTableItems.value,
429
459
  );
430
460
 
431
- const i18nGlobal = tm(UTable);
432
- const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
433
-
434
461
  const normalizedColumns = computed(() => TableService.normalizeColumns(props.columns));
435
462
 
436
463
  const isSelectedAllRows = computed(() => {
@@ -445,19 +472,20 @@ const lastRow = computed(() => {
445
472
  return props.rows.length - 1;
446
473
  });
447
474
 
448
- const isShownStickyOrActionsHeader = computed(() => {
449
- return isHeaderSticky.value || selectedRows.value.length;
450
- });
475
+ const isShownActionsHeader = computed(
476
+ () => hasSlotContent(slots["header-actions"]) && selectedRows.value.length,
477
+ );
451
478
 
452
- const isShownHeaderPosition = computed(() => {
453
- const positionForFixHeader = headerRow.value?.getBoundingClientRect().top + window.scrollY || 0;
479
+ const isHeaderSticky = computed(() => {
480
+ const positionForFixHeader =
481
+ headerRowRef.value?.getBoundingClientRect().top + window.scrollY || 0;
454
482
 
455
- return positionForFixHeader >= pagePositionY.value;
483
+ return positionForFixHeader <= pagePositionY.value && props.stickyHeader;
456
484
  });
457
485
 
458
486
  const isShownFooterPosition = computed(() => {
459
487
  const pageBottom = pagePositionY.value + window.innerHeight;
460
- const positionForFixFooter = footerRow.value?.getBoundingClientRect().bottom + window.scrollY;
488
+ const positionForFixFooter = footerRowRef.value?.getBoundingClientRect().bottom + window.scrollY;
461
489
 
462
490
  return pageBottom >= positionForFixFooter;
463
491
  });
@@ -474,10 +502,6 @@ const hasSlotContentBeforeFirstRow = computed(() => {
474
502
  : false;
475
503
  });
476
504
 
477
- const hasSlotContentTheadActions = computed(() => {
478
- return hasSlotContent(slots["thead-actions"]);
479
- });
480
-
481
505
  const emptyTableMsg = computed(() => {
482
506
  return props.filters ? currentLocale.value.noResultsForFilters : currentLocale.value.noItems;
483
507
  });
@@ -489,48 +513,49 @@ const isNesting = computed(() => {
489
513
  const {
490
514
  config,
491
515
  wrapperAttrs,
492
- stickyHeaderColumnAttrs,
516
+ stickyHeaderCellAttrs,
493
517
  stickyHeaderAttrs,
494
518
  tableWrapperAttrs,
495
519
  headerRowAttrs,
496
- afterLastRowAttrs,
497
- afterLastRowCellAttrs,
498
- beforeFirstRowAttrs,
499
- beforeFirstRowCellAttrs,
520
+ bodyRowAfterAttrs,
521
+ bodyRowAfterCellAttrs,
522
+ bodyRowBeforeAttrs,
523
+ bodyRowBeforeCellAttrs,
500
524
  bodyRowAttrs,
501
525
  footerClassesAttrs,
502
- dateSeparatorRowAttrs,
503
- toggleButtonWrapperAttrs,
526
+ bodyRowDateSeparatorAttrs,
527
+ bodyCellNestedWrapperAttrs,
504
528
  headerCellAttrs,
505
529
  bodyCellAttrs,
506
- checkboxBodyWrapperCellAttrs,
507
530
  footerCellAttrs,
508
- selectAllCheckboxAttrs,
509
- headerSelectAllCheckboxAttrs,
510
- tableCheckboxAttrs,
511
- collapseIconAttrs,
512
- expandIconAttrs,
513
- emptyAttrs,
514
- dateSeparatorAttrs,
515
- selectedRowsCountAttrs,
531
+ stickyHeaderActionsCheckboxAttrs,
532
+ stickyHeaderCheckboxAttrs,
533
+ headerCheckboxAttrs,
534
+ bodyCheckboxAttrs,
535
+ bodyCellNestedCollapseIconAttrs,
536
+ bodyCellNestedExpandIconAttrs,
537
+ bodyEmptyStateAttrs,
538
+ bodyDateSeparatorAttrs,
539
+ bodyCellDateSeparatorAttrs,
540
+ stickyHeaderActionsCounterAttrs,
541
+ stickyHeaderCounterAttrs,
516
542
  stickyHeaderLoaderAttrs,
517
543
  tableAttrs,
518
- tableLoaderAttrs,
544
+ headerLoaderAttrs,
519
545
  bodyAttrs,
520
- toggleItemButtonAttrs,
521
- secondaryRowAttrs,
522
- secondaryRowEmptyAttrs,
546
+ bodyCellNestedAttrs,
547
+ bodyCellSecondaryAttrs,
548
+ bodyCellSecondaryEmptyAttrs,
523
549
  footerRowAttrs,
524
- footerStickyRowAttrs,
550
+ stickyFooterRowAttrs,
525
551
  hasSlotContent,
526
552
  headerAttrs,
527
553
  } = useAttrs(props, {
528
554
  tableRows,
529
- selectedRows,
530
555
  isNesting,
556
+ isShownActionsHeader,
531
557
  isHeaderSticky,
532
558
  isFooterSticky,
533
- hasSlotContentTheadActions,
534
559
  });
535
560
 
536
561
  watch(selectAll, onChangeSelectAll, { deep: true });
@@ -538,9 +563,9 @@ watch(selectedRows, onChangeSelectedRows, { deep: true });
538
563
  watch(tableRows, () => emit("update:rows", toValue(tableRows)), { deep: true });
539
564
  watch(() => tableRows.value.length, updateSelectedRows);
540
565
  watch(() => props.rows, synchronizeTableItemsWithProps, { deep: true });
541
- watch(isHeaderSticky, setHeaderItemsWidth);
566
+ watch(isHeaderSticky, setHeaderCellWidth);
542
567
  watch(isFooterSticky, (newValue) =>
543
- newValue ? nextTick(setFooterItemsWidth) : setFooterItemsWidth(true),
568
+ newValue ? nextTick(setFooterCellWidth) : setFooterCellWidth(null),
544
569
  );
545
570
  watch(
546
571
  () => selectedRows.value.length,
@@ -553,33 +578,33 @@ watch(
553
578
  },
554
579
  );
555
580
 
556
- tableRows.value = props.rows;
557
-
558
581
  onMounted(() => {
559
- document.addEventListener("keyup", onKeyupClearCheckbox);
560
- document.addEventListener("scroll", onScrollGetPosition, { passive: true });
561
- window.addEventListener("resize", onWindowResizeSetWidth);
582
+ tableRows.value = props.rows;
583
+
584
+ document.addEventListener("keyup", onKeyupEsc);
585
+ document.addEventListener("scroll", onScroll, { passive: true });
586
+ window.addEventListener("resize", onWindowResize);
562
587
  });
563
588
 
564
589
  onUpdated(() => {
565
- tableHeight.value = tableWrapper.value?.offsetHeight;
566
- tableWidth.value = tableWrapper.value?.offsetWidth;
590
+ tableHeight.value = tableWrapperRef.value?.offsetHeight;
591
+ tableWidth.value = tableWrapperRef.value?.offsetWidth;
567
592
  });
568
593
 
569
594
  onBeforeUnmount(() => {
570
- document.removeEventListener("keyup", onKeyupClearCheckbox);
571
- document.removeEventListener("scroll", onScrollGetPosition);
572
- window.removeEventListener("resize", onWindowResizeSetWidth);
595
+ document.removeEventListener("keyup", onKeyupEsc);
596
+ document.removeEventListener("scroll", onScroll);
597
+ window.removeEventListener("resize", onWindowResize);
573
598
  });
574
599
 
575
- function onWindowResizeSetWidth() {
576
- tableWidth.value = tableWrapper.value.offsetWidth;
600
+ function onWindowResize() {
601
+ tableWidth.value = tableWrapperRef.value.offsetWidth;
577
602
 
578
- setHeaderItemsWidth();
579
- setFooterItemsWidth();
603
+ setHeaderCellWidth();
604
+ setFooterCellWidth();
580
605
  }
581
606
 
582
- function isShownIcon({ index, row }) {
607
+ function isShownNestedIcon({ index, row }) {
583
608
  const isChildren = row.childrenIds?.length > 0;
584
609
  const isWithinNestingLevel = row.nestedLevel >= props.nesting;
585
610
 
@@ -588,11 +613,11 @@ function isShownIcon({ index, row }) {
588
613
  return isFirstRow && (isChildren || row.isNestingRow) && isNesting.value && isWithinNestingLevel;
589
614
  }
590
615
 
591
- function isIconActive(row) {
616
+ function isActiveNestedIcon(row) {
592
617
  return !row.childrenIds?.length ? "grayscale" : "";
593
618
  }
594
619
 
595
- function onClickShowItem(row) {
620
+ function onClickNestedWrapper(row) {
596
621
  if (!isNesting.value || !row.childrenIds.length) return;
597
622
  const [firstElement] = row.childrenIds;
598
623
 
@@ -608,16 +633,16 @@ function onClickShowItem(row) {
608
633
  }
609
634
  }
610
635
 
636
+ function getNestedShift(nestedLevel) {
637
+ return { marginLeft: `${nestedLevel * 1.5}rem` };
638
+ }
639
+
611
640
  function getDateSeparatorLabel(separatorDate) {
612
641
  return Array.isArray(props.dateDivider)
613
642
  ? props.dateDivider.find((dateItem) => dateItem.date === separatorDate)?.label || separatorDate
614
643
  : separatorDate;
615
644
  }
616
645
 
617
- function setLeftMargin(nestedLevel) {
618
- return { marginLeft: `${nestedLevel * 1.5}rem` };
619
- }
620
-
621
646
  function isShownRow(row) {
622
647
  if (hiddenIds.value.includes(row.id)) {
623
648
  row.isHidden = true;
@@ -626,44 +651,35 @@ function isShownRow(row) {
626
651
  return hiddenIds.value.includes(row.id);
627
652
  }
628
653
 
629
- function setFooterItemsWidth(setNullWidth) {
654
+ function setFooterCellWidth(width) {
630
655
  const ZERO_WIDTH = 0;
631
656
 
632
657
  if (!props.stickyFooter) return;
633
658
 
634
- const mainFooterItems = [...footerRow.value.children];
635
- const stickyFooterItems = [...footerStickyRow.value.children];
659
+ const mainFooterItems = [...footerRowRef.value.children];
660
+ const stickyFooterItems = [...stickyFooterRowRef.value.children];
636
661
 
637
662
  stickyFooterItems.forEach((item, index) => {
638
- item.style.width = setNullWidth
639
- ? `${ZERO_WIDTH}rem`
640
- : `${mainFooterItems[index].offsetWidth / PX_IN_REM}rem`;
663
+ item.style.width =
664
+ width === null ? `${ZERO_WIDTH}rem` : `${mainFooterItems[index].offsetWidth / PX_IN_REM}rem`;
641
665
  });
642
666
  }
643
667
 
644
- function setHeaderItemsWidth() {
668
+ function setHeaderCellWidth() {
645
669
  if (selectedRows.value.length) return;
646
670
 
647
- const mainHeaderItems = [...(headerRow.value?.children || [])];
648
- const stickyHeaderItems = [...(headerStickyRow.value?.children || [])];
671
+ const mainHeaderItems = [...(headerRowRef.value?.children || [])];
672
+ const stickyHeaderItems = [...(stickyHeaderRowRef.value?.children || [])];
649
673
 
650
674
  stickyHeaderItems.forEach((item, index) => {
651
675
  item.style.width = `${mainHeaderItems[index]?.offsetWidth / PX_IN_REM}rem`;
652
676
  });
653
677
  }
654
678
 
655
- function onScrollGetPosition() {
679
+ function onScroll() {
656
680
  pagePositionY.value = window.scrollY;
657
681
  }
658
682
 
659
- function onKeyupClearCheckbox(event) {
660
- const escKeyCode = 27;
661
-
662
- if (event.keyCode === escKeyCode && props.selectable) {
663
- selectedRows.value = [];
664
- }
665
- }
666
-
667
683
  function synchronizeTableItemsWithProps() {
668
684
  if (!props.rows.length || props.rows.length !== tableRows.value.length) {
669
685
  selectedRows.value = [];
@@ -682,6 +698,14 @@ function updateSelectedRows() {
682
698
  selectedRows.value = tableRows.value.filter((row) => row.isChecked).map((row) => row.id);
683
699
  }
684
700
 
701
+ function onKeyupEsc(event) {
702
+ const escKeyCode = 27;
703
+
704
+ if (event.keyCode === escKeyCode && props.selectable) {
705
+ selectedRows.value = [];
706
+ }
707
+ }
708
+
685
709
  function isShownDateSeparator(rowIndex) {
686
710
  const prevIndex = rowIndex ? rowIndex - 1 : rowIndex;
687
711
  const nextIndex = rowIndex ? rowIndex + 1 : rowIndex;
@@ -693,21 +717,21 @@ function isShownDateSeparator(rowIndex) {
693
717
  return hasSlotContentBeforeFirstRow.value;
694
718
  }
695
719
 
696
- const isPrevSameDate = prevItem?.date?.primaryRow === currentItem?.date?.primaryRow;
697
- const isNextSameDate = nextItem?.date?.primaryRow === currentItem?.date?.primaryRow;
720
+ const isPrevSameDate = prevItem?.date?.primary === currentItem?.date?.primary;
721
+ const isNextSameDate = nextItem?.date?.primary === currentItem?.date?.primary;
698
722
 
699
723
  return isPrevSameDate && !isNextSameDate && props.dateDivider;
700
724
  }
701
725
 
702
- function rowClass(row) {
703
- return selectedRows.value.includes(row.id) ? config.value.checkedRow : "";
704
- }
705
-
706
726
  function onClickRow(row) {
707
727
  emit("clickRow", row);
708
728
  }
709
729
 
710
- function getTdClass(key) {
730
+ function getRowClasses(row) {
731
+ return selectedRows.value.includes(row.id) ? config.value.bodyRowChecked : "";
732
+ }
733
+
734
+ function getCellClasses(key) {
711
735
  return props.columns.find((column) => column.key === key)?.tdClass;
712
736
  }
713
737
 
@@ -729,9 +753,9 @@ function onChangeSelectedRows(selectedRows) {
729
753
  if (selectedRows.length) {
730
754
  canSelectAll.value = false;
731
755
 
732
- isCheckedMoreOneTableItems.value ? setFooterItemsWidth() : "";
756
+ isCheckedMoreOneTableItems.value ? setFooterCellWidth() : "";
733
757
  } else {
734
- nextTick(setHeaderItemsWidth);
758
+ nextTick(setHeaderCellWidth);
735
759
  }
736
760
 
737
761
  selectAll.value = !!selectedRows.length;