streamlined connections

This commit is contained in:
peterkogo
2024-06-26 15:03:12 +02:00
parent 44254648c8
commit 5493f045ff
25 changed files with 355 additions and 474 deletions
+4 -18
View File
@@ -12,6 +12,7 @@ import {
EdgeSelectionChange,
NodeSelectionChange,
ParentExpandChild,
initialConnection,
} from '@xyflow/system';
import { applyEdgeChanges, applyNodeChanges, createSelectionChange, getSelectionChanges } from '../utils/changes';
@@ -308,27 +309,12 @@ const createStore = ({
);
},
cancelConnection: () => {
const { connection } = get();
set({
connection: {
position: connection.position,
fromHandle: null,
toHandle: null,
isValid: null,
},
connection: { ...initialConnection },
});
},
updateConnection: (params) => {
const { connection } = get();
const currentConnection = {
connection: {
...params,
position: params.position ?? connection.position,
},
};
set(currentConnection);
updateConnection: (connection) => {
set({ connection });
},
reset: () => set({ ...getInitialState() }),
+2 -6
View File
@@ -7,6 +7,7 @@ import {
updateConnectionLookup,
devWarn,
getInternalNodesBounds,
initialConnection,
} from '@xyflow/system';
import type { Edge, InternalNode, Node, ReactFlowStore } from '../types';
@@ -101,12 +102,7 @@ const getInitialState = ({
multiSelectionActive: false,
connection: {
fromHandle: null,
toHandle: null,
position: { x: 0, y: 0 },
isValid: null,
},
connection: { ...initialConnection },
connectionClickStartHandle: null,
connectOnClick: true,