@@ -10,6 +10,7 @@ import {
1010 isEdge ,
1111 isNode
1212} from '../../types' ;
13+ import { AggregateEdgeRole } from '../../utils/createAggregateEdges' ;
1314import { SELECTION_STATE } from '../../behavior' ;
1415import { useEventListener } from '../../hooks' ;
1516import DefaultEdge from './DefaultEdge' ;
@@ -32,6 +33,22 @@ export interface DefaultAggregatedEdgeProps {
3233 element : GraphElement ;
3334 /** Flag indicating if the element is selected. Part of WithSelectionProps */
3435 selected ?: boolean ;
36+ /**
37+ * Segment role (`exit` / `bridge` / `entry`). Typically from `createAggregateEdges`
38+ * edge data, but apps may supply an equivalent.
39+ */
40+ role ?: AggregateEdgeRole | string ;
41+ /**
42+ * Number of leaf edges folded into this segment. Used for the default bridge tag
43+ * when {@link DefaultAggregatedEdgeProps.tag} is omitted.
44+ */
45+ count ?: number ;
46+ /** When true, the bridge shows terminals on both ends. */
47+ bidirectional ?: boolean ;
48+ /** Leaf edge ids flowing in the bridge's stored orientation. */
49+ forwardEdgeIds ?: string [ ] ;
50+ /** Leaf edge ids flowing opposite the bridge orientation. */
51+ reverseEdgeIds ?: string [ ] ;
3552 /**
3653 * Bump after structural changes (e.g. group collapse / model rebuild) that leave
3754 * fixed endpoints stale without enough bound change to re-trigger snap.
@@ -58,11 +75,26 @@ export interface DefaultAggregatedEdgeProps {
5875 * - Multi-segment path selection by shared `aggregatedEdgeIds`
5976 * - Bidirectional bridge terminals, muting the opposite arrow when selection is one-way
6077 *
78+ * Aggregate metadata (`role`, `count`, `bidirectional`, …) is passed as props so apps
79+ * can derive or override them instead of reading a fixed `element.getData()` shape.
80+ *
6181 * Note: path selection updates `SELECTION_STATE` directly. Prefer `withSelection()` for the
6282 * `selected` prop only — do not rely on its `onSelect` (it would collapse the path to one id).
6383 */
6484const DefaultAggregatedEdge : FunctionComponent < DefaultAggregatedEdgeProps > = observer (
65- ( { element, selected, snapGeneration = 0 , tag : tagProp , className, children } ) => {
85+ ( {
86+ element,
87+ selected,
88+ role,
89+ count,
90+ bidirectional,
91+ forwardEdgeIds,
92+ reverseEdgeIds,
93+ snapGeneration = 0 ,
94+ tag : tagProp ,
95+ className,
96+ children
97+ } ) => {
6698 const edge = isEdge ( element ) ? ( element as Edge ) : null ;
6799 const [ layoutSnapGeneration , setLayoutSnapGeneration ] = useState ( 0 ) ;
68100
@@ -80,9 +112,7 @@ const DefaultAggregatedEdge: FunctionComponent<DefaultAggregatedEdgeProps> = obs
80112 // Clear this edge's fixed endpoints and force-resnap when Cola (etc.) finishes.
81113 // Mid-layout snaps often leave stubs/bridges pointing at stale hulls.
82114 useEventListener ( GRAPH_LAYOUT_END_EVENT , onLayoutEnd ) ;
83- const data = edge ?. getData ( ) || { } ;
84- const role = data . role as string | undefined ;
85- const count = data . count as number | undefined ;
115+
86116 const sourceNode = edge ?. getSource ( ) ;
87117 const targetNode = edge ?. getTarget ( ) ;
88118
@@ -174,7 +204,11 @@ const DefaultAggregatedEdge: FunctionComponent<DefaultAggregatedEdgeProps> = obs
174204 const selectionState = edge . getController ( ) . getState < { [ SELECTION_STATE ] ?: string [ ] } > ( ) ;
175205 const selectedIds = selectionState [ SELECTION_STATE ] || [ ] ;
176206 const focusLeaves = getSelectionFocusLeaves ( edge , selectedIds ) ;
177- const terminals = getBridgeTerminalPresentation ( data , selected , focusLeaves ) ;
207+ const terminals = getBridgeTerminalPresentation (
208+ { bidirectional, forwardEdgeIds, reverseEdgeIds } ,
209+ selected ,
210+ focusLeaves
211+ ) ;
178212 startTerminalType = terminals . start ;
179213 endTerminalType = terminals . end ;
180214 if ( terminals . muteStart ) {
0 commit comments