wunderbaum 0.0.1-0 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/wunderbaum.css +1 -1
- package/dist/wunderbaum.d.ts +634 -171
- package/dist/wunderbaum.esm.js +818 -436
- package/dist/wunderbaum.esm.min.js +31 -21
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +820 -438
- package/dist/wunderbaum.umd.min.js +34 -24
- package/dist/wunderbaum.umd.min.js.map +1 -1
- package/package.json +35 -32
- package/src/common.ts +37 -5
- package/src/drag_observer.ts +169 -0
- package/src/util.ts +48 -13
- package/src/wb_ext_dnd.ts +145 -4
- package/src/wb_ext_edit.ts +10 -1
- package/src/wb_ext_filter.ts +35 -40
- package/src/wb_ext_grid.ts +45 -0
- package/src/wb_ext_keynav.ts +8 -4
- package/src/wb_node.ts +142 -78
- package/src/wb_options.ts +138 -25
- package/src/wunderbaum.scss +28 -5
- package/src/wunderbaum.ts +481 -321
package/dist/wunderbaum.d.ts
CHANGED
|
@@ -4,12 +4,13 @@ declare module "util" {
|
|
|
4
4
|
* Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
|
|
5
5
|
* @VERSION, @DATE (https://github.com/mar10/wunderbaum)
|
|
6
6
|
*/
|
|
7
|
+
/** @module util */
|
|
7
8
|
/** Readable names for `MouseEvent.button` */
|
|
8
9
|
export const MOUSE_BUTTONS: {
|
|
9
10
|
[key: number]: string;
|
|
10
11
|
};
|
|
11
12
|
export const MAX_INT = 9007199254740991;
|
|
12
|
-
/**True if the
|
|
13
|
+
/**True if the client is using a macOS platform. */
|
|
13
14
|
export const isMac: boolean;
|
|
14
15
|
export type FunctionType = (...args: any[]) => any;
|
|
15
16
|
export type EventCallbackType = (e: Event) => boolean | void;
|
|
@@ -94,32 +95,45 @@ declare module "util" {
|
|
|
94
95
|
* @param value a value that matches the target element.
|
|
95
96
|
*/
|
|
96
97
|
export function setValueToElem(elem: HTMLElement, value: any): void;
|
|
97
|
-
/**
|
|
98
|
+
/** Create and return an unconnected `HTMLElement` from a HTML string. */
|
|
98
99
|
export function elemFromHtml(html: string): HTMLElement;
|
|
99
100
|
/** Return a HtmlElement from selector or cast an existing element. */
|
|
100
101
|
export function elemFromSelector(obj: string | Element): HTMLElement | null;
|
|
102
|
+
/** Return a EventTarget from selector or cast an existing element. */
|
|
103
|
+
export function eventTargetFromSelector(obj: string | EventTarget): EventTarget | null;
|
|
101
104
|
/**
|
|
102
|
-
* Return a descriptive string for a keyboard or mouse event.
|
|
105
|
+
* Return a canonical descriptive string for a keyboard or mouse event.
|
|
103
106
|
*
|
|
104
107
|
* The result also contains a prefix for modifiers if any, for example
|
|
105
108
|
* `"x"`, `"F2"`, `"Control+Home"`, or `"Shift+clickright"`.
|
|
109
|
+
* This is especially useful in `switch` statements, to make sure that modifier
|
|
110
|
+
* keys are considered and handled correctly.
|
|
106
111
|
*/
|
|
107
112
|
export function eventToString(event: Event): string;
|
|
113
|
+
/**
|
|
114
|
+
* Copy allproperties from one or more source objects to a target object.
|
|
115
|
+
*
|
|
116
|
+
* @returns the modified target object.
|
|
117
|
+
*/
|
|
108
118
|
export function extend(...args: any[]): any;
|
|
119
|
+
/** Return true if `obj` is of type `array`. */
|
|
109
120
|
export function isArray(obj: any): boolean;
|
|
121
|
+
/** Return true if `obj` is of type `Object` and has no propertied. */
|
|
110
122
|
export function isEmptyObject(obj: any): boolean;
|
|
123
|
+
/** Return true if `obj` is of type `function`. */
|
|
111
124
|
export function isFunction(obj: any): boolean;
|
|
125
|
+
/** Return true if `obj` is of type `Object`. */
|
|
112
126
|
export function isPlainObject(obj: any): boolean;
|
|
113
127
|
/** A dummy function that does nothing ('no operation'). */
|
|
114
128
|
export function noop(...args: any[]): any;
|
|
115
129
|
/**
|
|
116
|
-
* Bind one or more event handlers directly to an [[
|
|
130
|
+
* Bind one or more event handlers directly to an [[EventTarget]].
|
|
117
131
|
*
|
|
118
|
-
* @param element
|
|
132
|
+
* @param element EventTarget or selector
|
|
119
133
|
* @param eventNames
|
|
120
134
|
* @param handler
|
|
121
135
|
*/
|
|
122
|
-
export function onEvent(
|
|
136
|
+
export function onEvent(rootTarget: EventTarget | string, eventNames: string, handler: EventCallbackType): void;
|
|
123
137
|
/**
|
|
124
138
|
* Bind one or more event handlers using event delegation.
|
|
125
139
|
*
|
|
@@ -131,12 +145,12 @@ declare module "util" {
|
|
|
131
145
|
* });
|
|
132
146
|
* ```
|
|
133
147
|
*
|
|
134
|
-
* @param element
|
|
148
|
+
* @param element EventTarget or selector
|
|
135
149
|
* @param eventNames
|
|
136
150
|
* @param selector
|
|
137
151
|
* @param handler
|
|
138
152
|
*/
|
|
139
|
-
export function onEvent(
|
|
153
|
+
export function onEvent(rootTarget: EventTarget | string, eventNames: string, selector: string, handler: EventCallbackType): void;
|
|
140
154
|
/** Return a wrapped handler method, that provides `this._super`.
|
|
141
155
|
*
|
|
142
156
|
* ```ts
|
|
@@ -165,6 +179,13 @@ declare module "util" {
|
|
|
165
179
|
export function sleep(ms: number): Promise<unknown>;
|
|
166
180
|
/**
|
|
167
181
|
* Set or rotate checkbox status with support for tri-state.
|
|
182
|
+
*
|
|
183
|
+
* An initial 'indeterminate' state becomes 'checked' on the first call.
|
|
184
|
+
*
|
|
185
|
+
* If the input element has the class 'wb-tristate' assigned, the sequence is:<br>
|
|
186
|
+
* 'indeterminate' -> 'checked' -> 'unchecked' -> 'indeterminate' -> ...<br>
|
|
187
|
+
* Otherwise we toggle like <br>
|
|
188
|
+
* 'checked' -> 'unchecked' -> 'checked' -> ...
|
|
168
189
|
*/
|
|
169
190
|
export function toggleCheckbox(element: HTMLElement | string, value?: boolean | null, tristate?: boolean): void;
|
|
170
191
|
/**
|
|
@@ -177,6 +198,7 @@ declare module "util" {
|
|
|
177
198
|
export function getOption(opts: any, name: string, defaultValue?: any): any;
|
|
178
199
|
/** Convert an Array or space-separated string to a Set. */
|
|
179
200
|
export function toSet(val: any): Set<string>;
|
|
201
|
+
/**Return a canonical string representation for an object's type (e.g. 'array', 'number', ...) */
|
|
180
202
|
export function type(obj: any): string;
|
|
181
203
|
}
|
|
182
204
|
declare module "deferred" {
|
|
@@ -211,20 +233,181 @@ declare module "deferred" {
|
|
|
211
233
|
finally(cb: finallyCallbackType): Promise<any>;
|
|
212
234
|
}
|
|
213
235
|
}
|
|
236
|
+
declare module "wb_extension_base" {
|
|
237
|
+
import { Wunderbaum } from "wunderbaum";
|
|
238
|
+
export type ExtensionsDict = {
|
|
239
|
+
[key: string]: WunderbaumExtension;
|
|
240
|
+
};
|
|
241
|
+
export abstract class WunderbaumExtension {
|
|
242
|
+
enabled: boolean;
|
|
243
|
+
readonly id: string;
|
|
244
|
+
readonly tree: Wunderbaum;
|
|
245
|
+
readonly treeOpts: any;
|
|
246
|
+
readonly extensionOpts: any;
|
|
247
|
+
constructor(tree: Wunderbaum, id: string, defaults: any);
|
|
248
|
+
/** Called on tree (re)init after all extensions are added, but before loading.*/
|
|
249
|
+
init(): void;
|
|
250
|
+
getPluginOption(name: string, defaultValue?: any): any;
|
|
251
|
+
setPluginOption(name: string, value: any): void;
|
|
252
|
+
setEnabled(flag?: boolean): void;
|
|
253
|
+
onKeyEvent(data: any): boolean | undefined;
|
|
254
|
+
onRender(data: any): boolean | undefined;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
declare module "wb_ext_dnd" {
|
|
258
|
+
import { Wunderbaum } from "wunderbaum";
|
|
259
|
+
import { WunderbaumExtension } from "wb_extension_base";
|
|
260
|
+
import { WunderbaumNode } from "wb_node";
|
|
261
|
+
import { WbNodeEventType } from "common";
|
|
262
|
+
export type DropRegionType = "over" | "before" | "after";
|
|
263
|
+
type DropRegionTypeSet = Set<DropRegionType>;
|
|
264
|
+
export type DndOptionsType = {
|
|
265
|
+
/**
|
|
266
|
+
* Expand nodes after n milliseconds of hovering
|
|
267
|
+
* Default: 1500
|
|
268
|
+
*/
|
|
269
|
+
autoExpandMS: 1500;
|
|
270
|
+
/**
|
|
271
|
+
* true: Drag multiple (i.e. selected) nodes. Also a callback() is allowed
|
|
272
|
+
* Default: false
|
|
273
|
+
*/
|
|
274
|
+
multiSource: false;
|
|
275
|
+
/**
|
|
276
|
+
* Restrict the possible cursor shapes and modifier operations (can also be set in the dragStart event)
|
|
277
|
+
* Default: "all"
|
|
278
|
+
*/
|
|
279
|
+
effectAllowed: "all";
|
|
280
|
+
/**
|
|
281
|
+
* Default dropEffect ('copy', 'link', or 'move') when no modifier is pressed (overide in dragDrag, dragOver).
|
|
282
|
+
* Default: "move"
|
|
283
|
+
*/
|
|
284
|
+
dropEffectDefault: string;
|
|
285
|
+
/**
|
|
286
|
+
* Prevent dropping nodes from different Wunderbaum trees
|
|
287
|
+
* Default: false
|
|
288
|
+
*/
|
|
289
|
+
preventForeignNodes: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Prevent dropping items on unloaded lazy Wunderbaum tree nodes
|
|
292
|
+
* Default: true
|
|
293
|
+
*/
|
|
294
|
+
preventLazyParents: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Prevent dropping items other than Wunderbaum tree nodes
|
|
297
|
+
* Default: false
|
|
298
|
+
*/
|
|
299
|
+
preventNonNodes: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Prevent dropping nodes on own descendants
|
|
302
|
+
* Default: true
|
|
303
|
+
*/
|
|
304
|
+
preventRecursion: boolean;
|
|
305
|
+
/**
|
|
306
|
+
* Prevent dropping nodes under same direct parent
|
|
307
|
+
* Default: false
|
|
308
|
+
*/
|
|
309
|
+
preventSameParent: false;
|
|
310
|
+
/**
|
|
311
|
+
* Prevent dropping nodes 'before self', etc. (move only)
|
|
312
|
+
* Default: true
|
|
313
|
+
*/
|
|
314
|
+
preventVoidMoves: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Enable auto-scrolling while dragging
|
|
317
|
+
* Default: true
|
|
318
|
+
*/
|
|
319
|
+
scroll: boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Active top/bottom margin in pixel
|
|
322
|
+
* Default: 20
|
|
323
|
+
*/
|
|
324
|
+
scrollSensitivity: 20;
|
|
325
|
+
/**
|
|
326
|
+
* Pixel per event
|
|
327
|
+
* Default: 5
|
|
328
|
+
*/
|
|
329
|
+
scrollSpeed: 5;
|
|
330
|
+
/**
|
|
331
|
+
* Optional callback passed to `toDict` on dragStart @since 2.38
|
|
332
|
+
* Default: null
|
|
333
|
+
*/
|
|
334
|
+
sourceCopyHook: null;
|
|
335
|
+
/**
|
|
336
|
+
* Callback(sourceNode, data), return true, to enable dnd drag
|
|
337
|
+
* Default: null
|
|
338
|
+
*/
|
|
339
|
+
dragStart?: WbNodeEventType;
|
|
340
|
+
/**
|
|
341
|
+
* Callback(sourceNode, data)
|
|
342
|
+
* Default: null
|
|
343
|
+
*/
|
|
344
|
+
dragDrag: null;
|
|
345
|
+
/**
|
|
346
|
+
* Callback(sourceNode, data)
|
|
347
|
+
* Default: null
|
|
348
|
+
*/
|
|
349
|
+
dragEnd: null;
|
|
350
|
+
/**
|
|
351
|
+
* Callback(targetNode, data), return true, to enable dnd drop
|
|
352
|
+
* Default: null
|
|
353
|
+
*/
|
|
354
|
+
dragEnter: null;
|
|
355
|
+
/**
|
|
356
|
+
* Callback(targetNode, data)
|
|
357
|
+
* Default: null
|
|
358
|
+
*/
|
|
359
|
+
dragOver: null;
|
|
360
|
+
/**
|
|
361
|
+
* Callback(targetNode, data), return false to prevent autoExpand
|
|
362
|
+
* Default: null
|
|
363
|
+
*/
|
|
364
|
+
dragExpand: null;
|
|
365
|
+
/**
|
|
366
|
+
* Callback(targetNode, data)
|
|
367
|
+
* Default: null
|
|
368
|
+
*/
|
|
369
|
+
dragDrop: null;
|
|
370
|
+
/**
|
|
371
|
+
* Callback(targetNode, data)
|
|
372
|
+
* Default: null
|
|
373
|
+
*/
|
|
374
|
+
dragLeave: null;
|
|
375
|
+
};
|
|
376
|
+
export class DndExtension extends WunderbaumExtension {
|
|
377
|
+
protected srcNode: WunderbaumNode | null;
|
|
378
|
+
protected lastTargetNode: WunderbaumNode | null;
|
|
379
|
+
protected lastEnterStamp: number;
|
|
380
|
+
protected lastAllowedDropRegions: DropRegionTypeSet | null;
|
|
381
|
+
protected lastDropEffect: string | null;
|
|
382
|
+
protected lastDropRegion: DropRegionType | false;
|
|
383
|
+
constructor(tree: Wunderbaum);
|
|
384
|
+
init(): void;
|
|
385
|
+
/** Cleanup classes after target node is no longer hovered. */
|
|
386
|
+
protected _leaveNode(): void;
|
|
387
|
+
/** */
|
|
388
|
+
protected unifyDragover(res: any): DropRegionTypeSet | false;
|
|
389
|
+
/** */
|
|
390
|
+
protected _calcDropRegion(e: DragEvent, allowed: DropRegionTypeSet | null): DropRegionType | false;
|
|
391
|
+
protected autoScroll(event: DragEvent): number;
|
|
392
|
+
protected onDragEvent(e: DragEvent): boolean;
|
|
393
|
+
protected onDropEvent(e: DragEvent): boolean;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
214
396
|
declare module "wb_options" {
|
|
215
397
|
/*!
|
|
216
398
|
* Wunderbaum - utils
|
|
217
399
|
* Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
|
|
218
400
|
* @VERSION, @DATE (https://github.com/mar10/wunderbaum)
|
|
219
401
|
*/
|
|
220
|
-
import { BoolOptionResolver, NavigationModeOption,
|
|
402
|
+
import { BoolOptionResolver, NavigationModeOption, WbNodeEventType, WbTreeEventType } from "common";
|
|
403
|
+
import { DndOptionsType } from "wb_ext_dnd";
|
|
221
404
|
export interface WbNodeData {
|
|
222
405
|
title: string;
|
|
223
406
|
key?: string;
|
|
224
407
|
refKey?: string;
|
|
225
408
|
expanded?: boolean;
|
|
226
409
|
selected?: boolean;
|
|
227
|
-
checkbox?: boolean |
|
|
410
|
+
checkbox?: boolean | string;
|
|
228
411
|
children?: Array<WbNodeData>;
|
|
229
412
|
}
|
|
230
413
|
/**
|
|
@@ -268,56 +451,164 @@ declare module "wb_options" {
|
|
|
268
451
|
*
|
|
269
452
|
* Default: `{}`.
|
|
270
453
|
*/
|
|
271
|
-
types
|
|
454
|
+
types?: any;
|
|
272
455
|
/**
|
|
273
456
|
* A list of maps that define column headers. If this option is set,
|
|
274
|
-
* Wunderbaum becomes a
|
|
457
|
+
* Wunderbaum becomes a treegrid control instead of a plain tree.
|
|
275
458
|
* Column definitions can be passed as tree option, or be part of a `source`
|
|
276
459
|
* response.
|
|
277
460
|
* Default: `[]` meaning this is a plain tree.
|
|
278
461
|
*/
|
|
279
462
|
columns?: Array<any>;
|
|
280
463
|
/**
|
|
281
|
-
*
|
|
464
|
+
* If true, add a `wb-skeleton` class to all nodes, that will result in a
|
|
465
|
+
* 'glow' effect. Typically used with initial dummy nodes, while loading the
|
|
466
|
+
* real data.
|
|
282
467
|
* Default: false.
|
|
283
468
|
*/
|
|
284
|
-
skeleton
|
|
469
|
+
skeleton?: false;
|
|
285
470
|
/**
|
|
286
|
-
*
|
|
287
|
-
* Default: false.
|
|
471
|
+
* Translation map for some system messages.
|
|
288
472
|
*/
|
|
289
|
-
strings
|
|
473
|
+
strings?: any;
|
|
290
474
|
/**
|
|
475
|
+
* 0:quiet, 1:errors, 2:warnings, 3:info, 4:verbose
|
|
476
|
+
* Default: 3 (4 in local debug environment)
|
|
291
477
|
*/
|
|
292
|
-
debugLevel:
|
|
293
|
-
minExpandLevel: 0;
|
|
294
|
-
escapeTitles: true;
|
|
295
|
-
headerHeightPx: 22;
|
|
296
|
-
autoCollapse: false;
|
|
297
|
-
dnd: any;
|
|
298
|
-
filter: any;
|
|
478
|
+
debugLevel: number;
|
|
299
479
|
/**
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
|
|
303
|
-
|
|
480
|
+
* Number of levels that are forced to be expanded, and have no expander icon.
|
|
481
|
+
* Default: 0
|
|
482
|
+
*/
|
|
483
|
+
minExpandLevel?: number;
|
|
484
|
+
/**
|
|
485
|
+
* Height of the header row div.
|
|
486
|
+
* Default: 22
|
|
487
|
+
*/
|
|
488
|
+
headerHeightPx: number;
|
|
489
|
+
/**
|
|
490
|
+
* Height of a node row div.
|
|
491
|
+
* Default: 22
|
|
492
|
+
*/
|
|
493
|
+
rowHeightPx?: number;
|
|
494
|
+
/**
|
|
495
|
+
* Collapse siblings when a node is expanded.
|
|
496
|
+
* Default: false
|
|
497
|
+
*/
|
|
498
|
+
autoCollapse?: boolean;
|
|
499
|
+
/**
|
|
500
|
+
* Default: NavigationModeOption.startRow
|
|
304
501
|
*/
|
|
305
502
|
navigationMode?: NavigationModeOption;
|
|
503
|
+
/**
|
|
504
|
+
* Show/hide header (pass bool or string)
|
|
505
|
+
*/
|
|
506
|
+
header?: boolean | string | null;
|
|
507
|
+
/**
|
|
508
|
+
*
|
|
509
|
+
*/
|
|
510
|
+
showSpinner?: boolean;
|
|
511
|
+
/**
|
|
512
|
+
* Default: true
|
|
513
|
+
*/
|
|
514
|
+
checkbox?: boolean | "radio" | BoolOptionResolver;
|
|
515
|
+
/**
|
|
516
|
+
* Default: 200
|
|
517
|
+
*/
|
|
518
|
+
updateThrottleWait?: number;
|
|
519
|
+
/**
|
|
520
|
+
* Default: true
|
|
521
|
+
*/
|
|
522
|
+
quicksearch?: boolean;
|
|
523
|
+
dnd?: DndOptionsType;
|
|
524
|
+
filter: any;
|
|
525
|
+
grid: any;
|
|
306
526
|
/**
|
|
307
527
|
* Called after initial data was loaded and tree markup was rendered.
|
|
528
|
+
* Check `e.error` for status.
|
|
308
529
|
* @category Callback
|
|
309
530
|
*/
|
|
310
|
-
init?: (e:
|
|
531
|
+
init?: (e: WbTreeEventType) => void;
|
|
311
532
|
/**
|
|
312
|
-
*
|
|
533
|
+
*
|
|
534
|
+
* @category Callback
|
|
535
|
+
*/
|
|
536
|
+
update?: (e: WbTreeEventType) => void;
|
|
537
|
+
/**
|
|
538
|
+
*
|
|
539
|
+
* @category Callback
|
|
540
|
+
*/
|
|
541
|
+
activate?: (e: WbNodeEventType) => void;
|
|
542
|
+
/**
|
|
543
|
+
*
|
|
544
|
+
* @category Callback
|
|
545
|
+
*/
|
|
546
|
+
deactivate?: (e: WbNodeEventType) => void;
|
|
547
|
+
/**
|
|
548
|
+
*
|
|
549
|
+
* @category Callback
|
|
550
|
+
*/
|
|
551
|
+
change?: (e: WbNodeEventType) => void;
|
|
552
|
+
/**
|
|
553
|
+
*
|
|
554
|
+
* @category Callback
|
|
555
|
+
*/
|
|
556
|
+
click?: (e: WbTreeEventType) => void;
|
|
557
|
+
/**
|
|
558
|
+
*
|
|
559
|
+
* @category Callback
|
|
560
|
+
*/
|
|
561
|
+
discard?: (e: WbNodeEventType) => void;
|
|
562
|
+
/**
|
|
563
|
+
*
|
|
564
|
+
* @category Callback
|
|
565
|
+
*/
|
|
566
|
+
error?: (e: WbTreeEventType) => void;
|
|
567
|
+
/**
|
|
568
|
+
*
|
|
569
|
+
* @category Callback
|
|
570
|
+
*/
|
|
571
|
+
enhanceTitle?: (e: WbNodeEventType) => void;
|
|
572
|
+
/**
|
|
573
|
+
*
|
|
574
|
+
* Check `e.flag` for status.
|
|
575
|
+
* @category Callback
|
|
576
|
+
*/
|
|
577
|
+
focus?: (e: WbTreeEventType) => void;
|
|
578
|
+
/**
|
|
579
|
+
*
|
|
313
580
|
* @category Callback
|
|
314
581
|
*/
|
|
315
|
-
|
|
582
|
+
keydown?: (e: WbNodeEventType) => void;
|
|
316
583
|
/**
|
|
317
584
|
* Called after data was loaded from local storage.
|
|
585
|
+
*/
|
|
586
|
+
load?: (e: WbNodeEventType) => void;
|
|
587
|
+
/**
|
|
318
588
|
* @category Callback
|
|
319
589
|
*/
|
|
320
|
-
modifyChild?: (e:
|
|
590
|
+
modifyChild?: (e: WbNodeEventType) => void;
|
|
591
|
+
/**
|
|
592
|
+
*
|
|
593
|
+
* @category Callback
|
|
594
|
+
*/
|
|
595
|
+
receive?: (e: WbNodeEventType) => void;
|
|
596
|
+
/**
|
|
597
|
+
*
|
|
598
|
+
* @category Callback
|
|
599
|
+
*/
|
|
600
|
+
render?: (e: WbNodeEventType) => void;
|
|
601
|
+
/**
|
|
602
|
+
*
|
|
603
|
+
* @category Callback
|
|
604
|
+
*/
|
|
605
|
+
renderStatusNode?: (e: WbNodeEventType) => void;
|
|
606
|
+
/**
|
|
607
|
+
*
|
|
608
|
+
* Check `e.flag` for status.
|
|
609
|
+
* @category Callback
|
|
610
|
+
*/
|
|
611
|
+
select?: (e: WbNodeEventType) => void;
|
|
321
612
|
}
|
|
322
613
|
}
|
|
323
614
|
declare module "wb_node" {
|
|
@@ -328,27 +619,47 @@ declare module "wb_node" {
|
|
|
328
619
|
*/
|
|
329
620
|
import "./wunderbaum.scss";
|
|
330
621
|
import { Wunderbaum } from "wunderbaum";
|
|
331
|
-
import { ChangeType, MatcherType, NodeAnyCallback, NodeStatusType, NodeVisitCallback, NodeVisitResponse, ApplyCommandType, AddNodeType } from "common";
|
|
622
|
+
import { ChangeType, MatcherType, NodeAnyCallback, NodeStatusType, NodeVisitCallback, NodeVisitResponse, ApplyCommandType, AddNodeType, SetActiveOptions, SetExpandedOptions, SetSelectedOptions } from "common";
|
|
332
623
|
import { WbNodeData } from "wb_options";
|
|
624
|
+
/**
|
|
625
|
+
* A single tree node.
|
|
626
|
+
*
|
|
627
|
+
* **NOTE:** <br>
|
|
628
|
+
* Generally you should not modify properties directly, since this may break
|
|
629
|
+
* the internal bookkeeping.
|
|
630
|
+
*/
|
|
333
631
|
export class WunderbaumNode {
|
|
334
632
|
static sequence: number;
|
|
335
633
|
/** Reference to owning tree. */
|
|
336
634
|
tree: Wunderbaum;
|
|
337
635
|
/** Parent node (null for the invisible root node `tree.root`). */
|
|
338
636
|
parent: WunderbaumNode;
|
|
637
|
+
/** Name of the node.
|
|
638
|
+
* @see Use {@link setTitle} to modify. */
|
|
339
639
|
title: string;
|
|
640
|
+
/** Unique key. Passed with constructor or defaults to `SEQUENCE`.
|
|
641
|
+
* @see Use {@link setKey} to modify. */
|
|
340
642
|
readonly key: string;
|
|
643
|
+
/** Reference key. Unlike {@link key}, a `refKey` may occur multiple
|
|
644
|
+
* times within a tree (in this case we have 'clone nodes').
|
|
645
|
+
* @see Use {@link setKey} to modify.
|
|
646
|
+
*/
|
|
341
647
|
readonly refKey: string | undefined;
|
|
342
648
|
children: WunderbaumNode[] | null;
|
|
343
649
|
checkbox?: boolean;
|
|
344
650
|
colspan?: boolean;
|
|
345
651
|
icon?: boolean | string;
|
|
346
652
|
lazy: boolean;
|
|
653
|
+
/** Expansion state.
|
|
654
|
+
* @see {@link isExpandable}, {@link isExpanded}, {@link setExpanded}. */
|
|
347
655
|
expanded: boolean;
|
|
656
|
+
/** Selection state.
|
|
657
|
+
* @see {@link isSelected}, {@link setSelected}. */
|
|
348
658
|
selected: boolean;
|
|
349
659
|
type?: string;
|
|
350
660
|
tooltip?: string;
|
|
351
|
-
/** Additional classes added to `div.wb-row`.
|
|
661
|
+
/** Additional classes added to `div.wb-row`.
|
|
662
|
+
* @see {@link addClass}, {@link removeClass}, {@link toggleClass}. */
|
|
352
663
|
extraClasses: Set<string>;
|
|
353
664
|
/** Custom data that was passed to the constructor */
|
|
354
665
|
data: any;
|
|
@@ -361,6 +672,7 @@ declare module "wb_node" {
|
|
|
361
672
|
match?: boolean;
|
|
362
673
|
subMatchCount?: number;
|
|
363
674
|
subMatchBadge?: HTMLElement;
|
|
675
|
+
/** @internal */
|
|
364
676
|
titleWithHighlight?: string;
|
|
365
677
|
_filterAutoExpanded?: boolean;
|
|
366
678
|
_rowIdx: number | undefined;
|
|
@@ -400,7 +712,8 @@ declare module "wb_node" {
|
|
|
400
712
|
addNode(nodeData: WbNodeData, mode?: string): WunderbaumNode;
|
|
401
713
|
/**
|
|
402
714
|
* Apply a modification (or navigation) operation.
|
|
403
|
-
*
|
|
715
|
+
*
|
|
716
|
+
* @see {@link Wunderbaum.applyCommand}
|
|
404
717
|
*/
|
|
405
718
|
applyCommand(cmd: ApplyCommandType, opts: any): any;
|
|
406
719
|
addClass(className: string | string[] | Set<string>): void;
|
|
@@ -424,8 +737,7 @@ declare module "wb_node" {
|
|
|
424
737
|
findFirst(match: string | MatcherType): WunderbaumNode | null;
|
|
425
738
|
/** Find a node relative to self.
|
|
426
739
|
*
|
|
427
|
-
* @
|
|
428
|
-
* or a keyword ('down', 'first', 'last', 'left', 'parent', 'right', 'up').
|
|
740
|
+
* @see {@link Wunderbaum.findRelatedNode|tree.findRelatedNode()}
|
|
429
741
|
*/
|
|
430
742
|
findRelatedNode(where: string, includeHidden?: boolean): any;
|
|
431
743
|
/** Return the `<span class='wb-col'>` element with a given index or id.
|
|
@@ -586,26 +898,45 @@ declare module "wb_node" {
|
|
|
586
898
|
*
|
|
587
899
|
* Evaluation sequence:
|
|
588
900
|
*
|
|
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`.
|
|
901
|
+
* - If `tree.options.<name>` is a callback that returns something, use that.
|
|
902
|
+
* - Else if `node.<name>` is defined, use that.
|
|
903
|
+
* - Else if `tree.types[<node.type>]` is a value, use that.
|
|
904
|
+
* - Else if `tree.options.<name>` is a value, use that.
|
|
905
|
+
* - Else use `defaultValue`.
|
|
594
906
|
*
|
|
595
907
|
* @param name name of the option property (on node and tree)
|
|
596
908
|
* @param defaultValue return this if nothing else matched
|
|
909
|
+
* {@link Wunderbaum.getOption|Wunderbaum.getOption()}
|
|
597
910
|
*/
|
|
598
911
|
getOption(name: string, defaultValue?: any): any;
|
|
912
|
+
/** Make sure that this node is visible in the viewport.
|
|
913
|
+
* @see {@link Wunderbaum.scrollTo|Wunderbaum.scrollTo()}
|
|
914
|
+
*/
|
|
599
915
|
scrollIntoView(options?: any): Promise<void>;
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
916
|
+
/**
|
|
917
|
+
* Activate this node, deactivate previous, send events, activate column and scroll int viewport.
|
|
918
|
+
*/
|
|
919
|
+
setActive(flag?: boolean, options?: SetActiveOptions): Promise<void>;
|
|
920
|
+
/**
|
|
921
|
+
* Expand or collapse this node.
|
|
922
|
+
*/
|
|
923
|
+
setExpanded(flag?: boolean, options?: SetExpandedOptions): Promise<void>;
|
|
924
|
+
/**
|
|
925
|
+
* Set keyboard focus here.
|
|
926
|
+
* @see {@link setActive}
|
|
607
927
|
*/
|
|
928
|
+
setFocus(flag?: boolean, options?: any): void;
|
|
929
|
+
/** Set a new icon path or class. */
|
|
930
|
+
setIcon(): void;
|
|
931
|
+
/** Change node's {@link key} and/or {@link refKey}. */
|
|
932
|
+
setKey(key: string | null, refKey: string | null): void;
|
|
933
|
+
/** Schedule a render, typically called to update after a status or data change. */
|
|
934
|
+
setModified(change?: ChangeType): void;
|
|
935
|
+
/** Modify the check/uncheck state. */
|
|
936
|
+
setSelected(flag?: boolean, options?: SetSelectedOptions): void;
|
|
937
|
+
/** Display node status (ok, loading, error, noData) using styles and a dummy child node. */
|
|
608
938
|
setStatus(status: NodeStatusType, message?: string, details?: string): WunderbaumNode | null;
|
|
939
|
+
/** Rename this node. */
|
|
609
940
|
setTitle(title: string): void;
|
|
610
941
|
/**
|
|
611
942
|
* Trigger `modifyChild` event on a parent to signal that a child was modified.
|
|
@@ -617,9 +948,12 @@ declare module "wb_node" {
|
|
|
617
948
|
* @param {string} operation Type of change: 'add', 'remove', 'rename', 'move', 'data', ...
|
|
618
949
|
* @param {object} [extra]
|
|
619
950
|
*/
|
|
620
|
-
triggerModify(operation: string, extra
|
|
621
|
-
/**
|
|
622
|
-
*
|
|
951
|
+
triggerModify(operation: string, extra?: any): void;
|
|
952
|
+
/**
|
|
953
|
+
* Call fn(node) for all child nodes in hierarchical order (depth-first).
|
|
954
|
+
*
|
|
955
|
+
* Stop iteration, if fn() returns false. Skip current branch, if fn()
|
|
956
|
+
* returns "skip".<br>
|
|
623
957
|
* Return false if iteration was stopped.
|
|
624
958
|
*
|
|
625
959
|
* @param {function} callback the callback function.
|
|
@@ -634,7 +968,8 @@ declare module "wb_node" {
|
|
|
634
968
|
* @param callback the callback function. Return false to stop iteration
|
|
635
969
|
*/
|
|
636
970
|
visitParents(callback: (node: WunderbaumNode) => boolean | void, includeSelf?: boolean): boolean;
|
|
637
|
-
/**
|
|
971
|
+
/**
|
|
972
|
+
* Call fn(node) for all sibling nodes.<br>
|
|
638
973
|
* Stop iteration, if fn() returns false.<br>
|
|
639
974
|
* Return false if iteration was stopped.
|
|
640
975
|
*
|
|
@@ -663,16 +998,16 @@ declare module "common" {
|
|
|
663
998
|
export type NodeAnyCallback = (node: WunderbaumNode) => any;
|
|
664
999
|
export type NodeVisitResponse = "skip" | boolean | void;
|
|
665
1000
|
export type NodeVisitCallback = (node: WunderbaumNode) => NodeVisitResponse;
|
|
666
|
-
export type
|
|
1001
|
+
export type WbTreeEventType = {
|
|
667
1002
|
name: string;
|
|
668
1003
|
event: Event;
|
|
669
1004
|
tree: Wunderbaum;
|
|
670
1005
|
[key: string]: unknown;
|
|
671
1006
|
};
|
|
672
|
-
export type WbNodeEventType =
|
|
1007
|
+
export type WbNodeEventType = WbTreeEventType & {
|
|
673
1008
|
node: WunderbaumNode;
|
|
674
1009
|
};
|
|
675
|
-
export type
|
|
1010
|
+
export type WbTreeCallbackType = (e: WbTreeEventType) => any;
|
|
676
1011
|
export type WbNodeCallbackType = (e: WbNodeEventType) => any;
|
|
677
1012
|
export type FilterModeType = null | "dim" | "hide";
|
|
678
1013
|
export type ApplyCommandType = "moveUp" | "moveDown" | "indent" | "outdent" | "remove" | "rename" | "addChild" | "addSibling" | "cut" | "copy" | "paste" | "down" | "first" | "last" | "left" | "pageDown" | "pageUp" | "parent" | "right" | "up";
|
|
@@ -684,7 +1019,9 @@ declare module "common" {
|
|
|
684
1019
|
any = "any",
|
|
685
1020
|
row = "row",
|
|
686
1021
|
structure = "structure",
|
|
687
|
-
status = "status"
|
|
1022
|
+
status = "status",
|
|
1023
|
+
vscroll = "vscroll",
|
|
1024
|
+
header = "header"
|
|
688
1025
|
}
|
|
689
1026
|
export enum NodeStatusType {
|
|
690
1027
|
ok = "ok",
|
|
@@ -731,6 +1068,32 @@ declare module "common" {
|
|
|
731
1068
|
cellNav = "cellNav",
|
|
732
1069
|
cellEdit = "cellEdit"
|
|
733
1070
|
}
|
|
1071
|
+
export type SetActiveOptions = {
|
|
1072
|
+
/** Generate (de)activate event, even if node already has this status. */
|
|
1073
|
+
retrigger?: boolean;
|
|
1074
|
+
/** Don not generate (de)activate event. */
|
|
1075
|
+
noEvents?: boolean;
|
|
1076
|
+
/** Optional original event that will be passed to the (de)activat handler. */
|
|
1077
|
+
event?: Event;
|
|
1078
|
+
/** Call {@link setColumn}. */
|
|
1079
|
+
colIdx?: number;
|
|
1080
|
+
};
|
|
1081
|
+
export type SetExpandedOptions = {
|
|
1082
|
+
/** Ignore {@link minExpandLevel}. @default false */
|
|
1083
|
+
force?: boolean;
|
|
1084
|
+
/** Avoid smooth scrolling. @default false */
|
|
1085
|
+
noAnimation?: boolean;
|
|
1086
|
+
/** Do not send events. @default false */
|
|
1087
|
+
noEvents?: boolean;
|
|
1088
|
+
/** Scroll to bring expanded nodes into viewport. @default false */
|
|
1089
|
+
scrollIntoView?: boolean;
|
|
1090
|
+
};
|
|
1091
|
+
export type SetSelectedOptions = {
|
|
1092
|
+
/** Ignore restrictions. @default false */
|
|
1093
|
+
force?: boolean;
|
|
1094
|
+
/** Do not send events. @default false */
|
|
1095
|
+
noEvents?: boolean;
|
|
1096
|
+
};
|
|
734
1097
|
/** Define which keys are handled by embedded <input> control, and should
|
|
735
1098
|
* *not* be passed to tree navigation handler in cell-edit mode: */
|
|
736
1099
|
export const INPUT_KEYS: {
|
|
@@ -753,27 +1116,6 @@ declare module "common" {
|
|
|
753
1116
|
/** */
|
|
754
1117
|
export function makeNodeTitleStartMatcher(s: string): MatcherType;
|
|
755
1118
|
}
|
|
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
1119
|
declare module "debounce" {
|
|
778
1120
|
/*!
|
|
779
1121
|
* debounce & throttle, taken from https://github.com/lodash/lodash v4.17.21
|
|
@@ -933,15 +1275,10 @@ declare module "wb_ext_filter" {
|
|
|
933
1275
|
filterBranches(filter: string | NodeFilterCallback, opts: any): void;
|
|
934
1276
|
/**
|
|
935
1277
|
* [ext-filter] Re-apply current filter.
|
|
936
|
-
*
|
|
937
|
-
* @requires jquery.fancytree.filter.js
|
|
938
1278
|
*/
|
|
939
1279
|
updateFilter(): void;
|
|
940
1280
|
/**
|
|
941
1281
|
* [ext-filter] Reset the filter.
|
|
942
|
-
*
|
|
943
|
-
* @alias Fancytree#clearFilter
|
|
944
|
-
* @requires jquery.fancytree.filter.js
|
|
945
1282
|
*/
|
|
946
1283
|
clearFilter(): void;
|
|
947
1284
|
}
|
|
@@ -965,30 +1302,75 @@ declare module "wb_ext_logger" {
|
|
|
965
1302
|
onKeyEvent(data: any): boolean | undefined;
|
|
966
1303
|
}
|
|
967
1304
|
}
|
|
968
|
-
declare module "
|
|
1305
|
+
declare module "drag_observer" {
|
|
1306
|
+
export type DragCallbackArgType = {
|
|
1307
|
+
/** "dragstart", "drag", or "dragstop". */
|
|
1308
|
+
type: string;
|
|
1309
|
+
/** Original mouse or touch event that triggered the drag event. */
|
|
1310
|
+
event: MouseEvent | TouchEvent;
|
|
1311
|
+
/** Element which is currently dragged. */
|
|
1312
|
+
dragElem: HTMLElement | null;
|
|
1313
|
+
/** Relative horizontal drag distance since start. */
|
|
1314
|
+
dx: number;
|
|
1315
|
+
/** Relative vertical drag distance since start. */
|
|
1316
|
+
dy: number;
|
|
1317
|
+
/** False if drag was canceled. */
|
|
1318
|
+
apply?: boolean;
|
|
1319
|
+
};
|
|
1320
|
+
export type DragCallbackType = (e: DragCallbackArgType) => boolean | void;
|
|
1321
|
+
type DragObserverOptionsType = {
|
|
1322
|
+
/**Event target (typically `window.document`). */
|
|
1323
|
+
root: EventTarget;
|
|
1324
|
+
/**Event delegation selector.*/
|
|
1325
|
+
selector?: string;
|
|
1326
|
+
/**Minimum drag distance in px. */
|
|
1327
|
+
thresh?: number;
|
|
1328
|
+
/**Return `false` to cancel drag. */
|
|
1329
|
+
dragstart: DragCallbackType;
|
|
1330
|
+
drag?: DragCallbackType;
|
|
1331
|
+
dragstop?: DragCallbackType;
|
|
1332
|
+
};
|
|
1333
|
+
/**
|
|
1334
|
+
* Convert mouse- and touch events to 'dragstart', 'drag', and 'dragstop'.
|
|
1335
|
+
*/
|
|
1336
|
+
export class DragObserver {
|
|
1337
|
+
protected _handler: any;
|
|
1338
|
+
protected root: EventTarget;
|
|
1339
|
+
protected start: {
|
|
1340
|
+
x: number;
|
|
1341
|
+
y: number;
|
|
1342
|
+
altKey: boolean;
|
|
1343
|
+
ctrlKey: boolean;
|
|
1344
|
+
metaKey: boolean;
|
|
1345
|
+
shiftKey: boolean;
|
|
1346
|
+
};
|
|
1347
|
+
protected dragElem: HTMLElement | null;
|
|
1348
|
+
protected dragging: boolean;
|
|
1349
|
+
protected events: string[];
|
|
1350
|
+
protected opts: DragObserverOptionsType;
|
|
1351
|
+
constructor(opts: DragObserverOptionsType);
|
|
1352
|
+
/** Unregister all event listeners. */
|
|
1353
|
+
disconnect(): void;
|
|
1354
|
+
getDragElem(): HTMLElement | null;
|
|
1355
|
+
isDragging(): boolean;
|
|
1356
|
+
stopDrag(cb_event?: DragCallbackArgType): void;
|
|
1357
|
+
protected handleEvent(e: MouseEvent): boolean | void;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
declare module "wb_ext_grid" {
|
|
1361
|
+
/*!
|
|
1362
|
+
* Wunderbaum - ext-grid
|
|
1363
|
+
* Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
|
|
1364
|
+
* @VERSION, @DATE (https://github.com/mar10/wunderbaum)
|
|
1365
|
+
*/
|
|
969
1366
|
import { Wunderbaum } from "wunderbaum";
|
|
970
1367
|
import { WunderbaumExtension } from "wb_extension_base";
|
|
971
|
-
import {
|
|
972
|
-
export
|
|
973
|
-
|
|
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;
|
|
1368
|
+
import { DragCallbackArgType, DragObserver } from "drag_observer";
|
|
1369
|
+
export class GridExtension extends WunderbaumExtension {
|
|
1370
|
+
protected observer: DragObserver;
|
|
981
1371
|
constructor(tree: Wunderbaum);
|
|
982
1372
|
init(): void;
|
|
983
|
-
|
|
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;
|
|
1373
|
+
protected handleDrag(e: DragCallbackArgType): void;
|
|
992
1374
|
}
|
|
993
1375
|
}
|
|
994
1376
|
declare module "wb_ext_edit" {
|
|
@@ -1053,67 +1435,79 @@ declare module "wunderbaum" {
|
|
|
1053
1435
|
* See also [[WunderbaumOptions]].
|
|
1054
1436
|
*/
|
|
1055
1437
|
export class Wunderbaum {
|
|
1438
|
+
protected static sequence: number;
|
|
1439
|
+
/** Wunderbaum release version number "MAJOR.MINOR.PATCH". */
|
|
1056
1440
|
static version: string;
|
|
1057
|
-
static sequence: number;
|
|
1058
1441
|
/** The invisible root node, that holds all visible top level nodes. */
|
|
1059
1442
|
readonly root: WunderbaumNode;
|
|
1443
|
+
/** Unique tree ID as passed to constructor. Defaults to `"wb_SEQUENCE"`. */
|
|
1060
1444
|
readonly id: string;
|
|
1445
|
+
/** The `div` container element that was passed to the constructor. */
|
|
1061
1446
|
readonly element: HTMLDivElement;
|
|
1447
|
+
/** The `div.wb-header` element if any. */
|
|
1062
1448
|
readonly headerElement: HTMLDivElement | null;
|
|
1449
|
+
/** The `div.wb-scroll-container` element that contains the `nodeListElement`. */
|
|
1063
1450
|
readonly scrollContainer: HTMLDivElement;
|
|
1451
|
+
/** The `div.wb-node-list` element that contains all visible div.wb-row child elements. */
|
|
1064
1452
|
readonly nodeListElement: HTMLDivElement;
|
|
1065
|
-
readonly _updateViewportThrottled: DebouncedFunction<(...args: any) => void>;
|
|
1453
|
+
protected readonly _updateViewportThrottled: DebouncedFunction<(...args: any) => void>;
|
|
1066
1454
|
protected extensionList: WunderbaumExtension[];
|
|
1067
1455
|
protected extensions: ExtensionsDict;
|
|
1068
1456
|
/** Merged options from constructor args and tree- and extension defaults. */
|
|
1069
1457
|
options: WunderbaumOptions;
|
|
1070
1458
|
protected keyMap: Map<string, WunderbaumNode>;
|
|
1071
1459
|
protected refKeyMap: Map<string, Set<WunderbaumNode>>;
|
|
1072
|
-
protected
|
|
1460
|
+
protected treeRowCount: number;
|
|
1461
|
+
protected _disableUpdateCount: number;
|
|
1462
|
+
/** Currently active node if any. */
|
|
1073
1463
|
activeNode: WunderbaumNode | null;
|
|
1464
|
+
/** Current node hat has keyboard focus if any. */
|
|
1074
1465
|
focusNode: WunderbaumNode | null;
|
|
1075
|
-
_disableUpdate: number;
|
|
1076
|
-
_disableUpdateCount: number;
|
|
1077
1466
|
/** Shared properties, referenced by `node.type`. */
|
|
1078
1467
|
types: {
|
|
1079
1468
|
[key: string]: any;
|
|
1080
1469
|
};
|
|
1081
1470
|
/** List of column definitions. */
|
|
1082
1471
|
columns: any[];
|
|
1083
|
-
_columnsById: {
|
|
1472
|
+
protected _columnsById: {
|
|
1084
1473
|
[key: string]: any;
|
|
1085
1474
|
};
|
|
1086
|
-
protected resizeObserver:
|
|
1087
|
-
protected
|
|
1088
|
-
|
|
1089
|
-
|
|
1475
|
+
protected resizeObserver: ResizeObserver;
|
|
1476
|
+
protected changeRedrawRequestPending: boolean;
|
|
1477
|
+
/** A Promise that is resolved when the tree was initialized (similar to `init(e)` event). */
|
|
1478
|
+
readonly ready: Promise<any>;
|
|
1479
|
+
/** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
|
|
1480
|
+
static util: typeof util;
|
|
1481
|
+
/** Expose some useful methods of the util.ts module as `tree._util`. */
|
|
1482
|
+
_util: typeof util;
|
|
1090
1483
|
filterMode: FilterModeType;
|
|
1484
|
+
/** @internal Use `setColumn()`/`getActiveColElem()`*/
|
|
1091
1485
|
activeColIdx: number;
|
|
1486
|
+
/** @internal */
|
|
1092
1487
|
navMode: NavigationMode;
|
|
1488
|
+
/** @internal */
|
|
1093
1489
|
lastQuicksearchTime: number;
|
|
1490
|
+
/** @internal */
|
|
1094
1491
|
lastQuicksearchTerm: string;
|
|
1095
1492
|
protected lastClickTime: number;
|
|
1096
|
-
readonly ready: Promise<any>;
|
|
1097
|
-
static util: typeof util;
|
|
1098
|
-
_util: typeof util;
|
|
1099
1493
|
constructor(options: WunderbaumOptions);
|
|
1100
|
-
/**
|
|
1101
|
-
|
|
1494
|
+
/**
|
|
1495
|
+
* Return a Wunderbaum instance, from element, id, index, or event.
|
|
1102
1496
|
*
|
|
1103
|
-
*
|
|
1104
|
-
* getTree();
|
|
1105
|
-
* getTree(1);
|
|
1106
|
-
* getTree(event);
|
|
1107
|
-
* getTree("foo");
|
|
1497
|
+
* ```js
|
|
1498
|
+
* getTree(); // Get first Wunderbaum instance on page
|
|
1499
|
+
* getTree(1); // Get second Wunderbaum instance on page
|
|
1500
|
+
* getTree(event); // Get tree for this mouse- or keyboard event
|
|
1501
|
+
* getTree("foo"); // Get tree for this `tree.options.id`
|
|
1108
1502
|
* getTree("#tree"); // Get tree for this matching element
|
|
1503
|
+
* ```
|
|
1109
1504
|
*/
|
|
1110
1505
|
static getTree(el?: Element | Event | number | string | WunderbaumNode): Wunderbaum | null;
|
|
1111
|
-
/**
|
|
1112
|
-
*
|
|
1113
|
-
* @param el
|
|
1506
|
+
/**
|
|
1507
|
+
* Return a WunderbaumNode instance from element or event.
|
|
1114
1508
|
*/
|
|
1115
1509
|
static getNode(el: Element | Event): WunderbaumNode | null;
|
|
1116
|
-
/** */
|
|
1510
|
+
/** @internal */
|
|
1117
1511
|
protected _registerExtension(extension: WunderbaumExtension): void;
|
|
1118
1512
|
/** Called on tree (re)init after markup is created, before loading. */
|
|
1119
1513
|
protected _initExtensions(): void;
|
|
@@ -1123,37 +1517,47 @@ declare module "wunderbaum" {
|
|
|
1123
1517
|
_unregisterNode(node: WunderbaumNode): void;
|
|
1124
1518
|
/** Call all hook methods of all registered extensions.*/
|
|
1125
1519
|
protected _callHook(hook: keyof WunderbaumExtension, data?: any): any;
|
|
1126
|
-
/**
|
|
1520
|
+
/**
|
|
1521
|
+
* Call tree method or extension method if defined.
|
|
1522
|
+
*
|
|
1127
1523
|
* Example:
|
|
1128
1524
|
* ```js
|
|
1129
1525
|
* tree._callMethod("edit.startEdit", "arg1", "arg2")
|
|
1130
1526
|
* ```
|
|
1131
1527
|
*/
|
|
1132
1528
|
_callMethod(name: string, ...args: any[]): any;
|
|
1133
|
-
/**
|
|
1529
|
+
/**
|
|
1530
|
+
* Call event handler if defined in tree or tree.EXTENSION options.
|
|
1531
|
+
*
|
|
1134
1532
|
* Example:
|
|
1135
1533
|
* ```js
|
|
1136
1534
|
* tree._callEvent("edit.beforeEdit", {foo: 42})
|
|
1137
1535
|
* ```
|
|
1138
1536
|
*/
|
|
1139
1537
|
_callEvent(name: string, extra?: any): any;
|
|
1140
|
-
/** Return the
|
|
1538
|
+
/** Return the node for given row index. */
|
|
1539
|
+
protected _getNodeByRowIdx(idx: number): WunderbaumNode | null;
|
|
1540
|
+
/** Return the topmost visible node in the viewport. */
|
|
1141
1541
|
protected _firstNodeInView(complete?: boolean): WunderbaumNode;
|
|
1142
|
-
/** Return the lowest visible node in the viewport */
|
|
1542
|
+
/** Return the lowest visible node in the viewport. */
|
|
1143
1543
|
protected _lastNodeInView(complete?: boolean): WunderbaumNode;
|
|
1144
|
-
/** Return preceeding visible node in the viewport */
|
|
1544
|
+
/** Return preceeding visible node in the viewport. */
|
|
1145
1545
|
protected _getPrevNodeInView(node?: WunderbaumNode, ofs?: number): WunderbaumNode;
|
|
1146
|
-
/** Return following visible node in the viewport */
|
|
1546
|
+
/** Return following visible node in the viewport. */
|
|
1147
1547
|
protected _getNextNodeInView(node?: WunderbaumNode, ofs?: number): WunderbaumNode;
|
|
1548
|
+
/**
|
|
1549
|
+
* Append (or insert) a list of toplevel nodes.
|
|
1550
|
+
*
|
|
1551
|
+
* @see {@link WunderbaumNode.addChildren}
|
|
1552
|
+
*/
|
|
1148
1553
|
addChildren(nodeData: any, options?: any): WunderbaumNode;
|
|
1149
1554
|
/**
|
|
1150
|
-
* Apply a modification (or navigation) operation on the tree or active node
|
|
1151
|
-
* @returns
|
|
1555
|
+
* Apply a modification (or navigation) operation on the **tree or active node**.
|
|
1152
1556
|
*/
|
|
1153
1557
|
applyCommand(cmd: ApplyCommandType, opts?: any): any;
|
|
1154
1558
|
/**
|
|
1155
|
-
* Apply a modification (or navigation) operation on a node
|
|
1156
|
-
* @
|
|
1559
|
+
* Apply a modification (or navigation) operation on a **node**.
|
|
1560
|
+
* @see {@link WunderbaumNode.applyCommand}
|
|
1157
1561
|
*/
|
|
1158
1562
|
applyCommand(cmd: ApplyCommandType, node: WunderbaumNode, opts?: any): any;
|
|
1159
1563
|
/** Delete all nodes. */
|
|
@@ -1169,10 +1573,11 @@ declare module "wunderbaum" {
|
|
|
1169
1573
|
/**
|
|
1170
1574
|
* Return `tree.option.NAME` (also resolving if this is a callback).
|
|
1171
1575
|
*
|
|
1172
|
-
* See also
|
|
1173
|
-
* `tree.types[node.type].NAME`.
|
|
1576
|
+
* See also {@link WunderbaumNode.getOption|WunderbaumNode.getOption()}
|
|
1577
|
+
* to consider `node.NAME` setting and `tree.types[node.type].NAME`.
|
|
1174
1578
|
*
|
|
1175
|
-
* @param name option name (use dot notation to access extension option, e.g.
|
|
1579
|
+
* @param name option name (use dot notation to access extension option, e.g.
|
|
1580
|
+
* `filter.mode`)
|
|
1176
1581
|
*/
|
|
1177
1582
|
getOption(name: string, defaultValue?: any): any;
|
|
1178
1583
|
/**
|
|
@@ -1189,26 +1594,33 @@ declare module "wunderbaum" {
|
|
|
1189
1594
|
expandAll(flag?: boolean): Promise<void>;
|
|
1190
1595
|
/** Return the number of nodes in the data model.*/
|
|
1191
1596
|
count(visible?: boolean): number;
|
|
1597
|
+
/** @internal sanity check. */
|
|
1192
1598
|
_check(): void;
|
|
1193
|
-
/**
|
|
1599
|
+
/**
|
|
1600
|
+
* Find all nodes that matches condition.
|
|
1194
1601
|
*
|
|
1195
1602
|
* @param match title string to search for, or a
|
|
1196
1603
|
* callback function that returns `true` if a node is matched.
|
|
1197
|
-
*
|
|
1604
|
+
*
|
|
1605
|
+
* @see {@link WunderbaumNode.findAll}
|
|
1198
1606
|
*/
|
|
1199
1607
|
findAll(match: string | MatcherType): WunderbaumNode[];
|
|
1200
|
-
/**
|
|
1608
|
+
/**
|
|
1609
|
+
* Find first node that matches condition.
|
|
1201
1610
|
*
|
|
1202
1611
|
* @param match title string to search for, or a
|
|
1203
1612
|
* callback function that returns `true` if a node is matched.
|
|
1204
|
-
* @see
|
|
1613
|
+
* @see {@link WunderbaumNode.findFirst}
|
|
1614
|
+
*
|
|
1205
1615
|
*/
|
|
1206
1616
|
findFirst(match: string | MatcherType): WunderbaumNode;
|
|
1207
|
-
/**
|
|
1617
|
+
/**
|
|
1618
|
+
* Find the next visible node that starts with `match`, starting at `startNode`
|
|
1208
1619
|
* and wrap-around at the end.
|
|
1209
1620
|
*/
|
|
1210
1621
|
findNextNode(match: string | MatcherType, startNode?: WunderbaumNode | null): WunderbaumNode | null;
|
|
1211
|
-
/**
|
|
1622
|
+
/**
|
|
1623
|
+
* Find a node relative to another node.
|
|
1212
1624
|
*
|
|
1213
1625
|
* @param node
|
|
1214
1626
|
* @param where 'down', 'first', 'last', 'left', 'parent', 'right', or 'up'.
|
|
@@ -1218,34 +1630,35 @@ declare module "wunderbaum" {
|
|
|
1218
1630
|
*/
|
|
1219
1631
|
findRelatedNode(node: WunderbaumNode, where: string, includeHidden?: boolean): any;
|
|
1220
1632
|
/**
|
|
1221
|
-
* Return the active cell of the currently active node or null.
|
|
1633
|
+
* Return the active cell (`span.wb-col`) of the currently active node or null.
|
|
1222
1634
|
*/
|
|
1223
1635
|
getActiveColElem(): HTMLSpanElement;
|
|
1224
1636
|
/**
|
|
1225
1637
|
* Return the currently active node or null.
|
|
1226
1638
|
*/
|
|
1227
1639
|
getActiveNode(): WunderbaumNode;
|
|
1228
|
-
/**
|
|
1229
|
-
*
|
|
1640
|
+
/**
|
|
1641
|
+
* Return the first top level node if any (not the invisible root node).
|
|
1230
1642
|
*/
|
|
1231
1643
|
getFirstChild(): WunderbaumNode;
|
|
1232
1644
|
/**
|
|
1233
1645
|
* Return the currently active node or null.
|
|
1234
1646
|
*/
|
|
1235
1647
|
getFocusNode(): WunderbaumNode;
|
|
1236
|
-
/** Return a {node:
|
|
1648
|
+
/** Return a {node: WunderbaumNode, region: TYPE} object for a mouse event.
|
|
1237
1649
|
*
|
|
1238
1650
|
* @param {Event} event Mouse event, e.g. click, ...
|
|
1239
|
-
* @returns {object} Return a {node:
|
|
1651
|
+
* @returns {object} Return a {node: WunderbaumNode, region: TYPE} object
|
|
1240
1652
|
* TYPE: 'title' | 'prefix' | 'expander' | 'checkbox' | 'icon' | undefined
|
|
1241
1653
|
*/
|
|
1242
1654
|
static getEventInfo(event: Event): {
|
|
1655
|
+
tree: Wunderbaum;
|
|
1243
1656
|
node: WunderbaumNode;
|
|
1244
1657
|
region: NodeRegion;
|
|
1245
1658
|
colDef: any;
|
|
1246
1659
|
colIdx: number;
|
|
1247
1660
|
colId: any;
|
|
1248
|
-
colElem:
|
|
1661
|
+
colElem: HTMLSpanElement;
|
|
1249
1662
|
};
|
|
1250
1663
|
/**
|
|
1251
1664
|
* Return readable string representation for this instance.
|
|
@@ -1254,15 +1667,19 @@ declare module "wunderbaum" {
|
|
|
1254
1667
|
toString(): string;
|
|
1255
1668
|
/** Return true if any node is currently in edit-title mode. */
|
|
1256
1669
|
isEditing(): boolean;
|
|
1257
|
-
/**
|
|
1670
|
+
/**
|
|
1671
|
+
* Return true if any node is currently beeing loaded, i.e. a Ajax request is pending.
|
|
1258
1672
|
*/
|
|
1259
1673
|
isLoading(): boolean;
|
|
1260
|
-
/** Alias for
|
|
1674
|
+
/** Alias for {@link Wunderbaum.logDebug}.
|
|
1675
|
+
* @alias Wunderbaum.logDebug
|
|
1676
|
+
*/
|
|
1261
1677
|
log: (...args: any[]) => void;
|
|
1262
1678
|
/** Log to console if opts.debugLevel >= 4 */
|
|
1263
1679
|
logDebug(...args: any[]): void;
|
|
1264
1680
|
/** Log error to console. */
|
|
1265
1681
|
logError(...args: any[]): void;
|
|
1682
|
+
/** Log to console if opts.debugLevel >= 3 */
|
|
1266
1683
|
logInfo(...args: any[]): void;
|
|
1267
1684
|
/** @internal */
|
|
1268
1685
|
logTime(label: string): string;
|
|
@@ -1270,41 +1687,69 @@ declare module "wunderbaum" {
|
|
|
1270
1687
|
logTimeEnd(label: string): void;
|
|
1271
1688
|
/** Log to console if opts.debugLevel >= 2 */
|
|
1272
1689
|
logWarn(...args: any[]): void;
|
|
1273
|
-
/** */
|
|
1274
|
-
protected render(opts?: any): boolean;
|
|
1275
|
-
/**Recalc and apply header columns from `this.columns`. */
|
|
1276
|
-
renderHeader(): void;
|
|
1277
1690
|
/**
|
|
1691
|
+
* Make sure that this node is scrolled into the viewport.
|
|
1278
1692
|
*
|
|
1279
1693
|
* @param {boolean | PlainObject} [effects=false] animation options.
|
|
1280
1694
|
* @param {object} [options=null] {topNode: null, effects: ..., parent: ...}
|
|
1281
1695
|
* this node will remain visible in
|
|
1282
1696
|
* any case, even if `this` is outside the scroll pane.
|
|
1283
|
-
* Make sure that a node is scrolled into the viewport.
|
|
1284
1697
|
*/
|
|
1285
1698
|
scrollTo(opts: any): void;
|
|
1286
|
-
/**
|
|
1287
|
-
|
|
1288
|
-
|
|
1699
|
+
/**
|
|
1700
|
+
* Set column #colIdx to 'active'.
|
|
1701
|
+
*
|
|
1702
|
+
* This higlights the column header and -cells by adding the `wb-active` class.
|
|
1703
|
+
* Available in cell-nav and cell-edit mode, not in row-mode.
|
|
1704
|
+
*/
|
|
1289
1705
|
setColumn(colIdx: number): void;
|
|
1290
|
-
/** */
|
|
1706
|
+
/** Set or remove keybaord focus to the tree container. */
|
|
1291
1707
|
setFocus(flag?: boolean): void;
|
|
1292
|
-
/** */
|
|
1708
|
+
/** Schedule an update request to reflect a tree change. */
|
|
1293
1709
|
setModified(change: ChangeType, options?: any): void;
|
|
1710
|
+
/** Schedule an update request to reflect a single node modification. */
|
|
1711
|
+
setModified(change: ChangeType, node: WunderbaumNode, options?: any): void;
|
|
1712
|
+
/** Set the tree's navigation mode. */
|
|
1713
|
+
setNavigationMode(mode: NavigationMode): void;
|
|
1714
|
+
/** Display tree status (ok, loading, error, noData) using styles and a dummy root node. */
|
|
1294
1715
|
setStatus(status: NodeStatusType, message?: string, details?: string): WunderbaumNode | null;
|
|
1295
1716
|
/** Update column headers and width. */
|
|
1296
|
-
updateColumns(opts
|
|
1297
|
-
/**
|
|
1717
|
+
updateColumns(opts?: any): void;
|
|
1718
|
+
/** Create/update header markup from `this.columns` definition.
|
|
1719
|
+
* @internal
|
|
1720
|
+
*/
|
|
1721
|
+
protected _renderHeaderMarkup(): void;
|
|
1722
|
+
/** Render header and all rows that are visible in the viewport (async, throttled). */
|
|
1298
1723
|
updateViewport(immediate?: boolean): void;
|
|
1724
|
+
/**
|
|
1725
|
+
* This is the actual update method, which is wrapped inside a throttle method.
|
|
1726
|
+
* This protected method should not be called directly but via
|
|
1727
|
+
* `tree.updateViewport()` or `tree.setModified()`.
|
|
1728
|
+
* It calls `updateColumns()` and `_updateRows()`.
|
|
1729
|
+
* @internal
|
|
1730
|
+
*/
|
|
1299
1731
|
protected _updateViewport(): void;
|
|
1300
|
-
/**
|
|
1732
|
+
/**
|
|
1733
|
+
* Assert that TR order matches the natural node order
|
|
1734
|
+
* @internal
|
|
1735
|
+
*/
|
|
1736
|
+
protected _validateRows(): boolean;
|
|
1737
|
+
protected _updateRows(opts?: any): boolean;
|
|
1738
|
+
/**
|
|
1739
|
+
* Call callback(node) for all nodes in hierarchical order (depth-first).
|
|
1301
1740
|
*
|
|
1302
1741
|
* @param {function} callback the callback function.
|
|
1303
|
-
* Return false to stop iteration, return "skip" to skip this node and
|
|
1742
|
+
* Return false to stop iteration, return "skip" to skip this node and
|
|
1743
|
+
* children only.
|
|
1304
1744
|
* @returns {boolean} false, if the iterator was stopped.
|
|
1305
1745
|
*/
|
|
1306
1746
|
visit(callback: (node: WunderbaumNode) => any): import("common").NodeVisitResponse;
|
|
1307
|
-
/**
|
|
1747
|
+
/**
|
|
1748
|
+
* Call fn(node) for all nodes in vertical order, top down (or bottom up).
|
|
1749
|
+
*
|
|
1750
|
+
* Note that this considers expansion state, i.e. children of collapsed nodes
|
|
1751
|
+
* are skipped.
|
|
1752
|
+
*
|
|
1308
1753
|
* Stop iteration, if fn() returns false.<br>
|
|
1309
1754
|
* Return false if iteration was stopped.
|
|
1310
1755
|
*
|
|
@@ -1316,14 +1761,32 @@ declare module "wunderbaum" {
|
|
|
1316
1761
|
* @returns {boolean} false if iteration was canceled
|
|
1317
1762
|
*/
|
|
1318
1763
|
visitRows(callback: (node: WunderbaumNode) => any, opts?: any): boolean;
|
|
1319
|
-
/**
|
|
1764
|
+
/**
|
|
1765
|
+
* Call fn(node) for all nodes in vertical order, bottom up.
|
|
1320
1766
|
* @internal
|
|
1321
1767
|
*/
|
|
1322
1768
|
protected _visitRowsUp(callback: (node: WunderbaumNode) => any, opts: any): boolean;
|
|
1323
|
-
/**
|
|
1769
|
+
/**
|
|
1770
|
+
* Reload the tree with a new source.
|
|
1771
|
+
*
|
|
1772
|
+
* Previous data is cleared.
|
|
1773
|
+
* Pass `options.columns` to define a header (may also be part of `source.columns`).
|
|
1774
|
+
*/
|
|
1324
1775
|
load(source: any, options?: any): Promise<void>;
|
|
1325
1776
|
/**
|
|
1777
|
+
* Disable render requests during operations that would trigger many updates.
|
|
1326
1778
|
*
|
|
1779
|
+
* ```js
|
|
1780
|
+
* try {
|
|
1781
|
+
* tree.enableUpdate(false);
|
|
1782
|
+
* // ... (long running operation that would trigger many updates)
|
|
1783
|
+
* foo();
|
|
1784
|
+
* // ... NOTE: make sure that async operations have finished
|
|
1785
|
+
* await foo();
|
|
1786
|
+
* } finally {
|
|
1787
|
+
* tree.enableUpdate(true);
|
|
1788
|
+
* }
|
|
1789
|
+
* ```
|
|
1327
1790
|
*/
|
|
1328
1791
|
enableUpdate(flag: boolean): void;
|
|
1329
1792
|
/**
|