wunderbaum 0.2.0 → 0.3.1

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.
@@ -1,7 +1,7 @@
1
1
  declare module "util" {
2
2
  /*!
3
3
  * Wunderbaum - util
4
- * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
4
+ * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
5
5
  * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
6
6
  */
7
7
  /** @module util */
@@ -67,17 +67,19 @@ declare module "util" {
67
67
  * the element is checked, unchecked, or indeterminate.
68
68
  * For datetime input control a numerical value is assumed, etc.
69
69
  *
70
- * Common use case: store the new user input in the `change` event:
70
+ * Common use case: store the new user input in a `change` event handler:
71
71
  *
72
72
  * ```ts
73
73
  * change: (e) => {
74
+ * const tree = e.tree;
75
+ * const node = e.node;
74
76
  * // Read the value from the input control that triggered the change event:
75
- * let value = e.tree.getValueFromElem(e.element);
76
- * //
77
- * e.node.data[]
77
+ * let value = tree.getValueFromElem(e.element);
78
+ * // and store it to the node model (assuming the column id matches the property name)
79
+ * node.data[e.info.colId] = value;
78
80
  * },
79
81
  * ```
80
- * @param elem `<input>` or `<select>` element Also a parent `span.wb-col` is accepted.
82
+ * @param elem `<input>` or `<select>` element. Also a parent `span.wb-col` is accepted.
81
83
  * @param coerce pass true to convert date/time inputs to `Date`.
82
84
  * @returns the value
83
85
  */
@@ -91,11 +93,28 @@ declare module "util" {
91
93
  * value is truethy, falsy, or `null`.
92
94
  * For datetime input control a numerical value is assumed, etc.
93
95
  *
96
+ * Common use case: update embedded input controls in a `render` event handler:
97
+ *
98
+ * ```ts
99
+ * render: (e) => {
100
+ * // e.node.log(e.type, e, e.node.data);
101
+ *
102
+ * for (const col of Object.values(e.renderColInfosById)) {
103
+ * switch (col.id) {
104
+ * default:
105
+ * // Assumption: we named column.id === node.data.NAME
106
+ * util.setValueToElem(col.elem, e.node.data[col.id]);
107
+ * break;
108
+ * }
109
+ * }
110
+ * },
111
+ * ```
112
+ *
94
113
  * @param elem `<input>` or `<select>` element Also a parent `span.wb-col` is accepted.
95
114
  * @param value a value that matches the target element.
96
115
  */
97
116
  export function setValueToElem(elem: HTMLElement, value: any): void;
98
- /** Show/hide element by setting the `display`style to 'none'. */
117
+ /** Show/hide element by setting the `display` style to 'none'. */
99
118
  export function setElemDisplay(elem: string | Element, flag: boolean): void;
100
119
  /** Create and return an unconnected `HTMLElement` from a HTML string. */
101
120
  export function elemFromHtml(html: string): HTMLElement;
@@ -109,7 +128,23 @@ declare module "util" {
109
128
  * The result also contains a prefix for modifiers if any, for example
110
129
  * `"x"`, `"F2"`, `"Control+Home"`, or `"Shift+clickright"`.
111
130
  * This is especially useful in `switch` statements, to make sure that modifier
112
- * keys are considered and handled correctly.
131
+ * keys are considered and handled correctly:
132
+ * ```ts
133
+ * const eventName = util.eventToString(e);
134
+ * switch (eventName) {
135
+ * case "+":
136
+ * case "Add":
137
+ * ...
138
+ * break;
139
+ * case "Enter":
140
+ * case "End":
141
+ * case "Control+End":
142
+ * case "Meta+ArrowDown":
143
+ * case "PageDown":
144
+ * ...
145
+ * break;
146
+ * }
147
+ * ```
113
148
  */
114
149
  export function eventToString(event: Event): string;
115
150
  /**
@@ -219,10 +254,11 @@ declare module "util" {
219
254
  declare module "common" {
220
255
  /*!
221
256
  * Wunderbaum - common
222
- * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
257
+ * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
223
258
  * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
224
259
  */
225
260
  import { MatcherCallback } from "types";
261
+ import { WunderbaumNode } from "wb_node";
226
262
  export const DEFAULT_DEBUGLEVEL = 4;
227
263
  /**
228
264
  * Fixed height of a row in pixel. Must match the SCSS variable `$row-outer-height`.
@@ -287,12 +323,14 @@ declare module "common" {
287
323
  export function makeNodeTitleMatcher(match: string | RegExp): MatcherCallback;
288
324
  /** Return a callback that returns true if the node title starts with a string (case-insensitive). */
289
325
  export function makeNodeTitleStartMatcher(s: string): MatcherCallback;
326
+ /** Compare two nodes by title (case-insensitive). */
327
+ export function nodeTitleSorter(a: WunderbaumNode, b: WunderbaumNode): number;
290
328
  export function inflateSourceData(source: any): void;
291
329
  }
292
330
  declare module "deferred" {
293
331
  /*!
294
332
  * Wunderbaum - deferred
295
- * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
333
+ * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
296
334
  * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
297
335
  */
298
336
  type PromiseCallbackType = (val: any) => void;
@@ -334,7 +372,7 @@ declare module "deferred" {
334
372
  declare module "wb_options" {
335
373
  /*!
336
374
  * Wunderbaum - utils
337
- * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
375
+ * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
338
376
  * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
339
377
  */
340
378
  import { BoolOptionResolver, ColumnDefinitionList, DndOptionsType, NavModeEnum, NodeTypeDefinitionMap, WbActivateEventType, WbChangeEventType, WbClickEventType, WbDeactivateEventType, WbEnhanceTitleEventType, WbErrorEventType, WbInitEventType, WbKeydownEventType, WbNodeEventType, WbReceiveEventType, WbRenderEventType, WbTreeEventType } from "types";
@@ -356,7 +394,7 @@ declare module "wb_options" {
356
394
  * ```js
357
395
  * const tree = new mar10.Wunderbaum({
358
396
  * id: "demo",
359
- * element: document.querySelector("#demo-tree"),
397
+ * element: document.getElementById("demo-tree"),
360
398
  * source: "url/of/data/request",
361
399
  * ...
362
400
  * });
@@ -419,7 +457,7 @@ declare module "wb_options" {
419
457
  * real data.
420
458
  * Default: false.
421
459
  */
422
- skeleton?: false;
460
+ skeleton?: boolean;
423
461
  /**
424
462
  * Translation map for some system messages.
425
463
  */
@@ -428,13 +466,19 @@ declare module "wb_options" {
428
466
  * 0:quiet, 1:errors, 2:warnings, 3:info, 4:verbose
429
467
  * Default: 3 (4 in local debug environment)
430
468
  */
431
- debugLevel: number;
469
+ debugLevel?: number;
432
470
  /**
433
471
  * Number of levels that are forced to be expanded, and have no expander icon.
434
472
  * E.g. 1 would keep all toplevel nodes expanded.
435
473
  * Default: 0
436
474
  */
437
475
  minExpandLevel?: number;
476
+ /**
477
+ * If true, allow to expand parent nodes, even if `node.children` conatains
478
+ * an empty array (`[]`). This is the the behavior of macOS Finder, for example.
479
+ * Default: false
480
+ */
481
+ emptyChildListExpandable?: boolean;
438
482
  /**
439
483
  * Height of a node row div.
440
484
  * Default: 22
@@ -489,9 +533,9 @@ declare module "wb_options" {
489
533
  */
490
534
  quicksearch?: boolean;
491
535
  dnd?: DndOptionsType;
492
- edit: any;
493
- filter: any;
494
- grid: any;
536
+ edit?: any;
537
+ filter?: any;
538
+ grid?: any;
495
539
  /**
496
540
  *
497
541
  * @category Callback
@@ -615,12 +659,12 @@ declare module "wb_options" {
615
659
  declare module "wb_node" {
616
660
  /*!
617
661
  * Wunderbaum - wunderbaum_node
618
- * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
662
+ * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
619
663
  * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
620
664
  */
621
665
  import "./wunderbaum.scss";
622
666
  import { Wunderbaum } from "wunderbaum";
623
- import { AddChildrenOptions, AddNodeType, ApplyCommandOptions, ApplyCommandType, ChangeType, ExpandAllOptions, MakeVisibleOptions, MatcherCallback, NavigateOptions, NodeAnyCallback, NodeStatusType, NodeStringCallback, NodeVisitCallback, NodeVisitResponse, RenderOptions, ScrollIntoViewOptions, SetActiveOptions, SetExpandedOptions, SetSelectedOptions, SetStatusOptions } from "types";
667
+ import { AddChildrenOptions, InsertNodeType, ApplyCommandOptions, ApplyCommandType, ChangeType, ExpandAllOptions, MakeVisibleOptions, MatcherCallback, NavigateOptions, NodeAnyCallback, NodeStatusType, NodeStringCallback, NodeVisitCallback, NodeVisitResponse, RenderOptions, ScrollIntoViewOptions, SetActiveOptions, SetExpandedOptions, SetSelectedOptions, SetStatusOptions, SortCallback } from "types";
624
668
  import { WbNodeData } from "wb_options";
625
669
  /**
626
670
  * A single tree node.
@@ -721,7 +765,7 @@ declare module "wb_node" {
721
765
  * @param [mode=child] 'before', 'after', 'firstChild', or 'child' ('over' is a synonym for 'child')
722
766
  * @returns new node
723
767
  */
724
- addNode(nodeData: WbNodeData, mode?: string): WunderbaumNode;
768
+ addNode(nodeData: WbNodeData, mode?: InsertNodeType): WunderbaumNode;
725
769
  /**
726
770
  * Apply a modification (or navigation) operation.
727
771
  *
@@ -905,6 +949,7 @@ declare module "wb_node" {
905
949
  */
906
950
  isVisible(): boolean;
907
951
  protected _loadSourceObject(source: any, level?: number): void;
952
+ _fetchWithOptions(source: any): Promise<any>;
908
953
  /** Download data from the cloud, then call `.update()`. */
909
954
  load(source: any): Promise<void>;
910
955
  /**Load content of a lazy node. */
@@ -922,7 +967,7 @@ declare module "wb_node" {
922
967
  */
923
968
  makeVisible(options?: MakeVisibleOptions): Promise<any>;
924
969
  /** Move this node to targetNode. */
925
- moveTo(targetNode: WunderbaumNode, mode?: AddNodeType, map?: NodeAnyCallback): void;
970
+ moveTo(targetNode: WunderbaumNode, mode?: InsertNodeType, map?: NodeAnyCallback): void;
926
971
  /** Set focus relative to this node and optionally activate.
927
972
  *
928
973
  * 'left' collapses the node if it is expanded, or move to the parent
@@ -1026,15 +1071,19 @@ declare module "wb_node" {
1026
1071
  */
1027
1072
  setFocus(flag?: boolean): void;
1028
1073
  /** Set a new icon path or class. */
1029
- setIcon(): void;
1074
+ setIcon(icon: string): void;
1030
1075
  /** Change node's {@link key} and/or {@link refKey}. */
1031
1076
  setKey(key: string | null, refKey: string | null): void;
1032
1077
  /**
1033
- * Schedule a render, typically called to update after a status or data change.
1078
+ * Trigger a repaint, typically after a status or data change.
1034
1079
  *
1035
1080
  * `change` defaults to 'data', which handles modifcations of title, icon,
1036
1081
  * and column content. It can be reduced to 'ChangeType.status' if only
1037
1082
  * active/focus/selected state has changed.
1083
+ *
1084
+ * This method will eventually call {@link WunderbaumNode.render()} with
1085
+ * default options, but may be more consistent with the tree's
1086
+ * {@link Wunderbaum.setModified()} API.
1038
1087
  */
1039
1088
  setModified(change?: ChangeType): void;
1040
1089
  /** Modify the check/uncheck state. */
@@ -1043,6 +1092,14 @@ declare module "wb_node" {
1043
1092
  setStatus(status: NodeStatusType, options?: SetStatusOptions): WunderbaumNode | null;
1044
1093
  /** Rename this node. */
1045
1094
  setTitle(title: string): void;
1095
+ _sortChildren(cmp: SortCallback, deep: boolean): void;
1096
+ /**
1097
+ * Sort child list by title or custom criteria.
1098
+ * @param {function} cmp custom compare function(a, b) that returns -1, 0, or 1
1099
+ * (defaults to sorting by title).
1100
+ * @param {boolean} deep pass true to sort all descendant nodes recursively
1101
+ */
1102
+ sortChildren(cmp?: SortCallback | null, deep?: boolean): void;
1046
1103
  /**
1047
1104
  * Trigger `modifyChild` event on a parent to signal that a child was modified.
1048
1105
  * @param {string} operation Type of change: 'add', 'remove', 'rename', 'move', 'data', ...
@@ -1092,13 +1149,15 @@ declare module "wb_node" {
1092
1149
  declare module "types" {
1093
1150
  /*!
1094
1151
  * Wunderbaum - types
1095
- * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
1152
+ * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1096
1153
  * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
1097
1154
  */
1098
1155
  import { WunderbaumNode } from "wb_node";
1099
1156
  import { Wunderbaum } from "wunderbaum";
1100
- /** Passed to find... methods. Should return true if node matches. */
1157
+ /** Passed to `find...()` methods. Should return true if node matches. */
1101
1158
  export type MatcherCallback = (node: WunderbaumNode) => boolean;
1159
+ /** Passed to `sortChildren()` methods. Should return -1, 0, or 1. */
1160
+ export type SortCallback = (a: WunderbaumNode, b: WunderbaumNode) => number;
1102
1161
  /** When set as option, called when the value is needed (e.g. `colspan` type definition). */
1103
1162
  export type BoolOptionResolver = (node: WunderbaumNode) => boolean;
1104
1163
  /** When set as option, called when the value is needed (e.g. `icon` type definition). */
@@ -1112,9 +1171,11 @@ declare module "types" {
1112
1171
  type: string;
1113
1172
  /** The affected tree instance. */
1114
1173
  tree: Wunderbaum;
1115
- /** Exposed utility module methods. */
1174
+ /** Exposed utility module methods
1175
+ * (see [API docs](https://mar10.github.io/wunderbaum/api/modules/util.html)).
1176
+ */
1116
1177
  util: any;
1117
- /** Originating HTML event, e.g. `click` if any. */
1178
+ /** Originating HTML event if any (e.g. `click`). */
1118
1179
  event?: Event;
1119
1180
  }
1120
1181
  export interface WbNodeEventType extends WbTreeEventType {
@@ -1286,29 +1347,37 @@ declare module "types" {
1286
1347
  colElem?: HTMLSpanElement;
1287
1348
  }
1288
1349
  export type FilterModeType = null | "dim" | "hide";
1289
- export type ApplyCommandType = "moveUp" | "moveDown" | "indent" | "outdent" | "remove" | "rename" | "addChild" | "addSibling" | "cut" | "copy" | "paste" | "down" | "first" | "last" | "left" | "pageDown" | "pageUp" | "parent" | "right" | "up";
1350
+ export type ApplyCommandType = "addChild" | "addSibling" | "copy" | "cut" | "down" | "first" | "indent" | "last" | "left" | "moveDown" | "moveUp" | "outdent" | "pageDown" | "pageUp" | "parent" | "paste" | "remove" | "rename" | "right" | "up";
1290
1351
  export type NodeFilterResponse = "skip" | "branch" | boolean | void;
1291
1352
  export type NodeFilterCallback = (node: WunderbaumNode) => NodeFilterResponse;
1292
- export type AddNodeType = "before" | "after" | "prependChild" | "appendChild";
1293
- export type DndModeType = "before" | "after" | "over";
1294
- /** Possible values for `setModified()`. */
1353
+ /**
1354
+ * Possible values for {@link WunderbaumNode.setModified()} and {@link Wunderbaum.setModified()}.
1355
+ */
1295
1356
  export enum ChangeType {
1296
1357
  /** Re-render the whole viewport, headers, and all rows. */
1297
1358
  any = "any",
1298
- /** Update current row title, icon, columns, and status. */
1359
+ /** A node's title, icon, columns, or status have changed. Update the existing row markup. */
1299
1360
  data = "data",
1300
- /** Redraw the header and update the width of all row columns. */
1301
- header = "header",
1302
- /** Re-render the whole current row. */
1361
+ /** The `tree.columns` definition has changed beyond simple width adjustments. */
1362
+ colStructure = "colStructure",
1363
+ /** The viewport/window was resized. Adjust layout attributes for all elements. */
1364
+ resize = "resize",
1365
+ /** A node's definition has changed beyond status and data. Re-render the whole row's markup. */
1303
1366
  row = "row",
1304
- /** Alias for 'any'. */
1367
+ /** Nodes have been added, removed, etc. Update markup. */
1305
1368
  structure = "structure",
1306
- /** Update current row's classes, to reflect active, selected, ... */
1369
+ /** A node's status has changed. Update current row's classes, to reflect active, selected, ... */
1307
1370
  status = "status",
1308
- /** Update the 'top' property of all rows. */
1309
- vscroll = "vscroll"
1371
+ /** Vertical scroll event. Update the 'top' property of all rows. */
1372
+ scroll = "scroll"
1373
+ }
1374
+ export enum RenderFlag {
1375
+ clearMarkup = "clearMarkup",
1376
+ header = "header",
1377
+ redraw = "redraw",
1378
+ scroll = "scroll"
1310
1379
  }
1311
- /** Possible values for `setStatus()`. */
1380
+ /** Possible values for {@link WunderbaumNode.setStatus()}. */
1312
1381
  export enum NodeStatusType {
1313
1382
  ok = "ok",
1314
1383
  loading = "loading",
@@ -1381,20 +1450,29 @@ declare module "types" {
1381
1450
  }
1382
1451
  /** Possible values for {@link Wunderbaum.navigate()}. */
1383
1452
  export interface NavigateOptions {
1453
+ /** Activate the new node (otherwise focus only). @default true */
1384
1454
  activate?: boolean;
1455
+ /** Originating event (e.g. KeyboardEvent) if any. */
1385
1456
  event?: Event;
1386
1457
  }
1387
1458
  /** Possible values for {@link WunderbaumNode.render()}. */
1388
1459
  export interface RenderOptions {
1460
+ /** Which parts need update? @default ChangeType.data */
1389
1461
  change?: ChangeType;
1462
+ /** Where to append a new node. @default 'last' */
1390
1463
  after?: any;
1464
+ /** @internal. @default false */
1391
1465
  isNew?: boolean;
1466
+ /** @internal. @default false */
1392
1467
  preventScroll?: boolean;
1468
+ /** @internal. @default false */
1393
1469
  isDataChange?: boolean;
1470
+ /** @internal. @default false */
1394
1471
  top?: number;
1472
+ /** @internal. @default true */
1395
1473
  resizeCols?: boolean;
1396
1474
  }
1397
- /** Possible values for {@link scrollIntoView()}. */
1475
+ /** Possible values for {@link scrollIntoView()} `options` argument. */
1398
1476
  export interface ScrollIntoViewOptions {
1399
1477
  /** Do not animate (currently not implemented). @default false */
1400
1478
  noAnimation?: boolean;
@@ -1405,12 +1483,12 @@ declare module "types" {
1405
1483
  /** Add N pixel offset at top. */
1406
1484
  ofsY?: number;
1407
1485
  }
1408
- /** Possible values for {@link Wunderbaum.scrollTo()}. */
1486
+ /** Possible values for {@link Wunderbaum.scrollTo()} `options` argument. */
1409
1487
  export interface ScrollToOptions extends ScrollIntoViewOptions {
1410
1488
  /** Which node to scroll into the viewport.*/
1411
1489
  node: WunderbaumNode;
1412
1490
  }
1413
- /** Possible values for `node.setActive()`. */
1491
+ /** Possible values for {@link WunderbaumNode.setActive()} `options` argument. */
1414
1492
  export interface SetActiveOptions {
1415
1493
  /** Generate (de)activate event, even if node already has this status (default: false). */
1416
1494
  retrigger?: boolean;
@@ -1425,7 +1503,7 @@ declare module "types" {
1425
1503
  /** Call {@link setColumn}. */
1426
1504
  colIdx?: number;
1427
1505
  }
1428
- /** Possible values for `node.setExpanded()`. */
1506
+ /** Possible values for {@link WunderbaumNode.setExpanded()} `options` argument. */
1429
1507
  export interface SetExpandedOptions {
1430
1508
  /** Ignore {@link minExpandLevel}. @default false */
1431
1509
  force?: boolean;
@@ -1438,151 +1516,151 @@ declare module "types" {
1438
1516
  /** Scroll up to bring expanded nodes into viewport. @default false */
1439
1517
  scrollIntoView?: boolean;
1440
1518
  }
1441
- /** Possible values for `node.setSetModified()`. */
1519
+ /** Possible values for {@link WunderbaumNode.setModified()} `options` argument. */
1442
1520
  export interface SetModifiedOptions {
1443
1521
  /** Force immediate redraw instead of throttled/async mode. @default false */
1444
1522
  immediate?: boolean;
1445
- /** Remove HTML markup of all rendered nodes before redraw. @default false */
1446
- removeMarkup?: boolean;
1447
1523
  }
1448
- /** Possible values for `node.setSelected()`. */
1524
+ /** Possible values for {@link WunderbaumNode.setSelected()} `options` argument. */
1449
1525
  export interface SetSelectedOptions {
1450
1526
  /** Ignore restrictions. @default false */
1451
1527
  force?: boolean;
1452
1528
  /** Do not send events. @default false */
1453
1529
  noEvents?: boolean;
1454
1530
  }
1455
- /** Possible values for `node.setSetModified()`. */
1531
+ /** Possible values for {@link WunderbaumNode.setStatus()} `options` argument. */
1456
1532
  export interface SetStatusOptions {
1457
1533
  /** Displayed as status node title. */
1458
1534
  message?: string;
1459
1535
  /** Used as tooltip. */
1460
1536
  details?: string;
1461
1537
  }
1462
- /** Possible values for {@link Wunderbaum.updateColumns()}. */
1463
- export interface UpdateColumnsOptions {
1464
- calculateCols?: boolean;
1465
- updateRows?: boolean;
1466
- }
1467
- /** Possible values for {@link Wunderbaum.visitRows()} and {@link Wunderbaum.visitRowsUp()}. */
1538
+ /** Options passed to {@link Wunderbaum.visitRows()}. */
1468
1539
  export interface VisitRowsOptions {
1469
- reverse?: boolean;
1470
- includeSelf?: boolean;
1540
+ /** Skip filtered nodes and children of collapsed nodes. @default false */
1471
1541
  includeHidden?: boolean;
1472
- wrap?: boolean;
1542
+ /** Return the start node as first result. @default true */
1543
+ includeSelf?: boolean;
1544
+ /** Traverse in opposite direction, i.e. bottom up. @default false */
1545
+ reverse?: boolean;
1546
+ /** Start traversal at this node @default first (topmost) tree node */
1473
1547
  start?: WunderbaumNode | null;
1548
+ /** Wrap around at last node and continue at the top,
1549
+ * until the start node is reached again @default false */
1550
+ wrap?: boolean;
1474
1551
  }
1552
+ export type InsertNodeType = "before" | "after" | "prependChild" | "appendChild";
1475
1553
  export type DropRegionType = "over" | "before" | "after";
1476
1554
  export type DropRegionTypeSet = Set<DropRegionType>;
1477
1555
  export type DndOptionsType = {
1478
1556
  /**
1479
1557
  * Expand nodes after n milliseconds of hovering
1480
- * Default: 1500
1558
+ * @default 1500
1481
1559
  */
1482
1560
  autoExpandMS: 1500;
1483
1561
  /**
1484
1562
  * true: Drag multiple (i.e. selected) nodes. Also a callback() is allowed
1485
- * Default: false
1563
+ * @default false
1486
1564
  */
1487
1565
  multiSource: false;
1488
1566
  /**
1489
1567
  * Restrict the possible cursor shapes and modifier operations (can also be set in the dragStart event)
1490
- * Default: "all"
1568
+ * @default "all"
1491
1569
  */
1492
1570
  effectAllowed: "all";
1493
1571
  /**
1494
1572
  * Default dropEffect ('copy', 'link', or 'move') when no modifier is pressed (overide in dragDrag, dragOver).
1495
- * Default: "move"
1573
+ * @default "move"
1496
1574
  */
1497
1575
  dropEffectDefault: string;
1498
1576
  /**
1499
1577
  * Prevent dropping nodes from different Wunderbaum trees
1500
- * Default: false
1578
+ * @default false
1501
1579
  */
1502
1580
  preventForeignNodes: boolean;
1503
1581
  /**
1504
1582
  * Prevent dropping items on unloaded lazy Wunderbaum tree nodes
1505
- * Default: true
1583
+ * @default true
1506
1584
  */
1507
1585
  preventLazyParents: boolean;
1508
1586
  /**
1509
1587
  * Prevent dropping items other than Wunderbaum tree nodes
1510
- * Default: false
1588
+ * @default false
1511
1589
  */
1512
1590
  preventNonNodes: boolean;
1513
1591
  /**
1514
1592
  * Prevent dropping nodes on own descendants
1515
- * Default: true
1593
+ * @default true
1516
1594
  */
1517
1595
  preventRecursion: boolean;
1518
1596
  /**
1519
1597
  * Prevent dropping nodes under same direct parent
1520
- * Default: false
1598
+ * @default false
1521
1599
  */
1522
1600
  preventSameParent: false;
1523
1601
  /**
1524
1602
  * Prevent dropping nodes 'before self', etc. (move only)
1525
- * Default: true
1603
+ * @default true
1526
1604
  */
1527
1605
  preventVoidMoves: boolean;
1528
1606
  /**
1529
1607
  * Enable auto-scrolling while dragging
1530
- * Default: true
1608
+ * @default true
1531
1609
  */
1532
1610
  scroll: boolean;
1533
1611
  /**
1534
1612
  * Active top/bottom margin in pixel
1535
- * Default: 20
1613
+ * @default 20
1536
1614
  */
1537
1615
  scrollSensitivity: 20;
1538
1616
  /**
1539
1617
  * Pixel per event
1540
- * Default: 5
1618
+ * @default 5
1541
1619
  */
1542
1620
  scrollSpeed: 5;
1543
1621
  /**
1544
1622
  * Optional callback passed to `toDict` on dragStart @since 2.38
1545
- * Default: null
1623
+ * @default null
1546
1624
  */
1547
1625
  sourceCopyHook: null;
1548
1626
  /**
1549
1627
  * Callback(sourceNode, data), return true, to enable dnd drag
1550
- * Default: null
1628
+ * @default null
1551
1629
  */
1552
1630
  dragStart?: WbNodeEventType;
1553
1631
  /**
1554
1632
  * Callback(sourceNode, data)
1555
- * Default: null
1633
+ * @default null
1556
1634
  */
1557
1635
  dragDrag: null;
1558
1636
  /**
1559
1637
  * Callback(sourceNode, data)
1560
- * Default: null
1638
+ * @default null
1561
1639
  */
1562
1640
  dragEnd: null;
1563
1641
  /**
1564
1642
  * Callback(targetNode, data), return true, to enable dnd drop
1565
- * Default: null
1643
+ * @default null
1566
1644
  */
1567
1645
  dragEnter: null;
1568
1646
  /**
1569
1647
  * Callback(targetNode, data)
1570
- * Default: null
1648
+ * @default null
1571
1649
  */
1572
1650
  dragOver: null;
1573
1651
  /**
1574
1652
  * Callback(targetNode, data), return false to prevent autoExpand
1575
- * Default: null
1653
+ * @default null
1576
1654
  */
1577
1655
  dragExpand: null;
1578
1656
  /**
1579
1657
  * Callback(targetNode, data)
1580
- * Default: null
1658
+ * @default null
1581
1659
  */
1582
1660
  dragDrop: null;
1583
1661
  /**
1584
1662
  * Callback(targetNode, data)
1585
- * Default: null
1663
+ * @default null
1586
1664
  */
1587
1665
  dragLeave: null;
1588
1666
  };
@@ -1821,7 +1899,7 @@ declare module "wb_ext_dnd" {
1821
1899
  declare module "drag_observer" {
1822
1900
  /*!
1823
1901
  * Wunderbaum - drag_observer
1824
- * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
1902
+ * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1825
1903
  * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
1826
1904
  */
1827
1905
  export type DragCallbackArgType = {
@@ -1881,7 +1959,7 @@ declare module "drag_observer" {
1881
1959
  declare module "wb_ext_grid" {
1882
1960
  /*!
1883
1961
  * Wunderbaum - ext-grid
1884
- * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
1962
+ * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1885
1963
  * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
1886
1964
  */
1887
1965
  import { Wunderbaum } from "wunderbaum";
@@ -1897,13 +1975,13 @@ declare module "wb_ext_grid" {
1897
1975
  declare module "wb_ext_edit" {
1898
1976
  /*!
1899
1977
  * Wunderbaum - ext-edit
1900
- * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
1978
+ * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1901
1979
  * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
1902
1980
  */
1903
1981
  import { Wunderbaum } from "wunderbaum";
1904
1982
  import { WunderbaumExtension } from "wb_extension_base";
1905
1983
  import { WunderbaumNode } from "wb_node";
1906
- import { AddNodeType } from "types";
1984
+ import { InsertNodeType } from "types";
1907
1985
  import { WbNodeData } from "wb_options";
1908
1986
  export class EditExtension extends WunderbaumExtension {
1909
1987
  protected debouncedOnChange: (e: Event) => void;
@@ -1928,7 +2006,7 @@ declare module "wb_ext_edit" {
1928
2006
  /**
1929
2007
  * Create a new child or sibling node and start edit mode.
1930
2008
  */
1931
- createNode(mode?: AddNodeType, node?: WunderbaumNode | null, init?: string | WbNodeData): void;
2009
+ createNode(mode?: InsertNodeType, node?: WunderbaumNode | null, init?: string | WbNodeData): void;
1932
2010
  }
1933
2011
  }
1934
2012
  declare module "wunderbaum" {
@@ -1937,7 +2015,7 @@ declare module "wunderbaum" {
1937
2015
  *
1938
2016
  * A treegrid control.
1939
2017
  *
1940
- * Copyright (c) 2021-2022, Martin Wendt (https://wwWendt.de).
2018
+ * Copyright (c) 2021-2023, Martin Wendt (https://wwWendt.de).
1941
2019
  * https://github.com/mar10/wunderbaum
1942
2020
  *
1943
2021
  * Released under the MIT license.
@@ -1947,7 +2025,7 @@ declare module "wunderbaum" {
1947
2025
  import "./wunderbaum.scss";
1948
2026
  import * as util from "util";
1949
2027
  import { ExtensionsDict, WunderbaumExtension } from "wb_extension_base";
1950
- import { ApplyCommandType, ChangeType, ColumnDefinitionList, ExpandAllOptions, FilterModeType, MatcherCallback, NavModeEnum, NodeStatusType, NodeStringCallback, NodeTypeDefinitionMap, ScrollToOptions, SetActiveOptions, SetModifiedOptions, SetStatusOptions, WbEventInfo, ApplyCommandOptions, AddChildrenOptions, UpdateColumnsOptions, VisitRowsOptions, NodeFilterCallback, FilterNodesOptions } from "types";
2028
+ import { ApplyCommandType, ChangeType, ColumnDefinitionList, ExpandAllOptions, FilterModeType, MatcherCallback, NavModeEnum, NodeStatusType, NodeStringCallback, NodeTypeDefinitionMap, ScrollToOptions, SetActiveOptions, SetModifiedOptions, SetStatusOptions, WbEventInfo, ApplyCommandOptions, AddChildrenOptions, VisitRowsOptions, NodeFilterCallback, FilterNodesOptions, RenderFlag, NodeVisitCallback, SortCallback } from "types";
1951
2029
  import { WunderbaumNode } from "wb_node";
1952
2030
  import { WunderbaumOptions } from "wb_options";
1953
2031
  /**
@@ -1985,6 +2063,7 @@ declare module "wunderbaum" {
1985
2063
  protected refKeyMap: Map<string, Set<WunderbaumNode>>;
1986
2064
  protected treeRowCount: number;
1987
2065
  protected _disableUpdateCount: number;
2066
+ protected _disableUpdateIgnoreCount: number;
1988
2067
  /** Currently active node if any. */
1989
2068
  activeNode: WunderbaumNode | null;
1990
2069
  /** Current node hat has keyboard focus if any. */
@@ -1997,8 +2076,7 @@ declare module "wunderbaum" {
1997
2076
  [key: string]: any;
1998
2077
  };
1999
2078
  protected resizeObserver: ResizeObserver;
2000
- protected changeRedrawRequestPending: boolean;
2001
- protected changeScrollRequestPending: boolean;
2079
+ protected pendingChangeTypes: Set<RenderFlag>;
2002
2080
  /** A Promise that is resolved when the tree was initialized (similar to `init(e)` event). */
2003
2081
  readonly ready: Promise<any>;
2004
2082
  /** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
@@ -2274,10 +2352,18 @@ declare module "wunderbaum" {
2274
2352
  setActiveNode(key: string, flag?: boolean, options?: SetActiveOptions): void;
2275
2353
  /** Set or remove keybaord focus to the tree container. */
2276
2354
  setFocus(flag?: boolean): void;
2277
- /** Schedule an update request to reflect a tree change. */
2355
+ /**
2356
+ * Schedule an update request to reflect a tree change.
2357
+ * The render operation is async and debounced unless the `immediate` option
2358
+ * is set.
2359
+ * Use {@link WunderbaumNode.setModified()} if only a single node has changed,
2360
+ * or {@link WunderbaumNode.render()}) to pass special options.
2361
+ */
2278
2362
  setModified(change: ChangeType, options?: SetModifiedOptions): void;
2279
- /** Schedule an update request to reflect a single node modification.
2280
- * @see {@link WunderbaumNode.setModified}
2363
+ /**
2364
+ * Update a row to reflect a single node's modification.
2365
+ *
2366
+ * @see {@link WunderbaumNode.setModified()}, {@link WunderbaumNode.render()}
2281
2367
  */
2282
2368
  setModified(change: ChangeType, node: WunderbaumNode, options?: SetModifiedOptions): void;
2283
2369
  /** Disable mouse and keyboard interaction (return prev. state). */
@@ -2298,10 +2384,18 @@ declare module "wunderbaum" {
2298
2384
  setStatus(status: NodeStatusType, options?: SetStatusOptions): WunderbaumNode | null;
2299
2385
  /** Add or redefine node type definitions. */
2300
2386
  setTypes(types: any, replace?: boolean): void;
2301
- /** Update column headers and width.
2387
+ /**
2388
+ * Sort nodes list by title or custom criteria.
2389
+ * @param {function} cmp custom compare function(a, b) that returns -1, 0, or 1
2390
+ * (defaults to sorting by title).
2391
+ * @param {boolean} deep pass true to sort all descendant nodes recursively
2392
+ */
2393
+ sortChildren(cmp?: SortCallback | null, deep?: boolean): void;
2394
+ /**
2395
+ * Update column headers and column width.
2302
2396
  * Return true if at least one column width changed.
2303
2397
  */
2304
- updateColumns(options?: UpdateColumnsOptions): boolean;
2398
+ _updateColumnWidths(): boolean;
2305
2399
  /** Create/update header markup from `this.columns` definition.
2306
2400
  * @internal
2307
2401
  */
@@ -2339,27 +2433,22 @@ declare module "wunderbaum" {
2339
2433
  */
2340
2434
  visit(callback: (node: WunderbaumNode) => any): import("types").NodeVisitResponse;
2341
2435
  /**
2342
- * Call fn(node) for all nodes in vertical order, top down (or bottom up).
2436
+ * Call callback(node) for all nodes in vertical order, top down (or bottom up).
2343
2437
  *
2344
- * Note that this considers expansion state, i.e. children of collapsed nodes
2345
- * are skipped.
2438
+ * Note that this considers expansion state, i.e. filtered nodes and children
2439
+ * of collapsed nodes are skipped, unless `includeHidden` is set.
2346
2440
  *
2347
- * Stop iteration, if fn() returns false.<br>
2441
+ * Stop iteration if callback() returns false.<br>
2348
2442
  * Return false if iteration was stopped.
2349
2443
  *
2350
- * @param callback the callback function.
2351
- * Return false to stop iteration, return "skip" to skip this node and children only.
2352
- * @param [options]
2353
- * Defaults:
2354
- * {start: First tree node, reverse: false, includeSelf: true, includeHidden: false, wrap: false}
2355
2444
  * @returns {boolean} false if iteration was canceled
2356
2445
  */
2357
- visitRows(callback: (node: WunderbaumNode) => any, options?: VisitRowsOptions): boolean;
2446
+ visitRows(callback: NodeVisitCallback, options?: VisitRowsOptions): boolean;
2358
2447
  /**
2359
2448
  * Call fn(node) for all nodes in vertical order, bottom up.
2360
2449
  * @internal
2361
2450
  */
2362
- protected _visitRowsUp(callback: (node: WunderbaumNode) => any, options: VisitRowsOptions): boolean;
2451
+ protected _visitRowsUp(callback: NodeVisitCallback, options: VisitRowsOptions): boolean;
2363
2452
  /**
2364
2453
  * Reload the tree with a new source.
2365
2454
  *