@neo4j-nvl/react 0.2.42 → 0.2.44
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,14 +1,14 @@
|
|
|
1
1
|
import type NVL from '@neo4j-nvl/core';
|
|
2
|
-
import type { ClickInteractionCallbacks, ClickInteractionOptions, DragNodeInteractionCallbacks, DrawInteractionCallbacks, HoverInteractionCallbacks, HoverInteractionOptions,
|
|
2
|
+
import type { BoxSelectInteractionCallbacks, BoxSelectInteractionOptions, ClickInteractionCallbacks, ClickInteractionOptions, DragNodeInteractionCallbacks, DrawInteractionCallbacks, HoverInteractionCallbacks, HoverInteractionOptions, LassoInteractionCallbacks, LassoInteractionOptions, PanInteractionCallbacks, PanInteractionOptions, ZoomInteractionCallbacks } 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' | 'onDragStart' | 'onDragEnd' | 'onDrawEnd' | '
|
|
10
|
-
export type MouseEventCallbacks = ClickInteractionCallbacks & DragNodeInteractionCallbacks & HoverInteractionCallbacks & PanInteractionCallbacks & ZoomInteractionCallbacks &
|
|
11
|
-
export type InteractionOptions = ClickInteractionOptions &
|
|
9
|
+
export type MouseEvent = 'onHover' | 'onNodeClick' | 'onNodeRightClick' | 'onNodeDoubleClick' | 'onRelationshipClick' | 'onRelationshipDoubleClick' | 'onRelationshipRightClick' | 'onCanvasClick' | 'onCanvasDoubleClick' | 'onCanvasRightClick' | 'onDrag' | 'onDragStart' | 'onDragEnd' | 'onDrawEnd' | 'onPan' | 'onZoom' | 'onBoxStarted' | 'onBoxSelect' | 'onLassoStarted' | 'onLassoSelect';
|
|
10
|
+
export type MouseEventCallbacks = ClickInteractionCallbacks & DragNodeInteractionCallbacks & HoverInteractionCallbacks & PanInteractionCallbacks & ZoomInteractionCallbacks & BoxSelectInteractionCallbacks & DrawInteractionCallbacks & LassoInteractionCallbacks;
|
|
11
|
+
export type InteractionOptions = ClickInteractionOptions & BoxSelectInteractionOptions & HoverInteractionOptions & PanInteractionOptions & LassoInteractionOptions;
|
|
12
12
|
/**
|
|
13
13
|
* The properties that can be passed to the {@link InteractiveNvlWrapper} component.
|
|
14
14
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClickInteraction, DragNodeInteraction, DrawInteraction, HoverInteraction,
|
|
1
|
+
import { BoxSelectInteraction, ClickInteraction, DragNodeInteraction, DrawInteraction, HoverInteraction, LassoInteraction, PanInteraction, ZoomInteraction } from '@neo4j-nvl/interaction-handlers';
|
|
2
2
|
import React, { forwardRef, memo, useEffect, useRef } from 'react';
|
|
3
3
|
import { BasicNvlWrapper } from '../basic-wrapper/BasicNvlWrapper';
|
|
4
4
|
const options = {
|
|
@@ -71,7 +71,7 @@ const useInteractionEffect = (interaction, interactionRef, callback, eventName,
|
|
|
71
71
|
*/
|
|
72
72
|
export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, mouseEventCallbacks = {}, nvlCallbacks = {}, nvlOptions = {}, interactionOptions = options }, nvlRef) => {
|
|
73
73
|
const myNvlRef = nvlRef !== null ? nvlRef : useRef(null);
|
|
74
|
-
const { onHover, onNodeClick, onNodeDoubleClick, onNodeRightClick, onRelationshipClick, onRelationshipDoubleClick, onRelationshipRightClick, onCanvasClick, onCanvasRightClick, onPan, onZoom, onDrag, onDragStart, onDragEnd, onDrawEnd,
|
|
74
|
+
const { onHover, onNodeClick, onNodeDoubleClick, onNodeRightClick, onRelationshipClick, onRelationshipDoubleClick, onRelationshipRightClick, onCanvasClick, onCanvasRightClick, onPan, onZoom, onDrag, onDragStart, onDragEnd, onDrawEnd, onBoxStarted, onBoxSelect, onLassoStarted, onLassoSelect } = mouseEventCallbacks;
|
|
75
75
|
const hoverInteraction = useRef();
|
|
76
76
|
const clickInteraction = useRef();
|
|
77
77
|
const panInteraction = useRef();
|
|
@@ -79,6 +79,7 @@ export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, layout, lay
|
|
|
79
79
|
const dragNodeInteraction = useRef();
|
|
80
80
|
const drawInteraction = useRef();
|
|
81
81
|
const multiSelectInteraction = useRef();
|
|
82
|
+
const lassoInteraction = useRef();
|
|
82
83
|
useInteractionEffect(HoverInteraction, hoverInteraction, onHover, 'onHover', myNvlRef, interactionOptions);
|
|
83
84
|
useInteractionEffect(ClickInteraction, clickInteraction, onNodeClick, 'onNodeClick', myNvlRef, interactionOptions);
|
|
84
85
|
useInteractionEffect(ClickInteraction, clickInteraction, onNodeDoubleClick, 'onNodeDoubleClick', myNvlRef, interactionOptions);
|
|
@@ -94,7 +95,10 @@ export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, layout, lay
|
|
|
94
95
|
useInteractionEffect(DragNodeInteraction, dragNodeInteraction, onDragStart, 'onDragStart', myNvlRef, interactionOptions);
|
|
95
96
|
useInteractionEffect(DragNodeInteraction, dragNodeInteraction, onDragEnd, 'onDragEnd', myNvlRef, interactionOptions);
|
|
96
97
|
useInteractionEffect(DrawInteraction, drawInteraction, onDrawEnd, 'onDrawEnd', myNvlRef, interactionOptions);
|
|
97
|
-
useInteractionEffect(
|
|
98
|
+
useInteractionEffect(BoxSelectInteraction, multiSelectInteraction, onBoxStarted, 'onBoxStarted', myNvlRef, interactionOptions);
|
|
99
|
+
useInteractionEffect(BoxSelectInteraction, multiSelectInteraction, onBoxSelect, 'onBoxSelect', myNvlRef, interactionOptions);
|
|
100
|
+
useInteractionEffect(LassoInteraction, lassoInteraction, onLassoStarted, 'onLassoStarted', myNvlRef, interactionOptions);
|
|
101
|
+
useInteractionEffect(LassoInteraction, lassoInteraction, onLassoSelect, 'onLassoSelect', myNvlRef, interactionOptions);
|
|
98
102
|
useEffect(() => () => {
|
|
99
103
|
destroyInteraction(hoverInteraction);
|
|
100
104
|
destroyInteraction(clickInteraction);
|
|
@@ -103,6 +107,7 @@ export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, layout, lay
|
|
|
103
107
|
destroyInteraction(dragNodeInteraction);
|
|
104
108
|
destroyInteraction(drawInteraction);
|
|
105
109
|
destroyInteraction(multiSelectInteraction);
|
|
110
|
+
destroyInteraction(lassoInteraction);
|
|
106
111
|
}, []);
|
|
107
112
|
return (React.createElement(BasicNvlWrapper, { ref: myNvlRef, nodes: nodes, rels: rels, nvlOptions: nvlOptions, nvlCallbacks: nvlCallbacks, layout: layout, layoutOptions: layoutOptions }));
|
|
108
113
|
}));
|