fix(connectionRadius): pass prop to store
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { FC, useMemo, CSSProperties } from 'react';
|
import { FC, useMemo, CSSProperties } from 'react';
|
||||||
import { EdgeProps, useStore, getBezierPath, ReactFlowState } from 'reactflow';
|
import { EdgeProps, useStore, getBezierPath, ReactFlowState } from 'reactflow';
|
||||||
|
|
||||||
import { getEdgeParams } from './utils';
|
import { getEdgeParams } from './utils';
|
||||||
@@ -17,7 +17,7 @@ const FloatingEdge: FC<EdgeProps> = ({ id, source, target, style }) => {
|
|||||||
|
|
||||||
const { sx, sy, tx, ty, sourcePos, targetPos } = getEdgeParams(sourceNode, targetNode);
|
const { sx, sy, tx, ty, sourcePos, targetPos } = getEdgeParams(sourceNode, targetNode);
|
||||||
|
|
||||||
const d = getBezierPath({
|
const [path] = getBezierPath({
|
||||||
sourceX: sx,
|
sourceX: sx,
|
||||||
sourceY: sy,
|
sourceY: sy,
|
||||||
sourcePosition: sourcePos,
|
sourcePosition: sourcePos,
|
||||||
@@ -28,7 +28,7 @@ const FloatingEdge: FC<EdgeProps> = ({ id, source, target, style }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<g className="react-flow__connection">
|
<g className="react-flow__connection">
|
||||||
<path id={id} className="react-flow__edge-path" d={d} style={style as CSSProperties} />
|
<path id={id} className="react-flow__edge-path" d={path} style={style as CSSProperties} />
|
||||||
</g>
|
</g>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ type StoreUpdaterProps = Pick<
|
|||||||
| 'autoPanOnConnect'
|
| 'autoPanOnConnect'
|
||||||
| 'autoPanOnNodeDrag'
|
| 'autoPanOnNodeDrag'
|
||||||
| 'onError'
|
| 'onError'
|
||||||
|
| 'connectionRadius'
|
||||||
> & { rfId: string };
|
> & { rfId: string };
|
||||||
|
|
||||||
const selector = (s: ReactFlowState) => ({
|
const selector = (s: ReactFlowState) => ({
|
||||||
@@ -125,6 +126,7 @@ const StoreUpdater = ({
|
|||||||
autoPanOnConnect,
|
autoPanOnConnect,
|
||||||
autoPanOnNodeDrag,
|
autoPanOnNodeDrag,
|
||||||
onError,
|
onError,
|
||||||
|
connectionRadius,
|
||||||
}: StoreUpdaterProps) => {
|
}: StoreUpdaterProps) => {
|
||||||
const {
|
const {
|
||||||
setNodes,
|
setNodes,
|
||||||
@@ -181,6 +183,7 @@ const StoreUpdater = ({
|
|||||||
useDirectStoreUpdater('autoPanOnConnect', autoPanOnConnect, store.setState);
|
useDirectStoreUpdater('autoPanOnConnect', autoPanOnConnect, store.setState);
|
||||||
useDirectStoreUpdater('autoPanOnNodeDrag', autoPanOnNodeDrag, store.setState);
|
useDirectStoreUpdater('autoPanOnNodeDrag', autoPanOnNodeDrag, store.setState);
|
||||||
useDirectStoreUpdater('onError', onError, store.setState);
|
useDirectStoreUpdater('onError', onError, store.setState);
|
||||||
|
useDirectStoreUpdater('connectionRadius', connectionRadius, store.setState);
|
||||||
|
|
||||||
useStoreUpdater<Node[]>(nodes, setNodes);
|
useStoreUpdater<Node[]>(nodes, setNodes);
|
||||||
useStoreUpdater<Edge[]>(edges, setEdges);
|
useStoreUpdater<Edge[]>(edges, setEdges);
|
||||||
|
|||||||
@@ -294,6 +294,7 @@ const ReactFlow = forwardRef<ReactFlowRefType, ReactFlowProps>(
|
|||||||
autoPanOnConnect={autoPanOnConnect}
|
autoPanOnConnect={autoPanOnConnect}
|
||||||
autoPanOnNodeDrag={autoPanOnNodeDrag}
|
autoPanOnNodeDrag={autoPanOnNodeDrag}
|
||||||
onError={onError}
|
onError={onError}
|
||||||
|
connectionRadius={connectionRadius}
|
||||||
/>
|
/>
|
||||||
<SelectionListener onSelectionChange={onSelectionChange} />
|
<SelectionListener onSelectionChange={onSelectionChange} />
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Reference in New Issue
Block a user