wunderbaum 0.3.2 → 0.3.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 +408 -0
- package/dist/wunderbaum.d.ts +8 -8
- package/dist/wunderbaum.esm.js +37 -20
- package/dist/wunderbaum.esm.min.js +16 -16
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +37 -20
- package/dist/wunderbaum.umd.min.js +16 -16
- package/dist/wunderbaum.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/types.ts +30 -9
- package/src/wb_ext_edit.ts +1 -2
- package/src/wb_node.ts +10 -7
- package/src/wb_options.ts +1 -12
- package/src/wunderbaum.scss +145 -74
- package/src/wunderbaum.ts +18 -1
package/src/types.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { WunderbaumNode } from "./wb_node";
|
|
8
8
|
import { Wunderbaum } from "./wunderbaum";
|
|
9
|
+
import { WunderbaumOptions } from "./wb_options";
|
|
9
10
|
|
|
10
11
|
/** Passed to `find...()` methods. Should return true if node matches. */
|
|
11
12
|
export type MatcherCallback = (node: WunderbaumNode) => boolean;
|
|
@@ -17,14 +18,34 @@ export type BoolOptionResolver = (node: WunderbaumNode) => boolean;
|
|
|
17
18
|
export type BoolOrStringOptionResolver = (
|
|
18
19
|
node: WunderbaumNode
|
|
19
20
|
) => boolean | string;
|
|
20
|
-
|
|
21
|
+
/** A callback that receives a node instance and returns an arbitrary value type. */
|
|
21
22
|
export type NodeAnyCallback = (node: WunderbaumNode) => any;
|
|
23
|
+
/** A callback that receives a node instance and returns a string value. */
|
|
22
24
|
export type NodeStringCallback = (node: WunderbaumNode) => string;
|
|
23
|
-
|
|
24
|
-
export type NodeVisitResponse = "skip" | boolean | void;
|
|
25
|
+
/** A callback that receives a node instance and returns an iteration modifier. */
|
|
25
26
|
export type NodeVisitCallback = (node: WunderbaumNode) => NodeVisitResponse;
|
|
27
|
+
/** A callback that receives a node instance and returns a string value. */
|
|
28
|
+
export type NodeVisitResponse = "skip" | boolean | void;
|
|
29
|
+
/** A callback that receives a node-data dictionary and a node instance and returns an iteration modifier. */
|
|
30
|
+
export type NodeToDictCallback = (
|
|
31
|
+
dict: WbNodeData,
|
|
32
|
+
node: WunderbaumNode
|
|
33
|
+
) => NodeVisitResponse;
|
|
26
34
|
|
|
27
35
|
// type WithWildcards<T> = T & { [key: string]: unknown };
|
|
36
|
+
/** A plain object (dictionary) that represents a node instance. */
|
|
37
|
+
export interface WbNodeData {
|
|
38
|
+
title: string;
|
|
39
|
+
key?: string;
|
|
40
|
+
refKey?: string;
|
|
41
|
+
expanded?: boolean;
|
|
42
|
+
selected?: boolean;
|
|
43
|
+
checkbox?: boolean | string;
|
|
44
|
+
colspan?: boolean;
|
|
45
|
+
children?: Array<WbNodeData>;
|
|
46
|
+
treeId?: string;
|
|
47
|
+
// ...any?: Any;
|
|
48
|
+
}
|
|
28
49
|
|
|
29
50
|
/* -----------------------------------------------------------------------------
|
|
30
51
|
* EVENT CALLBACK TYPES
|
|
@@ -99,7 +120,7 @@ export interface WbKeydownEventType extends WbTreeEventType {
|
|
|
99
120
|
event: KeyboardEvent;
|
|
100
121
|
node: WunderbaumNode;
|
|
101
122
|
info: WbEventInfo;
|
|
102
|
-
/** Canical name of the key including modifiers. @see {@link eventToString} */
|
|
123
|
+
/** Canical name of the key including modifiers. @see {@link util.eventToString} */
|
|
103
124
|
eventName: string;
|
|
104
125
|
}
|
|
105
126
|
|
|
@@ -168,7 +189,7 @@ export type NodeTypeDefinitionMap = { [type: string]: NodeTypeDefinition };
|
|
|
168
189
|
|
|
169
190
|
/**
|
|
170
191
|
* Column type definitions.
|
|
171
|
-
* @see {@link
|
|
192
|
+
* @see {@link Wunderbaum.columns}
|
|
172
193
|
*/
|
|
173
194
|
export interface ColumnDefinition {
|
|
174
195
|
/** Column ID as defined in `tree.columns` definition ("*" for title column). */
|
|
@@ -380,7 +401,7 @@ export interface MakeVisibleOptions {
|
|
|
380
401
|
noEvents?: boolean;
|
|
381
402
|
}
|
|
382
403
|
|
|
383
|
-
/** Possible values for {@link
|
|
404
|
+
/** Possible values for {@link WunderbaumNode.navigate()}. */
|
|
384
405
|
export interface NavigateOptions {
|
|
385
406
|
/** Activate the new node (otherwise focus only). @default true */
|
|
386
407
|
activate?: boolean;
|
|
@@ -406,7 +427,7 @@ export interface RenderOptions {
|
|
|
406
427
|
resizeCols?: boolean;
|
|
407
428
|
}
|
|
408
429
|
|
|
409
|
-
/** Possible values for {@link scrollIntoView()} `options` argument. */
|
|
430
|
+
/** Possible values for {@link WunderbaumNode.scrollIntoView()} `options` argument. */
|
|
410
431
|
export interface ScrollIntoViewOptions {
|
|
411
432
|
/** Do not animate (currently not implemented). @default false */
|
|
412
433
|
noAnimation?: boolean;
|
|
@@ -436,13 +457,13 @@ export interface SetActiveOptions {
|
|
|
436
457
|
focusTree?: boolean;
|
|
437
458
|
/** Optional original event that will be passed to the (de)activate handler. */
|
|
438
459
|
event?: Event;
|
|
439
|
-
/** Call {@link setColumn}. */
|
|
460
|
+
/** Call {@link Wunderbaum.setColumn}. */
|
|
440
461
|
colIdx?: number;
|
|
441
462
|
}
|
|
442
463
|
|
|
443
464
|
/** Possible values for {@link WunderbaumNode.setExpanded()} `options` argument. */
|
|
444
465
|
export interface SetExpandedOptions {
|
|
445
|
-
/** Ignore {@link minExpandLevel}. @default false */
|
|
466
|
+
/** Ignore {@link WunderbaumOptions.minExpandLevel}. @default false */
|
|
446
467
|
force?: boolean;
|
|
447
468
|
/** Immediately update viewport (async otherwise). @default false */
|
|
448
469
|
immediate?: boolean;
|
package/src/wb_ext_edit.ts
CHANGED
|
@@ -17,8 +17,7 @@ import {
|
|
|
17
17
|
} from "./util";
|
|
18
18
|
import { debounce } from "./debounce";
|
|
19
19
|
import { WunderbaumNode } from "./wb_node";
|
|
20
|
-
import { InsertNodeType } from "./types";
|
|
21
|
-
import { WbNodeData } from "./wb_options";
|
|
20
|
+
import { InsertNodeType, WbNodeData } from "./types";
|
|
22
21
|
|
|
23
22
|
// const START_MARKER = "\uFFF7";
|
|
24
23
|
|
package/src/wb_node.ts
CHANGED
|
@@ -31,6 +31,8 @@ import {
|
|
|
31
31
|
SetSelectedOptions,
|
|
32
32
|
SetStatusOptions,
|
|
33
33
|
SortCallback,
|
|
34
|
+
NodeToDictCallback,
|
|
35
|
+
WbNodeData,
|
|
34
36
|
} from "./types";
|
|
35
37
|
import {
|
|
36
38
|
iconMap,
|
|
@@ -45,7 +47,6 @@ import {
|
|
|
45
47
|
nodeTitleSorter,
|
|
46
48
|
} from "./common";
|
|
47
49
|
import { Deferred } from "./deferred";
|
|
48
|
-
import { WbNodeData } from "./wb_options";
|
|
49
50
|
|
|
50
51
|
/** Top-level properties that can be passed with `data`. */
|
|
51
52
|
const NODE_PROPS = new Set<string>([
|
|
@@ -330,7 +331,7 @@ export class WunderbaumNode {
|
|
|
330
331
|
*
|
|
331
332
|
* This a convenience function that calls addChildren()
|
|
332
333
|
*
|
|
333
|
-
* @param
|
|
334
|
+
* @param nodeData node definition
|
|
334
335
|
* @param [mode=child] 'before', 'after', 'firstChild', or 'child' ('over' is a synonym for 'child')
|
|
335
336
|
* @returns new node
|
|
336
337
|
*/
|
|
@@ -1857,9 +1858,9 @@ export class WunderbaumNode {
|
|
|
1857
1858
|
* modifications.
|
|
1858
1859
|
* Return `false` to ignore this node or `"skip"` to include this node
|
|
1859
1860
|
* without its children.
|
|
1860
|
-
* @
|
|
1861
|
+
* @see {@link Wunderbaum.toDictArray}.
|
|
1861
1862
|
*/
|
|
1862
|
-
toDict(recursive = false, callback?:
|
|
1863
|
+
toDict(recursive = false, callback?: NodeToDictCallback): WbNodeData {
|
|
1863
1864
|
const dict: any = {};
|
|
1864
1865
|
|
|
1865
1866
|
NODE_ATTRS.forEach((propName: string) => {
|
|
@@ -1883,7 +1884,8 @@ export class WunderbaumNode {
|
|
|
1883
1884
|
if (callback) {
|
|
1884
1885
|
const res = callback(dict, this);
|
|
1885
1886
|
if (res === false) {
|
|
1886
|
-
|
|
1887
|
+
// Note: a return value of `false` is only used internally
|
|
1888
|
+
return <any>false; // Don't include this node nor its children
|
|
1887
1889
|
}
|
|
1888
1890
|
if (res === "skip") {
|
|
1889
1891
|
recursive = false; // Include this node, but not the children
|
|
@@ -1895,7 +1897,8 @@ export class WunderbaumNode {
|
|
|
1895
1897
|
for (let i = 0, l = this.children!.length; i < l; i++) {
|
|
1896
1898
|
const node = this.children![i];
|
|
1897
1899
|
if (!node.isStatusNode()) {
|
|
1898
|
-
|
|
1900
|
+
// Note: a return value of `false` is only used internally
|
|
1901
|
+
const res = <any>node.toDict(true, callback);
|
|
1899
1902
|
if (res !== false) {
|
|
1900
1903
|
dict.children.push(res);
|
|
1901
1904
|
}
|
|
@@ -2281,7 +2284,7 @@ export class WunderbaumNode {
|
|
|
2281
2284
|
* @param {function} callback the callback function.
|
|
2282
2285
|
* Return false to stop iteration, return "skip" to skip this node and
|
|
2283
2286
|
* its children only.
|
|
2284
|
-
* @see {@link WunderbaumNode
|
|
2287
|
+
* @see {@link IterableIterator<WunderbaumNode>}, {@link Wunderbaum.visit}.
|
|
2285
2288
|
*/
|
|
2286
2289
|
visit(
|
|
2287
2290
|
callback: NodeVisitCallback,
|
package/src/wb_options.ts
CHANGED
|
@@ -18,24 +18,13 @@ import {
|
|
|
18
18
|
WbErrorEventType,
|
|
19
19
|
WbInitEventType,
|
|
20
20
|
WbKeydownEventType,
|
|
21
|
+
WbNodeData,
|
|
21
22
|
WbNodeEventType,
|
|
22
23
|
WbReceiveEventType,
|
|
23
24
|
WbRenderEventType,
|
|
24
25
|
WbTreeEventType,
|
|
25
26
|
} from "./types";
|
|
26
27
|
|
|
27
|
-
export interface WbNodeData {
|
|
28
|
-
title: string;
|
|
29
|
-
key?: string;
|
|
30
|
-
refKey?: string;
|
|
31
|
-
expanded?: boolean;
|
|
32
|
-
selected?: boolean;
|
|
33
|
-
checkbox?: boolean | string;
|
|
34
|
-
colspan?: boolean;
|
|
35
|
-
children?: Array<WbNodeData>;
|
|
36
|
-
// ...any?: Any;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
28
|
/**
|
|
40
29
|
* Available options for [[Wunderbaum]].
|
|
41
30
|
*
|