wunderbaum 0.0.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -337,7 +337,7 @@ declare module "wb_options" {
337
337
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
338
338
  * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
339
339
  */
340
- import { BoolOptionResolver, ColumnDefinitionList, DndOptionsType, NavigationOptions, NodeTypeDefinitions, WbNodeEventType, WbRenderEventType, WbTreeEventType } from "types";
340
+ import { BoolOptionResolver, ColumnDefinitionList, DndOptionsType, NavModeEnum, NodeTypeDefinitionMap, WbActivateEventType, WbChangeEventType, WbClickEventType, WbDeactivateEventType, WbEnhanceTitleEventType, WbErrorEventType, WbInitEventType, WbKeydownEventType, WbNodeEventType, WbReceiveEventType, WbRenderEventType, WbTreeEventType } from "types";
341
341
  export interface WbNodeData {
342
342
  title: string;
343
343
  key?: string;
@@ -345,6 +345,7 @@ declare module "wb_options" {
345
345
  expanded?: boolean;
346
346
  selected?: boolean;
347
347
  checkbox?: boolean | string;
348
+ colspan?: boolean;
348
349
  children?: Array<WbNodeData>;
349
350
  }
350
351
  /**
@@ -403,7 +404,7 @@ declare module "wb_options" {
403
404
  *
404
405
  * Default: `{}`.
405
406
  */
406
- types?: NodeTypeDefinitions;
407
+ types?: NodeTypeDefinitionMap;
407
408
  /**
408
409
  * A list of maps that define column headers. If this option is set,
409
410
  * Wunderbaum becomes a treegrid control instead of a plain tree.
@@ -450,9 +451,9 @@ declare module "wb_options" {
450
451
  */
451
452
  connectTopBreadcrumb?: HTMLElement;
452
453
  /**
453
- * Default: NavigationOptions.startRow
454
+ * Default: NavModeEnum.startRow
454
455
  */
455
- navigationModeOption?: NavigationOptions;
456
+ navigationModeOption?: NavModeEnum;
456
457
  /**
457
458
  * Show/hide header (default: null)
458
459
  * null: assume false for plain tree and true for grids.
@@ -495,32 +496,36 @@ declare module "wb_options" {
495
496
  *
496
497
  * @category Callback
497
498
  */
498
- activate?: (e: WbNodeEventType) => void;
499
+ activate?: (e: WbActivateEventType) => void;
499
500
  /**
500
501
  *
502
+ * Return `false` to prevent default handling, e.g. activating the node.
501
503
  * @category Callback
502
504
  */
503
- change?: (e: WbNodeEventType) => void;
505
+ beforeActivate?: (e: WbActivateEventType) => void;
504
506
  /**
505
507
  *
506
- * Return `false` to prevent default handling, e.g. activating the node.
507
508
  * @category Callback
508
509
  */
509
- click?: (e: WbTreeEventType) => void;
510
+ change?: (e: WbChangeEventType) => void;
510
511
  /**
511
512
  *
512
513
  * Return `false` to prevent default handling, e.g. activating the node.
513
514
  * @category Callback
514
515
  */
515
- beforeActivate?: (e: WbNodeEventType) => void;
516
+ click?: (e: WbClickEventType) => void;
516
517
  /**
518
+ *
519
+ * @category Callback
520
+ */
521
+ dblclick?: (e: WbClickEventType) => void;
517
522
  /**
518
523
  *
519
524
  * Return `false` to prevent default handling, e.g. deactivating the node
520
525
  * and activating the next.
521
526
  * @category Callback
522
527
  */
523
- deactivate?: (e: WbNodeEventType) => void;
528
+ deactivate?: (e: WbDeactivateEventType) => void;
524
529
  /**
525
530
  *
526
531
  * @category Callback
@@ -530,12 +535,12 @@ declare module "wb_options" {
530
535
  *
531
536
  * @category Callback
532
537
  */
533
- enhanceTitle?: (e: WbNodeEventType) => void;
538
+ enhanceTitle?: (e: WbEnhanceTitleEventType) => void;
534
539
  /**
535
540
  *
536
541
  * @category Callback
537
542
  */
538
- error?: (e: WbTreeEventType) => void;
543
+ error?: (e: WbErrorEventType) => void;
539
544
  /**
540
545
  *
541
546
  * Check `e.flag` for status.
@@ -549,12 +554,12 @@ declare module "wb_options" {
549
554
  * Check `e.error` for status.
550
555
  * @category Callback
551
556
  */
552
- init?: (e: WbTreeEventType) => void;
557
+ init?: (e: WbInitEventType) => void;
553
558
  /**
554
559
  *
555
560
  * @category Callback
556
561
  */
557
- keydown?: (e: WbNodeEventType) => void;
562
+ keydown?: (e: WbKeydownEventType) => void;
558
563
  /**
559
564
  * Fires when a node that was marked 'lazy', is expanded for the first time.
560
565
  * Typically we return an endpoint URL or the Promise of a fetch request that
@@ -579,7 +584,7 @@ declare module "wb_options" {
579
584
  * external response to native Wunderbaum syntax.
580
585
  * @category Callback
581
586
  */
582
- receive?: (e: WbNodeEventType) => void;
587
+ receive?: (e: WbReceiveEventType) => void;
583
588
  /**
584
589
  * Fires when a node is about to be displayed.
585
590
  * The default HTML markup is already created, but not yet added to the DOM.
@@ -593,7 +598,7 @@ declare module "wb_options" {
593
598
  *
594
599
  * @category Callback
595
600
  */
596
- renderStatusNode?: (e: WbNodeEventType) => void;
601
+ renderStatusNode?: (e: WbRenderEventType) => void;
597
602
  /**
598
603
  *
599
604
  * Check `e.flag` for status.
@@ -615,7 +620,7 @@ declare module "wb_node" {
615
620
  */
616
621
  import "./wunderbaum.scss";
617
622
  import { Wunderbaum } from "wunderbaum";
618
- import { AddChildrenOptions, AddNodeType, ApplyCommandType, ChangeType, ExpandAllOptions, MakeVisibleOptions, MatcherCallback, NodeAnyCallback, NodeStatusType, NodeVisitCallback, NodeVisitResponse, ScrollIntoViewOptions, SetActiveOptions, SetExpandedOptions, SetSelectedOptions, SetStatusOptions } from "types";
623
+ import { AddChildrenOptions, AddNodeType, ApplyCommandOptions, ApplyCommandType, ChangeType, ExpandAllOptions, MakeVisibleOptions, MatcherCallback, NavigateOptions, NodeAnyCallback, NodeStatusType, NodeStringCallback, NodeVisitCallback, NodeVisitResponse, RenderOptions, ScrollIntoViewOptions, SetActiveOptions, SetExpandedOptions, SetSelectedOptions, SetStatusOptions } from "types";
619
624
  import { WbNodeData } from "wb_options";
620
625
  /**
621
626
  * A single tree node.
@@ -680,6 +685,18 @@ declare module "wb_node" {
680
685
  * @internal
681
686
  */
682
687
  toString(): string;
688
+ /**
689
+ * Iterate all descendant nodes depth-first, pre-order using `for ... of ...` syntax.
690
+ * More concise, but slightly slower than {@link WunderbaumNode.visit}.
691
+ *
692
+ * Example:
693
+ * ```js
694
+ * for(const n of node) {
695
+ * ...
696
+ * }
697
+ * ```
698
+ */
699
+ [Symbol.iterator](): IterableIterator<WunderbaumNode>;
683
700
  /** Call event handler if defined in tree.options.
684
701
  * Example:
685
702
  * ```js
@@ -710,7 +727,7 @@ declare module "wb_node" {
710
727
  *
711
728
  * @see {@link Wunderbaum.applyCommand}
712
729
  */
713
- applyCommand(cmd: ApplyCommandType, opts: any): any;
730
+ applyCommand(cmd: ApplyCommandType, options: ApplyCommandOptions): any;
714
731
  /**
715
732
  * Add/remove one or more classes to `<div class='wb-row'>`.
716
733
  *
@@ -760,6 +777,27 @@ declare module "wb_node" {
760
777
  * @see {@link Wunderbaum.findRelatedNode|tree.findRelatedNode()}
761
778
  */
762
779
  findRelatedNode(where: string, includeHidden?: boolean): any;
780
+ /**
781
+ * Iterator version of {@link WunderbaumNode.format}.
782
+ */
783
+ format_iter(name_cb?: NodeStringCallback, connectors?: string[]): IterableIterator<string>;
784
+ /**
785
+ * Return a multiline string representation of a node/subnode hierarchy.
786
+ * Mostly useful for debugging.
787
+ *
788
+ * Example:
789
+ * ```js
790
+ * console.info(tree.getActiveNode().format((n)=>n.title));
791
+ * ```
792
+ * logs
793
+ * ```
794
+ * Books
795
+ * ├─ Art of War
796
+ * ╰─ Don Quixote
797
+ * ```
798
+ * @see {@link WunderbaumNode.format_iter}
799
+ */
800
+ format(name_cb?: NodeStringCallback, connectors?: string[]): string;
763
801
  /** Return the `<span class='wb-col'>` element with a given index or id.
764
802
  * @returns {WunderbaumNode | null}
765
803
  */
@@ -799,7 +837,11 @@ declare module "wb_node" {
799
837
  hasClass(className: string): boolean;
800
838
  /** Return true if this node is the currently active tree node. */
801
839
  isActive(): boolean;
802
- /** Return true if this node is a *direct* child of `other`.
840
+ /** Return true if this node is a direct or indirect parent of `other`.
841
+ * (See also [[isParentOf]].)
842
+ */
843
+ isAncestorOf(other: WunderbaumNode): boolean;
844
+ /** Return true if this node is a **direct** subnode of `other`.
803
845
  * (See also [[isDescendantOf]].)
804
846
  */
805
847
  isChildOf(other: WunderbaumNode): boolean;
@@ -807,7 +849,7 @@ declare module "wb_node" {
807
849
  * grid cells.
808
850
  */
809
851
  isColspan(): boolean;
810
- /** Return true if this node is a direct or indirect sub node of `other`.
852
+ /** Return true if this node is a direct or indirect subnode of `other`.
811
853
  * (See also [[isChildOf]].)
812
854
  */
813
855
  isDescendantOf(other: WunderbaumNode): boolean;
@@ -832,6 +874,10 @@ declare module "wb_node" {
832
874
  isLoading(): boolean;
833
875
  /** Return true if this node is a temporarily generated status node of type 'paging'. */
834
876
  isPagingNode(): boolean;
877
+ /** Return true if this node is a **direct** parent of `other`.
878
+ * (See also [[isAncestorOf]].)
879
+ */
880
+ isParentOf(other: WunderbaumNode): boolean;
835
881
  /** (experimental) Return true if this node is partially loaded. */
836
882
  isPartload(): boolean;
837
883
  /** Return true if this node is partially selected (tri-state). */
@@ -889,7 +935,7 @@ declare module "wb_node" {
889
935
  * e.g. `ArrowLeft` = 'left'.
890
936
  * @param options
891
937
  */
892
- navigate(where: string, options?: any): Promise<any>;
938
+ navigate(where: string, options?: NavigateOptions): Promise<any>;
893
939
  /** Delete this node and all descendants. */
894
940
  remove(): void;
895
941
  /** Remove all descendants of this node. */
@@ -897,35 +943,38 @@ declare module "wb_node" {
897
943
  /** Remove all HTML markup from the DOM. */
898
944
  removeMarkup(): void;
899
945
  protected _getRenderInfo(): any;
900
- protected _createIcon(parentElem: HTMLElement, replaceChild?: HTMLElement): HTMLElement | null;
946
+ protected _createIcon(parentElem: HTMLElement, replaceChild: HTMLElement | null, showLoading: boolean): HTMLElement | null;
901
947
  /**
902
948
  * Create a whole new `<div class="wb-row">` element.
903
949
  * @see {@link WunderbaumNode.render}
904
950
  */
905
- protected _render_markup(opts: any): void;
951
+ protected _render_markup(opts: RenderOptions): void;
906
952
  /**
907
953
  * Render `node.title`, `.icon` into an existing row.
908
954
  *
909
955
  * @see {@link WunderbaumNode.render}
910
956
  */
911
- protected _render_data(opts: any): void;
957
+ protected _render_data(opts: RenderOptions): void;
912
958
  /**
913
959
  * Update row classes to reflect active, focuses, etc.
914
960
  * @see {@link WunderbaumNode.render}
915
961
  */
916
- protected _render_status(opts: any): void;
962
+ protected _render_status(opts: RenderOptions): void;
917
963
  /**
918
964
  * Create or update node's markup.
919
965
  *
920
966
  * `options.change` defaults to ChangeType.data, which updates the title,
921
967
  * icon, and status. It also triggers the `render` event, that lets the user
922
- * create or update the content of embeded cell elements.<br>
968
+ * create or update the content of embeded cell elements.
923
969
  *
924
970
  * If only the status or other class-only modifications have changed,
925
971
  * `options.change` should be set to ChangeType.status instead for best
926
972
  * efficiency.
973
+ *
974
+ * Calling `setModified` instead may be a better alternative.
975
+ * @see {@link WunderbaumNode.setModified}
927
976
  */
928
- render(options?: any): void;
977
+ render(options?: RenderOptions): void;
929
978
  /**
930
979
  * Remove all children, collapse, and set the lazy-flag, so that the lazyLoad
931
980
  * event is triggered on next expand.
@@ -1006,7 +1055,7 @@ declare module "wb_node" {
1006
1055
  */
1007
1056
  triggerModify(operation: string, extra?: any): void;
1008
1057
  /**
1009
- * Call fn(node) for all child nodes in hierarchical order (depth-first).
1058
+ * Call `callback(node)` for all child nodes in hierarchical order (depth-first, pre-order).
1010
1059
  *
1011
1060
  * Stop iteration, if fn() returns false. Skip current branch, if fn()
1012
1061
  * returns "skip".<br>
@@ -1015,6 +1064,7 @@ declare module "wb_node" {
1015
1064
  * @param {function} callback the callback function.
1016
1065
  * Return false to stop iteration, return "skip" to skip this node and
1017
1066
  * its children only.
1067
+ * @see {@link WunderbaumNode.*[Symbol.iterator]}, {@link Wunderbaum.visit}.
1018
1068
  */
1019
1069
  visit(callback: NodeVisitCallback, includeSelf?: boolean): NodeVisitResponse;
1020
1070
  /** Call fn(node) for all parent nodes, bottom-up, including invisible system root.<br>
@@ -1054,13 +1104,16 @@ declare module "types" {
1054
1104
  /** When set as option, called when the value is needed (e.g. `icon` type definition). */
1055
1105
  export type BoolOrStringOptionResolver = (node: WunderbaumNode) => boolean | string;
1056
1106
  export type NodeAnyCallback = (node: WunderbaumNode) => any;
1107
+ export type NodeStringCallback = (node: WunderbaumNode) => string;
1057
1108
  export type NodeVisitResponse = "skip" | boolean | void;
1058
1109
  export type NodeVisitCallback = (node: WunderbaumNode) => NodeVisitResponse;
1059
1110
  export interface WbTreeEventType {
1060
1111
  /** Name of the event. */
1061
1112
  type: string;
1062
- /** The affected tree. */
1113
+ /** The affected tree instance. */
1063
1114
  tree: Wunderbaum;
1115
+ /** Exposed utility module methods. */
1116
+ util: any;
1064
1117
  /** Originating HTML event, e.g. `click` if any. */
1065
1118
  event?: Event;
1066
1119
  }
@@ -1073,6 +1126,53 @@ declare module "types" {
1073
1126
  */
1074
1127
  typeInfo: NodeTypeDefinition;
1075
1128
  }
1129
+ export interface WbActivateEventType extends WbNodeEventType {
1130
+ prevNode: WunderbaumNode;
1131
+ /** The original event. */
1132
+ event: Event;
1133
+ }
1134
+ export interface WbChangeEventType extends WbNodeEventType {
1135
+ info: WbEventInfo;
1136
+ inputElem: HTMLInputElement;
1137
+ inputValue: any;
1138
+ }
1139
+ export interface WbClickEventType extends WbTreeEventType {
1140
+ /** The original event. */
1141
+ event: MouseEvent;
1142
+ node: WunderbaumNode;
1143
+ info: WbEventInfo;
1144
+ }
1145
+ export interface WbErrorEventType extends WbNodeEventType {
1146
+ error: any;
1147
+ }
1148
+ export interface WbDeactivateEventType extends WbNodeEventType {
1149
+ nextNode: WunderbaumNode;
1150
+ /** The original event. */
1151
+ event: Event;
1152
+ }
1153
+ export interface WbEnhanceTitleEventType extends WbNodeEventType {
1154
+ titleSpan: HTMLSpanElement;
1155
+ }
1156
+ export interface WbFocusEventType extends WbTreeEventType {
1157
+ /** The original event. */
1158
+ event: FocusEvent;
1159
+ /** True if `focusin`, false if `focusout`. */
1160
+ flag: boolean;
1161
+ }
1162
+ export interface WbKeydownEventType extends WbTreeEventType {
1163
+ /** The original event. */
1164
+ event: KeyboardEvent;
1165
+ node: WunderbaumNode;
1166
+ info: WbEventInfo;
1167
+ /** Canical name of the key including modifiers. @see {@link eventToString} */
1168
+ eventName: string;
1169
+ }
1170
+ export interface WbInitEventType extends WbTreeEventType {
1171
+ error?: any;
1172
+ }
1173
+ export interface WbReceiveEventType extends WbNodeEventType {
1174
+ response: any;
1175
+ }
1076
1176
  export interface WbRenderEventType extends WbNodeEventType {
1077
1177
  /**
1078
1178
  * True if the node's markup was not yet created. In this case the render
@@ -1080,35 +1180,35 @@ declare module "types" {
1080
1180
  * values according to to current node data).
1081
1181
  */
1082
1182
  isNew: boolean;
1083
- /** True if the node only displays the title and is stretched over all remaining columns. */
1084
- isColspan: boolean;
1085
1183
  /** The node's `<span class='wb-node'>` element. */
1086
1184
  nodeElem: HTMLSpanElement;
1185
+ /** True if the node only displays the title and is stretched over all remaining columns. */
1186
+ isColspan: boolean;
1087
1187
  /**
1088
1188
  * Array of node's `<span class='wb-col'>` elements.
1089
1189
  * The first element is `<span class='wb-node wb-col'>`, which contains the
1090
1190
  * node title and icon (`idx: 0`, id: '*'`).
1091
1191
  */
1092
- allColInfosById: ColumnEventInfos;
1192
+ allColInfosById: ColumnEventInfoMap;
1093
1193
  /**
1094
1194
  * Array of node's `<span class='wb-node'>` elements, *that should be rendered*.
1095
1195
  * In contrast to `allColInfosById`, the node title is not part of this array.
1096
1196
  * If node.isColspan() is true, this array is empty (`[]`).
1097
1197
  */
1098
- renderColInfosById: ColumnEventInfos;
1198
+ renderColInfosById: ColumnEventInfoMap;
1099
1199
  }
1100
1200
  /**
1101
1201
  * Contains the node's type information, i.e. `tree.types[node.type]` if
1102
1202
  * defined. @see {@link Wunderbaum.types}
1103
1203
  */
1104
1204
  export interface NodeTypeDefinition {
1105
- /** En/disable checkbox for matching nodes.*/
1205
+ /** En/disable checkbox for matching nodes. */
1106
1206
  checkbox?: boolean | BoolOrStringOptionResolver;
1107
- /** En/disable checkbox for matching nodes.*/
1108
- colspan?: boolean | BoolOptionResolver;
1109
- /** Optional class names that are added to all `div.wb-row` elements of matching nodes.*/
1207
+ /** Optional class names that are added to all `div.wb-row` elements of matching nodes. */
1110
1208
  classes?: string;
1111
- /**Default icon for matching nodes.*/
1209
+ /** Only show title and hide other columns if any. */
1210
+ colspan?: boolean | BoolOptionResolver;
1211
+ /** Default icon for matching nodes. */
1112
1212
  icon?: boolean | string | BoolOrStringOptionResolver;
1113
1213
  /**
1114
1214
  * See also {@link WunderbaumNode.getOption|WunderbaumNode.getOption()}
@@ -1116,10 +1216,11 @@ declare module "types" {
1116
1216
  */
1117
1217
  [key: string]: unknown;
1118
1218
  }
1119
- export type NodeTypeDefinitions = {
1219
+ export type NodeTypeDefinitionMap = {
1120
1220
  [type: string]: NodeTypeDefinition;
1121
1221
  };
1122
1222
  /**
1223
+ * Column type definitions.
1123
1224
  * @see {@link `Wunderbaum.columns`}
1124
1225
  */
1125
1226
  export interface ColumnDefinition {
@@ -1148,6 +1249,9 @@ declare module "types" {
1148
1249
  _ofsPx?: number;
1149
1250
  }
1150
1251
  export type ColumnDefinitionList = Array<ColumnDefinition>;
1252
+ /**
1253
+ * Column information (passed to the `render` event).
1254
+ */
1151
1255
  export interface ColumnEventInfo {
1152
1256
  /** Column ID as defined in `tree.columns` definition ("*" for title column). */
1153
1257
  id: string;
@@ -1158,12 +1262,29 @@ declare module "types" {
1158
1262
  /** The value of `tree.columns[]` for the current index. */
1159
1263
  info: ColumnDefinition;
1160
1264
  }
1161
- export type ColumnEventInfos = {
1265
+ export type ColumnEventInfoMap = {
1162
1266
  [colId: string]: ColumnEventInfo;
1163
1267
  };
1164
- export type WbTreeCallbackType = (e: WbTreeEventType) => any;
1165
- export type WbNodeCallbackType = (e: WbNodeEventType) => any;
1166
- export type WbRenderCallbackType = (e: WbRenderEventType) => void;
1268
+ /**
1269
+ * Additional inforation derived from mouse or keyboard events.
1270
+ * @see {@link Wunderbaum.getEventInfo}
1271
+ */
1272
+ export interface WbEventInfo {
1273
+ /** The tree instance. */
1274
+ tree: Wunderbaum;
1275
+ /** The affected node instance instance if any. */
1276
+ node: WunderbaumNode | null;
1277
+ /** The affected part of the node span (e.g. title, expander, ...). */
1278
+ region: NodeRegion;
1279
+ /** The definition of the affected column if any. */
1280
+ colDef?: ColumnDefinition;
1281
+ /** The index of affected column or -1. */
1282
+ colIdx: number;
1283
+ /** The column definition ID of affected column if any. */
1284
+ colId?: string;
1285
+ /** The affected column's span tag if any. */
1286
+ colElem?: HTMLSpanElement;
1287
+ }
1167
1288
  export type FilterModeType = null | "dim" | "hide";
1168
1289
  export type ApplyCommandType = "moveUp" | "moveDown" | "indent" | "outdent" | "remove" | "rename" | "addChild" | "addSibling" | "cut" | "copy" | "paste" | "down" | "first" | "last" | "left" | "pageDown" | "pageUp" | "parent" | "right" | "up";
1169
1290
  export type NodeFilterResponse = "skip" | "branch" | boolean | void;
@@ -1195,7 +1316,7 @@ declare module "types" {
1195
1316
  noData = "noData"
1196
1317
  }
1197
1318
  /** Define the subregion of a node, where an event occurred. */
1198
- export enum TargetType {
1319
+ export enum NodeRegion {
1199
1320
  unknown = "",
1200
1321
  checkbox = "checkbox",
1201
1322
  column = "column",
@@ -1204,6 +1325,13 @@ declare module "types" {
1204
1325
  prefix = "prefix",
1205
1326
  title = "title"
1206
1327
  }
1328
+ /** Initial navigation mode and possible transition. */
1329
+ export enum NavModeEnum {
1330
+ startRow = "startRow",
1331
+ cell = "cell",
1332
+ startCell = "startCell",
1333
+ row = "row"
1334
+ }
1207
1335
  /** Possible values for {@link WunderbaumNode.addChildren()}. */
1208
1336
  export interface AddChildrenOptions {
1209
1337
  /** Insert children before this node (or index)
@@ -1219,6 +1347,10 @@ declare module "types" {
1219
1347
  /** (@internal Internal use, do not set! ) */
1220
1348
  _level?: number;
1221
1349
  }
1350
+ /** Possible values for {@link Wunderbaum.applyCommand()} and {@link WunderbaumNode.applyCommand()}. */
1351
+ export interface ApplyCommandOptions {
1352
+ [key: string]: unknown;
1353
+ }
1222
1354
  /** Possible values for {@link Wunderbaum.expandAll()} and {@link WunderbaumNode.expandAll()}. */
1223
1355
  export interface ExpandAllOptions {
1224
1356
  /** Restrict expand level @default 99 */
@@ -1228,6 +1360,16 @@ declare module "types" {
1228
1360
  /** Ignore `minExpandLevel` option @default false */
1229
1361
  force?: boolean;
1230
1362
  }
1363
+ /** Possible values for {@link Wunderbaum.filterNodes()} and {@link Wunderbaum.filterBranches()}. */
1364
+ export interface FilterNodesOptions {
1365
+ mode?: string;
1366
+ leavesOnly?: boolean;
1367
+ fuzzy?: boolean;
1368
+ highlight?: boolean;
1369
+ hideExpanders?: boolean;
1370
+ autoExpand?: boolean;
1371
+ noData?: boolean;
1372
+ }
1231
1373
  /** Possible values for {@link WunderbaumNode.makeVisible()}. */
1232
1374
  export interface MakeVisibleOptions {
1233
1375
  /** Do not animate expand (currently not implemented). @default false */
@@ -1237,12 +1379,19 @@ declare module "types" {
1237
1379
  /** Do not send events. @default false */
1238
1380
  noEvents?: boolean;
1239
1381
  }
1240
- /** Initial navigation mode and possible transition. */
1241
- export enum NavigationOptions {
1242
- startRow = "startRow",
1243
- cell = "cell",
1244
- startCell = "startCell",
1245
- row = "row"
1382
+ /** Possible values for {@link Wunderbaum.navigate()}. */
1383
+ export interface NavigateOptions {
1384
+ activate?: boolean;
1385
+ event?: Event;
1386
+ }
1387
+ /** Possible values for {@link WunderbaumNode.render()}. */
1388
+ export interface RenderOptions {
1389
+ change?: ChangeType;
1390
+ after?: any;
1391
+ isNew?: boolean;
1392
+ preventScroll?: boolean;
1393
+ isDataChange?: boolean;
1394
+ top?: number;
1246
1395
  }
1247
1396
  /** Possible values for {@link scrollIntoView()}. */
1248
1397
  export interface ScrollIntoViewOptions {
@@ -1309,6 +1458,19 @@ declare module "types" {
1309
1458
  /** Used as tooltip. */
1310
1459
  details?: string;
1311
1460
  }
1461
+ /** Possible values for {@link Wunderbaum.updateColumns()}. */
1462
+ export interface UpdateColumnsOptions {
1463
+ calculateCols?: boolean;
1464
+ updateRows?: boolean;
1465
+ }
1466
+ /** Possible values for {@link Wunderbaum.visitRows()} and {@link Wunderbaum.visitRowsUp()}. */
1467
+ export interface VisitRowsOptions {
1468
+ reverse?: boolean;
1469
+ includeSelf?: boolean;
1470
+ includeHidden?: boolean;
1471
+ wrap?: boolean;
1472
+ start?: WunderbaumNode | null;
1473
+ }
1312
1474
  export type DropRegionType = "over" | "before" | "after";
1313
1475
  export type DropRegionTypeSet = Set<DropRegionType>;
1314
1476
  export type DndOptionsType = {
@@ -1580,7 +1742,7 @@ declare module "debounce" {
1580
1742
  export function throttle<F extends Procedure>(func: F, wait?: number, options?: ThrottleOptions): DebouncedFunction<F>;
1581
1743
  }
1582
1744
  declare module "wb_ext_filter" {
1583
- import { NodeFilterCallback } from "types";
1745
+ import { FilterNodesOptions, NodeFilterCallback } from "types";
1584
1746
  import { Wunderbaum } from "wunderbaum";
1585
1747
  import { WunderbaumExtension } from "wb_extension_base";
1586
1748
  export class FilterExtension extends WunderbaumExtension {
@@ -1594,15 +1756,15 @@ declare module "wb_ext_filter" {
1594
1756
  /**
1595
1757
  * [ext-filter] Dim or hide nodes.
1596
1758
  *
1597
- * @param {boolean} [opts={autoExpand: false, leavesOnly: false}]
1759
+ * @param {boolean} [options={autoExpand: false, leavesOnly: false}]
1598
1760
  */
1599
- filterNodes(filter: string | NodeFilterCallback, opts: any): void;
1761
+ filterNodes(filter: string | NodeFilterCallback, options: FilterNodesOptions): void;
1600
1762
  /**
1601
1763
  * [ext-filter] Dim or hide whole branches.
1602
1764
  *
1603
- * @param {boolean} [opts={autoExpand: false}]
1765
+ * @param {boolean} [options={autoExpand: false}]
1604
1766
  */
1605
- filterBranches(filter: string | NodeFilterCallback, opts: any): void;
1767
+ filterBranches(filter: string | NodeFilterCallback, options: FilterNodesOptions): void;
1606
1768
  /**
1607
1769
  * [ext-filter] Re-apply current filter.
1608
1770
  */
@@ -1660,6 +1822,11 @@ declare module "wb_ext_dnd" {
1660
1822
  }
1661
1823
  }
1662
1824
  declare module "drag_observer" {
1825
+ /*!
1826
+ * Wunderbaum - drag_observer
1827
+ * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
1828
+ * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
1829
+ */
1663
1830
  export type DragCallbackArgType = {
1664
1831
  /** "dragstart", "drag", or "dragstop". */
1665
1832
  type: string;
@@ -1760,7 +1927,7 @@ declare module "wb_ext_edit" {
1760
1927
  * @returns
1761
1928
  */
1762
1929
  stopEditTitle(apply: boolean): void;
1763
- _stopEditTitle(apply: boolean, opts: any): void;
1930
+ _stopEditTitle(apply: boolean, options: any): void;
1764
1931
  /**
1765
1932
  * Create a new child or sibling node and start edit mode.
1766
1933
  */
@@ -1783,7 +1950,7 @@ declare module "wunderbaum" {
1783
1950
  import "./wunderbaum.scss";
1784
1951
  import * as util from "util";
1785
1952
  import { ExtensionsDict, WunderbaumExtension } from "wb_extension_base";
1786
- import { ApplyCommandType, ChangeType, ColumnDefinitionList, ExpandAllOptions, FilterModeType, MatcherCallback, NavigationOptions, NodeStatusType, NodeTypeDefinitions, ScrollToOptions, SetActiveOptions, SetStatusOptions, TargetType as NodeRegion } from "types";
1953
+ import { ApplyCommandType, ChangeType, ColumnDefinitionList, ExpandAllOptions, FilterModeType, MatcherCallback, NavModeEnum, NodeStatusType, NodeStringCallback, NodeTypeDefinitionMap, ScrollToOptions, SetActiveOptions, SetModifiedOptions, SetStatusOptions, WbEventInfo, ApplyCommandOptions, AddChildrenOptions, UpdateColumnsOptions, VisitRowsOptions } from "types";
1787
1954
  import { WunderbaumNode } from "wb_node";
1788
1955
  import { WunderbaumOptions } from "wb_options";
1789
1956
  /**
@@ -1804,8 +1971,8 @@ declare module "wunderbaum" {
1804
1971
  readonly element: HTMLDivElement;
1805
1972
  /** The `div.wb-header` element if any. */
1806
1973
  readonly headerElement: HTMLDivElement;
1807
- /** The `div.wb-scroll-container` element that contains the `nodeListElement`. */
1808
- readonly scrollContainerElement: HTMLDivElement;
1974
+ /** The `div.wb-list-container` element that contains the `nodeListElement`. */
1975
+ readonly listContainerElement: HTMLDivElement;
1809
1976
  /** The `div.wb-node-list` element that contains all visible div.wb-row child elements. */
1810
1977
  readonly nodeListElement: HTMLDivElement;
1811
1978
  /** Contains additional data that was sent as response to an Ajax source load request. */
@@ -1826,7 +1993,7 @@ declare module "wunderbaum" {
1826
1993
  /** Current node hat has keyboard focus if any. */
1827
1994
  focusNode: WunderbaumNode | null;
1828
1995
  /** Shared properties, referenced by `node.type`. */
1829
- types: NodeTypeDefinitions;
1996
+ types: NodeTypeDefinitionMap;
1830
1997
  /** List of column definitions. */
1831
1998
  columns: ColumnDefinitionList;
1832
1999
  protected _columnsById: {
@@ -1868,6 +2035,18 @@ declare module "wunderbaum" {
1868
2035
  * Return a WunderbaumNode instance from element or event.
1869
2036
  */
1870
2037
  static getNode(el: Element | Event): WunderbaumNode | null;
2038
+ /**
2039
+ * Iterate all descendant nodes depth-first, pre-order using `for ... of ...` syntax.
2040
+ * More concise, but slightly slower than {@link Wunderbaum.visit}.
2041
+ *
2042
+ * Example:
2043
+ * ```js
2044
+ * for(const node of tree) {
2045
+ * ...
2046
+ * }
2047
+ * ```
2048
+ */
2049
+ [Symbol.iterator](): IterableIterator<WunderbaumNode>;
1871
2050
  /** @internal */
1872
2051
  protected _registerExtension(extension: WunderbaumExtension): void;
1873
2052
  /** Called on tree (re)init after markup is created, before loading. */
@@ -1911,16 +2090,16 @@ declare module "wunderbaum" {
1911
2090
  *
1912
2091
  * @see {@link WunderbaumNode.addChildren}
1913
2092
  */
1914
- addChildren(nodeData: any, options?: any): WunderbaumNode;
2093
+ addChildren(nodeData: any, options?: AddChildrenOptions): WunderbaumNode;
1915
2094
  /**
1916
2095
  * Apply a modification (or navigation) operation on the **tree or active node**.
1917
2096
  */
1918
- applyCommand(cmd: ApplyCommandType, options?: any): any;
2097
+ applyCommand(cmd: ApplyCommandType, options?: ApplyCommandOptions): any;
1919
2098
  /**
1920
2099
  * Apply a modification (or navigation) operation on a **node**.
1921
2100
  * @see {@link WunderbaumNode.applyCommand}
1922
2101
  */
1923
- applyCommand(cmd: ApplyCommandType, node: WunderbaumNode, options?: any): any;
2102
+ applyCommand(cmd: ApplyCommandType, node: WunderbaumNode, options?: ApplyCommandOptions): any;
1924
2103
  /** Delete all nodes. */
1925
2104
  clear(): void;
1926
2105
  /**
@@ -2000,6 +2179,31 @@ declare module "wunderbaum" {
2000
2179
  * @param includeHidden Not yet implemented
2001
2180
  */
2002
2181
  findRelatedNode(node: WunderbaumNode, where: string, includeHidden?: boolean): any;
2182
+ /**
2183
+ * Iterator version of {@link Wunderbaum.format}.
2184
+ */
2185
+ format_iter(name_cb?: NodeStringCallback, connectors?: string[]): IterableIterator<string>;
2186
+ /**
2187
+ * Return multiline string representation of the node hierarchy.
2188
+ * Mostly useful for debugging.
2189
+ *
2190
+ * Example:
2191
+ * ```js
2192
+ * console.info(tree.format((n)=>n.title));
2193
+ * ```
2194
+ * logs
2195
+ * ```
2196
+ * Playground
2197
+ * ├─ Books
2198
+ * | ├─ Art of War
2199
+ * | ╰─ Don Quixote
2200
+ * ├─ Music
2201
+ * ...
2202
+ * ```
2203
+ *
2204
+ * @see {@link Wunderbaum.format_iter} and {@link WunderbaumNode.format}.
2205
+ */
2206
+ format(name_cb?: NodeStringCallback, connectors?: string[]): string;
2003
2207
  /**
2004
2208
  * Return the active cell (`span.wb-col`) of the currently active node or null.
2005
2209
  */
@@ -2022,15 +2226,7 @@ declare module "wunderbaum" {
2022
2226
  * @returns {object} Return a {node: WunderbaumNode, region: TYPE} object
2023
2227
  * TYPE: 'title' | 'prefix' | 'expander' | 'checkbox' | 'icon' | undefined
2024
2228
  */
2025
- static getEventInfo(event: Event): {
2026
- tree: Wunderbaum;
2027
- node: WunderbaumNode;
2028
- region: NodeRegion;
2029
- colDef: any;
2030
- colIdx: number;
2031
- colId: any;
2032
- colElem: HTMLSpanElement;
2033
- };
2229
+ static getEventInfo(event: Event): WbEventInfo;
2034
2230
  /**
2035
2231
  * Return readable string representation for this instance.
2036
2232
  * @internal
@@ -2082,9 +2278,11 @@ declare module "wunderbaum" {
2082
2278
  /** Set or remove keybaord focus to the tree container. */
2083
2279
  setFocus(flag?: boolean): void;
2084
2280
  /** Schedule an update request to reflect a tree change. */
2085
- setModified(change: ChangeType, options?: any): void;
2086
- /** Schedule an update request to reflect a single node modification. */
2087
- setModified(change: ChangeType, node: WunderbaumNode, options?: any): void;
2281
+ setModified(change: ChangeType, options?: SetModifiedOptions): void;
2282
+ /** Schedule an update request to reflect a single node modification.
2283
+ * @see {@link WunderbaumNode.setModified}
2284
+ */
2285
+ setModified(change: ChangeType, node: WunderbaumNode, options?: SetModifiedOptions): void;
2088
2286
  /** Disable mouse and keyboard interaction (return prev. state). */
2089
2287
  setEnabled(flag?: boolean): boolean;
2090
2288
  /** Return false if tree is disabled. */
@@ -2098,13 +2296,13 @@ declare module "wunderbaum" {
2098
2296
  /** Set the tree's navigation mode. */
2099
2297
  setCellNav(flag?: boolean): void;
2100
2298
  /** Set the tree's navigation mode option. */
2101
- setNavigationOption(mode: NavigationOptions, reset?: boolean): void;
2299
+ setNavigationOption(mode: NavModeEnum, reset?: boolean): void;
2102
2300
  /** Display tree status (ok, loading, error, noData) using styles and a dummy root node. */
2103
2301
  setStatus(status: NodeStatusType, options?: SetStatusOptions): WunderbaumNode | null;
2104
2302
  /** Add or redefine node type definitions. */
2105
2303
  setTypes(types: any, replace?: boolean): void;
2106
2304
  /** Update column headers and width. */
2107
- updateColumns(options?: any): void;
2305
+ updateColumns(options?: UpdateColumnsOptions): void;
2108
2306
  /** Create/update header markup from `this.columns` definition.
2109
2307
  * @internal
2110
2308
  */
@@ -2132,7 +2330,8 @@ declare module "wunderbaum" {
2132
2330
  protected _updateViewportImmediately(): void;
2133
2331
  protected _updateRows(options?: any): boolean;
2134
2332
  /**
2135
- * Call callback(node) for all nodes in hierarchical order (depth-first).
2333
+ * Call `callback(node)` for all nodes in hierarchical order (depth-first, pre-order).
2334
+ * @see {@link Wunderbaum.*[Symbol.iterator]}, {@link WunderbaumNode.visit}.
2136
2335
  *
2137
2336
  * @param {function} callback the callback function.
2138
2337
  * Return false to stop iteration, return "skip" to skip this node and
@@ -2156,12 +2355,12 @@ declare module "wunderbaum" {
2156
2355
  * {start: First tree node, reverse: false, includeSelf: true, includeHidden: false, wrap: false}
2157
2356
  * @returns {boolean} false if iteration was canceled
2158
2357
  */
2159
- visitRows(callback: (node: WunderbaumNode) => any, options?: any): boolean;
2358
+ visitRows(callback: (node: WunderbaumNode) => any, options?: VisitRowsOptions): boolean;
2160
2359
  /**
2161
2360
  * Call fn(node) for all nodes in vertical order, bottom up.
2162
2361
  * @internal
2163
2362
  */
2164
- protected _visitRowsUp(callback: (node: WunderbaumNode) => any, opts: any): boolean;
2363
+ protected _visitRowsUp(callback: (node: WunderbaumNode) => any, options: VisitRowsOptions): boolean;
2165
2364
  /**
2166
2365
  * Reload the tree with a new source.
2167
2366
  *