wunderbaum 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wunderbaum.css +5 -4
- package/dist/wunderbaum.css.map +1 -1
- package/dist/wunderbaum.d.ts +25 -30
- package/dist/wunderbaum.esm.js +245 -190
- package/dist/wunderbaum.esm.min.js +24 -24
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +245 -190
- package/dist/wunderbaum.umd.min.js +29 -29
- package/dist/wunderbaum.umd.min.js.map +1 -1
- package/package.json +8 -6
- package/src/common.ts +2 -2
- package/src/debounce.ts +1 -0
- package/src/types.ts +21 -21
- package/src/util.ts +28 -27
- package/src/wb_ext_dnd.ts +57 -21
- package/src/wb_ext_filter.ts +20 -18
- package/src/wb_ext_keynav.ts +8 -8
- package/src/wb_ext_logger.ts +3 -2
- package/src/wb_node.ts +97 -98
- package/src/wunderbaum.scss +5 -4
- package/src/wunderbaum.ts +59 -70
package/dist/wunderbaum.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Wunderbaum - util
|
|
3
3
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
4
|
-
* v0.5.
|
|
4
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
5
5
|
*/
|
|
6
6
|
/** @module util */
|
|
7
7
|
/** Readable names for `MouseEvent.button` */
|
|
@@ -120,7 +120,8 @@ function each(obj, callback) {
|
|
|
120
120
|
// accept `null` or `undefined`
|
|
121
121
|
return obj;
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
const length = obj.length;
|
|
124
|
+
let i = 0;
|
|
124
125
|
if (typeof length === "number") {
|
|
125
126
|
for (; i < length; i++) {
|
|
126
127
|
if (callback.call(obj[i], i, obj[i]) === false) {
|
|
@@ -129,7 +130,7 @@ function each(obj, callback) {
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
else {
|
|
132
|
-
for (
|
|
133
|
+
for (const k in obj) {
|
|
133
134
|
if (callback.call(obj[i], k, obj[k]) === false) {
|
|
134
135
|
break;
|
|
135
136
|
}
|
|
@@ -229,9 +230,11 @@ function getValueFromElem(elem, coerce = false) {
|
|
|
229
230
|
value = input.valueAsNumber;
|
|
230
231
|
break;
|
|
231
232
|
case "radio":
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
{
|
|
234
|
+
const name = input.name;
|
|
235
|
+
const checked = input.parentElement.querySelector(`input[name="${name}"]:checked`);
|
|
236
|
+
value = checked ? checked.value : undefined;
|
|
237
|
+
}
|
|
235
238
|
break;
|
|
236
239
|
case "text":
|
|
237
240
|
default:
|
|
@@ -403,7 +406,9 @@ function eventTargetFromSelector(obj) {
|
|
|
403
406
|
* ```
|
|
404
407
|
*/
|
|
405
408
|
function eventToString(event) {
|
|
406
|
-
|
|
409
|
+
const key = event.key;
|
|
410
|
+
const et = event.type;
|
|
411
|
+
const s = [];
|
|
407
412
|
if (event.altKey) {
|
|
408
413
|
s.push("Alt");
|
|
409
414
|
}
|
|
@@ -441,11 +446,11 @@ function eventToString(event) {
|
|
|
441
446
|
// TODO: support deep merge --> https://stackoverflow.com/a/42740894
|
|
442
447
|
function extend(...args) {
|
|
443
448
|
for (let i = 1; i < args.length; i++) {
|
|
444
|
-
|
|
449
|
+
const arg = args[i];
|
|
445
450
|
if (arg == null) {
|
|
446
451
|
continue;
|
|
447
452
|
}
|
|
448
|
-
for (
|
|
453
|
+
for (const key in arg) {
|
|
449
454
|
if (Object.prototype.hasOwnProperty.call(arg, key)) {
|
|
450
455
|
args[0][key] = arg[key];
|
|
451
456
|
}
|
|
@@ -513,12 +518,16 @@ function onEvent(rootTarget, eventNames, selectorOrHandler, handlerOrNone) {
|
|
|
513
518
|
```
|
|
514
519
|
*/
|
|
515
520
|
function overrideMethod(instance, methodName, handler, ctx) {
|
|
516
|
-
let prevSuper, prevSuperApply
|
|
521
|
+
let prevSuper, prevSuperApply;
|
|
522
|
+
const self = ctx || instance;
|
|
523
|
+
const prevFunc = instance[methodName];
|
|
524
|
+
const _super = (...args) => {
|
|
517
525
|
return prevFunc.apply(self, args);
|
|
518
|
-
}
|
|
526
|
+
};
|
|
527
|
+
const _superApply = (argsArray) => {
|
|
519
528
|
return prevFunc.apply(self, argsArray);
|
|
520
529
|
};
|
|
521
|
-
|
|
530
|
+
const wrapper = (...args) => {
|
|
522
531
|
try {
|
|
523
532
|
prevSuper = self._super;
|
|
524
533
|
prevSuperApply = self._superApply;
|
|
@@ -604,7 +613,7 @@ function getOption(opts, name, defaultValue = undefined) {
|
|
|
604
613
|
[ext, name] = name.split(".");
|
|
605
614
|
opts = opts[ext];
|
|
606
615
|
}
|
|
607
|
-
|
|
616
|
+
const value = opts ? opts[name] : null;
|
|
608
617
|
// Use value from value options dict, fallback do default
|
|
609
618
|
return value !== null && value !== void 0 ? value : defaultValue;
|
|
610
619
|
}
|
|
@@ -614,7 +623,7 @@ function toSet(val) {
|
|
|
614
623
|
return val;
|
|
615
624
|
}
|
|
616
625
|
if (typeof val === "string") {
|
|
617
|
-
|
|
626
|
+
const set = new Set();
|
|
618
627
|
for (const c of val.split(" ")) {
|
|
619
628
|
set.add(c.trim());
|
|
620
629
|
}
|
|
@@ -687,7 +696,7 @@ function adaptiveThrottle(callback, options) {
|
|
|
687
696
|
callback.apply(this, useArgs);
|
|
688
697
|
}
|
|
689
698
|
catch (error) {
|
|
690
|
-
console.error(error);
|
|
699
|
+
console.error(error); // eslint-disable-line no-console
|
|
691
700
|
}
|
|
692
701
|
const elap = Date.now() - start;
|
|
693
702
|
const curDelay = Math.min(Math.max(minDelay, elap * opts.delayFactor), maxDelay);
|
|
@@ -756,7 +765,7 @@ var util = /*#__PURE__*/Object.freeze({
|
|
|
756
765
|
/*!
|
|
757
766
|
* Wunderbaum - types
|
|
758
767
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
759
|
-
* v0.5.
|
|
768
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
760
769
|
*/
|
|
761
770
|
/**
|
|
762
771
|
* Possible values for {@link WunderbaumNode.update()} and {@link Wunderbaum.update()}.
|
|
@@ -820,7 +829,7 @@ var NavModeEnum;
|
|
|
820
829
|
/*!
|
|
821
830
|
* Wunderbaum - wb_extension_base
|
|
822
831
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
823
|
-
* v0.5.
|
|
832
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
824
833
|
*/
|
|
825
834
|
class WunderbaumExtension {
|
|
826
835
|
constructor(tree, id, defaults) {
|
|
@@ -1085,6 +1094,7 @@ function debounce(func, wait = 0, options = {}) {
|
|
|
1085
1094
|
const time = Date.now();
|
|
1086
1095
|
const isInvoking = shouldInvoke(time);
|
|
1087
1096
|
lastArgs = args;
|
|
1097
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1088
1098
|
lastThis = this;
|
|
1089
1099
|
lastCallTime = time;
|
|
1090
1100
|
if (isInvoking) {
|
|
@@ -1175,7 +1185,7 @@ function throttle(func, wait = 0, options = {}) {
|
|
|
1175
1185
|
/*!
|
|
1176
1186
|
* Wunderbaum - ext-filter
|
|
1177
1187
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
1178
|
-
* v0.5.
|
|
1188
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
1179
1189
|
*/
|
|
1180
1190
|
const START_MARKER = "\uFFF7";
|
|
1181
1191
|
const END_MARKER = "\uFFF8";
|
|
@@ -1225,9 +1235,15 @@ class FilterExtension extends WunderbaumExtension {
|
|
|
1225
1235
|
});
|
|
1226
1236
|
}
|
|
1227
1237
|
_applyFilterImpl(filter, branchMode, _opts) {
|
|
1228
|
-
let match, temp,
|
|
1238
|
+
let match, temp, count = 0;
|
|
1239
|
+
const start = Date.now();
|
|
1240
|
+
const tree = this.tree;
|
|
1241
|
+
const treeOpts = tree.options;
|
|
1229
1242
|
// escapeTitles = treeOpts.escapeTitles,
|
|
1230
|
-
prevAutoCollapse = treeOpts.autoCollapse
|
|
1243
|
+
const prevAutoCollapse = treeOpts.autoCollapse;
|
|
1244
|
+
const opts = extend({}, treeOpts.filter, _opts);
|
|
1245
|
+
const hideMode = opts.mode === "hide";
|
|
1246
|
+
const leavesOnly = !!opts.leavesOnly && !branchMode;
|
|
1231
1247
|
// Default to 'match title substring (case insensitive)'
|
|
1232
1248
|
if (typeof filter === "string") {
|
|
1233
1249
|
if (filter === "") {
|
|
@@ -1254,16 +1270,16 @@ class FilterExtension extends WunderbaumExtension {
|
|
|
1254
1270
|
else {
|
|
1255
1271
|
match = escapeRegex(filter); // make sure a '.' is treated literally
|
|
1256
1272
|
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1273
|
+
const re = new RegExp(match, "i");
|
|
1274
|
+
const reHighlight = new RegExp(escapeRegex(filter), "gi");
|
|
1259
1275
|
filter = (node) => {
|
|
1260
1276
|
if (!node.title) {
|
|
1261
1277
|
return false;
|
|
1262
1278
|
}
|
|
1263
1279
|
// let text = escapeTitles ? node.title : extractHtmlText(node.title);
|
|
1264
|
-
|
|
1280
|
+
const text = node.title;
|
|
1265
1281
|
// `.match` instead of `.test` to get the capture groups
|
|
1266
|
-
|
|
1282
|
+
const res = text.match(re);
|
|
1267
1283
|
if (res && opts.highlight) {
|
|
1268
1284
|
// if (escapeTitles) {
|
|
1269
1285
|
if (opts.fuzzy) {
|
|
@@ -1296,6 +1312,7 @@ class FilterExtension extends WunderbaumExtension {
|
|
|
1296
1312
|
};
|
|
1297
1313
|
}
|
|
1298
1314
|
tree.filterMode = opts.mode;
|
|
1315
|
+
// eslint-disable-next-line prefer-rest-params, prefer-spread
|
|
1299
1316
|
this.lastFilterArgs = arguments;
|
|
1300
1317
|
tree.element.classList.toggle("wb-ext-filter-hide", !!hideMode);
|
|
1301
1318
|
tree.element.classList.toggle("wb-ext-filter-dim", !hideMode);
|
|
@@ -1373,10 +1390,11 @@ class FilterExtension extends WunderbaumExtension {
|
|
|
1373
1390
|
*/
|
|
1374
1391
|
updateFilter() {
|
|
1375
1392
|
var _a;
|
|
1376
|
-
|
|
1393
|
+
const tree = this.tree;
|
|
1377
1394
|
if (tree.filterMode &&
|
|
1378
1395
|
this.lastFilterArgs &&
|
|
1379
1396
|
((_a = tree.options.filter) === null || _a === void 0 ? void 0 : _a.autoApply)) {
|
|
1397
|
+
// eslint-disable-next-line prefer-spread
|
|
1380
1398
|
this._applyFilterNoUpdate.apply(this, this.lastFilterArgs);
|
|
1381
1399
|
}
|
|
1382
1400
|
else {
|
|
@@ -1387,7 +1405,7 @@ class FilterExtension extends WunderbaumExtension {
|
|
|
1387
1405
|
* [ext-filter] Reset the filter.
|
|
1388
1406
|
*/
|
|
1389
1407
|
clearFilter() {
|
|
1390
|
-
|
|
1408
|
+
const tree = this.tree;
|
|
1391
1409
|
// statusNode = tree.root.findDirectChild(KEY_NODATA),
|
|
1392
1410
|
// escapeTitles = tree.options.escapeTitles;
|
|
1393
1411
|
tree.enableUpdate(false);
|
|
@@ -1435,10 +1453,10 @@ class FilterExtension extends WunderbaumExtension {
|
|
|
1435
1453
|
* @param {RegExpMatchArray} matches
|
|
1436
1454
|
*/
|
|
1437
1455
|
function _markFuzzyMatchedChars(text, matches, escapeTitles = true) {
|
|
1438
|
-
|
|
1456
|
+
const matchingIndices = [];
|
|
1439
1457
|
// get the indices of matched characters (Iterate through `RegExpMatchArray`)
|
|
1440
1458
|
for (let _matchingArrIdx = 1; _matchingArrIdx < matches.length; _matchingArrIdx++) {
|
|
1441
|
-
|
|
1459
|
+
const _mIdx =
|
|
1442
1460
|
// get matching char index by cumulatively adding
|
|
1443
1461
|
// the matched group length
|
|
1444
1462
|
matches[_matchingArrIdx].length +
|
|
@@ -1447,7 +1465,7 @@ function _markFuzzyMatchedChars(text, matches, escapeTitles = true) {
|
|
|
1447
1465
|
matchingIndices.push(_mIdx);
|
|
1448
1466
|
}
|
|
1449
1467
|
// Map each `text` char to its position and store in `textPoses`.
|
|
1450
|
-
|
|
1468
|
+
const textPoses = text.split("");
|
|
1451
1469
|
if (escapeTitles) {
|
|
1452
1470
|
// If escaping the title, then wrap the matching char within exotic chars
|
|
1453
1471
|
matchingIndices.forEach(function (v) {
|
|
@@ -1467,7 +1485,7 @@ function _markFuzzyMatchedChars(text, matches, escapeTitles = true) {
|
|
|
1467
1485
|
/*!
|
|
1468
1486
|
* Wunderbaum - ext-keynav
|
|
1469
1487
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
1470
|
-
* v0.5.
|
|
1488
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
1471
1489
|
*/
|
|
1472
1490
|
const QUICKSEARCH_DELAY = 500;
|
|
1473
1491
|
class KeynavExtension extends WunderbaumExtension {
|
|
@@ -1497,7 +1515,13 @@ class KeynavExtension extends WunderbaumExtension {
|
|
|
1497
1515
|
return !!ace;
|
|
1498
1516
|
}
|
|
1499
1517
|
onKeyEvent(data) {
|
|
1500
|
-
const event = data.event
|
|
1518
|
+
const event = data.event;
|
|
1519
|
+
const tree = this.tree;
|
|
1520
|
+
const opts = data.options;
|
|
1521
|
+
const activate = !event.ctrlKey || opts.autoActivate;
|
|
1522
|
+
const curInput = this._getEmbeddedInputElem(event.target);
|
|
1523
|
+
const inputHasFocus = curInput && this._isCurInputFocused();
|
|
1524
|
+
const navModeOption = opts.navigationModeOption;
|
|
1501
1525
|
// isCellEditMode = tree.navMode === NavigationMode.cellEdit;
|
|
1502
1526
|
let focusNode, eventName = eventToString(event), node = data.node, handled = true;
|
|
1503
1527
|
// tree.log(`onKeyEvent: ${eventName}, curInput`, curInput);
|
|
@@ -1562,7 +1586,7 @@ class KeynavExtension extends WunderbaumExtension {
|
|
|
1562
1586
|
}
|
|
1563
1587
|
tree.lastQuicksearchTime = stamp;
|
|
1564
1588
|
tree.lastQuicksearchTerm += eventName;
|
|
1565
|
-
|
|
1589
|
+
const matchNode = tree.findNextNode(tree.lastQuicksearchTerm, tree.getActiveNode());
|
|
1566
1590
|
if (matchNode) {
|
|
1567
1591
|
matchNode.setActive(true, { event: event });
|
|
1568
1592
|
}
|
|
@@ -1807,7 +1831,7 @@ class KeynavExtension extends WunderbaumExtension {
|
|
|
1807
1831
|
/*!
|
|
1808
1832
|
* Wunderbaum - ext-logger
|
|
1809
1833
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
1810
|
-
* v0.5.
|
|
1834
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
1811
1835
|
*/
|
|
1812
1836
|
class LoggerExtension extends WunderbaumExtension {
|
|
1813
1837
|
constructor(tree) {
|
|
@@ -1828,19 +1852,20 @@ class LoggerExtension extends WunderbaumExtension {
|
|
|
1828
1852
|
const ignoreEvents = this.ignoreEvents;
|
|
1829
1853
|
const prefix = this.prefix;
|
|
1830
1854
|
overrideMethod(tree, "callEvent", function (name, extra) {
|
|
1855
|
+
/* eslint-disable prefer-rest-params */
|
|
1831
1856
|
if (ignoreEvents.has(name)) {
|
|
1832
1857
|
return tree._superApply(arguments);
|
|
1833
1858
|
}
|
|
1834
1859
|
const start = Date.now();
|
|
1835
1860
|
const res = tree._superApply(arguments);
|
|
1836
|
-
|
|
1861
|
+
tree.logDebug(`${prefix}: callEvent('${name}') took ${Date.now() - start} ms.`, arguments[1]);
|
|
1837
1862
|
return res;
|
|
1838
1863
|
});
|
|
1839
1864
|
}
|
|
1840
1865
|
}
|
|
1841
1866
|
onKeyEvent(data) {
|
|
1842
1867
|
// this.tree.logInfo("onKeyEvent", eventToString(data.event), data);
|
|
1843
|
-
|
|
1868
|
+
this.tree.logDebug(`${this.prefix}: onKeyEvent()`, data);
|
|
1844
1869
|
return;
|
|
1845
1870
|
}
|
|
1846
1871
|
}
|
|
@@ -1848,7 +1873,7 @@ class LoggerExtension extends WunderbaumExtension {
|
|
|
1848
1873
|
/*!
|
|
1849
1874
|
* Wunderbaum - common
|
|
1850
1875
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
1851
|
-
* v0.5.
|
|
1876
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
1852
1877
|
*/
|
|
1853
1878
|
const DEFAULT_DEBUGLEVEL = 3; // Replaced by rollup script
|
|
1854
1879
|
/**
|
|
@@ -2006,7 +2031,7 @@ function unflattenSource(source) {
|
|
|
2006
2031
|
throw new Error(`source._positional must not include "children": ${_positional}`);
|
|
2007
2032
|
}
|
|
2008
2033
|
// Inverse keyMap:
|
|
2009
|
-
|
|
2034
|
+
const longToShort = {};
|
|
2010
2035
|
if (_keyMap) {
|
|
2011
2036
|
for (const [key, value] of Object.entries(_keyMap)) {
|
|
2012
2037
|
longToShort[value] = key;
|
|
@@ -2079,7 +2104,7 @@ function inflateSourceData(source) {
|
|
|
2079
2104
|
delete source._typeList;
|
|
2080
2105
|
delete source._positional;
|
|
2081
2106
|
function _iter(childList) {
|
|
2082
|
-
for (
|
|
2107
|
+
for (const node of childList) {
|
|
2083
2108
|
// Expand short alias names
|
|
2084
2109
|
if (_keyMap) {
|
|
2085
2110
|
// Iterate over a list of names, because we modify inside the loop:
|
|
@@ -2114,7 +2139,7 @@ function inflateSourceData(source) {
|
|
|
2114
2139
|
/*!
|
|
2115
2140
|
* Wunderbaum - ext-dnd
|
|
2116
2141
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
2117
|
-
* v0.5.
|
|
2142
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
2118
2143
|
*/
|
|
2119
2144
|
const nodeMimeType = "application/x-wunderbaum-node";
|
|
2120
2145
|
class DndExtension extends WunderbaumExtension {
|
|
@@ -2209,7 +2234,9 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2209
2234
|
}
|
|
2210
2235
|
throw new Error("Unsupported drop region definition: " + res);
|
|
2211
2236
|
}
|
|
2212
|
-
/**
|
|
2237
|
+
/**
|
|
2238
|
+
* Calculates the drop region based on the drag event and the allowed drop regions.
|
|
2239
|
+
*/
|
|
2213
2240
|
_calcDropRegion(e, allowed) {
|
|
2214
2241
|
const dy = e.offsetY;
|
|
2215
2242
|
if (!allowed) {
|
|
@@ -2307,17 +2334,19 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2307
2334
|
e.preventDefault();
|
|
2308
2335
|
return false;
|
|
2309
2336
|
}
|
|
2310
|
-
|
|
2337
|
+
const nodeData = srcNode.toDict(true, (n) => {
|
|
2311
2338
|
// We don't want to re-use the key on drop:
|
|
2312
2339
|
n._org_key = n.key;
|
|
2313
2340
|
delete n.key;
|
|
2314
2341
|
});
|
|
2315
2342
|
nodeData._treeId = srcNode.tree.id;
|
|
2316
2343
|
if (dndOpts.serializeClipboardData) {
|
|
2317
|
-
if (typeof dndOpts.serializeClipboardData === "function")
|
|
2344
|
+
if (typeof dndOpts.serializeClipboardData === "function") {
|
|
2318
2345
|
e.dataTransfer.setData(nodeMimeType, dndOpts.serializeClipboardData(nodeData));
|
|
2319
|
-
|
|
2346
|
+
}
|
|
2347
|
+
else {
|
|
2320
2348
|
e.dataTransfer.setData(nodeMimeType, JSON.stringify(nodeData));
|
|
2349
|
+
}
|
|
2321
2350
|
}
|
|
2322
2351
|
// e.dataTransfer!.setData("text/html", $(node.span).html());
|
|
2323
2352
|
e.dataTransfer.setData("text/plain", srcNode.title);
|
|
@@ -2330,8 +2359,9 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2330
2359
|
// --- drag ---
|
|
2331
2360
|
}
|
|
2332
2361
|
else if (e.type === "drag") {
|
|
2333
|
-
if (dndOpts.drag)
|
|
2362
|
+
if (dndOpts.drag) {
|
|
2334
2363
|
srcNode._callEvent("dnd.drag", { event: e });
|
|
2364
|
+
}
|
|
2335
2365
|
// --- dragend ---
|
|
2336
2366
|
}
|
|
2337
2367
|
else if (e.type === "dragend") {
|
|
@@ -2340,11 +2370,27 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2340
2370
|
if (this.lastTargetNode) {
|
|
2341
2371
|
this._leaveNode();
|
|
2342
2372
|
}
|
|
2343
|
-
if (dndOpts.dragEnd)
|
|
2373
|
+
if (dndOpts.dragEnd) {
|
|
2344
2374
|
srcNode._callEvent("dnd.dragEnd", { event: e });
|
|
2375
|
+
}
|
|
2345
2376
|
}
|
|
2346
2377
|
return true;
|
|
2347
2378
|
}
|
|
2379
|
+
/* Don't allow void operation ('drop on self').*/
|
|
2380
|
+
_isVoidDrop(targetNode, srcNode, dropRegion) {
|
|
2381
|
+
this.tree.logDebug(`_isVoidDrop: ${srcNode} -> ${dropRegion} ${targetNode}`);
|
|
2382
|
+
// TODO: should be checked on move only
|
|
2383
|
+
if (!this.treeOpts.dnd.preventVoidMoves || !srcNode) {
|
|
2384
|
+
return false;
|
|
2385
|
+
}
|
|
2386
|
+
if ((dropRegion === "before" && targetNode === srcNode.getNextSibling()) ||
|
|
2387
|
+
(dropRegion === "after" && targetNode === srcNode.getPrevSibling())) {
|
|
2388
|
+
this.tree.logDebug("Prevented before/after self");
|
|
2389
|
+
return true;
|
|
2390
|
+
}
|
|
2391
|
+
// Don't allow dropping nodes on own parent (or self)
|
|
2392
|
+
return srcNode === targetNode || srcNode.parent === targetNode;
|
|
2393
|
+
}
|
|
2348
2394
|
onDropEvent(e) {
|
|
2349
2395
|
// const isLink = event.dataTransfer.types.includes("text/uri-list");
|
|
2350
2396
|
const srcNode = this.srcNode;
|
|
@@ -2352,6 +2398,7 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2352
2398
|
const targetNode = Wunderbaum.getNode(e);
|
|
2353
2399
|
const dndOpts = this.treeOpts.dnd;
|
|
2354
2400
|
const dt = e.dataTransfer;
|
|
2401
|
+
const dropRegion = this._calcDropRegion(e, this.lastAllowedDropRegions);
|
|
2355
2402
|
if (!targetNode) {
|
|
2356
2403
|
this._leaveNode();
|
|
2357
2404
|
return;
|
|
@@ -2364,7 +2411,7 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2364
2411
|
", ea: " +
|
|
2365
2412
|
(dt === null || dt === void 0 ? void 0 : dt.effectAllowed) +
|
|
2366
2413
|
", de: " +
|
|
2367
|
-
(dt === null || dt === void 0 ? void 0 : dt.dropEffect), ", cy: " + e.offsetY, ", r: " +
|
|
2414
|
+
(dt === null || dt === void 0 ? void 0 : dt.dropEffect), ", cy: " + e.offsetY, ", r: " + dropRegion, ", srcNode: " + srcNode, e);
|
|
2368
2415
|
}
|
|
2369
2416
|
// --- dragenter ---
|
|
2370
2417
|
if (e.type === "dragenter") {
|
|
@@ -2386,16 +2433,15 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2386
2433
|
// Prevent dropping items other than Wunderbaum tree nodes:
|
|
2387
2434
|
(dndOpts.preventNonNodes && !srcNode) ||
|
|
2388
2435
|
// Prevent dropping nodes on own descendants:
|
|
2389
|
-
(dndOpts.preventRecursion &&
|
|
2390
|
-
srcNode &&
|
|
2391
|
-
srcNode.isAncestorOf(targetNode)) ||
|
|
2436
|
+
(dndOpts.preventRecursion && (srcNode === null || srcNode === void 0 ? void 0 : srcNode.isAncestorOf(targetNode))) ||
|
|
2392
2437
|
// Prevent dropping nodes under same direct parent:
|
|
2393
2438
|
(dndOpts.preventSameParent &&
|
|
2394
2439
|
srcNode &&
|
|
2395
2440
|
targetNode.parent === srcNode.parent) ||
|
|
2396
|
-
// Don't allow void operation ('drop on self'): TODO: should be
|
|
2441
|
+
// Don't allow void operation ('drop on self'): TODO: should be checked on move only
|
|
2397
2442
|
(dndOpts.preventVoidMoves && targetNode === srcNode)) {
|
|
2398
2443
|
dt.dropEffect = "none";
|
|
2444
|
+
this.tree.log("Prevented drop operation");
|
|
2399
2445
|
return true; // Prevent drop operation
|
|
2400
2446
|
}
|
|
2401
2447
|
// User may return a set of regions (or `false` to prevent drop)
|
|
@@ -2416,8 +2462,9 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2416
2462
|
else if (e.type === "dragover") {
|
|
2417
2463
|
const viewportY = e.clientY - this.tree.element.offsetTop;
|
|
2418
2464
|
this.autoScroll(viewportY);
|
|
2419
|
-
if (dndOpts.dragOver)
|
|
2465
|
+
if (dndOpts.dragOver) {
|
|
2420
2466
|
targetNode._callEvent("dnd.dragOver", { event: e });
|
|
2467
|
+
}
|
|
2421
2468
|
const region = this._calcDropRegion(e, this.lastAllowedDropRegions);
|
|
2422
2469
|
this.lastDropRegion = region;
|
|
2423
2470
|
if (dndOpts.autoExpandMS > 0 &&
|
|
@@ -2427,7 +2474,7 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2427
2474
|
targetNode._callEvent("dnd.dragExpand", { event: e }) !== false) {
|
|
2428
2475
|
targetNode.setExpanded();
|
|
2429
2476
|
}
|
|
2430
|
-
if (!region) {
|
|
2477
|
+
if (!region || this._isVoidDrop(targetNode, srcNode, region)) {
|
|
2431
2478
|
return; // We already rejected in dragenter
|
|
2432
2479
|
}
|
|
2433
2480
|
targetNode.setClass("wb-drop-over", region === "over");
|
|
@@ -2442,8 +2489,9 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2442
2489
|
else if (e.type === "dragleave") {
|
|
2443
2490
|
// NOTE: we cannot trust this event, since it is always fired,
|
|
2444
2491
|
// Instead we remove the marker on dragenter
|
|
2445
|
-
if (dndOpts.dragLeave)
|
|
2492
|
+
if (dndOpts.dragLeave) {
|
|
2446
2493
|
targetNode._callEvent("dnd.dragLeave", { event: e });
|
|
2494
|
+
}
|
|
2447
2495
|
// --- drop ---
|
|
2448
2496
|
}
|
|
2449
2497
|
else if (e.type === "drop") {
|
|
@@ -2463,7 +2511,7 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2463
2511
|
/*!
|
|
2464
2512
|
* Wunderbaum - drag_observer
|
|
2465
2513
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
2466
|
-
* v0.5.
|
|
2514
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
2467
2515
|
*/
|
|
2468
2516
|
/**
|
|
2469
2517
|
* Convert mouse- and touch events to 'dragstart', 'drag', and 'dragstop'.
|
|
@@ -2599,7 +2647,7 @@ class DragObserver {
|
|
|
2599
2647
|
/*!
|
|
2600
2648
|
* Wunderbaum - ext-grid
|
|
2601
2649
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
2602
|
-
* v0.5.
|
|
2650
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
2603
2651
|
*/
|
|
2604
2652
|
class GridExtension extends WunderbaumExtension {
|
|
2605
2653
|
constructor(tree) {
|
|
@@ -2636,7 +2684,7 @@ class GridExtension extends WunderbaumExtension {
|
|
|
2636
2684
|
/*!
|
|
2637
2685
|
* Wunderbaum - deferred
|
|
2638
2686
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
2639
|
-
* v0.5.
|
|
2687
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
2640
2688
|
*/
|
|
2641
2689
|
/**
|
|
2642
2690
|
* Implement a ES6 Promise, that exposes a resolve() and reject() method.
|
|
@@ -2689,7 +2737,7 @@ class Deferred {
|
|
|
2689
2737
|
/*!
|
|
2690
2738
|
* Wunderbaum - wunderbaum_node
|
|
2691
2739
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
2692
|
-
* v0.5.
|
|
2740
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
2693
2741
|
*/
|
|
2694
2742
|
/** WunderbaumNode properties that can be passed with source data.
|
|
2695
2743
|
* (Any other source properties will be stored as `node.data.PROP`.)
|
|
@@ -2863,7 +2911,7 @@ class WunderbaumNode {
|
|
|
2863
2911
|
nodeData = [nodeData];
|
|
2864
2912
|
}
|
|
2865
2913
|
const forceExpand = applyMinExpanLevel && _level < tree.options.minExpandLevel;
|
|
2866
|
-
for (
|
|
2914
|
+
for (const child of nodeData) {
|
|
2867
2915
|
const subChildren = child.children;
|
|
2868
2916
|
delete child.children;
|
|
2869
2917
|
const n = new WunderbaumNode(tree, this, child);
|
|
@@ -2884,7 +2932,7 @@ class WunderbaumNode {
|
|
|
2884
2932
|
else {
|
|
2885
2933
|
// Returns null if before is not a direct child:
|
|
2886
2934
|
before = this.findDirectChild(before);
|
|
2887
|
-
|
|
2935
|
+
const pos = this.children.indexOf(before);
|
|
2888
2936
|
assert(pos >= 0, `options.before must be a direct child of ${this}`);
|
|
2889
2937
|
// insert nodeList after children[pos]
|
|
2890
2938
|
this.children.splice(pos, 0, ...nodeList);
|
|
@@ -2950,7 +2998,7 @@ class WunderbaumNode {
|
|
|
2950
2998
|
* (Automatically called when `autoCollapse` is true.)
|
|
2951
2999
|
*/
|
|
2952
3000
|
collapseSiblings(options) {
|
|
2953
|
-
for (
|
|
3001
|
+
for (const node of this.parent.children) {
|
|
2954
3002
|
if (node !== this && node.expanded) {
|
|
2955
3003
|
node.setExpanded(false, options);
|
|
2956
3004
|
}
|
|
@@ -2994,7 +3042,7 @@ class WunderbaumNode {
|
|
|
2994
3042
|
async expandAll(flag = true, options) {
|
|
2995
3043
|
const tree = this.tree;
|
|
2996
3044
|
const minExpandLevel = this.tree.options.minExpandLevel;
|
|
2997
|
-
|
|
3045
|
+
const { depth = 99, loadLazy, force, keepActiveNodeVisible = true, } = options !== null && options !== void 0 ? options : {};
|
|
2998
3046
|
const expandOpts = {
|
|
2999
3047
|
scrollIntoView: false,
|
|
3000
3048
|
force: force,
|
|
@@ -3095,9 +3143,10 @@ class WunderbaumNode {
|
|
|
3095
3143
|
}
|
|
3096
3144
|
/** Return the direct child with a given key, index or null. */
|
|
3097
3145
|
findDirectChild(ptr) {
|
|
3098
|
-
|
|
3099
|
-
if (!cl)
|
|
3146
|
+
const cl = this.children;
|
|
3147
|
+
if (!cl) {
|
|
3100
3148
|
return null;
|
|
3149
|
+
}
|
|
3101
3150
|
if (typeof ptr === "string") {
|
|
3102
3151
|
for (let i = 0, l = cl.length; i < l; i++) {
|
|
3103
3152
|
if (cl[i].key === ptr) {
|
|
@@ -3160,7 +3209,7 @@ class WunderbaumNode {
|
|
|
3160
3209
|
return parts.join("");
|
|
3161
3210
|
};
|
|
3162
3211
|
yield name_cb(this);
|
|
3163
|
-
for (
|
|
3212
|
+
for (const node of this) {
|
|
3164
3213
|
yield _format_line(node);
|
|
3165
3214
|
}
|
|
3166
3215
|
}
|
|
@@ -3182,7 +3231,7 @@ class WunderbaumNode {
|
|
|
3182
3231
|
*/
|
|
3183
3232
|
format(name_cb, connectors) {
|
|
3184
3233
|
const a = [];
|
|
3185
|
-
for (
|
|
3234
|
+
for (const line of this.format_iter(name_cb, connectors)) {
|
|
3186
3235
|
a.push(line);
|
|
3187
3236
|
}
|
|
3188
3237
|
return a.join("\n");
|
|
@@ -3221,8 +3270,8 @@ class WunderbaumNode {
|
|
|
3221
3270
|
}
|
|
3222
3271
|
/** Return the successive node (under the same parent) or null. */
|
|
3223
3272
|
getNextSibling() {
|
|
3224
|
-
|
|
3225
|
-
|
|
3273
|
+
const ac = this.parent.children;
|
|
3274
|
+
const idx = ac.indexOf(this);
|
|
3226
3275
|
return ac[idx + 1] || null;
|
|
3227
3276
|
}
|
|
3228
3277
|
/** Return the parent node (null for the system root node). */
|
|
@@ -3235,7 +3284,8 @@ class WunderbaumNode {
|
|
|
3235
3284
|
* @param includeSelf Include the node itself.
|
|
3236
3285
|
*/
|
|
3237
3286
|
getParentList(includeRoot = false, includeSelf = false) {
|
|
3238
|
-
|
|
3287
|
+
const l = [];
|
|
3288
|
+
let dtn = includeSelf ? this : this.parent;
|
|
3239
3289
|
while (dtn) {
|
|
3240
3290
|
if (includeRoot || dtn.parent) {
|
|
3241
3291
|
l.unshift(dtn);
|
|
@@ -3253,7 +3303,9 @@ class WunderbaumNode {
|
|
|
3253
3303
|
// includeSelf = includeSelf !== false;
|
|
3254
3304
|
// part = part || "title";
|
|
3255
3305
|
// separator = separator || "/";
|
|
3256
|
-
let val
|
|
3306
|
+
let val;
|
|
3307
|
+
const path = [];
|
|
3308
|
+
const isFunc = typeof part === "function";
|
|
3257
3309
|
this.visitParents((n) => {
|
|
3258
3310
|
if (n.parent) {
|
|
3259
3311
|
val = isFunc
|
|
@@ -3267,8 +3319,8 @@ class WunderbaumNode {
|
|
|
3267
3319
|
}
|
|
3268
3320
|
/** Return the preceeding node (under the same parent) or null. */
|
|
3269
3321
|
getPrevSibling() {
|
|
3270
|
-
|
|
3271
|
-
|
|
3322
|
+
const ac = this.parent.children;
|
|
3323
|
+
const idx = ac.indexOf(this);
|
|
3272
3324
|
return ac[idx - 1] || null;
|
|
3273
3325
|
}
|
|
3274
3326
|
/** Return true if node has children.
|
|
@@ -3323,7 +3375,7 @@ class WunderbaumNode {
|
|
|
3323
3375
|
if (!other || other.tree !== this.tree) {
|
|
3324
3376
|
return false;
|
|
3325
3377
|
}
|
|
3326
|
-
|
|
3378
|
+
let p = this.parent;
|
|
3327
3379
|
while (p) {
|
|
3328
3380
|
if (p === other) {
|
|
3329
3381
|
return true;
|
|
@@ -3362,12 +3414,12 @@ class WunderbaumNode {
|
|
|
3362
3414
|
}
|
|
3363
3415
|
/** Return true if this node is the first node of its parent's children. */
|
|
3364
3416
|
isFirstSibling() {
|
|
3365
|
-
|
|
3417
|
+
const p = this.parent;
|
|
3366
3418
|
return !p || p.children[0] === this;
|
|
3367
3419
|
}
|
|
3368
3420
|
/** Return true if this node is the last node of its parent's children. */
|
|
3369
3421
|
isLastSibling() {
|
|
3370
|
-
|
|
3422
|
+
const p = this.parent;
|
|
3371
3423
|
return !p || p.children[p.children.length - 1] === this;
|
|
3372
3424
|
}
|
|
3373
3425
|
/** Return true if this node is lazy (even if data was already loaded) */
|
|
@@ -3441,7 +3493,8 @@ class WunderbaumNode {
|
|
|
3441
3493
|
* whether the node is scrolled into the visible part of the screen or viewport.
|
|
3442
3494
|
*/
|
|
3443
3495
|
isVisible() {
|
|
3444
|
-
|
|
3496
|
+
const hasFilter = this.tree.filterMode === "hide";
|
|
3497
|
+
const parents = this.getParentList(false, false);
|
|
3445
3498
|
// TODO: check $(n.span).is(":visible")
|
|
3446
3499
|
// i.e. return false for nodes (but not parents) that are hidden
|
|
3447
3500
|
// by a filter
|
|
@@ -3449,8 +3502,8 @@ class WunderbaumNode {
|
|
|
3449
3502
|
// this.debug( "isVisible: HIDDEN (" + hasFilter + ", " + this.match + ", " + this.match + ")" );
|
|
3450
3503
|
return false;
|
|
3451
3504
|
}
|
|
3452
|
-
for (i = 0, l = parents.length; i < l; i++) {
|
|
3453
|
-
n = parents[i];
|
|
3505
|
+
for (let i = 0, l = parents.length; i < l; i++) {
|
|
3506
|
+
const n = parents[i];
|
|
3454
3507
|
if (!n.expanded) {
|
|
3455
3508
|
// this.debug("isVisible: HIDDEN (parent collapsed)");
|
|
3456
3509
|
return false;
|
|
@@ -3560,7 +3613,7 @@ class WunderbaumNode {
|
|
|
3560
3613
|
this._requestId = requestId;
|
|
3561
3614
|
// const timerLabel = tree.logTime(this + ".load()");
|
|
3562
3615
|
try {
|
|
3563
|
-
|
|
3616
|
+
const url = typeof source === "string" ? source : source.url;
|
|
3564
3617
|
if (!url) {
|
|
3565
3618
|
// An array or a plain object (that does NOT contain a `.url` property)
|
|
3566
3619
|
// will be treated as native Wunderbaum data
|
|
@@ -3648,34 +3701,30 @@ class WunderbaumNode {
|
|
|
3648
3701
|
}
|
|
3649
3702
|
/** Alias for `logDebug` */
|
|
3650
3703
|
log(...args) {
|
|
3651
|
-
this.logDebug
|
|
3704
|
+
this.logDebug(...args);
|
|
3652
3705
|
}
|
|
3653
3706
|
/* Log to console if opts.debugLevel >= 4 */
|
|
3654
3707
|
logDebug(...args) {
|
|
3655
3708
|
if (this.tree.options.debugLevel >= 4) {
|
|
3656
|
-
|
|
3657
|
-
console.log.apply(console, args);
|
|
3709
|
+
console.log(this.toString(), ...args); // eslint-disable-line no-console
|
|
3658
3710
|
}
|
|
3659
3711
|
}
|
|
3660
3712
|
/* Log error to console. */
|
|
3661
3713
|
logError(...args) {
|
|
3662
3714
|
if (this.tree.options.debugLevel >= 1) {
|
|
3663
|
-
|
|
3664
|
-
console.error.apply(console, args);
|
|
3715
|
+
console.error(this.toString(), ...args); // eslint-disable-line no-console
|
|
3665
3716
|
}
|
|
3666
3717
|
}
|
|
3667
3718
|
/* Log to console if opts.debugLevel >= 3 */
|
|
3668
3719
|
logInfo(...args) {
|
|
3669
3720
|
if (this.tree.options.debugLevel >= 3) {
|
|
3670
|
-
|
|
3671
|
-
console.info.apply(console, args);
|
|
3721
|
+
console.info(this.toString(), ...args); // eslint-disable-line no-console
|
|
3672
3722
|
}
|
|
3673
3723
|
}
|
|
3674
3724
|
/* Log warning to console if opts.debugLevel >= 2 */
|
|
3675
3725
|
logWarn(...args) {
|
|
3676
3726
|
if (this.tree.options.debugLevel >= 2) {
|
|
3677
|
-
|
|
3678
|
-
console.warn.apply(console, args);
|
|
3727
|
+
console.warn(this.toString(), ...args); // eslint-disable-line no-console
|
|
3679
3728
|
}
|
|
3680
3729
|
}
|
|
3681
3730
|
/** Expand all parents and optionally scroll into visible area as neccessary.
|
|
@@ -3684,7 +3733,13 @@ class WunderbaumNode {
|
|
|
3684
3733
|
* Defaults to {noAnimation: false, noEvents: false, scrollIntoView: true}
|
|
3685
3734
|
*/
|
|
3686
3735
|
async makeVisible(options) {
|
|
3687
|
-
let i
|
|
3736
|
+
let i;
|
|
3737
|
+
const dfd = new Deferred();
|
|
3738
|
+
const deferreds = [];
|
|
3739
|
+
const parents = this.getParentList(false, false);
|
|
3740
|
+
const len = parents.length;
|
|
3741
|
+
const noAnimation = getOption(options, "noAnimation", false);
|
|
3742
|
+
const scroll = getOption(options, "scrollIntoView", true);
|
|
3688
3743
|
// Expand bottom-up, so only the top node is animated
|
|
3689
3744
|
for (i = len - 1; i >= 0; i--) {
|
|
3690
3745
|
// self.debug("pushexpand" + parents[i]);
|
|
@@ -3723,7 +3778,10 @@ class WunderbaumNode {
|
|
|
3723
3778
|
mode = "appendChild";
|
|
3724
3779
|
}
|
|
3725
3780
|
}
|
|
3726
|
-
let pos
|
|
3781
|
+
let pos;
|
|
3782
|
+
const tree = this.tree;
|
|
3783
|
+
const prevParent = this.parent;
|
|
3784
|
+
const targetParent = mode === "appendChild" ? targetNode : targetNode.parent;
|
|
3727
3785
|
if (this === targetNode) {
|
|
3728
3786
|
return;
|
|
3729
3787
|
}
|
|
@@ -3831,7 +3889,9 @@ class WunderbaumNode {
|
|
|
3831
3889
|
try {
|
|
3832
3890
|
node.makeVisible({ scrollIntoView: false });
|
|
3833
3891
|
}
|
|
3834
|
-
catch (e) {
|
|
3892
|
+
catch (e) {
|
|
3893
|
+
// ignore
|
|
3894
|
+
}
|
|
3835
3895
|
node.setFocus();
|
|
3836
3896
|
if ((options === null || options === void 0 ? void 0 : options.activate) === false) {
|
|
3837
3897
|
return Promise.resolve(this);
|
|
@@ -3898,7 +3958,7 @@ class WunderbaumNode {
|
|
|
3898
3958
|
? (this._rowElem.querySelectorAll("span.wb-col"))
|
|
3899
3959
|
: null;
|
|
3900
3960
|
let idx = 0;
|
|
3901
|
-
for (
|
|
3961
|
+
for (const col of this.tree.columns) {
|
|
3902
3962
|
allColInfosById[col.id] = {
|
|
3903
3963
|
id: col.id,
|
|
3904
3964
|
idx: idx,
|
|
@@ -3971,7 +4031,7 @@ class WunderbaumNode {
|
|
|
3971
4031
|
parentElem.appendChild(iconSpan);
|
|
3972
4032
|
}
|
|
3973
4033
|
// Event handler `tree.iconBadge` can return a badge text or HTMLSpanElement
|
|
3974
|
-
|
|
4034
|
+
const cbRes = this._callEvent("iconBadge", { iconSpan: iconSpan });
|
|
3975
4035
|
let badge = null;
|
|
3976
4036
|
if (cbRes != null && cbRes !== false) {
|
|
3977
4037
|
let classes = "";
|
|
@@ -4007,14 +4067,11 @@ class WunderbaumNode {
|
|
|
4007
4067
|
const checkbox = this.getOption("checkbox");
|
|
4008
4068
|
const columns = tree.columns;
|
|
4009
4069
|
const level = this.getLevel();
|
|
4070
|
+
const activeColIdx = tree.isRowNav() ? null : tree.activeColIdx;
|
|
4010
4071
|
let elem;
|
|
4011
|
-
let nodeElem;
|
|
4012
4072
|
let rowDiv = this._rowElem;
|
|
4013
|
-
let titleSpan;
|
|
4014
4073
|
let checkboxSpan = null;
|
|
4015
|
-
let iconSpan;
|
|
4016
4074
|
let expanderSpan = null;
|
|
4017
|
-
const activeColIdx = tree.isRowNav() ? null : tree.activeColIdx;
|
|
4018
4075
|
const isNew = !rowDiv;
|
|
4019
4076
|
assert(isNew);
|
|
4020
4077
|
assert(!isNew || (opts && opts.after), "opts.after expected, unless updating");
|
|
@@ -4025,7 +4082,7 @@ class WunderbaumNode {
|
|
|
4025
4082
|
this._rowElem = rowDiv;
|
|
4026
4083
|
// Attach a node reference to the DOM Element:
|
|
4027
4084
|
rowDiv._wb_node = this;
|
|
4028
|
-
nodeElem = document.createElement("span");
|
|
4085
|
+
const nodeElem = document.createElement("span");
|
|
4029
4086
|
nodeElem.classList.add("wb-node", "wb-col");
|
|
4030
4087
|
rowDiv.appendChild(nodeElem);
|
|
4031
4088
|
let ofsTitlePx = 0;
|
|
@@ -4052,11 +4109,11 @@ class WunderbaumNode {
|
|
|
4052
4109
|
}
|
|
4053
4110
|
// Render the icon (show a 'loading' icon if we do not have an expander that
|
|
4054
4111
|
// we would prefer).
|
|
4055
|
-
iconSpan = this._createIcon(tree.iconMap, nodeElem, null, !expanderSpan);
|
|
4112
|
+
const iconSpan = this._createIcon(tree.iconMap, nodeElem, null, !expanderSpan);
|
|
4056
4113
|
if (iconSpan) {
|
|
4057
4114
|
ofsTitlePx += ICON_WIDTH;
|
|
4058
4115
|
}
|
|
4059
|
-
titleSpan = document.createElement("span");
|
|
4116
|
+
const titleSpan = document.createElement("span");
|
|
4060
4117
|
titleSpan.classList.add("wb-title");
|
|
4061
4118
|
nodeElem.appendChild(titleSpan);
|
|
4062
4119
|
// this._callEvent("enhanceTitle", { titleSpan: titleSpan });
|
|
@@ -4071,7 +4128,7 @@ class WunderbaumNode {
|
|
|
4071
4128
|
const isColspan = this.isColspan();
|
|
4072
4129
|
if (!isColspan && columns.length > 1) {
|
|
4073
4130
|
let colIdx = 0;
|
|
4074
|
-
for (
|
|
4131
|
+
for (const col of columns) {
|
|
4075
4132
|
colIdx++;
|
|
4076
4133
|
let colElem;
|
|
4077
4134
|
if (col.id === "*") {
|
|
@@ -4144,7 +4201,7 @@ class WunderbaumNode {
|
|
|
4144
4201
|
// Set the width of the title span, so overflow ellipsis work
|
|
4145
4202
|
if (!treeOptions.skeleton) {
|
|
4146
4203
|
if (isColspan) {
|
|
4147
|
-
|
|
4204
|
+
const vpWidth = tree.element.clientWidth;
|
|
4148
4205
|
titleSpan.style.width =
|
|
4149
4206
|
vpWidth - nodeElem._ofsTitlePx - TITLE_SPAN_PAD_Y + "px";
|
|
4150
4207
|
}
|
|
@@ -4194,7 +4251,7 @@ class WunderbaumNode {
|
|
|
4194
4251
|
const nodeElem = rowDiv.querySelector("span.wb-node");
|
|
4195
4252
|
const expanderSpan = nodeElem.querySelector("i.wb-expander");
|
|
4196
4253
|
const checkboxSpan = nodeElem.querySelector("i.wb-checkbox");
|
|
4197
|
-
|
|
4254
|
+
const rowClasses = ["wb-row"];
|
|
4198
4255
|
this.expanded ? rowClasses.push("wb-expanded") : 0;
|
|
4199
4256
|
this.lazy ? rowClasses.push("wb-lazy") : 0;
|
|
4200
4257
|
this.selected ? rowClasses.push("wb-selected") : 0;
|
|
@@ -4234,12 +4291,15 @@ class WunderbaumNode {
|
|
|
4234
4291
|
else if (this.lazy && this.children == null) {
|
|
4235
4292
|
image = iconMap.expanderLazy;
|
|
4236
4293
|
}
|
|
4237
|
-
if (image == null)
|
|
4294
|
+
if (image == null) {
|
|
4238
4295
|
expanderSpan.classList.add("wb-indent");
|
|
4239
|
-
|
|
4296
|
+
}
|
|
4297
|
+
else if (TEST_IMG.test(image)) {
|
|
4240
4298
|
expanderSpan.style.backgroundImage = `url('${image}')`;
|
|
4241
|
-
|
|
4299
|
+
}
|
|
4300
|
+
else {
|
|
4242
4301
|
expanderSpan.className = "wb-expander " + image;
|
|
4302
|
+
}
|
|
4243
4303
|
}
|
|
4244
4304
|
if (checkboxSpan) {
|
|
4245
4305
|
let cbclass = "wb-checkbox ";
|
|
@@ -4270,7 +4330,7 @@ class WunderbaumNode {
|
|
|
4270
4330
|
// Fix active cell in cell-nav mode
|
|
4271
4331
|
if (!opts.isNew) {
|
|
4272
4332
|
let i = 0;
|
|
4273
|
-
for (
|
|
4333
|
+
for (const colSpan of rowDiv.children) {
|
|
4274
4334
|
colSpan.classList.toggle("wb-active", i++ === tree.activeColIdx);
|
|
4275
4335
|
}
|
|
4276
4336
|
// Update icon (if not opts.isNew, which would rebuild markup anyway)
|
|
@@ -4284,7 +4344,7 @@ class WunderbaumNode {
|
|
|
4284
4344
|
const colElems = rowDiv.querySelectorAll("span.wb-col");
|
|
4285
4345
|
let idx = 0;
|
|
4286
4346
|
let ofs = 0;
|
|
4287
|
-
for (
|
|
4347
|
+
for (const colDef of this.tree.columns) {
|
|
4288
4348
|
const colElem = colElems[idx];
|
|
4289
4349
|
colElem.style.left = `${ofs}px`;
|
|
4290
4350
|
colElem.style.width = `${colDef._widthPx}px`;
|
|
@@ -4413,16 +4473,16 @@ class WunderbaumNode {
|
|
|
4413
4473
|
* {@link Wunderbaum.getOption|Wunderbaum.getOption()}
|
|
4414
4474
|
*/
|
|
4415
4475
|
getOption(name, defaultValue) {
|
|
4416
|
-
|
|
4476
|
+
const tree = this.tree;
|
|
4417
4477
|
let opts = tree.options;
|
|
4418
4478
|
// Lookup `name` in options dict
|
|
4419
4479
|
if (name.indexOf(".") >= 0) {
|
|
4420
4480
|
[opts, name] = name.split(".");
|
|
4421
4481
|
}
|
|
4422
|
-
|
|
4482
|
+
const value = opts[name]; // ?? defaultValue;
|
|
4423
4483
|
// A callback resolver always takes precedence
|
|
4424
4484
|
if (typeof value === "function") {
|
|
4425
|
-
|
|
4485
|
+
const res = value.call(tree, {
|
|
4426
4486
|
type: "resolve",
|
|
4427
4487
|
tree: tree,
|
|
4428
4488
|
node: this,
|
|
@@ -4437,8 +4497,8 @@ class WunderbaumNode {
|
|
|
4437
4497
|
return this[name];
|
|
4438
4498
|
}
|
|
4439
4499
|
// Use value from type definition if defined
|
|
4440
|
-
|
|
4441
|
-
|
|
4500
|
+
const typeInfo = this.type ? tree.types[this.type] : undefined;
|
|
4501
|
+
const res = typeInfo ? typeInfo[name] : undefined;
|
|
4442
4502
|
if (res !== undefined) {
|
|
4443
4503
|
return res;
|
|
4444
4504
|
}
|
|
@@ -4487,10 +4547,12 @@ class WunderbaumNode {
|
|
|
4487
4547
|
if (prev !== this) {
|
|
4488
4548
|
if (flag) {
|
|
4489
4549
|
tree.activeNode = this;
|
|
4490
|
-
if (focusNode || focusTree)
|
|
4550
|
+
if (focusNode || focusTree) {
|
|
4491
4551
|
tree.focusNode = this;
|
|
4492
|
-
|
|
4552
|
+
}
|
|
4553
|
+
if (focusTree) {
|
|
4493
4554
|
tree.setFocus();
|
|
4555
|
+
}
|
|
4494
4556
|
}
|
|
4495
4557
|
prev === null || prev === void 0 ? void 0 : prev.update(ChangeType.status);
|
|
4496
4558
|
this.update(ChangeType.status);
|
|
@@ -4560,13 +4622,6 @@ class WunderbaumNode {
|
|
|
4560
4622
|
setKey(key, refKey) {
|
|
4561
4623
|
throw new Error("Not yet implemented");
|
|
4562
4624
|
}
|
|
4563
|
-
/**
|
|
4564
|
-
* @deprecated since v0.3.6: use `update()` instead.
|
|
4565
|
-
*/
|
|
4566
|
-
setModified(change = ChangeType.data) {
|
|
4567
|
-
this.logWarn("setModified() is deprecated: use update() instead.");
|
|
4568
|
-
return this.update(change);
|
|
4569
|
-
}
|
|
4570
4625
|
/**
|
|
4571
4626
|
* Trigger a repaint, typically after a status or data change.
|
|
4572
4627
|
*
|
|
@@ -4587,7 +4642,7 @@ class WunderbaumNode {
|
|
|
4587
4642
|
* @param stopOnParents only return the topmost selected node (useful with selectMode 'hier')
|
|
4588
4643
|
*/
|
|
4589
4644
|
getSelectedNodes(stopOnParents = false) {
|
|
4590
|
-
|
|
4645
|
+
const nodeList = [];
|
|
4591
4646
|
this.visit((node) => {
|
|
4592
4647
|
if (node.selected) {
|
|
4593
4648
|
nodeList.push(node);
|
|
@@ -4656,7 +4711,7 @@ class WunderbaumNode {
|
|
|
4656
4711
|
*/
|
|
4657
4712
|
fixSelection3AfterClick(opts) {
|
|
4658
4713
|
const force = !!(opts === null || opts === void 0 ? void 0 : opts.force);
|
|
4659
|
-
|
|
4714
|
+
const flag = this.isSelected();
|
|
4660
4715
|
this.visit((node) => {
|
|
4661
4716
|
if (node.radiogroup) {
|
|
4662
4717
|
return "skip"; // Don't (de)select this branch
|
|
@@ -4767,7 +4822,7 @@ class WunderbaumNode {
|
|
|
4767
4822
|
if (!flag && !(options === null || options === void 0 ? void 0 : options.force)) {
|
|
4768
4823
|
return prev; // don't uncheck radio buttons
|
|
4769
4824
|
}
|
|
4770
|
-
for (
|
|
4825
|
+
for (const sibling of this.parent.children) {
|
|
4771
4826
|
sibling.selected = sibling === this;
|
|
4772
4827
|
}
|
|
4773
4828
|
}
|
|
@@ -4796,7 +4851,7 @@ class WunderbaumNode {
|
|
|
4796
4851
|
let statusNode = null;
|
|
4797
4852
|
const _clearStatusNode = () => {
|
|
4798
4853
|
// Remove dedicated dummy node, if any
|
|
4799
|
-
|
|
4854
|
+
const children = this.children;
|
|
4800
4855
|
if (children && children.length && children[0].isStatusNode()) {
|
|
4801
4856
|
children[0].remove();
|
|
4802
4857
|
}
|
|
@@ -4805,8 +4860,8 @@ class WunderbaumNode {
|
|
|
4805
4860
|
// Create/modify the dedicated dummy node for 'loading...' or
|
|
4806
4861
|
// 'error!' status. (only called for direct child of the invisible
|
|
4807
4862
|
// system root)
|
|
4808
|
-
|
|
4809
|
-
|
|
4863
|
+
const children = this.children;
|
|
4864
|
+
const firstChild = children ? children[0] : null;
|
|
4810
4865
|
assert(data.statusNodeType);
|
|
4811
4866
|
assert(!firstChild || !firstChild.isStatusNode());
|
|
4812
4867
|
statusNode = this.addNode(data, "prependChild");
|
|
@@ -4906,8 +4961,9 @@ class WunderbaumNode {
|
|
|
4906
4961
|
*/
|
|
4907
4962
|
triggerModifyChild(operation, child, extra) {
|
|
4908
4963
|
this.logDebug(`modifyChild(${operation})`, extra, child);
|
|
4909
|
-
if (!this.tree.options.modifyChild)
|
|
4964
|
+
if (!this.tree.options.modifyChild) {
|
|
4910
4965
|
return;
|
|
4966
|
+
}
|
|
4911
4967
|
if (child && child.parent !== this) {
|
|
4912
4968
|
error("child " + child + " is not a child of " + this);
|
|
4913
4969
|
}
|
|
@@ -4937,7 +4993,8 @@ class WunderbaumNode {
|
|
|
4937
4993
|
* @see {@link IterableIterator<WunderbaumNode>}, {@link Wunderbaum.visit}.
|
|
4938
4994
|
*/
|
|
4939
4995
|
visit(callback, includeSelf = false) {
|
|
4940
|
-
let
|
|
4996
|
+
let res = true;
|
|
4997
|
+
const children = this.children;
|
|
4941
4998
|
if (includeSelf === true) {
|
|
4942
4999
|
res = callback(this);
|
|
4943
5000
|
if (res === false || res === "skip") {
|
|
@@ -4945,7 +5002,7 @@ class WunderbaumNode {
|
|
|
4945
5002
|
}
|
|
4946
5003
|
}
|
|
4947
5004
|
if (children) {
|
|
4948
|
-
for (i = 0, l = children.length; i < l; i++) {
|
|
5005
|
+
for (let i = 0, l = children.length; i < l; i++) {
|
|
4949
5006
|
res = children[i].visit(callback, true);
|
|
4950
5007
|
if (res === false) {
|
|
4951
5008
|
break;
|
|
@@ -4982,9 +5039,9 @@ class WunderbaumNode {
|
|
|
4982
5039
|
* Return false to stop iteration.
|
|
4983
5040
|
*/
|
|
4984
5041
|
visitSiblings(callback, includeSelf = false) {
|
|
4985
|
-
|
|
4986
|
-
for (i = 0, l = ac.length; i < l; i++) {
|
|
4987
|
-
n = ac[i];
|
|
5042
|
+
const ac = this.parent.children;
|
|
5043
|
+
for (let i = 0, l = ac.length; i < l; i++) {
|
|
5044
|
+
const n = ac[i];
|
|
4988
5045
|
if (includeSelf || n !== this) {
|
|
4989
5046
|
if (callback(n) === false) {
|
|
4990
5047
|
return false;
|
|
@@ -5005,7 +5062,7 @@ WunderbaumNode.sequence = 0;
|
|
|
5005
5062
|
/*!
|
|
5006
5063
|
* Wunderbaum - ext-edit
|
|
5007
5064
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
5008
|
-
* v0.5.
|
|
5065
|
+
* v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
|
|
5009
5066
|
*/
|
|
5010
5067
|
// const START_MARKER = "\uFFF7";
|
|
5011
5068
|
class EditExtension extends WunderbaumExtension {
|
|
@@ -5301,8 +5358,8 @@ class EditExtension extends WunderbaumExtension {
|
|
|
5301
5358
|
* https://github.com/mar10/wunderbaum
|
|
5302
5359
|
*
|
|
5303
5360
|
* Released under the MIT license.
|
|
5304
|
-
* @version v0.5.
|
|
5305
|
-
* @date
|
|
5361
|
+
* @version v0.5.3
|
|
5362
|
+
* @date Sun, 15 Oct 2023 16:42:56 GMT
|
|
5306
5363
|
*/
|
|
5307
5364
|
// import "./wunderbaum.scss";
|
|
5308
5365
|
class WbSystemRoot extends WunderbaumNode {
|
|
@@ -5366,7 +5423,7 @@ class Wunderbaum {
|
|
|
5366
5423
|
* @alias Wunderbaum.logDebug
|
|
5367
5424
|
*/
|
|
5368
5425
|
this.log = this.logDebug;
|
|
5369
|
-
|
|
5426
|
+
const opts = (this.options = extend({
|
|
5370
5427
|
id: null,
|
|
5371
5428
|
source: null,
|
|
5372
5429
|
element: null,
|
|
@@ -5417,7 +5474,7 @@ class Wunderbaum {
|
|
|
5417
5474
|
catch (error) {
|
|
5418
5475
|
// We re-raise in the reject handler, but Chrome resets the stack
|
|
5419
5476
|
// frame then, so we log it here:
|
|
5420
|
-
|
|
5477
|
+
this.logError("Exception inside `init(e)` event:", error);
|
|
5421
5478
|
}
|
|
5422
5479
|
})
|
|
5423
5480
|
.catch((err) => {
|
|
@@ -5668,7 +5725,7 @@ class Wunderbaum {
|
|
|
5668
5725
|
}
|
|
5669
5726
|
else if (typeof el === "string") {
|
|
5670
5727
|
// Search all trees for matching ID
|
|
5671
|
-
for (
|
|
5728
|
+
for (const treeElem of document.querySelectorAll(".wunderbaum")) {
|
|
5672
5729
|
const tree = treeElem._wb_tree;
|
|
5673
5730
|
if (tree && tree.id === el) {
|
|
5674
5731
|
return tree;
|
|
@@ -5747,7 +5804,7 @@ class Wunderbaum {
|
|
|
5747
5804
|
}
|
|
5748
5805
|
/** Called on tree (re)init after markup is created, before loading. */
|
|
5749
5806
|
_initExtensions() {
|
|
5750
|
-
for (
|
|
5807
|
+
for (const ext of this.extensionList) {
|
|
5751
5808
|
ext.init();
|
|
5752
5809
|
}
|
|
5753
5810
|
}
|
|
@@ -5756,9 +5813,9 @@ class Wunderbaum {
|
|
|
5756
5813
|
const key = node.key;
|
|
5757
5814
|
assert(key != null && !this.keyMap.has(key), `Missing or duplicate key: '${key}'.`);
|
|
5758
5815
|
this.keyMap.set(key, node);
|
|
5759
|
-
|
|
5816
|
+
const rk = node.refKey;
|
|
5760
5817
|
if (rk) {
|
|
5761
|
-
|
|
5818
|
+
const rks = this.refKeyMap.get(rk); // Set of nodes with this refKey
|
|
5762
5819
|
if (rks) {
|
|
5763
5820
|
rks.add(node);
|
|
5764
5821
|
}
|
|
@@ -5787,8 +5844,8 @@ class Wunderbaum {
|
|
|
5787
5844
|
/** Call all hook methods of all registered extensions.*/
|
|
5788
5845
|
_callHook(hook, data = {}) {
|
|
5789
5846
|
let res;
|
|
5790
|
-
|
|
5791
|
-
for (
|
|
5847
|
+
const d = extend({}, { tree: this, options: this.options, result: undefined }, data);
|
|
5848
|
+
for (const ext of this.extensionList) {
|
|
5792
5849
|
res = ext[hook].call(ext, d);
|
|
5793
5850
|
if (res === false) {
|
|
5794
5851
|
break;
|
|
@@ -6065,7 +6122,7 @@ class Wunderbaum {
|
|
|
6065
6122
|
this.resizeObserver.disconnect();
|
|
6066
6123
|
this.element.innerHTML = "";
|
|
6067
6124
|
// Remove all event handlers
|
|
6068
|
-
this.element.outerHTML = this.element.outerHTML;
|
|
6125
|
+
this.element.outerHTML = this.element.outerHTML; // eslint-disable-line
|
|
6069
6126
|
}
|
|
6070
6127
|
/**
|
|
6071
6128
|
* Return `tree.option.NAME` (also resolving if this is a callback).
|
|
@@ -6255,8 +6312,9 @@ class Wunderbaum {
|
|
|
6255
6312
|
*/
|
|
6256
6313
|
findNextNode(match, startNode) {
|
|
6257
6314
|
//, visibleOnly) {
|
|
6258
|
-
let res = null
|
|
6259
|
-
|
|
6315
|
+
let res = null;
|
|
6316
|
+
const firstNode = this.getFirstChild();
|
|
6317
|
+
const matcher = typeof match === "string" ? makeNodeTitleStartMatcher(match) : match;
|
|
6260
6318
|
startNode = startNode || firstNode;
|
|
6261
6319
|
function _checkNode(n) {
|
|
6262
6320
|
// console.log("_check " + n)
|
|
@@ -6347,13 +6405,15 @@ class Wunderbaum {
|
|
|
6347
6405
|
res = this._getNextNodeInView(node);
|
|
6348
6406
|
break;
|
|
6349
6407
|
case "pageDown":
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6408
|
+
{
|
|
6409
|
+
const bottomNode = this.getLowestVpNode();
|
|
6410
|
+
// this.logDebug(`${where}(${node}) -> ${bottomNode}`);
|
|
6411
|
+
if (node._rowIdx < bottomNode._rowIdx) {
|
|
6412
|
+
res = bottomNode;
|
|
6413
|
+
}
|
|
6414
|
+
else {
|
|
6415
|
+
res = this._getNextNodeInView(node, pageSize);
|
|
6416
|
+
}
|
|
6357
6417
|
}
|
|
6358
6418
|
break;
|
|
6359
6419
|
case "pageUp":
|
|
@@ -6380,7 +6440,7 @@ class Wunderbaum {
|
|
|
6380
6440
|
* Iterator version of {@link Wunderbaum.format}.
|
|
6381
6441
|
*/
|
|
6382
6442
|
*format_iter(name_cb, connectors) {
|
|
6383
|
-
|
|
6443
|
+
yield* this.root.format_iter(name_cb, connectors);
|
|
6384
6444
|
}
|
|
6385
6445
|
/**
|
|
6386
6446
|
* Return multiline string representation of the node hierarchy.
|
|
@@ -6439,7 +6499,12 @@ class Wunderbaum {
|
|
|
6439
6499
|
* TYPE: 'title' | 'prefix' | 'expander' | 'checkbox' | 'icon' | undefined
|
|
6440
6500
|
*/
|
|
6441
6501
|
static getEventInfo(event) {
|
|
6442
|
-
|
|
6502
|
+
const target = event.target;
|
|
6503
|
+
const cl = target.classList;
|
|
6504
|
+
const parentCol = target.closest("span.wb-col");
|
|
6505
|
+
const node = Wunderbaum.getNode(target);
|
|
6506
|
+
const tree = node ? node.tree : Wunderbaum.getTree(event);
|
|
6507
|
+
const res = {
|
|
6443
6508
|
event: event,
|
|
6444
6509
|
canonicalName: eventToString(event),
|
|
6445
6510
|
tree: tree,
|
|
@@ -6480,7 +6545,7 @@ class Wunderbaum {
|
|
|
6480
6545
|
else {
|
|
6481
6546
|
// Somewhere near the title
|
|
6482
6547
|
if (event.type !== "mousemove" && !(event instanceof KeyboardEvent)) {
|
|
6483
|
-
|
|
6548
|
+
tree === null || tree === void 0 ? void 0 : tree.logWarn("getEventInfo(): not found", event, res);
|
|
6484
6549
|
}
|
|
6485
6550
|
return res;
|
|
6486
6551
|
}
|
|
@@ -6507,7 +6572,7 @@ class Wunderbaum {
|
|
|
6507
6572
|
* Return true if any node is currently beeing loaded, i.e. a Ajax request is pending.
|
|
6508
6573
|
*/
|
|
6509
6574
|
isLoading() {
|
|
6510
|
-
|
|
6575
|
+
let res = false;
|
|
6511
6576
|
this.root.visit((n) => {
|
|
6512
6577
|
// also visit rootNode
|
|
6513
6578
|
if (n._isLoading || n._requestId) {
|
|
@@ -6520,42 +6585,38 @@ class Wunderbaum {
|
|
|
6520
6585
|
/** Log to console if opts.debugLevel >= 4 */
|
|
6521
6586
|
logDebug(...args) {
|
|
6522
6587
|
if (this.options.debugLevel >= 4) {
|
|
6523
|
-
|
|
6524
|
-
console.log.apply(console, args);
|
|
6588
|
+
console.log(this.toString(), ...args); // eslint-disable-line no-console
|
|
6525
6589
|
}
|
|
6526
6590
|
}
|
|
6527
6591
|
/** Log error to console. */
|
|
6528
6592
|
logError(...args) {
|
|
6529
6593
|
if (this.options.debugLevel >= 1) {
|
|
6530
|
-
|
|
6531
|
-
console.error.apply(console, args);
|
|
6594
|
+
console.error(this.toString(), ...args); // eslint-disable-line no-console
|
|
6532
6595
|
}
|
|
6533
6596
|
}
|
|
6534
6597
|
/** Log to console if opts.debugLevel >= 3 */
|
|
6535
6598
|
logInfo(...args) {
|
|
6536
6599
|
if (this.options.debugLevel >= 3) {
|
|
6537
|
-
|
|
6538
|
-
console.info.apply(console, args);
|
|
6600
|
+
console.info(this.toString(), ...args); // eslint-disable-line no-console
|
|
6539
6601
|
}
|
|
6540
6602
|
}
|
|
6541
6603
|
/** @internal */
|
|
6542
6604
|
logTime(label) {
|
|
6543
6605
|
if (this.options.debugLevel >= 4) {
|
|
6544
|
-
console.time(this + ": " + label);
|
|
6606
|
+
console.time(this + ": " + label); // eslint-disable-line no-console
|
|
6545
6607
|
}
|
|
6546
6608
|
return label;
|
|
6547
6609
|
}
|
|
6548
6610
|
/** @internal */
|
|
6549
6611
|
logTimeEnd(label) {
|
|
6550
6612
|
if (this.options.debugLevel >= 4) {
|
|
6551
|
-
console.timeEnd(this + ": " + label);
|
|
6613
|
+
console.timeEnd(this + ": " + label); // eslint-disable-line no-console
|
|
6552
6614
|
}
|
|
6553
6615
|
}
|
|
6554
6616
|
/** Log to console if opts.debugLevel >= 2 */
|
|
6555
6617
|
logWarn(...args) {
|
|
6556
6618
|
if (this.options.debugLevel >= 2) {
|
|
6557
|
-
|
|
6558
|
-
console.warn.apply(console, args);
|
|
6619
|
+
console.warn(this.toString(), ...args); // eslint-disable-line no-console
|
|
6559
6620
|
}
|
|
6560
6621
|
}
|
|
6561
6622
|
/**
|
|
@@ -6650,18 +6711,18 @@ class Wunderbaum {
|
|
|
6650
6711
|
this.activeColIdx = colIdx;
|
|
6651
6712
|
// Update `wb-active` class for all headers
|
|
6652
6713
|
if (this.hasHeader()) {
|
|
6653
|
-
for (
|
|
6714
|
+
for (const rowDiv of this.headerElement.children) {
|
|
6654
6715
|
let i = 0;
|
|
6655
|
-
for (
|
|
6716
|
+
for (const colDiv of rowDiv.children) {
|
|
6656
6717
|
colDiv.classList.toggle("wb-active", i++ === colIdx);
|
|
6657
6718
|
}
|
|
6658
6719
|
}
|
|
6659
6720
|
}
|
|
6660
6721
|
(_a = this.activeNode) === null || _a === void 0 ? void 0 : _a.update(ChangeType.status);
|
|
6661
6722
|
// Update `wb-active` class for all cell spans
|
|
6662
|
-
for (
|
|
6723
|
+
for (const rowDiv of this.nodeListElement.children) {
|
|
6663
6724
|
let i = 0;
|
|
6664
|
-
for (
|
|
6725
|
+
for (const colDiv of rowDiv.children) {
|
|
6665
6726
|
colDiv.classList.toggle("wb-active", i++ === colIdx);
|
|
6666
6727
|
}
|
|
6667
6728
|
}
|
|
@@ -6684,15 +6745,6 @@ class Wunderbaum {
|
|
|
6684
6745
|
this.element.blur();
|
|
6685
6746
|
}
|
|
6686
6747
|
}
|
|
6687
|
-
/**
|
|
6688
|
-
* @deprecated since v0.3.6: use `update()` instead.
|
|
6689
|
-
*/
|
|
6690
|
-
setModified(change, ...args) {
|
|
6691
|
-
this.logWarn("setModified() is deprecated: use update() instead.");
|
|
6692
|
-
// @ts-ignore
|
|
6693
|
-
// (!) TS2556: A spread argument must either have a tuple type or be passed to a rest parameter.
|
|
6694
|
-
return this.update.call(this, change, ...args);
|
|
6695
|
-
}
|
|
6696
6748
|
update(change, node, options) {
|
|
6697
6749
|
if (this._disableUpdateCount) {
|
|
6698
6750
|
// Assuming that we redraw all when enableUpdate() is re-enabled.
|
|
@@ -6838,7 +6890,7 @@ class Wunderbaum {
|
|
|
6838
6890
|
extend(this.types, types);
|
|
6839
6891
|
}
|
|
6840
6892
|
// Convert `TYPE.classes` to a Set
|
|
6841
|
-
for (
|
|
6893
|
+
for (const t of Object.values(this.types)) {
|
|
6842
6894
|
if (t.classes) {
|
|
6843
6895
|
t.classes = toSet(t.classes);
|
|
6844
6896
|
}
|
|
@@ -6876,7 +6928,7 @@ class Wunderbaum {
|
|
|
6876
6928
|
const defaultMinWidth = 4;
|
|
6877
6929
|
const vpWidth = this.element.clientWidth;
|
|
6878
6930
|
// Shorten last column width to avoid h-scrollbar
|
|
6879
|
-
const FIX_ADJUST_LAST_COL = 2;
|
|
6931
|
+
const FIX_ADJUST_LAST_COL = 0; // 2;
|
|
6880
6932
|
const columns = this.columns;
|
|
6881
6933
|
const col0 = columns[0];
|
|
6882
6934
|
let totalWidth = 0;
|
|
@@ -6893,9 +6945,9 @@ class Wunderbaum {
|
|
|
6893
6945
|
}
|
|
6894
6946
|
// Gather width definitions
|
|
6895
6947
|
this._columnsById = {};
|
|
6896
|
-
for (
|
|
6948
|
+
for (const col of columns) {
|
|
6897
6949
|
this._columnsById[col.id] = col;
|
|
6898
|
-
|
|
6950
|
+
const cw = col.width;
|
|
6899
6951
|
if (col.id === "*" && col !== col0) {
|
|
6900
6952
|
throw new Error(`Column id '*' must be defined only once: '${col.title}'.`);
|
|
6901
6953
|
}
|
|
@@ -6909,7 +6961,7 @@ class Wunderbaum {
|
|
|
6909
6961
|
}
|
|
6910
6962
|
else if (typeof cw === "string" && cw.endsWith("px")) {
|
|
6911
6963
|
col._weight = 0;
|
|
6912
|
-
|
|
6964
|
+
const px = parseFloat(cw.slice(0, -2));
|
|
6913
6965
|
if (col._widthPx != px) {
|
|
6914
6966
|
modified = true;
|
|
6915
6967
|
col._widthPx = px;
|
|
@@ -6923,7 +6975,7 @@ class Wunderbaum {
|
|
|
6923
6975
|
// Share remaining space between non-fixed columns
|
|
6924
6976
|
const restPx = Math.max(0, vpWidth - fixedWidth);
|
|
6925
6977
|
let ofsPx = 0;
|
|
6926
|
-
for (
|
|
6978
|
+
for (const col of columns) {
|
|
6927
6979
|
let minWidth;
|
|
6928
6980
|
if (col._weight) {
|
|
6929
6981
|
const cmw = col.minWidth;
|
|
@@ -7236,7 +7288,9 @@ class Wunderbaum {
|
|
|
7236
7288
|
return this._visitRowsUp(callback, options);
|
|
7237
7289
|
}
|
|
7238
7290
|
options = options || {};
|
|
7239
|
-
let i, nextIdx, parent, res, siblings, stopNode, siblingOfs = 0, skipFirstNode = options.includeSelf === false,
|
|
7291
|
+
let i, nextIdx, parent, res, siblings, stopNode, siblingOfs = 0, skipFirstNode = options.includeSelf === false, node = options.start || this.root.children[0];
|
|
7292
|
+
const includeHidden = !!options.includeHidden;
|
|
7293
|
+
const checkFilter = !includeHidden && this.filterMode === "hide";
|
|
7240
7294
|
parent = node.parent;
|
|
7241
7295
|
while (parent) {
|
|
7242
7296
|
// visit siblings
|
|
@@ -7301,7 +7355,8 @@ class Wunderbaum {
|
|
|
7301
7355
|
* @internal
|
|
7302
7356
|
*/
|
|
7303
7357
|
_visitRowsUp(callback, options) {
|
|
7304
|
-
let children, idx, parent,
|
|
7358
|
+
let children, idx, parent, node = options.start || this.root.children[0];
|
|
7359
|
+
const includeHidden = !!options.includeHidden;
|
|
7305
7360
|
if (options.includeSelf !== false) {
|
|
7306
7361
|
if (callback(node) === false) {
|
|
7307
7362
|
return false;
|
|
@@ -7436,7 +7491,7 @@ class Wunderbaum {
|
|
|
7436
7491
|
}
|
|
7437
7492
|
Wunderbaum.sequence = 0;
|
|
7438
7493
|
/** Wunderbaum release version number "MAJOR.MINOR.PATCH". */
|
|
7439
|
-
Wunderbaum.version = "v0.5.
|
|
7494
|
+
Wunderbaum.version = "v0.5.3"; // Set to semver by 'grunt release'
|
|
7440
7495
|
/** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
|
|
7441
7496
|
Wunderbaum.util = util;
|
|
7442
7497
|
|