fix(react): multi handles
This commit is contained in:
@@ -21,7 +21,7 @@ Svelte Flow had a big impact on this release as well. While combing through each
|
|||||||
Before you can try out the new features, you need to do some minor updates:
|
Before you can try out the new features, you need to do some minor updates:
|
||||||
|
|
||||||
- **A new npm package name:** Our name changed from `reactflow` to `@xyflow/react` and the main component is no longer a default, but a named import:
|
- **A new npm package name:** Our name changed from `reactflow` to `@xyflow/react` and the main component is no longer a default, but a named import:
|
||||||
- v11: `import ReactFlow from 'reactflow';`
|
- v11: `import { ReactFlow } from '@xyflow/react';`
|
||||||
- v12: `import { ReactFlow } from '@xyflow/react';`
|
- v12: `import { ReactFlow } from '@xyflow/react';`
|
||||||
- **Node attribute “computed”:** All computed node values are now stored in `node.computed`
|
- **Node attribute “computed”:** All computed node values are now stored in `node.computed`
|
||||||
- v11: `node.width`, `node.height` ,`node.positionAbsolute`
|
- v11: `node.width`, `node.height` ,`node.positionAbsolute`
|
||||||
@@ -29,17 +29,21 @@ Before you can try out the new features, you need to do some minor updates:
|
|||||||
- **Updating nodes:** We are not supporting node updates with object mutations anymore. If you want to update a certain attribute, you need to create a new node.
|
- **Updating nodes:** We are not supporting node updates with object mutations anymore. If you want to update a certain attribute, you need to create a new node.
|
||||||
- v11:
|
- v11:
|
||||||
```js
|
```js
|
||||||
setNodes(nds => nds.map((node) => {
|
setNodes((nds) =>
|
||||||
|
nds.map((node) => {
|
||||||
node.hidden = true;
|
node.hidden = true;
|
||||||
return node;
|
return node;
|
||||||
}));
|
})
|
||||||
|
);
|
||||||
```
|
```
|
||||||
- v12:
|
- v12:
|
||||||
```js
|
```js
|
||||||
setNodes(nds => nds.map((node) => ({
|
setNodes((nds) =>
|
||||||
|
nds.map((node) => ({
|
||||||
...node,
|
...node,
|
||||||
hidden: true
|
hidden: true,
|
||||||
})));
|
}))
|
||||||
|
);
|
||||||
```
|
```
|
||||||
- **NodeProps:** `posX`/`posY` is now called `positionAbsoluteX`/`positionAbsoluteY`
|
- **NodeProps:** `posX`/`posY` is now called `positionAbsoluteX`/`positionAbsoluteY`
|
||||||
- **Typescript only:** We simplified types and fixed issues about functions where users could pass a `NodeData` generic. The new way is to define your own node type for the whole app and then only use that one. The big advantage of this is, that you can have multiple node types with different data structures and always be able to distinguish by checking the `node.type` attribute.
|
- **Typescript only:** We simplified types and fixed issues about functions where users could pass a `NodeData` generic. The new way is to define your own node type for the whole app and then only use that one. The big advantage of this is, that you can have multiple node types with different data structures and always be able to distinguish by checking the `node.type` attribute.
|
||||||
@@ -48,7 +52,7 @@ Before you can try out the new features, you need to do some minor updates:
|
|||||||
- affected functions: `useNodes`, `useNodesState`, `useEdgesState`, `applyNodeChange`, `onInit`, `applyEdgeChanges` , `MiniMapProps`
|
- affected functions: `useNodes`, `useNodesState`, `useEdgesState`, `applyNodeChange`, `onInit`, `applyEdgeChanges` , `MiniMapProps`
|
||||||
- **Removal of deprecated functions:**
|
- **Removal of deprecated functions:**
|
||||||
- `getTransformForBounds` (new name: `getViewportForBounds`),
|
- `getTransformForBounds` (new name: `getViewportForBounds`),
|
||||||
- `getRectOfNodes` ****(new name: `getNodesBounds`)
|
- `getRectOfNodes` \*\*\*\*(new name: `getNodesBounds`)
|
||||||
- `project` (new name: `screenToFlowPosition`)
|
- `project` (new name: `screenToFlowPosition`)
|
||||||
- `getMarkerEndId`
|
- `getMarkerEndId`
|
||||||
|
|
||||||
@@ -93,5 +97,4 @@ These changes are not really user-facing, but it could be important for folks wh
|
|||||||
- We removed `connectionNodeId`, `connectionHandleId`, `connectionHandleType` from the store and added `connectionStartHandle.nodeId`, `connectionStartHandle.handleId`, …
|
- We removed `connectionNodeId`, `connectionHandleId`, `connectionHandleType` from the store and added `connectionStartHandle.nodeId`, `connectionStartHandle.handleId`, …
|
||||||
- add `data-id` to edges
|
- add `data-id` to edges
|
||||||
|
|
||||||
|
**With v12 the `reactflow` package was renamed to `@xyflow/react` - you can find the v11 source and the [`reactflow` changelog](https://github.com/xyflow/xyflow/blob/v11/packages/reactflow/CHANGELOG.md) on the v11 branch.**
|
||||||
__With v12 the `reactflow` package was renamed to `@xyflow/react` - you can find the v11 source and the [`reactflow` changelog](https://github.com/xyflow/xyflow/blob/v11/packages/reactflow/CHANGELOG.md) on the v11 branch.__
|
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ function EdgeWrapper({
|
|||||||
elementsSelectable,
|
elementsSelectable,
|
||||||
onClick,
|
onClick,
|
||||||
onDoubleClick,
|
onDoubleClick,
|
||||||
sourceHandleId,
|
|
||||||
targetHandleId,
|
|
||||||
onContextMenu,
|
onContextMenu,
|
||||||
onMouseEnter,
|
onMouseEnter,
|
||||||
onMouseMove,
|
onMouseMove,
|
||||||
@@ -78,8 +76,8 @@ function EdgeWrapper({
|
|||||||
id,
|
id,
|
||||||
sourceNode,
|
sourceNode,
|
||||||
targetNode,
|
targetNode,
|
||||||
sourceHandle: sourceHandleId || null,
|
sourceHandle: edge.sourceHandle || null,
|
||||||
targetHandle: targetHandleId || null,
|
targetHandle: edge.targetHandle || null,
|
||||||
connectionMode: store.connectionMode,
|
connectionMode: store.connectionMode,
|
||||||
onError,
|
onError,
|
||||||
});
|
});
|
||||||
@@ -97,7 +95,7 @@ function EdgeWrapper({
|
|||||||
...(edgePosition || nullPosition),
|
...(edgePosition || nullPosition),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[edge.source, edge.target, edge.selected, edge.zIndex]
|
[edge.source, edge.target, edge.sourceHandle, edge.targetHandle, edge.selected, edge.zIndex]
|
||||||
),
|
),
|
||||||
shallow
|
shallow
|
||||||
);
|
);
|
||||||
@@ -228,8 +226,8 @@ function EdgeWrapper({
|
|||||||
targetPosition={targetPosition}
|
targetPosition={targetPosition}
|
||||||
data={edge.data}
|
data={edge.data}
|
||||||
style={edge.style}
|
style={edge.style}
|
||||||
sourceHandleId={sourceHandleId}
|
sourceHandleId={edge.sourceHandle}
|
||||||
targetHandleId={targetHandleId}
|
targetHandleId={edge.targetHandle}
|
||||||
markerStart={markerStartUrl}
|
markerStart={markerStartUrl}
|
||||||
markerEnd={markerEndUrl}
|
markerEnd={markerEndUrl}
|
||||||
pathOptions={'pathOptions' in edge ? edge.pathOptions : undefined}
|
pathOptions={'pathOptions' in edge ? edge.pathOptions : undefined}
|
||||||
@@ -252,8 +250,8 @@ function EdgeWrapper({
|
|||||||
targetPosition={targetPosition}
|
targetPosition={targetPosition}
|
||||||
setUpdateHover={setUpdateHover}
|
setUpdateHover={setUpdateHover}
|
||||||
setUpdating={setUpdating}
|
setUpdating={setUpdating}
|
||||||
sourceHandleId={sourceHandleId}
|
sourceHandleId={edge.sourceHandle}
|
||||||
targetHandleId={targetHandleId}
|
targetHandleId={edge.targetHandle}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</g>
|
</g>
|
||||||
|
|||||||
@@ -69,8 +69,6 @@ export type EdgeWrapperProps = {
|
|||||||
noPanClassName: string;
|
noPanClassName: string;
|
||||||
onClick?: EdgeMouseHandler;
|
onClick?: EdgeMouseHandler;
|
||||||
onDoubleClick?: EdgeMouseHandler;
|
onDoubleClick?: EdgeMouseHandler;
|
||||||
sourceHandleId?: string | null;
|
|
||||||
targetHandleId?: string | null;
|
|
||||||
onEdgeUpdate?: OnEdgeUpdateFunc;
|
onEdgeUpdate?: OnEdgeUpdateFunc;
|
||||||
onContextMenu?: EdgeMouseHandler;
|
onContextMenu?: EdgeMouseHandler;
|
||||||
onMouseEnter?: EdgeMouseHandler;
|
onMouseEnter?: EdgeMouseHandler;
|
||||||
|
|||||||
Reference in New Issue
Block a user