wunderbaum 0.6.0 → 0.8.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 +11 -11
- package/dist/wunderbaum.css +4 -1
- package/dist/wunderbaum.css.map +1 -1
- package/dist/wunderbaum.d.ts +365 -224
- package/dist/wunderbaum.esm.js +796 -557
- package/dist/wunderbaum.esm.min.js +29 -29
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +7785 -7546
- package/dist/wunderbaum.umd.min.js +69 -70
- package/dist/wunderbaum.umd.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common.ts +108 -43
- package/src/deferred.ts +9 -9
- package/src/types.ts +123 -37
- package/src/util.ts +73 -33
- package/src/wb_ext_dnd.ts +3 -1
- package/src/wb_ext_edit.ts +90 -58
- package/src/wb_ext_filter.ts +5 -1
- package/src/wb_ext_keynav.ts +20 -9
- package/src/wb_node.ts +83 -33
- package/src/wb_options.ts +1 -1
- package/src/wunderbaum.scss +7 -1
- package/src/wunderbaum.ts +114 -55
package/dist/wunderbaum.d.ts
CHANGED
|
@@ -1,3 +1,137 @@
|
|
|
1
|
+
declare module "debounce" {
|
|
2
|
+
/*!
|
|
3
|
+
* debounce & throttle, taken from https://github.com/lodash/lodash v4.17.21
|
|
4
|
+
* MIT License: https://raw.githubusercontent.com/lodash/lodash/4.17.21-npm/LICENSE
|
|
5
|
+
* Modified for TypeScript type annotations.
|
|
6
|
+
*/
|
|
7
|
+
type Procedure = (...args: any[]) => any;
|
|
8
|
+
type DebounceOptions = {
|
|
9
|
+
leading?: boolean;
|
|
10
|
+
maxWait?: number;
|
|
11
|
+
trailing?: boolean;
|
|
12
|
+
};
|
|
13
|
+
type ThrottleOptions = {
|
|
14
|
+
leading?: boolean;
|
|
15
|
+
trailing?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export interface DebouncedFunction<F extends Procedure> {
|
|
18
|
+
(this: ThisParameterType<F>, ...args: Parameters<F>): ReturnType<F>;
|
|
19
|
+
cancel: () => void;
|
|
20
|
+
flush: () => any;
|
|
21
|
+
pending: () => boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
25
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
26
|
+
* invoked, or until the next browser frame is drawn. The debounced function
|
|
27
|
+
* comes with a `cancel` method to cancel delayed `func` invocations and a
|
|
28
|
+
* `flush` method to immediately invoke them. Provide `options` to indicate
|
|
29
|
+
* whether `func` should be invoked on the leading and/or trailing edge of the
|
|
30
|
+
* `wait` timeout. The `func` is invoked with the last arguments provided to the
|
|
31
|
+
* debounced function. Subsequent calls to the debounced function return the
|
|
32
|
+
* result of the last `func` invocation.
|
|
33
|
+
*
|
|
34
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
35
|
+
* invoked on the trailing edge of the timeout only if the debounced function
|
|
36
|
+
* is invoked more than once during the `wait` timeout.
|
|
37
|
+
*
|
|
38
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
39
|
+
* until the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
40
|
+
*
|
|
41
|
+
* If `wait` is omitted in an environment with `requestAnimationFrame`, `func`
|
|
42
|
+
* invocation will be deferred until the next frame is drawn (typically about
|
|
43
|
+
* 16ms).
|
|
44
|
+
*
|
|
45
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
46
|
+
* for details over the differences between `debounce` and `throttle`.
|
|
47
|
+
*
|
|
48
|
+
* @since 0.1.0
|
|
49
|
+
* @category Function
|
|
50
|
+
* @param {Function} func The function to debounce.
|
|
51
|
+
* @param {number} [wait=0]
|
|
52
|
+
* The number of milliseconds to delay; if omitted, `requestAnimationFrame` is
|
|
53
|
+
* used (if available).
|
|
54
|
+
* @param {Object} [options={}] The options object.
|
|
55
|
+
* @param {boolean} [options.leading=false]
|
|
56
|
+
* Specify invoking on the leading edge of the timeout.
|
|
57
|
+
* @param {number} [options.maxWait]
|
|
58
|
+
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
59
|
+
* @param {boolean} [options.trailing=true]
|
|
60
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
61
|
+
* @returns {Function} Returns the new debounced function.
|
|
62
|
+
* @example
|
|
63
|
+
*
|
|
64
|
+
* // Avoid costly calculations while the window size is in flux.
|
|
65
|
+
* jQuery(window).on('resize', debounce(calculateLayout, 150))
|
|
66
|
+
*
|
|
67
|
+
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
68
|
+
* jQuery(element).on('click', debounce(sendMail, 300, {
|
|
69
|
+
* 'leading': true,
|
|
70
|
+
* 'trailing': false
|
|
71
|
+
* }))
|
|
72
|
+
*
|
|
73
|
+
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
74
|
+
* const debounced = debounce(batchLog, 250, { 'maxWait': 1000 })
|
|
75
|
+
* const source = new EventSource('/stream')
|
|
76
|
+
* jQuery(source).on('message', debounced)
|
|
77
|
+
*
|
|
78
|
+
* // Cancel the trailing debounced invocation.
|
|
79
|
+
* jQuery(window).on('popstate', debounced.cancel)
|
|
80
|
+
*
|
|
81
|
+
* // Check for pending invocations.
|
|
82
|
+
* const status = debounced.pending() ? "Pending..." : "Ready"
|
|
83
|
+
*/
|
|
84
|
+
export function debounce<F extends Procedure>(func: F, wait?: number, options?: DebounceOptions): DebouncedFunction<F>;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a throttled function that only invokes `func` at most once per
|
|
87
|
+
* every `wait` milliseconds (or once per browser frame). The throttled function
|
|
88
|
+
* comes with a `cancel` method to cancel delayed `func` invocations and a
|
|
89
|
+
* `flush` method to immediately invoke them. Provide `options` to indicate
|
|
90
|
+
* whether `func` should be invoked on the leading and/or trailing edge of the
|
|
91
|
+
* `wait` timeout. The `func` is invoked with the last arguments provided to the
|
|
92
|
+
* throttled function. Subsequent calls to the throttled function return the
|
|
93
|
+
* result of the last `func` invocation.
|
|
94
|
+
*
|
|
95
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
96
|
+
* invoked on the trailing edge of the timeout only if the throttled function
|
|
97
|
+
* is invoked more than once during the `wait` timeout.
|
|
98
|
+
*
|
|
99
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
100
|
+
* until the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
101
|
+
*
|
|
102
|
+
* If `wait` is omitted in an environment with `requestAnimationFrame`, `func`
|
|
103
|
+
* invocation will be deferred until the next frame is drawn (typically about
|
|
104
|
+
* 16ms).
|
|
105
|
+
*
|
|
106
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
107
|
+
* for details over the differences between `throttle` and `debounce`.
|
|
108
|
+
*
|
|
109
|
+
* @since 0.1.0
|
|
110
|
+
* @category Function
|
|
111
|
+
* @param {Function} func The function to throttle.
|
|
112
|
+
* @param {number} [wait=0]
|
|
113
|
+
* The number of milliseconds to throttle invocations to; if omitted,
|
|
114
|
+
* `requestAnimationFrame` is used (if available).
|
|
115
|
+
* @param {Object} [options={}] The options object.
|
|
116
|
+
* @param {boolean} [options.leading=true]
|
|
117
|
+
* Specify invoking on the leading edge of the timeout.
|
|
118
|
+
* @param {boolean} [options.trailing=true]
|
|
119
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
120
|
+
* @returns {Function} Returns the new throttled function.
|
|
121
|
+
* @example
|
|
122
|
+
*
|
|
123
|
+
* // Avoid excessively updating the position while scrolling.
|
|
124
|
+
* jQuery(window).on('scroll', throttle(updatePosition, 100))
|
|
125
|
+
*
|
|
126
|
+
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
|
|
127
|
+
* const throttled = throttle(renewToken, 300000, { 'trailing': false })
|
|
128
|
+
* jQuery(element).on('click', throttled)
|
|
129
|
+
*
|
|
130
|
+
* // Cancel the trailing throttled invocation.
|
|
131
|
+
* jQuery(window).on('popstate', throttled.cancel)
|
|
132
|
+
*/
|
|
133
|
+
export function throttle<F extends Procedure>(func: F, wait?: number, options?: ThrottleOptions): DebouncedFunction<F>;
|
|
134
|
+
}
|
|
1
135
|
declare module "util" {
|
|
2
136
|
/*!
|
|
3
137
|
* Wunderbaum - util
|
|
@@ -5,6 +139,8 @@ declare module "util" {
|
|
|
5
139
|
* @VERSION, @DATE (https://github.com/mar10/wunderbaum)
|
|
6
140
|
*/
|
|
7
141
|
/** @module util */
|
|
142
|
+
import { DebouncedFunction, debounce, throttle } from "debounce";
|
|
143
|
+
export { debounce, throttle };
|
|
8
144
|
/** Readable names for `MouseEvent.button` */
|
|
9
145
|
export const MOUSE_BUTTONS: {
|
|
10
146
|
[key: number]: string;
|
|
@@ -14,8 +150,18 @@ declare module "util" {
|
|
|
14
150
|
export const isMac: boolean;
|
|
15
151
|
export type FunctionType = (...args: any[]) => any;
|
|
16
152
|
export type EventCallbackType = (e: Event) => boolean | void;
|
|
153
|
+
/** A generic error that can be thrown to indicate a validation error when
|
|
154
|
+
* handling the `apply` event for a node title or the `change` event for a
|
|
155
|
+
* grid cell.
|
|
156
|
+
*/
|
|
157
|
+
export class ValidationError extends Error {
|
|
158
|
+
constructor(message: string);
|
|
159
|
+
}
|
|
17
160
|
/**
|
|
18
161
|
* A ES6 Promise, that exposes the resolve()/reject() methods.
|
|
162
|
+
*
|
|
163
|
+
* TODO: See [Promise.withResolvers()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers#description)
|
|
164
|
+
* , a proposed standard, but not yet implemented in any browser.
|
|
19
165
|
*/
|
|
20
166
|
export class Deferred {
|
|
21
167
|
private thens;
|
|
@@ -115,13 +261,11 @@ declare module "util" {
|
|
|
115
261
|
*/
|
|
116
262
|
export function setValueToElem(elem: HTMLElement, value: any): void;
|
|
117
263
|
/** Show/hide element by setting the `display` style to 'none'. */
|
|
118
|
-
export function setElemDisplay(elem: string |
|
|
264
|
+
export function setElemDisplay(elem: string | HTMLElement, flag: boolean): void;
|
|
119
265
|
/** Create and return an unconnected `HTMLElement` from a HTML string. */
|
|
120
|
-
export function elemFromHtml(html: string):
|
|
266
|
+
export function elemFromHtml<T = HTMLElement>(html: string): T;
|
|
121
267
|
/** Return a HtmlElement from selector or cast an existing element. */
|
|
122
|
-
export function elemFromSelector(obj: string |
|
|
123
|
-
/** Return a EventTarget from selector or cast an existing element. */
|
|
124
|
-
export function eventTargetFromSelector(obj: string | EventTarget): EventTarget | null;
|
|
268
|
+
export function elemFromSelector<T = HTMLElement>(obj: string | T): T | null;
|
|
125
269
|
/**
|
|
126
270
|
* Return a canonical descriptive string for a keyboard or mouse event.
|
|
127
271
|
*
|
|
@@ -164,7 +308,7 @@ declare module "util" {
|
|
|
164
308
|
/** A dummy function that does nothing ('no operation'). */
|
|
165
309
|
export function noop(...args: any[]): any;
|
|
166
310
|
/**
|
|
167
|
-
* Bind one or more event handlers directly to an [
|
|
311
|
+
* Bind one or more event handlers directly to an [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget).
|
|
168
312
|
*
|
|
169
313
|
* @param element EventTarget or selector
|
|
170
314
|
* @param eventNames
|
|
@@ -202,7 +346,7 @@ declare module "util" {
|
|
|
202
346
|
*/
|
|
203
347
|
export function overrideMethod(instance: any, methodName: string, handler: FunctionType, ctx?: any): void;
|
|
204
348
|
/** Run function after ms milliseconds and return a promise that resolves when done. */
|
|
205
|
-
export function setTimeoutPromise(this: unknown, callback: (...args: any[]) =>
|
|
349
|
+
export function setTimeoutPromise<T = unknown>(this: unknown, callback: (...args: any[]) => T, ms: number): Promise<T>;
|
|
206
350
|
/**
|
|
207
351
|
* Wait `ms` microseconds.
|
|
208
352
|
*
|
|
@@ -249,7 +393,7 @@ declare module "util" {
|
|
|
249
393
|
* throttledFoo();
|
|
250
394
|
* ```
|
|
251
395
|
*/
|
|
252
|
-
export function adaptiveThrottle(this: unknown, callback: (...args: any[]) => void, options:
|
|
396
|
+
export function adaptiveThrottle(this: unknown, callback: (...args: any[]) => void, options: object): DebouncedFunction<(...args: any[]) => void>;
|
|
253
397
|
}
|
|
254
398
|
declare module "common" {
|
|
255
399
|
/*!
|
|
@@ -257,7 +401,7 @@ declare module "common" {
|
|
|
257
401
|
* Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
|
|
258
402
|
* @VERSION, @DATE (https://github.com/mar10/wunderbaum)
|
|
259
403
|
*/
|
|
260
|
-
import { MatcherCallback } from "types";
|
|
404
|
+
import { MatcherCallback, SourceObjectType } from "types";
|
|
261
405
|
import { WunderbaumNode } from "wb_node";
|
|
262
406
|
export const DEFAULT_DEBUGLEVEL = 4;
|
|
263
407
|
/**
|
|
@@ -305,14 +449,23 @@ declare module "common" {
|
|
|
305
449
|
};
|
|
306
450
|
/** Return a callback that returns true if the node title matches the string
|
|
307
451
|
* or regular expression.
|
|
308
|
-
* @see {@link WunderbaumNode.findAll}
|
|
452
|
+
* @see {@link WunderbaumNode.findAll()}
|
|
309
453
|
*/
|
|
310
454
|
export function makeNodeTitleMatcher(match: string | RegExp): MatcherCallback;
|
|
311
455
|
/** Return a callback that returns true if the node title starts with a string (case-insensitive). */
|
|
312
456
|
export function makeNodeTitleStartMatcher(s: string): MatcherCallback;
|
|
313
457
|
/** Compare two nodes by title (case-insensitive). */
|
|
314
458
|
export function nodeTitleSorter(a: WunderbaumNode, b: WunderbaumNode): number;
|
|
315
|
-
|
|
459
|
+
/**
|
|
460
|
+
* Decompresses the source data by
|
|
461
|
+
* - converting from 'flat' to 'nested' format
|
|
462
|
+
* - expanding short alias names to long names (if defined in _keyMap)
|
|
463
|
+
* - resolving value indexes to value strings (if defined in _valueMap)
|
|
464
|
+
*
|
|
465
|
+
* @param source - The source object to be decompressed.
|
|
466
|
+
* @returns void
|
|
467
|
+
*/
|
|
468
|
+
export function decompressSourceData(source: SourceObjectType): void;
|
|
316
469
|
}
|
|
317
470
|
declare module "deferred" {
|
|
318
471
|
/*!
|
|
@@ -337,23 +490,23 @@ declare module "deferred" {
|
|
|
337
490
|
* }
|
|
338
491
|
* ```
|
|
339
492
|
*/
|
|
340
|
-
export class Deferred {
|
|
493
|
+
export class Deferred<T> {
|
|
341
494
|
private _promise;
|
|
342
495
|
protected _resolve: any;
|
|
343
496
|
protected _reject: any;
|
|
344
497
|
constructor();
|
|
345
|
-
/** Resolve the
|
|
498
|
+
/** Resolve the Promise. */
|
|
346
499
|
resolve(value?: any): void;
|
|
347
|
-
/** Reject the
|
|
500
|
+
/** Reject the Promise. */
|
|
348
501
|
reject(reason?: any): void;
|
|
349
|
-
/** Return the native
|
|
350
|
-
promise(): Promise<
|
|
351
|
-
/** Call
|
|
502
|
+
/** Return the native Promise instance.*/
|
|
503
|
+
promise(): Promise<T>;
|
|
504
|
+
/** Call Promise.then on the embedded promise instance.*/
|
|
352
505
|
then(cb: PromiseCallbackType): Promise<void>;
|
|
353
|
-
/** Call
|
|
354
|
-
catch(cb: PromiseCallbackType): Promise<
|
|
355
|
-
/** Call
|
|
356
|
-
finally(cb: finallyCallbackType): Promise<
|
|
506
|
+
/** Call Promise.catch on the embedded promise instance.*/
|
|
507
|
+
catch(cb: PromiseCallbackType): Promise<void | T>;
|
|
508
|
+
/** Call Promise.finally on the embedded promise instance.*/
|
|
509
|
+
finally(cb: finallyCallbackType): Promise<T>;
|
|
357
510
|
}
|
|
358
511
|
}
|
|
359
512
|
declare module "wb_node" {
|
|
@@ -480,6 +633,8 @@ declare module "wb_node" {
|
|
|
480
633
|
* as space-separated string, array of strings, or set of strings.
|
|
481
634
|
*/
|
|
482
635
|
setClass(className: string | string[] | Set<string>, flag?: boolean): void;
|
|
636
|
+
/** Start editing this node's title. */
|
|
637
|
+
startEditTitle(): void;
|
|
483
638
|
/** Call `setExpanded()` on all descendant nodes. */
|
|
484
639
|
expandAll(flag?: boolean, options?: ExpandAllOptions): Promise<void>;
|
|
485
640
|
/**
|
|
@@ -545,6 +700,13 @@ declare module "wb_node" {
|
|
|
545
700
|
* @returns {WunderbaumNode | null}
|
|
546
701
|
*/
|
|
547
702
|
getColElem(colIdx: number | string): HTMLSpanElement;
|
|
703
|
+
/**
|
|
704
|
+
* Return all nodes with the same refKey.
|
|
705
|
+
*
|
|
706
|
+
* @param includeSelf Include this node itself.
|
|
707
|
+
* @see {@link Wunderbaum.findByRefKey}
|
|
708
|
+
*/
|
|
709
|
+
getCloneList(includeSelf?: boolean): WunderbaumNode[];
|
|
548
710
|
/** Return the first child node or null.
|
|
549
711
|
* @returns {WunderbaumNode | null}
|
|
550
712
|
*/
|
|
@@ -581,19 +743,22 @@ declare module "wb_node" {
|
|
|
581
743
|
/** Return true if this node is the currently active tree node. */
|
|
582
744
|
isActive(): boolean;
|
|
583
745
|
/** Return true if this node is a direct or indirect parent of `other`.
|
|
584
|
-
*
|
|
746
|
+
* @see {@link WunderbaumNode.isParentOf}
|
|
585
747
|
*/
|
|
586
748
|
isAncestorOf(other: WunderbaumNode): boolean;
|
|
587
749
|
/** Return true if this node is a **direct** subnode of `other`.
|
|
588
|
-
*
|
|
750
|
+
* @see {@link WunderbaumNode.isDescendantOf}
|
|
589
751
|
*/
|
|
590
752
|
isChildOf(other: WunderbaumNode): boolean;
|
|
753
|
+
/** Return true if this node's refKey is used by at least one other node.
|
|
754
|
+
*/
|
|
755
|
+
isClone(): boolean;
|
|
591
756
|
/** Return true if this node's title spans all columns, i.e. the node has no
|
|
592
757
|
* grid cells.
|
|
593
758
|
*/
|
|
594
759
|
isColspan(): boolean;
|
|
595
760
|
/** Return true if this node is a direct or indirect subnode of `other`.
|
|
596
|
-
*
|
|
761
|
+
* @see {@link WunderbaumNode.isChildOf}
|
|
597
762
|
*/
|
|
598
763
|
isDescendantOf(other: WunderbaumNode): boolean;
|
|
599
764
|
/** Return true if this node has children, i.e. the node is generally expandable.
|
|
@@ -601,8 +766,11 @@ declare module "wb_node" {
|
|
|
601
766
|
* an expand operation is currently possible.
|
|
602
767
|
*/
|
|
603
768
|
isExpandable(andCollapsed?: boolean): boolean;
|
|
604
|
-
/** Return true if
|
|
605
|
-
|
|
769
|
+
/** Return true if _this_ node is currently in edit-title mode.
|
|
770
|
+
*
|
|
771
|
+
* See {@link Wunderbaum.startEditTitle} to check if any node is currently edited.
|
|
772
|
+
*/
|
|
773
|
+
isEditingTitle(): boolean;
|
|
606
774
|
/** Return true if this node is currently expanded. */
|
|
607
775
|
isExpanded(): boolean;
|
|
608
776
|
/** Return true if this node is the first node of its parent's children. */
|
|
@@ -618,7 +786,7 @@ declare module "wb_node" {
|
|
|
618
786
|
/** Return true if this node is a temporarily generated status node of type 'paging'. */
|
|
619
787
|
isPagingNode(): boolean;
|
|
620
788
|
/** Return true if this node is a **direct** parent of `other`.
|
|
621
|
-
*
|
|
789
|
+
* @see {@link WunderbaumNode.isAncestorOf}
|
|
622
790
|
*/
|
|
623
791
|
isParentOf(other: WunderbaumNode): boolean;
|
|
624
792
|
/** (experimental) Return true if this node is partially loaded. */
|
|
@@ -630,7 +798,7 @@ declare module "wb_node" {
|
|
|
630
798
|
/** Return true if this node has DOM representaion, i.e. is displayed in the viewport. */
|
|
631
799
|
isRendered(): boolean;
|
|
632
800
|
/** Return true if this node is the (invisible) system root node.
|
|
633
|
-
*
|
|
801
|
+
* @see {@link WunderbaumNode.isTopLevel}
|
|
634
802
|
*/
|
|
635
803
|
isRootNode(): boolean;
|
|
636
804
|
/** Return true if this node is selected, i.e. the checkbox is set.
|
|
@@ -668,7 +836,7 @@ declare module "wb_node" {
|
|
|
668
836
|
* @param {object} [options] passed to `setExpanded()`.
|
|
669
837
|
* Defaults to {noAnimation: false, noEvents: false, scrollIntoView: true}
|
|
670
838
|
*/
|
|
671
|
-
makeVisible(options?: MakeVisibleOptions): Promise<
|
|
839
|
+
makeVisible(options?: MakeVisibleOptions): Promise<unknown>;
|
|
672
840
|
/** Move this node to targetNode. */
|
|
673
841
|
moveTo(targetNode: WunderbaumNode, mode?: InsertNodeType, map?: NodeAnyCallback): void;
|
|
674
842
|
/** Set focus relative to this node and optionally activate.
|
|
@@ -747,9 +915,10 @@ declare module "wb_node" {
|
|
|
747
915
|
*/
|
|
748
916
|
scrollIntoView(options?: ScrollIntoViewOptions): Promise<void>;
|
|
749
917
|
/**
|
|
750
|
-
* Activate this node, deactivate previous, send events, activate column and
|
|
918
|
+
* Activate this node, deactivate previous, send events, activate column and
|
|
919
|
+
* scroll into viewport.
|
|
751
920
|
*/
|
|
752
|
-
setActive(flag?: boolean, options?: SetActiveOptions): Promise<
|
|
921
|
+
setActive(flag?: boolean, options?: SetActiveOptions): Promise<void>;
|
|
753
922
|
/**
|
|
754
923
|
* Expand or collapse this node.
|
|
755
924
|
*/
|
|
@@ -865,7 +1034,7 @@ declare module "wb_options" {
|
|
|
865
1034
|
*/
|
|
866
1035
|
import { ColumnDefinitionList, DndOptionsType, DynamicBoolOption, DynamicBoolOrStringOption, DynamicCheckboxOption, DynamicIconOption, EditOptionsType, FilterOptionsType, NavModeEnum, NodeTypeDefinitionMap, SelectModeType, WbActivateEventType, WbChangeEventType, WbClickEventType, WbDeactivateEventType, WbErrorEventType, WbIconBadgeCallback, WbInitEventType, WbKeydownEventType, WbNodeData, WbNodeEventType, WbReceiveEventType, WbRenderEventType, WbTreeEventType } from "types";
|
|
867
1036
|
/**
|
|
868
|
-
* Available options for
|
|
1037
|
+
* Available options for {@link wunderbaum.Wunderbaum}.
|
|
869
1038
|
*
|
|
870
1039
|
* Options are passed to the constructor as plain object:
|
|
871
1040
|
*
|
|
@@ -1201,14 +1370,17 @@ declare module "types" {
|
|
|
1201
1370
|
export type SourceListType = Array<WbNodeData>;
|
|
1202
1371
|
export interface SourceObjectType {
|
|
1203
1372
|
_format?: "nested" | "flat";
|
|
1373
|
+
_version?: number;
|
|
1204
1374
|
types?: NodeTypeDefinitionMap;
|
|
1205
1375
|
columns?: ColumnDefinitionList;
|
|
1206
1376
|
children: SourceListType;
|
|
1207
1377
|
_keyMap?: {
|
|
1208
1378
|
[key: string]: string;
|
|
1209
1379
|
};
|
|
1210
|
-
_typeList?: Array<string>;
|
|
1211
1380
|
_positional?: Array<string>;
|
|
1381
|
+
_valueMap?: {
|
|
1382
|
+
[key: string]: Array<string>;
|
|
1383
|
+
};
|
|
1212
1384
|
}
|
|
1213
1385
|
/** Possible initilization for tree nodes. */
|
|
1214
1386
|
export type SourceType = string | SourceListType | SourceAjaxType | SourceObjectType;
|
|
@@ -1295,24 +1467,56 @@ declare module "types" {
|
|
|
1295
1467
|
event: Event;
|
|
1296
1468
|
}
|
|
1297
1469
|
export interface WbChangeEventType extends WbNodeEventType {
|
|
1470
|
+
/** Additional information derived from the original change event. */
|
|
1298
1471
|
info: WbEventInfo;
|
|
1299
|
-
|
|
1472
|
+
/** The embedded element that fired the change event. */
|
|
1473
|
+
inputElem: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
1474
|
+
/** The new value of the embedded element, depending on the input element type. */
|
|
1300
1475
|
inputValue: any;
|
|
1476
|
+
/** Result of `inputElem.checkValidity()`. */
|
|
1477
|
+
inputValid: boolean;
|
|
1301
1478
|
}
|
|
1302
1479
|
export interface WbClickEventType extends WbTreeEventType {
|
|
1303
1480
|
/** The original event. */
|
|
1304
1481
|
event: MouseEvent;
|
|
1482
|
+
/** The clicked node if any. */
|
|
1305
1483
|
node: WunderbaumNode;
|
|
1484
|
+
/** Additional information derived from the original mouse event. */
|
|
1306
1485
|
info: WbEventInfo;
|
|
1307
1486
|
}
|
|
1308
|
-
export interface WbErrorEventType extends WbNodeEventType {
|
|
1309
|
-
error: any;
|
|
1310
|
-
}
|
|
1311
1487
|
export interface WbDeactivateEventType extends WbNodeEventType {
|
|
1312
1488
|
nextNode: WunderbaumNode;
|
|
1313
1489
|
/** The original event. */
|
|
1314
1490
|
event: Event;
|
|
1315
1491
|
}
|
|
1492
|
+
export interface WbEditApplyEventType extends WbNodeEventType {
|
|
1493
|
+
/** Additional information derived from the original change event. */
|
|
1494
|
+
info: WbEventInfo;
|
|
1495
|
+
/** The input element of the node title that fired the change event. */
|
|
1496
|
+
inputElem: HTMLInputElement;
|
|
1497
|
+
/** The previous node title. */
|
|
1498
|
+
oldValue: string;
|
|
1499
|
+
/** The new node title. */
|
|
1500
|
+
newValue: string;
|
|
1501
|
+
/** Result of `inputElem.checkValidity()`. */
|
|
1502
|
+
inputValid: boolean;
|
|
1503
|
+
}
|
|
1504
|
+
export interface WbEditEditEventType extends WbNodeEventType {
|
|
1505
|
+
/** The input element of the node title that was just created. */
|
|
1506
|
+
inputElem: HTMLInputElement;
|
|
1507
|
+
}
|
|
1508
|
+
export interface WbErrorEventType extends WbNodeEventType {
|
|
1509
|
+
error: any;
|
|
1510
|
+
}
|
|
1511
|
+
export interface WbExpandEventType extends WbNodeEventType {
|
|
1512
|
+
flag: boolean;
|
|
1513
|
+
}
|
|
1514
|
+
export interface WbFocusEventType extends WbTreeEventType {
|
|
1515
|
+
/** The original event. */
|
|
1516
|
+
event: FocusEvent;
|
|
1517
|
+
/** True if `focusin`, false if `focusout`. */
|
|
1518
|
+
flag: boolean;
|
|
1519
|
+
}
|
|
1316
1520
|
export interface WbIconBadgeEventType extends WbNodeEventType {
|
|
1317
1521
|
iconSpan: HTMLElement;
|
|
1318
1522
|
}
|
|
@@ -1324,29 +1528,29 @@ declare module "types" {
|
|
|
1324
1528
|
/** Tooltip for the badge. */
|
|
1325
1529
|
badgeTooltip?: string;
|
|
1326
1530
|
}
|
|
1327
|
-
export interface
|
|
1328
|
-
|
|
1329
|
-
event: FocusEvent;
|
|
1330
|
-
/** True if `focusin`, false if `focusout`. */
|
|
1331
|
-
flag: boolean;
|
|
1531
|
+
export interface WbInitEventType extends WbTreeEventType {
|
|
1532
|
+
error?: any;
|
|
1332
1533
|
}
|
|
1333
1534
|
export interface WbKeydownEventType extends WbTreeEventType {
|
|
1334
1535
|
/** The original event. */
|
|
1335
1536
|
event: KeyboardEvent;
|
|
1336
1537
|
node: WunderbaumNode;
|
|
1538
|
+
/** Additional information derived from the original keyboard event. */
|
|
1337
1539
|
info: WbEventInfo;
|
|
1338
1540
|
}
|
|
1339
|
-
export interface WbInitEventType extends WbTreeEventType {
|
|
1340
|
-
error?: any;
|
|
1341
|
-
}
|
|
1342
1541
|
export interface WbReceiveEventType extends WbNodeEventType {
|
|
1343
1542
|
response: any;
|
|
1344
1543
|
}
|
|
1544
|
+
export interface WbSelectEventType extends WbNodeEventType {
|
|
1545
|
+
flag: boolean;
|
|
1546
|
+
}
|
|
1345
1547
|
export interface WbRenderEventType extends WbNodeEventType {
|
|
1346
1548
|
/**
|
|
1347
1549
|
* True if the node's markup was not yet created. In this case the render
|
|
1348
1550
|
* event should create embedded input controls (in addition to update the
|
|
1349
|
-
* values according to to current node data).
|
|
1551
|
+
* values according to to current node data). <br>
|
|
1552
|
+
* False if the node's markup was already created. In this case the render
|
|
1553
|
+
* event should only update the values according to to current node data.
|
|
1350
1554
|
*/
|
|
1351
1555
|
isNew: boolean;
|
|
1352
1556
|
/** The node's `<span class='wb-node'>` element. */
|
|
@@ -1360,9 +1564,20 @@ declare module "types" {
|
|
|
1360
1564
|
*/
|
|
1361
1565
|
allColInfosById: ColumnEventInfoMap;
|
|
1362
1566
|
/**
|
|
1363
|
-
* Array of node's `<span class='wb-node'>` elements,
|
|
1567
|
+
* Array of node's `<span class='wb-node'>` elements,
|
|
1568
|
+
* *that should be rendered by the event handler*.
|
|
1364
1569
|
* In contrast to `allColInfosById`, the node title is not part of this array.
|
|
1365
1570
|
* If node.isColspan() is true, this array is empty (`[]`).
|
|
1571
|
+
* This allows to iterate over all relevant in a simple loop:
|
|
1572
|
+
* ```
|
|
1573
|
+
* for (const col of Object.values(e.renderColInfosById)) {
|
|
1574
|
+
* switch (col.id) {
|
|
1575
|
+
* default:
|
|
1576
|
+
* // Assumption: we named column.id === node.data.NAME
|
|
1577
|
+
* col.elem.textContent = node.data[col.id];
|
|
1578
|
+
* break;
|
|
1579
|
+
* }
|
|
1580
|
+
* }
|
|
1366
1581
|
*/
|
|
1367
1582
|
renderColInfosById: ColumnEventInfoMap;
|
|
1368
1583
|
}
|
|
@@ -1413,14 +1628,17 @@ declare module "types" {
|
|
|
1413
1628
|
* elements of that column.
|
|
1414
1629
|
*/
|
|
1415
1630
|
classes?: string;
|
|
1416
|
-
/** If `headerClasses` is a
|
|
1417
|
-
*
|
|
1631
|
+
/** If `headerClasses` is a set, it will be used for the header element only
|
|
1632
|
+
* (unlike `classes`, which is used for body and header cells).
|
|
1418
1633
|
*/
|
|
1419
1634
|
headerClasses?: string;
|
|
1420
1635
|
/** Optional HTML content that is rendered into all `span.wb-col` elements of that column.*/
|
|
1421
1636
|
html?: string;
|
|
1637
|
+
/** @internal */
|
|
1422
1638
|
_weight?: number;
|
|
1639
|
+
/** @internal */
|
|
1423
1640
|
_widthPx?: number;
|
|
1641
|
+
/** @internal */
|
|
1424
1642
|
_ofsPx?: number;
|
|
1425
1643
|
[key: string]: unknown;
|
|
1426
1644
|
}
|
|
@@ -1442,7 +1660,7 @@ declare module "types" {
|
|
|
1442
1660
|
[colId: string]: ColumnEventInfo;
|
|
1443
1661
|
};
|
|
1444
1662
|
/**
|
|
1445
|
-
* Additional
|
|
1663
|
+
* Additional information derived from mouse or keyboard events.
|
|
1446
1664
|
* @see {@link Wunderbaum.getEventInfo}
|
|
1447
1665
|
*/
|
|
1448
1666
|
export interface WbEventInfo {
|
|
@@ -1613,22 +1831,37 @@ declare module "types" {
|
|
|
1613
1831
|
/** Which node to scroll into the viewport.*/
|
|
1614
1832
|
node: WunderbaumNode;
|
|
1615
1833
|
}
|
|
1616
|
-
/** Possible values for {@link WunderbaumNode.setActive
|
|
1834
|
+
/** Possible values for {@link WunderbaumNode.setActive} `options` argument. */
|
|
1617
1835
|
export interface SetActiveOptions {
|
|
1618
|
-
/** Generate (de)activate event, even if node already has this status (default: false). */
|
|
1836
|
+
/** Generate (de)activate event, even if node already has this status (@default: false). */
|
|
1619
1837
|
retrigger?: boolean;
|
|
1620
|
-
/** Do not generate (de)activate event (default: false). */
|
|
1838
|
+
/** Do not generate (de)activate event (@default: false). */
|
|
1621
1839
|
noEvents?: boolean;
|
|
1622
|
-
/**
|
|
1623
|
-
focusNode?: boolean;
|
|
1624
|
-
/** Set node as focused node (default: false). */
|
|
1840
|
+
/** Call `tree.setFocus()` to acquire keyboard focus (@default: false). */
|
|
1625
1841
|
focusTree?: boolean;
|
|
1626
1842
|
/** Optional original event that will be passed to the (de)activate handler. */
|
|
1627
1843
|
event?: Event;
|
|
1628
|
-
/**
|
|
1629
|
-
colIdx?: number;
|
|
1844
|
+
/** Also call {@link Wunderbaum.setColumn()}. */
|
|
1845
|
+
colIdx?: number | string;
|
|
1846
|
+
/**
|
|
1847
|
+
* Focus embedded input control of the grid cell if any (requires colIdx >= 0).
|
|
1848
|
+
* If colIdx is 0 or '*', the node title is put into edit mode.
|
|
1849
|
+
* Implies `focusTree: true`, requires `colIdx`.
|
|
1850
|
+
*/
|
|
1851
|
+
edit?: boolean;
|
|
1630
1852
|
}
|
|
1631
|
-
/** Possible values for {@link WunderbaumNode.
|
|
1853
|
+
/** Possible values for {@link WunderbaumNode.setColumn()} `options` argument. */
|
|
1854
|
+
export interface SetColumnOptions {
|
|
1855
|
+
/**
|
|
1856
|
+
* Focus embedded input control of the grid cell if any .
|
|
1857
|
+
* If colIdx is 0 or '*', the node title is put into edit mode.
|
|
1858
|
+
* @default false
|
|
1859
|
+
*/
|
|
1860
|
+
edit?: boolean;
|
|
1861
|
+
/** Horizontically scroll into view. @default: true */
|
|
1862
|
+
scrollIntoView?: boolean;
|
|
1863
|
+
}
|
|
1864
|
+
/** Possible values for {@link WunderbaumNode.setExpanded} `options` argument. */
|
|
1632
1865
|
export interface SetExpandedOptions {
|
|
1633
1866
|
/** Ignore {@link WunderbaumOptions.minExpandLevel}. @default false */
|
|
1634
1867
|
force?: boolean;
|
|
@@ -1728,46 +1961,63 @@ declare module "types" {
|
|
|
1728
1961
|
* Grayout unmatched nodes (pass "hide" to remove unmatched node instead)
|
|
1729
1962
|
* @default 'dim'
|
|
1730
1963
|
*/
|
|
1731
|
-
mode?:
|
|
1964
|
+
mode?: FilterModeType;
|
|
1732
1965
|
/**
|
|
1733
|
-
* Display a 'no data' status node if result is empty
|
|
1966
|
+
* Display a 'no data' status node if result is empty (hide-mode only).
|
|
1967
|
+
* Pass false to simply show an empy pane, or pass a string to customize the message.
|
|
1734
1968
|
* @default true
|
|
1735
1969
|
*/
|
|
1736
|
-
noData?: boolean;
|
|
1970
|
+
noData?: boolean | string;
|
|
1737
1971
|
};
|
|
1972
|
+
/**
|
|
1973
|
+
* Note: <br>
|
|
1974
|
+
* This options are used for renaming node titles. <br>
|
|
1975
|
+
* There is also the `tree.change` event to handle modifying node data from
|
|
1976
|
+
* input controls that are embedded in grid cells.
|
|
1977
|
+
*/
|
|
1738
1978
|
export type EditOptionsType = {
|
|
1739
1979
|
/**
|
|
1980
|
+
* Used to debounce the `change` event handler for grid cells [ms].
|
|
1740
1981
|
* @default 100
|
|
1741
1982
|
*/
|
|
1742
1983
|
debounce?: number;
|
|
1743
1984
|
/**
|
|
1985
|
+
* Minimum number of characters required for node title input field.
|
|
1744
1986
|
* @default 1
|
|
1745
1987
|
*/
|
|
1746
1988
|
minlength?: number;
|
|
1747
1989
|
/**
|
|
1990
|
+
* Maximum number of characters allowed for node title input field.
|
|
1748
1991
|
* @default null;
|
|
1749
1992
|
*/
|
|
1750
1993
|
maxlength?: null | number;
|
|
1751
1994
|
/**
|
|
1752
|
-
*
|
|
1995
|
+
* Array of strings to determine which user input should trigger edit mode.
|
|
1996
|
+
* E.g. `["clickActive", "F2", "macEnter"]`: <br>
|
|
1997
|
+
* 'clickActive': single click on active node title <br>
|
|
1998
|
+
* 'F2': press F2 key <br>
|
|
1999
|
+
* 'macEnter': press Enter (on macOS only) <br>
|
|
2000
|
+
* Pass an empty array to disable edit mode.
|
|
1753
2001
|
* @default []
|
|
1754
2002
|
*/
|
|
1755
2003
|
trigger?: string[];
|
|
1756
2004
|
/**
|
|
2005
|
+
* Trim whitespace before saving a node title.
|
|
1757
2006
|
* @default true
|
|
1758
2007
|
*/
|
|
1759
2008
|
trim?: boolean;
|
|
1760
2009
|
/**
|
|
2010
|
+
* Select all text of a node title, so it can be overwritten by typing.
|
|
1761
2011
|
* @default true
|
|
1762
2012
|
*/
|
|
1763
2013
|
select?: boolean;
|
|
1764
2014
|
/**
|
|
1765
|
-
* Handle 'clickActive' only if last click is less than this old (0: always)
|
|
2015
|
+
* Handle 'clickActive' only if last click is less than this ms old (0: always)
|
|
1766
2016
|
* @default 1000
|
|
1767
2017
|
*/
|
|
1768
2018
|
slowClickDelay?: number;
|
|
1769
2019
|
/**
|
|
1770
|
-
*
|
|
2020
|
+
* Permanently apply node title input validations (CSS and tooltip) on keydown.
|
|
1771
2021
|
* @default true
|
|
1772
2022
|
*/
|
|
1773
2023
|
validity?: boolean;
|
|
@@ -1963,140 +2213,6 @@ declare module "wb_extension_base" {
|
|
|
1963
2213
|
onRender(data: any): boolean | undefined;
|
|
1964
2214
|
}
|
|
1965
2215
|
}
|
|
1966
|
-
declare module "debounce" {
|
|
1967
|
-
/*!
|
|
1968
|
-
* debounce & throttle, taken from https://github.com/lodash/lodash v4.17.21
|
|
1969
|
-
* MIT License: https://raw.githubusercontent.com/lodash/lodash/4.17.21-npm/LICENSE
|
|
1970
|
-
* Modified for TypeScript type annotations.
|
|
1971
|
-
*/
|
|
1972
|
-
type Procedure = (...args: any[]) => any;
|
|
1973
|
-
type DebounceOptions = {
|
|
1974
|
-
leading?: boolean;
|
|
1975
|
-
maxWait?: number;
|
|
1976
|
-
trailing?: boolean;
|
|
1977
|
-
};
|
|
1978
|
-
type ThrottleOptions = {
|
|
1979
|
-
leading?: boolean;
|
|
1980
|
-
trailing?: boolean;
|
|
1981
|
-
};
|
|
1982
|
-
export interface DebouncedFunction<F extends Procedure> {
|
|
1983
|
-
(this: ThisParameterType<F>, ...args: Parameters<F>): ReturnType<F>;
|
|
1984
|
-
cancel: () => void;
|
|
1985
|
-
flush: () => any;
|
|
1986
|
-
pending: () => boolean;
|
|
1987
|
-
}
|
|
1988
|
-
/**
|
|
1989
|
-
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
1990
|
-
* milliseconds have elapsed since the last time the debounced function was
|
|
1991
|
-
* invoked, or until the next browser frame is drawn. The debounced function
|
|
1992
|
-
* comes with a `cancel` method to cancel delayed `func` invocations and a
|
|
1993
|
-
* `flush` method to immediately invoke them. Provide `options` to indicate
|
|
1994
|
-
* whether `func` should be invoked on the leading and/or trailing edge of the
|
|
1995
|
-
* `wait` timeout. The `func` is invoked with the last arguments provided to the
|
|
1996
|
-
* debounced function. Subsequent calls to the debounced function return the
|
|
1997
|
-
* result of the last `func` invocation.
|
|
1998
|
-
*
|
|
1999
|
-
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
2000
|
-
* invoked on the trailing edge of the timeout only if the debounced function
|
|
2001
|
-
* is invoked more than once during the `wait` timeout.
|
|
2002
|
-
*
|
|
2003
|
-
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
2004
|
-
* until the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
2005
|
-
*
|
|
2006
|
-
* If `wait` is omitted in an environment with `requestAnimationFrame`, `func`
|
|
2007
|
-
* invocation will be deferred until the next frame is drawn (typically about
|
|
2008
|
-
* 16ms).
|
|
2009
|
-
*
|
|
2010
|
-
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
2011
|
-
* for details over the differences between `debounce` and `throttle`.
|
|
2012
|
-
*
|
|
2013
|
-
* @since 0.1.0
|
|
2014
|
-
* @category Function
|
|
2015
|
-
* @param {Function} func The function to debounce.
|
|
2016
|
-
* @param {number} [wait=0]
|
|
2017
|
-
* The number of milliseconds to delay; if omitted, `requestAnimationFrame` is
|
|
2018
|
-
* used (if available).
|
|
2019
|
-
* @param {Object} [options={}] The options object.
|
|
2020
|
-
* @param {boolean} [options.leading=false]
|
|
2021
|
-
* Specify invoking on the leading edge of the timeout.
|
|
2022
|
-
* @param {number} [options.maxWait]
|
|
2023
|
-
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
2024
|
-
* @param {boolean} [options.trailing=true]
|
|
2025
|
-
* Specify invoking on the trailing edge of the timeout.
|
|
2026
|
-
* @returns {Function} Returns the new debounced function.
|
|
2027
|
-
* @example
|
|
2028
|
-
*
|
|
2029
|
-
* // Avoid costly calculations while the window size is in flux.
|
|
2030
|
-
* jQuery(window).on('resize', debounce(calculateLayout, 150))
|
|
2031
|
-
*
|
|
2032
|
-
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
2033
|
-
* jQuery(element).on('click', debounce(sendMail, 300, {
|
|
2034
|
-
* 'leading': true,
|
|
2035
|
-
* 'trailing': false
|
|
2036
|
-
* }))
|
|
2037
|
-
*
|
|
2038
|
-
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
2039
|
-
* const debounced = debounce(batchLog, 250, { 'maxWait': 1000 })
|
|
2040
|
-
* const source = new EventSource('/stream')
|
|
2041
|
-
* jQuery(source).on('message', debounced)
|
|
2042
|
-
*
|
|
2043
|
-
* // Cancel the trailing debounced invocation.
|
|
2044
|
-
* jQuery(window).on('popstate', debounced.cancel)
|
|
2045
|
-
*
|
|
2046
|
-
* // Check for pending invocations.
|
|
2047
|
-
* const status = debounced.pending() ? "Pending..." : "Ready"
|
|
2048
|
-
*/
|
|
2049
|
-
export function debounce<F extends Procedure>(func: F, wait?: number, options?: DebounceOptions): DebouncedFunction<F>;
|
|
2050
|
-
/**
|
|
2051
|
-
* Creates a throttled function that only invokes `func` at most once per
|
|
2052
|
-
* every `wait` milliseconds (or once per browser frame). The throttled function
|
|
2053
|
-
* comes with a `cancel` method to cancel delayed `func` invocations and a
|
|
2054
|
-
* `flush` method to immediately invoke them. Provide `options` to indicate
|
|
2055
|
-
* whether `func` should be invoked on the leading and/or trailing edge of the
|
|
2056
|
-
* `wait` timeout. The `func` is invoked with the last arguments provided to the
|
|
2057
|
-
* throttled function. Subsequent calls to the throttled function return the
|
|
2058
|
-
* result of the last `func` invocation.
|
|
2059
|
-
*
|
|
2060
|
-
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
2061
|
-
* invoked on the trailing edge of the timeout only if the throttled function
|
|
2062
|
-
* is invoked more than once during the `wait` timeout.
|
|
2063
|
-
*
|
|
2064
|
-
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
2065
|
-
* until the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
2066
|
-
*
|
|
2067
|
-
* If `wait` is omitted in an environment with `requestAnimationFrame`, `func`
|
|
2068
|
-
* invocation will be deferred until the next frame is drawn (typically about
|
|
2069
|
-
* 16ms).
|
|
2070
|
-
*
|
|
2071
|
-
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
2072
|
-
* for details over the differences between `throttle` and `debounce`.
|
|
2073
|
-
*
|
|
2074
|
-
* @since 0.1.0
|
|
2075
|
-
* @category Function
|
|
2076
|
-
* @param {Function} func The function to throttle.
|
|
2077
|
-
* @param {number} [wait=0]
|
|
2078
|
-
* The number of milliseconds to throttle invocations to; if omitted,
|
|
2079
|
-
* `requestAnimationFrame` is used (if available).
|
|
2080
|
-
* @param {Object} [options={}] The options object.
|
|
2081
|
-
* @param {boolean} [options.leading=true]
|
|
2082
|
-
* Specify invoking on the leading edge of the timeout.
|
|
2083
|
-
* @param {boolean} [options.trailing=true]
|
|
2084
|
-
* Specify invoking on the trailing edge of the timeout.
|
|
2085
|
-
* @returns {Function} Returns the new throttled function.
|
|
2086
|
-
* @example
|
|
2087
|
-
*
|
|
2088
|
-
* // Avoid excessively updating the position while scrolling.
|
|
2089
|
-
* jQuery(window).on('scroll', throttle(updatePosition, 100))
|
|
2090
|
-
*
|
|
2091
|
-
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
|
|
2092
|
-
* const throttled = throttle(renewToken, 300000, { 'trailing': false })
|
|
2093
|
-
* jQuery(element).on('click', throttled)
|
|
2094
|
-
*
|
|
2095
|
-
* // Cancel the trailing throttled invocation.
|
|
2096
|
-
* jQuery(window).on('popstate', throttled.cancel)
|
|
2097
|
-
*/
|
|
2098
|
-
export function throttle<F extends Procedure>(func: F, wait?: number, options?: ThrottleOptions): DebouncedFunction<F>;
|
|
2099
|
-
}
|
|
2100
2216
|
declare module "wb_ext_filter" {
|
|
2101
2217
|
import { FilterNodesOptions, FilterOptionsType, NodeFilterCallback } from "types";
|
|
2102
2218
|
import { Wunderbaum } from "wunderbaum";
|
|
@@ -2287,7 +2403,7 @@ declare module "wb_ext_edit" {
|
|
|
2287
2403
|
protected curEditNode: WunderbaumNode | null;
|
|
2288
2404
|
protected relatedNode: WunderbaumNode | null;
|
|
2289
2405
|
constructor(tree: Wunderbaum);
|
|
2290
|
-
protected _applyChange(eventName: string, node: WunderbaumNode, colElem: HTMLElement, extra: any): Promise<any>;
|
|
2406
|
+
protected _applyChange(eventName: string, node: WunderbaumNode, colElem: HTMLElement, inputElem: HTMLInputElement, extra: any): Promise<any>;
|
|
2291
2407
|
protected _onChange(e: Event): void;
|
|
2292
2408
|
init(): void;
|
|
2293
2409
|
_preprocessKeyEvent(data: any): boolean | undefined;
|
|
@@ -2323,13 +2439,14 @@ declare module "wunderbaum" {
|
|
|
2323
2439
|
*/
|
|
2324
2440
|
import * as util from "util";
|
|
2325
2441
|
import { ExtensionsDict, WunderbaumExtension } from "wb_extension_base";
|
|
2326
|
-
import { ApplyCommandType, ChangeType, ColumnDefinitionList, ExpandAllOptions, FilterModeType, MatcherCallback, NavModeEnum, NodeStatusType, NodeStringCallback, NodeTypeDefinitionMap, ScrollToOptions, SetActiveOptions, UpdateOptions, SetStatusOptions, WbEventInfo, ApplyCommandOptions, AddChildrenOptions, VisitRowsOptions, NodeFilterCallback, FilterNodesOptions, RenderFlag, NodeVisitCallback, SortCallback, NodeToDictCallback, WbNodeData, DynamicCheckboxOption, SourceType, DynamicIconOption, DynamicStringOption, DynamicBoolOption } from "types";
|
|
2442
|
+
import { ApplyCommandType, ChangeType, ColumnDefinitionList, ExpandAllOptions, FilterModeType, MatcherCallback, NavModeEnum, NodeStatusType, NodeStringCallback, NodeTypeDefinitionMap, ScrollToOptions, SetActiveOptions, UpdateOptions, SetStatusOptions, WbEventInfo, ApplyCommandOptions, AddChildrenOptions, VisitRowsOptions, NodeFilterCallback, FilterNodesOptions, RenderFlag, NodeVisitCallback, SortCallback, NodeToDictCallback, WbNodeData, DynamicCheckboxOption, SourceType, DynamicIconOption, DynamicStringOption, DynamicBoolOption, SetColumnOptions } from "types";
|
|
2327
2443
|
import { WunderbaumNode } from "wb_node";
|
|
2328
2444
|
import { WunderbaumOptions } from "wb_options";
|
|
2445
|
+
import { DebouncedFunction } from "debounce";
|
|
2329
2446
|
/**
|
|
2330
2447
|
* A persistent plain object or array.
|
|
2331
2448
|
*
|
|
2332
|
-
* See also
|
|
2449
|
+
* See also {@link WunderbaumOptions}.
|
|
2333
2450
|
*/
|
|
2334
2451
|
export class Wunderbaum {
|
|
2335
2452
|
protected static sequence: number;
|
|
@@ -2352,7 +2469,7 @@ declare module "wunderbaum" {
|
|
|
2352
2469
|
readonly data: {
|
|
2353
2470
|
[key: string]: any;
|
|
2354
2471
|
};
|
|
2355
|
-
protected readonly _updateViewportThrottled: (
|
|
2472
|
+
protected readonly _updateViewportThrottled: DebouncedFunction<() => void>;
|
|
2356
2473
|
protected extensionList: WunderbaumExtension<any>[];
|
|
2357
2474
|
protected extensions: ExtensionsDict;
|
|
2358
2475
|
/** Merged options from constructor args and tree- and extension defaults. */
|
|
@@ -2387,7 +2504,7 @@ declare module "wunderbaum" {
|
|
|
2387
2504
|
/** Expose some useful methods of the util.ts module as `tree._util`. */
|
|
2388
2505
|
_util: typeof util;
|
|
2389
2506
|
filterMode: FilterModeType;
|
|
2390
|
-
/** @internal Use `setColumn()`/`getActiveColElem()
|
|
2507
|
+
/** @internal Use `setColumn()`/`getActiveColElem()` to access. */
|
|
2391
2508
|
activeColIdx: number;
|
|
2392
2509
|
/** @internal */
|
|
2393
2510
|
_cellNavMode: boolean;
|
|
@@ -2405,7 +2522,7 @@ declare module "wunderbaum" {
|
|
|
2405
2522
|
* getTree(1); // Get second Wunderbaum instance on page
|
|
2406
2523
|
* getTree(event); // Get tree for this mouse- or keyboard event
|
|
2407
2524
|
* getTree("foo"); // Get tree for this `tree.options.id`
|
|
2408
|
-
* getTree("#tree"); // Get tree for
|
|
2525
|
+
* getTree("#tree"); // Get tree for first matching element selector
|
|
2409
2526
|
* ```
|
|
2410
2527
|
*/
|
|
2411
2528
|
static getTree(el?: Element | Event | number | string | WunderbaumNode): Wunderbaum | null;
|
|
@@ -2547,20 +2664,32 @@ declare module "wunderbaum" {
|
|
|
2547
2664
|
/**
|
|
2548
2665
|
* Find all nodes that match condition.
|
|
2549
2666
|
*
|
|
2667
|
+
* @param match title string to search for, or a
|
|
2668
|
+
* callback function that returns `true` if a node is matched.
|
|
2550
2669
|
* @see {@link WunderbaumNode.findAll}
|
|
2551
2670
|
*/
|
|
2552
2671
|
findAll(match: string | RegExp | MatcherCallback): WunderbaumNode[];
|
|
2672
|
+
/**
|
|
2673
|
+
* Find all nodes with a given _refKey_ (aka a list of clones).
|
|
2674
|
+
*
|
|
2675
|
+
* @param refKey a `node.refKey` value to search for.
|
|
2676
|
+
* @returns an array of matching nodes with at least two element or `[]`
|
|
2677
|
+
* if nothing found.
|
|
2678
|
+
*
|
|
2679
|
+
* @see {@link WunderbaumNode.getCloneList}
|
|
2680
|
+
*/
|
|
2681
|
+
findByRefKey(refKey: string): WunderbaumNode[];
|
|
2553
2682
|
/**
|
|
2554
2683
|
* Find first node that matches condition.
|
|
2555
2684
|
*
|
|
2685
|
+
* @param match title string to search for, or a
|
|
2686
|
+
* callback function that returns `true` if a node is matched.
|
|
2556
2687
|
* @see {@link WunderbaumNode.findFirst}
|
|
2557
2688
|
*/
|
|
2558
2689
|
findFirst(match: string | RegExp | MatcherCallback): WunderbaumNode;
|
|
2559
2690
|
/**
|
|
2560
2691
|
* Find first node that matches condition.
|
|
2561
2692
|
*
|
|
2562
|
-
* @param match title string to search for, or a
|
|
2563
|
-
* callback function that returns `true` if a node is matched.
|
|
2564
2693
|
* @see {@link WunderbaumNode.findFirst}
|
|
2565
2694
|
*
|
|
2566
2695
|
*/
|
|
@@ -2568,6 +2697,7 @@ declare module "wunderbaum" {
|
|
|
2568
2697
|
/**
|
|
2569
2698
|
* Find the next visible node that starts with `match`, starting at `startNode`
|
|
2570
2699
|
* and wrap-around at the end.
|
|
2700
|
+
* Used by quicksearch and keyboard navigation.
|
|
2571
2701
|
*/
|
|
2572
2702
|
findNextNode(match: string | MatcherCallback, startNode?: WunderbaumNode | null): WunderbaumNode | null;
|
|
2573
2703
|
/**
|
|
@@ -2611,6 +2741,9 @@ declare module "wunderbaum" {
|
|
|
2611
2741
|
getActiveColElem(): HTMLSpanElement;
|
|
2612
2742
|
/**
|
|
2613
2743
|
* Return the currently active node or null.
|
|
2744
|
+
* @see {@link WunderbaumNode.setActive}
|
|
2745
|
+
* @see {@link WunderbaumNode.isActive}
|
|
2746
|
+
* @see {@link WunderbaumNode.getFocusNode}
|
|
2614
2747
|
*/
|
|
2615
2748
|
getActiveNode(): WunderbaumNode;
|
|
2616
2749
|
/**
|
|
@@ -2618,7 +2751,8 @@ declare module "wunderbaum" {
|
|
|
2618
2751
|
*/
|
|
2619
2752
|
getFirstChild(): WunderbaumNode;
|
|
2620
2753
|
/**
|
|
2621
|
-
* Return the currently
|
|
2754
|
+
* Return the node that currently has keyboard focus or null.
|
|
2755
|
+
* @see {@link WunderbaumNode.getActiveNode}
|
|
2622
2756
|
*/
|
|
2623
2757
|
getFocusNode(): WunderbaumNode;
|
|
2624
2758
|
/** Return a {node: WunderbaumNode, region: TYPE} object for a mouse event.
|
|
@@ -2633,8 +2767,16 @@ declare module "wunderbaum" {
|
|
|
2633
2767
|
* @internal
|
|
2634
2768
|
*/
|
|
2635
2769
|
toString(): string;
|
|
2636
|
-
/** Return true if any node is currently
|
|
2770
|
+
/** Return true if any node title or grid cell is currently beeing edited.
|
|
2771
|
+
*
|
|
2772
|
+
* See also {@link Wunderbaum.isEditingTitle}.
|
|
2773
|
+
*/
|
|
2637
2774
|
isEditing(): boolean;
|
|
2775
|
+
/** Return true if any node is currently in edit-title mode.
|
|
2776
|
+
*
|
|
2777
|
+
* See also {@link WunderbaumNode.isEditingTitle} and {@link Wunderbaum.isEditing}.
|
|
2778
|
+
*/
|
|
2779
|
+
isEditingTitle(): boolean;
|
|
2638
2780
|
/**
|
|
2639
2781
|
* Return true if any node is currently beeing loaded, i.e. a Ajax request is pending.
|
|
2640
2782
|
*/
|
|
@@ -2670,18 +2812,23 @@ declare module "wunderbaum" {
|
|
|
2670
2812
|
/**
|
|
2671
2813
|
* Set column #colIdx to 'active'.
|
|
2672
2814
|
*
|
|
2673
|
-
* This higlights the column header and -cells by adding the `wb-active`
|
|
2815
|
+
* This higlights the column header and -cells by adding the `wb-active`
|
|
2816
|
+
* class to all grid cells of the active column. <br>
|
|
2674
2817
|
* Available in cell-nav mode only.
|
|
2818
|
+
*
|
|
2819
|
+
* If _options.edit_ is true, the embedded input element is focused, or if
|
|
2820
|
+
* colIdx is 0, the node title is put into edit mode.
|
|
2675
2821
|
*/
|
|
2676
|
-
setColumn(colIdx: number): void;
|
|
2677
|
-
/** Set or remove
|
|
2822
|
+
setColumn(colIdx: number | string, options?: SetColumnOptions): void;
|
|
2823
|
+
/** Set or remove keyboard focus to the tree container. */
|
|
2678
2824
|
setActiveNode(key: string, flag?: boolean, options?: SetActiveOptions): void;
|
|
2679
|
-
/** Set or remove
|
|
2825
|
+
/** Set or remove keyboard focus to the tree container. */
|
|
2680
2826
|
setFocus(flag?: boolean): void;
|
|
2681
2827
|
/**
|
|
2682
2828
|
* Schedule an update request to reflect a tree change.
|
|
2683
2829
|
* The render operation is async and debounced unless the `immediate` option
|
|
2684
2830
|
* is set.
|
|
2831
|
+
*
|
|
2685
2832
|
* Use {@link WunderbaumNode.update()} if only a single node has changed,
|
|
2686
2833
|
* or {@link WunderbaumNode._render()}) to pass special options.
|
|
2687
2834
|
*/
|
|
@@ -2808,29 +2955,23 @@ declare module "wunderbaum" {
|
|
|
2808
2955
|
*/
|
|
2809
2956
|
enableUpdate(flag: boolean): void;
|
|
2810
2957
|
/**
|
|
2811
|
-
*
|
|
2958
|
+
* Dim or hide nodes.
|
|
2812
2959
|
*/
|
|
2813
2960
|
filterNodes(filter: string | NodeFilterCallback, options: FilterNodesOptions): void;
|
|
2814
2961
|
/**
|
|
2815
|
-
*
|
|
2962
|
+
* Dim or hide whole branches.
|
|
2816
2963
|
*/
|
|
2817
2964
|
filterBranches(filter: string | NodeFilterCallback, options: FilterNodesOptions): void;
|
|
2818
2965
|
/**
|
|
2819
|
-
*
|
|
2820
|
-
*
|
|
2821
|
-
* @requires [[FilterExtension]]
|
|
2966
|
+
* Reset the filter.
|
|
2822
2967
|
*/
|
|
2823
2968
|
clearFilter(): void;
|
|
2824
2969
|
/**
|
|
2825
|
-
*
|
|
2826
|
-
*
|
|
2827
|
-
* @requires [[FilterExtension]]
|
|
2970
|
+
* Return true if a filter is currently applied.
|
|
2828
2971
|
*/
|
|
2829
2972
|
isFilterActive(): boolean;
|
|
2830
2973
|
/**
|
|
2831
|
-
*
|
|
2832
|
-
*
|
|
2833
|
-
* @requires [[FilterExtension]]
|
|
2974
|
+
* Re-apply current filter.
|
|
2834
2975
|
*/
|
|
2835
2976
|
updateFilter(): void;
|
|
2836
2977
|
}
|