@asup/tree-of-nodes 2.0.4 → 2.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.css +64 -9
- package/dist/cjs/main.css.map +1 -1
- package/dist/cjs/main.js +195 -167
- package/dist/cjs/main.js.map +1 -1
- package/dist/main.css +64 -9
- package/dist/main.css.map +1 -1
- package/dist/main.js +197 -169
- package/dist/main.js.map +1 -1
- package/dist/tree-of-nodes.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import "./main.css";
|
|
2
|
-
import {
|
|
2
|
+
import {jsxs as $duWW8$jsxs, Fragment as $duWW8$Fragment, jsx as $duWW8$jsx} from "react/jsx-runtime";
|
|
3
3
|
import {ContextMenuHandler as $duWW8$ContextMenuHandler} from "@asup/context-menu";
|
|
4
|
-
import $duWW8$react, {useContext as $duWW8$useContext, useMemo as $duWW8$useMemo, useState as $duWW8$useState,
|
|
4
|
+
import $duWW8$react, {useContext as $duWW8$useContext, useMemo as $duWW8$useMemo, useState as $duWW8$useState, useEffect as $duWW8$useEffect, useRef as $duWW8$useRef, useCallback as $duWW8$useCallback, createContext as $duWW8$createContext} from "react";
|
|
5
5
|
import {ExclamationCircleFill as $duWW8$ExclamationCircleFill, CaretRightFill as $duWW8$CaretRightFill, CaretDownFill as $duWW8$CaretDownFill, CaretRight as $duWW8$CaretRight} from "react-bootstrap-icons";
|
|
6
|
-
import {_ as $duWW8$_} from "@swc/helpers/_/_object_spread";
|
|
7
6
|
import {Spinner as $duWW8$Spinner} from "react-bootstrap";
|
|
8
7
|
|
|
9
8
|
|
|
@@ -54,21 +53,7 @@ const $886f402bccb0fd30$export$29ec378200e05207 = (0, $duWW8$createContext)(unde
|
|
|
54
53
|
|
|
55
54
|
|
|
56
55
|
|
|
57
|
-
|
|
58
56
|
const $84765747a8c6bfe2$export$14f190ac910bde69 = /*#__PURE__*/ (0, $duWW8$react).forwardRef(({ id: id, value: value, editing: editing, saving: saving, setValue: setValue, sendEscape: sendEscape, style: style, spellCheck: spellCheck = "true" }, ref)=>{
|
|
59
|
-
$84765747a8c6bfe2$export$14f190ac910bde69.displayName = "WordEntry";
|
|
60
|
-
const currentStyle = (0, $duWW8$useMemo)(()=>{
|
|
61
|
-
return (0, $duWW8$_)({
|
|
62
|
-
display: "inline-block",
|
|
63
|
-
padding: "1px",
|
|
64
|
-
paddingLeft: "3px",
|
|
65
|
-
paddingRight: "3px",
|
|
66
|
-
border: "1px",
|
|
67
|
-
borderRadius: "3px"
|
|
68
|
-
}, style);
|
|
69
|
-
}, [
|
|
70
|
-
style
|
|
71
|
-
]);
|
|
72
57
|
const [currentValue, setCurrentValue] = (0, $duWW8$useState)(value !== null && value !== void 0 ? value : "");
|
|
73
58
|
(0, $duWW8$useEffect)(()=>{
|
|
74
59
|
setCurrentValue(value !== null && value !== void 0 ? value : "");
|
|
@@ -91,17 +76,36 @@ const $84765747a8c6bfe2$export$14f190ac910bde69 = /*#__PURE__*/ (0, $duWW8$react
|
|
|
91
76
|
sendEscape,
|
|
92
77
|
value
|
|
93
78
|
]);
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
79
|
+
// Add window onMouseDown event to stop events when editing
|
|
80
|
+
(0, $duWW8$useEffect)(()=>{
|
|
81
|
+
const handleMouseDown = (e)=>{
|
|
82
|
+
const target = e.target;
|
|
83
|
+
if (editing && target.id !== `${id}` && target.id !== `${id}-holder` && target.id !== `${id}-spinner` && target.className !== "ton-rename") {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
returnData();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
window.addEventListener("mousedown", handleMouseDown);
|
|
90
|
+
return ()=>{
|
|
91
|
+
window.removeEventListener("mousedown", handleMouseDown);
|
|
92
|
+
};
|
|
93
|
+
}, [
|
|
94
|
+
editing,
|
|
95
|
+
id,
|
|
96
|
+
returnData
|
|
97
|
+
]);
|
|
98
|
+
return !editing ? /*#__PURE__*/ (0, $duWW8$jsx)("span", {
|
|
99
|
+
className: "ton-label-span",
|
|
100
|
+
style: style,
|
|
97
101
|
id: `${id}`,
|
|
98
102
|
children: value ? value : /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$Fragment), {
|
|
99
103
|
children: "\xa0"
|
|
100
104
|
})
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
style: currentStyle,
|
|
105
|
+
}) : /*#__PURE__*/ (0, $duWW8$jsxs)("div", {
|
|
106
|
+
style: style,
|
|
104
107
|
id: `${id}-holder`,
|
|
108
|
+
className: "ton-rename-holder",
|
|
105
109
|
children: [
|
|
106
110
|
saving && /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$Spinner), {
|
|
107
111
|
id: `${id}-spinner`,
|
|
@@ -114,12 +118,7 @@ const $84765747a8c6bfe2$export$14f190ac910bde69 = /*#__PURE__*/ (0, $duWW8$react
|
|
|
114
118
|
id: String(id),
|
|
115
119
|
ref: ref,
|
|
116
120
|
type: "text",
|
|
117
|
-
|
|
118
|
-
lineHeight: "0.75rem",
|
|
119
|
-
border: "1px dotted black",
|
|
120
|
-
width: "auto",
|
|
121
|
-
minWidth: "0"
|
|
122
|
-
},
|
|
121
|
+
className: "ton-rename",
|
|
123
122
|
value: currentValue,
|
|
124
123
|
disabled: saving,
|
|
125
124
|
onChange: (e)=>setCurrentValue(e.currentTarget.value),
|
|
@@ -129,6 +128,7 @@ const $84765747a8c6bfe2$export$14f190ac910bde69 = /*#__PURE__*/ (0, $duWW8$react
|
|
|
129
128
|
]
|
|
130
129
|
});
|
|
131
130
|
});
|
|
131
|
+
$84765747a8c6bfe2$export$14f190ac910bde69.displayName = "WordEntry";
|
|
132
132
|
|
|
133
133
|
|
|
134
134
|
const $47c36cf4281201f5$export$2eba8ec3a333fdbb = ({ id: id, canRemove: canRemove, canRename: canRename, canAddChildren: canAddChildren, canRemoveChildren: canRemoveChildren, canRenameChildren: canRenameChildren })=>{
|
|
@@ -152,7 +152,7 @@ const $47c36cf4281201f5$export$2eba8ec3a333fdbb = ({ id: id, canRemove: canRemov
|
|
|
152
152
|
]);
|
|
153
153
|
// State
|
|
154
154
|
const [error, setError] = (0, $duWW8$useState)(false);
|
|
155
|
-
const [errorText,
|
|
155
|
+
const [errorText, setErrorText] = (0, $duWW8$useState)("");
|
|
156
156
|
const expanded = (0, $duWW8$useMemo)(()=>{
|
|
157
157
|
var _treeContext_expandedNodes_findIndex;
|
|
158
158
|
return ((_treeContext_expandedNodes_findIndex = treeContext === null || treeContext === void 0 ? void 0 : treeContext.expandedNodes.findIndex((e)=>e === id)) !== null && _treeContext_expandedNodes_findIndex !== void 0 ? _treeContext_expandedNodes_findIndex : -1) > -1;
|
|
@@ -160,6 +160,14 @@ const $47c36cf4281201f5$export$2eba8ec3a333fdbb = ({ id: id, canRemove: canRemov
|
|
|
160
160
|
id,
|
|
161
161
|
treeContext === null || treeContext === void 0 ? void 0 : treeContext.expandedNodes
|
|
162
162
|
]);
|
|
163
|
+
// Ensures that child nodes are drawn before they are expanded
|
|
164
|
+
const [hasRenderedClosed, setHasRenderedClosed] = (0, $duWW8$useState)(childNodes !== undefined && childNodes.length > 0);
|
|
165
|
+
(0, $duWW8$useEffect)(()=>{
|
|
166
|
+
if (childNodes && childNodes.length > 0 && !hasRenderedClosed) setHasRenderedClosed(true);
|
|
167
|
+
}, [
|
|
168
|
+
childNodes,
|
|
169
|
+
hasRenderedClosed
|
|
170
|
+
]);
|
|
163
171
|
// Checkbox
|
|
164
172
|
const checkRef = (0, $duWW8$useRef)(null);
|
|
165
173
|
(0, $duWW8$useEffect)(()=>{
|
|
@@ -213,10 +221,10 @@ const $47c36cf4281201f5$export$2eba8ec3a333fdbb = ({ id: id, canRemove: canRemov
|
|
|
213
221
|
if (!ret.success) {
|
|
214
222
|
setError(true);
|
|
215
223
|
var _ret_ErrorText;
|
|
216
|
-
|
|
224
|
+
setErrorText((_ret_ErrorText = ret.ErrorText) !== null && _ret_ErrorText !== void 0 ? _ret_ErrorText : "An unknown error has occured");
|
|
217
225
|
} else {
|
|
218
226
|
setError(false);
|
|
219
|
-
|
|
227
|
+
setErrorText("");
|
|
220
228
|
}
|
|
221
229
|
}, []);
|
|
222
230
|
const confirmNewNode = (0, $duWW8$useCallback)(async (label)=>{
|
|
@@ -300,124 +308,140 @@ const $47c36cf4281201f5$export$2eba8ec3a333fdbb = ({ id: id, canRemove: canRemov
|
|
|
300
308
|
renameThis
|
|
301
309
|
]);
|
|
302
310
|
// Return node
|
|
303
|
-
return !treeContext ? null : /*#__PURE__*/ (0, $duWW8$
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
onClick: ()=>treeContext.handleExpandClick(id)
|
|
339
|
-
}) : /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$CaretDownFill), {
|
|
340
|
-
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
341
|
-
className: "ton-expander",
|
|
342
|
-
role: "button",
|
|
343
|
-
"aria-expanded": true,
|
|
344
|
-
"aria-label": "Expander",
|
|
345
|
-
color: nodeColour,
|
|
346
|
-
onClick: ()=>{
|
|
347
|
-
treeContext.handleExpandClick(id);
|
|
348
|
-
}
|
|
349
|
-
}) : /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$CaretRight), {
|
|
350
|
-
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
351
|
-
className: "ton-expander",
|
|
352
|
-
role: "button",
|
|
353
|
-
color: nodeColour,
|
|
354
|
-
"aria-expanded": false,
|
|
355
|
-
"aria-label": "Disabled expander",
|
|
356
|
-
onClick: ()=>treeContext.handleSelect && treeContext.handleSelect(id)
|
|
357
|
-
}),
|
|
358
|
-
thisNode && /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
359
|
-
style: {
|
|
360
|
-
display: "inline-block"
|
|
361
|
-
},
|
|
362
|
-
onContextMenuCapture: ()=>treeContext.handleSelect && treeContext.handleSelect(id),
|
|
363
|
-
onClickCapture: ()=>treeContext.handleSelect && treeContext.handleSelect(id),
|
|
364
|
-
onFocusCapture: ()=>treeContext.handleSelect && treeContext.handleSelect(id),
|
|
365
|
-
children: /*#__PURE__*/ (0, $duWW8$jsx)((0, $84765747a8c6bfe2$export$14f190ac910bde69), {
|
|
366
|
-
id: `${treeContext.id}-treenode-entry-${id}`,
|
|
367
|
-
ref: currentNameRef,
|
|
368
|
-
value: thisNode.label,
|
|
369
|
-
editing: renaming,
|
|
370
|
-
saving: updatingNode,
|
|
371
|
-
setValue: (ret)=>renameNode(ret),
|
|
372
|
-
sendEscape: ()=>setRenaming(false),
|
|
311
|
+
return !treeContext ? null : /*#__PURE__*/ (0, $duWW8$jsxs)((0, $duWW8$Fragment), {
|
|
312
|
+
children: [
|
|
313
|
+
/*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$ContextMenuHandler), {
|
|
314
|
+
menuItems: menuItems,
|
|
315
|
+
style: {
|
|
316
|
+
display: "inline-block",
|
|
317
|
+
width: "100%"
|
|
318
|
+
},
|
|
319
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
320
|
+
id: `${treeContext.id}-treenode-${id}`,
|
|
321
|
+
className: "treenode",
|
|
322
|
+
children: error ? /*#__PURE__*/ (0, $duWW8$jsxs)((0, $duWW8$Fragment), {
|
|
323
|
+
children: [
|
|
324
|
+
/*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$ExclamationCircleFill), {
|
|
325
|
+
color: "var(--bs-danger)"
|
|
326
|
+
}),
|
|
327
|
+
" ",
|
|
328
|
+
errorText
|
|
329
|
+
]
|
|
330
|
+
}) : /*#__PURE__*/ (0, $duWW8$jsxs)("div", {
|
|
331
|
+
className: "ton-node",
|
|
332
|
+
children: [
|
|
333
|
+
treeContext.showCheckBox && /*#__PURE__*/ (0, $duWW8$jsx)("input", {
|
|
334
|
+
ref: checkRef,
|
|
335
|
+
type: "checkbox",
|
|
336
|
+
role: "checkbox",
|
|
337
|
+
className: "ton-checkbox",
|
|
338
|
+
id: `${treeContext.id}-treenode-checkbox-${id}`,
|
|
339
|
+
onClick: ()=>{
|
|
340
|
+
var _treeContext_handleSelect;
|
|
341
|
+
return (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, descendents);
|
|
342
|
+
}
|
|
343
|
+
}),
|
|
344
|
+
childNodes && childNodes.length > 0 ? !expanded ? /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$CaretRightFill), {
|
|
345
|
+
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
373
346
|
style: {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
backgroundColor: currentBorder === "" ? "" : treeContext.textHighlight
|
|
347
|
+
width: "16px",
|
|
348
|
+
height: "16px"
|
|
377
349
|
},
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
350
|
+
className: "ton-expander",
|
|
351
|
+
role: "button",
|
|
352
|
+
color: nodeColour,
|
|
353
|
+
"aria-expanded": false,
|
|
354
|
+
"aria-label": "Expander",
|
|
355
|
+
onClick: ()=>treeContext.handleExpandClick(id)
|
|
356
|
+
}) : /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$CaretDownFill), {
|
|
357
|
+
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
358
|
+
className: "ton-expander",
|
|
359
|
+
role: "button",
|
|
360
|
+
"aria-expanded": true,
|
|
361
|
+
"aria-label": "Expander",
|
|
362
|
+
color: nodeColour,
|
|
363
|
+
onClick: ()=>treeContext.handleExpandClick(id)
|
|
364
|
+
}) : /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$CaretRight), {
|
|
365
|
+
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
366
|
+
className: "ton-expander",
|
|
367
|
+
role: "button",
|
|
368
|
+
color: nodeColour,
|
|
369
|
+
"aria-expanded": false,
|
|
370
|
+
"aria-label": "Disabled expander",
|
|
371
|
+
onClick: ()=>{
|
|
372
|
+
var _treeContext_handleSelect;
|
|
373
|
+
return (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, id);
|
|
374
|
+
}
|
|
375
|
+
}),
|
|
376
|
+
thisNode && /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
377
|
+
className: "ton-label",
|
|
378
|
+
style: {
|
|
379
|
+
width: `calc(100% - ${treeContext.showCheckBox ? "32px" : "16px"})`
|
|
380
|
+
},
|
|
381
|
+
onContextMenuCapture: ()=>{
|
|
382
|
+
var _treeContext_handleSelect;
|
|
383
|
+
return (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, id);
|
|
384
|
+
},
|
|
385
|
+
onClickCapture: ()=>{
|
|
386
|
+
var _treeContext_handleSelect;
|
|
387
|
+
if (!treeContext.expandedNodes.includes(id)) treeContext.handleExpandClick(id);
|
|
388
|
+
(_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, id);
|
|
389
|
+
},
|
|
390
|
+
onFocusCapture: ()=>{
|
|
391
|
+
var _treeContext_handleSelect;
|
|
392
|
+
return (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, id);
|
|
393
|
+
},
|
|
394
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)((0, $84765747a8c6bfe2$export$14f190ac910bde69), {
|
|
395
|
+
id: `${treeContext.id}-treenode-entry-${id}`,
|
|
396
|
+
ref: currentNameRef,
|
|
397
|
+
value: thisNode.label,
|
|
398
|
+
editing: renaming,
|
|
399
|
+
saving: updatingNode,
|
|
400
|
+
setValue: (ret)=>renameNode(ret),
|
|
401
|
+
sendEscape: ()=>setRenaming(false),
|
|
402
|
+
style: {
|
|
403
|
+
border: currentBorder,
|
|
404
|
+
margin: currentBorder === "" ? "1px" : "",
|
|
405
|
+
backgroundColor: currentBorder === "" ? "" : treeContext.textHighlight
|
|
406
|
+
},
|
|
407
|
+
spellCheck: treeContext.spellCheck
|
|
397
408
|
})
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
}),
|
|
401
|
-
showNewNode && /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
402
|
-
children: /*#__PURE__*/ (0, $duWW8$jsx)((0, $84765747a8c6bfe2$export$14f190ac910bde69), {
|
|
403
|
-
style: {
|
|
404
|
-
marginLeft: "14px"
|
|
405
|
-
},
|
|
406
|
-
id: `treenode-new-${id}`,
|
|
407
|
-
ref: newNameRef,
|
|
408
|
-
editing: true,
|
|
409
|
-
setValue: (ret)=>{
|
|
410
|
-
confirmNewNode(ret);
|
|
411
|
-
},
|
|
412
|
-
saving: savingNewNode,
|
|
413
|
-
sendEscape: ()=>{
|
|
414
|
-
setShowNewNode(false);
|
|
415
|
-
},
|
|
416
|
-
spellCheck: treeContext.spellCheck
|
|
409
|
+
})
|
|
410
|
+
]
|
|
417
411
|
})
|
|
418
412
|
})
|
|
419
|
-
|
|
420
|
-
|
|
413
|
+
}),
|
|
414
|
+
childNodes && /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
415
|
+
className: `ton-collapsible-wrapper ${expanded && hasRenderedClosed && childNodes.length > 0 ? "" : "collapsed"}`,
|
|
416
|
+
children: childNodes.length > 0 && /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
417
|
+
className: "ton-collapsible",
|
|
418
|
+
children: childNodes.map((h)=>/*#__PURE__*/ (0, $duWW8$jsx)("span", {
|
|
419
|
+
id: `${treeContext.id}-treenode-child-${h.id}`,
|
|
420
|
+
className: "ton-child",
|
|
421
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)($47c36cf4281201f5$export$2eba8ec3a333fdbb, {
|
|
422
|
+
id: h.id,
|
|
423
|
+
canRemove: canRemoveChildren,
|
|
424
|
+
canRename: canRenameChildren,
|
|
425
|
+
canAddChildren: canAddChildren,
|
|
426
|
+
canRemoveChildren: canRemoveChildren,
|
|
427
|
+
canRenameChildren: canRenameChildren
|
|
428
|
+
})
|
|
429
|
+
}, h.id))
|
|
430
|
+
})
|
|
431
|
+
}),
|
|
432
|
+
showNewNode && /*#__PURE__*/ (0, $duWW8$jsx)((0, $84765747a8c6bfe2$export$14f190ac910bde69), {
|
|
433
|
+
style: {
|
|
434
|
+
marginLeft: "14px"
|
|
435
|
+
},
|
|
436
|
+
id: `treenode-new-${id}`,
|
|
437
|
+
ref: newNameRef,
|
|
438
|
+
editing: true,
|
|
439
|
+
setValue: (ret)=>confirmNewNode(ret),
|
|
440
|
+
saving: savingNewNode,
|
|
441
|
+
sendEscape: ()=>setShowNewNode(false),
|
|
442
|
+
spellCheck: treeContext.spellCheck
|
|
443
|
+
})
|
|
444
|
+
]
|
|
421
445
|
});
|
|
422
446
|
};
|
|
423
447
|
$47c36cf4281201f5$export$2eba8ec3a333fdbb.displayName = "TreeNode";
|
|
@@ -466,30 +490,34 @@ const $ba47aaf387735a90$export$5580fff3e08a8be5 = ({ id: id, nodeList: nodeList,
|
|
|
466
490
|
}, [
|
|
467
491
|
expandedNodes
|
|
468
492
|
]);
|
|
469
|
-
return /*#__PURE__*/ (0, $duWW8$jsx)(
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
+
return /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
494
|
+
id: id,
|
|
495
|
+
className: "tree-of-nodes",
|
|
496
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)((0, $886f402bccb0fd30$export$29ec378200e05207).Provider, {
|
|
497
|
+
value: {
|
|
498
|
+
id: id,
|
|
499
|
+
nodeList: nodeList,
|
|
500
|
+
selected: selectedArray,
|
|
501
|
+
showCheckBox: showCheckBox,
|
|
502
|
+
handleSelect: handleSelect,
|
|
503
|
+
expandedNodes: expandedNodes,
|
|
504
|
+
handleExpandClick: (r, f)=>changeExpand(r, f),
|
|
505
|
+
onAddChild: onAdd,
|
|
506
|
+
onRename: onRename,
|
|
507
|
+
onRemove: onRemove,
|
|
508
|
+
nodeHighlight: nodeHighlight,
|
|
509
|
+
textHighlight: textHighlight,
|
|
510
|
+
spellCheck: spellCheck
|
|
511
|
+
},
|
|
512
|
+
children: roots.map((r)=>/*#__PURE__*/ (0, $duWW8$jsx)((0, $47c36cf4281201f5$export$2eba8ec3a333fdbb), {
|
|
513
|
+
id: r,
|
|
514
|
+
canRemove: canRemoveRoot,
|
|
515
|
+
canAddChildren: canAddChildren,
|
|
516
|
+
canRename: canRenameRoot,
|
|
517
|
+
canRemoveChildren: canRemoveChildren,
|
|
518
|
+
canRenameChildren: canRenameChildren
|
|
519
|
+
}, r))
|
|
520
|
+
})
|
|
493
521
|
});
|
|
494
522
|
};
|
|
495
523
|
$ba47aaf387735a90$export$5580fff3e08a8be5.displayName = "TreeOfNodes";
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AGGO,MAAM,4CAAe,CAC1B,IACA,UACA;IAEA,MAAM,aAAa,MAAM,OAAO,CAAC,MAAM,KAAK;QAAC;KAAG;IAEhD,MAAM,UAAU,WACb,GAAG,CAAC,CAAC,IAAM,eAAe,IAAI,CAAC,CAAC,IAAM,EAAE,EAAE,KAAK,IAC/C,MAAM,CAAC,CAAC,IAAM,MAAM;IACvB,IAAI,QAAQ,MAAM,KAAK,GAAG,OAAO;IAEjC,MAAM,UAAU,AACd,QACG,GAAG,CAAC,CAAC,IAAM,EAAE,QAAQ,EACrB,GAAG,CAAC,CAAC,MAAQ,eAAe,IAAI,CAAC,CAAC,IAAM,QAAQ,EAAE,EAAE,GACvD,MAAM,CAAC,CAAC,IAAM,MAAM;IACtB,IAAI,QAAQ,MAAM,KAAK,GAAG,OAAO;SAE/B,OAAO,0CACL,QAAQ,GAAG,CAAC,CAAC,IAAM,EAAE,EAAE,GACvB;WAAI;WAAa,QAAQ,MAAM,CAAC,CAAC,IAAM,CAAC,SAAS,QAAQ,CAAC;KAAI,EAC9D;AAEN;;;ACxBO,MAAM,4CAAmB,CAAC,IAAiB;IAChD,MAAM,aAAa,MAAM,OAAO,CAAC,MAAM,KAAK;QAAC;KAAG;IAChD,MAAM,cAAc,eACjB,MAAM,CACL,CAAC,IACC,EAAE,QAAQ,KAAK,aAAa,WAAW,QAAQ,CAAC,EAAE,QAAQ,KAAK,CAAC,WAAW,QAAQ,CAAC,EAAE,EAAE,GAE3F,GAAG,CAAC,CAAC,IAAM,EAAE,EAAE;IAClB,OAAO,YAAY,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ACA;2BACA;wBACA;QACF;kBAEC,MAAM,GAAG,CAAC,CAAC,kBACV,gBAAC,CAAA,GAAA,yCAAO;gBAEN,IAAI;gBACJ,WAAW;gBACX,gBAAgB;gBAChB,WAAW;gBACX,mBAAmB;gBACnB,mBAAmB;eANd;;AAWf;AAEA,0CAAY,WAAW,GAAG;;;;;;;;;;;","sources":["src/main.ts","src/components/index.ts","src/components/TreeNode.tsx","src/functions/getAncestors.tsx","src/functions/getDescendentIds.ts","src/components/TreeOfNodesContext.ts","src/components/WordEntry.tsx","src/components/TreeOfNodes.tsx","src/functions/checkExpandedNodes.ts","src/functions/index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./functions\";\n","import { TreeNode } from \"./TreeNode\";\nimport { TreeOfNodes } from \"./TreeOfNodes\";\nimport { iNodeUpdate, TreeNodeBase, TreeNodeData } from \"./interface\";\nimport { WordEntry } from \"./WordEntry\";\n\nexport { TreeNode, TreeOfNodes, WordEntry };\nexport type { TreeNodeBase, TreeNodeData, iNodeUpdate };\n","import { ContextMenuHandler, MenuItem } from \"@asup/context-menu\";\nimport {\n Key,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n CaretDownFill,\n CaretRight,\n CaretRightFill,\n ExclamationCircleFill,\n} from \"react-bootstrap-icons\";\nimport { getAncestors } from \"../functions/getAncestors\";\nimport { getDescendentIds } from \"../functions/getDescendentIds\";\nimport \"./TreeNode.css\";\nimport { TreeOfNodesContext } from \"./TreeOfNodesContext\";\nimport { WordEntry } from \"./WordEntry\";\nimport { iNodeUpdate } from \"./interface\";\n\ninterface TreeNodeProps {\n id: Key;\n indentLevel?: number;\n canRemove?: boolean;\n canRename?: boolean;\n canAddChildren?: boolean;\n canRemoveChildren?: boolean;\n canRenameChildren?: boolean;\n refresh?: () => void;\n}\n\nexport const TreeNode = ({\n id,\n canRemove,\n canRename,\n canAddChildren,\n canRemoveChildren,\n canRenameChildren,\n}: TreeNodeProps): ReactNode => {\n // Contexts\n const treeContext = useContext(TreeOfNodesContext);\n\n // Node information\n const thisNode = useMemo(\n () => treeContext?.nodeList.find((n) => n.id === id),\n [id, treeContext?.nodeList],\n );\n const childNodes = useMemo(\n () => treeContext?.nodeList.filter((n) => n.parentId === id),\n [id, treeContext?.nodeList],\n );\n const descendents = useMemo(\n () => getDescendentIds(id, treeContext?.nodeList ?? []),\n [id, treeContext],\n );\n\n // State\n const [error, setError] = useState<boolean>(false);\n const [errorText, setErrotText] = useState<string>(\"\");\n const expanded = useMemo(() => {\n return (treeContext?.expandedNodes.findIndex((e) => e === id) ?? -1) > -1;\n }, [id, treeContext?.expandedNodes]);\n\n // Checkbox\n const checkRef = useRef<HTMLInputElement | null>(null);\n useEffect(() => {\n if (checkRef.current) {\n if (treeContext?.selected.includes(id)) {\n checkRef.current.checked = true;\n checkRef.current.indeterminate = false;\n } else if (descendents.some((d) => treeContext?.selected.includes(d))) {\n checkRef.current.checked = false;\n checkRef.current.indeterminate = true;\n } else {\n checkRef.current.checked = false;\n checkRef.current.indeterminate = false;\n }\n }\n }, [descendents, id, treeContext?.selected]);\n\n // Apply selected border\n const currentBorder = useMemo<string>(() => {\n return treeContext?.selected.includes(id) ? \"1px solid black\" : \"\";\n }, [id, treeContext?.selected]);\n const nodeColour = useMemo<string | undefined>(() => {\n if (treeContext && treeContext.selected) {\n const anc = getAncestors(treeContext.selected, [], treeContext?.nodeList).map((n) => n.id);\n if ([...anc, treeContext.selected].includes(id)) return treeContext.nodeHighlight;\n }\n return;\n }, [id, treeContext]);\n\n // New node parameters\n const newNameRef = useRef<HTMLInputElement | null>(null);\n const [showNewNode, setShowNewNode] = useState<boolean>(false);\n const [savingNewNode, setSavingNewNode] = useState<boolean>(false);\n\n // Rename parameters\n const currentNameRef = useRef<HTMLInputElement | null>(null);\n const [renaming, setRenaming] = useState<boolean>(false);\n const [updatingNode, setUpdatingNode] = useState<boolean>(false);\n\n // Context functions\n const handleReturn = useCallback((ret: iNodeUpdate) => {\n if (!ret.success) {\n setError(true);\n setErrotText(ret.ErrorText ?? \"An unknown error has occured\");\n } else {\n setError(false);\n setErrotText(\"\");\n }\n }, []);\n\n const confirmNewNode = useCallback(\n async (label: string) => {\n setSavingNewNode(true);\n if (treeContext?.onAddChild) {\n handleReturn(await treeContext.onAddChild(id, label));\n }\n setSavingNewNode(false);\n setShowNewNode(false);\n },\n [handleReturn, id, treeContext],\n );\n\n const renameNode = useCallback(\n async (newLabel: string) => {\n setRenaming(false);\n if (treeContext?.onRename) {\n setUpdatingNode(true);\n handleReturn(await treeContext.onRename(id, newLabel));\n setUpdatingNode(false);\n }\n },\n [handleReturn, id, treeContext],\n );\n\n const deleteThis = useCallback(async () => {\n if (treeContext?.onRemove) {\n setUpdatingNode(true);\n handleReturn(await treeContext.onRemove(id));\n setUpdatingNode(false);\n }\n }, [handleReturn, id, treeContext]);\n\n // Context actions\n const addChild = useCallback(() => {\n setShowNewNode(true);\n treeContext?.handleExpandClick?.(id, true);\n }, [id, treeContext]);\n useEffect(() => {\n if (showNewNode === true && newNameRef.current) newNameRef.current.focus();\n }, [showNewNode]);\n const renameThis = useCallback(() => {\n setRenaming(true);\n treeContext?.handleSelect?.(id);\n }, [id, treeContext]);\n\n // Context menu\n const menuItems = useMemo(() => {\n const menuItems: MenuItem[] = [];\n if (canAddChildren) {\n menuItems.push({ label: \"Add\", action: addChild });\n }\n if (canRename) {\n menuItems.push({ label: \"Rename\", action: renameThis });\n }\n if (canRemove && (childNodes === undefined || childNodes.length === 0)) {\n menuItems.push({ label: \"Delete\", action: deleteThis });\n }\n return menuItems;\n }, [addChild, canAddChildren, canRemove, canRename, childNodes, deleteThis, renameThis]);\n\n // Return node\n return !treeContext ? null : (\n <ContextMenuHandler menuItems={menuItems}>\n <div\n id={`${treeContext.id}-treenode-${id}`}\n className=\"treenode\"\n >\n {error ? (\n <>\n <ExclamationCircleFill color=\"var(--bs-danger)\" /> {errorText}\n </>\n ) : (\n <div className=\"ton-node\">\n {treeContext.showCheckBox && (\n <input\n ref={checkRef}\n type=\"checkbox\"\n role=\"checkbox\"\n className=\"ton-checkbox\"\n id={`${treeContext.id}-treenode-checkbox-${id}`}\n onClick={() => {\n treeContext?.handleSelect?.(descendents);\n }}\n />\n )}\n {childNodes !== undefined && childNodes.length > 0 ? (\n !expanded ? (\n <CaretRightFill\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n color={nodeColour}\n aria-expanded={false}\n aria-label=\"Expander\"\n onClick={() => treeContext.handleExpandClick(id)}\n />\n ) : (\n <CaretDownFill\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n aria-expanded={true}\n aria-label=\"Expander\"\n color={nodeColour}\n onClick={() => {\n treeContext.handleExpandClick(id);\n }}\n />\n )\n ) : (\n <CaretRight\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n color={nodeColour}\n aria-expanded={false}\n aria-label=\"Disabled expander\"\n onClick={() => treeContext.handleSelect && treeContext.handleSelect(id)}\n />\n )}\n {thisNode && (\n <div\n style={{ display: \"inline-block\" }}\n onContextMenuCapture={() =>\n treeContext.handleSelect && treeContext.handleSelect(id)\n }\n onClickCapture={() => treeContext.handleSelect && treeContext.handleSelect(id)}\n onFocusCapture={() => treeContext.handleSelect && treeContext.handleSelect(id)}\n >\n <WordEntry\n id={`${treeContext.id}-treenode-entry-${id}`}\n ref={currentNameRef}\n value={thisNode.label}\n editing={renaming}\n saving={updatingNode}\n setValue={(ret) => renameNode(ret)}\n sendEscape={() => setRenaming(false)}\n style={{\n border: currentBorder,\n margin: currentBorder === \"\" ? \"1px\" : \"\",\n backgroundColor: currentBorder === \"\" ? \"\" : treeContext.textHighlight,\n }}\n spellCheck={treeContext.spellCheck}\n />\n </div>\n )}\n </div>\n )}\n {childNodes !== undefined && (\n <div className={`ton-collapsible-wrapper ${expanded ? \"\" : \"collapsed\"}`}>\n <div className=\"ton-collapsible\">\n {childNodes.map((h) => (\n <span\n key={h.id}\n id={`${treeContext.id}-treenode-child-${h.id}`}\n className=\"ton-child\"\n >\n <TreeNode\n id={h.id}\n canRemove={canRemoveChildren}\n canRename={canRenameChildren}\n canAddChildren={canAddChildren}\n canRemoveChildren={canRemoveChildren}\n canRenameChildren={canRenameChildren}\n />\n </span>\n ))}\n </div>\n </div>\n )}\n {showNewNode && (\n <div>\n <WordEntry\n style={{ marginLeft: \"14px\" }}\n id={`treenode-new-${id}`}\n ref={newNameRef}\n editing={true}\n setValue={(ret) => {\n confirmNewNode(ret);\n }}\n saving={savingNewNode}\n sendEscape={() => {\n setShowNewNode(false);\n }}\n spellCheck={treeContext.spellCheck}\n />\n </div>\n )}\n </div>\n </ContextMenuHandler>\n );\n};\n\nTreeNode.displayName = \"TreeNode\";\n","import { Key } from \"react\";\nimport { TreeNodeBase } from \"../components/interface\";\n\nexport const getAncestors = (\n id: Key | Key[],\n included: TreeNodeBase[],\n hierarchyNodes: TreeNodeBase[],\n): TreeNodeBase[] => {\n const processIds = Array.isArray(id) ? id : [id];\n\n const current = processIds\n .map((i) => hierarchyNodes.find((h) => h.id === i))\n .filter((h) => h !== undefined) as TreeNodeBase[];\n if (current.length === 0) return included;\n\n const parents = (\n current\n .map((h) => h.parentId)\n .map((pid) => hierarchyNodes.find((h) => pid === h.id)) as TreeNodeBase[]\n ).filter((p) => p !== undefined) as TreeNodeBase[];\n if (parents.length === 0) return included;\n else\n return getAncestors(\n parents.map((p) => p.id),\n [...included, ...parents.filter((p) => !included.includes(p))],\n hierarchyNodes,\n );\n};\n","import { Key } from \"react\";\nimport { TreeNodeBase } from \"../components/interface\";\n\nexport const getDescendentIds = (id: Key | Key[], hierarchyNodes: TreeNodeBase[]): Key[] => {\n const processIds = Array.isArray(id) ? id : [id];\n const newChildren = hierarchyNodes\n .filter(\n (h) =>\n h.parentId !== undefined && processIds.includes(h.parentId) && !processIds.includes(h.id),\n )\n .map((h) => h.id);\n return newChildren.length === 0\n ? processIds\n : getDescendentIds([...processIds, ...newChildren], hierarchyNodes);\n};\n","import { createContext, Key } from \"react\";\nimport { iNodeUpdate, TreeNodeData } from \"./interface\";\n\nexport interface TreeOfNodesContextProps<T> {\n id: string;\n nodeList: TreeNodeData<T>[];\n selected: Key[];\n showCheckBox: boolean;\n handleSelect?: (ret: Key | Key[]) => void;\n expandedNodes: Key[];\n handleExpandClick: (ret: Key, force?: boolean) => void;\n onAddChild?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;\n onRename?: (id: Key, newName: string) => Promise<iNodeUpdate>;\n onRemove?: (id: Key) => Promise<iNodeUpdate>;\n nodeHighlight: string;\n textHighlight: string;\n spellCheck?: \"true\" | \"false\";\n}\n\nexport const TreeOfNodesContext = createContext<TreeOfNodesContextProps<unknown> | undefined>(\n undefined,\n);\n","import React, { Key, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Spinner } from \"react-bootstrap\";\n\ninterface WordEntryProps {\n id: Key;\n value?: string;\n editing?: boolean;\n saving?: boolean;\n setValue?: (ret: string) => void;\n sendEscape?: () => void;\n style?: React.CSSProperties;\n spellCheck?: \"true\" | \"false\";\n}\n\nexport const WordEntry = React.forwardRef<HTMLInputElement, WordEntryProps>(\n (\n { id, value, editing, saving, setValue, sendEscape, style, spellCheck = \"true\" },\n ref,\n ): JSX.Element => {\n WordEntry.displayName = \"WordEntry\";\n const currentStyle = useMemo<React.CSSProperties>(() => {\n return {\n display: \"inline-block\",\n padding: \"1px\",\n paddingLeft: \"3px\",\n paddingRight: \"3px\",\n border: \"1px\",\n borderRadius: \"3px\",\n ...style,\n };\n }, [style]);\n\n const [currentValue, setCurrentValue] = useState<string>(value ?? \"\");\n useEffect(() => {\n setCurrentValue(value ?? \"\");\n }, [value]);\n\n const returnData = useCallback(() => {\n setValue?.(currentValue);\n }, [currentValue, setValue]);\n\n const keyPress = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.code === \"Escape\") {\n setCurrentValue(value ?? \"\");\n sendEscape?.();\n } else if (e.code === \"Enter\") {\n returnData();\n }\n },\n [returnData, sendEscape, value],\n );\n\n // Simple if not editing\n if (!editing) {\n return (\n <span\n style={currentStyle}\n id={`${id}`}\n >\n {value ? value : <> </>}\n </span>\n );\n }\n\n return (\n <div\n style={currentStyle}\n id={`${id}-holder`}\n >\n {saving && (\n <Spinner\n id={`${id}-spinner`}\n size=\"sm\"\n animation=\"border\"\n />\n )}\n <input\n autoFocus\n spellCheck={spellCheck}\n id={String(id)}\n ref={ref}\n type=\"text\"\n style={{\n lineHeight: \"0.75rem\",\n border: \"1px dotted black\",\n width: \"auto\",\n minWidth: \"0\",\n }}\n value={currentValue}\n disabled={saving}\n onChange={(e) => setCurrentValue(e.currentTarget.value)}\n onBlur={returnData}\n onKeyDownCapture={keyPress}\n />\n </div>\n );\n },\n);\n","import { Key, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { checkExpandedNodes } from \"../functions/checkExpandedNodes\";\nimport { iNodeUpdate, TreeNodeData } from \"./interface\";\nimport { TreeNode } from \"./TreeNode\";\nimport { TreeOfNodesContext } from \"./TreeOfNodesContext\";\n\ninterface TreeOfNodesProps<T> {\n id: string;\n nodeList: TreeNodeData<T>[];\n roots: Key[];\n showCheckBox?: boolean;\n selected?: Key | Key[];\n handleSelect?: (ret: Key | Key[]) => void;\n onAdd?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;\n onRename?: (childId: Key, newName: string) => Promise<iNodeUpdate>;\n onRemove?: (childId: Key) => Promise<iNodeUpdate>;\n canRemoveRoot?: boolean;\n canRenameRoot?: boolean;\n canAddChildren?: boolean;\n canRemoveChildren?: boolean;\n canRenameChildren?: boolean;\n nodeHighlight?: string;\n textHighlight?: string;\n spellCheck?: \"true\" | \"false\";\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport const TreeOfNodes = <T extends unknown>({\n id,\n nodeList,\n roots,\n selected = [],\n showCheckBox = false,\n handleSelect,\n onAdd,\n onRename,\n onRemove,\n canRemoveRoot = false,\n canRenameRoot = false,\n canAddChildren = false,\n canRemoveChildren = false,\n canRenameChildren = false,\n nodeHighlight = \"red\",\n textHighlight = \"rgba(255, 0, 0, 0.2)\",\n spellCheck = \"true\",\n}: TreeOfNodesProps<T>) => {\n const [expandedNodes, setExpandedNodes] = useState<Key[]>([]);\n const selectedArray = useMemo(\n () => (Array.isArray(selected) ? selected : [selected]),\n [selected],\n );\n useEffect(() => {\n if (selectedArray.length > 0) {\n // Check all nodes are showing that should be\n const shouldExpand = checkExpandedNodes(nodeList, selectedArray, expandedNodes);\n if (shouldExpand.filter((n) => !expandedNodes.includes(n)).length > 0) {\n setExpandedNodes(shouldExpand);\n }\n }\n }, [expandedNodes, nodeList, selectedArray]);\n\n // Change expansion and update contexts\n const changeExpand = useCallback(\n (eKey: Key, force?: boolean) => {\n const newExpandedNodes = [...expandedNodes];\n const ix = newExpandedNodes.findIndex((nKey) => nKey === eKey);\n if ((ix === -1 && force === undefined) || force === true) newExpandedNodes.push(eKey);\n else newExpandedNodes.splice(ix, 1);\n setExpandedNodes(newExpandedNodes);\n },\n [expandedNodes],\n );\n\n return (\n <TreeOfNodesContext.Provider\n value={{\n id: id,\n nodeList,\n selected: selectedArray,\n showCheckBox,\n handleSelect,\n expandedNodes,\n handleExpandClick: (r, f) => changeExpand(r, f),\n onAddChild: onAdd,\n onRename,\n onRemove,\n nodeHighlight,\n textHighlight,\n spellCheck,\n }}\n >\n {roots.map((r) => (\n <TreeNode\n key={r}\n id={r}\n canRemove={canRemoveRoot}\n canAddChildren={canAddChildren}\n canRename={canRenameRoot}\n canRemoveChildren={canRemoveChildren}\n canRenameChildren={canRenameChildren}\n />\n ))}\n </TreeOfNodesContext.Provider>\n );\n};\n\nTreeOfNodes.displayName = \"TreeOfNodes\";\n","import { TreeNodeBase } from \"components\";\nimport { Key } from \"react\";\nimport { getAncestors } from \"./getAncestors\";\n\nexport const checkExpandedNodes = (\n nodeList: TreeNodeBase[],\n selected: Key | Key[],\n expandedNodes: Key[],\n): Key[] => {\n return [\n ...expandedNodes,\n ...getAncestors(selected, [], nodeList)\n .map((n) => n.id)\n .filter((k) => !expandedNodes.includes(k)),\n ].sort((a, b) => `${a}`.localeCompare(`${b}`));\n};\n","import { getAncestors } from \"./getAncestors\";\n\nexport { getAncestors as getParents };\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;AGGO,MAAM,4CAAe,CAC1B,IACA,UACA;IAEA,MAAM,aAAa,MAAM,OAAO,CAAC,MAAM,KAAK;QAAC;KAAG;IAEhD,MAAM,UAAU,WACb,GAAG,CAAC,CAAC,IAAM,eAAe,IAAI,CAAC,CAAC,IAAM,EAAE,EAAE,KAAK,IAC/C,MAAM,CAAC,CAAC,IAAM,MAAM;IACvB,IAAI,QAAQ,MAAM,KAAK,GAAG,OAAO;IAEjC,MAAM,UAAU,AACd,QACG,GAAG,CAAC,CAAC,IAAM,EAAE,QAAQ,EACrB,GAAG,CAAC,CAAC,MAAQ,eAAe,IAAI,CAAC,CAAC,IAAM,QAAQ,EAAE,EAAE,GACvD,MAAM,CAAC,CAAC,IAAM,MAAM;IACtB,IAAI,QAAQ,MAAM,KAAK,GAAG,OAAO;SAE/B,OAAO,0CACL,QAAQ,GAAG,CAAC,CAAC,IAAM,EAAE,EAAE,GACvB;WAAI;WAAa,QAAQ,MAAM,CAAC,CAAC,IAAM,CAAC,SAAS,QAAQ,CAAC;KAAI,EAC9D;AAEN;;;ACxBO,MAAM,4CAAmB,CAAC,IAAiB;IAChD,MAAM,aAAa,MAAM,OAAO,CAAC,MAAM,KAAK;QAAC;KAAG;IAChD,MAAM,cAAc,eACjB,MAAM,CACL,CAAC,IACC,EAAE,QAAQ,KAAK,aAAa,WAAW,QAAQ,CAAC,EAAE,QAAQ,KAAK,CAAC,WAAW,QAAQ,CAAC,EAAE,EAAE,GAE3F,GAAG,CAAC,CAAC,IAAM,EAAE,EAAE;IAClB,OAAO,YAAY,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AAC;SAAS,EACtD;QAAC;KAAS;IAEZ,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,cAAc,MAAM,GAAG,GAAG;YAC5B,6CAA6C;YAC7C,MAAM,eAAe,CAAA,GAAA,yCAAiB,EAAE,UAAU,eAAe;YACjE,IAAI,aAAa,MAAM,CAAC,CAAC,IAAM,CAAC,cAAc,QAAQ,CAAC,IAAI,MAAM,GAAG,GAClE,iBAAiB;QAErB;IACF,GAAG;QAAC;QAAe;QAAU;KAAc;IAE3C,uCAAuC;IACvC,MAAM,eAAe,CAAA,GAAA,kBAAU,EAC7B,CAAC,MAAW;QACV,MAAM,mBAAmB;eAAI;SAAc;QAC3C,MAAM,KAAK,iBAAiB,SAAS,CAAC,CAAC,OAAS,SAAS;QACzD,IAAI,AAAC,OAAO,MAAM,UAAU,aAAc,UAAU,MAAM,iBAAiB,IAAI,CAAC;aAC3E,iBAAiB,MAAM,CAAC,IAAI;QACjC,iBAAiB;IACnB,GACA;QAAC;KAAc;IAGjB,qBACE,gBAAC;QACC,IAAI;QACJ,WAAU;kBAEV,cAAA,gBAAC,CAAA,GAAA,yCAAiB,EAAE,QAAQ;YAC1B,OAAO;gBACL,IAAI;0BACJ;gBACA,UAAU;8BACV;8BACA;+BACA;gBACA,mBAAmB,CAAC,GAAG,IAAM,aAAa,GAAG;gBAC7C,YAAY;0BACZ;0BACA;+BACA;+BACA;4BACA;YACF;sBAEC,MAAM,GAAG,CAAC,CAAC,kBACV,gBAAC,CAAA,GAAA,yCAAO;oBAEN,IAAI;oBACJ,WAAW;oBACX,gBAAgB;oBAChB,WAAW;oBACX,mBAAmB;oBACnB,mBAAmB;mBANd;;;AAYjB;AAEA,0CAAY,WAAW,GAAG;;;;;;;;;;;","sources":["src/main.ts","src/components/index.ts","src/components/TreeNode.tsx","src/functions/getAncestors.tsx","src/functions/getDescendentIds.ts","src/components/TreeOfNodesContext.ts","src/components/WordEntry.tsx","src/components/TreeOfNodes.tsx","src/functions/checkExpandedNodes.ts","src/functions/index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./functions\";\n","import { TreeNode } from \"./TreeNode\";\nimport { TreeOfNodes } from \"./TreeOfNodes\";\nimport { iNodeUpdate, TreeNodeBase, TreeNodeData } from \"./interface\";\nimport { WordEntry } from \"./WordEntry\";\n\nexport { TreeNode, TreeOfNodes, WordEntry };\nexport type { TreeNodeBase, TreeNodeData, iNodeUpdate };\n","import { ContextMenuHandler, MenuItem } from \"@asup/context-menu\";\nimport {\n Key,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n CaretDownFill,\n CaretRight,\n CaretRightFill,\n ExclamationCircleFill,\n} from \"react-bootstrap-icons\";\nimport { getAncestors } from \"../functions/getAncestors\";\nimport { getDescendentIds } from \"../functions/getDescendentIds\";\nimport \"./TreeNode.css\";\nimport { TreeOfNodesContext } from \"./TreeOfNodesContext\";\nimport { WordEntry } from \"./WordEntry\";\nimport { iNodeUpdate } from \"./interface\";\n\ninterface TreeNodeProps {\n id: Key;\n indentLevel?: number;\n canRemove?: boolean;\n canRename?: boolean;\n canAddChildren?: boolean;\n canRemoveChildren?: boolean;\n canRenameChildren?: boolean;\n refresh?: () => void;\n}\n\nexport const TreeNode = ({\n id,\n canRemove,\n canRename,\n canAddChildren,\n canRemoveChildren,\n canRenameChildren,\n}: TreeNodeProps): ReactNode => {\n // Contexts\n const treeContext = useContext(TreeOfNodesContext);\n\n // Node information\n const thisNode = useMemo(\n () => treeContext?.nodeList.find((n) => n.id === id),\n [id, treeContext?.nodeList],\n );\n const childNodes = useMemo(\n () => treeContext?.nodeList.filter((n) => n.parentId === id),\n [id, treeContext?.nodeList],\n );\n const descendents = useMemo(\n () => getDescendentIds(id, treeContext?.nodeList ?? []),\n [id, treeContext],\n );\n\n // State\n const [error, setError] = useState<boolean>(false);\n const [errorText, setErrorText] = useState<string>(\"\");\n const expanded = useMemo(() => {\n return (treeContext?.expandedNodes.findIndex((e) => e === id) ?? -1) > -1;\n }, [id, treeContext?.expandedNodes]);\n\n // Ensures that child nodes are drawn before they are expanded\n const [hasRenderedClosed, setHasRenderedClosed] = useState<boolean>(\n childNodes !== undefined && childNodes.length > 0,\n );\n useEffect(() => {\n if (childNodes && childNodes.length > 0 && !hasRenderedClosed) {\n setHasRenderedClosed(true);\n }\n }, [childNodes, hasRenderedClosed]);\n\n // Checkbox\n const checkRef = useRef<HTMLInputElement | null>(null);\n useEffect(() => {\n if (checkRef.current) {\n if (treeContext?.selected.includes(id)) {\n checkRef.current.checked = true;\n checkRef.current.indeterminate = false;\n } else if (descendents.some((d) => treeContext?.selected.includes(d))) {\n checkRef.current.checked = false;\n checkRef.current.indeterminate = true;\n } else {\n checkRef.current.checked = false;\n checkRef.current.indeterminate = false;\n }\n }\n }, [descendents, id, treeContext?.selected]);\n\n // Apply selected border\n const currentBorder = useMemo<string>(() => {\n return treeContext?.selected.includes(id) ? \"1px solid black\" : \"\";\n }, [id, treeContext?.selected]);\n const nodeColour = useMemo<string | undefined>(() => {\n if (treeContext && treeContext.selected) {\n const anc = getAncestors(treeContext.selected, [], treeContext?.nodeList).map((n) => n.id);\n if ([...anc, treeContext.selected].includes(id)) return treeContext.nodeHighlight;\n }\n return;\n }, [id, treeContext]);\n\n // New node parameters\n const newNameRef = useRef<HTMLInputElement | null>(null);\n const [showNewNode, setShowNewNode] = useState<boolean>(false);\n const [savingNewNode, setSavingNewNode] = useState<boolean>(false);\n\n // Rename parameters\n const currentNameRef = useRef<HTMLInputElement | null>(null);\n const [renaming, setRenaming] = useState<boolean>(false);\n const [updatingNode, setUpdatingNode] = useState<boolean>(false);\n\n // Context functions\n const handleReturn = useCallback((ret: iNodeUpdate) => {\n if (!ret.success) {\n setError(true);\n setErrorText(ret.ErrorText ?? \"An unknown error has occured\");\n } else {\n setError(false);\n setErrorText(\"\");\n }\n }, []);\n\n const confirmNewNode = useCallback(\n async (label: string) => {\n setSavingNewNode(true);\n if (treeContext?.onAddChild) {\n handleReturn(await treeContext.onAddChild(id, label));\n }\n setSavingNewNode(false);\n setShowNewNode(false);\n },\n [handleReturn, id, treeContext],\n );\n\n const renameNode = useCallback(\n async (newLabel: string) => {\n setRenaming(false);\n if (treeContext?.onRename) {\n setUpdatingNode(true);\n handleReturn(await treeContext.onRename(id, newLabel));\n setUpdatingNode(false);\n }\n },\n [handleReturn, id, treeContext],\n );\n\n const deleteThis = useCallback(async () => {\n if (treeContext?.onRemove) {\n setUpdatingNode(true);\n handleReturn(await treeContext.onRemove(id));\n setUpdatingNode(false);\n }\n }, [handleReturn, id, treeContext]);\n\n // Context actions\n const addChild = useCallback(() => {\n setShowNewNode(true);\n treeContext?.handleExpandClick?.(id, true);\n }, [id, treeContext]);\n useEffect(() => {\n if (showNewNode === true && newNameRef.current) newNameRef.current.focus();\n }, [showNewNode]);\n const renameThis = useCallback(() => {\n setRenaming(true);\n treeContext?.handleSelect?.(id);\n }, [id, treeContext]);\n\n // Context menu\n const menuItems = useMemo(() => {\n const menuItems: MenuItem[] = [];\n if (canAddChildren) {\n menuItems.push({ label: \"Add\", action: addChild });\n }\n if (canRename) {\n menuItems.push({ label: \"Rename\", action: renameThis });\n }\n if (canRemove && (childNodes === undefined || childNodes.length === 0)) {\n menuItems.push({ label: \"Delete\", action: deleteThis });\n }\n return menuItems;\n }, [addChild, canAddChildren, canRemove, canRename, childNodes, deleteThis, renameThis]);\n\n // Return node\n return !treeContext ? null : (\n <>\n <ContextMenuHandler\n menuItems={menuItems}\n style={{ display: \"inline-block\", width: \"100%\" }}\n >\n <div\n id={`${treeContext.id}-treenode-${id}`}\n className=\"treenode\"\n >\n {error ? (\n <>\n <ExclamationCircleFill color=\"var(--bs-danger)\" /> {errorText}\n </>\n ) : (\n <div className=\"ton-node\">\n {treeContext.showCheckBox && (\n <input\n ref={checkRef}\n type=\"checkbox\"\n role=\"checkbox\"\n className=\"ton-checkbox\"\n id={`${treeContext.id}-treenode-checkbox-${id}`}\n onClick={() => treeContext.handleSelect?.(descendents)}\n />\n )}\n {childNodes && childNodes.length > 0 ? (\n !expanded ? (\n <CaretRightFill\n id={`${treeContext.id}-treenode-caret-${id}`}\n style={{ width: \"16px\", height: \"16px\" }}\n className=\"ton-expander\"\n role=\"button\"\n color={nodeColour}\n aria-expanded={false}\n aria-label=\"Expander\"\n onClick={() => treeContext.handleExpandClick(id)}\n />\n ) : (\n <CaretDownFill\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n aria-expanded={true}\n aria-label=\"Expander\"\n color={nodeColour}\n onClick={() => treeContext.handleExpandClick(id)}\n />\n )\n ) : (\n <CaretRight\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n color={nodeColour}\n aria-expanded={false}\n aria-label=\"Disabled expander\"\n onClick={() => treeContext.handleSelect?.(id)}\n />\n )}\n {thisNode && (\n <div\n className=\"ton-label\"\n style={{ width: `calc(100% - ${treeContext.showCheckBox ? \"32px\" : \"16px\"})` }}\n onContextMenuCapture={() => treeContext.handleSelect?.(id)}\n onClickCapture={() => {\n if (!treeContext.expandedNodes.includes(id)) treeContext.handleExpandClick(id);\n treeContext.handleSelect?.(id);\n }}\n onFocusCapture={() => treeContext.handleSelect?.(id)}\n >\n <WordEntry\n id={`${treeContext.id}-treenode-entry-${id}`}\n ref={currentNameRef}\n value={thisNode.label}\n editing={renaming}\n saving={updatingNode}\n setValue={(ret) => renameNode(ret)}\n sendEscape={() => setRenaming(false)}\n style={{\n border: currentBorder,\n margin: currentBorder === \"\" ? \"1px\" : \"\",\n backgroundColor: currentBorder === \"\" ? \"\" : treeContext.textHighlight,\n }}\n spellCheck={treeContext.spellCheck}\n />\n </div>\n )}\n </div>\n )}\n </div>\n </ContextMenuHandler>\n {childNodes && (\n <div\n className={`ton-collapsible-wrapper ${expanded && hasRenderedClosed && childNodes.length > 0 ? \"\" : \"collapsed\"}`}\n >\n {childNodes.length > 0 && (\n <div className=\"ton-collapsible\">\n {childNodes.map((h) => (\n <span\n key={h.id}\n id={`${treeContext.id}-treenode-child-${h.id}`}\n className=\"ton-child\"\n >\n <TreeNode\n id={h.id}\n canRemove={canRemoveChildren}\n canRename={canRenameChildren}\n canAddChildren={canAddChildren}\n canRemoveChildren={canRemoveChildren}\n canRenameChildren={canRenameChildren}\n />\n </span>\n ))}\n </div>\n )}\n </div>\n )}\n {showNewNode && (\n <WordEntry\n style={{ marginLeft: \"14px\" }}\n id={`treenode-new-${id}`}\n ref={newNameRef}\n editing={true}\n setValue={(ret) => confirmNewNode(ret)}\n saving={savingNewNode}\n sendEscape={() => setShowNewNode(false)}\n spellCheck={treeContext.spellCheck}\n />\n )}\n </>\n );\n};\n\nTreeNode.displayName = \"TreeNode\";\n","import { Key } from \"react\";\nimport { TreeNodeBase } from \"../components/interface\";\n\nexport const getAncestors = (\n id: Key | Key[],\n included: TreeNodeBase[],\n hierarchyNodes: TreeNodeBase[],\n): TreeNodeBase[] => {\n const processIds = Array.isArray(id) ? id : [id];\n\n const current = processIds\n .map((i) => hierarchyNodes.find((h) => h.id === i))\n .filter((h) => h !== undefined) as TreeNodeBase[];\n if (current.length === 0) return included;\n\n const parents = (\n current\n .map((h) => h.parentId)\n .map((pid) => hierarchyNodes.find((h) => pid === h.id)) as TreeNodeBase[]\n ).filter((p) => p !== undefined) as TreeNodeBase[];\n if (parents.length === 0) return included;\n else\n return getAncestors(\n parents.map((p) => p.id),\n [...included, ...parents.filter((p) => !included.includes(p))],\n hierarchyNodes,\n );\n};\n","import { Key } from \"react\";\nimport { TreeNodeBase } from \"../components/interface\";\n\nexport const getDescendentIds = (id: Key | Key[], hierarchyNodes: TreeNodeBase[]): Key[] => {\n const processIds = Array.isArray(id) ? id : [id];\n const newChildren = hierarchyNodes\n .filter(\n (h) =>\n h.parentId !== undefined && processIds.includes(h.parentId) && !processIds.includes(h.id),\n )\n .map((h) => h.id);\n return newChildren.length === 0\n ? processIds\n : getDescendentIds([...processIds, ...newChildren], hierarchyNodes);\n};\n","import { createContext, Key } from \"react\";\nimport { iNodeUpdate, TreeNodeData } from \"./interface\";\n\nexport interface TreeOfNodesContextProps<T> {\n id: string;\n nodeList: TreeNodeData<T>[];\n selected: Key[];\n showCheckBox: boolean;\n handleSelect?: (ret: Key | Key[]) => void;\n expandedNodes: Key[];\n handleExpandClick: (ret: Key, force?: boolean) => void;\n onAddChild?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;\n onRename?: (id: Key, newName: string) => Promise<iNodeUpdate>;\n onRemove?: (id: Key) => Promise<iNodeUpdate>;\n nodeHighlight: string;\n textHighlight: string;\n spellCheck?: \"true\" | \"false\";\n}\n\nexport const TreeOfNodesContext = createContext<TreeOfNodesContextProps<unknown> | undefined>(\n undefined,\n);\n","import React, { Key, useCallback, useEffect, useState } from \"react\";\nimport { Spinner } from \"react-bootstrap\";\n\ninterface WordEntryProps {\n id: Key;\n value?: string;\n editing?: boolean;\n saving?: boolean;\n setValue?: (ret: string) => void;\n sendEscape?: () => void;\n style?: React.CSSProperties;\n spellCheck?: \"true\" | \"false\";\n}\n\nexport const WordEntry = React.forwardRef<HTMLInputElement, WordEntryProps>(\n (\n { id, value, editing, saving, setValue, sendEscape, style, spellCheck = \"true\" },\n ref,\n ): JSX.Element => {\n const [currentValue, setCurrentValue] = useState<string>(value ?? \"\");\n useEffect(() => {\n setCurrentValue(value ?? \"\");\n }, [value]);\n\n const returnData = useCallback(() => {\n setValue?.(currentValue);\n }, [currentValue, setValue]);\n\n const keyPress = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.code === \"Escape\") {\n setCurrentValue(value ?? \"\");\n sendEscape?.();\n } else if (e.code === \"Enter\") {\n returnData();\n }\n },\n [returnData, sendEscape, value],\n );\n\n // Add window onMouseDown event to stop events when editing\n useEffect(() => {\n const handleMouseDown = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n if (\n editing &&\n target.id !== `${id}` &&\n target.id !== `${id}-holder` &&\n target.id !== `${id}-spinner` &&\n target.className !== \"ton-rename\"\n ) {\n e.preventDefault();\n e.stopPropagation();\n returnData();\n }\n };\n window.addEventListener(\"mousedown\", handleMouseDown);\n return () => {\n window.removeEventListener(\"mousedown\", handleMouseDown);\n };\n }, [editing, id, returnData]);\n\n return !editing ? (\n <span\n className=\"ton-label-span\"\n style={style}\n id={`${id}`}\n >\n {value ? value : <> </>}\n </span>\n ) : (\n <div\n style={style}\n id={`${id}-holder`}\n className=\"ton-rename-holder\"\n >\n {saving && (\n <Spinner\n id={`${id}-spinner`}\n size=\"sm\"\n animation=\"border\"\n />\n )}\n <input\n autoFocus\n spellCheck={spellCheck}\n id={String(id)}\n ref={ref}\n type=\"text\"\n className=\"ton-rename\"\n value={currentValue}\n disabled={saving}\n onChange={(e) => setCurrentValue(e.currentTarget.value)}\n onBlur={returnData}\n onKeyDownCapture={keyPress}\n />\n </div>\n );\n },\n);\n\nWordEntry.displayName = \"WordEntry\";\n","import { Key, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { checkExpandedNodes } from \"../functions/checkExpandedNodes\";\nimport { iNodeUpdate, TreeNodeData } from \"./interface\";\nimport { TreeNode } from \"./TreeNode\";\nimport { TreeOfNodesContext } from \"./TreeOfNodesContext\";\n\ninterface TreeOfNodesProps<T> {\n id: string;\n nodeList: TreeNodeData<T>[];\n roots: Key[];\n showCheckBox?: boolean;\n selected?: Key | Key[];\n handleSelect?: (ret: Key | Key[]) => void;\n onAdd?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;\n onRename?: (childId: Key, newName: string) => Promise<iNodeUpdate>;\n onRemove?: (childId: Key) => Promise<iNodeUpdate>;\n canRemoveRoot?: boolean;\n canRenameRoot?: boolean;\n canAddChildren?: boolean;\n canRemoveChildren?: boolean;\n canRenameChildren?: boolean;\n nodeHighlight?: string;\n textHighlight?: string;\n spellCheck?: \"true\" | \"false\";\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport const TreeOfNodes = <T extends unknown>({\n id,\n nodeList,\n roots,\n selected = [],\n showCheckBox = false,\n handleSelect,\n onAdd,\n onRename,\n onRemove,\n canRemoveRoot = false,\n canRenameRoot = false,\n canAddChildren = false,\n canRemoveChildren = false,\n canRenameChildren = false,\n nodeHighlight = \"red\",\n textHighlight = \"rgba(255, 0, 0, 0.2)\",\n spellCheck = \"true\",\n}: TreeOfNodesProps<T>) => {\n const [expandedNodes, setExpandedNodes] = useState<Key[]>([]);\n const selectedArray = useMemo(\n () => (Array.isArray(selected) ? selected : [selected]),\n [selected],\n );\n useEffect(() => {\n if (selectedArray.length > 0) {\n // Check all nodes are showing that should be\n const shouldExpand = checkExpandedNodes(nodeList, selectedArray, expandedNodes);\n if (shouldExpand.filter((n) => !expandedNodes.includes(n)).length > 0) {\n setExpandedNodes(shouldExpand);\n }\n }\n }, [expandedNodes, nodeList, selectedArray]);\n\n // Change expansion and update contexts\n const changeExpand = useCallback(\n (eKey: Key, force?: boolean) => {\n const newExpandedNodes = [...expandedNodes];\n const ix = newExpandedNodes.findIndex((nKey) => nKey === eKey);\n if ((ix === -1 && force === undefined) || force === true) newExpandedNodes.push(eKey);\n else newExpandedNodes.splice(ix, 1);\n setExpandedNodes(newExpandedNodes);\n },\n [expandedNodes],\n );\n\n return (\n <div\n id={id}\n className=\"tree-of-nodes\"\n >\n <TreeOfNodesContext.Provider\n value={{\n id: id,\n nodeList,\n selected: selectedArray,\n showCheckBox,\n handleSelect,\n expandedNodes,\n handleExpandClick: (r, f) => changeExpand(r, f),\n onAddChild: onAdd,\n onRename,\n onRemove,\n nodeHighlight,\n textHighlight,\n spellCheck,\n }}\n >\n {roots.map((r) => (\n <TreeNode\n key={r}\n id={r}\n canRemove={canRemoveRoot}\n canAddChildren={canAddChildren}\n canRename={canRenameRoot}\n canRemoveChildren={canRemoveChildren}\n canRenameChildren={canRenameChildren}\n />\n ))}\n </TreeOfNodesContext.Provider>\n </div>\n );\n};\n\nTreeOfNodes.displayName = \"TreeOfNodes\";\n","import { TreeNodeBase } from \"components\";\nimport { Key } from \"react\";\nimport { getAncestors } from \"./getAncestors\";\n\nexport const checkExpandedNodes = (\n nodeList: TreeNodeBase[],\n selected: Key | Key[],\n expandedNodes: Key[],\n): Key[] => {\n return [\n ...expandedNodes,\n ...getAncestors(selected, [], nodeList)\n .map((n) => n.id)\n .filter((k) => !expandedNodes.includes(k)),\n ].sort((a, b) => `${a}`.localeCompare(`${b}`));\n};\n","import { getAncestors } from \"./getAncestors\";\n\nexport { getAncestors as getParents };\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAEA;IACE,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;IACE,EAAE,EAAE,GAAG,CAAC;IACR,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED,8BAA8B,CAAC,CAAE,SAAQ,YAAY;IACnD,IAAI,EAAE,CAAC,CAAC;CACT;ACZD,QAAO,MAAM,eACX,IAAI,GAAG,GAAG,GAAG,EAAE,EACf,UAAU,YAAY,EAAE,EACxB,gBAAgB,YAAY,EAAE,KAC7B,YAAY,EAoBd,CAAC;AGxBF;IACE,EAAE,EAAE,GAAG,CAAC;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,aAAa,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/B;AAED,OAAO,MAAM,
|
|
1
|
+
{"mappings":";;AAEA;IACE,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;IACE,EAAE,EAA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,GAAG,GAAG,GAAG,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,KAAK,IAAI,CAAC;IAC1C,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IACjE,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IACnE,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/B;AAGD,OAAO,MAAM;KAAe,CAAC,SAAS,OAAO,2NAkB1C,iBAAiB,CAAC,CAAC;;CAgErB,CAAC","sources":["src/src/components/interface.ts","src/src/functions/getAncestors.tsx","src/src/functions/getDescendentIds.ts","src/src/components/TreeOfNodesContext.ts","src/src/components/WordEntry.tsx","src/src/components/TreeNode.tsx","src/src/functions/checkExpandedNodes.ts","src/src/components/TreeOfNodes.tsx","src/src/components/index.ts","src/src/functions/index.ts","src/src/main.ts","src/main.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,"export * from \"./components\";\nexport * from \"./functions\";\n"],"names":[],"version":3,"file":"tree-of-nodes.d.ts.map"}
|