@dataloop-ai/components 0.20.165 → 0.20.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.
- package/package.json +1 -1
- package/src/components/compound/DlTable/hooks/tableRowSelection.ts +12 -8
- package/src/components/compound/DlTable/types.ts +1 -0
- package/src/components/compound/DlTreeTable/DlTreeTable.vue +7 -11
- package/src/components/compound/DlTreeTable/utils/treeTableRowSelection.ts +3 -1
- package/src/demos/DlTreeTableDemo.vue +11 -3
package/package.json
CHANGED
|
@@ -51,14 +51,18 @@ export function useTableRowSelection(
|
|
|
51
51
|
)
|
|
52
52
|
)
|
|
53
53
|
|
|
54
|
-
const someRowsSelected = computed(
|
|
55
|
-
()
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
const someRowsSelected = computed(() => {
|
|
55
|
+
if (allRowsSelected.value === true) return false
|
|
56
|
+
const stack = computedRows.value.slice()
|
|
57
|
+
while (stack.length) {
|
|
58
|
+
const row = stack.pop()
|
|
59
|
+
if (selectedKeys.value[getRowKey.value(row)] === true) return true
|
|
60
|
+
if (row.children && row.children.length) {
|
|
61
|
+
stack.push(...row.children)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return false
|
|
65
|
+
})
|
|
62
66
|
const rowsSelectedNumber = computed(() => props.selected.length)
|
|
63
67
|
|
|
64
68
|
function isRowSelected(key: string) {
|
|
@@ -513,7 +513,12 @@ export default defineComponent({
|
|
|
513
513
|
props.rowKey
|
|
514
514
|
)
|
|
515
515
|
|
|
516
|
-
updateSelection(
|
|
516
|
+
selectedData.value = updateSelection(
|
|
517
|
+
childrenKeys,
|
|
518
|
+
childrenCollection,
|
|
519
|
+
adding,
|
|
520
|
+
event
|
|
521
|
+
)
|
|
517
522
|
}
|
|
518
523
|
const headerSelectedValue = computed(() => {
|
|
519
524
|
if (selectedData.value.length === tableRows.value.length)
|
|
@@ -538,16 +543,7 @@ export default defineComponent({
|
|
|
538
543
|
updateSelected(value ? tableRows.value : [])
|
|
539
544
|
}
|
|
540
545
|
const updateSelected = (payload: DlTableRow[]) => {
|
|
541
|
-
|
|
542
|
-
selectedData.value = payload
|
|
543
|
-
|
|
544
|
-
if (payload.length > 0) {
|
|
545
|
-
selectAllRows(true)
|
|
546
|
-
} else if (payload.length === 0 && hasSelection) {
|
|
547
|
-
selectAllRows(false)
|
|
548
|
-
} else {
|
|
549
|
-
emitSelectedItems(payload)
|
|
550
|
-
}
|
|
546
|
+
selectedData.value = selectAllRows(!allRowsSelected.value)
|
|
551
547
|
}
|
|
552
548
|
const emitSelectedItems = (payload: DlTableRow[]) => {
|
|
553
549
|
emit('selected-items', payload)
|
|
@@ -182,6 +182,7 @@ export function useTreeTableRowSelection(
|
|
|
182
182
|
selectedItemsNested.value = selectedItems
|
|
183
183
|
|
|
184
184
|
emit('selected-items', selectedItems)
|
|
185
|
+
return selectedItems
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
function isIncludedInSelectedNestedItems(
|
|
@@ -257,12 +258,13 @@ export function useTreeTableRowSelection(
|
|
|
257
258
|
if (select) {
|
|
258
259
|
const allRows = getAllRows(computedRows.value)
|
|
259
260
|
const allKeys = allRows.map(getRowKey.value)
|
|
260
|
-
updateSelection(allKeys, allRows, true)
|
|
261
|
+
return updateSelection(allKeys, allRows, true)
|
|
261
262
|
} else {
|
|
262
263
|
clearSelection()
|
|
263
264
|
selectedItemsNested.value = []
|
|
264
265
|
emit('selected-items', [])
|
|
265
266
|
}
|
|
267
|
+
return []
|
|
266
268
|
}
|
|
267
269
|
|
|
268
270
|
return {
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
:loading="loading"
|
|
111
111
|
:rows="tableRows"
|
|
112
112
|
:resizable="resizable"
|
|
113
|
-
row-key="
|
|
113
|
+
row-key="id"
|
|
114
114
|
color="dl-color-secondary"
|
|
115
115
|
title="Table Title"
|
|
116
116
|
:virtual-scroll="vScroll"
|
|
@@ -560,7 +560,15 @@ const columns2 = [
|
|
|
560
560
|
hint: 'test hint'
|
|
561
561
|
}
|
|
562
562
|
]
|
|
563
|
-
|
|
563
|
+
function markAllSelectable(list: DlTableRow[]): DlTableRow[] {
|
|
564
|
+
return list.map((r) => ({
|
|
565
|
+
...r,
|
|
566
|
+
isSelectable: true,
|
|
567
|
+
...(Array.isArray(r.children) && r.children.length
|
|
568
|
+
? { children: markAllSelectable(r.children) }
|
|
569
|
+
: {})
|
|
570
|
+
}))
|
|
571
|
+
}
|
|
564
572
|
export default defineComponent({
|
|
565
573
|
components: {
|
|
566
574
|
DlSwitch,
|
|
@@ -583,7 +591,7 @@ export default defineComponent({
|
|
|
583
591
|
const denseState = ref([])
|
|
584
592
|
const virtualScroll = ref([])
|
|
585
593
|
const resizableState = ref([])
|
|
586
|
-
const tableRows = ref(rows)
|
|
594
|
+
const tableRows = ref(markAllSelectable(rows))
|
|
587
595
|
const tableRowsVS = ref(cloneDeep(rows))
|
|
588
596
|
const draggable = ref('both')
|
|
589
597
|
const tableColumns = ref(columns)
|