refactor(svelte/react): use edge layouting vanilla helpers

This commit is contained in:
moklick
2023-06-08 15:46:35 +02:00
parent 4707a07c8b
commit c1e2499028
21 changed files with 392 additions and 436 deletions
+8 -3
View File
@@ -19,7 +19,6 @@ import {
import { addEdge as addEdgeUtil } from '$lib/utils';
import type { EdgeTypes, NodeTypes, Node, Edge, FitViewOptions } from '$lib/types';
import { getEdgesLayouted } from './edges-layouted';
import { getConnectionPath } from './connection-path';
import {
initConnectionData,
@@ -29,6 +28,7 @@ import {
} from './initial-store';
import type { SvelteFlowStore } from './types';
import { syncNodeStores, syncEdgeStores } from './utils';
import { getEdgeTree } from './edge-tree';
export const key = Symbol();
@@ -332,12 +332,16 @@ export function createStore(): SvelteFlowStore {
cancelConnection();
}
function onError(id: string, msg: string) {
console.log(msg);
}
return {
// state
...store,
// derived state
edgesLayouted: getEdgesLayouted(store),
edgeTree: getEdgeTree(store, onError),
connectionPath: getConnectionPath(store),
markers: derived(
[store.edges, store.defaultMarkerColor, store.flowId],
@@ -364,7 +368,8 @@ export function createStore(): SvelteFlowStore {
panBy,
updateConnection,
cancelConnection,
reset
reset,
onError
};
}