wunderbaum 0.12.1 → 0.13.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/dist/wunderbaum.css +9 -0
- package/dist/wunderbaum.css.map +1 -1
- package/dist/wunderbaum.d.ts +147 -44
- package/dist/wunderbaum.esm.js +353 -187
- package/dist/wunderbaum.esm.min.js +26 -26
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +353 -187
- package/dist/wunderbaum.umd.min.js +29 -29
- package/dist/wunderbaum.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/common.ts +27 -3
- package/src/types.ts +115 -12
- package/src/util.ts +0 -13
- package/src/wb_ext_edit.ts +1 -1
- package/src/wb_ext_filter.ts +117 -42
- package/src/wb_extension_base.ts +3 -2
- package/src/wb_node.ts +24 -96
- package/src/wb_options.ts +6 -12
- package/src/wunderbaum.scss +9 -1
- package/src/wunderbaum.ts +264 -40
package/src/wb_node.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
MakeVisibleOptions,
|
|
22
22
|
MatcherCallback,
|
|
23
23
|
NavigateOptions,
|
|
24
|
+
NavigationType,
|
|
24
25
|
NodeAnyCallback,
|
|
25
26
|
NodeStatusType,
|
|
26
27
|
NodeStringCallback,
|
|
@@ -46,7 +47,7 @@ import {
|
|
|
46
47
|
import {
|
|
47
48
|
decompressSourceData,
|
|
48
49
|
ICON_WIDTH,
|
|
49
|
-
|
|
50
|
+
KEY_TO_NAVIGATION_MAP,
|
|
50
51
|
makeNodeTitleMatcher,
|
|
51
52
|
nodeTitleSorter,
|
|
52
53
|
RESERVED_TREE_SOURCE_KEYS,
|
|
@@ -171,7 +172,11 @@ export class WunderbaumNode {
|
|
|
171
172
|
_partsel = false;
|
|
172
173
|
_partload = false;
|
|
173
174
|
// --- FILTER ---
|
|
174
|
-
|
|
175
|
+
/**
|
|
176
|
+
* > 0 if matched (-1 to keep system nodes visible);
|
|
177
|
+
* Added and removed by filter code.
|
|
178
|
+
*/
|
|
179
|
+
public match?: number;
|
|
175
180
|
public subMatchCount?: number = 0;
|
|
176
181
|
// public subMatchBadge?: HTMLElement;
|
|
177
182
|
/** @internal */
|
|
@@ -656,7 +661,7 @@ export class WunderbaumNode {
|
|
|
656
661
|
*
|
|
657
662
|
* @see {@link Wunderbaum.findRelatedNode|tree.findRelatedNode()}
|
|
658
663
|
*/
|
|
659
|
-
findRelatedNode(where:
|
|
664
|
+
findRelatedNode(where: NavigationType, includeHidden = false) {
|
|
660
665
|
return this.tree.findRelatedNode(this, where, includeHidden);
|
|
661
666
|
}
|
|
662
667
|
|
|
@@ -987,7 +992,7 @@ export class WunderbaumNode {
|
|
|
987
992
|
return other && other.parent === this;
|
|
988
993
|
}
|
|
989
994
|
|
|
990
|
-
/**
|
|
995
|
+
/** Return true if this node is partially loaded. @experimental */
|
|
991
996
|
isPartload(): boolean {
|
|
992
997
|
return !!this._partload;
|
|
993
998
|
}
|
|
@@ -1509,12 +1514,12 @@ export class WunderbaumNode {
|
|
|
1509
1514
|
* e.g. `ArrowLeft` = 'left'.
|
|
1510
1515
|
* @param options
|
|
1511
1516
|
*/
|
|
1512
|
-
async navigate(where: string, options?: NavigateOptions) {
|
|
1517
|
+
async navigate(where: NavigationType | string, options?: NavigateOptions) {
|
|
1513
1518
|
// Allow to pass 'ArrowLeft' instead of 'left'
|
|
1514
|
-
|
|
1519
|
+
const navType = (KEY_TO_NAVIGATION_MAP[where] ?? where) as NavigationType;
|
|
1515
1520
|
|
|
1516
1521
|
// Otherwise activate or focus the related node
|
|
1517
|
-
const node = this.findRelatedNode(
|
|
1522
|
+
const node = this.findRelatedNode(navType);
|
|
1518
1523
|
if (!node) {
|
|
1519
1524
|
this.logWarn(`Could not find related node '${where}'.`);
|
|
1520
1525
|
return Promise.resolve(this);
|
|
@@ -1618,91 +1623,19 @@ export class WunderbaumNode {
|
|
|
1618
1623
|
}
|
|
1619
1624
|
|
|
1620
1625
|
protected _createIcon(
|
|
1621
|
-
iconMap: any,
|
|
1622
1626
|
parentElem: HTMLElement,
|
|
1623
1627
|
replaceChild: HTMLElement | null,
|
|
1624
1628
|
showLoading: boolean
|
|
1625
1629
|
): HTMLElement | null {
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
} else if (this._isLoading && showLoading) {
|
|
1631
|
-
// Status nodes, or nodes without expander (< minExpandLevel) should
|
|
1632
|
-
// display the 'loading' status with the i.wb-icon span
|
|
1633
|
-
icon = iconMap.loading;
|
|
1634
|
-
}
|
|
1635
|
-
if (icon === false) {
|
|
1636
|
-
return null; // explicitly disabled: don't try default icons
|
|
1637
|
-
}
|
|
1638
|
-
if (typeof icon === "string") {
|
|
1639
|
-
// Callback returned an icon definition
|
|
1640
|
-
// icon = icon.trim()
|
|
1641
|
-
} else if (this.statusNodeType) {
|
|
1642
|
-
icon = (<any>iconMap)[this.statusNodeType];
|
|
1643
|
-
} else if (this.expanded) {
|
|
1644
|
-
icon = iconMap.folderOpen;
|
|
1645
|
-
} else if (this.children) {
|
|
1646
|
-
icon = iconMap.folder;
|
|
1647
|
-
} else if (this.lazy) {
|
|
1648
|
-
icon = iconMap.folderLazy;
|
|
1649
|
-
} else {
|
|
1650
|
-
icon = iconMap.doc;
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
// this.log("_createIcon: " + icon);
|
|
1654
|
-
if (!icon) {
|
|
1655
|
-
iconSpan = document.createElement("i");
|
|
1656
|
-
iconSpan.className = "wb-icon";
|
|
1657
|
-
} else if (icon.indexOf("<") >= 0) {
|
|
1658
|
-
// HTML
|
|
1659
|
-
iconSpan = util.elemFromHtml(icon);
|
|
1660
|
-
} else if (TEST_IMG.test(icon)) {
|
|
1661
|
-
// Image URL
|
|
1662
|
-
iconSpan = util.elemFromHtml(
|
|
1663
|
-
`<i class="wb-icon" style="background-image: url('${icon}');">`
|
|
1664
|
-
);
|
|
1665
|
-
} else {
|
|
1666
|
-
// Class name
|
|
1667
|
-
iconSpan = document.createElement("i");
|
|
1668
|
-
iconSpan.className = "wb-icon " + icon;
|
|
1669
|
-
}
|
|
1670
|
-
if (replaceChild) {
|
|
1671
|
-
parentElem.replaceChild(iconSpan, replaceChild);
|
|
1672
|
-
} else {
|
|
1673
|
-
parentElem.appendChild(iconSpan);
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
// Event handler `tree.iconBadge` can return a badge text or HTMLSpanElement
|
|
1677
|
-
|
|
1678
|
-
const cbRes = this._callEvent("iconBadge", { iconSpan: iconSpan });
|
|
1679
|
-
let badge = null;
|
|
1680
|
-
if (cbRes != null && cbRes !== false) {
|
|
1681
|
-
let classes = "";
|
|
1682
|
-
let tooltip = "";
|
|
1683
|
-
if (util.isPlainObject(cbRes)) {
|
|
1684
|
-
badge = "" + cbRes.badge;
|
|
1685
|
-
classes = cbRes.badgeClass ? " " + cbRes.badgeClass : "";
|
|
1686
|
-
tooltip = cbRes.badgeTooltip ? ` title="${cbRes.badgeTooltip}"` : "";
|
|
1687
|
-
} else if (typeof cbRes === "number") {
|
|
1688
|
-
badge = "" + cbRes;
|
|
1630
|
+
const iconElem = this.tree._createNodeIcon(this, showLoading, true);
|
|
1631
|
+
if (iconElem) {
|
|
1632
|
+
if (replaceChild) {
|
|
1633
|
+
parentElem.replaceChild(iconElem, replaceChild);
|
|
1689
1634
|
} else {
|
|
1690
|
-
|
|
1691
|
-
}
|
|
1692
|
-
if (typeof badge === "string") {
|
|
1693
|
-
badge = util.elemFromHtml(
|
|
1694
|
-
`<span class="wb-badge${classes}"${tooltip}>${util.escapeHtml(
|
|
1695
|
-
badge
|
|
1696
|
-
)}</span>`
|
|
1697
|
-
);
|
|
1698
|
-
}
|
|
1699
|
-
if (badge) {
|
|
1700
|
-
iconSpan.append(<HTMLSpanElement>badge);
|
|
1635
|
+
parentElem.appendChild(iconElem);
|
|
1701
1636
|
}
|
|
1702
1637
|
}
|
|
1703
|
-
|
|
1704
|
-
// this.log("_createIcon: ", iconSpan);
|
|
1705
|
-
return iconSpan;
|
|
1638
|
+
return iconElem;
|
|
1706
1639
|
}
|
|
1707
1640
|
|
|
1708
1641
|
/**
|
|
@@ -1773,12 +1706,7 @@ export class WunderbaumNode {
|
|
|
1773
1706
|
|
|
1774
1707
|
// Render the icon (show a 'loading' icon if we do not have an expander that
|
|
1775
1708
|
// we would prefer).
|
|
1776
|
-
const iconSpan = this._createIcon(
|
|
1777
|
-
tree.iconMap,
|
|
1778
|
-
nodeElem,
|
|
1779
|
-
null,
|
|
1780
|
-
!expanderSpan
|
|
1781
|
-
);
|
|
1709
|
+
const iconSpan = this._createIcon(nodeElem, null, !expanderSpan);
|
|
1782
1710
|
if (iconSpan) {
|
|
1783
1711
|
ofsTitlePx += ICON_WIDTH;
|
|
1784
1712
|
}
|
|
@@ -2029,7 +1957,7 @@ export class WunderbaumNode {
|
|
|
2029
1957
|
// Update icon (if not opts.isNew, which would rebuild markup anyway)
|
|
2030
1958
|
const iconSpan = nodeElem.querySelector("i.wb-icon") as HTMLElement;
|
|
2031
1959
|
if (iconSpan) {
|
|
2032
|
-
this._createIcon(
|
|
1960
|
+
this._createIcon(nodeElem, iconSpan, !expanderSpan);
|
|
2033
1961
|
}
|
|
2034
1962
|
}
|
|
2035
1963
|
// Adjust column width
|
|
@@ -2641,7 +2569,7 @@ export class WunderbaumNode {
|
|
|
2641
2569
|
);
|
|
2642
2570
|
|
|
2643
2571
|
statusNode = this.addNode(data, "prependChild");
|
|
2644
|
-
statusNode.match =
|
|
2572
|
+
statusNode.match = -1; // Mark as 'match' to avoid hiding
|
|
2645
2573
|
tree.update(ChangeType.structure);
|
|
2646
2574
|
|
|
2647
2575
|
return statusNode;
|
|
@@ -2664,7 +2592,7 @@ export class WunderbaumNode {
|
|
|
2664
2592
|
_setStatusNode({
|
|
2665
2593
|
statusNodeType: status,
|
|
2666
2594
|
title:
|
|
2667
|
-
tree.options.strings
|
|
2595
|
+
tree.options.strings!.loading +
|
|
2668
2596
|
(message ? " (" + message + ")" : ""),
|
|
2669
2597
|
checkbox: false,
|
|
2670
2598
|
colspan: true,
|
|
@@ -2677,7 +2605,7 @@ export class WunderbaumNode {
|
|
|
2677
2605
|
_setStatusNode({
|
|
2678
2606
|
statusNodeType: status,
|
|
2679
2607
|
title:
|
|
2680
|
-
tree.options.strings
|
|
2608
|
+
tree.options.strings!.loadError +
|
|
2681
2609
|
(message ? " (" + message + ")" : ""),
|
|
2682
2610
|
checkbox: false,
|
|
2683
2611
|
colspan: true,
|
|
@@ -2690,7 +2618,7 @@ export class WunderbaumNode {
|
|
|
2690
2618
|
case "noData":
|
|
2691
2619
|
_setStatusNode({
|
|
2692
2620
|
statusNodeType: status,
|
|
2693
|
-
title: message || tree.options.strings
|
|
2621
|
+
title: message || tree.options.strings!.noData,
|
|
2694
2622
|
checkbox: false,
|
|
2695
2623
|
colspan: true,
|
|
2696
2624
|
tooltip: details,
|
package/src/wb_options.ts
CHANGED
|
@@ -13,12 +13,14 @@ import {
|
|
|
13
13
|
DynamicIconOption,
|
|
14
14
|
EditOptionsType,
|
|
15
15
|
FilterOptionsType,
|
|
16
|
+
IconMapType,
|
|
16
17
|
// GridOptionsType,
|
|
17
18
|
// KeynavOptionsType,
|
|
18
19
|
// LoggerOptionsType,
|
|
19
20
|
NavModeEnum,
|
|
20
21
|
NodeTypeDefinitionMap,
|
|
21
22
|
SelectModeType,
|
|
23
|
+
TranslationsType,
|
|
22
24
|
WbActivateEventType,
|
|
23
25
|
WbButtonClickEventType,
|
|
24
26
|
WbCancelableEventResultType,
|
|
@@ -113,16 +115,8 @@ export interface WunderbaumOptions {
|
|
|
113
115
|
skeleton?: boolean;
|
|
114
116
|
/**
|
|
115
117
|
* Translation map for some system messages.
|
|
116
|
-
* Default:
|
|
117
|
-
* ```js
|
|
118
|
-
* strings: {
|
|
119
|
-
* loading: "Loading...",
|
|
120
|
-
* loadError: "Error",
|
|
121
|
-
* noData: "No data",
|
|
122
|
-
* }
|
|
123
|
-
* ```
|
|
124
118
|
*/
|
|
125
|
-
strings?:
|
|
119
|
+
strings?: TranslationsType;
|
|
126
120
|
/**
|
|
127
121
|
* 0:quiet, 1:errors, 2:warnings, 3:info, 4:verbose
|
|
128
122
|
* Default: 3 (4 in local debug environment)
|
|
@@ -157,7 +151,7 @@ export interface WunderbaumOptions {
|
|
|
157
151
|
* Note: the icon font must be loaded separately.
|
|
158
152
|
* Default: "bootstrap"
|
|
159
153
|
*/
|
|
160
|
-
iconMap?: string |
|
|
154
|
+
iconMap?: string | IconMapType;
|
|
161
155
|
/**
|
|
162
156
|
* Collapse siblings when a node is expanded.
|
|
163
157
|
* Default: false
|
|
@@ -178,10 +172,10 @@ export interface WunderbaumOptions {
|
|
|
178
172
|
*/
|
|
179
173
|
adjustHeight?: boolean;
|
|
180
174
|
/**
|
|
181
|
-
* HTMLElement that receives the top nodes breadcrumb.
|
|
175
|
+
* HTMLElement or selector that receives the top nodes breadcrumb.
|
|
182
176
|
* Default: undefined
|
|
183
177
|
*/
|
|
184
|
-
connectTopBreadcrumb?: HTMLElement;
|
|
178
|
+
connectTopBreadcrumb?: HTMLElement | string;
|
|
185
179
|
/**
|
|
186
180
|
* Default: NavModeEnum.startRow
|
|
187
181
|
*/
|
package/src/wunderbaum.scss
CHANGED
|
@@ -759,6 +759,10 @@ div.wunderbaum {
|
|
|
759
759
|
}
|
|
760
760
|
|
|
761
761
|
/* --- TOOL CLASSES --- */
|
|
762
|
+
a.wb-breadcrumb {
|
|
763
|
+
cursor: pointer;
|
|
764
|
+
text-decoration: none;
|
|
765
|
+
}
|
|
762
766
|
|
|
763
767
|
.wb-helper-center {
|
|
764
768
|
text-align: center;
|
|
@@ -797,7 +801,11 @@ div.wunderbaum {
|
|
|
797
801
|
// .wb-helper-edit-text {
|
|
798
802
|
// // content-editable: true;
|
|
799
803
|
// }
|
|
800
|
-
|
|
804
|
+
button.wb-filter-hide {
|
|
805
|
+
font-weight: bolder;
|
|
806
|
+
// background-color: var(--wb-active-color);
|
|
807
|
+
// -webkit-appearance: auto; /* Removes default Safari styles */
|
|
808
|
+
}
|
|
801
809
|
/* RTL support */
|
|
802
810
|
.wb-helper-start,
|
|
803
811
|
.wb-helper-start > input {
|