Skip to content

Commit

Permalink
Fix typing of tree.options.dnd.dropEffect and others
Browse files Browse the repository at this point in the history
Close #73
  • Loading branch information
mar10 committed Jan 16, 2024
1 parent e20e01f commit ec8f9ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ First release.
- v0.8.1: Fix #76: Lazyload could be called for the same node multiple times
- v0.8.1: Fix #75: After reloading nodes with "resetLazy", wunderbaum is broken
- v0.8.1: Fix #73: Fix typing of `tree.options.dnd.dropEffect` and others
- v0.8.1: Fix #72: DragEnter event does not provide the source node, only the target
- Thanks to @jogibear9988 for the testing and opening #72, #73, #75, #76

- v0.8.0: Add `expand(e)` and `beforeExpand(e)` events.
- v0.8.0: Add `tree.findByRefKey()`, `node.getCloneList()`, and `node.isClone()`.
Expand Down
32 changes: 23 additions & 9 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,22 @@ export type DropRegionTypeSet = Set<DropRegionType>;
// | "none" // == false == "" == null
// | "over"; // == "child"

export interface DragEventType extends WbNodeEventType {
/** The original event. */
event: DragEvent;
/** The source node. */
node: WunderbaumNode;
}

export interface DropEventType extends WbNodeEventType {
/** The original event. */
event: DragEvent;
/** The target node. */
node: WunderbaumNode;
/** The source node if any. */
sourceNode: WunderbaumNode;
}

export type DndOptionsType = {
/**
* Expand nodes after n milliseconds of hovering
Expand Down Expand Up @@ -995,19 +1011,19 @@ export type DndOptionsType = {
* @default null
* @category Callback
*/
dragStart?: null | ((e: WbNodeEventType & { event: DragEvent }) => boolean);
dragStart?: null | ((e: DragEventType) => boolean);
/**
* Callback(sourceNode, data)
* @default null
* @category Callback
*/
drag?: null | ((e: WbNodeEventType & { event: DragEvent }) => void);
drag?: null | ((e: DragEventType) => void);
/**
* Callback(sourceNode, data)
* @default null
* @category Callback
*/
dragEnd?: null | ((e: WbNodeEventType & { event: DragEvent }) => void);
dragEnd?: null | ((e: DragEventType) => void);
// Events (drop support)
/**
* Callback(targetNode, data), return true, to enable dnd drop
Expand All @@ -1016,21 +1032,19 @@ export type DndOptionsType = {
*/
dragEnter?:
| null
| ((
e: WbNodeEventType & { event: DragEvent }
) => DropRegionTypeSet | boolean);
| ((e: DropEventType) => DropRegionType | DropRegionTypeSet | boolean);
/**
* Callback(targetNode, data)
* @default null
* @category Callback
*/
dragOver?: null | ((e: WbNodeEventType & { event: DragEvent }) => void);
dragOver?: null | ((e: DropEventType) => void);
/**
* Callback(targetNode, data), return false to prevent autoExpand
* @default null
* @category Callback
*/
dragExpand?: null | ((e: WbNodeEventType & { event: DragEvent }) => boolean);
dragExpand?: null | ((e: DropEventType) => boolean);
/**
* Callback(targetNode, data)
* @default null
Expand All @@ -1053,7 +1067,7 @@ export type DndOptionsType = {
* @default null
* @category Callback
*/
dragLeave?: null;
dragLeave?: null | ((e: DropEventType) => void);
};

/* -----------------------------------------------------------------------------
Expand Down

0 comments on commit ec8f9ce

Please sign in to comment.