@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.
Files changed (42) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/README.md +5 -1
  3. package/dist/types/index.d.ts +62 -27
  4. package/dist/types/modules/ExternalCallbackHandler.d.ts +17 -4
  5. package/dist/types/modules/NvlController.d.ts +1 -1
  6. package/dist/types/modules/state/types.d.ts +20 -2
  7. package/dist/types/types/graph-element.d.ts +32 -15
  8. package/dist/types/types/nvl-window-functions.d.ts +16 -0
  9. package/dist/types/utils/hitTest.d.ts +3 -0
  10. package/dist/types/utils/jsDriverResultTransformer.d.ts +10 -0
  11. package/dist/types/utils/zoomFunctions.d.ts +1 -2
  12. package/package.json +3 -3
  13. package/skills/neo4j-nvl-skill/SKILL.md +13 -9
  14. package/skills/neo4j-nvl-skill/references/api/base/classes/NVL.md +76 -33
  15. package/skills/neo4j-nvl-skill/references/api/base/functions/getZoomTargetForNodePositions.md +1 -1
  16. package/skills/neo4j-nvl-skill/references/api/base/index.md +3 -2
  17. package/skills/neo4j-nvl-skill/references/api/base/interfaces/CircularOptions.md +1 -1
  18. package/skills/neo4j-nvl-skill/references/api/base/interfaces/ClusteringOptions.md +17 -0
  19. package/skills/neo4j-nvl-skill/references/api/base/interfaces/ExternalCallbacks.md +4 -4
  20. package/skills/neo4j-nvl-skill/references/api/base/interfaces/HierarchicalOptions.md +1 -1
  21. package/skills/neo4j-nvl-skill/references/api/base/interfaces/Node.md +5 -5
  22. package/skills/neo4j-nvl-skill/references/api/base/interfaces/NvlOptions.md +1 -1
  23. package/skills/neo4j-nvl-skill/references/api/base/interfaces/NvlWindow.md +18 -0
  24. package/skills/neo4j-nvl-skill/references/api/base/interfaces/Relationship.md +3 -3
  25. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/HitTestTarget.md +2 -0
  26. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/NodeWithClientPosition.md +10 -4
  27. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/Renderer.md +3 -1
  28. package/skills/neo4j-nvl-skill/references/api/base/variables/nvlResultTransformer.md +11 -0
  29. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/HoverInteraction.md +6 -0
  30. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/PanInteraction.md +2 -1
  31. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/ZoomInteraction.md +5 -0
  32. package/skills/neo4j-nvl-skill/references/api/react/functions/StaticPictureWrapper.md +7 -0
  33. package/skills/neo4j-nvl-skill/references/api/react/index.md +2 -2
  34. package/skills/neo4j-nvl-skill/references/api/react/interfaces/BasicReactWrapperProps.md +3 -3
  35. package/skills/neo4j-nvl-skill/references/api/react/interfaces/InteractiveNvlWrapperProps.md +4 -4
  36. package/skills/neo4j-nvl-skill/references/api/react/type-aliases/KeyboardEvent.md +3 -0
  37. package/skills/neo4j-nvl-skill/references/api/react/type-aliases/MouseEventCallbacks.md +9 -0
  38. package/skills/neo4j-nvl-skill/references/api/react/variables/BasicNvlWrapper.md +16 -1
  39. package/skills/neo4j-nvl-skill/references/api/react/variables/InteractiveNvlWrapper.md +1 -0
  40. package/skills/neo4j-nvl-skill/references/labels-and-overlays.md +3 -1
  41. package/skills/neo4j-nvl-skill/references/layouts-and-positions.md +3 -3
  42. 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
- Any changes in properties will be reflected in the NVL instance by calling the corresponding methods.
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
- - Many distinct icon URLs (≈1,800 across 3,825 nodes) led to many nodes with no icon drawn and no warning. Keep the set of distinct images small. *runtime*
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` in node data are applied **on insert only**. Updating an existing node through `updateElementsInGraph` or the React `nodes` prop with new `x` / `y` does not move it; `setNodePositions` does. *source*
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
- - Mixed layouts (some nodes at data positions, others free): pin the fixed nodes, call `setNodePositions` for them, keep `forceDirected` for the rest. Switching back: un-pin, then `setNodePositions(current, true)`.
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 (and clears the attribute); a key that is omitted is not. *source*
60
- - Changing `x` / `y` on an existing node does **not** move it; positions are only read on insert. Use the `positions` prop or `setNodePositions`. *source*
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()`.