@likec4/diagram 1.18.0 → 1.19.0

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.
Files changed (277) hide show
  1. package/LICENSE +1 -1
  2. package/dist/LikeC4CustomColors.d.ts +7 -0
  3. package/dist/LikeC4CustomColors.js +30 -0
  4. package/dist/LikeC4Diagram.css.d.ts +5 -0
  5. package/dist/LikeC4Diagram.css.js +13 -0
  6. package/dist/LikeC4Diagram.d.ts +6 -0
  7. package/dist/LikeC4Diagram.js +194 -0
  8. package/dist/LikeC4Diagram.props.d.ts +166 -0
  9. package/dist/LikeC4ModelProvider.d.ts +9 -0
  10. package/dist/LikeC4ModelProvider.js +12 -0
  11. package/dist/LikeC4Search.css.d.ts +1 -0
  12. package/dist/LikeC4Search.css.js +5 -0
  13. package/dist/LikeC4Search.d.ts +2 -0
  14. package/dist/LikeC4Search.js +96 -0
  15. package/dist/StaticLikeC4Diagram.d.ts +3 -0
  16. package/dist/StaticLikeC4Diagram.js +41 -0
  17. package/dist/_virtual/_commonjsHelpers.js +6 -0
  18. package/dist/controls/Text.d.ts +2 -0
  19. package/dist/controls/Text.js +7 -0
  20. package/dist/controls/action-button-bar/ActionButtonBar.css.d.ts +1 -0
  21. package/dist/controls/action-button-bar/ActionButtonBar.css.js +5 -0
  22. package/dist/controls/action-button-bar/ActionButtonBar.d.ts +9 -0
  23. package/dist/controls/action-button-bar/ActionButtonBar.js +100 -0
  24. package/dist/controls/action-button-bar/useActionButtonBarCtx.d.ts +10 -0
  25. package/dist/controls/action-button-bar/useActionButtonBarCtx.js +9 -0
  26. package/dist/controls/action-buttons/ActionButton.css.d.ts +1 -0
  27. package/dist/controls/action-buttons/ActionButton.css.js +5 -0
  28. package/dist/controls/action-buttons/ActionButton.d.ts +9 -0
  29. package/dist/controls/action-buttons/ActionButton.js +66 -0
  30. package/dist/controls/action-buttons/ActionButtons.d.ts +12 -0
  31. package/dist/controls/action-buttons/ActionButtons.js +99 -0
  32. package/dist/globals.css.d.ts +1 -0
  33. package/dist/globals.css.js +92 -0
  34. package/dist/hooks/index.d.ts +5 -0
  35. package/dist/hooks/useDiagramState.d.ts +6 -0
  36. package/dist/hooks/useDiagramState.js +27 -0
  37. package/dist/hooks/useMantinePortalProps.d.ts +9 -0
  38. package/dist/hooks/useMantinePortalProps.js +9 -0
  39. package/dist/hooks/useSetState.d.ts +2 -0
  40. package/dist/hooks/useSetState.js +19 -0
  41. package/dist/hooks/useUpdateEffect.d.ts +4 -0
  42. package/dist/hooks/useUpdateEffect.js +32 -0
  43. package/dist/hooks/useXYFlow.d.ts +270 -0
  44. package/dist/hooks/useXYFlow.js +20 -0
  45. package/dist/index.d.ts +11 -0
  46. package/dist/index.js +25 -0
  47. package/dist/likec4model/LikeC4ModelContext.d.ts +3 -0
  48. package/dist/likec4model/LikeC4ModelContext.js +5 -0
  49. package/dist/likec4model/index.d.ts +2 -0
  50. package/dist/likec4model/useLikeC4ElementsTree.d.ts +12 -0
  51. package/dist/likec4model/useLikeC4ElementsTree.js +25 -0
  52. package/dist/likec4model/useLikeC4Model.d.ts +20 -0
  53. package/dist/likec4model/useLikeC4Model.js +55 -0
  54. package/dist/overlays/OverlayContext.d.ts +10 -0
  55. package/dist/overlays/OverlayContext.js +9 -0
  56. package/dist/overlays/Overlays.css.d.ts +3 -0
  57. package/dist/overlays/Overlays.css.js +7 -0
  58. package/dist/overlays/Overlays.d.ts +2 -0
  59. package/dist/overlays/Overlays.js +137 -0
  60. package/dist/overlays/edge-details/EdgeDetailsXYFlow.d.ts +5 -0
  61. package/dist/overlays/edge-details/EdgeDetailsXYFlow.js +185 -0
  62. package/dist/overlays/edge-details/SelectEdge.css.d.ts +7 -0
  63. package/dist/overlays/edge-details/SelectEdge.css.js +17 -0
  64. package/dist/overlays/edge-details/SelectEdge.d.ts +5 -0
  65. package/dist/overlays/edge-details/SelectEdge.js +129 -0
  66. package/dist/overlays/edge-details/_types.d.ts +14 -0
  67. package/dist/overlays/edge-details/use-layouted-edge-details.d.ts +21 -0
  68. package/dist/overlays/edge-details/use-layouted-edge-details.js +270 -0
  69. package/dist/overlays/edge-details/xyflow/CompoundNode.d.ts +5 -0
  70. package/dist/overlays/edge-details/xyflow/CompoundNode.js +76 -0
  71. package/dist/overlays/edge-details/xyflow/ElementNode.d.ts +5 -0
  72. package/dist/overlays/edge-details/xyflow/ElementNode.js +159 -0
  73. package/dist/overlays/edge-details/xyflow/RelationshipEdge.d.ts +3 -0
  74. package/dist/overlays/edge-details/xyflow/RelationshipEdge.js +84 -0
  75. package/dist/overlays/edge-details/xyflow/styles.css.d.ts +9 -0
  76. package/dist/overlays/edge-details/xyflow/styles.css.js +21 -0
  77. package/dist/overlays/element-details/ElementDetailsCard.css.d.ts +16 -0
  78. package/dist/overlays/element-details/ElementDetailsCard.css.js +33 -0
  79. package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -0
  80. package/dist/overlays/element-details/ElementDetailsCard.js +484 -0
  81. package/dist/overlays/element-details/TabPanelDeployments.css.d.ts +4 -0
  82. package/dist/overlays/element-details/TabPanelDeployments.css.js +11 -0
  83. package/dist/overlays/element-details/TabPanelDeployments.d.ts +7 -0
  84. package/dist/overlays/element-details/TabPanelDeployments.js +173 -0
  85. package/dist/overlays/element-details/TabPanelRelationships.css.d.ts +5 -0
  86. package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -0
  87. package/dist/overlays/element-details/TabPanelRelationships.d.ts +8 -0
  88. package/dist/overlays/element-details/TabPanelRelationships.js +157 -0
  89. package/dist/overlays/element-details/TabPanelStructure.css.d.ts +2 -0
  90. package/dist/overlays/element-details/TabPanelStructure.css.js +7 -0
  91. package/dist/overlays/element-details/TabPanelStructure.d.ts +25 -0
  92. package/dist/overlays/element-details/TabPanelStructure.js +91 -0
  93. package/dist/overlays/index.d.ts +1 -0
  94. package/dist/overlays/relationships-of/RelationshipsOverlay.d.ts +5 -0
  95. package/dist/overlays/relationships-of/RelationshipsOverlay.js +193 -0
  96. package/dist/overlays/relationships-of/RelationshipsXYFlow.d.ts +19 -0
  97. package/dist/overlays/relationships-of/RelationshipsXYFlow.js +290 -0
  98. package/dist/overlays/relationships-of/SelectElement.css.d.ts +2 -0
  99. package/dist/overlays/relationships-of/SelectElement.css.js +7 -0
  100. package/dist/overlays/relationships-of/SelectElement.d.ts +7 -0
  101. package/dist/overlays/relationships-of/SelectElement.js +126 -0
  102. package/dist/overlays/relationships-of/_types.d.ts +28 -0
  103. package/dist/overlays/relationships-of/use-layouted-relationships.d.ts +22 -0
  104. package/dist/overlays/relationships-of/use-layouted-relationships.js +496 -0
  105. package/dist/overlays/relationships-of/xyflow/CompoundNode.d.ts +6 -0
  106. package/dist/overlays/relationships-of/xyflow/CompoundNode.js +120 -0
  107. package/dist/overlays/relationships-of/xyflow/ElementNode.d.ts +6 -0
  108. package/dist/overlays/relationships-of/xyflow/ElementNode.js +194 -0
  109. package/dist/overlays/relationships-of/xyflow/EmptyNode.d.ts +5 -0
  110. package/dist/overlays/relationships-of/xyflow/EmptyNode.js +18 -0
  111. package/dist/overlays/relationships-of/xyflow/RelationshipEdge.d.ts +3 -0
  112. package/dist/overlays/relationships-of/xyflow/RelationshipEdge.js +123 -0
  113. package/dist/overlays/relationships-of/xyflow/styles.css.d.ts +14 -0
  114. package/dist/overlays/relationships-of/xyflow/styles.css.js +24 -0
  115. package/dist/overlays/shared/xyflow/RelationshipEdge.css.d.ts +4 -0
  116. package/dist/overlays/shared/xyflow/RelationshipEdge.css.js +12 -0
  117. package/dist/overlays/shared/xyflow/_types.d.ts +77 -0
  118. package/dist/state/DiagramContext.d.ts +1609 -0
  119. package/dist/state/DiagramContext.js +101 -0
  120. package/dist/state/aligners.d.ts +42 -0
  121. package/dist/state/aligners.js +349 -0
  122. package/dist/state/diagram-to-xyflow.d.ts +11 -0
  123. package/dist/state/diagram-to-xyflow.js +113 -0
  124. package/dist/state/diagramStore.d.ts +1705 -0
  125. package/dist/state/diagramStore.js +808 -0
  126. package/dist/state/diagramStore.layout.d.ts +4 -0
  127. package/dist/state/diagramStore.layout.js +56 -0
  128. package/dist/style.css +1 -0
  129. package/dist/theme-vars.css.d.ts +72 -0
  130. package/dist/theme-vars.css.js +6 -0
  131. package/dist/theme-vars.css.ts.vanilla.css.js +1 -0
  132. package/dist/theme-vars.d.ts +3 -0
  133. package/dist/theme-vars.js +5 -0
  134. package/dist/ui/DiagramTitlePanel.css.d.ts +4 -0
  135. package/dist/ui/DiagramTitlePanel.css.js +11 -0
  136. package/dist/ui/DiagramTitlePanel.d.ts +1 -0
  137. package/dist/ui/DiagramTitlePanel.js +159 -0
  138. package/dist/ui/DynamicViewWalkthrough.css.d.ts +4 -0
  139. package/dist/ui/DynamicViewWalkthrough.css.js +11 -0
  140. package/dist/ui/DynamicViewWalkthrough.d.ts +1 -0
  141. package/dist/ui/DynamicViewWalkthrough.js +156 -0
  142. package/dist/ui/EnsureMantine.d.ts +7 -0
  143. package/dist/ui/EnsureMantine.js +14 -0
  144. package/dist/ui/FramerMotionConfig.d.ts +2 -0
  145. package/dist/ui/FramerMotionConfig.js +14 -0
  146. package/dist/ui/Link.d.ts +4 -0
  147. package/dist/ui/Link.js +36 -0
  148. package/dist/ui/notation/NotationPanel.css.d.ts +6 -0
  149. package/dist/ui/notation/NotationPanel.css.js +16 -0
  150. package/dist/ui/notation/NotationPanel.d.ts +1 -0
  151. package/dist/ui/notation/NotationPanel.js +250 -0
  152. package/dist/ui/notation/index.d.ts +1 -0
  153. package/dist/ui/top-left/ChangeAutoLayoutButton.d.ts +2 -0
  154. package/dist/ui/top-left/ChangeAutoLayoutButton.js +159 -0
  155. package/dist/ui/top-left/ManualLayoutToolsButton.d.ts +2 -0
  156. package/dist/ui/top-left/ManualLayoutToolsButton.js +137 -0
  157. package/dist/ui/top-left/TopLeftPanel.d.ts +4 -0
  158. package/dist/ui/top-left/TopLeftPanel.js +211 -0
  159. package/dist/ui/top-left/_shared.d.ts +7 -0
  160. package/dist/ui/top-left/_shared.js +22 -0
  161. package/dist/ui/top-left/styles.css.d.ts +8 -0
  162. package/dist/ui/top-left/styles.css.js +17 -0
  163. package/dist/utils/types.d.ts +8 -0
  164. package/dist/utils/vector.d.ts +24 -0
  165. package/dist/utils/vector.js +55 -0
  166. package/dist/xyflow/EdgeMarkers.d.ts +12 -0
  167. package/dist/xyflow/EdgeMarkers.js +192 -0
  168. package/dist/xyflow/FitviewOnDiagramChange.d.ts +4 -0
  169. package/dist/xyflow/FitviewOnDiagramChange.js +72 -0
  170. package/dist/xyflow/SelectEdgesOnNodeFocus.d.ts +1 -0
  171. package/dist/xyflow/SelectEdgesOnNodeFocus.js +96 -0
  172. package/dist/xyflow/XYFlow.d.ts +8 -0
  173. package/dist/xyflow/XYFlow.js +145 -0
  174. package/dist/xyflow/XYFlowBackground.d.ts +10 -0
  175. package/dist/xyflow/XYFlowBackground.js +25 -0
  176. package/dist/xyflow/XYFlowInner.d.ts +8 -0
  177. package/dist/xyflow/XYFlowInner.js +41 -0
  178. package/dist/xyflow/const.d.ts +7 -0
  179. package/dist/xyflow/const.js +12 -0
  180. package/dist/xyflow/edges/EdgeLabel.d.ts +7 -0
  181. package/dist/xyflow/edges/EdgeLabel.js +160 -0
  182. package/dist/xyflow/edges/RelationshipEdge.d.ts +6 -0
  183. package/dist/xyflow/edges/RelationshipEdge.js +443 -0
  184. package/dist/xyflow/edges/RelationshipsDropdownMenu.css.d.ts +4 -0
  185. package/dist/xyflow/edges/RelationshipsDropdownMenu.css.js +11 -0
  186. package/dist/xyflow/edges/RelationshipsDropdownMenu.d.ts +13 -0
  187. package/dist/xyflow/edges/RelationshipsDropdownMenu.js +211 -0
  188. package/dist/xyflow/edges/edges.css.d.ts +17 -0
  189. package/dist/xyflow/edges/edges.css.js +37 -0
  190. package/dist/xyflow/edges/utils.d.ts +16 -0
  191. package/dist/xyflow/edges/utils.js +24 -0
  192. package/dist/xyflow/nodes/AnimateVariants.d.ts +1313 -0
  193. package/dist/xyflow/nodes/AnimateVariants.js +123 -0
  194. package/dist/xyflow/nodes/Node.css.d.ts +3 -0
  195. package/dist/xyflow/nodes/Node.css.js +9 -0
  196. package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +14 -0
  197. package/dist/xyflow/nodes/compound/CompoundNode.css.js +27 -0
  198. package/dist/xyflow/nodes/compound/CompoundNode.d.ts +6 -0
  199. package/dist/xyflow/nodes/compound/CompoundNode.js +216 -0
  200. package/dist/xyflow/nodes/compound/index.d.ts +1 -0
  201. package/dist/xyflow/nodes/element/ElementLink.css.d.ts +3 -0
  202. package/dist/xyflow/nodes/element/ElementLink.d.ts +6 -0
  203. package/dist/xyflow/nodes/element/ElementNode.d.ts +6 -0
  204. package/dist/xyflow/nodes/element/ElementNode.js +190 -0
  205. package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +17 -0
  206. package/dist/xyflow/nodes/element/ElementShapeSvg.js +175 -0
  207. package/dist/xyflow/nodes/element/element.css.d.ts +18 -0
  208. package/dist/xyflow/nodes/element/element.css.js +31 -0
  209. package/dist/xyflow/nodes/element/index.d.ts +1 -0
  210. package/dist/xyflow/nodes/shared/ElementIcon.d.ts +8 -0
  211. package/dist/xyflow/nodes/shared/ElementIcon.js +38 -0
  212. package/dist/xyflow/nodes/shared/Toolbar.d.ts +9 -0
  213. package/dist/xyflow/nodes/shared/Toolbar.js +436 -0
  214. package/dist/xyflow/types.d.ts +36 -0
  215. package/dist/xyflow/useLayoutConstraints.d.ts +42 -0
  216. package/dist/xyflow/useLayoutConstraints.js +226 -0
  217. package/dist/xyflow/useXYFlowEvents.d.ts +160 -0
  218. package/dist/xyflow/useXYFlowEvents.js +275 -0
  219. package/dist/xyflow/utils.d.ts +22 -0
  220. package/dist/xyflow/utils.js +72 -0
  221. package/package.json +34 -27
  222. package/src/LikeC4Diagram.tsx +4 -4
  223. package/src/LikeC4Search.css.ts +12 -0
  224. package/src/LikeC4Search.tsx +39 -90
  225. package/src/controls/Text.ts +5 -0
  226. package/src/controls/action-button-bar/ActionButtonBar.css.ts +13 -0
  227. package/src/controls/action-button-bar/ActionButtonBar.tsx +138 -0
  228. package/src/controls/action-button-bar/useActionButtonBarCtx.ts +13 -0
  229. package/src/controls/action-buttons/ActionButton.css.ts +29 -0
  230. package/src/controls/action-buttons/ActionButton.tsx +66 -0
  231. package/src/controls/action-buttons/ActionButtons.tsx +138 -0
  232. package/src/hooks/useXYFlow.ts +8 -8
  233. package/src/index.ts +12 -6
  234. package/src/likec4model/index.ts +12 -2
  235. package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -12
  236. package/src/overlays/edge-details/_types.ts +13 -37
  237. package/src/overlays/edge-details/use-layouted-edge-details.ts +16 -14
  238. package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
  239. package/src/overlays/edge-details/xyflow/ElementNode.tsx +4 -11
  240. package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +3 -3
  241. package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
  242. package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +23 -23
  243. package/src/overlays/relationships-of/_types.ts +20 -58
  244. package/src/overlays/relationships-of/use-layouted-relationships.ts +36 -40
  245. package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +9 -13
  246. package/src/overlays/relationships-of/xyflow/ElementNode.tsx +12 -15
  247. package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
  248. package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -14
  249. package/src/overlays/shared/xyflow/RelationshipEdge.css.ts +60 -0
  250. package/src/overlays/shared/xyflow/_types.ts +87 -0
  251. package/src/state/diagram-to-xyflow.ts +6 -7
  252. package/src/state/diagramStore.layout.ts +3 -4
  253. package/src/state/diagramStore.ts +35 -37
  254. package/src/theme-vars.css.ts +81 -0
  255. package/src/theme-vars.ts +8 -81
  256. package/src/ui/DiagramTitlePanel.tsx +6 -6
  257. package/src/utils/types.ts +6 -0
  258. package/src/xyflow/SelectEdgesOnNodeFocus.tsx +3 -3
  259. package/src/xyflow/XYFlow.tsx +2 -2
  260. package/src/xyflow/edges/EdgeLabel.tsx +25 -18
  261. package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
  262. package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +3 -3
  263. package/src/xyflow/edges/edges.css.ts +68 -74
  264. package/src/xyflow/edges/utils.ts +6 -6
  265. package/src/xyflow/nodes/AnimateVariants.ts +143 -0
  266. package/src/xyflow/nodes/Node.css.ts +44 -0
  267. package/src/xyflow/nodes/compound/CompoundNode.css.ts +1 -64
  268. package/src/xyflow/nodes/compound/CompoundNode.tsx +69 -182
  269. package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
  270. package/src/xyflow/nodes/element/ElementNode.tsx +64 -266
  271. package/src/xyflow/nodes/element/element.css.ts +0 -57
  272. package/src/xyflow/nodes/shared/Toolbar.tsx +30 -30
  273. package/src/xyflow/types.ts +48 -51
  274. package/src/xyflow/useLayoutConstraints.ts +9 -9
  275. package/src/xyflow/useXYFlowEvents.ts +13 -30
  276. package/src/xyflow/utils.ts +2 -2
  277. 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,5 @@
1
+ import { DiagramEdge, DiagramView } from '@likec4/core';
2
+ export declare const SelectEdge: ({ edge, view }: {
3
+ edge: DiagramEdge;
4
+ view: DiagramView;
5
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -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 {};