Skip to content

Commit 1a3c4ef

Browse files
Ego graph package (#1793)
* ego-graph package * create separate package * update ego-graph packege
1 parent aba16ef commit 1a3c4ef

47 files changed

Lines changed: 3441 additions & 1910 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bun.lock

Lines changed: 249 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-builder/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"decode-formdata": "^0.9.0",
9393
"deepsignal": "^1.6.0",
9494
"dinero.js": "2.0.2",
95+
"ego-graph": "workspace:*",
9596
"embla-carousel-react": "^8.6.0",
9697
"firebase": "^12.13.0",
9798
"i18next": "^26.3.0",

packages/app-builder/src/components/Graph/GraphImpl.tsx

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
type NodeMouseHandler,
1111
ReactFlow,
1212
} from '@xyflow/react';
13+
import { reachableNodeIds } from 'ego-graph';
1314
import { useCallback, useEffect, useMemo, useState } from 'react';
1415
import { Icon } from 'ui-icons';
1516
import { 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';
2323
import { createGraphTypeHelpers } from './data-model-map';
2424
import { graphEdgeTypes, graphNodeTypes } from './GraphComponents';
25-
import { withBestHandles } from './graph-handles';
2625
import { type GraphObjectRef, nodeKey, parseNodeKey } from './graph-keys';
26+
import { clusterGraphElements, type GraphLayoutMode, layoutByMode, withBestHandles } from './graph-layout';
2727
import { 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';
3228
import { toFlatFlowElements } from './utils';
3329
import '@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). */
3934
function 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-
7860
type VisibilityFilters = Pick<
7961
CustomerGraphContextValue,
8062
'showPersons' | 'showCompanies' | 'attributes' | 'hiddenNodeIds'

packages/app-builder/src/components/Graph/cluster-graph.spec.ts

Lines changed: 0 additions & 267 deletions
This file was deleted.

0 commit comments

Comments
 (0)