wunderbaum 0.0.1-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.
@@ -0,0 +1,1348 @@
1
+ declare module "util" {
2
+ /*!
3
+ * Wunderbaum - util
4
+ * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
5
+ * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
6
+ */
7
+ /** Readable names for `MouseEvent.button` */
8
+ export const MOUSE_BUTTONS: {
9
+ [key: number]: string;
10
+ };
11
+ export const MAX_INT = 9007199254740991;
12
+ /**True if the user is using a macOS platform. */
13
+ export const isMac: boolean;
14
+ export type FunctionType = (...args: any[]) => any;
15
+ export type EventCallbackType = (e: Event) => boolean | void;
16
+ /**
17
+ * A ES6 Promise, that exposes the resolve()/reject() methods.
18
+ */
19
+ export class Deferred {
20
+ private thens;
21
+ private catches;
22
+ private status;
23
+ private resolvedValue;
24
+ private rejectedError;
25
+ constructor();
26
+ resolve(value?: any): void;
27
+ reject(error?: any): void;
28
+ then(cb: any): void;
29
+ catch(cb: any): void;
30
+ promise(): {
31
+ then: (cb: any) => void;
32
+ catch: (cb: any) => void;
33
+ };
34
+ }
35
+ /**Throw an `Error` if `cond` is falsey. */
36
+ export function assert(cond: any, msg?: string): void;
37
+ /** Run `callback` when document was loaded. */
38
+ export function documentReady(callback: () => void): void;
39
+ /** Resolve when document was loaded. */
40
+ export function documentReadyPromise(): Promise<void>;
41
+ /**
42
+ * Iterate over Object properties or array elements.
43
+ *
44
+ * @param obj `Object`, `Array` or null
45
+ * @param callback(index, item) called for every item.
46
+ * `this` also contains the item.
47
+ * Return `false` to stop the iteration.
48
+ */
49
+ export function each(obj: any, callback: (index: number | string, item: any) => void | boolean): any;
50
+ /** Shortcut for `throw new Error(msg)`.*/
51
+ export function error(msg: string): void;
52
+ /** Convert `<`, `>`, `&`, `"`, `'`, and `/` to the equivalent entities. */
53
+ export function escapeHtml(s: string): string;
54
+ /**Convert a regular expression string by escaping special characters (e.g. `"$"` -> `"\$"`) */
55
+ export function escapeRegex(s: string): string;
56
+ /** Convert `<`, `>`, `"`, `'`, and `/` (but not `&`) to the equivalent entities. */
57
+ export function escapeTooltip(s: string): string;
58
+ /** TODO */
59
+ export function extractHtmlText(s: string): string;
60
+ /**
61
+ * Read the value from an HTML input element.
62
+ *
63
+ * If a `<span class="wb-col">` is passed, the first child input is used.
64
+ * Depending on the target element type, `value` is interpreted accordingly.
65
+ * For example for a checkbox, a value of true, false, or null is returned if the
66
+ * the element is checked, unchecked, or indeterminate.
67
+ * For datetime input control a numerical value is assumed, etc.
68
+ *
69
+ * Common use case: store the new user input in the `change` event:
70
+ *
71
+ * ```ts
72
+ * change: (e) => {
73
+ * // Read the value from the input control that triggered the change event:
74
+ * let value = e.tree.getValueFromElem(e.element);
75
+ * //
76
+ * e.node.data[]
77
+ * },
78
+ * ```
79
+ * @param elem `<input>` or `<select>` element Also a parent `span.wb-col` is accepted.
80
+ * @param coerce pass true to convert date/time inputs to `Date`.
81
+ * @returns the value
82
+ */
83
+ export function getValueFromElem(elem: HTMLElement, coerce?: boolean): any;
84
+ /**
85
+ * Set the value of an HTML input element.
86
+ *
87
+ * If a `<span class="wb-col">` is passed, the first child input is used.
88
+ * Depending on the target element type, `value` is interpreted accordingly.
89
+ * For example a checkbox is set to checked, unchecked, or indeterminate if the
90
+ * value is truethy, falsy, or `null`.
91
+ * For datetime input control a numerical value is assumed, etc.
92
+ *
93
+ * @param elem `<input>` or `<select>` element Also a parent `span.wb-col` is accepted.
94
+ * @param value a value that matches the target element.
95
+ */
96
+ export function setValueToElem(elem: HTMLElement, value: any): void;
97
+ /** Return an unconnected `HTMLElement` from a HTML string. */
98
+ export function elemFromHtml(html: string): HTMLElement;
99
+ /** Return a HtmlElement from selector or cast an existing element. */
100
+ export function elemFromSelector(obj: string | Element): HTMLElement | null;
101
+ /**
102
+ * Return a descriptive string for a keyboard or mouse event.
103
+ *
104
+ * The result also contains a prefix for modifiers if any, for example
105
+ * `"x"`, `"F2"`, `"Control+Home"`, or `"Shift+clickright"`.
106
+ */
107
+ export function eventToString(event: Event): string;
108
+ export function extend(...args: any[]): any;
109
+ export function isArray(obj: any): boolean;
110
+ export function isEmptyObject(obj: any): boolean;
111
+ export function isFunction(obj: any): boolean;
112
+ export function isPlainObject(obj: any): boolean;
113
+ /** A dummy function that does nothing ('no operation'). */
114
+ export function noop(...args: any[]): any;
115
+ /**
116
+ * Bind one or more event handlers directly to an [[HtmlElement]].
117
+ *
118
+ * @param element HTMLElement or selector
119
+ * @param eventNames
120
+ * @param handler
121
+ */
122
+ export function onEvent(rootElem: HTMLElement | string, eventNames: string, handler: EventCallbackType): void;
123
+ /**
124
+ * Bind one or more event handlers using event delegation.
125
+ *
126
+ * E.g. handle all 'input' events for input and textarea elements of a given
127
+ * form:
128
+ * ```ts
129
+ * onEvent("#form_1", "input", "input,textarea", function (e: Event) {
130
+ * console.log(e.type, e.target);
131
+ * });
132
+ * ```
133
+ *
134
+ * @param element HTMLElement or selector
135
+ * @param eventNames
136
+ * @param selector
137
+ * @param handler
138
+ */
139
+ export function onEvent(rootElem: HTMLElement | string, eventNames: string, selector: string, handler: EventCallbackType): void;
140
+ /** Return a wrapped handler method, that provides `this._super`.
141
+ *
142
+ * ```ts
143
+ // Implement `opts.createNode` event to add the 'draggable' attribute
144
+ overrideMethod(ctx.options, "createNode", (event, data) => {
145
+ // Default processing if any
146
+ this._super.apply(this, event, data);
147
+ // Add 'draggable' attribute
148
+ data.node.span.draggable = true;
149
+ });
150
+ ```
151
+ */
152
+ export function overrideMethod(instance: any, methodName: string, handler: FunctionType, ctx?: any): void;
153
+ /** Run function after ms milliseconds and return a promise that resolves when done. */
154
+ export function setTimeoutPromise(callback: (...args: any[]) => void, ms: number): Promise<unknown>;
155
+ /**
156
+ * Wait `ms` microseconds.
157
+ *
158
+ * Example:
159
+ * ```js
160
+ * await sleep(1000);
161
+ * ```
162
+ * @param ms duration
163
+ * @returns
164
+ */
165
+ export function sleep(ms: number): Promise<unknown>;
166
+ /**
167
+ * Set or rotate checkbox status with support for tri-state.
168
+ */
169
+ export function toggleCheckbox(element: HTMLElement | string, value?: boolean | null, tristate?: boolean): void;
170
+ /**
171
+ * Return `opts.NAME` if opts is valid and
172
+ *
173
+ * @param opts dict, object, or null
174
+ * @param name option name (use dot notation to access extension option, e.g. `filter.mode`)
175
+ * @param defaultValue returned when `opts` is not an object, or does not have a NAME property
176
+ */
177
+ export function getOption(opts: any, name: string, defaultValue?: any): any;
178
+ /** Convert an Array or space-separated string to a Set. */
179
+ export function toSet(val: any): Set<string>;
180
+ export function type(obj: any): string;
181
+ }
182
+ declare module "deferred" {
183
+ /*!
184
+ * Wunderbaum - deferred
185
+ * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
186
+ * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
187
+ */
188
+ type PromiseCallbackType = (val: any) => void;
189
+ type finallyCallbackType = () => void;
190
+ /**
191
+ * Deferred is a ES6 Promise, that exposes the resolve() and reject()` method.
192
+ *
193
+ * Loosely mimics [`jQuery.Deferred`](https://api.jquery.com/category/deferred-object/).
194
+ */
195
+ export class Deferred {
196
+ private _promise;
197
+ protected _resolve: any;
198
+ protected _reject: any;
199
+ constructor();
200
+ /** Resolve the [[Promise]]. */
201
+ resolve(value?: any): void;
202
+ /** Reject the [[Promise]]. */
203
+ reject(reason?: any): void;
204
+ /** Return the native [[Promise]] instance.*/
205
+ promise(): Promise<any>;
206
+ /** Call [[Promise.then]] on the embedded promise instance.*/
207
+ then(cb: PromiseCallbackType): Promise<void>;
208
+ /** Call [[Promise.catch]] on the embedded promise instance.*/
209
+ catch(cb: PromiseCallbackType): Promise<any>;
210
+ /** Call [[Promise.finally]] on the embedded promise instance.*/
211
+ finally(cb: finallyCallbackType): Promise<any>;
212
+ }
213
+ }
214
+ declare module "wb_options" {
215
+ /*!
216
+ * Wunderbaum - utils
217
+ * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
218
+ * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
219
+ */
220
+ import { BoolOptionResolver, NavigationModeOption, WbEventType } from "common";
221
+ export interface WbNodeData {
222
+ title: string;
223
+ key?: string;
224
+ refKey?: string;
225
+ expanded?: boolean;
226
+ selected?: boolean;
227
+ checkbox?: boolean | "radio" | BoolOptionResolver;
228
+ children?: Array<WbNodeData>;
229
+ }
230
+ /**
231
+ * Available options for [[Wunderbaum]].
232
+ *
233
+ * Options are passed to the constructor as plain object:
234
+ *
235
+ * ```js
236
+ * const tree = new mar10.Wunderbaum({
237
+ * id: "demo",
238
+ * element: document.querySelector("#demo-tree"),
239
+ * source: "url/of/data/request",
240
+ * ...
241
+ * });
242
+ * ```
243
+ */
244
+ export interface WunderbaumOptions {
245
+ /**
246
+ * The target `div` element (or selector) that shall become a Wunderbaum.
247
+ */
248
+ element: string | HTMLDivElement;
249
+ /**
250
+ * The identifier of this tree. Used to reference the instance, especially
251
+ * when multiple trees are present (e.g. `tree = mar10.Wunderbaum.getTree("demo")`).
252
+ *
253
+ * Default: `"wb_" + COUNTER`.
254
+ */
255
+ id?: string;
256
+ /**
257
+ * Define the initial tree data. Typically a URL of an endpoint that serves
258
+ * a JSON formatted structure, but also a callback, Promise, or static data
259
+ * is allowed.
260
+ *
261
+ * Default: `{}`.
262
+ */
263
+ source?: string | Array<WbNodeData>;
264
+ /**
265
+ * Define shared attributes for multiple nodes of the same type.
266
+ * This allows for more compact data models. Type definitions can be passed
267
+ * as tree option, or be part of a `source` response.
268
+ *
269
+ * Default: `{}`.
270
+ */
271
+ types: any;
272
+ /**
273
+ * A list of maps that define column headers. If this option is set,
274
+ * Wunderbaum becomes a tree-grid control instead of a plain tree.
275
+ * Column definitions can be passed as tree option, or be part of a `source`
276
+ * response.
277
+ * Default: `[]` meaning this is a plain tree.
278
+ */
279
+ columns?: Array<any>;
280
+ /**
281
+ *
282
+ * Default: false.
283
+ */
284
+ skeleton: false;
285
+ /**
286
+ *
287
+ * Default: false.
288
+ */
289
+ strings: any;
290
+ /**
291
+ */
292
+ debugLevel: 3;
293
+ minExpandLevel: 0;
294
+ escapeTitles: true;
295
+ headerHeightPx: 22;
296
+ autoCollapse: false;
297
+ dnd: any;
298
+ filter: any;
299
+ /**
300
+ * A list of maps that define column headers. If this option is set,
301
+ * Wunderbaum becomes a tree grid control instead of a plain tree.
302
+ * Column definitions can be passed as tree option, or be part of a `source`
303
+ * response.
304
+ */
305
+ navigationMode?: NavigationModeOption;
306
+ /**
307
+ * Called after initial data was loaded and tree markup was rendered.
308
+ * @category Callback
309
+ */
310
+ init?: (e: WbEventType) => void;
311
+ /**
312
+ * Called after data was loaded from local storage.
313
+ * @category Callback
314
+ */
315
+ update?: (e: WbEventType) => void;
316
+ /**
317
+ * Called after data was loaded from local storage.
318
+ * @category Callback
319
+ */
320
+ modifyChild?: (e: WbEventType) => void;
321
+ }
322
+ }
323
+ declare module "wb_node" {
324
+ /*!
325
+ * Wunderbaum - wunderbaum_node
326
+ * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
327
+ * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
328
+ */
329
+ import "./wunderbaum.scss";
330
+ import { Wunderbaum } from "wunderbaum";
331
+ import { ChangeType, MatcherType, NodeAnyCallback, NodeStatusType, NodeVisitCallback, NodeVisitResponse, ApplyCommandType, AddNodeType } from "common";
332
+ import { WbNodeData } from "wb_options";
333
+ export class WunderbaumNode {
334
+ static sequence: number;
335
+ /** Reference to owning tree. */
336
+ tree: Wunderbaum;
337
+ /** Parent node (null for the invisible root node `tree.root`). */
338
+ parent: WunderbaumNode;
339
+ title: string;
340
+ readonly key: string;
341
+ readonly refKey: string | undefined;
342
+ children: WunderbaumNode[] | null;
343
+ checkbox?: boolean;
344
+ colspan?: boolean;
345
+ icon?: boolean | string;
346
+ lazy: boolean;
347
+ expanded: boolean;
348
+ selected: boolean;
349
+ type?: string;
350
+ tooltip?: string;
351
+ /** Additional classes added to `div.wb-row`. */
352
+ extraClasses: Set<string>;
353
+ /** Custom data that was passed to the constructor */
354
+ data: any;
355
+ statusNodeType?: string;
356
+ _isLoading: boolean;
357
+ _requestId: number;
358
+ _errorInfo: any | null;
359
+ _partsel: boolean;
360
+ _partload: boolean;
361
+ match?: boolean;
362
+ subMatchCount?: number;
363
+ subMatchBadge?: HTMLElement;
364
+ titleWithHighlight?: string;
365
+ _filterAutoExpanded?: boolean;
366
+ _rowIdx: number | undefined;
367
+ _rowElem: HTMLDivElement | undefined;
368
+ constructor(tree: Wunderbaum, parent: WunderbaumNode, data: any);
369
+ /**
370
+ * Return readable string representation for this instance.
371
+ * @internal
372
+ */
373
+ toString(): string;
374
+ /** Call event handler if defined in tree.options.
375
+ * Example:
376
+ * ```js
377
+ * node._callEvent("edit.beforeEdit", {foo: 42})
378
+ * ```
379
+ */
380
+ _callEvent(name: string, extra?: any): any;
381
+ /**
382
+ * Append (or insert) a list of child nodes.
383
+ *
384
+ * Tip: pass `{ before: 0 }` to prepend children
385
+ * @param {NodeData[]} nodeData array of child node definitions (also single child accepted)
386
+ * @param child node (or key or index of such).
387
+ * If omitted, the new children are appended.
388
+ * @returns first child added
389
+ */
390
+ addChildren(nodeData: any, options?: any): WunderbaumNode;
391
+ /**
392
+ * Append or prepend a node, or append a child node.
393
+ *
394
+ * This a convenience function that calls addChildren()
395
+ *
396
+ * @param {NodeData} node node definition
397
+ * @param [mode=child] 'before', 'after', 'firstChild', or 'child' ('over' is a synonym for 'child')
398
+ * @returns new node
399
+ */
400
+ addNode(nodeData: WbNodeData, mode?: string): WunderbaumNode;
401
+ /**
402
+ * Apply a modification (or navigation) operation.
403
+ * @see Wunderbaum#applyCommand
404
+ */
405
+ applyCommand(cmd: ApplyCommandType, opts: any): any;
406
+ addClass(className: string | string[] | Set<string>): void;
407
+ removeClass(className: string | string[] | Set<string>): void;
408
+ toggleClass(className: string | string[] | Set<string>, flag: boolean): void;
409
+ /** */
410
+ expandAll(flag?: boolean): Promise<void>;
411
+ /**Find all nodes that match condition (excluding self).
412
+ *
413
+ * @param {string | function(node)} match title string to search for, or a
414
+ * callback function that returns `true` if a node is matched.
415
+ */
416
+ findAll(match: string | MatcherType): WunderbaumNode[];
417
+ /** Return the direct child with a given key, index or null. */
418
+ findDirectChild(ptr: number | string | WunderbaumNode): WunderbaumNode | null;
419
+ /**Find first node that matches condition (excluding self).
420
+ *
421
+ * @param match title string to search for, or a
422
+ * callback function that returns `true` if a node is matched.
423
+ */
424
+ findFirst(match: string | MatcherType): WunderbaumNode | null;
425
+ /** Find a node relative to self.
426
+ *
427
+ * @param where The keyCode that would normally trigger this move,
428
+ * or a keyword ('down', 'first', 'last', 'left', 'parent', 'right', 'up').
429
+ */
430
+ findRelatedNode(where: string, includeHidden?: boolean): any;
431
+ /** Return the `<span class='wb-col'>` element with a given index or id.
432
+ * @returns {WunderbaumNode | null}
433
+ */
434
+ getColElem(colIdx: number | string): HTMLSpanElement;
435
+ /** Return the first child node or null.
436
+ * @returns {WunderbaumNode | null}
437
+ */
438
+ getFirstChild(): WunderbaumNode;
439
+ /** Return the last child node or null.
440
+ * @returns {WunderbaumNode | null}
441
+ */
442
+ getLastChild(): WunderbaumNode;
443
+ /** Return node depth (starting with 1 for top level nodes). */
444
+ getLevel(): number;
445
+ /** Return the successive node (under the same parent) or null. */
446
+ getNextSibling(): WunderbaumNode | null;
447
+ /** Return the parent node (null for the system root node). */
448
+ getParent(): WunderbaumNode | null;
449
+ /** Return an array of all parent nodes (top-down).
450
+ * @param includeRoot Include the invisible system root node.
451
+ * @param includeSelf Include the node itself.
452
+ */
453
+ getParentList(includeRoot?: boolean, includeSelf?: boolean): any[];
454
+ /** Return a string representing the hierachical node path, e.g. "a/b/c".
455
+ * @param includeSelf
456
+ * @param node property name or callback
457
+ * @param separator
458
+ */
459
+ getPath(includeSelf?: boolean, part?: keyof WunderbaumNode | NodeAnyCallback, separator?: string): string;
460
+ /** Return the preceeding node (under the same parent) or null. */
461
+ getPrevSibling(): WunderbaumNode | null;
462
+ /** Return true if node has children.
463
+ * Return undefined if not sure, i.e. the node is lazy and not yet loaded.
464
+ */
465
+ hasChildren(): boolean;
466
+ /** Return true if this node is the currently active tree node. */
467
+ isActive(): boolean;
468
+ /** Return true if this node is a *direct* child of `other`.
469
+ * (See also [[isDescendantOf]].)
470
+ */
471
+ isChildOf(other: WunderbaumNode): boolean;
472
+ /** Return true if this node is a direct or indirect sub node of `other`.
473
+ * (See also [[isChildOf]].)
474
+ */
475
+ isDescendantOf(other: WunderbaumNode): boolean;
476
+ /** Return true if this node has children, i.e. the node is generally expandable.
477
+ * If `andCollapsed` is set, we also check if this node is collapsed, i.e.
478
+ * an expand operation is currently possible.
479
+ */
480
+ isExpandable(andCollapsed?: boolean): boolean;
481
+ /** Return true if this node is currently in edit-title mode. */
482
+ isEditing(): boolean;
483
+ /** Return true if this node is currently expanded. */
484
+ isExpanded(): boolean;
485
+ /** Return true if this node is the first node of its parent's children. */
486
+ isFirstSibling(): boolean;
487
+ /** Return true if this node is the last node of its parent's children. */
488
+ isLastSibling(): boolean;
489
+ /** Return true if this node is lazy (even if data was already loaded) */
490
+ isLazy(): boolean;
491
+ /** Return true if node is lazy and loaded. For non-lazy nodes always return true. */
492
+ isLoaded(): boolean;
493
+ /** Return true if node is currently loading, i.e. a GET request is pending. */
494
+ isLoading(): boolean;
495
+ /** Return true if this node is a temporarily generated status node of type 'paging'. */
496
+ isPagingNode(): boolean;
497
+ /** (experimental) Return true if this node is partially loaded. */
498
+ isPartload(): boolean;
499
+ /** Return true if this node is partially selected (tri-state). */
500
+ isPartsel(): boolean;
501
+ /** Return true if this node has DOM representaion, i.e. is displayed in the viewport. */
502
+ isRendered(): boolean;
503
+ /** Return true if this node is the (invisible) system root node.
504
+ * (See also [[isTopLevel()]].)
505
+ */
506
+ isRootNode(): boolean;
507
+ /** Return true if this node is selected, i.e. the checkbox is set. */
508
+ isSelected(): boolean;
509
+ /** Return true if this node is a temporarily generated system node like
510
+ * 'loading', 'paging', or 'error' (node.statusNodeType contains the type).
511
+ */
512
+ isStatusNode(): boolean;
513
+ /** Return true if this a top level node, i.e. a direct child of the (invisible) system root node. */
514
+ isTopLevel(): boolean;
515
+ /** Return true if node is marked lazy but not yet loaded.
516
+ * For non-lazy nodes always return false.
517
+ */
518
+ isUnloaded(): boolean;
519
+ /** Return true if all parent nodes are expanded. Note: this does not check
520
+ * whether the node is scrolled into the visible part of the screen or viewport.
521
+ */
522
+ isVisible(): boolean;
523
+ protected _loadSourceObject(source: any): void;
524
+ /** Download data from the cloud, then call `.update()`. */
525
+ load(source: any): Promise<void>;
526
+ /**Load content of a lazy node. */
527
+ loadLazy(forceReload?: boolean): Promise<void>;
528
+ /** Alias for `logDebug` */
529
+ log(...args: any[]): void;
530
+ logDebug(...args: any[]): void;
531
+ logError(...args: any[]): void;
532
+ logInfo(...args: any[]): void;
533
+ logWarn(...args: any[]): void;
534
+ /** Expand all parents and optionally scroll into visible area as neccessary.
535
+ * Promise is resolved, when lazy loading and animations are done.
536
+ * @param {object} [opts] passed to `setExpanded()`.
537
+ * Defaults to {noAnimation: false, noEvents: false, scrollIntoView: true}
538
+ */
539
+ makeVisible(opts: any): Promise<any>;
540
+ /** Move this node to targetNode. */
541
+ moveTo(targetNode: WunderbaumNode, mode?: AddNodeType, map?: NodeAnyCallback): void;
542
+ /** Set focus relative to this node and optionally activate.
543
+ *
544
+ * 'left' collapses the node if it is expanded, or move to the parent
545
+ * otherwise.
546
+ * 'right' expands the node if it is collapsed, or move to the first
547
+ * child otherwise.
548
+ *
549
+ * @param where 'down', 'first', 'last', 'left', 'parent', 'right', or 'up'.
550
+ * (Alternatively the `event.key` that would normally trigger this move,
551
+ * e.g. `ArrowLeft` = 'left'.
552
+ * @param options
553
+ */
554
+ navigate(where: string, options?: any): Promise<any>;
555
+ /** Delete this node and all descendants. */
556
+ remove(): void;
557
+ /** Remove all descendants of this node. */
558
+ removeChildren(): void;
559
+ /** Remove all HTML markup from the DOM. */
560
+ removeMarkup(): void;
561
+ protected _getRenderInfo(): {
562
+ [key: string]: any;
563
+ };
564
+ protected _createIcon(parentElem: HTMLElement, replaceChild?: HTMLElement): HTMLElement | null;
565
+ /** Create HTML markup for this node, i.e. the whole row. */
566
+ render(opts?: any): void;
567
+ /**
568
+ * Remove all children, collapse, and set the lazy-flag, so that the lazyLoad
569
+ * event is triggered on next expand.
570
+ */
571
+ resetLazy(): void;
572
+ /** Convert node (or whole branch) into a plain object.
573
+ *
574
+ * The result is compatible with node.addChildren().
575
+ *
576
+ * @param include child nodes
577
+ * @param callback(dict, node) is called for every node, in order to allow
578
+ * modifications.
579
+ * Return `false` to ignore this node or `"skip"` to include this node
580
+ * without its children.
581
+ * @returns {NodeData}
582
+ */
583
+ toDict(recursive?: boolean, callback?: any): any;
584
+ /** Return an option value that has a default, but may be overridden by a
585
+ * callback or a node instance attribute.
586
+ *
587
+ * Evaluation sequence:
588
+ *
589
+ * If `tree.options.<name>` is a callback that returns something, use that.
590
+ * Else if `node.<name>` is defined, use that.
591
+ * Else if `tree.types[<node.type>]` is a value, use that.
592
+ * Else if `tree.options.<name>` is a value, use that.
593
+ * Else use `defaultValue`.
594
+ *
595
+ * @param name name of the option property (on node and tree)
596
+ * @param defaultValue return this if nothing else matched
597
+ */
598
+ getOption(name: string, defaultValue?: any): any;
599
+ scrollIntoView(options?: any): Promise<void>;
600
+ setActive(flag?: boolean, options?: any): Promise<void>;
601
+ setDirty(type: ChangeType): void;
602
+ setExpanded(flag?: boolean, options?: any): Promise<void>;
603
+ setIcon(): void;
604
+ setFocus(flag?: boolean, options?: any): void;
605
+ setSelected(flag?: boolean, options?: any): void;
606
+ /** Show node status (ok, loading, error, noData) using styles and a dummy child node.
607
+ */
608
+ setStatus(status: NodeStatusType, message?: string, details?: string): WunderbaumNode | null;
609
+ setTitle(title: string): void;
610
+ /**
611
+ * Trigger `modifyChild` event on a parent to signal that a child was modified.
612
+ * @param {string} operation Type of change: 'add', 'remove', 'rename', 'move', 'data', ...
613
+ */
614
+ triggerModifyChild(operation: string, child: WunderbaumNode | null, extra?: any): void;
615
+ /**
616
+ * Trigger `modifyChild` event on node.parent(!).
617
+ * @param {string} operation Type of change: 'add', 'remove', 'rename', 'move', 'data', ...
618
+ * @param {object} [extra]
619
+ */
620
+ triggerModify(operation: string, extra: any): void;
621
+ /** Call fn(node) for all child nodes in hierarchical order (depth-first).<br>
622
+ * Stop iteration, if fn() returns false. Skip current branch, if fn() returns "skip".<br>
623
+ * Return false if iteration was stopped.
624
+ *
625
+ * @param {function} callback the callback function.
626
+ * Return false to stop iteration, return "skip" to skip this node and
627
+ * its children only.
628
+ */
629
+ visit(callback: NodeVisitCallback, includeSelf?: boolean): NodeVisitResponse;
630
+ /** Call fn(node) for all parent nodes, bottom-up, including invisible system root.<br>
631
+ * Stop iteration, if callback() returns false.<br>
632
+ * Return false if iteration was stopped.
633
+ *
634
+ * @param callback the callback function. Return false to stop iteration
635
+ */
636
+ visitParents(callback: (node: WunderbaumNode) => boolean | void, includeSelf?: boolean): boolean;
637
+ /** Call fn(node) for all sibling nodes.<br>
638
+ * Stop iteration, if fn() returns false.<br>
639
+ * Return false if iteration was stopped.
640
+ *
641
+ * @param {function} fn the callback function.
642
+ * Return false to stop iteration.
643
+ */
644
+ visitSiblings(callback: (node: WunderbaumNode) => boolean | void, includeSelf?: boolean): boolean;
645
+ /**
646
+ * [ext-filter] Return true if this node is matched by current filter (or no filter is active).
647
+ */
648
+ isMatched(): boolean;
649
+ }
650
+ }
651
+ declare module "common" {
652
+ import { WunderbaumNode } from "wb_node";
653
+ import { Wunderbaum } from "wunderbaum";
654
+ export type MatcherType = (node: WunderbaumNode) => boolean;
655
+ export type BoolOptionResolver = (node: WunderbaumNode) => boolean;
656
+ export const DEFAULT_DEBUGLEVEL = 4;
657
+ export const ROW_HEIGHT = 22;
658
+ export const ICON_WIDTH = 20;
659
+ export const ROW_EXTRA_PAD = 7;
660
+ export const RENDER_MIN_PREFETCH = 5;
661
+ export const RENDER_MAX_PREFETCH = 5;
662
+ export const TEST_IMG: RegExp;
663
+ export type NodeAnyCallback = (node: WunderbaumNode) => any;
664
+ export type NodeVisitResponse = "skip" | boolean | void;
665
+ export type NodeVisitCallback = (node: WunderbaumNode) => NodeVisitResponse;
666
+ export type WbEventType = {
667
+ name: string;
668
+ event: Event;
669
+ tree: Wunderbaum;
670
+ [key: string]: unknown;
671
+ };
672
+ export type WbNodeEventType = WbEventType & {
673
+ node: WunderbaumNode;
674
+ };
675
+ export type WbCallbackType = (e: WbEventType) => any;
676
+ export type WbNodeCallbackType = (e: WbNodeEventType) => any;
677
+ export type FilterModeType = null | "dim" | "hide";
678
+ export type ApplyCommandType = "moveUp" | "moveDown" | "indent" | "outdent" | "remove" | "rename" | "addChild" | "addSibling" | "cut" | "copy" | "paste" | "down" | "first" | "last" | "left" | "pageDown" | "pageUp" | "parent" | "right" | "up";
679
+ export type NodeFilterResponse = "skip" | "branch" | boolean | void;
680
+ export type NodeFilterCallback = (node: WunderbaumNode) => NodeFilterResponse;
681
+ export type AddNodeType = "before" | "after" | "prependChild" | "appendChild";
682
+ export type DndModeType = "before" | "after" | "over";
683
+ export enum ChangeType {
684
+ any = "any",
685
+ row = "row",
686
+ structure = "structure",
687
+ status = "status"
688
+ }
689
+ export enum NodeStatusType {
690
+ ok = "ok",
691
+ loading = "loading",
692
+ error = "error",
693
+ noData = "noData"
694
+ }
695
+ /**Define the subregion of a node, where an event occurred. */
696
+ export enum TargetType {
697
+ unknown = "",
698
+ checkbox = "checkbox",
699
+ column = "column",
700
+ expander = "expander",
701
+ icon = "icon",
702
+ prefix = "prefix",
703
+ title = "title"
704
+ }
705
+ export let iconMap: {
706
+ error: string;
707
+ loading: string;
708
+ noData: string;
709
+ expanderExpanded: string;
710
+ expanderCollapsed: string;
711
+ expanderLazy: string;
712
+ checkChecked: string;
713
+ checkUnchecked: string;
714
+ checkUnknown: string;
715
+ radioChecked: string;
716
+ radioUnchecked: string;
717
+ radioUnknown: string;
718
+ folder: string;
719
+ folderOpen: string;
720
+ doc: string;
721
+ };
722
+ export const KEY_NODATA = "__not_found__";
723
+ export enum NavigationModeOption {
724
+ startRow = "startRow",
725
+ cell = "cell",
726
+ startCell = "startCell",
727
+ row = "row"
728
+ }
729
+ export enum NavigationMode {
730
+ row = "row",
731
+ cellNav = "cellNav",
732
+ cellEdit = "cellEdit"
733
+ }
734
+ /** Define which keys are handled by embedded <input> control, and should
735
+ * *not* be passed to tree navigation handler in cell-edit mode: */
736
+ export const INPUT_KEYS: {
737
+ text: string[];
738
+ number: string[];
739
+ checkbox: any[];
740
+ link: any[];
741
+ radiobutton: string[];
742
+ "select-one": string[];
743
+ "select-multiple": string[];
744
+ };
745
+ /** Key codes that trigger grid navigation, even when inside an input element. */
746
+ export const NAVIGATE_IN_INPUT_KEYS: Set<string>;
747
+ /** Map `KeyEvent.key` to navigation action. */
748
+ export const KEY_TO_ACTION_DICT: {
749
+ [key: string]: string;
750
+ };
751
+ /** */
752
+ export function makeNodeTitleMatcher(s: string): MatcherType;
753
+ /** */
754
+ export function makeNodeTitleStartMatcher(s: string): MatcherType;
755
+ }
756
+ declare module "wb_extension_base" {
757
+ import { Wunderbaum } from "wunderbaum";
758
+ export type ExtensionsDict = {
759
+ [key: string]: WunderbaumExtension;
760
+ };
761
+ export abstract class WunderbaumExtension {
762
+ enabled: boolean;
763
+ readonly id: string;
764
+ readonly tree: Wunderbaum;
765
+ readonly treeOpts: any;
766
+ readonly extensionOpts: any;
767
+ constructor(tree: Wunderbaum, id: string, defaults: any);
768
+ /** Called on tree (re)init after all extensions are added, but before loading.*/
769
+ init(): void;
770
+ getPluginOption(name: string, defaultValue?: any): any;
771
+ setPluginOption(name: string, value: any): void;
772
+ setEnabled(flag?: boolean): void;
773
+ onKeyEvent(data: any): boolean | undefined;
774
+ onRender(data: any): boolean | undefined;
775
+ }
776
+ }
777
+ declare module "debounce" {
778
+ /*!
779
+ * debounce & throttle, taken from https://github.com/lodash/lodash v4.17.21
780
+ * MIT License: https://raw.githubusercontent.com/lodash/lodash/4.17.21-npm/LICENSE
781
+ * Modified for TypeScript type annotations.
782
+ */
783
+ type Procedure = (...args: any[]) => any;
784
+ type DebounceOptions = {
785
+ leading?: boolean;
786
+ maxWait?: number;
787
+ trailing?: boolean;
788
+ };
789
+ type ThrottleOptions = {
790
+ leading?: boolean;
791
+ trailing?: boolean;
792
+ };
793
+ export interface DebouncedFunction<F extends Procedure> {
794
+ (this: ThisParameterType<F>, ...args: Parameters<F>): ReturnType<F>;
795
+ cancel: () => void;
796
+ flush: () => any;
797
+ pending: () => boolean;
798
+ }
799
+ /**
800
+ * Creates a debounced function that delays invoking `func` until after `wait`
801
+ * milliseconds have elapsed since the last time the debounced function was
802
+ * invoked, or until the next browser frame is drawn. The debounced function
803
+ * comes with a `cancel` method to cancel delayed `func` invocations and a
804
+ * `flush` method to immediately invoke them. Provide `options` to indicate
805
+ * whether `func` should be invoked on the leading and/or trailing edge of the
806
+ * `wait` timeout. The `func` is invoked with the last arguments provided to the
807
+ * debounced function. Subsequent calls to the debounced function return the
808
+ * result of the last `func` invocation.
809
+ *
810
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
811
+ * invoked on the trailing edge of the timeout only if the debounced function
812
+ * is invoked more than once during the `wait` timeout.
813
+ *
814
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
815
+ * until the next tick, similar to `setTimeout` with a timeout of `0`.
816
+ *
817
+ * If `wait` is omitted in an environment with `requestAnimationFrame`, `func`
818
+ * invocation will be deferred until the next frame is drawn (typically about
819
+ * 16ms).
820
+ *
821
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
822
+ * for details over the differences between `debounce` and `throttle`.
823
+ *
824
+ * @since 0.1.0
825
+ * @category Function
826
+ * @param {Function} func The function to debounce.
827
+ * @param {number} [wait=0]
828
+ * The number of milliseconds to delay; if omitted, `requestAnimationFrame` is
829
+ * used (if available).
830
+ * @param {Object} [options={}] The options object.
831
+ * @param {boolean} [options.leading=false]
832
+ * Specify invoking on the leading edge of the timeout.
833
+ * @param {number} [options.maxWait]
834
+ * The maximum time `func` is allowed to be delayed before it's invoked.
835
+ * @param {boolean} [options.trailing=true]
836
+ * Specify invoking on the trailing edge of the timeout.
837
+ * @returns {Function} Returns the new debounced function.
838
+ * @example
839
+ *
840
+ * // Avoid costly calculations while the window size is in flux.
841
+ * jQuery(window).on('resize', debounce(calculateLayout, 150))
842
+ *
843
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
844
+ * jQuery(element).on('click', debounce(sendMail, 300, {
845
+ * 'leading': true,
846
+ * 'trailing': false
847
+ * }))
848
+ *
849
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
850
+ * const debounced = debounce(batchLog, 250, { 'maxWait': 1000 })
851
+ * const source = new EventSource('/stream')
852
+ * jQuery(source).on('message', debounced)
853
+ *
854
+ * // Cancel the trailing debounced invocation.
855
+ * jQuery(window).on('popstate', debounced.cancel)
856
+ *
857
+ * // Check for pending invocations.
858
+ * const status = debounced.pending() ? "Pending..." : "Ready"
859
+ */
860
+ export function debounce<F extends Procedure>(func: F, wait?: number, options?: DebounceOptions): DebouncedFunction<F>;
861
+ /**
862
+ * Creates a throttled function that only invokes `func` at most once per
863
+ * every `wait` milliseconds (or once per browser frame). The throttled function
864
+ * comes with a `cancel` method to cancel delayed `func` invocations and a
865
+ * `flush` method to immediately invoke them. Provide `options` to indicate
866
+ * whether `func` should be invoked on the leading and/or trailing edge of the
867
+ * `wait` timeout. The `func` is invoked with the last arguments provided to the
868
+ * throttled function. Subsequent calls to the throttled function return the
869
+ * result of the last `func` invocation.
870
+ *
871
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
872
+ * invoked on the trailing edge of the timeout only if the throttled function
873
+ * is invoked more than once during the `wait` timeout.
874
+ *
875
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
876
+ * until the next tick, similar to `setTimeout` with a timeout of `0`.
877
+ *
878
+ * If `wait` is omitted in an environment with `requestAnimationFrame`, `func`
879
+ * invocation will be deferred until the next frame is drawn (typically about
880
+ * 16ms).
881
+ *
882
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
883
+ * for details over the differences between `throttle` and `debounce`.
884
+ *
885
+ * @since 0.1.0
886
+ * @category Function
887
+ * @param {Function} func The function to throttle.
888
+ * @param {number} [wait=0]
889
+ * The number of milliseconds to throttle invocations to; if omitted,
890
+ * `requestAnimationFrame` is used (if available).
891
+ * @param {Object} [options={}] The options object.
892
+ * @param {boolean} [options.leading=true]
893
+ * Specify invoking on the leading edge of the timeout.
894
+ * @param {boolean} [options.trailing=true]
895
+ * Specify invoking on the trailing edge of the timeout.
896
+ * @returns {Function} Returns the new throttled function.
897
+ * @example
898
+ *
899
+ * // Avoid excessively updating the position while scrolling.
900
+ * jQuery(window).on('scroll', throttle(updatePosition, 100))
901
+ *
902
+ * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
903
+ * const throttled = throttle(renewToken, 300000, { 'trailing': false })
904
+ * jQuery(element).on('click', throttled)
905
+ *
906
+ * // Cancel the trailing throttled invocation.
907
+ * jQuery(window).on('popstate', throttled.cancel)
908
+ */
909
+ export function throttle<F extends Procedure>(func: F, wait?: number, options?: ThrottleOptions): DebouncedFunction<F>;
910
+ }
911
+ declare module "wb_ext_filter" {
912
+ import { NodeFilterCallback } from "common";
913
+ import { Wunderbaum } from "wunderbaum";
914
+ import { WunderbaumExtension } from "wb_extension_base";
915
+ export class FilterExtension extends WunderbaumExtension {
916
+ queryInput?: HTMLInputElement;
917
+ lastFilterArgs: IArguments | null;
918
+ constructor(tree: Wunderbaum);
919
+ init(): void;
920
+ _applyFilterNoUpdate(filter: string | NodeFilterCallback, branchMode: boolean, _opts: any): void;
921
+ _applyFilterImpl(filter: string | NodeFilterCallback, branchMode: boolean, _opts: any): number;
922
+ /**
923
+ * [ext-filter] Dim or hide nodes.
924
+ *
925
+ * @param {boolean} [opts={autoExpand: false, leavesOnly: false}]
926
+ */
927
+ filterNodes(filter: string | NodeFilterCallback, opts: any): void;
928
+ /**
929
+ * [ext-filter] Dim or hide whole branches.
930
+ *
931
+ * @param {boolean} [opts={autoExpand: false}]
932
+ */
933
+ filterBranches(filter: string | NodeFilterCallback, opts: any): void;
934
+ /**
935
+ * [ext-filter] Re-apply current filter.
936
+ *
937
+ * @requires jquery.fancytree.filter.js
938
+ */
939
+ updateFilter(): void;
940
+ /**
941
+ * [ext-filter] Reset the filter.
942
+ *
943
+ * @alias Fancytree#clearFilter
944
+ * @requires jquery.fancytree.filter.js
945
+ */
946
+ clearFilter(): void;
947
+ }
948
+ }
949
+ declare module "wb_ext_keynav" {
950
+ import { Wunderbaum } from "wunderbaum";
951
+ import { WunderbaumExtension } from "wb_extension_base";
952
+ export class KeynavExtension extends WunderbaumExtension {
953
+ constructor(tree: Wunderbaum);
954
+ onKeyEvent(data: any): boolean | undefined;
955
+ }
956
+ }
957
+ declare module "wb_ext_logger" {
958
+ import { WunderbaumExtension } from "wb_extension_base";
959
+ import { Wunderbaum } from "wunderbaum";
960
+ export class LoggerExtension extends WunderbaumExtension {
961
+ readonly prefix: string;
962
+ protected ignoreEvents: Set<string>;
963
+ constructor(tree: Wunderbaum);
964
+ init(): void;
965
+ onKeyEvent(data: any): boolean | undefined;
966
+ }
967
+ }
968
+ declare module "wb_ext_dnd" {
969
+ import { Wunderbaum } from "wunderbaum";
970
+ import { WunderbaumExtension } from "wb_extension_base";
971
+ import { WunderbaumNode } from "wb_node";
972
+ export type DropRegionType = "over" | "before" | "after";
973
+ type DropRegionTypeSet = Set<DropRegionType>;
974
+ export class DndExtension extends WunderbaumExtension {
975
+ protected srcNode: WunderbaumNode | null;
976
+ protected lastTargetNode: WunderbaumNode | null;
977
+ protected lastEnterStamp: number;
978
+ protected lastAllowedDropRegions: DropRegionTypeSet | null;
979
+ protected lastDropEffect: string | null;
980
+ protected lastDropRegion: DropRegionType | false;
981
+ constructor(tree: Wunderbaum);
982
+ init(): void;
983
+ /** Cleanup classes after target node is no longer hovered. */
984
+ protected _leaveNode(): void;
985
+ /** */
986
+ protected unifyDragover(res: any): DropRegionTypeSet | false;
987
+ /** */
988
+ protected _calcDropRegion(e: DragEvent, allowed: DropRegionTypeSet | null): DropRegionType | false;
989
+ protected autoScroll(event: DragEvent): number;
990
+ protected onDragEvent(e: DragEvent): boolean;
991
+ protected onDropEvent(e: DragEvent): boolean;
992
+ }
993
+ }
994
+ declare module "wb_ext_edit" {
995
+ /*!
996
+ * Wunderbaum - ext-edit
997
+ * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
998
+ * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
999
+ */
1000
+ import { Wunderbaum } from "wunderbaum";
1001
+ import { WunderbaumExtension } from "wb_extension_base";
1002
+ import { WunderbaumNode } from "wb_node";
1003
+ import { AddNodeType } from "common";
1004
+ import { WbNodeData } from "wb_options";
1005
+ export class EditExtension extends WunderbaumExtension {
1006
+ protected debouncedOnChange: (e: Event) => void;
1007
+ protected curEditNode: WunderbaumNode | null;
1008
+ protected relatedNode: WunderbaumNode | null;
1009
+ constructor(tree: Wunderbaum);
1010
+ protected _applyChange(eventName: string, node: WunderbaumNode, colElem: HTMLElement, extra: any): Promise<any>;
1011
+ protected _onChange(e: Event): void;
1012
+ init(): void;
1013
+ _preprocessKeyEvent(data: any): boolean | undefined;
1014
+ /** Return true if a title is currently being edited. */
1015
+ isEditingTitle(node?: WunderbaumNode): boolean;
1016
+ /** Start renaming, i.e. replace the title with an embedded `<input>`. */
1017
+ startEditTitle(node?: WunderbaumNode | null): void;
1018
+ /**
1019
+ *
1020
+ * @param apply
1021
+ * @returns
1022
+ */
1023
+ stopEditTitle(apply: boolean): void;
1024
+ _stopEditTitle(apply: boolean, opts: any): void;
1025
+ /**
1026
+ * Create a new child or sibling node and start edit mode.
1027
+ */
1028
+ createNode(mode?: AddNodeType, node?: WunderbaumNode | null, init?: string | WbNodeData): void;
1029
+ }
1030
+ }
1031
+ declare module "wunderbaum" {
1032
+ /*!
1033
+ * wunderbaum.ts
1034
+ *
1035
+ * A tree control.
1036
+ *
1037
+ * Copyright (c) 2021-2022, Martin Wendt (https://wwWendt.de).
1038
+ * Released under the MIT license.
1039
+ *
1040
+ * @version @VERSION
1041
+ * @date @DATE
1042
+ */
1043
+ import "./wunderbaum.scss";
1044
+ import * as util from "util";
1045
+ import { ExtensionsDict, WunderbaumExtension } from "wb_extension_base";
1046
+ import { NavigationMode, ChangeType, FilterModeType, MatcherType, NodeStatusType, TargetType as NodeRegion, ApplyCommandType } from "common";
1047
+ import { WunderbaumNode } from "wb_node";
1048
+ import { DebouncedFunction } from "debounce";
1049
+ import { WunderbaumOptions } from "wb_options";
1050
+ /**
1051
+ * A persistent plain object or array.
1052
+ *
1053
+ * See also [[WunderbaumOptions]].
1054
+ */
1055
+ export class Wunderbaum {
1056
+ static version: string;
1057
+ static sequence: number;
1058
+ /** The invisible root node, that holds all visible top level nodes. */
1059
+ readonly root: WunderbaumNode;
1060
+ readonly id: string;
1061
+ readonly element: HTMLDivElement;
1062
+ readonly headerElement: HTMLDivElement | null;
1063
+ readonly scrollContainer: HTMLDivElement;
1064
+ readonly nodeListElement: HTMLDivElement;
1065
+ readonly _updateViewportThrottled: DebouncedFunction<(...args: any) => void>;
1066
+ protected extensionList: WunderbaumExtension[];
1067
+ protected extensions: ExtensionsDict;
1068
+ /** Merged options from constructor args and tree- and extension defaults. */
1069
+ options: WunderbaumOptions;
1070
+ protected keyMap: Map<string, WunderbaumNode>;
1071
+ protected refKeyMap: Map<string, Set<WunderbaumNode>>;
1072
+ protected viewNodes: Set<WunderbaumNode>;
1073
+ activeNode: WunderbaumNode | null;
1074
+ focusNode: WunderbaumNode | null;
1075
+ _disableUpdate: number;
1076
+ _disableUpdateCount: number;
1077
+ /** Shared properties, referenced by `node.type`. */
1078
+ types: {
1079
+ [key: string]: any;
1080
+ };
1081
+ /** List of column definitions. */
1082
+ columns: any[];
1083
+ _columnsById: {
1084
+ [key: string]: any;
1085
+ };
1086
+ protected resizeObserver: any;
1087
+ protected changedSince: number;
1088
+ protected changes: Set<ChangeType>;
1089
+ protected changedNodes: Set<WunderbaumNode>;
1090
+ filterMode: FilterModeType;
1091
+ activeColIdx: number;
1092
+ navMode: NavigationMode;
1093
+ lastQuicksearchTime: number;
1094
+ lastQuicksearchTerm: string;
1095
+ protected lastClickTime: number;
1096
+ readonly ready: Promise<any>;
1097
+ static util: typeof util;
1098
+ _util: typeof util;
1099
+ constructor(options: WunderbaumOptions);
1100
+ /** */
1101
+ /** Return a Wunderbaum instance, from element, index, or event.
1102
+ *
1103
+ * @example
1104
+ * getTree(); // Get first Wunderbaum instance on page
1105
+ * getTree(1); // Get second Wunderbaum instance on page
1106
+ * getTree(event); // Get tree for this mouse- or keyboard event
1107
+ * getTree("foo"); // Get tree for this `tree.options.id`
1108
+ * getTree("#tree"); // Get tree for this matching element
1109
+ */
1110
+ static getTree(el?: Element | Event | number | string | WunderbaumNode): Wunderbaum | null;
1111
+ /** Return a WunderbaumNode instance from element, event.
1112
+ *
1113
+ * @param el
1114
+ */
1115
+ static getNode(el: Element | Event): WunderbaumNode | null;
1116
+ /** */
1117
+ protected _registerExtension(extension: WunderbaumExtension): void;
1118
+ /** Called on tree (re)init after markup is created, before loading. */
1119
+ protected _initExtensions(): void;
1120
+ /** Add node to tree's bookkeeping data structures. */
1121
+ _registerNode(node: WunderbaumNode): void;
1122
+ /** Remove node from tree's bookkeeping data structures. */
1123
+ _unregisterNode(node: WunderbaumNode): void;
1124
+ /** Call all hook methods of all registered extensions.*/
1125
+ protected _callHook(hook: keyof WunderbaumExtension, data?: any): any;
1126
+ /** Call tree method or extension method if defined.
1127
+ * Example:
1128
+ * ```js
1129
+ * tree._callMethod("edit.startEdit", "arg1", "arg2")
1130
+ * ```
1131
+ */
1132
+ _callMethod(name: string, ...args: any[]): any;
1133
+ /** Call event handler if defined in tree.options.
1134
+ * Example:
1135
+ * ```js
1136
+ * tree._callEvent("edit.beforeEdit", {foo: 42})
1137
+ * ```
1138
+ */
1139
+ _callEvent(name: string, extra?: any): any;
1140
+ /** Return the topmost visible node in the viewport */
1141
+ protected _firstNodeInView(complete?: boolean): WunderbaumNode;
1142
+ /** Return the lowest visible node in the viewport */
1143
+ protected _lastNodeInView(complete?: boolean): WunderbaumNode;
1144
+ /** Return preceeding visible node in the viewport */
1145
+ protected _getPrevNodeInView(node?: WunderbaumNode, ofs?: number): WunderbaumNode;
1146
+ /** Return following visible node in the viewport */
1147
+ protected _getNextNodeInView(node?: WunderbaumNode, ofs?: number): WunderbaumNode;
1148
+ addChildren(nodeData: any, options?: any): WunderbaumNode;
1149
+ /**
1150
+ * Apply a modification (or navigation) operation on the tree or active node.
1151
+ * @returns
1152
+ */
1153
+ applyCommand(cmd: ApplyCommandType, opts?: any): any;
1154
+ /**
1155
+ * Apply a modification (or navigation) operation on a node.
1156
+ * @returns
1157
+ */
1158
+ applyCommand(cmd: ApplyCommandType, node: WunderbaumNode, opts?: any): any;
1159
+ /** Delete all nodes. */
1160
+ clear(): void;
1161
+ /**
1162
+ * Clear nodes and markup and detach events and observers.
1163
+ *
1164
+ * This method may be useful to free up resources before re-creating a tree
1165
+ * on an existing div, for example in unittest suites.
1166
+ * Note that this Wunderbaum instance becomes unusable afterwards.
1167
+ */
1168
+ destroy(): void;
1169
+ /**
1170
+ * Return `tree.option.NAME` (also resolving if this is a callback).
1171
+ *
1172
+ * See also [[WunderbaumNode.getOption()]] to consider `node.NAME` setting and
1173
+ * `tree.types[node.type].NAME`.
1174
+ *
1175
+ * @param name option name (use dot notation to access extension option, e.g. `filter.mode`)
1176
+ */
1177
+ getOption(name: string, defaultValue?: any): any;
1178
+ /**
1179
+ *
1180
+ * @param name
1181
+ * @param value
1182
+ */
1183
+ setOption(name: string, value: any): void;
1184
+ /**Return true if the tree (or one of its nodes) has the input focus. */
1185
+ hasFocus(): boolean;
1186
+ /** Run code, but defer `updateViewport()` until done. */
1187
+ runWithoutUpdate(func: () => any, hint?: any): void;
1188
+ /** Recursively expand all expandable nodes (triggers lazy load id needed). */
1189
+ expandAll(flag?: boolean): Promise<void>;
1190
+ /** Return the number of nodes in the data model.*/
1191
+ count(visible?: boolean): number;
1192
+ _check(): void;
1193
+ /**Find all nodes that matches condition.
1194
+ *
1195
+ * @param match title string to search for, or a
1196
+ * callback function that returns `true` if a node is matched.
1197
+ * @see [[WunderbaumNode.findAll]]
1198
+ */
1199
+ findAll(match: string | MatcherType): WunderbaumNode[];
1200
+ /**Find first node that matches condition.
1201
+ *
1202
+ * @param match title string to search for, or a
1203
+ * callback function that returns `true` if a node is matched.
1204
+ * @see [[WunderbaumNode.findFirst]]
1205
+ */
1206
+ findFirst(match: string | MatcherType): WunderbaumNode;
1207
+ /** Find the next visible node that starts with `match`, starting at `startNode`
1208
+ * and wrap-around at the end.
1209
+ */
1210
+ findNextNode(match: string | MatcherType, startNode?: WunderbaumNode | null): WunderbaumNode | null;
1211
+ /** Find a node relative to another node.
1212
+ *
1213
+ * @param node
1214
+ * @param where 'down', 'first', 'last', 'left', 'parent', 'right', or 'up'.
1215
+ * (Alternatively the keyCode that would normally trigger this move,
1216
+ * e.g. `$.ui.keyCode.LEFT` = 'left'.
1217
+ * @param includeHidden Not yet implemented
1218
+ */
1219
+ findRelatedNode(node: WunderbaumNode, where: string, includeHidden?: boolean): any;
1220
+ /**
1221
+ * Return the active cell of the currently active node or null.
1222
+ */
1223
+ getActiveColElem(): HTMLSpanElement;
1224
+ /**
1225
+ * Return the currently active node or null.
1226
+ */
1227
+ getActiveNode(): WunderbaumNode;
1228
+ /** Return the first top level node if any (not the invisible root node).
1229
+ * @returns {FancytreeNode | null}
1230
+ */
1231
+ getFirstChild(): WunderbaumNode;
1232
+ /**
1233
+ * Return the currently active node or null.
1234
+ */
1235
+ getFocusNode(): WunderbaumNode;
1236
+ /** Return a {node: FancytreeNode, region: TYPE} object for a mouse event.
1237
+ *
1238
+ * @param {Event} event Mouse event, e.g. click, ...
1239
+ * @returns {object} Return a {node: FancytreeNode, region: TYPE} object
1240
+ * TYPE: 'title' | 'prefix' | 'expander' | 'checkbox' | 'icon' | undefined
1241
+ */
1242
+ static getEventInfo(event: Event): {
1243
+ node: WunderbaumNode;
1244
+ region: NodeRegion;
1245
+ colDef: any;
1246
+ colIdx: number;
1247
+ colId: any;
1248
+ colElem: Element;
1249
+ };
1250
+ /**
1251
+ * Return readable string representation for this instance.
1252
+ * @internal
1253
+ */
1254
+ toString(): string;
1255
+ /** Return true if any node is currently in edit-title mode. */
1256
+ isEditing(): boolean;
1257
+ /** Return true if any node is currently beeing loaded, i.e. a Ajax request is pending.
1258
+ */
1259
+ isLoading(): boolean;
1260
+ /** Alias for `logDebug` */
1261
+ log: (...args: any[]) => void;
1262
+ /** Log to console if opts.debugLevel >= 4 */
1263
+ logDebug(...args: any[]): void;
1264
+ /** Log error to console. */
1265
+ logError(...args: any[]): void;
1266
+ logInfo(...args: any[]): void;
1267
+ /** @internal */
1268
+ logTime(label: string): string;
1269
+ /** @internal */
1270
+ logTimeEnd(label: string): void;
1271
+ /** Log to console if opts.debugLevel >= 2 */
1272
+ logWarn(...args: any[]): void;
1273
+ /** */
1274
+ protected render(opts?: any): boolean;
1275
+ /**Recalc and apply header columns from `this.columns`. */
1276
+ renderHeader(): void;
1277
+ /**
1278
+ *
1279
+ * @param {boolean | PlainObject} [effects=false] animation options.
1280
+ * @param {object} [options=null] {topNode: null, effects: ..., parent: ...}
1281
+ * this node will remain visible in
1282
+ * any case, even if `this` is outside the scroll pane.
1283
+ * Make sure that a node is scrolled into the viewport.
1284
+ */
1285
+ scrollTo(opts: any): void;
1286
+ /** */
1287
+ setCellMode(mode: NavigationMode): void;
1288
+ /** */
1289
+ setColumn(colIdx: number): void;
1290
+ /** */
1291
+ setFocus(flag?: boolean): void;
1292
+ /** */
1293
+ setModified(change: ChangeType, options?: any): void;
1294
+ setStatus(status: NodeStatusType, message?: string, details?: string): WunderbaumNode | null;
1295
+ /** Update column headers and width. */
1296
+ updateColumns(opts: any): void;
1297
+ /** Render all rows that are visible in the viewport. */
1298
+ updateViewport(immediate?: boolean): void;
1299
+ protected _updateViewport(): void;
1300
+ /** Call callback(node) for all nodes in hierarchical order (depth-first).
1301
+ *
1302
+ * @param {function} callback the callback function.
1303
+ * Return false to stop iteration, return "skip" to skip this node and children only.
1304
+ * @returns {boolean} false, if the iterator was stopped.
1305
+ */
1306
+ visit(callback: (node: WunderbaumNode) => any): import("common").NodeVisitResponse;
1307
+ /** Call fn(node) for all nodes in vertical order, top down (or bottom up).<br>
1308
+ * Stop iteration, if fn() returns false.<br>
1309
+ * Return false if iteration was stopped.
1310
+ *
1311
+ * @param callback the callback function.
1312
+ * Return false to stop iteration, return "skip" to skip this node and children only.
1313
+ * @param [options]
1314
+ * Defaults:
1315
+ * {start: First tree node, reverse: false, includeSelf: true, includeHidden: false, wrap: false}
1316
+ * @returns {boolean} false if iteration was canceled
1317
+ */
1318
+ visitRows(callback: (node: WunderbaumNode) => any, opts?: any): boolean;
1319
+ /** Call fn(node) for all nodes in vertical order, bottom up.
1320
+ * @internal
1321
+ */
1322
+ protected _visitRowsUp(callback: (node: WunderbaumNode) => any, opts: any): boolean;
1323
+ /** . */
1324
+ load(source: any, options?: any): Promise<void>;
1325
+ /**
1326
+ *
1327
+ */
1328
+ enableUpdate(flag: boolean): void;
1329
+ /**
1330
+ * [ext-filter] Reset the filter.
1331
+ *
1332
+ * @requires [[FilterExtension]]
1333
+ */
1334
+ clearFilter(): void;
1335
+ /**
1336
+ * [ext-filter] Return true if a filter is currently applied.
1337
+ *
1338
+ * @requires [[FilterExtension]]
1339
+ */
1340
+ isFilterActive(): boolean;
1341
+ /**
1342
+ * [ext-filter] Re-apply current filter.
1343
+ *
1344
+ * @requires [[FilterExtension]]
1345
+ */
1346
+ updateFilter(): void;
1347
+ }
1348
+ }