wunderbaum 0.0.1 → 0.0.2
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 +3 -2
- package/dist/wunderbaum.css +1 -1
- package/dist/wunderbaum.d.ts +400 -80
- package/dist/wunderbaum.esm.js +356 -135
- package/dist/wunderbaum.esm.min.js +28 -18
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +358 -137
- package/dist/wunderbaum.umd.min.js +34 -24
- package/dist/wunderbaum.umd.min.js.map +1 -1
- package/package.json +29 -30
- package/src/common.ts +6 -5
- package/src/drag_observer.ts +169 -0
- package/src/util.ts +47 -13
- package/src/wb_ext_dnd.ts +144 -3
- package/src/wb_ext_filter.ts +35 -35
- package/src/wb_ext_grid.ts +45 -0
- package/src/wb_node.ts +23 -29
- package/src/wb_options.ts +138 -25
- package/src/wunderbaum.scss +20 -1
- package/src/wunderbaum.ts +82 -37
package/dist/wunderbaum.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare module "util" {
|
|
|
9
9
|
[key: number]: string;
|
|
10
10
|
};
|
|
11
11
|
export const MAX_INT = 9007199254740991;
|
|
12
|
-
/**True if the
|
|
12
|
+
/**True if the client is using a macOS platform. */
|
|
13
13
|
export const isMac: boolean;
|
|
14
14
|
export type FunctionType = (...args: any[]) => any;
|
|
15
15
|
export type EventCallbackType = (e: Event) => boolean | void;
|
|
@@ -94,32 +94,45 @@ declare module "util" {
|
|
|
94
94
|
* @param value a value that matches the target element.
|
|
95
95
|
*/
|
|
96
96
|
export function setValueToElem(elem: HTMLElement, value: any): void;
|
|
97
|
-
/**
|
|
97
|
+
/** Create and return an unconnected `HTMLElement` from a HTML string. */
|
|
98
98
|
export function elemFromHtml(html: string): HTMLElement;
|
|
99
99
|
/** Return a HtmlElement from selector or cast an existing element. */
|
|
100
100
|
export function elemFromSelector(obj: string | Element): HTMLElement | null;
|
|
101
|
+
/** Return a EventTarget from selector or cast an existing element. */
|
|
102
|
+
export function eventTargetFromSelector(obj: string | EventTarget): EventTarget | null;
|
|
101
103
|
/**
|
|
102
|
-
* Return a descriptive string for a keyboard or mouse event.
|
|
104
|
+
* Return a canonical descriptive string for a keyboard or mouse event.
|
|
103
105
|
*
|
|
104
106
|
* The result also contains a prefix for modifiers if any, for example
|
|
105
107
|
* `"x"`, `"F2"`, `"Control+Home"`, or `"Shift+clickright"`.
|
|
108
|
+
* This is especially useful in `switch` statements, to make sure that modifier
|
|
109
|
+
* keys are considered and handled correctly.
|
|
106
110
|
*/
|
|
107
111
|
export function eventToString(event: Event): string;
|
|
112
|
+
/**
|
|
113
|
+
* Copy allproperties from one or more source objects to a target object.
|
|
114
|
+
*
|
|
115
|
+
* @returns the modified target object.
|
|
116
|
+
*/
|
|
108
117
|
export function extend(...args: any[]): any;
|
|
118
|
+
/** Return true if `obj` is of type `array`. */
|
|
109
119
|
export function isArray(obj: any): boolean;
|
|
120
|
+
/** Return true if `obj` is of type `Object` and has no propertied. */
|
|
110
121
|
export function isEmptyObject(obj: any): boolean;
|
|
122
|
+
/** Return true if `obj` is of type `function`. */
|
|
111
123
|
export function isFunction(obj: any): boolean;
|
|
124
|
+
/** Return true if `obj` is of type `Object`. */
|
|
112
125
|
export function isPlainObject(obj: any): boolean;
|
|
113
126
|
/** A dummy function that does nothing ('no operation'). */
|
|
114
127
|
export function noop(...args: any[]): any;
|
|
115
128
|
/**
|
|
116
|
-
* Bind one or more event handlers directly to an [[
|
|
129
|
+
* Bind one or more event handlers directly to an [[EventTarget]].
|
|
117
130
|
*
|
|
118
|
-
* @param element
|
|
131
|
+
* @param element EventTarget or selector
|
|
119
132
|
* @param eventNames
|
|
120
133
|
* @param handler
|
|
121
134
|
*/
|
|
122
|
-
export function onEvent(
|
|
135
|
+
export function onEvent(rootTarget: EventTarget | string, eventNames: string, handler: EventCallbackType): void;
|
|
123
136
|
/**
|
|
124
137
|
* Bind one or more event handlers using event delegation.
|
|
125
138
|
*
|
|
@@ -131,12 +144,12 @@ declare module "util" {
|
|
|
131
144
|
* });
|
|
132
145
|
* ```
|
|
133
146
|
*
|
|
134
|
-
* @param element
|
|
147
|
+
* @param element EventTarget or selector
|
|
135
148
|
* @param eventNames
|
|
136
149
|
* @param selector
|
|
137
150
|
* @param handler
|
|
138
151
|
*/
|
|
139
|
-
export function onEvent(
|
|
152
|
+
export function onEvent(rootTarget: EventTarget | string, eventNames: string, selector: string, handler: EventCallbackType): void;
|
|
140
153
|
/** Return a wrapped handler method, that provides `this._super`.
|
|
141
154
|
*
|
|
142
155
|
* ```ts
|
|
@@ -165,6 +178,13 @@ declare module "util" {
|
|
|
165
178
|
export function sleep(ms: number): Promise<unknown>;
|
|
166
179
|
/**
|
|
167
180
|
* Set or rotate checkbox status with support for tri-state.
|
|
181
|
+
*
|
|
182
|
+
* An initial 'indeterminate' state becomes 'checked' on the first call.
|
|
183
|
+
*
|
|
184
|
+
* If the input element has the class 'wb-tristate' assigned, the sequence is:<br>
|
|
185
|
+
* 'indeterminate' -> 'checked' -> 'unchecked' -> 'indeterminate' -> ...<br>
|
|
186
|
+
* Otherwise we toggle like <br>
|
|
187
|
+
* 'checked' -> 'unchecked' -> 'checked' -> ...
|
|
168
188
|
*/
|
|
169
189
|
export function toggleCheckbox(element: HTMLElement | string, value?: boolean | null, tristate?: boolean): void;
|
|
170
190
|
/**
|
|
@@ -177,6 +197,7 @@ declare module "util" {
|
|
|
177
197
|
export function getOption(opts: any, name: string, defaultValue?: any): any;
|
|
178
198
|
/** Convert an Array or space-separated string to a Set. */
|
|
179
199
|
export function toSet(val: any): Set<string>;
|
|
200
|
+
/**Return a canonical string representation for an object's type (e.g. 'array', 'number', ...) */
|
|
180
201
|
export function type(obj: any): string;
|
|
181
202
|
}
|
|
182
203
|
declare module "deferred" {
|
|
@@ -211,20 +232,181 @@ declare module "deferred" {
|
|
|
211
232
|
finally(cb: finallyCallbackType): Promise<any>;
|
|
212
233
|
}
|
|
213
234
|
}
|
|
235
|
+
declare module "wb_extension_base" {
|
|
236
|
+
import { Wunderbaum } from "wunderbaum";
|
|
237
|
+
export type ExtensionsDict = {
|
|
238
|
+
[key: string]: WunderbaumExtension;
|
|
239
|
+
};
|
|
240
|
+
export abstract class WunderbaumExtension {
|
|
241
|
+
enabled: boolean;
|
|
242
|
+
readonly id: string;
|
|
243
|
+
readonly tree: Wunderbaum;
|
|
244
|
+
readonly treeOpts: any;
|
|
245
|
+
readonly extensionOpts: any;
|
|
246
|
+
constructor(tree: Wunderbaum, id: string, defaults: any);
|
|
247
|
+
/** Called on tree (re)init after all extensions are added, but before loading.*/
|
|
248
|
+
init(): void;
|
|
249
|
+
getPluginOption(name: string, defaultValue?: any): any;
|
|
250
|
+
setPluginOption(name: string, value: any): void;
|
|
251
|
+
setEnabled(flag?: boolean): void;
|
|
252
|
+
onKeyEvent(data: any): boolean | undefined;
|
|
253
|
+
onRender(data: any): boolean | undefined;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
declare module "wb_ext_dnd" {
|
|
257
|
+
import { Wunderbaum } from "wunderbaum";
|
|
258
|
+
import { WunderbaumExtension } from "wb_extension_base";
|
|
259
|
+
import { WunderbaumNode } from "wb_node";
|
|
260
|
+
import { WbNodeEventType } from "common";
|
|
261
|
+
export type DropRegionType = "over" | "before" | "after";
|
|
262
|
+
type DropRegionTypeSet = Set<DropRegionType>;
|
|
263
|
+
export type DndOptionsType = {
|
|
264
|
+
/**
|
|
265
|
+
* Expand nodes after n milliseconds of hovering
|
|
266
|
+
* Default: 1500
|
|
267
|
+
*/
|
|
268
|
+
autoExpandMS: 1500;
|
|
269
|
+
/**
|
|
270
|
+
* true: Drag multiple (i.e. selected) nodes. Also a callback() is allowed
|
|
271
|
+
* Default: false
|
|
272
|
+
*/
|
|
273
|
+
multiSource: false;
|
|
274
|
+
/**
|
|
275
|
+
* Restrict the possible cursor shapes and modifier operations (can also be set in the dragStart event)
|
|
276
|
+
* Default: "all"
|
|
277
|
+
*/
|
|
278
|
+
effectAllowed: "all";
|
|
279
|
+
/**
|
|
280
|
+
* Default dropEffect ('copy', 'link', or 'move') when no modifier is pressed (overide in dragDrag, dragOver).
|
|
281
|
+
* Default: "move"
|
|
282
|
+
*/
|
|
283
|
+
dropEffectDefault: string;
|
|
284
|
+
/**
|
|
285
|
+
* Prevent dropping nodes from different Wunderbaum trees
|
|
286
|
+
* Default: false
|
|
287
|
+
*/
|
|
288
|
+
preventForeignNodes: boolean;
|
|
289
|
+
/**
|
|
290
|
+
* Prevent dropping items on unloaded lazy Wunderbaum tree nodes
|
|
291
|
+
* Default: true
|
|
292
|
+
*/
|
|
293
|
+
preventLazyParents: boolean;
|
|
294
|
+
/**
|
|
295
|
+
* Prevent dropping items other than Wunderbaum tree nodes
|
|
296
|
+
* Default: false
|
|
297
|
+
*/
|
|
298
|
+
preventNonNodes: boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Prevent dropping nodes on own descendants
|
|
301
|
+
* Default: true
|
|
302
|
+
*/
|
|
303
|
+
preventRecursion: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Prevent dropping nodes under same direct parent
|
|
306
|
+
* Default: false
|
|
307
|
+
*/
|
|
308
|
+
preventSameParent: false;
|
|
309
|
+
/**
|
|
310
|
+
* Prevent dropping nodes 'before self', etc. (move only)
|
|
311
|
+
* Default: true
|
|
312
|
+
*/
|
|
313
|
+
preventVoidMoves: boolean;
|
|
314
|
+
/**
|
|
315
|
+
* Enable auto-scrolling while dragging
|
|
316
|
+
* Default: true
|
|
317
|
+
*/
|
|
318
|
+
scroll: boolean;
|
|
319
|
+
/**
|
|
320
|
+
* Active top/bottom margin in pixel
|
|
321
|
+
* Default: 20
|
|
322
|
+
*/
|
|
323
|
+
scrollSensitivity: 20;
|
|
324
|
+
/**
|
|
325
|
+
* Pixel per event
|
|
326
|
+
* Default: 5
|
|
327
|
+
*/
|
|
328
|
+
scrollSpeed: 5;
|
|
329
|
+
/**
|
|
330
|
+
* Optional callback passed to `toDict` on dragStart @since 2.38
|
|
331
|
+
* Default: null
|
|
332
|
+
*/
|
|
333
|
+
sourceCopyHook: null;
|
|
334
|
+
/**
|
|
335
|
+
* Callback(sourceNode, data), return true, to enable dnd drag
|
|
336
|
+
* Default: null
|
|
337
|
+
*/
|
|
338
|
+
dragStart?: WbNodeEventType;
|
|
339
|
+
/**
|
|
340
|
+
* Callback(sourceNode, data)
|
|
341
|
+
* Default: null
|
|
342
|
+
*/
|
|
343
|
+
dragDrag: null;
|
|
344
|
+
/**
|
|
345
|
+
* Callback(sourceNode, data)
|
|
346
|
+
* Default: null
|
|
347
|
+
*/
|
|
348
|
+
dragEnd: null;
|
|
349
|
+
/**
|
|
350
|
+
* Callback(targetNode, data), return true, to enable dnd drop
|
|
351
|
+
* Default: null
|
|
352
|
+
*/
|
|
353
|
+
dragEnter: null;
|
|
354
|
+
/**
|
|
355
|
+
* Callback(targetNode, data)
|
|
356
|
+
* Default: null
|
|
357
|
+
*/
|
|
358
|
+
dragOver: null;
|
|
359
|
+
/**
|
|
360
|
+
* Callback(targetNode, data), return false to prevent autoExpand
|
|
361
|
+
* Default: null
|
|
362
|
+
*/
|
|
363
|
+
dragExpand: null;
|
|
364
|
+
/**
|
|
365
|
+
* Callback(targetNode, data)
|
|
366
|
+
* Default: null
|
|
367
|
+
*/
|
|
368
|
+
dragDrop: null;
|
|
369
|
+
/**
|
|
370
|
+
* Callback(targetNode, data)
|
|
371
|
+
* Default: null
|
|
372
|
+
*/
|
|
373
|
+
dragLeave: null;
|
|
374
|
+
};
|
|
375
|
+
export class DndExtension extends WunderbaumExtension {
|
|
376
|
+
protected srcNode: WunderbaumNode | null;
|
|
377
|
+
protected lastTargetNode: WunderbaumNode | null;
|
|
378
|
+
protected lastEnterStamp: number;
|
|
379
|
+
protected lastAllowedDropRegions: DropRegionTypeSet | null;
|
|
380
|
+
protected lastDropEffect: string | null;
|
|
381
|
+
protected lastDropRegion: DropRegionType | false;
|
|
382
|
+
constructor(tree: Wunderbaum);
|
|
383
|
+
init(): void;
|
|
384
|
+
/** Cleanup classes after target node is no longer hovered. */
|
|
385
|
+
protected _leaveNode(): void;
|
|
386
|
+
/** */
|
|
387
|
+
protected unifyDragover(res: any): DropRegionTypeSet | false;
|
|
388
|
+
/** */
|
|
389
|
+
protected _calcDropRegion(e: DragEvent, allowed: DropRegionTypeSet | null): DropRegionType | false;
|
|
390
|
+
protected autoScroll(event: DragEvent): number;
|
|
391
|
+
protected onDragEvent(e: DragEvent): boolean;
|
|
392
|
+
protected onDropEvent(e: DragEvent): boolean;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
214
395
|
declare module "wb_options" {
|
|
215
396
|
/*!
|
|
216
397
|
* Wunderbaum - utils
|
|
217
398
|
* Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
|
|
218
399
|
* @VERSION, @DATE (https://github.com/mar10/wunderbaum)
|
|
219
400
|
*/
|
|
220
|
-
import { BoolOptionResolver, NavigationModeOption,
|
|
401
|
+
import { BoolOptionResolver, NavigationModeOption, WbNodeEventType, WbTreeEventType } from "common";
|
|
402
|
+
import { DndOptionsType } from "wb_ext_dnd";
|
|
221
403
|
export interface WbNodeData {
|
|
222
404
|
title: string;
|
|
223
405
|
key?: string;
|
|
224
406
|
refKey?: string;
|
|
225
407
|
expanded?: boolean;
|
|
226
408
|
selected?: boolean;
|
|
227
|
-
checkbox?: boolean |
|
|
409
|
+
checkbox?: boolean | string;
|
|
228
410
|
children?: Array<WbNodeData>;
|
|
229
411
|
}
|
|
230
412
|
/**
|
|
@@ -268,56 +450,164 @@ declare module "wb_options" {
|
|
|
268
450
|
*
|
|
269
451
|
* Default: `{}`.
|
|
270
452
|
*/
|
|
271
|
-
types
|
|
453
|
+
types?: any;
|
|
272
454
|
/**
|
|
273
455
|
* A list of maps that define column headers. If this option is set,
|
|
274
|
-
* Wunderbaum becomes a
|
|
456
|
+
* Wunderbaum becomes a treegrid control instead of a plain tree.
|
|
275
457
|
* Column definitions can be passed as tree option, or be part of a `source`
|
|
276
458
|
* response.
|
|
277
459
|
* Default: `[]` meaning this is a plain tree.
|
|
278
460
|
*/
|
|
279
461
|
columns?: Array<any>;
|
|
280
462
|
/**
|
|
281
|
-
*
|
|
463
|
+
* If true, add a `wb-skeleton` class to all nodes, that will result in a
|
|
464
|
+
* 'glow' effect. Typically used with initial dummy nodes, while loading the
|
|
465
|
+
* real data.
|
|
282
466
|
* Default: false.
|
|
283
467
|
*/
|
|
284
|
-
skeleton
|
|
468
|
+
skeleton?: false;
|
|
285
469
|
/**
|
|
286
|
-
*
|
|
287
|
-
* Default: false.
|
|
470
|
+
* Translation map for some system messages.
|
|
288
471
|
*/
|
|
289
|
-
strings
|
|
472
|
+
strings?: any;
|
|
290
473
|
/**
|
|
474
|
+
* 0:quiet, 1:errors, 2:warnings, 3:info, 4:verbose
|
|
475
|
+
* Default: 3 (4 in local debug environment)
|
|
291
476
|
*/
|
|
292
|
-
debugLevel:
|
|
293
|
-
minExpandLevel: 0;
|
|
294
|
-
escapeTitles: true;
|
|
295
|
-
headerHeightPx: 22;
|
|
296
|
-
autoCollapse: false;
|
|
297
|
-
dnd: any;
|
|
298
|
-
filter: any;
|
|
477
|
+
debugLevel: number;
|
|
299
478
|
/**
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
|
|
303
|
-
|
|
479
|
+
* Number of levels that are forced to be expanded, and have no expander icon.
|
|
480
|
+
* Default: 0
|
|
481
|
+
*/
|
|
482
|
+
minExpandLevel?: number;
|
|
483
|
+
/**
|
|
484
|
+
* Height of the header row div.
|
|
485
|
+
* Default: 22
|
|
486
|
+
*/
|
|
487
|
+
headerHeightPx: number;
|
|
488
|
+
/**
|
|
489
|
+
* Height of a node row div.
|
|
490
|
+
* Default: 22
|
|
491
|
+
*/
|
|
492
|
+
rowHeightPx?: number;
|
|
493
|
+
/**
|
|
494
|
+
* Collapse siblings when a node is expanded.
|
|
495
|
+
* Default: false
|
|
496
|
+
*/
|
|
497
|
+
autoCollapse?: boolean;
|
|
498
|
+
/**
|
|
499
|
+
* Default: NavigationModeOption.startRow
|
|
304
500
|
*/
|
|
305
501
|
navigationMode?: NavigationModeOption;
|
|
502
|
+
/**
|
|
503
|
+
* Show/hide header (pass bool or string)
|
|
504
|
+
*/
|
|
505
|
+
header?: boolean | string | null;
|
|
506
|
+
/**
|
|
507
|
+
*
|
|
508
|
+
*/
|
|
509
|
+
showSpinner?: boolean;
|
|
510
|
+
/**
|
|
511
|
+
* Default: true
|
|
512
|
+
*/
|
|
513
|
+
checkbox?: boolean | "radio" | BoolOptionResolver;
|
|
514
|
+
/**
|
|
515
|
+
* Default: 200
|
|
516
|
+
*/
|
|
517
|
+
updateThrottleWait?: number;
|
|
518
|
+
/**
|
|
519
|
+
* Default: true
|
|
520
|
+
*/
|
|
521
|
+
quicksearch?: boolean;
|
|
522
|
+
dnd?: DndOptionsType;
|
|
523
|
+
filter: any;
|
|
524
|
+
grid: any;
|
|
306
525
|
/**
|
|
307
526
|
* Called after initial data was loaded and tree markup was rendered.
|
|
527
|
+
* Check `e.error` for status.
|
|
308
528
|
* @category Callback
|
|
309
529
|
*/
|
|
310
|
-
init?: (e:
|
|
530
|
+
init?: (e: WbTreeEventType) => void;
|
|
311
531
|
/**
|
|
312
|
-
*
|
|
532
|
+
*
|
|
533
|
+
* @category Callback
|
|
534
|
+
*/
|
|
535
|
+
update?: (e: WbTreeEventType) => void;
|
|
536
|
+
/**
|
|
537
|
+
*
|
|
538
|
+
* @category Callback
|
|
539
|
+
*/
|
|
540
|
+
activate?: (e: WbNodeEventType) => void;
|
|
541
|
+
/**
|
|
542
|
+
*
|
|
543
|
+
* @category Callback
|
|
544
|
+
*/
|
|
545
|
+
deactivate?: (e: WbNodeEventType) => void;
|
|
546
|
+
/**
|
|
547
|
+
*
|
|
548
|
+
* @category Callback
|
|
549
|
+
*/
|
|
550
|
+
change?: (e: WbNodeEventType) => void;
|
|
551
|
+
/**
|
|
552
|
+
*
|
|
553
|
+
* @category Callback
|
|
554
|
+
*/
|
|
555
|
+
click?: (e: WbTreeEventType) => void;
|
|
556
|
+
/**
|
|
557
|
+
*
|
|
313
558
|
* @category Callback
|
|
314
559
|
*/
|
|
315
|
-
|
|
560
|
+
discard?: (e: WbNodeEventType) => void;
|
|
561
|
+
/**
|
|
562
|
+
*
|
|
563
|
+
* @category Callback
|
|
564
|
+
*/
|
|
565
|
+
error?: (e: WbTreeEventType) => void;
|
|
566
|
+
/**
|
|
567
|
+
*
|
|
568
|
+
* @category Callback
|
|
569
|
+
*/
|
|
570
|
+
enhanceTitle?: (e: WbNodeEventType) => void;
|
|
571
|
+
/**
|
|
572
|
+
*
|
|
573
|
+
* Check `e.flag` for status.
|
|
574
|
+
* @category Callback
|
|
575
|
+
*/
|
|
576
|
+
focus?: (e: WbTreeEventType) => void;
|
|
577
|
+
/**
|
|
578
|
+
*
|
|
579
|
+
* @category Callback
|
|
580
|
+
*/
|
|
581
|
+
keydown?: (e: WbNodeEventType) => void;
|
|
316
582
|
/**
|
|
317
583
|
* Called after data was loaded from local storage.
|
|
584
|
+
*/
|
|
585
|
+
load?: (e: WbNodeEventType) => void;
|
|
586
|
+
/**
|
|
587
|
+
* @category Callback
|
|
588
|
+
*/
|
|
589
|
+
modifyChild?: (e: WbNodeEventType) => void;
|
|
590
|
+
/**
|
|
591
|
+
*
|
|
318
592
|
* @category Callback
|
|
319
593
|
*/
|
|
320
|
-
|
|
594
|
+
receive?: (e: WbNodeEventType) => void;
|
|
595
|
+
/**
|
|
596
|
+
*
|
|
597
|
+
* @category Callback
|
|
598
|
+
*/
|
|
599
|
+
render?: (e: WbNodeEventType) => void;
|
|
600
|
+
/**
|
|
601
|
+
*
|
|
602
|
+
* @category Callback
|
|
603
|
+
*/
|
|
604
|
+
renderStatusNode?: (e: WbNodeEventType) => void;
|
|
605
|
+
/**
|
|
606
|
+
*
|
|
607
|
+
* Check `e.flag` for status.
|
|
608
|
+
* @category Callback
|
|
609
|
+
*/
|
|
610
|
+
select?: (e: WbNodeEventType) => void;
|
|
321
611
|
}
|
|
322
612
|
}
|
|
323
613
|
declare module "wb_node" {
|
|
@@ -598,7 +888,7 @@ declare module "wb_node" {
|
|
|
598
888
|
getOption(name: string, defaultValue?: any): any;
|
|
599
889
|
scrollIntoView(options?: any): Promise<void>;
|
|
600
890
|
setActive(flag?: boolean, options?: any): Promise<void>;
|
|
601
|
-
|
|
891
|
+
setModified(change?: ChangeType): void;
|
|
602
892
|
setExpanded(flag?: boolean, options?: any): Promise<void>;
|
|
603
893
|
setIcon(): void;
|
|
604
894
|
setFocus(flag?: boolean, options?: any): void;
|
|
@@ -663,16 +953,16 @@ declare module "common" {
|
|
|
663
953
|
export type NodeAnyCallback = (node: WunderbaumNode) => any;
|
|
664
954
|
export type NodeVisitResponse = "skip" | boolean | void;
|
|
665
955
|
export type NodeVisitCallback = (node: WunderbaumNode) => NodeVisitResponse;
|
|
666
|
-
export type
|
|
956
|
+
export type WbTreeEventType = {
|
|
667
957
|
name: string;
|
|
668
958
|
event: Event;
|
|
669
959
|
tree: Wunderbaum;
|
|
670
960
|
[key: string]: unknown;
|
|
671
961
|
};
|
|
672
|
-
export type WbNodeEventType =
|
|
962
|
+
export type WbNodeEventType = WbTreeEventType & {
|
|
673
963
|
node: WunderbaumNode;
|
|
674
964
|
};
|
|
675
|
-
export type
|
|
965
|
+
export type WbTreeCallbackType = (e: WbTreeEventType) => any;
|
|
676
966
|
export type WbNodeCallbackType = (e: WbNodeEventType) => any;
|
|
677
967
|
export type FilterModeType = null | "dim" | "hide";
|
|
678
968
|
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 +974,9 @@ declare module "common" {
|
|
|
684
974
|
any = "any",
|
|
685
975
|
row = "row",
|
|
686
976
|
structure = "structure",
|
|
687
|
-
status = "status"
|
|
977
|
+
status = "status",
|
|
978
|
+
vscroll = "vscroll",
|
|
979
|
+
header = "header"
|
|
688
980
|
}
|
|
689
981
|
export enum NodeStatusType {
|
|
690
982
|
ok = "ok",
|
|
@@ -753,27 +1045,6 @@ declare module "common" {
|
|
|
753
1045
|
/** */
|
|
754
1046
|
export function makeNodeTitleStartMatcher(s: string): MatcherType;
|
|
755
1047
|
}
|
|
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
1048
|
declare module "debounce" {
|
|
778
1049
|
/*!
|
|
779
1050
|
* debounce & throttle, taken from https://github.com/lodash/lodash v4.17.21
|
|
@@ -960,30 +1231,75 @@ declare module "wb_ext_logger" {
|
|
|
960
1231
|
onKeyEvent(data: any): boolean | undefined;
|
|
961
1232
|
}
|
|
962
1233
|
}
|
|
963
|
-
declare module "
|
|
1234
|
+
declare module "drag_observer" {
|
|
1235
|
+
export type DragCallbackArgType = {
|
|
1236
|
+
/** "dragstart", "drag", or "dragstop". */
|
|
1237
|
+
type: string;
|
|
1238
|
+
/** Original mouse or touch event that triggered the drag event. */
|
|
1239
|
+
event: MouseEvent | TouchEvent;
|
|
1240
|
+
/** Element which is currently dragged. */
|
|
1241
|
+
dragElem: HTMLElement | null;
|
|
1242
|
+
/** Relative horizontal drag distance since start. */
|
|
1243
|
+
dx: number;
|
|
1244
|
+
/** Relative vertical drag distance since start. */
|
|
1245
|
+
dy: number;
|
|
1246
|
+
/** False if drag was canceled. */
|
|
1247
|
+
apply?: boolean;
|
|
1248
|
+
};
|
|
1249
|
+
export type DragCallbackType = (e: DragCallbackArgType) => boolean | void;
|
|
1250
|
+
type DragObserverOptionsType = {
|
|
1251
|
+
/**Event target (typically `window.document`). */
|
|
1252
|
+
root: EventTarget;
|
|
1253
|
+
/**Event delegation selector.*/
|
|
1254
|
+
selector?: string;
|
|
1255
|
+
/**Minimum drag distance in px. */
|
|
1256
|
+
thresh?: number;
|
|
1257
|
+
/**Return `false` to cancel drag. */
|
|
1258
|
+
dragstart: DragCallbackType;
|
|
1259
|
+
drag?: DragCallbackType;
|
|
1260
|
+
dragstop?: DragCallbackType;
|
|
1261
|
+
};
|
|
1262
|
+
/**
|
|
1263
|
+
* Convert mouse- and touch events to 'dragstart', 'drag', and 'dragstop'.
|
|
1264
|
+
*/
|
|
1265
|
+
export class DragObserver {
|
|
1266
|
+
protected _handler: any;
|
|
1267
|
+
protected root: EventTarget;
|
|
1268
|
+
protected start: {
|
|
1269
|
+
x: number;
|
|
1270
|
+
y: number;
|
|
1271
|
+
altKey: boolean;
|
|
1272
|
+
ctrlKey: boolean;
|
|
1273
|
+
metaKey: boolean;
|
|
1274
|
+
shiftKey: boolean;
|
|
1275
|
+
};
|
|
1276
|
+
protected dragElem: HTMLElement | null;
|
|
1277
|
+
protected dragging: boolean;
|
|
1278
|
+
protected events: string[];
|
|
1279
|
+
protected opts: DragObserverOptionsType;
|
|
1280
|
+
constructor(opts: DragObserverOptionsType);
|
|
1281
|
+
/** Unregister all event listeners. */
|
|
1282
|
+
disconnect(): void;
|
|
1283
|
+
getDragElem(): HTMLElement | null;
|
|
1284
|
+
isDragging(): boolean;
|
|
1285
|
+
stopDrag(cb_event?: DragCallbackArgType): void;
|
|
1286
|
+
protected handleEvent(e: MouseEvent): boolean | void;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
declare module "wb_ext_grid" {
|
|
1290
|
+
/*!
|
|
1291
|
+
* Wunderbaum - ext-grid
|
|
1292
|
+
* Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
|
|
1293
|
+
* @VERSION, @DATE (https://github.com/mar10/wunderbaum)
|
|
1294
|
+
*/
|
|
964
1295
|
import { Wunderbaum } from "wunderbaum";
|
|
965
1296
|
import { WunderbaumExtension } from "wb_extension_base";
|
|
966
|
-
import {
|
|
967
|
-
export
|
|
968
|
-
|
|
969
|
-
export class DndExtension extends WunderbaumExtension {
|
|
970
|
-
protected srcNode: WunderbaumNode | null;
|
|
971
|
-
protected lastTargetNode: WunderbaumNode | null;
|
|
972
|
-
protected lastEnterStamp: number;
|
|
973
|
-
protected lastAllowedDropRegions: DropRegionTypeSet | null;
|
|
974
|
-
protected lastDropEffect: string | null;
|
|
975
|
-
protected lastDropRegion: DropRegionType | false;
|
|
1297
|
+
import { DragCallbackArgType, DragObserver } from "drag_observer";
|
|
1298
|
+
export class GridExtension extends WunderbaumExtension {
|
|
1299
|
+
protected observer: DragObserver;
|
|
976
1300
|
constructor(tree: Wunderbaum);
|
|
977
1301
|
init(): void;
|
|
978
|
-
|
|
979
|
-
protected _leaveNode(): void;
|
|
980
|
-
/** */
|
|
981
|
-
protected unifyDragover(res: any): DropRegionTypeSet | false;
|
|
982
|
-
/** */
|
|
983
|
-
protected _calcDropRegion(e: DragEvent, allowed: DropRegionTypeSet | null): DropRegionType | false;
|
|
984
|
-
protected autoScroll(event: DragEvent): number;
|
|
985
|
-
protected onDragEvent(e: DragEvent): boolean;
|
|
986
|
-
protected onDropEvent(e: DragEvent): boolean;
|
|
1302
|
+
protected handleDrag(e: DragCallbackArgType): void;
|
|
987
1303
|
}
|
|
988
1304
|
}
|
|
989
1305
|
declare module "wb_ext_edit" {
|
|
@@ -1082,6 +1398,7 @@ declare module "wunderbaum" {
|
|
|
1082
1398
|
protected changedSince: number;
|
|
1083
1399
|
protected changes: Set<ChangeType>;
|
|
1084
1400
|
protected changedNodes: Set<WunderbaumNode>;
|
|
1401
|
+
protected changeRedrawPending: boolean;
|
|
1085
1402
|
filterMode: FilterModeType;
|
|
1086
1403
|
activeColIdx: number;
|
|
1087
1404
|
navMode: NavigationMode;
|
|
@@ -1235,12 +1552,13 @@ declare module "wunderbaum" {
|
|
|
1235
1552
|
* TYPE: 'title' | 'prefix' | 'expander' | 'checkbox' | 'icon' | undefined
|
|
1236
1553
|
*/
|
|
1237
1554
|
static getEventInfo(event: Event): {
|
|
1555
|
+
tree: Wunderbaum;
|
|
1238
1556
|
node: WunderbaumNode;
|
|
1239
1557
|
region: NodeRegion;
|
|
1240
1558
|
colDef: any;
|
|
1241
1559
|
colIdx: number;
|
|
1242
1560
|
colId: any;
|
|
1243
|
-
colElem:
|
|
1561
|
+
colElem: HTMLSpanElement;
|
|
1244
1562
|
};
|
|
1245
1563
|
/**
|
|
1246
1564
|
* Return readable string representation for this instance.
|
|
@@ -1270,12 +1588,12 @@ declare module "wunderbaum" {
|
|
|
1270
1588
|
/**Recalc and apply header columns from `this.columns`. */
|
|
1271
1589
|
renderHeader(): void;
|
|
1272
1590
|
/**
|
|
1591
|
+
* Make sure that this node is scrolled into the viewport.
|
|
1273
1592
|
*
|
|
1274
1593
|
* @param {boolean | PlainObject} [effects=false] animation options.
|
|
1275
1594
|
* @param {object} [options=null] {topNode: null, effects: ..., parent: ...}
|
|
1276
1595
|
* this node will remain visible in
|
|
1277
1596
|
* any case, even if `this` is outside the scroll pane.
|
|
1278
|
-
* Make sure that a node is scrolled into the viewport.
|
|
1279
1597
|
*/
|
|
1280
1598
|
scrollTo(opts: any): void;
|
|
1281
1599
|
/** */
|
|
@@ -1286,6 +1604,8 @@ declare module "wunderbaum" {
|
|
|
1286
1604
|
setFocus(flag?: boolean): void;
|
|
1287
1605
|
/** */
|
|
1288
1606
|
setModified(change: ChangeType, options?: any): void;
|
|
1607
|
+
/** */
|
|
1608
|
+
setModified(change: ChangeType, node: WunderbaumNode, options?: any): void;
|
|
1289
1609
|
setStatus(status: NodeStatusType, message?: string, details?: string): WunderbaumNode | null;
|
|
1290
1610
|
/** Update column headers and width. */
|
|
1291
1611
|
updateColumns(opts: any): void;
|