@asup/tree-of-nodes 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/main.css +36 -1
- package/dist/cjs/main.css.map +1 -1
- package/dist/cjs/main.js +159 -143
- package/dist/cjs/main.js.map +1 -1
- package/dist/main.css +36 -1
- package/dist/main.css.map +1 -1
- package/dist/main.js +160 -144
- package/dist/main.js.map +1 -1
- package/dist/tree-of-nodes.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/main.css
CHANGED
|
@@ -4,7 +4,39 @@
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
.ton-expander {
|
|
7
|
-
margin
|
|
7
|
+
margin: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.ton-node {
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
align-items: center;
|
|
13
|
+
width: 100%;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
height: 34px;
|
|
16
|
+
display: flex;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.ton-label {
|
|
20
|
+
height: 34px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ton-label-span {
|
|
24
|
+
text-overflow: ellipsis;
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
width: 100%;
|
|
27
|
+
display: inline-block;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.ton-rename-holder {
|
|
32
|
+
width: 100%;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.ton-rename {
|
|
36
|
+
border: 1px dotted #000;
|
|
37
|
+
width: 100%;
|
|
38
|
+
min-width: 0;
|
|
39
|
+
line-height: .75rem;
|
|
8
40
|
}
|
|
9
41
|
|
|
10
42
|
.ton-child {
|
|
@@ -15,6 +47,8 @@
|
|
|
15
47
|
}
|
|
16
48
|
|
|
17
49
|
.ton-collapsible-wrapper {
|
|
50
|
+
width: 100%;
|
|
51
|
+
max-width: 100%;
|
|
18
52
|
display: flex;
|
|
19
53
|
overflow: hidden;
|
|
20
54
|
}
|
|
@@ -27,6 +61,7 @@
|
|
|
27
61
|
}
|
|
28
62
|
|
|
29
63
|
.ton-collapsible {
|
|
64
|
+
width: 100%;
|
|
30
65
|
max-height: 10000px;
|
|
31
66
|
margin-bottom: 0;
|
|
32
67
|
transition: margin-bottom .3s cubic-bezier(0, 0, 0, 1);
|
package/dist/cjs/main.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;AAKA;;;;AAIA;;;;;;;AAOA
|
|
1
|
+
{"mappings":"AAAA;;;;;AAKA;;;;AAIA;;;;;;;;;AASA;;;;AAIA;;;;;;;;AAQA;;;;AAIA;;;;;;;AAOA;;;;;;;AAOA;;;;;;;AAMA;;;;;;;AAQA;;;;;;;AAMA;;;;;;;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: 0;\n}\n\n.ton-node {\n display: flex;\n align-items: center;\n cursor: pointer;\n width: 100%;\n max-width: 100%;\n height: 34px;\n}\n\n.ton-label {\n height: 34px;\n}\n\n.ton-label-span {\n display: inline-block;\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.ton-rename-holder {\n width: 100%;\n}\n\n.ton-rename {\n line-height: 0.75rem;\n border: 1px dotted black;\n width: 100%;\n min-width: 0;\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 width: 100%;\n max-width: 100%;\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 width: 100%;\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
|
@@ -114,6 +114,7 @@ const $176d21a51def1fce$export$14f190ac910bde69 = /*#__PURE__*/ (0, ($parcel$int
|
|
|
114
114
|
]);
|
|
115
115
|
// Simple if not editing
|
|
116
116
|
if (!editing) return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
|
|
117
|
+
className: "ton-label-span",
|
|
117
118
|
style: currentStyle,
|
|
118
119
|
id: `${id}`,
|
|
119
120
|
children: value ? value : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactjsxruntime.Fragment), {
|
|
@@ -123,6 +124,7 @@ const $176d21a51def1fce$export$14f190ac910bde69 = /*#__PURE__*/ (0, ($parcel$int
|
|
|
123
124
|
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
|
|
124
125
|
style: currentStyle,
|
|
125
126
|
id: `${id}-holder`,
|
|
127
|
+
className: "ton-rename-holder",
|
|
126
128
|
children: [
|
|
127
129
|
saving && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrap.Spinner), {
|
|
128
130
|
id: `${id}-spinner`,
|
|
@@ -135,12 +137,7 @@ const $176d21a51def1fce$export$14f190ac910bde69 = /*#__PURE__*/ (0, ($parcel$int
|
|
|
135
137
|
id: String(id),
|
|
136
138
|
ref: ref,
|
|
137
139
|
type: "text",
|
|
138
|
-
|
|
139
|
-
lineHeight: "0.75rem",
|
|
140
|
-
border: "1px dotted black",
|
|
141
|
-
width: "auto",
|
|
142
|
-
minWidth: "0"
|
|
143
|
-
},
|
|
140
|
+
className: "ton-rename",
|
|
144
141
|
value: currentValue,
|
|
145
142
|
disabled: saving,
|
|
146
143
|
onChange: (e)=>setCurrentValue(e.currentTarget.value),
|
|
@@ -321,124 +318,139 @@ const $a56aac35d4408806$export$2eba8ec3a333fdbb = ({ id: id, canRemove: canRemov
|
|
|
321
318
|
renameThis
|
|
322
319
|
]);
|
|
323
320
|
// Return node
|
|
324
|
-
return !treeContext ? null : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
onClick: ()=>treeContext.handleExpandClick(id)
|
|
360
|
-
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretDownFill), {
|
|
361
|
-
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
362
|
-
className: "ton-expander",
|
|
363
|
-
role: "button",
|
|
364
|
-
"aria-expanded": true,
|
|
365
|
-
"aria-label": "Expander",
|
|
366
|
-
color: nodeColour,
|
|
367
|
-
onClick: ()=>{
|
|
368
|
-
treeContext.handleExpandClick(id);
|
|
369
|
-
}
|
|
370
|
-
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretRight), {
|
|
371
|
-
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
372
|
-
className: "ton-expander",
|
|
373
|
-
role: "button",
|
|
374
|
-
color: nodeColour,
|
|
375
|
-
"aria-expanded": false,
|
|
376
|
-
"aria-label": "Disabled expander",
|
|
377
|
-
onClick: ()=>treeContext.handleSelect && treeContext.handleSelect(id)
|
|
378
|
-
}),
|
|
379
|
-
thisNode && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
380
|
-
style: {
|
|
381
|
-
display: "inline-block"
|
|
382
|
-
},
|
|
383
|
-
onContextMenuCapture: ()=>treeContext.handleSelect && treeContext.handleSelect(id),
|
|
384
|
-
onClickCapture: ()=>treeContext.handleSelect && treeContext.handleSelect(id),
|
|
385
|
-
onFocusCapture: ()=>treeContext.handleSelect && treeContext.handleSelect(id),
|
|
386
|
-
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $176d21a51def1fce$export$14f190ac910bde69), {
|
|
387
|
-
id: `${treeContext.id}-treenode-entry-${id}`,
|
|
388
|
-
ref: currentNameRef,
|
|
389
|
-
value: thisNode.label,
|
|
390
|
-
editing: renaming,
|
|
391
|
-
saving: updatingNode,
|
|
392
|
-
setValue: (ret)=>renameNode(ret),
|
|
393
|
-
sendEscape: ()=>setRenaming(false),
|
|
321
|
+
return !treeContext ? null : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)((0, $gTuX4$reactjsxruntime.Fragment), {
|
|
322
|
+
children: [
|
|
323
|
+
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$asupcontextmenu.ContextMenuHandler), {
|
|
324
|
+
menuItems: menuItems,
|
|
325
|
+
style: {
|
|
326
|
+
display: "inline-block",
|
|
327
|
+
width: "100%"
|
|
328
|
+
},
|
|
329
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
330
|
+
id: `${treeContext.id}-treenode-${id}`,
|
|
331
|
+
className: "treenode",
|
|
332
|
+
children: error ? /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)((0, $gTuX4$reactjsxruntime.Fragment), {
|
|
333
|
+
children: [
|
|
334
|
+
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.ExclamationCircleFill), {
|
|
335
|
+
color: "var(--bs-danger)"
|
|
336
|
+
}),
|
|
337
|
+
" ",
|
|
338
|
+
errorText
|
|
339
|
+
]
|
|
340
|
+
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
|
|
341
|
+
className: "ton-node",
|
|
342
|
+
children: [
|
|
343
|
+
treeContext.showCheckBox && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("input", {
|
|
344
|
+
ref: checkRef,
|
|
345
|
+
type: "checkbox",
|
|
346
|
+
role: "checkbox",
|
|
347
|
+
className: "ton-checkbox",
|
|
348
|
+
id: `${treeContext.id}-treenode-checkbox-${id}`,
|
|
349
|
+
onClick: ()=>{
|
|
350
|
+
var _treeContext_handleSelect;
|
|
351
|
+
return treeContext === null || treeContext === void 0 ? void 0 : (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, descendents);
|
|
352
|
+
}
|
|
353
|
+
}),
|
|
354
|
+
childNodes !== undefined && childNodes.length > 0 ? !expanded ? /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretRightFill), {
|
|
355
|
+
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
394
356
|
style: {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
backgroundColor: currentBorder === "" ? "" : treeContext.textHighlight
|
|
357
|
+
width: "16px",
|
|
358
|
+
height: "16px"
|
|
398
359
|
},
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
360
|
+
className: "ton-expander",
|
|
361
|
+
role: "button",
|
|
362
|
+
color: nodeColour,
|
|
363
|
+
"aria-expanded": false,
|
|
364
|
+
"aria-label": "Expander",
|
|
365
|
+
onClick: ()=>treeContext.handleExpandClick(id)
|
|
366
|
+
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretDownFill), {
|
|
367
|
+
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
368
|
+
className: "ton-expander",
|
|
369
|
+
role: "button",
|
|
370
|
+
"aria-expanded": true,
|
|
371
|
+
"aria-label": "Expander",
|
|
372
|
+
color: nodeColour,
|
|
373
|
+
onClick: ()=>treeContext.handleExpandClick(id)
|
|
374
|
+
}) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactbootstrapicons.CaretRight), {
|
|
375
|
+
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
376
|
+
className: "ton-expander",
|
|
377
|
+
role: "button",
|
|
378
|
+
color: nodeColour,
|
|
379
|
+
"aria-expanded": false,
|
|
380
|
+
"aria-label": "Disabled expander",
|
|
381
|
+
onClick: ()=>{
|
|
382
|
+
var _treeContext_handleSelect;
|
|
383
|
+
return (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, id);
|
|
384
|
+
}
|
|
385
|
+
}),
|
|
386
|
+
thisNode && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
387
|
+
className: "ton-label",
|
|
388
|
+
style: {
|
|
389
|
+
width: `calc(100% - ${treeContext.showCheckBox ? "32px" : "16px"})`
|
|
390
|
+
},
|
|
391
|
+
onContextMenuCapture: ()=>{
|
|
392
|
+
var _treeContext_handleSelect;
|
|
393
|
+
return (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, id);
|
|
394
|
+
},
|
|
395
|
+
onClickCapture: ()=>{
|
|
396
|
+
var _treeContext_handleSelect;
|
|
397
|
+
return (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, id);
|
|
398
|
+
},
|
|
399
|
+
onFocusCapture: ()=>{
|
|
400
|
+
var _treeContext_handleSelect;
|
|
401
|
+
return (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, id);
|
|
402
|
+
},
|
|
403
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $176d21a51def1fce$export$14f190ac910bde69), {
|
|
404
|
+
id: `${treeContext.id}-treenode-entry-${id}`,
|
|
405
|
+
ref: currentNameRef,
|
|
406
|
+
value: thisNode.label,
|
|
407
|
+
editing: renaming,
|
|
408
|
+
saving: updatingNode,
|
|
409
|
+
setValue: (ret)=>renameNode(ret),
|
|
410
|
+
sendEscape: ()=>setRenaming(false),
|
|
411
|
+
style: {
|
|
412
|
+
border: currentBorder,
|
|
413
|
+
margin: currentBorder === "" ? "1px" : "",
|
|
414
|
+
backgroundColor: currentBorder === "" ? "" : treeContext.textHighlight
|
|
415
|
+
},
|
|
416
|
+
spellCheck: treeContext.spellCheck
|
|
418
417
|
})
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
}),
|
|
422
|
-
showNewNode && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
423
|
-
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $176d21a51def1fce$export$14f190ac910bde69), {
|
|
424
|
-
style: {
|
|
425
|
-
marginLeft: "14px"
|
|
426
|
-
},
|
|
427
|
-
id: `treenode-new-${id}`,
|
|
428
|
-
ref: newNameRef,
|
|
429
|
-
editing: true,
|
|
430
|
-
setValue: (ret)=>{
|
|
431
|
-
confirmNewNode(ret);
|
|
432
|
-
},
|
|
433
|
-
saving: savingNewNode,
|
|
434
|
-
sendEscape: ()=>{
|
|
435
|
-
setShowNewNode(false);
|
|
436
|
-
},
|
|
437
|
-
spellCheck: treeContext.spellCheck
|
|
418
|
+
})
|
|
419
|
+
]
|
|
438
420
|
})
|
|
439
421
|
})
|
|
440
|
-
|
|
441
|
-
|
|
422
|
+
}),
|
|
423
|
+
showNewNode && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $176d21a51def1fce$export$14f190ac910bde69), {
|
|
424
|
+
style: {
|
|
425
|
+
marginLeft: "14px"
|
|
426
|
+
},
|
|
427
|
+
id: `treenode-new-${id}`,
|
|
428
|
+
ref: newNameRef,
|
|
429
|
+
editing: true,
|
|
430
|
+
setValue: (ret)=>confirmNewNode(ret),
|
|
431
|
+
saving: savingNewNode,
|
|
432
|
+
sendEscape: ()=>setShowNewNode(false),
|
|
433
|
+
spellCheck: treeContext.spellCheck
|
|
434
|
+
}),
|
|
435
|
+
childNodes !== undefined && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
436
|
+
className: `ton-collapsible-wrapper ${expanded ? "" : "collapsed"}`,
|
|
437
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
438
|
+
className: "ton-collapsible",
|
|
439
|
+
children: childNodes.map((h)=>/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
|
|
440
|
+
id: `${treeContext.id}-treenode-child-${h.id}`,
|
|
441
|
+
className: "ton-child",
|
|
442
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)($a56aac35d4408806$export$2eba8ec3a333fdbb, {
|
|
443
|
+
id: h.id,
|
|
444
|
+
canRemove: canRemoveChildren,
|
|
445
|
+
canRename: canRenameChildren,
|
|
446
|
+
canAddChildren: canAddChildren,
|
|
447
|
+
canRemoveChildren: canRemoveChildren,
|
|
448
|
+
canRenameChildren: canRenameChildren
|
|
449
|
+
})
|
|
450
|
+
}, h.id))
|
|
451
|
+
})
|
|
452
|
+
})
|
|
453
|
+
]
|
|
442
454
|
});
|
|
443
455
|
};
|
|
444
456
|
$a56aac35d4408806$export$2eba8ec3a333fdbb.displayName = "TreeNode";
|
|
@@ -487,30 +499,34 @@ const $9becaaec3a803ae7$export$5580fff3e08a8be5 = ({ id: id, nodeList: nodeList,
|
|
|
487
499
|
}, [
|
|
488
500
|
expandedNodes
|
|
489
501
|
]);
|
|
490
|
-
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)(
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
502
|
+
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
503
|
+
id: id,
|
|
504
|
+
className: "tree-of-nodes",
|
|
505
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $ff9cca1fe8f6b24e$export$29ec378200e05207).Provider, {
|
|
506
|
+
value: {
|
|
507
|
+
id: id,
|
|
508
|
+
nodeList: nodeList,
|
|
509
|
+
selected: selectedArray,
|
|
510
|
+
showCheckBox: showCheckBox,
|
|
511
|
+
handleSelect: handleSelect,
|
|
512
|
+
expandedNodes: expandedNodes,
|
|
513
|
+
handleExpandClick: (r, f)=>changeExpand(r, f),
|
|
514
|
+
onAddChild: onAdd,
|
|
515
|
+
onRename: onRename,
|
|
516
|
+
onRemove: onRemove,
|
|
517
|
+
nodeHighlight: nodeHighlight,
|
|
518
|
+
textHighlight: textHighlight,
|
|
519
|
+
spellCheck: spellCheck
|
|
520
|
+
},
|
|
521
|
+
children: roots.map((r)=>/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $a56aac35d4408806$export$2eba8ec3a333fdbb), {
|
|
522
|
+
id: r,
|
|
523
|
+
canRemove: canRemoveRoot,
|
|
524
|
+
canAddChildren: canAddChildren,
|
|
525
|
+
canRename: canRenameRoot,
|
|
526
|
+
canRemoveChildren: canRemoveChildren,
|
|
527
|
+
canRenameChildren: canRenameChildren
|
|
528
|
+
}, r))
|
|
529
|
+
})
|
|
514
530
|
});
|
|
515
531
|
};
|
|
516
532
|
$9becaaec3a803ae7$export$5580fff3e08a8be5.displayName = "TreeOfNodes";
|
package/dist/cjs/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AGGO,MAAM,4CAAe,CAC1B,IACA,UACA;IAEA,MAAM,aAAa,MAAM,OAAO,CAAC,MAAM,KAAK;QAAC;KAAG;IAEhD,MAAM,UAAU,WACb,GAAG,CAAC,CAAC,IAAM,eAAe,IAAI,CAAC,CAAC,IAAM,EAAE,EAAE,KAAK,IAC/C,MAAM,CAAC,CAAC,IAAM,MAAM;IACvB,IAAI,QAAQ,MAAM,KAAK,GAAG,OAAO;IAEjC,MAAM,UAAU,AACd,QACG,GAAG,CAAC,CAAC,IAAM,EAAE,QAAQ,EACrB,GAAG,CAAC,CAAC,MAAQ,eAAe,IAAI,CAAC,CAAC,IAAM,QAAQ,EAAE,EAAE,GACvD,MAAM,CAAC,CAAC,IAAM,MAAM;IACtB,IAAI,QAAQ,MAAM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e;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, MenuItem } from \"@asup/context-menu\";\nimport {\n Key,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n CaretDownFill,\n CaretRight,\n CaretRightFill,\n ExclamationCircleFill,\n} from \"react-bootstrap-icons\";\nimport { getAncestors } from \"../functions/getAncestors\";\nimport { getDescendentIds } from \"../functions/getDescendentIds\";\nimport \"./TreeNode.css\";\nimport { TreeOfNodesContext } from \"./TreeOfNodesContext\";\nimport { WordEntry } from \"./WordEntry\";\nimport { iNodeUpdate } from \"./interface\";\n\ninterface TreeNodeProps {\n id: Key;\n indentLevel?: number;\n canRemove?: boolean;\n canRename?: boolean;\n canAddChildren?: boolean;\n canRemoveChildren?: boolean;\n canRenameChildren?: boolean;\n refresh?: () => void;\n}\n\nexport const TreeNode = ({\n id,\n canRemove,\n canRename,\n canAddChildren,\n canRemoveChildren,\n canRenameChildren,\n}: TreeNodeProps): ReactNode => {\n // Contexts\n const treeContext = useContext(TreeOfNodesContext);\n\n // Node information\n const thisNode = useMemo(\n () => treeContext?.nodeList.find((n) => n.id === id),\n [id, treeContext?.nodeList],\n );\n const childNodes = useMemo(\n () => treeContext?.nodeList.filter((n) => n.parentId === id),\n [id, treeContext?.nodeList],\n );\n const descendents = useMemo(\n () => getDescendentIds(id, treeContext?.nodeList ?? []),\n [id, treeContext],\n );\n\n // State\n const [error, setError] = useState<boolean>(false);\n const [errorText, setErrotText] = useState<string>(\"\");\n const expanded = useMemo(() => {\n return (treeContext?.expandedNodes.findIndex((e) => e === id) ?? -1) > -1;\n }, [id, treeContext?.expandedNodes]);\n\n // Checkbox\n const checkRef = useRef<HTMLInputElement | null>(null);\n useEffect(() => {\n if (checkRef.current) {\n if (treeContext?.selected.includes(id)) {\n checkRef.current.checked = true;\n checkRef.current.indeterminate = false;\n } else if (descendents.some((d) => treeContext?.selected.includes(d))) {\n checkRef.current.checked = false;\n checkRef.current.indeterminate = true;\n } else {\n checkRef.current.checked = false;\n checkRef.current.indeterminate = false;\n }\n }\n }, [descendents, id, treeContext?.selected]);\n\n // Apply selected border\n const currentBorder = useMemo<string>(() => {\n return treeContext?.selected.includes(id) ? \"1px solid black\" : \"\";\n }, [id, treeContext?.selected]);\n const nodeColour = useMemo<string | undefined>(() => {\n if (treeContext && treeContext.selected) {\n const anc = getAncestors(treeContext.selected, [], treeContext?.nodeList).map((n) => n.id);\n if ([...anc, treeContext.selected].includes(id)) return treeContext.nodeHighlight;\n }\n return;\n }, [id, treeContext]);\n\n // New node parameters\n const newNameRef = useRef<HTMLInputElement | null>(null);\n const [showNewNode, setShowNewNode] = useState<boolean>(false);\n const [savingNewNode, setSavingNewNode] = useState<boolean>(false);\n\n // Rename parameters\n const currentNameRef = useRef<HTMLInputElement | null>(null);\n const [renaming, setRenaming] = useState<boolean>(false);\n const [updatingNode, setUpdatingNode] = useState<boolean>(false);\n\n // Context functions\n const handleReturn = useCallback((ret: iNodeUpdate) => {\n if (!ret.success) {\n setError(true);\n setErrotText(ret.ErrorText ?? \"An unknown error has occured\");\n } else {\n setError(false);\n setErrotText(\"\");\n }\n }, []);\n\n const confirmNewNode = useCallback(\n async (label: string) => {\n setSavingNewNode(true);\n if (treeContext?.onAddChild) {\n handleReturn(await treeContext.onAddChild(id, label));\n }\n setSavingNewNode(false);\n setShowNewNode(false);\n },\n [handleReturn, id, treeContext],\n );\n\n const renameNode = useCallback(\n async (newLabel: string) => {\n setRenaming(false);\n if (treeContext?.onRename) {\n setUpdatingNode(true);\n handleReturn(await treeContext.onRename(id, newLabel));\n setUpdatingNode(false);\n }\n },\n [handleReturn, id, treeContext],\n );\n\n const deleteThis = useCallback(async () => {\n if (treeContext?.onRemove) {\n setUpdatingNode(true);\n handleReturn(await treeContext.onRemove(id));\n setUpdatingNode(false);\n }\n }, [handleReturn, id, treeContext]);\n\n // Context actions\n const addChild = useCallback(() => {\n setShowNewNode(true);\n treeContext?.handleExpandClick?.(id, true);\n }, [id, treeContext]);\n useEffect(() => {\n if (showNewNode === true && newNameRef.current) newNameRef.current.focus();\n }, [showNewNode]);\n const renameThis = useCallback(() => {\n setRenaming(true);\n treeContext?.handleSelect?.(id);\n }, [id, treeContext]);\n\n // Context menu\n const menuItems = useMemo(() => {\n const menuItems: MenuItem[] = [];\n if (canAddChildren) {\n menuItems.push({ label: \"Add\", action: addChild });\n }\n if (canRename) {\n menuItems.push({ label: \"Rename\", action: renameThis });\n }\n if (canRemove && (childNodes === undefined || childNodes.length === 0)) {\n menuItems.push({ label: \"Delete\", action: deleteThis });\n }\n return menuItems;\n }, [addChild, canAddChildren, canRemove, canRename, childNodes, deleteThis, renameThis]);\n\n // Return node\n return !treeContext ? null : (\n <ContextMenuHandler menuItems={menuItems}>\n <div\n id={`${treeContext.id}-treenode-${id}`}\n className=\"treenode\"\n >\n {error ? (\n <>\n <ExclamationCircleFill color=\"var(--bs-danger)\" /> {errorText}\n </>\n ) : (\n <div className=\"ton-node\">\n {treeContext.showCheckBox && (\n <input\n ref={checkRef}\n type=\"checkbox\"\n role=\"checkbox\"\n className=\"ton-checkbox\"\n id={`${treeContext.id}-treenode-checkbox-${id}`}\n onClick={() => {\n treeContext?.handleSelect?.(descendents);\n }}\n />\n )}\n {childNodes !== undefined && childNodes.length > 0 ? (\n !expanded ? (\n <CaretRightFill\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n color={nodeColour}\n aria-expanded={false}\n aria-label=\"Expander\"\n onClick={() => treeContext.handleExpandClick(id)}\n />\n ) : (\n <CaretDownFill\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n aria-expanded={true}\n aria-label=\"Expander\"\n color={nodeColour}\n onClick={() => {\n treeContext.handleExpandClick(id);\n }}\n />\n )\n ) : (\n <CaretRight\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n color={nodeColour}\n aria-expanded={false}\n aria-label=\"Disabled expander\"\n onClick={() => treeContext.handleSelect && treeContext.handleSelect(id)}\n />\n )}\n {thisNode && (\n <div\n style={{ display: \"inline-block\" }}\n onContextMenuCapture={() =>\n treeContext.handleSelect && treeContext.handleSelect(id)\n }\n onClickCapture={() => treeContext.handleSelect && treeContext.handleSelect(id)}\n onFocusCapture={() => treeContext.handleSelect && treeContext.handleSelect(id)}\n >\n <WordEntry\n id={`${treeContext.id}-treenode-entry-${id}`}\n ref={currentNameRef}\n value={thisNode.label}\n editing={renaming}\n saving={updatingNode}\n setValue={(ret) => renameNode(ret)}\n sendEscape={() => setRenaming(false)}\n style={{\n border: currentBorder,\n margin: currentBorder === \"\" ? \"1px\" : \"\",\n backgroundColor: currentBorder === \"\" ? \"\" : treeContext.textHighlight,\n }}\n spellCheck={treeContext.spellCheck}\n />\n </div>\n )}\n </div>\n )}\n {childNodes !== undefined && (\n <div className={`ton-collapsible-wrapper ${expanded ? \"\" : \"collapsed\"}`}>\n <div className=\"ton-collapsible\">\n {childNodes.map((h) => (\n <span\n key={h.id}\n id={`${treeContext.id}-treenode-child-${h.id}`}\n className=\"ton-child\"\n >\n <TreeNode\n id={h.id}\n canRemove={canRemoveChildren}\n canRename={canRenameChildren}\n canAddChildren={canAddChildren}\n canRemoveChildren={canRemoveChildren}\n canRenameChildren={canRenameChildren}\n />\n </span>\n ))}\n </div>\n </div>\n )}\n {showNewNode && (\n <div>\n <WordEntry\n style={{ marginLeft: \"14px\" }}\n id={`treenode-new-${id}`}\n ref={newNameRef}\n editing={true}\n setValue={(ret) => {\n confirmNewNode(ret);\n }}\n saving={savingNewNode}\n sendEscape={() => {\n setShowNewNode(false);\n }}\n spellCheck={treeContext.spellCheck}\n />\n </div>\n )}\n </div>\n </ContextMenuHandler>\n );\n};\n\nTreeNode.displayName = \"TreeNode\";\n","import { Key } from \"react\";\nimport { TreeNodeBase } from \"../components/interface\";\n\nexport const getAncestors = (\n id: Key | Key[],\n included: TreeNodeBase[],\n hierarchyNodes: TreeNodeBase[],\n): TreeNodeBase[] => {\n const processIds = Array.isArray(id) ? id : [id];\n\n const current = processIds\n .map((i) => hierarchyNodes.find((h) => h.id === i))\n .filter((h) => h !== undefined) as TreeNodeBase[];\n if (current.length === 0) return included;\n\n const parents = (\n current\n .map((h) => h.parentId)\n .map((pid) => hierarchyNodes.find((h) => pid === h.id)) as TreeNodeBase[]\n ).filter((p) => p !== undefined) as TreeNodeBase[];\n if (parents.length === 0) return included;\n else\n return getAncestors(\n parents.map((p) => p.id),\n [...included, ...parents.filter((p) => !included.includes(p))],\n hierarchyNodes,\n );\n};\n","import { Key } from \"react\";\nimport { TreeNodeBase } from \"../components/interface\";\n\nexport const getDescendentIds = (id: Key | Key[], hierarchyNodes: TreeNodeBase[]): Key[] => {\n const processIds = Array.isArray(id) ? id : [id];\n const newChildren = hierarchyNodes\n .filter(\n (h) =>\n h.parentId !== undefined && processIds.includes(h.parentId) && !processIds.includes(h.id),\n )\n .map((h) => h.id);\n return newChildren.length === 0\n ? processIds\n : getDescendentIds([...processIds, ...newChildren], hierarchyNodes);\n};\n","import { createContext, Key } from \"react\";\nimport { iNodeUpdate, TreeNodeData } from \"./interface\";\n\nexport interface TreeOfNodesContextProps<T> {\n id: string;\n nodeList: TreeNodeData<T>[];\n selected: Key[];\n showCheckBox: boolean;\n handleSelect?: (ret: Key | Key[]) => void;\n expandedNodes: Key[];\n handleExpandClick: (ret: Key, force?: boolean) => void;\n onAddChild?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;\n onRename?: (id: Key, newName: string) => Promise<iNodeUpdate>;\n onRemove?: (id: Key) => Promise<iNodeUpdate>;\n nodeHighlight: string;\n textHighlight: string;\n spellCheck?: \"true\" | \"false\";\n}\n\nexport const TreeOfNodesContext = createContext<TreeOfNodesContextProps<unknown> | undefined>(\n undefined,\n);\n","import React, { Key, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Spinner } from \"react-bootstrap\";\n\ninterface WordEntryProps {\n id: Key;\n value?: string;\n editing?: boolean;\n saving?: boolean;\n setValue?: (ret: string) => void;\n sendEscape?: () => void;\n style?: React.CSSProperties;\n spellCheck?: \"true\" | \"false\";\n}\n\nexport const WordEntry = React.forwardRef<HTMLInputElement, WordEntryProps>(\n (\n { id, value, editing, saving, setValue, sendEscape, style, spellCheck = \"true\" },\n ref,\n ): JSX.Element => {\n WordEntry.displayName = \"WordEntry\";\n const currentStyle = useMemo<React.CSSProperties>(() => {\n return {\n display: \"inline-block\",\n padding: \"1px\",\n paddingLeft: \"3px\",\n paddingRight: \"3px\",\n border: \"1px\",\n borderRadius: \"3px\",\n ...style,\n };\n }, [style]);\n\n const [currentValue, setCurrentValue] = useState<string>(value ?? \"\");\n useEffect(() => {\n setCurrentValue(value ?? \"\");\n }, [value]);\n\n const returnData = useCallback(() => {\n setValue?.(currentValue);\n }, [currentValue, setValue]);\n\n const keyPress = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.code === \"Escape\") {\n setCurrentValue(value ?? \"\");\n sendEscape?.();\n } else if (e.code === \"Enter\") {\n returnData();\n }\n },\n [returnData, sendEscape, value],\n );\n\n // Simple if not editing\n if (!editing) {\n return (\n <span\n style={currentStyle}\n id={`${id}`}\n >\n {value ? value : <> </>}\n </span>\n );\n }\n\n return (\n <div\n style={currentStyle}\n id={`${id}-holder`}\n >\n {saving && (\n <Spinner\n id={`${id}-spinner`}\n size=\"sm\"\n animation=\"border\"\n />\n )}\n <input\n autoFocus\n spellCheck={spellCheck}\n id={String(id)}\n ref={ref}\n type=\"text\"\n style={{\n lineHeight: \"0.75rem\",\n border: \"1px dotted black\",\n width: \"auto\",\n minWidth: \"0\",\n }}\n value={currentValue}\n disabled={saving}\n onChange={(e) => setCurrentValue(e.currentTarget.value)}\n onBlur={returnData}\n onKeyDownCapture={keyPress}\n />\n </div>\n );\n },\n);\n","import { Key, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { checkExpandedNodes } from \"../functions/checkExpandedNodes\";\nimport { iNodeUpdate, TreeNodeData } from \"./interface\";\nimport { TreeNode } from \"./TreeNode\";\nimport { TreeOfNodesContext } from \"./TreeOfNodesContext\";\n\ninterface TreeOfNodesProps<T> {\n id: string;\n nodeList: TreeNodeData<T>[];\n roots: Key[];\n showCheckBox?: boolean;\n selected?: Key | Key[];\n handleSelect?: (ret: Key | Key[]) => void;\n onAdd?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;\n onRename?: (childId: Key, newName: string) => Promise<iNodeUpdate>;\n onRemove?: (childId: Key) => Promise<iNodeUpdate>;\n canRemoveRoot?: boolean;\n canRenameRoot?: boolean;\n canAddChildren?: boolean;\n canRemoveChildren?: boolean;\n canRenameChildren?: boolean;\n nodeHighlight?: string;\n textHighlight?: string;\n spellCheck?: \"true\" | \"false\";\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport const TreeOfNodes = <T extends unknown>({\n id,\n nodeList,\n roots,\n selected = [],\n showCheckBox = false,\n handleSelect,\n onAdd,\n onRename,\n onRemove,\n canRemoveRoot = false,\n canRenameRoot = false,\n canAddChildren = false,\n canRemoveChildren = false,\n canRenameChildren = false,\n nodeHighlight = \"red\",\n textHighlight = \"rgba(255, 0, 0, 0.2)\",\n spellCheck = \"true\",\n}: TreeOfNodesProps<T>) => {\n const [expandedNodes, setExpandedNodes] = useState<Key[]>([]);\n const selectedArray = useMemo(\n () => (Array.isArray(selected) ? selected : [selected]),\n [selected],\n );\n useEffect(() => {\n if (selectedArray.length > 0) {\n // Check all nodes are showing that should be\n const shouldExpand = checkExpandedNodes(nodeList, selectedArray, expandedNodes);\n if (shouldExpand.filter((n) => !expandedNodes.includes(n)).length > 0) {\n setExpandedNodes(shouldExpand);\n }\n }\n }, [expandedNodes, nodeList, selectedArray]);\n\n // Change expansion and update contexts\n const changeExpand = useCallback(\n (eKey: Key, force?: boolean) => {\n const newExpandedNodes = [...expandedNodes];\n const ix = newExpandedNodes.findIndex((nKey) => nKey === eKey);\n if ((ix === -1 && force === undefined) || force === true) newExpandedNodes.push(eKey);\n else newExpandedNodes.splice(ix, 1);\n setExpandedNodes(newExpandedNodes);\n },\n [expandedNodes],\n );\n\n return (\n <TreeOfNodesContext.Provider\n value={{\n id: id,\n nodeList,\n selected: selectedArray,\n showCheckBox,\n handleSelect,\n expandedNodes,\n handleExpandClick: (r, f) => changeExpand(r, f),\n onAddChild: onAdd,\n onRename,\n onRemove,\n nodeHighlight,\n textHighlight,\n spellCheck,\n }}\n >\n {roots.map((r) => (\n <TreeNode\n key={r}\n id={r}\n canRemove={canRemoveRoot}\n canAddChildren={canAddChildren}\n canRename={canRenameRoot}\n canRemoveChildren={canRemoveChildren}\n canRenameChildren={canRenameChildren}\n />\n ))}\n </TreeOfNodesContext.Provider>\n );\n};\n\nTreeOfNodes.displayName = \"TreeOfNodes\";\n","import { TreeNodeBase } from \"components\";\nimport { Key } from \"react\";\nimport { getAncestors } from \"./getAncestors\";\n\nexport const checkExpandedNodes = (\n nodeList: TreeNodeBase[],\n selected: Key | Key[],\n expandedNodes: Key[],\n): Key[] => {\n return [\n ...expandedNodes,\n ...getAncestors(selected, [], nodeList)\n .map((n) => n.id)\n .filter((k) => !expandedNodes.includes(k)),\n ].sort((a, b) => `${a}`.localeCompare(`${b}`));\n};\n","import { getAncestors } from \"./getAncestors\";\n\nexport { getAncestors as getParents };\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AGGO,MAAM,4CAAe,CAC1B,IACA,UACA;IAEA,MAAM,aAAa,MAAM,OAAO,CAAC,MAAM,KAAK;QAAC;KAAG;IAEhD,MAAM,UAAU,WACb,GAAG,CAAC,CAAC,IAAM,eAAe,IAAI,CAAC,CAAC,IAAM,EAAE,EAAE,KAAK,IAC/C,MAAM,CAAC,CAAC,IAAM,MAAM;IACvB,IAAI,QAAQ,MAAM,KAAK,GAAG,OAAO;IAEjC,MAAM,UAAU,AACd,QACG,GAAG,CAAC,CAAC,IAAM,EAAE,QAAQ,EACrB,GAAG,CAAC,CAAC,MAAQ,eAAe,IAAI,CAAC,CAAC,IAAM,QAAQ,EAAE,EAAE,GACvD,M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E;QACR,IAAI,cAAc,MAAM,GAAG,GAAG;YAC5B,6CAA6C;YAC7C,MAAM,eAAe,CAAA,GAAA,yCAAiB,EAAE,UAAU,eAAe;YACjE,IAAI,aAAa,MAAM,CAAC,CAAC,IAAM,CAAC,cAAc,QAAQ,CAAC,IAAI,MAAM,GAAG,GAClE,iBAAiB;QAErB;IACF,GAAG;QAAC;QAAe;QAAU;KAAc;IAE3C,uCAAuC;IACvC,MAAM,eAAe,CAAA,GAAA,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;QACC,IAAI;QACJ,WAAU;kBAEV,cAAA,gCAAC,CAAA,GAAA,yCAAiB,EAAE,QAAQ;YAC1B,OAAO;gBACL,IAAI;0BACJ;gBACA,UAAU;8BACV;8BACA;+BACA;gBACA,mBAAmB,CAAC,GAAG,IAAM,aAAa,GAAG;gBAC7C,YAAY;0BACZ;0BACA;+BACA;+BACA;4BACA;YACF;sBAEC,MAAM,GAAG,CAAC,CAAC,kBACV,gCAAC,CAAA,GAAA,yCAAO;oBAEN,IAAI;oBACJ,WAAW;oBACX,gBAAgB;oBAChB,WAAW;oBACX,mBAAmB;oBACnB,mBAAmB;mBANd;;;AAYjB;AAEA,0CAAY,WAAW,GAAG;;;;;;;;;;;","sources":["src/main.ts","src/components/index.ts","src/components/TreeNode.tsx","src/functions/getAncestors.tsx","src/functions/getDescendentIds.ts","src/components/TreeOfNodesContext.ts","src/components/WordEntry.tsx","src/components/TreeOfNodes.tsx","src/functions/checkExpandedNodes.ts","src/functions/index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./functions\";\n","import { TreeNode } from \"./TreeNode\";\nimport { TreeOfNodes } from \"./TreeOfNodes\";\nimport { iNodeUpdate, TreeNodeBase, TreeNodeData } from \"./interface\";\nimport { WordEntry } from \"./WordEntry\";\n\nexport { TreeNode, TreeOfNodes, WordEntry };\nexport type { TreeNodeBase, TreeNodeData, iNodeUpdate };\n","import { ContextMenuHandler, MenuItem } from \"@asup/context-menu\";\nimport {\n Key,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n CaretDownFill,\n CaretRight,\n CaretRightFill,\n ExclamationCircleFill,\n} from \"react-bootstrap-icons\";\nimport { getAncestors } from \"../functions/getAncestors\";\nimport { getDescendentIds } from \"../functions/getDescendentIds\";\nimport \"./TreeNode.css\";\nimport { TreeOfNodesContext } from \"./TreeOfNodesContext\";\nimport { WordEntry } from \"./WordEntry\";\nimport { iNodeUpdate } from \"./interface\";\n\ninterface TreeNodeProps {\n id: Key;\n indentLevel?: number;\n canRemove?: boolean;\n canRename?: boolean;\n canAddChildren?: boolean;\n canRemoveChildren?: boolean;\n canRenameChildren?: boolean;\n refresh?: () => void;\n}\n\nexport const TreeNode = ({\n id,\n canRemove,\n canRename,\n canAddChildren,\n canRemoveChildren,\n canRenameChildren,\n}: TreeNodeProps): ReactNode => {\n // Contexts\n const treeContext = useContext(TreeOfNodesContext);\n\n // Node information\n const thisNode = useMemo(\n () => treeContext?.nodeList.find((n) => n.id === id),\n [id, treeContext?.nodeList],\n );\n const childNodes = useMemo(\n () => treeContext?.nodeList.filter((n) => n.parentId === id),\n [id, treeContext?.nodeList],\n );\n const descendents = useMemo(\n () => getDescendentIds(id, treeContext?.nodeList ?? []),\n [id, treeContext],\n );\n\n // State\n const [error, setError] = useState<boolean>(false);\n const [errorText, setErrotText] = useState<string>(\"\");\n const expanded = useMemo(() => {\n return (treeContext?.expandedNodes.findIndex((e) => e === id) ?? -1) > -1;\n }, [id, treeContext?.expandedNodes]);\n\n // Checkbox\n const checkRef = useRef<HTMLInputElement | null>(null);\n useEffect(() => {\n if (checkRef.current) {\n if (treeContext?.selected.includes(id)) {\n checkRef.current.checked = true;\n checkRef.current.indeterminate = false;\n } else if (descendents.some((d) => treeContext?.selected.includes(d))) {\n checkRef.current.checked = false;\n checkRef.current.indeterminate = true;\n } else {\n checkRef.current.checked = false;\n checkRef.current.indeterminate = false;\n }\n }\n }, [descendents, id, treeContext?.selected]);\n\n // Apply selected border\n const currentBorder = useMemo<string>(() => {\n return treeContext?.selected.includes(id) ? \"1px solid black\" : \"\";\n }, [id, treeContext?.selected]);\n const nodeColour = useMemo<string | undefined>(() => {\n if (treeContext && treeContext.selected) {\n const anc = getAncestors(treeContext.selected, [], treeContext?.nodeList).map((n) => n.id);\n if ([...anc, treeContext.selected].includes(id)) return treeContext.nodeHighlight;\n }\n return;\n }, [id, treeContext]);\n\n // New node parameters\n const newNameRef = useRef<HTMLInputElement | null>(null);\n const [showNewNode, setShowNewNode] = useState<boolean>(false);\n const [savingNewNode, setSavingNewNode] = useState<boolean>(false);\n\n // Rename parameters\n const currentNameRef = useRef<HTMLInputElement | null>(null);\n const [renaming, setRenaming] = useState<boolean>(false);\n const [updatingNode, setUpdatingNode] = useState<boolean>(false);\n\n // Context functions\n const handleReturn = useCallback((ret: iNodeUpdate) => {\n if (!ret.success) {\n setError(true);\n setErrotText(ret.ErrorText ?? \"An unknown error has occured\");\n } else {\n setError(false);\n setErrotText(\"\");\n }\n }, []);\n\n const confirmNewNode = useCallback(\n async (label: string) => {\n setSavingNewNode(true);\n if (treeContext?.onAddChild) {\n handleReturn(await treeContext.onAddChild(id, label));\n }\n setSavingNewNode(false);\n setShowNewNode(false);\n },\n [handleReturn, id, treeContext],\n );\n\n const renameNode = useCallback(\n async (newLabel: string) => {\n setRenaming(false);\n if (treeContext?.onRename) {\n setUpdatingNode(true);\n handleReturn(await treeContext.onRename(id, newLabel));\n setUpdatingNode(false);\n }\n },\n [handleReturn, id, treeContext],\n );\n\n const deleteThis = useCallback(async () => {\n if (treeContext?.onRemove) {\n setUpdatingNode(true);\n handleReturn(await treeContext.onRemove(id));\n setUpdatingNode(false);\n }\n }, [handleReturn, id, treeContext]);\n\n // Context actions\n const addChild = useCallback(() => {\n setShowNewNode(true);\n treeContext?.handleExpandClick?.(id, true);\n }, [id, treeContext]);\n useEffect(() => {\n if (showNewNode === true && newNameRef.current) newNameRef.current.focus();\n }, [showNewNode]);\n const renameThis = useCallback(() => {\n setRenaming(true);\n treeContext?.handleSelect?.(id);\n }, [id, treeContext]);\n\n // Context menu\n const menuItems = useMemo(() => {\n const menuItems: MenuItem[] = [];\n if (canAddChildren) {\n menuItems.push({ label: \"Add\", action: addChild });\n }\n if (canRename) {\n menuItems.push({ label: \"Rename\", action: renameThis });\n }\n if (canRemove && (childNodes === undefined || childNodes.length === 0)) {\n menuItems.push({ label: \"Delete\", action: deleteThis });\n }\n return menuItems;\n }, [addChild, canAddChildren, canRemove, canRename, childNodes, deleteThis, renameThis]);\n\n // Return node\n return !treeContext ? null : (\n <>\n <ContextMenuHandler\n menuItems={menuItems}\n style={{ display: \"inline-block\", width: \"100%\" }}\n >\n <div\n id={`${treeContext.id}-treenode-${id}`}\n className=\"treenode\"\n >\n {error ? (\n <>\n <ExclamationCircleFill color=\"var(--bs-danger)\" /> {errorText}\n </>\n ) : (\n <div className=\"ton-node\">\n {treeContext.showCheckBox && (\n <input\n ref={checkRef}\n type=\"checkbox\"\n role=\"checkbox\"\n className=\"ton-checkbox\"\n id={`${treeContext.id}-treenode-checkbox-${id}`}\n onClick={() => treeContext?.handleSelect?.(descendents)}\n />\n )}\n {childNodes !== undefined && childNodes.length > 0 ? (\n !expanded ? (\n <CaretRightFill\n id={`${treeContext.id}-treenode-caret-${id}`}\n style={{ width: \"16px\", height: \"16px\" }}\n className=\"ton-expander\"\n role=\"button\"\n color={nodeColour}\n aria-expanded={false}\n aria-label=\"Expander\"\n onClick={() => treeContext.handleExpandClick(id)}\n />\n ) : (\n <CaretDownFill\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n aria-expanded={true}\n aria-label=\"Expander\"\n color={nodeColour}\n onClick={() => treeContext.handleExpandClick(id)}\n />\n )\n ) : (\n <CaretRight\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n color={nodeColour}\n aria-expanded={false}\n aria-label=\"Disabled expander\"\n onClick={() => treeContext.handleSelect?.(id)}\n />\n )}\n {thisNode && (\n <div\n className=\"ton-label\"\n style={{ width: `calc(100% - ${treeContext.showCheckBox ? \"32px\" : \"16px\"})` }}\n onContextMenuCapture={() => treeContext.handleSelect?.(id)}\n onClickCapture={() => treeContext.handleSelect?.(id)}\n onFocusCapture={() => treeContext.handleSelect?.(id)}\n >\n <WordEntry\n id={`${treeContext.id}-treenode-entry-${id}`}\n ref={currentNameRef}\n value={thisNode.label}\n editing={renaming}\n saving={updatingNode}\n setValue={(ret) => renameNode(ret)}\n sendEscape={() => setRenaming(false)}\n style={{\n border: currentBorder,\n margin: currentBorder === \"\" ? \"1px\" : \"\",\n backgroundColor: currentBorder === \"\" ? \"\" : treeContext.textHighlight,\n }}\n spellCheck={treeContext.spellCheck}\n />\n </div>\n )}\n </div>\n )}\n </div>\n </ContextMenuHandler>\n {showNewNode && (\n <WordEntry\n style={{ marginLeft: \"14px\" }}\n id={`treenode-new-${id}`}\n ref={newNameRef}\n editing={true}\n setValue={(ret) => confirmNewNode(ret)}\n saving={savingNewNode}\n sendEscape={() => setShowNewNode(false)}\n spellCheck={treeContext.spellCheck}\n />\n )}\n {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 </>\n );\n};\n\nTreeNode.displayName = \"TreeNode\";\n","import { Key } from \"react\";\nimport { TreeNodeBase } from \"../components/interface\";\n\nexport const getAncestors = (\n id: Key | Key[],\n included: TreeNodeBase[],\n hierarchyNodes: TreeNodeBase[],\n): TreeNodeBase[] => {\n const processIds = Array.isArray(id) ? id : [id];\n\n const current = processIds\n .map((i) => hierarchyNodes.find((h) => h.id === i))\n .filter((h) => h !== undefined) as TreeNodeBase[];\n if (current.length === 0) return included;\n\n const parents = (\n current\n .map((h) => h.parentId)\n .map((pid) => hierarchyNodes.find((h) => pid === h.id)) as TreeNodeBase[]\n ).filter((p) => p !== undefined) as TreeNodeBase[];\n if (parents.length === 0) return included;\n else\n return getAncestors(\n parents.map((p) => p.id),\n [...included, ...parents.filter((p) => !included.includes(p))],\n hierarchyNodes,\n );\n};\n","import { Key } from \"react\";\nimport { TreeNodeBase } from \"../components/interface\";\n\nexport const getDescendentIds = (id: Key | Key[], hierarchyNodes: TreeNodeBase[]): Key[] => {\n const processIds = Array.isArray(id) ? id : [id];\n const newChildren = hierarchyNodes\n .filter(\n (h) =>\n h.parentId !== undefined && processIds.includes(h.parentId) && !processIds.includes(h.id),\n )\n .map((h) => h.id);\n return newChildren.length === 0\n ? processIds\n : getDescendentIds([...processIds, ...newChildren], hierarchyNodes);\n};\n","import { createContext, Key } from \"react\";\nimport { iNodeUpdate, TreeNodeData } from \"./interface\";\n\nexport interface TreeOfNodesContextProps<T> {\n id: string;\n nodeList: TreeNodeData<T>[];\n selected: Key[];\n showCheckBox: boolean;\n handleSelect?: (ret: Key | Key[]) => void;\n expandedNodes: Key[];\n handleExpandClick: (ret: Key, force?: boolean) => void;\n onAddChild?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;\n onRename?: (id: Key, newName: string) => Promise<iNodeUpdate>;\n onRemove?: (id: Key) => Promise<iNodeUpdate>;\n nodeHighlight: string;\n textHighlight: string;\n spellCheck?: \"true\" | \"false\";\n}\n\nexport const TreeOfNodesContext = createContext<TreeOfNodesContextProps<unknown> | undefined>(\n undefined,\n);\n","import React, { Key, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Spinner } from \"react-bootstrap\";\n\ninterface WordEntryProps {\n id: Key;\n value?: string;\n editing?: boolean;\n saving?: boolean;\n setValue?: (ret: string) => void;\n sendEscape?: () => void;\n style?: React.CSSProperties;\n spellCheck?: \"true\" | \"false\";\n}\n\nexport const WordEntry = React.forwardRef<HTMLInputElement, WordEntryProps>(\n (\n { id, value, editing, saving, setValue, sendEscape, style, spellCheck = \"true\" },\n ref,\n ): JSX.Element => {\n WordEntry.displayName = \"WordEntry\";\n const currentStyle = useMemo<React.CSSProperties>(() => {\n return {\n display: \"inline-block\",\n padding: \"1px\",\n paddingLeft: \"3px\",\n paddingRight: \"3px\",\n border: \"1px\",\n borderRadius: \"3px\",\n ...style,\n };\n }, [style]);\n\n const [currentValue, setCurrentValue] = useState<string>(value ?? \"\");\n useEffect(() => {\n setCurrentValue(value ?? \"\");\n }, [value]);\n\n const returnData = useCallback(() => {\n setValue?.(currentValue);\n }, [currentValue, setValue]);\n\n const keyPress = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.code === \"Escape\") {\n setCurrentValue(value ?? \"\");\n sendEscape?.();\n } else if (e.code === \"Enter\") {\n returnData();\n }\n },\n [returnData, sendEscape, value],\n );\n\n // Simple if not editing\n if (!editing) {\n return (\n <span\n className=\"ton-label-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 className=\"ton-rename-holder\"\n >\n {saving && (\n <Spinner\n id={`${id}-spinner`}\n size=\"sm\"\n animation=\"border\"\n />\n )}\n <input\n autoFocus\n spellCheck={spellCheck}\n id={String(id)}\n ref={ref}\n type=\"text\"\n className=\"ton-rename\"\n value={currentValue}\n disabled={saving}\n onChange={(e) => setCurrentValue(e.currentTarget.value)}\n onBlur={returnData}\n onKeyDownCapture={keyPress}\n />\n </div>\n );\n },\n);\n","import { Key, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { checkExpandedNodes } from \"../functions/checkExpandedNodes\";\nimport { iNodeUpdate, TreeNodeData } from \"./interface\";\nimport { TreeNode } from \"./TreeNode\";\nimport { TreeOfNodesContext } from \"./TreeOfNodesContext\";\n\ninterface TreeOfNodesProps<T> {\n id: string;\n nodeList: TreeNodeData<T>[];\n roots: Key[];\n showCheckBox?: boolean;\n selected?: Key | Key[];\n handleSelect?: (ret: Key | Key[]) => void;\n onAdd?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;\n onRename?: (childId: Key, newName: string) => Promise<iNodeUpdate>;\n onRemove?: (childId: Key) => Promise<iNodeUpdate>;\n canRemoveRoot?: boolean;\n canRenameRoot?: boolean;\n canAddChildren?: boolean;\n canRemoveChildren?: boolean;\n canRenameChildren?: boolean;\n nodeHighlight?: string;\n textHighlight?: string;\n spellCheck?: \"true\" | \"false\";\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport const TreeOfNodes = <T extends unknown>({\n id,\n nodeList,\n roots,\n selected = [],\n showCheckBox = false,\n handleSelect,\n onAdd,\n onRename,\n onRemove,\n canRemoveRoot = false,\n canRenameRoot = false,\n canAddChildren = false,\n canRemoveChildren = false,\n canRenameChildren = false,\n nodeHighlight = \"red\",\n textHighlight = \"rgba(255, 0, 0, 0.2)\",\n spellCheck = \"true\",\n}: TreeOfNodesProps<T>) => {\n const [expandedNodes, setExpandedNodes] = useState<Key[]>([]);\n const selectedArray = useMemo(\n () => (Array.isArray(selected) ? selected : [selected]),\n [selected],\n );\n useEffect(() => {\n if (selectedArray.length > 0) {\n // Check all nodes are showing that should be\n const shouldExpand = checkExpandedNodes(nodeList, selectedArray, expandedNodes);\n if (shouldExpand.filter((n) => !expandedNodes.includes(n)).length > 0) {\n setExpandedNodes(shouldExpand);\n }\n }\n }, [expandedNodes, nodeList, selectedArray]);\n\n // Change expansion and update contexts\n const changeExpand = useCallback(\n (eKey: Key, force?: boolean) => {\n const newExpandedNodes = [...expandedNodes];\n const ix = newExpandedNodes.findIndex((nKey) => nKey === eKey);\n if ((ix === -1 && force === undefined) || force === true) newExpandedNodes.push(eKey);\n else newExpandedNodes.splice(ix, 1);\n setExpandedNodes(newExpandedNodes);\n },\n [expandedNodes],\n );\n\n return (\n <div\n id={id}\n className=\"tree-of-nodes\"\n >\n <TreeOfNodesContext.Provider\n value={{\n id: id,\n nodeList,\n selected: selectedArray,\n showCheckBox,\n handleSelect,\n expandedNodes,\n handleExpandClick: (r, f) => changeExpand(r, f),\n onAddChild: onAdd,\n onRename,\n onRemove,\n nodeHighlight,\n textHighlight,\n spellCheck,\n }}\n >\n {roots.map((r) => (\n <TreeNode\n key={r}\n id={r}\n canRemove={canRemoveRoot}\n canAddChildren={canAddChildren}\n canRename={canRenameRoot}\n canRemoveChildren={canRemoveChildren}\n canRenameChildren={canRenameChildren}\n />\n ))}\n </TreeOfNodesContext.Provider>\n </div>\n );\n};\n\nTreeOfNodes.displayName = \"TreeOfNodes\";\n","import { TreeNodeBase } from \"components\";\nimport { Key } from \"react\";\nimport { getAncestors } from \"./getAncestors\";\n\nexport const checkExpandedNodes = (\n nodeList: TreeNodeBase[],\n selected: Key | Key[],\n expandedNodes: Key[],\n): Key[] => {\n return [\n ...expandedNodes,\n ...getAncestors(selected, [], nodeList)\n .map((n) => n.id)\n .filter((k) => !expandedNodes.includes(k)),\n ].sort((a, b) => `${a}`.localeCompare(`${b}`));\n};\n","import { getAncestors } from \"./getAncestors\";\n\nexport { getAncestors as getParents };\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/main.css
CHANGED
|
@@ -4,7 +4,39 @@
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
.ton-expander {
|
|
7
|
-
margin
|
|
7
|
+
margin: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.ton-node {
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
align-items: center;
|
|
13
|
+
width: 100%;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
height: 34px;
|
|
16
|
+
display: flex;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.ton-label {
|
|
20
|
+
height: 34px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ton-label-span {
|
|
24
|
+
text-overflow: ellipsis;
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
width: 100%;
|
|
27
|
+
display: inline-block;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.ton-rename-holder {
|
|
32
|
+
width: 100%;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.ton-rename {
|
|
36
|
+
border: 1px dotted #000;
|
|
37
|
+
width: 100%;
|
|
38
|
+
min-width: 0;
|
|
39
|
+
line-height: .75rem;
|
|
8
40
|
}
|
|
9
41
|
|
|
10
42
|
.ton-child {
|
|
@@ -15,6 +47,8 @@
|
|
|
15
47
|
}
|
|
16
48
|
|
|
17
49
|
.ton-collapsible-wrapper {
|
|
50
|
+
width: 100%;
|
|
51
|
+
max-width: 100%;
|
|
18
52
|
display: flex;
|
|
19
53
|
overflow: hidden;
|
|
20
54
|
}
|
|
@@ -27,6 +61,7 @@
|
|
|
27
61
|
}
|
|
28
62
|
|
|
29
63
|
.ton-collapsible {
|
|
64
|
+
width: 100%;
|
|
30
65
|
max-height: 10000px;
|
|
31
66
|
margin-bottom: 0;
|
|
32
67
|
transition: margin-bottom .3s cubic-bezier(0, 0, 0, 1);
|
package/dist/main.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;AAKA;;;;AAIA;;;;;;;AAOA
|
|
1
|
+
{"mappings":"AAAA;;;;;AAKA;;;;AAIA;;;;;;;;;AASA;;;;AAIA;;;;;;;;AAQA;;;;AAIA;;;;;;;AAOA;;;;;;;AAOA;;;;;;;AAMA;;;;;;;AAQA;;;;;;;AAMA;;;;;;;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: 0;\n}\n\n.ton-node {\n display: flex;\n align-items: center;\n cursor: pointer;\n width: 100%;\n max-width: 100%;\n height: 34px;\n}\n\n.ton-label {\n height: 34px;\n}\n\n.ton-label-span {\n display: inline-block;\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.ton-rename-holder {\n width: 100%;\n}\n\n.ton-rename {\n line-height: 0.75rem;\n border: 1px dotted black;\n width: 100%;\n min-width: 0;\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 width: 100%;\n max-width: 100%;\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 width: 100%;\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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./main.css";
|
|
2
|
-
import {
|
|
2
|
+
import {jsxs as $duWW8$jsxs, Fragment as $duWW8$Fragment, jsx as $duWW8$jsx} from "react/jsx-runtime";
|
|
3
3
|
import {ContextMenuHandler as $duWW8$ContextMenuHandler} from "@asup/context-menu";
|
|
4
4
|
import $duWW8$react, {useContext as $duWW8$useContext, useMemo as $duWW8$useMemo, useState as $duWW8$useState, useRef as $duWW8$useRef, useEffect as $duWW8$useEffect, useCallback as $duWW8$useCallback, createContext as $duWW8$createContext} from "react";
|
|
5
5
|
import {ExclamationCircleFill as $duWW8$ExclamationCircleFill, CaretRightFill as $duWW8$CaretRightFill, CaretDownFill as $duWW8$CaretDownFill, CaretRight as $duWW8$CaretRight} from "react-bootstrap-icons";
|
|
@@ -93,6 +93,7 @@ const $84765747a8c6bfe2$export$14f190ac910bde69 = /*#__PURE__*/ (0, $duWW8$react
|
|
|
93
93
|
]);
|
|
94
94
|
// Simple if not editing
|
|
95
95
|
if (!editing) return /*#__PURE__*/ (0, $duWW8$jsx)("span", {
|
|
96
|
+
className: "ton-label-span",
|
|
96
97
|
style: currentStyle,
|
|
97
98
|
id: `${id}`,
|
|
98
99
|
children: value ? value : /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$Fragment), {
|
|
@@ -102,6 +103,7 @@ const $84765747a8c6bfe2$export$14f190ac910bde69 = /*#__PURE__*/ (0, $duWW8$react
|
|
|
102
103
|
return /*#__PURE__*/ (0, $duWW8$jsxs)("div", {
|
|
103
104
|
style: currentStyle,
|
|
104
105
|
id: `${id}-holder`,
|
|
106
|
+
className: "ton-rename-holder",
|
|
105
107
|
children: [
|
|
106
108
|
saving && /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$Spinner), {
|
|
107
109
|
id: `${id}-spinner`,
|
|
@@ -114,12 +116,7 @@ const $84765747a8c6bfe2$export$14f190ac910bde69 = /*#__PURE__*/ (0, $duWW8$react
|
|
|
114
116
|
id: String(id),
|
|
115
117
|
ref: ref,
|
|
116
118
|
type: "text",
|
|
117
|
-
|
|
118
|
-
lineHeight: "0.75rem",
|
|
119
|
-
border: "1px dotted black",
|
|
120
|
-
width: "auto",
|
|
121
|
-
minWidth: "0"
|
|
122
|
-
},
|
|
119
|
+
className: "ton-rename",
|
|
123
120
|
value: currentValue,
|
|
124
121
|
disabled: saving,
|
|
125
122
|
onChange: (e)=>setCurrentValue(e.currentTarget.value),
|
|
@@ -300,124 +297,139 @@ const $47c36cf4281201f5$export$2eba8ec3a333fdbb = ({ id: id, canRemove: canRemov
|
|
|
300
297
|
renameThis
|
|
301
298
|
]);
|
|
302
299
|
// Return node
|
|
303
|
-
return !treeContext ? null : /*#__PURE__*/ (0, $duWW8$
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
onClick: ()=>treeContext.handleExpandClick(id)
|
|
339
|
-
}) : /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$CaretDownFill), {
|
|
340
|
-
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
341
|
-
className: "ton-expander",
|
|
342
|
-
role: "button",
|
|
343
|
-
"aria-expanded": true,
|
|
344
|
-
"aria-label": "Expander",
|
|
345
|
-
color: nodeColour,
|
|
346
|
-
onClick: ()=>{
|
|
347
|
-
treeContext.handleExpandClick(id);
|
|
348
|
-
}
|
|
349
|
-
}) : /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$CaretRight), {
|
|
350
|
-
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
351
|
-
className: "ton-expander",
|
|
352
|
-
role: "button",
|
|
353
|
-
color: nodeColour,
|
|
354
|
-
"aria-expanded": false,
|
|
355
|
-
"aria-label": "Disabled expander",
|
|
356
|
-
onClick: ()=>treeContext.handleSelect && treeContext.handleSelect(id)
|
|
357
|
-
}),
|
|
358
|
-
thisNode && /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
359
|
-
style: {
|
|
360
|
-
display: "inline-block"
|
|
361
|
-
},
|
|
362
|
-
onContextMenuCapture: ()=>treeContext.handleSelect && treeContext.handleSelect(id),
|
|
363
|
-
onClickCapture: ()=>treeContext.handleSelect && treeContext.handleSelect(id),
|
|
364
|
-
onFocusCapture: ()=>treeContext.handleSelect && treeContext.handleSelect(id),
|
|
365
|
-
children: /*#__PURE__*/ (0, $duWW8$jsx)((0, $84765747a8c6bfe2$export$14f190ac910bde69), {
|
|
366
|
-
id: `${treeContext.id}-treenode-entry-${id}`,
|
|
367
|
-
ref: currentNameRef,
|
|
368
|
-
value: thisNode.label,
|
|
369
|
-
editing: renaming,
|
|
370
|
-
saving: updatingNode,
|
|
371
|
-
setValue: (ret)=>renameNode(ret),
|
|
372
|
-
sendEscape: ()=>setRenaming(false),
|
|
300
|
+
return !treeContext ? null : /*#__PURE__*/ (0, $duWW8$jsxs)((0, $duWW8$Fragment), {
|
|
301
|
+
children: [
|
|
302
|
+
/*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$ContextMenuHandler), {
|
|
303
|
+
menuItems: menuItems,
|
|
304
|
+
style: {
|
|
305
|
+
display: "inline-block",
|
|
306
|
+
width: "100%"
|
|
307
|
+
},
|
|
308
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
309
|
+
id: `${treeContext.id}-treenode-${id}`,
|
|
310
|
+
className: "treenode",
|
|
311
|
+
children: error ? /*#__PURE__*/ (0, $duWW8$jsxs)((0, $duWW8$Fragment), {
|
|
312
|
+
children: [
|
|
313
|
+
/*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$ExclamationCircleFill), {
|
|
314
|
+
color: "var(--bs-danger)"
|
|
315
|
+
}),
|
|
316
|
+
" ",
|
|
317
|
+
errorText
|
|
318
|
+
]
|
|
319
|
+
}) : /*#__PURE__*/ (0, $duWW8$jsxs)("div", {
|
|
320
|
+
className: "ton-node",
|
|
321
|
+
children: [
|
|
322
|
+
treeContext.showCheckBox && /*#__PURE__*/ (0, $duWW8$jsx)("input", {
|
|
323
|
+
ref: checkRef,
|
|
324
|
+
type: "checkbox",
|
|
325
|
+
role: "checkbox",
|
|
326
|
+
className: "ton-checkbox",
|
|
327
|
+
id: `${treeContext.id}-treenode-checkbox-${id}`,
|
|
328
|
+
onClick: ()=>{
|
|
329
|
+
var _treeContext_handleSelect;
|
|
330
|
+
return treeContext === null || treeContext === void 0 ? void 0 : (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, descendents);
|
|
331
|
+
}
|
|
332
|
+
}),
|
|
333
|
+
childNodes !== undefined && childNodes.length > 0 ? !expanded ? /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$CaretRightFill), {
|
|
334
|
+
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
373
335
|
style: {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
backgroundColor: currentBorder === "" ? "" : treeContext.textHighlight
|
|
336
|
+
width: "16px",
|
|
337
|
+
height: "16px"
|
|
377
338
|
},
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
339
|
+
className: "ton-expander",
|
|
340
|
+
role: "button",
|
|
341
|
+
color: nodeColour,
|
|
342
|
+
"aria-expanded": false,
|
|
343
|
+
"aria-label": "Expander",
|
|
344
|
+
onClick: ()=>treeContext.handleExpandClick(id)
|
|
345
|
+
}) : /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$CaretDownFill), {
|
|
346
|
+
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
347
|
+
className: "ton-expander",
|
|
348
|
+
role: "button",
|
|
349
|
+
"aria-expanded": true,
|
|
350
|
+
"aria-label": "Expander",
|
|
351
|
+
color: nodeColour,
|
|
352
|
+
onClick: ()=>treeContext.handleExpandClick(id)
|
|
353
|
+
}) : /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$CaretRight), {
|
|
354
|
+
id: `${treeContext.id}-treenode-caret-${id}`,
|
|
355
|
+
className: "ton-expander",
|
|
356
|
+
role: "button",
|
|
357
|
+
color: nodeColour,
|
|
358
|
+
"aria-expanded": false,
|
|
359
|
+
"aria-label": "Disabled expander",
|
|
360
|
+
onClick: ()=>{
|
|
361
|
+
var _treeContext_handleSelect;
|
|
362
|
+
return (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, id);
|
|
363
|
+
}
|
|
364
|
+
}),
|
|
365
|
+
thisNode && /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
366
|
+
className: "ton-label",
|
|
367
|
+
style: {
|
|
368
|
+
width: `calc(100% - ${treeContext.showCheckBox ? "32px" : "16px"})`
|
|
369
|
+
},
|
|
370
|
+
onContextMenuCapture: ()=>{
|
|
371
|
+
var _treeContext_handleSelect;
|
|
372
|
+
return (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, id);
|
|
373
|
+
},
|
|
374
|
+
onClickCapture: ()=>{
|
|
375
|
+
var _treeContext_handleSelect;
|
|
376
|
+
return (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, id);
|
|
377
|
+
},
|
|
378
|
+
onFocusCapture: ()=>{
|
|
379
|
+
var _treeContext_handleSelect;
|
|
380
|
+
return (_treeContext_handleSelect = treeContext.handleSelect) === null || _treeContext_handleSelect === void 0 ? void 0 : _treeContext_handleSelect.call(treeContext, id);
|
|
381
|
+
},
|
|
382
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)((0, $84765747a8c6bfe2$export$14f190ac910bde69), {
|
|
383
|
+
id: `${treeContext.id}-treenode-entry-${id}`,
|
|
384
|
+
ref: currentNameRef,
|
|
385
|
+
value: thisNode.label,
|
|
386
|
+
editing: renaming,
|
|
387
|
+
saving: updatingNode,
|
|
388
|
+
setValue: (ret)=>renameNode(ret),
|
|
389
|
+
sendEscape: ()=>setRenaming(false),
|
|
390
|
+
style: {
|
|
391
|
+
border: currentBorder,
|
|
392
|
+
margin: currentBorder === "" ? "1px" : "",
|
|
393
|
+
backgroundColor: currentBorder === "" ? "" : treeContext.textHighlight
|
|
394
|
+
},
|
|
395
|
+
spellCheck: treeContext.spellCheck
|
|
397
396
|
})
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
}),
|
|
401
|
-
showNewNode && /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
402
|
-
children: /*#__PURE__*/ (0, $duWW8$jsx)((0, $84765747a8c6bfe2$export$14f190ac910bde69), {
|
|
403
|
-
style: {
|
|
404
|
-
marginLeft: "14px"
|
|
405
|
-
},
|
|
406
|
-
id: `treenode-new-${id}`,
|
|
407
|
-
ref: newNameRef,
|
|
408
|
-
editing: true,
|
|
409
|
-
setValue: (ret)=>{
|
|
410
|
-
confirmNewNode(ret);
|
|
411
|
-
},
|
|
412
|
-
saving: savingNewNode,
|
|
413
|
-
sendEscape: ()=>{
|
|
414
|
-
setShowNewNode(false);
|
|
415
|
-
},
|
|
416
|
-
spellCheck: treeContext.spellCheck
|
|
397
|
+
})
|
|
398
|
+
]
|
|
417
399
|
})
|
|
418
400
|
})
|
|
419
|
-
|
|
420
|
-
|
|
401
|
+
}),
|
|
402
|
+
showNewNode && /*#__PURE__*/ (0, $duWW8$jsx)((0, $84765747a8c6bfe2$export$14f190ac910bde69), {
|
|
403
|
+
style: {
|
|
404
|
+
marginLeft: "14px"
|
|
405
|
+
},
|
|
406
|
+
id: `treenode-new-${id}`,
|
|
407
|
+
ref: newNameRef,
|
|
408
|
+
editing: true,
|
|
409
|
+
setValue: (ret)=>confirmNewNode(ret),
|
|
410
|
+
saving: savingNewNode,
|
|
411
|
+
sendEscape: ()=>setShowNewNode(false),
|
|
412
|
+
spellCheck: treeContext.spellCheck
|
|
413
|
+
}),
|
|
414
|
+
childNodes !== undefined && /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
415
|
+
className: `ton-collapsible-wrapper ${expanded ? "" : "collapsed"}`,
|
|
416
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
417
|
+
className: "ton-collapsible",
|
|
418
|
+
children: childNodes.map((h)=>/*#__PURE__*/ (0, $duWW8$jsx)("span", {
|
|
419
|
+
id: `${treeContext.id}-treenode-child-${h.id}`,
|
|
420
|
+
className: "ton-child",
|
|
421
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)($47c36cf4281201f5$export$2eba8ec3a333fdbb, {
|
|
422
|
+
id: h.id,
|
|
423
|
+
canRemove: canRemoveChildren,
|
|
424
|
+
canRename: canRenameChildren,
|
|
425
|
+
canAddChildren: canAddChildren,
|
|
426
|
+
canRemoveChildren: canRemoveChildren,
|
|
427
|
+
canRenameChildren: canRenameChildren
|
|
428
|
+
})
|
|
429
|
+
}, h.id))
|
|
430
|
+
})
|
|
431
|
+
})
|
|
432
|
+
]
|
|
421
433
|
});
|
|
422
434
|
};
|
|
423
435
|
$47c36cf4281201f5$export$2eba8ec3a333fdbb.displayName = "TreeNode";
|
|
@@ -466,30 +478,34 @@ const $ba47aaf387735a90$export$5580fff3e08a8be5 = ({ id: id, nodeList: nodeList,
|
|
|
466
478
|
}, [
|
|
467
479
|
expandedNodes
|
|
468
480
|
]);
|
|
469
|
-
return /*#__PURE__*/ (0, $duWW8$jsx)(
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
481
|
+
return /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
482
|
+
id: id,
|
|
483
|
+
className: "tree-of-nodes",
|
|
484
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)((0, $886f402bccb0fd30$export$29ec378200e05207).Provider, {
|
|
485
|
+
value: {
|
|
486
|
+
id: id,
|
|
487
|
+
nodeList: nodeList,
|
|
488
|
+
selected: selectedArray,
|
|
489
|
+
showCheckBox: showCheckBox,
|
|
490
|
+
handleSelect: handleSelect,
|
|
491
|
+
expandedNodes: expandedNodes,
|
|
492
|
+
handleExpandClick: (r, f)=>changeExpand(r, f),
|
|
493
|
+
onAddChild: onAdd,
|
|
494
|
+
onRename: onRename,
|
|
495
|
+
onRemove: onRemove,
|
|
496
|
+
nodeHighlight: nodeHighlight,
|
|
497
|
+
textHighlight: textHighlight,
|
|
498
|
+
spellCheck: spellCheck
|
|
499
|
+
},
|
|
500
|
+
children: roots.map((r)=>/*#__PURE__*/ (0, $duWW8$jsx)((0, $47c36cf4281201f5$export$2eba8ec3a333fdbb), {
|
|
501
|
+
id: r,
|
|
502
|
+
canRemove: canRemoveRoot,
|
|
503
|
+
canAddChildren: canAddChildren,
|
|
504
|
+
canRename: canRenameRoot,
|
|
505
|
+
canRemoveChildren: canRemoveChildren,
|
|
506
|
+
canRenameChildren: canRenameChildren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AAC,CAAA,GAAA,yCAAO;gBAEN,IAAI;gBACJ,WAAW;gBACX,gBAAgB;gBAChB,WAAW;gBACX,mBAAmB;gBACnB,mBAAmB;eANd;;AAWf;AAEA,0CAAY,WAAW,GAAG;;;;;;;;;;;","sources":["src/main.ts","src/components/index.ts","src/components/TreeNode.tsx","src/functions/getAncestors.tsx","src/functions/getDescendentIds.ts","src/components/TreeOfNodesContext.ts","src/components/WordEntry.tsx","src/components/TreeOfNodes.tsx","src/functions/checkExpandedNodes.ts","src/functions/index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./functions\";\n","import { TreeNode } from \"./TreeNode\";\nimport { TreeOfNodes } from \"./TreeOfNodes\";\nimport { iNodeUpdate, TreeNodeBase, TreeNodeData } from \"./interface\";\nimport { WordEntry } from \"./WordEntry\";\n\nexport { TreeNode, TreeOfNodes, WordEntry };\nexport type { TreeNodeBase, TreeNodeData, iNodeUpdate };\n","import { ContextMenuHandler, MenuItem } from \"@asup/context-menu\";\nimport {\n Key,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n CaretDownFill,\n CaretRight,\n CaretRightFill,\n ExclamationCircleFill,\n} from \"react-bootstrap-icons\";\nimport { getAncestors } from \"../functions/getAncestors\";\nimport { getDescendentIds } from \"../functions/getDescendentIds\";\nimport \"./TreeNode.css\";\nimport { TreeOfNodesContext } from \"./TreeOfNodesContext\";\nimport { WordEntry } from \"./WordEntry\";\nimport { iNodeUpdate } from \"./interface\";\n\ninterface TreeNodeProps {\n id: Key;\n indentLevel?: number;\n canRemove?: boolean;\n canRename?: boolean;\n canAddChildren?: boolean;\n canRemoveChildren?: boolean;\n canRenameChildren?: boolean;\n refresh?: () => void;\n}\n\nexport const TreeNode = ({\n id,\n canRemove,\n canRename,\n canAddChildren,\n canRemoveChildren,\n canRenameChildren,\n}: TreeNodeProps): ReactNode => {\n // Contexts\n const treeContext = useContext(TreeOfNodesContext);\n\n // Node information\n const thisNode = useMemo(\n () => treeContext?.nodeList.find((n) => n.id === id),\n [id, treeContext?.nodeList],\n );\n const childNodes = useMemo(\n () => treeContext?.nodeList.filter((n) => n.parentId === id),\n [id, treeContext?.nodeList],\n );\n const descendents = useMemo(\n () => getDescendentIds(id, treeContext?.nodeList ?? []),\n [id, treeContext],\n );\n\n // State\n const [error, setError] = useState<boolean>(false);\n const [errorText, setErrotText] = useState<string>(\"\");\n const expanded = useMemo(() => {\n return (treeContext?.expandedNodes.findIndex((e) => e === id) ?? -1) > -1;\n }, [id, treeContext?.expandedNodes]);\n\n // Checkbox\n const checkRef = useRef<HTMLInputElement | null>(null);\n useEffect(() => {\n if (checkRef.current) {\n if (treeContext?.selected.includes(id)) {\n checkRef.current.checked = true;\n checkRef.current.indeterminate = false;\n } else if (descendents.some((d) => treeContext?.selected.includes(d))) {\n checkRef.current.checked = false;\n checkRef.current.indeterminate = true;\n } else {\n checkRef.current.checked = false;\n checkRef.current.indeterminate = false;\n }\n }\n }, [descendents, id, treeContext?.selected]);\n\n // Apply selected border\n const currentBorder = useMemo<string>(() => {\n return treeContext?.selected.includes(id) ? \"1px solid black\" : \"\";\n }, [id, treeContext?.selected]);\n const nodeColour = useMemo<string | undefined>(() => {\n if (treeContext && treeContext.selected) {\n const anc = getAncestors(treeContext.selected, [], treeContext?.nodeList).map((n) => n.id);\n if ([...anc, treeContext.selected].includes(id)) return treeContext.nodeHighlight;\n }\n return;\n }, [id, treeContext]);\n\n // New node parameters\n const newNameRef = useRef<HTMLInputElement | null>(null);\n const [showNewNode, setShowNewNode] = useState<boolean>(false);\n const [savingNewNode, setSavingNewNode] = useState<boolean>(false);\n\n // Rename parameters\n const currentNameRef = useRef<HTMLInputElement | null>(null);\n const [renaming, setRenaming] = useState<boolean>(false);\n const [updatingNode, setUpdatingNode] = useState<boolean>(false);\n\n // Context functions\n const handleReturn = useCallback((ret: iNodeUpdate) => {\n if (!ret.success) {\n setError(true);\n setErrotText(ret.ErrorText ?? \"An unknown error has occured\");\n } else {\n setError(false);\n setErrotText(\"\");\n }\n }, []);\n\n const confirmNewNode = useCallback(\n async (label: string) => {\n setSavingNewNode(true);\n if (treeContext?.onAddChild) {\n handleReturn(await treeContext.onAddChild(id, label));\n }\n setSavingNewNode(false);\n setShowNewNode(false);\n },\n [handleReturn, id, treeContext],\n );\n\n const renameNode = useCallback(\n async (newLabel: string) => {\n setRenaming(false);\n if (treeContext?.onRename) {\n setUpdatingNode(true);\n handleReturn(await treeContext.onRename(id, newLabel));\n setUpdatingNode(false);\n }\n },\n [handleReturn, id, treeContext],\n );\n\n const deleteThis = useCallback(async () => {\n if (treeContext?.onRemove) {\n setUpdatingNode(true);\n handleReturn(await treeContext.onRemove(id));\n setUpdatingNode(false);\n }\n }, [handleReturn, id, treeContext]);\n\n // Context actions\n const addChild = useCallback(() => {\n setShowNewNode(true);\n treeContext?.handleExpandClick?.(id, true);\n }, [id, treeContext]);\n useEffect(() => {\n if (showNewNode === true && newNameRef.current) newNameRef.current.focus();\n }, [showNewNode]);\n const renameThis = useCallback(() => {\n setRenaming(true);\n treeContext?.handleSelect?.(id);\n }, [id, treeContext]);\n\n // Context menu\n const menuItems = useMemo(() => {\n const menuItems: MenuItem[] = [];\n if (canAddChildren) {\n menuItems.push({ label: \"Add\", action: addChild });\n }\n if (canRename) {\n menuItems.push({ label: \"Rename\", action: renameThis });\n }\n if (canRemove && (childNodes === undefined || childNodes.length === 0)) {\n menuItems.push({ label: \"Delete\", action: deleteThis });\n }\n return menuItems;\n }, [addChild, canAddChildren, canRemove, canRename, childNodes, deleteThis, renameThis]);\n\n // Return node\n return !treeContext ? null : (\n <ContextMenuHandler menuItems={menuItems}>\n <div\n id={`${treeContext.id}-treenode-${id}`}\n className=\"treenode\"\n >\n {error ? (\n <>\n <ExclamationCircleFill color=\"var(--bs-danger)\" /> {errorText}\n </>\n ) : (\n <div className=\"ton-node\">\n {treeContext.showCheckBox && (\n <input\n ref={checkRef}\n type=\"checkbox\"\n role=\"checkbox\"\n className=\"ton-checkbox\"\n id={`${treeContext.id}-treenode-checkbox-${id}`}\n onClick={() => {\n treeContext?.handleSelect?.(descendents);\n }}\n />\n )}\n {childNodes !== undefined && childNodes.length > 0 ? (\n !expanded ? (\n <CaretRightFill\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n color={nodeColour}\n aria-expanded={false}\n aria-label=\"Expander\"\n onClick={() => treeContext.handleExpandClick(id)}\n />\n ) : (\n <CaretDownFill\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n aria-expanded={true}\n aria-label=\"Expander\"\n color={nodeColour}\n onClick={() => {\n treeContext.handleExpandClick(id);\n }}\n />\n )\n ) : (\n <CaretRight\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n color={nodeColour}\n aria-expanded={false}\n aria-label=\"Disabled expander\"\n onClick={() => treeContext.handleSelect && treeContext.handleSelect(id)}\n />\n )}\n {thisNode && (\n <div\n style={{ display: \"inline-block\" }}\n onContextMenuCapture={() =>\n treeContext.handleSelect && treeContext.handleSelect(id)\n }\n onClickCapture={() => treeContext.handleSelect && treeContext.handleSelect(id)}\n onFocusCapture={() => treeContext.handleSelect && treeContext.handleSelect(id)}\n >\n <WordEntry\n id={`${treeContext.id}-treenode-entry-${id}`}\n ref={currentNameRef}\n value={thisNode.label}\n editing={renaming}\n saving={updatingNode}\n setValue={(ret) => renameNode(ret)}\n sendEscape={() => setRenaming(false)}\n style={{\n border: currentBorder,\n margin: currentBorder === \"\" ? \"1px\" : \"\",\n backgroundColor: currentBorder === \"\" ? \"\" : treeContext.textHighlight,\n }}\n spellCheck={treeContext.spellCheck}\n />\n </div>\n )}\n </div>\n )}\n {childNodes !== undefined && (\n <div className={`ton-collapsible-wrapper ${expanded ? \"\" : \"collapsed\"}`}>\n <div className=\"ton-collapsible\">\n {childNodes.map((h) => (\n <span\n key={h.id}\n id={`${treeContext.id}-treenode-child-${h.id}`}\n className=\"ton-child\"\n >\n <TreeNode\n id={h.id}\n canRemove={canRemoveChildren}\n canRename={canRenameChildren}\n canAddChildren={canAddChildren}\n canRemoveChildren={canRemoveChildren}\n canRenameChildren={canRenameChildren}\n />\n </span>\n ))}\n </div>\n </div>\n )}\n {showNewNode && (\n <div>\n <WordEntry\n style={{ marginLeft: \"14px\" }}\n id={`treenode-new-${id}`}\n ref={newNameRef}\n editing={true}\n setValue={(ret) => {\n confirmNewNode(ret);\n }}\n saving={savingNewNode}\n sendEscape={() => {\n setShowNewNode(false);\n }}\n spellCheck={treeContext.spellCheck}\n />\n </div>\n )}\n </div>\n </ContextMenuHandler>\n );\n};\n\nTreeNode.displayName = \"TreeNode\";\n","import { Key } from \"react\";\nimport { TreeNodeBase } from \"../components/interface\";\n\nexport const getAncestors = (\n id: Key | Key[],\n included: TreeNodeBase[],\n hierarchyNodes: TreeNodeBase[],\n): TreeNodeBase[] => {\n const processIds = Array.isArray(id) ? id : [id];\n\n const current = processIds\n .map((i) => hierarchyNodes.find((h) => h.id === i))\n .filter((h) => h !== undefined) as TreeNodeBase[];\n if (current.length === 0) return included;\n\n const parents = (\n current\n .map((h) => h.parentId)\n .map((pid) => hierarchyNodes.find((h) => pid === h.id)) as TreeNodeBase[]\n ).filter((p) => p !== undefined) as TreeNodeBase[];\n if (parents.length === 0) return included;\n else\n return getAncestors(\n parents.map((p) => p.id),\n [...included, ...parents.filter((p) => !included.includes(p))],\n hierarchyNodes,\n );\n};\n","import { Key } from \"react\";\nimport { TreeNodeBase } from \"../components/interface\";\n\nexport const getDescendentIds = (id: Key | Key[], hierarchyNodes: TreeNodeBase[]): Key[] => {\n const processIds = Array.isArray(id) ? id : [id];\n const newChildren = hierarchyNodes\n .filter(\n (h) =>\n h.parentId !== undefined && processIds.includes(h.parentId) && !processIds.includes(h.id),\n )\n .map((h) => h.id);\n return newChildren.length === 0\n ? processIds\n : getDescendentIds([...processIds, ...newChildren], hierarchyNodes);\n};\n","import { createContext, Key } from \"react\";\nimport { iNodeUpdate, TreeNodeData } from \"./interface\";\n\nexport interface TreeOfNodesContextProps<T> {\n id: string;\n nodeList: TreeNodeData<T>[];\n selected: Key[];\n showCheckBox: boolean;\n handleSelect?: (ret: Key | Key[]) => void;\n expandedNodes: Key[];\n handleExpandClick: (ret: Key, force?: boolean) => void;\n onAddChild?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;\n onRename?: (id: Key, newName: string) => Promise<iNodeUpdate>;\n onRemove?: (id: Key) => Promise<iNodeUpdate>;\n nodeHighlight: string;\n textHighlight: string;\n spellCheck?: \"true\" | \"false\";\n}\n\nexport const TreeOfNodesContext = createContext<TreeOfNodesContextProps<unknown> | undefined>(\n undefined,\n);\n","import React, { Key, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Spinner } from \"react-bootstrap\";\n\ninterface WordEntryProps {\n id: Key;\n value?: string;\n editing?: boolean;\n saving?: boolean;\n setValue?: (ret: string) => void;\n sendEscape?: () => void;\n style?: React.CSSProperties;\n spellCheck?: \"true\" | \"false\";\n}\n\nexport const WordEntry = React.forwardRef<HTMLInputElement, WordEntryProps>(\n (\n { id, value, editing, saving, setValue, sendEscape, style, spellCheck = \"true\" },\n ref,\n ): JSX.Element => {\n WordEntry.displayName = \"WordEntry\";\n const currentStyle = useMemo<React.CSSProperties>(() => {\n return {\n display: \"inline-block\",\n padding: \"1px\",\n paddingLeft: \"3px\",\n paddingRight: \"3px\",\n border: \"1px\",\n borderRadius: \"3px\",\n ...style,\n };\n }, [style]);\n\n const [currentValue, setCurrentValue] = useState<string>(value ?? \"\");\n useEffect(() => {\n setCurrentValue(value ?? \"\");\n }, [value]);\n\n const returnData = useCallback(() => {\n setValue?.(currentValue);\n }, [currentValue, setValue]);\n\n const keyPress = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.code === \"Escape\") {\n setCurrentValue(value ?? \"\");\n sendEscape?.();\n } else if (e.code === \"Enter\") {\n returnData();\n }\n },\n [returnData, sendEscape, value],\n );\n\n // Simple if not editing\n if (!editing) {\n return (\n <span\n style={currentStyle}\n id={`${id}`}\n >\n {value ? value : <> </>}\n </span>\n );\n }\n\n return (\n <div\n style={currentStyle}\n id={`${id}-holder`}\n >\n {saving && (\n <Spinner\n id={`${id}-spinner`}\n size=\"sm\"\n animation=\"border\"\n />\n )}\n <input\n autoFocus\n spellCheck={spellCheck}\n id={String(id)}\n ref={ref}\n type=\"text\"\n style={{\n lineHeight: \"0.75rem\",\n border: \"1px dotted black\",\n width: \"auto\",\n minWidth: \"0\",\n }}\n value={currentValue}\n disabled={saving}\n onChange={(e) => setCurrentValue(e.currentTarget.value)}\n onBlur={returnData}\n onKeyDownCapture={keyPress}\n />\n </div>\n );\n },\n);\n","import { Key, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { checkExpandedNodes } from \"../functions/checkExpandedNodes\";\nimport { iNodeUpdate, TreeNodeData } from \"./interface\";\nimport { TreeNode } from \"./TreeNode\";\nimport { TreeOfNodesContext } from \"./TreeOfNodesContext\";\n\ninterface TreeOfNodesProps<T> {\n id: string;\n nodeList: TreeNodeData<T>[];\n roots: Key[];\n showCheckBox?: boolean;\n selected?: Key | Key[];\n handleSelect?: (ret: Key | Key[]) => void;\n onAdd?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;\n onRename?: (childId: Key, newName: string) => Promise<iNodeUpdate>;\n onRemove?: (childId: Key) => Promise<iNodeUpdate>;\n canRemoveRoot?: boolean;\n canRenameRoot?: boolean;\n canAddChildren?: boolean;\n canRemoveChildren?: boolean;\n canRenameChildren?: boolean;\n nodeHighlight?: string;\n textHighlight?: string;\n spellCheck?: \"true\" | \"false\";\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport const TreeOfNodes = <T extends unknown>({\n id,\n nodeList,\n roots,\n selected = [],\n showCheckBox = false,\n handleSelect,\n onAdd,\n onRename,\n onRemove,\n canRemoveRoot = false,\n canRenameRoot = false,\n canAddChildren = false,\n canRemoveChildren = false,\n canRenameChildren = false,\n nodeHighlight = \"red\",\n textHighlight = \"rgba(255, 0, 0, 0.2)\",\n spellCheck = \"true\",\n}: TreeOfNodesProps<T>) => {\n const [expandedNodes, setExpandedNodes] = useState<Key[]>([]);\n const selectedArray = useMemo(\n () => (Array.isArray(selected) ? selected : [selected]),\n [selected],\n );\n useEffect(() => {\n if (selectedArray.length > 0) {\n // Check all nodes are showing that should be\n const shouldExpand = checkExpandedNodes(nodeList, selectedArray, expandedNodes);\n if (shouldExpand.filter((n) => !expandedNodes.includes(n)).length > 0) {\n setExpandedNodes(shouldExpand);\n }\n }\n }, [expandedNodes, nodeList, selectedArray]);\n\n // Change expansion and update contexts\n const changeExpand = useCallback(\n (eKey: Key, force?: boolean) => {\n const newExpandedNodes = [...expandedNodes];\n const ix = newExpandedNodes.findIndex((nKey) => nKey === eKey);\n if ((ix === -1 && force === undefined) || force === true) newExpandedNodes.push(eKey);\n else newExpandedNodes.splice(ix, 1);\n setExpandedNodes(newExpandedNodes);\n },\n [expandedNodes],\n );\n\n return (\n <TreeOfNodesContext.Provider\n value={{\n id: id,\n nodeList,\n selected: selectedArray,\n showCheckBox,\n handleSelect,\n expandedNodes,\n handleExpandClick: (r, f) => changeExpand(r, f),\n onAddChild: onAdd,\n onRename,\n onRemove,\n nodeHighlight,\n textHighlight,\n spellCheck,\n }}\n >\n {roots.map((r) => (\n <TreeNode\n key={r}\n id={r}\n canRemove={canRemoveRoot}\n canAddChildren={canAddChildren}\n canRename={canRenameRoot}\n canRemoveChildren={canRemoveChildren}\n canRenameChildren={canRenameChildren}\n />\n ))}\n </TreeOfNodesContext.Provider>\n );\n};\n\nTreeOfNodes.displayName = \"TreeOfNodes\";\n","import { TreeNodeBase } from \"components\";\nimport { Key } from \"react\";\nimport { getAncestors } from \"./getAncestors\";\n\nexport const checkExpandedNodes = (\n nodeList: TreeNodeBase[],\n selected: Key | Key[],\n expandedNodes: Key[],\n): Key[] => {\n return [\n ...expandedNodes,\n ...getAncestors(selected, [], nodeList)\n .map((n) => n.id)\n .filter((k) => !expandedNodes.includes(k)),\n ].sort((a, b) => `${a}`.localeCompare(`${b}`));\n};\n","import { getAncestors } from \"./getAncestors\";\n\nexport { getAncestors as getParents };\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;AGGO,MAAM,4CAAe,CAC1B,IACA,UACA;IAEA,MAAM,aAAa,MAAM,OAAO,CAAC,MAAM,KAAK;QAAC;KAAG;IAEhD,MAAM,UAAU,WACb,GAAG,CAAC,CAAC,IAAM,eAAe,IAAI,CAAC,CAAC,IAAM,EAAE,EAAE,KAAK,IAC/C,MAAM,CAAC,CAAC,IAAM,MAAM;IACvB,IAAI,QAAQ,MAAM,KAAK,GAAG,OAAO;IAEjC,MAAM,UAAU,AACd,QACG,GAAG,CAAC,CAAC,IAAM,EAAE,QAAQ,EACrB,GAAG,CAAC,CAAC,MAAQ,eAAe,IAAI,CAAC,CAAC,IAAM,QAAQ,EAAE,EAAE,GACvD,MAAM,CAAC,CAAC,IAAM,MAAM;IACtB,IAAI,QAAQ,MAAM,KAAK,GAAG,OAAO;SAE/B,OAAO,0CACL,QAAQ,GAAG,CAAC,CAAC,IAAM,EAAE,EAAE,GACvB;WAAI;WAAa,QAAQ,MAAM,CAAC,CAAC,IAAM,CAAC,SAAS,QAAQ,CAAC;KAAI,EAC9D;AAEN;;;ACxBO,MAAM,4CAAmB,CAAC,IAAiB;IAChD,MAAM,aAAa,MAAM,OAAO,CAAC,MAAM,KAAK;QAAC;KAAG;IAChD,MAAM,cAAc,eACjB,MAAM,CACL,CAAC,IACC,EAAE,QAAQ,KAAK,aAAa,WAAW,QAAQ,CAAC,EAAE,QAAQ,KAAK,CAAC,WAAW,QAAQ,CAAC,EAAE,EAAE,GAE3F,GAAG,CAAC,CAAC,IAAM,EAAE,EAAE;IAClB,OAAO,YAAY,MAAM,KAAK,IAC1B,aACA,0CAAiB;WAAI;WAAe;KAAY,EAAE;AAC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C,CAAA,GAAA,yCAAiB,EAAE,QAAQ;YAC1B,OAAO;gBACL,IAAI;0BACJ;gBACA,UAAU;8BACV;8BACA;+BACA;gBACA,mBAAmB,CAAC,GAAG,IAAM,aAAa,GAAG;gBAC7C,YAAY;0BACZ;0BACA;+BACA;+BACA;4BACA;YACF;sBAEC,MAAM,GAAG,CAAC,CAAC,kBACV,gBAAC,CAAA,GAAA,yCAAO;oBAEN,IAAI;oBACJ,WAAW;oBACX,gBAAgB;oBAChB,WAAW;oBACX,mBAAmB;oBACnB,mBAAmB;mBANd;;;AAYjB;AAEA,0CAAY,WAAW,GAAG;;;;;;;;;;;","sources":["src/main.ts","src/components/index.ts","src/components/TreeNode.tsx","src/functions/getAncestors.tsx","src/functions/getDescendentIds.ts","src/components/TreeOfNodesContext.ts","src/components/WordEntry.tsx","src/components/TreeOfNodes.tsx","src/functions/checkExpandedNodes.ts","src/functions/index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./functions\";\n","import { TreeNode } from \"./TreeNode\";\nimport { TreeOfNodes } from \"./TreeOfNodes\";\nimport { iNodeUpdate, TreeNodeBase, TreeNodeData } from \"./interface\";\nimport { WordEntry } from \"./WordEntry\";\n\nexport { TreeNode, TreeOfNodes, WordEntry };\nexport type { TreeNodeBase, TreeNodeData, iNodeUpdate };\n","import { ContextMenuHandler, MenuItem } from \"@asup/context-menu\";\nimport {\n Key,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n CaretDownFill,\n CaretRight,\n CaretRightFill,\n ExclamationCircleFill,\n} from \"react-bootstrap-icons\";\nimport { getAncestors } from \"../functions/getAncestors\";\nimport { getDescendentIds } from \"../functions/getDescendentIds\";\nimport \"./TreeNode.css\";\nimport { TreeOfNodesContext } from \"./TreeOfNodesContext\";\nimport { WordEntry } from \"./WordEntry\";\nimport { iNodeUpdate } from \"./interface\";\n\ninterface TreeNodeProps {\n id: Key;\n indentLevel?: number;\n canRemove?: boolean;\n canRename?: boolean;\n canAddChildren?: boolean;\n canRemoveChildren?: boolean;\n canRenameChildren?: boolean;\n refresh?: () => void;\n}\n\nexport const TreeNode = ({\n id,\n canRemove,\n canRename,\n canAddChildren,\n canRemoveChildren,\n canRenameChildren,\n}: TreeNodeProps): ReactNode => {\n // Contexts\n const treeContext = useContext(TreeOfNodesContext);\n\n // Node information\n const thisNode = useMemo(\n () => treeContext?.nodeList.find((n) => n.id === id),\n [id, treeContext?.nodeList],\n );\n const childNodes = useMemo(\n () => treeContext?.nodeList.filter((n) => n.parentId === id),\n [id, treeContext?.nodeList],\n );\n const descendents = useMemo(\n () => getDescendentIds(id, treeContext?.nodeList ?? []),\n [id, treeContext],\n );\n\n // State\n const [error, setError] = useState<boolean>(false);\n const [errorText, setErrotText] = useState<string>(\"\");\n const expanded = useMemo(() => {\n return (treeContext?.expandedNodes.findIndex((e) => e === id) ?? -1) > -1;\n }, [id, treeContext?.expandedNodes]);\n\n // Checkbox\n const checkRef = useRef<HTMLInputElement | null>(null);\n useEffect(() => {\n if (checkRef.current) {\n if (treeContext?.selected.includes(id)) {\n checkRef.current.checked = true;\n checkRef.current.indeterminate = false;\n } else if (descendents.some((d) => treeContext?.selected.includes(d))) {\n checkRef.current.checked = false;\n checkRef.current.indeterminate = true;\n } else {\n checkRef.current.checked = false;\n checkRef.current.indeterminate = false;\n }\n }\n }, [descendents, id, treeContext?.selected]);\n\n // Apply selected border\n const currentBorder = useMemo<string>(() => {\n return treeContext?.selected.includes(id) ? \"1px solid black\" : \"\";\n }, [id, treeContext?.selected]);\n const nodeColour = useMemo<string | undefined>(() => {\n if (treeContext && treeContext.selected) {\n const anc = getAncestors(treeContext.selected, [], treeContext?.nodeList).map((n) => n.id);\n if ([...anc, treeContext.selected].includes(id)) return treeContext.nodeHighlight;\n }\n return;\n }, [id, treeContext]);\n\n // New node parameters\n const newNameRef = useRef<HTMLInputElement | null>(null);\n const [showNewNode, setShowNewNode] = useState<boolean>(false);\n const [savingNewNode, setSavingNewNode] = useState<boolean>(false);\n\n // Rename parameters\n const currentNameRef = useRef<HTMLInputElement | null>(null);\n const [renaming, setRenaming] = useState<boolean>(false);\n const [updatingNode, setUpdatingNode] = useState<boolean>(false);\n\n // Context functions\n const handleReturn = useCallback((ret: iNodeUpdate) => {\n if (!ret.success) {\n setError(true);\n setErrotText(ret.ErrorText ?? \"An unknown error has occured\");\n } else {\n setError(false);\n setErrotText(\"\");\n }\n }, []);\n\n const confirmNewNode = useCallback(\n async (label: string) => {\n setSavingNewNode(true);\n if (treeContext?.onAddChild) {\n handleReturn(await treeContext.onAddChild(id, label));\n }\n setSavingNewNode(false);\n setShowNewNode(false);\n },\n [handleReturn, id, treeContext],\n );\n\n const renameNode = useCallback(\n async (newLabel: string) => {\n setRenaming(false);\n if (treeContext?.onRename) {\n setUpdatingNode(true);\n handleReturn(await treeContext.onRename(id, newLabel));\n setUpdatingNode(false);\n }\n },\n [handleReturn, id, treeContext],\n );\n\n const deleteThis = useCallback(async () => {\n if (treeContext?.onRemove) {\n setUpdatingNode(true);\n handleReturn(await treeContext.onRemove(id));\n setUpdatingNode(false);\n }\n }, [handleReturn, id, treeContext]);\n\n // Context actions\n const addChild = useCallback(() => {\n setShowNewNode(true);\n treeContext?.handleExpandClick?.(id, true);\n }, [id, treeContext]);\n useEffect(() => {\n if (showNewNode === true && newNameRef.current) newNameRef.current.focus();\n }, [showNewNode]);\n const renameThis = useCallback(() => {\n setRenaming(true);\n treeContext?.handleSelect?.(id);\n }, [id, treeContext]);\n\n // Context menu\n const menuItems = useMemo(() => {\n const menuItems: MenuItem[] = [];\n if (canAddChildren) {\n menuItems.push({ label: \"Add\", action: addChild });\n }\n if (canRename) {\n menuItems.push({ label: \"Rename\", action: renameThis });\n }\n if (canRemove && (childNodes === undefined || childNodes.length === 0)) {\n menuItems.push({ label: \"Delete\", action: deleteThis });\n }\n return menuItems;\n }, [addChild, canAddChildren, canRemove, canRename, childNodes, deleteThis, renameThis]);\n\n // Return node\n return !treeContext ? null : (\n <>\n <ContextMenuHandler\n menuItems={menuItems}\n style={{ display: \"inline-block\", width: \"100%\" }}\n >\n <div\n id={`${treeContext.id}-treenode-${id}`}\n className=\"treenode\"\n >\n {error ? (\n <>\n <ExclamationCircleFill color=\"var(--bs-danger)\" /> {errorText}\n </>\n ) : (\n <div className=\"ton-node\">\n {treeContext.showCheckBox && (\n <input\n ref={checkRef}\n type=\"checkbox\"\n role=\"checkbox\"\n className=\"ton-checkbox\"\n id={`${treeContext.id}-treenode-checkbox-${id}`}\n onClick={() => treeContext?.handleSelect?.(descendents)}\n />\n )}\n {childNodes !== undefined && childNodes.length > 0 ? (\n !expanded ? (\n <CaretRightFill\n id={`${treeContext.id}-treenode-caret-${id}`}\n style={{ width: \"16px\", height: \"16px\" }}\n className=\"ton-expander\"\n role=\"button\"\n color={nodeColour}\n aria-expanded={false}\n aria-label=\"Expander\"\n onClick={() => treeContext.handleExpandClick(id)}\n />\n ) : (\n <CaretDownFill\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n aria-expanded={true}\n aria-label=\"Expander\"\n color={nodeColour}\n onClick={() => treeContext.handleExpandClick(id)}\n />\n )\n ) : (\n <CaretRight\n id={`${treeContext.id}-treenode-caret-${id}`}\n className=\"ton-expander\"\n role=\"button\"\n color={nodeColour}\n aria-expanded={false}\n aria-label=\"Disabled expander\"\n onClick={() => treeContext.handleSelect?.(id)}\n />\n )}\n {thisNode && (\n <div\n className=\"ton-label\"\n style={{ width: `calc(100% - ${treeContext.showCheckBox ? \"32px\" : \"16px\"})` }}\n onContextMenuCapture={() => treeContext.handleSelect?.(id)}\n onClickCapture={() => treeContext.handleSelect?.(id)}\n onFocusCapture={() => treeContext.handleSelect?.(id)}\n >\n <WordEntry\n id={`${treeContext.id}-treenode-entry-${id}`}\n ref={currentNameRef}\n value={thisNode.label}\n editing={renaming}\n saving={updatingNode}\n setValue={(ret) => renameNode(ret)}\n sendEscape={() => setRenaming(false)}\n style={{\n border: currentBorder,\n margin: currentBorder === \"\" ? \"1px\" : \"\",\n backgroundColor: currentBorder === \"\" ? \"\" : treeContext.textHighlight,\n }}\n spellCheck={treeContext.spellCheck}\n />\n </div>\n )}\n </div>\n )}\n </div>\n </ContextMenuHandler>\n {showNewNode && (\n <WordEntry\n style={{ marginLeft: \"14px\" }}\n id={`treenode-new-${id}`}\n ref={newNameRef}\n editing={true}\n setValue={(ret) => confirmNewNode(ret)}\n saving={savingNewNode}\n sendEscape={() => setShowNewNode(false)}\n spellCheck={treeContext.spellCheck}\n />\n )}\n {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 </>\n );\n};\n\nTreeNode.displayName = \"TreeNode\";\n","import { Key } from \"react\";\nimport { TreeNodeBase } from \"../components/interface\";\n\nexport const getAncestors = (\n id: Key | Key[],\n included: TreeNodeBase[],\n hierarchyNodes: TreeNodeBase[],\n): TreeNodeBase[] => {\n const processIds = Array.isArray(id) ? id : [id];\n\n const current = processIds\n .map((i) => hierarchyNodes.find((h) => h.id === i))\n .filter((h) => h !== undefined) as TreeNodeBase[];\n if (current.length === 0) return included;\n\n const parents = (\n current\n .map((h) => h.parentId)\n .map((pid) => hierarchyNodes.find((h) => pid === h.id)) as TreeNodeBase[]\n ).filter((p) => p !== undefined) as TreeNodeBase[];\n if (parents.length === 0) return included;\n else\n return getAncestors(\n parents.map((p) => p.id),\n [...included, ...parents.filter((p) => !included.includes(p))],\n hierarchyNodes,\n );\n};\n","import { Key } from \"react\";\nimport { TreeNodeBase } from \"../components/interface\";\n\nexport const getDescendentIds = (id: Key | Key[], hierarchyNodes: TreeNodeBase[]): Key[] => {\n const processIds = Array.isArray(id) ? id : [id];\n const newChildren = hierarchyNodes\n .filter(\n (h) =>\n h.parentId !== undefined && processIds.includes(h.parentId) && !processIds.includes(h.id),\n )\n .map((h) => h.id);\n return newChildren.length === 0\n ? processIds\n : getDescendentIds([...processIds, ...newChildren], hierarchyNodes);\n};\n","import { createContext, Key } from \"react\";\nimport { iNodeUpdate, TreeNodeData } from \"./interface\";\n\nexport interface TreeOfNodesContextProps<T> {\n id: string;\n nodeList: TreeNodeData<T>[];\n selected: Key[];\n showCheckBox: boolean;\n handleSelect?: (ret: Key | Key[]) => void;\n expandedNodes: Key[];\n handleExpandClick: (ret: Key, force?: boolean) => void;\n onAddChild?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;\n onRename?: (id: Key, newName: string) => Promise<iNodeUpdate>;\n onRemove?: (id: Key) => Promise<iNodeUpdate>;\n nodeHighlight: string;\n textHighlight: string;\n spellCheck?: \"true\" | \"false\";\n}\n\nexport const TreeOfNodesContext = createContext<TreeOfNodesContextProps<unknown> | undefined>(\n undefined,\n);\n","import React, { Key, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Spinner } from \"react-bootstrap\";\n\ninterface WordEntryProps {\n id: Key;\n value?: string;\n editing?: boolean;\n saving?: boolean;\n setValue?: (ret: string) => void;\n sendEscape?: () => void;\n style?: React.CSSProperties;\n spellCheck?: \"true\" | \"false\";\n}\n\nexport const WordEntry = React.forwardRef<HTMLInputElement, WordEntryProps>(\n (\n { id, value, editing, saving, setValue, sendEscape, style, spellCheck = \"true\" },\n ref,\n ): JSX.Element => {\n WordEntry.displayName = \"WordEntry\";\n const currentStyle = useMemo<React.CSSProperties>(() => {\n return {\n display: \"inline-block\",\n padding: \"1px\",\n paddingLeft: \"3px\",\n paddingRight: \"3px\",\n border: \"1px\",\n borderRadius: \"3px\",\n ...style,\n };\n }, [style]);\n\n const [currentValue, setCurrentValue] = useState<string>(value ?? \"\");\n useEffect(() => {\n setCurrentValue(value ?? \"\");\n }, [value]);\n\n const returnData = useCallback(() => {\n setValue?.(currentValue);\n }, [currentValue, setValue]);\n\n const keyPress = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.code === \"Escape\") {\n setCurrentValue(value ?? \"\");\n sendEscape?.();\n } else if (e.code === \"Enter\") {\n returnData();\n }\n },\n [returnData, sendEscape, value],\n );\n\n // Simple if not editing\n if (!editing) {\n return (\n <span\n className=\"ton-label-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 className=\"ton-rename-holder\"\n >\n {saving && (\n <Spinner\n id={`${id}-spinner`}\n size=\"sm\"\n animation=\"border\"\n />\n )}\n <input\n autoFocus\n spellCheck={spellCheck}\n id={String(id)}\n ref={ref}\n type=\"text\"\n className=\"ton-rename\"\n value={currentValue}\n disabled={saving}\n onChange={(e) => setCurrentValue(e.currentTarget.value)}\n onBlur={returnData}\n onKeyDownCapture={keyPress}\n />\n </div>\n );\n },\n);\n","import { Key, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { checkExpandedNodes } from \"../functions/checkExpandedNodes\";\nimport { iNodeUpdate, TreeNodeData } from \"./interface\";\nimport { TreeNode } from \"./TreeNode\";\nimport { TreeOfNodesContext } from \"./TreeOfNodesContext\";\n\ninterface TreeOfNodesProps<T> {\n id: string;\n nodeList: TreeNodeData<T>[];\n roots: Key[];\n showCheckBox?: boolean;\n selected?: Key | Key[];\n handleSelect?: (ret: Key | Key[]) => void;\n onAdd?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;\n onRename?: (childId: Key, newName: string) => Promise<iNodeUpdate>;\n onRemove?: (childId: Key) => Promise<iNodeUpdate>;\n canRemoveRoot?: boolean;\n canRenameRoot?: boolean;\n canAddChildren?: boolean;\n canRemoveChildren?: boolean;\n canRenameChildren?: boolean;\n nodeHighlight?: string;\n textHighlight?: string;\n spellCheck?: \"true\" | \"false\";\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport const TreeOfNodes = <T extends unknown>({\n id,\n nodeList,\n roots,\n selected = [],\n showCheckBox = false,\n handleSelect,\n onAdd,\n onRename,\n onRemove,\n canRemoveRoot = false,\n canRenameRoot = false,\n canAddChildren = false,\n canRemoveChildren = false,\n canRenameChildren = false,\n nodeHighlight = \"red\",\n textHighlight = \"rgba(255, 0, 0, 0.2)\",\n spellCheck = \"true\",\n}: TreeOfNodesProps<T>) => {\n const [expandedNodes, setExpandedNodes] = useState<Key[]>([]);\n const selectedArray = useMemo(\n () => (Array.isArray(selected) ? selected : [selected]),\n [selected],\n );\n useEffect(() => {\n if (selectedArray.length > 0) {\n // Check all nodes are showing that should be\n const shouldExpand = checkExpandedNodes(nodeList, selectedArray, expandedNodes);\n if (shouldExpand.filter((n) => !expandedNodes.includes(n)).length > 0) {\n setExpandedNodes(shouldExpand);\n }\n }\n }, [expandedNodes, nodeList, selectedArray]);\n\n // Change expansion and update contexts\n const changeExpand = useCallback(\n (eKey: Key, force?: boolean) => {\n const newExpandedNodes = [...expandedNodes];\n const ix = newExpandedNodes.findIndex((nKey) => nKey === eKey);\n if ((ix === -1 && force === undefined) || force === true) newExpandedNodes.push(eKey);\n else newExpandedNodes.splice(ix, 1);\n setExpandedNodes(newExpandedNodes);\n },\n [expandedNodes],\n );\n\n return (\n <div\n id={id}\n className=\"tree-of-nodes\"\n >\n <TreeOfNodesContext.Provider\n value={{\n id: id,\n nodeList,\n selected: selectedArray,\n showCheckBox,\n handleSelect,\n expandedNodes,\n handleExpandClick: (r, f) => changeExpand(r, f),\n onAddChild: onAdd,\n onRename,\n onRemove,\n nodeHighlight,\n textHighlight,\n spellCheck,\n }}\n >\n {roots.map((r) => (\n <TreeNode\n key={r}\n id={r}\n canRemove={canRemoveRoot}\n canAddChildren={canAddChildren}\n canRename={canRenameRoot}\n canRemoveChildren={canRemoveChildren}\n canRenameChildren={canRenameChildren}\n />\n ))}\n </TreeOfNodesContext.Provider>\n </div>\n );\n};\n\nTreeOfNodes.displayName = \"TreeOfNodes\";\n","import { TreeNodeBase } from \"components\";\nimport { Key } from \"react\";\nimport { getAncestors } from \"./getAncestors\";\n\nexport const checkExpandedNodes = (\n nodeList: TreeNodeBase[],\n selected: Key | Key[],\n expandedNodes: Key[],\n): Key[] => {\n return [\n ...expandedNodes,\n ...getAncestors(selected, [], nodeList)\n .map((n) => n.id)\n .filter((k) => !expandedNodes.includes(k)),\n ].sort((a, b) => `${a}`.localeCompare(`${b}`));\n};\n","import { getAncestors } from \"./getAncestors\";\n\nexport { getAncestors as getParents };\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAEA;IACE,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;IACE,EAAE,EAAE,GAAG,CAAC;IACR,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED,8BAA8B,CAAC,CAAE,SAAQ,YAAY;IACnD,IAAI,EAAE,CAAC,CAAC;CACT;ACZD,QAAO,MAAM,eACX,IAAI,GAAG,GAAG,GAAG,EAAE,EACf,UAAU,YAAY,EAAE,EACxB,gBAAgB,YAAY,EAAE,KAC7B,YAAY,EAoBd,CAAC;AGxBF;IACE,EAAE,EAAE,GAAG,CAAC;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,aAAa,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/B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AAQ,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC;IAC5B,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,KAAK,IAAI,CAAC;IAC1C,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IACjE,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IACnE,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/B;AAGD,OAAO,MAAM;KAAe,CAAC,SAAS,OAAO,2NAkB1C,iBAAiB,CAAC,CAAC;;CAgErB,CAAC","sources":["src/src/components/interface.ts","src/src/functions/getAncestors.tsx","src/src/functions/getDescendentIds.ts","src/src/components/TreeOfNodesContext.ts","src/src/components/WordEntry.tsx","src/src/components/TreeNode.tsx","src/src/functions/checkExpandedNodes.ts","src/src/components/TreeOfNodes.tsx","src/src/components/index.ts","src/src/functions/index.ts","src/src/main.ts","src/main.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,"export * from \"./components\";\nexport * from \"./functions\";\n"],"names":[],"version":3,"file":"tree-of-nodes.d.ts.map"}
|