@@ -10,6 +10,7 @@ import {
1010 type NodeMouseHandler ,
1111 ReactFlow ,
1212} from '@xyflow/react' ;
13+ import { reachableNodeIds } from 'ego-graph' ;
1314import { useCallback , useEffect , useMemo , useState } from 'react' ;
1415import { Icon } from 'ui-icons' ;
1516import { type GraphData } from '../../routes/_app/_builder/test-graph/-data' ;
@@ -19,21 +20,15 @@ import {
1920 PIVOT_TYPE_ATTRIBUTES ,
2021 useCustomerGraph ,
2122} from './CustomerGraphContext' ;
22- import { clusterGraphElements } from './cluster-graph' ;
2323import { createGraphTypeHelpers } from './data-model-map' ;
2424import { graphEdgeTypes , graphNodeTypes } from './GraphComponents' ;
25- import { withBestHandles } from './graph-handles' ;
2625import { type GraphObjectRef , nodeKey , parseNodeKey } from './graph-keys' ;
26+ import { clusterGraphElements , type GraphLayoutMode , layoutByMode , withBestHandles } from './graph-layout' ;
2727import { type GraphRfEdge , type GraphRfNode } from './graph-rf-types' ;
28- import { reachableNodeIds } from './graph-traversal' ;
29- import { layoutGraphElements as layoutGraphElementsRadDagre } from './layout-graph' ;
30- import { layoutGraphElements as layoutGraphElementsBalanced } from './layout-graph-2' ;
31- import { layoutGraphElements as layoutGraphElementsRadial } from './layout-graph-3' ;
3228import { toFlatFlowElements } from './utils' ;
3329import '@xyflow/react/dist/style.css' ;
34- import { match } from 'ts-pattern' ;
3530
36- export type GraphLayoutMode = 'rad-dagre' | 'balanced' | 'radial' ;
31+ export type { GraphLayoutMode } ;
3732
3833/** Re-run layout once React Flow has measured node sizes (must be a ReactFlow child). */
3934function GraphMeasuredLayout ( {
@@ -62,19 +57,6 @@ function resolveStartKey(nodes: GraphRfNode[], fallback: string): string {
6257 return start ?. id ?? fallback ;
6358}
6459
65- function layoutByMode (
66- mode : GraphLayoutMode ,
67- nodes : GraphRfNode [ ] ,
68- edges : GraphRfEdge [ ] ,
69- startKey : string ,
70- ) : { nodes : GraphRfNode [ ] ; edges : GraphRfEdge [ ] } {
71- return match ( mode )
72- . with ( 'balanced' , ( ) => layoutGraphElementsBalanced ( nodes , edges , startKey ) )
73- . with ( 'rad-dagre' , ( ) => layoutGraphElementsRadDagre ( nodes , edges , startKey ) )
74- . with ( 'radial' , ( ) => layoutGraphElementsRadial ( nodes , edges , startKey ) )
75- . exhaustive ( ) ;
76- }
77-
7860type VisibilityFilters = Pick <
7961 CustomerGraphContextValue ,
8062 'showPersons' | 'showCompanies' | 'attributes' | 'hiddenNodeIds'
0 commit comments