wunderbaum 0.5.4 → 0.6.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 +14 -23
- package/dist/wunderbaum.d.ts +43 -15
- package/dist/wunderbaum.esm.js +167 -98
- package/dist/wunderbaum.esm.min.js +22 -22
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +167 -98
- package/dist/wunderbaum.umd.min.js +25 -25
- package/dist/wunderbaum.umd.min.js.map +1 -1
- package/package.json +3 -1
- package/src/common.ts +4 -1
- package/src/types.ts +38 -12
- package/src/util.ts +2 -2
- package/src/wb_ext_dnd.ts +130 -69
- package/src/wb_ext_edit.ts +7 -4
- package/src/wb_node.ts +31 -15
- package/src/wunderbaum.ts +19 -12
package/README.md
CHANGED
|
@@ -2,37 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/mar10/wunderbaum/releases/latest)
|
|
4
4
|
[](https://github.com/mar10/wunderbaum/actions/workflows/node.js.yml)
|
|
5
|
-
[](https://travis-ci.com/github/mar10/wunderbaum)
|
|
6
5
|
[](https://www.npmjs.com/package/wunderbaum)
|
|
7
6
|
[](https://www.jsdelivr.com/package/npm/wunderbaum)
|
|
8
7
|
[](https://github.com/mar10/grunt-yabs)
|
|
9
8
|
[](https://stackoverflow.com/questions/tagged/wunderbaum)
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
<!-- [](https://travis-ci.com/github/mar10/wunderbaum) -->
|
|
11
|
+
|
|
12
|
+
> Potential successor of [Fancytree](https://github.com/mar10/fancytree).
|
|
13
|
+
|
|
14
|
+
**NOTE: Status _beta_. Do not use in production!**
|
|
12
15
|
|
|
13
16
|
[](https://mar10.github.io/wunderbaum/demo/)
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Drop legacy support (IE, jQuery, ...).
|
|
25
|
-
- Built-in support for
|
|
26
|
-
<!-- [aria](https://www.w3.org/TR/wai-aria-1.1/), -->
|
|
27
|
-
[drag and drop](https://mar10.github.io/wunderbaum/#/tutorial/tutorial_dnd),
|
|
28
|
-
[editing](https://mar10.github.io/wunderbaum/#/tutorial/tutorial_edit),
|
|
29
|
-
[filtering](https://mar10.github.io/wunderbaum/#/tutorial/tutorial_filter),
|
|
30
|
-
[multi-selection](https://mar10.github.io/wunderbaum/#/tutorial/tutorial_select).
|
|
31
|
-
- Fully [controllable using the keyboard](https://mar10.github.io/wunderbaum/#/tutorial/tutorial_keyboard).
|
|
32
|
-
- Framework agnostic.
|
|
33
|
-
- Written in TypeScript, transpiled to JavaScript ES6 with type hints (.esm & .umd).
|
|
34
|
-
<!-- - Good documentation. -->
|
|
35
|
-
<!-- - Decent test coverage. -->
|
|
18
|
+
<center>
|
|
19
|
+
Supports drag and drop,, editing, filtering, and multi-selection.<br>
|
|
20
|
+
Written in TypeScript, transpiled to ES6 (esm & umd).<br>
|
|
21
|
+
Performant handling of big data structures.<br>
|
|
22
|
+
Provide an object oriented API.<br>
|
|
23
|
+
Framework agnostic.<br>
|
|
24
|
+
Zero dependencies.<br>
|
|
25
|
+
Keyboard support.
|
|
26
|
+
</center>
|
|
36
27
|
|
|
37
28
|
### Details
|
|
38
29
|
|
package/dist/wunderbaum.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ declare module "util" {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
/**Throw an `Error` if `cond` is falsey. */
|
|
37
|
-
export function assert(cond: any, msg
|
|
37
|
+
export function assert(cond: any, msg: string): void;
|
|
38
38
|
/** Run `callback` when document was loaded. */
|
|
39
39
|
export function documentReady(callback: () => void): void;
|
|
40
40
|
/** Resolve when document was loaded. */
|
|
@@ -1790,6 +1790,8 @@ declare module "types" {
|
|
|
1790
1790
|
};
|
|
1791
1791
|
export type GridOptionsType = object;
|
|
1792
1792
|
export type InsertNodeType = "before" | "after" | "prependChild" | "appendChild";
|
|
1793
|
+
export type DropEffectType = "none" | "copy" | "link" | "move";
|
|
1794
|
+
export type DropEffectAllowedType = "none" | "copy" | "copyLink" | "copyMove" | "link" | "linkMove" | "move" | "all";
|
|
1793
1795
|
export type DropRegionType = "over" | "before" | "after";
|
|
1794
1796
|
export type DropRegionTypeSet = Set<DropRegionType>;
|
|
1795
1797
|
export type DndOptionsType = {
|
|
@@ -1804,15 +1806,26 @@ declare module "types" {
|
|
|
1804
1806
|
*/
|
|
1805
1807
|
multiSource?: false;
|
|
1806
1808
|
/**
|
|
1807
|
-
* Restrict the possible cursor shapes and modifier operations
|
|
1809
|
+
* Restrict the possible cursor shapes and modifier operations
|
|
1810
|
+
* (can also be set in the dragStart event)
|
|
1808
1811
|
* @default "all"
|
|
1809
1812
|
*/
|
|
1810
|
-
effectAllowed?:
|
|
1813
|
+
effectAllowed?: DropEffectAllowedType;
|
|
1811
1814
|
/**
|
|
1812
|
-
* Default dropEffect ('copy', 'link', or 'move') when no modifier is pressed
|
|
1815
|
+
* Default dropEffect ('copy', 'link', or 'move') when no modifier is pressed.
|
|
1816
|
+
* Overidable in the dragEnter or dragOver event.
|
|
1813
1817
|
* @default "move"
|
|
1814
1818
|
*/
|
|
1815
|
-
dropEffectDefault?:
|
|
1819
|
+
dropEffectDefault?: DropEffectType;
|
|
1820
|
+
/**
|
|
1821
|
+
* Use opinionated heuristics to determine the dropEffect ('copy', 'link', or 'move')
|
|
1822
|
+
* based on `effectAllowed`, `dropEffectDefault`, and modifier keys.
|
|
1823
|
+
* This is recalculated before each dragEnter and dragOver event and can be
|
|
1824
|
+
* overridden there.
|
|
1825
|
+
*
|
|
1826
|
+
* @default true
|
|
1827
|
+
*/
|
|
1828
|
+
guessDropEffect: boolean;
|
|
1816
1829
|
/**
|
|
1817
1830
|
* Prevent dropping nodes from different Wunderbaum trees
|
|
1818
1831
|
* @default false
|
|
@@ -1847,7 +1860,7 @@ declare module "types" {
|
|
|
1847
1860
|
* Serialize Node Data to datatransfer object
|
|
1848
1861
|
* @default true
|
|
1849
1862
|
*/
|
|
1850
|
-
serializeClipboardData?: boolean | ((nodeData: WbNodeData) => string);
|
|
1863
|
+
serializeClipboardData?: boolean | ((nodeData: WbNodeData, node: WunderbaumNode) => string);
|
|
1851
1864
|
/**
|
|
1852
1865
|
* Enable auto-scrolling while dragging
|
|
1853
1866
|
* @default true
|
|
@@ -1895,7 +1908,7 @@ declare module "types" {
|
|
|
1895
1908
|
*/
|
|
1896
1909
|
dragEnter?: null | ((e: WbNodeEventType & {
|
|
1897
1910
|
event: DragEvent;
|
|
1898
|
-
}) => boolean);
|
|
1911
|
+
}) => DropRegionTypeSet | boolean);
|
|
1899
1912
|
/**
|
|
1900
1913
|
* Callback(targetNode, data)
|
|
1901
1914
|
* @default null
|
|
@@ -1917,8 +1930,10 @@ declare module "types" {
|
|
|
1917
1930
|
drop?: null | ((e: WbNodeEventType & {
|
|
1918
1931
|
event: DragEvent;
|
|
1919
1932
|
region: DropRegionType;
|
|
1920
|
-
|
|
1933
|
+
suggestedDropMode: InsertNodeType;
|
|
1934
|
+
suggestedDropEffect: DropEffectType;
|
|
1921
1935
|
sourceNode: WunderbaumNode;
|
|
1936
|
+
sourceNodeData: WbNodeData | null;
|
|
1922
1937
|
}) => void);
|
|
1923
1938
|
/**
|
|
1924
1939
|
* Callback(targetNode, data)
|
|
@@ -2137,14 +2152,14 @@ declare module "wb_ext_dnd" {
|
|
|
2137
2152
|
import { Wunderbaum } from "wunderbaum";
|
|
2138
2153
|
import { WunderbaumExtension } from "wb_extension_base";
|
|
2139
2154
|
import { WunderbaumNode } from "wb_node";
|
|
2140
|
-
import { DndOptionsType, DropRegionType, DropRegionTypeSet } from "types";
|
|
2155
|
+
import { DndOptionsType, DropEffectType, DropRegionType, DropRegionTypeSet } from "types";
|
|
2141
2156
|
import { DebouncedFunction } from "debounce";
|
|
2142
2157
|
export class DndExtension extends WunderbaumExtension<DndOptionsType> {
|
|
2143
2158
|
protected srcNode: WunderbaumNode | null;
|
|
2144
2159
|
protected lastTargetNode: WunderbaumNode | null;
|
|
2145
2160
|
protected lastEnterStamp: number;
|
|
2146
2161
|
protected lastAllowedDropRegions: DropRegionTypeSet | null;
|
|
2147
|
-
protected lastDropEffect:
|
|
2162
|
+
protected lastDropEffect: DropEffectType | null;
|
|
2148
2163
|
protected lastDropRegion: DropRegionType | false;
|
|
2149
2164
|
protected currentScrollDir: number;
|
|
2150
2165
|
protected applyScrollDirThrottled: DebouncedFunction<() => void>;
|
|
@@ -2158,12 +2173,25 @@ declare module "wb_ext_dnd" {
|
|
|
2158
2173
|
* Calculates the drop region based on the drag event and the allowed drop regions.
|
|
2159
2174
|
*/
|
|
2160
2175
|
protected _calcDropRegion(e: DragEvent, allowed: DropRegionTypeSet | null): DropRegionType | false;
|
|
2161
|
-
|
|
2162
|
-
|
|
2176
|
+
/**
|
|
2177
|
+
* Guess drop effect (copy/link/move) using opinionated conventions.
|
|
2178
|
+
*
|
|
2179
|
+
* Default: dnd.dropEffectDefault
|
|
2180
|
+
*/
|
|
2181
|
+
protected _guessDropEffect(e: DragEvent): DropEffectType;
|
|
2182
|
+
/** Don't allow void operation ('drop on self').*/
|
|
2183
|
+
protected _isVoidDrop(targetNode: WunderbaumNode, srcNode: WunderbaumNode | null, dropRegion: DropRegionType | false): boolean;
|
|
2184
|
+
protected _applyScrollDir(): void;
|
|
2185
|
+
protected _autoScroll(viewportY: number): number;
|
|
2163
2186
|
/** Return true if a drag operation currently in progress. */
|
|
2164
2187
|
isDragging(): boolean;
|
|
2188
|
+
/**
|
|
2189
|
+
* Handle dragstart, drag and dragend events for the source node.
|
|
2190
|
+
*/
|
|
2165
2191
|
protected onDragEvent(e: DragEvent): boolean;
|
|
2166
|
-
|
|
2192
|
+
/**
|
|
2193
|
+
* Handle dragenter, dragover, dragleave, drop events.
|
|
2194
|
+
*/
|
|
2167
2195
|
protected onDropEvent(e: DragEvent): boolean;
|
|
2168
2196
|
}
|
|
2169
2197
|
}
|
|
@@ -2670,9 +2698,9 @@ declare module "wunderbaum" {
|
|
|
2670
2698
|
isEnabled(): boolean;
|
|
2671
2699
|
/** Return true if tree has more than one column, i.e. has additional data columns. */
|
|
2672
2700
|
isGrid(): boolean;
|
|
2673
|
-
/** Return true if cell-navigation mode is
|
|
2701
|
+
/** Return true if cell-navigation mode is active. */
|
|
2674
2702
|
isCellNav(): boolean;
|
|
2675
|
-
/** Return true if row-navigation mode is
|
|
2703
|
+
/** Return true if row-navigation mode is active. */
|
|
2676
2704
|
isRowNav(): boolean;
|
|
2677
2705
|
/** Set the tree's navigation mode. */
|
|
2678
2706
|
setCellNav(flag?: boolean): void;
|