react-arborist 3.2.0 → 3.3.1-0
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/main/components/cursor.d.ts +1 -0
- package/dist/main/components/cursor.js +20 -0
- package/dist/{components → main/components}/default-container.d.ts +1 -2
- package/dist/main/components/default-container.js +238 -0
- package/dist/main/components/default-cursor.js +35 -0
- package/dist/{components → main/components}/default-drag-preview.d.ts +1 -2
- package/dist/main/components/default-drag-preview.js +57 -0
- package/dist/{components → main/components}/default-node.d.ts +1 -2
- package/dist/main/components/default-node.js +32 -0
- package/dist/{components → main/components}/default-row.d.ts +1 -2
- package/dist/main/components/default-row.js +8 -0
- package/dist/main/components/drag-preview-container.d.ts +1 -0
- package/dist/main/components/drag-preview-container.js +21 -0
- package/dist/{components → main/components}/list-inner-element.d.ts +1 -1
- package/dist/main/components/list-inner-element.js +25 -0
- package/dist/main/components/list-outer-element.d.ts +2 -0
- package/dist/main/components/list-outer-element.js +38 -0
- package/dist/main/components/outer-drop.js +9 -0
- package/dist/{components → main/components}/provider.d.ts +2 -2
- package/dist/main/components/provider.js +52 -0
- package/dist/{components → main/components}/row-container.d.ts +2 -2
- package/dist/main/components/row-container.js +84 -0
- package/dist/main/components/tree-container.d.ts +1 -0
- package/dist/main/components/tree-container.js +12 -0
- package/dist/{components → main/components}/tree.d.ts +1 -1
- package/dist/main/components/tree.js +15 -0
- package/dist/{context.d.ts → main/context.d.ts} +4 -4
- package/dist/main/context.js +33 -0
- package/dist/main/data/create-index.js +10 -0
- package/dist/main/data/create-list.js +62 -0
- package/dist/main/data/create-root.js +43 -0
- package/dist/main/data/make-tree.d.ts +5 -0
- package/dist/main/data/make-tree.js +40 -0
- package/dist/{data → main/data}/simple-tree.d.ts +1 -1
- package/dist/main/data/simple-tree.js +100 -0
- package/dist/{dnd → main/dnd}/compute-drop.d.ts +6 -6
- package/dist/main/dnd/compute-drop.js +129 -0
- package/dist/main/dnd/drag-hook.js +46 -0
- package/dist/{dnd → main/dnd}/drop-hook.d.ts +2 -2
- package/dist/main/dnd/drop-hook.js +42 -0
- package/dist/main/dnd/measure-hover.d.ts +8 -0
- package/dist/main/dnd/measure-hover.js +21 -0
- package/dist/main/dnd/outer-drop-hook.js +45 -0
- package/dist/main/hooks/use-fresh-node.js +18 -0
- package/dist/{hooks → main/hooks}/use-simple-tree.d.ts +1 -1
- package/dist/main/hooks/use-simple-tree.js +35 -0
- package/dist/main/hooks/use-validated-props.js +29 -0
- package/dist/main/index.js +27 -0
- package/dist/{interfaces → main/interfaces}/node-api.d.ts +2 -1
- package/dist/main/interfaces/node-api.js +164 -0
- package/dist/{interfaces → main/interfaces}/tree-api.d.ts +90 -7
- package/dist/main/interfaces/tree-api.js +649 -0
- package/dist/main/interfaces/tree-api.test.d.ts +1 -0
- package/dist/main/interfaces/tree-api.test.js +14 -0
- package/dist/{state → main/state}/dnd-slice.d.ts +4 -4
- package/dist/main/state/dnd-slice.js +35 -0
- package/dist/{state → main/state}/drag-slice.d.ts +4 -2
- package/dist/main/state/drag-slice.js +24 -0
- package/dist/{state → main/state}/edit-slice.d.ts +1 -1
- package/dist/main/state/edit-slice.js +18 -0
- package/dist/{state → main/state}/focus-slice.d.ts +1 -1
- package/dist/main/state/focus-slice.js +26 -0
- package/dist/main/state/initial.js +29 -0
- package/dist/{state → main/state}/open-slice.d.ts +2 -2
- package/dist/main/state/open-slice.js +48 -0
- package/dist/main/state/root-reducer.d.ts +96 -0
- package/dist/main/state/root-reducer.js +20 -0
- package/dist/{state → main/state}/selection-slice.d.ts +1 -1
- package/dist/main/state/selection-slice.js +59 -0
- package/dist/{types → main/types}/dnd.d.ts +2 -2
- package/dist/main/types/dnd.js +2 -0
- package/dist/{types → main/types}/handlers.d.ts +5 -5
- package/dist/main/types/handlers.js +2 -0
- package/dist/{types → main/types}/renderers.d.ts +4 -4
- package/dist/main/types/renderers.js +2 -0
- package/dist/main/types/state.d.ts +2 -0
- package/dist/main/types/state.js +2 -0
- package/dist/main/types/tree-props.js +2 -0
- package/dist/{types → main/types}/utils.d.ts +5 -5
- package/dist/main/types/utils.js +2 -0
- package/dist/{utils.d.ts → main/utils.d.ts} +2 -2
- package/dist/main/utils.js +183 -0
- package/dist/module/components/cursor.d.ts +1 -0
- package/dist/module/components/cursor.js +16 -0
- package/dist/module/components/default-container.d.ts +6 -0
- package/dist/module/components/default-container.js +234 -0
- package/dist/module/components/default-cursor.d.ts +3 -0
- package/dist/module/components/default-cursor.js +29 -0
- package/dist/module/components/default-drag-preview.d.ts +2 -0
- package/dist/module/components/default-drag-preview.js +53 -0
- package/dist/module/components/default-node.d.ts +2 -0
- package/dist/module/components/default-node.js +28 -0
- package/dist/module/components/default-row.d.ts +2 -0
- package/dist/module/components/default-row.js +4 -0
- package/dist/module/components/drag-preview-container.d.ts +1 -0
- package/dist/module/components/drag-preview-container.js +17 -0
- package/dist/module/components/list-inner-element.d.ts +2 -0
- package/dist/module/components/list-inner-element.js +22 -0
- package/dist/module/components/list-outer-element.d.ts +2 -0
- package/dist/module/components/list-outer-element.js +35 -0
- package/dist/module/components/outer-drop.d.ts +4 -0
- package/dist/module/components/outer-drop.js +5 -0
- package/dist/module/components/provider.d.ts +10 -0
- package/dist/module/components/provider.js +48 -0
- package/dist/module/components/row-container.d.ts +7 -0
- package/dist/module/components/row-container.js +58 -0
- package/dist/module/components/tree-container.d.ts +1 -0
- package/dist/module/components/tree-container.js +8 -0
- package/dist/module/components/tree.d.ts +8 -0
- package/dist/module/components/tree.js +12 -0
- package/dist/module/context.d.ts +22 -0
- package/dist/module/context.js +26 -0
- package/dist/module/data/create-index.d.ts +4 -0
- package/dist/module/data/create-index.js +6 -0
- package/dist/module/data/create-list.d.ts +3 -0
- package/dist/module/data/create-list.js +58 -0
- package/dist/module/data/create-root.d.ts +4 -0
- package/dist/module/data/create-root.js +39 -0
- package/dist/module/data/make-tree.d.ts +5 -0
- package/dist/module/data/make-tree.js +36 -0
- package/dist/module/data/simple-tree.d.ts +44 -0
- package/dist/module/data/simple-tree.js +96 -0
- package/dist/module/dnd/compute-drop.d.ts +37 -0
- package/dist/module/dnd/compute-drop.js +125 -0
- package/dist/module/dnd/drag-hook.d.ts +3 -0
- package/dist/module/dnd/drag-hook.js +42 -0
- package/dist/module/dnd/drop-hook.d.ts +8 -0
- package/dist/module/dnd/drop-hook.js +38 -0
- package/dist/module/dnd/measure-hover.d.ts +8 -0
- package/dist/module/dnd/measure-hover.js +17 -0
- package/dist/module/dnd/outer-drop-hook.d.ts +1 -0
- package/dist/module/dnd/outer-drop-hook.js +41 -0
- package/dist/module/hooks/use-fresh-node.d.ts +1 -0
- package/dist/module/hooks/use-fresh-node.js +14 -0
- package/dist/module/hooks/use-simple-tree.d.ts +12 -0
- package/dist/module/hooks/use-simple-tree.js +31 -0
- package/dist/module/hooks/use-validated-props.d.ts +2 -0
- package/dist/module/hooks/use-validated-props.js +25 -0
- package/dist/module/index.d.ts +8 -0
- package/dist/module/index.js +9 -0
- package/dist/module/interfaces/node-api.d.ts +71 -0
- package/dist/module/interfaces/node-api.js +160 -0
- package/dist/module/interfaces/tree-api.d.ts +214 -0
- package/dist/module/interfaces/tree-api.js +622 -0
- package/dist/module/interfaces/tree-api.test.d.ts +1 -0
- package/dist/module/interfaces/tree-api.test.js +12 -0
- package/dist/module/state/dnd-slice.d.ts +29 -0
- package/dist/module/state/dnd-slice.js +31 -0
- package/dist/module/state/drag-slice.d.ts +9 -0
- package/dist/module/state/drag-slice.js +20 -0
- package/dist/module/state/edit-slice.d.ts +8 -0
- package/dist/module/state/edit-slice.js +13 -0
- package/dist/module/state/focus-slice.d.ts +12 -0
- package/dist/module/state/focus-slice.js +20 -0
- package/dist/module/state/initial.d.ts +3 -0
- package/dist/module/state/initial.js +25 -0
- package/dist/module/state/open-slice.d.ts +30 -0
- package/dist/module/state/open-slice.js +44 -0
- package/dist/module/state/root-reducer.d.ts +96 -0
- package/dist/module/state/root-reducer.js +17 -0
- package/dist/module/state/selection-slice.d.ts +42 -0
- package/dist/module/state/selection-slice.js +55 -0
- package/dist/module/types/dnd.d.ts +8 -0
- package/dist/module/types/dnd.js +1 -0
- package/dist/module/types/handlers.d.ts +30 -0
- package/dist/module/types/handlers.js +1 -0
- package/dist/module/types/renderers.d.ts +29 -0
- package/dist/module/types/renderers.js +1 -0
- package/dist/module/types/state.d.ts +2 -0
- package/dist/module/types/state.js +1 -0
- package/dist/module/types/tree-props.d.ts +56 -0
- package/dist/module/types/tree-props.js +1 -0
- package/dist/module/types/utils.d.ts +17 -0
- package/dist/module/types/utils.js +1 -0
- package/dist/module/utils.d.ts +24 -0
- package/dist/module/utils.js +162 -0
- package/package.json +26 -25
- package/src/components/default-container.tsx +2 -0
- package/src/components/provider.tsx +3 -2
- package/src/components/row-container.tsx +1 -1
- package/src/dnd/compute-drop.ts +6 -3
- package/src/dnd/drag-hook.ts +1 -1
- package/src/dnd/drop-hook.ts +1 -1
- package/src/interfaces/node-api.ts +10 -0
- package/src/interfaces/tree-api.ts +16 -3
- package/src/state/dnd-slice.ts +2 -2
- package/src/state/drag-slice.ts +27 -11
- package/src/state/initial.ts +6 -1
- package/src/utils.ts +2 -2
- package/dist/components/cursor.d.ts +0 -2
- package/dist/components/drag-preview-container.d.ts +0 -2
- package/dist/components/list-outer-element.d.ts +0 -2
- package/dist/components/tree-container.d.ts +0 -2
- package/dist/index.js +0 -2414
- package/dist/index.js.map +0 -1
- package/dist/module.js +0 -2387
- package/dist/module.js.map +0 -1
- package/dist/state/root-reducer.d.ts +0 -13
- package/dist/types/state.d.ts +0 -2
- package/jest.config.js +0 -5
- package/tsconfig.json +0 -4
- /package/dist/{components → main/components}/default-cursor.d.ts +0 -0
- /package/dist/{components → main/components}/outer-drop.d.ts +0 -0
- /package/dist/{data → main/data}/create-index.d.ts +0 -0
- /package/dist/{data → main/data}/create-list.d.ts +0 -0
- /package/dist/{data → main/data}/create-root.d.ts +0 -0
- /package/dist/{dnd → main/dnd}/drag-hook.d.ts +0 -0
- /package/dist/{dnd → main/dnd}/outer-drop-hook.d.ts +0 -0
- /package/dist/{hooks → main/hooks}/use-fresh-node.d.ts +0 -0
- /package/dist/{hooks → main/hooks}/use-validated-props.d.ts +0 -0
- /package/dist/{index.d.ts → main/index.d.ts} +0 -0
- /package/dist/{state → main/state}/initial.d.ts +0 -0
- /package/dist/{types → main/types}/tree-props.d.ts +0 -0
package/dist/index.js
DELETED
|
@@ -1,2414 +0,0 @@
|
|
|
1
|
-
var $foSVk$reactjsxruntime = require("react/jsx-runtime");
|
|
2
|
-
var $foSVk$react = require("react");
|
|
3
|
-
var $foSVk$usesyncexternalstoreshim = require("use-sync-external-store/shim");
|
|
4
|
-
var $foSVk$reactdndhtml5backend = require("react-dnd-html5-backend");
|
|
5
|
-
var $foSVk$reactdnd = require("react-dnd");
|
|
6
|
-
var $foSVk$redux = require("redux");
|
|
7
|
-
var $foSVk$reactwindow = require("react-window");
|
|
8
|
-
|
|
9
|
-
function $parcel$export(e, n, v, s) {
|
|
10
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
11
|
-
}
|
|
12
|
-
function $parcel$exportWildcard(dest, source) {
|
|
13
|
-
Object.keys(source).forEach(function(key) {
|
|
14
|
-
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(dest, key, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return source[key];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
return dest;
|
|
27
|
-
}
|
|
28
|
-
function $parcel$interopDefault(a) {
|
|
29
|
-
return a && a.__esModule ? a.default : a;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
$parcel$export(module.exports, "Tree", () => $641461e16d1a2941$export$7fbedc92909ed28e);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const $d5cb84d44d1b8acc$export$feef243b04ff4151 = (0, $foSVk$react.createContext)(null);
|
|
40
|
-
function $d5cb84d44d1b8acc$export$367b0f2231a90ba0() {
|
|
41
|
-
const value = (0, $foSVk$react.useContext)($d5cb84d44d1b8acc$export$feef243b04ff4151);
|
|
42
|
-
if (value === null) throw new Error("No Tree Api Provided");
|
|
43
|
-
return value;
|
|
44
|
-
}
|
|
45
|
-
const $d5cb84d44d1b8acc$export$f6d467aa8b3786af = (0, $foSVk$react.createContext)(null);
|
|
46
|
-
function $d5cb84d44d1b8acc$export$fd23f19d5d8f3033() {
|
|
47
|
-
const value = (0, $foSVk$react.useContext)($d5cb84d44d1b8acc$export$f6d467aa8b3786af);
|
|
48
|
-
if (value === null) throw new Error("Provide a NodesContext");
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
|
-
const $d5cb84d44d1b8acc$export$2d5c5ceac203fc1e = (0, $foSVk$react.createContext)(null);
|
|
52
|
-
function $d5cb84d44d1b8acc$export$4930f6bf413be70e() {
|
|
53
|
-
const value = (0, $foSVk$react.useContext)($d5cb84d44d1b8acc$export$2d5c5ceac203fc1e);
|
|
54
|
-
if (value === null) throw new Error("Provide a DnDContext");
|
|
55
|
-
return value;
|
|
56
|
-
}
|
|
57
|
-
const $d5cb84d44d1b8acc$export$d0c71bc5e3e2d897 = (0, $foSVk$react.createContext)(0);
|
|
58
|
-
function $d5cb84d44d1b8acc$export$83a4f9dc3b36edb8() {
|
|
59
|
-
(0, $foSVk$react.useContext)($d5cb84d44d1b8acc$export$d0c71bc5e3e2d897);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var $5c74fef433be2b0a$exports = {};
|
|
64
|
-
|
|
65
|
-
$parcel$export($5c74fef433be2b0a$exports, "TreeApi", () => $5c74fef433be2b0a$export$e2da3477247342d1);
|
|
66
|
-
var $eb5355379510ac9b$exports = {};
|
|
67
|
-
|
|
68
|
-
$parcel$export($eb5355379510ac9b$exports, "bound", () => $eb5355379510ac9b$export$adf7c0fe6059d774);
|
|
69
|
-
$parcel$export($eb5355379510ac9b$exports, "isItem", () => $eb5355379510ac9b$export$5318634f2ee07019);
|
|
70
|
-
$parcel$export($eb5355379510ac9b$exports, "isClosed", () => $eb5355379510ac9b$export$4210f5ea57fbae57);
|
|
71
|
-
$parcel$export($eb5355379510ac9b$exports, "isDecendent", () => $eb5355379510ac9b$export$1e38f72c6c546f70);
|
|
72
|
-
$parcel$export($eb5355379510ac9b$exports, "indexOf", () => $eb5355379510ac9b$export$305f7d4e9d4624f2);
|
|
73
|
-
$parcel$export($eb5355379510ac9b$exports, "noop", () => $eb5355379510ac9b$export$8793edee2d425525);
|
|
74
|
-
$parcel$export($eb5355379510ac9b$exports, "dfs", () => $eb5355379510ac9b$export$51b654aff22fc5a6);
|
|
75
|
-
$parcel$export($eb5355379510ac9b$exports, "walk", () => $eb5355379510ac9b$export$588732934346abbf);
|
|
76
|
-
$parcel$export($eb5355379510ac9b$exports, "focusNextElement", () => $eb5355379510ac9b$export$3b0237e8566c8d65);
|
|
77
|
-
$parcel$export($eb5355379510ac9b$exports, "focusPrevElement", () => $eb5355379510ac9b$export$33b47db07a82b2fb);
|
|
78
|
-
$parcel$export($eb5355379510ac9b$exports, "access", () => $eb5355379510ac9b$export$9bb0e144ba4929ca);
|
|
79
|
-
$parcel$export($eb5355379510ac9b$exports, "identifyNull", () => $eb5355379510ac9b$export$611823266272db76);
|
|
80
|
-
$parcel$export($eb5355379510ac9b$exports, "identify", () => $eb5355379510ac9b$export$65e5b62a4c490288);
|
|
81
|
-
$parcel$export($eb5355379510ac9b$exports, "mergeRefs", () => $eb5355379510ac9b$export$c9058316764c140e);
|
|
82
|
-
$parcel$export($eb5355379510ac9b$exports, "safeRun", () => $eb5355379510ac9b$export$c6d63370cef03886);
|
|
83
|
-
$parcel$export($eb5355379510ac9b$exports, "waitFor", () => $eb5355379510ac9b$export$9bbfceb27f687c1b);
|
|
84
|
-
$parcel$export($eb5355379510ac9b$exports, "getInsertIndex", () => $eb5355379510ac9b$export$e12bf2314d0bc2a9);
|
|
85
|
-
$parcel$export($eb5355379510ac9b$exports, "getInsertParentId", () => $eb5355379510ac9b$export$58fe32731f07ed56);
|
|
86
|
-
function $eb5355379510ac9b$export$adf7c0fe6059d774(n, min, max) {
|
|
87
|
-
return Math.max(Math.min(n, max), min);
|
|
88
|
-
}
|
|
89
|
-
function $eb5355379510ac9b$export$5318634f2ee07019(node) {
|
|
90
|
-
return node && node.isLeaf;
|
|
91
|
-
}
|
|
92
|
-
function $eb5355379510ac9b$export$4210f5ea57fbae57(node) {
|
|
93
|
-
return node && node.isInternal && !node.isOpen;
|
|
94
|
-
}
|
|
95
|
-
const $eb5355379510ac9b$export$1e38f72c6c546f70 = (a, b)=>{
|
|
96
|
-
let n = a;
|
|
97
|
-
while(n){
|
|
98
|
-
if (n.id === b.id) return true;
|
|
99
|
-
n = n.parent;
|
|
100
|
-
}
|
|
101
|
-
return false;
|
|
102
|
-
};
|
|
103
|
-
const $eb5355379510ac9b$export$305f7d4e9d4624f2 = (node)=>{
|
|
104
|
-
if (!node.parent) throw Error("Node does not have a parent");
|
|
105
|
-
return node.parent.children.findIndex((c)=>c.id === node.id);
|
|
106
|
-
};
|
|
107
|
-
function $eb5355379510ac9b$export$8793edee2d425525() {}
|
|
108
|
-
function $eb5355379510ac9b$export$51b654aff22fc5a6(node, id) {
|
|
109
|
-
if (!node) return null;
|
|
110
|
-
if (node.id === id) return node;
|
|
111
|
-
if (node.children) for (let child of node.children){
|
|
112
|
-
const result = $eb5355379510ac9b$export$51b654aff22fc5a6(child, id);
|
|
113
|
-
if (result) return result;
|
|
114
|
-
}
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
function $eb5355379510ac9b$export$588732934346abbf(node, fn) {
|
|
118
|
-
fn(node);
|
|
119
|
-
if (node.children) for (let child of node.children)$eb5355379510ac9b$export$588732934346abbf(child, fn);
|
|
120
|
-
}
|
|
121
|
-
function $eb5355379510ac9b$export$3b0237e8566c8d65(target) {
|
|
122
|
-
const elements = $eb5355379510ac9b$var$getFocusable(target);
|
|
123
|
-
let next;
|
|
124
|
-
for(let i = 0; i < elements.length; ++i){
|
|
125
|
-
const item = elements[i];
|
|
126
|
-
if (item === target) {
|
|
127
|
-
next = $eb5355379510ac9b$var$nextItem(elements, i);
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
// @ts-ignore ??
|
|
132
|
-
next?.focus();
|
|
133
|
-
}
|
|
134
|
-
function $eb5355379510ac9b$export$33b47db07a82b2fb(target) {
|
|
135
|
-
const elements = $eb5355379510ac9b$var$getFocusable(target);
|
|
136
|
-
let next;
|
|
137
|
-
for(let i = 0; i < elements.length; ++i){
|
|
138
|
-
const item = elements[i];
|
|
139
|
-
if (item === target) {
|
|
140
|
-
next = $eb5355379510ac9b$var$prevItem(elements, i);
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
// @ts-ignore
|
|
145
|
-
next?.focus();
|
|
146
|
-
}
|
|
147
|
-
function $eb5355379510ac9b$var$nextItem(list, index) {
|
|
148
|
-
if (index + 1 < list.length) return list[index + 1];
|
|
149
|
-
else return list[0];
|
|
150
|
-
}
|
|
151
|
-
function $eb5355379510ac9b$var$prevItem(list, index) {
|
|
152
|
-
if (index - 1 >= 0) return list[index - 1];
|
|
153
|
-
else return list[list.length - 1];
|
|
154
|
-
}
|
|
155
|
-
function $eb5355379510ac9b$var$getFocusable(target) {
|
|
156
|
-
return Array.from(document.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)')).filter((e)=>e === target || !target.contains(e));
|
|
157
|
-
}
|
|
158
|
-
function $eb5355379510ac9b$export$9bb0e144ba4929ca(obj, accessor) {
|
|
159
|
-
if (typeof accessor === "boolean") return accessor;
|
|
160
|
-
if (typeof accessor === "string") return obj[accessor];
|
|
161
|
-
return accessor(obj);
|
|
162
|
-
}
|
|
163
|
-
function $eb5355379510ac9b$export$611823266272db76(obj) {
|
|
164
|
-
if (obj === null) return null;
|
|
165
|
-
else return $eb5355379510ac9b$export$65e5b62a4c490288(obj);
|
|
166
|
-
}
|
|
167
|
-
function $eb5355379510ac9b$export$65e5b62a4c490288(obj) {
|
|
168
|
-
return typeof obj === "string" ? obj : obj.id;
|
|
169
|
-
}
|
|
170
|
-
function $eb5355379510ac9b$export$c9058316764c140e(...refs) {
|
|
171
|
-
return (instance)=>{
|
|
172
|
-
refs.forEach((ref)=>{
|
|
173
|
-
if (typeof ref === "function") ref(instance);
|
|
174
|
-
else if (ref != null) ref.current = instance;
|
|
175
|
-
});
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
function $eb5355379510ac9b$export$c6d63370cef03886(fn, ...args) {
|
|
179
|
-
if (fn) return fn(...args);
|
|
180
|
-
}
|
|
181
|
-
function $eb5355379510ac9b$export$9bbfceb27f687c1b(fn) {
|
|
182
|
-
return new Promise((resolve, reject)=>{
|
|
183
|
-
let tries = 0;
|
|
184
|
-
function check() {
|
|
185
|
-
tries += 1;
|
|
186
|
-
if (tries === 100) reject();
|
|
187
|
-
if (fn()) resolve();
|
|
188
|
-
else setTimeout(check, 10);
|
|
189
|
-
}
|
|
190
|
-
check();
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
function $eb5355379510ac9b$export$e12bf2314d0bc2a9(tree) {
|
|
194
|
-
const focus = tree.focusedNode;
|
|
195
|
-
if (!focus) return tree.root.children?.length ?? 0;
|
|
196
|
-
if (focus.isOpen) return 0;
|
|
197
|
-
if (focus.parent) return focus.childIndex + 1;
|
|
198
|
-
return 0;
|
|
199
|
-
}
|
|
200
|
-
function $eb5355379510ac9b$export$58fe32731f07ed56(tree) {
|
|
201
|
-
const focus = tree.focusedNode;
|
|
202
|
-
if (!focus) return null;
|
|
203
|
-
if (focus.isOpen) return focus.id;
|
|
204
|
-
if (focus.parent && !focus.parent.isRoot) return focus.parent.id;
|
|
205
|
-
return null;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const $c79fefb0d0a1d13b$var$placeholderStyle = {
|
|
212
|
-
display: "flex",
|
|
213
|
-
alignItems: "center",
|
|
214
|
-
zIndex: 1
|
|
215
|
-
};
|
|
216
|
-
const $c79fefb0d0a1d13b$var$lineStyle = {
|
|
217
|
-
flex: 1,
|
|
218
|
-
height: "2px",
|
|
219
|
-
background: "#4B91E2",
|
|
220
|
-
borderRadius: "1px"
|
|
221
|
-
};
|
|
222
|
-
const $c79fefb0d0a1d13b$var$circleStyle = {
|
|
223
|
-
width: "4px",
|
|
224
|
-
height: "4px",
|
|
225
|
-
boxShadow: "0 0 0 3px #4B91E2",
|
|
226
|
-
borderRadius: "50%"
|
|
227
|
-
};
|
|
228
|
-
const $c79fefb0d0a1d13b$export$6cb3c16721363d11 = /*#__PURE__*/ (0, ($parcel$interopDefault($foSVk$react))).memo(function DefaultCursor({ top: top , left: left , indent: indent }) {
|
|
229
|
-
const style = {
|
|
230
|
-
position: "absolute",
|
|
231
|
-
pointerEvents: "none",
|
|
232
|
-
top: top - 2 + "px",
|
|
233
|
-
left: left + "px",
|
|
234
|
-
right: indent + "px"
|
|
235
|
-
};
|
|
236
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsxs)("div", {
|
|
237
|
-
style: {
|
|
238
|
-
...$c79fefb0d0a1d13b$var$placeholderStyle,
|
|
239
|
-
...style
|
|
240
|
-
},
|
|
241
|
-
children: [
|
|
242
|
-
/*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
|
|
243
|
-
style: {
|
|
244
|
-
...$c79fefb0d0a1d13b$var$circleStyle
|
|
245
|
-
}
|
|
246
|
-
}),
|
|
247
|
-
/*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
|
|
248
|
-
style: {
|
|
249
|
-
...$c79fefb0d0a1d13b$var$lineStyle
|
|
250
|
-
}
|
|
251
|
-
})
|
|
252
|
-
]
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
function $ff6862a32cc2ac81$export$f9c541e71856c524({ node: node , attrs: attrs , innerRef: innerRef , children: children }) {
|
|
260
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
|
|
261
|
-
...attrs,
|
|
262
|
-
ref: innerRef,
|
|
263
|
-
onFocus: (e)=>e.stopPropagation(),
|
|
264
|
-
onClick: node.handleClick,
|
|
265
|
-
children: children
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
function $3240a4b0b5620968$export$909e23cbfbbd3351(props) {
|
|
273
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsxs)("div", {
|
|
274
|
-
ref: props.dragHandle,
|
|
275
|
-
style: props.style,
|
|
276
|
-
children: [
|
|
277
|
-
/*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("span", {
|
|
278
|
-
onClick: (e)=>{
|
|
279
|
-
e.stopPropagation();
|
|
280
|
-
props.node.toggle();
|
|
281
|
-
},
|
|
282
|
-
children: props.node.isLeaf ? "\uD83C\uDF33" : props.node.isOpen ? "\uD83D\uDDC1" : "\uD83D\uDDC0"
|
|
283
|
-
}),
|
|
284
|
-
" ",
|
|
285
|
-
props.node.isEditing ? /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)($3240a4b0b5620968$var$Edit, {
|
|
286
|
-
...props
|
|
287
|
-
}) : /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)($3240a4b0b5620968$var$Show, {
|
|
288
|
-
...props
|
|
289
|
-
})
|
|
290
|
-
]
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
function $3240a4b0b5620968$var$Show(props) {
|
|
294
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $foSVk$reactjsxruntime.Fragment), {
|
|
295
|
-
children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("span", {
|
|
296
|
-
children: props.node.data.name
|
|
297
|
-
})
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
function $3240a4b0b5620968$var$Edit({ node: node }) {
|
|
301
|
-
const input = (0, $foSVk$react.useRef)();
|
|
302
|
-
(0, $foSVk$react.useEffect)(()=>{
|
|
303
|
-
input.current?.focus();
|
|
304
|
-
input.current?.select();
|
|
305
|
-
}, []);
|
|
306
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("input", {
|
|
307
|
-
ref: input,
|
|
308
|
-
// @ts-ignore
|
|
309
|
-
defaultValue: node.data.name,
|
|
310
|
-
onBlur: ()=>node.reset(),
|
|
311
|
-
onKeyDown: (e)=>{
|
|
312
|
-
if (e.key === "Escape") node.reset();
|
|
313
|
-
if (e.key === "Enter") node.submit(input.current?.value || "");
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
function $1297c48a54b69bac$export$e1a8e267487c59d1(id) {
|
|
320
|
-
return {
|
|
321
|
-
type: "EDIT",
|
|
322
|
-
id: id
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
function $1297c48a54b69bac$export$1650419e431d3ba3(state = {
|
|
326
|
-
id: null
|
|
327
|
-
}, action) {
|
|
328
|
-
if (action.type === "EDIT") return {
|
|
329
|
-
...state,
|
|
330
|
-
id: action.id
|
|
331
|
-
};
|
|
332
|
-
else return state;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
function $61ef7f2c3c9633e7$export$d7ddd398f22d79ef(id) {
|
|
337
|
-
return {
|
|
338
|
-
type: "FOCUS",
|
|
339
|
-
id: id
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
function $61ef7f2c3c9633e7$export$6b6c976e46a06288() {
|
|
343
|
-
return {
|
|
344
|
-
type: "TREE_BLUR"
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
function $61ef7f2c3c9633e7$export$1650419e431d3ba3(state = {
|
|
348
|
-
id: null,
|
|
349
|
-
treeFocused: false
|
|
350
|
-
}, action) {
|
|
351
|
-
if (action.type === "FOCUS") return {
|
|
352
|
-
...state,
|
|
353
|
-
id: action.id,
|
|
354
|
-
treeFocused: true
|
|
355
|
-
};
|
|
356
|
-
else if (action.type === "TREE_BLUR") return {
|
|
357
|
-
...state,
|
|
358
|
-
treeFocused: false
|
|
359
|
-
};
|
|
360
|
-
else return state;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
var $9b37fe5960a1a3c6$exports = {};
|
|
365
|
-
|
|
366
|
-
$parcel$export($9b37fe5960a1a3c6$exports, "NodeApi", () => $9b37fe5960a1a3c6$export$d4b903da0f522dc8);
|
|
367
|
-
|
|
368
|
-
class $9b37fe5960a1a3c6$export$d4b903da0f522dc8 {
|
|
369
|
-
constructor(params){
|
|
370
|
-
this.tree = params.tree;
|
|
371
|
-
this.id = params.id;
|
|
372
|
-
this.data = params.data;
|
|
373
|
-
this.level = params.level;
|
|
374
|
-
this.children = params.children;
|
|
375
|
-
this.parent = params.parent;
|
|
376
|
-
this.isDraggable = params.isDraggable;
|
|
377
|
-
this.rowIndex = params.rowIndex;
|
|
378
|
-
}
|
|
379
|
-
get isRoot() {
|
|
380
|
-
return this.id === (0, $0d7f39915c1a8ae9$export$ec71a3379b43ae5c);
|
|
381
|
-
}
|
|
382
|
-
get isLeaf() {
|
|
383
|
-
return !Array.isArray(this.children);
|
|
384
|
-
}
|
|
385
|
-
get isInternal() {
|
|
386
|
-
return !this.isLeaf;
|
|
387
|
-
}
|
|
388
|
-
get isOpen() {
|
|
389
|
-
return this.isLeaf ? false : this.tree.isOpen(this.id);
|
|
390
|
-
}
|
|
391
|
-
get isClosed() {
|
|
392
|
-
return this.isLeaf ? false : !this.tree.isOpen(this.id);
|
|
393
|
-
}
|
|
394
|
-
get isEditable() {
|
|
395
|
-
return this.tree.isEditable(this.data);
|
|
396
|
-
}
|
|
397
|
-
get isEditing() {
|
|
398
|
-
return this.tree.editingId === this.id;
|
|
399
|
-
}
|
|
400
|
-
get isSelected() {
|
|
401
|
-
return this.tree.isSelected(this.id);
|
|
402
|
-
}
|
|
403
|
-
get isOnlySelection() {
|
|
404
|
-
return this.isSelected && this.tree.hasOneSelection;
|
|
405
|
-
}
|
|
406
|
-
get isSelectedStart() {
|
|
407
|
-
return this.isSelected && !this.prev?.isSelected;
|
|
408
|
-
}
|
|
409
|
-
get isSelectedEnd() {
|
|
410
|
-
return this.isSelected && !this.next?.isSelected;
|
|
411
|
-
}
|
|
412
|
-
get isFocused() {
|
|
413
|
-
return this.tree.isFocused(this.id);
|
|
414
|
-
}
|
|
415
|
-
get isDragging() {
|
|
416
|
-
return this.tree.isDragging(this.id);
|
|
417
|
-
}
|
|
418
|
-
get willReceiveDrop() {
|
|
419
|
-
return this.tree.willReceiveDrop(this.id);
|
|
420
|
-
}
|
|
421
|
-
get state() {
|
|
422
|
-
return {
|
|
423
|
-
isClosed: this.isClosed,
|
|
424
|
-
isDragging: this.isDragging,
|
|
425
|
-
isEditing: this.isEditing,
|
|
426
|
-
isFocused: this.isFocused,
|
|
427
|
-
isInternal: this.isInternal,
|
|
428
|
-
isLeaf: this.isLeaf,
|
|
429
|
-
isOpen: this.isOpen,
|
|
430
|
-
isSelected: this.isSelected,
|
|
431
|
-
isSelectedEnd: this.isSelectedEnd,
|
|
432
|
-
isSelectedStart: this.isSelectedStart,
|
|
433
|
-
willReceiveDrop: this.willReceiveDrop
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
get childIndex() {
|
|
437
|
-
if (this.parent && this.parent.children) return this.parent.children.findIndex((child)=>child.id === this.id);
|
|
438
|
-
else return -1;
|
|
439
|
-
}
|
|
440
|
-
get next() {
|
|
441
|
-
if (this.rowIndex === null) return null;
|
|
442
|
-
return this.tree.at(this.rowIndex + 1);
|
|
443
|
-
}
|
|
444
|
-
get prev() {
|
|
445
|
-
if (this.rowIndex === null) return null;
|
|
446
|
-
return this.tree.at(this.rowIndex - 1);
|
|
447
|
-
}
|
|
448
|
-
get nextSibling() {
|
|
449
|
-
const i = this.childIndex;
|
|
450
|
-
return this.parent?.children[i + 1] ?? null;
|
|
451
|
-
}
|
|
452
|
-
select() {
|
|
453
|
-
this.tree.select(this);
|
|
454
|
-
}
|
|
455
|
-
deselect() {
|
|
456
|
-
this.tree.deselect(this);
|
|
457
|
-
}
|
|
458
|
-
selectMulti() {
|
|
459
|
-
this.tree.selectMulti(this);
|
|
460
|
-
}
|
|
461
|
-
selectContiguous() {
|
|
462
|
-
this.tree.selectContiguous(this);
|
|
463
|
-
}
|
|
464
|
-
activate() {
|
|
465
|
-
this.tree.activate(this);
|
|
466
|
-
}
|
|
467
|
-
focus() {
|
|
468
|
-
this.tree.focus(this);
|
|
469
|
-
}
|
|
470
|
-
toggle() {
|
|
471
|
-
this.tree.toggle(this);
|
|
472
|
-
}
|
|
473
|
-
open() {
|
|
474
|
-
this.tree.open(this);
|
|
475
|
-
}
|
|
476
|
-
openParents() {
|
|
477
|
-
this.tree.openParents(this);
|
|
478
|
-
}
|
|
479
|
-
close() {
|
|
480
|
-
this.tree.close(this);
|
|
481
|
-
}
|
|
482
|
-
submit(value) {
|
|
483
|
-
this.tree.submit(this, value);
|
|
484
|
-
}
|
|
485
|
-
reset() {
|
|
486
|
-
this.tree.reset();
|
|
487
|
-
}
|
|
488
|
-
clone() {
|
|
489
|
-
return new $9b37fe5960a1a3c6$export$d4b903da0f522dc8({
|
|
490
|
-
...this
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
edit() {
|
|
494
|
-
return this.tree.edit(this);
|
|
495
|
-
}
|
|
496
|
-
handleClick = (e)=>{
|
|
497
|
-
if (e.metaKey && !this.tree.props.disableMultiSelection) this.isSelected ? this.deselect() : this.selectMulti();
|
|
498
|
-
else if (e.shiftKey && !this.tree.props.disableMultiSelection) this.selectContiguous();
|
|
499
|
-
else {
|
|
500
|
-
this.select();
|
|
501
|
-
this.activate();
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
const $0d7f39915c1a8ae9$export$ec71a3379b43ae5c = "__REACT_ARBORIST_INTERNAL_ROOT__";
|
|
508
|
-
function $0d7f39915c1a8ae9$export$882461b6382ed46c(tree) {
|
|
509
|
-
function visitSelfAndChildren(data, level, parent) {
|
|
510
|
-
const id = tree.accessId(data);
|
|
511
|
-
const node = new (0, $9b37fe5960a1a3c6$export$d4b903da0f522dc8)({
|
|
512
|
-
tree: tree,
|
|
513
|
-
data: data,
|
|
514
|
-
level: level,
|
|
515
|
-
parent: parent,
|
|
516
|
-
id: id,
|
|
517
|
-
children: null,
|
|
518
|
-
isDraggable: tree.isDraggable(data),
|
|
519
|
-
rowIndex: null
|
|
520
|
-
});
|
|
521
|
-
const children = tree.accessChildren(data);
|
|
522
|
-
if (children) node.children = children.map((child)=>visitSelfAndChildren(child, level + 1, node));
|
|
523
|
-
return node;
|
|
524
|
-
}
|
|
525
|
-
const root = new (0, $9b37fe5960a1a3c6$export$d4b903da0f522dc8)({
|
|
526
|
-
tree: tree,
|
|
527
|
-
id: $0d7f39915c1a8ae9$export$ec71a3379b43ae5c,
|
|
528
|
-
// @ts-ignore
|
|
529
|
-
data: {
|
|
530
|
-
id: $0d7f39915c1a8ae9$export$ec71a3379b43ae5c
|
|
531
|
-
},
|
|
532
|
-
level: -1,
|
|
533
|
-
parent: null,
|
|
534
|
-
children: null,
|
|
535
|
-
isDraggable: true,
|
|
536
|
-
rowIndex: null
|
|
537
|
-
});
|
|
538
|
-
const data = tree.props.data ?? [];
|
|
539
|
-
root.children = data.map((child)=>{
|
|
540
|
-
return visitSelfAndChildren(child, 0, root);
|
|
541
|
-
});
|
|
542
|
-
return root;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
const $d519ceb3313d9d0e$export$e324594224ef24da = {
|
|
547
|
-
open (id, filtered) {
|
|
548
|
-
return {
|
|
549
|
-
type: "VISIBILITY_OPEN",
|
|
550
|
-
id: id,
|
|
551
|
-
filtered: filtered
|
|
552
|
-
};
|
|
553
|
-
},
|
|
554
|
-
close (id, filtered) {
|
|
555
|
-
return {
|
|
556
|
-
type: "VISIBILITY_CLOSE",
|
|
557
|
-
id: id,
|
|
558
|
-
filtered: filtered
|
|
559
|
-
};
|
|
560
|
-
},
|
|
561
|
-
toggle (id, filtered) {
|
|
562
|
-
return {
|
|
563
|
-
type: "VISIBILITY_TOGGLE",
|
|
564
|
-
id: id,
|
|
565
|
-
filtered: filtered
|
|
566
|
-
};
|
|
567
|
-
},
|
|
568
|
-
clear (filtered) {
|
|
569
|
-
return {
|
|
570
|
-
type: "VISIBILITY_CLEAR",
|
|
571
|
-
filtered: filtered
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
};
|
|
575
|
-
/* Reducer */ function $d519ceb3313d9d0e$var$openMapReducer(state = {}, action) {
|
|
576
|
-
if (action.type === "VISIBILITY_OPEN") return {
|
|
577
|
-
...state,
|
|
578
|
-
[action.id]: true
|
|
579
|
-
};
|
|
580
|
-
else if (action.type === "VISIBILITY_CLOSE") return {
|
|
581
|
-
...state,
|
|
582
|
-
[action.id]: false
|
|
583
|
-
};
|
|
584
|
-
else if (action.type === "VISIBILITY_TOGGLE") {
|
|
585
|
-
const prev = state[action.id];
|
|
586
|
-
return {
|
|
587
|
-
...state,
|
|
588
|
-
[action.id]: !prev
|
|
589
|
-
};
|
|
590
|
-
} else if (action.type === "VISIBILITY_CLEAR") return {};
|
|
591
|
-
else return state;
|
|
592
|
-
}
|
|
593
|
-
function $d519ceb3313d9d0e$export$1650419e431d3ba3(state = {
|
|
594
|
-
filtered: {},
|
|
595
|
-
unfiltered: {}
|
|
596
|
-
}, action) {
|
|
597
|
-
if (!action.type.startsWith("VISIBILITY")) return state;
|
|
598
|
-
if (action.filtered) return {
|
|
599
|
-
...state,
|
|
600
|
-
filtered: $d519ceb3313d9d0e$var$openMapReducer(state.filtered, action)
|
|
601
|
-
};
|
|
602
|
-
else return {
|
|
603
|
-
...state,
|
|
604
|
-
unfiltered: $d519ceb3313d9d0e$var$openMapReducer(state.unfiltered, action)
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
const $9d556ecd8e421ffe$export$d4c72bab9d6cc13a = (props)=>({
|
|
611
|
-
nodes: {
|
|
612
|
-
// Changes together
|
|
613
|
-
open: {
|
|
614
|
-
filtered: {},
|
|
615
|
-
unfiltered: props?.initialOpenState ?? {}
|
|
616
|
-
},
|
|
617
|
-
focus: {
|
|
618
|
-
id: null,
|
|
619
|
-
treeFocused: false
|
|
620
|
-
},
|
|
621
|
-
edit: {
|
|
622
|
-
id: null
|
|
623
|
-
},
|
|
624
|
-
drag: {
|
|
625
|
-
id: null,
|
|
626
|
-
idWillReceiveDrop: null
|
|
627
|
-
},
|
|
628
|
-
selection: {
|
|
629
|
-
ids: new Set(),
|
|
630
|
-
anchor: null,
|
|
631
|
-
mostRecent: null
|
|
632
|
-
}
|
|
633
|
-
},
|
|
634
|
-
dnd: {
|
|
635
|
-
cursor: {
|
|
636
|
-
type: "none"
|
|
637
|
-
},
|
|
638
|
-
dragId: null,
|
|
639
|
-
dragIds: [],
|
|
640
|
-
parentId: null,
|
|
641
|
-
index: -1
|
|
642
|
-
}
|
|
643
|
-
});
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
const $58f9381615aa3d17$export$e324594224ef24da = {
|
|
647
|
-
clear: ()=>({
|
|
648
|
-
type: "SELECTION_CLEAR"
|
|
649
|
-
}),
|
|
650
|
-
only: (id)=>({
|
|
651
|
-
type: "SELECTION_ONLY",
|
|
652
|
-
id: (0, $eb5355379510ac9b$export$65e5b62a4c490288)(id)
|
|
653
|
-
}),
|
|
654
|
-
add: (id)=>({
|
|
655
|
-
type: "SELECTION_ADD",
|
|
656
|
-
ids: (Array.isArray(id) ? id : [
|
|
657
|
-
id
|
|
658
|
-
]).map((0, $eb5355379510ac9b$export$65e5b62a4c490288))
|
|
659
|
-
}),
|
|
660
|
-
remove: (id)=>({
|
|
661
|
-
type: "SELECTION_REMOVE",
|
|
662
|
-
ids: (Array.isArray(id) ? id : [
|
|
663
|
-
id
|
|
664
|
-
]).map((0, $eb5355379510ac9b$export$65e5b62a4c490288))
|
|
665
|
-
}),
|
|
666
|
-
set: (args)=>({
|
|
667
|
-
type: "SELECTION_SET",
|
|
668
|
-
...args
|
|
669
|
-
}),
|
|
670
|
-
mostRecent: (id)=>({
|
|
671
|
-
type: "SELECTION_MOST_RECENT",
|
|
672
|
-
id: id === null ? null : (0, $eb5355379510ac9b$export$65e5b62a4c490288)(id)
|
|
673
|
-
}),
|
|
674
|
-
anchor: (id)=>({
|
|
675
|
-
type: "SELECTION_ANCHOR",
|
|
676
|
-
id: id === null ? null : (0, $eb5355379510ac9b$export$65e5b62a4c490288)(id)
|
|
677
|
-
})
|
|
678
|
-
};
|
|
679
|
-
function $58f9381615aa3d17$export$1650419e431d3ba3(state = (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)()["nodes"]["selection"], action) {
|
|
680
|
-
const ids = state.ids;
|
|
681
|
-
switch(action.type){
|
|
682
|
-
case "SELECTION_CLEAR":
|
|
683
|
-
return {
|
|
684
|
-
...state,
|
|
685
|
-
ids: new Set()
|
|
686
|
-
};
|
|
687
|
-
case "SELECTION_ONLY":
|
|
688
|
-
return {
|
|
689
|
-
...state,
|
|
690
|
-
ids: new Set([
|
|
691
|
-
action.id
|
|
692
|
-
])
|
|
693
|
-
};
|
|
694
|
-
case "SELECTION_ADD":
|
|
695
|
-
if (action.ids.length === 0) return state;
|
|
696
|
-
action.ids.forEach((id)=>ids.add(id));
|
|
697
|
-
return {
|
|
698
|
-
...state,
|
|
699
|
-
ids: new Set(ids)
|
|
700
|
-
};
|
|
701
|
-
case "SELECTION_REMOVE":
|
|
702
|
-
if (action.ids.length === 0) return state;
|
|
703
|
-
action.ids.forEach((id)=>ids.delete(id));
|
|
704
|
-
return {
|
|
705
|
-
...state,
|
|
706
|
-
ids: new Set(ids)
|
|
707
|
-
};
|
|
708
|
-
case "SELECTION_SET":
|
|
709
|
-
return {
|
|
710
|
-
...state,
|
|
711
|
-
ids: action.ids,
|
|
712
|
-
mostRecent: action.mostRecent,
|
|
713
|
-
anchor: action.anchor
|
|
714
|
-
};
|
|
715
|
-
case "SELECTION_MOST_RECENT":
|
|
716
|
-
return {
|
|
717
|
-
...state,
|
|
718
|
-
mostRecent: action.id
|
|
719
|
-
};
|
|
720
|
-
case "SELECTION_ANCHOR":
|
|
721
|
-
return {
|
|
722
|
-
...state,
|
|
723
|
-
anchor: action.id
|
|
724
|
-
};
|
|
725
|
-
default:
|
|
726
|
-
return state;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
const $7d98f5b84ecaa66b$export$e324594224ef24da = {
|
|
733
|
-
cursor (cursor) {
|
|
734
|
-
return {
|
|
735
|
-
type: "DND_CURSOR",
|
|
736
|
-
cursor: cursor
|
|
737
|
-
};
|
|
738
|
-
},
|
|
739
|
-
dragStart (id, dragIds) {
|
|
740
|
-
return {
|
|
741
|
-
type: "DND_DRAG_START",
|
|
742
|
-
id: id,
|
|
743
|
-
dragIds: dragIds
|
|
744
|
-
};
|
|
745
|
-
},
|
|
746
|
-
dragEnd () {
|
|
747
|
-
return {
|
|
748
|
-
type: "DND_DRAG_END"
|
|
749
|
-
};
|
|
750
|
-
},
|
|
751
|
-
hovering (parentId, index) {
|
|
752
|
-
return {
|
|
753
|
-
type: "DND_HOVERING",
|
|
754
|
-
parentId: parentId,
|
|
755
|
-
index: index
|
|
756
|
-
};
|
|
757
|
-
}
|
|
758
|
-
};
|
|
759
|
-
function $7d98f5b84ecaa66b$export$1650419e431d3ba3(state = (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)()["dnd"], action) {
|
|
760
|
-
switch(action.type){
|
|
761
|
-
case "DND_CURSOR":
|
|
762
|
-
return {
|
|
763
|
-
...state,
|
|
764
|
-
cursor: action.cursor
|
|
765
|
-
};
|
|
766
|
-
case "DND_DRAG_START":
|
|
767
|
-
return {
|
|
768
|
-
...state,
|
|
769
|
-
dragId: action.id,
|
|
770
|
-
dragIds: action.dragIds
|
|
771
|
-
};
|
|
772
|
-
case "DND_DRAG_END":
|
|
773
|
-
return (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)()["dnd"];
|
|
774
|
-
case "DND_HOVERING":
|
|
775
|
-
return {
|
|
776
|
-
...state,
|
|
777
|
-
parentId: action.parentId,
|
|
778
|
-
index: action.index
|
|
779
|
-
};
|
|
780
|
-
default:
|
|
781
|
-
return state;
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
const $6e3db8c23c41dfc9$var$layerStyles = {
|
|
790
|
-
position: "fixed",
|
|
791
|
-
pointerEvents: "none",
|
|
792
|
-
zIndex: 100,
|
|
793
|
-
left: 0,
|
|
794
|
-
top: 0,
|
|
795
|
-
width: "100%",
|
|
796
|
-
height: "100%"
|
|
797
|
-
};
|
|
798
|
-
const $6e3db8c23c41dfc9$var$getStyle = (offset)=>{
|
|
799
|
-
if (!offset) return {
|
|
800
|
-
display: "none"
|
|
801
|
-
};
|
|
802
|
-
const { x: x , y: y } = offset;
|
|
803
|
-
return {
|
|
804
|
-
transform: `translate(${x}px, ${y}px)`
|
|
805
|
-
};
|
|
806
|
-
};
|
|
807
|
-
const $6e3db8c23c41dfc9$var$getCountStyle = (offset)=>{
|
|
808
|
-
if (!offset) return {
|
|
809
|
-
display: "none"
|
|
810
|
-
};
|
|
811
|
-
const { x: x , y: y } = offset;
|
|
812
|
-
return {
|
|
813
|
-
transform: `translate(${x + 10}px, ${y + 10}px)`
|
|
814
|
-
};
|
|
815
|
-
};
|
|
816
|
-
function $6e3db8c23c41dfc9$export$84e211ad8431a387({ offset: offset , mouse: mouse , id: id , dragIds: dragIds , isDragging: isDragging }) {
|
|
817
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsxs)($6e3db8c23c41dfc9$var$Overlay, {
|
|
818
|
-
isDragging: isDragging,
|
|
819
|
-
children: [
|
|
820
|
-
/*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)($6e3db8c23c41dfc9$var$Position, {
|
|
821
|
-
offset: offset,
|
|
822
|
-
children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)($6e3db8c23c41dfc9$var$PreviewNode, {
|
|
823
|
-
id: id,
|
|
824
|
-
dragIds: dragIds
|
|
825
|
-
})
|
|
826
|
-
}),
|
|
827
|
-
/*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)($6e3db8c23c41dfc9$var$Count, {
|
|
828
|
-
mouse: mouse,
|
|
829
|
-
count: dragIds.length
|
|
830
|
-
})
|
|
831
|
-
]
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
const $6e3db8c23c41dfc9$var$Overlay = /*#__PURE__*/ (0, $foSVk$react.memo)(function Overlay(props) {
|
|
835
|
-
if (!props.isDragging) return null;
|
|
836
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
|
|
837
|
-
style: $6e3db8c23c41dfc9$var$layerStyles,
|
|
838
|
-
children: props.children
|
|
839
|
-
});
|
|
840
|
-
});
|
|
841
|
-
function $6e3db8c23c41dfc9$var$Position(props) {
|
|
842
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
|
|
843
|
-
className: "row preview",
|
|
844
|
-
style: $6e3db8c23c41dfc9$var$getStyle(props.offset),
|
|
845
|
-
children: props.children
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
function $6e3db8c23c41dfc9$var$Count(props) {
|
|
849
|
-
const { count: count , mouse: mouse } = props;
|
|
850
|
-
if (count > 1) return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
|
|
851
|
-
className: "selected-count",
|
|
852
|
-
style: $6e3db8c23c41dfc9$var$getCountStyle(mouse),
|
|
853
|
-
children: count
|
|
854
|
-
});
|
|
855
|
-
else return null;
|
|
856
|
-
}
|
|
857
|
-
const $6e3db8c23c41dfc9$var$PreviewNode = /*#__PURE__*/ (0, $foSVk$react.memo)(function PreviewNode(props) {
|
|
858
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
|
|
859
|
-
const node = tree.get(props.id);
|
|
860
|
-
if (!node) return null;
|
|
861
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)(tree.renderNode, {
|
|
862
|
-
preview: true,
|
|
863
|
-
node: node,
|
|
864
|
-
style: {
|
|
865
|
-
paddingLeft: node.level * tree.indent,
|
|
866
|
-
opacity: 0.2,
|
|
867
|
-
background: "transparent"
|
|
868
|
-
},
|
|
869
|
-
tree: tree
|
|
870
|
-
});
|
|
871
|
-
});
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
function $e527b4e3d64e6932$export$b6a79797ad180576() {
|
|
884
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
|
|
885
|
-
const state = (0, $d5cb84d44d1b8acc$export$4930f6bf413be70e)();
|
|
886
|
-
const cursor = state.cursor;
|
|
887
|
-
if (!cursor || cursor.type !== "line") return null;
|
|
888
|
-
const indent = tree.indent;
|
|
889
|
-
const top = tree.rowHeight * cursor.index + ((tree.props.padding ?? tree.props.paddingTop) ?? 0);
|
|
890
|
-
const left = indent * cursor.level;
|
|
891
|
-
const Cursor = tree.renderCursor;
|
|
892
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)(Cursor, {
|
|
893
|
-
top: top,
|
|
894
|
-
left: left,
|
|
895
|
-
indent: indent
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
const $0e2adc7837d85ac3$export$70c2b8898b86d3ad = /*#__PURE__*/ (0, $foSVk$react.forwardRef)(function Outer(props, ref) {
|
|
901
|
-
const { children: children , ...rest } = props;
|
|
902
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
|
|
903
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsxs)("div", {
|
|
904
|
-
// @ts-ignore
|
|
905
|
-
ref: ref,
|
|
906
|
-
...rest,
|
|
907
|
-
onClick: (e)=>{
|
|
908
|
-
if (e.currentTarget === e.target) tree.deselectAll();
|
|
909
|
-
},
|
|
910
|
-
children: [
|
|
911
|
-
/*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)($0e2adc7837d85ac3$var$DropContainer, {}),
|
|
912
|
-
children
|
|
913
|
-
]
|
|
914
|
-
});
|
|
915
|
-
});
|
|
916
|
-
const $0e2adc7837d85ac3$var$DropContainer = ()=>{
|
|
917
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
|
|
918
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
|
|
919
|
-
style: {
|
|
920
|
-
height: tree.visibleNodes.length * tree.rowHeight,
|
|
921
|
-
width: "100%",
|
|
922
|
-
position: "absolute",
|
|
923
|
-
left: "0",
|
|
924
|
-
right: "0"
|
|
925
|
-
},
|
|
926
|
-
children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $e527b4e3d64e6932$export$b6a79797ad180576), {})
|
|
927
|
-
});
|
|
928
|
-
};
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
const $472f3c5b35f3bf96$export$a9af0da3ae60cd00 = /*#__PURE__*/ (0, $foSVk$react.forwardRef)(function InnerElement({ style: style , ...rest }, ref) {
|
|
936
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
|
|
937
|
-
const paddingTop = (tree.props.padding ?? tree.props.paddingTop) ?? 0;
|
|
938
|
-
const paddingBottom = (tree.props.padding ?? tree.props.paddingBottom) ?? 0;
|
|
939
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
|
|
940
|
-
ref: ref,
|
|
941
|
-
style: {
|
|
942
|
-
...style,
|
|
943
|
-
height: `${parseFloat(style.height) + paddingTop + paddingBottom}px`
|
|
944
|
-
},
|
|
945
|
-
...rest
|
|
946
|
-
});
|
|
947
|
-
});
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
function $74bee24dbb0f3e2b$export$715c0d031ede7907(node) {
|
|
961
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
|
|
962
|
-
const ids = tree.selectedIds;
|
|
963
|
-
const [_, ref, preview] = (0, $foSVk$reactdnd.useDrag)(()=>({
|
|
964
|
-
canDrag: ()=>node.isDraggable,
|
|
965
|
-
type: "NODE",
|
|
966
|
-
item: ()=>{
|
|
967
|
-
// This is fired once at the begging of a drag operation
|
|
968
|
-
const dragIds = tree.isSelected(node.id) ? Array.from(ids) : [
|
|
969
|
-
node.id
|
|
970
|
-
];
|
|
971
|
-
tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).dragStart(node.id, dragIds));
|
|
972
|
-
return {
|
|
973
|
-
id: node.id
|
|
974
|
-
};
|
|
975
|
-
},
|
|
976
|
-
end: ()=>{
|
|
977
|
-
tree.hideCursor();
|
|
978
|
-
let { parentId: parentId , index: index , dragIds: dragIds } = tree.state.dnd;
|
|
979
|
-
// If they held down meta, we need to create a copy
|
|
980
|
-
// if (drop.dropEffect === "copy")
|
|
981
|
-
if (tree.canDrop()) {
|
|
982
|
-
(0, $eb5355379510ac9b$export$c6d63370cef03886)(tree.props.onMove, {
|
|
983
|
-
dragIds: dragIds,
|
|
984
|
-
parentId: parentId === (0, $0d7f39915c1a8ae9$export$ec71a3379b43ae5c) ? null : parentId,
|
|
985
|
-
index: index,
|
|
986
|
-
dragNodes: tree.dragNodes,
|
|
987
|
-
parentNode: tree.get(parentId)
|
|
988
|
-
});
|
|
989
|
-
tree.open(parentId);
|
|
990
|
-
}
|
|
991
|
-
tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).dragEnd());
|
|
992
|
-
}
|
|
993
|
-
}), [
|
|
994
|
-
ids,
|
|
995
|
-
node
|
|
996
|
-
]);
|
|
997
|
-
(0, $foSVk$react.useEffect)(()=>{
|
|
998
|
-
preview((0, $foSVk$reactdndhtml5backend.getEmptyImage)());
|
|
999
|
-
}, [
|
|
1000
|
-
preview
|
|
1001
|
-
]);
|
|
1002
|
-
return ref;
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
function $462841de7cc5b715$var$measureHover(el, offset) {
|
|
1010
|
-
const rect = el.getBoundingClientRect();
|
|
1011
|
-
const x = offset.x - Math.round(rect.x);
|
|
1012
|
-
const y = offset.y - Math.round(rect.y);
|
|
1013
|
-
const height = rect.height;
|
|
1014
|
-
const inTopHalf = y < height / 2;
|
|
1015
|
-
const inBottomHalf = !inTopHalf;
|
|
1016
|
-
const pad = height / 4;
|
|
1017
|
-
const inMiddle = y > pad && y < height - pad;
|
|
1018
|
-
const atTop = !inMiddle && inTopHalf;
|
|
1019
|
-
const atBottom = !inMiddle && inBottomHalf;
|
|
1020
|
-
return {
|
|
1021
|
-
x: x,
|
|
1022
|
-
inTopHalf: inTopHalf,
|
|
1023
|
-
inBottomHalf: inBottomHalf,
|
|
1024
|
-
inMiddle: inMiddle,
|
|
1025
|
-
atTop: atTop,
|
|
1026
|
-
atBottom: atBottom
|
|
1027
|
-
};
|
|
1028
|
-
}
|
|
1029
|
-
function $462841de7cc5b715$var$getNodesAroundCursor(node, prev, next, hover) {
|
|
1030
|
-
if (!node) // We're hoving over the empty part of the list, not over an item,
|
|
1031
|
-
// Put the cursor below the last item which is "prev"
|
|
1032
|
-
return [
|
|
1033
|
-
prev,
|
|
1034
|
-
null
|
|
1035
|
-
];
|
|
1036
|
-
if (node.isInternal) {
|
|
1037
|
-
if (hover.atTop) return [
|
|
1038
|
-
prev,
|
|
1039
|
-
node
|
|
1040
|
-
];
|
|
1041
|
-
else if (hover.inMiddle) return [
|
|
1042
|
-
node,
|
|
1043
|
-
node
|
|
1044
|
-
];
|
|
1045
|
-
else return [
|
|
1046
|
-
node,
|
|
1047
|
-
next
|
|
1048
|
-
];
|
|
1049
|
-
} else {
|
|
1050
|
-
if (hover.inTopHalf) return [
|
|
1051
|
-
prev,
|
|
1052
|
-
node
|
|
1053
|
-
];
|
|
1054
|
-
else return [
|
|
1055
|
-
node,
|
|
1056
|
-
next
|
|
1057
|
-
];
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
function $462841de7cc5b715$var$getDropLevel(hovering, aboveCursor, belowCursor, indent) {
|
|
1061
|
-
const hoverLevel = Math.round(Math.max(0, hovering.x - indent) / indent);
|
|
1062
|
-
let min, max;
|
|
1063
|
-
if (!aboveCursor) {
|
|
1064
|
-
max = 0;
|
|
1065
|
-
min = 0;
|
|
1066
|
-
} else if (!belowCursor) {
|
|
1067
|
-
max = aboveCursor.level;
|
|
1068
|
-
min = 0;
|
|
1069
|
-
} else {
|
|
1070
|
-
max = aboveCursor.level;
|
|
1071
|
-
min = belowCursor.level;
|
|
1072
|
-
}
|
|
1073
|
-
return (0, $eb5355379510ac9b$export$adf7c0fe6059d774)(hoverLevel, min, max);
|
|
1074
|
-
}
|
|
1075
|
-
function $462841de7cc5b715$var$dropAt(parentId, index) {
|
|
1076
|
-
return {
|
|
1077
|
-
parentId: parentId || null,
|
|
1078
|
-
index: index
|
|
1079
|
-
};
|
|
1080
|
-
}
|
|
1081
|
-
function $462841de7cc5b715$var$lineCursor(index, level) {
|
|
1082
|
-
return {
|
|
1083
|
-
type: "line",
|
|
1084
|
-
index: index,
|
|
1085
|
-
level: level
|
|
1086
|
-
};
|
|
1087
|
-
}
|
|
1088
|
-
function $462841de7cc5b715$var$noCursor() {
|
|
1089
|
-
return {
|
|
1090
|
-
type: "none"
|
|
1091
|
-
};
|
|
1092
|
-
}
|
|
1093
|
-
function $462841de7cc5b715$var$highlightCursor(id) {
|
|
1094
|
-
return {
|
|
1095
|
-
type: "highlight",
|
|
1096
|
-
id: id
|
|
1097
|
-
};
|
|
1098
|
-
}
|
|
1099
|
-
function $462841de7cc5b715$var$walkUpFrom(node, level) {
|
|
1100
|
-
let drop = node;
|
|
1101
|
-
while(drop.parent && drop.level > level)drop = drop.parent;
|
|
1102
|
-
const parentId = drop.parent?.id || null;
|
|
1103
|
-
const index = (0, $eb5355379510ac9b$export$305f7d4e9d4624f2)(drop) + 1;
|
|
1104
|
-
return {
|
|
1105
|
-
parentId: parentId,
|
|
1106
|
-
index: index
|
|
1107
|
-
};
|
|
1108
|
-
}
|
|
1109
|
-
function $462841de7cc5b715$export$f502ca02ebb85a1c(args) {
|
|
1110
|
-
const hover = $462841de7cc5b715$var$measureHover(args.element, args.offset);
|
|
1111
|
-
const { node: node , nextNode: nextNode , prevNode: prevNode } = args;
|
|
1112
|
-
const [above, below] = $462841de7cc5b715$var$getNodesAroundCursor(node, prevNode, nextNode, hover);
|
|
1113
|
-
/* Hovering over the middle of a folder */ if (node && node.isInternal && hover.inMiddle) return {
|
|
1114
|
-
drop: $462841de7cc5b715$var$dropAt(node.id, 0),
|
|
1115
|
-
cursor: $462841de7cc5b715$var$highlightCursor(node.id)
|
|
1116
|
-
};
|
|
1117
|
-
/* At the top of the list */ if (!above) return {
|
|
1118
|
-
drop: $462841de7cc5b715$var$dropAt(below?.parent?.id, 0),
|
|
1119
|
-
cursor: $462841de7cc5b715$var$lineCursor(0, 0)
|
|
1120
|
-
};
|
|
1121
|
-
/* The above node is an item or a closed folder */ if ((0, $eb5355379510ac9b$export$5318634f2ee07019)(above) || (0, $eb5355379510ac9b$export$4210f5ea57fbae57)(above)) {
|
|
1122
|
-
const level = $462841de7cc5b715$var$getDropLevel(hover, above, below, args.indent);
|
|
1123
|
-
return {
|
|
1124
|
-
drop: $462841de7cc5b715$var$walkUpFrom(above, level),
|
|
1125
|
-
cursor: $462841de7cc5b715$var$lineCursor(above.rowIndex + 1, level)
|
|
1126
|
-
};
|
|
1127
|
-
}
|
|
1128
|
-
/* The above node is an open folder */ return {
|
|
1129
|
-
drop: $462841de7cc5b715$var$dropAt(above?.id, 0),
|
|
1130
|
-
cursor: $462841de7cc5b715$var$lineCursor(above.rowIndex + 1, above.level + 1)
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
function $cf8ebdb33758b119$export$57afafec4637d997(el, node) {
|
|
1137
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
|
|
1138
|
-
const [_, dropRef] = (0, $foSVk$reactdnd.useDrop)(()=>({
|
|
1139
|
-
accept: "NODE",
|
|
1140
|
-
canDrop: ()=>tree.canDrop(),
|
|
1141
|
-
hover: (_item, m)=>{
|
|
1142
|
-
const offset = m.getClientOffset();
|
|
1143
|
-
if (!el.current || !offset) return;
|
|
1144
|
-
const { cursor: cursor , drop: drop } = (0, $462841de7cc5b715$export$f502ca02ebb85a1c)({
|
|
1145
|
-
element: el.current,
|
|
1146
|
-
offset: offset,
|
|
1147
|
-
indent: tree.indent,
|
|
1148
|
-
node: node,
|
|
1149
|
-
prevNode: node.prev,
|
|
1150
|
-
nextNode: node.next
|
|
1151
|
-
});
|
|
1152
|
-
if (drop) tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).hovering(drop.parentId, drop.index));
|
|
1153
|
-
if (m.canDrop()) {
|
|
1154
|
-
if (cursor) tree.showCursor(cursor);
|
|
1155
|
-
} else tree.hideCursor();
|
|
1156
|
-
},
|
|
1157
|
-
drop: (_, m)=>{
|
|
1158
|
-
if (!m.canDrop()) return null;
|
|
1159
|
-
}
|
|
1160
|
-
}), [
|
|
1161
|
-
node,
|
|
1162
|
-
el.current,
|
|
1163
|
-
tree.props
|
|
1164
|
-
]);
|
|
1165
|
-
return dropRef;
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
function $3105f2bcc0822e0d$export$d75ab90b05ebbfaa(index) {
|
|
1172
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
|
|
1173
|
-
const original = tree.at(index);
|
|
1174
|
-
if (!original) throw new Error(`Could not find node for index: ${index}`);
|
|
1175
|
-
return (0, $foSVk$react.useMemo)(()=>{
|
|
1176
|
-
const fresh = original.clone();
|
|
1177
|
-
tree.visibleNodes[index] = fresh; // sneaky
|
|
1178
|
-
return fresh;
|
|
1179
|
-
// Return a fresh instance if the state values change
|
|
1180
|
-
}, [
|
|
1181
|
-
...Object.values(original.state),
|
|
1182
|
-
original
|
|
1183
|
-
]);
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
const $37e3f46f8fd1101f$export$a9754b3c8daa5172 = /*#__PURE__*/ (0, ($parcel$interopDefault($foSVk$react))).memo(function RowContainer({ index: index , style: style }) {
|
|
1188
|
-
/* When will the <Row> will re-render.
|
|
1189
|
-
*
|
|
1190
|
-
* The row component is memo'd so it will only render
|
|
1191
|
-
* when a new instance of the NodeApi class is passed
|
|
1192
|
-
* to it.
|
|
1193
|
-
*
|
|
1194
|
-
* The TreeApi instance is stable. It does not
|
|
1195
|
-
* change when the internal state changes.
|
|
1196
|
-
*
|
|
1197
|
-
* The TreeApi has all the references to the nodes.
|
|
1198
|
-
* We need to clone the nodes when their state
|
|
1199
|
-
* changes. The node class contains no state itself,
|
|
1200
|
-
* It always checks the tree for state. The tree's
|
|
1201
|
-
* state will always be up to date.
|
|
1202
|
-
*/ (0, $d5cb84d44d1b8acc$export$83a4f9dc3b36edb8)(); // Re-render when tree props or visability changes
|
|
1203
|
-
const _ = (0, $d5cb84d44d1b8acc$export$fd23f19d5d8f3033)(); // So that we re-render appropriately
|
|
1204
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)(); // Tree already has the fresh state
|
|
1205
|
-
const node = (0, $3105f2bcc0822e0d$export$d75ab90b05ebbfaa)(index);
|
|
1206
|
-
const el = (0, $foSVk$react.useRef)(null);
|
|
1207
|
-
const dragRef = (0, $74bee24dbb0f3e2b$export$715c0d031ede7907)(node);
|
|
1208
|
-
const dropRef = (0, $cf8ebdb33758b119$export$57afafec4637d997)(el, node);
|
|
1209
|
-
const innerRef = (0, $foSVk$react.useCallback)((n)=>{
|
|
1210
|
-
el.current = n;
|
|
1211
|
-
dropRef(n);
|
|
1212
|
-
}, [
|
|
1213
|
-
dropRef
|
|
1214
|
-
]);
|
|
1215
|
-
const indent = tree.indent * node.level;
|
|
1216
|
-
const nodeStyle = (0, $foSVk$react.useMemo)(()=>({
|
|
1217
|
-
paddingLeft: indent
|
|
1218
|
-
}), [
|
|
1219
|
-
indent
|
|
1220
|
-
]);
|
|
1221
|
-
const rowStyle = (0, $foSVk$react.useMemo)(()=>({
|
|
1222
|
-
...style,
|
|
1223
|
-
top: parseFloat(style.top) + ((tree.props.padding ?? tree.props.paddingTop) ?? 0)
|
|
1224
|
-
}), [
|
|
1225
|
-
style,
|
|
1226
|
-
tree.props.padding,
|
|
1227
|
-
tree.props.paddingTop
|
|
1228
|
-
]);
|
|
1229
|
-
const rowAttrs = {
|
|
1230
|
-
role: "treeitem",
|
|
1231
|
-
"aria-level": node.level,
|
|
1232
|
-
"aria-selected": node.isSelected,
|
|
1233
|
-
style: rowStyle,
|
|
1234
|
-
tabIndex: -1,
|
|
1235
|
-
className: tree.props.rowClassName
|
|
1236
|
-
};
|
|
1237
|
-
(0, $foSVk$react.useEffect)(()=>{
|
|
1238
|
-
if (!node.isEditing && node.isFocused) el.current?.focus({
|
|
1239
|
-
preventScroll: true
|
|
1240
|
-
});
|
|
1241
|
-
}, [
|
|
1242
|
-
node.isEditing,
|
|
1243
|
-
node.isFocused,
|
|
1244
|
-
el.current
|
|
1245
|
-
]);
|
|
1246
|
-
const Node = tree.renderNode;
|
|
1247
|
-
const Row = tree.renderRow;
|
|
1248
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)(Row, {
|
|
1249
|
-
node: node,
|
|
1250
|
-
innerRef: innerRef,
|
|
1251
|
-
attrs: rowAttrs,
|
|
1252
|
-
children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)(Node, {
|
|
1253
|
-
node: node,
|
|
1254
|
-
tree: tree,
|
|
1255
|
-
style: nodeStyle,
|
|
1256
|
-
dragHandle: dragRef
|
|
1257
|
-
})
|
|
1258
|
-
});
|
|
1259
|
-
});
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
let $bb9a1e34249689ac$var$focusSearchTerm = "";
|
|
1263
|
-
let $bb9a1e34249689ac$var$timeoutId = null;
|
|
1264
|
-
function $bb9a1e34249689ac$export$ff4858a4110d9246() {
|
|
1265
|
-
(0, $d5cb84d44d1b8acc$export$83a4f9dc3b36edb8)();
|
|
1266
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
|
|
1267
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
|
|
1268
|
-
style: {
|
|
1269
|
-
height: tree.height,
|
|
1270
|
-
width: tree.width,
|
|
1271
|
-
minHeight: 0,
|
|
1272
|
-
minWidth: 0
|
|
1273
|
-
},
|
|
1274
|
-
onContextMenu: tree.props.onContextMenu,
|
|
1275
|
-
onClick: tree.props.onClick,
|
|
1276
|
-
tabIndex: 0,
|
|
1277
|
-
onFocus: (e)=>{
|
|
1278
|
-
if (!e.currentTarget.contains(e.relatedTarget)) tree.onFocus();
|
|
1279
|
-
},
|
|
1280
|
-
onBlur: (e)=>{
|
|
1281
|
-
if (!e.currentTarget.contains(e.relatedTarget)) tree.onBlur();
|
|
1282
|
-
},
|
|
1283
|
-
onKeyDown: (e)=>{
|
|
1284
|
-
if (tree.isEditing) return;
|
|
1285
|
-
if (e.key === "Backspace") {
|
|
1286
|
-
if (!tree.props.onDelete) return;
|
|
1287
|
-
const ids = Array.from(tree.selectedIds);
|
|
1288
|
-
if (ids.length > 1) {
|
|
1289
|
-
let nextFocus = tree.mostRecentNode;
|
|
1290
|
-
while(nextFocus && nextFocus.isSelected)nextFocus = nextFocus.nextSibling;
|
|
1291
|
-
if (!nextFocus) nextFocus = tree.lastNode;
|
|
1292
|
-
tree.focus(nextFocus, {
|
|
1293
|
-
scroll: false
|
|
1294
|
-
});
|
|
1295
|
-
tree.delete(Array.from(ids));
|
|
1296
|
-
} else {
|
|
1297
|
-
const node = tree.focusedNode;
|
|
1298
|
-
if (node) {
|
|
1299
|
-
const sib = node.nextSibling;
|
|
1300
|
-
const parent = node.parent;
|
|
1301
|
-
tree.focus(sib || parent, {
|
|
1302
|
-
scroll: false
|
|
1303
|
-
});
|
|
1304
|
-
tree.delete(node);
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
return;
|
|
1308
|
-
}
|
|
1309
|
-
if (e.key === "Tab" && !e.shiftKey) {
|
|
1310
|
-
e.preventDefault();
|
|
1311
|
-
(0, $eb5355379510ac9b$export$3b0237e8566c8d65)(e.currentTarget);
|
|
1312
|
-
return;
|
|
1313
|
-
}
|
|
1314
|
-
if (e.key === "Tab" && e.shiftKey) {
|
|
1315
|
-
e.preventDefault();
|
|
1316
|
-
(0, $eb5355379510ac9b$export$33b47db07a82b2fb)(e.currentTarget);
|
|
1317
|
-
return;
|
|
1318
|
-
}
|
|
1319
|
-
if (e.key === "ArrowDown") {
|
|
1320
|
-
e.preventDefault();
|
|
1321
|
-
const next = tree.nextNode;
|
|
1322
|
-
if (e.metaKey) {
|
|
1323
|
-
tree.select(tree.focusedNode);
|
|
1324
|
-
tree.activate(tree.focusedNode);
|
|
1325
|
-
return;
|
|
1326
|
-
} else if (!e.shiftKey || tree.props.disableMultiSelection) {
|
|
1327
|
-
tree.focus(next);
|
|
1328
|
-
return;
|
|
1329
|
-
} else {
|
|
1330
|
-
if (!next) return;
|
|
1331
|
-
const current = tree.focusedNode;
|
|
1332
|
-
if (!current) tree.focus(tree.firstNode);
|
|
1333
|
-
else if (current.isSelected) tree.selectContiguous(next);
|
|
1334
|
-
else tree.selectMulti(next);
|
|
1335
|
-
return;
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
if (e.key === "ArrowUp") {
|
|
1339
|
-
e.preventDefault();
|
|
1340
|
-
const prev = tree.prevNode;
|
|
1341
|
-
if (!e.shiftKey || tree.props.disableMultiSelection) {
|
|
1342
|
-
tree.focus(prev);
|
|
1343
|
-
return;
|
|
1344
|
-
} else {
|
|
1345
|
-
if (!prev) return;
|
|
1346
|
-
const current1 = tree.focusedNode;
|
|
1347
|
-
if (!current1) tree.focus(tree.lastNode); // ?
|
|
1348
|
-
else if (current1.isSelected) tree.selectContiguous(prev);
|
|
1349
|
-
else tree.selectMulti(prev);
|
|
1350
|
-
return;
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
if (e.key === "ArrowRight") {
|
|
1354
|
-
const node1 = tree.focusedNode;
|
|
1355
|
-
if (!node1) return;
|
|
1356
|
-
if (node1.isInternal && node1.isOpen) tree.focus(tree.nextNode);
|
|
1357
|
-
else if (node1.isInternal) tree.open(node1.id);
|
|
1358
|
-
return;
|
|
1359
|
-
}
|
|
1360
|
-
if (e.key === "ArrowLeft") {
|
|
1361
|
-
const node2 = tree.focusedNode;
|
|
1362
|
-
if (!node2 || node2.isRoot) return;
|
|
1363
|
-
if (node2.isInternal && node2.isOpen) tree.close(node2.id);
|
|
1364
|
-
else if (!node2.parent?.isRoot) tree.focus(node2.parent);
|
|
1365
|
-
return;
|
|
1366
|
-
}
|
|
1367
|
-
if (e.key === "a" && e.metaKey && !tree.props.disableMultiSelection) {
|
|
1368
|
-
e.preventDefault();
|
|
1369
|
-
tree.selectAll();
|
|
1370
|
-
return;
|
|
1371
|
-
}
|
|
1372
|
-
if (e.key === "a" && !e.metaKey && tree.props.onCreate) {
|
|
1373
|
-
tree.createLeaf();
|
|
1374
|
-
return;
|
|
1375
|
-
}
|
|
1376
|
-
if (e.key === "A" && !e.metaKey) {
|
|
1377
|
-
if (!tree.props.onCreate) return;
|
|
1378
|
-
tree.createInternal();
|
|
1379
|
-
return;
|
|
1380
|
-
}
|
|
1381
|
-
if (e.key === "Home") {
|
|
1382
|
-
// add shift keys
|
|
1383
|
-
e.preventDefault();
|
|
1384
|
-
tree.focus(tree.firstNode);
|
|
1385
|
-
return;
|
|
1386
|
-
}
|
|
1387
|
-
if (e.key === "End") {
|
|
1388
|
-
// add shift keys
|
|
1389
|
-
e.preventDefault();
|
|
1390
|
-
tree.focus(tree.lastNode);
|
|
1391
|
-
return;
|
|
1392
|
-
}
|
|
1393
|
-
if (e.key === "Enter") {
|
|
1394
|
-
const node3 = tree.focusedNode;
|
|
1395
|
-
if (!node3) return;
|
|
1396
|
-
if (!node3.isEditable || !tree.props.onRename) return;
|
|
1397
|
-
setTimeout(()=>{
|
|
1398
|
-
if (node3) tree.edit(node3);
|
|
1399
|
-
});
|
|
1400
|
-
return;
|
|
1401
|
-
}
|
|
1402
|
-
if (e.key === " ") {
|
|
1403
|
-
e.preventDefault();
|
|
1404
|
-
const node4 = tree.focusedNode;
|
|
1405
|
-
if (!node4) return;
|
|
1406
|
-
if (node4.isLeaf) {
|
|
1407
|
-
node4.select();
|
|
1408
|
-
node4.activate();
|
|
1409
|
-
} else node4.toggle();
|
|
1410
|
-
return;
|
|
1411
|
-
}
|
|
1412
|
-
if (e.key === "*") {
|
|
1413
|
-
const node5 = tree.focusedNode;
|
|
1414
|
-
if (!node5) return;
|
|
1415
|
-
tree.openSiblings(node5);
|
|
1416
|
-
return;
|
|
1417
|
-
}
|
|
1418
|
-
if (e.key === "PageUp") {
|
|
1419
|
-
e.preventDefault();
|
|
1420
|
-
tree.pageUp();
|
|
1421
|
-
return;
|
|
1422
|
-
}
|
|
1423
|
-
if (e.key === "PageDown") {
|
|
1424
|
-
e.preventDefault();
|
|
1425
|
-
tree.pageDown();
|
|
1426
|
-
}
|
|
1427
|
-
// If they type a sequence of characters
|
|
1428
|
-
// collect them. Reset them after a timeout.
|
|
1429
|
-
// Use it to search the tree for a node, then focus it.
|
|
1430
|
-
// Clean this up a bit later
|
|
1431
|
-
clearTimeout($bb9a1e34249689ac$var$timeoutId);
|
|
1432
|
-
$bb9a1e34249689ac$var$focusSearchTerm += e.key;
|
|
1433
|
-
$bb9a1e34249689ac$var$timeoutId = setTimeout(()=>{
|
|
1434
|
-
$bb9a1e34249689ac$var$focusSearchTerm = "";
|
|
1435
|
-
}, 600);
|
|
1436
|
-
const node6 = tree.visibleNodes.find((n)=>{
|
|
1437
|
-
// @ts-ignore
|
|
1438
|
-
const name = n.data.name;
|
|
1439
|
-
if (typeof name === "string") return name.toLowerCase().startsWith($bb9a1e34249689ac$var$focusSearchTerm);
|
|
1440
|
-
else return false;
|
|
1441
|
-
});
|
|
1442
|
-
if (node6) tree.focus(node6.id);
|
|
1443
|
-
},
|
|
1444
|
-
children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $foSVk$reactwindow.FixedSizeList), {
|
|
1445
|
-
className: tree.props.className,
|
|
1446
|
-
outerRef: tree.listEl,
|
|
1447
|
-
itemCount: tree.visibleNodes.length,
|
|
1448
|
-
height: tree.height,
|
|
1449
|
-
width: tree.width,
|
|
1450
|
-
itemSize: tree.rowHeight,
|
|
1451
|
-
overscanCount: tree.overscanCount,
|
|
1452
|
-
itemKey: (index)=>tree.visibleNodes[index]?.id || index,
|
|
1453
|
-
outerElementType: (0, $0e2adc7837d85ac3$export$70c2b8898b86d3ad),
|
|
1454
|
-
innerElementType: (0, $472f3c5b35f3bf96$export$a9af0da3ae60cd00),
|
|
1455
|
-
onScroll: tree.props.onScroll,
|
|
1456
|
-
onItemsRendered: tree.onItemsRendered.bind(tree),
|
|
1457
|
-
ref: tree.list,
|
|
1458
|
-
children: (0, $37e3f46f8fd1101f$export$a9754b3c8daa5172)
|
|
1459
|
-
})
|
|
1460
|
-
});
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
function $07d1cda4da20dc54$export$5897d8d7c7a3d871(tree) {
|
|
1465
|
-
if (tree.isFiltered) return $07d1cda4da20dc54$var$flattenAndFilterTree(tree.root, tree.isMatch.bind(tree));
|
|
1466
|
-
else return $07d1cda4da20dc54$var$flattenTree(tree.root);
|
|
1467
|
-
}
|
|
1468
|
-
function $07d1cda4da20dc54$var$flattenTree(root) {
|
|
1469
|
-
const list = [];
|
|
1470
|
-
function collect(node) {
|
|
1471
|
-
if (node.level >= 0) list.push(node);
|
|
1472
|
-
if (node.isOpen) node.children?.forEach(collect);
|
|
1473
|
-
}
|
|
1474
|
-
collect(root);
|
|
1475
|
-
list.forEach($07d1cda4da20dc54$var$assignRowIndex);
|
|
1476
|
-
return list;
|
|
1477
|
-
}
|
|
1478
|
-
function $07d1cda4da20dc54$var$flattenAndFilterTree(root, isMatch) {
|
|
1479
|
-
const matches = {};
|
|
1480
|
-
const list = [];
|
|
1481
|
-
function markMatch(node) {
|
|
1482
|
-
const yes = !node.isRoot && isMatch(node);
|
|
1483
|
-
if (yes) {
|
|
1484
|
-
matches[node.id] = true;
|
|
1485
|
-
let parent = node.parent;
|
|
1486
|
-
while(parent){
|
|
1487
|
-
matches[parent.id] = true;
|
|
1488
|
-
parent = parent.parent;
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
if (node.children) for (let child of node.children)markMatch(child);
|
|
1492
|
-
}
|
|
1493
|
-
function collect(node) {
|
|
1494
|
-
if (node.level >= 0 && matches[node.id]) list.push(node);
|
|
1495
|
-
if (node.isOpen) node.children?.forEach(collect);
|
|
1496
|
-
}
|
|
1497
|
-
markMatch(root);
|
|
1498
|
-
collect(root);
|
|
1499
|
-
list.forEach($07d1cda4da20dc54$var$assignRowIndex);
|
|
1500
|
-
return list;
|
|
1501
|
-
}
|
|
1502
|
-
function $07d1cda4da20dc54$var$assignRowIndex(node, index) {
|
|
1503
|
-
node.rowIndex = index;
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
const $db9e6e601e34ba08$export$c6d108d7c8095f19 = (nodes)=>{
|
|
1508
|
-
return nodes.reduce((map, node, index)=>{
|
|
1509
|
-
map[node.id] = index;
|
|
1510
|
-
return map;
|
|
1511
|
-
}, {});
|
|
1512
|
-
};
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
const { safeRun: $5c74fef433be2b0a$var$safeRun , identify: $5c74fef433be2b0a$var$identify , identifyNull: $5c74fef433be2b0a$var$identifyNull } = $eb5355379510ac9b$exports;
|
|
1516
|
-
class $5c74fef433be2b0a$export$e2da3477247342d1 {
|
|
1517
|
-
constructor(store, props, list, listEl){
|
|
1518
|
-
this.store = store;
|
|
1519
|
-
this.props = props;
|
|
1520
|
-
this.list = list;
|
|
1521
|
-
this.listEl = listEl;
|
|
1522
|
-
this.visibleStartIndex = 0;
|
|
1523
|
-
this.visibleStopIndex = 0;
|
|
1524
|
-
/* Changes here must also be made in update() */ this.root = (0, $0d7f39915c1a8ae9$export$882461b6382ed46c)(this);
|
|
1525
|
-
this.visibleNodes = (0, $07d1cda4da20dc54$export$5897d8d7c7a3d871)(this);
|
|
1526
|
-
this.idToIndex = (0, $db9e6e601e34ba08$export$c6d108d7c8095f19)(this.visibleNodes);
|
|
1527
|
-
}
|
|
1528
|
-
/* Changes here must also be made in constructor() */ update(props) {
|
|
1529
|
-
this.props = props;
|
|
1530
|
-
this.root = (0, $0d7f39915c1a8ae9$export$882461b6382ed46c)(this);
|
|
1531
|
-
this.visibleNodes = (0, $07d1cda4da20dc54$export$5897d8d7c7a3d871)(this);
|
|
1532
|
-
this.idToIndex = (0, $db9e6e601e34ba08$export$c6d108d7c8095f19)(this.visibleNodes);
|
|
1533
|
-
}
|
|
1534
|
-
/* Store helpers */ dispatch(action) {
|
|
1535
|
-
return this.store.dispatch(action);
|
|
1536
|
-
}
|
|
1537
|
-
get state() {
|
|
1538
|
-
return this.store.getState();
|
|
1539
|
-
}
|
|
1540
|
-
get openState() {
|
|
1541
|
-
return this.state.nodes.open.unfiltered;
|
|
1542
|
-
}
|
|
1543
|
-
/* Tree Props */ get width() {
|
|
1544
|
-
return this.props.width ?? 300;
|
|
1545
|
-
}
|
|
1546
|
-
get height() {
|
|
1547
|
-
return this.props.height ?? 500;
|
|
1548
|
-
}
|
|
1549
|
-
get indent() {
|
|
1550
|
-
return this.props.indent ?? 24;
|
|
1551
|
-
}
|
|
1552
|
-
get rowHeight() {
|
|
1553
|
-
return this.props.rowHeight ?? 24;
|
|
1554
|
-
}
|
|
1555
|
-
get overscanCount() {
|
|
1556
|
-
return this.props.overscanCount ?? 1;
|
|
1557
|
-
}
|
|
1558
|
-
get searchTerm() {
|
|
1559
|
-
return (this.props.searchTerm || "").trim();
|
|
1560
|
-
}
|
|
1561
|
-
get matchFn() {
|
|
1562
|
-
const match = this.props.searchMatch ?? ((node, term)=>{
|
|
1563
|
-
const string = JSON.stringify(Object.values(node.data));
|
|
1564
|
-
return string.toLocaleLowerCase().includes(term.toLocaleLowerCase());
|
|
1565
|
-
});
|
|
1566
|
-
return (node)=>match(node, this.searchTerm);
|
|
1567
|
-
}
|
|
1568
|
-
accessChildren(data) {
|
|
1569
|
-
const get = this.props.childrenAccessor || "children";
|
|
1570
|
-
return $eb5355379510ac9b$exports.access(data, get) ?? null;
|
|
1571
|
-
}
|
|
1572
|
-
accessId(data) {
|
|
1573
|
-
const get = this.props.idAccessor || "id";
|
|
1574
|
-
const id = $eb5355379510ac9b$exports.access(data, get);
|
|
1575
|
-
if (!id) throw new Error("Data must contain an 'id' property or props.idAccessor must return a string");
|
|
1576
|
-
return id;
|
|
1577
|
-
}
|
|
1578
|
-
/* Node Access */ get firstNode() {
|
|
1579
|
-
return this.visibleNodes[0] ?? null;
|
|
1580
|
-
}
|
|
1581
|
-
get lastNode() {
|
|
1582
|
-
return this.visibleNodes[this.visibleNodes.length - 1] ?? null;
|
|
1583
|
-
}
|
|
1584
|
-
get focusedNode() {
|
|
1585
|
-
return this.get(this.state.nodes.focus.id) ?? null;
|
|
1586
|
-
}
|
|
1587
|
-
get mostRecentNode() {
|
|
1588
|
-
return this.get(this.state.nodes.selection.mostRecent) ?? null;
|
|
1589
|
-
}
|
|
1590
|
-
get nextNode() {
|
|
1591
|
-
const index = this.indexOf(this.focusedNode);
|
|
1592
|
-
if (index === null) return null;
|
|
1593
|
-
else return this.at(index + 1);
|
|
1594
|
-
}
|
|
1595
|
-
get prevNode() {
|
|
1596
|
-
const index = this.indexOf(this.focusedNode);
|
|
1597
|
-
if (index === null) return null;
|
|
1598
|
-
else return this.at(index - 1);
|
|
1599
|
-
}
|
|
1600
|
-
get(id) {
|
|
1601
|
-
if (!id) return null;
|
|
1602
|
-
if (id in this.idToIndex) return this.visibleNodes[this.idToIndex[id]] || null;
|
|
1603
|
-
else return null;
|
|
1604
|
-
}
|
|
1605
|
-
at(index) {
|
|
1606
|
-
return this.visibleNodes[index] || null;
|
|
1607
|
-
}
|
|
1608
|
-
nodesBetween(startId, endId) {
|
|
1609
|
-
if (startId === null || endId === null) return [];
|
|
1610
|
-
const index1 = this.indexOf(startId) ?? 0;
|
|
1611
|
-
const index2 = this.indexOf(endId);
|
|
1612
|
-
if (index2 === null) return [];
|
|
1613
|
-
const start = Math.min(index1, index2);
|
|
1614
|
-
const end = Math.max(index1, index2);
|
|
1615
|
-
return this.visibleNodes.slice(start, end + 1);
|
|
1616
|
-
}
|
|
1617
|
-
indexOf(id) {
|
|
1618
|
-
const key = $eb5355379510ac9b$exports.identifyNull(id);
|
|
1619
|
-
if (!key) return null;
|
|
1620
|
-
return this.idToIndex[key];
|
|
1621
|
-
}
|
|
1622
|
-
/* Data Operations */ get editingId() {
|
|
1623
|
-
return this.state.nodes.edit.id;
|
|
1624
|
-
}
|
|
1625
|
-
createInternal() {
|
|
1626
|
-
return this.create({
|
|
1627
|
-
type: "internal"
|
|
1628
|
-
});
|
|
1629
|
-
}
|
|
1630
|
-
createLeaf() {
|
|
1631
|
-
return this.create({
|
|
1632
|
-
type: "leaf"
|
|
1633
|
-
});
|
|
1634
|
-
}
|
|
1635
|
-
async create(opts = {}) {
|
|
1636
|
-
const parentId = opts.parentId === undefined ? $eb5355379510ac9b$exports.getInsertParentId(this) : opts.parentId;
|
|
1637
|
-
const index = opts.index ?? $eb5355379510ac9b$exports.getInsertIndex(this);
|
|
1638
|
-
const type = opts.type ?? "leaf";
|
|
1639
|
-
const data = await $5c74fef433be2b0a$var$safeRun(this.props.onCreate, {
|
|
1640
|
-
type: type,
|
|
1641
|
-
parentId: parentId,
|
|
1642
|
-
index: index,
|
|
1643
|
-
parentNode: this.get(parentId)
|
|
1644
|
-
});
|
|
1645
|
-
if (data) {
|
|
1646
|
-
this.focus(data);
|
|
1647
|
-
setTimeout(()=>{
|
|
1648
|
-
this.edit(data).then(()=>{
|
|
1649
|
-
this.select(data);
|
|
1650
|
-
this.activate(data);
|
|
1651
|
-
});
|
|
1652
|
-
});
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
async delete(node) {
|
|
1656
|
-
if (!node) return;
|
|
1657
|
-
const idents = Array.isArray(node) ? node : [
|
|
1658
|
-
node
|
|
1659
|
-
];
|
|
1660
|
-
const ids = idents.map($5c74fef433be2b0a$var$identify);
|
|
1661
|
-
const nodes = ids.map((id)=>this.get(id)).filter((n)=>!!n);
|
|
1662
|
-
await $5c74fef433be2b0a$var$safeRun(this.props.onDelete, {
|
|
1663
|
-
nodes: nodes,
|
|
1664
|
-
ids: ids
|
|
1665
|
-
});
|
|
1666
|
-
}
|
|
1667
|
-
edit(node) {
|
|
1668
|
-
const id = $5c74fef433be2b0a$var$identify(node);
|
|
1669
|
-
this.resolveEdit({
|
|
1670
|
-
cancelled: true
|
|
1671
|
-
});
|
|
1672
|
-
this.scrollTo(id);
|
|
1673
|
-
this.dispatch((0, $1297c48a54b69bac$export$e1a8e267487c59d1)(id));
|
|
1674
|
-
return new Promise((resolve)=>{
|
|
1675
|
-
$5c74fef433be2b0a$export$e2da3477247342d1.editPromise = resolve;
|
|
1676
|
-
});
|
|
1677
|
-
}
|
|
1678
|
-
async submit(identity, value) {
|
|
1679
|
-
if (!identity) return;
|
|
1680
|
-
const id = $5c74fef433be2b0a$var$identify(identity);
|
|
1681
|
-
await $5c74fef433be2b0a$var$safeRun(this.props.onRename, {
|
|
1682
|
-
id: id,
|
|
1683
|
-
name: value,
|
|
1684
|
-
node: this.get(id)
|
|
1685
|
-
});
|
|
1686
|
-
this.dispatch((0, $1297c48a54b69bac$export$e1a8e267487c59d1)(null));
|
|
1687
|
-
this.resolveEdit({
|
|
1688
|
-
cancelled: false,
|
|
1689
|
-
value: value
|
|
1690
|
-
});
|
|
1691
|
-
setTimeout(()=>this.onFocus()); // Return focus to element;
|
|
1692
|
-
}
|
|
1693
|
-
reset() {
|
|
1694
|
-
this.dispatch((0, $1297c48a54b69bac$export$e1a8e267487c59d1)(null));
|
|
1695
|
-
this.resolveEdit({
|
|
1696
|
-
cancelled: true
|
|
1697
|
-
});
|
|
1698
|
-
setTimeout(()=>this.onFocus()); // Return focus to element;
|
|
1699
|
-
}
|
|
1700
|
-
activate(id) {
|
|
1701
|
-
const node = this.get($5c74fef433be2b0a$var$identifyNull(id));
|
|
1702
|
-
if (!node) return;
|
|
1703
|
-
$5c74fef433be2b0a$var$safeRun(this.props.onActivate, node);
|
|
1704
|
-
}
|
|
1705
|
-
resolveEdit(value) {
|
|
1706
|
-
const resolve = $5c74fef433be2b0a$export$e2da3477247342d1.editPromise;
|
|
1707
|
-
if (resolve) resolve(value);
|
|
1708
|
-
$5c74fef433be2b0a$export$e2da3477247342d1.editPromise = null;
|
|
1709
|
-
}
|
|
1710
|
-
/* Focus and Selection */ get selectedIds() {
|
|
1711
|
-
return this.state.nodes.selection.ids;
|
|
1712
|
-
}
|
|
1713
|
-
get selectedNodes() {
|
|
1714
|
-
let nodes = [];
|
|
1715
|
-
for (let id of Array.from(this.selectedIds)){
|
|
1716
|
-
const node = this.get(id);
|
|
1717
|
-
if (node) nodes.push(node);
|
|
1718
|
-
}
|
|
1719
|
-
return nodes;
|
|
1720
|
-
}
|
|
1721
|
-
focus(node, opts = {}) {
|
|
1722
|
-
if (!node) return;
|
|
1723
|
-
/* Focus is responsible for scrolling, while selection is
|
|
1724
|
-
* responsible for focus. If selectionFollowsFocus, then
|
|
1725
|
-
* just select it. */ if (this.props.selectionFollowsFocus) this.select(node);
|
|
1726
|
-
else {
|
|
1727
|
-
this.dispatch((0, $61ef7f2c3c9633e7$export$d7ddd398f22d79ef)($5c74fef433be2b0a$var$identify(node)));
|
|
1728
|
-
if (opts.scroll !== false) this.scrollTo(node);
|
|
1729
|
-
if (this.focusedNode) $5c74fef433be2b0a$var$safeRun(this.props.onFocus, this.focusedNode);
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
pageUp() {
|
|
1733
|
-
const start = this.visibleStartIndex;
|
|
1734
|
-
const stop = this.visibleStopIndex;
|
|
1735
|
-
const page = stop - start;
|
|
1736
|
-
let index = this.focusedNode?.rowIndex ?? 0;
|
|
1737
|
-
if (index > start) index = start;
|
|
1738
|
-
else index = Math.max(start - page, 0);
|
|
1739
|
-
this.focus(this.at(index));
|
|
1740
|
-
}
|
|
1741
|
-
pageDown() {
|
|
1742
|
-
const start = this.visibleStartIndex;
|
|
1743
|
-
const stop = this.visibleStopIndex;
|
|
1744
|
-
const page = stop - start;
|
|
1745
|
-
let index = this.focusedNode?.rowIndex ?? 0;
|
|
1746
|
-
if (index < stop) index = stop;
|
|
1747
|
-
else index = Math.min(index + page, this.visibleNodes.length - 1);
|
|
1748
|
-
this.focus(this.at(index));
|
|
1749
|
-
}
|
|
1750
|
-
select(node, opts = {}) {
|
|
1751
|
-
if (!node) return;
|
|
1752
|
-
const changeFocus = opts.focus !== false;
|
|
1753
|
-
const id = $5c74fef433be2b0a$var$identify(node);
|
|
1754
|
-
if (changeFocus) this.dispatch((0, $61ef7f2c3c9633e7$export$d7ddd398f22d79ef)(id));
|
|
1755
|
-
this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).only(id));
|
|
1756
|
-
this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).anchor(id));
|
|
1757
|
-
this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).mostRecent(id));
|
|
1758
|
-
this.scrollTo(id, opts.align);
|
|
1759
|
-
if (this.focusedNode && changeFocus) $5c74fef433be2b0a$var$safeRun(this.props.onFocus, this.focusedNode);
|
|
1760
|
-
$5c74fef433be2b0a$var$safeRun(this.props.onSelect, this.selectedNodes);
|
|
1761
|
-
}
|
|
1762
|
-
deselect(node) {
|
|
1763
|
-
if (!node) return;
|
|
1764
|
-
const id = $5c74fef433be2b0a$var$identify(node);
|
|
1765
|
-
this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).remove(id));
|
|
1766
|
-
}
|
|
1767
|
-
selectMulti(identity) {
|
|
1768
|
-
const node = this.get($5c74fef433be2b0a$var$identifyNull(identity));
|
|
1769
|
-
if (!node) return;
|
|
1770
|
-
this.dispatch((0, $61ef7f2c3c9633e7$export$d7ddd398f22d79ef)(node.id));
|
|
1771
|
-
this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).add(node.id));
|
|
1772
|
-
this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).anchor(node.id));
|
|
1773
|
-
this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).mostRecent(node.id));
|
|
1774
|
-
this.scrollTo(node);
|
|
1775
|
-
if (this.focusedNode) $5c74fef433be2b0a$var$safeRun(this.props.onFocus, this.focusedNode);
|
|
1776
|
-
$5c74fef433be2b0a$var$safeRun(this.props.onSelect, this.selectedNodes);
|
|
1777
|
-
}
|
|
1778
|
-
selectContiguous(identity) {
|
|
1779
|
-
if (!identity) return;
|
|
1780
|
-
const id = $5c74fef433be2b0a$var$identify(identity);
|
|
1781
|
-
const { anchor: anchor , mostRecent: mostRecent } = this.state.nodes.selection;
|
|
1782
|
-
this.dispatch((0, $61ef7f2c3c9633e7$export$d7ddd398f22d79ef)(id));
|
|
1783
|
-
this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).remove(this.nodesBetween(anchor, mostRecent)));
|
|
1784
|
-
this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).add(this.nodesBetween(anchor, $5c74fef433be2b0a$var$identifyNull(id))));
|
|
1785
|
-
this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).mostRecent(id));
|
|
1786
|
-
this.scrollTo(id);
|
|
1787
|
-
if (this.focusedNode) $5c74fef433be2b0a$var$safeRun(this.props.onFocus, this.focusedNode);
|
|
1788
|
-
$5c74fef433be2b0a$var$safeRun(this.props.onSelect, this.selectedNodes);
|
|
1789
|
-
}
|
|
1790
|
-
deselectAll() {
|
|
1791
|
-
this.setSelection({
|
|
1792
|
-
ids: [],
|
|
1793
|
-
anchor: null,
|
|
1794
|
-
mostRecent: null
|
|
1795
|
-
});
|
|
1796
|
-
$5c74fef433be2b0a$var$safeRun(this.props.onSelect, this.selectedNodes);
|
|
1797
|
-
}
|
|
1798
|
-
selectAll() {
|
|
1799
|
-
this.setSelection({
|
|
1800
|
-
ids: Object.keys(this.idToIndex),
|
|
1801
|
-
anchor: this.firstNode,
|
|
1802
|
-
mostRecent: this.lastNode
|
|
1803
|
-
});
|
|
1804
|
-
this.dispatch((0, $61ef7f2c3c9633e7$export$d7ddd398f22d79ef)(this.lastNode?.id));
|
|
1805
|
-
if (this.focusedNode) $5c74fef433be2b0a$var$safeRun(this.props.onFocus, this.focusedNode);
|
|
1806
|
-
$5c74fef433be2b0a$var$safeRun(this.props.onSelect, this.selectedNodes);
|
|
1807
|
-
}
|
|
1808
|
-
setSelection(args) {
|
|
1809
|
-
const ids = new Set(args.ids?.map($5c74fef433be2b0a$var$identify));
|
|
1810
|
-
const anchor = $5c74fef433be2b0a$var$identifyNull(args.anchor);
|
|
1811
|
-
const mostRecent = $5c74fef433be2b0a$var$identifyNull(args.mostRecent);
|
|
1812
|
-
this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).set({
|
|
1813
|
-
ids: ids,
|
|
1814
|
-
anchor: anchor,
|
|
1815
|
-
mostRecent: mostRecent
|
|
1816
|
-
}));
|
|
1817
|
-
$5c74fef433be2b0a$var$safeRun(this.props.onSelect, this.selectedNodes);
|
|
1818
|
-
}
|
|
1819
|
-
/* Drag and Drop */ get cursorParentId() {
|
|
1820
|
-
const { cursor: cursor } = this.state.dnd;
|
|
1821
|
-
switch(cursor.type){
|
|
1822
|
-
case "highlight":
|
|
1823
|
-
return cursor.id;
|
|
1824
|
-
default:
|
|
1825
|
-
return null;
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
get cursorOverFolder() {
|
|
1829
|
-
return this.state.dnd.cursor.type === "highlight";
|
|
1830
|
-
}
|
|
1831
|
-
get dragNodes() {
|
|
1832
|
-
return this.state.dnd.dragIds.map((id)=>this.get(id)).filter((n)=>!!n);
|
|
1833
|
-
}
|
|
1834
|
-
canDrop() {
|
|
1835
|
-
if (this.isFiltered) return false;
|
|
1836
|
-
const parentNode = this.get(this.state.dnd.parentId) ?? this.root;
|
|
1837
|
-
const dragNodes = this.dragNodes;
|
|
1838
|
-
const isDisabled = this.props.disableDrop;
|
|
1839
|
-
for (const drag of dragNodes){
|
|
1840
|
-
if (!drag) return false;
|
|
1841
|
-
if (!parentNode) return false;
|
|
1842
|
-
if (drag.isInternal && $eb5355379510ac9b$exports.isDecendent(parentNode, drag)) return false;
|
|
1843
|
-
}
|
|
1844
|
-
// Allow the user to insert their own logic
|
|
1845
|
-
if (typeof isDisabled == "function") return !isDisabled({
|
|
1846
|
-
parentNode: parentNode,
|
|
1847
|
-
dragNodes: this.dragNodes,
|
|
1848
|
-
index: this.state.dnd.index
|
|
1849
|
-
});
|
|
1850
|
-
else if (typeof isDisabled == "string") // @ts-ignore
|
|
1851
|
-
return !parentNode.data[isDisabled];
|
|
1852
|
-
else if (typeof isDisabled === "boolean") return !isDisabled;
|
|
1853
|
-
else return true;
|
|
1854
|
-
}
|
|
1855
|
-
hideCursor() {
|
|
1856
|
-
this.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).cursor({
|
|
1857
|
-
type: "none"
|
|
1858
|
-
}));
|
|
1859
|
-
}
|
|
1860
|
-
showCursor(cursor) {
|
|
1861
|
-
this.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).cursor(cursor));
|
|
1862
|
-
}
|
|
1863
|
-
/* Visibility */ open(identity) {
|
|
1864
|
-
const id = $5c74fef433be2b0a$var$identifyNull(identity);
|
|
1865
|
-
if (!id) return;
|
|
1866
|
-
if (this.isOpen(id)) return;
|
|
1867
|
-
this.dispatch((0, $d519ceb3313d9d0e$export$e324594224ef24da).open(id, this.isFiltered));
|
|
1868
|
-
$5c74fef433be2b0a$var$safeRun(this.props.onToggle, id);
|
|
1869
|
-
}
|
|
1870
|
-
close(identity) {
|
|
1871
|
-
const id = $5c74fef433be2b0a$var$identifyNull(identity);
|
|
1872
|
-
if (!id) return;
|
|
1873
|
-
if (!this.isOpen(id)) return;
|
|
1874
|
-
this.dispatch((0, $d519ceb3313d9d0e$export$e324594224ef24da).close(id, this.isFiltered));
|
|
1875
|
-
$5c74fef433be2b0a$var$safeRun(this.props.onToggle, id);
|
|
1876
|
-
}
|
|
1877
|
-
toggle(identity) {
|
|
1878
|
-
const id = $5c74fef433be2b0a$var$identifyNull(identity);
|
|
1879
|
-
if (!id) return;
|
|
1880
|
-
return this.isOpen(id) ? this.close(id) : this.open(id);
|
|
1881
|
-
}
|
|
1882
|
-
openParents(identity) {
|
|
1883
|
-
const id = $5c74fef433be2b0a$var$identifyNull(identity);
|
|
1884
|
-
if (!id) return;
|
|
1885
|
-
const node = $eb5355379510ac9b$exports.dfs(this.root, id);
|
|
1886
|
-
let parent = node?.parent;
|
|
1887
|
-
while(parent){
|
|
1888
|
-
this.open(parent.id);
|
|
1889
|
-
parent = parent.parent;
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
openSiblings(node) {
|
|
1893
|
-
const parent = node.parent;
|
|
1894
|
-
if (!parent) this.toggle(node.id);
|
|
1895
|
-
else if (parent.children) {
|
|
1896
|
-
const isOpen = node.isOpen;
|
|
1897
|
-
for (let sibling of parent.children)if (sibling.isInternal) isOpen ? this.close(sibling.id) : this.open(sibling.id);
|
|
1898
|
-
this.scrollTo(this.focusedNode);
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
openAll() {
|
|
1902
|
-
$eb5355379510ac9b$exports.walk(this.root, (node)=>{
|
|
1903
|
-
if (node.isInternal) node.open();
|
|
1904
|
-
});
|
|
1905
|
-
}
|
|
1906
|
-
closeAll() {
|
|
1907
|
-
$eb5355379510ac9b$exports.walk(this.root, (node)=>{
|
|
1908
|
-
if (node.isInternal) node.close();
|
|
1909
|
-
});
|
|
1910
|
-
}
|
|
1911
|
-
/* Scrolling */ scrollTo(identity, align = "smart") {
|
|
1912
|
-
if (!identity) return;
|
|
1913
|
-
const id = $5c74fef433be2b0a$var$identify(identity);
|
|
1914
|
-
this.openParents(id);
|
|
1915
|
-
return $eb5355379510ac9b$exports.waitFor(()=>id in this.idToIndex).then(()=>{
|
|
1916
|
-
const index = this.idToIndex[id];
|
|
1917
|
-
if (index === undefined) return;
|
|
1918
|
-
this.list.current?.scrollToItem(index, align);
|
|
1919
|
-
}).catch(()=>{
|
|
1920
|
-
// Id: ${id} never appeared in the list.
|
|
1921
|
-
});
|
|
1922
|
-
}
|
|
1923
|
-
/* State Checks */ get isEditing() {
|
|
1924
|
-
return this.state.nodes.edit.id !== null;
|
|
1925
|
-
}
|
|
1926
|
-
get isFiltered() {
|
|
1927
|
-
return !!this.props.searchTerm?.trim();
|
|
1928
|
-
}
|
|
1929
|
-
get hasFocus() {
|
|
1930
|
-
return this.state.nodes.focus.treeFocused;
|
|
1931
|
-
}
|
|
1932
|
-
get hasNoSelection() {
|
|
1933
|
-
return this.state.nodes.selection.ids.size === 0;
|
|
1934
|
-
}
|
|
1935
|
-
get hasOneSelection() {
|
|
1936
|
-
return this.state.nodes.selection.ids.size === 1;
|
|
1937
|
-
}
|
|
1938
|
-
get hasMultipleSelections() {
|
|
1939
|
-
return this.state.nodes.selection.ids.size > 1;
|
|
1940
|
-
}
|
|
1941
|
-
isSelected(id) {
|
|
1942
|
-
if (!id) return false;
|
|
1943
|
-
return this.state.nodes.selection.ids.has(id);
|
|
1944
|
-
}
|
|
1945
|
-
isOpen(id) {
|
|
1946
|
-
if (!id) return false;
|
|
1947
|
-
if (id === (0, $0d7f39915c1a8ae9$export$ec71a3379b43ae5c)) return true;
|
|
1948
|
-
const def = this.props.openByDefault ?? true;
|
|
1949
|
-
if (this.isFiltered) return this.state.nodes.open.filtered[id] ?? true; // Filtered folders are always opened by default
|
|
1950
|
-
else return this.state.nodes.open.unfiltered[id] ?? def;
|
|
1951
|
-
}
|
|
1952
|
-
isEditable(data) {
|
|
1953
|
-
const check = this.props.disableEdit || (()=>false);
|
|
1954
|
-
return !$eb5355379510ac9b$exports.access(data, check) ?? true;
|
|
1955
|
-
}
|
|
1956
|
-
isDraggable(data) {
|
|
1957
|
-
const check = this.props.disableDrag || (()=>false);
|
|
1958
|
-
return !$eb5355379510ac9b$exports.access(data, check) ?? true;
|
|
1959
|
-
}
|
|
1960
|
-
isDragging(node) {
|
|
1961
|
-
const id = $5c74fef433be2b0a$var$identifyNull(node);
|
|
1962
|
-
if (!id) return false;
|
|
1963
|
-
return this.state.nodes.drag.id === id;
|
|
1964
|
-
}
|
|
1965
|
-
isFocused(id) {
|
|
1966
|
-
return this.hasFocus && this.state.nodes.focus.id === id;
|
|
1967
|
-
}
|
|
1968
|
-
isMatch(node) {
|
|
1969
|
-
return this.matchFn(node);
|
|
1970
|
-
}
|
|
1971
|
-
willReceiveDrop(node) {
|
|
1972
|
-
const id = $5c74fef433be2b0a$var$identifyNull(node);
|
|
1973
|
-
if (!id) return false;
|
|
1974
|
-
return id === this.state.nodes.drag.idWillReceiveDrop;
|
|
1975
|
-
}
|
|
1976
|
-
/* Tree Event Handlers */ onFocus() {
|
|
1977
|
-
const node = this.focusedNode || this.firstNode;
|
|
1978
|
-
if (node) this.dispatch((0, $61ef7f2c3c9633e7$export$d7ddd398f22d79ef)(node.id));
|
|
1979
|
-
}
|
|
1980
|
-
onBlur() {
|
|
1981
|
-
this.dispatch((0, $61ef7f2c3c9633e7$export$6b6c976e46a06288)());
|
|
1982
|
-
}
|
|
1983
|
-
onItemsRendered(args) {
|
|
1984
|
-
this.visibleStartIndex = args.visibleStartIndex;
|
|
1985
|
-
this.visibleStopIndex = args.visibleStopIndex;
|
|
1986
|
-
}
|
|
1987
|
-
/* Get Renderers */ get renderContainer() {
|
|
1988
|
-
return this.props.renderContainer || (0, $bb9a1e34249689ac$export$ff4858a4110d9246);
|
|
1989
|
-
}
|
|
1990
|
-
get renderRow() {
|
|
1991
|
-
return this.props.renderRow || (0, $ff6862a32cc2ac81$export$f9c541e71856c524);
|
|
1992
|
-
}
|
|
1993
|
-
get renderNode() {
|
|
1994
|
-
return this.props.children || (0, $3240a4b0b5620968$export$909e23cbfbbd3351);
|
|
1995
|
-
}
|
|
1996
|
-
get renderDragPreview() {
|
|
1997
|
-
return this.props.renderDragPreview || (0, $6e3db8c23c41dfc9$export$84e211ad8431a387);
|
|
1998
|
-
}
|
|
1999
|
-
get renderCursor() {
|
|
2000
|
-
return this.props.renderCursor || (0, $c79fefb0d0a1d13b$export$6cb3c16721363d11);
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
function $2f73c1963cd9aa06$export$1650419e431d3ba3(state = {
|
|
2013
|
-
id: null,
|
|
2014
|
-
idWillReceiveDrop: null
|
|
2015
|
-
}, action) {
|
|
2016
|
-
switch(action.type){
|
|
2017
|
-
case "DND_DRAG_START":
|
|
2018
|
-
return {
|
|
2019
|
-
...state,
|
|
2020
|
-
id: action.id
|
|
2021
|
-
};
|
|
2022
|
-
case "DND_DRAG_END":
|
|
2023
|
-
return {
|
|
2024
|
-
...state,
|
|
2025
|
-
id: null
|
|
2026
|
-
};
|
|
2027
|
-
case "DND_CURSOR":
|
|
2028
|
-
const c = action.cursor;
|
|
2029
|
-
if (c.type === "highlight" && c.id !== state.idWillReceiveDrop) return {
|
|
2030
|
-
...state,
|
|
2031
|
-
idWillReceiveDrop: c.id
|
|
2032
|
-
};
|
|
2033
|
-
else if (c.type !== "highlight" && state.idWillReceiveDrop !== null) return {
|
|
2034
|
-
...state,
|
|
2035
|
-
idWillReceiveDrop: null
|
|
2036
|
-
};
|
|
2037
|
-
else return state;
|
|
2038
|
-
default:
|
|
2039
|
-
return state;
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
const $cdb8f316fadc608f$export$a8a69c316169e623 = (0, $foSVk$redux.combineReducers)({
|
|
2045
|
-
nodes: (0, $foSVk$redux.combineReducers)({
|
|
2046
|
-
focus: $61ef7f2c3c9633e7$export$1650419e431d3ba3,
|
|
2047
|
-
edit: $1297c48a54b69bac$export$1650419e431d3ba3,
|
|
2048
|
-
open: $d519ceb3313d9d0e$export$1650419e431d3ba3,
|
|
2049
|
-
selection: $58f9381615aa3d17$export$1650419e431d3ba3,
|
|
2050
|
-
drag: $2f73c1963cd9aa06$export$1650419e431d3ba3
|
|
2051
|
-
}),
|
|
2052
|
-
dnd: $7d98f5b84ecaa66b$export$1650419e431d3ba3
|
|
2053
|
-
});
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
const $9511ad6af37da13b$var$SERVER_STATE = (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)();
|
|
2061
|
-
function $9511ad6af37da13b$export$c49dab5eb1b4ce0c({ treeProps: treeProps , imperativeHandle: imperativeHandle , children: children }) {
|
|
2062
|
-
const list = (0, $foSVk$react.useRef)(null);
|
|
2063
|
-
const listEl = (0, $foSVk$react.useRef)(null);
|
|
2064
|
-
const store = (0, $foSVk$react.useRef)((0, $foSVk$redux.createStore)((0, $cdb8f316fadc608f$export$a8a69c316169e623), (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)(treeProps)));
|
|
2065
|
-
const state = (0, $foSVk$usesyncexternalstoreshim.useSyncExternalStore)(store.current.subscribe, store.current.getState, ()=>$9511ad6af37da13b$var$SERVER_STATE);
|
|
2066
|
-
/* The tree api object is stable. */ const api = (0, $foSVk$react.useMemo)(()=>{
|
|
2067
|
-
return new (0, $5c74fef433be2b0a$export$e2da3477247342d1)(store.current, treeProps, list, listEl);
|
|
2068
|
-
}, []);
|
|
2069
|
-
/* Make sure the tree instance stays in sync */ const updateCount = (0, $foSVk$react.useRef)(0);
|
|
2070
|
-
(0, $foSVk$react.useMemo)(()=>{
|
|
2071
|
-
updateCount.current += 1;
|
|
2072
|
-
api.update(treeProps);
|
|
2073
|
-
}, [
|
|
2074
|
-
...Object.values(treeProps),
|
|
2075
|
-
state.nodes.open
|
|
2076
|
-
]);
|
|
2077
|
-
/* Expose the tree api */ (0, $foSVk$react.useImperativeHandle)(imperativeHandle, ()=>api);
|
|
2078
|
-
/* Change selection based on props */ (0, $foSVk$react.useEffect)(()=>{
|
|
2079
|
-
if (api.props.selection) api.select(api.props.selection, {
|
|
2080
|
-
focus: false
|
|
2081
|
-
});
|
|
2082
|
-
else api.deselectAll();
|
|
2083
|
-
}, [
|
|
2084
|
-
api.props.selection
|
|
2085
|
-
]);
|
|
2086
|
-
/* Clear visability for filtered nodes */ (0, $foSVk$react.useEffect)(()=>{
|
|
2087
|
-
if (!api.props.searchTerm) store.current.dispatch((0, $d519ceb3313d9d0e$export$e324594224ef24da).clear(true));
|
|
2088
|
-
}, [
|
|
2089
|
-
api.props.searchTerm
|
|
2090
|
-
]);
|
|
2091
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $d5cb84d44d1b8acc$export$feef243b04ff4151).Provider, {
|
|
2092
|
-
value: api,
|
|
2093
|
-
children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $d5cb84d44d1b8acc$export$d0c71bc5e3e2d897).Provider, {
|
|
2094
|
-
value: updateCount.current,
|
|
2095
|
-
children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $d5cb84d44d1b8acc$export$f6d467aa8b3786af).Provider, {
|
|
2096
|
-
value: state.nodes,
|
|
2097
|
-
children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $d5cb84d44d1b8acc$export$2d5c5ceac203fc1e).Provider, {
|
|
2098
|
-
value: state.dnd,
|
|
2099
|
-
children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $foSVk$reactdnd.DndProvider), {
|
|
2100
|
-
backend: (0, $foSVk$reactdndhtml5backend.HTML5Backend),
|
|
2101
|
-
options: {
|
|
2102
|
-
rootElement: api.props.dndRootElement || undefined
|
|
2103
|
-
},
|
|
2104
|
-
...treeProps.dndManager && {
|
|
2105
|
-
manager: treeProps.dndManager
|
|
2106
|
-
},
|
|
2107
|
-
children: children
|
|
2108
|
-
})
|
|
2109
|
-
})
|
|
2110
|
-
})
|
|
2111
|
-
})
|
|
2112
|
-
});
|
|
2113
|
-
}
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
function $6c0a9a91d5e7ff45$export$5a6c424b1725f44f() {
|
|
2121
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
|
|
2122
|
-
// In case we drop an item at the bottom of the list
|
|
2123
|
-
const [, drop] = (0, $foSVk$reactdnd.useDrop)(()=>({
|
|
2124
|
-
accept: "NODE",
|
|
2125
|
-
canDrop: (_item, m)=>{
|
|
2126
|
-
if (!m.isOver({
|
|
2127
|
-
shallow: true
|
|
2128
|
-
})) return false;
|
|
2129
|
-
return tree.canDrop();
|
|
2130
|
-
},
|
|
2131
|
-
hover: (_item, m)=>{
|
|
2132
|
-
if (!m.isOver({
|
|
2133
|
-
shallow: true
|
|
2134
|
-
})) return;
|
|
2135
|
-
const offset = m.getClientOffset();
|
|
2136
|
-
if (!tree.listEl.current || !offset) return;
|
|
2137
|
-
const { cursor: cursor , drop: drop } = (0, $462841de7cc5b715$export$f502ca02ebb85a1c)({
|
|
2138
|
-
element: tree.listEl.current,
|
|
2139
|
-
offset: offset,
|
|
2140
|
-
indent: tree.indent,
|
|
2141
|
-
node: null,
|
|
2142
|
-
prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],
|
|
2143
|
-
nextNode: null
|
|
2144
|
-
});
|
|
2145
|
-
if (drop) tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).hovering(drop.parentId, drop.index));
|
|
2146
|
-
if (m.canDrop()) {
|
|
2147
|
-
if (cursor) tree.showCursor(cursor);
|
|
2148
|
-
} else tree.hideCursor();
|
|
2149
|
-
}
|
|
2150
|
-
}), [
|
|
2151
|
-
tree
|
|
2152
|
-
]);
|
|
2153
|
-
drop(tree.listEl);
|
|
2154
|
-
}
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
function $df8d0340a995314b$export$a6ee728c3c6ef11d(props) {
|
|
2158
|
-
(0, $6c0a9a91d5e7ff45$export$5a6c424b1725f44f)();
|
|
2159
|
-
return props.children;
|
|
2160
|
-
}
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
function $17a87d0a329a3eaa$export$cdf2ef3f6364d85() {
|
|
2168
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
|
|
2169
|
-
const Container = tree.props.renderContainer || (0, $bb9a1e34249689ac$export$ff4858a4110d9246);
|
|
2170
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $foSVk$reactjsxruntime.Fragment), {
|
|
2171
|
-
children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)(Container, {})
|
|
2172
|
-
});
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
function $ed13b1d404b3872b$export$3e21b60650ec7e55() {
|
|
2181
|
-
const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
|
|
2182
|
-
const { offset: offset , mouse: mouse , item: item , isDragging: isDragging } = (0, $foSVk$reactdnd.useDragLayer)((m)=>{
|
|
2183
|
-
return {
|
|
2184
|
-
offset: m.getSourceClientOffset(),
|
|
2185
|
-
mouse: m.getClientOffset(),
|
|
2186
|
-
item: m.getItem(),
|
|
2187
|
-
isDragging: m.isDragging()
|
|
2188
|
-
};
|
|
2189
|
-
});
|
|
2190
|
-
const DragPreview = tree.props.renderDragPreview || (0, $6e3db8c23c41dfc9$export$84e211ad8431a387);
|
|
2191
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)(DragPreview, {
|
|
2192
|
-
offset: offset,
|
|
2193
|
-
mouse: mouse,
|
|
2194
|
-
id: item?.id || null,
|
|
2195
|
-
dragIds: item?.dragIds || [],
|
|
2196
|
-
isDragging: isDragging
|
|
2197
|
-
});
|
|
2198
|
-
}
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
var $2492d77b1ec82005$exports = {};
|
|
2202
|
-
|
|
2203
|
-
$parcel$export($2492d77b1ec82005$exports, "useSimpleTree", () => $2492d77b1ec82005$export$dcd27aa2043b2724);
|
|
2204
|
-
|
|
2205
|
-
var $ce2da9e8a36b0fcd$exports = {};
|
|
2206
|
-
|
|
2207
|
-
$parcel$export($ce2da9e8a36b0fcd$exports, "SimpleTree", () => $ce2da9e8a36b0fcd$export$e32206264f456dce);
|
|
2208
|
-
class $ce2da9e8a36b0fcd$export$e32206264f456dce {
|
|
2209
|
-
constructor(data){
|
|
2210
|
-
this.root = $ce2da9e8a36b0fcd$var$createRoot(data);
|
|
2211
|
-
}
|
|
2212
|
-
get data() {
|
|
2213
|
-
return this.root.children?.map((node)=>node.data) ?? [];
|
|
2214
|
-
}
|
|
2215
|
-
create(args) {
|
|
2216
|
-
const parent = args.parentId ? this.find(args.parentId) : this.root;
|
|
2217
|
-
if (!parent) return null;
|
|
2218
|
-
parent.addChild(args.data, args.index);
|
|
2219
|
-
}
|
|
2220
|
-
move(args) {
|
|
2221
|
-
const src = this.find(args.id);
|
|
2222
|
-
const parent = args.parentId ? this.find(args.parentId) : this.root;
|
|
2223
|
-
if (!src || !parent) return;
|
|
2224
|
-
parent.addChild(src.data, args.index);
|
|
2225
|
-
src.drop();
|
|
2226
|
-
}
|
|
2227
|
-
update(args) {
|
|
2228
|
-
const node = this.find(args.id);
|
|
2229
|
-
if (node) node.update(args.changes);
|
|
2230
|
-
}
|
|
2231
|
-
drop(args) {
|
|
2232
|
-
const node = this.find(args.id);
|
|
2233
|
-
if (node) node.drop();
|
|
2234
|
-
}
|
|
2235
|
-
find(id, node = this.root) {
|
|
2236
|
-
if (!node) return null;
|
|
2237
|
-
if (node.id === id) return node;
|
|
2238
|
-
if (node.children) {
|
|
2239
|
-
for (let child of node.children){
|
|
2240
|
-
const found = this.find(id, child);
|
|
2241
|
-
if (found) return found;
|
|
2242
|
-
}
|
|
2243
|
-
return null;
|
|
2244
|
-
}
|
|
2245
|
-
return null;
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
function $ce2da9e8a36b0fcd$var$createRoot(data) {
|
|
2249
|
-
const root = new $ce2da9e8a36b0fcd$var$SimpleNode({
|
|
2250
|
-
id: "ROOT"
|
|
2251
|
-
}, null);
|
|
2252
|
-
root.children = data.map((d)=>$ce2da9e8a36b0fcd$var$createNode(d, root));
|
|
2253
|
-
return root;
|
|
2254
|
-
}
|
|
2255
|
-
function $ce2da9e8a36b0fcd$var$createNode(data, parent) {
|
|
2256
|
-
const node = new $ce2da9e8a36b0fcd$var$SimpleNode(data, parent);
|
|
2257
|
-
if (data.children) node.children = data.children.map((d)=>$ce2da9e8a36b0fcd$var$createNode(d, node));
|
|
2258
|
-
return node;
|
|
2259
|
-
}
|
|
2260
|
-
class $ce2da9e8a36b0fcd$var$SimpleNode {
|
|
2261
|
-
constructor(data, parent){
|
|
2262
|
-
this.data = data;
|
|
2263
|
-
this.parent = parent;
|
|
2264
|
-
this.id = data.id;
|
|
2265
|
-
}
|
|
2266
|
-
hasParent() {
|
|
2267
|
-
return !!this.parent;
|
|
2268
|
-
}
|
|
2269
|
-
get childIndex() {
|
|
2270
|
-
return this.hasParent() ? this.parent.children.indexOf(this) : -1;
|
|
2271
|
-
}
|
|
2272
|
-
addChild(data, index) {
|
|
2273
|
-
const node = $ce2da9e8a36b0fcd$var$createNode(data, this);
|
|
2274
|
-
this.children = this.children ?? [];
|
|
2275
|
-
this.children.splice(index, 0, node);
|
|
2276
|
-
this.data.children = this.data.children ?? [];
|
|
2277
|
-
this.data.children.splice(index, 0, data);
|
|
2278
|
-
}
|
|
2279
|
-
removeChild(index) {
|
|
2280
|
-
this.children?.splice(index, 1);
|
|
2281
|
-
this.data.children?.splice(index, 1);
|
|
2282
|
-
}
|
|
2283
|
-
update(changes) {
|
|
2284
|
-
if (this.hasParent()) {
|
|
2285
|
-
const i = this.childIndex;
|
|
2286
|
-
this.parent.addChild({
|
|
2287
|
-
...this.data,
|
|
2288
|
-
...changes
|
|
2289
|
-
}, i);
|
|
2290
|
-
this.drop();
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
|
-
drop() {
|
|
2294
|
-
if (this.hasParent()) this.parent.removeChild(this.childIndex);
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
let $2492d77b1ec82005$var$nextId = 0;
|
|
2300
|
-
function $2492d77b1ec82005$export$dcd27aa2043b2724(initialData) {
|
|
2301
|
-
const [data, setData] = (0, $foSVk$react.useState)(initialData);
|
|
2302
|
-
const tree = (0, $foSVk$react.useMemo)(()=>new (0, $ce2da9e8a36b0fcd$export$e32206264f456dce)(data), [
|
|
2303
|
-
data
|
|
2304
|
-
]);
|
|
2305
|
-
const onMove = (args)=>{
|
|
2306
|
-
for (const id of args.dragIds)tree.move({
|
|
2307
|
-
id: id,
|
|
2308
|
-
parentId: args.parentId,
|
|
2309
|
-
index: args.index
|
|
2310
|
-
});
|
|
2311
|
-
setData(tree.data);
|
|
2312
|
-
};
|
|
2313
|
-
const onRename = ({ name: name , id: id })=>{
|
|
2314
|
-
tree.update({
|
|
2315
|
-
id: id,
|
|
2316
|
-
changes: {
|
|
2317
|
-
name: name
|
|
2318
|
-
}
|
|
2319
|
-
});
|
|
2320
|
-
setData(tree.data);
|
|
2321
|
-
};
|
|
2322
|
-
const onCreate = ({ parentId: parentId , index: index , type: type })=>{
|
|
2323
|
-
const data = {
|
|
2324
|
-
id: `simple-tree-id-${$2492d77b1ec82005$var$nextId++}`,
|
|
2325
|
-
name: ""
|
|
2326
|
-
};
|
|
2327
|
-
if (type === "internal") data.children = [];
|
|
2328
|
-
tree.create({
|
|
2329
|
-
parentId: parentId,
|
|
2330
|
-
index: index,
|
|
2331
|
-
data: data
|
|
2332
|
-
});
|
|
2333
|
-
setData(tree.data);
|
|
2334
|
-
return data;
|
|
2335
|
-
};
|
|
2336
|
-
const onDelete = (args)=>{
|
|
2337
|
-
args.ids.forEach((id)=>tree.drop({
|
|
2338
|
-
id: id
|
|
2339
|
-
}));
|
|
2340
|
-
setData(tree.data);
|
|
2341
|
-
};
|
|
2342
|
-
const controller = {
|
|
2343
|
-
onMove: onMove,
|
|
2344
|
-
onRename: onRename,
|
|
2345
|
-
onCreate: onCreate,
|
|
2346
|
-
onDelete: onDelete
|
|
2347
|
-
};
|
|
2348
|
-
return [
|
|
2349
|
-
data,
|
|
2350
|
-
controller
|
|
2351
|
-
];
|
|
2352
|
-
}
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
function $8e1ae4dab2259e77$export$d227906824a13416(props) {
|
|
2356
|
-
if (props.initialData && props.data) throw new Error(`React Arborist Tree => Provide either a data or initialData prop, but not both.`);
|
|
2357
|
-
if (props.initialData && (props.onCreate || props.onDelete || props.onMove || props.onRename)) throw new Error(`React Arborist Tree => You passed the initialData prop along with a data handler.
|
|
2358
|
-
Use the data prop if you want to provide your own handlers.`);
|
|
2359
|
-
if (props.initialData) {
|
|
2360
|
-
/**
|
|
2361
|
-
* Let's break the rules of hooks here. If the initialData prop
|
|
2362
|
-
* is provided, we will assume it will not change for the life of
|
|
2363
|
-
* the component.
|
|
2364
|
-
*
|
|
2365
|
-
* We will provide the real data and the handlers to update it.
|
|
2366
|
-
* */ const [data, controller] = (0, $2492d77b1ec82005$export$dcd27aa2043b2724)(props.initialData);
|
|
2367
|
-
return {
|
|
2368
|
-
...props,
|
|
2369
|
-
...controller,
|
|
2370
|
-
data: data
|
|
2371
|
-
};
|
|
2372
|
-
} else return props;
|
|
2373
|
-
}
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
function $641461e16d1a2941$var$TreeComponent(props, ref) {
|
|
2377
|
-
const treeProps = (0, $8e1ae4dab2259e77$export$d227906824a13416)(props);
|
|
2378
|
-
return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsxs)((0, $9511ad6af37da13b$export$c49dab5eb1b4ce0c), {
|
|
2379
|
-
treeProps: treeProps,
|
|
2380
|
-
imperativeHandle: ref,
|
|
2381
|
-
children: [
|
|
2382
|
-
/*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $df8d0340a995314b$export$a6ee728c3c6ef11d), {
|
|
2383
|
-
children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $17a87d0a329a3eaa$export$cdf2ef3f6364d85), {})
|
|
2384
|
-
}),
|
|
2385
|
-
/*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $ed13b1d404b3872b$export$3e21b60650ec7e55), {})
|
|
2386
|
-
]
|
|
2387
|
-
});
|
|
2388
|
-
}
|
|
2389
|
-
const $641461e16d1a2941$export$7fbedc92909ed28e = /*#__PURE__*/ (0, $foSVk$react.forwardRef)($641461e16d1a2941$var$TreeComponent);
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
var $73c61fb8fd3b5237$exports = {};
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
var $6740b53b975d3884$exports = {};
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
var $6cfe0c91f2a90e78$exports = {};
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
$parcel$exportWildcard(module.exports, $73c61fb8fd3b5237$exports);
|
|
2406
|
-
$parcel$exportWildcard(module.exports, $6740b53b975d3884$exports);
|
|
2407
|
-
$parcel$exportWildcard(module.exports, $6cfe0c91f2a90e78$exports);
|
|
2408
|
-
$parcel$exportWildcard(module.exports, $9b37fe5960a1a3c6$exports);
|
|
2409
|
-
$parcel$exportWildcard(module.exports, $5c74fef433be2b0a$exports);
|
|
2410
|
-
$parcel$exportWildcard(module.exports, $ce2da9e8a36b0fcd$exports);
|
|
2411
|
-
$parcel$exportWildcard(module.exports, $2492d77b1ec82005$exports);
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
//# sourceMappingURL=index.js.map
|