react-arborist 2.3.0 → 3.0.1
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/README.md +21 -16
- package/dist/components/list-inner-element.d.ts +1 -1
- package/dist/components/list-outer-element.d.ts +1 -1
- package/dist/components/tree.d.ts +5 -1
- package/dist/index.js +107 -141
- package/dist/index.js.map +1 -1
- package/dist/interfaces/node-api.d.ts +1 -2
- package/dist/interfaces/tree-api.d.ts +3 -1
- package/dist/module.js +107 -141
- package/dist/module.js.map +1 -1
- package/dist/state/dnd-slice.d.ts +10 -1
- package/dist/types/dnd.d.ts +0 -1
- package/dist/types/tree-props.d.ts +8 -3
- package/dist/types/utils.d.ts +0 -4
- package/package.json +5 -2
- package/src/components/default-container.tsx +4 -2
- package/src/components/tree.tsx +6 -2
- package/src/data/create-root.ts +0 -2
- package/src/dnd/compute-drop.ts +0 -19
- package/src/dnd/drag-hook.ts +15 -18
- package/src/dnd/drop-hook.ts +8 -38
- package/src/dnd/outer-drop-hook.ts +13 -45
- package/src/interfaces/node-api.ts +4 -3
- package/src/interfaces/tree-api.ts +39 -4
- package/src/state/dnd-slice.ts +17 -6
- package/src/state/initial.ts +7 -1
- package/src/types/dnd.ts +0 -1
- package/src/types/tree-props.ts +12 -4
- package/src/types/utils.ts +0 -8
- package/src/utils.ts +1 -1
- package/tsconfig.json +1 -25
|
@@ -7,7 +7,6 @@ declare type Params<T> = {
|
|
|
7
7
|
children: NodeApi<T>[] | null;
|
|
8
8
|
parent: NodeApi<T> | null;
|
|
9
9
|
isDraggable: boolean;
|
|
10
|
-
isDroppable: boolean;
|
|
11
10
|
rowIndex: number | null;
|
|
12
11
|
tree: TreeApi<T>;
|
|
13
12
|
};
|
|
@@ -19,7 +18,6 @@ export declare class NodeApi<T = any> {
|
|
|
19
18
|
children: NodeApi<T>[] | null;
|
|
20
19
|
parent: NodeApi<T> | null;
|
|
21
20
|
isDraggable: boolean;
|
|
22
|
-
isDroppable: boolean;
|
|
23
21
|
rowIndex: number | null;
|
|
24
22
|
constructor(params: Params<T>);
|
|
25
23
|
get isRoot(): boolean;
|
|
@@ -27,6 +25,7 @@ export declare class NodeApi<T = any> {
|
|
|
27
25
|
get isInternal(): boolean;
|
|
28
26
|
get isOpen(): boolean;
|
|
29
27
|
get isClosed(): boolean;
|
|
28
|
+
get isEditable(): boolean;
|
|
30
29
|
get isEditing(): boolean;
|
|
31
30
|
get isSelected(): boolean;
|
|
32
31
|
get isOnlySelection(): boolean;
|
|
@@ -88,6 +88,8 @@ export declare class TreeApi<T> {
|
|
|
88
88
|
selectAll(): void;
|
|
89
89
|
get cursorParentId(): string | null;
|
|
90
90
|
get cursorOverFolder(): boolean;
|
|
91
|
+
get dragNodes(): NodeApi<T>[];
|
|
92
|
+
canDrop(): boolean;
|
|
91
93
|
hideCursor(): void;
|
|
92
94
|
showCursor(cursor: Cursor): void;
|
|
93
95
|
open(identity: Identity): void;
|
|
@@ -106,8 +108,8 @@ export declare class TreeApi<T> {
|
|
|
106
108
|
get hasMultipleSelections(): boolean;
|
|
107
109
|
isSelected(id?: string): boolean;
|
|
108
110
|
isOpen(id?: string): boolean;
|
|
111
|
+
isEditable(data: T): boolean;
|
|
109
112
|
isDraggable(data: T): boolean;
|
|
110
|
-
isDroppable(data: T): boolean;
|
|
111
113
|
isDragging(node: string | IdObj | null): boolean;
|
|
112
114
|
isFocused(id: string): boolean;
|
|
113
115
|
isMatch(node: NodeApi<T>): boolean;
|
package/dist/module.js
CHANGED
|
@@ -180,7 +180,7 @@ function $0e6083160f4b36ed$export$58fe32731f07ed56(tree) {
|
|
|
180
180
|
const focus = tree.focusedNode;
|
|
181
181
|
if (!focus) return null;
|
|
182
182
|
if (focus.isOpen) return focus.id;
|
|
183
|
-
if (focus.parent) return focus.parent.id;
|
|
183
|
+
if (focus.parent && !focus.parent.isRoot) return focus.parent.id;
|
|
184
184
|
return null;
|
|
185
185
|
}
|
|
186
186
|
|
|
@@ -353,7 +353,6 @@ class $096e74084443e9a3$export$d4b903da0f522dc8 {
|
|
|
353
353
|
this.children = params.children;
|
|
354
354
|
this.parent = params.parent;
|
|
355
355
|
this.isDraggable = params.isDraggable;
|
|
356
|
-
this.isDroppable = params.isDroppable;
|
|
357
356
|
this.rowIndex = params.rowIndex;
|
|
358
357
|
}
|
|
359
358
|
get isRoot() {
|
|
@@ -371,6 +370,9 @@ class $096e74084443e9a3$export$d4b903da0f522dc8 {
|
|
|
371
370
|
get isClosed() {
|
|
372
371
|
return this.isLeaf ? false : !this.tree.isOpen(this.id);
|
|
373
372
|
}
|
|
373
|
+
get isEditable() {
|
|
374
|
+
return this.tree.isEditable(this.data);
|
|
375
|
+
}
|
|
374
376
|
get isEditing() {
|
|
375
377
|
return this.tree.editingId === this.id;
|
|
376
378
|
}
|
|
@@ -493,7 +495,6 @@ function $81080a351c006222$export$882461b6382ed46c(tree) {
|
|
|
493
495
|
id: id,
|
|
494
496
|
children: null,
|
|
495
497
|
isDraggable: tree.isDraggable(data),
|
|
496
|
-
isDroppable: tree.isDroppable(data),
|
|
497
498
|
rowIndex: null
|
|
498
499
|
});
|
|
499
500
|
const children = tree.accessChildren(data);
|
|
@@ -511,7 +512,6 @@ function $81080a351c006222$export$882461b6382ed46c(tree) {
|
|
|
511
512
|
parent: null,
|
|
512
513
|
children: null,
|
|
513
514
|
isDraggable: true,
|
|
514
|
-
isDroppable: true,
|
|
515
515
|
rowIndex: null
|
|
516
516
|
});
|
|
517
517
|
const data = tree.props.data ?? [];
|
|
@@ -614,7 +614,10 @@ const $6ad32e02250c922e$export$d4c72bab9d6cc13a = (props)=>({
|
|
|
614
614
|
cursor: {
|
|
615
615
|
type: "none"
|
|
616
616
|
},
|
|
617
|
-
dragId: null
|
|
617
|
+
dragId: null,
|
|
618
|
+
dragIds: [],
|
|
619
|
+
parentId: null,
|
|
620
|
+
index: -1
|
|
618
621
|
}
|
|
619
622
|
});
|
|
620
623
|
|
|
@@ -710,16 +713,24 @@ const $59f144a8dd651e5e$export$e324594224ef24da = {
|
|
|
710
713
|
cursor: cursor
|
|
711
714
|
};
|
|
712
715
|
},
|
|
713
|
-
dragStart (id) {
|
|
716
|
+
dragStart (id, dragIds) {
|
|
714
717
|
return {
|
|
715
718
|
type: "DND_DRAG_START",
|
|
716
|
-
id: id
|
|
719
|
+
id: id,
|
|
720
|
+
dragIds: dragIds
|
|
717
721
|
};
|
|
718
722
|
},
|
|
719
723
|
dragEnd () {
|
|
720
724
|
return {
|
|
721
725
|
type: "DND_DRAG_END"
|
|
722
726
|
};
|
|
727
|
+
},
|
|
728
|
+
hovering (parentId, index) {
|
|
729
|
+
return {
|
|
730
|
+
type: "DND_HOVERING",
|
|
731
|
+
parentId: parentId,
|
|
732
|
+
index: index
|
|
733
|
+
};
|
|
723
734
|
}
|
|
724
735
|
};
|
|
725
736
|
function $59f144a8dd651e5e$export$1650419e431d3ba3(state = (0, $6ad32e02250c922e$export$d4c72bab9d6cc13a)()["dnd"], action) {
|
|
@@ -732,12 +743,16 @@ function $59f144a8dd651e5e$export$1650419e431d3ba3(state = (0, $6ad32e02250c922e
|
|
|
732
743
|
case "DND_DRAG_START":
|
|
733
744
|
return {
|
|
734
745
|
...state,
|
|
735
|
-
dragId: action.id
|
|
746
|
+
dragId: action.id,
|
|
747
|
+
dragIds: action.dragIds
|
|
736
748
|
};
|
|
737
749
|
case "DND_DRAG_END":
|
|
750
|
+
return (0, $6ad32e02250c922e$export$d4c72bab9d6cc13a)()["dnd"];
|
|
751
|
+
case "DND_HOVERING":
|
|
738
752
|
return {
|
|
739
753
|
...state,
|
|
740
|
-
|
|
754
|
+
parentId: action.parentId,
|
|
755
|
+
index: action.index
|
|
741
756
|
};
|
|
742
757
|
default:
|
|
743
758
|
return state;
|
|
@@ -925,32 +940,32 @@ function $907e707a330ef23a$export$715c0d031ede7907(node) {
|
|
|
925
940
|
const [_, ref, preview] = (0, $g00cZ$useDrag)(()=>({
|
|
926
941
|
canDrag: ()=>node.isDraggable,
|
|
927
942
|
type: "NODE",
|
|
928
|
-
item: ()=>
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
943
|
+
item: ()=>{
|
|
944
|
+
// This is fired once at the begging of a drag operation
|
|
945
|
+
const dragIds = tree.isSelected(node.id) ? Array.from(ids) : [
|
|
946
|
+
node.id
|
|
947
|
+
];
|
|
948
|
+
tree.dispatch((0, $59f144a8dd651e5e$export$e324594224ef24da).dragStart(node.id, dragIds));
|
|
949
|
+
return {
|
|
950
|
+
id: node.id
|
|
951
|
+
};
|
|
936
952
|
},
|
|
937
|
-
end: (
|
|
938
|
-
tree.dispatch((0, $59f144a8dd651e5e$export$e324594224ef24da).dragEnd());
|
|
953
|
+
end: ()=>{
|
|
939
954
|
tree.hideCursor();
|
|
940
|
-
|
|
955
|
+
let { parentId: parentId , index: index , dragIds: dragIds } = tree.state.dnd;
|
|
941
956
|
// If they held down meta, we need to create a copy
|
|
942
957
|
// if (drop.dropEffect === "copy")
|
|
943
|
-
if (
|
|
944
|
-
const parentId = drop.parentId === (0, $81080a351c006222$export$ec71a3379b43ae5c) ? null : drop.parentId;
|
|
958
|
+
if (tree.canDrop()) {
|
|
945
959
|
(0, $0e6083160f4b36ed$export$c6d63370cef03886)(tree.props.onMove, {
|
|
946
|
-
dragIds:
|
|
947
|
-
parentId: parentId,
|
|
948
|
-
index:
|
|
949
|
-
dragNodes:
|
|
950
|
-
parentNode: tree.get(
|
|
960
|
+
dragIds: dragIds,
|
|
961
|
+
parentId: parentId === (0, $81080a351c006222$export$ec71a3379b43ae5c) ? null : parentId,
|
|
962
|
+
index: index,
|
|
963
|
+
dragNodes: tree.dragNodes,
|
|
964
|
+
parentNode: tree.get(parentId)
|
|
951
965
|
});
|
|
952
|
-
tree.open(
|
|
966
|
+
tree.open(parentId);
|
|
953
967
|
}
|
|
968
|
+
tree.dispatch((0, $59f144a8dd651e5e$export$e324594224ef24da).dragEnd());
|
|
954
969
|
}
|
|
955
970
|
}), [
|
|
956
971
|
ids,
|
|
@@ -968,7 +983,6 @@ function $907e707a330ef23a$export$715c0d031ede7907(node) {
|
|
|
968
983
|
|
|
969
984
|
|
|
970
985
|
|
|
971
|
-
|
|
972
986
|
function $2db980bfed6822da$var$measureHover(el, offset) {
|
|
973
987
|
const rect = el.getBoundingClientRect();
|
|
974
988
|
const x = offset.x - Math.round(rect.x);
|
|
@@ -1035,16 +1049,6 @@ function $2db980bfed6822da$var$getDropLevel(hovering, aboveCursor, belowCursor,
|
|
|
1035
1049
|
}
|
|
1036
1050
|
return (0, $0e6083160f4b36ed$export$adf7c0fe6059d774)(hoverLevel, min, max);
|
|
1037
1051
|
}
|
|
1038
|
-
function $2db980bfed6822da$var$canDrop(above, below) {
|
|
1039
|
-
if (!above) return true;
|
|
1040
|
-
let n = above;
|
|
1041
|
-
if ((0, $0e6083160f4b36ed$export$4210f5ea57fbae57)(above) && above !== below) n = above.parent;
|
|
1042
|
-
while(n){
|
|
1043
|
-
if (!n.isDroppable) return false;
|
|
1044
|
-
n = n.parent;
|
|
1045
|
-
}
|
|
1046
|
-
return true;
|
|
1047
|
-
}
|
|
1048
1052
|
function $2db980bfed6822da$var$dropAt(parentId, index) {
|
|
1049
1053
|
return {
|
|
1050
1054
|
parentId: parentId || null,
|
|
@@ -1083,10 +1087,6 @@ function $2db980bfed6822da$export$f502ca02ebb85a1c(args) {
|
|
|
1083
1087
|
const hover = $2db980bfed6822da$var$measureHover(args.element, args.offset);
|
|
1084
1088
|
const { node: node , nextNode: nextNode , prevNode: prevNode } = args;
|
|
1085
1089
|
const [above, below] = $2db980bfed6822da$var$getNodesAroundCursor(node, prevNode, nextNode, hover);
|
|
1086
|
-
if (!$2db980bfed6822da$var$canDrop(above, below)) return {
|
|
1087
|
-
drop: null,
|
|
1088
|
-
cursor: $2db980bfed6822da$var$noCursor()
|
|
1089
|
-
};
|
|
1090
1090
|
/* Hovering over the middle of a folder */ if (node && node.isInternal && hover.inMiddle) return {
|
|
1091
1091
|
drop: $2db980bfed6822da$var$dropAt(node.id, 0),
|
|
1092
1092
|
cursor: $2db980bfed6822da$var$highlightCursor(node.id)
|
|
@@ -1109,15 +1109,16 @@ function $2db980bfed6822da$export$f502ca02ebb85a1c(args) {
|
|
|
1109
1109
|
}
|
|
1110
1110
|
|
|
1111
1111
|
|
|
1112
|
+
|
|
1112
1113
|
function $d38aa53467160173$export$57afafec4637d997(el, node) {
|
|
1113
1114
|
const tree = (0, $89e93131aae74bd9$export$367b0f2231a90ba0)();
|
|
1114
1115
|
const [_, dropRef] = (0, $g00cZ$useDrop)(()=>({
|
|
1115
1116
|
accept: "NODE",
|
|
1116
|
-
canDrop: (
|
|
1117
|
-
|
|
1117
|
+
canDrop: ()=>tree.canDrop(),
|
|
1118
|
+
hover: (_item, m)=>{
|
|
1118
1119
|
const offset = m.getClientOffset();
|
|
1119
|
-
if (!el.current || !offset) return
|
|
1120
|
-
const { drop: drop } = (0, $2db980bfed6822da$export$f502ca02ebb85a1c)({
|
|
1120
|
+
if (!el.current || !offset) return;
|
|
1121
|
+
const { cursor: cursor , drop: drop } = (0, $2db980bfed6822da$export$f502ca02ebb85a1c)({
|
|
1121
1122
|
element: el.current,
|
|
1122
1123
|
offset: offset,
|
|
1123
1124
|
indent: tree.indent,
|
|
@@ -1125,43 +1126,13 @@ function $d38aa53467160173$export$57afafec4637d997(el, node) {
|
|
|
1125
1126
|
prevNode: node.prev,
|
|
1126
1127
|
nextNode: node.next
|
|
1127
1128
|
});
|
|
1128
|
-
if (
|
|
1129
|
-
const dropParent = tree.get(drop.parentId) ?? tree.root;
|
|
1130
|
-
for (let id of item.dragIds){
|
|
1131
|
-
const drag = tree.get(id);
|
|
1132
|
-
if (!drag) return false;
|
|
1133
|
-
if (!dropParent) return false;
|
|
1134
|
-
if (drag.isInternal && (0, $0e6083160f4b36ed$export$1e38f72c6c546f70)(dropParent, drag)) return false;
|
|
1135
|
-
}
|
|
1136
|
-
return true;
|
|
1137
|
-
},
|
|
1138
|
-
hover: (item, m)=>{
|
|
1129
|
+
if (drop) tree.dispatch((0, $59f144a8dd651e5e$export$e324594224ef24da).hovering(drop.parentId, drop.index));
|
|
1139
1130
|
if (m.canDrop()) {
|
|
1140
|
-
const offset = m.getClientOffset();
|
|
1141
|
-
if (!el.current || !offset) return;
|
|
1142
|
-
const { cursor: cursor } = (0, $2db980bfed6822da$export$f502ca02ebb85a1c)({
|
|
1143
|
-
element: el.current,
|
|
1144
|
-
offset: offset,
|
|
1145
|
-
indent: tree.indent,
|
|
1146
|
-
node: node,
|
|
1147
|
-
prevNode: node.prev,
|
|
1148
|
-
nextNode: node.next
|
|
1149
|
-
});
|
|
1150
1131
|
if (cursor) tree.showCursor(cursor);
|
|
1151
1132
|
} else tree.hideCursor();
|
|
1152
1133
|
},
|
|
1153
|
-
drop: (
|
|
1154
|
-
|
|
1155
|
-
if (!el.current || !offset) return;
|
|
1156
|
-
const { drop: drop } = (0, $2db980bfed6822da$export$f502ca02ebb85a1c)({
|
|
1157
|
-
element: el.current,
|
|
1158
|
-
offset: offset,
|
|
1159
|
-
indent: tree.indent,
|
|
1160
|
-
node: node,
|
|
1161
|
-
prevNode: node.prev,
|
|
1162
|
-
nextNode: node.next
|
|
1163
|
-
});
|
|
1164
|
-
return drop;
|
|
1134
|
+
drop: (_, m)=>{
|
|
1135
|
+
if (!m.canDrop()) return null;
|
|
1165
1136
|
}
|
|
1166
1137
|
}), [
|
|
1167
1138
|
node,
|
|
@@ -1397,26 +1368,28 @@ function $065a164934293bf2$export$ff4858a4110d9246() {
|
|
|
1397
1368
|
return;
|
|
1398
1369
|
}
|
|
1399
1370
|
if (e.key === "Enter") {
|
|
1400
|
-
|
|
1371
|
+
const node3 = tree.focusedNode;
|
|
1372
|
+
if (!node3) return;
|
|
1373
|
+
if (!node3.isEditable || !tree.props.onRename) return;
|
|
1401
1374
|
setTimeout(()=>{
|
|
1402
|
-
if (
|
|
1375
|
+
if (node3) tree.edit(node3);
|
|
1403
1376
|
});
|
|
1404
1377
|
return;
|
|
1405
1378
|
}
|
|
1406
1379
|
if (e.key === " ") {
|
|
1407
1380
|
e.preventDefault();
|
|
1408
|
-
const
|
|
1409
|
-
if (!
|
|
1410
|
-
if (
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
} else
|
|
1381
|
+
const node4 = tree.focusedNode;
|
|
1382
|
+
if (!node4) return;
|
|
1383
|
+
if (node4.isLeaf) {
|
|
1384
|
+
node4.select();
|
|
1385
|
+
node4.activate();
|
|
1386
|
+
} else node4.toggle();
|
|
1414
1387
|
return;
|
|
1415
1388
|
}
|
|
1416
1389
|
if (e.key === "*") {
|
|
1417
|
-
const
|
|
1418
|
-
if (!
|
|
1419
|
-
tree.openSiblings(
|
|
1390
|
+
const node5 = tree.focusedNode;
|
|
1391
|
+
if (!node5) return;
|
|
1392
|
+
tree.openSiblings(node5);
|
|
1420
1393
|
return;
|
|
1421
1394
|
}
|
|
1422
1395
|
if (e.key === "PageUp") {
|
|
@@ -1437,13 +1410,13 @@ function $065a164934293bf2$export$ff4858a4110d9246() {
|
|
|
1437
1410
|
$065a164934293bf2$var$timeoutId = setTimeout(()=>{
|
|
1438
1411
|
$065a164934293bf2$var$focusSearchTerm = "";
|
|
1439
1412
|
}, 600);
|
|
1440
|
-
const
|
|
1413
|
+
const node6 = tree.visibleNodes.find((n)=>{
|
|
1441
1414
|
// @ts-ignore
|
|
1442
1415
|
const name = n.data.name;
|
|
1443
1416
|
if (typeof name === "string") return name.toLowerCase().startsWith($065a164934293bf2$var$focusSearchTerm);
|
|
1444
1417
|
else return false;
|
|
1445
1418
|
});
|
|
1446
|
-
if (
|
|
1419
|
+
if (node6) tree.focus(node6.id);
|
|
1447
1420
|
},
|
|
1448
1421
|
children: /*#__PURE__*/ (0, $g00cZ$jsx)((0, $g00cZ$FixedSizeList), {
|
|
1449
1422
|
className: tree.props.className,
|
|
@@ -1810,6 +1783,30 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1810
1783
|
get cursorOverFolder() {
|
|
1811
1784
|
return this.state.dnd.cursor.type === "highlight";
|
|
1812
1785
|
}
|
|
1786
|
+
get dragNodes() {
|
|
1787
|
+
return this.state.dnd.dragIds.map((id)=>this.get(id)).filter((n)=>!!n);
|
|
1788
|
+
}
|
|
1789
|
+
canDrop() {
|
|
1790
|
+
if (this.isFiltered) return false;
|
|
1791
|
+
const parentNode = this.get(this.state.dnd.parentId) ?? this.root;
|
|
1792
|
+
const dragNodes = this.dragNodes;
|
|
1793
|
+
const check = this.props.disableDrop;
|
|
1794
|
+
for (const drag of dragNodes){
|
|
1795
|
+
if (!drag) return false;
|
|
1796
|
+
if (!parentNode) return false;
|
|
1797
|
+
if (drag.isInternal && $0e6083160f4b36ed$exports.isDecendent(parentNode, drag)) return false;
|
|
1798
|
+
}
|
|
1799
|
+
// Allow the user to insert their own logic
|
|
1800
|
+
if (typeof check == "function") return check({
|
|
1801
|
+
parentNode: parentNode,
|
|
1802
|
+
dragNodes: this.dragNodes,
|
|
1803
|
+
index: this.state.dnd.index
|
|
1804
|
+
});
|
|
1805
|
+
else if (typeof check == "string") // @ts-ignore
|
|
1806
|
+
return !!parentNode.data[check];
|
|
1807
|
+
else if (typeof check === "boolean") return check;
|
|
1808
|
+
else return true;
|
|
1809
|
+
}
|
|
1813
1810
|
hideCursor() {
|
|
1814
1811
|
this.dispatch((0, $59f144a8dd651e5e$export$e324594224ef24da).cursor({
|
|
1815
1812
|
type: "none"
|
|
@@ -1907,12 +1904,12 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1907
1904
|
if (this.isFiltered) return this.state.nodes.open.filtered[id] ?? true; // Filtered folders are always opened by default
|
|
1908
1905
|
else return this.state.nodes.open.unfiltered[id] ?? def;
|
|
1909
1906
|
}
|
|
1910
|
-
|
|
1911
|
-
const check = this.props.
|
|
1907
|
+
isEditable(data) {
|
|
1908
|
+
const check = this.props.disableEdit || (()=>false);
|
|
1912
1909
|
return !$0e6083160f4b36ed$exports.access(data, check) ?? true;
|
|
1913
1910
|
}
|
|
1914
|
-
|
|
1915
|
-
const check = this.props.
|
|
1911
|
+
isDraggable(data) {
|
|
1912
|
+
const check = this.props.disableDrag || (()=>false);
|
|
1916
1913
|
return !$0e6083160f4b36ed$exports.access(data, check) ?? true;
|
|
1917
1914
|
}
|
|
1918
1915
|
isDragging(node) {
|
|
@@ -2075,54 +2072,19 @@ function $e739455e59c6aed3$export$5a6c424b1725f44f() {
|
|
|
2075
2072
|
// In case we drop an item at the bottom of the list
|
|
2076
2073
|
const [, drop] = (0, $g00cZ$useDrop)(()=>({
|
|
2077
2074
|
accept: "NODE",
|
|
2078
|
-
|
|
2075
|
+
canDrop: (_item, m)=>{
|
|
2079
2076
|
if (!m.isOver({
|
|
2080
2077
|
shallow: true
|
|
2081
|
-
})) return;
|
|
2082
|
-
|
|
2083
|
-
const offset = m.getClientOffset();
|
|
2084
|
-
if (!tree.listEl.current || !offset) return;
|
|
2085
|
-
const { cursor: cursor } = (0, $2db980bfed6822da$export$f502ca02ebb85a1c)({
|
|
2086
|
-
element: tree.listEl.current,
|
|
2087
|
-
offset: offset,
|
|
2088
|
-
indent: tree.indent,
|
|
2089
|
-
node: null,
|
|
2090
|
-
prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],
|
|
2091
|
-
nextNode: null
|
|
2092
|
-
});
|
|
2093
|
-
if (cursor) tree.showCursor(cursor);
|
|
2094
|
-
} else tree.hideCursor();
|
|
2078
|
+
})) return false;
|
|
2079
|
+
return tree.canDrop();
|
|
2095
2080
|
},
|
|
2096
|
-
|
|
2081
|
+
hover: (_item, m)=>{
|
|
2097
2082
|
if (!m.isOver({
|
|
2098
2083
|
shallow: true
|
|
2099
|
-
})) return
|
|
2100
|
-
if (tree.isFiltered) return false;
|
|
2101
|
-
const offset = m.getClientOffset();
|
|
2102
|
-
if (!tree.listEl.current || !offset) return false;
|
|
2103
|
-
const { drop: drop } = (0, $2db980bfed6822da$export$f502ca02ebb85a1c)({
|
|
2104
|
-
element: tree.listEl.current,
|
|
2105
|
-
offset: offset,
|
|
2106
|
-
indent: tree.indent,
|
|
2107
|
-
node: null,
|
|
2108
|
-
prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],
|
|
2109
|
-
nextNode: null
|
|
2110
|
-
});
|
|
2111
|
-
if (!drop) return false;
|
|
2112
|
-
const dropParent = tree.get(drop.parentId) ?? tree.root;
|
|
2113
|
-
for (let id of item.dragIds){
|
|
2114
|
-
const drag = tree.get(id);
|
|
2115
|
-
if (!drag) return false;
|
|
2116
|
-
if (!dropParent) return false;
|
|
2117
|
-
if (drag.isInternal && (0, $0e6083160f4b36ed$export$1e38f72c6c546f70)(dropParent, drag)) return false;
|
|
2118
|
-
}
|
|
2119
|
-
return true;
|
|
2120
|
-
},
|
|
2121
|
-
drop: (item, m)=>{
|
|
2122
|
-
if (m.didDrop()) return;
|
|
2084
|
+
})) return;
|
|
2123
2085
|
const offset = m.getClientOffset();
|
|
2124
2086
|
if (!tree.listEl.current || !offset) return;
|
|
2125
|
-
const { drop: drop } = (0, $2db980bfed6822da$export$f502ca02ebb85a1c)({
|
|
2087
|
+
const { cursor: cursor , drop: drop } = (0, $2db980bfed6822da$export$f502ca02ebb85a1c)({
|
|
2126
2088
|
element: tree.listEl.current,
|
|
2127
2089
|
offset: offset,
|
|
2128
2090
|
indent: tree.indent,
|
|
@@ -2130,7 +2092,10 @@ function $e739455e59c6aed3$export$5a6c424b1725f44f() {
|
|
|
2130
2092
|
prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],
|
|
2131
2093
|
nextNode: null
|
|
2132
2094
|
});
|
|
2133
|
-
|
|
2095
|
+
if (drop) tree.dispatch((0, $59f144a8dd651e5e$export$e324594224ef24da).hovering(drop.parentId, drop.index));
|
|
2096
|
+
if (m.canDrop()) {
|
|
2097
|
+
if (cursor) tree.showCursor(cursor);
|
|
2098
|
+
} else tree.hideCursor();
|
|
2134
2099
|
}
|
|
2135
2100
|
}), [
|
|
2136
2101
|
tree
|
|
@@ -2358,7 +2323,7 @@ Use the data prop if you want to provide your own handlers.`);
|
|
|
2358
2323
|
}
|
|
2359
2324
|
|
|
2360
2325
|
|
|
2361
|
-
|
|
2326
|
+
function $2ba43033bb8eb39d$var$TreeComponent(props, ref) {
|
|
2362
2327
|
const treeProps = (0, $c881d1adb735dfd0$export$d227906824a13416)(props);
|
|
2363
2328
|
return /*#__PURE__*/ (0, $g00cZ$jsxs)((0, $dac24389e46ba09d$export$c49dab5eb1b4ce0c), {
|
|
2364
2329
|
treeProps: treeProps,
|
|
@@ -2370,7 +2335,8 @@ const $2ba43033bb8eb39d$export$7fbedc92909ed28e = /*#__PURE__*/ (0, $g00cZ$forwa
|
|
|
2370
2335
|
/*#__PURE__*/ (0, $g00cZ$jsx)((0, $8f8be4c9bb5ab52a$export$3e21b60650ec7e55), {})
|
|
2371
2336
|
]
|
|
2372
2337
|
});
|
|
2373
|
-
}
|
|
2338
|
+
}
|
|
2339
|
+
const $2ba43033bb8eb39d$export$7fbedc92909ed28e = /*#__PURE__*/ (0, $g00cZ$forwardRef)($2ba43033bb8eb39d$var$TreeComponent);
|
|
2374
2340
|
|
|
2375
2341
|
|
|
2376
2342
|
var $8c5b0bb55f55c0d2$exports = {};
|