@neo4j-nvl/react 0.3.6-d168b648 → 0.3.6-d3b74ee8

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.
@@ -23,6 +23,8 @@ export interface BasicReactWrapperProps {
23
23
  nvlCallbacks?: ExternalCallbacks;
24
24
  /** An object containing options for the Nvl instance */
25
25
  nvlOptions?: NvlOptions;
26
+ /** Sets the positions of the nodes in the graph using the {@link NVL.setNodePositions} method. */
27
+ positions?: Node[];
26
28
  /** A callback to handle any errors that happen during NVL initialization */
27
29
  onInitializationError?: (error: unknown) => void;
28
30
  }
@@ -12,7 +12,7 @@ import { useDeepCompareEffect } from '../utils/hooks';
12
12
  *
13
13
  * For examples, head to the {@link https://neo4j.com/docs/nvl/current/react-wrappers/#_basic_react_wrapper Basic React wrapper documentation page}.
14
14
  */
15
- export const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, nvlCallbacks = {}, nvlOptions = {}, onInitializationError, ...nvlEvents }, ref) => {
15
+ export const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, nvlCallbacks = {}, nvlOptions = {}, positions = [], onInitializationError, ...nvlEvents }, ref) => {
16
16
  const nvlRef = useRef(null);
17
17
  useImperativeHandle(ref, () => {
18
18
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
@@ -107,5 +107,11 @@ export const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOpt
107
107
  }
108
108
  nvlRef.current.setDisableWebGL(nvlOptions.disableWebGL);
109
109
  }, [nvlOptions.disableWebGL]);
110
+ useEffect(() => {
111
+ if (nvlRef.current === null || positions.length === 0) {
112
+ return;
113
+ }
114
+ nvlRef.current.setNodePositions(positions);
115
+ }, [positions]);
110
116
  return _jsx("div", { id: BASIC_WRAPPER_ID, ref: containerRef, style: { height: '100%', outline: '0' }, ...nvlEvents });
111
117
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-nvl/react",
3
- "version": "0.3.6-d168b648",
3
+ "version": "0.3.6-d3b74ee8",
4
4
  "main": "lib/index.js",
5
5
  "homepage": "https://neo4j.com/docs/nvl/current/",
6
6
  "license": "SEE LICENSE IN 'LICENSE.txt'",
@@ -34,8 +34,8 @@
34
34
  "babel-eslint": "^10.1.0"
35
35
  },
36
36
  "dependencies": {
37
- "@neo4j-nvl/base": "0.3.6-d168b648",
38
- "@neo4j-nvl/interaction-handlers": "0.3.6-d168b648",
37
+ "@neo4j-nvl/base": "0.3.6-d3b74ee8",
38
+ "@neo4j-nvl/interaction-handlers": "0.3.6-d3b74ee8",
39
39
  "lodash": "4.17.21",
40
40
  "react": "^18.2.0",
41
41
  "react-dom": "^18.2.0"