@neo4j-nvl/base 2.0.0-ec6fdba7 → 2.1.0-307fceac
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 +2 -1
- package/README.md +5 -1
- package/dist/types/index.d.ts +62 -27
- package/dist/types/modules/ExternalCallbackHandler.d.ts +17 -4
- package/dist/types/modules/NvlController.d.ts +1 -1
- package/dist/types/modules/state/types.d.ts +20 -2
- package/dist/types/types/graph-element.d.ts +32 -15
- package/dist/types/types/nvl-window-functions.d.ts +16 -0
- package/dist/types/utils/hitTest.d.ts +3 -0
- package/dist/types/utils/jsDriverResultTransformer.d.ts +10 -0
- package/dist/types/utils/zoomFunctions.d.ts +1 -2
- package/package.json +3 -3
- package/skills/neo4j-nvl-skill/SKILL.md +13 -9
- package/skills/neo4j-nvl-skill/references/api/base/classes/NVL.md +76 -33
- package/skills/neo4j-nvl-skill/references/api/base/functions/getZoomTargetForNodePositions.md +1 -1
- package/skills/neo4j-nvl-skill/references/api/base/index.md +3 -2
- package/skills/neo4j-nvl-skill/references/api/base/interfaces/CircularOptions.md +1 -1
- package/skills/neo4j-nvl-skill/references/api/base/interfaces/ClusteringOptions.md +17 -0
- package/skills/neo4j-nvl-skill/references/api/base/interfaces/ExternalCallbacks.md +4 -4
- package/skills/neo4j-nvl-skill/references/api/base/interfaces/HierarchicalOptions.md +1 -1
- package/skills/neo4j-nvl-skill/references/api/base/interfaces/Node.md +5 -5
- package/skills/neo4j-nvl-skill/references/api/base/interfaces/NvlOptions.md +1 -1
- package/skills/neo4j-nvl-skill/references/api/base/interfaces/NvlWindow.md +18 -0
- package/skills/neo4j-nvl-skill/references/api/base/interfaces/Relationship.md +3 -3
- package/skills/neo4j-nvl-skill/references/api/base/type-aliases/HitTestTarget.md +2 -0
- package/skills/neo4j-nvl-skill/references/api/base/type-aliases/NodeWithClientPosition.md +10 -4
- package/skills/neo4j-nvl-skill/references/api/base/type-aliases/Renderer.md +3 -1
- package/skills/neo4j-nvl-skill/references/api/base/variables/nvlResultTransformer.md +11 -0
- package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/HoverInteraction.md +6 -0
- package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/PanInteraction.md +2 -1
- package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/ZoomInteraction.md +5 -0
- package/skills/neo4j-nvl-skill/references/api/react/functions/StaticPictureWrapper.md +7 -0
- package/skills/neo4j-nvl-skill/references/api/react/index.md +2 -2
- package/skills/neo4j-nvl-skill/references/api/react/interfaces/BasicReactWrapperProps.md +3 -3
- package/skills/neo4j-nvl-skill/references/api/react/interfaces/InteractiveNvlWrapperProps.md +4 -4
- package/skills/neo4j-nvl-skill/references/api/react/type-aliases/KeyboardEvent.md +3 -0
- package/skills/neo4j-nvl-skill/references/api/react/type-aliases/MouseEventCallbacks.md +9 -0
- package/skills/neo4j-nvl-skill/references/api/react/variables/BasicNvlWrapper.md +16 -1
- package/skills/neo4j-nvl-skill/references/api/react/variables/InteractiveNvlWrapper.md +1 -0
- package/skills/neo4j-nvl-skill/references/labels-and-overlays.md +3 -1
- package/skills/neo4j-nvl-skill/references/layouts-and-positions.md +3 -3
- package/skills/neo4j-nvl-skill/references/react-wrappers.md +6 -2
|
@@ -45,6 +45,21 @@ const BasicNvlWrapper: MemoExoticComponent<ForwardRefExoticComponent<Omit<BasicR
|
|
|
45
45
|
|
|
46
46
|
A basic React wrapper that wraps the NVL base library within a React component.
|
|
47
47
|
It takes the class' arguments as properties, which are passed to the NVL constructor.
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
The `ref` exposes every NVL method. Calls made before the instance exists return `null`.
|
|
49
50
|
|
|
50
51
|
For examples, head to the [Basic React wrapper documentation page](https://neo4j.com/docs/nvl/current/react-wrappers/#_basic_react_wrapper).
|
|
52
|
+
|
|
53
|
+
## Example
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
const Graph = () => {
|
|
57
|
+
const nvlRef = useRef<NVL>(null)
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
<BasicNvlWrapper ref={nvlRef} nodes={nodes} rels={relationships} />
|
|
61
|
+
<button onClick={() => nvlRef.current?.fit(nodes.map((node) => node.id))}>Fit</button>
|
|
62
|
+
</>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
```
|
|
@@ -13,5 +13,6 @@ It is an extension of the [BasicNvlWrapper](BasicNvlWrapper.md) component and in
|
|
|
13
13
|
|
|
14
14
|
The mouseEventCallbacks property takes an object where various callbacks can be defined
|
|
15
15
|
and behavior can be toggled on and off.
|
|
16
|
+
See [MouseEventCallbacks](../type-aliases/MouseEventCallbacks.md) for which key enables which handler.
|
|
16
17
|
|
|
17
18
|
For examples, head to the [Interactive React wrapper documentation page](https://neo4j.com/docs/nvl/current/react-wrappers/#_interactive_react_wrapper).
|
|
@@ -13,6 +13,8 @@ Verification tags: **source**, **types**, **runtime** (see `SKILL.md`).
|
|
|
13
13
|
|
|
14
14
|
WebGL rendering and the force-directed physics need **WebGL2**. `disableWebGL: true` forces Canvas and the non-GPU layout implementations. Switch at runtime with `setRenderer`. *types*
|
|
15
15
|
|
|
16
|
+
An experimental `'svg'` renderer exists internally but is excluded from the public `Renderer` type; use `saveToSvg()` for SVG output. *types*
|
|
17
|
+
|
|
16
18
|
## Captions
|
|
17
19
|
|
|
18
20
|
`caption` (single string) or `captions: StyledCaption[]` (styled, multiple); `captions` wins if both are set. Captions are drawn by the Canvas renderer only; with WebGL they are silently absent. There is no texture-size limit involved; it is a renderer feature gap. *types*
|
|
@@ -27,7 +29,7 @@ Options when you need text and WebGL:
|
|
|
27
29
|
## `icon`
|
|
28
30
|
|
|
29
31
|
- URL of a square image drawn inside the node. Icons are expected to be black; on dark node colours they are inverted to white. *types*
|
|
30
|
-
-
|
|
32
|
+
- The WebGL renderer holds at most 256 distinct icon images (`url` × inverted/not); further icons are silently not drawn, with no warning. The Canvas renderer has no such cap. Keep the set of distinct images small. *source, runtime*
|
|
31
33
|
|
|
32
34
|
## `overlayIcon`
|
|
33
35
|
|
|
@@ -47,9 +47,9 @@ nvl.setNodePositions(nvl.getNodePositions(), true)
|
|
|
47
47
|
## Setting positions
|
|
48
48
|
|
|
49
49
|
- `setNodePositions(nodes, updateLayout = false)` moves nodes to the given `x` / `y`. With `updateLayout: true` the current layout continues from there. *types*
|
|
50
|
-
- `x` / `y`
|
|
51
|
-
- `pinNode(id)` / `unPinNode(ids: string[])` or `pinned: true` in node data hold nodes in place for the force-directed layout. Clustering forces ignore pins (see [clustering](clustering.md)). *types, runtime*
|
|
52
|
-
-
|
|
50
|
+
- Never set `x` / `y` on node data (`addAndUpdateElementsInGraph`, `updateElementsInGraph`, the React `nodes` prop). Positions are owned by the layout, and these properties are slated for removal from `Node`. `setNodePositions` (or the React `positions` prop) is the way to position nodes. *source*
|
|
51
|
+
- `pinNode(id)` / `unPinNode(ids: string[])` or `pinned: true` in node data hold nodes in place for the force-directed layout, at whatever position they currently have. Clustering forces ignore pins (see [clustering](clustering.md)). *types, runtime*
|
|
52
|
+
- Fixed anchors under `forceDirected`: insert the anchors with `pinned: true`, then `setNodePositions(anchors, true)` right after construction so the layout continues around them. Releasing them: `unPinNode(ids)` then `setNodePositions(getNodePositions(), true)`. *runtime*
|
|
53
53
|
|
|
54
54
|
## Coordinates
|
|
55
55
|
|
|
@@ -56,8 +56,8 @@ To change a creation-time option, call `nvlRef.current.restart(newOptions, true)
|
|
|
56
56
|
|
|
57
57
|
On every render the wrapper diffs the new arrays against the previous ones by `id`, then calls `addAndUpdateElementsInGraph` for added and changed elements and `removeNodesWithIds` / `removeRelationshipsWithIds` for removed ones. *source*
|
|
58
58
|
|
|
59
|
-
- Only keys whose value changed are sent, so updates are partial. A key set to `undefined` is sent
|
|
60
|
-
-
|
|
59
|
+
- Only keys whose value changed are sent, so updates are partial. A key set to `undefined` is sent; a key that is omitted is not. To un-pin, send `pinned: false`: the force-directed layout ignores `pinned: undefined`. *source*
|
|
60
|
+
- Never set `x` / `y` on `nodes`; they do not position anything. Use the `positions` prop (calls `setNodePositions` without `updateLayout`) or `setNodePositions` via the ref (see [layouts-and-positions](layouts-and-positions.md)). *source*
|
|
61
61
|
- `pinned` does apply through the diff. *runtime*
|
|
62
62
|
- Keep the arrays referentially stable between renders (`useMemo`) or the diff runs on every render.
|
|
63
63
|
|
|
@@ -83,6 +83,10 @@ Keep the object stable (`useMemo`); a new object each render re-runs every inter
|
|
|
83
83
|
|
|
84
84
|
Flipping `selectOnClick` or other `interactionOptions` across renders, or registering your own `container.addEventListener('click')` next to the wrapper's `ClickInteraction`, produces double handling. Set the options once and use the wrapper's callbacks.
|
|
85
85
|
|
|
86
|
+
## Many `<StaticPictureWrapper>`s at once
|
|
87
|
+
|
|
88
|
+
Each instance holds two WebGL contexts until its image is captured, and browsers allow only about 16 per page. Around eight pictures rendering at the same time hit that limit ("Too many active WebGL contexts"). For galleries or lists, pass `nvlOptions={{ disableWebGL: true }}`, or mount the pictures in batches. *source, runtime*
|
|
89
|
+
|
|
86
90
|
## Teardown
|
|
87
91
|
|
|
88
92
|
The wrappers call `nvl.destroy()` on unmount and destroy their handlers. Only manual `new NVL(...)` in a `useEffect` needs an explicit `return () => nvl.destroy()`.
|