@neo4j-nvl/react 1.2.0-645be73b → 1.2.0-676bec77

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/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to NVL will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
4
4
 
5
+ ## [1.2.1] - 2026-07-28
6
+
7
+ This 1.2.1 patch release contains several fixes and accessibility improvements.
8
+
9
+ ### Added
10
+ * Outline when the canvas is focused while using the keyboard interaction handlers.
11
+
12
+ ### Changed
13
+ * Renamed links in README from Explore to Neo4j Bloom.
14
+
15
+ ### Fixed
16
+ * Aligned padding on svg and png export.
17
+ * Aligned start behaviour of box and lasso select interaction handlers.
18
+ * Fixed static image wrapper React component returning incorrect height when using SVG format.
19
+ * Fixed self-referencing relationship captions being misplaced on downward curves.
20
+
5
21
  ## [1.2.0] - 2026-05-27
6
22
 
7
23
  This 1.2.0 release introduces a new keyboard interaction handler and SVG support for the static image wrapper React component. It also includes several performance improvements for clustering and text/icon rendering, as well as several bug fixes.
@@ -27,7 +27,11 @@ describe('BasicNvlWrapper', () => {
27
27
  });
28
28
  test('initialises NVL expectedly with a graph object and properties', () => {
29
29
  const mockLayoutDoneFunction = jest.fn();
30
- render(_jsx("div", { children: _jsx(BasicNvlWrapper, { nodes: [{ id: '1' }, { id: '2' }], rels: [{ id: '12', from: '1', to: '2' }], layout: HierarchicalLayoutType, layoutOptions: { direction: 'down' }, nvlOptions: { renderer: 'canvas' }, nvlCallbacks: { onLayoutDone: mockLayoutDoneFunction } }) }));
30
+ render(_jsx("div", { children: _jsx(BasicNvlWrapper, { nodes: [{ id: '1' }, { id: '2' }], rels: [{ id: '12', from: '1', to: '2' }], nvlOptions: {
31
+ renderer: 'canvas',
32
+ layout: HierarchicalLayoutType,
33
+ layoutOptions: { direction: 'down' }
34
+ }, nvlCallbacks: { onLayoutDone: mockLayoutDoneFunction } }) }));
31
35
  expect(NVL).toHaveBeenCalledWith(expect.any(HTMLDivElement), [{ id: '1' }, { id: '2' }], [{ id: '12', from: '1', to: '2' }], { renderer: 'canvas', layout: HierarchicalLayoutType, layoutOptions: { direction: 'down' } }, {
32
36
  onLayoutDone: mockLayoutDoneFunction
33
37
  });
@@ -132,4 +136,24 @@ describe('BasicNvlWrapper', () => {
132
136
  expect(setZoomAndPan).toHaveBeenCalledTimes(1);
133
137
  expect(setZoom).not.toHaveBeenCalled();
134
138
  });
139
+ test('calls setLayout when nvlOptions.layout changes', () => {
140
+ const setLayout = jest.fn();
141
+ jest.spyOn(NVL.prototype, 'setLayout').mockImplementation(setLayout);
142
+ const { rerender } = render(_jsx("div", { children: _jsx(BasicNvlWrapper, { nodes: [], rels: [], nvlOptions: { layout: HierarchicalLayoutType } }) }));
143
+ expect(setLayout).toHaveBeenCalledWith(HierarchicalLayoutType);
144
+ expect(setLayout).toHaveBeenCalledTimes(1);
145
+ rerender(_jsx("div", { children: _jsx(BasicNvlWrapper, { nodes: [], rels: [], nvlOptions: { layout: 'forceDirected' } }) }));
146
+ expect(setLayout).toHaveBeenCalledWith('forceDirected');
147
+ expect(setLayout).toHaveBeenCalledTimes(2);
148
+ });
149
+ test('calls setLayoutOptions when nvlOptions.layoutOptions changes', () => {
150
+ const setLayoutOptions = jest.fn();
151
+ jest.spyOn(NVL.prototype, 'setLayoutOptions').mockImplementation(setLayoutOptions);
152
+ const { rerender } = render(_jsx("div", { children: _jsx(BasicNvlWrapper, { nodes: [], rels: [], nvlOptions: { layoutOptions: { direction: 'down' } } }) }));
153
+ expect(setLayoutOptions).toHaveBeenCalledWith({ direction: 'down' });
154
+ expect(setLayoutOptions).toHaveBeenCalledTimes(1);
155
+ rerender(_jsx("div", { children: _jsx(BasicNvlWrapper, { nodes: [], rels: [], nvlOptions: { layoutOptions: { direction: 'up' } } }) }));
156
+ expect(setLayoutOptions).toHaveBeenCalledWith({ direction: 'up' });
157
+ expect(setLayoutOptions).toHaveBeenCalledTimes(2);
158
+ });
135
159
  });
