wunderbaum 0.10.1 → 0.11.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.
- package/README.md +6 -7
- package/dist/wunderbaum.css +18 -10
- package/dist/wunderbaum.css.map +1 -1
- package/dist/wunderbaum.d.ts +204 -49
- package/dist/wunderbaum.esm.js +826 -606
- package/dist/wunderbaum.esm.min.js +26 -26
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +826 -606
- package/dist/wunderbaum.umd.min.js +32 -32
- package/dist/wunderbaum.umd.min.js.map +1 -1
- package/package.json +11 -10
- package/src/common.ts +17 -2
- package/src/types.ts +126 -30
- package/src/util.ts +18 -8
- package/src/wb_ext_dnd.ts +9 -4
- package/src/wb_ext_edit.ts +4 -0
- package/src/wb_ext_grid.ts +1 -1
- package/src/wb_node.ts +164 -17
- package/src/wb_options.ts +26 -2
- package/src/wunderbaum.scss +10 -0
- package/src/wunderbaum.ts +124 -47
package/dist/wunderbaum.d.ts
CHANGED
|
@@ -293,7 +293,7 @@ declare module "util" {
|
|
|
293
293
|
*/
|
|
294
294
|
export function extend(...args: any[]): any;
|
|
295
295
|
/** Return true if `obj` is of type `array`. */
|
|
296
|
-
export function isArray(obj: any):
|
|
296
|
+
export function isArray(obj: any): obj is any[];
|
|
297
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`. */
|
|
@@ -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.
|
|
@@ -394,6 +396,13 @@ declare module "util" {
|
|
|
394
396
|
* ```
|
|
395
397
|
*/
|
|
396
398
|
export function toBool(...boolDefaults: (boolean | undefined | null)[]): boolean;
|
|
399
|
+
/**
|
|
400
|
+
* Return `val` unless `val` is a number in which case we convert to boolean.
|
|
401
|
+
* This is useful when a boolean value is stored as a 0/1 (e.g. in JSON) and
|
|
402
|
+
* we still want to maintain string values. null and undefined are returned as
|
|
403
|
+
* is. E.g. `checkbox` may be boolean or 'radio'.
|
|
404
|
+
*/
|
|
405
|
+
export function intToBool(val: boolean | number | string | undefined): boolean | string | undefined;
|
|
397
406
|
/** Return a canonical string representation for an object's type (e.g. 'array', 'number', ...). */
|
|
398
407
|
export function type(obj: any): string;
|
|
399
408
|
/**
|
|
@@ -422,7 +431,7 @@ declare module "common" {
|
|
|
422
431
|
/**
|
|
423
432
|
* Fixed height of a row in pixel. Must match the SCSS variable `$row-outer-height`.
|
|
424
433
|
*/
|
|
425
|
-
export const
|
|
434
|
+
export const DEFAULT_ROW_HEIGHT = 22;
|
|
426
435
|
/**
|
|
427
436
|
* Fixed width of node icons in pixel. Must match the SCSS variable `$icon-outer-width`.
|
|
428
437
|
*/
|
|
@@ -466,7 +475,7 @@ declare module "common" {
|
|
|
466
475
|
};
|
|
467
476
|
/** Return a callback that returns true if the node title matches the string
|
|
468
477
|
* or regular expression.
|
|
469
|
-
* @see {@link WunderbaumNode.findAll
|
|
478
|
+
* @see {@link WunderbaumNode.findAll}
|
|
470
479
|
*/
|
|
471
480
|
export function makeNodeTitleMatcher(match: string | RegExp): MatcherCallback;
|
|
472
481
|
/** Return a callback that returns true if the node title starts with a string (case-insensitive). */
|
|
@@ -528,7 +537,7 @@ declare module "deferred" {
|
|
|
528
537
|
}
|
|
529
538
|
declare module "wb_node" {
|
|
530
539
|
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";
|
|
540
|
+
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
541
|
/**
|
|
533
542
|
* A single tree node.
|
|
534
543
|
*
|
|
@@ -553,12 +562,26 @@ declare module "wb_node" {
|
|
|
553
562
|
* @see Use {@link setKey} to modify.
|
|
554
563
|
*/
|
|
555
564
|
readonly refKey: string | undefined;
|
|
565
|
+
/**
|
|
566
|
+
* Array of child nodes (null for leaf nodes).
|
|
567
|
+
* For lazy nodes, this is `null` or ùndefined` until the children are loaded
|
|
568
|
+
* and leaf nodes may be `[]` (empty array).
|
|
569
|
+
* @see {@link hasChildren}, {@link addChildren}, {@link lazy}.
|
|
570
|
+
*/
|
|
556
571
|
children: WunderbaumNode[] | null;
|
|
572
|
+
/** Render a checkbox or radio button @see {@link selected}. */
|
|
557
573
|
checkbox?: CheckboxOption;
|
|
574
|
+
/** If true, this node's children are considerd radio buttons.
|
|
575
|
+
* @see {@link isRadio}.
|
|
576
|
+
*/
|
|
558
577
|
radiogroup?: boolean;
|
|
559
578
|
/** If true, (in grid mode) no cells are rendered, except for the node title.*/
|
|
560
579
|
colspan?: boolean;
|
|
580
|
+
/** Icon definition. */
|
|
561
581
|
icon?: IconOption;
|
|
582
|
+
/** Lazy loading flag.
|
|
583
|
+
* @see {@link isLazy}, {@link isLoaded}, {@link isUnloaded}.
|
|
584
|
+
*/
|
|
562
585
|
lazy?: boolean;
|
|
563
586
|
/** Expansion state.
|
|
564
587
|
* @see {@link isExpandable}, {@link isExpanded}, {@link setExpanded}. */
|
|
@@ -567,8 +590,14 @@ declare module "wb_node" {
|
|
|
567
590
|
* @see {@link isSelected}, {@link setSelected}, {@link toggleSelected}. */
|
|
568
591
|
selected?: boolean;
|
|
569
592
|
unselectable?: boolean;
|
|
593
|
+
/** Node type (used for styling).
|
|
594
|
+
* @see {@link Wunderbaum.types}.
|
|
595
|
+
*/
|
|
570
596
|
type?: string;
|
|
571
|
-
|
|
597
|
+
/** Tooltip definition (`true`: use node's title). */
|
|
598
|
+
tooltip?: TooltipOption;
|
|
599
|
+
/** Icon tooltip definition (`true`: use node's title). */
|
|
600
|
+
iconTooltip?: TooltipOption;
|
|
572
601
|
/** Additional classes added to `div.wb-row`.
|
|
573
602
|
* @see {@link hasClass}, {@link setClass}. */
|
|
574
603
|
classes: Set<string> | null;
|
|
@@ -757,7 +786,7 @@ declare module "wb_node" {
|
|
|
757
786
|
hasChildren(): boolean;
|
|
758
787
|
/** Return true if node has className set. */
|
|
759
788
|
hasClass(className: string): boolean;
|
|
760
|
-
/** Return true if node ist the currently focused node. */
|
|
789
|
+
/** Return true if node ist the currently focused node. @since 0.9.0 */
|
|
761
790
|
hasFocus(): boolean;
|
|
762
791
|
/** Return true if this node is the currently active tree node. */
|
|
763
792
|
isActive(): boolean;
|
|
@@ -939,11 +968,11 @@ declare module "wb_node" {
|
|
|
939
968
|
*
|
|
940
969
|
* @param name name of the option property (on node and tree)
|
|
941
970
|
* @param defaultValue return this if nothing else matched
|
|
942
|
-
* {@link Wunderbaum.getOption|Wunderbaum.getOption
|
|
971
|
+
* {@link Wunderbaum.getOption|Wunderbaum.getOption}
|
|
943
972
|
*/
|
|
944
973
|
getOption(name: string, defaultValue?: any): any;
|
|
945
974
|
/** Make sure that this node is visible in the viewport.
|
|
946
|
-
* @see {@link Wunderbaum.scrollTo|Wunderbaum.scrollTo
|
|
975
|
+
* @see {@link Wunderbaum.scrollTo|Wunderbaum.scrollTo}
|
|
947
976
|
*/
|
|
948
977
|
scrollIntoView(options?: ScrollIntoViewOptions): Promise<void>;
|
|
949
978
|
/**
|
|
@@ -971,9 +1000,9 @@ declare module "wb_node" {
|
|
|
971
1000
|
* and column content. It can be reduced to 'ChangeType.status' if only
|
|
972
1001
|
* active/focus/selected state has changed.
|
|
973
1002
|
*
|
|
974
|
-
* This method will eventually call {@link WunderbaumNode._render
|
|
1003
|
+
* This method will eventually call {@link WunderbaumNode._render} with
|
|
975
1004
|
* default options, but may be more consistent with the tree's
|
|
976
|
-
* {@link Wunderbaum.update
|
|
1005
|
+
* {@link Wunderbaum.update} API.
|
|
977
1006
|
*/
|
|
978
1007
|
update(change?: ChangeType): void;
|
|
979
1008
|
/**
|
|
@@ -1014,6 +1043,18 @@ declare module "wb_node" {
|
|
|
1014
1043
|
* @param {boolean} deep pass true to sort all descendant nodes recursively
|
|
1015
1044
|
*/
|
|
1016
1045
|
sortChildren(cmp?: SortCallback | null, deep?: boolean): void;
|
|
1046
|
+
/**
|
|
1047
|
+
* Renumber nodes `_nativeIndex`. This is useful to allow to restore the
|
|
1048
|
+
* order after sorting a column.
|
|
1049
|
+
* This method is automatically called after loading new child nodes.
|
|
1050
|
+
* @since 0.11.0
|
|
1051
|
+
*/
|
|
1052
|
+
resetNativeChildOrder(options?: ResetOrderOptions): void;
|
|
1053
|
+
/**
|
|
1054
|
+
* Convenience method to implement column sorting.
|
|
1055
|
+
* @since 0.11.0
|
|
1056
|
+
*/
|
|
1057
|
+
sortByProperty(options: SortByPropertyOptions): void;
|
|
1017
1058
|
/**
|
|
1018
1059
|
* Trigger `modifyChild` event on a parent to signal that a child was modified.
|
|
1019
1060
|
* @param {string} operation Type of change: 'add', 'remove', 'rename', 'move', 'data', ...
|
|
@@ -1067,7 +1108,7 @@ declare module "wb_options" {
|
|
|
1067
1108
|
* Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
|
|
1068
1109
|
* @VERSION, @DATE (https://github.com/mar10/wunderbaum)
|
|
1069
1110
|
*/
|
|
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";
|
|
1111
|
+
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
1112
|
/**
|
|
1072
1113
|
* Available options for {@link wunderbaum.Wunderbaum}.
|
|
1073
1114
|
*
|
|
@@ -1239,11 +1280,30 @@ declare module "wb_options" {
|
|
|
1239
1280
|
* Default: false
|
|
1240
1281
|
*/
|
|
1241
1282
|
fixedCol?: boolean;
|
|
1283
|
+
/**
|
|
1284
|
+
* Default value for ColumnDefinition.filterable option.
|
|
1285
|
+
* Default: false
|
|
1286
|
+
* @since 0.11.0
|
|
1287
|
+
*/
|
|
1288
|
+
columnsFilterable?: boolean;
|
|
1289
|
+
/**
|
|
1290
|
+
* Default value for ColumnDefinition.menu option.
|
|
1291
|
+
* Default: false
|
|
1292
|
+
* @since 0.11.0
|
|
1293
|
+
*/
|
|
1294
|
+
columnsMenu?: boolean;
|
|
1242
1295
|
/**
|
|
1243
1296
|
* Default value for ColumnDefinition.resizable option.
|
|
1244
1297
|
* Default: false
|
|
1298
|
+
* @since 0.10.0
|
|
1299
|
+
*/
|
|
1300
|
+
columnsResizable?: boolean;
|
|
1301
|
+
/**
|
|
1302
|
+
* Default value for ColumnDefinition.sortable option.
|
|
1303
|
+
* Default: false
|
|
1304
|
+
* @since 0.11.0
|
|
1245
1305
|
*/
|
|
1246
|
-
|
|
1306
|
+
columnsSortable?: boolean;
|
|
1247
1307
|
/**
|
|
1248
1308
|
* Default: "multi"
|
|
1249
1309
|
*/
|
|
@@ -1279,11 +1339,15 @@ declare module "wb_options" {
|
|
|
1279
1339
|
*/
|
|
1280
1340
|
beforeExpand?: (e: WbExpandEventType) => WbCancelableEventResultType;
|
|
1281
1341
|
/**
|
|
1282
|
-
*
|
|
1283
1342
|
* Return `false` to prevent default handling, i.e. (de)selecting the node.
|
|
1284
1343
|
* @category Callback
|
|
1285
1344
|
*/
|
|
1286
1345
|
beforeSelect?: (e: WbSelectEventType) => WbCancelableEventResultType;
|
|
1346
|
+
/**
|
|
1347
|
+
* Return `false` to prevent default handling, i.e. (de)selecting the node.
|
|
1348
|
+
* @category Callback
|
|
1349
|
+
*/
|
|
1350
|
+
buttonClick?: (e: WbButtonClickEventType) => void;
|
|
1287
1351
|
/**
|
|
1288
1352
|
*
|
|
1289
1353
|
* @category Callback
|
|
@@ -1462,11 +1526,20 @@ declare module "types" {
|
|
|
1462
1526
|
export type NodeAnyCallback = (node: WunderbaumNode) => any;
|
|
1463
1527
|
/** A callback that receives a node instance and returns a string value. */
|
|
1464
1528
|
export type NodeStringCallback = (node: WunderbaumNode) => string;
|
|
1529
|
+
/** A callback that receives a node instance and property name returns a value. */
|
|
1530
|
+
export type NodePropertyGetterCallback = (node: WunderbaumNode, propName: string) => any;
|
|
1465
1531
|
/** A callback that receives a node instance and returns an iteration modifier. */
|
|
1466
1532
|
export type NodeVisitCallback = (node: WunderbaumNode) => NodeVisitResponse;
|
|
1467
|
-
/**
|
|
1533
|
+
/**
|
|
1534
|
+
* Returned by `NodeVisitCallback` to control iteration.
|
|
1535
|
+
* `false` stops iteration, `skip` skips descendants but continues.
|
|
1536
|
+
* All other values continue iteration.
|
|
1537
|
+
*/
|
|
1468
1538
|
export type NodeVisitResponse = "skip" | boolean | void;
|
|
1469
|
-
/**
|
|
1539
|
+
/**
|
|
1540
|
+
* A callback that receives a node-data dictionary and a node instance and
|
|
1541
|
+
* returns an iteration modifier.
|
|
1542
|
+
*/
|
|
1470
1543
|
export type NodeToDictCallback = (dict: WbNodeData, node: WunderbaumNode) => NodeVisitResponse;
|
|
1471
1544
|
/** A callback that receives a node instance and returns a string value. */
|
|
1472
1545
|
export type NodeSelectCallback = (node: WunderbaumNode) => boolean | void;
|
|
@@ -1488,7 +1561,7 @@ declare module "types" {
|
|
|
1488
1561
|
colspan?: boolean;
|
|
1489
1562
|
expanded?: boolean;
|
|
1490
1563
|
icon?: IconOption;
|
|
1491
|
-
iconTooltip?:
|
|
1564
|
+
iconTooltip?: TooltipOption;
|
|
1492
1565
|
key?: string;
|
|
1493
1566
|
lazy?: boolean;
|
|
1494
1567
|
/** Make child nodes single-select radio buttons. */
|
|
@@ -1497,7 +1570,7 @@ declare module "types" {
|
|
|
1497
1570
|
selected?: boolean;
|
|
1498
1571
|
statusNodeType?: NodeStatusType;
|
|
1499
1572
|
title: string;
|
|
1500
|
-
tooltip?:
|
|
1573
|
+
tooltip?: TooltipOption;
|
|
1501
1574
|
type?: string;
|
|
1502
1575
|
unselectable?: boolean;
|
|
1503
1576
|
/** @internal */
|
|
@@ -1616,6 +1689,11 @@ declare module "types" {
|
|
|
1616
1689
|
export interface WbSelectEventType extends WbNodeEventType {
|
|
1617
1690
|
flag: boolean;
|
|
1618
1691
|
}
|
|
1692
|
+
export interface WbButtonClickEventType extends WbTreeEventType {
|
|
1693
|
+
info: WbEventInfo;
|
|
1694
|
+
/** The associated command, e.g. 'menu', 'sort', 'filter', ... */
|
|
1695
|
+
command: string;
|
|
1696
|
+
}
|
|
1619
1697
|
export interface WbRenderEventType extends WbNodeEventType {
|
|
1620
1698
|
/**
|
|
1621
1699
|
* True if the node's markup was not yet created. In this case the render
|
|
@@ -1668,8 +1746,8 @@ declare module "types" {
|
|
|
1668
1746
|
colspan?: boolean;
|
|
1669
1747
|
/** Default icon for matching nodes. */
|
|
1670
1748
|
icon?: IconOption;
|
|
1671
|
-
/** Default icon for matching nodes. */
|
|
1672
|
-
iconTooltip?:
|
|
1749
|
+
/** Default icon tooltip for matching nodes. */
|
|
1750
|
+
iconTooltip?: TooltipOption;
|
|
1673
1751
|
[key: string]: unknown;
|
|
1674
1752
|
}
|
|
1675
1753
|
export type NodeTypeDefinitionMap = {
|
|
@@ -1697,28 +1775,53 @@ declare module "types" {
|
|
|
1697
1775
|
*/
|
|
1698
1776
|
minWidth?: string | number;
|
|
1699
1777
|
/** Allow user to resize the column.
|
|
1700
|
-
*
|
|
1778
|
+
* @default false (or global tree option `columnsSortable`)
|
|
1779
|
+
* @see {@link WunderbaumOptions.columnsResizable}.
|
|
1780
|
+
* @since 0.10.0
|
|
1701
1781
|
*/
|
|
1702
1782
|
resizable?: boolean;
|
|
1703
1783
|
/** Optional custom column width when user resized by mouse drag.
|
|
1704
1784
|
* Default: unset.
|
|
1705
1785
|
*/
|
|
1706
1786
|
customWidthPx?: number;
|
|
1707
|
-
/**
|
|
1708
|
-
*
|
|
1787
|
+
/** Display a 'filter' button in the column header. Default: false. <br>
|
|
1788
|
+
* Note: The actual filtering must be implemented in the `buttonClick()` event.
|
|
1789
|
+
* @default false (or global tree option `columnsFilterable`)
|
|
1790
|
+
* @since 0.11.0
|
|
1791
|
+
*/
|
|
1792
|
+
filterable?: boolean;
|
|
1793
|
+
/** .
|
|
1794
|
+
* Default: inactive. <br>
|
|
1795
|
+
* Note: The actual filtering must be implemented in the `buttonClick()` event.
|
|
1796
|
+
*/
|
|
1797
|
+
filterActive?: boolean;
|
|
1798
|
+
/** Display a 'sort' button in the column header. Default: false. <br>
|
|
1799
|
+
* Note: The actual sorting must be implemented in the `buttonClick()` event.
|
|
1800
|
+
* @default false (or global tree option `columnsSortable`)
|
|
1801
|
+
* @see {@link WunderbaumOptions.columnsSortable}.
|
|
1802
|
+
* @since 0.11.0
|
|
1709
1803
|
*/
|
|
1710
1804
|
sortable?: boolean;
|
|
1711
1805
|
/** Optional custom column sort orde when user clicked the sort icon.
|
|
1712
|
-
* Default: unset. <br>
|
|
1713
|
-
*
|
|
1806
|
+
* Default: unset, e.g. not sorted. <br>
|
|
1807
|
+
* Note: The actual sorting must be implemented in the `buttonClick()` event.
|
|
1808
|
+
* @since 0.11.0
|
|
1714
1809
|
*/
|
|
1715
1810
|
sortOrder?: SortOrderType;
|
|
1811
|
+
/** Display a menu icon that may open a context menu for this column.
|
|
1812
|
+
* Note: The actual functionality must be implemented in the `buttonClick()` event.
|
|
1813
|
+
* @default false (or global tree option `columnsMenu`)
|
|
1814
|
+
* @see {@link WunderbaumOptions.columnsMenu}.
|
|
1815
|
+
* @since 0.11.0
|
|
1816
|
+
*/
|
|
1817
|
+
menu?: boolean;
|
|
1716
1818
|
/** Optional class names that are added to all `span.wb-col` header AND data
|
|
1717
|
-
* elements of that column.
|
|
1819
|
+
* elements of that column. Separate multiple classes with space.
|
|
1718
1820
|
*/
|
|
1719
1821
|
classes?: string;
|
|
1720
1822
|
/** If `headerClasses` is a set, it will be used for the header element only
|
|
1721
1823
|
* (unlike `classes`, which is used for body and header cells).
|
|
1824
|
+
* Separate multiple classes with space.
|
|
1722
1825
|
*/
|
|
1723
1826
|
headerClasses?: string;
|
|
1724
1827
|
/** Optional HTML content that is rendered into all `span.wb-col` elements of that column.*/
|
|
@@ -1780,7 +1883,7 @@ declare module "types" {
|
|
|
1780
1883
|
export type NodeFilterResponse = "skip" | "branch" | boolean | void;
|
|
1781
1884
|
export type NodeFilterCallback = (node: WunderbaumNode) => NodeFilterResponse;
|
|
1782
1885
|
/**
|
|
1783
|
-
* Possible values for {@link WunderbaumNode.update
|
|
1886
|
+
* Possible values for {@link WunderbaumNode.update} and {@link Wunderbaum.update}.
|
|
1784
1887
|
*/
|
|
1785
1888
|
export enum ChangeType {
|
|
1786
1889
|
/** Re-render the whole viewport, headers, and all rows. */
|
|
@@ -1806,7 +1909,7 @@ declare module "types" {
|
|
|
1806
1909
|
redraw = "redraw",
|
|
1807
1910
|
scroll = "scroll"
|
|
1808
1911
|
}
|
|
1809
|
-
/** Possible values for {@link WunderbaumNode.setStatus
|
|
1912
|
+
/** Possible values for {@link WunderbaumNode.setStatus}. */
|
|
1810
1913
|
export enum NodeStatusType {
|
|
1811
1914
|
ok = "ok",
|
|
1812
1915
|
loading = "loading",
|
|
@@ -1831,7 +1934,7 @@ declare module "types" {
|
|
|
1831
1934
|
startCell = "startCell",// Start in cell-nav mode, but allow row mode
|
|
1832
1935
|
row = "row"
|
|
1833
1936
|
}
|
|
1834
|
-
/** Possible values for {@link WunderbaumNode.addChildren
|
|
1937
|
+
/** Possible values for {@link WunderbaumNode.addChildren}. */
|
|
1835
1938
|
export interface AddChildrenOptions {
|
|
1836
1939
|
/** Insert children before this node (or index)
|
|
1837
1940
|
* @default undefined or null: append as last child
|
|
@@ -1846,11 +1949,11 @@ declare module "types" {
|
|
|
1846
1949
|
/** (@internal Internal use, do not set! ) */
|
|
1847
1950
|
_level?: number;
|
|
1848
1951
|
}
|
|
1849
|
-
/** Possible values for {@link Wunderbaum.applyCommand
|
|
1952
|
+
/** Possible values for {@link Wunderbaum.applyCommand} and {@link WunderbaumNode.applyCommand}. */
|
|
1850
1953
|
export interface ApplyCommandOptions {
|
|
1851
1954
|
[key: string]: unknown;
|
|
1852
1955
|
}
|
|
1853
|
-
/** Possible values for {@link Wunderbaum.expandAll
|
|
1956
|
+
/** Possible values for {@link Wunderbaum.expandAll} and {@link WunderbaumNode.expandAll}. */
|
|
1854
1957
|
export interface ExpandAllOptions {
|
|
1855
1958
|
/** Restrict expand level @default 99 */
|
|
1856
1959
|
depth?: number;
|
|
@@ -1862,7 +1965,7 @@ declare module "types" {
|
|
|
1862
1965
|
keepActiveNodeVisible?: boolean;
|
|
1863
1966
|
}
|
|
1864
1967
|
/**
|
|
1865
|
-
* Possible option values for {@link Wunderbaum.filterNodes
|
|
1968
|
+
* Possible option values for {@link Wunderbaum.filterNodes}.
|
|
1866
1969
|
* The defaults are inherited from the tree instances ´tree.options.filter`
|
|
1867
1970
|
* settings (see also {@link FilterOptionsType}).
|
|
1868
1971
|
*/
|
|
@@ -1887,7 +1990,7 @@ declare module "types" {
|
|
|
1887
1990
|
/** Display a 'no data' status node if result is empty @default true */
|
|
1888
1991
|
noData?: boolean | string;
|
|
1889
1992
|
}
|
|
1890
|
-
/** Possible values for {@link WunderbaumNode.makeVisible
|
|
1993
|
+
/** Possible values for {@link WunderbaumNode.makeVisible}. */
|
|
1891
1994
|
export interface MakeVisibleOptions {
|
|
1892
1995
|
/** Do not animate expand (currently not implemented). @default false */
|
|
1893
1996
|
noAnimation?: boolean;
|
|
@@ -1896,14 +1999,14 @@ declare module "types" {
|
|
|
1896
1999
|
/** Do not send events. @default false */
|
|
1897
2000
|
noEvents?: boolean;
|
|
1898
2001
|
}
|
|
1899
|
-
/** Possible values for {@link WunderbaumNode.navigate
|
|
2002
|
+
/** Possible values for {@link WunderbaumNode.navigate}. */
|
|
1900
2003
|
export interface NavigateOptions {
|
|
1901
2004
|
/** Activate the new node (otherwise focus only). @default true */
|
|
1902
2005
|
activate?: boolean;
|
|
1903
2006
|
/** Originating event (e.g. KeyboardEvent) if any. */
|
|
1904
2007
|
event?: Event;
|
|
1905
2008
|
}
|
|
1906
|
-
/** Possible values for {@link WunderbaumNode._render
|
|
2009
|
+
/** Possible values for {@link WunderbaumNode._render}. */
|
|
1907
2010
|
export interface RenderOptions {
|
|
1908
2011
|
/** Which parts need update? @default ChangeType.data */
|
|
1909
2012
|
change?: ChangeType;
|
|
@@ -1920,7 +2023,7 @@ declare module "types" {
|
|
|
1920
2023
|
/** @internal. @default true */
|
|
1921
2024
|
resizeCols?: boolean;
|
|
1922
2025
|
}
|
|
1923
|
-
/** Possible values for {@link WunderbaumNode.scrollIntoView
|
|
2026
|
+
/** Possible values for {@link WunderbaumNode.scrollIntoView} `options` argument. */
|
|
1924
2027
|
export interface ScrollIntoViewOptions {
|
|
1925
2028
|
/** Do not animate (currently not implemented). @default false */
|
|
1926
2029
|
noAnimation?: boolean;
|
|
@@ -1931,7 +2034,7 @@ declare module "types" {
|
|
|
1931
2034
|
/** Add N pixel offset at top. */
|
|
1932
2035
|
ofsY?: number;
|
|
1933
2036
|
}
|
|
1934
|
-
/** Possible values for {@link Wunderbaum.scrollTo
|
|
2037
|
+
/** Possible values for {@link Wunderbaum.scrollTo} `options` argument. */
|
|
1935
2038
|
export interface ScrollToOptions extends ScrollIntoViewOptions {
|
|
1936
2039
|
/** Which node to scroll into the viewport.*/
|
|
1937
2040
|
node: WunderbaumNode;
|
|
@@ -1946,7 +2049,7 @@ declare module "types" {
|
|
|
1946
2049
|
focusTree?: boolean;
|
|
1947
2050
|
/** Optional original event that will be passed to the (de)activate handler. */
|
|
1948
2051
|
event?: Event;
|
|
1949
|
-
/** Also call {@link Wunderbaum.setColumn
|
|
2052
|
+
/** Also call {@link Wunderbaum.setColumn}. */
|
|
1950
2053
|
colIdx?: number | string;
|
|
1951
2054
|
/**
|
|
1952
2055
|
* Focus embedded input control of the grid cell if any (requires colIdx >= 0).
|
|
@@ -1955,7 +2058,7 @@ declare module "types" {
|
|
|
1955
2058
|
*/
|
|
1956
2059
|
edit?: boolean;
|
|
1957
2060
|
}
|
|
1958
|
-
/** Possible values for {@link Wunderbaum.setColumn
|
|
2061
|
+
/** Possible values for {@link Wunderbaum.setColumn} `options` argument. */
|
|
1959
2062
|
export interface SetColumnOptions {
|
|
1960
2063
|
/**
|
|
1961
2064
|
* Focus embedded input control of the grid cell if any .
|
|
@@ -1979,12 +2082,12 @@ declare module "types" {
|
|
|
1979
2082
|
/** Scroll up to bring expanded nodes into viewport. @default false */
|
|
1980
2083
|
scrollIntoView?: boolean;
|
|
1981
2084
|
}
|
|
1982
|
-
/** Possible values for {@link WunderbaumNode.update
|
|
2085
|
+
/** Possible values for {@link WunderbaumNode.update} `options` argument. */
|
|
1983
2086
|
export interface UpdateOptions {
|
|
1984
2087
|
/** Force immediate redraw instead of throttled/async mode. @default false */
|
|
1985
2088
|
immediate?: boolean;
|
|
1986
2089
|
}
|
|
1987
|
-
/** Possible values for {@link WunderbaumNode.setSelected
|
|
2090
|
+
/** Possible values for {@link WunderbaumNode.setSelected} `options` argument. */
|
|
1988
2091
|
export interface SetSelectedOptions {
|
|
1989
2092
|
/** Ignore restrictions, e.g. (`unselectable`). @default false */
|
|
1990
2093
|
force?: boolean;
|
|
@@ -1995,14 +2098,58 @@ declare module "types" {
|
|
|
1995
2098
|
/** Called for every node. May return false to prevent action. @default null */
|
|
1996
2099
|
callback?: NodeSelectCallback;
|
|
1997
2100
|
}
|
|
1998
|
-
/** Possible values for {@link WunderbaumNode.setStatus
|
|
2101
|
+
/** Possible values for {@link WunderbaumNode.setStatus} `options` argument. */
|
|
1999
2102
|
export interface SetStatusOptions {
|
|
2000
2103
|
/** Displayed as status node title. */
|
|
2001
2104
|
message?: string;
|
|
2002
2105
|
/** Used as tooltip. */
|
|
2003
2106
|
details?: string;
|
|
2004
2107
|
}
|
|
2005
|
-
/**
|
|
2108
|
+
/**
|
|
2109
|
+
* Possible values for {@link WunderbaumNode.sortByProperty} `options` argument.
|
|
2110
|
+
*/
|
|
2111
|
+
export interface ResetOrderOptions {
|
|
2112
|
+
/** Sort descendants recursively. @default true */
|
|
2113
|
+
recursive?: boolean;
|
|
2114
|
+
/** The name of the node property that will be renumbered.
|
|
2115
|
+
* @default `_nativeIndex`.
|
|
2116
|
+
*/
|
|
2117
|
+
propName?: string;
|
|
2118
|
+
}
|
|
2119
|
+
/**
|
|
2120
|
+
* Possible values for {@link WunderbaumNode.sortByProperty} `options` argument.
|
|
2121
|
+
*/
|
|
2122
|
+
export interface SortByPropertyOptions {
|
|
2123
|
+
/** Column ID as defined in `tree.columns` definition. Required if updateColInfo is true.*/
|
|
2124
|
+
colId?: string;
|
|
2125
|
+
/** The name of the node property that will be used for sorting.
|
|
2126
|
+
* @default use the `colId` as property name.
|
|
2127
|
+
*/
|
|
2128
|
+
propName?: string;
|
|
2129
|
+
/** Sort order. @default Use value from column definition (rotated).*/
|
|
2130
|
+
order?: SortOrderType;
|
|
2131
|
+
/**
|
|
2132
|
+
* Sort by this property if order is `undefined`.
|
|
2133
|
+
* See also {@link WunderbaumNode.resetNativeChildOrder}.
|
|
2134
|
+
* @default `_nativeIndex`.
|
|
2135
|
+
*/
|
|
2136
|
+
nativeOrderPropName?: string;
|
|
2137
|
+
/** Sort string values case insensitive. @default false */
|
|
2138
|
+
caseInsensitive?: boolean;
|
|
2139
|
+
/** Sort descendants recursively. @default true */
|
|
2140
|
+
deep?: boolean;
|
|
2141
|
+
/**
|
|
2142
|
+
* Rotate sort order (asc -> desc -> none) before sorting.
|
|
2143
|
+
* Update the sort icons in the column header
|
|
2144
|
+
* Note:
|
|
2145
|
+
* Sorting is done in-place. There is no 'unsorted' state, but we can
|
|
2146
|
+
* call `setCurrentSortOrder()` to renumber the `node._sortIdx` property,
|
|
2147
|
+
* which will be used as sort key, when `order` is `undefined`.
|
|
2148
|
+
* @default false
|
|
2149
|
+
*/
|
|
2150
|
+
updateColInfo?: boolean;
|
|
2151
|
+
}
|
|
2152
|
+
/** Options passed to {@link Wunderbaum.visitRows}. */
|
|
2006
2153
|
export interface VisitRowsOptions {
|
|
2007
2154
|
/** Skip filtered nodes and children of collapsed nodes. @default false */
|
|
2008
2155
|
includeHidden?: boolean;
|
|
@@ -2208,7 +2355,7 @@ declare module "types" {
|
|
|
2208
2355
|
*/
|
|
2209
2356
|
scrollSpeed?: 5;
|
|
2210
2357
|
/**
|
|
2211
|
-
* Optional callback passed to `toDict` on dragStart
|
|
2358
|
+
* Optional callback passed to `toDict` on dragStart
|
|
2212
2359
|
* @default null
|
|
2213
2360
|
* @category Callback
|
|
2214
2361
|
*/
|
|
@@ -2549,7 +2696,7 @@ declare module "wunderbaum" {
|
|
|
2549
2696
|
*/
|
|
2550
2697
|
import * as util from "util";
|
|
2551
2698
|
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";
|
|
2699
|
+
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
2700
|
import { WunderbaumNode } from "wb_node";
|
|
2554
2701
|
import { WunderbaumOptions } from "wb_options";
|
|
2555
2702
|
import { DebouncedFunction } from "debounce";
|
|
@@ -2758,7 +2905,7 @@ declare module "wunderbaum" {
|
|
|
2758
2905
|
hasHeader(): boolean;
|
|
2759
2906
|
/** Run code, but defer rendering of viewport until done.
|
|
2760
2907
|
*
|
|
2761
|
-
* ```
|
|
2908
|
+
* ```js
|
|
2762
2909
|
* tree.runWithDeferredUpdate(() => {
|
|
2763
2910
|
* return someFuncThatWouldUpdateManyNodes();
|
|
2764
2911
|
* });
|
|
@@ -2929,7 +3076,7 @@ declare module "wunderbaum" {
|
|
|
2929
3076
|
logTimeEnd(label: string): void;
|
|
2930
3077
|
/** Write to `console.warn` with tree name as prefix with if opts.debugLevel >= 2. */
|
|
2931
3078
|
logWarn(...args: any[]): void;
|
|
2932
|
-
/** Reset column widths to default. */
|
|
3079
|
+
/** Reset column widths to default. @since 0.10.0 */
|
|
2933
3080
|
resetColumns(): void;
|
|
2934
3081
|
/**
|
|
2935
3082
|
* Make sure that this node is vertically scrolled into the viewport.
|
|
@@ -2965,14 +3112,14 @@ declare module "wunderbaum" {
|
|
|
2965
3112
|
* The render operation is async and debounced unless the `immediate` option
|
|
2966
3113
|
* is set.
|
|
2967
3114
|
*
|
|
2968
|
-
* Use {@link WunderbaumNode.update
|
|
2969
|
-
* or {@link WunderbaumNode._render
|
|
3115
|
+
* Use {@link WunderbaumNode.update} if only a single node has changed,
|
|
3116
|
+
* or {@link WunderbaumNode._render}) to pass special options.
|
|
2970
3117
|
*/
|
|
2971
3118
|
update(change: ChangeType, options?: UpdateOptions): void;
|
|
2972
3119
|
/**
|
|
2973
3120
|
* Update a row to reflect a single node's modification.
|
|
2974
3121
|
*
|
|
2975
|
-
* @see {@link WunderbaumNode.update
|
|
3122
|
+
* @see {@link WunderbaumNode.update}, {@link WunderbaumNode._render}
|
|
2976
3123
|
*/
|
|
2977
3124
|
update(change: ChangeType, node: WunderbaumNode, options?: UpdateOptions): void;
|
|
2978
3125
|
/** Disable mouse and keyboard interaction (return prev. state). */
|
|
@@ -3000,6 +3147,12 @@ declare module "wunderbaum" {
|
|
|
3000
3147
|
* @param {boolean} deep pass true to sort all descendant nodes recursively
|
|
3001
3148
|
*/
|
|
3002
3149
|
sortChildren(cmp?: SortCallback | null, deep?: boolean): void;
|
|
3150
|
+
/**
|
|
3151
|
+
* Convenience method to implement column sorting.
|
|
3152
|
+
* @see {@link WunderbaumNode.sortByProperty}.
|
|
3153
|
+
* @since 0.11.0
|
|
3154
|
+
*/
|
|
3155
|
+
sortByProperty(options: SortByPropertyOptions): void;
|
|
3003
3156
|
/** Convert tree to an array of plain objects.
|
|
3004
3157
|
*
|
|
3005
3158
|
* @param callback is called for every node, in order to allow
|
|
@@ -3014,6 +3167,7 @@ declare module "wunderbaum" {
|
|
|
3014
3167
|
* Return true if at least one column width changed.
|
|
3015
3168
|
*/
|
|
3016
3169
|
_updateColumnWidths(): boolean;
|
|
3170
|
+
protected _insertIcon(icon: string, elem: HTMLElement): void;
|
|
3017
3171
|
/** Create/update header markup from `this.columns` definition.
|
|
3018
3172
|
* @internal
|
|
3019
3173
|
*/
|
|
@@ -3106,6 +3260,7 @@ declare module "wunderbaum" {
|
|
|
3106
3260
|
/**
|
|
3107
3261
|
* Return the number of nodes that match the current filter.
|
|
3108
3262
|
* @see {@link Wunderbaum.filterNodes}
|
|
3263
|
+
* @since 0.9.0
|
|
3109
3264
|
*/
|
|
3110
3265
|
countMatches(): number;
|
|
3111
3266
|
/**
|