@likec4/diagram 1.18.0 → 1.19.1
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/LICENSE +1 -1
- package/dist/LikeC4CustomColors.d.ts +7 -0
- package/dist/LikeC4CustomColors.js +30 -0
- package/dist/LikeC4Diagram.css.d.ts +5 -0
- package/dist/LikeC4Diagram.css.js +13 -0
- package/dist/LikeC4Diagram.d.ts +6 -0
- package/dist/LikeC4Diagram.js +194 -0
- package/dist/LikeC4Diagram.props.d.ts +166 -0
- package/dist/LikeC4ModelProvider.d.ts +9 -0
- package/dist/LikeC4ModelProvider.js +12 -0
- package/dist/LikeC4Search.css.d.ts +1 -0
- package/dist/LikeC4Search.css.js +5 -0
- package/dist/LikeC4Search.d.ts +2 -0
- package/dist/LikeC4Search.js +96 -0
- package/dist/StaticLikeC4Diagram.d.ts +3 -0
- package/dist/StaticLikeC4Diagram.js +41 -0
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/controls/Text.d.ts +2 -0
- package/dist/controls/Text.js +7 -0
- package/dist/controls/action-button-bar/ActionButtonBar.css.d.ts +1 -0
- package/dist/controls/action-button-bar/ActionButtonBar.css.js +5 -0
- package/dist/controls/action-button-bar/ActionButtonBar.d.ts +9 -0
- package/dist/controls/action-button-bar/ActionButtonBar.js +100 -0
- package/dist/controls/action-button-bar/useActionButtonBarCtx.d.ts +10 -0
- package/dist/controls/action-button-bar/useActionButtonBarCtx.js +9 -0
- package/dist/controls/action-buttons/ActionButton.css.d.ts +1 -0
- package/dist/controls/action-buttons/ActionButton.css.js +5 -0
- package/dist/controls/action-buttons/ActionButton.d.ts +9 -0
- package/dist/controls/action-buttons/ActionButton.js +66 -0
- package/dist/controls/action-buttons/ActionButtons.d.ts +12 -0
- package/dist/controls/action-buttons/ActionButtons.js +99 -0
- package/dist/globals.css.d.ts +1 -0
- package/dist/globals.css.js +92 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useDiagramState.d.ts +6 -0
- package/dist/hooks/useDiagramState.js +27 -0
- package/dist/hooks/useMantinePortalProps.d.ts +9 -0
- package/dist/hooks/useMantinePortalProps.js +9 -0
- package/dist/hooks/useSetState.d.ts +2 -0
- package/dist/hooks/useSetState.js +19 -0
- package/dist/hooks/useUpdateEffect.d.ts +4 -0
- package/dist/hooks/useUpdateEffect.js +32 -0
- package/dist/hooks/useXYFlow.d.ts +270 -0
- package/dist/hooks/useXYFlow.js +20 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +25 -0
- package/dist/likec4model/LikeC4ModelContext.d.ts +3 -0
- package/dist/likec4model/LikeC4ModelContext.js +5 -0
- package/dist/likec4model/index.d.ts +2 -0
- package/dist/likec4model/useLikeC4ElementsTree.d.ts +12 -0
- package/dist/likec4model/useLikeC4ElementsTree.js +25 -0
- package/dist/likec4model/useLikeC4Model.d.ts +20 -0
- package/dist/likec4model/useLikeC4Model.js +55 -0
- package/dist/overlays/OverlayContext.d.ts +10 -0
- package/dist/overlays/OverlayContext.js +9 -0
- package/dist/overlays/Overlays.css.d.ts +3 -0
- package/dist/overlays/Overlays.css.js +7 -0
- package/dist/overlays/Overlays.d.ts +2 -0
- package/dist/overlays/Overlays.js +137 -0
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.d.ts +5 -0
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.js +185 -0
- package/dist/overlays/edge-details/SelectEdge.css.d.ts +7 -0
- package/dist/overlays/edge-details/SelectEdge.css.js +17 -0
- package/dist/overlays/edge-details/SelectEdge.d.ts +5 -0
- package/dist/overlays/edge-details/SelectEdge.js +129 -0
- package/dist/overlays/edge-details/_types.d.ts +14 -0
- package/dist/overlays/edge-details/use-layouted-edge-details.d.ts +21 -0
- package/dist/overlays/edge-details/use-layouted-edge-details.js +270 -0
- package/dist/overlays/edge-details/xyflow/CompoundNode.d.ts +5 -0
- package/dist/overlays/edge-details/xyflow/CompoundNode.js +76 -0
- package/dist/overlays/edge-details/xyflow/ElementNode.d.ts +5 -0
- package/dist/overlays/edge-details/xyflow/ElementNode.js +159 -0
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.d.ts +3 -0
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.js +84 -0
- package/dist/overlays/edge-details/xyflow/styles.css.d.ts +9 -0
- package/dist/overlays/edge-details/xyflow/styles.css.js +21 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.d.ts +16 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.js +33 -0
- package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -0
- package/dist/overlays/element-details/ElementDetailsCard.js +484 -0
- package/dist/overlays/element-details/TabPanelDeployments.css.d.ts +4 -0
- package/dist/overlays/element-details/TabPanelDeployments.css.js +11 -0
- package/dist/overlays/element-details/TabPanelDeployments.d.ts +7 -0
- package/dist/overlays/element-details/TabPanelDeployments.js +173 -0
- package/dist/overlays/element-details/TabPanelRelationships.css.d.ts +5 -0
- package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -0
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +8 -0
- package/dist/overlays/element-details/TabPanelRelationships.js +157 -0
- package/dist/overlays/element-details/TabPanelStructure.css.d.ts +2 -0
- package/dist/overlays/element-details/TabPanelStructure.css.js +7 -0
- package/dist/overlays/element-details/TabPanelStructure.d.ts +25 -0
- package/dist/overlays/element-details/TabPanelStructure.js +91 -0
- package/dist/overlays/index.d.ts +1 -0
- package/dist/overlays/relationships-of/RelationshipsOverlay.d.ts +5 -0
- package/dist/overlays/relationships-of/RelationshipsOverlay.js +193 -0
- package/dist/overlays/relationships-of/RelationshipsXYFlow.d.ts +19 -0
- package/dist/overlays/relationships-of/RelationshipsXYFlow.js +290 -0
- package/dist/overlays/relationships-of/SelectElement.css.d.ts +2 -0
- package/dist/overlays/relationships-of/SelectElement.css.js +7 -0
- package/dist/overlays/relationships-of/SelectElement.d.ts +7 -0
- package/dist/overlays/relationships-of/SelectElement.js +126 -0
- package/dist/overlays/relationships-of/_types.d.ts +28 -0
- package/dist/overlays/relationships-of/use-layouted-relationships.d.ts +22 -0
- package/dist/overlays/relationships-of/use-layouted-relationships.js +496 -0
- package/dist/overlays/relationships-of/xyflow/CompoundNode.d.ts +6 -0
- package/dist/overlays/relationships-of/xyflow/CompoundNode.js +120 -0
- package/dist/overlays/relationships-of/xyflow/ElementNode.d.ts +6 -0
- package/dist/overlays/relationships-of/xyflow/ElementNode.js +194 -0
- package/dist/overlays/relationships-of/xyflow/EmptyNode.d.ts +5 -0
- package/dist/overlays/relationships-of/xyflow/EmptyNode.js +18 -0
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.d.ts +3 -0
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.js +123 -0
- package/dist/overlays/relationships-of/xyflow/styles.css.d.ts +14 -0
- package/dist/overlays/relationships-of/xyflow/styles.css.js +24 -0
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.d.ts +4 -0
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.js +12 -0
- package/dist/overlays/shared/xyflow/_types.d.ts +77 -0
- package/dist/state/DiagramContext.d.ts +1609 -0
- package/dist/state/DiagramContext.js +101 -0
- package/dist/state/aligners.d.ts +42 -0
- package/dist/state/aligners.js +349 -0
- package/dist/state/diagram-to-xyflow.d.ts +11 -0
- package/dist/state/diagram-to-xyflow.js +113 -0
- package/dist/state/diagramStore.d.ts +1705 -0
- package/dist/state/diagramStore.js +808 -0
- package/dist/state/diagramStore.layout.d.ts +4 -0
- package/dist/state/diagramStore.layout.js +56 -0
- package/dist/style.css +1 -0
- package/dist/theme-vars.css.d.ts +72 -0
- package/dist/theme-vars.css.js +6 -0
- package/dist/theme-vars.css.ts.vanilla.css.js +1 -0
- package/dist/theme-vars.d.ts +3 -0
- package/dist/theme-vars.js +5 -0
- package/dist/ui/DiagramTitlePanel.css.d.ts +4 -0
- package/dist/ui/DiagramTitlePanel.css.js +11 -0
- package/dist/ui/DiagramTitlePanel.d.ts +1 -0
- package/dist/ui/DiagramTitlePanel.js +159 -0
- package/dist/ui/DynamicViewWalkthrough.css.d.ts +4 -0
- package/dist/ui/DynamicViewWalkthrough.css.js +11 -0
- package/dist/ui/DynamicViewWalkthrough.d.ts +1 -0
- package/dist/ui/DynamicViewWalkthrough.js +156 -0
- package/dist/ui/EnsureMantine.d.ts +7 -0
- package/dist/ui/EnsureMantine.js +14 -0
- package/dist/ui/FramerMotionConfig.d.ts +2 -0
- package/dist/ui/FramerMotionConfig.js +14 -0
- package/dist/ui/Link.d.ts +4 -0
- package/dist/ui/Link.js +36 -0
- package/dist/ui/notation/NotationPanel.css.d.ts +6 -0
- package/dist/ui/notation/NotationPanel.css.js +16 -0
- package/dist/ui/notation/NotationPanel.d.ts +1 -0
- package/dist/ui/notation/NotationPanel.js +250 -0
- package/dist/ui/notation/index.d.ts +1 -0
- package/dist/ui/top-left/ChangeAutoLayoutButton.d.ts +2 -0
- package/dist/ui/top-left/ChangeAutoLayoutButton.js +159 -0
- package/dist/ui/top-left/ManualLayoutToolsButton.d.ts +2 -0
- package/dist/ui/top-left/ManualLayoutToolsButton.js +137 -0
- package/dist/ui/top-left/TopLeftPanel.d.ts +4 -0
- package/dist/ui/top-left/TopLeftPanel.js +211 -0
- package/dist/ui/top-left/_shared.d.ts +7 -0
- package/dist/ui/top-left/_shared.js +22 -0
- package/dist/ui/top-left/styles.css.d.ts +8 -0
- package/dist/ui/top-left/styles.css.js +17 -0
- package/dist/utils/types.d.ts +8 -0
- package/dist/utils/vector.d.ts +24 -0
- package/dist/utils/vector.js +55 -0
- package/dist/xyflow/EdgeMarkers.d.ts +12 -0
- package/dist/xyflow/EdgeMarkers.js +192 -0
- package/dist/xyflow/FitviewOnDiagramChange.d.ts +4 -0
- package/dist/xyflow/FitviewOnDiagramChange.js +72 -0
- package/dist/xyflow/SelectEdgesOnNodeFocus.d.ts +1 -0
- package/dist/xyflow/SelectEdgesOnNodeFocus.js +96 -0
- package/dist/xyflow/XYFlow.d.ts +8 -0
- package/dist/xyflow/XYFlow.js +145 -0
- package/dist/xyflow/XYFlowBackground.d.ts +10 -0
- package/dist/xyflow/XYFlowBackground.js +25 -0
- package/dist/xyflow/XYFlowInner.d.ts +8 -0
- package/dist/xyflow/XYFlowInner.js +41 -0
- package/dist/xyflow/const.d.ts +7 -0
- package/dist/xyflow/const.js +12 -0
- package/dist/xyflow/edges/EdgeLabel.d.ts +7 -0
- package/dist/xyflow/edges/EdgeLabel.js +160 -0
- package/dist/xyflow/edges/RelationshipEdge.d.ts +6 -0
- package/dist/xyflow/edges/RelationshipEdge.js +443 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.css.d.ts +4 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.css.js +11 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.d.ts +13 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.js +211 -0
- package/dist/xyflow/edges/edges.css.d.ts +17 -0
- package/dist/xyflow/edges/edges.css.js +37 -0
- package/dist/xyflow/edges/utils.d.ts +16 -0
- package/dist/xyflow/edges/utils.js +24 -0
- package/dist/xyflow/nodes/AnimateVariants.d.ts +1313 -0
- package/dist/xyflow/nodes/AnimateVariants.js +123 -0
- package/dist/xyflow/nodes/Node.css.d.ts +3 -0
- package/dist/xyflow/nodes/Node.css.js +9 -0
- package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +14 -0
- package/dist/xyflow/nodes/compound/CompoundNode.css.js +27 -0
- package/dist/xyflow/nodes/compound/CompoundNode.d.ts +6 -0
- package/dist/xyflow/nodes/compound/CompoundNode.js +216 -0
- package/dist/xyflow/nodes/compound/index.d.ts +1 -0
- package/dist/xyflow/nodes/element/ElementLink.css.d.ts +3 -0
- package/dist/xyflow/nodes/element/ElementLink.d.ts +6 -0
- package/dist/xyflow/nodes/element/ElementNode.d.ts +6 -0
- package/dist/xyflow/nodes/element/ElementNode.js +190 -0
- package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +17 -0
- package/dist/xyflow/nodes/element/ElementShapeSvg.js +175 -0
- package/dist/xyflow/nodes/element/element.css.d.ts +18 -0
- package/dist/xyflow/nodes/element/element.css.js +31 -0
- package/dist/xyflow/nodes/element/index.d.ts +1 -0
- package/dist/xyflow/nodes/shared/ElementIcon.d.ts +8 -0
- package/dist/xyflow/nodes/shared/ElementIcon.js +38 -0
- package/dist/xyflow/nodes/shared/Toolbar.d.ts +9 -0
- package/dist/xyflow/nodes/shared/Toolbar.js +436 -0
- package/dist/xyflow/types.d.ts +36 -0
- package/dist/xyflow/useLayoutConstraints.d.ts +42 -0
- package/dist/xyflow/useLayoutConstraints.js +226 -0
- package/dist/xyflow/useXYFlowEvents.d.ts +160 -0
- package/dist/xyflow/useXYFlowEvents.js +275 -0
- package/dist/xyflow/utils.d.ts +22 -0
- package/dist/xyflow/utils.js +72 -0
- package/package.json +34 -27
- package/src/LikeC4Diagram.tsx +4 -4
- package/src/LikeC4Search.css.ts +12 -0
- package/src/LikeC4Search.tsx +39 -90
- package/src/controls/Text.ts +5 -0
- package/src/controls/action-button-bar/ActionButtonBar.css.ts +13 -0
- package/src/controls/action-button-bar/ActionButtonBar.tsx +138 -0
- package/src/controls/action-button-bar/useActionButtonBarCtx.ts +13 -0
- package/src/controls/action-buttons/ActionButton.css.ts +29 -0
- package/src/controls/action-buttons/ActionButton.tsx +66 -0
- package/src/controls/action-buttons/ActionButtons.tsx +138 -0
- package/src/hooks/useXYFlow.ts +8 -8
- package/src/index.ts +12 -6
- package/src/likec4model/index.ts +12 -2
- package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -12
- package/src/overlays/edge-details/_types.ts +13 -37
- package/src/overlays/edge-details/use-layouted-edge-details.ts +16 -14
- package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
- package/src/overlays/edge-details/xyflow/ElementNode.tsx +4 -11
- package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +3 -3
- package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
- package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +23 -23
- package/src/overlays/relationships-of/_types.ts +20 -58
- package/src/overlays/relationships-of/use-layouted-relationships.ts +36 -40
- package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +9 -13
- package/src/overlays/relationships-of/xyflow/ElementNode.tsx +12 -15
- package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
- package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -14
- package/src/overlays/shared/xyflow/RelationshipEdge.css.ts +60 -0
- package/src/overlays/shared/xyflow/_types.ts +87 -0
- package/src/state/diagram-to-xyflow.ts +6 -7
- package/src/state/diagramStore.layout.ts +3 -4
- package/src/state/diagramStore.ts +35 -37
- package/src/theme-vars.css.ts +81 -0
- package/src/theme-vars.ts +8 -81
- package/src/ui/DiagramTitlePanel.tsx +6 -6
- package/src/utils/types.ts +6 -0
- package/src/xyflow/SelectEdgesOnNodeFocus.tsx +3 -3
- package/src/xyflow/XYFlow.tsx +2 -2
- package/src/xyflow/edges/EdgeLabel.tsx +25 -18
- package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
- package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +3 -3
- package/src/xyflow/edges/edges.css.ts +68 -74
- package/src/xyflow/edges/utils.ts +6 -6
- package/src/xyflow/nodes/AnimateVariants.ts +143 -0
- package/src/xyflow/nodes/Node.css.ts +44 -0
- package/src/xyflow/nodes/compound/CompoundNode.css.ts +1 -64
- package/src/xyflow/nodes/compound/CompoundNode.tsx +69 -182
- package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
- package/src/xyflow/nodes/element/ElementNode.tsx +64 -266
- package/src/xyflow/nodes/element/element.css.ts +0 -57
- package/src/xyflow/nodes/shared/Toolbar.tsx +30 -30
- package/src/xyflow/types.ts +48 -51
- package/src/xyflow/useLayoutConstraints.ts +9 -9
- package/src/xyflow/useXYFlowEvents.ts +13 -30
- package/src/xyflow/utils.ts +2 -2
- package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import "@likec4/core";
|
|
3
|
+
import { Group, Box, Text } from "@mantine/core";
|
|
4
|
+
import { useSyncedRef, useDebouncedCallback, useUpdateEffect } from "@react-hookz/web";
|
|
5
|
+
import { useReactFlow, useStoreApi, getViewportForBounds, ReactFlow, Panel, ViewportPortal } from "@xyflow/react";
|
|
6
|
+
import { memo, useEffect } from "react";
|
|
7
|
+
import { only } from "remeda";
|
|
8
|
+
import { useDiagramStoreApi } from "../../hooks/useDiagramState.js";
|
|
9
|
+
import { SelectEdge } from "./SelectEdge.js";
|
|
10
|
+
import { edgeDataGrid } from "./SelectEdge.css.js";
|
|
11
|
+
import { useLayoutedEdgeDetails, ZIndexes } from "./use-layouted-edge-details.js";
|
|
12
|
+
import { CompoundNode } from "./xyflow/CompoundNode.js";
|
|
13
|
+
import { ElementNode } from "./xyflow/ElementNode.js";
|
|
14
|
+
import { RelationshipEdge } from "./xyflow/RelationshipEdge.js";
|
|
15
|
+
const nodeTypes = {
|
|
16
|
+
element: ElementNode,
|
|
17
|
+
compound: CompoundNode
|
|
18
|
+
};
|
|
19
|
+
const edgeTypes = {
|
|
20
|
+
relation: RelationshipEdge
|
|
21
|
+
};
|
|
22
|
+
const resetDimmedAndHovered = (xyflow) => {
|
|
23
|
+
xyflow.setEdges(
|
|
24
|
+
(edges) => edges.map((edge) => ({
|
|
25
|
+
...edge,
|
|
26
|
+
data: {
|
|
27
|
+
...edge.data,
|
|
28
|
+
dimmed: false,
|
|
29
|
+
hovered: false
|
|
30
|
+
},
|
|
31
|
+
animated: false
|
|
32
|
+
}))
|
|
33
|
+
);
|
|
34
|
+
xyflow.setNodes(
|
|
35
|
+
(nodes) => nodes.map(
|
|
36
|
+
(n) => ({
|
|
37
|
+
...n,
|
|
38
|
+
data: {
|
|
39
|
+
...n.data,
|
|
40
|
+
dimmed: false,
|
|
41
|
+
hovered: false
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
const EdgeDetailsXYFlow = memo(function EdgeDetailsXYFlow2({ edgeId }) {
|
|
48
|
+
const diagramStore = useDiagramStoreApi();
|
|
49
|
+
const {
|
|
50
|
+
view,
|
|
51
|
+
edge,
|
|
52
|
+
edges,
|
|
53
|
+
nodes,
|
|
54
|
+
bounds
|
|
55
|
+
} = useLayoutedEdgeDetails(edgeId);
|
|
56
|
+
const boundsRef = useSyncedRef(bounds);
|
|
57
|
+
const xyflow = useReactFlow();
|
|
58
|
+
const xystore = useStoreApi();
|
|
59
|
+
const fitview = useDebouncedCallback(
|
|
60
|
+
() => {
|
|
61
|
+
const {
|
|
62
|
+
width,
|
|
63
|
+
height
|
|
64
|
+
} = xystore.getState();
|
|
65
|
+
const viewport = getViewportForBounds(
|
|
66
|
+
{
|
|
67
|
+
...boundsRef.current,
|
|
68
|
+
height: Math.max(boundsRef.current.height + 100, height - 200)
|
|
69
|
+
// Add some padding to the bottom
|
|
70
|
+
},
|
|
71
|
+
width,
|
|
72
|
+
height,
|
|
73
|
+
0.2,
|
|
74
|
+
1,
|
|
75
|
+
0.2
|
|
76
|
+
);
|
|
77
|
+
xyflow.setViewport(viewport, { duration: 350 });
|
|
78
|
+
},
|
|
79
|
+
[xyflow],
|
|
80
|
+
150
|
|
81
|
+
);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
xyflow.setNodes(nodes);
|
|
84
|
+
xyflow.setEdges(edges);
|
|
85
|
+
}, [nodes, edges]);
|
|
86
|
+
const zoomable = true;
|
|
87
|
+
useUpdateEffect(() => fitview(), [edge.id]);
|
|
88
|
+
return /* @__PURE__ */ jsxs(
|
|
89
|
+
ReactFlow,
|
|
90
|
+
{
|
|
91
|
+
defaultEdges: [],
|
|
92
|
+
defaultNodes: [],
|
|
93
|
+
nodeTypes,
|
|
94
|
+
edgeTypes,
|
|
95
|
+
defaultMarkerColor: "var(--xy-edge-stroke)",
|
|
96
|
+
zoomOnPinch: zoomable,
|
|
97
|
+
zoomOnScroll: false,
|
|
98
|
+
zoomOnDoubleClick: false,
|
|
99
|
+
maxZoom: 1.5,
|
|
100
|
+
minZoom: 0.1,
|
|
101
|
+
fitView: true,
|
|
102
|
+
fitViewOptions: {
|
|
103
|
+
padding: 0.2,
|
|
104
|
+
maxZoom: 1,
|
|
105
|
+
minZoom: 0.1,
|
|
106
|
+
includeHiddenNodes: true
|
|
107
|
+
},
|
|
108
|
+
preventScrolling: true,
|
|
109
|
+
noDragClassName: "nodrag",
|
|
110
|
+
noPanClassName: "nopan",
|
|
111
|
+
panOnScroll: true,
|
|
112
|
+
panOnDrag: true,
|
|
113
|
+
elementsSelectable: true,
|
|
114
|
+
nodesFocusable: false,
|
|
115
|
+
edgesFocusable: false,
|
|
116
|
+
nodesDraggable: false,
|
|
117
|
+
onEdgeMouseEnter: (_, edge2) => {
|
|
118
|
+
xyflow.setEdges(
|
|
119
|
+
(edges2) => edges2.map((e) => ({
|
|
120
|
+
...e,
|
|
121
|
+
data: {
|
|
122
|
+
...e.data,
|
|
123
|
+
dimmed: e.id !== edge2.id,
|
|
124
|
+
hovered: e.id === edge2.id
|
|
125
|
+
},
|
|
126
|
+
zIndex: e.id === edge2.id ? ZIndexes.max : ZIndexes.edge,
|
|
127
|
+
animated: e.id === edge2.id
|
|
128
|
+
}))
|
|
129
|
+
);
|
|
130
|
+
xyflow.setNodes(
|
|
131
|
+
(nodes2) => nodes2.map((n) => ({
|
|
132
|
+
...n,
|
|
133
|
+
data: {
|
|
134
|
+
...n.data,
|
|
135
|
+
dimmed: n.id !== edge2.source && n.id !== edge2.target
|
|
136
|
+
}
|
|
137
|
+
}))
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
onEdgeMouseLeave: () => {
|
|
141
|
+
resetDimmedAndHovered(xyflow);
|
|
142
|
+
},
|
|
143
|
+
onEdgeClick: (e, edge2) => {
|
|
144
|
+
var _a, _b, _c;
|
|
145
|
+
e.stopPropagation();
|
|
146
|
+
let relationId = (_a = only(edge2.data.relations)) == null ? void 0 : _a.id;
|
|
147
|
+
if (relationId) {
|
|
148
|
+
(_c = (_b = diagramStore.getState()).onOpenSource) == null ? void 0 : _c.call(_b, {
|
|
149
|
+
relation: relationId
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ jsx(Panel, { position: "top-center", children: /* @__PURE__ */ jsx(Group, { gap: "xs", wrap: "nowrap", children: /* @__PURE__ */ jsx(
|
|
155
|
+
SelectEdge,
|
|
156
|
+
{
|
|
157
|
+
view,
|
|
158
|
+
edge
|
|
159
|
+
}
|
|
160
|
+
) }) }),
|
|
161
|
+
/* @__PURE__ */ jsx(EdgeData, { edge, top: bounds.height, width: bounds.width })
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
});
|
|
166
|
+
const EdgeData = ({ edge, top, width }) => {
|
|
167
|
+
return /* @__PURE__ */ jsx(ViewportPortal, { children: /* @__PURE__ */ jsx(
|
|
168
|
+
Box,
|
|
169
|
+
{
|
|
170
|
+
maw: width,
|
|
171
|
+
style: {
|
|
172
|
+
transform: `translate(100px, ${top + 32}px)`
|
|
173
|
+
},
|
|
174
|
+
children: /* @__PURE__ */ jsxs(Box, { className: edgeDataGrid, children: [
|
|
175
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", fw: 500, c: "dimmed", children: "technology" }),
|
|
176
|
+
/* @__PURE__ */ jsx(Text, { children: edge.technology || "unknown" }),
|
|
177
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", fw: 500, c: "dimmed", children: "description" }),
|
|
178
|
+
/* @__PURE__ */ jsx(Text, { children: edge.description || "no description" })
|
|
179
|
+
] })
|
|
180
|
+
}
|
|
181
|
+
) });
|
|
182
|
+
};
|
|
183
|
+
export {
|
|
184
|
+
EdgeDetailsXYFlow
|
|
185
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const edgeSource: string;
|
|
2
|
+
export declare const edgeArrow: string;
|
|
3
|
+
export declare const edgeTarget: string;
|
|
4
|
+
export declare const edgeLabel: string;
|
|
5
|
+
export declare const edgeRow: string;
|
|
6
|
+
export declare const edgeGrid: string;
|
|
7
|
+
export declare const edgeDataGrid: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
var edgeSource = "_1n45dyn1 _1n45dyn0";
|
|
3
|
+
var edgeArrow = "_1n45dyn2 _1n45dyn0";
|
|
4
|
+
var edgeTarget = "_1n45dyn3 _1n45dyn0";
|
|
5
|
+
var edgeLabel = "_1n45dyn4";
|
|
6
|
+
var edgeRow = "_1n45dyn5";
|
|
7
|
+
var edgeGrid = "_1n45dyn6";
|
|
8
|
+
var edgeDataGrid = "_1n45dyn7";
|
|
9
|
+
export {
|
|
10
|
+
edgeArrow,
|
|
11
|
+
edgeDataGrid,
|
|
12
|
+
edgeGrid,
|
|
13
|
+
edgeLabel,
|
|
14
|
+
edgeRow,
|
|
15
|
+
edgeSource,
|
|
16
|
+
edgeTarget
|
|
17
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import "@likec4/core";
|
|
3
|
+
import { useComputedColorScheme, Popover, PopoverTarget, Button, Box, Text, ThemeIcon, PopoverDropdown, ScrollAreaAutosize } from "@mantine/core";
|
|
4
|
+
import { IconSelector, IconArrowRight } from "@tabler/icons-react";
|
|
5
|
+
import { useRef } from "react";
|
|
6
|
+
import { useOverlayDialog } from "../OverlayContext.js";
|
|
7
|
+
import { edgeSource, edgeTarget, edgeGrid, edgeRow, edgeArrow, edgeLabel } from "./SelectEdge.css.js";
|
|
8
|
+
const SelectEdge = ({
|
|
9
|
+
edge,
|
|
10
|
+
view
|
|
11
|
+
}) => {
|
|
12
|
+
const overlay = useOverlayDialog();
|
|
13
|
+
const viewport = useRef(null);
|
|
14
|
+
const theme = useComputedColorScheme();
|
|
15
|
+
const edgeSource$1 = view.nodes.find((n) => n.id === edge.source);
|
|
16
|
+
const edgeTarget$1 = view.nodes.find((n) => n.id === edge.target);
|
|
17
|
+
const edges = view.edges.map((edge2) => {
|
|
18
|
+
const source = view.nodes.find((n) => n.id === edge2.source);
|
|
19
|
+
const target = view.nodes.find((n) => n.id === edge2.target);
|
|
20
|
+
return {
|
|
21
|
+
id: edge2.id,
|
|
22
|
+
source,
|
|
23
|
+
target,
|
|
24
|
+
label: edge2.label
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
return /* @__PURE__ */ jsxs(
|
|
28
|
+
Popover,
|
|
29
|
+
{
|
|
30
|
+
position: "bottom",
|
|
31
|
+
shadow: "md",
|
|
32
|
+
keepMounted: true,
|
|
33
|
+
withinPortal: false,
|
|
34
|
+
closeOnClickOutside: true,
|
|
35
|
+
clickOutsideEvents: ["pointerdown", "mousedown", "click"],
|
|
36
|
+
onOpen: () => {
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
var _a;
|
|
39
|
+
const item = (_a = viewport.current) == null ? void 0 : _a.querySelector(`[data-edge-id="${edge.id}"]`);
|
|
40
|
+
item == null ? void 0 : item.scrollIntoView({ behavior: "instant", block: "nearest" });
|
|
41
|
+
}, 100);
|
|
42
|
+
},
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ jsx(PopoverTarget, { children: /* @__PURE__ */ jsxs(
|
|
45
|
+
Button,
|
|
46
|
+
{
|
|
47
|
+
size: "xs",
|
|
48
|
+
variant: "light",
|
|
49
|
+
color: theme === "light" ? "dark" : "gray",
|
|
50
|
+
fw: "500",
|
|
51
|
+
style: { padding: "0.25rem 0.75rem" },
|
|
52
|
+
rightSection: /* @__PURE__ */ jsx(IconSelector, { size: 16 }),
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx(
|
|
55
|
+
Box,
|
|
56
|
+
{
|
|
57
|
+
className: edgeSource,
|
|
58
|
+
maw: 160,
|
|
59
|
+
p: 0,
|
|
60
|
+
mod: {
|
|
61
|
+
"likec4-color": edgeSource$1.color
|
|
62
|
+
},
|
|
63
|
+
children: /* @__PURE__ */ jsx(Text, { component: "span", truncate: true, children: edgeSource$1.title })
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
/* @__PURE__ */ jsx(ThemeIcon, { color: "dark", variant: "transparent", size: "xs", children: /* @__PURE__ */ jsx(IconArrowRight, { style: { width: "80%" } }) }),
|
|
67
|
+
/* @__PURE__ */ jsx(
|
|
68
|
+
Box,
|
|
69
|
+
{
|
|
70
|
+
className: edgeTarget,
|
|
71
|
+
maw: 160,
|
|
72
|
+
p: 0,
|
|
73
|
+
mod: {
|
|
74
|
+
"likec4-color": edgeTarget$1.color
|
|
75
|
+
},
|
|
76
|
+
children: /* @__PURE__ */ jsx(Text, { component: "span", truncate: true, children: edgeTarget$1.title })
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
) }),
|
|
82
|
+
/* @__PURE__ */ jsx(PopoverDropdown, { p: 0, miw: 250, maw: 420, children: /* @__PURE__ */ jsx(ScrollAreaAutosize, { mah: "70vh", scrollbars: "y", type: "never", viewportRef: viewport, children: /* @__PURE__ */ jsx(Box, { className: edgeGrid, p: "xs", children: edges.map((e) => /* @__PURE__ */ jsxs(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
className: edgeRow,
|
|
86
|
+
"data-selected": e.id === edge.id,
|
|
87
|
+
onClick: (event) => {
|
|
88
|
+
event.stopPropagation();
|
|
89
|
+
overlay.openOverlay({
|
|
90
|
+
edgeDetails: e.id
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ jsx(
|
|
95
|
+
Box,
|
|
96
|
+
{
|
|
97
|
+
className: edgeSource,
|
|
98
|
+
maw: 160,
|
|
99
|
+
mod: {
|
|
100
|
+
"edge-id": e.id,
|
|
101
|
+
"likec4-color": e.source.color
|
|
102
|
+
},
|
|
103
|
+
children: /* @__PURE__ */ jsx(Text, { component: "span", truncate: true, children: e.source.title })
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ jsx(Box, { className: edgeArrow, children: /* @__PURE__ */ jsx(ThemeIcon, { color: "dark", variant: "transparent", size: "xs", children: /* @__PURE__ */ jsx(IconArrowRight, { style: { width: "80%" } }) }) }),
|
|
107
|
+
/* @__PURE__ */ jsx(
|
|
108
|
+
Box,
|
|
109
|
+
{
|
|
110
|
+
className: edgeTarget,
|
|
111
|
+
maw: 160,
|
|
112
|
+
mod: {
|
|
113
|
+
"likec4-color": e.target.color
|
|
114
|
+
},
|
|
115
|
+
children: /* @__PURE__ */ jsx(Text, { component: "span", truncate: true, children: e.target.title })
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ jsx(Box, { className: edgeLabel, children: /* @__PURE__ */ jsx(Text, { component: "span", truncate: true, children: e.label || "untitled" }) })
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
e.id
|
|
122
|
+
)) }) }) })
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
export {
|
|
128
|
+
SelectEdge
|
|
129
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AddEdgeData } from '../../utils/types';
|
|
2
|
+
import { SharedFlowTypes } from '../shared/xyflow/_types';
|
|
3
|
+
export declare namespace EdgeDetailsFlowTypes {
|
|
4
|
+
/**
|
|
5
|
+
* Data that is exclusive to the edge-details overlay. It will be merged into the edge types
|
|
6
|
+
* provided by SharedFlowTypes.
|
|
7
|
+
*/
|
|
8
|
+
type EdgeDetailsEdgeData = {
|
|
9
|
+
technology: string | null;
|
|
10
|
+
description: string | null;
|
|
11
|
+
};
|
|
12
|
+
export type Edge = AddEdgeData<SharedFlowTypes.Edge, EdgeDetailsEdgeData>;
|
|
13
|
+
export {};
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DiagramEdge, DiagramView, EdgeId } from '@likec4/core';
|
|
2
|
+
import { SharedFlowTypes } from '../shared/xyflow/_types';
|
|
3
|
+
import { EdgeDetailsFlowTypes } from './_types';
|
|
4
|
+
export declare const ZIndexes: {
|
|
5
|
+
compound: number;
|
|
6
|
+
edge: number;
|
|
7
|
+
element: number;
|
|
8
|
+
max: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function useLayoutedEdgeDetails(edgeId: EdgeId): {
|
|
11
|
+
view: DiagramView;
|
|
12
|
+
edge: DiagramEdge;
|
|
13
|
+
nodes: SharedFlowTypes.Node[];
|
|
14
|
+
edges: EdgeDetailsFlowTypes.Edge[];
|
|
15
|
+
bounds: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import dagre from "@dagrejs/dagre";
|
|
2
|
+
import { invariant, compareRelations, compareFqnHierarchically, isAncestor } from "@likec4/core";
|
|
3
|
+
import { MarkerType } from "@xyflow/system";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { pipe, sort, reverse, forEach, takeWhile, first, map, sortBy, prop, filter, isTruthy } from "remeda";
|
|
6
|
+
import { useDiagramState } from "../../hooks/useDiagramState.js";
|
|
7
|
+
import { useLikeC4Model } from "../../likec4model/useLikeC4Model.js";
|
|
8
|
+
const Sizes = {
|
|
9
|
+
dagre: {
|
|
10
|
+
ranksep: 40,
|
|
11
|
+
nodesep: 25,
|
|
12
|
+
edgesep: 15
|
|
13
|
+
},
|
|
14
|
+
edgeLabel: {
|
|
15
|
+
width: 120
|
|
16
|
+
},
|
|
17
|
+
nodeWidth: 270,
|
|
18
|
+
hodeHeight: 160,
|
|
19
|
+
// Spacer between elements in a compound node
|
|
20
|
+
// 0 means no spacer
|
|
21
|
+
spacerHeight: 0,
|
|
22
|
+
compoundLabelHeight: 5
|
|
23
|
+
};
|
|
24
|
+
const ZIndexes = {
|
|
25
|
+
compound: 2,
|
|
26
|
+
edge: 3,
|
|
27
|
+
element: 4,
|
|
28
|
+
max: 5
|
|
29
|
+
};
|
|
30
|
+
function createGraph() {
|
|
31
|
+
const g = new dagre.graphlib.Graph({
|
|
32
|
+
directed: true,
|
|
33
|
+
compound: true
|
|
34
|
+
});
|
|
35
|
+
g.setGraph({
|
|
36
|
+
...Sizes.dagre,
|
|
37
|
+
rankdir: "LR"
|
|
38
|
+
});
|
|
39
|
+
g.setDefaultEdgeLabel(() => ({ ...Sizes.edgeLabel }));
|
|
40
|
+
g.setDefaultNodeLabel(() => ({}));
|
|
41
|
+
return g;
|
|
42
|
+
}
|
|
43
|
+
const sized = (height = Sizes.hodeHeight) => ({
|
|
44
|
+
width: Sizes.nodeWidth,
|
|
45
|
+
height
|
|
46
|
+
});
|
|
47
|
+
const graphId = (node) => ({
|
|
48
|
+
id: node.id,
|
|
49
|
+
port: node.type === "compound" ? `${node.id}::port` : node.id,
|
|
50
|
+
body: `${node.id}`,
|
|
51
|
+
spacer: `${node.id}:spacer`
|
|
52
|
+
});
|
|
53
|
+
function nodeData(element, ctx) {
|
|
54
|
+
var _a;
|
|
55
|
+
let diagramNode = ctx.diagramNodes.get(element.id);
|
|
56
|
+
const ancestor = diagramNode ?? pipe(
|
|
57
|
+
element.ancestors().toArray(),
|
|
58
|
+
map((ancestor2) => ctx.diagramNodes.get(ancestor2.id)),
|
|
59
|
+
filter(isTruthy),
|
|
60
|
+
first()
|
|
61
|
+
);
|
|
62
|
+
return {
|
|
63
|
+
fqn: element.id,
|
|
64
|
+
element: {
|
|
65
|
+
kind: element.kind,
|
|
66
|
+
title: (diagramNode == null ? void 0 : diagramNode.title) ?? element.title,
|
|
67
|
+
description: (diagramNode == null ? void 0 : diagramNode.description) ?? element.description,
|
|
68
|
+
color: (diagramNode == null ? void 0 : diagramNode.color) ?? (ancestor == null ? void 0 : ancestor.color) ?? element.color,
|
|
69
|
+
shape: (diagramNode == null ? void 0 : diagramNode.shape) ?? element.shape
|
|
70
|
+
},
|
|
71
|
+
navigateTo: (diagramNode == null ? void 0 : diagramNode.navigateTo) ?? ((_a = first(element.scopedViews().take(1).toArray())) == null ? void 0 : _a.id) ?? null,
|
|
72
|
+
ports: {
|
|
73
|
+
in: [],
|
|
74
|
+
out: []
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function createNode(nodeType, element, ctx) {
|
|
79
|
+
let node = ctx.xynodes.get(element.id);
|
|
80
|
+
if (node) {
|
|
81
|
+
return node;
|
|
82
|
+
}
|
|
83
|
+
const g = ctx.g;
|
|
84
|
+
const parent = pipe(
|
|
85
|
+
element.ancestors().toArray(),
|
|
86
|
+
takeWhile((ancestor) => !isAncestor(ancestor.id, ctx.edge.source) && !isAncestor(ancestor.id, ctx.edge.target)),
|
|
87
|
+
first(),
|
|
88
|
+
(found) => found ? createNode("compound", found, ctx) : null
|
|
89
|
+
);
|
|
90
|
+
const xynode = {
|
|
91
|
+
type: nodeType,
|
|
92
|
+
id: element.id,
|
|
93
|
+
position: { x: 0, y: 0 },
|
|
94
|
+
data: {
|
|
95
|
+
...nodeData(element, ctx)
|
|
96
|
+
},
|
|
97
|
+
zIndex: ZIndexes[nodeType],
|
|
98
|
+
...!!parent && { parentId: parent.id }
|
|
99
|
+
};
|
|
100
|
+
ctx.xynodes.set(element.id, xynode);
|
|
101
|
+
const k = graphId(xynode);
|
|
102
|
+
g.setNode(k.id, sized());
|
|
103
|
+
if (xynode.type === "compound") {
|
|
104
|
+
g.setNode(k.port, {
|
|
105
|
+
width: Sizes.nodeWidth - Sizes.dagre.ranksep,
|
|
106
|
+
height: Sizes.compoundLabelHeight
|
|
107
|
+
});
|
|
108
|
+
g.setParent(k.port, k.id);
|
|
109
|
+
}
|
|
110
|
+
if (parent) {
|
|
111
|
+
const parentGraphId = graphId(parent).body;
|
|
112
|
+
g.setParent(k.id, parentGraphId);
|
|
113
|
+
}
|
|
114
|
+
return xynode;
|
|
115
|
+
}
|
|
116
|
+
function applyDagreLayout(g) {
|
|
117
|
+
dagre.layout(g);
|
|
118
|
+
return function nodeBounds(nodeId, relativeTo) {
|
|
119
|
+
const { x, y, width, height } = g.node(nodeId);
|
|
120
|
+
const pos = {
|
|
121
|
+
position: {
|
|
122
|
+
x: x - Math.round(width / 2),
|
|
123
|
+
y: y - Math.round(height / 2)
|
|
124
|
+
},
|
|
125
|
+
width,
|
|
126
|
+
height
|
|
127
|
+
};
|
|
128
|
+
if (!relativeTo) {
|
|
129
|
+
return pos;
|
|
130
|
+
}
|
|
131
|
+
const offset = nodeBounds(relativeTo).position;
|
|
132
|
+
return {
|
|
133
|
+
position: {
|
|
134
|
+
x: pos.position.x - offset.x,
|
|
135
|
+
y: pos.position.y - offset.y
|
|
136
|
+
},
|
|
137
|
+
width: pos.width,
|
|
138
|
+
height: pos.height
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function layout(edgeId, view, likec4model) {
|
|
143
|
+
const edge = view.edges.find((e) => e.id === edgeId);
|
|
144
|
+
invariant(edge, "edge not found");
|
|
145
|
+
const all = /* @__PURE__ */ new Set([edge.source, edge.target]);
|
|
146
|
+
const relations = edge.relations.map((r) => {
|
|
147
|
+
const relation = likec4model.relationship(r);
|
|
148
|
+
all.add(relation.source.id);
|
|
149
|
+
all.add(relation.target.id);
|
|
150
|
+
return {
|
|
151
|
+
source: relation.source.id,
|
|
152
|
+
target: relation.target.id,
|
|
153
|
+
relation: relation.$relationship
|
|
154
|
+
};
|
|
155
|
+
}).sort(compareRelations).reverse();
|
|
156
|
+
const diagramNodes = new Map(view.nodes.map((n) => [n.id, n]));
|
|
157
|
+
const g = createGraph();
|
|
158
|
+
const ctx = {
|
|
159
|
+
g,
|
|
160
|
+
xynodes: /* @__PURE__ */ new Map(),
|
|
161
|
+
edge,
|
|
162
|
+
diagramNodes,
|
|
163
|
+
edges: []
|
|
164
|
+
};
|
|
165
|
+
pipe(
|
|
166
|
+
[...all],
|
|
167
|
+
sort(compareFqnHierarchically),
|
|
168
|
+
reverse(),
|
|
169
|
+
forEach((id) => {
|
|
170
|
+
const element = likec4model.element(id);
|
|
171
|
+
createNode("element", element, ctx);
|
|
172
|
+
})
|
|
173
|
+
);
|
|
174
|
+
if (relations.length === 1 && all.size < 4) {
|
|
175
|
+
g.setDefaultEdgeLabel(() => ({ width: 250 }));
|
|
176
|
+
}
|
|
177
|
+
for (const { relation, ...points } of relations) {
|
|
178
|
+
const source = ctx.xynodes.get(points.source);
|
|
179
|
+
invariant(source, "source node not found");
|
|
180
|
+
const target = ctx.xynodes.get(points.target);
|
|
181
|
+
invariant(target, "target node not found");
|
|
182
|
+
source.data.ports.out.push(target.id);
|
|
183
|
+
target.data.ports.in.push(source.id);
|
|
184
|
+
g.setEdge(graphId(source).port, graphId(target).port);
|
|
185
|
+
const edge2 = {
|
|
186
|
+
id: relation.id,
|
|
187
|
+
type: "relation",
|
|
188
|
+
source: source.id,
|
|
189
|
+
target: target.id,
|
|
190
|
+
sourceHandle: target.id,
|
|
191
|
+
targetHandle: source.id,
|
|
192
|
+
data: {
|
|
193
|
+
relations: [relation],
|
|
194
|
+
navigateTo: relation.navigateTo ?? null,
|
|
195
|
+
technology: relation.technology ?? null,
|
|
196
|
+
description: relation.description ?? null
|
|
197
|
+
},
|
|
198
|
+
label: relation.title,
|
|
199
|
+
zIndex: ZIndexes.edge,
|
|
200
|
+
markerEnd: {
|
|
201
|
+
type: MarkerType.ArrowClosed,
|
|
202
|
+
width: 10
|
|
203
|
+
},
|
|
204
|
+
style: {
|
|
205
|
+
strokeWidth: 2.2,
|
|
206
|
+
strokeDasharray: "5, 5"
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
ctx.edges.push(edge2);
|
|
210
|
+
}
|
|
211
|
+
const nodebounds = applyDagreLayout(ctx.g);
|
|
212
|
+
const sortedPorts = (ports) => {
|
|
213
|
+
if (ports.length < 2) {
|
|
214
|
+
return ports;
|
|
215
|
+
}
|
|
216
|
+
return pipe(
|
|
217
|
+
ports,
|
|
218
|
+
map((port) => {
|
|
219
|
+
return {
|
|
220
|
+
port,
|
|
221
|
+
topY: nodebounds(port).position.y
|
|
222
|
+
};
|
|
223
|
+
}),
|
|
224
|
+
sortBy(prop("topY")),
|
|
225
|
+
map(prop("port"))
|
|
226
|
+
);
|
|
227
|
+
};
|
|
228
|
+
const xynodes = [...ctx.xynodes.values()].map((node) => {
|
|
229
|
+
if (node.data.ports.in.length > 1) {
|
|
230
|
+
node.data.ports.in = sortedPorts(node.data.ports.in);
|
|
231
|
+
}
|
|
232
|
+
if (node.data.ports.out.length > 1) {
|
|
233
|
+
node.data.ports.out = sortedPorts(node.data.ports.out);
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
...node,
|
|
237
|
+
...nodebounds(node.id, node.parentId)
|
|
238
|
+
};
|
|
239
|
+
});
|
|
240
|
+
return {
|
|
241
|
+
view,
|
|
242
|
+
edge,
|
|
243
|
+
edges: ctx.edges,
|
|
244
|
+
nodes: xynodes,
|
|
245
|
+
bounds: {
|
|
246
|
+
x: 0,
|
|
247
|
+
y: 0,
|
|
248
|
+
width: g.graph().width ?? 0,
|
|
249
|
+
height: g.graph().height ?? 0
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function useLayoutedEdgeDetails(edgeId) {
|
|
254
|
+
const view = useDiagramState((s) => s.view);
|
|
255
|
+
const likec4model = useLikeC4Model(true);
|
|
256
|
+
return useMemo(() => layout(
|
|
257
|
+
edgeId,
|
|
258
|
+
view,
|
|
259
|
+
likec4model
|
|
260
|
+
), [
|
|
261
|
+
edgeId,
|
|
262
|
+
view,
|
|
263
|
+
likec4model,
|
|
264
|
+
layout
|
|
265
|
+
]);
|
|
266
|
+
}
|
|
267
|
+
export {
|
|
268
|
+
ZIndexes,
|
|
269
|
+
useLayoutedEdgeDetails
|
|
270
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NodeProps } from '@xyflow/react';
|
|
2
|
+
import { SharedFlowTypes } from '../../shared/xyflow/_types';
|
|
3
|
+
type CompoundNodeProps = NodeProps<SharedFlowTypes.CompoundNode>;
|
|
4
|
+
export declare function CompoundNode({ data: { element, ports, ...data }, width, selectable }: CompoundNodeProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export {};
|