@asup/tree-of-nodes 1.0.4 → 1.0.6
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/cjs/main.js +212 -328
- package/dist/cjs/main.js.map +1 -1
- package/dist/main.js +199 -303
- package/dist/main.js.map +1 -1
- package/dist/tree-of-nodes.d.ts +4 -29
- package/dist/tree-of-nodes.d.ts.map +1 -1
- package/package.json +5 -1
- package/dist/cjs/main.css +0 -41
- package/dist/cjs/main.css.map +0 -1
- package/dist/main.css +0 -41
- package/dist/main.css.map +0 -1
package/dist/cjs/main.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
require("./main.css");
|
|
2
|
-
var $gTuX4$reactjsxruntime = require("react/jsx-runtime");
|
|
3
|
-
var $gTuX4$react = require("react");
|
|
4
|
-
var $gTuX4$swchelperslib_sliced_to_arrayjs = require("@swc/helpers/lib/_sliced_to_array.js");
|
|
5
1
|
var $gTuX4$swchelperslib_async_to_generatorjs = require("@swc/helpers/lib/_async_to_generator.js");
|
|
2
|
+
var $gTuX4$swchelperslib_sliced_to_arrayjs = require("@swc/helpers/lib/_sliced_to_array.js");
|
|
6
3
|
var $gTuX4$swchelperslib_ts_generatorjs = require("@swc/helpers/lib/_ts_generator.js");
|
|
7
|
-
var $gTuX4$
|
|
4
|
+
var $gTuX4$reactjsxruntime = require("react/jsx-runtime");
|
|
5
|
+
var $gTuX4$asupcontextmenu = require("@asup/context-menu");
|
|
6
|
+
var $gTuX4$react = require("react");
|
|
8
7
|
var $gTuX4$reactbootstrapicons = require("react-bootstrap-icons");
|
|
9
|
-
var $gTuX4$swchelperslib_object_spreadjs = require("@swc/helpers/lib/_object_spread.js");
|
|
10
8
|
var $gTuX4$swchelperslib_to_consumable_arrayjs = require("@swc/helpers/lib/_to_consumable_array.js");
|
|
9
|
+
var $gTuX4$swchelperslib_object_spreadjs = require("@swc/helpers/lib/_object_spread.js");
|
|
10
|
+
var $gTuX4$reactbootstrap = require("react-bootstrap");
|
|
11
11
|
|
|
12
12
|
function $parcel$exportWildcard(dest, source) {
|
|
13
13
|
Object.keys(source).forEach(function(key) {
|
|
@@ -33,118 +33,39 @@ function $parcel$interopDefault(a) {
|
|
|
33
33
|
}
|
|
34
34
|
var $a68bd8a6c0fd98c2$exports = {};
|
|
35
35
|
|
|
36
|
-
$parcel$export($a68bd8a6c0fd98c2$exports, "ContextMenu", function () { return $5150b66b01c99189$export$8dc6765e8be191c7; });
|
|
37
|
-
$parcel$export($a68bd8a6c0fd98c2$exports, "ContextMenuProvider", function () { return $bad272ba85e71af5$export$434a17f82a8154e4; });
|
|
38
36
|
$parcel$export($a68bd8a6c0fd98c2$exports, "TreeNode", function () { return $a56aac35d4408806$export$2eba8ec3a333fdbb; });
|
|
39
37
|
$parcel$export($a68bd8a6c0fd98c2$exports, "TreeOfNodes", function () { return $9becaaec3a803ae7$export$5580fff3e08a8be5; });
|
|
40
38
|
$parcel$export($a68bd8a6c0fd98c2$exports, "WordEntry", function () { return $176d21a51def1fce$export$14f190ac910bde69; });
|
|
41
39
|
|
|
42
40
|
|
|
43
41
|
|
|
44
|
-
var $5150b66b01c99189$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, ($parcel$interopDefault($gTuX4$react))).forwardRef(function(param, ref) {
|
|
45
|
-
var entries = param.entries, visible = param.visible, xPos = param.xPos, yPos = param.yPos;
|
|
46
|
-
$5150b66b01c99189$export$8dc6765e8be191c7.displayName = "ContextMenu";
|
|
47
|
-
var _e_label;
|
|
48
|
-
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
49
|
-
ref: ref,
|
|
50
|
-
className: "context-menu ".concat(visible ? "visible" : ""),
|
|
51
|
-
style: {
|
|
52
|
-
top: "".concat(yPos, "px"),
|
|
53
|
-
left: "".concat(xPos, "px")
|
|
54
|
-
},
|
|
55
|
-
children: entries.map(function(e, i) {
|
|
56
|
-
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
57
|
-
className: "context-menu-item",
|
|
58
|
-
onClick: function() {
|
|
59
|
-
e.action && e.action();
|
|
60
|
-
},
|
|
61
|
-
children: (_e_label = e.label) !== null && _e_label !== void 0 ? _e_label : ""
|
|
62
|
-
}, i);
|
|
63
|
-
})
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
42
|
|
|
67
43
|
|
|
68
44
|
|
|
69
45
|
|
|
70
46
|
|
|
71
47
|
|
|
72
|
-
var $
|
|
73
|
-
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
var _useState3 = (0, ($parcel$interopDefault($gTuX4$swchelperslib_sliced_to_arrayjs)))((0, $gTuX4$react.useState)([]), 2), menuItems = _useState3[0], setMenuItems = _useState3[1];
|
|
82
|
-
// Update menu items
|
|
83
|
-
var updateMenu = (0, $gTuX4$react.useCallback)(function(ret) {
|
|
84
|
-
if (divRef.current) {
|
|
85
|
-
if (ret.visible !== undefined) setMenuVisible(ret.visible);
|
|
86
|
-
if (ret.x) setMenuXPos(ret.x - window.scrollX - divRef.current.getBoundingClientRect().x);
|
|
87
|
-
if (ret.y) setMenuYPos(ret.y - window.scrollX - divRef.current.getBoundingClientRect().y);
|
|
88
|
-
if (ret.menuItems !== undefined) setMenuItems(ret.menuItems);
|
|
89
|
-
}
|
|
90
|
-
}, []);
|
|
91
|
-
// Handle click off the menu
|
|
92
|
-
var handleClick = (0, $gTuX4$react.useCallback)(function(e) {
|
|
93
|
-
var _menuRef_current;
|
|
94
|
-
if (menuRef.current && (e.target instanceof Element && !((_menuRef_current = menuRef.current) === null || _menuRef_current === void 0 ? void 0 : _menuRef_current.contains(e.target)) || !(e.target instanceof Element))) setMenuVisible(false);
|
|
95
|
-
}, []);
|
|
96
|
-
// Update the document click handler
|
|
97
|
-
(0, $gTuX4$react.useEffect)(function() {
|
|
98
|
-
if (menuVisible) document.addEventListener("mousedown", handleClick);
|
|
99
|
-
else document.removeEventListener("mousedown", handleClick);
|
|
100
|
-
return function() {
|
|
101
|
-
document.removeEventListener("mousedown", handleClick);
|
|
102
|
-
};
|
|
103
|
-
}, [
|
|
104
|
-
handleClick,
|
|
105
|
-
menuVisible
|
|
106
|
-
]);
|
|
107
|
-
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)($bad272ba85e71af5$export$c7e742effb1c51e2.Provider, {
|
|
108
|
-
value: {
|
|
109
|
-
visible: menuVisible,
|
|
110
|
-
x: menuXPos,
|
|
111
|
-
y: menuYPos,
|
|
112
|
-
set: updateMenu
|
|
113
|
-
},
|
|
114
|
-
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
|
|
115
|
-
className: "menu-context-provider",
|
|
116
|
-
style: {
|
|
117
|
-
position: "relative"
|
|
118
|
-
},
|
|
119
|
-
ref: divRef,
|
|
120
|
-
children: [
|
|
121
|
-
children,
|
|
122
|
-
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $5150b66b01c99189$export$8dc6765e8be191c7), {
|
|
123
|
-
ref: menuRef,
|
|
124
|
-
entries: menuItems,
|
|
125
|
-
visible: menuVisible,
|
|
126
|
-
xPos: menuXPos,
|
|
127
|
-
yPos: menuYPos
|
|
128
|
-
})
|
|
129
|
-
]
|
|
130
|
-
})
|
|
48
|
+
var $580f9b3e262282c9$export$c6fd3ab3f44300d0 = function(id, included, hierarchyNodes) {
|
|
49
|
+
// Get current node
|
|
50
|
+
var current = hierarchyNodes.find(function(h) {
|
|
51
|
+
return h.id === id;
|
|
52
|
+
});
|
|
53
|
+
if (current === undefined) return [];
|
|
54
|
+
// Get parent node
|
|
55
|
+
var parent = hierarchyNodes.find(function(h) {
|
|
56
|
+
return h.id === current.parentId;
|
|
131
57
|
});
|
|
58
|
+
// Stop if no more parents
|
|
59
|
+
return parent === undefined ? included : $580f9b3e262282c9$export$c6fd3ab3f44300d0(parent.id, (0, ($parcel$interopDefault($gTuX4$swchelperslib_to_consumable_arrayjs)))(included.filter(function(i) {
|
|
60
|
+
return i.id !== parent.id;
|
|
61
|
+
})).concat([
|
|
62
|
+
parent
|
|
63
|
+
]), hierarchyNodes);
|
|
132
64
|
};
|
|
133
65
|
|
|
134
66
|
|
|
135
67
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
var $ff9cca1fe8f6b24e$export$29ec378200e05207 = (0, $gTuX4$react.createContext)({
|
|
145
|
-
id: "tree-of-nodes",
|
|
146
|
-
nodeList: []
|
|
147
|
-
});
|
|
68
|
+
var $ff9cca1fe8f6b24e$export$29ec378200e05207 = (0, $gTuX4$react.createContext)(undefined);
|
|
148
69
|
|
|
149
70
|
|
|
150
71
|
|
|
@@ -205,6 +126,7 @@ var $176d21a51def1fce$export$14f190ac910bde69 = /*#__PURE__*/ (0, ($parcel$inter
|
|
|
205
126
|
animation: "border"
|
|
206
127
|
}),
|
|
207
128
|
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("input", {
|
|
129
|
+
autoFocus: true,
|
|
208
130
|
id: String(id),
|
|
209
131
|
ref: ref,
|
|
210
132
|
type: "text",
|
|
@@ -231,51 +153,55 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
231
153
|
var id = param.id, canRemove = param.canRemove, canRename = param.canRename, canAddChildren = param.canAddChildren, canRemoveChildren = param.canRemoveChildren, canRenameChildren = param.canRenameChildren;
|
|
232
154
|
// Contexts
|
|
233
155
|
var treeContext = (0, $gTuX4$react.useContext)((0, $ff9cca1fe8f6b24e$export$29ec378200e05207));
|
|
234
|
-
var menuContext = (0, $gTuX4$react.useContext)((0, $bad272ba85e71af5$export$c7e742effb1c51e2));
|
|
235
156
|
// Node information
|
|
236
157
|
var thisNode = (0, $gTuX4$react.useMemo)(function() {
|
|
237
|
-
return treeContext.nodeList.find(function(n) {
|
|
158
|
+
return treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList.find(function(n) {
|
|
238
159
|
return n.id === id;
|
|
239
160
|
});
|
|
240
161
|
}, [
|
|
241
162
|
id,
|
|
242
|
-
treeContext.nodeList
|
|
163
|
+
treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList
|
|
243
164
|
]);
|
|
244
165
|
var childNodes = (0, $gTuX4$react.useMemo)(function() {
|
|
245
|
-
return treeContext.nodeList.filter(function(n) {
|
|
166
|
+
return treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList.filter(function(n) {
|
|
246
167
|
return n.parentId === id;
|
|
247
168
|
});
|
|
248
169
|
}, [
|
|
249
170
|
id,
|
|
250
|
-
treeContext.nodeList
|
|
171
|
+
treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList
|
|
251
172
|
]);
|
|
252
173
|
// State
|
|
253
|
-
var loading = (0, $gTuX4$react.useMemo)(function() {
|
|
254
|
-
return treeContext.nodeList.findIndex(function(n) {
|
|
255
|
-
return n.id === id;
|
|
256
|
-
}) === -1;
|
|
257
|
-
}, [
|
|
258
|
-
id,
|
|
259
|
-
treeContext.nodeList
|
|
260
|
-
]);
|
|
261
174
|
var _useState = (0, ($parcel$interopDefault($gTuX4$swchelperslib_sliced_to_arrayjs)))((0, $gTuX4$react.useState)(false), 2), error = _useState[0], setError = _useState[1];
|
|
262
175
|
var _useState1 = (0, ($parcel$interopDefault($gTuX4$swchelperslib_sliced_to_arrayjs)))((0, $gTuX4$react.useState)(null), 2), errorText = _useState1[0], setErrotText = _useState1[1];
|
|
263
176
|
var expanded = (0, $gTuX4$react.useMemo)(function() {
|
|
264
|
-
var _treeContext_expandedNodes;
|
|
265
177
|
var _treeContext_expandedNodes_findIndex;
|
|
266
|
-
return ((_treeContext_expandedNodes_findIndex =
|
|
178
|
+
return ((_treeContext_expandedNodes_findIndex = treeContext === null || treeContext === void 0 ? void 0 : treeContext.expandedNodes.findIndex(function(e) {
|
|
267
179
|
return e === id;
|
|
268
180
|
})) !== null && _treeContext_expandedNodes_findIndex !== void 0 ? _treeContext_expandedNodes_findIndex : -1) > -1;
|
|
269
181
|
}, [
|
|
270
182
|
id,
|
|
271
|
-
treeContext.expandedNodes
|
|
183
|
+
treeContext === null || treeContext === void 0 ? void 0 : treeContext.expandedNodes
|
|
272
184
|
]);
|
|
273
185
|
// // Apply selected borer
|
|
274
186
|
var currentBorder = (0, $gTuX4$react.useMemo)(function() {
|
|
275
|
-
return id === treeContext.selectedId ? "1px solid black" : "";
|
|
187
|
+
return id === (treeContext === null || treeContext === void 0 ? void 0 : treeContext.selectedId) ? "1px solid black" : "";
|
|
276
188
|
}, [
|
|
277
189
|
id,
|
|
278
|
-
treeContext.selectedId
|
|
190
|
+
treeContext === null || treeContext === void 0 ? void 0 : treeContext.selectedId
|
|
191
|
+
]);
|
|
192
|
+
var nodeColour = (0, $gTuX4$react.useMemo)(function() {
|
|
193
|
+
if (treeContext && treeContext.selectedId) {
|
|
194
|
+
var anc = (0, $580f9b3e262282c9$export$c6fd3ab3f44300d0)(treeContext.selectedId, [], treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList).map(function(n) {
|
|
195
|
+
return n.id;
|
|
196
|
+
});
|
|
197
|
+
if ((0, ($parcel$interopDefault($gTuX4$swchelperslib_to_consumable_arrayjs)))(anc).concat([
|
|
198
|
+
treeContext.selectedId
|
|
199
|
+
]).includes(id)) return treeContext.nodeHighlight;
|
|
200
|
+
}
|
|
201
|
+
return;
|
|
202
|
+
}, [
|
|
203
|
+
id,
|
|
204
|
+
treeContext
|
|
279
205
|
]);
|
|
280
206
|
// New node parameters
|
|
281
207
|
var newNameRef = (0, $gTuX4$react.useRef)(null);
|
|
@@ -302,7 +228,7 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
302
228
|
switch(_state.label){
|
|
303
229
|
case 0:
|
|
304
230
|
setSavingNewNode(true);
|
|
305
|
-
if (!treeContext.onAddChild) return [
|
|
231
|
+
if (!(treeContext === null || treeContext === void 0 ? void 0 : treeContext.onAddChild)) return [
|
|
306
232
|
3,
|
|
307
233
|
2
|
|
308
234
|
];
|
|
@@ -338,11 +264,11 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
338
264
|
switch(_state.label){
|
|
339
265
|
case 0:
|
|
340
266
|
setRenaming(false);
|
|
341
|
-
|
|
342
|
-
if (!treeContext.onRename) return [
|
|
267
|
+
if (!(treeContext === null || treeContext === void 0 ? void 0 : treeContext.onRename)) return [
|
|
343
268
|
3,
|
|
344
269
|
2
|
|
345
270
|
];
|
|
271
|
+
setUpdatingNode(true);
|
|
346
272
|
return [
|
|
347
273
|
4,
|
|
348
274
|
treeContext.onRename(id, newLabel)
|
|
@@ -351,9 +277,9 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
351
277
|
handleReturn.apply(void 0, [
|
|
352
278
|
_state.sent()
|
|
353
279
|
]);
|
|
280
|
+
setUpdatingNode(false);
|
|
354
281
|
_state.label = 2;
|
|
355
282
|
case 2:
|
|
356
|
-
setUpdatingNode(false);
|
|
357
283
|
return [
|
|
358
284
|
2
|
|
359
285
|
];
|
|
@@ -372,11 +298,11 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
372
298
|
return (0, ($parcel$interopDefault($gTuX4$swchelperslib_ts_generatorjs)))(this, function(_state) {
|
|
373
299
|
switch(_state.label){
|
|
374
300
|
case 0:
|
|
375
|
-
|
|
376
|
-
if (!treeContext.onRemove) return [
|
|
301
|
+
if (!(treeContext === null || treeContext === void 0 ? void 0 : treeContext.onRemove)) return [
|
|
377
302
|
3,
|
|
378
303
|
2
|
|
379
304
|
];
|
|
305
|
+
setUpdatingNode(true);
|
|
380
306
|
return [
|
|
381
307
|
4,
|
|
382
308
|
treeContext.onRemove(id)
|
|
@@ -385,9 +311,9 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
385
311
|
handleReturn.apply(void 0, [
|
|
386
312
|
_state.sent()
|
|
387
313
|
]);
|
|
314
|
+
setUpdatingNode(false);
|
|
388
315
|
_state.label = 2;
|
|
389
316
|
case 2:
|
|
390
|
-
setUpdatingNode(false);
|
|
391
317
|
return [
|
|
392
318
|
2
|
|
393
319
|
];
|
|
@@ -400,16 +326,10 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
400
326
|
]);
|
|
401
327
|
// Context actions
|
|
402
328
|
var addChild = (0, $gTuX4$react.useCallback)(function() {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
visible: false
|
|
406
|
-
});
|
|
407
|
-
setShowNewNode(true);
|
|
408
|
-
treeContext.handleExpandClick && treeContext.handleExpandClick(id, true);
|
|
409
|
-
}
|
|
329
|
+
setShowNewNode(true);
|
|
330
|
+
treeContext && treeContext.handleExpandClick(id, true);
|
|
410
331
|
}, [
|
|
411
332
|
id,
|
|
412
|
-
menuContext,
|
|
413
333
|
treeContext
|
|
414
334
|
]);
|
|
415
335
|
(0, $gTuX4$react.useEffect)(function() {
|
|
@@ -418,35 +338,14 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
418
338
|
showNewNode
|
|
419
339
|
]);
|
|
420
340
|
var renameThis = (0, $gTuX4$react.useCallback)(function() {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
visible: false
|
|
424
|
-
});
|
|
425
|
-
setRenaming(true);
|
|
426
|
-
}
|
|
427
|
-
}, [
|
|
428
|
-
menuContext
|
|
429
|
-
]);
|
|
430
|
-
(0, $gTuX4$react.useEffect)(function() {
|
|
431
|
-
if (renaming === true && currentNameRef.current) currentNameRef.current.focus();
|
|
432
|
-
}, [
|
|
433
|
-
renaming
|
|
434
|
-
]);
|
|
435
|
-
var removeThis = (0, $gTuX4$react.useCallback)(function() {
|
|
436
|
-
if (menuContext.set) {
|
|
437
|
-
menuContext.set({
|
|
438
|
-
visible: false
|
|
439
|
-
});
|
|
440
|
-
deleteThis();
|
|
441
|
-
}
|
|
341
|
+
setRenaming(true);
|
|
342
|
+
treeContext === null || treeContext === void 0 ? void 0 : treeContext.handleSelect(id);
|
|
442
343
|
}, [
|
|
443
|
-
|
|
444
|
-
|
|
344
|
+
id,
|
|
345
|
+
treeContext
|
|
445
346
|
]);
|
|
446
347
|
// Context menu
|
|
447
|
-
var
|
|
448
|
-
e.preventDefault();
|
|
449
|
-
e.stopPropagation();
|
|
348
|
+
var menuItems = (0, $gTuX4$react.useMemo)(function() {
|
|
450
349
|
var menuItems = [];
|
|
451
350
|
if (canAddChildren) menuItems.push({
|
|
452
351
|
label: "Add",
|
|
@@ -458,138 +357,135 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
458
357
|
});
|
|
459
358
|
if (canRemove && (childNodes === undefined || childNodes.length === 0)) menuItems.push({
|
|
460
359
|
label: "Delete",
|
|
461
|
-
action:
|
|
462
|
-
});
|
|
463
|
-
if (typeof menuContext.set === "function") menuContext.set({
|
|
464
|
-
visible: true,
|
|
465
|
-
y: e.pageY,
|
|
466
|
-
x: e.pageX,
|
|
467
|
-
menuItems: menuItems
|
|
360
|
+
action: deleteThis
|
|
468
361
|
});
|
|
362
|
+
return menuItems;
|
|
469
363
|
}, [
|
|
470
364
|
addChild,
|
|
471
365
|
canAddChildren,
|
|
472
366
|
canRemove,
|
|
473
367
|
canRename,
|
|
474
368
|
childNodes,
|
|
475
|
-
|
|
476
|
-
removeThis,
|
|
369
|
+
deleteThis,
|
|
477
370
|
renameThis
|
|
478
371
|
]);
|
|
479
372
|
// Return node
|
|
480
|
-
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
373
|
+
if (!treeContext) return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactjsxruntime.Fragment), {});
|
|
374
|
+
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$asupcontextmenu.ContextMenuHandler), {
|
|
375
|
+
menuItems: menuItems,
|
|
376
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
|
|
377
|
+
id: "".concat(treeContext.id, "-treenode-").concat(id),
|
|
378
|
+
className: "treenode",
|
|
379
|
+
children: [
|
|
380
|
+
error ? /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)((0, $gTuX4$reactjsxruntime.Fragment), {
|
|
381
|
+
children: [
|
|
382
|
+
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.ExclamationCircleFill), {
|
|
383
|
+
color: "var(--bs-danger)"
|
|
384
|
+
}),
|
|
385
|
+
" ",
|
|
386
|
+
errorText && errorText !== "" ? errorText : "An unknown error has occured"
|
|
387
|
+
]
|
|
388
|
+
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("span", {
|
|
389
|
+
children: [
|
|
390
|
+
childNodes !== undefined && childNodes.length > 0 ? !expanded ? /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretRightFill), {
|
|
391
|
+
id: "".concat(treeContext.id, "-treenode-caret-").concat(id),
|
|
392
|
+
role: "button",
|
|
393
|
+
color: nodeColour,
|
|
394
|
+
"aria-expanded": false,
|
|
395
|
+
onClick: function() {
|
|
396
|
+
return treeContext.handleExpandClick(id);
|
|
397
|
+
}
|
|
398
|
+
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretDownFill), {
|
|
399
|
+
id: "".concat(treeContext.id, "-treenode-caret-").concat(id),
|
|
400
|
+
role: "button",
|
|
401
|
+
"aria-expanded": true,
|
|
402
|
+
color: nodeColour,
|
|
403
|
+
onClick: function() {
|
|
404
|
+
treeContext.handleExpandClick(id);
|
|
405
|
+
}
|
|
406
|
+
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretRight), {
|
|
407
|
+
id: "".concat(treeContext.id, "-treenode-caret-").concat(id),
|
|
408
|
+
role: "button",
|
|
409
|
+
color: nodeColour,
|
|
410
|
+
"aria-expanded": false,
|
|
411
|
+
"aria-disabled": true
|
|
412
|
+
}),
|
|
413
|
+
thisNode && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
414
|
+
style: {
|
|
415
|
+
display: "inline-block"
|
|
416
|
+
},
|
|
417
|
+
onContextMenuCapture: function() {
|
|
418
|
+
return treeContext.handleSelect(id);
|
|
419
|
+
},
|
|
420
|
+
onClickCapture: function() {
|
|
421
|
+
return treeContext.handleSelect(id);
|
|
422
|
+
},
|
|
423
|
+
onFocusCapture: function() {
|
|
424
|
+
return treeContext.handleSelect(id);
|
|
425
|
+
},
|
|
426
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $176d21a51def1fce$export$14f190ac910bde69), {
|
|
427
|
+
id: "".concat(treeContext.id, "-treenode-entry-").concat(id),
|
|
428
|
+
ref: currentNameRef,
|
|
429
|
+
value: thisNode.label,
|
|
430
|
+
editing: renaming,
|
|
431
|
+
saving: updatingNode,
|
|
432
|
+
setValue: function(ret) {
|
|
433
|
+
return renameNode(ret);
|
|
434
|
+
},
|
|
435
|
+
sendEscape: function() {
|
|
436
|
+
return setRenaming(false);
|
|
437
|
+
},
|
|
438
|
+
style: {
|
|
439
|
+
border: currentBorder,
|
|
440
|
+
margin: currentBorder === "" ? "1px" : "",
|
|
441
|
+
backgroundColor: currentBorder === "" ? "" : treeContext.textHighlight
|
|
442
|
+
}
|
|
443
|
+
})
|
|
444
|
+
})
|
|
445
|
+
]
|
|
446
|
+
}),
|
|
447
|
+
childNodes !== undefined && childNodes.map(function(h) {
|
|
448
|
+
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
|
|
449
|
+
id: "".concat(treeContext.id, "-treenode-child-").concat(h.id),
|
|
450
|
+
style: {
|
|
451
|
+
marginLeft: "16px",
|
|
452
|
+
display: "block",
|
|
453
|
+
maxHeight: expanded ? "99999px" : "0px",
|
|
454
|
+
height: expanded ? "auto" : "0px",
|
|
455
|
+
overflowY: "hidden",
|
|
456
|
+
visibility: expanded ? "inherit" : "hidden",
|
|
457
|
+
opacity: expanded ? 1 : 0,
|
|
458
|
+
transition: "visibility .3s, opacity .3s ease-in-out, max-height 0.3s ease-in-out"
|
|
459
|
+
},
|
|
460
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)($a56aac35d4408806$export$2eba8ec3a333fdbb, {
|
|
461
|
+
id: h.id,
|
|
462
|
+
canRemove: canRemoveChildren,
|
|
463
|
+
canRename: canRenameChildren,
|
|
464
|
+
canAddChildren: canAddChildren,
|
|
465
|
+
canRemoveChildren: canRemoveChildren,
|
|
466
|
+
canRenameChildren: canRenameChildren
|
|
467
|
+
})
|
|
468
|
+
}, h.id);
|
|
469
|
+
}),
|
|
470
|
+
showNewNode && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
471
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $176d21a51def1fce$export$14f190ac910bde69), {
|
|
472
|
+
style: {
|
|
473
|
+
marginLeft: "14px"
|
|
474
|
+
},
|
|
475
|
+
id: "treenode-new-".concat(id),
|
|
476
|
+
ref: newNameRef,
|
|
477
|
+
editing: true,
|
|
538
478
|
setValue: function(ret) {
|
|
539
|
-
|
|
479
|
+
confirmNewNode(ret);
|
|
540
480
|
},
|
|
481
|
+
saving: savingNewNode,
|
|
541
482
|
sendEscape: function() {
|
|
542
|
-
|
|
543
|
-
},
|
|
544
|
-
style: {
|
|
545
|
-
border: currentBorder,
|
|
546
|
-
margin: currentBorder === "" ? "1px" : "",
|
|
547
|
-
backgroundColor: currentBorder === "" ? "" : "lightgrey"
|
|
483
|
+
setShowNewNode(false);
|
|
548
484
|
}
|
|
549
485
|
})
|
|
550
|
-
]
|
|
551
|
-
}),
|
|
552
|
-
childNodes !== undefined && childNodes.map(function(h, i) {
|
|
553
|
-
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
|
|
554
|
-
id: "".concat(treeContext.id, "-treenode-child-").concat(h.id),
|
|
555
|
-
style: {
|
|
556
|
-
marginLeft: "16px",
|
|
557
|
-
display: "block",
|
|
558
|
-
maxHeight: expanded ? "99999px" : "0px",
|
|
559
|
-
height: expanded ? "auto" : "0px",
|
|
560
|
-
overflowY: "hidden",
|
|
561
|
-
visibility: expanded ? "inherit" : "hidden",
|
|
562
|
-
opacity: expanded ? 1 : 0,
|
|
563
|
-
transition: "visibility .3s, opacity .3s ease-in-out, max-height 0.3s ease-in-out"
|
|
564
|
-
},
|
|
565
|
-
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)($a56aac35d4408806$export$2eba8ec3a333fdbb, {
|
|
566
|
-
id: h.id,
|
|
567
|
-
canRemove: canRemoveChildren,
|
|
568
|
-
canRename: canRenameChildren,
|
|
569
|
-
canAddChildren: canAddChildren,
|
|
570
|
-
canRemoveChildren: canRemoveChildren,
|
|
571
|
-
canRenameChildren: canRenameChildren
|
|
572
|
-
})
|
|
573
|
-
}, h.id);
|
|
574
|
-
}),
|
|
575
|
-
showNewNode && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
576
|
-
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $176d21a51def1fce$export$14f190ac910bde69), {
|
|
577
|
-
style: {
|
|
578
|
-
marginLeft: "14px"
|
|
579
|
-
},
|
|
580
|
-
id: "treenode-new-".concat(id),
|
|
581
|
-
ref: newNameRef,
|
|
582
|
-
editing: true,
|
|
583
|
-
setValue: function(ret) {
|
|
584
|
-
confirmNewNode(ret);
|
|
585
|
-
},
|
|
586
|
-
saving: savingNewNode,
|
|
587
|
-
sendEscape: function() {
|
|
588
|
-
setShowNewNode(false);
|
|
589
|
-
}
|
|
590
486
|
})
|
|
591
|
-
|
|
592
|
-
|
|
487
|
+
]
|
|
488
|
+
})
|
|
593
489
|
});
|
|
594
490
|
};
|
|
595
491
|
|
|
@@ -600,51 +496,39 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
600
496
|
|
|
601
497
|
|
|
602
498
|
|
|
603
|
-
var $a983ffa23085f8d6$export$85488b7eb1e4976f = function(id, included, hierarchyNodes) {
|
|
604
|
-
// Get current node
|
|
605
|
-
var current = hierarchyNodes.find(function(h) {
|
|
606
|
-
return h.id === id;
|
|
607
|
-
});
|
|
608
|
-
if (current === undefined) return [];
|
|
609
|
-
// Set return as children, current node or parent's return
|
|
610
|
-
var ret = current.parentId === undefined || current.parentId === null || hierarchyNodes.findIndex(function(h) {
|
|
611
|
-
return h.id === (current === null || current === void 0 ? void 0 : current.parentId);
|
|
612
|
-
}) === -1 ? (0, ($parcel$interopDefault($gTuX4$swchelperslib_to_consumable_arrayjs)))(included).concat([
|
|
613
|
-
current
|
|
614
|
-
]) : $a983ffa23085f8d6$export$85488b7eb1e4976f(current.parentId, (0, ($parcel$interopDefault($gTuX4$swchelperslib_to_consumable_arrayjs)))(included.filter(function(c) {
|
|
615
|
-
return c.id !== current.parentId && c.id !== current.id;
|
|
616
|
-
})).concat([
|
|
617
|
-
current
|
|
618
|
-
]), hierarchyNodes);
|
|
619
|
-
return ret;
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
|
|
623
499
|
var $f31429c9cc6d3bce$export$40c47a7ac5f85aba = function(nodeList, selectedId, expandedNodes) {
|
|
624
|
-
|
|
500
|
+
return (0, ($parcel$interopDefault($gTuX4$swchelperslib_to_consumable_arrayjs)))(expandedNodes).concat((0, ($parcel$interopDefault($gTuX4$swchelperslib_to_consumable_arrayjs)))((0, $580f9b3e262282c9$export$c6fd3ab3f44300d0)(selectedId, [], nodeList).map(function(n) {
|
|
625
501
|
return n.id;
|
|
626
502
|
}).filter(function(k) {
|
|
627
503
|
return !expandedNodes.includes(k);
|
|
628
504
|
}))).sort(function(a, b) {
|
|
629
505
|
return "".concat(a).localeCompare("".concat(b));
|
|
630
506
|
});
|
|
631
|
-
return k;
|
|
632
507
|
};
|
|
633
508
|
|
|
634
509
|
|
|
635
510
|
|
|
636
511
|
|
|
637
|
-
|
|
638
512
|
var $9becaaec3a803ae7$export$5580fff3e08a8be5 = function(param) {
|
|
639
513
|
var id = param.id, nodeList = param.nodeList, roots = param.roots, _param_canRemoveRoot = param.// canAddRoot = false,
|
|
640
514
|
canRemoveRoot, canRemoveRoot = _param_canRemoveRoot === void 0 ? false : _param_canRemoveRoot, _param_canRenameRoot = param.canRenameRoot, canRenameRoot = _param_canRenameRoot === void 0 ? false : _param_canRenameRoot, _param_canAddChildren = param.canAddChildren, canAddChildren = _param_canAddChildren === void 0 ? false : _param_canAddChildren, _param_canRemoveChildren = param.canRemoveChildren, canRemoveChildren = _param_canRemoveChildren === void 0 ? false : _param_canRemoveChildren, _param_canRenameChildren = param.canRenameChildren, canRenameChildren = _param_canRenameChildren === void 0 ? false : _param_canRenameChildren, selectedId = param.selectedId, _param_handleSelect = param.handleSelect, handleSelect = _param_handleSelect === void 0 ? function() {
|
|
641
515
|
return;
|
|
642
|
-
} : _param_handleSelect, onAdd = param.onAdd, onRename = param.onRename, onRemove = param.onRemove;
|
|
516
|
+
} : _param_handleSelect, onAdd = param.onAdd, onRename = param.onRename, onRemove = param.onRemove, _param_nodeHighlight = param.nodeHighlight, nodeHighlight = _param_nodeHighlight === void 0 ? "red" : _param_nodeHighlight, _param_textHighlight = param.textHighlight, textHighlight = _param_textHighlight === void 0 ? "rgba(255, 0, 0, 0.2)" : _param_textHighlight;
|
|
643
517
|
var _useState = (0, ($parcel$interopDefault($gTuX4$swchelperslib_sliced_to_arrayjs)))((0, $gTuX4$react.useState)([]), 2), expandedNodes = _useState[0], setExpandedNodes = _useState[1];
|
|
644
518
|
(0, $gTuX4$react.useEffect)(function() {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
519
|
+
if (selectedId) {
|
|
520
|
+
// Check all nodes are showing that should be
|
|
521
|
+
var shouldExpand = (0, $f31429c9cc6d3bce$export$40c47a7ac5f85aba)(nodeList, selectedId, expandedNodes);
|
|
522
|
+
shouldExpand.filter(function(n) {
|
|
523
|
+
return !expandedNodes.includes(n);
|
|
524
|
+
}).length > 0 && setExpandedNodes(shouldExpand);
|
|
525
|
+
}
|
|
526
|
+
}, [
|
|
527
|
+
expandedNodes,
|
|
528
|
+
nodeList,
|
|
529
|
+
selectedId
|
|
530
|
+
]);
|
|
531
|
+
// Change expansion and update contexts
|
|
648
532
|
var changeExpand = (0, $gTuX4$react.useCallback)(function(eKey, force) {
|
|
649
533
|
var newExpandedNodes = (0, ($parcel$interopDefault($gTuX4$swchelperslib_to_consumable_arrayjs)))(expandedNodes);
|
|
650
534
|
var ix = newExpandedNodes.findIndex(function(nKey) {
|
|
@@ -656,31 +540,31 @@ var $9becaaec3a803ae7$export$5580fff3e08a8be5 = function(param) {
|
|
|
656
540
|
}, [
|
|
657
541
|
expandedNodes
|
|
658
542
|
]);
|
|
659
|
-
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
return changeExpand(r, f);
|
|
669
|
-
},
|
|
670
|
-
onAddChild: onAdd,
|
|
671
|
-
onRename: onRename,
|
|
672
|
-
onRemove: onRemove
|
|
543
|
+
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $ff9cca1fe8f6b24e$export$29ec378200e05207).Provider, {
|
|
544
|
+
value: {
|
|
545
|
+
id: id,
|
|
546
|
+
nodeList: nodeList,
|
|
547
|
+
selectedId: selectedId,
|
|
548
|
+
handleSelect: handleSelect,
|
|
549
|
+
expandedNodes: expandedNodes,
|
|
550
|
+
handleExpandClick: function(r, f) {
|
|
551
|
+
return changeExpand(r, f);
|
|
673
552
|
},
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
553
|
+
onAddChild: onAdd,
|
|
554
|
+
onRename: onRename,
|
|
555
|
+
onRemove: onRemove,
|
|
556
|
+
nodeHighlight: nodeHighlight,
|
|
557
|
+
textHighlight: textHighlight
|
|
558
|
+
},
|
|
559
|
+
children: roots.map(function(r) {
|
|
560
|
+
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $a56aac35d4408806$export$2eba8ec3a333fdbb), {
|
|
561
|
+
id: r,
|
|
562
|
+
canRemove: canRemoveRoot,
|
|
563
|
+
canAddChildren: canAddChildren,
|
|
564
|
+
canRename: canRenameRoot,
|
|
565
|
+
canRemoveChildren: canRemoveChildren,
|
|
566
|
+
canRenameChildren: canRenameChildren
|
|
567
|
+
}, r);
|
|
684
568
|
})
|
|
685
569
|
});
|
|
686
570
|
};
|
|
@@ -691,7 +575,7 @@ var $9becaaec3a803ae7$export$5580fff3e08a8be5 = function(param) {
|
|
|
691
575
|
|
|
692
576
|
var $f8937e88ee74204e$exports = {};
|
|
693
577
|
|
|
694
|
-
$parcel$export($f8937e88ee74204e$exports, "getParents", function () { return $
|
|
578
|
+
$parcel$export($f8937e88ee74204e$exports, "getParents", function () { return $580f9b3e262282c9$export$c6fd3ab3f44300d0; });
|
|
695
579
|
|
|
696
580
|
|
|
697
581
|
|