@nesso-how/graph 0.1.0-alpha.35 → 0.1.0-alpha.37
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/README.md +2 -0
- package/dist/NessoGraph.d.ts +2 -0
- package/dist/NessoGraph.js +13 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,6 +47,8 @@ Turn on `nodesDraggable`/`nodesConnectable`/`elementsSelectable` as needed. How
|
|
|
47
47
|
- `nodes`/`edges` — _controlled_: you own the state and must also pass `onNodesChange`/`onEdgesChange`/`onConnect` to apply updates (e.g. the main app, where positions live in its own store).
|
|
48
48
|
- `defaultNodes`/`defaultEdges` — _uncontrolled_: React Flow seeds its internal state once and manages drag/connect/selection itself — no wiring needed, the right choice for decorative or one-off embeds.
|
|
49
49
|
|
|
50
|
+
When `zoomOnScroll` is off (typical for decorative embeds in a scrollable page), `NessoGraph` sets `preventScrolling` to false so the page keeps scrolling over the canvas. Override via `reactFlowProps.preventScrolling` if needed.
|
|
51
|
+
|
|
50
52
|
```tsx
|
|
51
53
|
<NessoGraph
|
|
52
54
|
defaultNodes={nodes}
|
package/dist/NessoGraph.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { Node, Edge, NodeTypes, EdgeTypes, ReactFlowProps, Viewport, OnNode
|
|
|
2
2
|
import type { RelationTypeName, ConceptNodeData, NessoGraphDocument, NessoGraphDocumentInput, CategoryPalette } from '@nesso-how/vocab-learning';
|
|
3
3
|
import type { NessoEdgeData, GraphDisplaySettings } from './display.js';
|
|
4
4
|
import { type CategoryColorMode } from './context.js';
|
|
5
|
+
/** React Flow defaults `preventScrolling` to true, which blocks page scroll over the canvas even when wheel zoom/pan are off. */
|
|
6
|
+
export declare function resolvePreventScrolling(zoomOnScroll: boolean, reactFlowProps?: Pick<ReactFlowProps, 'preventScrolling' | 'panOnScroll'>): boolean;
|
|
5
7
|
type PassthroughKeys = 'nodes' | 'defaultNodes' | 'edges' | 'defaultEdges' | 'nodeTypes' | 'edgeTypes' | 'nodesDraggable' | 'nodesConnectable' | 'elementsSelectable' | 'onNodesChange' | 'onEdgesChange' | 'onConnect' | 'onConnectStart' | 'onConnectEnd' | 'onSelectionChange' | 'onMoveEnd' | 'onNodeClick' | 'onEdgeClick' | 'fitView' | 'defaultViewport' | 'minZoom' | 'maxZoom' | 'panOnDrag' | 'zoomOnScroll';
|
|
6
8
|
export interface NessoGraphProps {
|
|
7
9
|
graph?: NessoGraphDocument | NessoGraphDocumentInput;
|
package/dist/NessoGraph.js
CHANGED
|
@@ -8,6 +8,12 @@ import { ConceptNode } from './ConceptNode.js';
|
|
|
8
8
|
import { NessoEdge } from './NessoEdge.js';
|
|
9
9
|
const DEFAULT_NODE_TYPES = { concept: ConceptNode };
|
|
10
10
|
const DEFAULT_EDGE_TYPES = { nesso: NessoEdge };
|
|
11
|
+
/** React Flow defaults `preventScrolling` to true, which blocks page scroll over the canvas even when wheel zoom/pan are off. */
|
|
12
|
+
export function resolvePreventScrolling(zoomOnScroll, reactFlowProps) {
|
|
13
|
+
if (reactFlowProps?.preventScrolling !== undefined)
|
|
14
|
+
return reactFlowProps.preventScrolling;
|
|
15
|
+
return zoomOnScroll || Boolean(reactFlowProps?.panOnScroll);
|
|
16
|
+
}
|
|
11
17
|
export function NessoGraph({ graph, nodes: nodesProp, defaultNodes, edges: edgesProp, defaultEdges, display, palette = 'default', categoryColorMode = 'palette', getRelationLabel, isItemSelected, nodeTypes = DEFAULT_NODE_TYPES, edgeTypes = DEFAULT_EDGE_TYPES, nodesDraggable = false, nodesConnectable = false, elementsSelectable = true, panOnDrag = true, zoomOnScroll = true, onNodesChange, onEdgesChange, onConnect, onConnectStart, onConnectEnd, onSelectionChange, onMoveEnd, onNodeClick, onEdgeClick, fitView = true, defaultViewport, minZoom, maxZoom, reactFlowProps, style, className, onDoubleClick, children, }) {
|
|
12
18
|
const rendered = graph ? documentToRenderGraph(graph) : undefined;
|
|
13
19
|
const graphDisplay = rendered?.display;
|
|
@@ -31,7 +37,12 @@ export function NessoGraph({ graph, nodes: nodesProp, defaultNodes, edges: edges
|
|
|
31
37
|
getRelationLabel,
|
|
32
38
|
isItemSelected,
|
|
33
39
|
}), [display, graphDisplay, palette, categoryColorMode, getRelationLabel, isItemSelected]);
|
|
34
|
-
|
|
40
|
+
const { preventScrolling: preventScrollingOverride, ...restReactFlowProps } = reactFlowProps ?? {};
|
|
41
|
+
const preventScrolling = resolvePreventScrolling(zoomOnScroll, {
|
|
42
|
+
preventScrolling: preventScrollingOverride,
|
|
43
|
+
panOnScroll: restReactFlowProps.panOnScroll,
|
|
44
|
+
});
|
|
45
|
+
return (_jsx("div", { style: { width: '100%', height: '100%', ...style }, className: className, onDoubleClick: onDoubleClick, children: _jsx(GraphDisplayContext.Provider, { value: ctx, children: _jsx(ReactFlow, { ...nodesProps, ...edgesProps, nodeTypes: nodeTypes, edgeTypes: edgeTypes, nodesDraggable: nodesDraggable, nodesConnectable: nodesConnectable, elementsSelectable: elementsSelectable, panOnDrag: panOnDrag, zoomOnScroll: zoomOnScroll, preventScrolling: preventScrolling, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: onConnect, onConnectStart: onConnectStart, onConnectEnd: onConnectEnd, onSelectionChange: onSelectionChange, onMoveEnd: onMoveEnd, fitView: fitView, defaultViewport: defaultViewport, minZoom: minZoom, maxZoom: maxZoom, onNodeClick: onNodeClick
|
|
35
46
|
? (_, node) => onNodeClick(node.id, node.data)
|
|
36
|
-
: undefined, onEdgeClick: onEdgeClick ? (_, edge) => onEdgeClick(edge.id, edge.data) : undefined, ...
|
|
47
|
+
: undefined, onEdgeClick: onEdgeClick ? (_, edge) => onEdgeClick(edge.id, edge.data) : undefined, ...restReactFlowProps, children: children ?? (_jsxs(_Fragment, { children: [_jsx(Background, {}), _jsx(Controls, {})] })) }) }) }));
|
|
37
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nesso-how/graph",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.37",
|
|
4
4
|
"description": "Embeddable Nesso knowledge graph React component (read-only by default)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@nesso-how/vocab-learning": "0.1.0-alpha.
|
|
25
|
+
"@nesso-how/vocab-learning": "0.1.0-alpha.37"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@xyflow/react": "^12.6.4",
|