wunderbaum 0.5.2 → 0.5.4
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/src/wb_node.ts
CHANGED
|
@@ -283,7 +283,7 @@ export class WunderbaumNode {
|
|
|
283
283
|
}
|
|
284
284
|
const forceExpand =
|
|
285
285
|
applyMinExpanLevel && _level < tree.options.minExpandLevel!;
|
|
286
|
-
for (
|
|
286
|
+
for (const child of <WbNodeData[]>nodeData) {
|
|
287
287
|
const subChildren = child.children;
|
|
288
288
|
delete child.children;
|
|
289
289
|
|
|
@@ -304,7 +304,7 @@ export class WunderbaumNode {
|
|
|
304
304
|
} else {
|
|
305
305
|
// Returns null if before is not a direct child:
|
|
306
306
|
before = this.findDirectChild(before)!;
|
|
307
|
-
|
|
307
|
+
const pos = this.children.indexOf(before);
|
|
308
308
|
util.assert(
|
|
309
309
|
pos >= 0,
|
|
310
310
|
`options.before must be a direct child of ${this}`
|
|
@@ -378,7 +378,7 @@ export class WunderbaumNode {
|
|
|
378
378
|
* (Automatically called when `autoCollapse` is true.)
|
|
379
379
|
*/
|
|
380
380
|
collapseSiblings(options?: SetExpandedOptions): any {
|
|
381
|
-
for (
|
|
381
|
+
for (const node of this.parent.children!) {
|
|
382
382
|
if (node !== this && node.expanded) {
|
|
383
383
|
node.setExpanded(false, options);
|
|
384
384
|
}
|
|
@@ -424,7 +424,7 @@ export class WunderbaumNode {
|
|
|
424
424
|
async expandAll(flag: boolean = true, options?: ExpandAllOptions) {
|
|
425
425
|
const tree = this.tree;
|
|
426
426
|
const minExpandLevel = this.tree.options.minExpandLevel;
|
|
427
|
-
|
|
427
|
+
const {
|
|
428
428
|
depth = 99,
|
|
429
429
|
loadLazy,
|
|
430
430
|
force,
|
|
@@ -534,9 +534,11 @@ export class WunderbaumNode {
|
|
|
534
534
|
findDirectChild(
|
|
535
535
|
ptr: number | string | WunderbaumNode
|
|
536
536
|
): WunderbaumNode | null {
|
|
537
|
-
|
|
537
|
+
const cl = this.children;
|
|
538
538
|
|
|
539
|
-
if (!cl)
|
|
539
|
+
if (!cl) {
|
|
540
|
+
return null;
|
|
541
|
+
}
|
|
540
542
|
if (typeof ptr === "string") {
|
|
541
543
|
for (let i = 0, l = cl.length; i < l; i++) {
|
|
542
544
|
if (cl[i].key === ptr) {
|
|
@@ -607,7 +609,7 @@ export class WunderbaumNode {
|
|
|
607
609
|
};
|
|
608
610
|
|
|
609
611
|
yield name_cb(this);
|
|
610
|
-
for (
|
|
612
|
+
for (const node of this) {
|
|
611
613
|
yield _format_line(node);
|
|
612
614
|
}
|
|
613
615
|
}
|
|
@@ -630,7 +632,7 @@ export class WunderbaumNode {
|
|
|
630
632
|
*/
|
|
631
633
|
format(name_cb?: NodeStringCallback, connectors?: string[]): string {
|
|
632
634
|
const a = [];
|
|
633
|
-
for (
|
|
635
|
+
for (const line of this.format_iter(name_cb, connectors)) {
|
|
634
636
|
a.push(line);
|
|
635
637
|
}
|
|
636
638
|
return a.join("\n");
|
|
@@ -675,8 +677,8 @@ export class WunderbaumNode {
|
|
|
675
677
|
|
|
676
678
|
/** Return the successive node (under the same parent) or null. */
|
|
677
679
|
getNextSibling(): WunderbaumNode | null {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
+
const ac = this.parent.children!;
|
|
681
|
+
const idx = ac.indexOf(this);
|
|
680
682
|
return ac[idx + 1] || null;
|
|
681
683
|
}
|
|
682
684
|
|
|
@@ -691,8 +693,8 @@ export class WunderbaumNode {
|
|
|
691
693
|
* @param includeSelf Include the node itself.
|
|
692
694
|
*/
|
|
693
695
|
getParentList(includeRoot = false, includeSelf = false) {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
+
const l = [];
|
|
697
|
+
let dtn = includeSelf ? this : this.parent;
|
|
696
698
|
while (dtn) {
|
|
697
699
|
if (includeRoot || dtn.parent) {
|
|
698
700
|
l.unshift(dtn);
|
|
@@ -715,9 +717,9 @@ export class WunderbaumNode {
|
|
|
715
717
|
// part = part || "title";
|
|
716
718
|
// separator = separator || "/";
|
|
717
719
|
|
|
718
|
-
let val
|
|
719
|
-
|
|
720
|
-
|
|
720
|
+
let val;
|
|
721
|
+
const path: string[] = [];
|
|
722
|
+
const isFunc = typeof part === "function";
|
|
721
723
|
|
|
722
724
|
this.visitParents((n) => {
|
|
723
725
|
if (n.parent) {
|
|
@@ -733,8 +735,8 @@ export class WunderbaumNode {
|
|
|
733
735
|
|
|
734
736
|
/** Return the preceeding node (under the same parent) or null. */
|
|
735
737
|
getPrevSibling(): WunderbaumNode | null {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
+
const ac = this.parent.children!;
|
|
739
|
+
const idx = ac.indexOf(this);
|
|
738
740
|
return ac[idx - 1] || null;
|
|
739
741
|
}
|
|
740
742
|
|
|
@@ -796,7 +798,7 @@ export class WunderbaumNode {
|
|
|
796
798
|
if (!other || other.tree !== this.tree) {
|
|
797
799
|
return false;
|
|
798
800
|
}
|
|
799
|
-
|
|
801
|
+
let p = this.parent;
|
|
800
802
|
while (p) {
|
|
801
803
|
if (p === other) {
|
|
802
804
|
return true;
|
|
@@ -839,13 +841,13 @@ export class WunderbaumNode {
|
|
|
839
841
|
|
|
840
842
|
/** Return true if this node is the first node of its parent's children. */
|
|
841
843
|
isFirstSibling(): boolean {
|
|
842
|
-
|
|
844
|
+
const p = this.parent;
|
|
843
845
|
return !p || p.children![0] === this;
|
|
844
846
|
}
|
|
845
847
|
|
|
846
848
|
/** Return true if this node is the last node of its parent's children. */
|
|
847
849
|
isLastSibling(): boolean {
|
|
848
|
-
|
|
850
|
+
const p = this.parent;
|
|
849
851
|
return !p || p.children![p.children!.length - 1] === this;
|
|
850
852
|
}
|
|
851
853
|
|
|
@@ -934,11 +936,8 @@ export class WunderbaumNode {
|
|
|
934
936
|
* whether the node is scrolled into the visible part of the screen or viewport.
|
|
935
937
|
*/
|
|
936
938
|
isVisible(): boolean {
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
n,
|
|
940
|
-
hasFilter = this.tree.filterMode === "hide",
|
|
941
|
-
parents = this.getParentList(false, false);
|
|
939
|
+
const hasFilter = this.tree.filterMode === "hide";
|
|
940
|
+
const parents = this.getParentList(false, false);
|
|
942
941
|
|
|
943
942
|
// TODO: check $(n.span).is(":visible")
|
|
944
943
|
// i.e. return false for nodes (but not parents) that are hidden
|
|
@@ -948,8 +947,8 @@ export class WunderbaumNode {
|
|
|
948
947
|
return false;
|
|
949
948
|
}
|
|
950
949
|
|
|
951
|
-
for (i = 0, l = parents.length; i < l; i++) {
|
|
952
|
-
n = parents[i];
|
|
950
|
+
for (let i = 0, l = parents.length; i < l; i++) {
|
|
951
|
+
const n = parents[i];
|
|
953
952
|
|
|
954
953
|
if (!n.expanded) {
|
|
955
954
|
// this.debug("isVisible: HIDDEN (parent collapsed)");
|
|
@@ -1085,7 +1084,8 @@ export class WunderbaumNode {
|
|
|
1085
1084
|
// const timerLabel = tree.logTime(this + ".load()");
|
|
1086
1085
|
|
|
1087
1086
|
try {
|
|
1088
|
-
|
|
1087
|
+
const url: string =
|
|
1088
|
+
typeof source === "string" ? source : (<any>source).url;
|
|
1089
1089
|
if (!url) {
|
|
1090
1090
|
// An array or a plain object (that does NOT contain a `.url` property)
|
|
1091
1091
|
// will be treated as native Wunderbaum data
|
|
@@ -1185,38 +1185,34 @@ export class WunderbaumNode {
|
|
|
1185
1185
|
|
|
1186
1186
|
/** Alias for `logDebug` */
|
|
1187
1187
|
log(...args: any[]) {
|
|
1188
|
-
this.logDebug
|
|
1188
|
+
this.logDebug(...args);
|
|
1189
1189
|
}
|
|
1190
1190
|
|
|
1191
1191
|
/* Log to console if opts.debugLevel >= 4 */
|
|
1192
1192
|
logDebug(...args: any[]) {
|
|
1193
1193
|
if (this.tree.options.debugLevel! >= 4) {
|
|
1194
|
-
|
|
1195
|
-
console.log.apply(console, args);
|
|
1194
|
+
console.log(this.toString(), ...args); // eslint-disable-line no-console
|
|
1196
1195
|
}
|
|
1197
1196
|
}
|
|
1198
1197
|
|
|
1199
1198
|
/* Log error to console. */
|
|
1200
1199
|
logError(...args: any[]) {
|
|
1201
1200
|
if (this.tree.options.debugLevel! >= 1) {
|
|
1202
|
-
|
|
1203
|
-
console.error.apply(console, args);
|
|
1201
|
+
console.error(this.toString(), ...args); // eslint-disable-line no-console
|
|
1204
1202
|
}
|
|
1205
1203
|
}
|
|
1206
1204
|
|
|
1207
1205
|
/* Log to console if opts.debugLevel >= 3 */
|
|
1208
1206
|
logInfo(...args: any[]) {
|
|
1209
1207
|
if (this.tree.options.debugLevel! >= 3) {
|
|
1210
|
-
|
|
1211
|
-
console.info.apply(console, args);
|
|
1208
|
+
console.info(this.toString(), ...args); // eslint-disable-line no-console
|
|
1212
1209
|
}
|
|
1213
1210
|
}
|
|
1214
1211
|
|
|
1215
1212
|
/* Log warning to console if opts.debugLevel >= 2 */
|
|
1216
1213
|
logWarn(...args: any[]) {
|
|
1217
1214
|
if (this.tree.options.debugLevel! >= 2) {
|
|
1218
|
-
|
|
1219
|
-
console.warn.apply(console, args);
|
|
1215
|
+
console.warn(this.toString(), ...args); // eslint-disable-line no-console
|
|
1220
1216
|
}
|
|
1221
1217
|
}
|
|
1222
1218
|
|
|
@@ -1226,13 +1222,13 @@ export class WunderbaumNode {
|
|
|
1226
1222
|
* Defaults to {noAnimation: false, noEvents: false, scrollIntoView: true}
|
|
1227
1223
|
*/
|
|
1228
1224
|
async makeVisible(options?: MakeVisibleOptions) {
|
|
1229
|
-
let i
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1225
|
+
let i;
|
|
1226
|
+
const dfd = new Deferred();
|
|
1227
|
+
const deferreds = [];
|
|
1228
|
+
const parents = this.getParentList(false, false);
|
|
1229
|
+
const len = parents.length;
|
|
1230
|
+
const noAnimation = util.getOption(options, "noAnimation", false);
|
|
1231
|
+
const scroll = util.getOption(options, "scrollIntoView", true);
|
|
1236
1232
|
|
|
1237
1233
|
// Expand bottom-up, so only the top node is animated
|
|
1238
1234
|
for (i = len - 1; i >= 0; i--) {
|
|
@@ -1275,10 +1271,11 @@ export class WunderbaumNode {
|
|
|
1275
1271
|
mode = "appendChild";
|
|
1276
1272
|
}
|
|
1277
1273
|
}
|
|
1278
|
-
let pos
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1274
|
+
let pos;
|
|
1275
|
+
const tree = this.tree;
|
|
1276
|
+
const prevParent = this.parent;
|
|
1277
|
+
const targetParent =
|
|
1278
|
+
mode === "appendChild" ? targetNode : targetNode.parent;
|
|
1282
1279
|
|
|
1283
1280
|
if (this === targetNode) {
|
|
1284
1281
|
return;
|
|
@@ -1385,7 +1382,9 @@ export class WunderbaumNode {
|
|
|
1385
1382
|
// setFocus/setActive will scroll later (if autoScroll is specified)
|
|
1386
1383
|
try {
|
|
1387
1384
|
node.makeVisible({ scrollIntoView: false });
|
|
1388
|
-
} catch (e) {
|
|
1385
|
+
} catch (e) {
|
|
1386
|
+
// ignore
|
|
1387
|
+
}
|
|
1389
1388
|
node.setFocus();
|
|
1390
1389
|
if (options?.activate === false) {
|
|
1391
1390
|
return Promise.resolve(this);
|
|
@@ -1460,7 +1459,7 @@ export class WunderbaumNode {
|
|
|
1460
1459
|
: null;
|
|
1461
1460
|
|
|
1462
1461
|
let idx = 0;
|
|
1463
|
-
for (
|
|
1462
|
+
for (const col of this.tree.columns) {
|
|
1464
1463
|
allColInfosById[col.id] = {
|
|
1465
1464
|
id: col.id,
|
|
1466
1465
|
idx: idx,
|
|
@@ -1537,7 +1536,7 @@ export class WunderbaumNode {
|
|
|
1537
1536
|
|
|
1538
1537
|
// Event handler `tree.iconBadge` can return a badge text or HTMLSpanElement
|
|
1539
1538
|
|
|
1540
|
-
|
|
1539
|
+
const cbRes = this._callEvent("iconBadge", { iconSpan: iconSpan });
|
|
1541
1540
|
let badge = null;
|
|
1542
1541
|
if (cbRes != null && cbRes !== false) {
|
|
1543
1542
|
let classes = "";
|
|
@@ -1577,14 +1576,12 @@ export class WunderbaumNode {
|
|
|
1577
1576
|
const checkbox = this.getOption("checkbox");
|
|
1578
1577
|
const columns = tree.columns;
|
|
1579
1578
|
const level = this.getLevel();
|
|
1579
|
+
const activeColIdx = tree.isRowNav() ? null : tree.activeColIdx;
|
|
1580
|
+
|
|
1580
1581
|
let elem: HTMLElement;
|
|
1581
|
-
let nodeElem: HTMLElement;
|
|
1582
1582
|
let rowDiv = this._rowElem;
|
|
1583
|
-
let titleSpan: HTMLElement;
|
|
1584
1583
|
let checkboxSpan: HTMLElement | null = null;
|
|
1585
|
-
let iconSpan: HTMLElement | null;
|
|
1586
1584
|
let expanderSpan: HTMLElement | null = null;
|
|
1587
|
-
const activeColIdx = tree.isRowNav() ? null : tree.activeColIdx;
|
|
1588
1585
|
|
|
1589
1586
|
const isNew = !rowDiv;
|
|
1590
1587
|
util.assert(isNew);
|
|
@@ -1604,7 +1601,7 @@ export class WunderbaumNode {
|
|
|
1604
1601
|
// Attach a node reference to the DOM Element:
|
|
1605
1602
|
(<any>rowDiv)._wb_node = this;
|
|
1606
1603
|
|
|
1607
|
-
nodeElem = document.createElement("span");
|
|
1604
|
+
const nodeElem: HTMLElement = document.createElement("span");
|
|
1608
1605
|
nodeElem.classList.add("wb-node", "wb-col");
|
|
1609
1606
|
rowDiv.appendChild(nodeElem);
|
|
1610
1607
|
|
|
@@ -1636,12 +1633,17 @@ export class WunderbaumNode {
|
|
|
1636
1633
|
|
|
1637
1634
|
// Render the icon (show a 'loading' icon if we do not have an expander that
|
|
1638
1635
|
// we would prefer).
|
|
1639
|
-
iconSpan = this._createIcon(
|
|
1636
|
+
const iconSpan = this._createIcon(
|
|
1637
|
+
tree.iconMap,
|
|
1638
|
+
nodeElem,
|
|
1639
|
+
null,
|
|
1640
|
+
!expanderSpan
|
|
1641
|
+
);
|
|
1640
1642
|
if (iconSpan) {
|
|
1641
1643
|
ofsTitlePx += ICON_WIDTH;
|
|
1642
1644
|
}
|
|
1643
1645
|
|
|
1644
|
-
titleSpan = document.createElement("span");
|
|
1646
|
+
const titleSpan = document.createElement("span");
|
|
1645
1647
|
titleSpan.classList.add("wb-title");
|
|
1646
1648
|
nodeElem.appendChild(titleSpan);
|
|
1647
1649
|
|
|
@@ -1661,7 +1663,7 @@ export class WunderbaumNode {
|
|
|
1661
1663
|
|
|
1662
1664
|
if (!isColspan && columns.length > 1) {
|
|
1663
1665
|
let colIdx = 0;
|
|
1664
|
-
for (
|
|
1666
|
+
for (const col of columns) {
|
|
1665
1667
|
colIdx++;
|
|
1666
1668
|
|
|
1667
1669
|
let colElem;
|
|
@@ -1741,7 +1743,7 @@ export class WunderbaumNode {
|
|
|
1741
1743
|
// Set the width of the title span, so overflow ellipsis work
|
|
1742
1744
|
if (!treeOptions.skeleton) {
|
|
1743
1745
|
if (isColspan) {
|
|
1744
|
-
|
|
1746
|
+
const vpWidth = tree.element.clientWidth;
|
|
1745
1747
|
titleSpan.style.width =
|
|
1746
1748
|
vpWidth - (<any>nodeElem)._ofsTitlePx - TITLE_SPAN_PAD_Y + "px";
|
|
1747
1749
|
} else {
|
|
@@ -1799,7 +1801,7 @@ export class WunderbaumNode {
|
|
|
1799
1801
|
"i.wb-checkbox"
|
|
1800
1802
|
) as HTMLLIElement;
|
|
1801
1803
|
|
|
1802
|
-
|
|
1804
|
+
const rowClasses = ["wb-row"];
|
|
1803
1805
|
this.expanded ? rowClasses.push("wb-expanded") : 0;
|
|
1804
1806
|
this.lazy ? rowClasses.push("wb-lazy") : 0;
|
|
1805
1807
|
this.selected ? rowClasses.push("wb-selected") : 0;
|
|
@@ -1842,10 +1844,13 @@ export class WunderbaumNode {
|
|
|
1842
1844
|
image = iconMap.expanderLazy;
|
|
1843
1845
|
}
|
|
1844
1846
|
|
|
1845
|
-
if (image == null)
|
|
1846
|
-
|
|
1847
|
+
if (image == null) {
|
|
1848
|
+
expanderSpan.classList.add("wb-indent");
|
|
1849
|
+
} else if (TEST_IMG.test(image)) {
|
|
1847
1850
|
expanderSpan.style.backgroundImage = `url('${image}')`;
|
|
1848
|
-
else
|
|
1851
|
+
} else {
|
|
1852
|
+
expanderSpan.className = "wb-expander " + image;
|
|
1853
|
+
}
|
|
1849
1854
|
}
|
|
1850
1855
|
if (checkboxSpan) {
|
|
1851
1856
|
let cbclass = "wb-checkbox ";
|
|
@@ -1872,7 +1877,7 @@ export class WunderbaumNode {
|
|
|
1872
1877
|
// Fix active cell in cell-nav mode
|
|
1873
1878
|
if (!opts.isNew) {
|
|
1874
1879
|
let i = 0;
|
|
1875
|
-
for (
|
|
1880
|
+
for (const colSpan of rowDiv.children) {
|
|
1876
1881
|
colSpan.classList.toggle("wb-active", i++ === tree.activeColIdx);
|
|
1877
1882
|
}
|
|
1878
1883
|
// Update icon (if not opts.isNew, which would rebuild markup anyway)
|
|
@@ -1886,7 +1891,7 @@ export class WunderbaumNode {
|
|
|
1886
1891
|
const colElems = rowDiv.querySelectorAll("span.wb-col");
|
|
1887
1892
|
let idx = 0;
|
|
1888
1893
|
let ofs = 0;
|
|
1889
|
-
for (
|
|
1894
|
+
for (const colDef of this.tree.columns) {
|
|
1890
1895
|
const colElem = colElems[idx] as HTMLSpanElement;
|
|
1891
1896
|
colElem.style.left = `${ofs}px`;
|
|
1892
1897
|
colElem.style.width = `${colDef._widthPx}px`;
|
|
@@ -2020,18 +2025,18 @@ export class WunderbaumNode {
|
|
|
2020
2025
|
* {@link Wunderbaum.getOption|Wunderbaum.getOption()}
|
|
2021
2026
|
*/
|
|
2022
2027
|
getOption(name: string, defaultValue?: any) {
|
|
2023
|
-
|
|
2028
|
+
const tree = this.tree;
|
|
2024
2029
|
let opts: any = tree.options;
|
|
2025
2030
|
|
|
2026
2031
|
// Lookup `name` in options dict
|
|
2027
2032
|
if (name.indexOf(".") >= 0) {
|
|
2028
2033
|
[opts, name] = name.split(".");
|
|
2029
2034
|
}
|
|
2030
|
-
|
|
2035
|
+
const value = opts[name]; // ?? defaultValue;
|
|
2031
2036
|
|
|
2032
2037
|
// A callback resolver always takes precedence
|
|
2033
2038
|
if (typeof value === "function") {
|
|
2034
|
-
|
|
2039
|
+
const res = value.call(tree, {
|
|
2035
2040
|
type: "resolve",
|
|
2036
2041
|
tree: tree,
|
|
2037
2042
|
node: this,
|
|
@@ -2046,8 +2051,8 @@ export class WunderbaumNode {
|
|
|
2046
2051
|
return (<any>this)[name];
|
|
2047
2052
|
}
|
|
2048
2053
|
// Use value from type definition if defined
|
|
2049
|
-
|
|
2050
|
-
|
|
2054
|
+
const typeInfo = this.type ? tree.types[this.type] : undefined;
|
|
2055
|
+
const res = typeInfo ? typeInfo[name] : undefined;
|
|
2051
2056
|
if (res !== undefined) {
|
|
2052
2057
|
return res;
|
|
2053
2058
|
}
|
|
@@ -2101,8 +2106,12 @@ export class WunderbaumNode {
|
|
|
2101
2106
|
if (prev !== this) {
|
|
2102
2107
|
if (flag) {
|
|
2103
2108
|
tree.activeNode = this;
|
|
2104
|
-
if (focusNode || focusTree)
|
|
2105
|
-
|
|
2109
|
+
if (focusNode || focusTree) {
|
|
2110
|
+
tree.focusNode = this;
|
|
2111
|
+
}
|
|
2112
|
+
if (focusTree) {
|
|
2113
|
+
tree.setFocus();
|
|
2114
|
+
}
|
|
2106
2115
|
}
|
|
2107
2116
|
prev?.update(ChangeType.status);
|
|
2108
2117
|
this.update(ChangeType.status);
|
|
@@ -2181,13 +2190,6 @@ export class WunderbaumNode {
|
|
|
2181
2190
|
throw new Error("Not yet implemented");
|
|
2182
2191
|
}
|
|
2183
2192
|
|
|
2184
|
-
/**
|
|
2185
|
-
* @deprecated since v0.3.6: use `update()` instead.
|
|
2186
|
-
*/
|
|
2187
|
-
setModified(change: ChangeType = ChangeType.data): void {
|
|
2188
|
-
this.logWarn("setModified() is deprecated: use update() instead.");
|
|
2189
|
-
return this.update(change);
|
|
2190
|
-
}
|
|
2191
2193
|
/**
|
|
2192
2194
|
* Trigger a repaint, typically after a status or data change.
|
|
2193
2195
|
*
|
|
@@ -2209,7 +2211,7 @@ export class WunderbaumNode {
|
|
|
2209
2211
|
* @param stopOnParents only return the topmost selected node (useful with selectMode 'hier')
|
|
2210
2212
|
*/
|
|
2211
2213
|
getSelectedNodes(stopOnParents: boolean = false): WunderbaumNode[] {
|
|
2212
|
-
|
|
2214
|
+
const nodeList: WunderbaumNode[] = [];
|
|
2213
2215
|
this.visit((node) => {
|
|
2214
2216
|
if (node.selected) {
|
|
2215
2217
|
nodeList.push(node);
|
|
@@ -2282,7 +2284,7 @@ export class WunderbaumNode {
|
|
|
2282
2284
|
*/
|
|
2283
2285
|
fixSelection3AfterClick(opts?: SetSelectedOptions): void {
|
|
2284
2286
|
const force = !!opts?.force;
|
|
2285
|
-
|
|
2287
|
+
const flag = this.isSelected();
|
|
2286
2288
|
|
|
2287
2289
|
this.visit((node) => {
|
|
2288
2290
|
if (node.radiogroup) {
|
|
@@ -2414,7 +2416,7 @@ export class WunderbaumNode {
|
|
|
2414
2416
|
if (!flag && !options?.force) {
|
|
2415
2417
|
return prev; // don't uncheck radio buttons
|
|
2416
2418
|
}
|
|
2417
|
-
for (
|
|
2419
|
+
for (const sibling of this.parent.children!) {
|
|
2418
2420
|
sibling.selected = sibling === this;
|
|
2419
2421
|
}
|
|
2420
2422
|
} else {
|
|
@@ -2448,7 +2450,7 @@ export class WunderbaumNode {
|
|
|
2448
2450
|
|
|
2449
2451
|
const _clearStatusNode = () => {
|
|
2450
2452
|
// Remove dedicated dummy node, if any
|
|
2451
|
-
|
|
2453
|
+
const children = this.children;
|
|
2452
2454
|
|
|
2453
2455
|
if (children && children.length && children[0].isStatusNode()) {
|
|
2454
2456
|
children[0].remove();
|
|
@@ -2459,8 +2461,8 @@ export class WunderbaumNode {
|
|
|
2459
2461
|
// Create/modify the dedicated dummy node for 'loading...' or
|
|
2460
2462
|
// 'error!' status. (only called for direct child of the invisible
|
|
2461
2463
|
// system root)
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
+
const children = this.children;
|
|
2465
|
+
const firstChild = children ? children[0] : null;
|
|
2464
2466
|
|
|
2465
2467
|
util.assert(data.statusNodeType);
|
|
2466
2468
|
util.assert(!firstChild || !firstChild.isStatusNode());
|
|
@@ -2578,7 +2580,9 @@ export class WunderbaumNode {
|
|
|
2578
2580
|
extra?: any
|
|
2579
2581
|
) {
|
|
2580
2582
|
this.logDebug(`modifyChild(${operation})`, extra, child);
|
|
2581
|
-
if (!this.tree.options.modifyChild)
|
|
2583
|
+
if (!this.tree.options.modifyChild) {
|
|
2584
|
+
return;
|
|
2585
|
+
}
|
|
2582
2586
|
if (child && child.parent !== this) {
|
|
2583
2587
|
util.error("child " + child + " is not a child of " + this);
|
|
2584
2588
|
}
|
|
@@ -2616,10 +2620,8 @@ export class WunderbaumNode {
|
|
|
2616
2620
|
callback: NodeVisitCallback,
|
|
2617
2621
|
includeSelf: boolean = false
|
|
2618
2622
|
): NodeVisitResponse {
|
|
2619
|
-
let
|
|
2620
|
-
|
|
2621
|
-
res: any = true,
|
|
2622
|
-
children = this.children;
|
|
2623
|
+
let res: any = true;
|
|
2624
|
+
const children = this.children;
|
|
2623
2625
|
|
|
2624
2626
|
if (includeSelf === true) {
|
|
2625
2627
|
res = callback(this);
|
|
@@ -2628,7 +2630,7 @@ export class WunderbaumNode {
|
|
|
2628
2630
|
}
|
|
2629
2631
|
}
|
|
2630
2632
|
if (children) {
|
|
2631
|
-
for (i = 0, l = children.length; i < l; i++) {
|
|
2633
|
+
for (let i = 0, l = children.length; i < l; i++) {
|
|
2632
2634
|
res = children[i].visit(callback, true);
|
|
2633
2635
|
if (res === false) {
|
|
2634
2636
|
break;
|
|
@@ -2673,13 +2675,10 @@ export class WunderbaumNode {
|
|
|
2673
2675
|
callback: (node: WunderbaumNode) => boolean | void,
|
|
2674
2676
|
includeSelf: boolean = false
|
|
2675
2677
|
): boolean {
|
|
2676
|
-
|
|
2677
|
-
l,
|
|
2678
|
-
n,
|
|
2679
|
-
ac = this.parent.children!;
|
|
2678
|
+
const ac = this.parent.children!;
|
|
2680
2679
|
|
|
2681
|
-
for (i = 0, l = ac.length; i < l; i++) {
|
|
2682
|
-
n = ac[i];
|
|
2680
|
+
for (let i = 0, l = ac.length; i < l; i++) {
|
|
2681
|
+
const n = ac[i];
|
|
2683
2682
|
if (includeSelf || n !== this) {
|
|
2684
2683
|
if (callback(n) === false) {
|
|
2685
2684
|
return false;
|
package/src/wunderbaum.scss
CHANGED
|
@@ -416,7 +416,7 @@ div.wunderbaum {
|
|
|
416
416
|
i.wb-indent {
|
|
417
417
|
height: var(--wb-icon-outer-height);
|
|
418
418
|
width: var(--wb-icon-outer-width);
|
|
419
|
-
padding: var(--wb-icon-padding) var(--wb-icon-padding-x);
|
|
419
|
+
padding: var(--wb-icon-padding-y) var(--wb-icon-padding-x);
|
|
420
420
|
display: inline-block;
|
|
421
421
|
}
|
|
422
422
|
|
|
@@ -635,7 +635,7 @@ div.wunderbaum {
|
|
|
635
635
|
// content: url(../docs/assets/drop_marker_16x32.png);
|
|
636
636
|
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAQCAMAAABA3o1rAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACKUExURe/v9/f39+//7+f35+f/79bW5wgIawwYd97e55Tnpc731rjA2d7350LOY1LWa7Xvvf///wAQcyAze97e773vxnuczgA5pQBCpdb33rXvxu//9whjxgBaxlKU1oOz5ABz3gB73tbn99bW1rXe/wCM9xiU997v/97e3gCc/xil/9bv/wic/+/3/wAAALM9X5QAAAAudFJOU////////////////////////////////////////////////////////////wCCj3NVAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAqUlEQVQoU6WQ2w6CMAxA54agsCHq1HlFBREv/f/fs1tHAoaoiedlbXrWtGXwhV8FNqAXuAi4DwkShmE0cgGIcSwCCgkSkrAxpEonot0DhQxJptFsbnOpdNdgsFh6VtYwyqzTmG+oijDY7hr22E4qY7QybeGQe46nsxP0Wwc3Q1GWl+qKec8MlqKubxX+xzV7tkDuD1+3d+heigT2zGx/hCMUeUj4wL8CwAsW1kqCTugMCwAAAABJRU5ErkJggg==);
|
|
637
637
|
left: 0; //-$icon-outer-width;
|
|
638
|
-
top: calc(($row-outer-height - --wb-icon-height) / 2);
|
|
638
|
+
top: calc(($row-outer-height - var(--wb-icon-height)) / 2);
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
641
|
}
|
|
@@ -658,13 +658,13 @@ div.wunderbaum {
|
|
|
658
658
|
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAMAAACROYkbAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACNUExURe/v9/f39+//7+f35+f/79bW5wgIawwYd97e55Tnpc731rjA2d7350LOY1LWa7Xvvf///wAQcyAze97e773vxgAAAHuczgA5pQBCpdb33rXvxu//9whjxgBaxlKU1oOz5ABz3gB73tbn99bW1rXe/wCM9xiU997v/97e3gCc/xil/9bv/wic/+/3/wAAAParqS4AAAAvdFJOU/////////////////////////////////////////////////////////////8AWqU49wAAAAlwSFlzAAAOwwAADsMBx2+oZAAAALlJREFUOE/FktsSgiAQhglMS8WstKLzQTM77Ps/XguL16I208cFyzB8/LPAYCC/ErARzcCFx23pBgnGfjAxBYhpKDwq3SBB5DeGWCYz0SUDClIkmgeLpV7HMiNDbrbbYbBaWzbaoKTaJiHfQe5oYLA/NBwxTiyVyqTSghYwox4MTmfL5XozgqxjAtODoizv1QPXPXqgKer6WeH9+Iw9XgF5ve15/Q+6/SQSsE+q8yMcocoREgzg3wKAL4vrpBIKREShAAAAAElFTkSuQmCC);
|
|
659
659
|
left: 0; // $icon-outer-width * 1.5;
|
|
660
660
|
top: calc(
|
|
661
|
-
($row-outer-height - --wb-icon-height) / 2 - $row-outer-height / 2
|
|
661
|
+
($row-outer-height - var(--wb-icon-height)) / 2 - $row-outer-height / 2
|
|
662
662
|
);
|
|
663
663
|
}
|
|
664
664
|
|
|
665
665
|
div.wb-row.wb-drop-target.wb-drop-after .wb-node .wb-icon::after {
|
|
666
666
|
top: calc(
|
|
667
|
-
($row-outer-height - --wb-icon-height) / 2 + $row-outer-height / 2
|
|
667
|
+
($row-outer-height - var(--wb-icon-height)) / 2 + $row-outer-height / 2
|
|
668
668
|
);
|
|
669
669
|
}
|
|
670
670
|
|
|
@@ -813,6 +813,7 @@ i.wb-icon {
|
|
|
813
813
|
white-space: nowrap;
|
|
814
814
|
// vertical-align: baseline;
|
|
815
815
|
border-radius: 0.5rem;
|
|
816
|
+
pointer-events: none;
|
|
816
817
|
}
|
|
817
818
|
}
|
|
818
819
|
|