@v-c/tree 1.2.0 → 1.2.2
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/dist/MotionTreeNode.js +40 -6
- package/dist/NodeList.js +9 -1
- package/dist/Tree.js +62 -27
- package/dist/TreeNode.js +43 -10
- package/dist/util.d.ts +3 -3
- package/dist/util.js +3 -2
- package/dist/utils/treeUtil.d.ts +2 -2
- package/package.json +2 -2
package/dist/MotionTreeNode.js
CHANGED
|
@@ -112,6 +112,7 @@ var MotionTreeNode = /* @__PURE__ */ defineComponent((props) => {
|
|
|
112
112
|
default: void 0
|
|
113
113
|
},
|
|
114
114
|
motion: {
|
|
115
|
+
type: Object,
|
|
115
116
|
required: false,
|
|
116
117
|
default: void 0
|
|
117
118
|
},
|
|
@@ -145,6 +146,7 @@ var MotionTreeNode = /* @__PURE__ */ defineComponent((props) => {
|
|
|
145
146
|
default: void 0
|
|
146
147
|
},
|
|
147
148
|
eventKey: {
|
|
149
|
+
type: [String, Number],
|
|
148
150
|
required: false,
|
|
149
151
|
default: void 0
|
|
150
152
|
},
|
|
@@ -164,6 +166,7 @@ var MotionTreeNode = /* @__PURE__ */ defineComponent((props) => {
|
|
|
164
166
|
default: void 0
|
|
165
167
|
},
|
|
166
168
|
id: {
|
|
169
|
+
type: [String, Number],
|
|
167
170
|
required: false,
|
|
168
171
|
default: void 0
|
|
169
172
|
},
|
|
@@ -198,9 +201,16 @@ var MotionTreeNode = /* @__PURE__ */ defineComponent((props) => {
|
|
|
198
201
|
default: void 0
|
|
199
202
|
},
|
|
200
203
|
title: {
|
|
201
|
-
type:
|
|
204
|
+
type: [
|
|
205
|
+
Object,
|
|
206
|
+
Function,
|
|
207
|
+
String,
|
|
208
|
+
Number,
|
|
209
|
+
null,
|
|
210
|
+
Boolean,
|
|
211
|
+
Array
|
|
212
|
+
],
|
|
202
213
|
required: false,
|
|
203
|
-
skipCheck: true,
|
|
204
214
|
default: void 0
|
|
205
215
|
},
|
|
206
216
|
dragOver: {
|
|
@@ -238,6 +248,7 @@ var MotionTreeNode = /* @__PURE__ */ defineComponent((props) => {
|
|
|
238
248
|
default: void 0
|
|
239
249
|
},
|
|
240
250
|
onMouseMove: {
|
|
251
|
+
type: Function,
|
|
241
252
|
required: false,
|
|
242
253
|
default: void 0
|
|
243
254
|
},
|
|
@@ -267,18 +278,41 @@ var MotionTreeNode = /* @__PURE__ */ defineComponent((props) => {
|
|
|
267
278
|
default: void 0
|
|
268
279
|
},
|
|
269
280
|
icon: {
|
|
270
|
-
type:
|
|
281
|
+
type: [
|
|
282
|
+
Object,
|
|
283
|
+
Function,
|
|
284
|
+
String,
|
|
285
|
+
Number,
|
|
286
|
+
null,
|
|
287
|
+
Boolean,
|
|
288
|
+
Array
|
|
289
|
+
],
|
|
271
290
|
required: false,
|
|
272
|
-
skipCheck: true,
|
|
273
291
|
default: void 0
|
|
274
292
|
},
|
|
275
293
|
switcherIcon: {
|
|
276
|
-
type:
|
|
294
|
+
type: [
|
|
295
|
+
Object,
|
|
296
|
+
Function,
|
|
297
|
+
String,
|
|
298
|
+
Number,
|
|
299
|
+
null,
|
|
300
|
+
Boolean,
|
|
301
|
+
Array
|
|
302
|
+
],
|
|
277
303
|
required: false,
|
|
278
|
-
skipCheck: true,
|
|
279
304
|
default: void 0
|
|
280
305
|
},
|
|
281
306
|
children: {
|
|
307
|
+
type: [
|
|
308
|
+
Object,
|
|
309
|
+
Function,
|
|
310
|
+
String,
|
|
311
|
+
Number,
|
|
312
|
+
null,
|
|
313
|
+
Boolean,
|
|
314
|
+
Array
|
|
315
|
+
],
|
|
282
316
|
required: false,
|
|
283
317
|
default: void 0
|
|
284
318
|
}
|
package/dist/NodeList.js
CHANGED
|
@@ -245,12 +245,20 @@ var NodeList = /* @__PURE__ */ defineComponent((props, { attrs, expose }) => {
|
|
|
245
245
|
required: false,
|
|
246
246
|
default: void 0
|
|
247
247
|
},
|
|
248
|
-
dragOverNodeKey: {
|
|
248
|
+
dragOverNodeKey: {
|
|
249
|
+
type: [
|
|
250
|
+
String,
|
|
251
|
+
Number,
|
|
252
|
+
null
|
|
253
|
+
],
|
|
254
|
+
required: true
|
|
255
|
+
},
|
|
249
256
|
dropPosition: {
|
|
250
257
|
type: [Number, null],
|
|
251
258
|
required: true
|
|
252
259
|
},
|
|
253
260
|
motion: {
|
|
261
|
+
type: Object,
|
|
254
262
|
required: false,
|
|
255
263
|
default: void 0
|
|
256
264
|
},
|
package/dist/Tree.js
CHANGED
|
@@ -85,20 +85,22 @@ var Tree = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) =>
|
|
|
85
85
|
const setExpandedKeys = (keys) => {
|
|
86
86
|
expandedKeys.value = keys;
|
|
87
87
|
};
|
|
88
|
-
watch(() => props.expandedKeys, () => {
|
|
89
|
-
if (
|
|
90
|
-
|
|
88
|
+
watch(() => [props.expandedKeys, props.autoExpandParent], ([keys], [prevKeys]) => {
|
|
89
|
+
if (keys === void 0) {
|
|
90
|
+
if (prevKeys !== void 0) expandedKeys.value = [];
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const nextKeys = keys ?? [];
|
|
91
94
|
if (props.autoExpandParent) {
|
|
92
|
-
expandedKeys.value = conductExpandParent(
|
|
95
|
+
expandedKeys.value = conductExpandParent(nextKeys, keyEntities.value);
|
|
93
96
|
return;
|
|
94
97
|
}
|
|
95
|
-
expandedKeys.value =
|
|
98
|
+
expandedKeys.value = nextKeys;
|
|
96
99
|
});
|
|
97
100
|
const flattenNodes = computed(() => flattenTreeData(mergedTreeData.value, expandedKeys.value, mergedFieldNames.value));
|
|
98
101
|
const selectedKeys = shallowRef(calcSelectedKeys(props?.selectedKeys || props.defaultSelectedKeys || [], { multiple: mergedMultiple.value }) || []);
|
|
99
102
|
watch(() => props.selectedKeys, () => {
|
|
100
|
-
|
|
101
|
-
selectedKeys.value = calcSelectedKeys(props.selectedKeys, { multiple: mergedMultiple.value }) || [];
|
|
103
|
+
selectedKeys.value = calcSelectedKeys(props.selectedKeys ?? [], { multiple: mergedMultiple.value }) || [];
|
|
102
104
|
});
|
|
103
105
|
const setSelectedKeys = (keys) => {
|
|
104
106
|
selectedKeys.value = keys;
|
|
@@ -120,8 +122,7 @@ var Tree = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) =>
|
|
|
120
122
|
rawCheckedKeys.value = keys;
|
|
121
123
|
};
|
|
122
124
|
watch(() => props.checkedKeys, () => {
|
|
123
|
-
|
|
124
|
-
const parsed = parseCheckedKeys(props.checkedKeys);
|
|
125
|
+
const parsed = props.checkedKeys === void 0 ? null : parseCheckedKeys(props.checkedKeys);
|
|
125
126
|
rawCheckedKeys.value = parsed?.checkedKeys || [];
|
|
126
127
|
});
|
|
127
128
|
const rawHalfCheckedKeys = shallowRef(defaultCheckedKeyEntity.halfCheckedKeys);
|
|
@@ -129,8 +130,7 @@ var Tree = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) =>
|
|
|
129
130
|
rawHalfCheckedKeys.value = keys;
|
|
130
131
|
};
|
|
131
132
|
watch(() => props.checkedKeys, () => {
|
|
132
|
-
|
|
133
|
-
const parsed = parseCheckedKeys(props.checkedKeys);
|
|
133
|
+
const parsed = props.checkedKeys === void 0 ? null : parseCheckedKeys(props.checkedKeys);
|
|
134
134
|
rawHalfCheckedKeys.value = parsed?.halfCheckedKeys || [];
|
|
135
135
|
});
|
|
136
136
|
const mergedChecked = computed(() => {
|
|
@@ -152,10 +152,16 @@ var Tree = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) =>
|
|
|
152
152
|
halfCheckedKeys: halfCheckedKeysValue
|
|
153
153
|
};
|
|
154
154
|
});
|
|
155
|
-
const [loadedKeys, setLoadedKeys] = useMergedState(() => [], {
|
|
155
|
+
const [loadedKeys, setLoadedKeys] = useMergedState(() => [], {
|
|
156
|
+
value: computed(() => props.loadedKeys === void 0 ? void 0 : props.loadedKeys),
|
|
157
|
+
postState: (keys) => keys ?? []
|
|
158
|
+
});
|
|
156
159
|
const loadingKeys = ref([]);
|
|
157
160
|
const listChanging = ref(false);
|
|
158
|
-
const [activeKey, setActiveKey] = useMergedState(null, {
|
|
161
|
+
const [activeKey, setActiveKey] = useMergedState(null, {
|
|
162
|
+
value: computed(() => props.activeKey === void 0 ? void 0 : props.activeKey),
|
|
163
|
+
postState: (key) => key ?? null
|
|
164
|
+
});
|
|
159
165
|
function onListChangeStart() {
|
|
160
166
|
listChanging.value = true;
|
|
161
167
|
}
|
|
@@ -177,8 +183,14 @@ var Tree = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) =>
|
|
|
177
183
|
let dragNodeProps = null;
|
|
178
184
|
let dragStartMousePosition = null;
|
|
179
185
|
let currentMouseOverDroppableNodeKey = null;
|
|
180
|
-
|
|
186
|
+
let delayedDragEnterLogic = {};
|
|
181
187
|
const loadingRetryTimes = {};
|
|
188
|
+
const clearDelayedDragEnterLogic = () => {
|
|
189
|
+
Object.values(delayedDragEnterLogic).forEach((timeoutId) => {
|
|
190
|
+
clearTimeout(timeoutId);
|
|
191
|
+
});
|
|
192
|
+
delayedDragEnterLogic = {};
|
|
193
|
+
};
|
|
182
194
|
const listRef = ref();
|
|
183
195
|
let focusedByMouse = false;
|
|
184
196
|
const getTreeNodeRequiredProps = computed(() => ({
|
|
@@ -223,7 +235,7 @@ var Tree = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) =>
|
|
|
223
235
|
onActiveChange(item ? item.key : null);
|
|
224
236
|
}
|
|
225
237
|
function onFocus(e) {
|
|
226
|
-
if (!focusedByMouse && !mergedDisabled.value && activeKey.value === null) {
|
|
238
|
+
if (e.target === e.currentTarget && !focusedByMouse && !mergedDisabled.value && activeKey.value === null) {
|
|
227
239
|
const visibleSelectedKey = selectedKeys.value.find((key) => {
|
|
228
240
|
return flattenNodes.value.some((nodeItem) => nodeItem.key === key);
|
|
229
241
|
});
|
|
@@ -433,11 +445,9 @@ var Tree = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) =>
|
|
|
433
445
|
window.addEventListener("mouseup", onGlobalMouseUp);
|
|
434
446
|
});
|
|
435
447
|
onBeforeUnmount(() => {
|
|
448
|
+
clearDelayedDragEnterLogic();
|
|
436
449
|
window.removeEventListener("dragend", onWindowDragEnd);
|
|
437
450
|
window.removeEventListener("mouseup", onGlobalMouseUp);
|
|
438
|
-
Object.keys(delayedDragEnterLogic).forEach((key) => {
|
|
439
|
-
clearTimeout(delayedDragEnterLogic[key]);
|
|
440
|
-
});
|
|
441
451
|
});
|
|
442
452
|
const onNodeDragStart = (event, nodeProps) => {
|
|
443
453
|
dragNodeProps = nodeProps;
|
|
@@ -468,9 +478,7 @@ var Tree = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) =>
|
|
|
468
478
|
resetDragState();
|
|
469
479
|
return;
|
|
470
480
|
}
|
|
471
|
-
|
|
472
|
-
clearTimeout(delayedDragEnterLogic[key]);
|
|
473
|
-
});
|
|
481
|
+
clearDelayedDragEnterLogic();
|
|
474
482
|
if (dragNodeProps.eventKey !== nodeProps.eventKey) delayedDragEnterLogic[pos] = window.setTimeout(() => {
|
|
475
483
|
if (draggingNodeKey.value === null) return;
|
|
476
484
|
let newExpandedKeys = [...expandedKeys.value];
|
|
@@ -788,6 +796,11 @@ var Tree = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) =>
|
|
|
788
796
|
default: void 0
|
|
789
797
|
},
|
|
790
798
|
activeKey: {
|
|
799
|
+
type: [
|
|
800
|
+
String,
|
|
801
|
+
Number,
|
|
802
|
+
null
|
|
803
|
+
],
|
|
791
804
|
required: false,
|
|
792
805
|
default: void 0
|
|
793
806
|
},
|
|
@@ -817,9 +830,16 @@ var Tree = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) =>
|
|
|
817
830
|
default: void 0
|
|
818
831
|
},
|
|
819
832
|
icon: {
|
|
820
|
-
type:
|
|
833
|
+
type: [
|
|
834
|
+
Object,
|
|
835
|
+
Function,
|
|
836
|
+
String,
|
|
837
|
+
Number,
|
|
838
|
+
null,
|
|
839
|
+
Boolean,
|
|
840
|
+
Array
|
|
841
|
+
],
|
|
821
842
|
required: false,
|
|
822
|
-
skipCheck: true,
|
|
823
843
|
default: void 0
|
|
824
844
|
},
|
|
825
845
|
selectable: {
|
|
@@ -843,9 +863,16 @@ var Tree = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) =>
|
|
|
843
863
|
default: void 0
|
|
844
864
|
},
|
|
845
865
|
checkable: {
|
|
846
|
-
type:
|
|
866
|
+
type: [
|
|
867
|
+
Boolean,
|
|
868
|
+
Object,
|
|
869
|
+
Function,
|
|
870
|
+
String,
|
|
871
|
+
Number,
|
|
872
|
+
null,
|
|
873
|
+
Array
|
|
874
|
+
],
|
|
847
875
|
required: false,
|
|
848
|
-
skipCheck: true,
|
|
849
876
|
default: void 0
|
|
850
877
|
},
|
|
851
878
|
checkStrictly: {
|
|
@@ -1048,13 +1075,21 @@ var Tree = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) =>
|
|
|
1048
1075
|
default: void 0
|
|
1049
1076
|
},
|
|
1050
1077
|
motion: {
|
|
1078
|
+
type: Object,
|
|
1051
1079
|
required: false,
|
|
1052
1080
|
default: void 0
|
|
1053
1081
|
},
|
|
1054
1082
|
switcherIcon: {
|
|
1055
|
-
type:
|
|
1083
|
+
type: [
|
|
1084
|
+
Object,
|
|
1085
|
+
Function,
|
|
1086
|
+
String,
|
|
1087
|
+
Number,
|
|
1088
|
+
null,
|
|
1089
|
+
Boolean,
|
|
1090
|
+
Array
|
|
1091
|
+
],
|
|
1056
1092
|
required: false,
|
|
1057
|
-
skipCheck: true,
|
|
1058
1093
|
default: void 0
|
|
1059
1094
|
},
|
|
1060
1095
|
height: {
|
package/dist/TreeNode.js
CHANGED
|
@@ -3,7 +3,7 @@ import { TreeContextKey, UnstableContextKey } from "./contextTypes.js";
|
|
|
3
3
|
import getEntity from "./utils/keyUtil.js";
|
|
4
4
|
import { convertNodePropsToEventData, isLeafNode } from "./utils/treeUtil.js";
|
|
5
5
|
import { computed, createVNode, defineComponent, inject, mergeProps, ref, watchEffect } from "vue";
|
|
6
|
-
import { clsx } from "@v-c/util";
|
|
6
|
+
import { clsx, isVueRenderable } from "@v-c/util";
|
|
7
7
|
import { getId } from "@v-c/util/dist/hooks/useId";
|
|
8
8
|
import pickAttrs from "@v-c/util/dist/pickAttrs";
|
|
9
9
|
import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
@@ -75,10 +75,10 @@ var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
75
75
|
const onDragStart = (e) => {
|
|
76
76
|
e.stopPropagation();
|
|
77
77
|
dragNodeHighlight.value = true;
|
|
78
|
-
context.onNodeDragStart(e, props);
|
|
79
78
|
try {
|
|
80
79
|
e.dataTransfer?.setData("text/plain", "");
|
|
81
80
|
} catch {}
|
|
81
|
+
context.onNodeDragStart(e, props);
|
|
82
82
|
};
|
|
83
83
|
const onDragEnter = (e) => {
|
|
84
84
|
e.preventDefault();
|
|
@@ -173,8 +173,8 @@ var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
173
173
|
const wrapClass = `${context.prefixCls}-node-content-wrapper`;
|
|
174
174
|
let icon;
|
|
175
175
|
if (context.showIcon) {
|
|
176
|
-
const currentIcon = props.icon
|
|
177
|
-
icon = currentIcon ? createVNode("span", {
|
|
176
|
+
const currentIcon = isVueRenderable(props.icon) ? props.icon : context.icon;
|
|
177
|
+
icon = isVueRenderable(currentIcon) ? createVNode("span", {
|
|
178
178
|
"class": clsx(context.classNames?.itemIcon, `${context.prefixCls}-iconEle`, `${context.prefixCls}-icon__customize`),
|
|
179
179
|
"style": context.styles?.itemIcon
|
|
180
180
|
}, [typeof currentIcon === "function" ? currentIcon(props) : currentIcon]) : iconNode.value;
|
|
@@ -272,6 +272,7 @@ var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
272
272
|
}, {
|
|
273
273
|
props: {
|
|
274
274
|
eventKey: {
|
|
275
|
+
type: [String, Number],
|
|
275
276
|
required: false,
|
|
276
277
|
default: void 0
|
|
277
278
|
},
|
|
@@ -291,6 +292,7 @@ var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
291
292
|
default: void 0
|
|
292
293
|
},
|
|
293
294
|
id: {
|
|
295
|
+
type: [String, Number],
|
|
294
296
|
required: false,
|
|
295
297
|
default: void 0
|
|
296
298
|
},
|
|
@@ -330,9 +332,16 @@ var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
330
332
|
default: void 0
|
|
331
333
|
},
|
|
332
334
|
title: {
|
|
333
|
-
type:
|
|
335
|
+
type: [
|
|
336
|
+
Object,
|
|
337
|
+
Function,
|
|
338
|
+
String,
|
|
339
|
+
Number,
|
|
340
|
+
null,
|
|
341
|
+
Boolean,
|
|
342
|
+
Array
|
|
343
|
+
],
|
|
334
344
|
required: false,
|
|
335
|
-
skipCheck: true,
|
|
336
345
|
default: void 0
|
|
337
346
|
},
|
|
338
347
|
dragOver: {
|
|
@@ -379,6 +388,7 @@ var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
379
388
|
default: void 0
|
|
380
389
|
},
|
|
381
390
|
onMouseMove: {
|
|
391
|
+
type: Function,
|
|
382
392
|
required: false,
|
|
383
393
|
default: void 0
|
|
384
394
|
},
|
|
@@ -408,18 +418,41 @@ var TreeNode = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
408
418
|
default: void 0
|
|
409
419
|
},
|
|
410
420
|
icon: {
|
|
411
|
-
type:
|
|
421
|
+
type: [
|
|
422
|
+
Object,
|
|
423
|
+
Function,
|
|
424
|
+
String,
|
|
425
|
+
Number,
|
|
426
|
+
null,
|
|
427
|
+
Boolean,
|
|
428
|
+
Array
|
|
429
|
+
],
|
|
412
430
|
required: false,
|
|
413
|
-
skipCheck: true,
|
|
414
431
|
default: void 0
|
|
415
432
|
},
|
|
416
433
|
switcherIcon: {
|
|
417
|
-
type:
|
|
434
|
+
type: [
|
|
435
|
+
Object,
|
|
436
|
+
Function,
|
|
437
|
+
String,
|
|
438
|
+
Number,
|
|
439
|
+
null,
|
|
440
|
+
Boolean,
|
|
441
|
+
Array
|
|
442
|
+
],
|
|
418
443
|
required: false,
|
|
419
|
-
skipCheck: true,
|
|
420
444
|
default: void 0
|
|
421
445
|
},
|
|
422
446
|
children: {
|
|
447
|
+
type: [
|
|
448
|
+
Object,
|
|
449
|
+
Function,
|
|
450
|
+
String,
|
|
451
|
+
Number,
|
|
452
|
+
null,
|
|
453
|
+
Boolean,
|
|
454
|
+
Array
|
|
455
|
+
],
|
|
423
456
|
required: false,
|
|
424
457
|
default: void 0
|
|
425
458
|
}
|
package/dist/util.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export interface AllowDropOptions<TreeDataType extends BasicDataNode = DataNode>
|
|
|
5
5
|
dropPosition: -1 | 0 | 1;
|
|
6
6
|
}
|
|
7
7
|
export type AllowDrop<TreeDataType extends BasicDataNode = DataNode> = (options: AllowDropOptions<TreeDataType>) => boolean;
|
|
8
|
-
export declare function arrDel(list: Key[], value: Key):
|
|
9
|
-
export declare function arrAdd(list: Key[], value: Key):
|
|
8
|
+
export declare function arrDel(list: Key[], value: Key): import('packages/util/dist/type').Key[];
|
|
9
|
+
export declare function arrAdd(list: Key[], value: Key): import('packages/util/dist/type').Key[];
|
|
10
10
|
export declare function posToArr(pos: string): string[];
|
|
11
11
|
export declare function getDragChildrenKeys<TreeDataType extends BasicDataNode = DataNode>(dragNodeKey: Key, keyEntities: KeyEntities<TreeDataType>): Key[];
|
|
12
12
|
export declare function isLastChild<TreeDataType extends BasicDataNode = DataNode>(treeNodeEntity: DataEntity<TreeDataType>): boolean;
|
|
@@ -25,7 +25,7 @@ export declare function calcDropPosition<TreeDataType extends BasicDataNode = Da
|
|
|
25
25
|
};
|
|
26
26
|
export declare function calcSelectedKeys(selectedKeys: Key[], { multiple }: {
|
|
27
27
|
multiple?: boolean;
|
|
28
|
-
}):
|
|
28
|
+
}): import('packages/util/dist/type').Key[] | undefined;
|
|
29
29
|
export declare function parseCheckedKeys(keys: Key[] | {
|
|
30
30
|
checked: Key[];
|
|
31
31
|
halfChecked: Key[];
|
package/dist/util.js
CHANGED
|
@@ -45,7 +45,8 @@ function calcDropPosition(event, dragNodeProps, targetNodeProps, indent, startMo
|
|
|
45
45
|
const rawDropLevelOffset = ((direction === "rtl" ? -1 : 1) * ((startMousePosition?.x || 0) - clientX) - 12) / indent;
|
|
46
46
|
const filteredExpandKeys = expandKeys.filter((key) => (getEntity(keyEntities, key)?.children || []).length);
|
|
47
47
|
let abstractDropNodeEntity = getEntity(keyEntities, targetNodeProps.eventKey);
|
|
48
|
-
|
|
48
|
+
const dropBeforeTarget = clientY < top + height / 2 && isFirstChild(abstractDropNodeEntity);
|
|
49
|
+
if (clientY < top + height / 2 && !dropBeforeTarget) {
|
|
49
50
|
const nodeIndex = flattenedNodes.findIndex(({ key }) => key === abstractDropNodeEntity.key);
|
|
50
51
|
const prevNodeKey = flattenedNodes[nodeIndex <= 0 ? 0 : nodeIndex - 1].key;
|
|
51
52
|
abstractDropNodeEntity = getEntity(keyEntities, prevNodeKey);
|
|
@@ -62,7 +63,7 @@ function calcDropPosition(event, dragNodeProps, targetNodeProps, indent, startMo
|
|
|
62
63
|
const abstractDragDataNode = dragNodeProps.data;
|
|
63
64
|
const abstractDropDataNode = abstractDropNodeEntity.node;
|
|
64
65
|
let dropAllowed = true;
|
|
65
|
-
if (
|
|
66
|
+
if (dropBeforeTarget && allowDrop({
|
|
66
67
|
dragNode: abstractDragDataNode,
|
|
67
68
|
dropNode: abstractDropDataNode,
|
|
68
69
|
dropPosition: -1
|
package/dist/utils/treeUtil.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BasicDataNode, DataEntity, DataNode, EventDataNode, FieldNames, FlattenNode, GetKey, Key, KeyEntities, NodeElement, TreeNodeProps } from '../interface';
|
|
2
2
|
export declare function getPosition(level: string | number, index: number): string;
|
|
3
3
|
export declare function isTreeNode(node: NodeElement): boolean;
|
|
4
|
-
export declare function getKey(key: Key, pos: string):
|
|
4
|
+
export declare function getKey(key: Key, pos: string): import('packages/util/dist/type').Key;
|
|
5
5
|
export declare function fillFieldNames(fieldNames?: FieldNames): Required<FieldNames>;
|
|
6
6
|
export declare function warningWithoutKey(treeData: DataNode[], fieldNames: FieldNames): void;
|
|
7
7
|
export declare function convertTreeToData(rootNodes: any): DataNode[];
|
|
@@ -47,7 +47,7 @@ export interface TreeNodeRequiredProps<TreeDataType extends BasicDataNode = Data
|
|
|
47
47
|
keyEntities: KeyEntities<TreeDataType>;
|
|
48
48
|
}
|
|
49
49
|
export declare function getTreeNodeProps<TreeDataType extends BasicDataNode = DataNode>(key: Key, { expandedKeys, selectedKeys, loadedKeys, loadingKeys, checkedKeys, halfCheckedKeys, dragOverNodeKey, dropPosition, keyEntities, }: TreeNodeRequiredProps<TreeDataType>): {
|
|
50
|
-
eventKey:
|
|
50
|
+
eventKey: import('packages/util/dist/type').Key;
|
|
51
51
|
expanded: boolean;
|
|
52
52
|
selected: boolean;
|
|
53
53
|
loaded: boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/tree",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.2",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"vue": "^3.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@v-c/util": "^1.
|
|
37
|
+
"@v-c/util": "^1.2.0",
|
|
38
38
|
"@v-c/virtual-list": "^1.1.1"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|