Rename updateEdge to reconnectEdge (#4373)
* refactor(edges): rename update to reconnect * refactor(react): rename edge update to reconnect * chore(examples): repair broken reconnect example * chore(react): changelog
This commit is contained in:
@@ -132,23 +132,23 @@ export const addEdge = <EdgeType extends EdgeBase>(
|
||||
return edges.concat(edge);
|
||||
};
|
||||
|
||||
export type UpdateEdgeOptions = {
|
||||
export type ReconnectEdgeOptions = {
|
||||
shouldReplaceId?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* A handy utility to update an existing Edge with new properties
|
||||
* A handy utility to reconnect an existing edge with new properties
|
||||
* @param oldEdge - The edge you want to update
|
||||
* @param newConnection - The new connection you want to update the edge with
|
||||
* @param edges - The array of all current edges
|
||||
* @param options.shouldReplaceId - should the id of the old edge be replaced with the new connection id
|
||||
* @returns the updated edges array
|
||||
*/
|
||||
export const updateEdge = <EdgeType extends EdgeBase>(
|
||||
export const reconnectEdge = <EdgeType extends EdgeBase>(
|
||||
oldEdge: EdgeType,
|
||||
newConnection: Connection,
|
||||
edges: EdgeType[],
|
||||
options: UpdateEdgeOptions = { shouldReplaceId: true }
|
||||
options: ReconnectEdgeOptions = { shouldReplaceId: true }
|
||||
): EdgeType[] => {
|
||||
const { id: oldEdgeId, ...rest } = oldEdge;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export type OnPointerDownParams = {
|
||||
onConnect?: OnConnect;
|
||||
onConnectEnd?: OnConnectEnd;
|
||||
isValidConnection?: IsValidConnection;
|
||||
onEdgeUpdateEnd?: (evt: MouseEvent | TouchEvent) => void;
|
||||
onReconnectEnd?: (evt: MouseEvent | TouchEvent) => void;
|
||||
getTransform: () => Transform;
|
||||
getConnectionStartHandle: () => ConnectingHandle | null;
|
||||
};
|
||||
@@ -89,7 +89,7 @@ function onPointerDown(
|
||||
onConnect,
|
||||
onConnectEnd,
|
||||
isValidConnection = alwaysValid,
|
||||
onEdgeUpdateEnd,
|
||||
onReconnectEnd,
|
||||
updateConnection,
|
||||
getTransform,
|
||||
getConnectionStartHandle,
|
||||
@@ -211,7 +211,7 @@ function onPointerDown(
|
||||
onConnectEnd?.(event);
|
||||
|
||||
if (edgeUpdaterType) {
|
||||
onEdgeUpdateEnd?.(event);
|
||||
onReconnectEnd?.(event);
|
||||
}
|
||||
|
||||
cancelConnection();
|
||||
|
||||
Reference in New Issue
Block a user