@neo4j-nvl/react 2.0.0-ec6fdba7 → 2.1.0

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,7 +2,7 @@
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
- ## [Unreleased]
5
+ ## [2.1.0] - 2026-11-10
6
6
 
7
7
  This release adds keyboard actions for moving nodes, ships an agent skill for NVL, and makes all packages loadable as ESM in Node.js without a bundler.
8
8
 
@@ -24,6 +24,7 @@ This release adds keyboard actions for moving nodes, ships an agent skill for NV
24
24
  * `fit()` zooms out beyond `minZoom` when `allowDynamicMinZoom` is `true` and the graph does not fit the viewport.
25
25
  * `onHover` callback's `element` parameter is now typed as possibly `undefined`, matching the runtime behaviour.
26
26
  * Added missing caret for the React 18 peer dependency range in `@neo4j-nvl/react`.
27
+ * Several dependency updates
27
28
 
28
29
  ## [2.0.0] - 2026-09-15
29
30
 
package/README.md CHANGED
@@ -78,6 +78,14 @@ const [boxSelect, setBoxSelect] = useState(false)
78
78
 
79
79
  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/).
80
80
 
81
+ ### Agent skills
82
+
83
+ The agent skill for NVL (`neo4j-nvl-skill`) ships with `@neo4j-nvl/base`, which this package depends on. To make it available to your AI coding assistant, run the following with a recent version of the `skills` CLI:
84
+
85
+ ```bash
86
+ npx skills experimental_sync
87
+ ```
88
+
81
89
  ### Product analytics
82
90
 
83
91
  In order to improve the library we are collecting some information about the usage of NVL. If you prefer to disable this behavior setting `disableTelemetry` to `true` in the `nvlOptions` property.
