wunderbaum 0.10.0 → 0.11.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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021-2023 Martin Wendt
3
+ Copyright (c) 2021-2024 Martin Wendt
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -14,9 +14,9 @@
14
14
 
15
15
  **Status _beta_:<br>API, Markup, Stylesheet, etc. are still subject to change.**
16
16
 
17
- [![Demo](docs/assets/teaser_2.png?raw=true)](https://mar10.github.io/wunderbaum/demo/)
17
+ [![Demo](https://mar10.github.io/wunderbaum/assets/teaser_2.png)](https://mar10.github.io/wunderbaum/demo/)
18
18
 
19
- - Supports drag and drop, editing, filtering, and multi-selection.
19
+ - Supports drag and drop, editing, filtering, sorting, and multi-selection.
20
20
  - Written in TypeScript, transpiled to ES6 (esm & umd).
21
21
  - Performant handling of big data structures.
22
22
  - Provide an object oriented API.
@@ -94,8 +94,8 @@ div.wunderbaum div.wb-header {
94
94
  position: sticky;
95
95
  top: 0;
96
96
  z-index: 2;
97
- user-select: none;
98
97
  -webkit-user-select: none; /* Safari */
98
+ user-select: none;
99
99
  }
100
100
  div.wunderbaum div.wb-header,
101
101
  div.wunderbaum div.wb-list-container {
@@ -204,12 +204,20 @@ div.wunderbaum div.wb-header span.wb-col-resizer {
204
204
  border: none;
205
205
  border-right: 2px solid var(--wb-border-color);
206
206
  height: 100%;
207
- user-select: none;
208
207
  -webkit-user-select: none;
208
+ user-select: none;
209
209
  }
210
210
  div.wunderbaum div.wb-header span.wb-col-resizer.wb-col-resizer-active {
211
211
  cursor: col-resize;
212
212
  }
213
+ div.wunderbaum div.wb-header i.wb-col-icon {
214
+ float: inline-end;
215
+ padding-left: 2px;
216
+ }
217
+ div.wunderbaum div.wb-header i.wb-col-icon:hover {
218
+ cursor: pointer;
219
+ color: var(--wb-focus-border-color);
220
+ }
213
221
  div.wunderbaum span.wb-col {
214
222
  position: absolute;
215
223
  display: inline-block;
@@ -224,8 +232,8 @@ div.wunderbaum span.wb-col:last-of-type {
224
232
  border-right: none;
225
233
  }
226
234
  div.wunderbaum span.wb-node {
227
- user-select: none;
228
235
  -webkit-user-select: none;
236
+ user-select: none;
229
237
  /* Fix Bootstrap Icon alignment */
230
238
  }
231
239
  div.wunderbaum span.wb-node i.wb-checkbox,
@@ -445,12 +453,12 @@ div.wunderbaum.wb-checkbox-auto-hide:focus .wb-row.wb-active i.wb-checkbox, div.
445
453
  }
446
454
 
447
455
  .wb-no-select {
448
- user-select: none;
449
456
  -webkit-user-select: none;
457
+ user-select: none;
450
458
  }
451
459
  .wb-no-select span.wb-title {
452
- user-select: contain;
453
460
  -webkit-user-select: contain;
461
+ user-select: contain;
454
462
  }
455
463
 
456
464
  /* RTL support */
@@ -1 +1 @@
1
- {"version":3,"sourceRoot":"","sources":["../src/wunderbaum.scss"],"names":[],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AA2EA;AAAA;EAME;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EAEA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EAEA;;;AAMF;EACE;;;AAGF;EACE;EACA;EACA;EACA;EACA;EAEA;EACA;EAEA;EACA;EACA;EACA;EACA;EAGA;AAsBA;AAyBA;AA8QA;AAoHA;AA8BA;AAgEA;AAEA;AAUA;AAoBA;AAYA;;AAvjBA;EAEE;;AAIF;EACE;EACA;;AAGF;EACE;EAEA;;AAMF;EACE;EACA;EACA;EACA;EACA;;AAGF;AAAA;EAEE;;AAKF;EACE;EACA;EACA;EACA;EACA;;AAMA;EACE;EACA;EACA;EACA;;A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EAEE;;AAFF;AAAA;EAEE;;AAOJ;EAIE;EACA;;AAGF;AAAA;EAKE;EACA;;AAMF;AAAA;EAEE;EACA;EACA;EACA;;AAOF;EACE;;AAGF;AAAA;EAEE;;AAKA;EACE;;;AAMR;AAEA;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;;AAEA;EACE;EACA;;;AAQJ;AACA;AAAA;EAEE;;;AAGF;AAAA;EAEE;;;AAIA;AAAA;EAEE;;AAGF;AAAA;EAEE;;;AAIJ;EACE;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;;;AAIJ;AAAA;AAAA;AAMA;EACE;EACA;;;AAGF;EAGE;;;AAGF;EACE;;;AAKF;EACE;IACE;;EAGF;IACE;;;AAIJ;EACE;IACE;;EAGF;IACE;;;AAIJ;EACE;IACE;;EAGF;IACE","file":"wunderbaum.css"}
1
+ {"version":3,"sourceRoot":"","sources":["../src/wunderbaum.scss"],"names":[],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AA2EA;AAAA;EAME;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EAEA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EAEA;;;AAMF;EACE;;;AAGF;EACE;EACA;EACA;EACA;EACA;EAEA;EACA;EAEA;EACA;EACA;EACA;EACA;EAGA;AAsBA;AAyBA;AAwRA;AAoHA;AA8BA;AAgEA;AAEA;AAUA;AAoBA;AAYA;;AAjkBA;EAEE;;AAIF;EACE;EACA;;AAGF;EACE;EAEA;;AAMF;EACE;EACA;EACA;EACA;EACA;;AAGF;AAAA;EAEE;;AAKF;EACE;EACA;EACA;EACA;EACA;;AAMA;EACE;EAC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AUE;AAAA;EAEE;;AAFF;AAAA;EAEE;;AAFF;AAAA;EAEE;;AAFF;AAAA;EAEE;;AAOJ;EAIE;EACA;;AAGF;AAAA;EAKE;EACA;;AAMF;AAAA;EAEE;EACA;EACA;EACA;;AAOF;EACE;;AAGF;AAAA;EAEE;;AAKA;EACE;;;AAMR;AAEA;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;;AAEA;EACE;EACA;;;AAQJ;AACA;AAAA;EAEE;;;AAGF;AAAA;EAEE;;;AAIA;AAAA;EAEE;;AAGF;AAAA;EAEE;;;AAIJ;EACE;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;;;AAIJ;AAAA;AAAA;AAMA;EACE;EACA;;;AAGF;EAGE;;;AAGF;EACE;;;AAKF;EACE;IACE;;EAGF;IACE;;;AAIJ;EACE;IACE;;EAGF;IACE;;;AAIJ;EACE;IACE;;EAGF;IACE","file":"wunderbaum.css"}
@@ -294,7 +294,7 @@ declare module "util" {
294
294
  export function extend(...args: any[]): any;
295
295
  /** Return true if `obj` is of type `array`. */
296
296
  export function isArray(obj: any): boolean;
297
- /** Return true if `obj` is of type `Object` and has no propertied. */
297
+ /** Return true if `obj` is of type `Object` and has no properties. */
298
298
  export function isEmptyObject(obj: any): boolean;
299
299
  /** Return true if `obj` is of type `function`. */
300
300
  export function isFunction(obj: any): boolean;
@@ -372,6 +372,8 @@ declare module "util" {
372
372
  * @param defaultValue returned when `opts` is not an object, or does not have a NAME property
373
373
  */
374
374
  export function getOption(opts: any, name: string, defaultValue?: any): any;
375
+ /** Return the next value from a list of values (rotating). @since 0.11 */
376
+ export function rotate(value: any, values: any[]): any;
375
377
  /** Convert an Array or space-separated string to a Set. */
376
378
  export function toSet(val: any): Set<string>;
377
379
  /** Convert a pixel string to number.
@@ -380,15 +382,17 @@ declare module "util" {
380
382
  *
381
383
  * Example:
382
384
  * ```js
383
- * const width = util.toPixel("123px", 100);
385
+ * let x = undefined;
386
+ * let y = "123px";
387
+ * const width = util.toPixel(x, y, 100); // returns 123
384
388
  * ```
385
389
  */
386
390
  export function toPixel(...defaults: (string | number | undefined | null)[]): number;
387
- /** Evaluate a boolean value using default if undefined.
391
+ /** Return the the boolean value of the first non-null element.
388
392
  * Example:
389
393
  * ```js
390
394
  * const opts = { flag: true };
391
- * const value = util.toBool(opts.flag, otherVar, false);
395
+ * const value = util.toBool(opts.foo, opts.flag, false); // returns true
392
396
  * ```
393
397
  */
394
398
  export function toBool(...boolDefaults: (boolean | undefined | null)[]): boolean;
@@ -464,7 +468,7 @@ declare module "common" {
464
468
  };
465
469
  /** Return a callback that returns true if the node title matches the string
466
470
  * or regular expression.
467
- * @see {@link WunderbaumNode.findAll()}
471
+ * @see {@link WunderbaumNode.findAll}
468
472
  */
469
473
  export function makeNodeTitleMatcher(match: string | RegExp): MatcherCallback;
470
474
  /** Return a callback that returns true if the node title starts with a string (case-insensitive). */
@@ -526,7 +530,7 @@ declare module "deferred" {
526
530
  }
527
531
  declare module "wb_node" {
528
532
  import { Wunderbaum } from "wunderbaum";
529
- import { AddChildrenOptions, ApplyCommandOptions, ApplyCommandType, ChangeType, CheckboxOption, ExpandAllOptions, IconOption, InsertNodeType, MakeVisibleOptions, MatcherCallback, NavigateOptions, NodeAnyCallback, NodeStatusType, NodeStringCallback, NodeToDictCallback, NodeVisitCallback, NodeVisitResponse, RenderOptions, ScrollIntoViewOptions, SetActiveOptions, SetExpandedOptions, SetSelectedOptions, SetStatusOptions, SortCallback, SourceType, TooltipOption, TristateType, WbNodeData } from "types";
533
+ import { AddChildrenOptions, ApplyCommandOptions, ApplyCommandType, ChangeType, CheckboxOption, ExpandAllOptions, IconOption, InsertNodeType, MakeVisibleOptions, MatcherCallback, NavigateOptions, NodeAnyCallback, NodeStatusType, NodeStringCallback, NodeToDictCallback, NodeVisitCallback, NodeVisitResponse, RenderOptions, ResetOrderOptions, ScrollIntoViewOptions, SetActiveOptions, SetExpandedOptions, SetSelectedOptions, SetStatusOptions, SortByPropertyOptions, SortCallback, SourceType, TooltipOption, TristateType, WbNodeData } from "types";
530
534
  /**
531
535
  * A single tree node.
532
536
  *
@@ -551,12 +555,26 @@ declare module "wb_node" {
551
555
  * @see Use {@link setKey} to modify.
552
556
  */
553
557
  readonly refKey: string | undefined;
558
+ /**
559
+ * Array of child nodes (null for leaf nodes).
560
+ * For lazy nodes, this is `null` or ùndefined` until the children are loaded
561
+ * and leaf nodes may be `[]` (empty array).
562
+ * @see {@link hasChildren}, {@link addChildren}, {@link lazy}.
563
+ */
554
564
  children: WunderbaumNode[] | null;
565
+ /** Render a checkbox or radio button @see {@link selected}. */
555
566
  checkbox?: CheckboxOption;
567
+ /** If true, this node's children are considerd radio buttons.
568
+ * @see {@link isRadio}.
569
+ */
556
570
  radiogroup?: boolean;
557
571
  /** If true, (in grid mode) no cells are rendered, except for the node title.*/
558
572
  colspan?: boolean;
573
+ /** Icon definition. */
559
574
  icon?: IconOption;
575
+ /** Lazy loading flag.
576
+ * @see {@link isLazy}, {@link isLoaded}, {@link isUnloaded}.
577
+ */
560
578
  lazy?: boolean;
561
579
  /** Expansion state.
562
580
  * @see {@link isExpandable}, {@link isExpanded}, {@link setExpanded}. */
@@ -565,7 +583,11 @@ declare module "wb_node" {
565
583
  * @see {@link isSelected}, {@link setSelected}, {@link toggleSelected}. */
566
584
  selected?: boolean;
567
585
  unselectable?: boolean;
586
+ /** Node type (used for styling).
587
+ * @see {@link Wunderbaum.types}.
588
+ */
568
589
  type?: string;
590
+ /** Tooltip definition (`true`: use node's title). */
569
591
  tooltip?: string | boolean;
570
592
  /** Additional classes added to `div.wb-row`.
571
593
  * @see {@link hasClass}, {@link setClass}. */
@@ -755,7 +777,7 @@ declare module "wb_node" {
755
777
  hasChildren(): boolean;
756
778
  /** Return true if node has className set. */
757
779
  hasClass(className: string): boolean;
758
- /** Return true if node ist the currently focused node. */
780
+ /** Return true if node ist the currently focused node. @since 0.9.0 */
759
781
  hasFocus(): boolean;
760
782
  /** Return true if this node is the currently active tree node. */
761
783
  isActive(): boolean;
@@ -937,11 +959,11 @@ declare module "wb_node" {
937
959
  *
938
960
  * @param name name of the option property (on node and tree)
939
961
  * @param defaultValue return this if nothing else matched
940
- * {@link Wunderbaum.getOption|Wunderbaum.getOption()}
962
+ * {@link Wunderbaum.getOption|Wunderbaum.getOption}
941
963
  */
942
964
  getOption(name: string, defaultValue?: any): any;
943
965
  /** Make sure that this node is visible in the viewport.
944
- * @see {@link Wunderbaum.scrollTo|Wunderbaum.scrollTo()}
966
+ * @see {@link Wunderbaum.scrollTo|Wunderbaum.scrollTo}
945
967
  */
946
968
  scrollIntoView(options?: ScrollIntoViewOptions): Promise<void>;
947
969
  /**
@@ -969,9 +991,9 @@ declare module "wb_node" {
969
991
  * and column content. It can be reduced to 'ChangeType.status' if only
970
992
  * active/focus/selected state has changed.
971
993
  *
972
- * This method will eventually call {@link WunderbaumNode._render()} with
994
+ * This method will eventually call {@link WunderbaumNode._render} with
973
995
  * default options, but may be more consistent with the tree's
974
- * {@link Wunderbaum.update()} API.
996
+ * {@link Wunderbaum.update} API.
975
997
  */
976
998
  update(change?: ChangeType): void;
977
999
  /**
@@ -1012,6 +1034,18 @@ declare module "wb_node" {
1012
1034
  * @param {boolean} deep pass true to sort all descendant nodes recursively
1013
1035
  */
1014
1036
  sortChildren(cmp?: SortCallback | null, deep?: boolean): void;
1037
+ /**
1038
+ * Renumber nodes `_nativeIndex`. This is useful to allow to restore the
1039
+ * order after sorting a column.
1040
+ * This method is automatically called after loading new child nodes.
1041
+ * @since 0.11.0
1042
+ */
1043
+ resetNativeChildOrder(options?: ResetOrderOptions): void;
1044
+ /**
1045
+ * Convenience method to implement column sorting.
1046
+ * @since 0.11.0
1047
+ */
1048
+ sortByProperty(options: SortByPropertyOptions): void;
1015
1049
  /**
1016
1050
  * Trigger `modifyChild` event on a parent to signal that a child was modified.
1017
1051
  * @param {string} operation Type of change: 'add', 'remove', 'rename', 'move', 'data', ...
@@ -1065,7 +1099,7 @@ declare module "wb_options" {
1065
1099
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1066
1100
  * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
1067
1101
  */
1068
- import { ColumnDefinitionList, DndOptionsType, DynamicBoolOption, DynamicBoolOrStringOption, DynamicCheckboxOption, DynamicIconOption, EditOptionsType, FilterOptionsType, NavModeEnum, NodeTypeDefinitionMap, SelectModeType, WbActivateEventType, WbCancelableEventResultType, WbChangeEventType, WbClickEventType, WbDeactivateEventType, WbErrorEventType, WbExpandEventType, WbIconBadgeCallback, WbIconBadgeEventResultType, WbInitEventType, WbKeydownEventType, WbNodeData, WbNodeEventType, WbReceiveEventType, WbRenderEventType, WbSelectEventType, WbTreeEventType } from "types";
1102
+ import { ColumnDefinitionList, DndOptionsType, DynamicBoolOption, DynamicBoolOrStringOption, DynamicCheckboxOption, DynamicIconOption, EditOptionsType, FilterOptionsType, NavModeEnum, NodeTypeDefinitionMap, SelectModeType, WbActivateEventType, WbButtonClickEventType, WbCancelableEventResultType, WbChangeEventType, WbClickEventType, WbDeactivateEventType, WbErrorEventType, WbExpandEventType, WbIconBadgeCallback, WbIconBadgeEventResultType, WbInitEventType, WbKeydownEventType, WbNodeData, WbNodeEventType, WbReceiveEventType, WbRenderEventType, WbSelectEventType, WbTreeEventType } from "types";
1069
1103
  /**
1070
1104
  * Available options for {@link wunderbaum.Wunderbaum}.
1071
1105
  *
@@ -1237,11 +1271,30 @@ declare module "wb_options" {
1237
1271
  * Default: false
1238
1272
  */
1239
1273
  fixedCol?: boolean;
1274
+ /**
1275
+ * Default value for ColumnDefinition.filterable option.
1276
+ * Default: false
1277
+ * @since 0.11.0
1278
+ */
1279
+ columnsFilterable?: boolean;
1280
+ /**
1281
+ * Default value for ColumnDefinition.menu option.
1282
+ * Default: false
1283
+ * @since 0.11.0
1284
+ */
1285
+ columnsMenu?: boolean;
1240
1286
  /**
1241
1287
  * Default value for ColumnDefinition.resizable option.
1242
1288
  * Default: false
1289
+ * @since 0.10.0
1290
+ */
1291
+ columnsResizable?: boolean;
1292
+ /**
1293
+ * Default value for ColumnDefinition.sortable option.
1294
+ * Default: false
1295
+ * @since 0.11.0
1243
1296
  */
1244
- resizableColumns?: boolean;
1297
+ columnsSortable?: boolean;
1245
1298
  /**
1246
1299
  * Default: "multi"
1247
1300
  */
@@ -1277,11 +1330,15 @@ declare module "wb_options" {
1277
1330
  */
1278
1331
  beforeExpand?: (e: WbExpandEventType) => WbCancelableEventResultType;
1279
1332
  /**
1280
- *
1281
1333
  * Return `false` to prevent default handling, i.e. (de)selecting the node.
1282
1334
  * @category Callback
1283
1335
  */
1284
1336
  beforeSelect?: (e: WbSelectEventType) => WbCancelableEventResultType;
1337
+ /**
1338
+ * Return `false` to prevent default handling, i.e. (de)selecting the node.
1339
+ * @category Callback
1340
+ */
1341
+ buttonClick?: (e: WbButtonClickEventType) => void;
1285
1342
  /**
1286
1343
  *
1287
1344
  * @category Callback
@@ -1460,11 +1517,20 @@ declare module "types" {
1460
1517
  export type NodeAnyCallback = (node: WunderbaumNode) => any;
1461
1518
  /** A callback that receives a node instance and returns a string value. */
1462
1519
  export type NodeStringCallback = (node: WunderbaumNode) => string;
1520
+ /** A callback that receives a node instance and property name returns a value. */
1521
+ export type NodePropertyGetterCallback = (node: WunderbaumNode, propName: string) => any;
1463
1522
  /** A callback that receives a node instance and returns an iteration modifier. */
1464
1523
  export type NodeVisitCallback = (node: WunderbaumNode) => NodeVisitResponse;
1465
- /** A callback that receives a node instance and returns a string value. */
1524
+ /**
1525
+ * Returned by `NodeVisitCallback` to control iteration.
1526
+ * `false` stops iteration, `skip` skips descendants but continues.
1527
+ * All other values continue iteration.
1528
+ */
1466
1529
  export type NodeVisitResponse = "skip" | boolean | void;
1467
- /** A callback that receives a node-data dictionary and a node instance and returns an iteration modifier. */
1530
+ /**
1531
+ * A callback that receives a node-data dictionary and a node instance and
1532
+ * returns an iteration modifier.
1533
+ */
1468
1534
  export type NodeToDictCallback = (dict: WbNodeData, node: WunderbaumNode) => NodeVisitResponse;
1469
1535
  /** A callback that receives a node instance and returns a string value. */
1470
1536
  export type NodeSelectCallback = (node: WunderbaumNode) => boolean | void;
@@ -1614,6 +1680,11 @@ declare module "types" {
1614
1680
  export interface WbSelectEventType extends WbNodeEventType {
1615
1681
  flag: boolean;
1616
1682
  }
1683
+ export interface WbButtonClickEventType extends WbTreeEventType {
1684
+ info: WbEventInfo;
1685
+ /** The associated command, e.g. 'menu', 'sort', 'filter', ... */
1686
+ command: string;
1687
+ }
1617
1688
  export interface WbRenderEventType extends WbNodeEventType {
1618
1689
  /**
1619
1690
  * True if the node's markup was not yet created. In this case the render
@@ -1695,27 +1766,53 @@ declare module "types" {
1695
1766
  */
1696
1767
  minWidth?: string | number;
1697
1768
  /** Allow user to resize the column.
1698
- * Default: false.
1769
+ * @default false (or global tree option `columnsSortable`)
1770
+ * @see {@link WunderbaumOptions.columnsResizable}.
1771
+ * @since 0.10.0
1699
1772
  */
1700
1773
  resizable?: boolean;
1701
1774
  /** Optional custom column width when user resized by mouse drag.
1702
1775
  * Default: unset.
1703
1776
  */
1704
1777
  customWidthPx?: number;
1705
- /** Allow user to sort the column.
1706
- * Default: false.
1778
+ /** Display a 'filter' button in the column header. Default: false. <br>
1779
+ * Note: The actual filtering must be implemented in the `buttonClick()` event.
1780
+ * @default false (or global tree option `columnsFilterable`)
1781
+ * @since 0.11.0
1782
+ */
1783
+ filterable?: boolean;
1784
+ /** .
1785
+ * Default: inactive. <br>
1786
+ * Note: The actual filtering must be implemented in the `buttonClick()` event.
1787
+ */
1788
+ filterActive?: boolean;
1789
+ /** Display a 'sort' button in the column header. Default: false. <br>
1790
+ * Note: The actual sorting must be implemented in the `buttonClick()` event.
1791
+ * @default false (or global tree option `columnsSortable`)
1792
+ * @see {@link WunderbaumOptions.columnsSortable}.
1793
+ * @since 0.11.0
1707
1794
  */
1708
1795
  sortable?: boolean;
1709
1796
  /** Optional custom column sort orde when user clicked the sort icon.
1710
- * Default: unset.
1797
+ * Default: unset, e.g. not sorted. <br>
1798
+ * Note: The actual sorting must be implemented in the `buttonClick()` event.
1799
+ * @since 0.11.0
1711
1800
  */
1712
1801
  sortOrder?: SortOrderType;
1802
+ /** Display a menu icon that may open a context menu for this column.
1803
+ * Note: The actual functionality must be implemented in the `buttonClick()` event.
1804
+ * @default false (or global tree option `columnsMenu`)
1805
+ * @see {@link WunderbaumOptions.columnsMenu}.
1806
+ * @since 0.11.0
1807
+ */
1808
+ menu?: boolean;
1713
1809
  /** Optional class names that are added to all `span.wb-col` header AND data
1714
- * elements of that column.
1810
+ * elements of that column. Separate multiple classes with space.
1715
1811
  */
1716
1812
  classes?: string;
1717
1813
  /** If `headerClasses` is a set, it will be used for the header element only
1718
1814
  * (unlike `classes`, which is used for body and header cells).
1815
+ * Separate multiple classes with space.
1719
1816
  */
1720
1817
  headerClasses?: string;
1721
1818
  /** Optional HTML content that is rendered into all `span.wb-col` elements of that column.*/
@@ -1777,7 +1874,7 @@ declare module "types" {
1777
1874
  export type NodeFilterResponse = "skip" | "branch" | boolean | void;
1778
1875
  export type NodeFilterCallback = (node: WunderbaumNode) => NodeFilterResponse;
1779
1876
  /**
1780
- * Possible values for {@link WunderbaumNode.update()} and {@link Wunderbaum.update()}.
1877
+ * Possible values for {@link WunderbaumNode.update} and {@link Wunderbaum.update}.
1781
1878
  */
1782
1879
  export enum ChangeType {
1783
1880
  /** Re-render the whole viewport, headers, and all rows. */
@@ -1803,7 +1900,7 @@ declare module "types" {
1803
1900
  redraw = "redraw",
1804
1901
  scroll = "scroll"
1805
1902
  }
1806
- /** Possible values for {@link WunderbaumNode.setStatus()}. */
1903
+ /** Possible values for {@link WunderbaumNode.setStatus}. */
1807
1904
  export enum NodeStatusType {
1808
1905
  ok = "ok",
1809
1906
  loading = "loading",
@@ -1828,7 +1925,7 @@ declare module "types" {
1828
1925
  startCell = "startCell",// Start in cell-nav mode, but allow row mode
1829
1926
  row = "row"
1830
1927
  }
1831
- /** Possible values for {@link WunderbaumNode.addChildren()}. */
1928
+ /** Possible values for {@link WunderbaumNode.addChildren}. */
1832
1929
  export interface AddChildrenOptions {
1833
1930
  /** Insert children before this node (or index)
1834
1931
  * @default undefined or null: append as last child
@@ -1843,11 +1940,11 @@ declare module "types" {
1843
1940
  /** (@internal Internal use, do not set! ) */
1844
1941
  _level?: number;
1845
1942
  }
1846
- /** Possible values for {@link Wunderbaum.applyCommand()} and {@link WunderbaumNode.applyCommand()}. */
1943
+ /** Possible values for {@link Wunderbaum.applyCommand} and {@link WunderbaumNode.applyCommand}. */
1847
1944
  export interface ApplyCommandOptions {
1848
1945
  [key: string]: unknown;
1849
1946
  }
1850
- /** Possible values for {@link Wunderbaum.expandAll()} and {@link WunderbaumNode.expandAll()}. */
1947
+ /** Possible values for {@link Wunderbaum.expandAll} and {@link WunderbaumNode.expandAll}. */
1851
1948
  export interface ExpandAllOptions {
1852
1949
  /** Restrict expand level @default 99 */
1853
1950
  depth?: number;
@@ -1859,7 +1956,7 @@ declare module "types" {
1859
1956
  keepActiveNodeVisible?: boolean;
1860
1957
  }
1861
1958
  /**
1862
- * Possible option values for {@link Wunderbaum.filterNodes()}.
1959
+ * Possible option values for {@link Wunderbaum.filterNodes}.
1863
1960
  * The defaults are inherited from the tree instances ´tree.options.filter`
1864
1961
  * settings (see also {@link FilterOptionsType}).
1865
1962
  */
@@ -1884,7 +1981,7 @@ declare module "types" {
1884
1981
  /** Display a 'no data' status node if result is empty @default true */
1885
1982
  noData?: boolean | string;
1886
1983
  }
1887
- /** Possible values for {@link WunderbaumNode.makeVisible()}. */
1984
+ /** Possible values for {@link WunderbaumNode.makeVisible}. */
1888
1985
  export interface MakeVisibleOptions {
1889
1986
  /** Do not animate expand (currently not implemented). @default false */
1890
1987
  noAnimation?: boolean;
@@ -1893,14 +1990,14 @@ declare module "types" {
1893
1990
  /** Do not send events. @default false */
1894
1991
  noEvents?: boolean;
1895
1992
  }
1896
- /** Possible values for {@link WunderbaumNode.navigate()}. */
1993
+ /** Possible values for {@link WunderbaumNode.navigate}. */
1897
1994
  export interface NavigateOptions {
1898
1995
  /** Activate the new node (otherwise focus only). @default true */
1899
1996
  activate?: boolean;
1900
1997
  /** Originating event (e.g. KeyboardEvent) if any. */
1901
1998
  event?: Event;
1902
1999
  }
1903
- /** Possible values for {@link WunderbaumNode._render()}. */
2000
+ /** Possible values for {@link WunderbaumNode._render}. */
1904
2001
  export interface RenderOptions {
1905
2002
  /** Which parts need update? @default ChangeType.data */
1906
2003
  change?: ChangeType;
@@ -1917,7 +2014,7 @@ declare module "types" {
1917
2014
  /** @internal. @default true */
1918
2015
  resizeCols?: boolean;
1919
2016
  }
1920
- /** Possible values for {@link WunderbaumNode.scrollIntoView()} `options` argument. */
2017
+ /** Possible values for {@link WunderbaumNode.scrollIntoView} `options` argument. */
1921
2018
  export interface ScrollIntoViewOptions {
1922
2019
  /** Do not animate (currently not implemented). @default false */
1923
2020
  noAnimation?: boolean;
@@ -1928,7 +2025,7 @@ declare module "types" {
1928
2025
  /** Add N pixel offset at top. */
1929
2026
  ofsY?: number;
1930
2027
  }
1931
- /** Possible values for {@link Wunderbaum.scrollTo()} `options` argument. */
2028
+ /** Possible values for {@link Wunderbaum.scrollTo} `options` argument. */
1932
2029
  export interface ScrollToOptions extends ScrollIntoViewOptions {
1933
2030
  /** Which node to scroll into the viewport.*/
1934
2031
  node: WunderbaumNode;
@@ -1943,7 +2040,7 @@ declare module "types" {
1943
2040
  focusTree?: boolean;
1944
2041
  /** Optional original event that will be passed to the (de)activate handler. */
1945
2042
  event?: Event;
1946
- /** Also call {@link Wunderbaum.setColumn()}. */
2043
+ /** Also call {@link Wunderbaum.setColumn}. */
1947
2044
  colIdx?: number | string;
1948
2045
  /**
1949
2046
  * Focus embedded input control of the grid cell if any (requires colIdx >= 0).
@@ -1952,7 +2049,7 @@ declare module "types" {
1952
2049
  */
1953
2050
  edit?: boolean;
1954
2051
  }
1955
- /** Possible values for {@link Wunderbaum.setColumn()} `options` argument. */
2052
+ /** Possible values for {@link Wunderbaum.setColumn} `options` argument. */
1956
2053
  export interface SetColumnOptions {
1957
2054
  /**
1958
2055
  * Focus embedded input control of the grid cell if any .
@@ -1976,12 +2073,12 @@ declare module "types" {
1976
2073
  /** Scroll up to bring expanded nodes into viewport. @default false */
1977
2074
  scrollIntoView?: boolean;
1978
2075
  }
1979
- /** Possible values for {@link WunderbaumNode.update()} `options` argument. */
2076
+ /** Possible values for {@link WunderbaumNode.update} `options` argument. */
1980
2077
  export interface UpdateOptions {
1981
2078
  /** Force immediate redraw instead of throttled/async mode. @default false */
1982
2079
  immediate?: boolean;
1983
2080
  }
1984
- /** Possible values for {@link WunderbaumNode.setSelected()} `options` argument. */
2081
+ /** Possible values for {@link WunderbaumNode.setSelected} `options` argument. */
1985
2082
  export interface SetSelectedOptions {
1986
2083
  /** Ignore restrictions, e.g. (`unselectable`). @default false */
1987
2084
  force?: boolean;
@@ -1992,14 +2089,58 @@ declare module "types" {
1992
2089
  /** Called for every node. May return false to prevent action. @default null */
1993
2090
  callback?: NodeSelectCallback;
1994
2091
  }
1995
- /** Possible values for {@link WunderbaumNode.setStatus()} `options` argument. */
2092
+ /** Possible values for {@link WunderbaumNode.setStatus} `options` argument. */
1996
2093
  export interface SetStatusOptions {
1997
2094
  /** Displayed as status node title. */
1998
2095
  message?: string;
1999
2096
  /** Used as tooltip. */
2000
2097
  details?: string;
2001
2098
  }
2002
- /** Options passed to {@link Wunderbaum.visitRows()}. */
2099
+ /**
2100
+ * Possible values for {@link WunderbaumNode.sortByProperty} `options` argument.
2101
+ */
2102
+ export interface ResetOrderOptions {
2103
+ /** Sort descendants recursively. @default true */
2104
+ recursive?: boolean;
2105
+ /** The name of the node property that will be renumbered.
2106
+ * @default `_nativeIndex`.
2107
+ */
2108
+ propName?: string;
2109
+ }
2110
+ /**
2111
+ * Possible values for {@link WunderbaumNode.sortByProperty} `options` argument.
2112
+ */
2113
+ export interface SortByPropertyOptions {
2114
+ /** Column ID as defined in `tree.columns` definition. Required if updateColInfo is true.*/
2115
+ colId?: string;
2116
+ /** The name of the node property that will be used for sorting.
2117
+ * @default use the `colId` as property name.
2118
+ */
2119
+ propName?: string;
2120
+ /** Sort order. @default Use value from column definition (rotated).*/
2121
+ order?: SortOrderType;
2122
+ /**
2123
+ * Sort by this property if order is `undefined`.
2124
+ * See also {@link WunderbaumNode.resetNativeChildOrder}.
2125
+ * @default `_nativeIndex`.
2126
+ */
2127
+ nativeOrderPropName?: string;
2128
+ /** Sort string values case insensitive. @default false */
2129
+ caseInsensitive?: boolean;
2130
+ /** Sort descendants recursively. @default true */
2131
+ deep?: boolean;
2132
+ /**
2133
+ * Rotate sort order (asc -> desc -> none) before sorting.
2134
+ * Update the sort icons in the column header
2135
+ * Note:
2136
+ * Sorting is done in-place. There is no 'unsorted' state, but we can
2137
+ * call `setCurrentSortOrder()` to renumber the `node._sortIdx` property,
2138
+ * which will be used as sort key, when `order` is `undefined`.
2139
+ * @default false
2140
+ */
2141
+ updateColInfo?: boolean;
2142
+ }
2143
+ /** Options passed to {@link Wunderbaum.visitRows}. */
2003
2144
  export interface VisitRowsOptions {
2004
2145
  /** Skip filtered nodes and children of collapsed nodes. @default false */
2005
2146
  includeHidden?: boolean;
@@ -2205,7 +2346,7 @@ declare module "types" {
2205
2346
  */
2206
2347
  scrollSpeed?: 5;
2207
2348
  /**
2208
- * Optional callback passed to `toDict` on dragStart @since 2.38
2349
+ * Optional callback passed to `toDict` on dragStart
2209
2350
  * @default null
2210
2351
  * @category Callback
2211
2352
  */
@@ -2546,7 +2687,7 @@ declare module "wunderbaum" {
2546
2687
  */
2547
2688
  import * as util from "util";
2548
2689
  import { ExtensionsDict, WunderbaumExtension } from "wb_extension_base";
2549
- import { AddChildrenOptions, ApplyCommandOptions, ApplyCommandType, ChangeType, ColumnDefinitionList, DynamicBoolOption, DynamicCheckboxOption, DynamicIconOption, DynamicStringOption, DynamicTooltipOption, ExpandAllOptions, FilterModeType, FilterNodesOptions, MatcherCallback, NavModeEnum, NodeFilterCallback, NodeStatusType, NodeStringCallback, NodeToDictCallback, NodeTypeDefinitionMap, NodeVisitCallback, RenderFlag, ScrollToOptions, SetActiveOptions, SetColumnOptions, SetStatusOptions, SortCallback, SourceType, UpdateOptions, VisitRowsOptions, WbEventInfo, WbNodeData } from "types";
2690
+ import { AddChildrenOptions, ApplyCommandOptions, ApplyCommandType, ChangeType, ColumnDefinitionList, DynamicBoolOption, DynamicCheckboxOption, DynamicIconOption, DynamicStringOption, DynamicTooltipOption, ExpandAllOptions, FilterModeType, FilterNodesOptions, MatcherCallback, NavModeEnum, NodeFilterCallback, NodeStatusType, NodeStringCallback, NodeToDictCallback, NodeTypeDefinitionMap, NodeVisitCallback, RenderFlag, ScrollToOptions, SetActiveOptions, SetColumnOptions, SetStatusOptions, SortByPropertyOptions, SortCallback, SourceType, UpdateOptions, VisitRowsOptions, WbEventInfo, WbNodeData } from "types";
2550
2691
  import { WunderbaumNode } from "wb_node";
2551
2692
  import { WunderbaumOptions } from "wb_options";
2552
2693
  import { DebouncedFunction } from "debounce";
@@ -2755,7 +2896,7 @@ declare module "wunderbaum" {
2755
2896
  hasHeader(): boolean;
2756
2897
  /** Run code, but defer rendering of viewport until done.
2757
2898
  *
2758
- * ```
2899
+ * ```js
2759
2900
  * tree.runWithDeferredUpdate(() => {
2760
2901
  * return someFuncThatWouldUpdateManyNodes();
2761
2902
  * });
@@ -2926,7 +3067,7 @@ declare module "wunderbaum" {
2926
3067
  logTimeEnd(label: string): void;
2927
3068
  /** Write to `console.warn` with tree name as prefix with if opts.debugLevel >= 2. */
2928
3069
  logWarn(...args: any[]): void;
2929
- /** Reset column widths to default. */
3070
+ /** Reset column widths to default. @since 0.10.0 */
2930
3071
  resetColumns(): void;
2931
3072
  /**
2932
3073
  * Make sure that this node is vertically scrolled into the viewport.
@@ -2962,14 +3103,14 @@ declare module "wunderbaum" {
2962
3103
  * The render operation is async and debounced unless the `immediate` option
2963
3104
  * is set.
2964
3105
  *
2965
- * Use {@link WunderbaumNode.update()} if only a single node has changed,
2966
- * or {@link WunderbaumNode._render()}) to pass special options.
3106
+ * Use {@link WunderbaumNode.update} if only a single node has changed,
3107
+ * or {@link WunderbaumNode._render}) to pass special options.
2967
3108
  */
2968
3109
  update(change: ChangeType, options?: UpdateOptions): void;
2969
3110
  /**
2970
3111
  * Update a row to reflect a single node's modification.
2971
3112
  *
2972
- * @see {@link WunderbaumNode.update()}, {@link WunderbaumNode._render()}
3113
+ * @see {@link WunderbaumNode.update}, {@link WunderbaumNode._render}
2973
3114
  */
2974
3115
  update(change: ChangeType, node: WunderbaumNode, options?: UpdateOptions): void;
2975
3116
  /** Disable mouse and keyboard interaction (return prev. state). */
@@ -2997,6 +3138,12 @@ declare module "wunderbaum" {
2997
3138
  * @param {boolean} deep pass true to sort all descendant nodes recursively
2998
3139
  */
2999
3140
  sortChildren(cmp?: SortCallback | null, deep?: boolean): void;
3141
+ /**
3142
+ * Convenience method to implement column sorting.
3143
+ * @see {@link WunderbaumNode.sortByProperty}.
3144
+ * @since 0.11.0
3145
+ */
3146
+ sortByProperty(options: SortByPropertyOptions): void;
3000
3147
  /** Convert tree to an array of plain objects.
3001
3148
  *
3002
3149
  * @param callback is called for every node, in order to allow
@@ -3011,6 +3158,7 @@ declare module "wunderbaum" {
3011
3158
  * Return true if at least one column width changed.
3012
3159
  */
3013
3160
  _updateColumnWidths(): boolean;
3161
+ protected _insertIcon(icon: string, elem: HTMLElement): void;
3014
3162
  /** Create/update header markup from `this.columns` definition.
3015
3163
  * @internal
3016
3164
  */
@@ -3103,6 +3251,7 @@ declare module "wunderbaum" {
3103
3251
  /**
3104
3252
  * Return the number of nodes that match the current filter.
3105
3253
  * @see {@link Wunderbaum.filterNodes}
3254
+ * @since 0.9.0
3106
3255
  */
3107
3256
  countMatches(): number;
3108
3257
  /**