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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wunderbaum",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"title": "A treegrid control.",
|
|
5
5
|
"description": "JavaScript tree/grid/treegrid control.",
|
|
6
6
|
"homepage": "https://github.com/mar10/wunderbaum",
|
|
@@ -54,14 +54,13 @@
|
|
|
54
54
|
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
|
55
55
|
"@typescript-eslint/parser": "^6.7.5",
|
|
56
56
|
"concurrently": "^8.1.0",
|
|
57
|
-
"docsify-cli": "^4.4.4",
|
|
58
57
|
"eslint": "^8.51.0",
|
|
59
58
|
"eslint-config-jquery": "^3.0.0",
|
|
60
59
|
"eslint-config-prettier": "^8.8.0",
|
|
61
60
|
"eslint-plugin-prettier": "^4.2.1",
|
|
62
61
|
"grunt": "^1.6.1",
|
|
63
62
|
"grunt-contrib-connect": "^3.0.0",
|
|
64
|
-
"grunt-contrib-qunit": "^
|
|
63
|
+
"grunt-contrib-qunit": "^10.1.1",
|
|
65
64
|
"grunt-contrib-watch": "^1.1.0",
|
|
66
65
|
"grunt-exec": "^3.0.0",
|
|
67
66
|
"grunt-yabs": "^1.3.0",
|
|
@@ -71,7 +70,7 @@
|
|
|
71
70
|
"postcss-url": "^10.1.3",
|
|
72
71
|
"prettier": "^2.8.8",
|
|
73
72
|
"pretty-quick": "^3.1.3",
|
|
74
|
-
"puppeteer": "^
|
|
73
|
+
"puppeteer": "^23.10.0",
|
|
75
74
|
"qunit": "^2.19.4",
|
|
76
75
|
"rollup": "^3.23.0",
|
|
77
76
|
"rollup-plugin-scss": "^4.0.0",
|
|
@@ -81,7 +80,8 @@
|
|
|
81
80
|
"ts-node": "^10.9.1",
|
|
82
81
|
"tslib": "^2.5.2",
|
|
83
82
|
"typedoc": "^0.25.2",
|
|
84
|
-
"typescript": "^5.2.2"
|
|
83
|
+
"typescript": "^5.2.2",
|
|
84
|
+
"yarn-audit-fix": "^10.1.1"
|
|
85
85
|
},
|
|
86
86
|
"nodemonConfig": {
|
|
87
87
|
"watch": [
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
},
|
|
102
102
|
"scripts": {
|
|
103
103
|
"test": "npm run lint && npm run build:js && grunt ci --verbose",
|
|
104
|
-
"
|
|
104
|
+
"api_docs": "typedoc && touch docs/api/.nojekyll && rm docs/unittest/*.*; cp test/unit/*.* docs/unittest",
|
|
105
105
|
"format": "eslint src --fix && prettier src docs/demo -w && npm run lint",
|
|
106
106
|
"lint": "prettier src docs/demo --check && eslint src docs/demo && tsc -t esnext --moduleResolution node --noEmit src/wunderbaum.ts",
|
|
107
107
|
"build:minjs:umd": "terser build/wunderbaum.umd.js --compress --mangle --source-map \"base='build',url='wunderbaum.umd.min.js.map',filename='wunderbaum.umd.js'\" --output build/wunderbaum.umd.min.js",
|
|
@@ -110,13 +110,13 @@
|
|
|
110
110
|
"build:scss": "sass src/wunderbaum.scss build/wunderbaum.css",
|
|
111
111
|
"build:js": "rollup -c rollup.config.mjs && npm run build:minjs",
|
|
112
112
|
"build:types": "tsc -t esnext --moduleResolution node -d --emitDeclarationOnly --outFile build/wunderbaum.d.ts src/wunderbaum.ts",
|
|
113
|
-
"build": "npm run format && mkdir build; rm build/*.*; ls build && npm run build:js -s && npm run build:scss && npm run build:types -s && npm run
|
|
113
|
+
"build": "npm run format && mkdir build; rm build/*.*; ls build && npm run build:js -s && npm run build:scss && npm run build:types -s && npm run api_docs",
|
|
114
114
|
"make_dist": "npm run build && rm dist/*.* ; cp build/*.* dist",
|
|
115
115
|
"watch:umd": "nodemon --watch src --ext 'ts' -x \"npm run build:minjs\"",
|
|
116
116
|
"watch": "nodemon",
|
|
117
117
|
"serve": "http-server test -p 8080 -o /",
|
|
118
|
-
"
|
|
119
|
-
"
|
|
118
|
+
"dev": "concurrently \"http-server . -p 8080 -o /docs/demo \" \"nodemon\"",
|
|
119
|
+
"dev_mkdocs": "pipenv run mkdocs serve"
|
|
120
120
|
},
|
|
121
121
|
"npmName": "wunderbaum",
|
|
122
122
|
"npmFileMap": [
|
|
@@ -132,5 +132,6 @@
|
|
|
132
132
|
"wunderbaum.umd.min.js.map"
|
|
133
133
|
]
|
|
134
134
|
}
|
|
135
|
-
]
|
|
135
|
+
],
|
|
136
|
+
"packageManager": "yarn@4.4.1+sha512.f825273d0689cc9ead3259c14998037662f1dcd06912637b21a450e8da7cfeb4b1965bbee73d16927baa1201054126bc385c6f43ff4aa705c8631d26e12460f1"
|
|
136
137
|
}
|
package/src/common.ts
CHANGED
|
@@ -12,7 +12,7 @@ export const DEFAULT_DEBUGLEVEL = 4; // Replaced by rollup script
|
|
|
12
12
|
/**
|
|
13
13
|
* Fixed height of a row in pixel. Must match the SCSS variable `$row-outer-height`.
|
|
14
14
|
*/
|
|
15
|
-
export const
|
|
15
|
+
export const DEFAULT_ROW_HEIGHT = 22;
|
|
16
16
|
/**
|
|
17
17
|
* Fixed width of node icons in pixel. Must match the SCSS variable `$icon-outer-width`.
|
|
18
18
|
*/
|
|
@@ -64,6 +64,15 @@ export const iconMaps: { [key: string]: { [key: string]: string } } = {
|
|
|
64
64
|
folderOpen: "bi bi-folder2-open",
|
|
65
65
|
folderLazy: "bi bi-folder-symlink",
|
|
66
66
|
doc: "bi bi-file-earmark",
|
|
67
|
+
colSortable: "bi bi-chevron-expand",
|
|
68
|
+
// colSortable: "bi bi-arrow-down-up",
|
|
69
|
+
// colSortAsc: "bi bi-chevron-down",
|
|
70
|
+
// colSortDesc: "bi bi-chevron-up",
|
|
71
|
+
colSortAsc: "bi bi-arrow-down",
|
|
72
|
+
colSortDesc: "bi bi-arrow-up",
|
|
73
|
+
colFilter: "bi bi-filter-circle",
|
|
74
|
+
colFilterActive: "bi bi-filter-circle-fill wb-helper-invalid",
|
|
75
|
+
colMenu: "bi bi-three-dots-vertical",
|
|
67
76
|
},
|
|
68
77
|
fontawesome6: {
|
|
69
78
|
error: "fa-solid fa-triangle-exclamation",
|
|
@@ -82,6 +91,12 @@ export const iconMaps: { [key: string]: { [key: string]: string } } = {
|
|
|
82
91
|
folderOpen: "fa-regular fa-folder-open",
|
|
83
92
|
folderLazy: "fa-solid fa-folder-plus",
|
|
84
93
|
doc: "fa-regular fa-file",
|
|
94
|
+
colSortable: "fa-solid fa-fw fa-sort",
|
|
95
|
+
colSortAsc: "fa-solid fa-fw fa-sort-up",
|
|
96
|
+
colSortDesc: "fa-solid fa-fw fa-sort-down",
|
|
97
|
+
colFilter: "fa-solid fa-fw fa-filter",
|
|
98
|
+
colFilterActive: "fa-solid fa-fw fa-filter wb-helper-invalid",
|
|
99
|
+
colMenu: "fa-solid fa-fw fa-ellipsis-v",
|
|
85
100
|
},
|
|
86
101
|
};
|
|
87
102
|
|
|
@@ -149,7 +164,7 @@ export const KEY_TO_ACTION_DICT: { [key: string]: string } = {
|
|
|
149
164
|
|
|
150
165
|
/** Return a callback that returns true if the node title matches the string
|
|
151
166
|
* or regular expression.
|
|
152
|
-
* @see {@link WunderbaumNode.findAll
|
|
167
|
+
* @see {@link WunderbaumNode.findAll}
|
|
153
168
|
*/
|
|
154
169
|
export function makeNodeTitleMatcher(match: string | RegExp): MatcherCallback {
|
|
155
170
|
if (match instanceof RegExp) {
|
package/src/types.ts
CHANGED
|
@@ -72,11 +72,23 @@ export type BoolOrStringOptionResolver = (
|
|
|
72
72
|
export type NodeAnyCallback = (node: WunderbaumNode) => any;
|
|
73
73
|
/** A callback that receives a node instance and returns a string value. */
|
|
74
74
|
export type NodeStringCallback = (node: WunderbaumNode) => string;
|
|
75
|
+
/** A callback that receives a node instance and property name returns a value. */
|
|
76
|
+
export type NodePropertyGetterCallback = (
|
|
77
|
+
node: WunderbaumNode,
|
|
78
|
+
propName: string
|
|
79
|
+
) => any;
|
|
75
80
|
/** A callback that receives a node instance and returns an iteration modifier. */
|
|
76
81
|
export type NodeVisitCallback = (node: WunderbaumNode) => NodeVisitResponse;
|
|
77
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Returned by `NodeVisitCallback` to control iteration.
|
|
84
|
+
* `false` stops iteration, `skip` skips descendants but continues.
|
|
85
|
+
* All other values continue iteration.
|
|
86
|
+
*/
|
|
78
87
|
export type NodeVisitResponse = "skip" | boolean | void;
|
|
79
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* A callback that receives a node-data dictionary and a node instance and
|
|
90
|
+
* returns an iteration modifier.
|
|
91
|
+
*/
|
|
80
92
|
export type NodeToDictCallback = (
|
|
81
93
|
dict: WbNodeData,
|
|
82
94
|
node: WunderbaumNode
|
|
@@ -107,7 +119,7 @@ export interface WbNodeData {
|
|
|
107
119
|
colspan?: boolean;
|
|
108
120
|
expanded?: boolean;
|
|
109
121
|
icon?: IconOption;
|
|
110
|
-
iconTooltip?:
|
|
122
|
+
iconTooltip?: TooltipOption;
|
|
111
123
|
key?: string;
|
|
112
124
|
lazy?: boolean;
|
|
113
125
|
/** Make child nodes single-select radio buttons. */
|
|
@@ -116,7 +128,7 @@ export interface WbNodeData {
|
|
|
116
128
|
selected?: boolean;
|
|
117
129
|
statusNodeType?: NodeStatusType;
|
|
118
130
|
title: string;
|
|
119
|
-
tooltip?:
|
|
131
|
+
tooltip?: TooltipOption;
|
|
120
132
|
type?: string;
|
|
121
133
|
unselectable?: boolean;
|
|
122
134
|
/** @internal */
|
|
@@ -264,6 +276,12 @@ export interface WbSelectEventType extends WbNodeEventType {
|
|
|
264
276
|
flag: boolean;
|
|
265
277
|
}
|
|
266
278
|
|
|
279
|
+
export interface WbButtonClickEventType extends WbTreeEventType {
|
|
280
|
+
info: WbEventInfo;
|
|
281
|
+
/** The associated command, e.g. 'menu', 'sort', 'filter', ... */
|
|
282
|
+
command: string;
|
|
283
|
+
}
|
|
284
|
+
|
|
267
285
|
export interface WbRenderEventType extends WbNodeEventType {
|
|
268
286
|
/**
|
|
269
287
|
* True if the node's markup was not yet created. In this case the render
|
|
@@ -317,8 +335,8 @@ export interface NodeTypeDefinition {
|
|
|
317
335
|
colspan?: boolean;
|
|
318
336
|
/** Default icon for matching nodes. */
|
|
319
337
|
icon?: IconOption;
|
|
320
|
-
/** Default icon for matching nodes. */
|
|
321
|
-
iconTooltip?:
|
|
338
|
+
/** Default icon tooltip for matching nodes. */
|
|
339
|
+
iconTooltip?: TooltipOption;
|
|
322
340
|
// and more
|
|
323
341
|
[key: string]: unknown;
|
|
324
342
|
}
|
|
@@ -351,30 +369,58 @@ export interface ColumnDefinition {
|
|
|
351
369
|
*/
|
|
352
370
|
minWidth?: string | number;
|
|
353
371
|
/** Allow user to resize the column.
|
|
354
|
-
*
|
|
372
|
+
* @default false (or global tree option `columnsSortable`)
|
|
373
|
+
* @see {@link WunderbaumOptions.columnsResizable}.
|
|
374
|
+
* @since 0.10.0
|
|
355
375
|
*/
|
|
356
376
|
resizable?: boolean;
|
|
357
377
|
/** Optional custom column width when user resized by mouse drag.
|
|
358
378
|
* Default: unset.
|
|
359
379
|
*/
|
|
360
380
|
customWidthPx?: number;
|
|
361
|
-
/**
|
|
362
|
-
*
|
|
381
|
+
/** Display a 'filter' button in the column header. Default: false. <br>
|
|
382
|
+
* Note: The actual filtering must be implemented in the `buttonClick()` event.
|
|
383
|
+
* @default false (or global tree option `columnsFilterable`)
|
|
384
|
+
* @since 0.11.0
|
|
385
|
+
*/
|
|
386
|
+
filterable?: boolean;
|
|
387
|
+
/** .
|
|
388
|
+
* Default: inactive. <br>
|
|
389
|
+
* Note: The actual filtering must be implemented in the `buttonClick()` event.
|
|
390
|
+
*/
|
|
391
|
+
filterActive?: boolean;
|
|
392
|
+
/** Display a 'sort' button in the column header. Default: false. <br>
|
|
393
|
+
* Note: The actual sorting must be implemented in the `buttonClick()` event.
|
|
394
|
+
* @default false (or global tree option `columnsSortable`)
|
|
395
|
+
* @see {@link WunderbaumOptions.columnsSortable}.
|
|
396
|
+
* @since 0.11.0
|
|
363
397
|
*/
|
|
364
398
|
sortable?: boolean;
|
|
365
399
|
/** Optional custom column sort orde when user clicked the sort icon.
|
|
366
|
-
* Default: unset. <br>
|
|
367
|
-
*
|
|
400
|
+
* Default: unset, e.g. not sorted. <br>
|
|
401
|
+
* Note: The actual sorting must be implemented in the `buttonClick()` event.
|
|
402
|
+
* @since 0.11.0
|
|
368
403
|
*/
|
|
369
404
|
sortOrder?: SortOrderType;
|
|
405
|
+
/** Display a menu icon that may open a context menu for this column.
|
|
406
|
+
* Note: The actual functionality must be implemented in the `buttonClick()` event.
|
|
407
|
+
* @default false (or global tree option `columnsMenu`)
|
|
408
|
+
* @see {@link WunderbaumOptions.columnsMenu}.
|
|
409
|
+
* @since 0.11.0
|
|
410
|
+
*/
|
|
411
|
+
menu?: boolean;
|
|
370
412
|
/** Optional class names that are added to all `span.wb-col` header AND data
|
|
371
|
-
* elements of that column.
|
|
413
|
+
* elements of that column. Separate multiple classes with space.
|
|
372
414
|
*/
|
|
373
415
|
classes?: string;
|
|
374
416
|
/** If `headerClasses` is a set, it will be used for the header element only
|
|
375
417
|
* (unlike `classes`, which is used for body and header cells).
|
|
418
|
+
* Separate multiple classes with space.
|
|
376
419
|
*/
|
|
377
420
|
headerClasses?: string;
|
|
421
|
+
// /** A list of icon definitions added to the column header.
|
|
422
|
+
// */
|
|
423
|
+
// headerIcons?: string;
|
|
378
424
|
/** Optional HTML content that is rendered into all `span.wb-col` elements of that column.*/
|
|
379
425
|
html?: string;
|
|
380
426
|
/** @internal */
|
|
@@ -464,7 +510,7 @@ export type NodeFilterResponse = "skip" | "branch" | boolean | void;
|
|
|
464
510
|
export type NodeFilterCallback = (node: WunderbaumNode) => NodeFilterResponse;
|
|
465
511
|
|
|
466
512
|
/**
|
|
467
|
-
* Possible values for {@link WunderbaumNode.update
|
|
513
|
+
* Possible values for {@link WunderbaumNode.update} and {@link Wunderbaum.update}.
|
|
468
514
|
*/
|
|
469
515
|
export enum ChangeType {
|
|
470
516
|
/** Re-render the whole viewport, headers, and all rows. */
|
|
@@ -493,7 +539,7 @@ export enum RenderFlag {
|
|
|
493
539
|
scroll = "scroll",
|
|
494
540
|
}
|
|
495
541
|
|
|
496
|
-
/** Possible values for {@link WunderbaumNode.setStatus
|
|
542
|
+
/** Possible values for {@link WunderbaumNode.setStatus}. */
|
|
497
543
|
export enum NodeStatusType {
|
|
498
544
|
ok = "ok",
|
|
499
545
|
loading = "loading",
|
|
@@ -525,7 +571,7 @@ export enum NavModeEnum {
|
|
|
525
571
|
* METHOD OPTIONS TYPES
|
|
526
572
|
* ---------------------------------------------------------------------------*/
|
|
527
573
|
|
|
528
|
-
/** Possible values for {@link WunderbaumNode.addChildren
|
|
574
|
+
/** Possible values for {@link WunderbaumNode.addChildren}. */
|
|
529
575
|
export interface AddChildrenOptions {
|
|
530
576
|
/** Insert children before this node (or index)
|
|
531
577
|
* @default undefined or null: append as last child
|
|
@@ -541,12 +587,12 @@ export interface AddChildrenOptions {
|
|
|
541
587
|
_level?: number;
|
|
542
588
|
}
|
|
543
589
|
|
|
544
|
-
/** Possible values for {@link Wunderbaum.applyCommand
|
|
590
|
+
/** Possible values for {@link Wunderbaum.applyCommand} and {@link WunderbaumNode.applyCommand}. */
|
|
545
591
|
export interface ApplyCommandOptions {
|
|
546
592
|
[key: string]: unknown;
|
|
547
593
|
}
|
|
548
594
|
|
|
549
|
-
/** Possible values for {@link Wunderbaum.expandAll
|
|
595
|
+
/** Possible values for {@link Wunderbaum.expandAll} and {@link WunderbaumNode.expandAll}. */
|
|
550
596
|
export interface ExpandAllOptions {
|
|
551
597
|
/** Restrict expand level @default 99 */
|
|
552
598
|
depth?: number;
|
|
@@ -559,7 +605,7 @@ export interface ExpandAllOptions {
|
|
|
559
605
|
}
|
|
560
606
|
|
|
561
607
|
/**
|
|
562
|
-
* Possible option values for {@link Wunderbaum.filterNodes
|
|
608
|
+
* Possible option values for {@link Wunderbaum.filterNodes}.
|
|
563
609
|
* The defaults are inherited from the tree instances ´tree.options.filter`
|
|
564
610
|
* settings (see also {@link FilterOptionsType}).
|
|
565
611
|
*/
|
|
@@ -585,7 +631,7 @@ export interface FilterNodesOptions {
|
|
|
585
631
|
noData?: boolean | string;
|
|
586
632
|
}
|
|
587
633
|
|
|
588
|
-
/** Possible values for {@link WunderbaumNode.makeVisible
|
|
634
|
+
/** Possible values for {@link WunderbaumNode.makeVisible}. */
|
|
589
635
|
export interface MakeVisibleOptions {
|
|
590
636
|
/** Do not animate expand (currently not implemented). @default false */
|
|
591
637
|
noAnimation?: boolean;
|
|
@@ -595,7 +641,7 @@ export interface MakeVisibleOptions {
|
|
|
595
641
|
noEvents?: boolean;
|
|
596
642
|
}
|
|
597
643
|
|
|
598
|
-
/** Possible values for {@link WunderbaumNode.navigate
|
|
644
|
+
/** Possible values for {@link WunderbaumNode.navigate}. */
|
|
599
645
|
export interface NavigateOptions {
|
|
600
646
|
/** Activate the new node (otherwise focus only). @default true */
|
|
601
647
|
activate?: boolean;
|
|
@@ -603,7 +649,7 @@ export interface NavigateOptions {
|
|
|
603
649
|
event?: Event;
|
|
604
650
|
}
|
|
605
651
|
|
|
606
|
-
/** Possible values for {@link WunderbaumNode._render
|
|
652
|
+
/** Possible values for {@link WunderbaumNode._render}. */
|
|
607
653
|
export interface RenderOptions {
|
|
608
654
|
/** Which parts need update? @default ChangeType.data */
|
|
609
655
|
change?: ChangeType;
|
|
@@ -621,7 +667,7 @@ export interface RenderOptions {
|
|
|
621
667
|
resizeCols?: boolean;
|
|
622
668
|
}
|
|
623
669
|
|
|
624
|
-
/** Possible values for {@link WunderbaumNode.scrollIntoView
|
|
670
|
+
/** Possible values for {@link WunderbaumNode.scrollIntoView} `options` argument. */
|
|
625
671
|
export interface ScrollIntoViewOptions {
|
|
626
672
|
/** Do not animate (currently not implemented). @default false */
|
|
627
673
|
noAnimation?: boolean;
|
|
@@ -633,7 +679,7 @@ export interface ScrollIntoViewOptions {
|
|
|
633
679
|
ofsY?: number;
|
|
634
680
|
}
|
|
635
681
|
|
|
636
|
-
/** Possible values for {@link Wunderbaum.scrollTo
|
|
682
|
+
/** Possible values for {@link Wunderbaum.scrollTo} `options` argument. */
|
|
637
683
|
export interface ScrollToOptions extends ScrollIntoViewOptions {
|
|
638
684
|
/** Which node to scroll into the viewport.*/
|
|
639
685
|
node: WunderbaumNode;
|
|
@@ -653,7 +699,7 @@ export interface SetActiveOptions {
|
|
|
653
699
|
focusTree?: boolean;
|
|
654
700
|
/** Optional original event that will be passed to the (de)activate handler. */
|
|
655
701
|
event?: Event;
|
|
656
|
-
/** Also call {@link Wunderbaum.setColumn
|
|
702
|
+
/** Also call {@link Wunderbaum.setColumn}. */
|
|
657
703
|
colIdx?: number | string;
|
|
658
704
|
/**
|
|
659
705
|
* Focus embedded input control of the grid cell if any (requires colIdx >= 0).
|
|
@@ -663,7 +709,7 @@ export interface SetActiveOptions {
|
|
|
663
709
|
edit?: boolean;
|
|
664
710
|
}
|
|
665
711
|
|
|
666
|
-
/** Possible values for {@link Wunderbaum.setColumn
|
|
712
|
+
/** Possible values for {@link Wunderbaum.setColumn} `options` argument. */
|
|
667
713
|
export interface SetColumnOptions {
|
|
668
714
|
/**
|
|
669
715
|
* Focus embedded input control of the grid cell if any .
|
|
@@ -689,7 +735,7 @@ export interface SetExpandedOptions {
|
|
|
689
735
|
scrollIntoView?: boolean;
|
|
690
736
|
}
|
|
691
737
|
|
|
692
|
-
/** Possible values for {@link WunderbaumNode.update
|
|
738
|
+
/** Possible values for {@link WunderbaumNode.update} `options` argument. */
|
|
693
739
|
export interface UpdateOptions {
|
|
694
740
|
/** Force immediate redraw instead of throttled/async mode. @default false */
|
|
695
741
|
immediate?: boolean;
|
|
@@ -697,7 +743,7 @@ export interface UpdateOptions {
|
|
|
697
743
|
// removeMarkup?: boolean;
|
|
698
744
|
}
|
|
699
745
|
|
|
700
|
-
/** Possible values for {@link WunderbaumNode.setSelected
|
|
746
|
+
/** Possible values for {@link WunderbaumNode.setSelected} `options` argument. */
|
|
701
747
|
export interface SetSelectedOptions {
|
|
702
748
|
/** Ignore restrictions, e.g. (`unselectable`). @default false */
|
|
703
749
|
force?: boolean;
|
|
@@ -711,7 +757,7 @@ export interface SetSelectedOptions {
|
|
|
711
757
|
callback?: NodeSelectCallback;
|
|
712
758
|
}
|
|
713
759
|
|
|
714
|
-
/** Possible values for {@link WunderbaumNode.setStatus
|
|
760
|
+
/** Possible values for {@link WunderbaumNode.setStatus} `options` argument. */
|
|
715
761
|
export interface SetStatusOptions {
|
|
716
762
|
/** Displayed as status node title. */
|
|
717
763
|
message?: string;
|
|
@@ -719,7 +765,57 @@ export interface SetStatusOptions {
|
|
|
719
765
|
details?: string;
|
|
720
766
|
}
|
|
721
767
|
|
|
722
|
-
/**
|
|
768
|
+
/**
|
|
769
|
+
* Possible values for {@link WunderbaumNode.sortByProperty} `options` argument.
|
|
770
|
+
*/
|
|
771
|
+
export interface ResetOrderOptions {
|
|
772
|
+
/** Sort descendants recursively. @default true */
|
|
773
|
+
recursive?: boolean;
|
|
774
|
+
/** The name of the node property that will be renumbered.
|
|
775
|
+
* @default `_nativeIndex`.
|
|
776
|
+
*/
|
|
777
|
+
propName?: string;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Possible values for {@link WunderbaumNode.sortByProperty} `options` argument.
|
|
782
|
+
*/
|
|
783
|
+
export interface SortByPropertyOptions {
|
|
784
|
+
/** Column ID as defined in `tree.columns` definition. Required if updateColInfo is true.*/
|
|
785
|
+
colId?: string;
|
|
786
|
+
/** The name of the node property that will be used for sorting.
|
|
787
|
+
* @default use the `colId` as property name.
|
|
788
|
+
*/
|
|
789
|
+
propName?: string;
|
|
790
|
+
// /** If defined, this callback is used to extract the value to be sorted. */
|
|
791
|
+
// vallueGetter?: NodePropertyGetterCallback;
|
|
792
|
+
/** Sort order. @default Use value from column definition (rotated).*/
|
|
793
|
+
order?: SortOrderType;
|
|
794
|
+
/**
|
|
795
|
+
* Sort by this property if order is `undefined`.
|
|
796
|
+
* See also {@link WunderbaumNode.resetNativeChildOrder}.
|
|
797
|
+
* @default `_nativeIndex`.
|
|
798
|
+
*/
|
|
799
|
+
nativeOrderPropName?: string;
|
|
800
|
+
/** Sort string values case insensitive. @default false */
|
|
801
|
+
caseInsensitive?: boolean;
|
|
802
|
+
/** Sort descendants recursively. @default true */
|
|
803
|
+
deep?: boolean;
|
|
804
|
+
// /** Rotate sort order (asc -> desc -> none) before sorting. @default false */
|
|
805
|
+
// rotateOrder?: boolean;
|
|
806
|
+
/**
|
|
807
|
+
* Rotate sort order (asc -> desc -> none) before sorting.
|
|
808
|
+
* Update the sort icons in the column header
|
|
809
|
+
* Note:
|
|
810
|
+
* Sorting is done in-place. There is no 'unsorted' state, but we can
|
|
811
|
+
* call `setCurrentSortOrder()` to renumber the `node._sortIdx` property,
|
|
812
|
+
* which will be used as sort key, when `order` is `undefined`.
|
|
813
|
+
* @default false
|
|
814
|
+
*/
|
|
815
|
+
updateColInfo?: boolean;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/** Options passed to {@link Wunderbaum.visitRows}. */
|
|
723
819
|
export interface VisitRowsOptions {
|
|
724
820
|
/** Skip filtered nodes and children of collapsed nodes. @default false */
|
|
725
821
|
includeHidden?: boolean;
|
|
@@ -998,7 +1094,7 @@ export type DndOptionsType = {
|
|
|
998
1094
|
// */
|
|
999
1095
|
// setTextTypeJson: boolean;
|
|
1000
1096
|
/**
|
|
1001
|
-
* Optional callback passed to `toDict` on dragStart
|
|
1097
|
+
* Optional callback passed to `toDict` on dragStart
|
|
1002
1098
|
* @default null
|
|
1003
1099
|
* @category Callback
|
|
1004
1100
|
*/
|
package/src/util.ts
CHANGED
|
@@ -746,6 +746,12 @@ export function getOption(
|
|
|
746
746
|
return value ?? defaultValue;
|
|
747
747
|
}
|
|
748
748
|
|
|
749
|
+
/** Return the next value from a list of values (rotating). @since 0.11 */
|
|
750
|
+
export function rotate(value: any, values: any[]): any {
|
|
751
|
+
const idx = values.indexOf(value);
|
|
752
|
+
return values[(idx + 1) % values.length];
|
|
753
|
+
}
|
|
754
|
+
|
|
749
755
|
/** Convert an Array or space-separated string to a Set. */
|
|
750
756
|
export function toSet(val: any): Set<string> {
|
|
751
757
|
if (val instanceof Set) {
|
|
@@ -776,12 +782,8 @@ export function toSet(val: any): Set<string> {
|
|
|
776
782
|
* ```
|
|
777
783
|
*/
|
|
778
784
|
export function toPixel(
|
|
779
|
-
// val: string | number | undefined | null,
|
|
780
785
|
...defaults: (string | number | undefined | null)[]
|
|
781
786
|
): number {
|
|
782
|
-
// if (typeof val === "number") {
|
|
783
|
-
// return val;
|
|
784
|
-
// }
|
|
785
787
|
for (const d of defaults) {
|
|
786
788
|
if (typeof d === "number") {
|
|
787
789
|
return d;
|
|
@@ -802,12 +804,8 @@ export function toPixel(
|
|
|
802
804
|
* ```
|
|
803
805
|
*/
|
|
804
806
|
export function toBool(
|
|
805
|
-
// val: boolean | undefined | null,
|
|
806
807
|
...boolDefaults: (boolean | undefined | null)[]
|
|
807
808
|
): boolean {
|
|
808
|
-
// if (val != null) {
|
|
809
|
-
// return !!val;
|
|
810
|
-
// }
|
|
811
809
|
for (const d of boolDefaults) {
|
|
812
810
|
if (d != null) {
|
|
813
811
|
return !!d;
|
|
@@ -816,6 +814,18 @@ export function toBool(
|
|
|
816
814
|
throw new Error("No default boolean value provided");
|
|
817
815
|
}
|
|
818
816
|
|
|
817
|
+
/**
|
|
818
|
+
* Return `val` unless `val` is a number in which case we convert to boolean.
|
|
819
|
+
* This is useful when a boolean value is stored as a 0/1 (e.g. in JSON) and
|
|
820
|
+
* we still want to maintain string values. null and undefined are returned as
|
|
821
|
+
* is. E.g. `checkbox` may be boolean or 'radio'.
|
|
822
|
+
*/
|
|
823
|
+
export function intToBool(
|
|
824
|
+
val: boolean | number | string | undefined
|
|
825
|
+
): boolean | string | undefined {
|
|
826
|
+
return typeof val === "number" ? !!val : val;
|
|
827
|
+
}
|
|
828
|
+
|
|
819
829
|
// /** Check if a string is contained in an Array or Set. */
|
|
820
830
|
// export function isAnyOf(s: string, items: Array<string>|Set<string>): boolean {
|
|
821
831
|
// return Array.prototype.includes.call(items, s)
|
package/src/wb_ext_dnd.ts
CHANGED
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
DropRegionType,
|
|
15
15
|
DropRegionTypeSet,
|
|
16
16
|
} from "./types";
|
|
17
|
-
import { ROW_HEIGHT } from "./common";
|
|
18
17
|
import { DebouncedFunction, throttle } from "./debounce";
|
|
19
18
|
|
|
20
19
|
const nodeMimeType = "application/x-wunderbaum-node";
|
|
@@ -135,21 +134,22 @@ export class DndExtension extends WunderbaumExtension<DndOptionsType> {
|
|
|
135
134
|
e: DragEvent,
|
|
136
135
|
allowed: DropRegionTypeSet | null
|
|
137
136
|
): DropRegionType | false {
|
|
137
|
+
const rowHeight = this.tree.options.rowHeightPx!;
|
|
138
138
|
const dy = e.offsetY;
|
|
139
139
|
|
|
140
140
|
if (!allowed) {
|
|
141
141
|
return false;
|
|
142
142
|
} else if (allowed.size === 3) {
|
|
143
|
-
return dy < 0.25 *
|
|
143
|
+
return dy < 0.25 * rowHeight
|
|
144
144
|
? "before"
|
|
145
|
-
: dy > 0.75 *
|
|
145
|
+
: dy > 0.75 * rowHeight
|
|
146
146
|
? "after"
|
|
147
147
|
: "over";
|
|
148
148
|
} else if (allowed.size === 1 && allowed.has("over")) {
|
|
149
149
|
return "over";
|
|
150
150
|
} else {
|
|
151
151
|
// Only 'before' and 'after':
|
|
152
|
-
return dy >
|
|
152
|
+
return dy > rowHeight / 2 ? "after" : "before";
|
|
153
153
|
}
|
|
154
154
|
// return "over";
|
|
155
155
|
}
|
|
@@ -452,7 +452,12 @@ export class DndExtension extends WunderbaumExtension<DndOptionsType> {
|
|
|
452
452
|
}
|
|
453
453
|
this.lastAllowedDropRegions = regionSet;
|
|
454
454
|
this.lastDropEffect = dt.dropEffect;
|
|
455
|
+
|
|
456
|
+
const region = this._calcDropRegion(e, this.lastAllowedDropRegions);
|
|
455
457
|
targetNode.setClass("wb-drop-target");
|
|
458
|
+
targetNode.setClass("wb-drop-over", region === "over");
|
|
459
|
+
targetNode.setClass("wb-drop-before", region === "before");
|
|
460
|
+
targetNode.setClass("wb-drop-after", region === "after");
|
|
456
461
|
|
|
457
462
|
e.preventDefault(); // Allow drop (Drop operation is denied by default)
|
|
458
463
|
return false;
|
package/src/wb_ext_edit.ts
CHANGED
|
@@ -213,6 +213,10 @@ export class EditExtension extends WunderbaumExtension<EditOptionsType> {
|
|
|
213
213
|
if (!node) {
|
|
214
214
|
return;
|
|
215
215
|
}
|
|
216
|
+
if (node.isStatusNode()) {
|
|
217
|
+
node.logWarn("Cannot edit status node.");
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
216
220
|
this.tree.logDebug(`startEditTitle(node=${node})`);
|
|
217
221
|
let inputHtml = node._callEvent("edit.beforeEdit");
|
|
218
222
|
if (inputHtml === false) {
|
package/src/wb_ext_grid.ts
CHANGED
|
@@ -29,7 +29,7 @@ export class GridExtension extends WunderbaumExtension<GridOptionsType> {
|
|
|
29
29
|
const allow =
|
|
30
30
|
colDef &&
|
|
31
31
|
this.tree.element.contains(e.dragElem) &&
|
|
32
|
-
toBool(colDef.resizable, tree.options.
|
|
32
|
+
toBool(colDef.resizable, tree.options.columnsResizable, false);
|
|
33
33
|
|
|
34
34
|
// this.tree.log("dragstart", colDef, e, info);
|
|
35
35
|
|