wunderbaum 0.7.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/dist/wunderbaum.css +4 -1
- package/dist/wunderbaum.css.map +1 -1
- package/dist/wunderbaum.d.ts +350 -221
- package/dist/wunderbaum.esm.js +716 -537
- package/dist/wunderbaum.esm.min.js +32 -32
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +7785 -7606
- 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 +1 -1
- package/src/deferred.ts +9 -9
- package/src/types.ts +120 -36
- package/src/util.ts +73 -33
- package/src/wb_ext_dnd.ts +1 -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 +78 -30
- 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
|
/*!
|
|
@@ -305,7 +449,7 @@ 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). */
|
|
@@ -346,23 +490,23 @@ declare module "deferred" {
|
|
|
346
490
|
* }
|
|
347
491
|
* ```
|
|
348
492
|
*/
|
|
349
|
-
export class Deferred {
|
|
493
|
+
export class Deferred<T> {
|
|
350
494
|
private _promise;
|
|
351
495
|
protected _resolve: any;
|
|
352
496
|
protected _reject: any;
|
|
353
497
|
constructor();
|
|
354
|
-
/** Resolve the
|
|
498
|
+
/** Resolve the Promise. */
|
|
355
499
|
resolve(value?: any): void;
|
|
356
|
-
/** Reject the
|
|
500
|
+
/** Reject the Promise. */
|
|
357
501
|
reject(reason?: any): void;
|
|
358
|
-
/** Return the native
|
|
359
|
-
promise(): Promise<
|
|
360
|
-
/** Call
|
|
502
|
+
/** Return the native Promise instance.*/
|
|
503
|
+
promise(): Promise<T>;
|
|
504
|
+
/** Call Promise.then on the embedded promise instance.*/
|
|
361
505
|
then(cb: PromiseCallbackType): Promise<void>;
|
|
362
|
-
/** Call
|
|
363
|
-
catch(cb: PromiseCallbackType): Promise<
|
|
364
|
-
/** Call
|
|
365
|
-
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>;
|
|
366
510
|
}
|
|
367
511
|
}
|
|
368
512
|
declare module "wb_node" {
|
|
@@ -489,6 +633,8 @@ declare module "wb_node" {
|
|
|
489
633
|
* as space-separated string, array of strings, or set of strings.
|
|
490
634
|
*/
|
|
491
635
|
setClass(className: string | string[] | Set<string>, flag?: boolean): void;
|
|
636
|
+
/** Start editing this node's title. */
|
|
637
|
+
startEditTitle(): void;
|
|
492
638
|
/** Call `setExpanded()` on all descendant nodes. */
|
|
493
639
|
expandAll(flag?: boolean, options?: ExpandAllOptions): Promise<void>;
|
|
494
640
|
/**
|
|
@@ -554,6 +700,13 @@ declare module "wb_node" {
|
|
|
554
700
|
* @returns {WunderbaumNode | null}
|
|
555
701
|
*/
|
|
556
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[];
|
|
557
710
|
/** Return the first child node or null.
|
|
558
711
|
* @returns {WunderbaumNode | null}
|
|
559
712
|
*/
|
|
@@ -590,19 +743,22 @@ declare module "wb_node" {
|
|
|
590
743
|
/** Return true if this node is the currently active tree node. */
|
|
591
744
|
isActive(): boolean;
|
|
592
745
|
/** Return true if this node is a direct or indirect parent of `other`.
|
|
593
|
-
*
|
|
746
|
+
* @see {@link WunderbaumNode.isParentOf}
|
|
594
747
|
*/
|
|
595
748
|
isAncestorOf(other: WunderbaumNode): boolean;
|
|
596
749
|
/** Return true if this node is a **direct** subnode of `other`.
|
|
597
|
-
*
|
|
750
|
+
* @see {@link WunderbaumNode.isDescendantOf}
|
|
598
751
|
*/
|
|
599
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;
|
|
600
756
|
/** Return true if this node's title spans all columns, i.e. the node has no
|
|
601
757
|
* grid cells.
|
|
602
758
|
*/
|
|
603
759
|
isColspan(): boolean;
|
|
604
760
|
/** Return true if this node is a direct or indirect subnode of `other`.
|
|
605
|
-
*
|
|
761
|
+
* @see {@link WunderbaumNode.isChildOf}
|
|
606
762
|
*/
|
|
607
763
|
isDescendantOf(other: WunderbaumNode): boolean;
|
|
608
764
|
/** Return true if this node has children, i.e. the node is generally expandable.
|
|
@@ -610,8 +766,11 @@ declare module "wb_node" {
|
|
|
610
766
|
* an expand operation is currently possible.
|
|
611
767
|
*/
|
|
612
768
|
isExpandable(andCollapsed?: boolean): boolean;
|
|
613
|
-
/** Return true if
|
|
614
|
-
|
|
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;
|
|
615
774
|
/** Return true if this node is currently expanded. */
|
|
616
775
|
isExpanded(): boolean;
|
|
617
776
|
/** Return true if this node is the first node of its parent's children. */
|
|
@@ -627,7 +786,7 @@ declare module "wb_node" {
|
|
|
627
786
|
/** Return true if this node is a temporarily generated status node of type 'paging'. */
|
|
628
787
|
isPagingNode(): boolean;
|
|
629
788
|
/** Return true if this node is a **direct** parent of `other`.
|
|
630
|
-
*
|
|
789
|
+
* @see {@link WunderbaumNode.isAncestorOf}
|
|
631
790
|
*/
|
|
632
791
|
isParentOf(other: WunderbaumNode): boolean;
|
|
633
792
|
/** (experimental) Return true if this node is partially loaded. */
|
|
@@ -639,7 +798,7 @@ declare module "wb_node" {
|
|
|
639
798
|
/** Return true if this node has DOM representaion, i.e. is displayed in the viewport. */
|
|
640
799
|
isRendered(): boolean;
|
|
641
800
|
/** Return true if this node is the (invisible) system root node.
|
|
642
|
-
*
|
|
801
|
+
* @see {@link WunderbaumNode.isTopLevel}
|
|
643
802
|
*/
|
|
644
803
|
isRootNode(): boolean;
|
|
645
804
|
/** Return true if this node is selected, i.e. the checkbox is set.
|
|
@@ -677,7 +836,7 @@ declare module "wb_node" {
|
|
|
677
836
|
* @param {object} [options] passed to `setExpanded()`.
|
|
678
837
|
* Defaults to {noAnimation: false, noEvents: false, scrollIntoView: true}
|
|
679
838
|
*/
|
|
680
|
-
makeVisible(options?: MakeVisibleOptions): Promise<
|
|
839
|
+
makeVisible(options?: MakeVisibleOptions): Promise<unknown>;
|
|
681
840
|
/** Move this node to targetNode. */
|
|
682
841
|
moveTo(targetNode: WunderbaumNode, mode?: InsertNodeType, map?: NodeAnyCallback): void;
|
|
683
842
|
/** Set focus relative to this node and optionally activate.
|
|
@@ -756,9 +915,10 @@ declare module "wb_node" {
|
|
|
756
915
|
*/
|
|
757
916
|
scrollIntoView(options?: ScrollIntoViewOptions): Promise<void>;
|
|
758
917
|
/**
|
|
759
|
-
* 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.
|
|
760
920
|
*/
|
|
761
|
-
setActive(flag?: boolean, options?: SetActiveOptions): Promise<
|
|
921
|
+
setActive(flag?: boolean, options?: SetActiveOptions): Promise<void>;
|
|
762
922
|
/**
|
|
763
923
|
* Expand or collapse this node.
|
|
764
924
|
*/
|
|
@@ -874,7 +1034,7 @@ declare module "wb_options" {
|
|
|
874
1034
|
*/
|
|
875
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";
|
|
876
1036
|
/**
|
|
877
|
-
* Available options for
|
|
1037
|
+
* Available options for {@link wunderbaum.Wunderbaum}.
|
|
878
1038
|
*
|
|
879
1039
|
* Options are passed to the constructor as plain object:
|
|
880
1040
|
*
|
|
@@ -1307,24 +1467,56 @@ declare module "types" {
|
|
|
1307
1467
|
event: Event;
|
|
1308
1468
|
}
|
|
1309
1469
|
export interface WbChangeEventType extends WbNodeEventType {
|
|
1470
|
+
/** Additional information derived from the original change event. */
|
|
1310
1471
|
info: WbEventInfo;
|
|
1311
|
-
|
|
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. */
|
|
1312
1475
|
inputValue: any;
|
|
1476
|
+
/** Result of `inputElem.checkValidity()`. */
|
|
1477
|
+
inputValid: boolean;
|
|
1313
1478
|
}
|
|
1314
1479
|
export interface WbClickEventType extends WbTreeEventType {
|
|
1315
1480
|
/** The original event. */
|
|
1316
1481
|
event: MouseEvent;
|
|
1482
|
+
/** The clicked node if any. */
|
|
1317
1483
|
node: WunderbaumNode;
|
|
1484
|
+
/** Additional information derived from the original mouse event. */
|
|
1318
1485
|
info: WbEventInfo;
|
|
1319
1486
|
}
|
|
1320
|
-
export interface WbErrorEventType extends WbNodeEventType {
|
|
1321
|
-
error: any;
|
|
1322
|
-
}
|
|
1323
1487
|
export interface WbDeactivateEventType extends WbNodeEventType {
|
|
1324
1488
|
nextNode: WunderbaumNode;
|
|
1325
1489
|
/** The original event. */
|
|
1326
1490
|
event: Event;
|
|
1327
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
|
+
}
|
|
1328
1520
|
export interface WbIconBadgeEventType extends WbNodeEventType {
|
|
1329
1521
|
iconSpan: HTMLElement;
|
|
1330
1522
|
}
|
|
@@ -1336,29 +1528,29 @@ declare module "types" {
|
|
|
1336
1528
|
/** Tooltip for the badge. */
|
|
1337
1529
|
badgeTooltip?: string;
|
|
1338
1530
|
}
|
|
1339
|
-
export interface
|
|
1340
|
-
|
|
1341
|
-
event: FocusEvent;
|
|
1342
|
-
/** True if `focusin`, false if `focusout`. */
|
|
1343
|
-
flag: boolean;
|
|
1531
|
+
export interface WbInitEventType extends WbTreeEventType {
|
|
1532
|
+
error?: any;
|
|
1344
1533
|
}
|
|
1345
1534
|
export interface WbKeydownEventType extends WbTreeEventType {
|
|
1346
1535
|
/** The original event. */
|
|
1347
1536
|
event: KeyboardEvent;
|
|
1348
1537
|
node: WunderbaumNode;
|
|
1538
|
+
/** Additional information derived from the original keyboard event. */
|
|
1349
1539
|
info: WbEventInfo;
|
|
1350
1540
|
}
|
|
1351
|
-
export interface WbInitEventType extends WbTreeEventType {
|
|
1352
|
-
error?: any;
|
|
1353
|
-
}
|
|
1354
1541
|
export interface WbReceiveEventType extends WbNodeEventType {
|
|
1355
1542
|
response: any;
|
|
1356
1543
|
}
|
|
1544
|
+
export interface WbSelectEventType extends WbNodeEventType {
|
|
1545
|
+
flag: boolean;
|
|
1546
|
+
}
|
|
1357
1547
|
export interface WbRenderEventType extends WbNodeEventType {
|
|
1358
1548
|
/**
|
|
1359
1549
|
* True if the node's markup was not yet created. In this case the render
|
|
1360
1550
|
* event should create embedded input controls (in addition to update the
|
|
1361
|
-
* 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.
|
|
1362
1554
|
*/
|
|
1363
1555
|
isNew: boolean;
|
|
1364
1556
|
/** The node's `<span class='wb-node'>` element. */
|
|
@@ -1372,9 +1564,20 @@ declare module "types" {
|
|
|
1372
1564
|
*/
|
|
1373
1565
|
allColInfosById: ColumnEventInfoMap;
|
|
1374
1566
|
/**
|
|
1375
|
-
* 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*.
|
|
1376
1569
|
* In contrast to `allColInfosById`, the node title is not part of this array.
|
|
1377
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
|
+
* }
|
|
1378
1581
|
*/
|
|
1379
1582
|
renderColInfosById: ColumnEventInfoMap;
|
|
1380
1583
|
}
|
|
@@ -1425,14 +1628,17 @@ declare module "types" {
|
|
|
1425
1628
|
* elements of that column.
|
|
1426
1629
|
*/
|
|
1427
1630
|
classes?: string;
|
|
1428
|
-
/** If `headerClasses` is a
|
|
1429
|
-
*
|
|
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).
|
|
1430
1633
|
*/
|
|
1431
1634
|
headerClasses?: string;
|
|
1432
1635
|
/** Optional HTML content that is rendered into all `span.wb-col` elements of that column.*/
|
|
1433
1636
|
html?: string;
|
|
1637
|
+
/** @internal */
|
|
1434
1638
|
_weight?: number;
|
|
1639
|
+
/** @internal */
|
|
1435
1640
|
_widthPx?: number;
|
|
1641
|
+
/** @internal */
|
|
1436
1642
|
_ofsPx?: number;
|
|
1437
1643
|
[key: string]: unknown;
|
|
1438
1644
|
}
|
|
@@ -1454,7 +1660,7 @@ declare module "types" {
|
|
|
1454
1660
|
[colId: string]: ColumnEventInfo;
|
|
1455
1661
|
};
|
|
1456
1662
|
/**
|
|
1457
|
-
* Additional
|
|
1663
|
+
* Additional information derived from mouse or keyboard events.
|
|
1458
1664
|
* @see {@link Wunderbaum.getEventInfo}
|
|
1459
1665
|
*/
|
|
1460
1666
|
export interface WbEventInfo {
|
|
@@ -1625,22 +1831,37 @@ declare module "types" {
|
|
|
1625
1831
|
/** Which node to scroll into the viewport.*/
|
|
1626
1832
|
node: WunderbaumNode;
|
|
1627
1833
|
}
|
|
1628
|
-
/** Possible values for {@link WunderbaumNode.setActive
|
|
1834
|
+
/** Possible values for {@link WunderbaumNode.setActive} `options` argument. */
|
|
1629
1835
|
export interface SetActiveOptions {
|
|
1630
|
-
/** 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). */
|
|
1631
1837
|
retrigger?: boolean;
|
|
1632
|
-
/** Do not generate (de)activate event (default: false). */
|
|
1838
|
+
/** Do not generate (de)activate event (@default: false). */
|
|
1633
1839
|
noEvents?: boolean;
|
|
1634
|
-
/**
|
|
1635
|
-
focusNode?: boolean;
|
|
1636
|
-
/** Set node as focused node (default: false). */
|
|
1840
|
+
/** Call `tree.setFocus()` to acquire keyboard focus (@default: false). */
|
|
1637
1841
|
focusTree?: boolean;
|
|
1638
1842
|
/** Optional original event that will be passed to the (de)activate handler. */
|
|
1639
1843
|
event?: Event;
|
|
1640
|
-
/**
|
|
1641
|
-
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;
|
|
1852
|
+
}
|
|
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;
|
|
1642
1863
|
}
|
|
1643
|
-
/** Possible values for {@link WunderbaumNode.setExpanded
|
|
1864
|
+
/** Possible values for {@link WunderbaumNode.setExpanded} `options` argument. */
|
|
1644
1865
|
export interface SetExpandedOptions {
|
|
1645
1866
|
/** Ignore {@link WunderbaumOptions.minExpandLevel}. @default false */
|
|
1646
1867
|
force?: boolean;
|
|
@@ -1740,46 +1961,63 @@ declare module "types" {
|
|
|
1740
1961
|
* Grayout unmatched nodes (pass "hide" to remove unmatched node instead)
|
|
1741
1962
|
* @default 'dim'
|
|
1742
1963
|
*/
|
|
1743
|
-
mode?:
|
|
1964
|
+
mode?: FilterModeType;
|
|
1744
1965
|
/**
|
|
1745
|
-
* 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.
|
|
1746
1968
|
* @default true
|
|
1747
1969
|
*/
|
|
1748
|
-
noData?: boolean;
|
|
1970
|
+
noData?: boolean | string;
|
|
1749
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
|
+
*/
|
|
1750
1978
|
export type EditOptionsType = {
|
|
1751
1979
|
/**
|
|
1980
|
+
* Used to debounce the `change` event handler for grid cells [ms].
|
|
1752
1981
|
* @default 100
|
|
1753
1982
|
*/
|
|
1754
1983
|
debounce?: number;
|
|
1755
1984
|
/**
|
|
1985
|
+
* Minimum number of characters required for node title input field.
|
|
1756
1986
|
* @default 1
|
|
1757
1987
|
*/
|
|
1758
1988
|
minlength?: number;
|
|
1759
1989
|
/**
|
|
1990
|
+
* Maximum number of characters allowed for node title input field.
|
|
1760
1991
|
* @default null;
|
|
1761
1992
|
*/
|
|
1762
1993
|
maxlength?: null | number;
|
|
1763
1994
|
/**
|
|
1764
|
-
*
|
|
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.
|
|
1765
2001
|
* @default []
|
|
1766
2002
|
*/
|
|
1767
2003
|
trigger?: string[];
|
|
1768
2004
|
/**
|
|
2005
|
+
* Trim whitespace before saving a node title.
|
|
1769
2006
|
* @default true
|
|
1770
2007
|
*/
|
|
1771
2008
|
trim?: boolean;
|
|
1772
2009
|
/**
|
|
2010
|
+
* Select all text of a node title, so it can be overwritten by typing.
|
|
1773
2011
|
* @default true
|
|
1774
2012
|
*/
|
|
1775
2013
|
select?: boolean;
|
|
1776
2014
|
/**
|
|
1777
|
-
* 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)
|
|
1778
2016
|
* @default 1000
|
|
1779
2017
|
*/
|
|
1780
2018
|
slowClickDelay?: number;
|
|
1781
2019
|
/**
|
|
1782
|
-
*
|
|
2020
|
+
* Permanently apply node title input validations (CSS and tooltip) on keydown.
|
|
1783
2021
|
* @default true
|
|
1784
2022
|
*/
|
|
1785
2023
|
validity?: boolean;
|
|
@@ -1975,140 +2213,6 @@ declare module "wb_extension_base" {
|
|
|
1975
2213
|
onRender(data: any): boolean | undefined;
|
|
1976
2214
|
}
|
|
1977
2215
|
}
|
|
1978
|
-
declare module "debounce" {
|
|
1979
|
-
/*!
|
|
1980
|
-
* debounce & throttle, taken from https://github.com/lodash/lodash v4.17.21
|
|
1981
|
-
* MIT License: https://raw.githubusercontent.com/lodash/lodash/4.17.21-npm/LICENSE
|
|
1982
|
-
* Modified for TypeScript type annotations.
|
|
1983
|
-
*/
|
|
1984
|
-
type Procedure = (...args: any[]) => any;
|
|
1985
|
-
type DebounceOptions = {
|
|
1986
|
-
leading?: boolean;
|
|
1987
|
-
maxWait?: number;
|
|
1988
|
-
trailing?: boolean;
|
|
1989
|
-
};
|
|
1990
|
-
type ThrottleOptions = {
|
|
1991
|
-
leading?: boolean;
|
|
1992
|
-
trailing?: boolean;
|
|
1993
|
-
};
|
|
1994
|
-
export interface DebouncedFunction<F extends Procedure> {
|
|
1995
|
-
(this: ThisParameterType<F>, ...args: Parameters<F>): ReturnType<F>;
|
|
1996
|
-
cancel: () => void;
|
|
1997
|
-
flush: () => any;
|
|
1998
|
-
pending: () => boolean;
|
|
1999
|
-
}
|
|
2000
|
-
/**
|
|
2001
|
-
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
2002
|
-
* milliseconds have elapsed since the last time the debounced function was
|
|
2003
|
-
* invoked, or until the next browser frame is drawn. The debounced function
|
|
2004
|
-
* comes with a `cancel` method to cancel delayed `func` invocations and a
|
|
2005
|
-
* `flush` method to immediately invoke them. Provide `options` to indicate
|
|
2006
|
-
* whether `func` should be invoked on the leading and/or trailing edge of the
|
|
2007
|
-
* `wait` timeout. The `func` is invoked with the last arguments provided to the
|
|
2008
|
-
* debounced function. Subsequent calls to the debounced function return the
|
|
2009
|
-
* result of the last `func` invocation.
|
|
2010
|
-
*
|
|
2011
|
-
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
2012
|
-
* invoked on the trailing edge of the timeout only if the debounced function
|
|
2013
|
-
* is invoked more than once during the `wait` timeout.
|
|
2014
|
-
*
|
|
2015
|
-
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
2016
|
-
* until the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
2017
|
-
*
|
|
2018
|
-
* If `wait` is omitted in an environment with `requestAnimationFrame`, `func`
|
|
2019
|
-
* invocation will be deferred until the next frame is drawn (typically about
|
|
2020
|
-
* 16ms).
|
|
2021
|
-
*
|
|
2022
|
-
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
2023
|
-
* for details over the differences between `debounce` and `throttle`.
|
|
2024
|
-
*
|
|
2025
|
-
* @since 0.1.0
|
|
2026
|
-
* @category Function
|
|
2027
|
-
* @param {Function} func The function to debounce.
|
|
2028
|
-
* @param {number} [wait=0]
|
|
2029
|
-
* The number of milliseconds to delay; if omitted, `requestAnimationFrame` is
|
|
2030
|
-
* used (if available).
|
|
2031
|
-
* @param {Object} [options={}] The options object.
|
|
2032
|
-
* @param {boolean} [options.leading=false]
|
|
2033
|
-
* Specify invoking on the leading edge of the timeout.
|
|
2034
|
-
* @param {number} [options.maxWait]
|
|
2035
|
-
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
2036
|
-
* @param {boolean} [options.trailing=true]
|
|
2037
|
-
* Specify invoking on the trailing edge of the timeout.
|
|
2038
|
-
* @returns {Function} Returns the new debounced function.
|
|
2039
|
-
* @example
|
|
2040
|
-
*
|
|
2041
|
-
* // Avoid costly calculations while the window size is in flux.
|
|
2042
|
-
* jQuery(window).on('resize', debounce(calculateLayout, 150))
|
|
2043
|
-
*
|
|
2044
|
-
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
2045
|
-
* jQuery(element).on('click', debounce(sendMail, 300, {
|
|
2046
|
-
* 'leading': true,
|
|
2047
|
-
* 'trailing': false
|
|
2048
|
-
* }))
|
|
2049
|
-
*
|
|
2050
|
-
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
2051
|
-
* const debounced = debounce(batchLog, 250, { 'maxWait': 1000 })
|
|
2052
|
-
* const source = new EventSource('/stream')
|
|
2053
|
-
* jQuery(source).on('message', debounced)
|
|
2054
|
-
*
|
|
2055
|
-
* // Cancel the trailing debounced invocation.
|
|
2056
|
-
* jQuery(window).on('popstate', debounced.cancel)
|
|
2057
|
-
*
|
|
2058
|
-
* // Check for pending invocations.
|
|
2059
|
-
* const status = debounced.pending() ? "Pending..." : "Ready"
|
|
2060
|
-
*/
|
|
2061
|
-
export function debounce<F extends Procedure>(func: F, wait?: number, options?: DebounceOptions): DebouncedFunction<F>;
|
|
2062
|
-
/**
|
|
2063
|
-
* Creates a throttled function that only invokes `func` at most once per
|
|
2064
|
-
* every `wait` milliseconds (or once per browser frame). The throttled function
|
|
2065
|
-
* comes with a `cancel` method to cancel delayed `func` invocations and a
|
|
2066
|
-
* `flush` method to immediately invoke them. Provide `options` to indicate
|
|
2067
|
-
* whether `func` should be invoked on the leading and/or trailing edge of the
|
|
2068
|
-
* `wait` timeout. The `func` is invoked with the last arguments provided to the
|
|
2069
|
-
* throttled function. Subsequent calls to the throttled function return the
|
|
2070
|
-
* result of the last `func` invocation.
|
|
2071
|
-
*
|
|
2072
|
-
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
2073
|
-
* invoked on the trailing edge of the timeout only if the throttled function
|
|
2074
|
-
* is invoked more than once during the `wait` timeout.
|
|
2075
|
-
*
|
|
2076
|
-
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
2077
|
-
* until the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
2078
|
-
*
|
|
2079
|
-
* If `wait` is omitted in an environment with `requestAnimationFrame`, `func`
|
|
2080
|
-
* invocation will be deferred until the next frame is drawn (typically about
|
|
2081
|
-
* 16ms).
|
|
2082
|
-
*
|
|
2083
|
-
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
2084
|
-
* for details over the differences between `throttle` and `debounce`.
|
|
2085
|
-
*
|
|
2086
|
-
* @since 0.1.0
|
|
2087
|
-
* @category Function
|
|
2088
|
-
* @param {Function} func The function to throttle.
|
|
2089
|
-
* @param {number} [wait=0]
|
|
2090
|
-
* The number of milliseconds to throttle invocations to; if omitted,
|
|
2091
|
-
* `requestAnimationFrame` is used (if available).
|
|
2092
|
-
* @param {Object} [options={}] The options object.
|
|
2093
|
-
* @param {boolean} [options.leading=true]
|
|
2094
|
-
* Specify invoking on the leading edge of the timeout.
|
|
2095
|
-
* @param {boolean} [options.trailing=true]
|
|
2096
|
-
* Specify invoking on the trailing edge of the timeout.
|
|
2097
|
-
* @returns {Function} Returns the new throttled function.
|
|
2098
|
-
* @example
|
|
2099
|
-
*
|
|
2100
|
-
* // Avoid excessively updating the position while scrolling.
|
|
2101
|
-
* jQuery(window).on('scroll', throttle(updatePosition, 100))
|
|
2102
|
-
*
|
|
2103
|
-
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
|
|
2104
|
-
* const throttled = throttle(renewToken, 300000, { 'trailing': false })
|
|
2105
|
-
* jQuery(element).on('click', throttled)
|
|
2106
|
-
*
|
|
2107
|
-
* // Cancel the trailing throttled invocation.
|
|
2108
|
-
* jQuery(window).on('popstate', throttled.cancel)
|
|
2109
|
-
*/
|
|
2110
|
-
export function throttle<F extends Procedure>(func: F, wait?: number, options?: ThrottleOptions): DebouncedFunction<F>;
|
|
2111
|
-
}
|
|
2112
2216
|
declare module "wb_ext_filter" {
|
|
2113
2217
|
import { FilterNodesOptions, FilterOptionsType, NodeFilterCallback } from "types";
|
|
2114
2218
|
import { Wunderbaum } from "wunderbaum";
|
|
@@ -2299,7 +2403,7 @@ declare module "wb_ext_edit" {
|
|
|
2299
2403
|
protected curEditNode: WunderbaumNode | null;
|
|
2300
2404
|
protected relatedNode: WunderbaumNode | null;
|
|
2301
2405
|
constructor(tree: Wunderbaum);
|
|
2302
|
-
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>;
|
|
2303
2407
|
protected _onChange(e: Event): void;
|
|
2304
2408
|
init(): void;
|
|
2305
2409
|
_preprocessKeyEvent(data: any): boolean | undefined;
|
|
@@ -2335,13 +2439,14 @@ declare module "wunderbaum" {
|
|
|
2335
2439
|
*/
|
|
2336
2440
|
import * as util from "util";
|
|
2337
2441
|
import { ExtensionsDict, WunderbaumExtension } from "wb_extension_base";
|
|
2338
|
-
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";
|
|
2339
2443
|
import { WunderbaumNode } from "wb_node";
|
|
2340
2444
|
import { WunderbaumOptions } from "wb_options";
|
|
2445
|
+
import { DebouncedFunction } from "debounce";
|
|
2341
2446
|
/**
|
|
2342
2447
|
* A persistent plain object or array.
|
|
2343
2448
|
*
|
|
2344
|
-
* See also
|
|
2449
|
+
* See also {@link WunderbaumOptions}.
|
|
2345
2450
|
*/
|
|
2346
2451
|
export class Wunderbaum {
|
|
2347
2452
|
protected static sequence: number;
|
|
@@ -2364,7 +2469,7 @@ declare module "wunderbaum" {
|
|
|
2364
2469
|
readonly data: {
|
|
2365
2470
|
[key: string]: any;
|
|
2366
2471
|
};
|
|
2367
|
-
protected readonly _updateViewportThrottled: (
|
|
2472
|
+
protected readonly _updateViewportThrottled: DebouncedFunction<() => void>;
|
|
2368
2473
|
protected extensionList: WunderbaumExtension<any>[];
|
|
2369
2474
|
protected extensions: ExtensionsDict;
|
|
2370
2475
|
/** Merged options from constructor args and tree- and extension defaults. */
|
|
@@ -2399,7 +2504,7 @@ declare module "wunderbaum" {
|
|
|
2399
2504
|
/** Expose some useful methods of the util.ts module as `tree._util`. */
|
|
2400
2505
|
_util: typeof util;
|
|
2401
2506
|
filterMode: FilterModeType;
|
|
2402
|
-
/** @internal Use `setColumn()`/`getActiveColElem()
|
|
2507
|
+
/** @internal Use `setColumn()`/`getActiveColElem()` to access. */
|
|
2403
2508
|
activeColIdx: number;
|
|
2404
2509
|
/** @internal */
|
|
2405
2510
|
_cellNavMode: boolean;
|
|
@@ -2417,7 +2522,7 @@ declare module "wunderbaum" {
|
|
|
2417
2522
|
* getTree(1); // Get second Wunderbaum instance on page
|
|
2418
2523
|
* getTree(event); // Get tree for this mouse- or keyboard event
|
|
2419
2524
|
* getTree("foo"); // Get tree for this `tree.options.id`
|
|
2420
|
-
* getTree("#tree"); // Get tree for
|
|
2525
|
+
* getTree("#tree"); // Get tree for first matching element selector
|
|
2421
2526
|
* ```
|
|
2422
2527
|
*/
|
|
2423
2528
|
static getTree(el?: Element | Event | number | string | WunderbaumNode): Wunderbaum | null;
|
|
@@ -2559,20 +2664,32 @@ declare module "wunderbaum" {
|
|
|
2559
2664
|
/**
|
|
2560
2665
|
* Find all nodes that match condition.
|
|
2561
2666
|
*
|
|
2667
|
+
* @param match title string to search for, or a
|
|
2668
|
+
* callback function that returns `true` if a node is matched.
|
|
2562
2669
|
* @see {@link WunderbaumNode.findAll}
|
|
2563
2670
|
*/
|
|
2564
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[];
|
|
2565
2682
|
/**
|
|
2566
2683
|
* Find first node that matches condition.
|
|
2567
2684
|
*
|
|
2685
|
+
* @param match title string to search for, or a
|
|
2686
|
+
* callback function that returns `true` if a node is matched.
|
|
2568
2687
|
* @see {@link WunderbaumNode.findFirst}
|
|
2569
2688
|
*/
|
|
2570
2689
|
findFirst(match: string | RegExp | MatcherCallback): WunderbaumNode;
|
|
2571
2690
|
/**
|
|
2572
2691
|
* Find first node that matches condition.
|
|
2573
2692
|
*
|
|
2574
|
-
* @param match title string to search for, or a
|
|
2575
|
-
* callback function that returns `true` if a node is matched.
|
|
2576
2693
|
* @see {@link WunderbaumNode.findFirst}
|
|
2577
2694
|
*
|
|
2578
2695
|
*/
|
|
@@ -2580,6 +2697,7 @@ declare module "wunderbaum" {
|
|
|
2580
2697
|
/**
|
|
2581
2698
|
* Find the next visible node that starts with `match`, starting at `startNode`
|
|
2582
2699
|
* and wrap-around at the end.
|
|
2700
|
+
* Used by quicksearch and keyboard navigation.
|
|
2583
2701
|
*/
|
|
2584
2702
|
findNextNode(match: string | MatcherCallback, startNode?: WunderbaumNode | null): WunderbaumNode | null;
|
|
2585
2703
|
/**
|
|
@@ -2623,6 +2741,9 @@ declare module "wunderbaum" {
|
|
|
2623
2741
|
getActiveColElem(): HTMLSpanElement;
|
|
2624
2742
|
/**
|
|
2625
2743
|
* Return the currently active node or null.
|
|
2744
|
+
* @see {@link WunderbaumNode.setActive}
|
|
2745
|
+
* @see {@link WunderbaumNode.isActive}
|
|
2746
|
+
* @see {@link WunderbaumNode.getFocusNode}
|
|
2626
2747
|
*/
|
|
2627
2748
|
getActiveNode(): WunderbaumNode;
|
|
2628
2749
|
/**
|
|
@@ -2630,7 +2751,8 @@ declare module "wunderbaum" {
|
|
|
2630
2751
|
*/
|
|
2631
2752
|
getFirstChild(): WunderbaumNode;
|
|
2632
2753
|
/**
|
|
2633
|
-
* Return the currently
|
|
2754
|
+
* Return the node that currently has keyboard focus or null.
|
|
2755
|
+
* @see {@link WunderbaumNode.getActiveNode}
|
|
2634
2756
|
*/
|
|
2635
2757
|
getFocusNode(): WunderbaumNode;
|
|
2636
2758
|
/** Return a {node: WunderbaumNode, region: TYPE} object for a mouse event.
|
|
@@ -2645,8 +2767,16 @@ declare module "wunderbaum" {
|
|
|
2645
2767
|
* @internal
|
|
2646
2768
|
*/
|
|
2647
2769
|
toString(): string;
|
|
2648
|
-
/** 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
|
+
*/
|
|
2649
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;
|
|
2650
2780
|
/**
|
|
2651
2781
|
* Return true if any node is currently beeing loaded, i.e. a Ajax request is pending.
|
|
2652
2782
|
*/
|
|
@@ -2682,18 +2812,23 @@ declare module "wunderbaum" {
|
|
|
2682
2812
|
/**
|
|
2683
2813
|
* Set column #colIdx to 'active'.
|
|
2684
2814
|
*
|
|
2685
|
-
* 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>
|
|
2686
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.
|
|
2687
2821
|
*/
|
|
2688
|
-
setColumn(colIdx: number): void;
|
|
2689
|
-
/** Set or remove
|
|
2822
|
+
setColumn(colIdx: number | string, options?: SetColumnOptions): void;
|
|
2823
|
+
/** Set or remove keyboard focus to the tree container. */
|
|
2690
2824
|
setActiveNode(key: string, flag?: boolean, options?: SetActiveOptions): void;
|
|
2691
|
-
/** Set or remove
|
|
2825
|
+
/** Set or remove keyboard focus to the tree container. */
|
|
2692
2826
|
setFocus(flag?: boolean): void;
|
|
2693
2827
|
/**
|
|
2694
2828
|
* Schedule an update request to reflect a tree change.
|
|
2695
2829
|
* The render operation is async and debounced unless the `immediate` option
|
|
2696
2830
|
* is set.
|
|
2831
|
+
*
|
|
2697
2832
|
* Use {@link WunderbaumNode.update()} if only a single node has changed,
|
|
2698
2833
|
* or {@link WunderbaumNode._render()}) to pass special options.
|
|
2699
2834
|
*/
|
|
@@ -2820,29 +2955,23 @@ declare module "wunderbaum" {
|
|
|
2820
2955
|
*/
|
|
2821
2956
|
enableUpdate(flag: boolean): void;
|
|
2822
2957
|
/**
|
|
2823
|
-
*
|
|
2958
|
+
* Dim or hide nodes.
|
|
2824
2959
|
*/
|
|
2825
2960
|
filterNodes(filter: string | NodeFilterCallback, options: FilterNodesOptions): void;
|
|
2826
2961
|
/**
|
|
2827
|
-
*
|
|
2962
|
+
* Dim or hide whole branches.
|
|
2828
2963
|
*/
|
|
2829
2964
|
filterBranches(filter: string | NodeFilterCallback, options: FilterNodesOptions): void;
|
|
2830
2965
|
/**
|
|
2831
|
-
*
|
|
2832
|
-
*
|
|
2833
|
-
* @requires [[FilterExtension]]
|
|
2966
|
+
* Reset the filter.
|
|
2834
2967
|
*/
|
|
2835
2968
|
clearFilter(): void;
|
|
2836
2969
|
/**
|
|
2837
|
-
*
|
|
2838
|
-
*
|
|
2839
|
-
* @requires [[FilterExtension]]
|
|
2970
|
+
* Return true if a filter is currently applied.
|
|
2840
2971
|
*/
|
|
2841
2972
|
isFilterActive(): boolean;
|
|
2842
2973
|
/**
|
|
2843
|
-
*
|
|
2844
|
-
*
|
|
2845
|
-
* @requires [[FilterExtension]]
|
|
2974
|
+
* Re-apply current filter.
|
|
2846
2975
|
*/
|
|
2847
2976
|
updateFilter(): void;
|
|
2848
2977
|
}
|