@neo4j-nvl/react 0.2.6 → 0.2.8
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.
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import type NVL from '@neo4j-nvl/core';
|
|
2
|
-
import type { ClickInteractionOptions, HoverInteractionOptions, MultiSelectInteractionOptions } from '@neo4j-nvl/interaction-handlers';
|
|
2
|
+
import type { ClickInteractionOptions, ClickInteractionCallbacks, HoverInteractionOptions, MultiSelectInteractionOptions, MultiSelectInteractionCallbacks, DragNodeInteractionCallbacks, HoverInteractionCallbacks, PanInteractionCallbacks, ZoomInteractionCallbacks, DrawInteractionCallbacks } from '@neo4j-nvl/interaction-handlers';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import type { BasicReactWrapperProps } from '../basic-wrapper/BasicNvlWrapper';
|
|
5
5
|
/**
|
|
6
6
|
* The events that can be passed to the {@link MouseEventCallbacks} object
|
|
7
7
|
* to turn on/off certain events for the {@link InteractiveNvlWrapper} component.
|
|
8
8
|
*/
|
|
9
|
-
export type MouseEvent = 'onHover' | 'onNodeClick' | 'onNodeRightClick' | 'onNodeDoubleClick' | 'onRelationshipClick' | 'onRelationshipDoubleClick' | 'onRelationshipRightClick' | 'onCanvasClick' | 'onCanvasDoubleClick' | 'onCanvasRightClick' | 'onDrag' | '
|
|
10
|
-
|
|
11
|
-
* An object to turn on/off certain events and provide callbacks for all {@link MouseEvent}s
|
|
12
|
-
* for the {@link InteractiveNvlWrapper} component.
|
|
13
|
-
*/
|
|
14
|
-
export type MouseEventCallbacks<T extends string = MouseEvent> = {
|
|
15
|
-
[K in T]?: ((...args: unknown[]) => void) | boolean;
|
|
16
|
-
};
|
|
9
|
+
export type MouseEvent = 'onHover' | 'onNodeClick' | 'onNodeRightClick' | 'onNodeDoubleClick' | 'onRelationshipClick' | 'onRelationshipDoubleClick' | 'onRelationshipRightClick' | 'onCanvasClick' | 'onCanvasDoubleClick' | 'onCanvasRightClick' | 'onDrag' | 'onDrawEnd' | 'onMultiSelect' | 'onPan' | 'onZoom';
|
|
10
|
+
export type MouseEventCallbacks = ClickInteractionCallbacks & DragNodeInteractionCallbacks & HoverInteractionCallbacks & PanInteractionCallbacks & ZoomInteractionCallbacks & MultiSelectInteractionCallbacks & DrawInteractionCallbacks;
|
|
17
11
|
export type InteractionOptions = ClickInteractionOptions & MultiSelectInteractionOptions & HoverInteractionOptions;
|
|
18
12
|
/**
|
|
19
13
|
* The properties that can be passed to the {@link InteractiveNvlWrapper} component.
|
|
@@ -67,9 +67,9 @@ const useInteractionEffect = (interaction, interactionRef, callback, eventName,
|
|
|
67
67
|
* </>
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
|
-
export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, mouseEventCallbacks
|
|
70
|
+
export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, mouseEventCallbacks, nvlCallbacks, nvlOptions = {}, interactionOptions = options }, nvlRef) => {
|
|
71
71
|
const myNvlRef = nvlRef !== null ? nvlRef : useRef(null);
|
|
72
|
-
const { onHover, onNodeClick, onNodeDoubleClick, onNodeRightClick, onRelationshipClick, onRelationshipDoubleClick, onRelationshipRightClick, onCanvasClick, onCanvasRightClick, onPan, onZoom, onDrag,
|
|
72
|
+
const { onHover, onNodeClick, onNodeDoubleClick, onNodeRightClick, onRelationshipClick, onRelationshipDoubleClick, onRelationshipRightClick, onCanvasClick, onCanvasRightClick, onPan, onZoom, onDrag, onDrawEnd, onMultiSelect } = mouseEventCallbacks;
|
|
73
73
|
const hoverInteraction = useRef();
|
|
74
74
|
const clickInteraction = useRef();
|
|
75
75
|
const panInteraction = useRef();
|
|
@@ -89,7 +89,7 @@ export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, layout, lay
|
|
|
89
89
|
useInteractionEffect(PanInteraction, panInteraction, onPan, 'onPan', myNvlRef, interactionOptions);
|
|
90
90
|
useInteractionEffect(ZoomInteraction, zoomInteraction, onZoom, 'onZoom', myNvlRef, interactionOptions);
|
|
91
91
|
useInteractionEffect(DragNodeInteraction, dragNodeInteraction, onDrag, 'onDrag', myNvlRef, interactionOptions);
|
|
92
|
-
useInteractionEffect(DrawInteraction, drawInteraction,
|
|
92
|
+
useInteractionEffect(DrawInteraction, drawInteraction, onDrawEnd, 'onDrawEnd', myNvlRef, interactionOptions);
|
|
93
93
|
useInteractionEffect(MultiSelectInteraction, multiSelectInteraction, onMultiSelect, 'onMultiSelect', myNvlRef, interactionOptions);
|
|
94
94
|
useEffect(() => () => {
|
|
95
95
|
destroyInteraction(hoverInteraction);
|