@likec4/diagram 1.27.1 → 1.27.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/index.js +2147 -6730
- package/dist/LikeC4Diagram.js +1 -1
- package/dist/LikeC4Diagram.props.d.ts +5 -3
- package/dist/StaticLikeC4Diagram.js +1 -1
- package/dist/_virtual/set.js +5 -0
- package/dist/_virtual/set2.js +3 -0
- package/dist/base/BaseXYFlow.d.ts +2 -1
- package/dist/base/primitives/compound/CompoundNodeContainer.d.ts +1 -1
- package/dist/base/primitives/compound/CompoundNodeContainer.js +0 -1
- package/dist/base/primitives/element/ElementActionButtons.js +5 -10
- package/dist/base/primitives/element/ElementNodeContainer.css.js +4 -4
- package/dist/base/updateEdges.js +1 -9
- package/dist/base/updateNodes.js +1 -12
- package/dist/bundle/LikeC4View.js +2 -2
- package/dist/bundle/LikeC4View.props.d.ts +7 -7
- package/dist/hooks/useCurrentViewId.js +8 -2
- package/dist/hooks/useDiagram.d.ts +1517 -684
- package/dist/hooks/useDiagram.js +16 -8
- package/dist/likec4diagram/ui/notation/NotationPanel.css.js +3 -3
- package/dist/likec4diagram/ui/notation/NotationPanel.js +10 -4
- package/dist/node_modules/.pnpm/mnemonist@0.40.3_patch_hash_5c12abb43fcff6fd81e53021b89075d53249640d165a2556cc1e58d71201a13a/node_modules/mnemonist/set.js +369 -0
- package/dist/overlays/Overlays.js +3 -1
- package/dist/overlays/element-details/actor.d.ts +2769 -173
- package/dist/overlays/overlay/Overlay.css.d.ts +26 -2
- package/dist/overlays/overlay/Overlay.css.js +66 -18
- package/dist/overlays/overlay/Overlay.d.ts +7 -6
- package/dist/overlays/overlay/Overlay.js +12 -8
- package/dist/overlays/overlaysActor.js +2 -2
- package/dist/overlays/relationship-details/RelationshipDetails.js +113 -70
- package/dist/overlays/relationship-details/SelectEdge.d.ts +1 -1
- package/dist/overlays/relationship-details/SelectEdge.js +15 -9
- package/dist/overlays/relationship-details/_types.d.ts +4 -1
- package/dist/overlays/relationship-details/actor.d.ts +415 -128
- package/dist/overlays/relationship-details/actor.js +162 -53
- package/dist/overlays/relationship-details/compute.d.ts +12 -0
- package/dist/overlays/relationship-details/compute.js +139 -0
- package/dist/overlays/relationship-details/custom/ElementActions.js +27 -5
- package/dist/overlays/relationship-details/custom/edgeTypes.js +1 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +2 -1
- package/dist/overlays/relationship-details/hooks.d.ts +336 -6
- package/dist/overlays/relationship-details/hooks.js +9 -7
- package/dist/overlays/relationship-details/layout-to-xyflow.d.ts +12 -0
- package/dist/overlays/relationship-details/layout-to-xyflow.js +149 -0
- package/dist/overlays/relationship-details/layout.d.ts +22 -0
- package/dist/overlays/relationship-details/layout.js +314 -0
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +3 -1
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +2 -2
- package/dist/overlays/relationships-browser/_types.d.ts +2 -0
- package/dist/overlays/relationships-browser/actor.d.ts +130 -14
- package/dist/overlays/relationships-browser/actor.js +30 -16
- package/dist/overlays/relationships-browser/custom/ElementActions.js +5 -3
- package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +3 -1
- package/dist/overlays/relationships-browser/custom/edgeTypes.js +1 -1
- package/dist/overlays/relationships-browser/hooks.d.ts +3 -1
- package/dist/overlays/relationships-browser/hooks.js +1 -1
- package/dist/overlays/relationships-browser/{-useRelationshipsView.d.ts → layout.d.ts} +2 -0
- package/dist/overlays/relationships-browser/{-useRelationshipsView.js → layout.js} +19 -2
- package/dist/overlays/relationships-browser/useViewToNodesEdges.d.ts +1 -1
- package/dist/overlays/relationships-browser/useViewToNodesEdges.js +3 -1
- package/dist/packages/core/src/compute-view/relationships-view/compute.js +1 -1
- package/dist/packages/core/src/model/connection/model/ConnectionModel.js +121 -0
- package/dist/packages/core/src/model/connection/model/find.js +39 -0
- package/dist/packages/core/src/model/connection/ops.js +7 -0
- package/dist/packages/core/src/utils/const.js +3 -0
- package/dist/packages/core/src/utils/fqn.js +9 -1
- package/dist/packages/core/src/utils/iterable/find.js +21 -0
- package/dist/packages/core/src/utils/iterable/some.js +21 -0
- package/dist/packages/core/src/utils/set.js +48 -0
- package/dist/packages/core/src/utils/string-hash.js +13 -0
- package/dist/state/diagram-machine.d.ts +1552 -703
- package/dist/state/diagram-machine.js +39 -3
- package/dist/state/syncManualLayoutActor.d.ts +1 -1
- package/dist/styles.css.js +1 -1
- package/package.json +11 -11
- package/src/LikeC4Diagram.props.ts +7 -3
- package/src/LikeC4Diagram.tsx +1 -1
- package/src/StaticLikeC4Diagram.tsx +1 -1
- package/src/base/BaseXYFlow.tsx +2 -1
- package/src/base/primitives/compound/CompoundNodeContainer.tsx +0 -2
- package/src/base/primitives/element/ElementActionButtons.tsx +6 -7
- package/src/base/primitives/element/ElementNodeContainer.css.ts +4 -4
- package/src/base/updateEdges.ts +8 -8
- package/src/base/updateNodes.ts +11 -11
- package/src/bundle/LikeC4View.props.ts +7 -7
- package/src/bundle/LikeC4View.tsx +2 -2
- package/src/hooks/useCurrentViewId.ts +4 -2
- package/src/hooks/useDiagram.ts +18 -9
- package/src/likec4diagram/ui/notation/NotationPanel.css.ts +2 -2
- package/src/likec4diagram/ui/notation/NotationPanel.tsx +8 -6
- package/src/overlays/Overlays.tsx +3 -1
- package/src/overlays/overlay/Overlay.css.ts +67 -17
- package/src/overlays/overlay/Overlay.tsx +26 -21
- package/src/overlays/overlaysActor.ts +1 -1
- package/src/overlays/relationship-details/RelationshipDetails.tsx +131 -68
- package/src/overlays/relationship-details/SelectEdge.tsx +19 -12
- package/src/overlays/relationship-details/_types.ts +3 -1
- package/src/overlays/relationship-details/actor.ts +217 -68
- package/src/overlays/relationship-details/compute.ts +186 -0
- package/src/overlays/relationship-details/custom/ElementActions.tsx +27 -18
- package/src/overlays/relationship-details/custom/edgeTypes.tsx +1 -1
- package/src/overlays/relationship-details/hooks.ts +10 -8
- package/src/overlays/relationship-details/layout-to-xyflow.ts +195 -0
- package/src/overlays/relationship-details/layout.ts +470 -0
- package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +2 -2
- package/src/overlays/relationships-browser/_types.ts +2 -0
- package/src/overlays/relationships-browser/actor.ts +39 -14
- package/src/overlays/relationships-browser/custom/ElementActions.tsx +5 -3
- package/src/overlays/relationships-browser/custom/edgeTypes.tsx +1 -1
- package/src/overlays/relationships-browser/hooks.ts +2 -2
- package/src/overlays/relationships-browser/{-useRelationshipsView.ts → layout.ts} +23 -13
- package/src/overlays/relationships-browser/useViewToNodesEdges.ts +3 -1
- package/src/state/diagram-machine.ts +51 -6
- package/dist/overlays/relationship-details/useLayoutedDetails.d.ts +0 -19
- package/dist/overlays/relationship-details/useLayoutedDetails.js +0 -267
- package/src/overlays/relationship-details/useLayoutedDetails.ts +0 -376
|
@@ -1,22 +1,32 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DiagramEdge, type DiagramView, ifind, invariant, isAncestor, nonNullable } from '@likec4/core'
|
|
2
2
|
import { ActionIcon, Group } from '@mantine/core'
|
|
3
3
|
import { useCallbackRef, useStateHistory } from '@mantine/hooks'
|
|
4
4
|
import { IconChevronLeft, IconChevronRight, IconX } from '@tabler/icons-react'
|
|
5
|
-
import {
|
|
5
|
+
import { useSelector } from '@xstate/react'
|
|
6
|
+
import { Panel, ReactFlowProvider, useReactFlow, useStoreApi } from '@xyflow/react'
|
|
6
7
|
import clsx from 'clsx'
|
|
8
|
+
import { deepEqual } from 'fast-equals'
|
|
7
9
|
import { AnimatePresence, LayoutGroup, m } from 'framer-motion'
|
|
8
|
-
import { memo, useEffect, useRef } from 'react'
|
|
10
|
+
import { memo, useEffect, useMemo, useRef } from 'react'
|
|
11
|
+
import { first } from 'remeda'
|
|
9
12
|
import { BaseXYFlow } from '../../base/BaseXYFlow'
|
|
13
|
+
import { useLikeC4Model } from '../../likec4model/useLikeC4Model'
|
|
10
14
|
import type { RelationshipDetailsTypes, RelationshipDetailsTypes as Types } from './_types'
|
|
11
15
|
import type { RelationshipDetailsActorRef, RelationshipDetailsSnapshot } from './actor'
|
|
16
|
+
import {
|
|
17
|
+
type RelationshipDetailsViewData,
|
|
18
|
+
computeEdgeDetailsViewData,
|
|
19
|
+
computeRelationshipDetailsViewData,
|
|
20
|
+
} from './compute'
|
|
12
21
|
import { CompoundNode, ElementNode, RelationshipEdge } from './custom'
|
|
13
22
|
import {
|
|
14
23
|
RelationshipDetailsActorContext,
|
|
15
24
|
useRelationshipDetails,
|
|
25
|
+
useRelationshipDetailsActor,
|
|
16
26
|
useRelationshipDetailsState,
|
|
17
27
|
} from './hooks'
|
|
28
|
+
import { layoutRelationshipDetails } from './layout'
|
|
18
29
|
import { SelectEdge } from './SelectEdge'
|
|
19
|
-
import { useLayoutedDetails } from './useLayoutedDetails'
|
|
20
30
|
|
|
21
31
|
const nodeTypes = {
|
|
22
32
|
element: ElementNode,
|
|
@@ -59,60 +69,76 @@ export function RelationshipDetails({ actorRef }: RelationshipDetailsProps) {
|
|
|
59
69
|
<RelationshipDetailsInner />
|
|
60
70
|
</AnimatePresence>
|
|
61
71
|
</LayoutGroup>
|
|
72
|
+
<SyncRelationshipDetailsXYFlow />
|
|
62
73
|
</ReactFlowProvider>
|
|
63
74
|
</RelationshipDetailsActorContext.Provider>
|
|
64
75
|
)
|
|
65
76
|
}
|
|
66
77
|
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
initialized: state.context.initialized,
|
|
71
|
-
nodes: state.context.xynodes,
|
|
72
|
-
edges: state.context.xyedges,
|
|
78
|
+
const selectSubject = (state: RelationshipDetailsSnapshot) => ({
|
|
79
|
+
...state.context.subject,
|
|
80
|
+
viewId: state.context.viewId,
|
|
73
81
|
})
|
|
74
82
|
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
83
|
+
function SyncRelationshipDetailsXYFlow() {
|
|
84
|
+
const actor = useRelationshipDetailsActor()
|
|
85
|
+
const subject = useSelector(actor, selectSubject, deepEqual)
|
|
86
|
+
const likec4model = useLikeC4Model(true)
|
|
87
|
+
const view = likec4model.findView(subject.viewId) ?? null
|
|
88
|
+
const data = useMemo(() => {
|
|
89
|
+
let data: RelationshipDetailsViewData
|
|
90
|
+
if ('edgeId' in subject) {
|
|
91
|
+
invariant(view, `view ${subject.viewId} not found`)
|
|
92
|
+
const edge = nonNullable(view.findEdge(subject.edgeId), `edge ${subject.edgeId} not found in ${subject.viewId}`)
|
|
93
|
+
data = computeEdgeDetailsViewData([edge.id], view)
|
|
94
|
+
} else {
|
|
95
|
+
data = computeRelationshipDetailsViewData({
|
|
96
|
+
source: likec4model.element(subject.source),
|
|
97
|
+
target: likec4model.element(subject.target),
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
return layoutRelationshipDetails(data, view)
|
|
101
|
+
}, [
|
|
102
|
+
subject,
|
|
79
103
|
view,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
edges,
|
|
83
|
-
} = useRelationshipDetailsState(selector)
|
|
104
|
+
likec4model,
|
|
105
|
+
])
|
|
84
106
|
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
xynodes,
|
|
88
|
-
xyedges,
|
|
89
|
-
bounds,
|
|
90
|
-
} = useLayoutedDetails(edgeId, view)
|
|
91
|
-
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
browser.send({ type: 'update.xydata', xynodes, xyedges })
|
|
94
|
-
}, [xynodes, xyedges])
|
|
95
|
-
|
|
96
|
-
const [historyEdgeId, historyOps, { history, current }] = useStateHistory(edgeId)
|
|
107
|
+
const store = useStoreApi<RelationshipDetailsTypes.Node, RelationshipDetailsTypes.Edge>()
|
|
108
|
+
const instance = useReactFlow<RelationshipDetailsTypes.Node, RelationshipDetailsTypes.Edge>()
|
|
97
109
|
|
|
98
110
|
useEffect(() => {
|
|
99
|
-
if (
|
|
100
|
-
|
|
111
|
+
if (instance.viewportInitialized) {
|
|
112
|
+
actor.send({ type: 'xyflow.init', instance, store })
|
|
101
113
|
}
|
|
102
|
-
}, [
|
|
114
|
+
}, [store, instance.viewportInitialized, actor])
|
|
103
115
|
|
|
104
116
|
useEffect(() => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
}, [historyEdgeId])
|
|
117
|
+
actor.send({ type: 'update.layoutData', data })
|
|
118
|
+
}, [data, actor])
|
|
109
119
|
|
|
110
|
-
|
|
111
|
-
|
|
120
|
+
return null
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const selector = ({ context }: RelationshipDetailsSnapshot) => ({
|
|
124
|
+
// subject: context.subject,
|
|
125
|
+
// view: state.context.view,
|
|
126
|
+
initialized: context.initialized.xydata && context.initialized.xyflow,
|
|
127
|
+
nodes: context.xynodes,
|
|
128
|
+
edges: context.xyedges,
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
const RelationshipDetailsInner = memo(() => {
|
|
132
|
+
const browser = useRelationshipDetails()
|
|
133
|
+
const {
|
|
134
|
+
initialized,
|
|
135
|
+
nodes,
|
|
136
|
+
edges,
|
|
137
|
+
} = useRelationshipDetailsState(selector, deepEqual)
|
|
112
138
|
|
|
113
139
|
return (
|
|
114
140
|
<BaseXYFlow<Types.Node, Types.Edge>
|
|
115
|
-
id={
|
|
141
|
+
id={browser.rootElementId}
|
|
116
142
|
nodes={nodes}
|
|
117
143
|
edges={edges}
|
|
118
144
|
className={clsx(initialized ? 'initialized' : 'not-initialized')}
|
|
@@ -125,9 +151,6 @@ const RelationshipDetailsInner = memo(() => {
|
|
|
125
151
|
browser.send({ type: 'xyflow.applyEdgeChanges', changes })
|
|
126
152
|
})}
|
|
127
153
|
fitViewPadding={0.05}
|
|
128
|
-
onInit={useCallbackRef((instance) => {
|
|
129
|
-
browser.send({ type: 'xyflow.init', instance })
|
|
130
|
-
})}
|
|
131
154
|
onNodeClick={useCallbackRef((e, node) => {
|
|
132
155
|
e.stopPropagation()
|
|
133
156
|
browser.send({ type: 'xyflow.nodeClick', node })
|
|
@@ -137,17 +160,23 @@ const RelationshipDetailsInner = memo(() => {
|
|
|
137
160
|
browser.send({ type: 'xyflow.edgeClick', edge })
|
|
138
161
|
})}
|
|
139
162
|
onPaneClick={useCallbackRef((e) => {
|
|
140
|
-
e.stopPropagation()
|
|
141
163
|
browser.send({ type: 'xyflow.paneClick' })
|
|
142
164
|
})}
|
|
165
|
+
onDoubleClick={useCallbackRef(e => {
|
|
166
|
+
browser.send({ type: 'xyflow.paneDblClick' })
|
|
167
|
+
})}
|
|
143
168
|
onViewportResize={useCallbackRef(() => {
|
|
144
169
|
browser.send({ type: 'xyflow.resized' })
|
|
145
170
|
})}
|
|
146
171
|
onEdgeMouseEnter={useCallbackRef((_event, edge) => {
|
|
147
|
-
|
|
172
|
+
if (!edge.data.hovered) {
|
|
173
|
+
browser.send({ type: 'xyflow.edgeMouseEnter', edge })
|
|
174
|
+
}
|
|
148
175
|
})}
|
|
149
176
|
onEdgeMouseLeave={useCallbackRef((_event, edge) => {
|
|
150
|
-
|
|
177
|
+
if (edge.data.hovered) {
|
|
178
|
+
browser.send({ type: 'xyflow.edgeMouseLeave', edge })
|
|
179
|
+
}
|
|
151
180
|
})}
|
|
152
181
|
onSelectionChange={useCallbackRef((params) => {
|
|
153
182
|
browser.send({ type: 'xyflow.selectionChange', ...params })
|
|
@@ -157,14 +186,7 @@ const RelationshipDetailsInner = memo(() => {
|
|
|
157
186
|
pannable
|
|
158
187
|
zoomable
|
|
159
188
|
>
|
|
160
|
-
<TopLeftPanel
|
|
161
|
-
edge={edge}
|
|
162
|
-
view={view}
|
|
163
|
-
hasStepBack={hasStepBack}
|
|
164
|
-
hasStepForward={hasStepForward}
|
|
165
|
-
onStepBack={() => historyOps.back()}
|
|
166
|
-
onStepForward={() => historyOps.forward()}
|
|
167
|
-
/>
|
|
189
|
+
<TopLeftPanel />
|
|
168
190
|
<Panel position="top-right">
|
|
169
191
|
<ActionIcon
|
|
170
192
|
variant="default"
|
|
@@ -184,23 +206,64 @@ const RelationshipDetailsInner = memo(() => {
|
|
|
184
206
|
)
|
|
185
207
|
})
|
|
186
208
|
|
|
209
|
+
// type TopLeftPanelProps = {
|
|
210
|
+
// edge: DiagramEdge
|
|
211
|
+
// view: DiagramView
|
|
212
|
+
// hasStepBack: boolean
|
|
213
|
+
// hasStepForward: boolean
|
|
214
|
+
// onStepBack: () => void
|
|
215
|
+
// onStepForward: () => void
|
|
216
|
+
// }
|
|
217
|
+
const topLeftPanelselector = ({ context }: RelationshipDetailsSnapshot) => ({
|
|
218
|
+
subject: context.subject,
|
|
219
|
+
viewId: context.viewId,
|
|
220
|
+
})
|
|
221
|
+
const TopLeftPanel = memo(() => {
|
|
222
|
+
const { subject, viewId } = useRelationshipDetailsState(topLeftPanelselector, deepEqual)
|
|
223
|
+
const likec4model = useLikeC4Model(true)
|
|
224
|
+
const view = likec4model.findView(viewId)
|
|
225
|
+
|
|
226
|
+
if (!view || !view.isDiagram()) {
|
|
227
|
+
return null
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
let edge = ('edgeId' in subject)
|
|
231
|
+
? view.findEdge(subject.edgeId)
|
|
232
|
+
: ifind(view.edges(), (e) => e.source.element?.id === subject.source && e.target.element?.id === subject.target)
|
|
233
|
+
?? ifind(view.edges(), (e) => {
|
|
234
|
+
return (e.source.element?.id === subject.source || isAncestor(e.source.element?.id ?? '--', subject.source)) &&
|
|
235
|
+
(e.target.element?.id === subject.target || isAncestor(e.target.element?.id ?? '', subject.target))
|
|
236
|
+
})
|
|
237
|
+
if (!edge) {
|
|
238
|
+
return null
|
|
239
|
+
}
|
|
240
|
+
return <TopLeftPanelInner edge={edge.$edge} view={view.$view} />
|
|
241
|
+
})
|
|
242
|
+
|
|
187
243
|
type TopLeftPanelProps = {
|
|
188
244
|
edge: DiagramEdge
|
|
189
245
|
view: DiagramView
|
|
190
|
-
hasStepBack: boolean
|
|
191
|
-
hasStepForward: boolean
|
|
192
|
-
onStepBack: () => void
|
|
193
|
-
onStepForward: () => void
|
|
194
246
|
}
|
|
195
|
-
const
|
|
196
|
-
edge,
|
|
197
|
-
view,
|
|
198
|
-
hasStepBack,
|
|
199
|
-
hasStepForward,
|
|
200
|
-
onStepBack,
|
|
201
|
-
onStepForward,
|
|
202
|
-
}: TopLeftPanelProps) => {
|
|
247
|
+
const TopLeftPanelInner = ({ edge, view }: TopLeftPanelProps) => {
|
|
203
248
|
const browser = useRelationshipDetails()
|
|
249
|
+
const edgeId = edge.id
|
|
250
|
+
const [historyEdgeId, historyOps, { history, current }] = useStateHistory(edge.id)
|
|
251
|
+
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
if (historyEdgeId !== edgeId) {
|
|
254
|
+
historyOps.set(edgeId)
|
|
255
|
+
}
|
|
256
|
+
}, [edgeId])
|
|
257
|
+
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
if (historyEdgeId !== edgeId) {
|
|
260
|
+
browser.navigateTo(historyEdgeId)
|
|
261
|
+
}
|
|
262
|
+
}, [historyEdgeId])
|
|
263
|
+
|
|
264
|
+
const hasStepBack = current > 0
|
|
265
|
+
const hasStepForward = current + 1 < history.length
|
|
266
|
+
|
|
204
267
|
return (
|
|
205
268
|
<Panel position="top-left">
|
|
206
269
|
<Group gap={4} wrap={'nowrap'}>
|
|
@@ -220,7 +283,7 @@ const TopLeftPanel = ({
|
|
|
220
283
|
color="gray"
|
|
221
284
|
onClick={e => {
|
|
222
285
|
e.stopPropagation()
|
|
223
|
-
|
|
286
|
+
historyOps.back()
|
|
224
287
|
}}>
|
|
225
288
|
<IconChevronLeft />
|
|
226
289
|
</ActionIcon>
|
|
@@ -241,7 +304,7 @@ const TopLeftPanel = ({
|
|
|
241
304
|
color="gray"
|
|
242
305
|
onClick={e => {
|
|
243
306
|
e.stopPropagation()
|
|
244
|
-
|
|
307
|
+
historyOps.forward()
|
|
245
308
|
}}>
|
|
246
309
|
<IconChevronRight />
|
|
247
310
|
</ActionIcon>
|
|
@@ -24,7 +24,7 @@ export const SelectEdge = ({
|
|
|
24
24
|
view: DiagramView
|
|
25
25
|
// onSelect: (id: Fqn) => void
|
|
26
26
|
}) => {
|
|
27
|
-
const
|
|
27
|
+
const browser = useRelationshipDetails()
|
|
28
28
|
const viewport = useRef<HTMLDivElement>(null)
|
|
29
29
|
const portalProps = useMantinePortalProps()
|
|
30
30
|
// const data = useLikeC4ElementsTree(scope === 'view' ? viewId : undefined)
|
|
@@ -41,20 +41,27 @@ export const SelectEdge = ({
|
|
|
41
41
|
|
|
42
42
|
const theme = useComputedColorScheme()
|
|
43
43
|
|
|
44
|
-
const edgeSource = view.nodes.find(n => n.id === edge.source)
|
|
45
|
-
const edgeTarget = view.nodes.find(n => n.id === edge.target)
|
|
44
|
+
const edgeSource = view.nodes.find(n => n.id === edge.source)
|
|
45
|
+
const edgeTarget = view.nodes.find(n => n.id === edge.target)
|
|
46
46
|
|
|
47
|
-
const edges = view.edges.
|
|
48
|
-
const source = view.nodes.find(n => n.id === edge.source)
|
|
49
|
-
const target = view.nodes.find(n => n.id === edge.target)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
const edges = view.edges.flatMap(edge => {
|
|
48
|
+
const source = view.nodes.find(n => n.id === edge.source)
|
|
49
|
+
const target = view.nodes.find(n => n.id === edge.target)
|
|
50
|
+
if (source && target) {
|
|
51
|
+
return {
|
|
52
|
+
id: edge.id,
|
|
53
|
+
source,
|
|
54
|
+
target,
|
|
55
|
+
label: edge.label,
|
|
56
|
+
}
|
|
55
57
|
}
|
|
58
|
+
return []
|
|
56
59
|
})
|
|
57
60
|
|
|
61
|
+
if (!edgeSource || !edgeTarget || edges.length === 0) {
|
|
62
|
+
return null
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
return (
|
|
59
66
|
<Popover
|
|
60
67
|
position="bottom-start"
|
|
@@ -113,7 +120,7 @@ export const SelectEdge = ({
|
|
|
113
120
|
data-selected={e.id === edge.id}
|
|
114
121
|
onClick={event => {
|
|
115
122
|
event.stopPropagation()
|
|
116
|
-
|
|
123
|
+
browser.navigateTo(e.id)
|
|
117
124
|
}}>
|
|
118
125
|
<Box
|
|
119
126
|
className={css.edgeSource}
|
|
@@ -2,6 +2,7 @@ import type { Color, DiagramNode, Fqn, IconUrl, RelationId, RelationshipLineType
|
|
|
2
2
|
import type { Base, NonOptional, ReactFlowEdge, ReactFlowNode } from '../../base/types'
|
|
3
3
|
|
|
4
4
|
export namespace RelationshipDetailsTypes {
|
|
5
|
+
export type Column = 'sources' | 'targets'
|
|
5
6
|
/**
|
|
6
7
|
* The node's incoming and outgoing ports
|
|
7
8
|
*/
|
|
@@ -26,6 +27,7 @@ export namespace RelationshipDetailsTypes {
|
|
|
26
27
|
>
|
|
27
28
|
>
|
|
28
29
|
& {
|
|
30
|
+
column: Column
|
|
29
31
|
fqn: Fqn
|
|
30
32
|
icon: IconUrl
|
|
31
33
|
ports: Ports
|
|
@@ -38,11 +40,11 @@ export namespace RelationshipDetailsTypes {
|
|
|
38
40
|
DiagramNode,
|
|
39
41
|
| 'title'
|
|
40
42
|
| 'color'
|
|
41
|
-
| 'shape'
|
|
42
43
|
| 'style'
|
|
43
44
|
>
|
|
44
45
|
>
|
|
45
46
|
& {
|
|
47
|
+
column: Column
|
|
46
48
|
fqn: Fqn
|
|
47
49
|
depth: number
|
|
48
50
|
icon?: IconUrl
|