wunderbaum 0.10.1 → 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/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.
@@ -210,6 +210,14 @@ div.wunderbaum div.wb-header span.wb-col-resizer {
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;
@@ -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;EAC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ACE;;AASJ;EACE;;AAEA;EACE;;AAGF;EACE;;AAMJ;EACE;;AAaJ;EACE;;AAEA;EACE;;AAIJ;EACE;;AAEA;EACE;EACA;;AAGA;EACE;EACA;;AAEA;EAGE;EACA;EAGA;EACA;EACA;;AAgBR;AAAA;EAIE;EACA;EACA;;AAKF;EACE;;AAUE;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"}
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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EACE;;AAEA;EACE;;AAON;EACE;;AAEA;EACE;;AAQJ;EACE;;AASJ;EACE;;AAEA;EACE;;AAGF;EACE;;AAMJ;EACE;;AAaJ;EACE;;AAEA;EACE;;AAIJ;EACE;;AAEA;EACE;EACA;;AAGA;EACE;EACA;;AAEA;EAGE;EACA;EAGA;EACA;EACA;;AAgBR;AAAA;EAIE;EACA;EACA;;AAKF;EACE;;AAUE;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"}
@@ -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.
@@ -466,7 +468,7 @@ declare module "common" {
466
468
  };
467
469
  /** Return a callback that returns true if the node title matches the string
468
470
  * or regular expression.
469
- * @see {@link WunderbaumNode.findAll()}
471
+ * @see {@link WunderbaumNode.findAll}
470
472
  */
471
473
  export function makeNodeTitleMatcher(match: string | RegExp): MatcherCallback;
472
474
  /** Return a callback that returns true if the node title starts with a string (case-insensitive). */
@@ -528,7 +530,7 @@ declare module "deferred" {
528
530
  }
529
531
  declare module "wb_node" {
530
532
  import { Wunderbaum } from "wunderbaum";
531
- 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";
532
534
  /**
533
535
  * A single tree node.
534
536
  *
@@ -553,12 +555,26 @@ declare module "wb_node" {
553
555
  * @see Use {@link setKey} to modify.
554
556
  */
555
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
+ */
556
564
  children: WunderbaumNode[] | null;
565
+ /** Render a checkbox or radio button @see {@link selected}. */
557
566
  checkbox?: CheckboxOption;
567
+ /** If true, this node's children are considerd radio buttons.
568
+ * @see {@link isRadio}.
569
+ */
558
570
  radiogroup?: boolean;
559
571
  /** If true, (in grid mode) no cells are rendered, except for the node title.*/
560
572
  colspan?: boolean;
573
+ /** Icon definition. */
561
574
  icon?: IconOption;
575
+ /** Lazy loading flag.
576
+ * @see {@link isLazy}, {@link isLoaded}, {@link isUnloaded}.
577
+ */
562
578
  lazy?: boolean;
563
579
  /** Expansion state.
564
580
  * @see {@link isExpandable}, {@link isExpanded}, {@link setExpanded}. */
@@ -567,7 +583,11 @@ declare module "wb_node" {
567
583
  * @see {@link isSelected}, {@link setSelected}, {@link toggleSelected}. */
568
584
  selected?: boolean;
569
585
  unselectable?: boolean;
586
+ /** Node type (used for styling).
587
+ * @see {@link Wunderbaum.types}.
588
+ */
570
589
  type?: string;
590
+ /** Tooltip definition (`true`: use node's title). */
571
591
  tooltip?: string | boolean;
572
592
  /** Additional classes added to `div.wb-row`.
573
593
  * @see {@link hasClass}, {@link setClass}. */
@@ -757,7 +777,7 @@ declare module "wb_node" {
757
777
  hasChildren(): boolean;
758
778
  /** Return true if node has className set. */
759
779
  hasClass(className: string): boolean;
760
- /** Return true if node ist the currently focused node. */
780
+ /** Return true if node ist the currently focused node. @since 0.9.0 */
761
781
  hasFocus(): boolean;
762
782
  /** Return true if this node is the currently active tree node. */
763
783
  isActive(): boolean;
@@ -939,11 +959,11 @@ declare module "wb_node" {
939
959
  *
940
960
  * @param name name of the option property (on node and tree)
941
961
  * @param defaultValue return this if nothing else matched
942
- * {@link Wunderbaum.getOption|Wunderbaum.getOption()}
962
+ * {@link Wunderbaum.getOption|Wunderbaum.getOption}
943
963
  */
944
964
  getOption(name: string, defaultValue?: any): any;
945
965
  /** Make sure that this node is visible in the viewport.
946
- * @see {@link Wunderbaum.scrollTo|Wunderbaum.scrollTo()}
966
+ * @see {@link Wunderbaum.scrollTo|Wunderbaum.scrollTo}
947
967
  */
948
968
  scrollIntoView(options?: ScrollIntoViewOptions): Promise<void>;
949
969
  /**
@@ -971,9 +991,9 @@ declare module "wb_node" {
971
991
  * and column content. It can be reduced to 'ChangeType.status' if only
972
992
  * active/focus/selected state has changed.
973
993
  *
974
- * This method will eventually call {@link WunderbaumNode._render()} with
994
+ * This method will eventually call {@link WunderbaumNode._render} with
975
995
  * default options, but may be more consistent with the tree's
976
- * {@link Wunderbaum.update()} API.
996
+ * {@link Wunderbaum.update} API.
977
997
  */
978
998
  update(change?: ChangeType): void;
979
999
  /**
@@ -1014,6 +1034,18 @@ declare module "wb_node" {
1014
1034
  * @param {boolean} deep pass true to sort all descendant nodes recursively
1015
1035
  */
1016
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;
1017
1049
  /**
1018
1050
  * Trigger `modifyChild` event on a parent to signal that a child was modified.
1019
1051
  * @param {string} operation Type of change: 'add', 'remove', 'rename', 'move', 'data', ...
@@ -1067,7 +1099,7 @@ declare module "wb_options" {
1067
1099
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1068
1100
  * @VERSION, @DATE (https://github.com/mar10/wunderbaum)
1069
1101
  */
1070
- 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";
1071
1103
  /**
1072
1104
  * Available options for {@link wunderbaum.Wunderbaum}.
1073
1105
  *
@@ -1239,11 +1271,30 @@ declare module "wb_options" {
1239
1271
  * Default: false
1240
1272
  */
1241
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;
1242
1286
  /**
1243
1287
  * Default value for ColumnDefinition.resizable option.
1244
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
1245
1296
  */
1246
- resizableColumns?: boolean;
1297
+ columnsSortable?: boolean;
1247
1298
  /**
1248
1299
  * Default: "multi"
1249
1300
  */
@@ -1279,11 +1330,15 @@ declare module "wb_options" {
1279
1330
  */
1280
1331
  beforeExpand?: (e: WbExpandEventType) => WbCancelableEventResultType;
1281
1332
  /**
1282
- *
1283
1333
  * Return `false` to prevent default handling, i.e. (de)selecting the node.
1284
1334
  * @category Callback
1285
1335
  */
1286
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;
1287
1342
  /**
1288
1343
  *
1289
1344
  * @category Callback
@@ -1462,11 +1517,20 @@ declare module "types" {
1462
1517
  export type NodeAnyCallback = (node: WunderbaumNode) => any;
1463
1518
  /** A callback that receives a node instance and returns a string value. */
1464
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;
1465
1522
  /** A callback that receives a node instance and returns an iteration modifier. */
1466
1523
  export type NodeVisitCallback = (node: WunderbaumNode) => NodeVisitResponse;
1467
- /** 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
+ */
1468
1529
  export type NodeVisitResponse = "skip" | boolean | void;
1469
- /** 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
+ */
1470
1534
  export type NodeToDictCallback = (dict: WbNodeData, node: WunderbaumNode) => NodeVisitResponse;
1471
1535
  /** A callback that receives a node instance and returns a string value. */
1472
1536
  export type NodeSelectCallback = (node: WunderbaumNode) => boolean | void;
@@ -1616,6 +1680,11 @@ declare module "types" {
1616
1680
  export interface WbSelectEventType extends WbNodeEventType {
1617
1681
  flag: boolean;
1618
1682
  }
1683
+ export interface WbButtonClickEventType extends WbTreeEventType {
1684
+ info: WbEventInfo;
1685
+ /** The associated command, e.g. 'menu', 'sort', 'filter', ... */
1686
+ command: string;
1687
+ }
1619
1688
  export interface WbRenderEventType extends WbNodeEventType {
1620
1689
  /**
1621
1690
  * True if the node's markup was not yet created. In this case the render
@@ -1697,28 +1766,53 @@ declare module "types" {
1697
1766
  */
1698
1767
  minWidth?: string | number;
1699
1768
  /** Allow user to resize the column.
1700
- * Default: false.
1769
+ * @default false (or global tree option `columnsSortable`)
1770
+ * @see {@link WunderbaumOptions.columnsResizable}.
1771
+ * @since 0.10.0
1701
1772
  */
1702
1773
  resizable?: boolean;
1703
1774
  /** Optional custom column width when user resized by mouse drag.
1704
1775
  * Default: unset.
1705
1776
  */
1706
1777
  customWidthPx?: number;
1707
- /** Allow user to sort the column. Default: false. <br>
1708
- * **Note:** Sorting is not implemented yet.
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
1709
1794
  */
1710
1795
  sortable?: boolean;
1711
1796
  /** Optional custom column sort orde when user clicked the sort icon.
1712
- * Default: unset. <br>
1713
- * **Note:** Sorting is not implemented yet.
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
1714
1800
  */
1715
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;
1716
1809
  /** Optional class names that are added to all `span.wb-col` header AND data
1717
- * elements of that column.
1810
+ * elements of that column. Separate multiple classes with space.
1718
1811
  */
1719
1812
  classes?: string;
1720
1813
  /** If `headerClasses` is a set, it will be used for the header element only
1721
1814
  * (unlike `classes`, which is used for body and header cells).
1815
+ * Separate multiple classes with space.
1722
1816
  */
1723
1817
  headerClasses?: string;
1724
1818
  /** Optional HTML content that is rendered into all `span.wb-col` elements of that column.*/
@@ -1780,7 +1874,7 @@ declare module "types" {
1780
1874
  export type NodeFilterResponse = "skip" | "branch" | boolean | void;
1781
1875
  export type NodeFilterCallback = (node: WunderbaumNode) => NodeFilterResponse;
1782
1876
  /**
1783
- * Possible values for {@link WunderbaumNode.update()} and {@link Wunderbaum.update()}.
1877
+ * Possible values for {@link WunderbaumNode.update} and {@link Wunderbaum.update}.
1784
1878
  */
1785
1879
  export enum ChangeType {
1786
1880
  /** Re-render the whole viewport, headers, and all rows. */
@@ -1806,7 +1900,7 @@ declare module "types" {
1806
1900
  redraw = "redraw",
1807
1901
  scroll = "scroll"
1808
1902
  }
1809
- /** Possible values for {@link WunderbaumNode.setStatus()}. */
1903
+ /** Possible values for {@link WunderbaumNode.setStatus}. */
1810
1904
  export enum NodeStatusType {
1811
1905
  ok = "ok",
1812
1906
  loading = "loading",
@@ -1831,7 +1925,7 @@ declare module "types" {
1831
1925
  startCell = "startCell",// Start in cell-nav mode, but allow row mode
1832
1926
  row = "row"
1833
1927
  }
1834
- /** Possible values for {@link WunderbaumNode.addChildren()}. */
1928
+ /** Possible values for {@link WunderbaumNode.addChildren}. */
1835
1929
  export interface AddChildrenOptions {
1836
1930
  /** Insert children before this node (or index)
1837
1931
  * @default undefined or null: append as last child
@@ -1846,11 +1940,11 @@ declare module "types" {
1846
1940
  /** (@internal Internal use, do not set! ) */
1847
1941
  _level?: number;
1848
1942
  }
1849
- /** Possible values for {@link Wunderbaum.applyCommand()} and {@link WunderbaumNode.applyCommand()}. */
1943
+ /** Possible values for {@link Wunderbaum.applyCommand} and {@link WunderbaumNode.applyCommand}. */
1850
1944
  export interface ApplyCommandOptions {
1851
1945
  [key: string]: unknown;
1852
1946
  }
1853
- /** Possible values for {@link Wunderbaum.expandAll()} and {@link WunderbaumNode.expandAll()}. */
1947
+ /** Possible values for {@link Wunderbaum.expandAll} and {@link WunderbaumNode.expandAll}. */
1854
1948
  export interface ExpandAllOptions {
1855
1949
  /** Restrict expand level @default 99 */
1856
1950
  depth?: number;
@@ -1862,7 +1956,7 @@ declare module "types" {
1862
1956
  keepActiveNodeVisible?: boolean;
1863
1957
  }
1864
1958
  /**
1865
- * Possible option values for {@link Wunderbaum.filterNodes()}.
1959
+ * Possible option values for {@link Wunderbaum.filterNodes}.
1866
1960
  * The defaults are inherited from the tree instances ´tree.options.filter`
1867
1961
  * settings (see also {@link FilterOptionsType}).
1868
1962
  */
@@ -1887,7 +1981,7 @@ declare module "types" {
1887
1981
  /** Display a 'no data' status node if result is empty @default true */
1888
1982
  noData?: boolean | string;
1889
1983
  }
1890
- /** Possible values for {@link WunderbaumNode.makeVisible()}. */
1984
+ /** Possible values for {@link WunderbaumNode.makeVisible}. */
1891
1985
  export interface MakeVisibleOptions {
1892
1986
  /** Do not animate expand (currently not implemented). @default false */
1893
1987
  noAnimation?: boolean;
@@ -1896,14 +1990,14 @@ declare module "types" {
1896
1990
  /** Do not send events. @default false */
1897
1991
  noEvents?: boolean;
1898
1992
  }
1899
- /** Possible values for {@link WunderbaumNode.navigate()}. */
1993
+ /** Possible values for {@link WunderbaumNode.navigate}. */
1900
1994
  export interface NavigateOptions {
1901
1995
  /** Activate the new node (otherwise focus only). @default true */
1902
1996
  activate?: boolean;
1903
1997
  /** Originating event (e.g. KeyboardEvent) if any. */
1904
1998
  event?: Event;
1905
1999
  }
1906
- /** Possible values for {@link WunderbaumNode._render()}. */
2000
+ /** Possible values for {@link WunderbaumNode._render}. */
1907
2001
  export interface RenderOptions {
1908
2002
  /** Which parts need update? @default ChangeType.data */
1909
2003
  change?: ChangeType;
@@ -1920,7 +2014,7 @@ declare module "types" {
1920
2014
  /** @internal. @default true */
1921
2015
  resizeCols?: boolean;
1922
2016
  }
1923
- /** Possible values for {@link WunderbaumNode.scrollIntoView()} `options` argument. */
2017
+ /** Possible values for {@link WunderbaumNode.scrollIntoView} `options` argument. */
1924
2018
  export interface ScrollIntoViewOptions {
1925
2019
  /** Do not animate (currently not implemented). @default false */
1926
2020
  noAnimation?: boolean;
@@ -1931,7 +2025,7 @@ declare module "types" {
1931
2025
  /** Add N pixel offset at top. */
1932
2026
  ofsY?: number;
1933
2027
  }
1934
- /** Possible values for {@link Wunderbaum.scrollTo()} `options` argument. */
2028
+ /** Possible values for {@link Wunderbaum.scrollTo} `options` argument. */
1935
2029
  export interface ScrollToOptions extends ScrollIntoViewOptions {
1936
2030
  /** Which node to scroll into the viewport.*/
1937
2031
  node: WunderbaumNode;
@@ -1946,7 +2040,7 @@ declare module "types" {
1946
2040
  focusTree?: boolean;
1947
2041
  /** Optional original event that will be passed to the (de)activate handler. */
1948
2042
  event?: Event;
1949
- /** Also call {@link Wunderbaum.setColumn()}. */
2043
+ /** Also call {@link Wunderbaum.setColumn}. */
1950
2044
  colIdx?: number | string;
1951
2045
  /**
1952
2046
  * Focus embedded input control of the grid cell if any (requires colIdx >= 0).
@@ -1955,7 +2049,7 @@ declare module "types" {
1955
2049
  */
1956
2050
  edit?: boolean;
1957
2051
  }
1958
- /** Possible values for {@link Wunderbaum.setColumn()} `options` argument. */
2052
+ /** Possible values for {@link Wunderbaum.setColumn} `options` argument. */
1959
2053
  export interface SetColumnOptions {
1960
2054
  /**
1961
2055
  * Focus embedded input control of the grid cell if any .
@@ -1979,12 +2073,12 @@ declare module "types" {
1979
2073
  /** Scroll up to bring expanded nodes into viewport. @default false */
1980
2074
  scrollIntoView?: boolean;
1981
2075
  }
1982
- /** Possible values for {@link WunderbaumNode.update()} `options` argument. */
2076
+ /** Possible values for {@link WunderbaumNode.update} `options` argument. */
1983
2077
  export interface UpdateOptions {
1984
2078
  /** Force immediate redraw instead of throttled/async mode. @default false */
1985
2079
  immediate?: boolean;
1986
2080
  }
1987
- /** Possible values for {@link WunderbaumNode.setSelected()} `options` argument. */
2081
+ /** Possible values for {@link WunderbaumNode.setSelected} `options` argument. */
1988
2082
  export interface SetSelectedOptions {
1989
2083
  /** Ignore restrictions, e.g. (`unselectable`). @default false */
1990
2084
  force?: boolean;
@@ -1995,14 +2089,58 @@ declare module "types" {
1995
2089
  /** Called for every node. May return false to prevent action. @default null */
1996
2090
  callback?: NodeSelectCallback;
1997
2091
  }
1998
- /** Possible values for {@link WunderbaumNode.setStatus()} `options` argument. */
2092
+ /** Possible values for {@link WunderbaumNode.setStatus} `options` argument. */
1999
2093
  export interface SetStatusOptions {
2000
2094
  /** Displayed as status node title. */
2001
2095
  message?: string;
2002
2096
  /** Used as tooltip. */
2003
2097
  details?: string;
2004
2098
  }
2005
- /** 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}. */
2006
2144
  export interface VisitRowsOptions {
2007
2145
  /** Skip filtered nodes and children of collapsed nodes. @default false */
2008
2146
  includeHidden?: boolean;
@@ -2208,7 +2346,7 @@ declare module "types" {
2208
2346
  */
2209
2347
  scrollSpeed?: 5;
2210
2348
  /**
2211
- * Optional callback passed to `toDict` on dragStart @since 2.38
2349
+ * Optional callback passed to `toDict` on dragStart
2212
2350
  * @default null
2213
2351
  * @category Callback
2214
2352
  */
@@ -2549,7 +2687,7 @@ declare module "wunderbaum" {
2549
2687
  */
2550
2688
  import * as util from "util";
2551
2689
  import { ExtensionsDict, WunderbaumExtension } from "wb_extension_base";
2552
- 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";
2553
2691
  import { WunderbaumNode } from "wb_node";
2554
2692
  import { WunderbaumOptions } from "wb_options";
2555
2693
  import { DebouncedFunction } from "debounce";
@@ -2758,7 +2896,7 @@ declare module "wunderbaum" {
2758
2896
  hasHeader(): boolean;
2759
2897
  /** Run code, but defer rendering of viewport until done.
2760
2898
  *
2761
- * ```
2899
+ * ```js
2762
2900
  * tree.runWithDeferredUpdate(() => {
2763
2901
  * return someFuncThatWouldUpdateManyNodes();
2764
2902
  * });
@@ -2929,7 +3067,7 @@ declare module "wunderbaum" {
2929
3067
  logTimeEnd(label: string): void;
2930
3068
  /** Write to `console.warn` with tree name as prefix with if opts.debugLevel >= 2. */
2931
3069
  logWarn(...args: any[]): void;
2932
- /** Reset column widths to default. */
3070
+ /** Reset column widths to default. @since 0.10.0 */
2933
3071
  resetColumns(): void;
2934
3072
  /**
2935
3073
  * Make sure that this node is vertically scrolled into the viewport.
@@ -2965,14 +3103,14 @@ declare module "wunderbaum" {
2965
3103
  * The render operation is async and debounced unless the `immediate` option
2966
3104
  * is set.
2967
3105
  *
2968
- * Use {@link WunderbaumNode.update()} if only a single node has changed,
2969
- * 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.
2970
3108
  */
2971
3109
  update(change: ChangeType, options?: UpdateOptions): void;
2972
3110
  /**
2973
3111
  * Update a row to reflect a single node's modification.
2974
3112
  *
2975
- * @see {@link WunderbaumNode.update()}, {@link WunderbaumNode._render()}
3113
+ * @see {@link WunderbaumNode.update}, {@link WunderbaumNode._render}
2976
3114
  */
2977
3115
  update(change: ChangeType, node: WunderbaumNode, options?: UpdateOptions): void;
2978
3116
  /** Disable mouse and keyboard interaction (return prev. state). */
@@ -3000,6 +3138,12 @@ declare module "wunderbaum" {
3000
3138
  * @param {boolean} deep pass true to sort all descendant nodes recursively
3001
3139
  */
3002
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;
3003
3147
  /** Convert tree to an array of plain objects.
3004
3148
  *
3005
3149
  * @param callback is called for every node, in order to allow
@@ -3014,6 +3158,7 @@ declare module "wunderbaum" {
3014
3158
  * Return true if at least one column width changed.
3015
3159
  */
3016
3160
  _updateColumnWidths(): boolean;
3161
+ protected _insertIcon(icon: string, elem: HTMLElement): void;
3017
3162
  /** Create/update header markup from `this.columns` definition.
3018
3163
  * @internal
3019
3164
  */
@@ -3106,6 +3251,7 @@ declare module "wunderbaum" {
3106
3251
  /**
3107
3252
  * Return the number of nodes that match the current filter.
3108
3253
  * @see {@link Wunderbaum.filterNodes}
3254
+ * @since 0.9.0
3109
3255
  */
3110
3256
  countMatches(): number;
3111
3257
  /**