wunderbaum 0.5.5 → 0.7.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 +12 -22
- package/dist/wunderbaum.d.ts +15 -3
- package/dist/wunderbaum.esm.js +127 -55
- package/dist/wunderbaum.esm.min.js +27 -27
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +127 -55
- package/dist/wunderbaum.umd.min.js +23 -23
- package/dist/wunderbaum.umd.min.js.map +1 -1
- package/package.json +3 -1
- package/src/common.ts +107 -42
- package/src/types.ts +3 -1
- package/src/wb_ext_dnd.ts +5 -1
- package/src/wb_ext_edit.ts +6 -3
- package/src/wb_node.ts +10 -3
package/README.md
CHANGED
|
@@ -9,34 +9,24 @@
|
|
|
9
9
|
|
|
10
10
|
<!-- [](https://travis-ci.com/github/mar10/wunderbaum) -->
|
|
11
11
|
|
|
12
|
-
>
|
|
12
|
+
> A modern tree/treegrid control for the web. <br>
|
|
13
|
+
> Potential successor of [Fancytree](https://github.com/mar10/fancytree).
|
|
14
|
+
|
|
15
|
+
**Status _beta_:<br>API, Markup, Stylesheet, etc. are still subject to change.**
|
|
13
16
|
|
|
14
17
|
[](https://mar10.github.io/wunderbaum/demo/)
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
Depending on the number of columns and nesting depth, Wunderbaum can also be
|
|
21
|
-
used as a **plain tree**, **plain grid**, or a **simple list** control.
|
|
22
|
-
- **Performant** and efficient handling of **big data structures**.
|
|
23
|
-
- Use modern technologies with **zero dependencies** (except for icon fonts you
|
|
24
|
-
may want to use).<br>
|
|
25
|
-
Drop legacy support (IE, jQuery, ...).
|
|
26
|
-
- Built-in support for
|
|
27
|
-
<!-- [aria](https://www.w3.org/TR/wai-aria-1.1/), -->
|
|
28
|
-
[drag and drop](https://mar10.github.io/wunderbaum/#/tutorial/tutorial_dnd),
|
|
29
|
-
[editing](https://mar10.github.io/wunderbaum/#/tutorial/tutorial_edit),
|
|
30
|
-
[filtering](https://mar10.github.io/wunderbaum/#/tutorial/tutorial_filter),
|
|
31
|
-
[multi-selection](https://mar10.github.io/wunderbaum/#/tutorial/tutorial_select).
|
|
32
|
-
- Fully [controllable using the keyboard](https://mar10.github.io/wunderbaum/#/tutorial/tutorial_keyboard).
|
|
19
|
+
- Supports drag and drop, editing, filtering, and multi-selection.
|
|
20
|
+
- Written in TypeScript, transpiled to ES6 (esm & umd).
|
|
21
|
+
- Performant handling of big data structures.
|
|
22
|
+
- Provide an object oriented API.
|
|
33
23
|
- Framework agnostic.
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
<!-- - Decent test coverage. -->
|
|
24
|
+
- Zero dependencies.
|
|
25
|
+
- Keyboard support.
|
|
37
26
|
|
|
38
27
|
### Details
|
|
39
28
|
|
|
40
29
|
- [Online Demo](https://mar10.github.io/wunderbaum/demo/)
|
|
41
|
-
- [
|
|
30
|
+
- [Documentation](https://mar10.github.io/wunderbaum/)
|
|
42
31
|
- [API Reference](https://mar10.github.io/wunderbaum/api/index.html)
|
|
32
|
+
- [Quick Start](https://mar10.github.io/wunderbaum/#/tutorial/quick_start)
|
package/dist/wunderbaum.d.ts
CHANGED
|
@@ -257,7 +257,7 @@ declare module "common" {
|
|
|
257
257
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
258
258
|
* @VERSION, @DATE (https://github.com/mar10/wunderbaum)
|
|
259
259
|
*/
|
|
260
|
-
import { MatcherCallback } from "types";
|
|
260
|
+
import { MatcherCallback, SourceObjectType } from "types";
|
|
261
261
|
import { WunderbaumNode } from "wb_node";
|
|
262
262
|
export const DEFAULT_DEBUGLEVEL = 4;
|
|
263
263
|
/**
|
|
@@ -312,7 +312,16 @@ declare module "common" {
|
|
|
312
312
|
export function makeNodeTitleStartMatcher(s: string): MatcherCallback;
|
|
313
313
|
/** Compare two nodes by title (case-insensitive). */
|
|
314
314
|
export function nodeTitleSorter(a: WunderbaumNode, b: WunderbaumNode): number;
|
|
315
|
-
|
|
315
|
+
/**
|
|
316
|
+
* Decompresses the source data by
|
|
317
|
+
* - converting from 'flat' to 'nested' format
|
|
318
|
+
* - expanding short alias names to long names (if defined in _keyMap)
|
|
319
|
+
* - resolving value indexes to value strings (if defined in _valueMap)
|
|
320
|
+
*
|
|
321
|
+
* @param source - The source object to be decompressed.
|
|
322
|
+
* @returns void
|
|
323
|
+
*/
|
|
324
|
+
export function decompressSourceData(source: SourceObjectType): void;
|
|
316
325
|
}
|
|
317
326
|
declare module "deferred" {
|
|
318
327
|
/*!
|
|
@@ -1201,14 +1210,17 @@ declare module "types" {
|
|
|
1201
1210
|
export type SourceListType = Array<WbNodeData>;
|
|
1202
1211
|
export interface SourceObjectType {
|
|
1203
1212
|
_format?: "nested" | "flat";
|
|
1213
|
+
_version?: number;
|
|
1204
1214
|
types?: NodeTypeDefinitionMap;
|
|
1205
1215
|
columns?: ColumnDefinitionList;
|
|
1206
1216
|
children: SourceListType;
|
|
1207
1217
|
_keyMap?: {
|
|
1208
1218
|
[key: string]: string;
|
|
1209
1219
|
};
|
|
1210
|
-
_typeList?: Array<string>;
|
|
1211
1220
|
_positional?: Array<string>;
|
|
1221
|
+
_valueMap?: {
|
|
1222
|
+
[key: string]: Array<string>;
|
|
1223
|
+
};
|
|
1212
1224
|
}
|
|
1213
1225
|
/** Possible initilization for tree nodes. */
|
|
1214
1226
|
export type SourceType = string | SourceListType | SourceAjaxType | SourceObjectType;
|
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.
|
|
4
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
5
5
|
*/
|
|
6
6
|
/** @module util */
|
|
7
7
|
/** Readable names for `MouseEvent.button` */
|
|
@@ -765,7 +765,7 @@ var util = /*#__PURE__*/Object.freeze({
|
|
|
765
765
|
/*!
|
|
766
766
|
* Wunderbaum - types
|
|
767
767
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
768
|
-
* v0.
|
|
768
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
769
769
|
*/
|
|
770
770
|
/**
|
|
771
771
|
* Possible values for {@link WunderbaumNode.update()} and {@link Wunderbaum.update()}.
|
|
@@ -829,7 +829,7 @@ var NavModeEnum;
|
|
|
829
829
|
/*!
|
|
830
830
|
* Wunderbaum - wb_extension_base
|
|
831
831
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
832
|
-
* v0.
|
|
832
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
833
833
|
*/
|
|
834
834
|
class WunderbaumExtension {
|
|
835
835
|
constructor(tree, id, defaults) {
|
|
@@ -1185,7 +1185,7 @@ function throttle(func, wait = 0, options = {}) {
|
|
|
1185
1185
|
/*!
|
|
1186
1186
|
* Wunderbaum - ext-filter
|
|
1187
1187
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
1188
|
-
* v0.
|
|
1188
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
1189
1189
|
*/
|
|
1190
1190
|
const START_MARKER = "\uFFF7";
|
|
1191
1191
|
const END_MARKER = "\uFFF8";
|
|
@@ -1485,7 +1485,7 @@ function _markFuzzyMatchedChars(text, matches, escapeTitles = true) {
|
|
|
1485
1485
|
/*!
|
|
1486
1486
|
* Wunderbaum - ext-keynav
|
|
1487
1487
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
1488
|
-
* v0.
|
|
1488
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
1489
1489
|
*/
|
|
1490
1490
|
const QUICKSEARCH_DELAY = 500;
|
|
1491
1491
|
class KeynavExtension extends WunderbaumExtension {
|
|
@@ -1831,7 +1831,7 @@ class KeynavExtension extends WunderbaumExtension {
|
|
|
1831
1831
|
/*!
|
|
1832
1832
|
* Wunderbaum - ext-logger
|
|
1833
1833
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
1834
|
-
* v0.
|
|
1834
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
1835
1835
|
*/
|
|
1836
1836
|
class LoggerExtension extends WunderbaumExtension {
|
|
1837
1837
|
constructor(tree) {
|
|
@@ -1873,7 +1873,7 @@ class LoggerExtension extends WunderbaumExtension {
|
|
|
1873
1873
|
/*!
|
|
1874
1874
|
* Wunderbaum - common
|
|
1875
1875
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
1876
|
-
* v0.
|
|
1876
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
1877
1877
|
*/
|
|
1878
1878
|
const DEFAULT_DEBUGLEVEL = 3; // Replaced by rollup script
|
|
1879
1879
|
/**
|
|
@@ -1952,6 +1952,7 @@ const RESERVED_TREE_SOURCE_KEYS = new Set([
|
|
|
1952
1952
|
"_keyMap",
|
|
1953
1953
|
"_positional",
|
|
1954
1954
|
"_typeList",
|
|
1955
|
+
"_valueMap",
|
|
1955
1956
|
"_version",
|
|
1956
1957
|
"children",
|
|
1957
1958
|
"columns",
|
|
@@ -2021,18 +2022,34 @@ function nodeTitleSorter(a, b) {
|
|
|
2021
2022
|
const y = b.title.toLowerCase();
|
|
2022
2023
|
return x === y ? 0 : x > y ? 1 : -1;
|
|
2023
2024
|
}
|
|
2025
|
+
/**
|
|
2026
|
+
* Convert 'flat' to 'nested' format.
|
|
2027
|
+
*
|
|
2028
|
+
* Flat node entry format:
|
|
2029
|
+
* [PARENT_ID, [POSITIONAL_ARGS]]
|
|
2030
|
+
* or
|
|
2031
|
+
* [PARENT_ID, [POSITIONAL_ARGS], {KEY_VALUE_ARGS}]
|
|
2032
|
+
*
|
|
2033
|
+
* 1. Parent-referencing list is converted to a list of nested dicts with
|
|
2034
|
+
* optional `children` properties.
|
|
2035
|
+
* 2. `[POSITIONAL_ARGS]` are added as dict attributes.
|
|
2036
|
+
*/
|
|
2024
2037
|
function unflattenSource(source) {
|
|
2025
2038
|
var _a, _b, _c;
|
|
2026
|
-
const { _format, _keyMap, _positional, children } = source;
|
|
2039
|
+
const { _format, _keyMap = {}, _positional = [], children } = source;
|
|
2027
2040
|
if (_format !== "flat") {
|
|
2028
2041
|
throw new Error(`Expected source._format: "flat", but got ${_format}`);
|
|
2029
2042
|
}
|
|
2030
2043
|
if (_positional && _positional.includes("children")) {
|
|
2031
2044
|
throw new Error(`source._positional must not include "children": ${_positional}`);
|
|
2032
2045
|
}
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2046
|
+
let longToShort = _keyMap;
|
|
2047
|
+
if (_keyMap.t) {
|
|
2048
|
+
// Inverse keyMap was used (pre 0.7.0)
|
|
2049
|
+
// TODO: raise Error on final 1.x release
|
|
2050
|
+
const msg = `source._keyMap maps from long to short since v0.7.0. Flip key/value!`;
|
|
2051
|
+
console.warn(msg); // eslint-disable-line no-console
|
|
2052
|
+
longToShort = {};
|
|
2036
2053
|
for (const [key, value] of Object.entries(_keyMap)) {
|
|
2037
2054
|
longToShort[value] = key;
|
|
2038
2055
|
}
|
|
@@ -2043,16 +2060,16 @@ function unflattenSource(source) {
|
|
|
2043
2060
|
const indexToNodeMap = {};
|
|
2044
2061
|
const keyAttrName = (_a = longToShort["key"]) !== null && _a !== void 0 ? _a : "key";
|
|
2045
2062
|
const childrenAttrName = (_b = longToShort["children"]) !== null && _b !== void 0 ? _b : "children";
|
|
2046
|
-
for (const [index,
|
|
2063
|
+
for (const [index, nodeTuple] of children.entries()) {
|
|
2047
2064
|
// Node entry format:
|
|
2048
2065
|
// [PARENT_ID, [POSITIONAL_ARGS]]
|
|
2049
2066
|
// or
|
|
2050
2067
|
// [PARENT_ID, [POSITIONAL_ARGS], {KEY_VALUE_ARGS}]
|
|
2051
|
-
const [parentId, args, kwargs = {}] =
|
|
2068
|
+
const [parentId, args, kwargs = {}] = nodeTuple;
|
|
2052
2069
|
// Free up some memory as we go
|
|
2053
|
-
|
|
2054
|
-
if (
|
|
2055
|
-
|
|
2070
|
+
nodeTuple[1] = null;
|
|
2071
|
+
if (nodeTuple[2] != null) {
|
|
2072
|
+
nodeTuple[2] = null;
|
|
2056
2073
|
}
|
|
2057
2074
|
// console.log("flatten", parentId, args, kwargs)
|
|
2058
2075
|
// We keep `kwargs` as our new node definition. Then we add all positional
|
|
@@ -2090,56 +2107,96 @@ function unflattenSource(source) {
|
|
|
2090
2107
|
newChildren.push(kwargs);
|
|
2091
2108
|
}
|
|
2092
2109
|
}
|
|
2093
|
-
delete source.children;
|
|
2094
2110
|
source.children = newChildren;
|
|
2095
2111
|
}
|
|
2096
|
-
|
|
2097
|
-
|
|
2112
|
+
/**
|
|
2113
|
+
* Decompresses the source data by
|
|
2114
|
+
* - converting from 'flat' to 'nested' format
|
|
2115
|
+
* - expanding short alias names to long names (if defined in _keyMap)
|
|
2116
|
+
* - resolving value indexes to value strings (if defined in _valueMap)
|
|
2117
|
+
*
|
|
2118
|
+
* @param source - The source object to be decompressed.
|
|
2119
|
+
* @returns void
|
|
2120
|
+
*/
|
|
2121
|
+
function decompressSourceData(source) {
|
|
2122
|
+
let { _format, _version = 1, _keyMap, _valueMap } = source;
|
|
2123
|
+
assert(_version === 1, `Expected file version 1 instead of ${_version}`);
|
|
2124
|
+
let longToShort = _keyMap;
|
|
2125
|
+
let shortToLong = {};
|
|
2126
|
+
if (longToShort) {
|
|
2127
|
+
for (const [key, value] of Object.entries(longToShort)) {
|
|
2128
|
+
shortToLong[value] = key;
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
// Fallback for old format (pre 0.7.0, using _keyMap in reverse direction)
|
|
2132
|
+
// TODO: raise Error on final 1.x release
|
|
2133
|
+
if (longToShort && longToShort.t) {
|
|
2134
|
+
const msg = `source._keyMap maps from long to short since v0.7.0. Flip key/value!`;
|
|
2135
|
+
console.warn(msg); // eslint-disable-line no-console
|
|
2136
|
+
[longToShort, shortToLong] = [shortToLong, longToShort];
|
|
2137
|
+
}
|
|
2138
|
+
// Fallback for old format (pre 0.7.0, using _typeList instead of _valueMap)
|
|
2139
|
+
// TODO: raise Error on final 1.x release
|
|
2140
|
+
if (source._typeList != null) {
|
|
2141
|
+
const msg = `source._typeList is deprecated since v0.7.0: use source._valueMap: {"type": [...]} instead.`;
|
|
2142
|
+
if (_valueMap != null) {
|
|
2143
|
+
throw new Error(msg);
|
|
2144
|
+
}
|
|
2145
|
+
else {
|
|
2146
|
+
console.warn(msg); // eslint-disable-line no-console
|
|
2147
|
+
_valueMap = { type: source._typeList };
|
|
2148
|
+
delete source._typeList;
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2098
2151
|
if (_format === "flat") {
|
|
2099
2152
|
unflattenSource(source);
|
|
2100
2153
|
}
|
|
2101
2154
|
delete source._format;
|
|
2102
2155
|
delete source._version;
|
|
2103
2156
|
delete source._keyMap;
|
|
2104
|
-
delete source.
|
|
2157
|
+
delete source._valueMap;
|
|
2105
2158
|
delete source._positional;
|
|
2106
2159
|
function _iter(childList) {
|
|
2107
2160
|
for (const node of childList) {
|
|
2108
|
-
//
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2161
|
+
// Iterate over a list of names, because we modify inside the loop
|
|
2162
|
+
// (for ... of ... does not allow this)
|
|
2163
|
+
Object.getOwnPropertyNames(node).forEach((propName) => {
|
|
2164
|
+
const value = node[propName];
|
|
2165
|
+
// Replace short names with long names if defined in _keyMap
|
|
2166
|
+
let longName = propName;
|
|
2167
|
+
if (_keyMap && shortToLong[propName] != null) {
|
|
2168
|
+
longName = shortToLong[propName];
|
|
2169
|
+
if (longName !== propName) {
|
|
2170
|
+
node[longName] = value;
|
|
2116
2171
|
delete node[propName];
|
|
2117
2172
|
}
|
|
2118
|
-
});
|
|
2119
|
-
}
|
|
2120
|
-
// `node` now has long attribute names
|
|
2121
|
-
// Resolve node type indexes
|
|
2122
|
-
const type = node.type;
|
|
2123
|
-
if (_typeList && type != null && typeof type === "number") {
|
|
2124
|
-
const newType = _typeList[type];
|
|
2125
|
-
if (newType == null) {
|
|
2126
|
-
throw new Error(`Expected typeList[${type}] entry in [${_typeList}]`);
|
|
2127
2173
|
}
|
|
2128
|
-
|
|
2129
|
-
|
|
2174
|
+
// Replace type index with type name if defined in _valueMap
|
|
2175
|
+
if (_valueMap &&
|
|
2176
|
+
typeof value === "number" &&
|
|
2177
|
+
_valueMap[longName] != null) {
|
|
2178
|
+
const newValue = _valueMap[longName][value];
|
|
2179
|
+
if (newValue == null) {
|
|
2180
|
+
throw new Error(`Expected valueMap[${longName}][${value}] entry in [${_valueMap[longName]}]`);
|
|
2181
|
+
}
|
|
2182
|
+
node[longName] = newValue;
|
|
2183
|
+
}
|
|
2184
|
+
});
|
|
2130
2185
|
// Recursion
|
|
2131
2186
|
if (node.children) {
|
|
2132
2187
|
_iter(node.children);
|
|
2133
2188
|
}
|
|
2134
2189
|
}
|
|
2135
2190
|
}
|
|
2136
|
-
|
|
2191
|
+
if (_keyMap || _valueMap) {
|
|
2192
|
+
_iter(source.children);
|
|
2193
|
+
}
|
|
2137
2194
|
}
|
|
2138
2195
|
|
|
2139
2196
|
/*!
|
|
2140
2197
|
* Wunderbaum - ext-dnd
|
|
2141
2198
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
2142
|
-
* v0.
|
|
2199
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
2143
2200
|
*/
|
|
2144
2201
|
const nodeMimeType = "application/x-wunderbaum-node";
|
|
2145
2202
|
class DndExtension extends WunderbaumExtension {
|
|
@@ -2373,6 +2430,7 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2373
2430
|
* Handle dragstart, drag and dragend events for the source node.
|
|
2374
2431
|
*/
|
|
2375
2432
|
onDragEvent(e) {
|
|
2433
|
+
var _a;
|
|
2376
2434
|
// const tree = this.tree;
|
|
2377
2435
|
const dndOpts = this.treeOpts.dnd;
|
|
2378
2436
|
const srcNode = Wunderbaum.getNode(e);
|
|
@@ -2413,7 +2471,9 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2413
2471
|
}
|
|
2414
2472
|
}
|
|
2415
2473
|
// e.dataTransfer!.setData("text/html", $(node.span).html());
|
|
2416
|
-
e.dataTransfer.
|
|
2474
|
+
if (!((_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.types.includes("text/plain"))) {
|
|
2475
|
+
e.dataTransfer.setData("text/plain", srcNode.title);
|
|
2476
|
+
}
|
|
2417
2477
|
this.srcNode = srcNode;
|
|
2418
2478
|
setTimeout(() => {
|
|
2419
2479
|
// Decouple this call, so the CSS is applied to the node, but not to
|
|
@@ -2539,6 +2599,7 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2539
2599
|
}
|
|
2540
2600
|
else if (e.type === "drop") {
|
|
2541
2601
|
e.stopPropagation(); // prevent browser from opening links?
|
|
2602
|
+
e.preventDefault(); // #69 prevent iOS browser from opening links
|
|
2542
2603
|
this._leaveNode();
|
|
2543
2604
|
const region = this.lastDropRegion;
|
|
2544
2605
|
let nodeData = (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData(nodeMimeType);
|
|
@@ -2559,13 +2620,14 @@ class DndExtension extends WunderbaumExtension {
|
|
|
2559
2620
|
});
|
|
2560
2621
|
}, 10);
|
|
2561
2622
|
}
|
|
2623
|
+
return false;
|
|
2562
2624
|
}
|
|
2563
2625
|
}
|
|
2564
2626
|
|
|
2565
2627
|
/*!
|
|
2566
2628
|
* Wunderbaum - drag_observer
|
|
2567
2629
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
2568
|
-
* v0.
|
|
2630
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
2569
2631
|
*/
|
|
2570
2632
|
/**
|
|
2571
2633
|
* Convert mouse- and touch events to 'dragstart', 'drag', and 'dragstop'.
|
|
@@ -2701,7 +2763,7 @@ class DragObserver {
|
|
|
2701
2763
|
/*!
|
|
2702
2764
|
* Wunderbaum - ext-grid
|
|
2703
2765
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
2704
|
-
* v0.
|
|
2766
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
2705
2767
|
*/
|
|
2706
2768
|
class GridExtension extends WunderbaumExtension {
|
|
2707
2769
|
constructor(tree) {
|
|
@@ -2738,7 +2800,7 @@ class GridExtension extends WunderbaumExtension {
|
|
|
2738
2800
|
/*!
|
|
2739
2801
|
* Wunderbaum - deferred
|
|
2740
2802
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
2741
|
-
* v0.
|
|
2803
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
2742
2804
|
*/
|
|
2743
2805
|
/**
|
|
2744
2806
|
* Implement a ES6 Promise, that exposes a resolve() and reject() method.
|
|
@@ -2791,7 +2853,7 @@ class Deferred {
|
|
|
2791
2853
|
/*!
|
|
2792
2854
|
* Wunderbaum - wunderbaum_node
|
|
2793
2855
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
2794
|
-
* v0.
|
|
2856
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
2795
2857
|
*/
|
|
2796
2858
|
/** WunderbaumNode properties that can be passed with source data.
|
|
2797
2859
|
* (Any other source properties will be stored as `node.data.PROP`.)
|
|
@@ -3586,7 +3648,7 @@ class WunderbaumNode {
|
|
|
3586
3648
|
const format = (_a = source.format) !== null && _a !== void 0 ? _a : "nested";
|
|
3587
3649
|
assert(format === "nested" || format === "flat", `Expected source.format = 'nested' or 'flat': ${format}`);
|
|
3588
3650
|
// Pre-rocess for 'nested' or 'flat' format
|
|
3589
|
-
|
|
3651
|
+
decompressSourceData(source);
|
|
3590
3652
|
assert(source.children, "If `source` is an object, it must have a `children` property");
|
|
3591
3653
|
if (source.types) {
|
|
3592
3654
|
tree.logInfo("Redefine types", source.columns);
|
|
@@ -3671,6 +3733,11 @@ class WunderbaumNode {
|
|
|
3671
3733
|
if (!url) {
|
|
3672
3734
|
// An array or a plain object (that does NOT contain a `.url` property)
|
|
3673
3735
|
// will be treated as native Wunderbaum data
|
|
3736
|
+
if (typeof source.then === "function") {
|
|
3737
|
+
const msg = tree.logTime(`Resolve thenable ${source}`);
|
|
3738
|
+
source = await Promise.resolve(source);
|
|
3739
|
+
tree.logTimeEnd(msg);
|
|
3740
|
+
}
|
|
3674
3741
|
this._loadSourceObject(source);
|
|
3675
3742
|
elapProcess = Date.now() - start;
|
|
3676
3743
|
}
|
|
@@ -3739,7 +3806,8 @@ class WunderbaumNode {
|
|
|
3739
3806
|
return;
|
|
3740
3807
|
}
|
|
3741
3808
|
assert(isArray(source) || (source && source.url), "The lazyLoad event must return a node list, `{url: ...}`, or false.");
|
|
3742
|
-
await this.load(source);
|
|
3809
|
+
await this.load(source);
|
|
3810
|
+
this.setStatus(NodeStatusType.ok);
|
|
3743
3811
|
if (wasExpanded) {
|
|
3744
3812
|
this.expanded = true;
|
|
3745
3813
|
this.tree.update(ChangeType.structure);
|
|
@@ -5118,7 +5186,7 @@ WunderbaumNode.sequence = 0;
|
|
|
5118
5186
|
/*!
|
|
5119
5187
|
* Wunderbaum - ext-edit
|
|
5120
5188
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
5121
|
-
* v0.
|
|
5189
|
+
* v0.7.0, Sat, 09 Dec 2023 13:47:27 GMT (https://github.com/mar10/wunderbaum)
|
|
5122
5190
|
*/
|
|
5123
5191
|
// const START_MARKER = "\uFFF7";
|
|
5124
5192
|
class EditExtension extends WunderbaumExtension {
|
|
@@ -5197,9 +5265,13 @@ class EditExtension extends WunderbaumExtension {
|
|
|
5197
5265
|
init() {
|
|
5198
5266
|
super.init();
|
|
5199
5267
|
onEvent(this.tree.element, "change", //"change input",
|
|
5200
|
-
".contenteditable,input,textarea,select",
|
|
5201
|
-
|
|
5202
|
-
|
|
5268
|
+
".contenteditable,input,textarea,select",
|
|
5269
|
+
// #61: we must not debounce the `change`, event.target may be reset to null
|
|
5270
|
+
// when the debounced handler is called.
|
|
5271
|
+
// (e) => {
|
|
5272
|
+
// this.debouncedOnChange(e);
|
|
5273
|
+
// }
|
|
5274
|
+
(e) => this._onChange(e));
|
|
5203
5275
|
}
|
|
5204
5276
|
/* Called by ext_keynav to pre-process input. */
|
|
5205
5277
|
_preprocessKeyEvent(data) {
|
|
@@ -5414,8 +5486,8 @@ class EditExtension extends WunderbaumExtension {
|
|
|
5414
5486
|
* https://github.com/mar10/wunderbaum
|
|
5415
5487
|
*
|
|
5416
5488
|
* Released under the MIT license.
|
|
5417
|
-
* @version v0.
|
|
5418
|
-
* @date
|
|
5489
|
+
* @version v0.7.0
|
|
5490
|
+
* @date Sat, 09 Dec 2023 13:47:27 GMT
|
|
5419
5491
|
*/
|
|
5420
5492
|
// import "./wunderbaum.scss";
|
|
5421
5493
|
class WbSystemRoot extends WunderbaumNode {
|
|
@@ -7548,7 +7620,7 @@ class Wunderbaum {
|
|
|
7548
7620
|
}
|
|
7549
7621
|
Wunderbaum.sequence = 0;
|
|
7550
7622
|
/** Wunderbaum release version number "MAJOR.MINOR.PATCH". */
|
|
7551
|
-
Wunderbaum.version = "v0.
|
|
7623
|
+
Wunderbaum.version = "v0.7.0"; // Set to semver by 'grunt release'
|
|
7552
7624
|
/** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
|
|
7553
7625
|
Wunderbaum.util = util;
|
|
7554
7626
|
|