@dataloop-ai/components 0.18.144 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/src/assets/constants.scss +25 -26
- package/src/assets/globals.scss +58 -56
- package/src/assets/grid.css +1 -1
- package/src/assets/grid.scss +4 -4
- package/src/components/basic/DlAccordion/DlAccordion.vue +10 -3
- package/src/components/basic/DlEmptyState/types.ts +1 -1
- package/src/components/basic/DlGrid/DlGrid.vue +2 -1
- package/src/components/basic/DlPopup/DlPopup.vue +159 -396
- package/src/components/basic/DlWidget/DlWidget.vue +2 -1
- package/src/components/basic/utils.ts +0 -9
- package/src/components/blocks/DlLabelPicker/DlLabelPicker.vue +127 -0
- package/src/components/blocks/DlLabelPicker/index.ts +3 -0
- package/src/components/blocks/DlLabelPicker/types.ts +6 -0
- package/src/components/blocks/index.ts +1 -0
- package/src/components/blocks/types.ts +1 -0
- package/src/components/compound/DlCodeEditor/README.md +5 -4
- package/src/components/compound/DlCodeEditor/styles/themes-base16.css +16934 -11289
- package/src/components/compound/DlCodeEditor/styles/themes.css +5122 -3448
- package/src/components/compound/DlInput/DlInput.vue +609 -178
- package/src/components/compound/DlInput/components/InputFileElement.vue +97 -0
- package/src/components/compound/DlInput/types.ts +12 -0
- package/src/components/compound/DlInput/utils.ts +117 -0
- package/src/components/compound/DlSearches/DlSearch/DlSearch.vue +10 -1
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +12 -3
- package/src/components/compound/DlSearches/DlSmartSearch/utils/highlightSyntax.ts +1 -1
- package/src/components/compound/DlSlider/sliderStyles.scss +92 -92
- package/src/components/compound/DlTable/DlTable.vue +701 -358
- package/src/components/compound/DlTable/components/DlTd.vue +11 -9
- package/src/components/compound/DlTable/components/DlTh.vue +22 -21
- package/src/components/compound/DlTable/components/SortableJS.vue +33 -0
- package/src/components/compound/DlTable/hooks/tableActions.ts +3 -3
- package/src/components/compound/DlTable/hooks/tableColumnSelection.ts +3 -4
- package/src/components/compound/DlTable/hooks/use-sortable.ts +152 -0
- package/src/components/compound/DlTable/styles/dl-table-styles.scss +372 -377
- package/src/components/compound/DlTable/types.ts +6 -0
- package/src/components/compound/DlTable/utils/getCellValue.ts +27 -0
- package/src/components/compound/DlTable/utils/insertAtIndex.ts +22 -0
- package/src/components/compound/DlTable/utils/tableClasses.ts +22 -0
- package/src/components/compound/DlToast/api/useToast.ts +10 -4
- package/src/components/compound/DlToast/components/ToastComponent.vue +26 -21
- package/src/components/compound/DlToast/utils/render.ts +15 -8
- package/src/components/compound/DlTreeTable/DlTreeTable.vue +708 -323
- package/src/components/compound/DlTreeTable/components/DlTdTree.vue +10 -9
- package/src/components/compound/DlTreeTable/components/DlTrTree.vue +13 -0
- package/src/components/compound/DlTreeTable/emits.ts +2 -2
- package/src/components/compound/DlTreeTable/utils/index.ts +6 -0
- package/src/components/compound/DlTreeTable/utils/moveNestedRow.ts +95 -0
- package/src/components/compound/DlTreeTable/utils/trSpacing.ts +12 -1
- package/src/components/compound/DlTreeTable/utils/treeTableRowSelection.ts +10 -7
- package/src/components/compound/DlTreeTable/views/DlTrTreeView.vue +52 -58
- package/src/components/essential/DlMenu/DlMenu.vue +25 -0
- package/src/components/index.ts +1 -0
- package/src/components/shared/DlVirtualScroll/DlVirtualScroll.vue +2 -1
- package/src/components/shared/DlVirtualScroll/styles/dl-virtual-scroll-styles.scss +62 -41
- package/src/components/types.ts +1 -0
- package/src/demos/DlAccordionDemo.vue +32 -0
- package/src/demos/DlButtonDemo.vue +7 -0
- package/src/demos/DlDemoPage.vue +1 -0
- package/src/demos/DlInputDemo.vue +122 -64
- package/src/demos/DlLabelPickerDemo.vue +46 -0
- package/src/demos/DlPopupDemo.vue +94 -4
- package/src/demos/DlSearchDemo.vue +0 -1
- package/src/demos/DlTableDemo.vue +261 -162
- package/src/demos/DlToastDemo.vue +28 -1
- package/src/demos/DlTreeTableDemo.vue +266 -262
- package/src/demos/DlVirtualScrollDemo.vue +1 -4
- package/src/demos/index.ts +3 -1
- package/src/hooks/use-model-toggle.ts +26 -62
- package/src/utils/browse-nested-nodes.ts +26 -0
- package/src/utils/draggable-table.ts +100 -488
- package/src/utils/get-element-above.ts +8 -0
- package/src/utils/getSlotByVersion.ts +11 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/keyCodes.ts +1 -1
- package/src/utils/remove-child-nodes.ts +5 -0
- package/src/utils/render-fn.ts +46 -0
- package/src/utils/resizable-table.ts +110 -0
- package/src/utils/selection.ts +196 -0
- package/src/utils/swap-nodes.ts +11 -0
- package/src/utils/table-columns.ts +209 -0
- package/src/components/compound/DlTable/utils/ResizableManager.ts +0 -236
- package/src/components/compound/DlTable/utils/index.ts +0 -1
- package/src/components/compound/DlTable/utils/props.ts +0 -120
- package/src/components/compound/DlTreeTable/props.ts +0 -134
- package/src/components/compound/DlTreeTable/utils/flatTreeData.ts +0 -19
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
3
|
:id="uuid"
|
|
4
|
+
:key="tableKey"
|
|
4
5
|
ref="rootRef"
|
|
6
|
+
:style="containerStyle"
|
|
5
7
|
:class="containerClass"
|
|
6
8
|
>
|
|
7
9
|
<div
|
|
@@ -68,7 +70,7 @@
|
|
|
68
70
|
@virtual-scroll="onVScroll"
|
|
69
71
|
>
|
|
70
72
|
<template #before>
|
|
71
|
-
<thead>
|
|
73
|
+
<thead v-if="hasThead">
|
|
72
74
|
<slot
|
|
73
75
|
v-if="!hideHeader"
|
|
74
76
|
name="header"
|
|
@@ -79,11 +81,12 @@
|
|
|
79
81
|
v-if="hasDraggableRows"
|
|
80
82
|
class="dl-table--col-auto-with empty-col"
|
|
81
83
|
:data-resizable="false"
|
|
84
|
+
style="width: 25px; padding: 5px"
|
|
82
85
|
@mousedown="stopAndPrevent"
|
|
83
86
|
/>
|
|
84
87
|
<th
|
|
85
88
|
v-if="singleSelection"
|
|
86
|
-
class="dl-table--col-auto-
|
|
89
|
+
class="dl-table--col-auto-width"
|
|
87
90
|
@mousedown="stopAndPrevent"
|
|
88
91
|
/>
|
|
89
92
|
<th
|
|
@@ -109,9 +112,16 @@
|
|
|
109
112
|
</slot>
|
|
110
113
|
</th>
|
|
111
114
|
|
|
115
|
+
<th
|
|
116
|
+
v-if="isTreeTable"
|
|
117
|
+
class="dl-table--col-auto-with empty-col chevron-header"
|
|
118
|
+
:data-resizable="false"
|
|
119
|
+
style="width: 25px"
|
|
120
|
+
/>
|
|
121
|
+
|
|
112
122
|
<slot
|
|
113
|
-
v-for="col in computedCols"
|
|
114
|
-
v-bind="getHeaderScope({ col
|
|
123
|
+
v-for="(col, colIndex) in computedCols"
|
|
124
|
+
v-bind="getHeaderScope({ col })"
|
|
115
125
|
:name="
|
|
116
126
|
hasSlotByName(`header-cell-${col.name}`)
|
|
117
127
|
? `header-cell-${col.name}`
|
|
@@ -121,59 +131,78 @@
|
|
|
121
131
|
<DlTh
|
|
122
132
|
:key="col.name"
|
|
123
133
|
:props="getHeaderScope({ col })"
|
|
124
|
-
|
|
134
|
+
:col-index="colIndex"
|
|
125
135
|
>
|
|
126
|
-
|
|
127
|
-
style="
|
|
128
|
-
width: 100%;
|
|
129
|
-
display: flex;
|
|
130
|
-
align-items: center;
|
|
131
|
-
gap: 2px;
|
|
132
|
-
"
|
|
133
|
-
>
|
|
134
|
-
{{ col.label }}
|
|
135
|
-
<dl-icon
|
|
136
|
-
v-if="col.hint"
|
|
137
|
-
icon="icon-dl-info"
|
|
138
|
-
size="10px"
|
|
139
|
-
>
|
|
140
|
-
<dl-tooltip>
|
|
141
|
-
{{ col.hint }}
|
|
142
|
-
</dl-tooltip>
|
|
143
|
-
</dl-icon>
|
|
144
|
-
</div>
|
|
136
|
+
{{ col.label }}
|
|
145
137
|
</DlTh>
|
|
146
138
|
</slot>
|
|
139
|
+
|
|
147
140
|
<DlTh
|
|
148
|
-
v-if="
|
|
149
|
-
key="
|
|
150
|
-
class="visible-columns-justify-end"
|
|
141
|
+
v-if="visibleColumns && visibleColumns.length"
|
|
142
|
+
key="visibleColsBtn"
|
|
151
143
|
>
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
144
|
+
<slot
|
|
145
|
+
name="visible-columns-button"
|
|
146
|
+
:computed-visible-cols="computedVisibleCols"
|
|
147
|
+
:group-options="groupOptions"
|
|
148
|
+
:handle-visible-columns-update="
|
|
149
|
+
handleVisibleColumnsUpdate
|
|
150
|
+
"
|
|
156
151
|
>
|
|
157
|
-
<dl-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
152
|
+
<dl-button
|
|
153
|
+
text-color="dl-color-medium"
|
|
154
|
+
flat
|
|
155
|
+
icon="icon-dl-column"
|
|
156
|
+
tooltip="Manage columns"
|
|
157
|
+
>
|
|
158
|
+
<slot
|
|
159
|
+
name="visible-columns-menu"
|
|
160
|
+
:computed-visible-cols="
|
|
161
|
+
computedVisibleCols
|
|
162
|
+
"
|
|
163
|
+
:group-options="groupOptions"
|
|
164
|
+
:handle-visible-columns-update="
|
|
165
|
+
handleVisibleColumnsUpdate
|
|
166
|
+
"
|
|
167
|
+
>
|
|
168
|
+
<dl-menu>
|
|
169
|
+
<slot
|
|
170
|
+
name="visible-columns-menu-content"
|
|
171
|
+
:computed-visible-cols="
|
|
172
|
+
computedVisibleCols
|
|
173
|
+
"
|
|
174
|
+
:group-options="
|
|
175
|
+
groupOptions
|
|
176
|
+
"
|
|
177
|
+
:handle-visible-columns-update="
|
|
178
|
+
handleVisibleColumnsUpdate
|
|
179
|
+
"
|
|
180
|
+
>
|
|
181
|
+
<dl-list separator>
|
|
182
|
+
<dl-option-group
|
|
183
|
+
:model-value="
|
|
184
|
+
computedVisibleCols
|
|
185
|
+
"
|
|
186
|
+
:options="
|
|
187
|
+
groupOptions
|
|
188
|
+
"
|
|
189
|
+
:left-label="true"
|
|
190
|
+
max-width="250px"
|
|
191
|
+
type="switch"
|
|
192
|
+
class="table-options"
|
|
193
|
+
@update:model-value="
|
|
194
|
+
handleVisibleColumnsUpdate
|
|
195
|
+
"
|
|
196
|
+
/>
|
|
197
|
+
</dl-list>
|
|
198
|
+
</slot>
|
|
199
|
+
</dl-menu>
|
|
200
|
+
</slot>
|
|
201
|
+
</dl-button>
|
|
202
|
+
</slot>
|
|
175
203
|
</DlTh>
|
|
176
204
|
</DlTr>
|
|
205
|
+
|
|
177
206
|
<tr
|
|
178
207
|
v-if="loading && !hasLoadingSlot"
|
|
179
208
|
class="dl-table__progress"
|
|
@@ -196,7 +225,7 @@
|
|
|
196
225
|
name="table-body"
|
|
197
226
|
v-bind="props"
|
|
198
227
|
>
|
|
199
|
-
<template v-if="!
|
|
228
|
+
<template v-if="!isDataEmpty && !hasSlotBody">
|
|
200
229
|
<slot
|
|
201
230
|
v-bind="
|
|
202
231
|
getBodyScope({
|
|
@@ -288,37 +317,36 @@
|
|
|
288
317
|
/>
|
|
289
318
|
</slot>
|
|
290
319
|
</td>
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
v-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
320
|
+
<slot
|
|
321
|
+
v-for="(col, colIndex) in computedCols"
|
|
322
|
+
v-bind="
|
|
323
|
+
getBodyCellScope({
|
|
324
|
+
key: getRowKey(props.item),
|
|
325
|
+
row: props.item,
|
|
326
|
+
pageIndex: props.pageIndex,
|
|
327
|
+
col
|
|
328
|
+
})
|
|
329
|
+
"
|
|
330
|
+
:name="
|
|
331
|
+
hasSlotByName(`body-cell-${col.name}`)
|
|
332
|
+
? `body-cell-${col.name}`
|
|
333
|
+
: 'body-cell'
|
|
334
|
+
"
|
|
297
335
|
>
|
|
298
|
-
<
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
pageIndex: props.pageIndex,
|
|
304
|
-
col
|
|
305
|
-
})
|
|
306
|
-
"
|
|
307
|
-
:name="
|
|
308
|
-
hasSlotByName(
|
|
309
|
-
`body-cell-${col.name}`
|
|
310
|
-
)
|
|
311
|
-
? `body-cell-${col.name}`
|
|
312
|
-
: 'body-cell'
|
|
313
|
-
"
|
|
336
|
+
<DlTd
|
|
337
|
+
:class="col.tdClass(props.item)"
|
|
338
|
+
:style="col.tdStyle(props.item)"
|
|
339
|
+
:no-hover="noHover"
|
|
340
|
+
:col-index="colIndex"
|
|
314
341
|
>
|
|
315
342
|
{{ getCellValue(col, props.item) }}
|
|
316
|
-
</
|
|
317
|
-
</
|
|
343
|
+
</DlTd>
|
|
344
|
+
</slot>
|
|
318
345
|
<DlTd
|
|
319
|
-
v-if="
|
|
346
|
+
v-if="showRowActions"
|
|
320
347
|
key="body-cell-row-actions"
|
|
321
348
|
class="visible-columns-justify-end"
|
|
349
|
+
no-tooltip
|
|
322
350
|
>
|
|
323
351
|
<slot
|
|
324
352
|
v-bind="
|
|
@@ -340,7 +368,7 @@
|
|
|
340
368
|
</DlTr>
|
|
341
369
|
</slot>
|
|
342
370
|
</template>
|
|
343
|
-
<DlTr v-if="
|
|
371
|
+
<DlTr v-if="isDataEmpty">
|
|
344
372
|
<DlTd colspan="100%">
|
|
345
373
|
<div class="flex justify-center full-width">
|
|
346
374
|
<dl-empty-state v-bind="emptyStateProps">
|
|
@@ -370,7 +398,10 @@
|
|
|
370
398
|
class="dl-table"
|
|
371
399
|
:class="additionalClasses"
|
|
372
400
|
>
|
|
373
|
-
<thead
|
|
401
|
+
<thead
|
|
402
|
+
v-if="hasThead"
|
|
403
|
+
:colspan="columns.length"
|
|
404
|
+
>
|
|
374
405
|
<slot
|
|
375
406
|
v-if="!hideHeader"
|
|
376
407
|
name="header"
|
|
@@ -381,11 +412,12 @@
|
|
|
381
412
|
v-if="hasDraggableRows"
|
|
382
413
|
class="dl-table--col-auto-with empty-col"
|
|
383
414
|
:data-resizable="false"
|
|
415
|
+
style="width: 25px"
|
|
384
416
|
@mousedown="stopAndPrevent"
|
|
385
417
|
/>
|
|
386
418
|
<th
|
|
387
419
|
v-if="singleSelection"
|
|
388
|
-
class="dl-table--col-auto-with"
|
|
420
|
+
class="dl-table--col-auto-with dl-table--col-checkbox-wrapper"
|
|
389
421
|
@mousedown="stopAndPrevent"
|
|
390
422
|
/>
|
|
391
423
|
|
|
@@ -410,8 +442,15 @@
|
|
|
410
442
|
</slot>
|
|
411
443
|
</th>
|
|
412
444
|
|
|
445
|
+
<th
|
|
446
|
+
v-if="isTreeTable"
|
|
447
|
+
class="dl-table--col-auto-with empty-col"
|
|
448
|
+
:data-resizable="false"
|
|
449
|
+
style="width: 25px; padding: 5px"
|
|
450
|
+
/>
|
|
451
|
+
|
|
413
452
|
<slot
|
|
414
|
-
v-for="col in computedCols"
|
|
453
|
+
v-for="(col, colIndex) in computedCols"
|
|
415
454
|
v-bind="getHeaderScope({ col, onThClick })"
|
|
416
455
|
:name="
|
|
417
456
|
hasSlotByName(`header-cell-${col.name}`)
|
|
@@ -422,35 +461,20 @@
|
|
|
422
461
|
<DlTh
|
|
423
462
|
:key="col.name"
|
|
424
463
|
:props="getHeaderScope({ col })"
|
|
464
|
+
:col-index="colIndex"
|
|
425
465
|
@click="onThClick($event, col.name)"
|
|
426
466
|
>
|
|
427
|
-
|
|
428
|
-
style="
|
|
429
|
-
width: 100%;
|
|
430
|
-
display: flex;
|
|
431
|
-
align-items: center;
|
|
432
|
-
gap: 2px;
|
|
433
|
-
"
|
|
434
|
-
>
|
|
435
|
-
{{ col.label }}
|
|
436
|
-
<dl-icon
|
|
437
|
-
v-if="col.hint"
|
|
438
|
-
icon="icon-dl-info"
|
|
439
|
-
size="10px"
|
|
440
|
-
>
|
|
441
|
-
<dl-tooltip>
|
|
442
|
-
{{ col.hint }}
|
|
443
|
-
</dl-tooltip>
|
|
444
|
-
</dl-icon>
|
|
445
|
-
</div>
|
|
467
|
+
{{ col.label }}
|
|
446
468
|
</DlTh>
|
|
447
469
|
</slot>
|
|
448
470
|
<DlTh
|
|
449
|
-
v-if="
|
|
450
|
-
key="
|
|
451
|
-
class="visible-columns-justify-end"
|
|
471
|
+
v-if="showRowActions"
|
|
472
|
+
key="visibleColsBtn"
|
|
452
473
|
>
|
|
453
474
|
<dl-button
|
|
475
|
+
v-if="
|
|
476
|
+
visibleColumns && visibleColumns.length
|
|
477
|
+
"
|
|
454
478
|
text-color="dl-color-medium"
|
|
455
479
|
flat
|
|
456
480
|
icon="icon-dl-column"
|
|
@@ -492,163 +516,194 @@
|
|
|
492
516
|
</tr>
|
|
493
517
|
</slot>
|
|
494
518
|
</thead>
|
|
495
|
-
<
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
519
|
+
<slot
|
|
520
|
+
name="tbody"
|
|
521
|
+
v-bind="{
|
|
522
|
+
computedRows,
|
|
523
|
+
class: 'dl-virtual-scroll__content'
|
|
524
|
+
}"
|
|
525
|
+
>
|
|
526
|
+
<Sortable
|
|
527
|
+
:key="tbodyKey"
|
|
528
|
+
ref="tbody"
|
|
529
|
+
tag="tbody"
|
|
530
|
+
class="nested-table dl-virtual-scroll__content"
|
|
531
|
+
v-bind="{
|
|
532
|
+
onEnd: handleSortableEvent
|
|
533
|
+
}"
|
|
534
|
+
:is-sortable="hasDraggableRows"
|
|
535
|
+
:options="{
|
|
536
|
+
group: 'nested',
|
|
537
|
+
animation: 150,
|
|
538
|
+
fallbackOnBody: true,
|
|
539
|
+
invertSwap: true,
|
|
540
|
+
swapThreshold: 0.5
|
|
541
|
+
}"
|
|
503
542
|
>
|
|
504
543
|
<slot
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
trClass: isRowSelected(getRowKey(row))
|
|
512
|
-
? 'selected'
|
|
513
|
-
: ''
|
|
514
|
-
})
|
|
515
|
-
"
|
|
516
|
-
:has-any-action="hasAnyAction"
|
|
517
|
-
name="row-body"
|
|
544
|
+
name="top-row"
|
|
545
|
+
:cols="computedCols"
|
|
546
|
+
/>
|
|
547
|
+
<slot
|
|
548
|
+
name="table-body"
|
|
549
|
+
:computed-rows="computedRows"
|
|
518
550
|
>
|
|
519
|
-
<
|
|
520
|
-
v-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
:
|
|
527
|
-
? '
|
|
551
|
+
<slot
|
|
552
|
+
v-for="(row, pageIndex) in computedRows"
|
|
553
|
+
v-bind="
|
|
554
|
+
getBodyScope({
|
|
555
|
+
key: getRowKey(row),
|
|
556
|
+
row,
|
|
557
|
+
pageIndex,
|
|
558
|
+
trClass: isRowSelected(getRowKey(row))
|
|
559
|
+
? 'selected'
|
|
528
560
|
: ''
|
|
561
|
+
})
|
|
529
562
|
"
|
|
530
|
-
:
|
|
531
|
-
|
|
532
|
-
@dblclick="onTrDblClick($event, row, pageIndex)"
|
|
533
|
-
@contextmenu="
|
|
534
|
-
onTrContextMenu($event, row, pageIndex)
|
|
535
|
-
"
|
|
563
|
+
:has-any-action="hasAnyAction"
|
|
564
|
+
name="row-body"
|
|
536
565
|
>
|
|
537
|
-
<
|
|
538
|
-
v-if="
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
566
|
+
<DlTr
|
|
567
|
+
v-if="!isDataEmpty"
|
|
568
|
+
:key="getRowKey(row)"
|
|
569
|
+
:has-any-action="hasAnyAction"
|
|
570
|
+
:class="
|
|
571
|
+
isRowSelected(getRowKey(row))
|
|
572
|
+
? 'selected'
|
|
573
|
+
: hasAnyAction
|
|
574
|
+
? ' cursor-pointer'
|
|
575
|
+
: ''
|
|
576
|
+
"
|
|
577
|
+
:no-hover="noHover"
|
|
578
|
+
@click="onTrClick($event, row, pageIndex)"
|
|
579
|
+
@dblclick="
|
|
580
|
+
onTrDblClick($event, row, pageIndex)
|
|
581
|
+
"
|
|
582
|
+
@contextmenu="
|
|
583
|
+
onTrContextMenu($event, row, pageIndex)
|
|
584
|
+
"
|
|
550
585
|
>
|
|
551
|
-
<
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
key: getRowKey(row),
|
|
556
|
-
row,
|
|
557
|
-
pageIndex
|
|
558
|
-
})
|
|
559
|
-
"
|
|
586
|
+
<td
|
|
587
|
+
v-if="hasDraggableRows"
|
|
588
|
+
style="width: 25px"
|
|
589
|
+
class="dl-table__drag-icon"
|
|
560
590
|
>
|
|
561
|
-
<
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
591
|
+
<dl-icon
|
|
592
|
+
class="draggable-icon"
|
|
593
|
+
icon="icon-dl-drag"
|
|
594
|
+
size="12px"
|
|
595
|
+
/>
|
|
596
|
+
</td>
|
|
597
|
+
<td
|
|
598
|
+
v-if="hasSelectionMode"
|
|
599
|
+
class="dl-table--col-auto-with"
|
|
600
|
+
>
|
|
601
|
+
<slot
|
|
602
|
+
name="body-selection"
|
|
603
|
+
v-bind="
|
|
604
|
+
getBodySelectionScope({
|
|
605
|
+
key: getRowKey(row),
|
|
606
|
+
row,
|
|
607
|
+
pageIndex
|
|
608
|
+
})
|
|
565
609
|
"
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
evt
|
|
610
|
+
>
|
|
611
|
+
<DlCheckbox
|
|
612
|
+
:color="color"
|
|
613
|
+
:model-value="
|
|
614
|
+
isRowSelected(
|
|
615
|
+
getRowKey(row)
|
|
573
616
|
)
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
"
|
|
593
|
-
:name="
|
|
594
|
-
hasSlotByName(
|
|
595
|
-
`body-cell-${col.name}`
|
|
596
|
-
)
|
|
597
|
-
? `body-cell-${col.name}`
|
|
598
|
-
: 'body-cell'
|
|
599
|
-
"
|
|
617
|
+
"
|
|
618
|
+
@update:model-value="
|
|
619
|
+
(adding, evt) =>
|
|
620
|
+
updateSelection(
|
|
621
|
+
[getRowKey(row)],
|
|
622
|
+
[row],
|
|
623
|
+
adding,
|
|
624
|
+
evt
|
|
625
|
+
)
|
|
626
|
+
"
|
|
627
|
+
/>
|
|
628
|
+
</slot>
|
|
629
|
+
</td>
|
|
630
|
+
<DlTd
|
|
631
|
+
v-for="(col, colIndex) in computedCols"
|
|
632
|
+
:key="col.name"
|
|
633
|
+
:class="col.tdClass(row)"
|
|
634
|
+
:style="col.tdStyle(row)"
|
|
635
|
+
:col-index="colIndex"
|
|
600
636
|
>
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
"
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
</DlTr>
|
|
627
|
-
</slot>
|
|
628
|
-
</slot>
|
|
629
|
-
|
|
630
|
-
<DlTr v-if="isEmpty && hasEmptyStateProps">
|
|
631
|
-
<DlTd colspan="100%">
|
|
632
|
-
<div class="flex justify-center full-width">
|
|
633
|
-
<dl-empty-state v-bind="emptyStateProps">
|
|
634
|
-
<template
|
|
635
|
-
v-for="(_, slot) in $slots"
|
|
636
|
-
#[slot]="emptyStateProps"
|
|
637
|
+
<slot
|
|
638
|
+
v-bind="
|
|
639
|
+
getBodyCellScope({
|
|
640
|
+
key: getRowKey(row),
|
|
641
|
+
row,
|
|
642
|
+
pageIndex,
|
|
643
|
+
col
|
|
644
|
+
})
|
|
645
|
+
"
|
|
646
|
+
:name="
|
|
647
|
+
hasSlotByName(
|
|
648
|
+
`body-cell-${col.name}`
|
|
649
|
+
)
|
|
650
|
+
? `body-cell-${col.name}`
|
|
651
|
+
: 'body-cell'
|
|
652
|
+
"
|
|
653
|
+
>
|
|
654
|
+
{{ getCellValue(col, row) }}
|
|
655
|
+
</slot>
|
|
656
|
+
</DlTd>
|
|
657
|
+
<DlTd
|
|
658
|
+
v-if="showRowActions"
|
|
659
|
+
key="body-cell-row-actions"
|
|
660
|
+
class="visible-columns-justify-end"
|
|
661
|
+
no-tooltip
|
|
637
662
|
>
|
|
638
663
|
<slot
|
|
639
|
-
|
|
640
|
-
|
|
664
|
+
v-bind="
|
|
665
|
+
getBodyCellScope({
|
|
666
|
+
key: getRowKey(row),
|
|
667
|
+
row: row,
|
|
668
|
+
pageIndex: pageIndex
|
|
669
|
+
})
|
|
670
|
+
"
|
|
671
|
+
:name="
|
|
672
|
+
hasSlotByName(
|
|
673
|
+
`body-cell-row-actions`
|
|
674
|
+
)
|
|
675
|
+
? `body-cell-row-actions`
|
|
676
|
+
: 'body-cell'
|
|
677
|
+
"
|
|
641
678
|
/>
|
|
642
|
-
</
|
|
643
|
-
</
|
|
644
|
-
</
|
|
645
|
-
</
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
679
|
+
</DlTd>
|
|
680
|
+
</DlTr>
|
|
681
|
+
</slot>
|
|
682
|
+
</slot>
|
|
683
|
+
|
|
684
|
+
<DlTr v-if="isDataEmpty && hasEmptyStateProps">
|
|
685
|
+
<DlTd colspan="100%">
|
|
686
|
+
<div class="flex justify-center full-width">
|
|
687
|
+
<dl-empty-state v-bind="emptyStateProps">
|
|
688
|
+
<template
|
|
689
|
+
v-for="(_, slot) in $slots"
|
|
690
|
+
#[slot]="emptyStateProps"
|
|
691
|
+
>
|
|
692
|
+
<slot
|
|
693
|
+
:name="slot"
|
|
694
|
+
v-bind="emptyStateProps"
|
|
695
|
+
/>
|
|
696
|
+
</template>
|
|
697
|
+
</dl-empty-state>
|
|
698
|
+
</div>
|
|
699
|
+
</DlTd>
|
|
700
|
+
</DlTr>
|
|
701
|
+
<slot
|
|
702
|
+
name="bottom-row"
|
|
703
|
+
:cols="computedCols"
|
|
704
|
+
/>
|
|
705
|
+
</Sortable>
|
|
706
|
+
</slot>
|
|
652
707
|
</table>
|
|
653
708
|
</div>
|
|
654
709
|
|
|
@@ -717,29 +772,41 @@ import {
|
|
|
717
772
|
getCurrentInstance,
|
|
718
773
|
ComputedRef,
|
|
719
774
|
onMounted,
|
|
720
|
-
|
|
775
|
+
toRef,
|
|
776
|
+
toRefs,
|
|
777
|
+
nextTick,
|
|
778
|
+
PropType
|
|
721
779
|
} from 'vue-demi'
|
|
722
|
-
import { props } from './utils/props'
|
|
723
780
|
import { emits } from './utils/emits'
|
|
724
781
|
import {
|
|
725
782
|
useTablePagination,
|
|
783
|
+
useTablePaginationProps,
|
|
726
784
|
useTablePaginationState
|
|
727
785
|
} from './hooks/tablePagination'
|
|
728
786
|
import DlTr from './components/DlTr.vue'
|
|
729
787
|
import DlTh from './components/DlTh.vue'
|
|
730
788
|
import DlTd from './components/DlTd.vue'
|
|
731
|
-
import {
|
|
789
|
+
import {
|
|
790
|
+
commonVirtPropsList,
|
|
791
|
+
commonVirtScrollProps
|
|
792
|
+
} from '../../shared/DlVirtualScroll/useVirtualScroll'
|
|
732
793
|
import DlVirtualScroll from '../../shared/DlVirtualScroll/DlVirtualScroll.vue'
|
|
733
|
-
import { useTableFilter } from './hooks/tableFilter'
|
|
734
|
-
import { useTableSort } from './hooks/tableSort'
|
|
735
|
-
import {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
794
|
+
import { useTableFilter, useTableFilterProps } from './hooks/tableFilter'
|
|
795
|
+
import { useTableSort, useTableSortProps } from './hooks/tableSort'
|
|
796
|
+
import {
|
|
797
|
+
useTableRowSelection,
|
|
798
|
+
useTableRowSelectionProps
|
|
799
|
+
} from './hooks/tableRowSelection'
|
|
739
800
|
import {
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
} from '
|
|
801
|
+
useTableColumnSelection,
|
|
802
|
+
useTableColumnSelectionProps
|
|
803
|
+
} from './hooks/tableColumnSelection'
|
|
804
|
+
import {
|
|
805
|
+
useTableRowExpand,
|
|
806
|
+
useTableRowExpandProps
|
|
807
|
+
} from './hooks/tableRowExpand'
|
|
808
|
+
import { useTableActions, useTableActionsProps } from './hooks/tableActions'
|
|
809
|
+
import { applyDraggableColumns, applyResizableColumns } from '../../../utils'
|
|
743
810
|
import { injectProp } from '../../../utils/inject-object-prop'
|
|
744
811
|
import { DlTableRow, DlTableProps, DlTableColumn } from './types'
|
|
745
812
|
import { DlPagination } from '../DlPagination'
|
|
@@ -750,15 +817,18 @@ import {
|
|
|
750
817
|
DlMenu,
|
|
751
818
|
DlList
|
|
752
819
|
} from '../../essential'
|
|
753
|
-
import { DlTooltip } from '../../shared'
|
|
754
|
-
import { ResizableManager } from './utils'
|
|
755
820
|
import { DlButton } from '../../basic'
|
|
756
821
|
import DlOptionGroup from '../DlOptionGroup/DlOptionGroup.vue'
|
|
757
822
|
import DlEmptyState from '../../basic/DlEmptyState/DlEmptyState.vue'
|
|
758
823
|
import { v4 } from 'uuid'
|
|
759
|
-
import {
|
|
760
|
-
import {
|
|
761
|
-
import
|
|
824
|
+
import { stopAndPrevent, setAllColumnWidths } from '../../../utils'
|
|
825
|
+
import { DlEmptyStateProps, DlVirtualScrollEvent } from '../../types'
|
|
826
|
+
import Sortable from './components/SortableJS.vue'
|
|
827
|
+
import { SortableEvent } from 'sortablejs'
|
|
828
|
+
import { insertAtIndex } from './utils/insertAtIndex'
|
|
829
|
+
import { getCellValue } from './utils/getCellValue'
|
|
830
|
+
import { getContainerClass } from './utils/tableClasses'
|
|
831
|
+
import { isEqual } from 'lodash'
|
|
762
832
|
|
|
763
833
|
const commonVirtPropsObj = {} as Record<string, any>
|
|
764
834
|
commonVirtPropsList.forEach((p) => {
|
|
@@ -781,9 +851,241 @@ export default defineComponent({
|
|
|
781
851
|
DlOptionGroup,
|
|
782
852
|
DlMenu,
|
|
783
853
|
DlList,
|
|
784
|
-
|
|
854
|
+
Sortable
|
|
855
|
+
},
|
|
856
|
+
props: {
|
|
857
|
+
/**
|
|
858
|
+
* Array of DlTableColumn objects
|
|
859
|
+
*/
|
|
860
|
+
columns: { type: Array, default: () => [] as Record<string, any>[] },
|
|
861
|
+
/**
|
|
862
|
+
* Array of DlTableRow objects
|
|
863
|
+
*/
|
|
864
|
+
rows: {
|
|
865
|
+
type: Array,
|
|
866
|
+
default: () => [] as Record<string, any>[]
|
|
867
|
+
},
|
|
868
|
+
/**
|
|
869
|
+
* Specify which key will identify each row
|
|
870
|
+
*/
|
|
871
|
+
rowKey: {
|
|
872
|
+
type: [String, Function],
|
|
873
|
+
default: 'id'
|
|
874
|
+
},
|
|
875
|
+
/**
|
|
876
|
+
* Surrounded by a border
|
|
877
|
+
*/
|
|
878
|
+
bordered: Boolean,
|
|
879
|
+
/**
|
|
880
|
+
* Borders inside the table: horizontal, vertical, cell or none
|
|
881
|
+
*/
|
|
882
|
+
separator: {
|
|
883
|
+
type: String,
|
|
884
|
+
default: 'horizontal',
|
|
885
|
+
validator: (v: string) =>
|
|
886
|
+
['horizontal', 'vertical', 'cell', 'none'].includes(v)
|
|
887
|
+
},
|
|
888
|
+
/**
|
|
889
|
+
* Type of the draggable functionality: rows, columns or both
|
|
890
|
+
*/
|
|
891
|
+
draggable: {
|
|
892
|
+
type: String,
|
|
893
|
+
default: 'none',
|
|
894
|
+
validator: (v: string) =>
|
|
895
|
+
['rows', 'columns', 'none', 'both'].includes(v)
|
|
896
|
+
},
|
|
897
|
+
/**
|
|
898
|
+
* Title to be displayed next to the table
|
|
899
|
+
*/
|
|
900
|
+
title: { type: String, default: '' },
|
|
901
|
+
/**
|
|
902
|
+
* Text color
|
|
903
|
+
*/
|
|
904
|
+
color: {
|
|
905
|
+
type: String,
|
|
906
|
+
default: 'dl-color-darker'
|
|
907
|
+
},
|
|
908
|
+
/**
|
|
909
|
+
* Show a loading animation on the table
|
|
910
|
+
*/
|
|
911
|
+
loading: {
|
|
912
|
+
type: Boolean,
|
|
913
|
+
default: false
|
|
914
|
+
},
|
|
915
|
+
/**
|
|
916
|
+
* Cells shrinks in size
|
|
917
|
+
*/
|
|
918
|
+
dense: {
|
|
919
|
+
type: Boolean,
|
|
920
|
+
default: false
|
|
921
|
+
},
|
|
922
|
+
/**
|
|
923
|
+
* Resizable columns
|
|
924
|
+
*/
|
|
925
|
+
resizable: {
|
|
926
|
+
type: Boolean,
|
|
927
|
+
default: false
|
|
928
|
+
},
|
|
929
|
+
/**
|
|
930
|
+
* Don't show the "No data" message
|
|
931
|
+
*/
|
|
932
|
+
hideNoData: {
|
|
933
|
+
type: Boolean,
|
|
934
|
+
default: false
|
|
935
|
+
},
|
|
936
|
+
/**
|
|
937
|
+
* Don't show the header
|
|
938
|
+
*/
|
|
939
|
+
hideHeader: {
|
|
940
|
+
type: Boolean,
|
|
941
|
+
default: false
|
|
942
|
+
},
|
|
943
|
+
/**
|
|
944
|
+
* Don't show the footer
|
|
945
|
+
*/
|
|
946
|
+
hideBottom: {
|
|
947
|
+
type: Boolean,
|
|
948
|
+
default: false
|
|
949
|
+
},
|
|
950
|
+
/**
|
|
951
|
+
* Enable virtual scroll
|
|
952
|
+
*/
|
|
953
|
+
virtualScroll: {
|
|
954
|
+
type: Boolean,
|
|
955
|
+
default: false
|
|
956
|
+
},
|
|
957
|
+
/**
|
|
958
|
+
* Hide table pagination
|
|
959
|
+
*/
|
|
960
|
+
hidePagination: {
|
|
961
|
+
type: Boolean,
|
|
962
|
+
default: false
|
|
963
|
+
},
|
|
964
|
+
/**
|
|
965
|
+
* Hide selected banner
|
|
966
|
+
*/
|
|
967
|
+
hideSelectedBanner: {
|
|
968
|
+
type: Boolean,
|
|
969
|
+
default: false
|
|
970
|
+
},
|
|
971
|
+
/**
|
|
972
|
+
* Function to generate the label visible when selecting rows
|
|
973
|
+
*/
|
|
974
|
+
selectedRowsLabel: {
|
|
975
|
+
type: Function,
|
|
976
|
+
default: (val: number) => `${val} records selected`
|
|
977
|
+
},
|
|
978
|
+
/**
|
|
979
|
+
* Label visible when loading is active
|
|
980
|
+
*/
|
|
981
|
+
loadingLabel: {
|
|
982
|
+
type: String,
|
|
983
|
+
default: 'Loading...'
|
|
984
|
+
},
|
|
985
|
+
/**
|
|
986
|
+
* Label visible when there are no results
|
|
987
|
+
*/
|
|
988
|
+
noResultsLabel: {
|
|
989
|
+
type: String,
|
|
990
|
+
default: 'There are no results to display'
|
|
991
|
+
},
|
|
992
|
+
/**
|
|
993
|
+
* Label visible when data is empty
|
|
994
|
+
*/
|
|
995
|
+
noDataLabel: {
|
|
996
|
+
type: String,
|
|
997
|
+
default: 'No data available'
|
|
998
|
+
},
|
|
999
|
+
/**
|
|
1000
|
+
* Virtual scroll target
|
|
1001
|
+
*/
|
|
1002
|
+
virtualScrollTarget: {
|
|
1003
|
+
type: Object as PropType<HTMLElement>,
|
|
1004
|
+
default: null as unknown as PropType<HTMLElement>
|
|
1005
|
+
},
|
|
1006
|
+
/**
|
|
1007
|
+
* CSS class for the title
|
|
1008
|
+
*/
|
|
1009
|
+
titleClass: {
|
|
1010
|
+
type: [String, Array, Object],
|
|
1011
|
+
default: null as unknown as PropType<any[]>
|
|
1012
|
+
},
|
|
1013
|
+
/**
|
|
1014
|
+
* Styles to be applied to the table container
|
|
1015
|
+
*/
|
|
1016
|
+
tableStyle: {
|
|
1017
|
+
type: [String, Array, Object],
|
|
1018
|
+
default: null as unknown as PropType<any[]>
|
|
1019
|
+
},
|
|
1020
|
+
/**
|
|
1021
|
+
* CSS class for the table container
|
|
1022
|
+
*/
|
|
1023
|
+
tableClass: {
|
|
1024
|
+
type: [String, Array, Object],
|
|
1025
|
+
default: null as unknown as PropType<any[]>
|
|
1026
|
+
},
|
|
1027
|
+
/**
|
|
1028
|
+
* Styles to be applies to the table header
|
|
1029
|
+
*/
|
|
1030
|
+
tableHeaderStyle: {
|
|
1031
|
+
type: [String, Array, Object],
|
|
1032
|
+
default: null as unknown as PropType<any[]>
|
|
1033
|
+
},
|
|
1034
|
+
/**
|
|
1035
|
+
* CSS class for the table header
|
|
1036
|
+
*/
|
|
1037
|
+
tableHeaderClass: {
|
|
1038
|
+
type: [String, Array, Object],
|
|
1039
|
+
default: null as unknown as PropType<any[]>
|
|
1040
|
+
},
|
|
1041
|
+
noHover: Boolean,
|
|
1042
|
+
/**
|
|
1043
|
+
* Indicates the data is empty
|
|
1044
|
+
*/
|
|
1045
|
+
isEmpty: Boolean,
|
|
1046
|
+
/**
|
|
1047
|
+
* Will add another column with a button opening a menu which lets the user choose the visible columns
|
|
1048
|
+
*/
|
|
1049
|
+
visibleColumns: {
|
|
1050
|
+
type: Array as PropType<DlTableColumn[]>,
|
|
1051
|
+
default: (): [] => []
|
|
1052
|
+
},
|
|
1053
|
+
/**
|
|
1054
|
+
* Props for the empty state component
|
|
1055
|
+
*/
|
|
1056
|
+
emptyStateProps: {
|
|
1057
|
+
type: Object as PropType<DlEmptyStateProps>,
|
|
1058
|
+
default: () =>
|
|
1059
|
+
({
|
|
1060
|
+
title: '',
|
|
1061
|
+
subtitle: 'No data to show yet',
|
|
1062
|
+
icon: 'icon-dl-dataset-filled'
|
|
1063
|
+
} as unknown as PropType<DlEmptyStateProps>)
|
|
1064
|
+
},
|
|
1065
|
+
/**
|
|
1066
|
+
* Scrolling delay
|
|
1067
|
+
*/
|
|
1068
|
+
scrollDebounce: {
|
|
1069
|
+
type: Number,
|
|
1070
|
+
default: 100
|
|
1071
|
+
},
|
|
1072
|
+
isTreeTable: {
|
|
1073
|
+
type: Boolean,
|
|
1074
|
+
default: false
|
|
1075
|
+
},
|
|
1076
|
+
fitAllColumns: {
|
|
1077
|
+
type: Boolean,
|
|
1078
|
+
default: true
|
|
1079
|
+
},
|
|
1080
|
+
...useTableActionsProps,
|
|
1081
|
+
...commonVirtScrollProps,
|
|
1082
|
+
...useTableRowExpandProps,
|
|
1083
|
+
...useTablePaginationProps,
|
|
1084
|
+
...useTableFilterProps,
|
|
1085
|
+
...useTableSortProps,
|
|
1086
|
+
...useTableColumnSelectionProps,
|
|
1087
|
+
...useTableRowSelectionProps
|
|
785
1088
|
},
|
|
786
|
-
props,
|
|
787
1089
|
emits,
|
|
788
1090
|
setup(props, { emit, slots }) {
|
|
789
1091
|
const vm = getCurrentInstance()
|
|
@@ -798,6 +1100,10 @@ export default defineComponent({
|
|
|
798
1100
|
rows
|
|
799
1101
|
} = toRefs(props)
|
|
800
1102
|
|
|
1103
|
+
const tbodyKey = ref()
|
|
1104
|
+
const tableKey = ref()
|
|
1105
|
+
const getTableKey = () => tableKey.value
|
|
1106
|
+
|
|
801
1107
|
const rootRef = ref<HTMLDivElement>(null)
|
|
802
1108
|
const virtScrollRef = ref(null)
|
|
803
1109
|
const hasVirtScroll = computed<boolean>(
|
|
@@ -810,15 +1116,21 @@ export default defineComponent({
|
|
|
810
1116
|
: false
|
|
811
1117
|
)
|
|
812
1118
|
|
|
1119
|
+
const isDataEmpty = computed(() => !props.rows.length)
|
|
1120
|
+
|
|
813
1121
|
const groupOptions = computed(() =>
|
|
814
|
-
(
|
|
1122
|
+
(
|
|
1123
|
+
props.columns.filter(
|
|
1124
|
+
(col) => !(col as DlTableColumn).required
|
|
1125
|
+
) as DlTableColumn[]
|
|
1126
|
+
)?.map((item) => ({
|
|
815
1127
|
label: item.label,
|
|
816
1128
|
value: item.name
|
|
817
1129
|
}))
|
|
818
1130
|
)
|
|
819
1131
|
|
|
820
1132
|
const visibleColumnsState = ref(
|
|
821
|
-
(props.
|
|
1133
|
+
(props.visibleColumns as DlTableColumn[])?.map((col) => col.name)
|
|
822
1134
|
)
|
|
823
1135
|
|
|
824
1136
|
const computedVisibleCols = computed(() =>
|
|
@@ -833,6 +1145,13 @@ export default defineComponent({
|
|
|
833
1145
|
: (row: Record<string, any>) => row[props.rowKey as string]
|
|
834
1146
|
)
|
|
835
1147
|
|
|
1148
|
+
const isResizing = ref(false)
|
|
1149
|
+
const isDragging = ref(false)
|
|
1150
|
+
const setIsResizing = (val: boolean) => (isResizing.value = val)
|
|
1151
|
+
const setIsDragging = (val: boolean) => (isDragging.value = val)
|
|
1152
|
+
const getIsDragging = () => isDragging.value
|
|
1153
|
+
const getIsResizing = () => isResizing.value
|
|
1154
|
+
|
|
836
1155
|
// table slots
|
|
837
1156
|
const hasSlotByName = (name: string) => !!slots[name]
|
|
838
1157
|
|
|
@@ -847,29 +1166,21 @@ export default defineComponent({
|
|
|
847
1166
|
)
|
|
848
1167
|
//
|
|
849
1168
|
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
let classNames = `dl-table__container dl-table--${props.separator}-separator column no-wrap dl-table--no-wrap`
|
|
853
|
-
|
|
854
|
-
if (props.bordered) {
|
|
855
|
-
classNames = classNames + ' dl-table--bordered'
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
if (props.dense) {
|
|
859
|
-
classNames = classNames + ' dl-table--dense'
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
return classNames
|
|
1169
|
+
const hasThead = computed(() => {
|
|
1170
|
+
return !isDataEmpty.value || !!slots['tbody']
|
|
863
1171
|
})
|
|
864
1172
|
|
|
865
1173
|
const containerClass = computed(() => {
|
|
866
|
-
|
|
1174
|
+
const { separator, bordered, dense, loading } = props
|
|
1175
|
+
return getContainerClass(separator, bordered, dense, loading)
|
|
1176
|
+
})
|
|
867
1177
|
|
|
868
|
-
|
|
869
|
-
|
|
1178
|
+
const containerStyle = computed(() => {
|
|
1179
|
+
if (props.virtualScroll) {
|
|
1180
|
+
return {
|
|
1181
|
+
height: 'var(--dl-table-height, 500px)'
|
|
1182
|
+
}
|
|
870
1183
|
}
|
|
871
|
-
|
|
872
|
-
return classNames
|
|
873
1184
|
})
|
|
874
1185
|
|
|
875
1186
|
const nothingToDisplay = computed(() => computedRows.value.length === 0)
|
|
@@ -905,14 +1216,13 @@ export default defineComponent({
|
|
|
905
1216
|
const hasDraggableRows = computed(() =>
|
|
906
1217
|
['rows', 'both'].includes(draggable.value)
|
|
907
1218
|
)
|
|
1219
|
+
|
|
908
1220
|
const hasDraggableColumns = computed(() =>
|
|
909
1221
|
['columns', 'both'].includes(draggable.value)
|
|
910
1222
|
)
|
|
911
1223
|
|
|
912
|
-
|
|
913
|
-
let removeDraggableColumns = () => {}
|
|
1224
|
+
const removeDraggableColumns = () => {}
|
|
914
1225
|
|
|
915
|
-
let resizableManager: ResizableManager | null = null
|
|
916
1226
|
let tableEl: HTMLTableElement = null
|
|
917
1227
|
|
|
918
1228
|
const totalItemsCount = computed(() => {
|
|
@@ -920,29 +1230,24 @@ export default defineComponent({
|
|
|
920
1230
|
})
|
|
921
1231
|
|
|
922
1232
|
onMounted(() => {
|
|
923
|
-
tableEl =
|
|
1233
|
+
tableEl = document.querySelector(
|
|
924
1234
|
'table.dl-table'
|
|
925
1235
|
) as HTMLTableElement
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
if (props.resizable === true) {
|
|
929
|
-
resizableManager.addResizeCapability(tableEl)
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
if (hasDraggableRows.value === true) {
|
|
933
|
-
removeDraggableRows = applyDraggableRows(
|
|
1236
|
+
nextTick(() => {
|
|
1237
|
+
setAllColumnWidths(
|
|
934
1238
|
tableEl,
|
|
935
|
-
|
|
936
|
-
|
|
1239
|
+
props.columns as DlTableColumn[],
|
|
1240
|
+
props.fitAllColumns
|
|
937
1241
|
)
|
|
1242
|
+
})
|
|
1243
|
+
if (props.resizable === true) {
|
|
1244
|
+
applyResizableColumns(tableEl, vm)
|
|
938
1245
|
}
|
|
939
|
-
|
|
940
1246
|
if (hasDraggableColumns.value === true) {
|
|
941
|
-
|
|
1247
|
+
applyDraggableColumns(
|
|
942
1248
|
tableEl,
|
|
943
1249
|
vm,
|
|
944
|
-
vm.refs.dragRef as HTMLDivElement
|
|
945
|
-
rootRef.value
|
|
1250
|
+
vm.refs.dragRef as HTMLDivElement
|
|
946
1251
|
)
|
|
947
1252
|
}
|
|
948
1253
|
})
|
|
@@ -955,26 +1260,14 @@ export default defineComponent({
|
|
|
955
1260
|
) as HTMLTableElement
|
|
956
1261
|
|
|
957
1262
|
if (props.resizable) {
|
|
958
|
-
|
|
959
|
-
resizableManager.addResizeCapability(tableEl)
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
if (hasDraggableRows.value === true) {
|
|
963
|
-
removeDraggableRows()
|
|
964
|
-
removeDraggableRows = applyDraggableRows(
|
|
965
|
-
tableEl,
|
|
966
|
-
vm,
|
|
967
|
-
rootRef.value
|
|
968
|
-
)
|
|
1263
|
+
applyResizableColumns(tableEl, vm)
|
|
969
1264
|
}
|
|
970
1265
|
|
|
971
1266
|
if (hasDraggableColumns.value === true) {
|
|
972
|
-
|
|
973
|
-
removeDraggableColumns = applyDraggableColumns(
|
|
1267
|
+
applyDraggableColumns(
|
|
974
1268
|
tableEl,
|
|
975
1269
|
vm,
|
|
976
|
-
vm.refs.dragRef as HTMLDivElement
|
|
977
|
-
rootRef.value
|
|
1270
|
+
vm.refs.dragRef as HTMLDivElement
|
|
978
1271
|
)
|
|
979
1272
|
}
|
|
980
1273
|
},
|
|
@@ -985,17 +1278,27 @@ export default defineComponent({
|
|
|
985
1278
|
|
|
986
1279
|
watch(
|
|
987
1280
|
() => props.resizable,
|
|
988
|
-
(
|
|
989
|
-
|
|
990
|
-
resizableManager.addResizeCapability(tableEl)
|
|
991
|
-
} else {
|
|
992
|
-
resizableManager.removeResizeCapability()
|
|
993
|
-
}
|
|
1281
|
+
() => {
|
|
1282
|
+
applyResizableColumns(tableEl, vm)
|
|
994
1283
|
}
|
|
995
1284
|
)
|
|
996
1285
|
|
|
997
1286
|
watch(
|
|
998
|
-
() =>
|
|
1287
|
+
() => props.columns,
|
|
1288
|
+
(newColumns) => {
|
|
1289
|
+
setAllColumnWidths(
|
|
1290
|
+
rootRef.value,
|
|
1291
|
+
newColumns as DlTableColumn[],
|
|
1292
|
+
props.fitAllColumns
|
|
1293
|
+
)
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
flush: 'post'
|
|
1297
|
+
}
|
|
1298
|
+
)
|
|
1299
|
+
|
|
1300
|
+
watch(
|
|
1301
|
+
() => (props as any).visibleColummns,
|
|
999
1302
|
(value) => {
|
|
1000
1303
|
visibleColumnsState.value = value
|
|
1001
1304
|
}
|
|
@@ -1005,22 +1308,11 @@ export default defineComponent({
|
|
|
1005
1308
|
() => props.draggable,
|
|
1006
1309
|
() => {
|
|
1007
1310
|
if (tableEl) {
|
|
1008
|
-
if (hasDraggableRows.value === true) {
|
|
1009
|
-
removeDraggableRows = applyDraggableRows(
|
|
1010
|
-
tableEl,
|
|
1011
|
-
vm,
|
|
1012
|
-
rootRef.value
|
|
1013
|
-
)
|
|
1014
|
-
} else {
|
|
1015
|
-
removeDraggableRows()
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
1311
|
if (hasDraggableColumns.value === true) {
|
|
1019
|
-
|
|
1312
|
+
applyDraggableColumns(
|
|
1020
1313
|
tableEl,
|
|
1021
1314
|
vm,
|
|
1022
|
-
vm.refs.dragRef as HTMLDivElement
|
|
1023
|
-
rootRef.value
|
|
1315
|
+
vm.refs.dragRef as HTMLDivElement
|
|
1024
1316
|
)
|
|
1025
1317
|
} else {
|
|
1026
1318
|
removeDraggableColumns()
|
|
@@ -1036,7 +1328,7 @@ export default defineComponent({
|
|
|
1036
1328
|
tableClass,
|
|
1037
1329
|
tableHeaderStyle,
|
|
1038
1330
|
tableHeaderClass,
|
|
1039
|
-
|
|
1331
|
+
containerClass
|
|
1040
1332
|
],
|
|
1041
1333
|
() => {
|
|
1042
1334
|
if (
|
|
@@ -1054,10 +1346,8 @@ export default defineComponent({
|
|
|
1054
1346
|
watch(
|
|
1055
1347
|
[computedPagination, dense],
|
|
1056
1348
|
() => {
|
|
1057
|
-
if (tableEl && props.resizable
|
|
1349
|
+
if (tableEl && props.resizable) {
|
|
1058
1350
|
const tableHeight = tableEl.offsetHeight || 0
|
|
1059
|
-
|
|
1060
|
-
resizableManager.updateResizersHeight(tableHeight)
|
|
1061
1351
|
}
|
|
1062
1352
|
},
|
|
1063
1353
|
{ deep: true, flush: 'post' }
|
|
@@ -1123,7 +1413,7 @@ export default defineComponent({
|
|
|
1123
1413
|
}
|
|
1124
1414
|
}
|
|
1125
1415
|
|
|
1126
|
-
return
|
|
1416
|
+
return filtered
|
|
1127
1417
|
})
|
|
1128
1418
|
|
|
1129
1419
|
const additionalClasses = computed(() => {
|
|
@@ -1277,20 +1567,6 @@ export default defineComponent({
|
|
|
1277
1567
|
lastPage
|
|
1278
1568
|
}))
|
|
1279
1569
|
|
|
1280
|
-
function getCellValue(
|
|
1281
|
-
col: Record<string, any>,
|
|
1282
|
-
row: Record<string, any>
|
|
1283
|
-
) {
|
|
1284
|
-
if (!col) {
|
|
1285
|
-
return
|
|
1286
|
-
}
|
|
1287
|
-
const val =
|
|
1288
|
-
typeof col?.field === 'function'
|
|
1289
|
-
? col?.field(row)
|
|
1290
|
-
: row[col.field]
|
|
1291
|
-
return col?.format ? col.format(val, row) : val
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
1570
|
function resetVirtualScroll() {
|
|
1295
1571
|
if (hasVirtScroll.value === true) {
|
|
1296
1572
|
virtScrollRef.value.reset()
|
|
@@ -1438,6 +1714,28 @@ export default defineComponent({
|
|
|
1438
1714
|
() => !!slots['header-selection']
|
|
1439
1715
|
)
|
|
1440
1716
|
|
|
1717
|
+
const handleSortableEvent = (event: SortableEvent) => {
|
|
1718
|
+
const { oldIndex, newIndex } = event
|
|
1719
|
+
const newRows = insertAtIndex(props.rows, oldIndex, newIndex)
|
|
1720
|
+
tbodyKey.value = v4()
|
|
1721
|
+
emit('row-reorder', newRows)
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
const reorderColumns = (sourceIndex: number, targetIndex: number) => {
|
|
1725
|
+
const newColumns = insertAtIndex(
|
|
1726
|
+
props.columns,
|
|
1727
|
+
sourceIndex,
|
|
1728
|
+
targetIndex
|
|
1729
|
+
)
|
|
1730
|
+
if (isEqual(newColumns, props.columns)) return
|
|
1731
|
+
tableKey.value = v4()
|
|
1732
|
+
emit('col-update', newColumns)
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
const updateColumns = (newColumns: DlTableColumn[]) => {
|
|
1736
|
+
emit('col-update', newColumns)
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1441
1739
|
// expose public methods and needed computed props
|
|
1442
1740
|
Object.assign(vm.proxy, {
|
|
1443
1741
|
resetVirtualScroll,
|
|
@@ -1447,7 +1745,14 @@ export default defineComponent({
|
|
|
1447
1745
|
firstPage,
|
|
1448
1746
|
prevPage,
|
|
1449
1747
|
nextPage,
|
|
1450
|
-
lastPage
|
|
1748
|
+
lastPage,
|
|
1749
|
+
updateColumns,
|
|
1750
|
+
reorderColumns,
|
|
1751
|
+
setIsResizing,
|
|
1752
|
+
setIsDragging,
|
|
1753
|
+
getIsResizing,
|
|
1754
|
+
getIsDragging,
|
|
1755
|
+
getTableKey
|
|
1451
1756
|
})
|
|
1452
1757
|
|
|
1453
1758
|
const slotNames = computed(() => {
|
|
@@ -1464,7 +1769,19 @@ export default defineComponent({
|
|
|
1464
1769
|
emit('update-visible-columns', columns)
|
|
1465
1770
|
}
|
|
1466
1771
|
|
|
1772
|
+
const showRowActions = computed<boolean>(
|
|
1773
|
+
() =>
|
|
1774
|
+
!!(props.visibleColumns && props.visibleColumns.length) ||
|
|
1775
|
+
!!hasSlotByName(`body-cell-row-actions`)
|
|
1776
|
+
)
|
|
1777
|
+
|
|
1467
1778
|
return {
|
|
1779
|
+
containerStyle,
|
|
1780
|
+
isDataEmpty,
|
|
1781
|
+
hasThead,
|
|
1782
|
+
handleSortableEvent,
|
|
1783
|
+
tbodyKey,
|
|
1784
|
+
tableKey,
|
|
1468
1785
|
uuid: `dl-table-${v4()}`,
|
|
1469
1786
|
rootRef,
|
|
1470
1787
|
containerClass,
|
|
@@ -1522,10 +1839,36 @@ export default defineComponent({
|
|
|
1522
1839
|
visibleColumnsState,
|
|
1523
1840
|
handleVisibleColumnsUpdate,
|
|
1524
1841
|
computedVisibleCols,
|
|
1525
|
-
totalItemsCount
|
|
1842
|
+
totalItemsCount,
|
|
1843
|
+
showRowActions
|
|
1526
1844
|
}
|
|
1527
1845
|
}
|
|
1528
1846
|
})
|
|
1529
1847
|
</script>
|
|
1530
1848
|
|
|
1531
|
-
<style scoped
|
|
1849
|
+
<style scoped lang="scss">
|
|
1850
|
+
@import './styles/dl-table-styles.scss';
|
|
1851
|
+
|
|
1852
|
+
table {
|
|
1853
|
+
width: 100%;
|
|
1854
|
+
table-layout: fixed;
|
|
1855
|
+
border-collapse: collapse;
|
|
1856
|
+
border-spacing: 0;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
tbody {
|
|
1860
|
+
display: table-row-group;
|
|
1861
|
+
vertical-align: middle;
|
|
1862
|
+
border-color: inherit;
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
tr {
|
|
1866
|
+
display: table-row;
|
|
1867
|
+
vertical-align: inherit;
|
|
1868
|
+
border-color: inherit;
|
|
1869
|
+
}
|
|
1870
|
+
th,
|
|
1871
|
+
td {
|
|
1872
|
+
box-sizing: border-box;
|
|
1873
|
+
}
|
|
1874
|
+
</style>
|