@dataloop-ai/components 0.18.77 → 0.18.78
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/src/components/compound/DlTable/DlTable.vue +77 -4
- package/src/components/compound/DlTable/hooks/tableColumnSelection.ts +5 -4
- package/src/components/compound/DlTable/utils/props.ts +1 -0
- package/src/components/compound/DlTreeTable/emits.ts +1 -0
- package/src/demos/DlTableDemo.vue +9 -0
package/package.json
CHANGED
|
@@ -332,6 +332,34 @@
|
|
|
332
332
|
{{ col.label }}
|
|
333
333
|
</DlTh>
|
|
334
334
|
</slot>
|
|
335
|
+
<DlTh
|
|
336
|
+
v-if="hasEditableColumns"
|
|
337
|
+
key="visibleColsBtn"
|
|
338
|
+
>
|
|
339
|
+
<dl-button
|
|
340
|
+
text-color="dl-color-medium"
|
|
341
|
+
flat
|
|
342
|
+
icon="icon-dl-column"
|
|
343
|
+
>
|
|
344
|
+
<dl-menu>
|
|
345
|
+
<dl-list separator>
|
|
346
|
+
<dl-option-group
|
|
347
|
+
:model-value="
|
|
348
|
+
computedVisibleCols
|
|
349
|
+
"
|
|
350
|
+
:options="groupOptions"
|
|
351
|
+
:left-label="true"
|
|
352
|
+
max-width="250px"
|
|
353
|
+
type="switch"
|
|
354
|
+
class="table-options"
|
|
355
|
+
@update:model-value="
|
|
356
|
+
handleVisibleColumnsUpdate
|
|
357
|
+
"
|
|
358
|
+
/>
|
|
359
|
+
</dl-list>
|
|
360
|
+
</dl-menu>
|
|
361
|
+
</dl-button>
|
|
362
|
+
</DlTh>
|
|
335
363
|
</DlTr>
|
|
336
364
|
|
|
337
365
|
<tr
|
|
@@ -583,8 +611,16 @@ import {
|
|
|
583
611
|
import { injectProp } from '../../../utils/inject-object-prop'
|
|
584
612
|
import { DlTableRow, DlTableProps, DlTableColumn } from './types'
|
|
585
613
|
import { DlPagination } from '../DlPagination'
|
|
586
|
-
import {
|
|
614
|
+
import {
|
|
615
|
+
DlIcon,
|
|
616
|
+
DlCheckbox,
|
|
617
|
+
DlProgressBar,
|
|
618
|
+
DlMenu,
|
|
619
|
+
DlList
|
|
620
|
+
} from '../../essential'
|
|
587
621
|
import { ResizableManager } from './utils'
|
|
622
|
+
import { DlButton } from '../../basic'
|
|
623
|
+
import { DlOptionGroup } from '../../compound'
|
|
588
624
|
import DlEmptyState from '../../basic/DlEmptyState/DlEmptyState.vue'
|
|
589
625
|
import { v4 } from 'uuid'
|
|
590
626
|
import { flatTreeData } from '../DlTreeTable/utils/flatTreeData'
|
|
@@ -606,7 +642,11 @@ export default defineComponent({
|
|
|
606
642
|
DlProgressBar,
|
|
607
643
|
DlIcon,
|
|
608
644
|
DlCheckbox,
|
|
609
|
-
DlEmptyState
|
|
645
|
+
DlEmptyState,
|
|
646
|
+
DlButton,
|
|
647
|
+
DlOptionGroup,
|
|
648
|
+
DlMenu,
|
|
649
|
+
DlList
|
|
610
650
|
},
|
|
611
651
|
props,
|
|
612
652
|
emits,
|
|
@@ -625,6 +665,21 @@ export default defineComponent({
|
|
|
625
665
|
const virtScrollRef = ref(null)
|
|
626
666
|
const hasVirtScroll = computed(() => props.virtualScroll === true)
|
|
627
667
|
|
|
668
|
+
const groupOptions = computed(() =>
|
|
669
|
+
(props.columns as DlTableColumn[]).map((item) => ({
|
|
670
|
+
label: item.label,
|
|
671
|
+
value: item.name
|
|
672
|
+
}))
|
|
673
|
+
)
|
|
674
|
+
|
|
675
|
+
const visibleColumnsState = ref(
|
|
676
|
+
(props.columns as DlTableColumn[]).map((col) => col.name)
|
|
677
|
+
)
|
|
678
|
+
|
|
679
|
+
const computedVisibleCols = computed(() =>
|
|
680
|
+
computedCols.value.map((col) => col.name)
|
|
681
|
+
)
|
|
682
|
+
|
|
628
683
|
const { hasAnyAction } = useTableActions(props) // todo: does not work
|
|
629
684
|
|
|
630
685
|
const getRowKey = computed(() =>
|
|
@@ -790,6 +845,13 @@ export default defineComponent({
|
|
|
790
845
|
}
|
|
791
846
|
)
|
|
792
847
|
|
|
848
|
+
watch(
|
|
849
|
+
() => (props as any).visibleColummns,
|
|
850
|
+
(value) => {
|
|
851
|
+
visibleColumnsState.value = value
|
|
852
|
+
}
|
|
853
|
+
)
|
|
854
|
+
|
|
793
855
|
watch(
|
|
794
856
|
() => props.draggable,
|
|
795
857
|
() => {
|
|
@@ -950,7 +1012,8 @@ export default defineComponent({
|
|
|
950
1012
|
props as unknown as DlTableProps,
|
|
951
1013
|
computedPagination,
|
|
952
1014
|
hasSelectionMode,
|
|
953
|
-
hasDraggableRows
|
|
1015
|
+
hasDraggableRows,
|
|
1016
|
+
visibleColumnsState
|
|
954
1017
|
)
|
|
955
1018
|
|
|
956
1019
|
const { columnToSort, computedSortMethod, sort } = useTableSort(
|
|
@@ -1243,6 +1306,12 @@ export default defineComponent({
|
|
|
1243
1306
|
() => Object.keys(props.emptyStateProps).length > 0
|
|
1244
1307
|
)
|
|
1245
1308
|
|
|
1309
|
+
const handleVisibleColumnsUpdate = (columns: string[]) => {
|
|
1310
|
+
if (columns.length < 1) return
|
|
1311
|
+
visibleColumnsState.value = columns
|
|
1312
|
+
emit('update-visible-columns', columns)
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1246
1315
|
return {
|
|
1247
1316
|
uuid: `dl-table-${v4()}`,
|
|
1248
1317
|
rootRef,
|
|
@@ -1296,7 +1365,11 @@ export default defineComponent({
|
|
|
1296
1365
|
hasSlotHeaderSelection,
|
|
1297
1366
|
stopAndPrevent,
|
|
1298
1367
|
updatePagination,
|
|
1299
|
-
hasEmptyStateProps
|
|
1368
|
+
hasEmptyStateProps,
|
|
1369
|
+
groupOptions,
|
|
1370
|
+
visibleColumnsState,
|
|
1371
|
+
handleVisibleColumnsUpdate,
|
|
1372
|
+
computedVisibleCols
|
|
1300
1373
|
}
|
|
1301
1374
|
}
|
|
1302
1375
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, ComputedRef } from 'vue-demi'
|
|
1
|
+
import { computed, ComputedRef, Ref } from 'vue-demi'
|
|
2
2
|
|
|
3
3
|
import { isNumber } from '../../../../utils/is'
|
|
4
4
|
import { DlTableProps, DlTableColumn, DlTableRow } from '../types'
|
|
@@ -12,7 +12,8 @@ export function useTableColumnSelection(
|
|
|
12
12
|
props: DlTableProps,
|
|
13
13
|
computedPagination: ComputedRef<TablePagination>,
|
|
14
14
|
hasSelectionMode: ComputedRef<boolean>,
|
|
15
|
-
hasDraggableRows: ComputedRef<boolean
|
|
15
|
+
hasDraggableRows: ComputedRef<boolean>,
|
|
16
|
+
visibleColumnsState: Ref
|
|
16
17
|
) {
|
|
17
18
|
const colList = computed(() => {
|
|
18
19
|
if (props.columns) {
|
|
@@ -40,11 +41,11 @@ export function useTableColumnSelection(
|
|
|
40
41
|
const computedCols = computed(() => {
|
|
41
42
|
const { sortBy, descending } = computedPagination.value
|
|
42
43
|
|
|
43
|
-
const cols =
|
|
44
|
+
const cols = visibleColumnsState?.value
|
|
44
45
|
? colList.value.filter(
|
|
45
46
|
(col) =>
|
|
46
47
|
col.required === true ||
|
|
47
|
-
|
|
48
|
+
visibleColumnsState.value.includes(col.name) === true
|
|
48
49
|
)
|
|
49
50
|
: colList.value
|
|
50
51
|
|
|
@@ -408,6 +408,15 @@
|
|
|
408
408
|
</template>
|
|
409
409
|
</DlTable>
|
|
410
410
|
</div>
|
|
411
|
+
<div>
|
|
412
|
+
<p>With editable columns</p>
|
|
413
|
+
<DlTable
|
|
414
|
+
:rows="tableRows"
|
|
415
|
+
:columns="tableColumns"
|
|
416
|
+
title="Editable Columns"
|
|
417
|
+
has-editable-columns
|
|
418
|
+
/>
|
|
419
|
+
</div>
|
|
411
420
|
</div>
|
|
412
421
|
</div>
|
|
413
422
|
</template>
|