@asup/tree-of-nodes 2.0.2 → 2.0.3
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.map +1 -1
- package/dist/cjs/main.js +128 -268
- package/dist/cjs/main.js.map +1 -1
- package/dist/main.css.map +1 -1
- package/dist/main.js +6 -11
- package/dist/main.js.map +1 -1
- package/dist/tree-of-nodes.d.ts +2 -2
- package/dist/tree-of-nodes.d.ts.map +1 -1
- package/package.json +9 -15
package/dist/cjs/main.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;AAKA;;;;AAIA;;;;;;;AAOA;;;;;AAIA;;;;;;;
|
|
1
|
+
{"mappings":"AAAA;;;;;AAKA;;;;AAIA;;;;;;;AAOA;;;;;AAIA;;;;;;;AAQA;;;;;;AAKA;;;;;;;AASA;;;;;;AAKA;;;;AAGA","sources":["src/components/TreeNode.css"],"sourcesContent":[".ton-checkbox {\n margin-right: 3px;\n margin-top: 3px;\n}\n\n.ton-expander {\n margin-bottom: 4px;\n}\n\n.ton-child {\n margin-left: 16px;\n display: block;\n opacity: 1;\n transition: opacity 0.6s linear;\n}\n\n.ton-collapsible-wrapper {\n display: flex;\n overflow: hidden;\n}\n.ton-collapsible-wrapper:after {\n content: \"\";\n height: 20px;\n transition:\n height 0.3s linear,\n max-height 0s 0.3s linear;\n max-height: 0px;\n}\n.ton-collapsible {\n transition: margin-bottom 0.3s cubic-bezier(0, 0, 0, 1);\n margin-bottom: 0;\n max-height: 10000px;\n}\n.ton-collapsible-wrapper.collapsed > .ton-collapsible {\n margin-bottom: -2000px;\n transition:\n margin-bottom 0.3s cubic-bezier(1, 0, 1, 1),\n visibility 0s 0.3s,\n max-height 0s 0.3s;\n visibility: hidden;\n max-height: 0;\n}\n.ton-collapsible-wrapper.collapsed:after {\n height: 0;\n transition: height 0.3s linear;\n max-height: 20px;\n}\n.ton-collapsible-wrapper.collapsed {\n visibility: hidden;\n}\n.ton-collapsible-wrapper.collapsed .ton-child {\n opacity: 0;\n transition: opacity 0.6s linear;\n}\n"],"names":[],"version":3,"file":"main.css.map"}
|
package/dist/cjs/main.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
require("./main.css");
|
|
2
|
-
var $gTuX4$swchelperscjs_async_to_generatorcjs = require("@swc/helpers/cjs/_async_to_generator.cjs");
|
|
3
|
-
var $gTuX4$swchelperscjs_sliced_to_arraycjs = require("@swc/helpers/cjs/_sliced_to_array.cjs");
|
|
4
|
-
var $gTuX4$swchelperscjs_to_consumable_arraycjs = require("@swc/helpers/cjs/_to_consumable_array.cjs");
|
|
5
|
-
var $gTuX4$swchelperscjs_ts_generatorcjs = require("@swc/helpers/cjs/_ts_generator.cjs");
|
|
6
2
|
var $gTuX4$reactjsxruntime = require("react/jsx-runtime");
|
|
7
3
|
var $gTuX4$asupcontextmenu = require("@asup/context-menu");
|
|
8
4
|
var $gTuX4$react = require("react");
|
|
9
5
|
var $gTuX4$reactbootstrapicons = require("react-bootstrap-icons");
|
|
10
|
-
var $gTuX4$swchelperscjs_object_spreadcjs = require("@swc/helpers/cjs/_object_spread.cjs");
|
|
11
6
|
var $gTuX4$reactbootstrap = require("react-bootstrap");
|
|
12
7
|
|
|
8
|
+
|
|
13
9
|
function $parcel$exportWildcard(dest, source) {
|
|
14
10
|
Object.keys(source).forEach(function(key) {
|
|
15
|
-
if (key === 'default' || key === '__esModule' ||
|
|
11
|
+
if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {
|
|
16
12
|
return;
|
|
17
13
|
}
|
|
18
14
|
|
|
@@ -26,9 +22,11 @@ function $parcel$exportWildcard(dest, source) {
|
|
|
26
22
|
|
|
27
23
|
return dest;
|
|
28
24
|
}
|
|
25
|
+
|
|
29
26
|
function $parcel$export(e, n, v, s) {
|
|
30
27
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
31
28
|
}
|
|
29
|
+
|
|
32
30
|
function $parcel$interopDefault(a) {
|
|
33
31
|
return a && a.__esModule ? a.default : a;
|
|
34
32
|
}
|
|
@@ -41,93 +39,69 @@ $parcel$export($a68bd8a6c0fd98c2$exports, "WordEntry", function () { return $176
|
|
|
41
39
|
|
|
42
40
|
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var $580f9b3e262282c9$export$c6fd3ab3f44300d0 = function(id, included, hierarchyNodes) {
|
|
50
|
-
var processIds = Array.isArray(id) ? id : [
|
|
42
|
+
const $580f9b3e262282c9$export$c6fd3ab3f44300d0 = (id, included, hierarchyNodes)=>{
|
|
43
|
+
const processIds = Array.isArray(id) ? id : [
|
|
51
44
|
id
|
|
52
45
|
];
|
|
53
|
-
|
|
54
|
-
return hierarchyNodes.find(function(h) {
|
|
55
|
-
return h.id === i;
|
|
56
|
-
});
|
|
57
|
-
}).filter(function(h) {
|
|
58
|
-
return h !== undefined;
|
|
59
|
-
});
|
|
46
|
+
const current = processIds.map((i)=>hierarchyNodes.find((h)=>h.id === i)).filter((h)=>h !== undefined);
|
|
60
47
|
if (current.length === 0) return included;
|
|
61
|
-
|
|
62
|
-
return h.parentId;
|
|
63
|
-
}).map(function(pid) {
|
|
64
|
-
return hierarchyNodes.find(function(h) {
|
|
65
|
-
return pid === h.id;
|
|
66
|
-
});
|
|
67
|
-
}).filter(function(p) {
|
|
68
|
-
return p !== undefined;
|
|
69
|
-
});
|
|
48
|
+
const parents = current.map((h)=>h.parentId).map((pid)=>hierarchyNodes.find((h)=>pid === h.id)).filter((p)=>p !== undefined);
|
|
70
49
|
if (parents.length === 0) return included;
|
|
71
|
-
else return $580f9b3e262282c9$export$c6fd3ab3f44300d0(parents.map(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}))), hierarchyNodes);
|
|
50
|
+
else return $580f9b3e262282c9$export$c6fd3ab3f44300d0(parents.map((p)=>p.id), [
|
|
51
|
+
...included,
|
|
52
|
+
...parents.filter((p)=>!included.includes(p))
|
|
53
|
+
], hierarchyNodes);
|
|
76
54
|
};
|
|
77
55
|
|
|
78
56
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var processIds = Array.isArray(id) ? id : [
|
|
57
|
+
const $a19ef65643ae39e0$export$bd923365b402cb04 = (id, hierarchyNodes)=>{
|
|
58
|
+
const processIds = Array.isArray(id) ? id : [
|
|
82
59
|
id
|
|
83
60
|
];
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return newChildren.length === 0 ? processIds : $a19ef65643ae39e0$export$bd923365b402cb04((0, $gTuX4$swchelperscjs_to_consumable_arraycjs._)(processIds).concat((0, $gTuX4$swchelperscjs_to_consumable_arraycjs._)(newChildren)), hierarchyNodes);
|
|
61
|
+
const newChildren = hierarchyNodes.filter((h)=>h.parentId !== undefined && processIds.includes(h.parentId) && !processIds.includes(h.id)).map((h)=>h.id);
|
|
62
|
+
return newChildren.length === 0 ? processIds : $a19ef65643ae39e0$export$bd923365b402cb04([
|
|
63
|
+
...processIds,
|
|
64
|
+
...newChildren
|
|
65
|
+
], hierarchyNodes);
|
|
90
66
|
};
|
|
91
67
|
|
|
92
68
|
|
|
93
69
|
|
|
94
70
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
71
|
+
const $ff9cca1fe8f6b24e$export$29ec378200e05207 = (0, $gTuX4$react.createContext)(undefined);
|
|
98
72
|
|
|
99
73
|
|
|
100
74
|
|
|
101
75
|
|
|
102
76
|
|
|
103
|
-
|
|
104
|
-
var id = param.id, value = param.value, editing = param.editing, saving = param.saving, setValue = param.setValue, sendEscape = param.sendEscape, style = param.style, _param_spellCheck = param.spellCheck, spellCheck = _param_spellCheck === void 0 ? "true" : _param_spellCheck;
|
|
77
|
+
const $176d21a51def1fce$export$14f190ac910bde69 = /*#__PURE__*/ (0, ($parcel$interopDefault($gTuX4$react))).forwardRef(({ id: id, value: value, editing: editing, saving: saving, setValue: setValue, sendEscape: sendEscape, style: style, spellCheck: spellCheck = "true" }, ref)=>{
|
|
105
78
|
$176d21a51def1fce$export$14f190ac910bde69.displayName = "WordEntry";
|
|
106
|
-
|
|
107
|
-
return
|
|
79
|
+
const currentStyle = (0, $gTuX4$react.useMemo)(()=>{
|
|
80
|
+
return {
|
|
108
81
|
display: "inline-block",
|
|
109
82
|
padding: "1px",
|
|
110
83
|
paddingLeft: "3px",
|
|
111
84
|
paddingRight: "3px",
|
|
112
85
|
border: "1px",
|
|
113
|
-
borderRadius: "3px"
|
|
114
|
-
|
|
86
|
+
borderRadius: "3px",
|
|
87
|
+
...style
|
|
88
|
+
};
|
|
115
89
|
}, [
|
|
116
90
|
style
|
|
117
91
|
]);
|
|
118
|
-
|
|
119
|
-
(0, $gTuX4$react.useEffect)(
|
|
92
|
+
const [currentValue, setCurrentValue] = (0, $gTuX4$react.useState)(value !== null && value !== void 0 ? value : "");
|
|
93
|
+
(0, $gTuX4$react.useEffect)(()=>{
|
|
120
94
|
setCurrentValue(value !== null && value !== void 0 ? value : "");
|
|
121
95
|
}, [
|
|
122
96
|
value
|
|
123
97
|
]);
|
|
124
|
-
|
|
98
|
+
const returnData = (0, $gTuX4$react.useCallback)(()=>{
|
|
125
99
|
setValue && setValue(currentValue);
|
|
126
100
|
}, [
|
|
127
101
|
currentValue,
|
|
128
102
|
setValue
|
|
129
103
|
]);
|
|
130
|
-
|
|
104
|
+
const keyPress = (0, $gTuX4$react.useCallback)((e)=>{
|
|
131
105
|
if (e.code === "Escape") {
|
|
132
106
|
setCurrentValue(value !== null && value !== void 0 ? value : "");
|
|
133
107
|
sendEscape && sendEscape();
|
|
@@ -140,17 +114,17 @@ var $176d21a51def1fce$export$14f190ac910bde69 = /*#__PURE__*/ (0, ($parcel$inter
|
|
|
140
114
|
// Simple if not editing
|
|
141
115
|
if (!editing) return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
|
|
142
116
|
style: currentStyle,
|
|
143
|
-
id:
|
|
117
|
+
id: `${id}`,
|
|
144
118
|
children: value ? value : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactjsxruntime.Fragment), {
|
|
145
119
|
children: "\xa0"
|
|
146
120
|
})
|
|
147
121
|
});
|
|
148
122
|
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
|
|
149
123
|
style: currentStyle,
|
|
150
|
-
id:
|
|
124
|
+
id: `${id}-holder`,
|
|
151
125
|
children: [
|
|
152
126
|
saving && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrap.Spinner), {
|
|
153
|
-
id:
|
|
127
|
+
id: `${id}-spinner`,
|
|
154
128
|
size: "sm",
|
|
155
129
|
animation: "border"
|
|
156
130
|
}),
|
|
@@ -168,9 +142,7 @@ var $176d21a51def1fce$export$14f190ac910bde69 = /*#__PURE__*/ (0, ($parcel$inter
|
|
|
168
142
|
},
|
|
169
143
|
value: currentValue,
|
|
170
144
|
disabled: saving,
|
|
171
|
-
onChange:
|
|
172
|
-
return setCurrentValue(e.currentTarget.value);
|
|
173
|
-
},
|
|
145
|
+
onChange: (e)=>setCurrentValue(e.currentTarget.value),
|
|
174
146
|
onBlur: returnData,
|
|
175
147
|
onKeyDownCapture: keyPress
|
|
176
148
|
})
|
|
@@ -179,56 +151,43 @@ var $176d21a51def1fce$export$14f190ac910bde69 = /*#__PURE__*/ (0, ($parcel$inter
|
|
|
179
151
|
});
|
|
180
152
|
|
|
181
153
|
|
|
182
|
-
|
|
183
|
-
var id = param.id, canRemove = param.canRemove, canRename = param.canRename, canAddChildren = param.canAddChildren, canRemoveChildren = param.canRemoveChildren, canRenameChildren = param.canRenameChildren;
|
|
154
|
+
const $a56aac35d4408806$export$2eba8ec3a333fdbb = ({ id: id, canRemove: canRemove, canRename: canRename, canAddChildren: canAddChildren, canRemoveChildren: canRemoveChildren, canRenameChildren: canRenameChildren })=>{
|
|
184
155
|
// Contexts
|
|
185
|
-
|
|
156
|
+
const treeContext = (0, $gTuX4$react.useContext)((0, $ff9cca1fe8f6b24e$export$29ec378200e05207));
|
|
186
157
|
// Node information
|
|
187
|
-
|
|
188
|
-
return treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList.find(function(n) {
|
|
189
|
-
return n.id === id;
|
|
190
|
-
});
|
|
191
|
-
}, [
|
|
158
|
+
const thisNode = (0, $gTuX4$react.useMemo)(()=>treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList.find((n)=>n.id === id), [
|
|
192
159
|
id,
|
|
193
160
|
treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList
|
|
194
161
|
]);
|
|
195
|
-
|
|
196
|
-
return treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList.filter(function(n) {
|
|
197
|
-
return n.parentId === id;
|
|
198
|
-
});
|
|
199
|
-
}, [
|
|
162
|
+
const childNodes = (0, $gTuX4$react.useMemo)(()=>treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList.filter((n)=>n.parentId === id), [
|
|
200
163
|
id,
|
|
201
164
|
treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList
|
|
202
165
|
]);
|
|
203
|
-
|
|
204
|
-
|
|
166
|
+
const descendents = (0, $gTuX4$react.useMemo)(()=>{
|
|
167
|
+
var _treeContext_nodeList;
|
|
205
168
|
return (0, $a19ef65643ae39e0$export$bd923365b402cb04)(id, (_treeContext_nodeList = treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList) !== null && _treeContext_nodeList !== void 0 ? _treeContext_nodeList : []);
|
|
206
169
|
}, [
|
|
207
170
|
id,
|
|
208
171
|
treeContext
|
|
209
172
|
]);
|
|
210
173
|
// State
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
174
|
+
const [error, setError] = (0, $gTuX4$react.useState)(false);
|
|
175
|
+
const [errorText, setErrotText] = (0, $gTuX4$react.useState)("");
|
|
176
|
+
const expanded = (0, $gTuX4$react.useMemo)(()=>{
|
|
214
177
|
var _treeContext_expandedNodes_findIndex;
|
|
215
|
-
return ((_treeContext_expandedNodes_findIndex = treeContext === null || treeContext === void 0 ? void 0 : treeContext.expandedNodes.findIndex(
|
|
216
|
-
return e === id;
|
|
217
|
-
})) !== null && _treeContext_expandedNodes_findIndex !== void 0 ? _treeContext_expandedNodes_findIndex : -1) > -1;
|
|
178
|
+
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;
|
|
218
179
|
}, [
|
|
219
180
|
id,
|
|
220
181
|
treeContext === null || treeContext === void 0 ? void 0 : treeContext.expandedNodes
|
|
221
182
|
]);
|
|
222
183
|
// Checkbox
|
|
223
|
-
|
|
224
|
-
(0, $gTuX4$react.useEffect)(
|
|
184
|
+
const checkRef = (0, $gTuX4$react.useRef)(null);
|
|
185
|
+
(0, $gTuX4$react.useEffect)(()=>{
|
|
225
186
|
if (checkRef.current) {
|
|
226
187
|
if (treeContext === null || treeContext === void 0 ? void 0 : treeContext.selected.includes(id)) {
|
|
227
188
|
checkRef.current.checked = true;
|
|
228
189
|
checkRef.current.indeterminate = false;
|
|
229
|
-
} else if (descendents.some(
|
|
230
|
-
return treeContext === null || treeContext === void 0 ? void 0 : treeContext.selected.includes(d);
|
|
231
|
-
})) {
|
|
190
|
+
} else if (descendents.some((d)=>treeContext === null || treeContext === void 0 ? void 0 : treeContext.selected.includes(d))) {
|
|
232
191
|
checkRef.current.checked = false;
|
|
233
192
|
checkRef.current.indeterminate = true;
|
|
234
193
|
} else {
|
|
@@ -242,20 +201,19 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
242
201
|
treeContext === null || treeContext === void 0 ? void 0 : treeContext.selected
|
|
243
202
|
]);
|
|
244
203
|
// Apply selected border
|
|
245
|
-
|
|
204
|
+
const currentBorder = (0, $gTuX4$react.useMemo)(()=>{
|
|
246
205
|
return (treeContext === null || treeContext === void 0 ? void 0 : treeContext.selected.includes(id)) ? "1px solid black" : "";
|
|
247
206
|
}, [
|
|
248
207
|
id,
|
|
249
208
|
treeContext === null || treeContext === void 0 ? void 0 : treeContext.selected
|
|
250
209
|
]);
|
|
251
|
-
|
|
210
|
+
const nodeColour = (0, $gTuX4$react.useMemo)(()=>{
|
|
252
211
|
if (treeContext && treeContext.selected) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if ((0, $gTuX4$swchelperscjs_to_consumable_arraycjs._)(anc).concat([
|
|
212
|
+
const anc = (0, $580f9b3e262282c9$export$c6fd3ab3f44300d0)(treeContext.selected, [], treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList).map((n)=>n.id);
|
|
213
|
+
if ([
|
|
214
|
+
...anc,
|
|
257
215
|
treeContext.selected
|
|
258
|
-
]
|
|
216
|
+
].includes(id)) return treeContext.nodeHighlight;
|
|
259
217
|
}
|
|
260
218
|
return;
|
|
261
219
|
}, [
|
|
@@ -263,15 +221,15 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
263
221
|
treeContext
|
|
264
222
|
]);
|
|
265
223
|
// New node parameters
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
224
|
+
const newNameRef = (0, $gTuX4$react.useRef)(null);
|
|
225
|
+
const [showNewNode, setShowNewNode] = (0, $gTuX4$react.useState)(false);
|
|
226
|
+
const [savingNewNode, setSavingNewNode] = (0, $gTuX4$react.useState)(false);
|
|
269
227
|
// Rename parameters
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
228
|
+
const currentNameRef = (0, $gTuX4$react.useRef)(null);
|
|
229
|
+
const [renaming, setRenaming] = (0, $gTuX4$react.useState)(false);
|
|
230
|
+
const [updatingNode, setUpdatingNode] = (0, $gTuX4$react.useState)(false);
|
|
273
231
|
// Context functions
|
|
274
|
-
|
|
232
|
+
const handleReturn = (0, $gTuX4$react.useCallback)((ret)=>{
|
|
275
233
|
if (!ret.success) {
|
|
276
234
|
setError(true);
|
|
277
235
|
var _ret_ErrorText;
|
|
@@ -281,122 +239,53 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
281
239
|
setErrotText("");
|
|
282
240
|
}
|
|
283
241
|
}, []);
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
if (!(treeContext === null || treeContext === void 0 ? void 0 : treeContext.onAddChild)) return [
|
|
291
|
-
3,
|
|
292
|
-
2
|
|
293
|
-
];
|
|
294
|
-
return [
|
|
295
|
-
4,
|
|
296
|
-
treeContext.onAddChild(id, label)
|
|
297
|
-
];
|
|
298
|
-
case 1:
|
|
299
|
-
handleReturn.apply(void 0, [
|
|
300
|
-
_state.sent()
|
|
301
|
-
]);
|
|
302
|
-
_state.label = 2;
|
|
303
|
-
case 2:
|
|
304
|
-
setSavingNewNode(false);
|
|
305
|
-
setShowNewNode(false);
|
|
306
|
-
return [
|
|
307
|
-
2
|
|
308
|
-
];
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
return function(label) {
|
|
313
|
-
return _ref.apply(this, arguments);
|
|
314
|
-
};
|
|
315
|
-
}(), [
|
|
242
|
+
const confirmNewNode = (0, $gTuX4$react.useCallback)(async (label)=>{
|
|
243
|
+
setSavingNewNode(true);
|
|
244
|
+
if (treeContext === null || treeContext === void 0 ? void 0 : treeContext.onAddChild) handleReturn(await treeContext.onAddChild(id, label));
|
|
245
|
+
setSavingNewNode(false);
|
|
246
|
+
setShowNewNode(false);
|
|
247
|
+
}, [
|
|
316
248
|
handleReturn,
|
|
317
249
|
id,
|
|
318
250
|
treeContext
|
|
319
251
|
]);
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
2
|
|
329
|
-
];
|
|
330
|
-
setUpdatingNode(true);
|
|
331
|
-
return [
|
|
332
|
-
4,
|
|
333
|
-
treeContext.onRename(id, newLabel)
|
|
334
|
-
];
|
|
335
|
-
case 1:
|
|
336
|
-
handleReturn.apply(void 0, [
|
|
337
|
-
_state.sent()
|
|
338
|
-
]);
|
|
339
|
-
setUpdatingNode(false);
|
|
340
|
-
_state.label = 2;
|
|
341
|
-
case 2:
|
|
342
|
-
return [
|
|
343
|
-
2
|
|
344
|
-
];
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
return function(newLabel) {
|
|
349
|
-
return _ref.apply(this, arguments);
|
|
350
|
-
};
|
|
351
|
-
}(), [
|
|
252
|
+
const renameNode = (0, $gTuX4$react.useCallback)(async (newLabel)=>{
|
|
253
|
+
setRenaming(false);
|
|
254
|
+
if (treeContext === null || treeContext === void 0 ? void 0 : treeContext.onRename) {
|
|
255
|
+
setUpdatingNode(true);
|
|
256
|
+
handleReturn(await treeContext.onRename(id, newLabel));
|
|
257
|
+
setUpdatingNode(false);
|
|
258
|
+
}
|
|
259
|
+
}, [
|
|
352
260
|
handleReturn,
|
|
353
261
|
id,
|
|
354
262
|
treeContext
|
|
355
263
|
]);
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
];
|
|
364
|
-
setUpdatingNode(true);
|
|
365
|
-
return [
|
|
366
|
-
4,
|
|
367
|
-
treeContext.onRemove(id)
|
|
368
|
-
];
|
|
369
|
-
case 1:
|
|
370
|
-
handleReturn.apply(void 0, [
|
|
371
|
-
_state.sent()
|
|
372
|
-
]);
|
|
373
|
-
setUpdatingNode(false);
|
|
374
|
-
_state.label = 2;
|
|
375
|
-
case 2:
|
|
376
|
-
return [
|
|
377
|
-
2
|
|
378
|
-
];
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
}), [
|
|
264
|
+
const deleteThis = (0, $gTuX4$react.useCallback)(async ()=>{
|
|
265
|
+
if (treeContext === null || treeContext === void 0 ? void 0 : treeContext.onRemove) {
|
|
266
|
+
setUpdatingNode(true);
|
|
267
|
+
handleReturn(await treeContext.onRemove(id));
|
|
268
|
+
setUpdatingNode(false);
|
|
269
|
+
}
|
|
270
|
+
}, [
|
|
382
271
|
handleReturn,
|
|
383
272
|
id,
|
|
384
273
|
treeContext
|
|
385
274
|
]);
|
|
386
275
|
// Context actions
|
|
387
|
-
|
|
276
|
+
const addChild = (0, $gTuX4$react.useCallback)(()=>{
|
|
388
277
|
setShowNewNode(true);
|
|
389
278
|
treeContext && treeContext.handleExpandClick(id, true);
|
|
390
279
|
}, [
|
|
391
280
|
id,
|
|
392
281
|
treeContext
|
|
393
282
|
]);
|
|
394
|
-
(0, $gTuX4$react.useEffect)(
|
|
283
|
+
(0, $gTuX4$react.useEffect)(()=>{
|
|
395
284
|
if (showNewNode === true && newNameRef.current) newNameRef.current.focus();
|
|
396
285
|
}, [
|
|
397
286
|
showNewNode
|
|
398
287
|
]);
|
|
399
|
-
|
|
288
|
+
const renameThis = (0, $gTuX4$react.useCallback)(()=>{
|
|
400
289
|
setRenaming(true);
|
|
401
290
|
treeContext && treeContext.handleSelect && treeContext.handleSelect(id);
|
|
402
291
|
}, [
|
|
@@ -404,8 +293,8 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
404
293
|
treeContext
|
|
405
294
|
]);
|
|
406
295
|
// Context menu
|
|
407
|
-
|
|
408
|
-
|
|
296
|
+
const menuItems = (0, $gTuX4$react.useMemo)(()=>{
|
|
297
|
+
const menuItems = [];
|
|
409
298
|
if (canAddChildren) menuItems.push({
|
|
410
299
|
label: "Add",
|
|
411
300
|
action: addChild
|
|
@@ -433,7 +322,7 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
433
322
|
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$asupcontextmenu.ContextMenuHandler), {
|
|
434
323
|
menuItems: menuItems,
|
|
435
324
|
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
|
|
436
|
-
id:
|
|
325
|
+
id: `${treeContext.id}-treenode-${id}`,
|
|
437
326
|
className: "treenode",
|
|
438
327
|
children: [
|
|
439
328
|
error ? /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)((0, $gTuX4$reactjsxruntime.Fragment), {
|
|
@@ -452,65 +341,53 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
452
341
|
type: "checkbox",
|
|
453
342
|
role: "checkbox",
|
|
454
343
|
className: "ton-checkbox",
|
|
455
|
-
id:
|
|
456
|
-
onClick:
|
|
344
|
+
id: `${treeContext.id}-treenode-checkbox-${id}`,
|
|
345
|
+
onClick: ()=>{
|
|
457
346
|
treeContext.handleSelect && treeContext.handleSelect(descendents);
|
|
458
347
|
}
|
|
459
348
|
}),
|
|
460
349
|
childNodes !== undefined && childNodes.length > 0 ? !expanded ? /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretRightFill), {
|
|
461
|
-
id:
|
|
350
|
+
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
462
351
|
className: "ton-expander",
|
|
463
352
|
role: "button",
|
|
464
353
|
color: nodeColour,
|
|
465
354
|
"aria-expanded": false,
|
|
466
355
|
"aria-label": "Expander",
|
|
467
|
-
onClick:
|
|
468
|
-
return treeContext.handleExpandClick(id);
|
|
469
|
-
}
|
|
356
|
+
onClick: ()=>treeContext.handleExpandClick(id)
|
|
470
357
|
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretDownFill), {
|
|
471
|
-
id:
|
|
358
|
+
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
472
359
|
className: "ton-expander",
|
|
473
360
|
role: "button",
|
|
474
361
|
"aria-expanded": true,
|
|
475
362
|
"aria-label": "Expander",
|
|
476
363
|
color: nodeColour,
|
|
477
|
-
onClick:
|
|
364
|
+
onClick: ()=>{
|
|
478
365
|
treeContext.handleExpandClick(id);
|
|
479
366
|
}
|
|
480
367
|
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretRight), {
|
|
481
|
-
id:
|
|
368
|
+
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
482
369
|
className: "ton-expander",
|
|
483
370
|
role: "button",
|
|
484
371
|
color: nodeColour,
|
|
485
372
|
"aria-expanded": false,
|
|
486
373
|
"aria-label": "Disabled expander",
|
|
487
|
-
|
|
374
|
+
onClick: ()=>treeContext.handleSelect && treeContext.handleSelect(id)
|
|
488
375
|
}),
|
|
489
376
|
thisNode && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
490
377
|
style: {
|
|
491
378
|
display: "inline-block"
|
|
492
379
|
},
|
|
493
|
-
onContextMenuCapture:
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
onClickCapture: function() {
|
|
497
|
-
return treeContext.handleSelect && treeContext.handleSelect(id);
|
|
498
|
-
},
|
|
499
|
-
onFocusCapture: function() {
|
|
500
|
-
return treeContext.handleSelect && treeContext.handleSelect(id);
|
|
501
|
-
},
|
|
380
|
+
onContextMenuCapture: ()=>treeContext.handleSelect && treeContext.handleSelect(id),
|
|
381
|
+
onClickCapture: ()=>treeContext.handleSelect && treeContext.handleSelect(id),
|
|
382
|
+
onFocusCapture: ()=>treeContext.handleSelect && treeContext.handleSelect(id),
|
|
502
383
|
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $176d21a51def1fce$export$14f190ac910bde69), {
|
|
503
|
-
id:
|
|
384
|
+
id: `${treeContext.id}-treenode-entry-${id}`,
|
|
504
385
|
ref: currentNameRef,
|
|
505
386
|
value: thisNode.label,
|
|
506
387
|
editing: renaming,
|
|
507
388
|
saving: updatingNode,
|
|
508
|
-
setValue:
|
|
509
|
-
|
|
510
|
-
},
|
|
511
|
-
sendEscape: function() {
|
|
512
|
-
return setRenaming(false);
|
|
513
|
-
},
|
|
389
|
+
setValue: (ret)=>renameNode(ret),
|
|
390
|
+
sendEscape: ()=>setRenaming(false),
|
|
514
391
|
style: {
|
|
515
392
|
border: currentBorder,
|
|
516
393
|
margin: currentBorder === "" ? "1px" : "",
|
|
@@ -522,12 +399,11 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
522
399
|
]
|
|
523
400
|
}),
|
|
524
401
|
childNodes !== undefined && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
525
|
-
className:
|
|
402
|
+
className: `ton-collapsible-wrapper ${expanded ? "" : "collapsed"}`,
|
|
526
403
|
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
527
404
|
className: "ton-collapsible",
|
|
528
|
-
children: childNodes.map(
|
|
529
|
-
|
|
530
|
-
id: "".concat(treeContext.id, "-treenode-child-").concat(h.id),
|
|
405
|
+
children: childNodes.map((h)=>/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
|
|
406
|
+
id: `${treeContext.id}-treenode-child-${h.id}`,
|
|
531
407
|
className: "ton-child",
|
|
532
408
|
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)($a56aac35d4408806$export$2eba8ec3a333fdbb, {
|
|
533
409
|
id: h.id,
|
|
@@ -537,8 +413,7 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
537
413
|
canRemoveChildren: canRemoveChildren,
|
|
538
414
|
canRenameChildren: canRenameChildren
|
|
539
415
|
})
|
|
540
|
-
}, h.id)
|
|
541
|
-
})
|
|
416
|
+
}, h.id))
|
|
542
417
|
})
|
|
543
418
|
}),
|
|
544
419
|
showNewNode && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
@@ -546,14 +421,14 @@ var $a56aac35d4408806$export$2eba8ec3a333fdbb = function(param) {
|
|
|
546
421
|
style: {
|
|
547
422
|
marginLeft: "14px"
|
|
548
423
|
},
|
|
549
|
-
id:
|
|
424
|
+
id: `treenode-new-${id}`,
|
|
550
425
|
ref: newNameRef,
|
|
551
426
|
editing: true,
|
|
552
|
-
setValue:
|
|
427
|
+
setValue: (ret)=>{
|
|
553
428
|
confirmNewNode(ret);
|
|
554
429
|
},
|
|
555
430
|
saving: savingNewNode,
|
|
556
|
-
sendEscape:
|
|
431
|
+
sendEscape: ()=>{
|
|
557
432
|
setShowNewNode(false);
|
|
558
433
|
},
|
|
559
434
|
spellCheck: treeContext.spellCheck
|
|
@@ -569,39 +444,28 @@ $a56aac35d4408806$export$2eba8ec3a333fdbb.displayName = "TreeNode";
|
|
|
569
444
|
|
|
570
445
|
|
|
571
446
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
return n.id;
|
|
578
|
-
}).filter(function(k) {
|
|
579
|
-
return !expandedNodes.includes(k);
|
|
580
|
-
}))).sort(function(a, b) {
|
|
581
|
-
return "".concat(a).localeCompare("".concat(b));
|
|
582
|
-
});
|
|
447
|
+
const $f31429c9cc6d3bce$export$40c47a7ac5f85aba = (nodeList, selected, expandedNodes)=>{
|
|
448
|
+
return [
|
|
449
|
+
...expandedNodes,
|
|
450
|
+
...(0, $580f9b3e262282c9$export$c6fd3ab3f44300d0)(selected, [], nodeList).map((n)=>n.id).filter((k)=>!expandedNodes.includes(k))
|
|
451
|
+
].sort((a, b)=>`${a}`.localeCompare(`${b}`));
|
|
583
452
|
};
|
|
584
453
|
|
|
585
454
|
|
|
586
455
|
|
|
587
456
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
var selectedArray = (0, $gTuX4$react.useMemo)(function() {
|
|
592
|
-
return Array.isArray(selected) ? selected : [
|
|
457
|
+
const $9becaaec3a803ae7$export$5580fff3e08a8be5 = ({ id: id, nodeList: nodeList, roots: roots, selected: selected = [], showCheckBox: showCheckBox = false, handleSelect: handleSelect, onAdd: onAdd, onRename: onRename, onRemove: onRemove, canRemoveRoot: canRemoveRoot = false, canRenameRoot: canRenameRoot = false, canAddChildren: canAddChildren = false, canRemoveChildren: canRemoveChildren = false, canRenameChildren: canRenameChildren = false, nodeHighlight: nodeHighlight = "red", textHighlight: textHighlight = "rgba(255, 0, 0, 0.2)", spellCheck: spellCheck = "true" })=>{
|
|
458
|
+
const [expandedNodes, setExpandedNodes] = (0, $gTuX4$react.useState)([]);
|
|
459
|
+
const selectedArray = (0, $gTuX4$react.useMemo)(()=>Array.isArray(selected) ? selected : [
|
|
593
460
|
selected
|
|
594
|
-
]
|
|
595
|
-
}, [
|
|
461
|
+
], [
|
|
596
462
|
selected
|
|
597
463
|
]);
|
|
598
|
-
(0, $gTuX4$react.useEffect)(
|
|
464
|
+
(0, $gTuX4$react.useEffect)(()=>{
|
|
599
465
|
if (selectedArray.length > 0) {
|
|
600
466
|
// Check all nodes are showing that should be
|
|
601
|
-
|
|
602
|
-
shouldExpand.filter(
|
|
603
|
-
return !expandedNodes.includes(n);
|
|
604
|
-
}).length > 0 && setExpandedNodes(shouldExpand);
|
|
467
|
+
const shouldExpand = (0, $f31429c9cc6d3bce$export$40c47a7ac5f85aba)(nodeList, selectedArray, expandedNodes);
|
|
468
|
+
shouldExpand.filter((n)=>!expandedNodes.includes(n)).length > 0 && setExpandedNodes(shouldExpand);
|
|
605
469
|
}
|
|
606
470
|
}, [
|
|
607
471
|
expandedNodes,
|
|
@@ -609,11 +473,11 @@ var $9becaaec3a803ae7$export$5580fff3e08a8be5 = function(param) {
|
|
|
609
473
|
selectedArray
|
|
610
474
|
]);
|
|
611
475
|
// Change expansion and update contexts
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
476
|
+
const changeExpand = (0, $gTuX4$react.useCallback)((eKey, force)=>{
|
|
477
|
+
const newExpandedNodes = [
|
|
478
|
+
...expandedNodes
|
|
479
|
+
];
|
|
480
|
+
const ix = newExpandedNodes.findIndex((nKey)=>nKey === eKey);
|
|
617
481
|
if (ix === -1 && force === undefined || force === true) newExpandedNodes.push(eKey);
|
|
618
482
|
else newExpandedNodes.splice(ix, 1);
|
|
619
483
|
setExpandedNodes(newExpandedNodes);
|
|
@@ -628,9 +492,7 @@ var $9becaaec3a803ae7$export$5580fff3e08a8be5 = function(param) {
|
|
|
628
492
|
showCheckBox: showCheckBox,
|
|
629
493
|
handleSelect: handleSelect,
|
|
630
494
|
expandedNodes: expandedNodes,
|
|
631
|
-
handleExpandClick:
|
|
632
|
-
return changeExpand(r, f);
|
|
633
|
-
},
|
|
495
|
+
handleExpandClick: (r, f)=>changeExpand(r, f),
|
|
634
496
|
onAddChild: onAdd,
|
|
635
497
|
onRename: onRename,
|
|
636
498
|
onRemove: onRemove,
|
|
@@ -638,16 +500,14 @@ var $9becaaec3a803ae7$export$5580fff3e08a8be5 = function(param) {
|
|
|
638
500
|
textHighlight: textHighlight,
|
|
639
501
|
spellCheck: spellCheck
|
|
640
502
|
},
|
|
641
|
-
children: roots.map(
|
|
642
|
-
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $a56aac35d4408806$export$2eba8ec3a333fdbb), {
|
|
503
|
+
children: roots.map((r)=>/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $a56aac35d4408806$export$2eba8ec3a333fdbb), {
|
|
643
504
|
id: r,
|
|
644
505
|
canRemove: canRemoveRoot,
|
|
645
506
|
canAddChildren: canAddChildren,
|
|
646
507
|
canRename: canRenameRoot,
|
|
647
508
|
canRemoveChildren: canRemoveChildren,
|
|
648
509
|
canRenameChildren: canRenameChildren
|
|
649
|
-
}, r)
|
|
650
|
-
})
|
|
510
|
+
}, r))
|
|
651
511
|
});
|
|
652
512
|
};
|
|
653
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AO,EAAS,EAAE,OAArD,gBAAmC,cAApB,mBAAoB;IAC1C,IAAM,gBAAgB,CAAA,GAAA,oBAAM,EAC1B;eAAO,MAAM,QAAQ,YAAY,WAAW;YAAC;SAAS;OACtD;QAAC;KAAS;IAEZ,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,cAAc,SAAS,GAAG;YAC5B,6CAA6C;YAC7C,IAAM,eAAe,CAAA,GAAA,yCAAiB,EAAE,UAAU,eAAe;YACjE,aAAa,OAAO,SAAC;uBAAM,CAAC,cAAc,SAAS;eAAI,SAAS,KAC9D,iBAAiB;QACrB;IACF,GAAG;QAAC;QAAe;QAAU;KAAc;IAE3C,uCAAuC;IACvC,IAAM,eAAe,CAAA,GAAA,wBAAU,EAC7B,SAAC,MAAW;QACV,IAAM,mBAAoB,mDAAG;QAC7B,IAAM,KAAK,iBAAiB,UAAU,SAAC;mBAAS,SAAS;;QACzD,IAAI,AAAC,OAAO,MAAM,UAAU,aAAc,UAAU,MAAM,iBAAiB,KAAK;aAC3E,iBAAiB,OAAO,IAAI;QACjC,iBAAiB;IACnB,GACA;QAAC;KAAc;IAGjB,qBACE,gCAAC,CAAA,GAAA,yCAAiB,EAAE;QAClB,OAAO;YACL,IAAI;YACJ,UAAA;YACA,UAAU;YACV,cAAA;YACA,cAAA;YACA,eAAA;YACA,mBAAmB,SAAC,GAAG;uBAAM,aAAa,GAAG;;YAC7C,YAAY;YACZ,UAAA;YACA,UAAA;YACA,eAAA;YACA,eAAA;YACA,YAAA;QACF;kBAEC,MAAM,IAAI,SAAC;iCACV,gCAAC,CAAA,GAAA,yCAAO;gBAEN,IAAI;gBACJ,WAAW;gBACX,gBAAgB;gBAChB,WAAW;gBACX,mBAAmB;gBACnB,mBAAmB;eANd;;;AAWf;AAEA,0CAAY,cAAc;;;;;;;;;;;","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, iMenuItem } from '@asup/context-menu';\nimport { Key, useCallback, useContext, useEffect, useMemo, useRef, useState } 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): JSX.Element => {\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 && 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 && treeContext.handleSelect && treeContext.handleSelect(id);\n }, [id, treeContext]);\n\n // Context menu\n const menuItems = useMemo(() => {\n const menuItems: iMenuItem[] = [];\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 if (!treeContext) return <></>;\n return (\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 && 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 aria-disabled={true}\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 && setValue(currentValue);\n }, [currentValue, setValue]);\n\n const keyPress = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.code === 'Escape') {\n setCurrentValue(value ?? '');\n sendEscape && 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 shouldExpand.filter((n) => !expandedNodes.includes(n)).length > 0 &&\n setExpandedNodes(shouldExpand);\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,M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,GAAA,sBAAQ,EAAE;QACR,IAAI,cAAc,MAAM,GAAG,GAAG;YAC5B,6CAA6C;YAC7C,MAAM,eAAe,CAAA,GAAA,yCAAiB,EAAE,UAAU,eAAe;YACjE,aAAa,MAAM,CAAC,CAAC,IAAM,CAAC,cAAc,QAAQ,CAAC,IAAI,MAAM,GAAG,KAC9D,iBAAiB;QACrB;IACF,GAAG;QAAC;QAAe;QAAU;KAAc;IAE3C,uCAAuC;IACvC,MAAM,eAAe,CAAA,GAAA,wBAAU,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,gCAAC,CAAA,GAAA,yCAAiB,EAAE,QAAQ;QAC1B,OAAO;YACL,IAAI;sBACJ;YACA,UAAU;0BACV;0BACA;2BACA;YACA,mBAAmB,CAAC,GAAG,IAAM,aAAa,GAAG;YAC7C,YAAY;sBACZ;sBACA;2BACA;2BACA;wBACA;QACF;kBAEC,MAAM,GAAG,CAAC,CAAC,kBACV,gCAAC,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, iMenuItem } from \"@asup/context-menu\";\nimport { Key, useCallback, useContext, useEffect, useMemo, useRef, useState } 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): JSX.Element => {\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 && 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 && treeContext.handleSelect && treeContext.handleSelect(id);\n }, [id, treeContext]);\n\n // Context menu\n const menuItems = useMemo(() => {\n const menuItems: iMenuItem[] = [];\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 if (!treeContext) return <></>;\n return (\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 && 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 && setValue(currentValue);\n }, [currentValue, setValue]);\n\n const keyPress = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.code === \"Escape\") {\n setCurrentValue(value ?? \"\");\n sendEscape && 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 shouldExpand.filter((n) => !expandedNodes.includes(n)).length > 0 &&\n setExpandedNodes(shouldExpand);\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"}
|
package/dist/main.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;AAKA;;;;AAIA;;;;;;;AAOA;;;;;AAIA;;;;;;;
|
|
1
|
+
{"mappings":"AAAA;;;;;AAKA;;;;AAIA;;;;;;;AAOA;;;;;AAIA;;;;;;;AAQA;;;;;;AAKA;;;;;;;AASA;;;;;;AAKA;;;;AAGA","sources":["src/components/TreeNode.css"],"sourcesContent":[".ton-checkbox {\n margin-right: 3px;\n margin-top: 3px;\n}\n\n.ton-expander {\n margin-bottom: 4px;\n}\n\n.ton-child {\n margin-left: 16px;\n display: block;\n opacity: 1;\n transition: opacity 0.6s linear;\n}\n\n.ton-collapsible-wrapper {\n display: flex;\n overflow: hidden;\n}\n.ton-collapsible-wrapper:after {\n content: \"\";\n height: 20px;\n transition:\n height 0.3s linear,\n max-height 0s 0.3s linear;\n max-height: 0px;\n}\n.ton-collapsible {\n transition: margin-bottom 0.3s cubic-bezier(0, 0, 0, 1);\n margin-bottom: 0;\n max-height: 10000px;\n}\n.ton-collapsible-wrapper.collapsed > .ton-collapsible {\n margin-bottom: -2000px;\n transition:\n margin-bottom 0.3s cubic-bezier(1, 0, 1, 1),\n visibility 0s 0.3s,\n max-height 0s 0.3s;\n visibility: hidden;\n max-height: 0;\n}\n.ton-collapsible-wrapper.collapsed:after {\n height: 0;\n transition: height 0.3s linear;\n max-height: 20px;\n}\n.ton-collapsible-wrapper.collapsed {\n visibility: hidden;\n}\n.ton-collapsible-wrapper.collapsed .ton-child {\n opacity: 0;\n transition: opacity 0.6s linear;\n}\n"],"names":[],"version":3,"file":"main.css.map"}
|
package/dist/main.js
CHANGED
|
@@ -5,6 +5,7 @@ import $duWW8$react, {useContext as $duWW8$useContext, useMemo as $duWW8$useMemo
|
|
|
5
5
|
import {ExclamationCircleFill as $duWW8$ExclamationCircleFill, CaretRightFill as $duWW8$CaretRightFill, CaretDownFill as $duWW8$CaretDownFill, CaretRight as $duWW8$CaretRight} from "react-bootstrap-icons";
|
|
6
6
|
import {Spinner as $duWW8$Spinner} from "react-bootstrap";
|
|
7
7
|
|
|
8
|
+
|
|
8
9
|
function $parcel$export(e, n, v, s) {
|
|
9
10
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
11
|
}
|
|
@@ -133,20 +134,16 @@ const $47c36cf4281201f5$export$2eba8ec3a333fdbb = ({ id: id, canRemove: canRemov
|
|
|
133
134
|
// Contexts
|
|
134
135
|
const treeContext = (0, $duWW8$useContext)((0, $886f402bccb0fd30$export$29ec378200e05207));
|
|
135
136
|
// Node information
|
|
136
|
-
const thisNode = (0, $duWW8$useMemo)(()=>
|
|
137
|
-
return treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList.find((n)=>n.id === id);
|
|
138
|
-
}, [
|
|
137
|
+
const thisNode = (0, $duWW8$useMemo)(()=>treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList.find((n)=>n.id === id), [
|
|
139
138
|
id,
|
|
140
139
|
treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList
|
|
141
140
|
]);
|
|
142
|
-
const childNodes = (0, $duWW8$useMemo)(()=>
|
|
143
|
-
return treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList.filter((n)=>n.parentId === id);
|
|
144
|
-
}, [
|
|
141
|
+
const childNodes = (0, $duWW8$useMemo)(()=>treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList.filter((n)=>n.parentId === id), [
|
|
145
142
|
id,
|
|
146
143
|
treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList
|
|
147
144
|
]);
|
|
148
|
-
var _treeContext_nodeList;
|
|
149
145
|
const descendents = (0, $duWW8$useMemo)(()=>{
|
|
146
|
+
var _treeContext_nodeList;
|
|
150
147
|
return (0, $33abc00b1ca5c55c$export$bd923365b402cb04)(id, (_treeContext_nodeList = treeContext === null || treeContext === void 0 ? void 0 : treeContext.nodeList) !== null && _treeContext_nodeList !== void 0 ? _treeContext_nodeList : []);
|
|
151
148
|
}, [
|
|
152
149
|
id,
|
|
@@ -169,9 +166,7 @@ const $47c36cf4281201f5$export$2eba8ec3a333fdbb = ({ id: id, canRemove: canRemov
|
|
|
169
166
|
if (treeContext === null || treeContext === void 0 ? void 0 : treeContext.selected.includes(id)) {
|
|
170
167
|
checkRef.current.checked = true;
|
|
171
168
|
checkRef.current.indeterminate = false;
|
|
172
|
-
} else if (descendents.some((d)=>{
|
|
173
|
-
return treeContext === null || treeContext === void 0 ? void 0 : treeContext.selected.includes(d);
|
|
174
|
-
})) {
|
|
169
|
+
} else if (descendents.some((d)=>treeContext === null || treeContext === void 0 ? void 0 : treeContext.selected.includes(d))) {
|
|
175
170
|
checkRef.current.checked = false;
|
|
176
171
|
checkRef.current.indeterminate = true;
|
|
177
172
|
} else {
|
|
@@ -355,7 +350,7 @@ const $47c36cf4281201f5$export$2eba8ec3a333fdbb = ({ id: id, canRemove: canRemov
|
|
|
355
350
|
color: nodeColour,
|
|
356
351
|
"aria-expanded": false,
|
|
357
352
|
"aria-label": "Disabled expander",
|
|
358
|
-
|
|
353
|
+
onClick: ()=>treeContext.handleSelect && treeContext.handleSelect(id)
|
|
359
354
|
}),
|
|
360
355
|
thisNode && /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
361
356
|
style: {
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;AGGO,MAAM,4CAAe,CAC1B,IACA,UACA;IAEA,MAAM,aAAa,MAAM,QAAQ,MAAM,KAAK;QAAC;KAAG;IAEhD,MAAM,UAAU,WACb,IAAI,CAAC,IAAM,eAAe,KAAK,CAAC,IAAM,EAAE,OAAO,IAC/C,OAAO,CAAC,IAAM,MAAM;IACvB,IAAI,QAAQ,WAAW,GAAG,OAAO;IAEjC,MAAM,UAAU,AACd,QACG,IAAI,CAAC,IAAM,EAAE,UACb,IAAI,CAAC,MAAQ,eAAe,KAAK,CAAC,IAAM,QAAQ,EAAE,KACrD,OAAO,CAAC,IAAM,MAAM;IACtB,IAAI,QAAQ,WAAW,GAAG,OAAO;SAE/B,OAAO,0CACL,QAAQ,IAAI,CAAC,IAAM,EAAE,KACrB;WAAI;WAAa,QAAQ,OAAO,CAAC,IAAM,CAAC,SAAS,SAAS;KAAI,EAC9D;AAEN;;;ACxBO,MAAM,4C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;;","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, iMenuItem } from '@asup/context-menu';\nimport { Key, useCallback, useContext, useEffect, useMemo, useRef, useState } 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): JSX.Element => {\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 && 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 && treeContext.handleSelect && treeContext.handleSelect(id);\n }, [id, treeContext]);\n\n // Context menu\n const menuItems = useMemo(() => {\n const menuItems: iMenuItem[] = [];\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 if (!treeContext) return <></>;\n return (\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 && 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 aria-disabled={true}\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 && setValue(currentValue);\n }, [currentValue, setValue]);\n\n const keyPress = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.code === 'Escape') {\n setCurrentValue(value ?? '');\n sendEscape && 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 shouldExpand.filter((n) => !expandedNodes.includes(n)).length > 0 &&\n setExpandedNodes(shouldExpand);\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/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AC,YAAY,WAAW;YAAC;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,aAAa,MAAM,CAAC,CAAC,IAAM,CAAC,cAAc,QAAQ,CAAC,IAAI,MAAM,GAAG,KAC9D,iBAAiB;QACrB;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,CAAA,GAAA,yCAAiB,EAAE,QAAQ;QAC1B,OAAO;YACL,IAAI;sBACJ;YACA,UAAU;0BACV;0BACA;2BACA;YACA,mBAAmB,CAAC,GAAG,IAAM,aAAa,GAAG;YAC7C,YAAY;sBACZ;sBACA;2BACA;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, iMenuItem } from \"@asup/context-menu\";\nimport { Key, useCallback, useContext, useEffect, useMemo, useRef, useState } 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): JSX.Element => {\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 && 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 && treeContext.handleSelect && treeContext.handleSelect(id);\n }, [id, treeContext]);\n\n // Context menu\n const menuItems = useMemo(() => {\n const menuItems: iMenuItem[] = [];\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 if (!treeContext) return <></>;\n return (\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 && 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 && setValue(currentValue);\n }, [currentValue, setValue]);\n\n const keyPress = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.code === \"Escape\") {\n setCurrentValue(value ?? \"\");\n sendEscape && 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 shouldExpand.filter((n) => !expandedNodes.includes(n)).length > 0 &&\n setExpandedNodes(shouldExpand);\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"}
|
package/dist/tree-of-nodes.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ interface WordEntryProps {
|
|
|
20
20
|
setValue?: (ret: string) => void;
|
|
21
21
|
sendEscape?: () => void;
|
|
22
22
|
style?: React.CSSProperties;
|
|
23
|
-
spellCheck?:
|
|
23
|
+
spellCheck?: "true" | "false";
|
|
24
24
|
}
|
|
25
25
|
export const WordEntry: React.ForwardRefExoticComponent<WordEntryProps & React.RefAttributes<HTMLInputElement>>;
|
|
26
26
|
interface TreeNodeProps {
|
|
@@ -54,7 +54,7 @@ interface TreeOfNodesProps<T> {
|
|
|
54
54
|
canRenameChildren?: boolean;
|
|
55
55
|
nodeHighlight?: string;
|
|
56
56
|
textHighlight?: string;
|
|
57
|
-
spellCheck?:
|
|
57
|
+
spellCheck?: "true" | "false";
|
|
58
58
|
}
|
|
59
59
|
export const TreeOfNodes: {
|
|
60
60
|
<T extends unknown>({ id, nodeList, roots, selected, showCheckBox, handleSelect, onAdd, onRename, onRemove, canRemoveRoot, canRenameRoot, canAddChildren, canRemoveChildren, canRenameChildren, nodeHighlight, textHighlight, spellCheck, }: TreeOfNodesProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -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,mBACP,GAAG,GAAG,GAAG,EAAE,YACL,YAAY,EAAE,kBACR,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,EA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AM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/B;AAGD,OAAO,MAAM;;;CA4EZ,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asup/tree-of-nodes",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "REACT Typescript Treeview component",
|
|
5
5
|
"author": "Paul Thomas <@PaulDThomas>",
|
|
6
6
|
"private": false,
|
|
@@ -39,29 +39,29 @@
|
|
|
39
39
|
"@parcel/transformer-sass": "^2.7.0",
|
|
40
40
|
"@parcel/transformer-typescript-types": "^2.8.0",
|
|
41
41
|
"@parcel/transformer-webmanifest": "^2.7.0",
|
|
42
|
-
"@testing-library/jest-dom": "^
|
|
42
|
+
"@testing-library/jest-dom": "^6.1.4",
|
|
43
43
|
"@testing-library/react": "^14.0.0",
|
|
44
44
|
"@testing-library/user-event": "^14.4.3",
|
|
45
45
|
"@types/jest": "^29.2.2",
|
|
46
|
-
"@types/node": "^
|
|
46
|
+
"@types/node": "^20.9.5",
|
|
47
47
|
"@types/react": "^18.0.25",
|
|
48
48
|
"@types/react-dom": "^18.0.8",
|
|
49
49
|
"@types/rollup-plugin-peer-deps-external": "^2.2.1",
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
51
|
-
"@typescript-eslint/parser": "^
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
51
|
+
"@typescript-eslint/parser": "^6.12.0",
|
|
52
52
|
"eslint": "^8.32.0",
|
|
53
|
-
"eslint-config-prettier": "^
|
|
54
|
-
"eslint-plugin-prettier": "^
|
|
53
|
+
"eslint-config-prettier": "^9.0.0",
|
|
54
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
55
55
|
"eslint-plugin-react": "^7.31.10",
|
|
56
56
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
57
57
|
"husky": "^8.0.1",
|
|
58
58
|
"jest": "^29.2.2",
|
|
59
59
|
"jest-environment-jsdom": "^29.3.1",
|
|
60
60
|
"jest-watch-typeahead": "^2.2.2",
|
|
61
|
-
"lint-staged": "^
|
|
61
|
+
"lint-staged": "^15.1.0",
|
|
62
62
|
"parcel": "^2.7.0",
|
|
63
63
|
"postcss": "^8.4.18",
|
|
64
|
-
"prettier": "^
|
|
64
|
+
"prettier": "^3.1.0",
|
|
65
65
|
"process": "^0.11.10",
|
|
66
66
|
"ts-jest": "^29.0.3",
|
|
67
67
|
"ts-node": "^10.9.1",
|
|
@@ -76,12 +76,6 @@
|
|
|
76
76
|
"files": [
|
|
77
77
|
"dist"
|
|
78
78
|
],
|
|
79
|
-
"eslintConfig": {
|
|
80
|
-
"extends": [
|
|
81
|
-
"react-app",
|
|
82
|
-
"react-app/jest"
|
|
83
|
-
]
|
|
84
|
-
},
|
|
85
79
|
"browserslist": {
|
|
86
80
|
"production": [
|
|
87
81
|
">0.2%",
|