@@ -8,11 +8,25 @@ export interface BasicReactWrapperProps {
8
8
  nodes: Node[];
9
9
  /** The rels of the graph of type Relationship[] */
10
10
  rels: Relationship[];
11
- /** an Object containing functions for callbacks on certain actions */
11
+ /**
12
+ * An object containing functions for callbacks on certain actions.
13
+ * @remarks Passed to the NVL constructor once; later changes to this prop are ignored.
14
+ * Read changing state through a ref inside the callbacks instead of redefining them.
15
+ */
12
16
  nvlCallbacks?: ExternalCallbacks;
13
- /** An object containing options for the Nvl instance */
17
+ /**
18
+ * An object containing options for the Nvl instance.
19
+ * @remarks
20
+ * If `minimapContainer` is present it must be a non-null element before NVL is created, otherwise
21
+ * creation is deferred until it is.
22
+ */
14
23
  nvlOptions?: NvlOptions;
15
- /** Sets the positions of the nodes in the graph using the setNodePositions method. */
24
+ /**
25
+ * Sets the positions of the nodes in the graph using the setNodePositions method.
26
+ * @remarks Applied whenever the array reference changes and is non-empty. This is the way to
27
+ * position nodes.
28
+ * Do not set `x` and `y` on `nodes` directly.
29
+ */
16
30
  positions?: Node[];
17
31
  /**
18
32
  * Sets the zoom level of the viewport using the setZoom method.
@@ -36,8 +50,21 @@ export interface BasicReactWrapperProps {
36
50
  *
37
51
  * A basic React wrapper that wraps the NVL base library within a React component.
38
52
  * It takes the class' arguments as properties, which are passed to the NVL constructor.
39
- * Any changes in properties will be reflected in the NVL instance by calling the corresponding methods.
53
+ *
54
+ * The `ref` exposes every NVL method. Calls made before the instance exists return `null`.
40
55
  *
41
56
  * For examples, head to the {@link https://neo4j.com/docs/nvl/current/react-wrappers/#_basic_react_wrapper Basic React wrapper documentation page}.
57
+ * @example
58
+ * ```tsx
59
+ * const Graph = () => {
60
+ * const nvlRef = useRef<NVL>(null)
61
+ * return (
62
+ * <>
63
+ * <BasicNvlWrapper ref={nvlRef} nodes={nodes} rels={relationships} />
64
+ * <button onClick={() => nvlRef.current?.fit(nodes.map((node) => node.id))}>Fit</button>
65
+ * </>
66
+ * )
67
+ * }
68
+ * ```
42
69
  */
43
70
  export declare const BasicNvlWrapper: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<BasicReactWrapperProps & HTMLProps<HTMLDivElement>, "ref"> & import("react").RefAttributes<Partial<Pick<NVL, "restart" | "addAndUpdateElementsInGraph" | "getSelectedNodes" | "getSelectedRelationships" | "removeNodesWithIds" | "removeRelationshipsWithIds" | "getNodes" | "getRelationships" | "getNodeById" | "getRelationshipById" | "getPositionById" | "getCurrentOptions" | "destroy" | "deselectAll" | "fit" | "resetZoom" | "setRenderer" | "setDisableWebGL" | "pinNode" | "unPinNode" | "setLayout" | "setLayoutOptions" | "getNodesOnScreen" | "getNodePositions" | "setNodePositions" | "isLayoutMoving" | "saveToFile" | "saveToSvg" | "getImageDataUrl" | "getSvgDataUrl" | "saveFullGraphToLargeFile" | "getZoomLimits" | "setZoom" | "getScale" | "getPan" | "getHits" | "getContainer">>>>>;
@@ -9,9 +9,22 @@ import { jsx } from "react/jsx-runtime";
9
9
  *
10
10
  * A basic React wrapper that wraps the NVL base library within a React component.
11
11
  * It takes the class' arguments as properties, which are passed to the NVL constructor.
12
- * Any changes in properties will be reflected in the NVL instance by calling the corresponding methods.
12
+ *
13
+ * The `ref` exposes every NVL method. Calls made before the instance exists return `null`.
13
14
  *
14
15
  * For examples, head to the {@link https://neo4j.com/docs/nvl/current/react-wrappers/#_basic_react_wrapper Basic React wrapper documentation page}.
16
+ * @example
17
+ * ```tsx
18
+ * const Graph = () => {
19
+ * const nvlRef = useRef<NVL>(null)
20
+ * return (
21
+ * <>
22
+ * <BasicNvlWrapper ref={nvlRef} nodes={nodes} rels={relationships} />
23
+ * <button onClick={() => nvlRef.current?.fit(nodes.map((node) => node.id))}>Fit</button>
24
+ * </>
25
+ * )
26
+ * }
27
+ * ```
15
28
  */
16
29
  const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, nvlCallbacks = {}, nvlOptions = {}, positions = [], zoom, pan, onInitializationError, ...nvlEvents }, ref) => {
17
30
  const nvlRef = useRef(null);
@@ -9,6 +9,7 @@ import { HTMLProps } from "react";
9
9
  *
10
10
  * The mouseEventCallbacks property takes an object where various callbacks can be defined
11
11
  * and behavior can be toggled on and off.
12
+ * See {@link MouseEventCallbacks} for which key enables which handler.
12
13
  *
13
14
  * For examples, head to the {@link https://neo4j.com/docs/nvl/current/react-wrappers/#_interactive_react_wrapper Interactive React wrapper documentation page}.
14
15
  */
@@ -18,6 +18,7 @@ const options = {
18
18
  *
19
19
  * The mouseEventCallbacks property takes an object where various callbacks can be defined
20
20
  * and behavior can be toggled on and off.
21
+ * See {@link MouseEventCallbacks} for which key enables which handler.
21
22
  *
22
23
  * For examples, head to the {@link https://neo4j.com/docs/nvl/current/react-wrappers/#_interactive_react_wrapper Interactive React wrapper documentation page}.
23
24
  */
@@ -5,6 +5,13 @@ export type Interaction = HoverInteraction | ClickInteraction | PanInteraction |
5
5
  /**
6
6
  * Collection of mouse event callbacks that can be used with
7
7
  * the {@link InteractiveNvlWrapper} component.
8
+ *
9
+ * Each key enables the interaction handler that owns it: a function enables the handler and is
10
+ * called.
11
+ * `true` enables it without a callback and `false` destroys the handler (and all its other callbacks).
12
+ *
13
+ * @remarks Zoom is only enabled through `onZoomAndPan`. There is no `onZoom` key.
14
+ * Keyboard callbacks use the separate {@link KeyboardEventCallbacks} prop.
8
15
  */
9
16
  export type MouseEventCallbacks = ClickInteractionCallbacks & DragNodeInteractionCallbacks & HoverInteractionCallbacks & PanInteractionCallbacks & ZoomInteractionCallbacks & BoxSelectInteractionCallbacks & DrawInteractionCallbacks & LassoInteractionCallbacks;
10
17
  /**
@@ -22,6 +29,10 @@ export type InteractionOptions = ClickInteractionOptions & BoxSelectInteractionO
22
29
  * to turn on/off certain events for the {@link InteractiveNvlWrapper} component.
23
30
  */
24
31
  export type MouseEvent = keyof MouseEventCallbacks;
32
+ /**
33
+ * The events that can be passed to the {@link KeyboardEventCallbacks} object
34
+ * to turn on/off certain events for the {@link InteractiveNvlWrapper} component.
35
+ */
25
36
  export type KeyboardEvent = keyof KeyboardEventCallbacks;
26
37
  /**
27
38
  * The properties that can be passed to the {@link InteractiveNvlWrapper} component.
@@ -31,6 +42,10 @@ export interface InteractiveNvlWrapperProps extends BasicReactWrapperProps {
31
42
  mouseEventCallbacks?: MouseEventCallbacks;
32
43
  /** {@link KeyboardEventCallbacks} containing functions for callbacks on keyboard actions */
33
44
  keyboardEventCallbacks?: KeyboardEventCallbacks;
34
- /** {@link InteractionOptions} for the underlying interaction handlers */
45
+ /**
46
+ * {@link InteractionOptions} for the underlying interaction handlers.
47
+ * @remarks Options are read when a handler is
48
+ * first created and changing them later does not affect existing handlers.
49
+ */
35
50
  interactionOptions?: InteractionOptions;
36
51
  }
@@ -23,6 +23,12 @@ export type StaticPictureWrapperProps = {
23
23
  * The component automatically fits all nodes in the viewport before capturing the image
24
24
  * NVL is automatically destroyed after capturing the image to free up resources.
25
25
  *
26
+ * @remarks
27
+ * When showing many pictures at once, either set `disableWebGL: true` in `nvlOptions` or mount the components in
28
+ * batches to avoid exceeding the WebGL context limit of the browser.
29
+ * Otherwise, the browser may drop the oldest contexts and warn "Too many active WebGL contexts" when reaching its limit
30
+ * and some pictures can fail to render.
31
+ *
26
32
  * @param props - The component properties
27
33
  * @returns An img element displaying the graph visualization, or null during rendering
28
34
  *
@@ -8,6 +8,12 @@ import { jsx } from "react/jsx-runtime";
8
8
  * The component automatically fits all nodes in the viewport before capturing the image
9
9
  * NVL is automatically destroyed after capturing the image to free up resources.
10
10
  *
11
+ * @remarks
12
+ * When showing many pictures at once, either set `disableWebGL: true` in `nvlOptions` or mount the components in
13
+ * batches to avoid exceeding the WebGL context limit of the browser.
14
+ * Otherwise, the browser may drop the oldest contexts and warn "Too many active WebGL contexts" when reaching its limit
15
+ * and some pictures can fail to render.
16
+ *
11
17
  * @param props - The component properties
12
18
  * @returns An img element displaying the graph visualization, or null during rendering
13
19
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-nvl/react",
3
- "version": "2.0.0-ec6fdba7",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,13 +50,12 @@
50
50
  "tsdown": "0.23.1"
51
51
  },
52
52
  "dependencies": {
53
- "@neo4j-nvl/base": "2.0.0-ec6fdba7",
54
- "@neo4j-nvl/interaction-handlers": "2.0.0-ec6fdba7",
53
+ "@neo4j-nvl/base": "2.1.0",
54
+ "@neo4j-nvl/interaction-handlers": "2.1.0",
55
55
  "lodash-es": "4.18.1"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "react": "^18.0.0 || ^19.0.0",
59
59
  "react-dom": "^18.0.0 || ^19.0.0"
60
- },
61
- "stableVersion": "2.0.0"
60
+ }
62
61
  }