feat(onConnectEnd): pass connectionState

This commit is contained in:
moklick
2024-08-14 11:17:34 +02:00
parent 6eb6a8e525
commit aae62e9ec6
4 changed files with 20 additions and 6 deletions
+4 -1
View File
@@ -50,7 +50,10 @@ export type OnConnectStartParams = {
export type OnConnectStart = (event: MouseEvent | TouchEvent, params: OnConnectStartParams) => void;
export type OnConnect = (connection: Connection) => void;
export type OnConnectEnd = (event: MouseEvent | TouchEvent) => void;
export type OnConnectEnd = (
event: MouseEvent | TouchEvent,
connectionState: Omit<ConnectionState, 'inProgress'>
) => void;
export type IsValidConnection = (edge: EdgeBase | Connection) => boolean;
+6 -1
View File
@@ -193,7 +193,12 @@ function onPointerDown(
// it's important to get a fresh reference from the store here
// in order to get the latest state of onConnectEnd
onConnectEnd?.(event);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { inProgress, ...connectionState } = previousConnection;
onConnectEnd?.(event, {
...connectionState,
toPosition: previousConnection.toHandle ? previousConnection.toPosition : null,
});
if (edgeUpdaterType) {
onReconnectEnd?.(event);