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 CHANGED
@@ -2,37 +2,28 @@
2
2
 
3
3
  [![GitHub version](https://img.shields.io/github/v/release/mar10/wunderbaum?display_name=tag&sort=semver)](https://github.com/mar10/wunderbaum/releases/latest)
4
4
  [![Node.js CI](https://github.com/mar10/wunderbaum/actions/workflows/node.js.yml/badge.svg)](https://github.com/mar10/wunderbaum/actions/workflows/node.js.yml)
5
- [![Build Status](https://travis-ci.com/mar10/wunderbaum.svg?branch=main)](https://travis-ci.com/github/mar10/wunderbaum)
6
5
  [![npm](https://img.shields.io/npm/dm/wunderbaum.svg)](https://www.npmjs.com/package/wunderbaum)
7
6
  [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/wunderbaum/badge)](https://www.jsdelivr.com/package/npm/wunderbaum)
8
7
  [![Released with: grunt-yabs](https://img.shields.io/badge/released%20with-grunt--yabs-yellowgreen)](https://github.com/mar10/grunt-yabs)
9
8
  [![StackOverflow: wunderbaum](https://img.shields.io/badge/StackOverflow-wunderbaum-blue.svg)](https://stackoverflow.com/questions/tagged/wunderbaum)
10
9
 
11
- > Potential successor of [Fancytree](https://github.com/mar10/fancytree).<br> > **NOTE: Status _beta_. Do not use in production!**
10
+ <!-- [![Build Status](https://travis-ci.com/mar10/wunderbaum.svg?branch=main)](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
  [![Demo](docs/assets/teaser_2.png?raw=true)](https://mar10.github.io/wunderbaum/demo/)
14
17
 
15
- Wunderbaum is a rewrite of the [Fancytree](https://github.com/mar10/fancytree)
16
- library. Major features include
17
-
18
- - **Treegrid** control with emphasis on "tree".<br>
19
- Depending on the number of columns and nesting depth, Wunderbaum can also be
20
- used as a **plain tree**, **plain grid**, or a **simple list** control.
21
- - **Performant** and efficient handling of **big data structures**.
22
- - Use modern technologies with **zero dependencies** (except for icon fonts you
23
- may want to use).<br>
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
 
@@ -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?: string): void;
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 (can also be set in the dragStart event)
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?: "all";
1813
+ effectAllowed?: DropEffectAllowedType;
1811
1814
  /**
1812
- * Default dropEffect ('copy', 'link', or 'move') when no modifier is pressed (overide in drag, dragOver).
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?: string;
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
- defaultDropMode: string;
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: string | null;
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
- protected applyScrollDir(): void;
2162
- protected autoScroll(viewportY: number): number;
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
- private _isVoidDrop;
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 acive. */
2701
+ /** Return true if cell-navigation mode is active. */
2674
2702
  isCellNav(): boolean;
2675
- /** Return true if row-navigation mode is acive. */
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;