@asup/tree-of-nodes 1.0.3 → 1.0.5
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 +167 -311
- package/dist/cjs/main.js.map +1 -1
- package/dist/main.js +157 -286
- package/dist/main.js.map +1 -1
- package/dist/tree-of-nodes.d.ts +0 -27
- package/dist/tree-of-nodes.d.ts.map +1 -1
- package/package.json +5 -1
package/dist/cjs/main.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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
8
|
var $gTuX4$swchelperslib_object_spreadjs = require("@swc/helpers/lib/_object_spread.js");
|
|
9
|
+
var $gTuX4$reactbootstrap = require("react-bootstrap");
|
|
10
10
|
var $gTuX4$swchelperslib_to_consumable_arrayjs = require("@swc/helpers/lib/_to_consumable_array.js");
|
|
11
11
|
|
|
12
12
|
function $parcel$exportWildcard(dest, source) {
|
|
@@ -33,118 +33,18 @@ 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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var $bad272ba85e71af5$export$c7e742effb1c51e2 = /*#__PURE__*/ (0, ($parcel$interopDefault($gTuX4$react))).createContext({});
|
|
73
|
-
var $bad272ba85e71af5$export$434a17f82a8154e4 = function(param) {
|
|
74
|
-
var children = param.children;
|
|
75
|
-
// Menu resources
|
|
76
|
-
var divRef = (0, $gTuX4$react.useRef)(null);
|
|
77
|
-
var menuRef = (0, $gTuX4$react.useRef)(null);
|
|
78
|
-
var _useState = (0, ($parcel$interopDefault($gTuX4$swchelperslib_sliced_to_arrayjs)))((0, $gTuX4$react.useState)(0), 2), menuXPos = _useState[0], setMenuXPos = _useState[1];
|
|
79
|
-
var _useState1 = (0, ($parcel$interopDefault($gTuX4$swchelperslib_sliced_to_arrayjs)))((0, $gTuX4$react.useState)(0), 2), menuYPos = _useState1[0], setMenuYPos = _useState1[1];
|
|
80
|
-
var _useState2 = (0, ($parcel$interopDefault($gTuX4$swchelperslib_sliced_to_arrayjs)))((0, $gTuX4$react.useState)(false), 2), menuVisible = _useState2[0], setMenuVisible = _useState2[1];
|
|
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
|
-
})
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
42
|
|
|
137
43
|
|
|
138
44
|
|
|
139
45
|
|
|
140
46
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
var $ff9cca1fe8f6b24e$export$29ec378200e05207 = (0, $gTuX4$react.createContext)({
|
|
145
|
-
id: "tree-of-nodes",
|
|
146
|
-
nodeList: []
|
|
147
|
-
});
|
|
47
|
+
var $ff9cca1fe8f6b24e$export$29ec378200e05207 = (0, $gTuX4$react.createContext)(undefined);
|
|
148
48
|
|
|
149
49
|
|
|
150
50
|
|
|
@@ -231,51 +131,41 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
231
131
|
var id = param.id, canRemove = param.canRemove, canRename = param.canRename, canAddChildren = param.canAddChildren, canRemoveChildren = param.canRemoveChildren, canRenameChildren = param.canRenameChildren;
|
|
232
132
|
// Contexts
|
|
233
133
|
var treeContext = (0, $gTuX4$react.useContext)((0, $ff9cca1fe8f6b24e$export$29ec378200e05207));
|
|
234
|
-
var menuContext = (0, $gTuX4$react.useContext)((0, $bad272ba85e71af5$export$c7e742effb1c51e2));
|
|
235
134
|
// Node information
|
|
236
135
|
var thisNode = (0, $gTuX4$react.useMemo)(function() {
|
|
237
|
-
return treeContext.nodeList.find(function(n) {
|
|
136
|
+
return treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList.find(function(n) {
|
|
238
137
|
return n.id === id;
|
|
239
138
|
});
|
|
240
139
|
}, [
|
|
241
140
|
id,
|
|
242
|
-
treeContext.nodeList
|
|
141
|
+
treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList
|
|
243
142
|
]);
|
|
244
143
|
var childNodes = (0, $gTuX4$react.useMemo)(function() {
|
|
245
|
-
return treeContext.nodeList.filter(function(n) {
|
|
144
|
+
return treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList.filter(function(n) {
|
|
246
145
|
return n.parentId === id;
|
|
247
146
|
});
|
|
248
147
|
}, [
|
|
249
148
|
id,
|
|
250
|
-
treeContext.nodeList
|
|
149
|
+
treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList
|
|
251
150
|
]);
|
|
252
151
|
// 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
152
|
var _useState = (0, ($parcel$interopDefault($gTuX4$swchelperslib_sliced_to_arrayjs)))((0, $gTuX4$react.useState)(false), 2), error = _useState[0], setError = _useState[1];
|
|
262
153
|
var _useState1 = (0, ($parcel$interopDefault($gTuX4$swchelperslib_sliced_to_arrayjs)))((0, $gTuX4$react.useState)(null), 2), errorText = _useState1[0], setErrotText = _useState1[1];
|
|
263
154
|
var expanded = (0, $gTuX4$react.useMemo)(function() {
|
|
264
|
-
var _treeContext_expandedNodes;
|
|
265
155
|
var _treeContext_expandedNodes_findIndex;
|
|
266
|
-
return ((_treeContext_expandedNodes_findIndex =
|
|
156
|
+
return ((_treeContext_expandedNodes_findIndex = treeContext === null || treeContext === void 0 ? void 0 : treeContext.expandedNodes.findIndex(function(e) {
|
|
267
157
|
return e === id;
|
|
268
158
|
})) !== null && _treeContext_expandedNodes_findIndex !== void 0 ? _treeContext_expandedNodes_findIndex : -1) > -1;
|
|
269
159
|
}, [
|
|
270
160
|
id,
|
|
271
|
-
treeContext.expandedNodes
|
|
161
|
+
treeContext === null || treeContext === void 0 ? void 0 : treeContext.expandedNodes
|
|
272
162
|
]);
|
|
273
163
|
// // Apply selected borer
|
|
274
164
|
var currentBorder = (0, $gTuX4$react.useMemo)(function() {
|
|
275
|
-
return id === treeContext.selectedId ? "1px solid black" : "";
|
|
165
|
+
return id === (treeContext === null || treeContext === void 0 ? void 0 : treeContext.selectedId) ? "1px solid black" : "";
|
|
276
166
|
}, [
|
|
277
167
|
id,
|
|
278
|
-
treeContext.selectedId
|
|
168
|
+
treeContext === null || treeContext === void 0 ? void 0 : treeContext.selectedId
|
|
279
169
|
]);
|
|
280
170
|
// New node parameters
|
|
281
171
|
var newNameRef = (0, $gTuX4$react.useRef)(null);
|
|
@@ -302,7 +192,7 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
302
192
|
switch(_state.label){
|
|
303
193
|
case 0:
|
|
304
194
|
setSavingNewNode(true);
|
|
305
|
-
if (!treeContext.onAddChild) return [
|
|
195
|
+
if (!(treeContext === null || treeContext === void 0 ? void 0 : treeContext.onAddChild)) return [
|
|
306
196
|
3,
|
|
307
197
|
2
|
|
308
198
|
];
|
|
@@ -338,11 +228,11 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
338
228
|
switch(_state.label){
|
|
339
229
|
case 0:
|
|
340
230
|
setRenaming(false);
|
|
341
|
-
|
|
342
|
-
if (!treeContext.onRename) return [
|
|
231
|
+
if (!(treeContext === null || treeContext === void 0 ? void 0 : treeContext.onRename)) return [
|
|
343
232
|
3,
|
|
344
233
|
2
|
|
345
234
|
];
|
|
235
|
+
setUpdatingNode(true);
|
|
346
236
|
return [
|
|
347
237
|
4,
|
|
348
238
|
treeContext.onRename(id, newLabel)
|
|
@@ -351,9 +241,9 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
351
241
|
handleReturn.apply(void 0, [
|
|
352
242
|
_state.sent()
|
|
353
243
|
]);
|
|
244
|
+
setUpdatingNode(false);
|
|
354
245
|
_state.label = 2;
|
|
355
246
|
case 2:
|
|
356
|
-
setUpdatingNode(false);
|
|
357
247
|
return [
|
|
358
248
|
2
|
|
359
249
|
];
|
|
@@ -372,11 +262,11 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
372
262
|
return (0, ($parcel$interopDefault($gTuX4$swchelperslib_ts_generatorjs)))(this, function(_state) {
|
|
373
263
|
switch(_state.label){
|
|
374
264
|
case 0:
|
|
375
|
-
|
|
376
|
-
if (!treeContext.onRemove) return [
|
|
265
|
+
if (!(treeContext === null || treeContext === void 0 ? void 0 : treeContext.onRemove)) return [
|
|
377
266
|
3,
|
|
378
267
|
2
|
|
379
268
|
];
|
|
269
|
+
setUpdatingNode(true);
|
|
380
270
|
return [
|
|
381
271
|
4,
|
|
382
272
|
treeContext.onRemove(id)
|
|
@@ -385,9 +275,9 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
385
275
|
handleReturn.apply(void 0, [
|
|
386
276
|
_state.sent()
|
|
387
277
|
]);
|
|
278
|
+
setUpdatingNode(false);
|
|
388
279
|
_state.label = 2;
|
|
389
280
|
case 2:
|
|
390
|
-
setUpdatingNode(false);
|
|
391
281
|
return [
|
|
392
282
|
2
|
|
393
283
|
];
|
|
@@ -400,16 +290,10 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
400
290
|
]);
|
|
401
291
|
// Context actions
|
|
402
292
|
var addChild = (0, $gTuX4$react.useCallback)(function() {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
visible: false
|
|
406
|
-
});
|
|
407
|
-
setShowNewNode(true);
|
|
408
|
-
treeContext.handleExpandClick && treeContext.handleExpandClick(id, true);
|
|
409
|
-
}
|
|
293
|
+
setShowNewNode(true);
|
|
294
|
+
treeContext && treeContext.handleExpandClick(id, true);
|
|
410
295
|
}, [
|
|
411
296
|
id,
|
|
412
|
-
menuContext,
|
|
413
297
|
treeContext
|
|
414
298
|
]);
|
|
415
299
|
(0, $gTuX4$react.useEffect)(function() {
|
|
@@ -418,35 +302,14 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
418
302
|
showNewNode
|
|
419
303
|
]);
|
|
420
304
|
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
|
-
}
|
|
305
|
+
setRenaming(true);
|
|
306
|
+
treeContext === null || treeContext === void 0 ? void 0 : treeContext.handleSelect(id);
|
|
442
307
|
}, [
|
|
443
|
-
|
|
444
|
-
|
|
308
|
+
id,
|
|
309
|
+
treeContext
|
|
445
310
|
]);
|
|
446
311
|
// Context menu
|
|
447
|
-
var
|
|
448
|
-
e.preventDefault();
|
|
449
|
-
e.stopPropagation();
|
|
312
|
+
var menuItems = (0, $gTuX4$react.useMemo)(function() {
|
|
450
313
|
var menuItems = [];
|
|
451
314
|
if (canAddChildren) menuItems.push({
|
|
452
315
|
label: "Add",
|
|
@@ -458,138 +321,126 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
458
321
|
});
|
|
459
322
|
if (canRemove && (childNodes === undefined || childNodes.length === 0)) menuItems.push({
|
|
460
323
|
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
|
|
324
|
+
action: deleteThis
|
|
468
325
|
});
|
|
326
|
+
return menuItems;
|
|
469
327
|
}, [
|
|
470
328
|
addChild,
|
|
471
329
|
canAddChildren,
|
|
472
330
|
canRemove,
|
|
473
331
|
canRename,
|
|
474
332
|
childNodes,
|
|
475
|
-
|
|
476
|
-
removeThis,
|
|
333
|
+
deleteThis,
|
|
477
334
|
renameThis
|
|
478
335
|
]);
|
|
479
336
|
// 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
|
-
|
|
337
|
+
if (!treeContext) return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactjsxruntime.Fragment), {});
|
|
338
|
+
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$asupcontextmenu.ContextMenuHandler), {
|
|
339
|
+
menuItems: menuItems,
|
|
340
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
|
|
341
|
+
id: "".concat(treeContext.id, "-treenode-").concat(id),
|
|
342
|
+
className: "treenode",
|
|
343
|
+
onClickCapture: function() {
|
|
344
|
+
return treeContext.handleSelect(id);
|
|
345
|
+
},
|
|
346
|
+
onContextMenuCapture: function() {
|
|
347
|
+
return treeContext.handleSelect(id);
|
|
348
|
+
},
|
|
349
|
+
onFocusCapture: function() {
|
|
350
|
+
return treeContext.handleSelect(id);
|
|
351
|
+
},
|
|
352
|
+
children: [
|
|
353
|
+
error ? /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)((0, $gTuX4$reactjsxruntime.Fragment), {
|
|
354
|
+
children: [
|
|
355
|
+
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.ExclamationCircleFill), {
|
|
356
|
+
color: "var(--bs-danger)"
|
|
357
|
+
}),
|
|
358
|
+
" ",
|
|
359
|
+
errorText && errorText !== "" ? errorText : "An unknown error has occured"
|
|
360
|
+
]
|
|
361
|
+
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("span", {
|
|
362
|
+
children: [
|
|
363
|
+
childNodes !== undefined && childNodes.length > 0 ? !expanded ? /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretRightFill), {
|
|
364
|
+
role: "button",
|
|
365
|
+
"aria-expanded": false,
|
|
366
|
+
id: "".concat(treeContext.id, "-treenode-caret-").concat(id),
|
|
367
|
+
onClick: function() {
|
|
368
|
+
return treeContext.handleExpandClick(id);
|
|
369
|
+
}
|
|
370
|
+
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretDownFill), {
|
|
371
|
+
role: "button",
|
|
372
|
+
"aria-expanded": true,
|
|
373
|
+
id: "".concat(treeContext.id, "-treenode-caret-").concat(id),
|
|
374
|
+
onClick: function() {
|
|
375
|
+
return treeContext.handleExpandClick(id);
|
|
376
|
+
}
|
|
377
|
+
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretRight), {
|
|
378
|
+
role: "button",
|
|
379
|
+
"aria-expanded": false,
|
|
380
|
+
"aria-disabled": true
|
|
381
|
+
}),
|
|
382
|
+
thisNode && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $176d21a51def1fce$export$14f190ac910bde69), {
|
|
383
|
+
id: "".concat(treeContext.id, "-treenode-entry-").concat(id),
|
|
384
|
+
ref: currentNameRef,
|
|
385
|
+
value: thisNode.label,
|
|
386
|
+
editing: renaming,
|
|
387
|
+
saving: updatingNode,
|
|
388
|
+
setValue: function(ret) {
|
|
389
|
+
return renameNode(ret);
|
|
390
|
+
},
|
|
391
|
+
sendEscape: function() {
|
|
392
|
+
return setRenaming(false);
|
|
393
|
+
},
|
|
394
|
+
style: {
|
|
395
|
+
border: currentBorder,
|
|
396
|
+
margin: currentBorder === "" ? "1px" : "",
|
|
397
|
+
backgroundColor: currentBorder === "" ? "" : "lightgrey"
|
|
398
|
+
}
|
|
399
|
+
})
|
|
400
|
+
]
|
|
401
|
+
}),
|
|
402
|
+
childNodes !== undefined && childNodes.map(function(h) {
|
|
403
|
+
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
|
|
404
|
+
id: "".concat(treeContext.id, "-treenode-child-").concat(h.id),
|
|
405
|
+
style: {
|
|
406
|
+
marginLeft: "16px",
|
|
407
|
+
display: "block",
|
|
408
|
+
maxHeight: expanded ? "99999px" : "0px",
|
|
409
|
+
height: expanded ? "auto" : "0px",
|
|
410
|
+
overflowY: "hidden",
|
|
411
|
+
visibility: expanded ? "inherit" : "hidden",
|
|
412
|
+
opacity: expanded ? 1 : 0,
|
|
413
|
+
transition: "visibility .3s, opacity .3s ease-in-out, max-height 0.3s ease-in-out"
|
|
414
|
+
},
|
|
415
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)($a56aac35d4408806$export$2eba8ec3a333fdbb, {
|
|
416
|
+
id: h.id,
|
|
417
|
+
canRemove: canRemoveChildren,
|
|
418
|
+
canRename: canRenameChildren,
|
|
419
|
+
canAddChildren: canAddChildren,
|
|
420
|
+
canRemoveChildren: canRemoveChildren,
|
|
421
|
+
canRenameChildren: canRenameChildren
|
|
422
|
+
})
|
|
423
|
+
}, h.id);
|
|
424
|
+
}),
|
|
425
|
+
showNewNode && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
426
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $176d21a51def1fce$export$14f190ac910bde69), {
|
|
427
|
+
style: {
|
|
428
|
+
marginLeft: "14px"
|
|
429
|
+
},
|
|
430
|
+
id: "treenode-new-".concat(id),
|
|
431
|
+
ref: newNameRef,
|
|
432
|
+
editing: true,
|
|
538
433
|
setValue: function(ret) {
|
|
539
|
-
|
|
434
|
+
confirmNewNode(ret);
|
|
540
435
|
},
|
|
436
|
+
saving: savingNewNode,
|
|
541
437
|
sendEscape: function() {
|
|
542
|
-
|
|
543
|
-
},
|
|
544
|
-
style: {
|
|
545
|
-
border: currentBorder,
|
|
546
|
-
margin: currentBorder === "" ? "1px" : "",
|
|
547
|
-
backgroundColor: currentBorder === "" ? "" : "lightgrey"
|
|
438
|
+
setShowNewNode(false);
|
|
548
439
|
}
|
|
549
440
|
})
|
|
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
441
|
})
|
|
591
|
-
|
|
592
|
-
|
|
442
|
+
]
|
|
443
|
+
})
|
|
593
444
|
});
|
|
594
445
|
};
|
|
595
446
|
|
|
@@ -621,21 +472,18 @@ var $a983ffa23085f8d6$export$85488b7eb1e4976f = function(id, included, hierarchy
|
|
|
621
472
|
|
|
622
473
|
|
|
623
474
|
var $f31429c9cc6d3bce$export$40c47a7ac5f85aba = function(nodeList, selectedId, expandedNodes) {
|
|
624
|
-
|
|
475
|
+
return (0, ($parcel$interopDefault($gTuX4$swchelperslib_to_consumable_arrayjs)))(expandedNodes).concat((0, ($parcel$interopDefault($gTuX4$swchelperslib_to_consumable_arrayjs)))((0, $a983ffa23085f8d6$export$85488b7eb1e4976f)(selectedId, [], nodeList).map(function(n) {
|
|
625
476
|
return n.id;
|
|
626
477
|
}).filter(function(k) {
|
|
627
478
|
return !expandedNodes.includes(k);
|
|
628
479
|
}))).sort(function(a, b) {
|
|
629
480
|
return "".concat(a).localeCompare("".concat(b));
|
|
630
481
|
});
|
|
631
|
-
console.log("checkExpandedNodes: ".concat(k.join(",")));
|
|
632
|
-
return k;
|
|
633
482
|
};
|
|
634
483
|
|
|
635
484
|
|
|
636
485
|
|
|
637
486
|
|
|
638
|
-
|
|
639
487
|
var $9becaaec3a803ae7$export$5580fff3e08a8be5 = function(param) {
|
|
640
488
|
var id = param.id, nodeList = param.nodeList, roots = param.roots, _param_canRemoveRoot = param.// canAddRoot = false,
|
|
641
489
|
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() {
|
|
@@ -643,8 +491,18 @@ var $9becaaec3a803ae7$export$5580fff3e08a8be5 = function(param) {
|
|
|
643
491
|
} : _param_handleSelect, onAdd = param.onAdd, onRename = param.onRename, onRemove = param.onRemove;
|
|
644
492
|
var _useState = (0, ($parcel$interopDefault($gTuX4$swchelperslib_sliced_to_arrayjs)))((0, $gTuX4$react.useState)([]), 2), expandedNodes = _useState[0], setExpandedNodes = _useState[1];
|
|
645
493
|
(0, $gTuX4$react.useEffect)(function() {
|
|
646
|
-
|
|
647
|
-
|
|
494
|
+
if (selectedId) {
|
|
495
|
+
// Check all nodes are showing that should be
|
|
496
|
+
var shouldExpand = (0, $f31429c9cc6d3bce$export$40c47a7ac5f85aba)(nodeList, selectedId, expandedNodes);
|
|
497
|
+
shouldExpand.filter(function(n) {
|
|
498
|
+
return !expandedNodes.includes(n);
|
|
499
|
+
}).length > 0 && setExpandedNodes(shouldExpand);
|
|
500
|
+
}
|
|
501
|
+
}, [
|
|
502
|
+
expandedNodes,
|
|
503
|
+
nodeList,
|
|
504
|
+
selectedId
|
|
505
|
+
]);
|
|
648
506
|
// Change expansion and update context
|
|
649
507
|
var changeExpand = (0, $gTuX4$react.useCallback)(function(eKey, force) {
|
|
650
508
|
var newExpandedNodes = (0, ($parcel$interopDefault($gTuX4$swchelperslib_to_consumable_arrayjs)))(expandedNodes);
|
|
@@ -657,31 +515,29 @@ var $9becaaec3a803ae7$export$5580fff3e08a8be5 = function(param) {
|
|
|
657
515
|
}, [
|
|
658
516
|
expandedNodes
|
|
659
517
|
]);
|
|
660
|
-
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
return changeExpand(r, f);
|
|
670
|
-
},
|
|
671
|
-
onAddChild: onAdd,
|
|
672
|
-
onRename: onRename,
|
|
673
|
-
onRemove: onRemove
|
|
518
|
+
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $ff9cca1fe8f6b24e$export$29ec378200e05207).Provider, {
|
|
519
|
+
value: {
|
|
520
|
+
id: id,
|
|
521
|
+
nodeList: nodeList,
|
|
522
|
+
selectedId: selectedId,
|
|
523
|
+
handleSelect: handleSelect,
|
|
524
|
+
expandedNodes: expandedNodes,
|
|
525
|
+
handleExpandClick: function(r, f) {
|
|
526
|
+
return changeExpand(r, f);
|
|
674
527
|
},
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
528
|
+
onAddChild: onAdd,
|
|
529
|
+
onRename: onRename,
|
|
530
|
+
onRemove: onRemove
|
|
531
|
+
},
|
|
532
|
+
children: roots.map(function(r) {
|
|
533
|
+
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $a56aac35d4408806$export$2eba8ec3a333fdbb), {
|
|
534
|
+
id: r,
|
|
535
|
+
canRemove: canRemoveRoot,
|
|
536
|
+
canAddChildren: canAddChildren,
|
|
537
|
+
canRename: canRenameRoot,
|
|
538
|
+
canRemoveChildren: canRemoveChildren,
|
|
539
|
+
canRenameChildren: canRenameChildren
|
|
540
|
+
}, r);
|
|
685
541
|
})
|
|
686
542
|
});
|
|
687
543
|
};
|