@@ -85,7 +85,11 @@ describe('InteractiveNvlWrapper', () => {
85
85
  });
86
86
  test('initialises NVL expectedly with a graph object and properties', () => {
87
87
  const mockLayoutDoneFunction = jest.fn();
88
- render(_jsx(InteractiveNvlWrapper, { nodes: [{ id: '1' }, { id: '2' }], rels: [{ id: '12', from: '1', to: '2' }], layout: HierarchicalLayoutType, layoutOptions: { direction: 'down' }, nvlOptions: { renderer: 'canvas' }, nvlCallbacks: { onLayoutDone: mockLayoutDoneFunction } }));
88
+ render(_jsx(InteractiveNvlWrapper, { nodes: [{ id: '1' }, { id: '2' }], rels: [{ id: '12', from: '1', to: '2' }], nvlOptions: {
89
+ renderer: 'canvas',
90
+ layout: HierarchicalLayoutType,
91
+ layoutOptions: { direction: 'down' }
92
+ }, nvlCallbacks: { onLayoutDone: mockLayoutDoneFunction } }));
89
93
  act(() => {
90
94
  mockOnInitialization?.();
91
95
  });
@@ -1,4 +1,4 @@
1
- import type { ExternalCallbacks, Layout, LayoutOptions, Node, NvlOptions, Relationship } from '@neo4j-nvl/base';
1
+ import type { ExternalCallbacks, Node, NvlOptions, Relationship } from '@neo4j-nvl/base';
2
2
  import NVL from '@neo4j-nvl/base';
3
3
  import { type HTMLProps } from 'react';
4
4
  /**
@@ -9,10 +9,6 @@ export interface BasicReactWrapperProps {
9
9
  nodes: Node[];
10
10
  /** The rels of the graph of type Relationship[] */
11
11
  rels: Relationship[];
12
- /** The layout, can be 'forceDirected' or 'hierarchical' */
13
- layout?: Layout;
14
- /** Options for the current layout */
15
- layoutOptions?: LayoutOptions;
16
12
  /** an Object containing functions for callbacks on certain actions */
17
13
  nvlCallbacks?: ExternalCallbacks;
18
14
  /** An object containing options for the Nvl instance */
@@ -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 = {}, positions = [], zoom, pan, onInitializationError, ...nvlEvents }, ref) => {
15
+ export const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, nvlCallbacks = {}, nvlOptions = {}, positions = [], zoom, pan, onInitializationError, ...nvlEvents }, ref) => {
16
16
  const nvlRef = useRef(null);
17
17
  const prevZoomRef = useRef(undefined);
18
18
  const prevPanRef = useRef(undefined);
@@ -47,12 +47,8 @@ export const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOpt
47
47
  const mainContainerIsReady = containerRef.current !== null;
48
48
  if (mainContainerIsReady && minimapContainerIsReady) {
49
49
  if (nvlRef.current === null) {
50
- const combinedOptions = { ...nvlOptions, layoutOptions };
51
- if (layout !== undefined) {
52
- combinedOptions.layout = layout;
53
- }
54
50
  try {
55
- newNvl = new NVL(containerRef.current, currentNodes, currentRels, combinedOptions, nvlCallbacks);
51
+ newNvl = new NVL(containerRef.current, currentNodes, currentRels, nvlOptions, nvlCallbacks);
56
52
  nvlRef.current = newNvl;
57
53
  setCurrentRels(rels);
58
54
  setCurrentNodes(nodes);
@@ -96,19 +92,17 @@ export const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOpt
96
92
  nvlRef.current.removeNodesWithIds(nodesToRemove);
97
93
  }, [currentNodes, currentRels, nodes, rels]);
98
94
  useEffect(() => {
99
- const updatedLayout = layout ?? nvlOptions.layout;
100
- if (nvlRef.current === null || updatedLayout === undefined) {
95
+ if (nvlRef.current === null || nvlOptions.layout === undefined) {
101
96
  return;
102
97
  }
103
- nvlRef.current.setLayout(updatedLayout);
104
- }, [layout, nvlOptions.layout]);
98
+ nvlRef.current.setLayout(nvlOptions.layout);
99
+ }, [nvlOptions.layout]);
105
100
  useDeepCompareEffect(() => {
106
- const updatedLayoutOptions = layoutOptions ?? nvlOptions?.layoutOptions;
107
- if (nvlRef.current === null || updatedLayoutOptions === undefined) {
101
+ if (nvlRef.current === null || nvlOptions.layoutOptions === undefined) {
108
102
  return;
109
103
  }
110
- nvlRef.current.setLayoutOptions(updatedLayoutOptions);
111
- }, [layoutOptions, nvlOptions.layoutOptions]);
104
+ nvlRef.current.setLayoutOptions(nvlOptions.layoutOptions);
105
+ }, [nvlOptions.layoutOptions]);
112
106
  useEffect(() => {
113
107
  if (nvlRef.current === null || nvlOptions.renderer === undefined) {
114
108
  return;
@@ -20,7 +20,7 @@ const options = {
20
20
  *
21
21
  * For examples, head to the {@link https://neo4j.com/docs/nvl/current/react-wrappers/#_interactive_reactive_wrapperr Interactive React wrapper documentation page}.
22
22
  */
23
- export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, onInitializationError, mouseEventCallbacks = {}, keyboardEventCallbacks = {}, nvlCallbacks = {}, nvlOptions = {}, interactionOptions = options, ...nvlEvents }, nvlRef) => {
23
+ export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, onInitializationError, mouseEventCallbacks = {}, keyboardEventCallbacks = {}, nvlCallbacks = {}, nvlOptions = {}, interactionOptions = options, ...nvlEvents }, nvlRef) => {
24
24
  const newNvlRef = useRef(null);
25
25
  const myNvlRef = nvlRef ?? newNvlRef;
26
26
  const [isNvlInitialized, setIsNvlInitialized] = useState(false);
@@ -42,5 +42,5 @@ export const InteractiveNvlWrapper = memo(forwardRef(({ nodes, rels, layout, lay
42
42
  }
43
43
  handleInitialization();
44
44
  }
45
- }, layout: layout, layoutOptions: layoutOptions, onInitializationError: handleInitializationError, ...nvlEvents }), setupInteractions && (_jsx(InteractionHandlers, { nvlRef: myNvlRef, mouseEventCallbacks: mouseEventCallbacks, keyboardEventCallbacks: keyboardEventCallbacks, interactionOptions: interactionOptions }))] }));
45
+ }, onInitializationError: handleInitializationError, ...nvlEvents }), setupInteractions && (_jsx(InteractionHandlers, { nvlRef: myNvlRef, mouseEventCallbacks: mouseEventCallbacks, keyboardEventCallbacks: keyboardEventCallbacks, interactionOptions: interactionOptions }))] }));
46
46
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-nvl/react",
3
- "version": "1.2.0-645be73b",
3
+ "version": "1.2.0-676bec77",
4
4
  "main": "lib/index.js",
5
5
  "homepage": "https://neo4j.com/docs/nvl/current/",
6
6
  "license": "SEE LICENSE IN 'LICENSE.txt'",
@@ -36,8 +36,8 @@
36
36
  "react-dom": "19.2.1"
37
37
  },
38
38
  "dependencies": {
39
- "@neo4j-nvl/base": "1.2.0-645be73b",
40
- "@neo4j-nvl/interaction-handlers": "1.2.0-645be73b",
39
+ "@neo4j-nvl/base": "1.2.0-676bec77",
40
+ "@neo4j-nvl/interaction-handlers": "1.2.0-676bec77",
41
41
  "lodash": "4.18.1"
42
42
  },
43
43
  "peerDependencies": {