@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,14 +1,23 @@
|
|
|
1
|
-
import { EdgeId, RelationId, Color,
|
|
2
|
-
import { RelationshipDetailsActorRef, RelationshipDetailsSnapshot,
|
|
1
|
+
import { EdgeId, Fqn, ViewId, RelationId, Color, RelationshipLineType, BBox } from '@likec4/core';
|
|
2
|
+
import { RelationshipDetailsActorRef, RelationshipDetailsSnapshot, Events } from './actor';
|
|
3
3
|
import { Context, ReactNode, CSSProperties } from 'react';
|
|
4
|
-
import { GeneralHelpers, ViewportHelperFunctions } from '@xyflow/react';
|
|
4
|
+
import { GeneralHelpers, ViewportHelperFunctions, ReactFlowState } from '@xyflow/react';
|
|
5
5
|
import { EdgeMarkerType, HandleType } from '@xyflow/system';
|
|
6
6
|
export declare const RelationshipDetailsActorContext: Context<RelationshipDetailsActorRef | null>;
|
|
7
7
|
export declare function useRelationshipDetailsActor(): RelationshipDetailsActorRef;
|
|
8
8
|
export declare function useRelationshipDetailsState<T = unknown>(selector: (state: RelationshipDetailsSnapshot) => T, compare?: (a: NoInfer<T>, b: NoInfer<T>) => boolean): T;
|
|
9
9
|
export declare function useRelationshipDetails(): {
|
|
10
10
|
actor: RelationshipDetailsActorRef;
|
|
11
|
-
|
|
11
|
+
readonly rootElementId: string;
|
|
12
|
+
getState: () => Readonly<{
|
|
13
|
+
subject: {
|
|
14
|
+
edgeId: EdgeId;
|
|
15
|
+
} | {
|
|
16
|
+
source: Fqn;
|
|
17
|
+
target: Fqn;
|
|
18
|
+
edgeId?: never;
|
|
19
|
+
};
|
|
20
|
+
viewId: ViewId;
|
|
12
21
|
xyflow: ( GeneralHelpers<import("./_types").RelationshipDetailsTypes.Node, {
|
|
13
22
|
id: string;
|
|
14
23
|
source: string;
|
|
@@ -51,12 +60,333 @@ export declare function useRelationshipDetails(): {
|
|
|
51
60
|
}> & Omit< ViewportHelperFunctions, "initialized"> & {
|
|
52
61
|
viewportInitialized: boolean;
|
|
53
62
|
}) | null;
|
|
54
|
-
|
|
63
|
+
xystore: {
|
|
64
|
+
getState: () => ReactFlowState<import("./_types").RelationshipDetailsTypes.Node, {
|
|
65
|
+
id: string;
|
|
66
|
+
source: string;
|
|
67
|
+
target: string;
|
|
68
|
+
sourceHandle?: string | null;
|
|
69
|
+
targetHandle?: string | null;
|
|
70
|
+
animated?: boolean;
|
|
71
|
+
hidden?: boolean;
|
|
72
|
+
deletable?: boolean;
|
|
73
|
+
selectable?: boolean;
|
|
74
|
+
selected?: boolean;
|
|
75
|
+
markerStart?: EdgeMarkerType;
|
|
76
|
+
markerEnd?: EdgeMarkerType;
|
|
77
|
+
zIndex?: number;
|
|
78
|
+
ariaLabel?: string;
|
|
79
|
+
interactionWidth?: number;
|
|
80
|
+
label?: ReactNode;
|
|
81
|
+
labelStyle?: CSSProperties;
|
|
82
|
+
labelShowBg?: boolean;
|
|
83
|
+
labelBgStyle?: CSSProperties;
|
|
84
|
+
labelBgPadding?: [number, number];
|
|
85
|
+
labelBgBorderRadius?: number;
|
|
86
|
+
style?: CSSProperties;
|
|
87
|
+
className?: string;
|
|
88
|
+
reconnectable?: boolean | HandleType;
|
|
89
|
+
focusable?: boolean;
|
|
90
|
+
type: "relationship";
|
|
91
|
+
data: {
|
|
92
|
+
relationId: RelationId;
|
|
93
|
+
color: Color | undefined;
|
|
94
|
+
label: string | null;
|
|
95
|
+
technology?: string | undefined | undefined;
|
|
96
|
+
description?: string | undefined | undefined;
|
|
97
|
+
navigateTo: ViewId | null;
|
|
98
|
+
line: RelationshipLineType;
|
|
99
|
+
hovered?: boolean;
|
|
100
|
+
active?: boolean;
|
|
101
|
+
dimmed?: import("../../base").Base.Dimmed;
|
|
102
|
+
};
|
|
103
|
+
}>;
|
|
104
|
+
setState: (partial: ReactFlowState<import("./_types").RelationshipDetailsTypes.Node, {
|
|
105
|
+
id: string;
|
|
106
|
+
source: string;
|
|
107
|
+
target: string;
|
|
108
|
+
sourceHandle?: string | null;
|
|
109
|
+
targetHandle?: string | null;
|
|
110
|
+
animated?: boolean;
|
|
111
|
+
hidden?: boolean;
|
|
112
|
+
deletable?: boolean;
|
|
113
|
+
selectable?: boolean;
|
|
114
|
+
selected?: boolean;
|
|
115
|
+
markerStart?: EdgeMarkerType;
|
|
116
|
+
markerEnd?: EdgeMarkerType;
|
|
117
|
+
zIndex?: number;
|
|
118
|
+
ariaLabel?: string;
|
|
119
|
+
interactionWidth?: number;
|
|
120
|
+
label?: ReactNode;
|
|
121
|
+
labelStyle?: CSSProperties;
|
|
122
|
+
labelShowBg?: boolean;
|
|
123
|
+
labelBgStyle?: CSSProperties;
|
|
124
|
+
labelBgPadding?: [number, number];
|
|
125
|
+
labelBgBorderRadius?: number;
|
|
126
|
+
style?: CSSProperties;
|
|
127
|
+
className?: string;
|
|
128
|
+
reconnectable?: boolean | HandleType;
|
|
129
|
+
focusable?: boolean;
|
|
130
|
+
type: "relationship";
|
|
131
|
+
data: {
|
|
132
|
+
relationId: RelationId;
|
|
133
|
+
color: Color | undefined;
|
|
134
|
+
label: string | null;
|
|
135
|
+
technology?: string | undefined | undefined;
|
|
136
|
+
description?: string | undefined | undefined;
|
|
137
|
+
navigateTo: ViewId | null;
|
|
138
|
+
line: RelationshipLineType;
|
|
139
|
+
hovered?: boolean;
|
|
140
|
+
active?: boolean;
|
|
141
|
+
dimmed?: import("../../base").Base.Dimmed;
|
|
142
|
+
};
|
|
143
|
+
}> | Partial< ReactFlowState<import("./_types").RelationshipDetailsTypes.Node, {
|
|
144
|
+
id: string;
|
|
145
|
+
source: string;
|
|
146
|
+
target: string;
|
|
147
|
+
sourceHandle?: string | null;
|
|
148
|
+
targetHandle?: string | null;
|
|
149
|
+
animated?: boolean;
|
|
150
|
+
hidden?: boolean;
|
|
151
|
+
deletable?: boolean;
|
|
152
|
+
selectable?: boolean;
|
|
153
|
+
selected?: boolean;
|
|
154
|
+
markerStart?: EdgeMarkerType;
|
|
155
|
+
markerEnd?: EdgeMarkerType;
|
|
156
|
+
zIndex?: number;
|
|
157
|
+
ariaLabel?: string;
|
|
158
|
+
interactionWidth?: number;
|
|
159
|
+
label?: ReactNode;
|
|
160
|
+
labelStyle?: CSSProperties;
|
|
161
|
+
labelShowBg?: boolean;
|
|
162
|
+
labelBgStyle?: CSSProperties;
|
|
163
|
+
labelBgPadding?: [number, number];
|
|
164
|
+
labelBgBorderRadius?: number;
|
|
165
|
+
style?: CSSProperties;
|
|
166
|
+
className?: string;
|
|
167
|
+
reconnectable?: boolean | HandleType;
|
|
168
|
+
focusable?: boolean;
|
|
169
|
+
type: "relationship";
|
|
170
|
+
data: {
|
|
171
|
+
relationId: RelationId;
|
|
172
|
+
color: Color | undefined;
|
|
173
|
+
label: string | null;
|
|
174
|
+
technology?: string | undefined | undefined;
|
|
175
|
+
description?: string | undefined | undefined;
|
|
176
|
+
navigateTo: ViewId | null;
|
|
177
|
+
line: RelationshipLineType;
|
|
178
|
+
hovered?: boolean;
|
|
179
|
+
active?: boolean;
|
|
180
|
+
dimmed?: import("../../base").Base.Dimmed;
|
|
181
|
+
};
|
|
182
|
+
}>> | ((state: ReactFlowState<import("./_types").RelationshipDetailsTypes.Node, {
|
|
183
|
+
id: string;
|
|
184
|
+
source: string;
|
|
185
|
+
target: string;
|
|
186
|
+
sourceHandle?: string | null;
|
|
187
|
+
targetHandle?: string | null;
|
|
188
|
+
animated?: boolean;
|
|
189
|
+
hidden?: boolean;
|
|
190
|
+
deletable?: boolean;
|
|
191
|
+
selectable?: boolean;
|
|
192
|
+
selected?: boolean;
|
|
193
|
+
markerStart?: EdgeMarkerType;
|
|
194
|
+
markerEnd?: EdgeMarkerType;
|
|
195
|
+
zIndex?: number;
|
|
196
|
+
ariaLabel?: string;
|
|
197
|
+
interactionWidth?: number;
|
|
198
|
+
label?: ReactNode;
|
|
199
|
+
labelStyle?: CSSProperties;
|
|
200
|
+
labelShowBg?: boolean;
|
|
201
|
+
labelBgStyle?: CSSProperties;
|
|
202
|
+
labelBgPadding?: [number, number];
|
|
203
|
+
labelBgBorderRadius?: number;
|
|
204
|
+
style?: CSSProperties;
|
|
205
|
+
className?: string;
|
|
206
|
+
reconnectable?: boolean | HandleType;
|
|
207
|
+
focusable?: boolean;
|
|
208
|
+
type: "relationship";
|
|
209
|
+
data: {
|
|
210
|
+
relationId: RelationId;
|
|
211
|
+
color: Color | undefined;
|
|
212
|
+
label: string | null;
|
|
213
|
+
technology?: string | undefined | undefined;
|
|
214
|
+
description?: string | undefined | undefined;
|
|
215
|
+
navigateTo: ViewId | null;
|
|
216
|
+
line: RelationshipLineType;
|
|
217
|
+
hovered?: boolean;
|
|
218
|
+
active?: boolean;
|
|
219
|
+
dimmed?: import("../../base").Base.Dimmed;
|
|
220
|
+
};
|
|
221
|
+
}>) => ReactFlowState<import("./_types").RelationshipDetailsTypes.Node, {
|
|
222
|
+
id: string;
|
|
223
|
+
source: string;
|
|
224
|
+
target: string;
|
|
225
|
+
sourceHandle?: string | null;
|
|
226
|
+
targetHandle?: string | null;
|
|
227
|
+
animated?: boolean;
|
|
228
|
+
hidden?: boolean;
|
|
229
|
+
deletable?: boolean;
|
|
230
|
+
selectable?: boolean;
|
|
231
|
+
selected?: boolean;
|
|
232
|
+
markerStart?: EdgeMarkerType;
|
|
233
|
+
markerEnd?: EdgeMarkerType;
|
|
234
|
+
zIndex?: number;
|
|
235
|
+
ariaLabel?: string;
|
|
236
|
+
interactionWidth?: number;
|
|
237
|
+
label?: ReactNode;
|
|
238
|
+
labelStyle?: CSSProperties;
|
|
239
|
+
labelShowBg?: boolean;
|
|
240
|
+
labelBgStyle?: CSSProperties;
|
|
241
|
+
labelBgPadding?: [number, number];
|
|
242
|
+
labelBgBorderRadius?: number;
|
|
243
|
+
style?: CSSProperties;
|
|
244
|
+
className?: string;
|
|
245
|
+
reconnectable?: boolean | HandleType;
|
|
246
|
+
focusable?: boolean;
|
|
247
|
+
type: "relationship";
|
|
248
|
+
data: {
|
|
249
|
+
relationId: RelationId;
|
|
250
|
+
color: Color | undefined;
|
|
251
|
+
label: string | null;
|
|
252
|
+
technology?: string | undefined | undefined;
|
|
253
|
+
description?: string | undefined | undefined;
|
|
254
|
+
navigateTo: ViewId | null;
|
|
255
|
+
line: RelationshipLineType;
|
|
256
|
+
hovered?: boolean;
|
|
257
|
+
active?: boolean;
|
|
258
|
+
dimmed?: import("../../base").Base.Dimmed;
|
|
259
|
+
};
|
|
260
|
+
}> | Partial< ReactFlowState<import("./_types").RelationshipDetailsTypes.Node, {
|
|
261
|
+
id: string;
|
|
262
|
+
source: string;
|
|
263
|
+
target: string;
|
|
264
|
+
sourceHandle?: string | null;
|
|
265
|
+
targetHandle?: string | null;
|
|
266
|
+
animated?: boolean;
|
|
267
|
+
hidden?: boolean;
|
|
268
|
+
deletable?: boolean;
|
|
269
|
+
selectable?: boolean;
|
|
270
|
+
selected?: boolean;
|
|
271
|
+
markerStart?: EdgeMarkerType;
|
|
272
|
+
markerEnd?: EdgeMarkerType;
|
|
273
|
+
zIndex?: number;
|
|
274
|
+
ariaLabel?: string;
|
|
275
|
+
interactionWidth?: number;
|
|
276
|
+
label?: ReactNode;
|
|
277
|
+
labelStyle?: CSSProperties;
|
|
278
|
+
labelShowBg?: boolean;
|
|
279
|
+
labelBgStyle?: CSSProperties;
|
|
280
|
+
labelBgPadding?: [number, number];
|
|
281
|
+
labelBgBorderRadius?: number;
|
|
282
|
+
style?: CSSProperties;
|
|
283
|
+
className?: string;
|
|
284
|
+
reconnectable?: boolean | HandleType;
|
|
285
|
+
focusable?: boolean;
|
|
286
|
+
type: "relationship";
|
|
287
|
+
data: {
|
|
288
|
+
relationId: RelationId;
|
|
289
|
+
color: Color | undefined;
|
|
290
|
+
label: string | null;
|
|
291
|
+
technology?: string | undefined | undefined;
|
|
292
|
+
description?: string | undefined | undefined;
|
|
293
|
+
navigateTo: ViewId | null;
|
|
294
|
+
line: RelationshipLineType;
|
|
295
|
+
hovered?: boolean;
|
|
296
|
+
active?: boolean;
|
|
297
|
+
dimmed?: import("../../base").Base.Dimmed;
|
|
298
|
+
};
|
|
299
|
+
}>>), replace?: boolean | undefined) => void;
|
|
300
|
+
subscribe: (listener: (state: ReactFlowState<import("./_types").RelationshipDetailsTypes.Node, {
|
|
301
|
+
id: string;
|
|
302
|
+
source: string;
|
|
303
|
+
target: string;
|
|
304
|
+
sourceHandle?: string | null;
|
|
305
|
+
targetHandle?: string | null;
|
|
306
|
+
animated?: boolean;
|
|
307
|
+
hidden?: boolean;
|
|
308
|
+
deletable?: boolean;
|
|
309
|
+
selectable?: boolean;
|
|
310
|
+
selected?: boolean;
|
|
311
|
+
markerStart?: EdgeMarkerType;
|
|
312
|
+
markerEnd?: EdgeMarkerType;
|
|
313
|
+
zIndex?: number;
|
|
314
|
+
ariaLabel?: string;
|
|
315
|
+
interactionWidth?: number;
|
|
316
|
+
label?: ReactNode;
|
|
317
|
+
labelStyle?: CSSProperties;
|
|
318
|
+
labelShowBg?: boolean;
|
|
319
|
+
labelBgStyle?: CSSProperties;
|
|
320
|
+
labelBgPadding?: [number, number];
|
|
321
|
+
labelBgBorderRadius?: number;
|
|
322
|
+
style?: CSSProperties;
|
|
323
|
+
className?: string;
|
|
324
|
+
reconnectable?: boolean | HandleType;
|
|
325
|
+
focusable?: boolean;
|
|
326
|
+
type: "relationship";
|
|
327
|
+
data: {
|
|
328
|
+
relationId: RelationId;
|
|
329
|
+
color: Color | undefined;
|
|
330
|
+
label: string | null;
|
|
331
|
+
technology?: string | undefined | undefined;
|
|
332
|
+
description?: string | undefined | undefined;
|
|
333
|
+
navigateTo: ViewId | null;
|
|
334
|
+
line: RelationshipLineType;
|
|
335
|
+
hovered?: boolean;
|
|
336
|
+
active?: boolean;
|
|
337
|
+
dimmed?: import("../../base").Base.Dimmed;
|
|
338
|
+
};
|
|
339
|
+
}>, prevState: ReactFlowState<import("./_types").RelationshipDetailsTypes.Node, {
|
|
340
|
+
id: string;
|
|
341
|
+
source: string;
|
|
342
|
+
target: string;
|
|
343
|
+
sourceHandle?: string | null;
|
|
344
|
+
targetHandle?: string | null;
|
|
345
|
+
animated?: boolean;
|
|
346
|
+
hidden?: boolean;
|
|
347
|
+
deletable?: boolean;
|
|
348
|
+
selectable?: boolean;
|
|
349
|
+
selected?: boolean;
|
|
350
|
+
markerStart?: EdgeMarkerType;
|
|
351
|
+
markerEnd?: EdgeMarkerType;
|
|
352
|
+
zIndex?: number;
|
|
353
|
+
ariaLabel?: string;
|
|
354
|
+
interactionWidth?: number;
|
|
355
|
+
label?: ReactNode;
|
|
356
|
+
labelStyle?: CSSProperties;
|
|
357
|
+
labelShowBg?: boolean;
|
|
358
|
+
labelBgStyle?: CSSProperties;
|
|
359
|
+
labelBgPadding?: [number, number];
|
|
360
|
+
labelBgBorderRadius?: number;
|
|
361
|
+
style?: CSSProperties;
|
|
362
|
+
className?: string;
|
|
363
|
+
reconnectable?: boolean | HandleType;
|
|
364
|
+
focusable?: boolean;
|
|
365
|
+
type: "relationship";
|
|
366
|
+
data: {
|
|
367
|
+
relationId: RelationId;
|
|
368
|
+
color: Color | undefined;
|
|
369
|
+
label: string | null;
|
|
370
|
+
technology?: string | undefined | undefined;
|
|
371
|
+
description?: string | undefined | undefined;
|
|
372
|
+
navigateTo: ViewId | null;
|
|
373
|
+
line: RelationshipLineType;
|
|
374
|
+
hovered?: boolean;
|
|
375
|
+
active?: boolean;
|
|
376
|
+
dimmed?: import("../../base").Base.Dimmed;
|
|
377
|
+
};
|
|
378
|
+
}>) => void) => () => void;
|
|
379
|
+
} | null;
|
|
380
|
+
initialized: {
|
|
381
|
+
xydata: boolean;
|
|
382
|
+
xyflow: boolean;
|
|
383
|
+
};
|
|
55
384
|
xynodes: import("./_types").RelationshipDetailsTypes.Node[];
|
|
56
385
|
xyedges: import("./_types").RelationshipDetailsTypes.Edge[];
|
|
386
|
+
bounds: BBox;
|
|
57
387
|
}>;
|
|
58
388
|
send: (event: Events) => void;
|
|
59
|
-
navigateTo: (edgeId: EdgeId) => void;
|
|
389
|
+
navigateTo: (...params: [edgeId: EdgeId] | [source: Fqn, target: Fqn]) => void;
|
|
60
390
|
fitDiagram: () => void;
|
|
61
391
|
close: () => void;
|
|
62
392
|
};
|
|
@@ -18,15 +18,17 @@ function useRelationshipDetails() {
|
|
|
18
18
|
const [, startTransition] = useTransition();
|
|
19
19
|
return useMemo(() => ({
|
|
20
20
|
actor,
|
|
21
|
+
get rootElementId() {
|
|
22
|
+
return `relationship-details-${actor.sessionId.replaceAll(":", "_")}`;
|
|
23
|
+
},
|
|
21
24
|
getState: () => actor.getSnapshot().context,
|
|
22
25
|
send: actor.send,
|
|
23
|
-
navigateTo: (
|
|
24
|
-
|
|
25
|
-
actor.send({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
26
|
+
navigateTo: (...params) => {
|
|
27
|
+
if (params.length === 1) {
|
|
28
|
+
actor.send({ type: "navigate.to", params: { edgeId: params[0] } });
|
|
29
|
+
} else {
|
|
30
|
+
actor.send({ type: "navigate.to", params: { source: params[0], target: params[1] } });
|
|
31
|
+
}
|
|
30
32
|
},
|
|
31
33
|
fitDiagram: () => {
|
|
32
34
|
startTransition(() => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RelationshipDetailsTypes } from './_types';
|
|
2
|
+
import { LayoutResult } from './layout';
|
|
3
|
+
export declare function layoutResultToXYFlow(layout: LayoutResult): {
|
|
4
|
+
xynodes: RelationshipDetailsTypes.Node[];
|
|
5
|
+
xyedges: RelationshipDetailsTypes.Edge[];
|
|
6
|
+
bounds: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import '@dagrejs/dagre';
|
|
2
|
+
import { Queue, nonNullable } from '@likec4/core';
|
|
3
|
+
import '@xstate/react';
|
|
4
|
+
import 'fast-equals';
|
|
5
|
+
import 'react';
|
|
6
|
+
import { hasAtLeast } from 'remeda';
|
|
7
|
+
import { ZIndexes } from '../../base/const.js';
|
|
8
|
+
|
|
9
|
+
function layoutResultToXYFlow(layout) {
|
|
10
|
+
const xynodes = [], xyedges = [], nodeLookup = /* @__PURE__ */ new Map();
|
|
11
|
+
const queue = Queue.from(layout.nodes.reduce(
|
|
12
|
+
(acc, node) => {
|
|
13
|
+
nodeLookup.set(node.id, node);
|
|
14
|
+
if (!node.parent) {
|
|
15
|
+
acc.push({ node, parent: null });
|
|
16
|
+
}
|
|
17
|
+
return acc;
|
|
18
|
+
},
|
|
19
|
+
[]
|
|
20
|
+
));
|
|
21
|
+
const ns = "";
|
|
22
|
+
const nodeById = (id) => nonNullable(nodeLookup.get(id), `Node not found: ${id}`);
|
|
23
|
+
let next;
|
|
24
|
+
while (next = queue.dequeue()) {
|
|
25
|
+
const { node, parent } = next;
|
|
26
|
+
const isCompound = hasAtLeast(node.children, 1);
|
|
27
|
+
if (isCompound) {
|
|
28
|
+
for (const child of node.children) {
|
|
29
|
+
queue.enqueue({ node: nodeById(child), parent: node });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const position = {
|
|
33
|
+
x: node.position[0],
|
|
34
|
+
y: node.position[1]
|
|
35
|
+
};
|
|
36
|
+
if (parent) {
|
|
37
|
+
position.x -= parent.position[0];
|
|
38
|
+
position.y -= parent.position[1];
|
|
39
|
+
}
|
|
40
|
+
const id = ns + node.id;
|
|
41
|
+
const base = {
|
|
42
|
+
id,
|
|
43
|
+
draggable: false,
|
|
44
|
+
selectable: true,
|
|
45
|
+
focusable: true,
|
|
46
|
+
deletable: false,
|
|
47
|
+
position,
|
|
48
|
+
zIndex: isCompound ? ZIndexes.Compound : ZIndexes.Element,
|
|
49
|
+
style: {
|
|
50
|
+
width: node.width,
|
|
51
|
+
height: node.height
|
|
52
|
+
},
|
|
53
|
+
initialWidth: node.width,
|
|
54
|
+
initialHeight: node.height,
|
|
55
|
+
...parent && {
|
|
56
|
+
parentId: ns + parent.id
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const fqn = node.modelRef;
|
|
60
|
+
const navigateTo = { navigateTo: node.navigateTo ?? null };
|
|
61
|
+
switch (true) {
|
|
62
|
+
case isCompound: {
|
|
63
|
+
xynodes.push(
|
|
64
|
+
{
|
|
65
|
+
...base,
|
|
66
|
+
type: "compound",
|
|
67
|
+
data: {
|
|
68
|
+
column: node.column,
|
|
69
|
+
title: node.title,
|
|
70
|
+
color: node.color,
|
|
71
|
+
style: node.style,
|
|
72
|
+
depth: node.depth ?? 0,
|
|
73
|
+
icon: node.icon ?? "none",
|
|
74
|
+
ports: node.ports,
|
|
75
|
+
fqn,
|
|
76
|
+
...navigateTo
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
default: {
|
|
83
|
+
xynodes.push(
|
|
84
|
+
{
|
|
85
|
+
...base,
|
|
86
|
+
type: "element",
|
|
87
|
+
data: {
|
|
88
|
+
column: node.column,
|
|
89
|
+
fqn,
|
|
90
|
+
title: node.title,
|
|
91
|
+
technology: node.technology,
|
|
92
|
+
description: node.description,
|
|
93
|
+
height: node.height,
|
|
94
|
+
width: node.width,
|
|
95
|
+
color: node.color,
|
|
96
|
+
shape: node.shape,
|
|
97
|
+
icon: node.icon ?? "none",
|
|
98
|
+
ports: node.ports,
|
|
99
|
+
style: node.style,
|
|
100
|
+
...navigateTo
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
for (const {
|
|
108
|
+
source,
|
|
109
|
+
target,
|
|
110
|
+
relationId,
|
|
111
|
+
label,
|
|
112
|
+
technology,
|
|
113
|
+
description,
|
|
114
|
+
navigateTo = null,
|
|
115
|
+
color = "gray",
|
|
116
|
+
line = "dashed",
|
|
117
|
+
...edge
|
|
118
|
+
} of layout.edges) {
|
|
119
|
+
const id = ns + edge.id;
|
|
120
|
+
xyedges.push({
|
|
121
|
+
id,
|
|
122
|
+
type: "relationship",
|
|
123
|
+
source: ns + source,
|
|
124
|
+
target: ns + target,
|
|
125
|
+
sourceHandle: edge.sourceHandle,
|
|
126
|
+
targetHandle: edge.targetHandle,
|
|
127
|
+
zIndex: ZIndexes.Edge,
|
|
128
|
+
// selectable: selectable,
|
|
129
|
+
// hidden: !visiblePredicate(edge),
|
|
130
|
+
deletable: false,
|
|
131
|
+
data: {
|
|
132
|
+
relationId,
|
|
133
|
+
label,
|
|
134
|
+
color,
|
|
135
|
+
navigateTo,
|
|
136
|
+
line,
|
|
137
|
+
...technology && { technology },
|
|
138
|
+
...description && { description }
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
xynodes,
|
|
144
|
+
xyedges,
|
|
145
|
+
bounds: layout.bounds
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export { layoutResultToXYFlow };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DiagramEdge, DiagramNode, DiagramView, Fqn, RelationId } from '@likec4/core/types';
|
|
2
|
+
import { AnyAux, LikeC4ViewModel } from '@likec4/core/model';
|
|
3
|
+
import { RelationshipDetailsTypes } from './_types';
|
|
4
|
+
import { RelationshipDetailsViewData } from './compute';
|
|
5
|
+
export type LayoutResult = {
|
|
6
|
+
nodes: LayoutResult.Node[];
|
|
7
|
+
edges: LayoutResult.Edge[];
|
|
8
|
+
bounds: DiagramView['bounds'];
|
|
9
|
+
};
|
|
10
|
+
export declare namespace LayoutResult {
|
|
11
|
+
type Node = Omit<DiagramNode, 'modelRef' | 'deploymentRef' | 'inEdges' | 'outEdges'> & {
|
|
12
|
+
modelRef: Fqn;
|
|
13
|
+
column: RelationshipDetailsTypes.Column;
|
|
14
|
+
ports: RelationshipDetailsTypes.Ports;
|
|
15
|
+
};
|
|
16
|
+
type Edge = Omit<DiagramEdge, 'relations'> & {
|
|
17
|
+
relationId: RelationId;
|
|
18
|
+
sourceHandle: string;
|
|
19
|
+
targetHandle: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare function layoutRelationshipDetails(data: RelationshipDetailsViewData, scope: LikeC4ViewModel<AnyAux> | null): LayoutResult;
|