@neo4j-nvl/react 0.3.1-854a900a → 0.3.1-bdd0eb1f
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 +1 -1
- package/lib/basic-wrapper/BasicNvlWrapper.d.ts +0 -2
- package/lib/basic-wrapper/BasicNvlWrapper.js +7 -3
- package/lib/interactive-nvl-wrapper/InteractiveNvlWrapper.d.ts +2 -1
- package/lib/interactive-nvl-wrapper/InteractiveNvlWrapper.js +2 -2
- package/lib/interactive-nvl-wrapper/hooks.js +5 -0
- package/package.json +15 -3
package/README.md
CHANGED
|
@@ -82,4 +82,4 @@ const [multiSelect, setMultiSelect] = useState(false)
|
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
|
|
85
|
-
You can also find more instructions and examples on how to use NVL in the docs.
|
|
85
|
+
You can also find more instructions and examples on how to use the NVL React wrappers in the [docs](https://neo4j.com/docs/nvl/current/react-wrappers/).
|
|
@@ -22,8 +22,6 @@ export interface BasicReactWrapperProps {
|
|
|
22
22
|
nvlOptions?: NvlOptions;
|
|
23
23
|
/** A callback to handle any errors that happen during NVL initialization */
|
|
24
24
|
onInitializationError?: (error: unknown) => void;
|
|
25
|
-
/** Any events that should be passed to the NVL instance */
|
|
26
|
-
nvlEvents?: Record<string, (event: unknown) => void>;
|
|
27
25
|
}
|
|
28
26
|
/**
|
|
29
27
|
* A basic React wrapper for the {@link NVL} class.
|
|
@@ -94,9 +94,13 @@ export const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOpt
|
|
|
94
94
|
const nvlMethods = Object.getOwnPropertyNames(NVL.prototype);
|
|
95
95
|
return nvlMethods.reduce((current, method) => ({
|
|
96
96
|
...current,
|
|
97
|
-
[method]: (...args) =>
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
[method]: (...args) => {
|
|
98
|
+
if (nvlRef.current === null) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
// @ts-ignore suppress the type casting error on spreading
|
|
102
|
+
return nvlRef.current[method](...args);
|
|
103
|
+
}
|
|
100
104
|
}),
|
|
101
105
|
// eslint-disable-next-line max-len
|
|
102
106
|
// eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter, @typescript-eslint/consistent-type-assertions
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type NVL from '@neo4j-nvl/base';
|
|
2
|
+
import type { HTMLProps } from 'react';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import type { InteractiveNvlWrapperProps } from './types';
|
|
4
5
|
/**
|
|
@@ -30,4 +31,4 @@ import type { InteractiveNvlWrapperProps } from './types';
|
|
|
30
31
|
* </>
|
|
31
32
|
* ```
|
|
32
33
|
*/
|
|
33
|
-
export declare const InteractiveNvlWrapper: React.MemoExoticComponent<React.ForwardRefExoticComponent<InteractiveNvlWrapperProps & React.RefAttributes<NVL>>>;
|
|
34
|
+
export declare const InteractiveNvlWrapper: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<InteractiveNvlWrapperProps & HTMLProps<HTMLDivElement>, "ref"> & React.RefAttributes<NVL>>>;
|
|
@@ -38,7 +38,7 @@ const options = {
|
|
|
38
38
|
* </>
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, mouseEventCallbacks = {}, nvlCallbacks = {}, nvlOptions = {}, interactionOptions = options }, nvlRef) => {
|
|
41
|
+
export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, mouseEventCallbacks = {}, nvlCallbacks = {}, nvlOptions = {}, interactionOptions = options, onInitializationError = null, ...nvlEvents }, nvlRef) => {
|
|
42
42
|
const newNvlRef = useRef(null);
|
|
43
43
|
const myNvlRef = nvlRef ?? newNvlRef;
|
|
44
44
|
const { onHover, onNodeClick, onNodeDoubleClick, onNodeRightClick, onRelationshipClick, onRelationshipDoubleClick, onRelationshipRightClick, onCanvasClick, onCanvasRightClick, onPan, onZoom, onDrag, onDragStart, onDragEnd, onDrawEnd, onHoverNodeMargin, onBoxStarted, onBoxSelect, onLassoStarted, onLassoSelect } = mouseEventCallbacks;
|
|
@@ -80,5 +80,5 @@ export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, layout, lay
|
|
|
80
80
|
destroyInteraction(multiSelectInteraction);
|
|
81
81
|
destroyInteraction(lassoInteraction);
|
|
82
82
|
}, []);
|
|
83
|
-
return (_jsx(BasicNvlWrapper, { ref: myNvlRef, nodes: nodes, rels: rels, nvlOptions: nvlOptions, nvlCallbacks: nvlCallbacks, layout: layout, layoutOptions: layoutOptions }));
|
|
83
|
+
return (_jsx(BasicNvlWrapper, { ref: myNvlRef, nodes: nodes, rels: rels, nvlOptions: nvlOptions, nvlCallbacks: nvlCallbacks, layout: layout, layoutOptions: layoutOptions, onInitializationError: onInitializationError, ...nvlEvents }));
|
|
84
84
|
}));
|
|
@@ -6,6 +6,11 @@ export const destroyInteraction = (interactionRef) => {
|
|
|
6
6
|
};
|
|
7
7
|
export const useInteraction = (Interaction, interactionRef, callback, eventName, nvlRef, interactionOptions) => {
|
|
8
8
|
useEffect(() => {
|
|
9
|
+
const container = nvlRef.current?.getContainer();
|
|
10
|
+
// Make sure we are not mounting interaction handlers when there is NVL setup
|
|
11
|
+
if (isNil(container)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
9
14
|
if ((callback === true || typeof callback === 'function') && !isNil(nvlRef.current)) {
|
|
10
15
|
if (isNil(interactionRef.current)) {
|
|
11
16
|
interactionRef.current = new Interaction(nvlRef.current, interactionOptions);
|
package/package.json
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-nvl/react",
|
|
3
|
-
"version": "0.3.1-
|
|
3
|
+
"version": "0.3.1-bdd0eb1f",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
|
+
"homepage": "https://neo4j.com/docs/nvl/current/",
|
|
5
6
|
"license": "SEE LICENSE IN 'LICENSE.txt'",
|
|
7
|
+
"description": "React wrappers for the Neo4j Visualization Library",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"neo4j",
|
|
10
|
+
"visualization",
|
|
11
|
+
"graph",
|
|
12
|
+
"react"
|
|
13
|
+
],
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://community.neo4j.com/c/neo4j-graph-platform/neo4j-bloom"
|
|
16
|
+
},
|
|
6
17
|
"scripts": {
|
|
7
18
|
"build": "tsc",
|
|
19
|
+
"watch": "tsc -w",
|
|
8
20
|
"test": "jest",
|
|
9
21
|
"prepack": "cp ../../LICENSE.txt ./",
|
|
10
22
|
"postpack": "rm LICENSE.txt"
|
|
@@ -29,8 +41,8 @@
|
|
|
29
41
|
"typescript": "^5.4.5"
|
|
30
42
|
},
|
|
31
43
|
"dependencies": {
|
|
32
|
-
"@neo4j-nvl/base": "^0.3.1-
|
|
33
|
-
"@neo4j-nvl/interaction-handlers": "^0.3.1-
|
|
44
|
+
"@neo4j-nvl/base": "^0.3.1-bdd0eb1f",
|
|
45
|
+
"@neo4j-nvl/interaction-handlers": "^0.3.1-bdd0eb1f",
|
|
34
46
|
"lodash": "4.17.21",
|
|
35
47
|
"react": "^18.2.0",
|
|
36
48
|
"react-dom": "^18.2.0"
|