@dataloop-ai/components 0.18.68 → 0.18.70
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/DlCodeEditor/components/CodeEditor.vue +3 -3
- package/src/components/compound/DlTreeTable/DlTreeTable.vue +14 -12
- package/src/components/compound/DlTreeTable/components/DlTrTree.vue +30 -2
- package/src/components/compound/DlTreeTable/utils/getFromChildren.ts +1 -0
- package/src/components/compound/DlTreeTable/views/DlTrTreeView.vue +98 -12
- package/src/utils/draggable-table.ts +95 -25
package/package.json
CHANGED
|
@@ -410,7 +410,7 @@ export default defineComponent({
|
|
|
410
410
|
if (scrolling.value) {
|
|
411
411
|
scrolling.value = false
|
|
412
412
|
} else {
|
|
413
|
-
debouncedGetLinesCount()
|
|
413
|
+
debouncedGetLinesCount.value()
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
hljs.highlightElement(code.value)
|
|
@@ -443,7 +443,7 @@ export default defineComponent({
|
|
|
443
443
|
if (scrolling.value) {
|
|
444
444
|
scrolling.value = false
|
|
445
445
|
} else {
|
|
446
|
-
debouncedGetLinesCount()
|
|
446
|
+
debouncedGetLinesCount.value()
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
449
|
})
|
|
@@ -454,7 +454,7 @@ export default defineComponent({
|
|
|
454
454
|
if (scrolling.value) {
|
|
455
455
|
scrolling.value = false
|
|
456
456
|
} else {
|
|
457
|
-
debouncedGetLinesCount()
|
|
457
|
+
debouncedGetLinesCount.value()
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
})
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
dlTableRef.getBodySelectionScope({
|
|
54
54
|
key: getRowKey(props.item),
|
|
55
55
|
row: props.item,
|
|
56
|
-
|
|
56
|
+
rowIndex: props.index
|
|
57
57
|
})
|
|
58
58
|
"
|
|
59
59
|
:bind-body-cell-scope="
|
|
60
60
|
dlTableRef.getBodyCellScope({
|
|
61
61
|
key: getRowKey(props.item),
|
|
62
62
|
row: props.item,
|
|
63
|
-
|
|
63
|
+
rowIndex: props.index
|
|
64
64
|
})
|
|
65
65
|
"
|
|
66
66
|
:color="color"
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
dlTableRef.getBodyCellScope({
|
|
103
103
|
key: getRowKey(props.item),
|
|
104
104
|
row: props.item,
|
|
105
|
-
|
|
105
|
+
rowIndex: props.index
|
|
106
106
|
})
|
|
107
107
|
"
|
|
108
108
|
/>
|
|
@@ -112,9 +112,10 @@
|
|
|
112
112
|
<template v-else>
|
|
113
113
|
<template v-if="dlTableRef && !isEmpty">
|
|
114
114
|
<DlTrTreeView
|
|
115
|
-
v-for="(row,
|
|
116
|
-
:key="
|
|
115
|
+
v-for="(row, rowIndex) in computedRows"
|
|
116
|
+
:key="rowIndex"
|
|
117
117
|
:row="row"
|
|
118
|
+
:row-key="rowKey"
|
|
118
119
|
:is-row-selected="
|
|
119
120
|
isRowSelected(rowKey, getRowKey(row))
|
|
120
121
|
? 'selected'
|
|
@@ -122,21 +123,21 @@
|
|
|
122
123
|
"
|
|
123
124
|
:has-any-action="dlTableRef.hasAnyAction"
|
|
124
125
|
:no-hover="dlTableRef.noHover"
|
|
125
|
-
:
|
|
126
|
+
:row-index="rowIndex"
|
|
126
127
|
:has-draggable-rows="dlTableRef.hasDraggableRows"
|
|
127
128
|
:has-selection-mode="dlTableRef.hasSelectionMode"
|
|
128
129
|
:bind-body-selection="
|
|
129
130
|
dlTableRef.getBodySelectionScope({
|
|
130
131
|
key: getRowKey(row),
|
|
131
132
|
row,
|
|
132
|
-
|
|
133
|
+
rowIndex
|
|
133
134
|
})
|
|
134
135
|
"
|
|
135
136
|
:bind-body-cell-scope="
|
|
136
137
|
dlTableRef.getBodyCellScope({
|
|
137
138
|
key: getRowKey(row),
|
|
138
139
|
row,
|
|
139
|
-
|
|
140
|
+
rowIndex
|
|
140
141
|
})
|
|
141
142
|
"
|
|
142
143
|
:color="color"
|
|
@@ -148,12 +149,12 @@
|
|
|
148
149
|
(adding, evt) =>
|
|
149
150
|
updateSelectionHierarchy(adding, evt, row)
|
|
150
151
|
"
|
|
151
|
-
@rowClick="dlTableRef.onTrClick($event, row,
|
|
152
|
+
@rowClick="dlTableRef.onTrClick($event, row, rowIndex)"
|
|
152
153
|
@rowDoubleClick="
|
|
153
|
-
dlTableRef.onTrDblClick($event, row,
|
|
154
|
+
dlTableRef.onTrDblClick($event, row, rowIndex)
|
|
154
155
|
"
|
|
155
156
|
@rowContextMenu="
|
|
156
|
-
dlTableRef.onTrContextMenu($event, row,
|
|
157
|
+
dlTableRef.onTrContextMenu($event, row, rowIndex)
|
|
157
158
|
"
|
|
158
159
|
@updateExpandedRow="
|
|
159
160
|
updateExpandedRow(!row.expanded, getRowKey(row))
|
|
@@ -169,7 +170,7 @@
|
|
|
169
170
|
dlTableRef.getBodySelectionScope({
|
|
170
171
|
key: getRowKey(row),
|
|
171
172
|
row,
|
|
172
|
-
|
|
173
|
+
rowIndex
|
|
173
174
|
})
|
|
174
175
|
"
|
|
175
176
|
/>
|
|
@@ -222,6 +223,7 @@ export default defineComponent({
|
|
|
222
223
|
const tableRows = ref(cloneDeep(props.rows))
|
|
223
224
|
const tableColumns = ref(props.columns)
|
|
224
225
|
const hasFlatTreeData = true
|
|
226
|
+
|
|
225
227
|
const hasEmptyStateProps = computed(
|
|
226
228
|
() => Object.keys(props.emptyStateProps).length > 0
|
|
227
229
|
)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<tr
|
|
3
|
+
ref="dlTrTreeRef"
|
|
3
4
|
:class="trClasses"
|
|
4
5
|
v-bind="$attrs"
|
|
6
|
+
:children="children"
|
|
5
7
|
v-on="listeners"
|
|
6
8
|
>
|
|
7
9
|
<slot />
|
|
@@ -9,15 +11,22 @@
|
|
|
9
11
|
</template>
|
|
10
12
|
|
|
11
13
|
<script lang="ts">
|
|
12
|
-
import { defineComponent, isVue2 } from 'vue-demi'
|
|
14
|
+
import { defineComponent, isVue2, watch } from 'vue-demi'
|
|
13
15
|
|
|
14
16
|
export default defineComponent({
|
|
15
17
|
name: 'DlTrTree',
|
|
16
18
|
props: {
|
|
17
19
|
props: { type: Object, default: () => {} },
|
|
18
|
-
noHover: Boolean
|
|
20
|
+
noHover: Boolean,
|
|
21
|
+
children: {
|
|
22
|
+
type: Number,
|
|
23
|
+
default: null
|
|
24
|
+
}
|
|
19
25
|
},
|
|
20
26
|
computed: {
|
|
27
|
+
childrenComputed() {
|
|
28
|
+
return this.children
|
|
29
|
+
},
|
|
21
30
|
listeners(): any {
|
|
22
31
|
if (isVue2) {
|
|
23
32
|
// @ts-ignore
|
|
@@ -45,6 +54,25 @@ export default defineComponent({
|
|
|
45
54
|
|
|
46
55
|
return classes
|
|
47
56
|
}
|
|
57
|
+
},
|
|
58
|
+
watch: {
|
|
59
|
+
childrenComputed(value) {
|
|
60
|
+
(this.$refs.dlTrTreeRef as any).setAttribute(
|
|
61
|
+
'data-children',
|
|
62
|
+
value
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
mounted(): void {
|
|
67
|
+
this.setAttributeChildren()
|
|
68
|
+
},
|
|
69
|
+
methods: {
|
|
70
|
+
setAttributeChildren() {
|
|
71
|
+
(this.$refs.dlTrTreeRef as any).setAttribute(
|
|
72
|
+
'data-children',
|
|
73
|
+
this.children
|
|
74
|
+
)
|
|
75
|
+
}
|
|
48
76
|
}
|
|
49
77
|
})
|
|
50
78
|
</script>
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
v-show="row.isExpandedParent || row.level === 1"
|
|
4
4
|
:class="rowClass"
|
|
5
5
|
:no-hover="noHover"
|
|
6
|
-
|
|
7
|
-
@
|
|
8
|
-
@
|
|
6
|
+
:children="childrenCount"
|
|
7
|
+
@click="emitRowClick($event, row, rowIndex)"
|
|
8
|
+
@dblclick="onTrDoubleClick($event, row, rowIndex)"
|
|
9
|
+
@contextmenu="onTrContextMenu($event, row, rowIndex)"
|
|
9
10
|
>
|
|
10
11
|
<td v-if="hasDraggableRows">
|
|
11
12
|
<dl-icon
|
|
@@ -62,7 +63,14 @@
|
|
|
62
63
|
</template>
|
|
63
64
|
|
|
64
65
|
<script lang="ts">
|
|
65
|
-
import {
|
|
66
|
+
import {
|
|
67
|
+
defineComponent,
|
|
68
|
+
PropType,
|
|
69
|
+
onMounted,
|
|
70
|
+
ref,
|
|
71
|
+
toRefs,
|
|
72
|
+
watch
|
|
73
|
+
} from 'vue-demi'
|
|
66
74
|
import DlTrTree from '../components/DlTrTree.vue'
|
|
67
75
|
import DlTdTree from '../components/DlTdTree.vue'
|
|
68
76
|
import DlIcon from '../../../essential/DlIcon/DlIcon.vue'
|
|
@@ -84,6 +92,9 @@ export default defineComponent({
|
|
|
84
92
|
type: Object as PropType<Record<string, any>>,
|
|
85
93
|
default: () => ({} as Record<string, any>)
|
|
86
94
|
},
|
|
95
|
+
rowKey: {
|
|
96
|
+
type: [String, Function]
|
|
97
|
+
},
|
|
87
98
|
isRowSelected: {
|
|
88
99
|
type: [Boolean, String],
|
|
89
100
|
default: null
|
|
@@ -96,7 +107,7 @@ export default defineComponent({
|
|
|
96
107
|
type: Boolean,
|
|
97
108
|
default: false
|
|
98
109
|
},
|
|
99
|
-
|
|
110
|
+
rowIndex: {
|
|
100
111
|
type: Number,
|
|
101
112
|
default: null
|
|
102
113
|
},
|
|
@@ -153,28 +164,43 @@ export default defineComponent({
|
|
|
153
164
|
'updateExpandedRow'
|
|
154
165
|
],
|
|
155
166
|
setup(props, context) {
|
|
167
|
+
const visibleChildren = ref(1)
|
|
168
|
+
const childrenCount = ref(1)
|
|
169
|
+
const { row } = toRefs(props)
|
|
170
|
+
|
|
171
|
+
watch(
|
|
172
|
+
row,
|
|
173
|
+
() => {
|
|
174
|
+
getChildrenCount()
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
deep: true,
|
|
178
|
+
flush: 'post'
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
|
|
156
182
|
const emitRowClick = (
|
|
157
183
|
event: MouseEvent,
|
|
158
184
|
row: Record<string, any>,
|
|
159
|
-
|
|
185
|
+
rowIndex: number
|
|
160
186
|
) => {
|
|
161
|
-
context.emit('rowClick', event, row,
|
|
187
|
+
context.emit('rowClick', event, row, rowIndex)
|
|
162
188
|
}
|
|
163
189
|
|
|
164
190
|
const onTrDoubleClick = (
|
|
165
191
|
evt: MouseEvent,
|
|
166
192
|
row: DlTableRow,
|
|
167
|
-
|
|
193
|
+
rowIndex: number
|
|
168
194
|
) => {
|
|
169
|
-
context.emit('rowDoubleClick', evt, row,
|
|
195
|
+
context.emit('rowDoubleClick', evt, row, rowIndex)
|
|
170
196
|
}
|
|
171
197
|
|
|
172
198
|
const onTrContextMenu = (
|
|
173
199
|
evt: MouseEvent,
|
|
174
200
|
row: DlTableRow,
|
|
175
|
-
|
|
201
|
+
rowIndex: number
|
|
176
202
|
) => {
|
|
177
|
-
context.emit('rowContextMenu', evt, row,
|
|
203
|
+
context.emit('rowContextMenu', evt, row, rowIndex)
|
|
178
204
|
}
|
|
179
205
|
|
|
180
206
|
const emitUpdateModelValue = (adding: boolean, evt: Event) => {
|
|
@@ -234,7 +260,65 @@ export default defineComponent({
|
|
|
234
260
|
return ''
|
|
235
261
|
}
|
|
236
262
|
|
|
263
|
+
const getExpandedvisibleChildren = (): void => {
|
|
264
|
+
visibleChildren.value = 1
|
|
265
|
+
updateExpandedvisibleChildren(row.value)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const updateExpandedvisibleChildren = (
|
|
269
|
+
parentRow: Record<string, any>
|
|
270
|
+
): void => {
|
|
271
|
+
if (!parentRow) {
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (!parentRow.expanded) {
|
|
276
|
+
visibleChildren.value = 1
|
|
277
|
+
return
|
|
278
|
+
} else {
|
|
279
|
+
visibleChildren.value += parentRow.children.length
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (!parentRow?.children) {
|
|
283
|
+
return
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
for (const child of parentRow.children) {
|
|
287
|
+
if (child.expanded) {
|
|
288
|
+
updateExpandedvisibleChildren(child)
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const getChildrenCount = (): void => {
|
|
294
|
+
childrenCount.value = 1
|
|
295
|
+
let arr = []
|
|
296
|
+
|
|
297
|
+
if (!Array.isArray(row.value)) {
|
|
298
|
+
arr.push(row.value)
|
|
299
|
+
} else {
|
|
300
|
+
arr = row.value
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
getLength(arr)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const getLength = (data: any) => {
|
|
307
|
+
for (let count = 0; count < data.length; count++) {
|
|
308
|
+
if (data[count]?.children?.length) {
|
|
309
|
+
childrenCount.value += data[count].children.length
|
|
310
|
+
getLength(data[count].children)
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
onMounted(() => {
|
|
316
|
+
getChildrenCount()
|
|
317
|
+
})
|
|
318
|
+
|
|
237
319
|
return {
|
|
320
|
+
visibleChildren,
|
|
321
|
+
childrenCount,
|
|
238
322
|
getRowKey,
|
|
239
323
|
emitRowClick,
|
|
240
324
|
onTrDoubleClick,
|
|
@@ -245,7 +329,9 @@ export default defineComponent({
|
|
|
245
329
|
getCellValue,
|
|
246
330
|
hasSlotByName,
|
|
247
331
|
rowClass,
|
|
248
|
-
getSlotByName
|
|
332
|
+
getSlotByName,
|
|
333
|
+
getExpandedvisibleChildren,
|
|
334
|
+
updateExpandedvisibleChildren
|
|
249
335
|
}
|
|
250
336
|
}
|
|
251
337
|
})
|
|
@@ -68,7 +68,7 @@ export function applyDraggableRows(
|
|
|
68
68
|
) {
|
|
69
69
|
const tbody = table.querySelector('tbody.dl-virtual-scroll__content')!
|
|
70
70
|
|
|
71
|
-
let
|
|
71
|
+
let draggableParentRow: any = null
|
|
72
72
|
let dragElem: any = null
|
|
73
73
|
let oldIndex = 0
|
|
74
74
|
let newIndex = 0
|
|
@@ -79,6 +79,8 @@ export function applyDraggableRows(
|
|
|
79
79
|
let mouseDrag = false
|
|
80
80
|
let rowHeight = 0
|
|
81
81
|
let wasMoved = false
|
|
82
|
+
let draggableTable: any = null
|
|
83
|
+
let childrenCount: number
|
|
82
84
|
|
|
83
85
|
function bindMouse() {
|
|
84
86
|
table.addEventListener('mousedown', handleMouseDown)
|
|
@@ -89,14 +91,60 @@ export function applyDraggableRows(
|
|
|
89
91
|
function handleMouseDown(event: MouseEvent) {
|
|
90
92
|
if (event.button != 0) return true
|
|
91
93
|
|
|
92
|
-
const
|
|
94
|
+
const parentRow = getTargetRow(event.target)
|
|
93
95
|
|
|
94
|
-
if (
|
|
96
|
+
if (!parentRow) {
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
parentRow.classList.add('dl-table__is-dragging')
|
|
101
|
+
const targetRow = parentRow.cloneNode(true)
|
|
102
|
+
|
|
103
|
+
const allRows = [...(table.querySelectorAll('tr') as any)]
|
|
104
|
+
let draggableParentRowIndex = allRows.indexOf(parentRow)
|
|
105
|
+
|
|
106
|
+
const parentRowStyle = window.getComputedStyle(parentRow)
|
|
107
|
+
|
|
108
|
+
draggableTable = document.createElement('table')
|
|
109
|
+
|
|
110
|
+
draggableTable.style.backgroundColor =
|
|
111
|
+
'var(--dl-color-panel-background)'
|
|
112
|
+
draggableTable.style.width = parentRowStyle.width
|
|
113
|
+
draggableTable.style.color = 'var(--dl-color-darker)'
|
|
114
|
+
draggableTable.style.fontSize = '13px'
|
|
115
|
+
draggableTable.style.boxShadow = `var(--dl-menu-shadow)`
|
|
116
|
+
draggableTable.style.zIndex = '9999'
|
|
117
|
+
draggableTable.style.position = 'absolute'
|
|
118
|
+
draggableTable.classList.add('dl-table--horizontal-separator')
|
|
119
|
+
|
|
120
|
+
draggableTable.append(targetRow)
|
|
121
|
+
|
|
122
|
+
childrenCount = targetRow.dataset.children
|
|
123
|
+
? Number(targetRow.dataset.children)
|
|
124
|
+
: 1
|
|
125
|
+
|
|
126
|
+
for (let i = 1; i < childrenCount; i++) {
|
|
127
|
+
draggableParentRowIndex += 1
|
|
128
|
+
allRows[draggableParentRowIndex].classList.add(
|
|
129
|
+
'dl-table__is-dragging'
|
|
130
|
+
)
|
|
131
|
+
draggableTable.append(
|
|
132
|
+
allRows[draggableParentRowIndex].cloneNode(true)
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
Array.from(draggableTable.children).forEach((element) => {
|
|
137
|
+
(element as HTMLElement).classList.remove('dl-table__is-dragging')
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
if (targetRow) {
|
|
95
141
|
table.style.userSelect = 'none'
|
|
96
|
-
rowHeight =
|
|
142
|
+
rowHeight =
|
|
143
|
+
targetRow.cells[0].getBoundingClientRect().height *
|
|
144
|
+
(childrenCount ? childrenCount : 1)
|
|
97
145
|
|
|
98
|
-
|
|
99
|
-
addDraggableRow(
|
|
146
|
+
draggableParentRow = parentRow
|
|
147
|
+
addDraggableRow(draggableTable)
|
|
100
148
|
|
|
101
149
|
const coords = getMouseCoords(event, root)
|
|
102
150
|
|
|
@@ -122,7 +170,7 @@ export function applyDraggableRows(
|
|
|
122
170
|
function handleMouseUp() {
|
|
123
171
|
if (!mouseDrag) return
|
|
124
172
|
|
|
125
|
-
|
|
173
|
+
draggableParentRow.classList.remove('dl-table__is-dragging')
|
|
126
174
|
table.removeChild(dragElem)
|
|
127
175
|
|
|
128
176
|
if (oldIndex !== newIndex) vm?.emit('row-reorder', oldIndex, newIndex)
|
|
@@ -133,25 +181,47 @@ export function applyDraggableRows(
|
|
|
133
181
|
wasMoved = false
|
|
134
182
|
|
|
135
183
|
table.style.userSelect = 'auto'
|
|
184
|
+
|
|
185
|
+
Array.from(tbody.children).forEach((element) => {
|
|
186
|
+
element.classList.remove('dl-table__is-dragging')
|
|
187
|
+
})
|
|
136
188
|
}
|
|
137
189
|
|
|
138
190
|
function swapRow(row: any, index: number) {
|
|
139
|
-
const
|
|
140
|
-
const row1 = currIndex > index ? currRow : row
|
|
141
|
-
const row2 = currIndex > index ? row : currRow
|
|
191
|
+
const allRows = Array.from(tbody.children)
|
|
142
192
|
|
|
143
193
|
newIndex = index + 1
|
|
144
194
|
wasMoved = oldIndex !== newIndex
|
|
145
|
-
|
|
195
|
+
|
|
196
|
+
let indexOfParentRow = allRows.indexOf(draggableParentRow)
|
|
197
|
+
if (indexOfParentRow === -1) {
|
|
198
|
+
return
|
|
199
|
+
}
|
|
200
|
+
const indexEnd = indexOfParentRow + childrenCount
|
|
201
|
+
const hierarchyData = allRows.slice(indexOfParentRow, indexEnd)
|
|
202
|
+
const rowIndex = hierarchyData.indexOf(row)
|
|
203
|
+
const isDraggingOverChildren = rowIndex > -1
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Prevent insertBefore when dragging over the item in the children hierarchy
|
|
207
|
+
* */
|
|
208
|
+
if (isDraggingOverChildren) {
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
for (let i = 0; i < childrenCount; i++) {
|
|
213
|
+
tbody.insertBefore(allRows[indexOfParentRow], row)
|
|
214
|
+
indexOfParentRow++
|
|
215
|
+
}
|
|
146
216
|
}
|
|
147
217
|
|
|
148
218
|
function moveRow(x: number, y: number) {
|
|
149
219
|
dragElem.style.top = y + 'px'
|
|
150
220
|
dragElem.style.left = x + 'px'
|
|
151
221
|
|
|
152
|
-
const
|
|
153
|
-
const
|
|
154
|
-
const
|
|
222
|
+
const draggingPosition = dragElem.getBoundingClientRect()
|
|
223
|
+
const currentStartY = draggingPosition.y
|
|
224
|
+
const currentEndY = currentStartY + draggingPosition.height
|
|
155
225
|
const rows = getRows(table)
|
|
156
226
|
|
|
157
227
|
for (let i = 0; i < rows.length; i++) {
|
|
@@ -161,25 +231,25 @@ export function applyDraggableRows(
|
|
|
161
231
|
const rowEndY = rowStartY + rowSize.height
|
|
162
232
|
|
|
163
233
|
if (
|
|
164
|
-
|
|
165
|
-
isIntersecting(
|
|
234
|
+
draggableParentRow !== rowElem &&
|
|
235
|
+
isIntersecting(currentStartY, currentEndY, rowStartY, rowEndY)
|
|
166
236
|
) {
|
|
167
|
-
if (Math.abs(
|
|
237
|
+
if (Math.abs(currentStartY - rowStartY) < rowSize.height / 2)
|
|
168
238
|
swapRow(rowElem, i)
|
|
169
239
|
}
|
|
170
240
|
}
|
|
171
241
|
}
|
|
172
242
|
|
|
173
|
-
function addDraggableRow(
|
|
174
|
-
|
|
175
|
-
dragElem =
|
|
176
|
-
oldIndex =
|
|
177
|
-
newIndex =
|
|
243
|
+
function addDraggableRow(targetRow: any) {
|
|
244
|
+
targetRow.classList.add('dl-table__is-dragging')
|
|
245
|
+
dragElem = targetRow.cloneNode(true)
|
|
246
|
+
oldIndex = targetRow.rowIndex
|
|
247
|
+
newIndex = targetRow.rowIndex
|
|
178
248
|
|
|
179
249
|
dragElem.classList.add('dl-table__drag')
|
|
180
250
|
dragElem.style.height = `${rowHeight}px`
|
|
181
|
-
for (let i = 0; i <
|
|
182
|
-
const oldTD =
|
|
251
|
+
for (let i = 0; i < targetRow.children.length; i++) {
|
|
252
|
+
const oldTD = targetRow.children[i]
|
|
183
253
|
const newTD = dragElem.children[i]
|
|
184
254
|
newTD.style.width = getStyle(oldTD, 'width')
|
|
185
255
|
newTD.style.height = getStyle(oldTD, 'height')
|
|
@@ -189,7 +259,7 @@ export function applyDraggableRows(
|
|
|
189
259
|
|
|
190
260
|
table.appendChild(dragElem)
|
|
191
261
|
|
|
192
|
-
const tPos =
|
|
262
|
+
const tPos = targetRow.getBoundingClientRect()
|
|
193
263
|
const dPos = dragElem.getBoundingClientRect()
|
|
194
264
|
dragElem.style.bottom = dPos.y - tPos.y - tPos.height + 'px'
|
|
195
265
|
dragElem.style.left = '-1px'
|