Merge branch 'main' of github.com:wbkd/react-flow into main
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
"start:testserver": "npm run build && npm run start:examples",
|
"start:testserver": "npm run build && npm run start:examples",
|
||||||
"build:dev": "npm install && npm run build && cd example && npm install && npm run build",
|
"build:dev": "npm install && npm run build && cd example && npm install && npm run build",
|
||||||
"dev:wait": "start-server-and-test start:testserver http-get://localhost:3000",
|
"dev:wait": "start-server-and-test start:testserver http-get://localhost:3000",
|
||||||
"test": "npm run dev:wait test:chrome",
|
"test": "BROWSER=none npm run dev:wait test:chrome",
|
||||||
"test:chrome": "cypress run --browser chrome --headless",
|
"test:chrome": "cypress run --browser chrome --headless",
|
||||||
"test:firefox": "cypress run --browser firefox",
|
"test:firefox": "cypress run --browser firefox",
|
||||||
"test:all": "npm run test:chrome && npm run test:firefox",
|
"test:all": "npm run test:chrome && npm run test:firefox",
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export default (EdgeComponent: ComponentType<EdgeProps>) => {
|
|||||||
handleEdgeUpdate,
|
handleEdgeUpdate,
|
||||||
onConnectEdge,
|
onConnectEdge,
|
||||||
onContextMenu,
|
onContextMenu,
|
||||||
|
edgeUpdaterRadius,
|
||||||
}: WrapEdgeProps): JSX.Element | null => {
|
}: WrapEdgeProps): JSX.Element | null => {
|
||||||
const addSelectedElements = useStoreActions((actions) => actions.addSelectedElements);
|
const addSelectedElements = useStoreActions((actions) => actions.addSelectedElements);
|
||||||
const setConnectionNodeId = useStoreActions((actions) => actions.setConnectionNodeId);
|
const setConnectionNodeId = useStoreActions((actions) => actions.setConnectionNodeId);
|
||||||
@@ -151,6 +152,7 @@ export default (EdgeComponent: ComponentType<EdgeProps>) => {
|
|||||||
position={sourcePosition}
|
position={sourcePosition}
|
||||||
centerX={sourceX}
|
centerX={sourceX}
|
||||||
centerY={sourceY}
|
centerY={sourceY}
|
||||||
|
radius={edgeUpdaterRadius}
|
||||||
/>
|
/>
|
||||||
</g>
|
</g>
|
||||||
)}
|
)}
|
||||||
@@ -189,6 +191,7 @@ export default (EdgeComponent: ComponentType<EdgeProps>) => {
|
|||||||
position={targetPosition}
|
position={targetPosition}
|
||||||
centerX={targetX}
|
centerX={targetX}
|
||||||
centerY={targetY}
|
centerY={targetY}
|
||||||
|
radius={edgeUpdaterRadius}
|
||||||
/>
|
/>
|
||||||
</g>
|
</g>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ interface EdgeRendererProps {
|
|||||||
onlyRenderVisibleElements: boolean;
|
onlyRenderVisibleElements: boolean;
|
||||||
onEdgeUpdate?: OnEdgeUpdateFunc;
|
onEdgeUpdate?: OnEdgeUpdateFunc;
|
||||||
onEdgeContextMenu?: (event: React.MouseEvent, element: Edge) => void;
|
onEdgeContextMenu?: (event: React.MouseEvent, element: Edge) => void;
|
||||||
|
edgeUpdaterRadius?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EdgeWrapperProps {
|
interface EdgeWrapperProps {
|
||||||
@@ -165,6 +166,7 @@ const Edge = ({
|
|||||||
onConnectEdge={onConnectEdge}
|
onConnectEdge={onConnectEdge}
|
||||||
handleEdgeUpdate={typeof props.onEdgeUpdate !== 'undefined'}
|
handleEdgeUpdate={typeof props.onEdgeUpdate !== 'undefined'}
|
||||||
onContextMenu={props.onEdgeContextMenu}
|
onContextMenu={props.onEdgeContextMenu}
|
||||||
|
edgeUpdaterRadius={props.edgeUpdaterRadius}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -86,8 +86,9 @@ const GraphView = ({
|
|||||||
onPaneContextMenu,
|
onPaneContextMenu,
|
||||||
onEdgeUpdate,
|
onEdgeUpdate,
|
||||||
onEdgeContextMenu,
|
onEdgeContextMenu,
|
||||||
|
edgeUpdaterRadius,
|
||||||
}: GraphViewProps) => {
|
}: GraphViewProps) => {
|
||||||
const isInitialised = useRef<boolean>(false);
|
const isInitialized = useRef<boolean>(false);
|
||||||
const setOnConnect = useStoreActions((actions) => actions.setOnConnect);
|
const setOnConnect = useStoreActions((actions) => actions.setOnConnect);
|
||||||
const setOnConnectStart = useStoreActions((actions) => actions.setOnConnectStart);
|
const setOnConnectStart = useStoreActions((actions) => actions.setOnConnectStart);
|
||||||
const setOnConnectStop = useStoreActions((actions) => actions.setOnConnectStop);
|
const setOnConnectStop = useStoreActions((actions) => actions.setOnConnectStop);
|
||||||
@@ -106,7 +107,7 @@ const GraphView = ({
|
|||||||
const { zoomIn, zoomOut, zoomTo, transform, fitView, initialized } = useZoomPanHelper();
|
const { zoomIn, zoomOut, zoomTo, transform, fitView, initialized } = useZoomPanHelper();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isInitialised.current && initialized) {
|
if (!isInitialized.current && initialized) {
|
||||||
if (onLoad) {
|
if (onLoad) {
|
||||||
onLoad({
|
onLoad({
|
||||||
fitView: (params = { padding: 0.1 }) => fitView(params),
|
fitView: (params = { padding: 0.1 }) => fitView(params),
|
||||||
@@ -120,7 +121,7 @@ const GraphView = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
isInitialised.current = true;
|
isInitialized.current = true;
|
||||||
}
|
}
|
||||||
}, [onLoad, zoomIn, zoomOut, zoomTo, transform, fitView, initialized]);
|
}, [onLoad, zoomIn, zoomOut, zoomTo, transform, fitView, initialized]);
|
||||||
|
|
||||||
@@ -264,6 +265,7 @@ const GraphView = ({
|
|||||||
onEdgeUpdate={onEdgeUpdate}
|
onEdgeUpdate={onEdgeUpdate}
|
||||||
onlyRenderVisibleElements={onlyRenderVisibleElements}
|
onlyRenderVisibleElements={onlyRenderVisibleElements}
|
||||||
onEdgeContextMenu={onEdgeContextMenu}
|
onEdgeContextMenu={onEdgeContextMenu}
|
||||||
|
edgeUpdaterRadius={edgeUpdaterRadius}
|
||||||
/>
|
/>
|
||||||
</FlowRenderer>
|
</FlowRenderer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ export interface ReactFlowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
|
|||||||
zoomOnDoubleClick?: boolean;
|
zoomOnDoubleClick?: boolean;
|
||||||
onEdgeUpdate?: OnEdgeUpdateFunc;
|
onEdgeUpdate?: OnEdgeUpdateFunc;
|
||||||
onEdgeContextMenu?: (event: MouseEvent, nodes: Edge) => void;
|
onEdgeContextMenu?: (event: MouseEvent, nodes: Edge) => void;
|
||||||
|
edgeUpdaterRadius?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReactFlow = ({
|
const ReactFlow = ({
|
||||||
@@ -175,6 +176,7 @@ const ReactFlow = ({
|
|||||||
children,
|
children,
|
||||||
onEdgeUpdate,
|
onEdgeUpdate,
|
||||||
onEdgeContextMenu,
|
onEdgeContextMenu,
|
||||||
|
edgeUpdaterRadius = 10,
|
||||||
...rest
|
...rest
|
||||||
}: ReactFlowProps) => {
|
}: ReactFlowProps) => {
|
||||||
const nodeTypesParsed = useMemo(() => createNodeTypes(nodeTypes), []);
|
const nodeTypesParsed = useMemo(() => createNodeTypes(nodeTypes), []);
|
||||||
@@ -243,6 +245,7 @@ const ReactFlow = ({
|
|||||||
onSelectionContextMenu={onSelectionContextMenu}
|
onSelectionContextMenu={onSelectionContextMenu}
|
||||||
onEdgeUpdate={onEdgeUpdate}
|
onEdgeUpdate={onEdgeUpdate}
|
||||||
onEdgeContextMenu={onEdgeContextMenu}
|
onEdgeContextMenu={onEdgeContextMenu}
|
||||||
|
edgeUpdaterRadius={edgeUpdaterRadius}
|
||||||
/>
|
/>
|
||||||
<ElementUpdater elements={elements} />
|
<ElementUpdater elements={elements} />
|
||||||
{onSelectionChange && <SelectionListener onSelectionChange={onSelectionChange} />}
|
{onSelectionChange && <SelectionListener onSelectionChange={onSelectionChange} />}
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ export interface WrapEdgeProps<T = any> {
|
|||||||
handleEdgeUpdate: boolean;
|
handleEdgeUpdate: boolean;
|
||||||
onConnectEdge: OnConnectFunc;
|
onConnectEdge: OnConnectFunc;
|
||||||
onContextMenu: (event: React.MouseEvent, edge: Edge) => void;
|
onContextMenu: (event: React.MouseEvent, edge: Edge) => void;
|
||||||
|
edgeUpdaterRadius?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EdgeProps<T = any> {
|
export interface EdgeProps<T = any> {
|
||||||
|
|||||||
Reference in New Issue
Block a user