vueless 0.0.165 → 0.0.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/ui.data-table/composables/attrs.composable.js +122 -114
- package/ui.data-table/configs/default.config.js +42 -49
- package/ui.data-table/index.stories.js +40 -35
- package/ui.data-table/index.vue +220 -196
- package/ui.data-table-cell/configs/default.config.js +1 -1
- package/web-types.json +12 -21
package/ui.data-table/index.vue
CHANGED
|
@@ -1,42 +1,59 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :data-cy="dataCy" v-bind="wrapperAttrs">
|
|
3
3
|
<div
|
|
4
|
-
v-show="
|
|
5
|
-
ref="
|
|
4
|
+
v-show="isHeaderSticky || isShownActionsHeader"
|
|
5
|
+
ref="stickyHeaderRowRef"
|
|
6
6
|
:style="tableRowWidthStyle"
|
|
7
7
|
v-bind="stickyHeaderAttrs"
|
|
8
8
|
>
|
|
9
|
-
<
|
|
10
|
-
v-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
<div
|
|
22
|
+
v-if="selectedRows.length"
|
|
23
|
+
v-bind="stickyHeaderActionsCounterAttrs"
|
|
24
|
+
v-text="selectedRows.length"
|
|
25
|
+
/>
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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="
|
|
52
|
+
v-bind="stickyHeaderCellAttrs(column.thClass)"
|
|
36
53
|
>
|
|
37
|
-
<template v-if="hasSlotContent($slots[`
|
|
54
|
+
<template v-if="hasSlotContent($slots[`header-${column.key}`])">
|
|
38
55
|
<!-- @slot Use it to customise table column. -->
|
|
39
|
-
<slot :name="`
|
|
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="`
|
|
64
|
+
<slot :name="`header-${column.key}-after`" :column="column" />
|
|
48
65
|
</div>
|
|
49
66
|
</template>
|
|
50
67
|
|
|
@@ -55,21 +72,37 @@
|
|
|
55
72
|
/>
|
|
56
73
|
</div>
|
|
57
74
|
|
|
58
|
-
<div ref="
|
|
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
|
|
62
|
-
<
|
|
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
|
|
66
|
-
|
|
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="
|
|
99
|
+
v-bind="headerCheckboxAttrs"
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
|
+
<div
|
|
103
|
+
v-if="selectedRows.length"
|
|
104
|
+
v-bind="headerCounterAttrs"
|
|
105
|
+
v-text="selectedRows.length"
|
|
73
106
|
/>
|
|
74
107
|
</th>
|
|
75
108
|
|
|
@@ -78,90 +111,98 @@
|
|
|
78
111
|
:key="index"
|
|
79
112
|
v-bind="headerCellAttrs(column.thClass)"
|
|
80
113
|
>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
114
|
+
<!-- @slot Use it to customise table column. -->
|
|
115
|
+
<slot
|
|
116
|
+
v-if="hasSlotContent($slots[`header-${column.key}`])"
|
|
117
|
+
:name="`header-${column.key}`"
|
|
118
|
+
:column="column"
|
|
119
|
+
/>
|
|
85
120
|
|
|
86
121
|
<template v-else>
|
|
87
122
|
{{ column.label }}
|
|
88
123
|
</template>
|
|
89
124
|
|
|
90
125
|
<!-- @slot Use it to add content after table column. -->
|
|
91
|
-
<slot :name="`
|
|
126
|
+
<slot :name="`header-${column.key}-after`" :column="column" />
|
|
92
127
|
</th>
|
|
93
128
|
</tr>
|
|
94
129
|
|
|
95
|
-
<ULoaderTop v-if="resource" :resource-names="resource" v-bind="
|
|
130
|
+
<ULoaderTop v-if="resource" :resource-names="resource" v-bind="headerLoaderAttrs" />
|
|
96
131
|
</thead>
|
|
97
132
|
|
|
98
133
|
<tbody v-if="tableRows.length" v-bind="bodyAttrs">
|
|
99
134
|
<template v-for="(row, rowIndex) in tableRows" :key="row.id">
|
|
100
|
-
<tr v-if="rowIndex === firstRow" v-bind="
|
|
135
|
+
<tr v-if="rowIndex === firstRow" v-bind="bodyRowBeforeAttrs">
|
|
101
136
|
<UTableCell
|
|
102
137
|
v-if="hasSlotContent($slots['before-first-row'])"
|
|
103
138
|
:colspan="colsCount"
|
|
104
139
|
:compact="compact"
|
|
105
|
-
v-bind="
|
|
140
|
+
v-bind="bodyRowBeforeCellAttrs"
|
|
106
141
|
>
|
|
107
142
|
<!-- @slot Use it to add something before first row. -->
|
|
108
143
|
<slot name="before-first-row" />
|
|
109
144
|
</UTableCell>
|
|
110
145
|
|
|
111
|
-
<td v-else :colspan="colsCount" v-bind="
|
|
146
|
+
<td v-else :colspan="colsCount" v-bind="bodyRowBeforeCellAttrs" />
|
|
112
147
|
</tr>
|
|
113
148
|
|
|
114
149
|
<tr
|
|
115
150
|
v-if="isShownDateSeparator(rowIndex) && row.date"
|
|
116
|
-
v-bind="
|
|
151
|
+
v-bind="bodyRowDateSeparatorAttrs(rowIndex)"
|
|
117
152
|
>
|
|
118
|
-
<td :colspan="colsCount">
|
|
153
|
+
<td v-bind="bodyCellDateSeparatorAttrs(rowIndex)" :colspan="colsCount">
|
|
119
154
|
<UDivider
|
|
120
155
|
size="xs"
|
|
121
156
|
:label="getDateSeparatorLabel(row.date.separatorDate)"
|
|
122
|
-
v-bind="
|
|
157
|
+
v-bind="bodyDateSeparatorAttrs"
|
|
123
158
|
/>
|
|
124
159
|
</td>
|
|
125
160
|
</tr>
|
|
126
161
|
|
|
127
162
|
<tr
|
|
128
163
|
v-if="!isShownRow(row)"
|
|
129
|
-
v-bind="bodyRowAttrs(
|
|
164
|
+
v-bind="bodyRowAttrs(getRowClasses(row))"
|
|
130
165
|
:data-cy="`${dataCy}-row`"
|
|
131
166
|
@click="onClickRow(row)"
|
|
132
167
|
>
|
|
133
|
-
<
|
|
168
|
+
<UTableCell
|
|
169
|
+
v-if="selectable"
|
|
170
|
+
:compact="compact"
|
|
171
|
+
v-bind="bodyCellAttrs(config.bodyCellCheckbox)"
|
|
172
|
+
>
|
|
134
173
|
<UCheckbox
|
|
135
174
|
v-model="selectedRows"
|
|
175
|
+
:data-id="row.id"
|
|
136
176
|
:value="row.id"
|
|
137
177
|
size="sm"
|
|
138
|
-
:data-cy="`${dataCy}-
|
|
139
|
-
v-bind="
|
|
178
|
+
:data-cy="`${dataCy}-body-checkbox`"
|
|
179
|
+
v-bind="bodyCheckboxAttrs"
|
|
140
180
|
@click.stop
|
|
141
181
|
/>
|
|
142
|
-
</
|
|
182
|
+
</UTableCell>
|
|
143
183
|
|
|
144
184
|
<UTableCell
|
|
145
185
|
v-for="(value, key, index) in TableService.getFilteredRow(row, columns)"
|
|
146
186
|
:key="index"
|
|
147
187
|
:compact="compact"
|
|
148
|
-
v-bind="bodyCellAttrs(
|
|
188
|
+
v-bind="bodyCellAttrs(getCellClasses(key))"
|
|
149
189
|
>
|
|
150
|
-
<template v-if="
|
|
190
|
+
<template v-if="hasSlotContent($slots[`cell-${key}`])">
|
|
151
191
|
<div
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
192
|
+
v-if="isNesting"
|
|
193
|
+
:style="getNestedShift(row.nestedLevel)"
|
|
194
|
+
v-bind="bodyCellNestedWrapperAttrs(index)"
|
|
195
|
+
@click="onClickNestedWrapper(row)"
|
|
155
196
|
>
|
|
156
|
-
<div v-if="
|
|
197
|
+
<div v-if="isShownNestedIcon({ index, row })" v-bind="bodyCellNestedAttrs">
|
|
157
198
|
<UIcon
|
|
158
199
|
v-if="row.isHidden"
|
|
159
200
|
size="xs"
|
|
160
201
|
internal
|
|
161
202
|
interactive
|
|
162
|
-
:name="config.
|
|
163
|
-
:color="
|
|
164
|
-
v-bind="
|
|
203
|
+
:name="config.bodyCellNestedExpandIconName"
|
|
204
|
+
:color="isActiveNestedIcon(row)"
|
|
205
|
+
v-bind="bodyCellNestedExpandIconAttrs"
|
|
165
206
|
/>
|
|
166
207
|
|
|
167
208
|
<UIcon
|
|
@@ -169,35 +210,32 @@
|
|
|
169
210
|
size="xs"
|
|
170
211
|
internal
|
|
171
212
|
interactive
|
|
172
|
-
:name="config.
|
|
173
|
-
v-bind="
|
|
213
|
+
:name="config.bodyCellNestedCollapseIconName"
|
|
214
|
+
v-bind="bodyCellNestedCollapseIconAttrs"
|
|
174
215
|
/>
|
|
175
216
|
</div>
|
|
176
|
-
<!-- @slot Use it to customise table cell item (in whole column). -->
|
|
177
|
-
<slot :name="`cell-${key}`" :value="value" :row="row" />
|
|
178
217
|
</div>
|
|
179
|
-
</template>
|
|
180
218
|
|
|
181
|
-
|
|
182
|
-
<slot name="cell
|
|
219
|
+
<!-- @slot Use it to customise table cell item (in whole column). -->
|
|
220
|
+
<slot :name="`cell-${key}`" :value="value" :row="row" />
|
|
183
221
|
</template>
|
|
184
222
|
|
|
185
|
-
<template v-else-if="value?.hasOwnProperty('
|
|
223
|
+
<template v-else-if="value?.hasOwnProperty('secondary')">
|
|
186
224
|
<div :data-cy="`${dataCy}-${key}-cell`">
|
|
187
|
-
{{ value.
|
|
225
|
+
{{ value.primary || HYPHEN_SYMBOL }}
|
|
188
226
|
</div>
|
|
189
227
|
|
|
190
|
-
<div v-bind="
|
|
191
|
-
<template v-if="Array.isArray(value.
|
|
192
|
-
<div v-for="(
|
|
193
|
-
<span v-bind="
|
|
194
|
-
{{
|
|
228
|
+
<div v-bind="bodyCellSecondaryAttrs">
|
|
229
|
+
<template v-if="Array.isArray(value.secondary)">
|
|
230
|
+
<div v-for="(secondary, idx) in value.secondary" :key="idx">
|
|
231
|
+
<span v-bind="bodyCellSecondaryEmptyAttrs">
|
|
232
|
+
{{ secondary }}
|
|
195
233
|
</span>
|
|
196
234
|
</div>
|
|
197
235
|
</template>
|
|
198
236
|
|
|
199
237
|
<template v-else>
|
|
200
|
-
{{ value.
|
|
238
|
+
{{ value.secondary }}
|
|
201
239
|
</template>
|
|
202
240
|
</div>
|
|
203
241
|
</template>
|
|
@@ -210,18 +248,18 @@
|
|
|
210
248
|
</UTableCell>
|
|
211
249
|
</tr>
|
|
212
250
|
|
|
213
|
-
<tr v-if="rowIndex === lastRow" v-bind="
|
|
251
|
+
<tr v-if="rowIndex === lastRow" v-bind="bodyRowAfterAttrs">
|
|
214
252
|
<UTableCell
|
|
215
|
-
v-if="hasSlotContent(slots['after-last-row'])"
|
|
253
|
+
v-if="hasSlotContent($slots['after-last-row'])"
|
|
216
254
|
:compact="compact"
|
|
217
255
|
:colspan="colsCount"
|
|
218
|
-
v-bind="
|
|
256
|
+
v-bind="bodyRowAfterCellAttrs"
|
|
219
257
|
>
|
|
220
258
|
<!-- @slot Use it to add something after last row. -->
|
|
221
259
|
<slot name="after-last-row" />
|
|
222
260
|
</UTableCell>
|
|
223
261
|
|
|
224
|
-
<td v-else :colspan="colsCount" v-bind="
|
|
262
|
+
<td v-else :colspan="colsCount" v-bind="bodyRowAfterCellAttrs" />
|
|
225
263
|
</tr>
|
|
226
264
|
</template>
|
|
227
265
|
</tbody>
|
|
@@ -229,31 +267,32 @@
|
|
|
229
267
|
<tbody v-else>
|
|
230
268
|
<tr>
|
|
231
269
|
<td :colspan="colsCount">
|
|
232
|
-
|
|
270
|
+
<!-- @slot Use it to add custom empty state. -->
|
|
271
|
+
<slot name="empty-state">
|
|
233
272
|
<UEmpty
|
|
234
273
|
size="sm"
|
|
235
|
-
:description="
|
|
274
|
+
:description="currentLocale.noData"
|
|
236
275
|
:data-cy="`${dataCy}-empty`"
|
|
237
|
-
v-bind="
|
|
276
|
+
v-bind="bodyEmptyStateAttrs"
|
|
238
277
|
/>
|
|
239
278
|
</slot>
|
|
240
279
|
</td>
|
|
241
280
|
</tr>
|
|
242
281
|
</tbody>
|
|
243
282
|
|
|
244
|
-
<tfoot v-if="hasSlotContent($slots['
|
|
245
|
-
<tr ref="
|
|
283
|
+
<tfoot v-if="hasSlotContent($slots['footer'])" v-bind="footerClassesAttrs">
|
|
284
|
+
<tr ref="footerRowRef" v-bind="footerRowAttrs">
|
|
246
285
|
<UTableCell v-if="selectable" :compact="compact" v-bind="footerCellAttrs" />
|
|
247
286
|
|
|
248
287
|
<!-- @slot Use it to add something in table footer. -->
|
|
249
|
-
<slot name="
|
|
288
|
+
<slot name="footer" :cols-count="colsCount" />
|
|
250
289
|
</tr>
|
|
251
290
|
|
|
252
|
-
<tr ref="
|
|
291
|
+
<tr ref="stickyFooterRowRef" :style="tableRowWidthStyle" v-bind="stickyFooterRowAttrs">
|
|
253
292
|
<UTableCell v-if="selectable" :compact="compact" v-bind="footerCellAttrs" />
|
|
254
293
|
|
|
255
294
|
<!-- @slot Use it to add something in table footer. -->
|
|
256
|
-
<slot name="
|
|
295
|
+
<slot name="footer" :cols-count="colsCount" />
|
|
257
296
|
</tr>
|
|
258
297
|
</tfoot>
|
|
259
298
|
</table>
|
|
@@ -313,7 +352,7 @@ const props = defineProps({
|
|
|
313
352
|
},
|
|
314
353
|
|
|
315
354
|
/**
|
|
316
|
-
* Show
|
|
355
|
+
* Show date divider label.
|
|
317
356
|
*/
|
|
318
357
|
dateDivider: {
|
|
319
358
|
type: [Array, Boolean],
|
|
@@ -356,18 +395,10 @@ const props = defineProps({
|
|
|
356
395
|
* Sets the nesting level from which folding button need to be shown.
|
|
357
396
|
*/
|
|
358
397
|
nesting: {
|
|
359
|
-
type: Number,
|
|
398
|
+
type: [Number, Boolean],
|
|
360
399
|
default: UIService.get(defaultConfig, UTable).default.nesting,
|
|
361
400
|
},
|
|
362
401
|
|
|
363
|
-
/**
|
|
364
|
-
* Indicate if filters applied.
|
|
365
|
-
*/
|
|
366
|
-
filters: {
|
|
367
|
-
type: Boolean,
|
|
368
|
-
default: false,
|
|
369
|
-
},
|
|
370
|
-
|
|
371
402
|
/**
|
|
372
403
|
* Set loader resource name to activate table top loader exact for that resource.
|
|
373
404
|
*/
|
|
@@ -410,15 +441,14 @@ const tableWidth = ref(0);
|
|
|
410
441
|
const tableHeight = ref(0);
|
|
411
442
|
const pagePositionY = ref(0);
|
|
412
443
|
|
|
413
|
-
const
|
|
414
|
-
const
|
|
415
|
-
const
|
|
416
|
-
const
|
|
417
|
-
const
|
|
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
|
|
420
|
-
|
|
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
|
|
449
|
-
|
|
450
|
-
|
|
475
|
+
const isShownActionsHeader = computed(
|
|
476
|
+
() => hasSlotContent(slots["header-actions"]) && selectedRows.value.length,
|
|
477
|
+
);
|
|
451
478
|
|
|
452
|
-
const
|
|
453
|
-
const positionForFixHeader =
|
|
479
|
+
const isHeaderSticky = computed(() => {
|
|
480
|
+
const positionForFixHeader =
|
|
481
|
+
headerRowRef.value?.getBoundingClientRect().top + window.scrollY || 0;
|
|
454
482
|
|
|
455
|
-
return positionForFixHeader
|
|
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 =
|
|
488
|
+
const positionForFixFooter = footerRowRef.value?.getBoundingClientRect().bottom + window.scrollY;
|
|
461
489
|
|
|
462
490
|
return pageBottom >= positionForFixFooter;
|
|
463
491
|
});
|
|
@@ -474,63 +502,57 @@ const hasSlotContentBeforeFirstRow = computed(() => {
|
|
|
474
502
|
: false;
|
|
475
503
|
});
|
|
476
504
|
|
|
477
|
-
const hasSlotContentTheadActions = computed(() => {
|
|
478
|
-
return hasSlotContent(slots["thead-actions"]);
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
const emptyTableMsg = computed(() => {
|
|
482
|
-
return props.filters ? currentLocale.value.noResultsForFilters : currentLocale.value.noItems;
|
|
483
|
-
});
|
|
484
|
-
|
|
485
505
|
const isNesting = computed(() => {
|
|
486
|
-
return
|
|
506
|
+
return Boolean(props.nesting) || props.nesting === 0;
|
|
487
507
|
});
|
|
488
508
|
|
|
489
509
|
const {
|
|
490
510
|
config,
|
|
491
511
|
wrapperAttrs,
|
|
492
|
-
|
|
512
|
+
stickyHeaderCellAttrs,
|
|
493
513
|
stickyHeaderAttrs,
|
|
494
514
|
tableWrapperAttrs,
|
|
495
515
|
headerRowAttrs,
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
516
|
+
bodyRowAfterAttrs,
|
|
517
|
+
bodyRowAfterCellAttrs,
|
|
518
|
+
bodyRowBeforeAttrs,
|
|
519
|
+
bodyRowBeforeCellAttrs,
|
|
500
520
|
bodyRowAttrs,
|
|
501
521
|
footerClassesAttrs,
|
|
502
|
-
|
|
503
|
-
|
|
522
|
+
bodyRowDateSeparatorAttrs,
|
|
523
|
+
bodyCellNestedWrapperAttrs,
|
|
504
524
|
headerCellAttrs,
|
|
505
525
|
bodyCellAttrs,
|
|
506
|
-
checkboxBodyWrapperCellAttrs,
|
|
507
526
|
footerCellAttrs,
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
527
|
+
stickyHeaderActionsCheckboxAttrs,
|
|
528
|
+
stickyHeaderCheckboxAttrs,
|
|
529
|
+
headerCheckboxAttrs,
|
|
530
|
+
headerCounterAttrs,
|
|
531
|
+
bodyCheckboxAttrs,
|
|
532
|
+
bodyCellNestedCollapseIconAttrs,
|
|
533
|
+
bodyCellNestedExpandIconAttrs,
|
|
534
|
+
bodyEmptyStateAttrs,
|
|
535
|
+
bodyDateSeparatorAttrs,
|
|
536
|
+
bodyCellDateSeparatorAttrs,
|
|
537
|
+
stickyHeaderActionsCounterAttrs,
|
|
538
|
+
stickyHeaderCounterAttrs,
|
|
516
539
|
stickyHeaderLoaderAttrs,
|
|
517
540
|
tableAttrs,
|
|
518
|
-
|
|
541
|
+
headerLoaderAttrs,
|
|
519
542
|
bodyAttrs,
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
543
|
+
bodyCellNestedAttrs,
|
|
544
|
+
bodyCellSecondaryAttrs,
|
|
545
|
+
bodyCellSecondaryEmptyAttrs,
|
|
523
546
|
footerRowAttrs,
|
|
524
|
-
|
|
547
|
+
stickyFooterRowAttrs,
|
|
525
548
|
hasSlotContent,
|
|
526
549
|
headerAttrs,
|
|
527
550
|
} = useAttrs(props, {
|
|
528
551
|
tableRows,
|
|
529
|
-
selectedRows,
|
|
530
552
|
isNesting,
|
|
553
|
+
isShownActionsHeader,
|
|
531
554
|
isHeaderSticky,
|
|
532
555
|
isFooterSticky,
|
|
533
|
-
hasSlotContentTheadActions,
|
|
534
556
|
});
|
|
535
557
|
|
|
536
558
|
watch(selectAll, onChangeSelectAll, { deep: true });
|
|
@@ -538,9 +560,9 @@ watch(selectedRows, onChangeSelectedRows, { deep: true });
|
|
|
538
560
|
watch(tableRows, () => emit("update:rows", toValue(tableRows)), { deep: true });
|
|
539
561
|
watch(() => tableRows.value.length, updateSelectedRows);
|
|
540
562
|
watch(() => props.rows, synchronizeTableItemsWithProps, { deep: true });
|
|
541
|
-
watch(isHeaderSticky,
|
|
563
|
+
watch(isHeaderSticky, setHeaderCellWidth);
|
|
542
564
|
watch(isFooterSticky, (newValue) =>
|
|
543
|
-
newValue ? nextTick(
|
|
565
|
+
newValue ? nextTick(setFooterCellWidth) : setFooterCellWidth(null),
|
|
544
566
|
);
|
|
545
567
|
watch(
|
|
546
568
|
() => selectedRows.value.length,
|
|
@@ -553,46 +575,47 @@ watch(
|
|
|
553
575
|
},
|
|
554
576
|
);
|
|
555
577
|
|
|
556
|
-
tableRows.value = props.rows;
|
|
557
|
-
|
|
558
578
|
onMounted(() => {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
579
|
+
tableRows.value = props.rows;
|
|
580
|
+
|
|
581
|
+
document.addEventListener("keyup", onKeyupEsc);
|
|
582
|
+
document.addEventListener("scroll", onScroll, { passive: true });
|
|
583
|
+
window.addEventListener("resize", onWindowResize);
|
|
562
584
|
});
|
|
563
585
|
|
|
564
586
|
onUpdated(() => {
|
|
565
|
-
tableHeight.value =
|
|
566
|
-
tableWidth.value =
|
|
587
|
+
tableHeight.value = tableWrapperRef.value?.offsetHeight;
|
|
588
|
+
tableWidth.value = tableWrapperRef.value?.offsetWidth;
|
|
567
589
|
});
|
|
568
590
|
|
|
569
591
|
onBeforeUnmount(() => {
|
|
570
|
-
document.removeEventListener("keyup",
|
|
571
|
-
document.removeEventListener("scroll",
|
|
572
|
-
window.removeEventListener("resize",
|
|
592
|
+
document.removeEventListener("keyup", onKeyupEsc);
|
|
593
|
+
document.removeEventListener("scroll", onScroll);
|
|
594
|
+
window.removeEventListener("resize", onWindowResize);
|
|
573
595
|
});
|
|
574
596
|
|
|
575
|
-
function
|
|
576
|
-
tableWidth.value =
|
|
597
|
+
function onWindowResize() {
|
|
598
|
+
tableWidth.value = tableWrapperRef.value.offsetWidth;
|
|
577
599
|
|
|
578
|
-
|
|
579
|
-
|
|
600
|
+
setHeaderCellWidth();
|
|
601
|
+
setFooterCellWidth();
|
|
580
602
|
}
|
|
581
603
|
|
|
582
|
-
function
|
|
604
|
+
function isShownNestedIcon({ index, row }) {
|
|
605
|
+
const nestedLevel = props.nesting === true ? 0 : Number(props.nesting);
|
|
606
|
+
const isWithinNestingLevel = row.nestedLevel >= nestedLevel;
|
|
583
607
|
const isChildren = row.childrenIds?.length > 0;
|
|
584
|
-
const isWithinNestingLevel = row.nestedLevel >= props.nesting;
|
|
585
608
|
|
|
586
609
|
const isFirstRow = index === 0;
|
|
587
610
|
|
|
588
611
|
return isFirstRow && (isChildren || row.isNestingRow) && isNesting.value && isWithinNestingLevel;
|
|
589
612
|
}
|
|
590
613
|
|
|
591
|
-
function
|
|
614
|
+
function isActiveNestedIcon(row) {
|
|
592
615
|
return !row.childrenIds?.length ? "grayscale" : "";
|
|
593
616
|
}
|
|
594
617
|
|
|
595
|
-
function
|
|
618
|
+
function onClickNestedWrapper(row) {
|
|
596
619
|
if (!isNesting.value || !row.childrenIds.length) return;
|
|
597
620
|
const [firstElement] = row.childrenIds;
|
|
598
621
|
|
|
@@ -601,23 +624,25 @@ function onClickShowItem(row) {
|
|
|
601
624
|
if (row.isHidden && row.childrenIds.length) {
|
|
602
625
|
hiddenIds.value.push(...row.childrenIds);
|
|
603
626
|
} else {
|
|
627
|
+
const nestedLevel = props.nesting === true ? 0 : Number(props.nesting);
|
|
628
|
+
|
|
604
629
|
hiddenIds.value =
|
|
605
|
-
row.nestedLevel ===
|
|
630
|
+
row.nestedLevel === nestedLevel
|
|
606
631
|
? row.childrenIds.filter((item) => !hiddenIds.value.includes(item))
|
|
607
632
|
: hiddenIds.value.filter((item) => item !== firstElement);
|
|
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
|
|
654
|
+
function setFooterCellWidth(width) {
|
|
630
655
|
const ZERO_WIDTH = 0;
|
|
631
656
|
|
|
632
657
|
if (!props.stickyFooter) return;
|
|
633
658
|
|
|
634
|
-
const mainFooterItems = [...
|
|
635
|
-
const stickyFooterItems = [...
|
|
659
|
+
const mainFooterItems = [...footerRowRef.value.children];
|
|
660
|
+
const stickyFooterItems = [...stickyFooterRowRef.value.children];
|
|
636
661
|
|
|
637
662
|
stickyFooterItems.forEach((item, index) => {
|
|
638
|
-
item.style.width =
|
|
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
|
|
668
|
+
function setHeaderCellWidth() {
|
|
645
669
|
if (selectedRows.value.length) return;
|
|
646
670
|
|
|
647
|
-
const mainHeaderItems = [...(
|
|
648
|
-
const stickyHeaderItems = [...(
|
|
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
|
|
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?.
|
|
697
|
-
const isNextSameDate = nextItem?.date?.
|
|
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
|
|
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 ?
|
|
756
|
+
isCheckedMoreOneTableItems.value ? setFooterCellWidth() : "";
|
|
733
757
|
} else {
|
|
734
|
-
nextTick(
|
|
758
|
+
nextTick(setHeaderCellWidth);
|
|
735
759
|
}
|
|
736
760
|
|
|
737
761
|
selectAll.value = !!selectedRows.length;
|