wunderbaum 0.1.0 → 0.2.0
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/README.md +1 -1
- package/dist/wunderbaum.css +1 -1
- package/dist/wunderbaum.d.ts +14 -7
- package/dist/wunderbaum.esm.js +95 -30
- package/dist/wunderbaum.esm.min.js +18 -18
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +95 -30
- package/dist/wunderbaum.umd.min.js +20 -20
- package/dist/wunderbaum.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/types.ts +1 -0
- package/src/wb_ext_edit.ts +1 -1
- package/src/wb_ext_filter.ts +0 -4
- package/src/wb_ext_keynav.ts +25 -1
- package/src/wb_node.ts +13 -0
- package/src/wunderbaum.ts +61 -8
package/src/wb_node.ts
CHANGED
|
@@ -1723,6 +1723,19 @@ export class WunderbaumNode {
|
|
|
1723
1723
|
this._createIcon(nodeElem, iconSpan, !expanderSpan);
|
|
1724
1724
|
}
|
|
1725
1725
|
}
|
|
1726
|
+
// Adjust column width
|
|
1727
|
+
if (opts.resizeCols !== false && !this.isColspan()) {
|
|
1728
|
+
const colElems = rowDiv.querySelectorAll("span.wb-col");
|
|
1729
|
+
let idx = 0;
|
|
1730
|
+
let ofs = 0;
|
|
1731
|
+
for (let colDef of this.tree.columns) {
|
|
1732
|
+
const colElem = colElems[idx] as HTMLSpanElement;
|
|
1733
|
+
colElem.style.left = `${ofs}px`;
|
|
1734
|
+
colElem.style.width = `${colDef._widthPx}px`;
|
|
1735
|
+
idx++;
|
|
1736
|
+
ofs += colDef._widthPx!;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1726
1739
|
}
|
|
1727
1740
|
|
|
1728
1741
|
/**
|
package/src/wunderbaum.ts
CHANGED
|
@@ -40,6 +40,8 @@ import {
|
|
|
40
40
|
AddChildrenOptions,
|
|
41
41
|
UpdateColumnsOptions,
|
|
42
42
|
VisitRowsOptions,
|
|
43
|
+
NodeFilterCallback,
|
|
44
|
+
FilterNodesOptions,
|
|
43
45
|
} from "./types";
|
|
44
46
|
import {
|
|
45
47
|
DEFAULT_DEBUGLEVEL,
|
|
@@ -420,6 +422,7 @@ export class Wunderbaum {
|
|
|
420
422
|
return false;
|
|
421
423
|
}
|
|
422
424
|
if (node && info.colIdx === 0 && node.isExpandable()) {
|
|
425
|
+
this._callMethod("edit._stopEditTitle");
|
|
423
426
|
node.setExpanded(!node.isExpanded());
|
|
424
427
|
}
|
|
425
428
|
});
|
|
@@ -439,8 +442,17 @@ export class Wunderbaum {
|
|
|
439
442
|
|
|
440
443
|
util.onEvent(this.element, "focusin focusout", (e) => {
|
|
441
444
|
const flag = e.type === "focusin";
|
|
445
|
+
const targetNode = Wunderbaum.getNode(e)!;
|
|
442
446
|
|
|
443
447
|
this._callEvent("focus", { flag: flag, event: e });
|
|
448
|
+
|
|
449
|
+
if (flag && this.isRowNav() && !this.isEditing()) {
|
|
450
|
+
if ((opts.navigationModeOption as NavModeEnum) === NavModeEnum.row) {
|
|
451
|
+
targetNode?.setActive();
|
|
452
|
+
} else {
|
|
453
|
+
this.setCellNav();
|
|
454
|
+
}
|
|
455
|
+
}
|
|
444
456
|
if (!flag) {
|
|
445
457
|
this._callMethod("edit._stopEditTitle", true, {
|
|
446
458
|
event: e,
|
|
@@ -1717,14 +1729,18 @@ export class Wunderbaum {
|
|
|
1717
1729
|
}
|
|
1718
1730
|
}
|
|
1719
1731
|
}
|
|
1720
|
-
/** Update column headers and width.
|
|
1721
|
-
|
|
1732
|
+
/** Update column headers and width.
|
|
1733
|
+
* Return true if at least one column width changed.
|
|
1734
|
+
*/
|
|
1735
|
+
updateColumns(options?: UpdateColumnsOptions): boolean {
|
|
1722
1736
|
options = Object.assign({ calculateCols: true, updateRows: true }, options);
|
|
1723
1737
|
const defaultMinWidth = 4;
|
|
1724
1738
|
const vpWidth = this.element.clientWidth;
|
|
1725
1739
|
const isGrid = this.isGrid();
|
|
1726
1740
|
// Shorten last column width to avoid h-scrollbar
|
|
1727
1741
|
const FIX_ADJUST_LAST_COL = 2;
|
|
1742
|
+
const columns = this.columns;
|
|
1743
|
+
const col0 = columns[0];
|
|
1728
1744
|
|
|
1729
1745
|
let totalWidth = 0;
|
|
1730
1746
|
let totalWeight = 0;
|
|
@@ -1737,11 +1753,19 @@ export class Wunderbaum {
|
|
|
1737
1753
|
}
|
|
1738
1754
|
|
|
1739
1755
|
if (options.calculateCols) {
|
|
1756
|
+
if (col0.id !== "*") {
|
|
1757
|
+
throw new Error(`First column must have id '*': got '${col0.id}'`);
|
|
1758
|
+
}
|
|
1740
1759
|
// Gather width definitions
|
|
1741
1760
|
this._columnsById = {};
|
|
1742
|
-
for (let col of
|
|
1761
|
+
for (let col of columns) {
|
|
1743
1762
|
this._columnsById[<string>col.id] = col;
|
|
1744
1763
|
let cw = col.width;
|
|
1764
|
+
if (col.id === "*" && col !== col0) {
|
|
1765
|
+
throw new Error(
|
|
1766
|
+
`Column id '*' must be defined only once: '${col.title}'`
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1745
1769
|
|
|
1746
1770
|
if (!cw || cw === "*") {
|
|
1747
1771
|
col._weight = 1.0;
|
|
@@ -1758,14 +1782,16 @@ export class Wunderbaum {
|
|
|
1758
1782
|
}
|
|
1759
1783
|
fixedWidth += px;
|
|
1760
1784
|
} else {
|
|
1761
|
-
util.error(
|
|
1785
|
+
util.error(
|
|
1786
|
+
`Invalid column width: ${cw} (expected string ending with 'px' or number, e.g. "<num>px" or <int>)`
|
|
1787
|
+
);
|
|
1762
1788
|
}
|
|
1763
1789
|
}
|
|
1764
1790
|
// Share remaining space between non-fixed columns
|
|
1765
1791
|
const restPx = Math.max(0, vpWidth - fixedWidth);
|
|
1766
1792
|
let ofsPx = 0;
|
|
1767
1793
|
|
|
1768
|
-
for (let col of
|
|
1794
|
+
for (let col of columns) {
|
|
1769
1795
|
let minWidth: number;
|
|
1770
1796
|
|
|
1771
1797
|
if (col._weight) {
|
|
@@ -1786,7 +1812,7 @@ export class Wunderbaum {
|
|
|
1786
1812
|
col._ofsPx = ofsPx;
|
|
1787
1813
|
ofsPx += col._widthPx!;
|
|
1788
1814
|
}
|
|
1789
|
-
|
|
1815
|
+
columns[columns.length - 1]._widthPx! -= FIX_ADJUST_LAST_COL;
|
|
1790
1816
|
totalWidth = ofsPx - FIX_ADJUST_LAST_COL;
|
|
1791
1817
|
}
|
|
1792
1818
|
// if (this.options.fixedCol) {
|
|
@@ -1806,6 +1832,7 @@ export class Wunderbaum {
|
|
|
1806
1832
|
this._updateRows();
|
|
1807
1833
|
}
|
|
1808
1834
|
}
|
|
1835
|
+
return modified;
|
|
1809
1836
|
}
|
|
1810
1837
|
|
|
1811
1838
|
/** Create/update header markup from `this.columns` definition.
|
|
@@ -1902,9 +1929,9 @@ export class Wunderbaum {
|
|
|
1902
1929
|
}
|
|
1903
1930
|
// console.profile(`_updateViewportImmediately()`)
|
|
1904
1931
|
|
|
1905
|
-
this.updateColumns({ updateRows: false });
|
|
1932
|
+
const modified = this.updateColumns({ updateRows: false });
|
|
1906
1933
|
|
|
1907
|
-
this._updateRows({ newNodesOnly: newNodesOnly });
|
|
1934
|
+
this._updateRows({ newNodesOnly: newNodesOnly && !modified });
|
|
1908
1935
|
|
|
1909
1936
|
// console.profileEnd(`_updateViewportImmediately()`)
|
|
1910
1937
|
|
|
@@ -2281,6 +2308,32 @@ export class Wunderbaum {
|
|
|
2281
2308
|
/* ---------------------------------------------------------------------------
|
|
2282
2309
|
* FILTER
|
|
2283
2310
|
* -------------------------------------------------------------------------*/
|
|
2311
|
+
/**
|
|
2312
|
+
* [ext-filter] Dim or hide nodes.
|
|
2313
|
+
*/
|
|
2314
|
+
filterNodes(
|
|
2315
|
+
filter: string | NodeFilterCallback,
|
|
2316
|
+
options: FilterNodesOptions
|
|
2317
|
+
) {
|
|
2318
|
+
return (this.extensions.filter as FilterExtension).filterNodes(
|
|
2319
|
+
filter,
|
|
2320
|
+
options
|
|
2321
|
+
);
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
/**
|
|
2325
|
+
* [ext-filter] Dim or hide whole branches.
|
|
2326
|
+
*/
|
|
2327
|
+
filterBranches(
|
|
2328
|
+
filter: string | NodeFilterCallback,
|
|
2329
|
+
options: FilterNodesOptions
|
|
2330
|
+
) {
|
|
2331
|
+
return (this.extensions.filter as FilterExtension).filterBranches(
|
|
2332
|
+
filter,
|
|
2333
|
+
options
|
|
2334
|
+
);
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2284
2337
|
/**
|
|
2285
2338
|
* [ext-filter] Reset the filter.
|
|
2286
2339
|
*
|