wunderbaum 0.0.2 → 0.0.5
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 -1
- package/dist/wunderbaum.css +1 -1
- package/dist/wunderbaum.d.ts +475 -135
- package/dist/wunderbaum.esm.js +1195 -685
- package/dist/wunderbaum.esm.min.js +26 -25
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +1195 -685
- package/dist/wunderbaum.umd.min.js +29 -29
- package/dist/wunderbaum.umd.min.js.map +1 -1
- package/package.json +3 -3
- package/src/common.ts +55 -8
- package/src/deferred.ts +12 -2
- package/src/util.ts +87 -6
- package/src/wb_ext_dnd.ts +10 -9
- package/src/wb_ext_edit.ts +19 -11
- package/src/wb_ext_filter.ts +14 -2
- package/src/wb_ext_keynav.ts +88 -17
- package/src/wb_extension_base.ts +3 -3
- package/src/wb_node.ts +394 -225
- package/src/wb_options.ts +111 -23
- package/src/wunderbaum.scss +184 -49
- package/src/wunderbaum.ts +681 -384
package/dist/wunderbaum.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ 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;
|
|
@@ -62,7 +63,7 @@ declare module "util" {
|
|
|
62
63
|
*
|
|
63
64
|
* If a `<span class="wb-col">` is passed, the first child input is used.
|
|
64
65
|
* 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
|
|
66
|
+
* For example for a checkbox, a value of true, false, or null is returned if
|
|
66
67
|
* the element is checked, unchecked, or indeterminate.
|
|
67
68
|
* For datetime input control a numerical value is assumed, etc.
|
|
68
69
|
*
|
|
@@ -164,7 +165,7 @@ declare module "util" {
|
|
|
164
165
|
*/
|
|
165
166
|
export function overrideMethod(instance: any, methodName: string, handler: FunctionType, ctx?: any): void;
|
|
166
167
|
/** Run function after ms milliseconds and return a promise that resolves when done. */
|
|
167
|
-
export function setTimeoutPromise(callback: (...args: any[]) => void, ms: number): Promise<unknown>;
|
|
168
|
+
export function setTimeoutPromise(this: unknown, callback: (...args: any[]) => void, ms: number): Promise<unknown>;
|
|
168
169
|
/**
|
|
169
170
|
* Wait `ms` microseconds.
|
|
170
171
|
*
|
|
@@ -197,8 +198,21 @@ declare module "util" {
|
|
|
197
198
|
export function getOption(opts: any, name: string, defaultValue?: any): any;
|
|
198
199
|
/** Convert an Array or space-separated string to a Set. */
|
|
199
200
|
export function toSet(val: any): Set<string>;
|
|
200
|
-
/**Return a canonical string representation for an object's type (e.g. 'array', 'number', ...) */
|
|
201
|
+
/** Return a canonical string representation for an object's type (e.g. 'array', 'number', ...). */
|
|
201
202
|
export function type(obj: any): string;
|
|
203
|
+
/**
|
|
204
|
+
* Return a function that can be called instead of `callback`, but guarantees
|
|
205
|
+
* a limited execution rate.
|
|
206
|
+
* The execution rate is calculated based on the runtime duration of the
|
|
207
|
+
* previous call.
|
|
208
|
+
* Example:
|
|
209
|
+
* ```js
|
|
210
|
+
* throttledFoo = util.adaptiveThrottle(foo.bind(this), {});
|
|
211
|
+
* throttledFoo();
|
|
212
|
+
* throttledFoo();
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export function adaptiveThrottle(this: unknown, callback: (...args: any[]) => void, options: any): (...args: any[]) => void;
|
|
202
216
|
}
|
|
203
217
|
declare module "deferred" {
|
|
204
218
|
/*!
|
|
@@ -209,9 +223,19 @@ declare module "deferred" {
|
|
|
209
223
|
type PromiseCallbackType = (val: any) => void;
|
|
210
224
|
type finallyCallbackType = () => void;
|
|
211
225
|
/**
|
|
212
|
-
*
|
|
226
|
+
* Implement a ES6 Promise, that exposes a resolve() and reject() method.
|
|
213
227
|
*
|
|
214
|
-
* Loosely mimics
|
|
228
|
+
* Loosely mimics {@link https://api.jquery.com/category/deferred-object/ | jQuery.Deferred}.
|
|
229
|
+
* Example:
|
|
230
|
+
* ```js
|
|
231
|
+
* function foo() {
|
|
232
|
+
* let dfd = new Deferred(),
|
|
233
|
+
* ...
|
|
234
|
+
* dfd.resolve('foo')
|
|
235
|
+
* ...
|
|
236
|
+
* return dfd.promise();
|
|
237
|
+
* }
|
|
238
|
+
* ```
|
|
215
239
|
*/
|
|
216
240
|
export class Deferred {
|
|
217
241
|
private _promise;
|
|
@@ -409,6 +433,39 @@ declare module "wb_options" {
|
|
|
409
433
|
checkbox?: boolean | string;
|
|
410
434
|
children?: Array<WbNodeData>;
|
|
411
435
|
}
|
|
436
|
+
export interface ColumnDefinition {
|
|
437
|
+
/** Column ID (pass "*" for the main tree nodes column ) */
|
|
438
|
+
id: string;
|
|
439
|
+
/** Column header (defaults to id) */
|
|
440
|
+
title: string;
|
|
441
|
+
/** Column width or weight.
|
|
442
|
+
* Either an absolute pixel value (e.g. `"50px"`) or a relative weight (e.g. `1`)
|
|
443
|
+
* that is used to calculate the width inside the remaining available space.
|
|
444
|
+
* Default: `"*"`, which is interpreted as `1`.
|
|
445
|
+
*/
|
|
446
|
+
width?: string | number;
|
|
447
|
+
/** Only used for columns with a relative weight.
|
|
448
|
+
* Default: `4px`.
|
|
449
|
+
*/
|
|
450
|
+
minWidth?: string | number;
|
|
451
|
+
/** Optional class names that are added to all `span.wb-col` elements of that column.*/
|
|
452
|
+
classes?: string;
|
|
453
|
+
/** Optional HTML content that is rendered into all `span.wb-col` elements of that column.*/
|
|
454
|
+
html: string;
|
|
455
|
+
}
|
|
456
|
+
export interface TypeDefinition {
|
|
457
|
+
/** En/disable checkbox for matching nodes.*/
|
|
458
|
+
checkbox?: boolean | BoolOptionResolver;
|
|
459
|
+
/** Optional class names that are added to all `div.wb-row` elements of matching nodes.*/
|
|
460
|
+
classes?: string;
|
|
461
|
+
/**Default icon for matching nodes.*/
|
|
462
|
+
icon?: boolean | string | BoolOptionResolver;
|
|
463
|
+
/**
|
|
464
|
+
* See also {@link WunderbaumNode.getOption|WunderbaumNode.getOption()}
|
|
465
|
+
* to evaluate `node.NAME` setting and `tree.types[node.type].NAME`.
|
|
466
|
+
*/
|
|
467
|
+
_any: any;
|
|
468
|
+
}
|
|
412
469
|
/**
|
|
413
470
|
* Available options for [[Wunderbaum]].
|
|
414
471
|
*
|
|
@@ -422,6 +479,21 @@ declare module "wb_options" {
|
|
|
422
479
|
* ...
|
|
423
480
|
* });
|
|
424
481
|
* ```
|
|
482
|
+
*
|
|
483
|
+
* Event handlers are also passed as callbacks
|
|
484
|
+
*
|
|
485
|
+
* ```js
|
|
486
|
+
* const tree = new mar10.Wunderbaum({
|
|
487
|
+
* ...
|
|
488
|
+
* init: (e) => {
|
|
489
|
+
* console.log(`Tree ${e.tree} was initialized and loaded.`)
|
|
490
|
+
* },
|
|
491
|
+
* activate: (e) => {
|
|
492
|
+
* console.log(`Node ${e.node} was activated.`)
|
|
493
|
+
* },
|
|
494
|
+
* ...
|
|
495
|
+
* });
|
|
496
|
+
* ```
|
|
425
497
|
*/
|
|
426
498
|
export interface WunderbaumOptions {
|
|
427
499
|
/**
|
|
@@ -450,7 +522,9 @@ declare module "wb_options" {
|
|
|
450
522
|
*
|
|
451
523
|
* Default: `{}`.
|
|
452
524
|
*/
|
|
453
|
-
types?:
|
|
525
|
+
types?: {
|
|
526
|
+
[key: string]: TypeDefinition;
|
|
527
|
+
};
|
|
454
528
|
/**
|
|
455
529
|
* A list of maps that define column headers. If this option is set,
|
|
456
530
|
* Wunderbaum becomes a treegrid control instead of a plain tree.
|
|
@@ -458,7 +532,7 @@ declare module "wb_options" {
|
|
|
458
532
|
* response.
|
|
459
533
|
* Default: `[]` meaning this is a plain tree.
|
|
460
534
|
*/
|
|
461
|
-
columns?: Array<
|
|
535
|
+
columns?: Array<ColumnDefinition>;
|
|
462
536
|
/**
|
|
463
537
|
* If true, add a `wb-skeleton` class to all nodes, that will result in a
|
|
464
538
|
* 'glow' effect. Typically used with initial dummy nodes, while loading the
|
|
@@ -477,7 +551,7 @@ declare module "wb_options" {
|
|
|
477
551
|
debugLevel: number;
|
|
478
552
|
/**
|
|
479
553
|
* Number of levels that are forced to be expanded, and have no expander icon.
|
|
480
|
-
*
|
|
554
|
+
* Default: 0
|
|
481
555
|
*/
|
|
482
556
|
minExpandLevel?: number;
|
|
483
557
|
/**
|
|
@@ -495,6 +569,11 @@ declare module "wb_options" {
|
|
|
495
569
|
* Default: false
|
|
496
570
|
*/
|
|
497
571
|
autoCollapse?: boolean;
|
|
572
|
+
/**
|
|
573
|
+
* HTMLElement that receives the top nodes breadcrumb.
|
|
574
|
+
* Default: undefined
|
|
575
|
+
*/
|
|
576
|
+
attachBreadcrumb?: HTMLElement;
|
|
498
577
|
/**
|
|
499
578
|
* Default: NavigationModeOption.startRow
|
|
500
579
|
*/
|
|
@@ -515,29 +594,38 @@ declare module "wb_options" {
|
|
|
515
594
|
* Default: 200
|
|
516
595
|
*/
|
|
517
596
|
updateThrottleWait?: number;
|
|
597
|
+
/**
|
|
598
|
+
* Default: true
|
|
599
|
+
*/
|
|
600
|
+
enabled?: boolean;
|
|
601
|
+
/**
|
|
602
|
+
* Default: false
|
|
603
|
+
*/
|
|
604
|
+
fixedCol?: boolean;
|
|
518
605
|
/**
|
|
519
606
|
* Default: true
|
|
520
607
|
*/
|
|
521
608
|
quicksearch?: boolean;
|
|
522
609
|
dnd?: DndOptionsType;
|
|
610
|
+
edit: any;
|
|
523
611
|
filter: any;
|
|
524
612
|
grid: any;
|
|
525
613
|
/**
|
|
526
|
-
*
|
|
527
|
-
* Check `e.error` for status.
|
|
614
|
+
*
|
|
528
615
|
* @category Callback
|
|
529
616
|
*/
|
|
530
|
-
|
|
617
|
+
activate?: (e: WbNodeEventType) => void;
|
|
531
618
|
/**
|
|
532
619
|
*
|
|
533
620
|
* @category Callback
|
|
534
621
|
*/
|
|
535
|
-
|
|
622
|
+
change?: (e: WbNodeEventType) => void;
|
|
536
623
|
/**
|
|
537
624
|
*
|
|
625
|
+
* Return `false` to prevent default handling, e.g. activating the node.
|
|
538
626
|
* @category Callback
|
|
539
627
|
*/
|
|
540
|
-
|
|
628
|
+
click?: (e: WbTreeEventType) => void;
|
|
541
629
|
/**
|
|
542
630
|
*
|
|
543
631
|
* @category Callback
|
|
@@ -547,40 +635,47 @@ declare module "wb_options" {
|
|
|
547
635
|
*
|
|
548
636
|
* @category Callback
|
|
549
637
|
*/
|
|
550
|
-
|
|
638
|
+
discard?: (e: WbNodeEventType) => void;
|
|
551
639
|
/**
|
|
552
640
|
*
|
|
553
641
|
* @category Callback
|
|
554
642
|
*/
|
|
555
|
-
|
|
643
|
+
enhanceTitle?: (e: WbNodeEventType) => void;
|
|
556
644
|
/**
|
|
557
645
|
*
|
|
558
646
|
* @category Callback
|
|
559
647
|
*/
|
|
560
|
-
|
|
648
|
+
error?: (e: WbTreeEventType) => void;
|
|
561
649
|
/**
|
|
562
650
|
*
|
|
651
|
+
* Check `e.flag` for status.
|
|
563
652
|
* @category Callback
|
|
564
653
|
*/
|
|
565
|
-
|
|
654
|
+
focus?: (e: WbTreeEventType) => void;
|
|
566
655
|
/**
|
|
567
|
-
*
|
|
656
|
+
* Fires when the tree markup was created and the initial source data was loaded.
|
|
657
|
+
* Typical use cases would be activating a node, setting focus, enabling other
|
|
658
|
+
* controls on the page, etc.<br>
|
|
659
|
+
* Check `e.error` for status.
|
|
568
660
|
* @category Callback
|
|
569
661
|
*/
|
|
570
|
-
|
|
662
|
+
init?: (e: WbTreeEventType) => void;
|
|
571
663
|
/**
|
|
572
664
|
*
|
|
573
|
-
* Check `e.flag` for status.
|
|
574
665
|
* @category Callback
|
|
575
666
|
*/
|
|
576
|
-
|
|
667
|
+
keydown?: (e: WbNodeEventType) => void;
|
|
577
668
|
/**
|
|
578
|
-
*
|
|
669
|
+
* Fires when a node that was marked 'lazy', is expanded for the first time.
|
|
670
|
+
* Typically we return an endpoint URL or the Promise of a fetch request that
|
|
671
|
+
* provides a (potentially nested) list of child nodes.
|
|
579
672
|
* @category Callback
|
|
580
673
|
*/
|
|
581
|
-
|
|
674
|
+
lazyLoad?: (e: WbNodeEventType) => void;
|
|
582
675
|
/**
|
|
583
|
-
*
|
|
676
|
+
* Fires when data was loaded (initial request, reload, or lazy loading),
|
|
677
|
+
* after the data is applied and rendered.
|
|
678
|
+
* @category Callback
|
|
584
679
|
*/
|
|
585
680
|
load?: (e: WbNodeEventType) => void;
|
|
586
681
|
/**
|
|
@@ -588,12 +683,19 @@ declare module "wb_options" {
|
|
|
588
683
|
*/
|
|
589
684
|
modifyChild?: (e: WbNodeEventType) => void;
|
|
590
685
|
/**
|
|
591
|
-
*
|
|
686
|
+
* Fires when data was fetched (initial request, reload, or lazy loading),
|
|
687
|
+
* but before the data is applied and rendered.
|
|
688
|
+
* Here we can modify and adjust the received data, for example to convert an
|
|
689
|
+
* external response to native Wunderbaum syntax.
|
|
592
690
|
* @category Callback
|
|
593
691
|
*/
|
|
594
692
|
receive?: (e: WbNodeEventType) => void;
|
|
595
693
|
/**
|
|
596
|
-
*
|
|
694
|
+
* Fires when a node is about to be displayed.
|
|
695
|
+
* The default HTML markup is already created, but not yet added to the DOM.
|
|
696
|
+
* Now we can tweak the markup, create HTML elements in this node's column
|
|
697
|
+
* cells, etc.
|
|
698
|
+
* See also `Custom Rendering` for details.
|
|
597
699
|
* @category Callback
|
|
598
700
|
*/
|
|
599
701
|
render?: (e: WbNodeEventType) => void;
|
|
@@ -608,6 +710,11 @@ declare module "wb_options" {
|
|
|
608
710
|
* @category Callback
|
|
609
711
|
*/
|
|
610
712
|
select?: (e: WbNodeEventType) => void;
|
|
713
|
+
/**
|
|
714
|
+
* Fires when the viewport content was updated, after scroling, expanding etc.
|
|
715
|
+
* @category Callback
|
|
716
|
+
*/
|
|
717
|
+
update?: (e: WbTreeEventType) => void;
|
|
611
718
|
}
|
|
612
719
|
}
|
|
613
720
|
declare module "wb_node" {
|
|
@@ -618,28 +725,48 @@ declare module "wb_node" {
|
|
|
618
725
|
*/
|
|
619
726
|
import "./wunderbaum.scss";
|
|
620
727
|
import { Wunderbaum } from "wunderbaum";
|
|
621
|
-
import { ChangeType, MatcherType, NodeAnyCallback, NodeStatusType, NodeVisitCallback, NodeVisitResponse, ApplyCommandType, AddNodeType } from "common";
|
|
728
|
+
import { ChangeType, MatcherType, NodeAnyCallback, NodeStatusType, NodeVisitCallback, NodeVisitResponse, ApplyCommandType, AddNodeType, SetActiveOptions, SetExpandedOptions, SetSelectedOptions } from "common";
|
|
622
729
|
import { WbNodeData } from "wb_options";
|
|
730
|
+
/**
|
|
731
|
+
* A single tree node.
|
|
732
|
+
*
|
|
733
|
+
* **NOTE:** <br>
|
|
734
|
+
* Generally you should not modify properties directly, since this may break
|
|
735
|
+
* the internal bookkeeping.
|
|
736
|
+
*/
|
|
623
737
|
export class WunderbaumNode {
|
|
624
738
|
static sequence: number;
|
|
625
739
|
/** Reference to owning tree. */
|
|
626
740
|
tree: Wunderbaum;
|
|
627
741
|
/** Parent node (null for the invisible root node `tree.root`). */
|
|
628
742
|
parent: WunderbaumNode;
|
|
743
|
+
/** Name of the node.
|
|
744
|
+
* @see Use {@link setTitle} to modify. */
|
|
629
745
|
title: string;
|
|
746
|
+
/** Unique key. Passed with constructor or defaults to `SEQUENCE`.
|
|
747
|
+
* @see Use {@link setKey} to modify. */
|
|
630
748
|
readonly key: string;
|
|
749
|
+
/** Reference key. Unlike {@link key}, a `refKey` may occur multiple
|
|
750
|
+
* times within a tree (in this case we have 'clone nodes').
|
|
751
|
+
* @see Use {@link setKey} to modify.
|
|
752
|
+
*/
|
|
631
753
|
readonly refKey: string | undefined;
|
|
632
754
|
children: WunderbaumNode[] | null;
|
|
633
755
|
checkbox?: boolean;
|
|
634
756
|
colspan?: boolean;
|
|
635
757
|
icon?: boolean | string;
|
|
636
758
|
lazy: boolean;
|
|
759
|
+
/** Expansion state.
|
|
760
|
+
* @see {@link isExpandable}, {@link isExpanded}, {@link setExpanded}. */
|
|
637
761
|
expanded: boolean;
|
|
762
|
+
/** Selection state.
|
|
763
|
+
* @see {@link isSelected}, {@link setSelected}. */
|
|
638
764
|
selected: boolean;
|
|
639
765
|
type?: string;
|
|
640
766
|
tooltip?: string;
|
|
641
|
-
/** Additional classes added to `div.wb-row`.
|
|
642
|
-
|
|
767
|
+
/** Additional classes added to `div.wb-row`.
|
|
768
|
+
* @see {@link hasClass}, {@link setClass}. */
|
|
769
|
+
classes: Set<string> | null;
|
|
643
770
|
/** Custom data that was passed to the constructor */
|
|
644
771
|
data: any;
|
|
645
772
|
statusNodeType?: string;
|
|
@@ -651,6 +778,7 @@ declare module "wb_node" {
|
|
|
651
778
|
match?: boolean;
|
|
652
779
|
subMatchCount?: number;
|
|
653
780
|
subMatchBadge?: HTMLElement;
|
|
781
|
+
/** @internal */
|
|
654
782
|
titleWithHighlight?: string;
|
|
655
783
|
_filterAutoExpanded?: boolean;
|
|
656
784
|
_rowIdx: number | undefined;
|
|
@@ -667,7 +795,7 @@ declare module "wb_node" {
|
|
|
667
795
|
* node._callEvent("edit.beforeEdit", {foo: 42})
|
|
668
796
|
* ```
|
|
669
797
|
*/
|
|
670
|
-
_callEvent(
|
|
798
|
+
_callEvent(type: string, extra?: any): any;
|
|
671
799
|
/**
|
|
672
800
|
* Append (or insert) a list of child nodes.
|
|
673
801
|
*
|
|
@@ -690,12 +818,19 @@ declare module "wb_node" {
|
|
|
690
818
|
addNode(nodeData: WbNodeData, mode?: string): WunderbaumNode;
|
|
691
819
|
/**
|
|
692
820
|
* Apply a modification (or navigation) operation.
|
|
693
|
-
*
|
|
821
|
+
*
|
|
822
|
+
* @see {@link Wunderbaum.applyCommand}
|
|
694
823
|
*/
|
|
695
824
|
applyCommand(cmd: ApplyCommandType, opts: any): any;
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
825
|
+
/**
|
|
826
|
+
* Add/remove one or more classes to `<div class='wb-row'>`.
|
|
827
|
+
*
|
|
828
|
+
* This also maintains `node.classes`, so the class will survive a re-render.
|
|
829
|
+
*
|
|
830
|
+
* @param className one or more class names. Multiple classes can be passed
|
|
831
|
+
* as space-separated string, array of strings, or set of strings.
|
|
832
|
+
*/
|
|
833
|
+
setClass(className: string | string[] | Set<string>, flag?: boolean): void;
|
|
699
834
|
/** */
|
|
700
835
|
expandAll(flag?: boolean): Promise<void>;
|
|
701
836
|
/**Find all nodes that match condition (excluding self).
|
|
@@ -714,8 +849,7 @@ declare module "wb_node" {
|
|
|
714
849
|
findFirst(match: string | MatcherType): WunderbaumNode | null;
|
|
715
850
|
/** Find a node relative to self.
|
|
716
851
|
*
|
|
717
|
-
* @
|
|
718
|
-
* or a keyword ('down', 'first', 'last', 'left', 'parent', 'right', 'up').
|
|
852
|
+
* @see {@link Wunderbaum.findRelatedNode|tree.findRelatedNode()}
|
|
719
853
|
*/
|
|
720
854
|
findRelatedNode(where: string, includeHidden?: boolean): any;
|
|
721
855
|
/** Return the `<span class='wb-col'>` element with a given index or id.
|
|
@@ -753,6 +887,8 @@ declare module "wb_node" {
|
|
|
753
887
|
* Return undefined if not sure, i.e. the node is lazy and not yet loaded.
|
|
754
888
|
*/
|
|
755
889
|
hasChildren(): boolean;
|
|
890
|
+
/** Return true if node has className set. */
|
|
891
|
+
hasClass(className: string): boolean;
|
|
756
892
|
/** Return true if this node is the currently active tree node. */
|
|
757
893
|
isActive(): boolean;
|
|
758
894
|
/** Return true if this node is a *direct* child of `other`.
|
|
@@ -852,8 +988,34 @@ declare module "wb_node" {
|
|
|
852
988
|
[key: string]: any;
|
|
853
989
|
};
|
|
854
990
|
protected _createIcon(parentElem: HTMLElement, replaceChild?: HTMLElement): HTMLElement | null;
|
|
855
|
-
/**
|
|
856
|
-
|
|
991
|
+
/**
|
|
992
|
+
* Create a whole new `<div class="wb-row">` element.
|
|
993
|
+
* @see {@link Wunderbaumode.render}
|
|
994
|
+
*/
|
|
995
|
+
protected _render_markup(opts: any): void;
|
|
996
|
+
/**
|
|
997
|
+
* Render `node.title`, `.icon` into an existing row.
|
|
998
|
+
*
|
|
999
|
+
* @see {@link Wunderbaumode.render}
|
|
1000
|
+
*/
|
|
1001
|
+
protected _render_data(opts: any): void;
|
|
1002
|
+
/**
|
|
1003
|
+
* Update row classes to reflect active, focuses, etc.
|
|
1004
|
+
* @see {@link Wunderbaumode.render}
|
|
1005
|
+
*/
|
|
1006
|
+
protected _render_status(opts: any): void;
|
|
1007
|
+
/**
|
|
1008
|
+
* Create or update node's markup.
|
|
1009
|
+
*
|
|
1010
|
+
* `options.change` defaults to ChangeType.data, which updates the title,
|
|
1011
|
+
* icon, and status. It also triggers the `render` event, that lets the user
|
|
1012
|
+
* create or update the content of embeded cell elements.<br>
|
|
1013
|
+
*
|
|
1014
|
+
* If only the status or other class-only modifications have changed,
|
|
1015
|
+
* `options.change` should be set to ChangeType.status instead for best
|
|
1016
|
+
* efficiency.
|
|
1017
|
+
*/
|
|
1018
|
+
render(options?: any): void;
|
|
857
1019
|
/**
|
|
858
1020
|
* Remove all children, collapse, and set the lazy-flag, so that the lazyLoad
|
|
859
1021
|
* event is triggered on next expand.
|
|
@@ -876,26 +1038,51 @@ declare module "wb_node" {
|
|
|
876
1038
|
*
|
|
877
1039
|
* Evaluation sequence:
|
|
878
1040
|
*
|
|
879
|
-
* If `tree.options.<name>` is a callback that returns something, use that.
|
|
880
|
-
* Else if `node.<name>` is defined, use that.
|
|
881
|
-
* Else if `tree.types[<node.type>]` is a value, use that.
|
|
882
|
-
* Else if `tree.options.<name>` is a value, use that.
|
|
883
|
-
* Else use `defaultValue`.
|
|
1041
|
+
* - If `tree.options.<name>` is a callback that returns something, use that.
|
|
1042
|
+
* - Else if `node.<name>` is defined, use that.
|
|
1043
|
+
* - Else if `tree.types[<node.type>]` is a value, use that.
|
|
1044
|
+
* - Else if `tree.options.<name>` is a value, use that.
|
|
1045
|
+
* - Else use `defaultValue`.
|
|
884
1046
|
*
|
|
885
1047
|
* @param name name of the option property (on node and tree)
|
|
886
1048
|
* @param defaultValue return this if nothing else matched
|
|
1049
|
+
* {@link Wunderbaum.getOption|Wunderbaum.getOption()}
|
|
887
1050
|
*/
|
|
888
1051
|
getOption(name: string, defaultValue?: any): any;
|
|
1052
|
+
/** Make sure that this node is visible in the viewport.
|
|
1053
|
+
* @see {@link Wunderbaum.scrollTo|Wunderbaum.scrollTo()}
|
|
1054
|
+
*/
|
|
889
1055
|
scrollIntoView(options?: any): Promise<void>;
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1056
|
+
/**
|
|
1057
|
+
* Activate this node, deactivate previous, send events, activate column and scroll int viewport.
|
|
1058
|
+
*/
|
|
1059
|
+
setActive(flag?: boolean, options?: SetActiveOptions): Promise<void>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Expand or collapse this node.
|
|
1062
|
+
*/
|
|
1063
|
+
setExpanded(flag?: boolean, options?: SetExpandedOptions): Promise<void>;
|
|
1064
|
+
/**
|
|
1065
|
+
* Set keyboard focus here.
|
|
1066
|
+
* @see {@link setActive}
|
|
1067
|
+
*/
|
|
894
1068
|
setFocus(flag?: boolean, options?: any): void;
|
|
895
|
-
|
|
896
|
-
|
|
1069
|
+
/** Set a new icon path or class. */
|
|
1070
|
+
setIcon(): void;
|
|
1071
|
+
/** Change node's {@link key} and/or {@link refKey}. */
|
|
1072
|
+
setKey(key: string | null, refKey: string | null): void;
|
|
1073
|
+
/**
|
|
1074
|
+
* Schedule a render, typically called to update after a status or data change.
|
|
1075
|
+
*
|
|
1076
|
+
* `change` defaults to 'data', which handles modifcations of title, icon,
|
|
1077
|
+
* and column content. It can be reduced to 'ChangeType.status' if only
|
|
1078
|
+
* active/focus/selected state has changed.
|
|
897
1079
|
*/
|
|
1080
|
+
setModified(change?: ChangeType): void;
|
|
1081
|
+
/** Modify the check/uncheck state. */
|
|
1082
|
+
setSelected(flag?: boolean, options?: SetSelectedOptions): void;
|
|
1083
|
+
/** Display node status (ok, loading, error, noData) using styles and a dummy child node. */
|
|
898
1084
|
setStatus(status: NodeStatusType, message?: string, details?: string): WunderbaumNode | null;
|
|
1085
|
+
/** Rename this node. */
|
|
899
1086
|
setTitle(title: string): void;
|
|
900
1087
|
/**
|
|
901
1088
|
* Trigger `modifyChild` event on a parent to signal that a child was modified.
|
|
@@ -907,9 +1094,12 @@ declare module "wb_node" {
|
|
|
907
1094
|
* @param {string} operation Type of change: 'add', 'remove', 'rename', 'move', 'data', ...
|
|
908
1095
|
* @param {object} [extra]
|
|
909
1096
|
*/
|
|
910
|
-
triggerModify(operation: string, extra
|
|
911
|
-
/**
|
|
912
|
-
*
|
|
1097
|
+
triggerModify(operation: string, extra?: any): void;
|
|
1098
|
+
/**
|
|
1099
|
+
* Call fn(node) for all child nodes in hierarchical order (depth-first).
|
|
1100
|
+
*
|
|
1101
|
+
* Stop iteration, if fn() returns false. Skip current branch, if fn()
|
|
1102
|
+
* returns "skip".<br>
|
|
913
1103
|
* Return false if iteration was stopped.
|
|
914
1104
|
*
|
|
915
1105
|
* @param {function} callback the callback function.
|
|
@@ -924,7 +1114,8 @@ declare module "wb_node" {
|
|
|
924
1114
|
* @param callback the callback function. Return false to stop iteration
|
|
925
1115
|
*/
|
|
926
1116
|
visitParents(callback: (node: WunderbaumNode) => boolean | void, includeSelf?: boolean): boolean;
|
|
927
|
-
/**
|
|
1117
|
+
/**
|
|
1118
|
+
* Call fn(node) for all sibling nodes.<br>
|
|
928
1119
|
* Stop iteration, if fn() returns false.<br>
|
|
929
1120
|
* Return false if iteration was stopped.
|
|
930
1121
|
*
|
|
@@ -954,7 +1145,7 @@ declare module "common" {
|
|
|
954
1145
|
export type NodeVisitResponse = "skip" | boolean | void;
|
|
955
1146
|
export type NodeVisitCallback = (node: WunderbaumNode) => NodeVisitResponse;
|
|
956
1147
|
export type WbTreeEventType = {
|
|
957
|
-
|
|
1148
|
+
type: string;
|
|
958
1149
|
event: Event;
|
|
959
1150
|
tree: Wunderbaum;
|
|
960
1151
|
[key: string]: unknown;
|
|
@@ -970,21 +1161,31 @@ declare module "common" {
|
|
|
970
1161
|
export type NodeFilterCallback = (node: WunderbaumNode) => NodeFilterResponse;
|
|
971
1162
|
export type AddNodeType = "before" | "after" | "prependChild" | "appendChild";
|
|
972
1163
|
export type DndModeType = "before" | "after" | "over";
|
|
1164
|
+
/** Possible values for `setModified()`. */
|
|
973
1165
|
export enum ChangeType {
|
|
1166
|
+
/** Re-render the whole viewport, headers, and all rows. */
|
|
974
1167
|
any = "any",
|
|
1168
|
+
/** Update current row title, icon, columns, and status. */
|
|
1169
|
+
data = "data",
|
|
1170
|
+
/** Redraw the header and update the width of all row columns. */
|
|
1171
|
+
header = "header",
|
|
1172
|
+
/** Re-render the whole current row. */
|
|
975
1173
|
row = "row",
|
|
1174
|
+
/** Alias for 'any'. */
|
|
976
1175
|
structure = "structure",
|
|
1176
|
+
/** Update current row's classes, to reflect active, selected, ... */
|
|
977
1177
|
status = "status",
|
|
978
|
-
|
|
979
|
-
|
|
1178
|
+
/** Update the 'top' property of all rows. */
|
|
1179
|
+
vscroll = "vscroll"
|
|
980
1180
|
}
|
|
1181
|
+
/** Possible values for `setStatus()`. */
|
|
981
1182
|
export enum NodeStatusType {
|
|
982
1183
|
ok = "ok",
|
|
983
1184
|
loading = "loading",
|
|
984
1185
|
error = "error",
|
|
985
1186
|
noData = "noData"
|
|
986
1187
|
}
|
|
987
|
-
/**Define the subregion of a node, where an event occurred. */
|
|
1188
|
+
/** Define the subregion of a node, where an event occurred. */
|
|
988
1189
|
export enum TargetType {
|
|
989
1190
|
unknown = "",
|
|
990
1191
|
checkbox = "checkbox",
|
|
@@ -1012,19 +1213,21 @@ declare module "common" {
|
|
|
1012
1213
|
doc: string;
|
|
1013
1214
|
};
|
|
1014
1215
|
export const KEY_NODATA = "__not_found__";
|
|
1216
|
+
/** Initial navigation mode and possible transition. */
|
|
1015
1217
|
export enum NavigationModeOption {
|
|
1016
1218
|
startRow = "startRow",
|
|
1017
1219
|
cell = "cell",
|
|
1018
1220
|
startCell = "startCell",
|
|
1019
1221
|
row = "row"
|
|
1020
1222
|
}
|
|
1223
|
+
/** Tree's current navigation mode (see `tree.setNavigationMode()`). */
|
|
1021
1224
|
export enum NavigationMode {
|
|
1022
1225
|
row = "row",
|
|
1023
1226
|
cellNav = "cellNav",
|
|
1024
1227
|
cellEdit = "cellEdit"
|
|
1025
1228
|
}
|
|
1026
1229
|
/** Define which keys are handled by embedded <input> control, and should
|
|
1027
|
-
* *not* be passed to tree navigation handler in cell-edit mode
|
|
1230
|
+
* *not* be passed to tree navigation handler in cell-edit mode. */
|
|
1028
1231
|
export const INPUT_KEYS: {
|
|
1029
1232
|
text: string[];
|
|
1030
1233
|
number: string[];
|
|
@@ -1036,13 +1239,42 @@ declare module "common" {
|
|
|
1036
1239
|
};
|
|
1037
1240
|
/** Key codes that trigger grid navigation, even when inside an input element. */
|
|
1038
1241
|
export const NAVIGATE_IN_INPUT_KEYS: Set<string>;
|
|
1242
|
+
/** Possible values for `node.setActive()`. */
|
|
1243
|
+
export type SetActiveOptions = {
|
|
1244
|
+
/** Generate (de)activate event, even if node already has this status. */
|
|
1245
|
+
retrigger?: boolean;
|
|
1246
|
+
/** Do not generate (de)activate event. */
|
|
1247
|
+
noEvents?: boolean;
|
|
1248
|
+
/** Optional original event that will be passed to the (de)activate handler. */
|
|
1249
|
+
event?: Event;
|
|
1250
|
+
/** Call {@link setColumn}. */
|
|
1251
|
+
colIdx?: number;
|
|
1252
|
+
};
|
|
1253
|
+
/** Possible values for `node.setExpanded()`. */
|
|
1254
|
+
export type SetExpandedOptions = {
|
|
1255
|
+
/** Ignore {@link minExpandLevel}. @default false */
|
|
1256
|
+
force?: boolean;
|
|
1257
|
+
/** Avoid smooth scrolling. @default false */
|
|
1258
|
+
noAnimation?: boolean;
|
|
1259
|
+
/** Do not send events. @default false */
|
|
1260
|
+
noEvents?: boolean;
|
|
1261
|
+
/** Scroll to bring expanded nodes into viewport. @default false */
|
|
1262
|
+
scrollIntoView?: boolean;
|
|
1263
|
+
};
|
|
1264
|
+
/** Possible values for `node.setSelected()`. */
|
|
1265
|
+
export type SetSelectedOptions = {
|
|
1266
|
+
/** Ignore restrictions. @default false */
|
|
1267
|
+
force?: boolean;
|
|
1268
|
+
/** Do not send events. @default false */
|
|
1269
|
+
noEvents?: boolean;
|
|
1270
|
+
};
|
|
1039
1271
|
/** Map `KeyEvent.key` to navigation action. */
|
|
1040
1272
|
export const KEY_TO_ACTION_DICT: {
|
|
1041
1273
|
[key: string]: string;
|
|
1042
1274
|
};
|
|
1043
|
-
/** */
|
|
1275
|
+
/** Return a callback that returns true if the node title contains a substring (case-insensitive). */
|
|
1044
1276
|
export function makeNodeTitleMatcher(s: string): MatcherType;
|
|
1045
|
-
/** */
|
|
1277
|
+
/** Return a callback that returns true if the node title starts with a string (case-insensitive). */
|
|
1046
1278
|
export function makeNodeTitleStartMatcher(s: string): MatcherType;
|
|
1047
1279
|
}
|
|
1048
1280
|
declare module "debounce" {
|
|
@@ -1188,6 +1420,7 @@ declare module "wb_ext_filter" {
|
|
|
1188
1420
|
lastFilterArgs: IArguments | null;
|
|
1189
1421
|
constructor(tree: Wunderbaum);
|
|
1190
1422
|
init(): void;
|
|
1423
|
+
setPluginOption(name: string, value: any): void;
|
|
1191
1424
|
_applyFilterNoUpdate(filter: string | NodeFilterCallback, branchMode: boolean, _opts: any): void;
|
|
1192
1425
|
_applyFilterImpl(filter: string | NodeFilterCallback, branchMode: boolean, _opts: any): number;
|
|
1193
1426
|
/**
|
|
@@ -1217,6 +1450,7 @@ declare module "wb_ext_keynav" {
|
|
|
1217
1450
|
import { WunderbaumExtension } from "wb_extension_base";
|
|
1218
1451
|
export class KeynavExtension extends WunderbaumExtension {
|
|
1219
1452
|
constructor(tree: Wunderbaum);
|
|
1453
|
+
protected _getEmbeddedInputElem(elem: any, setFocus?: boolean): HTMLInputElement | null;
|
|
1220
1454
|
onKeyEvent(data: any): boolean | undefined;
|
|
1221
1455
|
}
|
|
1222
1456
|
}
|
|
@@ -1343,20 +1577,20 @@ declare module "wunderbaum" {
|
|
|
1343
1577
|
/*!
|
|
1344
1578
|
* wunderbaum.ts
|
|
1345
1579
|
*
|
|
1346
|
-
* A
|
|
1580
|
+
* A treegrid control.
|
|
1347
1581
|
*
|
|
1348
1582
|
* Copyright (c) 2021-2022, Martin Wendt (https://wwWendt.de).
|
|
1349
|
-
*
|
|
1583
|
+
* https://github.com/mar10/wunderbaum
|
|
1350
1584
|
*
|
|
1585
|
+
* Released under the MIT license.
|
|
1351
1586
|
* @version @VERSION
|
|
1352
1587
|
* @date @DATE
|
|
1353
1588
|
*/
|
|
1354
1589
|
import "./wunderbaum.scss";
|
|
1355
1590
|
import * as util from "util";
|
|
1356
1591
|
import { ExtensionsDict, WunderbaumExtension } from "wb_extension_base";
|
|
1357
|
-
import { NavigationMode, ChangeType, FilterModeType, MatcherType, NodeStatusType, TargetType as NodeRegion, ApplyCommandType } from "common";
|
|
1592
|
+
import { NavigationMode, ChangeType, FilterModeType, MatcherType, NodeStatusType, TargetType as NodeRegion, ApplyCommandType, SetActiveOptions } from "common";
|
|
1358
1593
|
import { WunderbaumNode } from "wb_node";
|
|
1359
|
-
import { DebouncedFunction } from "debounce";
|
|
1360
1594
|
import { WunderbaumOptions } from "wb_options";
|
|
1361
1595
|
/**
|
|
1362
1596
|
* A persistent plain object or array.
|
|
@@ -1364,68 +1598,80 @@ declare module "wunderbaum" {
|
|
|
1364
1598
|
* See also [[WunderbaumOptions]].
|
|
1365
1599
|
*/
|
|
1366
1600
|
export class Wunderbaum {
|
|
1601
|
+
protected static sequence: number;
|
|
1602
|
+
protected enabled: boolean;
|
|
1603
|
+
/** Wunderbaum release version number "MAJOR.MINOR.PATCH". */
|
|
1367
1604
|
static version: string;
|
|
1368
|
-
static sequence: number;
|
|
1369
1605
|
/** The invisible root node, that holds all visible top level nodes. */
|
|
1370
1606
|
readonly root: WunderbaumNode;
|
|
1607
|
+
/** Unique tree ID as passed to constructor. Defaults to `"wb_SEQUENCE"`. */
|
|
1371
1608
|
readonly id: string;
|
|
1609
|
+
/** The `div` container element that was passed to the constructor. */
|
|
1372
1610
|
readonly element: HTMLDivElement;
|
|
1611
|
+
/** The `div.wb-header` element if any. */
|
|
1373
1612
|
readonly headerElement: HTMLDivElement | null;
|
|
1374
|
-
|
|
1613
|
+
/** The `div.wb-scroll-container` element that contains the `nodeListElement`. */
|
|
1614
|
+
readonly scrollContainerElement: HTMLDivElement;
|
|
1615
|
+
/** The `div.wb-node-list` element that contains all visible div.wb-row child elements. */
|
|
1375
1616
|
readonly nodeListElement: HTMLDivElement;
|
|
1376
|
-
readonly _updateViewportThrottled:
|
|
1617
|
+
protected readonly _updateViewportThrottled: (...args: any) => void;
|
|
1377
1618
|
protected extensionList: WunderbaumExtension[];
|
|
1378
1619
|
protected extensions: ExtensionsDict;
|
|
1379
1620
|
/** Merged options from constructor args and tree- and extension defaults. */
|
|
1380
1621
|
options: WunderbaumOptions;
|
|
1381
1622
|
protected keyMap: Map<string, WunderbaumNode>;
|
|
1382
1623
|
protected refKeyMap: Map<string, Set<WunderbaumNode>>;
|
|
1383
|
-
protected
|
|
1624
|
+
protected treeRowCount: number;
|
|
1625
|
+
protected _disableUpdateCount: number;
|
|
1626
|
+
/** Currently active node if any. */
|
|
1384
1627
|
activeNode: WunderbaumNode | null;
|
|
1628
|
+
/** Current node hat has keyboard focus if any. */
|
|
1385
1629
|
focusNode: WunderbaumNode | null;
|
|
1386
|
-
_disableUpdate: number;
|
|
1387
|
-
_disableUpdateCount: number;
|
|
1388
1630
|
/** Shared properties, referenced by `node.type`. */
|
|
1389
1631
|
types: {
|
|
1390
1632
|
[key: string]: any;
|
|
1391
1633
|
};
|
|
1392
1634
|
/** List of column definitions. */
|
|
1393
1635
|
columns: any[];
|
|
1394
|
-
_columnsById: {
|
|
1636
|
+
protected _columnsById: {
|
|
1395
1637
|
[key: string]: any;
|
|
1396
1638
|
};
|
|
1397
|
-
protected resizeObserver:
|
|
1398
|
-
protected
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1639
|
+
protected resizeObserver: ResizeObserver;
|
|
1640
|
+
protected changeRedrawRequestPending: boolean;
|
|
1641
|
+
/** A Promise that is resolved when the tree was initialized (similar to `init(e)` event). */
|
|
1642
|
+
readonly ready: Promise<any>;
|
|
1643
|
+
/** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
|
|
1644
|
+
static util: typeof util;
|
|
1645
|
+
/** Expose some useful methods of the util.ts module as `tree._util`. */
|
|
1646
|
+
_util: typeof util;
|
|
1402
1647
|
filterMode: FilterModeType;
|
|
1648
|
+
/** @internal Use `setColumn()`/`getActiveColElem()`*/
|
|
1403
1649
|
activeColIdx: number;
|
|
1650
|
+
/** @internal */
|
|
1404
1651
|
navMode: NavigationMode;
|
|
1652
|
+
/** @internal */
|
|
1405
1653
|
lastQuicksearchTime: number;
|
|
1654
|
+
/** @internal */
|
|
1406
1655
|
lastQuicksearchTerm: string;
|
|
1407
1656
|
protected lastClickTime: number;
|
|
1408
|
-
readonly ready: Promise<any>;
|
|
1409
|
-
static util: typeof util;
|
|
1410
|
-
_util: typeof util;
|
|
1411
1657
|
constructor(options: WunderbaumOptions);
|
|
1412
|
-
/**
|
|
1413
|
-
|
|
1658
|
+
/**
|
|
1659
|
+
* Return a Wunderbaum instance, from element, id, index, or event.
|
|
1414
1660
|
*
|
|
1415
|
-
*
|
|
1416
|
-
* getTree();
|
|
1417
|
-
* getTree(1);
|
|
1418
|
-
* getTree(event);
|
|
1419
|
-
* getTree("foo");
|
|
1661
|
+
* ```js
|
|
1662
|
+
* getTree(); // Get first Wunderbaum instance on page
|
|
1663
|
+
* getTree(1); // Get second Wunderbaum instance on page
|
|
1664
|
+
* getTree(event); // Get tree for this mouse- or keyboard event
|
|
1665
|
+
* getTree("foo"); // Get tree for this `tree.options.id`
|
|
1420
1666
|
* getTree("#tree"); // Get tree for this matching element
|
|
1667
|
+
* ```
|
|
1421
1668
|
*/
|
|
1422
1669
|
static getTree(el?: Element | Event | number | string | WunderbaumNode): Wunderbaum | null;
|
|
1423
|
-
/**
|
|
1424
|
-
*
|
|
1425
|
-
* @param el
|
|
1670
|
+
/**
|
|
1671
|
+
* Return a WunderbaumNode instance from element or event.
|
|
1426
1672
|
*/
|
|
1427
1673
|
static getNode(el: Element | Event): WunderbaumNode | null;
|
|
1428
|
-
/** */
|
|
1674
|
+
/** @internal */
|
|
1429
1675
|
protected _registerExtension(extension: WunderbaumExtension): void;
|
|
1430
1676
|
/** Called on tree (re)init after markup is created, before loading. */
|
|
1431
1677
|
protected _initExtensions(): void;
|
|
@@ -1435,37 +1681,47 @@ declare module "wunderbaum" {
|
|
|
1435
1681
|
_unregisterNode(node: WunderbaumNode): void;
|
|
1436
1682
|
/** Call all hook methods of all registered extensions.*/
|
|
1437
1683
|
protected _callHook(hook: keyof WunderbaumExtension, data?: any): any;
|
|
1438
|
-
/**
|
|
1684
|
+
/**
|
|
1685
|
+
* Call tree method or extension method if defined.
|
|
1686
|
+
*
|
|
1439
1687
|
* Example:
|
|
1440
1688
|
* ```js
|
|
1441
1689
|
* tree._callMethod("edit.startEdit", "arg1", "arg2")
|
|
1442
1690
|
* ```
|
|
1443
1691
|
*/
|
|
1444
1692
|
_callMethod(name: string, ...args: any[]): any;
|
|
1445
|
-
/**
|
|
1693
|
+
/**
|
|
1694
|
+
* Call event handler if defined in tree or tree.EXTENSION options.
|
|
1695
|
+
*
|
|
1446
1696
|
* Example:
|
|
1447
1697
|
* ```js
|
|
1448
1698
|
* tree._callEvent("edit.beforeEdit", {foo: 42})
|
|
1449
1699
|
* ```
|
|
1450
1700
|
*/
|
|
1451
|
-
_callEvent(
|
|
1452
|
-
/** Return the
|
|
1453
|
-
protected
|
|
1454
|
-
/** Return the
|
|
1455
|
-
|
|
1456
|
-
/** Return
|
|
1701
|
+
_callEvent(type: string, extra?: any): any;
|
|
1702
|
+
/** Return the node for given row index. */
|
|
1703
|
+
protected _getNodeByRowIdx(idx: number): WunderbaumNode | null;
|
|
1704
|
+
/** Return the topmost visible node in the viewport. */
|
|
1705
|
+
getTopmostVpNode(complete?: boolean): WunderbaumNode;
|
|
1706
|
+
/** Return the lowest visible node in the viewport. */
|
|
1707
|
+
getLowestVpNode(complete?: boolean): WunderbaumNode;
|
|
1708
|
+
/** Return preceeding visible node in the viewport. */
|
|
1457
1709
|
protected _getPrevNodeInView(node?: WunderbaumNode, ofs?: number): WunderbaumNode;
|
|
1458
|
-
/** Return following visible node in the viewport */
|
|
1710
|
+
/** Return following visible node in the viewport. */
|
|
1459
1711
|
protected _getNextNodeInView(node?: WunderbaumNode, ofs?: number): WunderbaumNode;
|
|
1712
|
+
/**
|
|
1713
|
+
* Append (or insert) a list of toplevel nodes.
|
|
1714
|
+
*
|
|
1715
|
+
* @see {@link WunderbaumNode.addChildren}
|
|
1716
|
+
*/
|
|
1460
1717
|
addChildren(nodeData: any, options?: any): WunderbaumNode;
|
|
1461
1718
|
/**
|
|
1462
|
-
* Apply a modification (or navigation) operation on the tree or active node
|
|
1463
|
-
* @returns
|
|
1719
|
+
* Apply a modification (or navigation) operation on the **tree or active node**.
|
|
1464
1720
|
*/
|
|
1465
1721
|
applyCommand(cmd: ApplyCommandType, opts?: any): any;
|
|
1466
1722
|
/**
|
|
1467
|
-
* Apply a modification (or navigation) operation on a node
|
|
1468
|
-
* @
|
|
1723
|
+
* Apply a modification (or navigation) operation on a **node**.
|
|
1724
|
+
* @see {@link WunderbaumNode.applyCommand}
|
|
1469
1725
|
*/
|
|
1470
1726
|
applyCommand(cmd: ApplyCommandType, node: WunderbaumNode, opts?: any): any;
|
|
1471
1727
|
/** Delete all nodes. */
|
|
@@ -1481,10 +1737,11 @@ declare module "wunderbaum" {
|
|
|
1481
1737
|
/**
|
|
1482
1738
|
* Return `tree.option.NAME` (also resolving if this is a callback).
|
|
1483
1739
|
*
|
|
1484
|
-
* See also
|
|
1485
|
-
* `tree.types[node.type].NAME`.
|
|
1740
|
+
* See also {@link WunderbaumNode.getOption|WunderbaumNode.getOption()}
|
|
1741
|
+
* to evaluate `node.NAME` setting and `tree.types[node.type].NAME`.
|
|
1486
1742
|
*
|
|
1487
|
-
* @param name option name (use dot notation to access extension option, e.g.
|
|
1743
|
+
* @param name option name (use dot notation to access extension option, e.g.
|
|
1744
|
+
* `filter.mode`)
|
|
1488
1745
|
*/
|
|
1489
1746
|
getOption(name: string, defaultValue?: any): any;
|
|
1490
1747
|
/**
|
|
@@ -1499,28 +1756,46 @@ declare module "wunderbaum" {
|
|
|
1499
1756
|
runWithoutUpdate(func: () => any, hint?: any): void;
|
|
1500
1757
|
/** Recursively expand all expandable nodes (triggers lazy load id needed). */
|
|
1501
1758
|
expandAll(flag?: boolean): Promise<void>;
|
|
1759
|
+
/** Recursively select all nodes. */
|
|
1760
|
+
selectAll(flag?: boolean): void;
|
|
1502
1761
|
/** Return the number of nodes in the data model.*/
|
|
1503
1762
|
count(visible?: boolean): number;
|
|
1763
|
+
/** @internal sanity check. */
|
|
1504
1764
|
_check(): void;
|
|
1505
|
-
/**
|
|
1765
|
+
/**
|
|
1766
|
+
* Find all nodes that matches condition.
|
|
1506
1767
|
*
|
|
1507
1768
|
* @param match title string to search for, or a
|
|
1508
1769
|
* callback function that returns `true` if a node is matched.
|
|
1509
|
-
*
|
|
1770
|
+
*
|
|
1771
|
+
* @see {@link WunderbaumNode.findAll}
|
|
1510
1772
|
*/
|
|
1511
1773
|
findAll(match: string | MatcherType): WunderbaumNode[];
|
|
1512
|
-
/**
|
|
1774
|
+
/**
|
|
1775
|
+
* Find first node that matches condition.
|
|
1513
1776
|
*
|
|
1514
1777
|
* @param match title string to search for, or a
|
|
1515
1778
|
* callback function that returns `true` if a node is matched.
|
|
1516
|
-
* @see
|
|
1779
|
+
* @see {@link WunderbaumNode.findFirst}
|
|
1780
|
+
*
|
|
1517
1781
|
*/
|
|
1518
1782
|
findFirst(match: string | MatcherType): WunderbaumNode;
|
|
1519
|
-
/**
|
|
1783
|
+
/**
|
|
1784
|
+
* Find first node that matches condition.
|
|
1785
|
+
*
|
|
1786
|
+
* @param match title string to search for, or a
|
|
1787
|
+
* callback function that returns `true` if a node is matched.
|
|
1788
|
+
* @see {@link WunderbaumNode.findFirst}
|
|
1789
|
+
*
|
|
1790
|
+
*/
|
|
1791
|
+
findKey(key: string): WunderbaumNode | undefined;
|
|
1792
|
+
/**
|
|
1793
|
+
* Find the next visible node that starts with `match`, starting at `startNode`
|
|
1520
1794
|
* and wrap-around at the end.
|
|
1521
1795
|
*/
|
|
1522
1796
|
findNextNode(match: string | MatcherType, startNode?: WunderbaumNode | null): WunderbaumNode | null;
|
|
1523
|
-
/**
|
|
1797
|
+
/**
|
|
1798
|
+
* Find a node relative to another node.
|
|
1524
1799
|
*
|
|
1525
1800
|
* @param node
|
|
1526
1801
|
* @param where 'down', 'first', 'last', 'left', 'parent', 'right', or 'up'.
|
|
@@ -1530,7 +1805,7 @@ declare module "wunderbaum" {
|
|
|
1530
1805
|
*/
|
|
1531
1806
|
findRelatedNode(node: WunderbaumNode, where: string, includeHidden?: boolean): any;
|
|
1532
1807
|
/**
|
|
1533
|
-
* Return the active cell of the currently active node or null.
|
|
1808
|
+
* Return the active cell (`span.wb-col`) of the currently active node or null.
|
|
1534
1809
|
*/
|
|
1535
1810
|
getActiveColElem(): HTMLSpanElement;
|
|
1536
1811
|
/**
|
|
@@ -1567,15 +1842,19 @@ declare module "wunderbaum" {
|
|
|
1567
1842
|
toString(): string;
|
|
1568
1843
|
/** Return true if any node is currently in edit-title mode. */
|
|
1569
1844
|
isEditing(): boolean;
|
|
1570
|
-
/**
|
|
1845
|
+
/**
|
|
1846
|
+
* Return true if any node is currently beeing loaded, i.e. a Ajax request is pending.
|
|
1571
1847
|
*/
|
|
1572
1848
|
isLoading(): boolean;
|
|
1573
|
-
/** Alias for
|
|
1849
|
+
/** Alias for {@link Wunderbaum.logDebug}.
|
|
1850
|
+
* @alias Wunderbaum.logDebug
|
|
1851
|
+
*/
|
|
1574
1852
|
log: (...args: any[]) => void;
|
|
1575
1853
|
/** Log to console if opts.debugLevel >= 4 */
|
|
1576
1854
|
logDebug(...args: any[]): void;
|
|
1577
1855
|
/** Log error to console. */
|
|
1578
1856
|
logError(...args: any[]): void;
|
|
1857
|
+
/** Log to console if opts.debugLevel >= 3 */
|
|
1579
1858
|
logInfo(...args: any[]): void;
|
|
1580
1859
|
/** @internal */
|
|
1581
1860
|
logTime(label: string): string;
|
|
@@ -1583,43 +1862,86 @@ declare module "wunderbaum" {
|
|
|
1583
1862
|
logTimeEnd(label: string): void;
|
|
1584
1863
|
/** Log to console if opts.debugLevel >= 2 */
|
|
1585
1864
|
logWarn(...args: any[]): void;
|
|
1586
|
-
/** */
|
|
1587
|
-
protected render(opts?: any): boolean;
|
|
1588
|
-
/**Recalc and apply header columns from `this.columns`. */
|
|
1589
|
-
renderHeader(): void;
|
|
1590
1865
|
/**
|
|
1591
|
-
* Make sure that this node is scrolled into the viewport.
|
|
1866
|
+
* Make sure that this node is vertically scrolled into the viewport.
|
|
1592
1867
|
*
|
|
1593
|
-
* @param {boolean | PlainObject} [effects=false] animation options.
|
|
1594
1868
|
* @param {object} [options=null] {topNode: null, effects: ..., parent: ...}
|
|
1595
1869
|
* this node will remain visible in
|
|
1596
1870
|
* any case, even if `this` is outside the scroll pane.
|
|
1597
1871
|
*/
|
|
1598
1872
|
scrollTo(opts: any): void;
|
|
1599
|
-
/**
|
|
1600
|
-
|
|
1601
|
-
|
|
1873
|
+
/**
|
|
1874
|
+
* Make sure that this node is horizontally scrolled into the viewport.
|
|
1875
|
+
*
|
|
1876
|
+
* Used for `fixedCol` mode.
|
|
1877
|
+
*
|
|
1878
|
+
* @param {boolean | PlainObject} [effects=false] animation options.
|
|
1879
|
+
* @param {object} [options=null] {topNode: null, effects: ..., parent: ...}
|
|
1880
|
+
* this node will remain visible in
|
|
1881
|
+
* any case, even if `this` is outside the scroll pane.
|
|
1882
|
+
*/
|
|
1883
|
+
scrollToHorz(opts: any): void;
|
|
1884
|
+
/**
|
|
1885
|
+
* Set column #colIdx to 'active'.
|
|
1886
|
+
*
|
|
1887
|
+
* This higlights the column header and -cells by adding the `wb-active` class.
|
|
1888
|
+
* Available in cell-nav and cell-edit mode, not in row-mode.
|
|
1889
|
+
*/
|
|
1602
1890
|
setColumn(colIdx: number): void;
|
|
1603
|
-
/** */
|
|
1891
|
+
/** Set or remove keybaord focus to the tree container. */
|
|
1892
|
+
setActiveNode(key: string, flag?: boolean, options?: SetActiveOptions): void;
|
|
1893
|
+
/** Set or remove keybaord focus to the tree container. */
|
|
1604
1894
|
setFocus(flag?: boolean): void;
|
|
1605
|
-
/** */
|
|
1895
|
+
/** Schedule an update request to reflect a tree change. */
|
|
1606
1896
|
setModified(change: ChangeType, options?: any): void;
|
|
1607
|
-
/** */
|
|
1897
|
+
/** Schedule an update request to reflect a single node modification. */
|
|
1608
1898
|
setModified(change: ChangeType, node: WunderbaumNode, options?: any): void;
|
|
1899
|
+
/** Get the tree's navigation mode. */
|
|
1900
|
+
getNavigationMode(): NavigationMode;
|
|
1901
|
+
/** Set the tree's navigation mode. */
|
|
1902
|
+
setNavigationMode(mode: NavigationMode): void;
|
|
1903
|
+
/** Disable mouse and keyboard interaction (return prev. state). */
|
|
1904
|
+
setEnabled(flag?: boolean): boolean;
|
|
1905
|
+
/** Return false if tree is disabled. */
|
|
1906
|
+
isEnabled(): boolean;
|
|
1907
|
+
/** Return true if tree has one or more data columns in addition to the plain nodes. */
|
|
1908
|
+
isGrid(): boolean;
|
|
1909
|
+
/** Display tree status (ok, loading, error, noData) using styles and a dummy root node. */
|
|
1609
1910
|
setStatus(status: NodeStatusType, message?: string, details?: string): WunderbaumNode | null;
|
|
1911
|
+
/** Add or redefine node type definitions. */
|
|
1912
|
+
setTypes(types: any, replace?: boolean): void;
|
|
1610
1913
|
/** Update column headers and width. */
|
|
1611
|
-
updateColumns(opts
|
|
1612
|
-
/**
|
|
1914
|
+
updateColumns(opts?: any): void;
|
|
1915
|
+
/** Create/update header markup from `this.columns` definition.
|
|
1916
|
+
* @internal
|
|
1917
|
+
*/
|
|
1918
|
+
protected _renderHeaderMarkup(): void;
|
|
1919
|
+
/** Render header and all rows that are visible in the viewport (async, throttled). */
|
|
1613
1920
|
updateViewport(immediate?: boolean): void;
|
|
1921
|
+
/**
|
|
1922
|
+
* This is the actual update method, which is wrapped inside a throttle method.
|
|
1923
|
+
* This protected method should not be called directly but via
|
|
1924
|
+
* `tree.updateViewport()` or `tree.setModified()`.
|
|
1925
|
+
* It calls `updateColumns()` and `_updateRows()`.
|
|
1926
|
+
* @internal
|
|
1927
|
+
*/
|
|
1614
1928
|
protected _updateViewport(): void;
|
|
1615
|
-
|
|
1929
|
+
protected _updateRows(opts?: any): boolean;
|
|
1930
|
+
/**
|
|
1931
|
+
* Call callback(node) for all nodes in hierarchical order (depth-first).
|
|
1616
1932
|
*
|
|
1617
1933
|
* @param {function} callback the callback function.
|
|
1618
|
-
* Return false to stop iteration, return "skip" to skip this node and
|
|
1934
|
+
* Return false to stop iteration, return "skip" to skip this node and
|
|
1935
|
+
* children only.
|
|
1619
1936
|
* @returns {boolean} false, if the iterator was stopped.
|
|
1620
1937
|
*/
|
|
1621
1938
|
visit(callback: (node: WunderbaumNode) => any): import("common").NodeVisitResponse;
|
|
1622
|
-
/**
|
|
1939
|
+
/**
|
|
1940
|
+
* Call fn(node) for all nodes in vertical order, top down (or bottom up).
|
|
1941
|
+
*
|
|
1942
|
+
* Note that this considers expansion state, i.e. children of collapsed nodes
|
|
1943
|
+
* are skipped.
|
|
1944
|
+
*
|
|
1623
1945
|
* Stop iteration, if fn() returns false.<br>
|
|
1624
1946
|
* Return false if iteration was stopped.
|
|
1625
1947
|
*
|
|
@@ -1631,14 +1953,32 @@ declare module "wunderbaum" {
|
|
|
1631
1953
|
* @returns {boolean} false if iteration was canceled
|
|
1632
1954
|
*/
|
|
1633
1955
|
visitRows(callback: (node: WunderbaumNode) => any, opts?: any): boolean;
|
|
1634
|
-
/**
|
|
1956
|
+
/**
|
|
1957
|
+
* Call fn(node) for all nodes in vertical order, bottom up.
|
|
1635
1958
|
* @internal
|
|
1636
1959
|
*/
|
|
1637
1960
|
protected _visitRowsUp(callback: (node: WunderbaumNode) => any, opts: any): boolean;
|
|
1638
|
-
/** . */
|
|
1639
|
-
load(source: any, options?: any): Promise<void>;
|
|
1640
1961
|
/**
|
|
1962
|
+
* Reload the tree with a new source.
|
|
1641
1963
|
*
|
|
1964
|
+
* Previous data is cleared. Note that also column- and type defintions may
|
|
1965
|
+
* be passed with the `source` object.
|
|
1966
|
+
*/
|
|
1967
|
+
load(source: any): Promise<void>;
|
|
1968
|
+
/**
|
|
1969
|
+
* Disable render requests during operations that would trigger many updates.
|
|
1970
|
+
*
|
|
1971
|
+
* ```js
|
|
1972
|
+
* try {
|
|
1973
|
+
* tree.enableUpdate(false);
|
|
1974
|
+
* // ... (long running operation that would trigger many updates)
|
|
1975
|
+
* foo();
|
|
1976
|
+
* // ... NOTE: make sure that async operations have finished, e.g.
|
|
1977
|
+
* await foo();
|
|
1978
|
+
* } finally {
|
|
1979
|
+
* tree.enableUpdate(true);
|
|
1980
|
+
* }
|
|
1981
|
+
* ```
|
|
1642
1982
|
*/
|
|
1643
1983
|
enableUpdate(flag: boolean): void;
|
|
1644
1984
|
/**
|