@likec4/diagram 1.17.1 → 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 (300) 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 +40 -31
  222. package/src/LikeC4Diagram.props.ts +21 -12
  223. package/src/LikeC4Diagram.tsx +8 -10
  224. package/src/LikeC4Search.css.ts +12 -0
  225. package/src/LikeC4Search.tsx +45 -93
  226. package/src/controls/Text.ts +5 -0
  227. package/src/controls/action-button-bar/ActionButtonBar.css.ts +13 -0
  228. package/src/controls/action-button-bar/ActionButtonBar.tsx +138 -0
  229. package/src/controls/action-button-bar/useActionButtonBarCtx.ts +13 -0
  230. package/src/controls/action-buttons/ActionButton.css.ts +29 -0
  231. package/src/controls/action-buttons/ActionButton.tsx +66 -0
  232. package/src/controls/action-buttons/ActionButtons.tsx +138 -0
  233. package/src/hooks/useDiagramState.ts +8 -3
  234. package/src/hooks/useXYFlow.ts +9 -8
  235. package/src/index.ts +12 -6
  236. package/src/likec4model/index.ts +12 -2
  237. package/src/likec4model/useLikeC4ElementsTree.ts +6 -13
  238. package/src/likec4model/useLikeC4Model.ts +21 -11
  239. package/src/overlays/Overlays.tsx +96 -63
  240. package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -10
  241. package/src/overlays/edge-details/_types.ts +13 -33
  242. package/src/overlays/edge-details/use-layouted-edge-details.ts +35 -26
  243. package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
  244. package/src/overlays/edge-details/xyflow/ElementNode.tsx +8 -13
  245. package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +7 -7
  246. package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
  247. package/src/overlays/element-details/ElementDetailsCard.tsx +91 -78
  248. package/src/overlays/element-details/TabPanelDeployments.css.ts +69 -0
  249. package/src/overlays/element-details/TabPanelDeployments.tsx +217 -0
  250. package/src/overlays/element-details/TabPanelRelationships.tsx +8 -9
  251. package/src/overlays/element-details/TabPanelStructure.tsx +10 -10
  252. package/src/overlays/relationships-of/RelationshipsOverlay.tsx +1 -1
  253. package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +26 -34
  254. package/src/overlays/relationships-of/SelectElement.tsx +2 -2
  255. package/src/overlays/relationships-of/_types.ts +20 -58
  256. package/src/overlays/relationships-of/use-layouted-relationships.ts +54 -59
  257. package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +10 -16
  258. package/src/overlays/relationships-of/xyflow/ElementNode.tsx +24 -21
  259. package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
  260. package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -15
  261. package/src/overlays/shared/xyflow/RelationshipEdge.css.ts +60 -0
  262. package/src/overlays/shared/xyflow/_types.ts +87 -0
  263. package/src/state/diagram-to-xyflow.ts +6 -7
  264. package/src/state/diagramStore.layout.ts +3 -4
  265. package/src/state/diagramStore.ts +63 -48
  266. package/src/theme-vars.css.ts +81 -0
  267. package/src/theme-vars.ts +8 -81
  268. package/src/ui/DiagramTitlePanel.tsx +7 -34
  269. package/src/ui/Link.tsx +40 -0
  270. package/src/ui/notation/NotationPanel.tsx +4 -2
  271. package/src/ui/top-left/ChangeAutoLayoutButton.tsx +2 -2
  272. package/src/ui/top-left/TopLeftPanel.tsx +5 -5
  273. package/src/utils/types.ts +6 -0
  274. package/src/xyflow/SelectEdgesOnNodeFocus.tsx +3 -3
  275. package/src/xyflow/XYFlow.tsx +2 -2
  276. package/src/xyflow/edges/EdgeLabel.tsx +26 -19
  277. package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
  278. package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +23 -10
  279. package/src/xyflow/edges/edges.css.ts +68 -74
  280. package/src/xyflow/edges/utils.ts +6 -6
  281. package/src/xyflow/nodes/AnimateVariants.ts +143 -0
  282. package/src/xyflow/nodes/Node.css.ts +44 -0
  283. package/src/xyflow/nodes/compound/CompoundNode.css.ts +27 -75
  284. package/src/xyflow/nodes/compound/CompoundNode.tsx +82 -163
  285. package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
  286. package/src/xyflow/nodes/element/ElementNode.tsx +73 -252
  287. package/src/xyflow/nodes/element/element.css.ts +40 -64
  288. package/src/xyflow/nodes/shared/ElementIcon.tsx +1 -1
  289. package/src/xyflow/nodes/shared/Toolbar.tsx +51 -35
  290. package/src/xyflow/types.ts +48 -51
  291. package/src/xyflow/useLayoutConstraints.ts +10 -10
  292. package/src/xyflow/useXYFlowEvents.ts +31 -35
  293. package/src/xyflow/utils.ts +2 -2
  294. package/src/ui/OptionsPanel.css.ts +0 -9
  295. package/src/ui/OptionsPanel.tsx +0 -70
  296. package/src/ui/options/EdgeOptions.tsx +0 -142
  297. package/src/ui/options/NodeOptions.tsx +0 -362
  298. package/src/xyflow/nodes/element/ElementDetails.css.ts +0 -101
  299. package/src/xyflow/nodes/element/ElementDetails.tsx +0 -393
  300. package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
@@ -7,27 +7,27 @@ import * as css from './TabPanelStructure.css'
7
7
  interface ElementTreeNodeData {
8
8
  label: ReactNode
9
9
  value: string
10
- element: LikeC4Model.ElementModel
10
+ element: LikeC4Model.Element
11
11
  type: 'ancestor' | 'current' | 'descedant'
12
12
  children: TreeNodeData[]
13
13
  }
14
14
 
15
- interface MessageNodeData {
15
+ export interface MessageNodeData {
16
16
  label: ReactNode
17
17
  value: string
18
18
  type: 'message'
19
19
  children: TreeNodeData[]
20
20
  }
21
21
 
22
- type TreeNodeData = ElementTreeNodeData | MessageNodeData
22
+ export type TreeNodeData = ElementTreeNodeData | MessageNodeData
23
23
 
24
- type TabElementStructureProps = {
25
- element: LikeC4Model.ElementModel
24
+ type TabPanelStructureProps = {
25
+ element: LikeC4Model.Element
26
26
  }
27
27
 
28
- const ElementLabel = ({
28
+ export const ElementLabel = ({
29
29
  element
30
- }: { element: LikeC4Model.ElementModel; type: 'ancestor' | 'current' | 'descedant' }) => (
30
+ }: { element: LikeC4Model.Element; type: 'ancestor' | 'current' | 'descedant' }) => (
31
31
  <Box className={css.elementLabel}>
32
32
  <Text component="div" fz={'sm'} fw={'500'}>{element.title}</Text>
33
33
  </Box>
@@ -38,9 +38,9 @@ const ElementLabel = ({
38
38
  // }: RenderTreeNodePayload) => {
39
39
  // }
40
40
 
41
- export function TabElementStructure({
41
+ export function TabPanelStructure({
42
42
  element
43
- }: TabElementStructureProps) {
43
+ }: TabPanelStructureProps) {
44
44
  const tree = useTree({
45
45
  multiple: false
46
46
  })
@@ -60,7 +60,7 @@ export function TabElementStructure({
60
60
  value: element.id,
61
61
  element,
62
62
  type: 'current',
63
- children: element.children().map((child): TreeNodeData => ({
63
+ children: [...element.children()].map((child): TreeNodeData => ({
64
64
  label: <ElementLabel type="descedant" element={child} />,
65
65
  value: child.id,
66
66
  element: child,
@@ -93,7 +93,7 @@ export const RelationshipsOverlay = memo<{ subjectId: Fqn }>(function Relationsh
93
93
  <Box flex={'1 0 auto'}>
94
94
  <SelectElement
95
95
  scope={scope}
96
- subject={subject.element}
96
+ subject={subject.$element}
97
97
  onSelect={fqn =>
98
98
  overlay.openOverlay({
99
99
  relationshipsOf: fqn
@@ -1,13 +1,8 @@
1
- import { delay, type DiagramView, type Fqn, isAncestor, type Relation } from '@likec4/core'
2
- import { Box, Button, Group, SegmentedControl, Space, Text } from '@mantine/core'
3
- import { useId, useLocalStorage, useStateHistory } from '@mantine/hooks'
1
+ import { type AbstractRelation, delay, type DiagramView, type Fqn, isAncestor } from '@likec4/core'
2
+ import { useId } from '@mantine/hooks'
4
3
  import { useDebouncedCallback, useDeepCompareEffect, useSyncedRef } from '@react-hookz/web'
5
- import { IconArrowLeft, IconArrowRight } from '@tabler/icons-react'
6
4
  import {
7
- Background,
8
- BackgroundVariant,
9
5
  getViewportForBounds,
10
- Panel,
11
6
  ReactFlow,
12
7
  type ReactFlowInstance,
13
8
  type ReactFlowProps,
@@ -19,16 +14,13 @@ import {
19
14
  useStoreApi
20
15
  } from '@xyflow/react'
21
16
  import { getNodeDimensions } from '@xyflow/system'
22
- import { memo, type PropsWithChildren, useEffect, useRef, useState } from 'react'
17
+ import { type PropsWithChildren, useRef, useState } from 'react'
23
18
  import { isNullish, map, omit, only, prop, setPath, unique } from 'remeda'
24
19
  import { useUpdateEffect } from '../../hooks'
25
- import { useDiagramStoreApi } from '../../hooks/useDiagramState'
26
20
  import { centerXYInternalNode } from '../../xyflow/utils'
27
- import { useOverlayDialog } from '../OverlayContext'
28
21
  import { cssReactflowMarker } from '../Overlays.css'
29
- import type { XYFlowTypes } from './_types'
30
- import { SelectElement } from './SelectElement'
31
- import { useLayoutedRelationships, ZIndexes } from './use-layouted-relationships'
22
+ import type { RelationshipsOfFlowTypes } from './_types'
23
+ import { ZIndexes } from './use-layouted-relationships'
32
24
  import { CompoundNode } from './xyflow/CompoundNode'
33
25
  import { ElementNode } from './xyflow/ElementNode'
34
26
  import { EmptyNode } from './xyflow/EmptyNode'
@@ -46,10 +38,10 @@ const edgeTypes = {
46
38
  /**
47
39
  * Root node in 'subjects' column
48
40
  */
49
- const findRootSubject = (nodes: XYFlowTypes.Node[]) =>
50
- nodes.find((n): n is XYFlowTypes.ElementNode => n.data.column === 'subjects' && isNullish(n.parentId))
41
+ const findRootSubject = (nodes: RelationshipsOfFlowTypes.Node[]) =>
42
+ nodes.find((n): n is RelationshipsOfFlowTypes.ElementNode => n.data.column === 'subjects' && isNullish(n.parentId))
51
43
 
52
- const resetDimmedAndHovered = (xyflow: ReactFlowInstance<XYFlowTypes.Node, XYFlowTypes.Edge>) => {
44
+ const resetDimmedAndHovered = (xyflow: ReactFlowInstance<RelationshipsOfFlowTypes.Node, RelationshipsOfFlowTypes.Edge>) => {
53
45
  xyflow.setEdges(edges =>
54
46
  edges.map(edge => ({
55
47
  ...edge,
@@ -70,12 +62,12 @@ const resetDimmedAndHovered = (xyflow: ReactFlowInstance<XYFlowTypes.Node, XYFlo
70
62
  dimmed: false,
71
63
  hovered: false
72
64
  }
73
- }) as XYFlowTypes.Node
65
+ }) as RelationshipsOfFlowTypes.Node
74
66
  )
75
67
  )
76
68
  }
77
69
 
78
- const animateEdge = (node: XYFlowTypes.Node, animated = true) => (edges: XYFlowTypes.Edge[]) => {
70
+ const animateEdge = (node: RelationshipsOfFlowTypes.Node, animated = true) => (edges: RelationshipsOfFlowTypes.Edge[]) => {
79
71
  return edges.map(edge => {
80
72
  const isConnected = edge.source === node.id || edge.target === node.id || isAncestor(node.id, edge.source)
81
73
  || isAncestor(node.id, edge.target)
@@ -86,10 +78,10 @@ const animateEdge = (node: XYFlowTypes.Node, animated = true) => (edges: XYFlowT
86
78
  })
87
79
  }
88
80
 
89
- const onlyOneUnique = <T extends keyof Relation>(
90
- data: XYFlowTypes.Edge['data'],
81
+ const onlyOneUnique = <T extends keyof AbstractRelation>(
82
+ data: RelationshipsOfFlowTypes.Edge['data'],
91
83
  property: T
92
- ): Relation[T] | undefined => {
84
+ ): AbstractRelation[T] | undefined => {
93
85
  return only(unique(map(data.relations, prop(property))))
94
86
  }
95
87
 
@@ -97,8 +89,8 @@ type RelationshipsXYFlowProps =
97
89
  & PropsWithChildren<{
98
90
  subjectId: Fqn
99
91
  view: DiagramView
100
- nodes: XYFlowTypes.Node[]
101
- edges: XYFlowTypes.Edge[]
92
+ nodes: RelationshipsOfFlowTypes.Node[]
93
+ edges: RelationshipsOfFlowTypes.Edge[]
102
94
  bounds: {
103
95
  x: number
104
96
  y: number
@@ -108,7 +100,7 @@ type RelationshipsXYFlowProps =
108
100
  viewportPadding?: number | undefined
109
101
  }>
110
102
  & Pick<
111
- ReactFlowProps<XYFlowTypes.Node, XYFlowTypes.Edge>,
103
+ ReactFlowProps<RelationshipsOfFlowTypes.Node, RelationshipsOfFlowTypes.Edge>,
112
104
  | 'onNodeClick'
113
105
  | 'elementsSelectable'
114
106
  | 'maxZoom'
@@ -130,10 +122,10 @@ function RelationshipsXYFlowWrapped({
130
122
  }: RelationshipsXYFlowProps) {
131
123
  const id = useId()
132
124
 
133
- const lastClickedNodeRef = useRef<XYFlowTypes.NonEmptyNode | null>(null)
125
+ const lastClickedNodeRef = useRef<RelationshipsOfFlowTypes.NonEmptyNode | null>(null)
134
126
 
135
- const xyflow = useReactFlow<XYFlowTypes.Node, XYFlowTypes.Edge>()
136
- const xystore = useStoreApi<XYFlowTypes.Node, XYFlowTypes.Edge>()
127
+ const xyflow = useReactFlow<RelationshipsOfFlowTypes.Node, RelationshipsOfFlowTypes.Edge>()
128
+ const xystore = useStoreApi<RelationshipsOfFlowTypes.Node, RelationshipsOfFlowTypes.Edge>()
137
129
 
138
130
  const [zoomOnDoubleClick, setZoomOnDoubleClick] = useState(true)
139
131
 
@@ -191,7 +183,7 @@ function RelationshipsXYFlowWrapped({
191
183
 
192
184
  // If subject node is the same, don't animate
193
185
  if (currentSubjectNode && nextSubjectNode?.data.fqn === currentSubjectNode.data.fqn) {
194
- setNodes(map(nodes, setPath(['data', 'initialAnimation'], false)))
186
+ setNodes(map(nodes, setPath(['data', 'entering'], false)))
195
187
  setEdges(edges)
196
188
  fitview()
197
189
  return
@@ -235,7 +227,7 @@ function RelationshipsXYFlowWrapped({
235
227
  dimmed: n.data.column === 'subjects' ? 'immediate' : false
236
228
  }
237
229
  // hidden: n.data.column === 'subjects'
238
- } as XYFlowTypes.Node
230
+ } as RelationshipsOfFlowTypes.Node
239
231
  }
240
232
  // Move existing node
241
233
  return {
@@ -250,7 +242,7 @@ function RelationshipsXYFlowWrapped({
250
242
  leaving: false,
251
243
  dimmed: false
252
244
  }
253
- } as XYFlowTypes.Node
245
+ } as RelationshipsOfFlowTypes.Node
254
246
  }))
255
247
  setEdges(_edges.map(e => ({
256
248
  ...e,
@@ -290,7 +282,7 @@ function RelationshipsXYFlowWrapped({
290
282
  isCancelled = true
291
283
  }
292
284
  }
293
- setNodes(map(nodes, setPath(['data', 'initialAnimation'], false)))
285
+ setNodes(map(nodes, setPath(['data', 'entering'], false)))
294
286
  setEdges(edges)
295
287
  fitview()
296
288
  return undefined
@@ -299,8 +291,8 @@ function RelationshipsXYFlowWrapped({
299
291
  return (
300
292
  <ReactFlow
301
293
  id={id}
302
- defaultEdges={[] as XYFlowTypes.Edge[]}
303
- defaultNodes={[] as XYFlowTypes.Node[]}
294
+ defaultEdges={[] as RelationshipsOfFlowTypes.Edge[]}
295
+ defaultNodes={[] as RelationshipsOfFlowTypes.Node[]}
304
296
  nodeTypes={nodeTypes}
305
297
  edgeTypes={edgeTypes}
306
298
  defaultMarkerColor="var(--likec4-relation-lineColor)"
@@ -352,7 +344,7 @@ function RelationshipsXYFlowWrapped({
352
344
  ...n.data,
353
345
  dimmed: n.id !== edge.source && n.id !== edge.target
354
346
  }
355
- } as XYFlowTypes.Node))
347
+ } as RelationshipsOfFlowTypes.Node))
356
348
  )
357
349
  }}
358
350
  onEdgeMouseLeave={() => {
@@ -1,4 +1,4 @@
1
- import { ancestorsFqn, type Element, type Fqn, type ViewID } from '@likec4/core'
1
+ import { ancestorsFqn, type Element, type Fqn, type ViewId } from '@likec4/core'
2
2
  import {
3
3
  ActionIcon,
4
4
  Box,
@@ -25,7 +25,7 @@ export const SelectElement = ({
25
25
  onSelect
26
26
  }: {
27
27
  subject: Element
28
- viewId: ViewID
28
+ viewId: ViewId
29
29
  scope: 'global' | 'view'
30
30
  onSelect: (id: Fqn) => void
31
31
  }) => {
@@ -1,78 +1,40 @@
1
- import type { ComputedNode, Fqn, Relation, ViewID } from '@likec4/core'
2
- import type {
3
- Edge as ReactFlowEdge,
4
- InternalNode as ReactFlowInternalNode,
5
- Node as ReactFlowNode,
6
- ReactFlowInstance
7
- } from '@xyflow/react'
8
- import type { SetRequired } from 'type-fest'
1
+ import type { AddEdgeData, AddNodeData } from '../../utils/types'
2
+ import type { SharedFlowTypes } from '../shared/xyflow/_types'
3
+
4
+ export namespace RelationshipsOfFlowTypes {
9
5
 
10
- export namespace XYFlowTypes {
11
6
  /**
12
- * Handle in ReactFlow terms
7
+ * Data that is exclusive to the relationships-of overlay. It will be merged into the node types
8
+ * provided by SharedFlowTypes.
13
9
  */
14
- export type Port = {
15
- id: string
16
- type: 'in' | 'out'
17
- }
18
-
19
- type NodeProps = {
10
+ type RelationshipsOfNodeData = {
20
11
  depth?: number
21
12
  column: 'incomers' | 'subjects' | 'outgoers'
22
- fqn: Fqn
23
13
  existsInCurrentView: boolean
24
- element: Pick<ComputedNode, 'color' | 'title' | 'description' | 'shape' | 'kind'>
25
- ports: {
26
- left: Port[]
27
- right: Port[]
28
- }
29
- navigateTo: ViewID | null
30
- hovered?: boolean
31
14
  layoutId?: string
32
- leaving?: boolean
33
- /**
34
- * @default true
35
- */
36
- initialAnimation?: boolean
37
- /**
38
- * Whether the node is dimmed
39
- * 'immediate' means that the node is dimmed without delay
40
- */
41
- dimmed?: 'immediate' | boolean
42
15
  }
43
16
 
44
- export type ElementNode = SetRequired<ReactFlowNode<NodeProps, 'element'>, 'type'>
17
+ // Extend the node types provided by SharedFlowTypes with RelationshipsOfNodeData
18
+
19
+ export type ElementNode = AddNodeData<SharedFlowTypes.ElementNode, RelationshipsOfNodeData>
45
20
 
46
- export type CompoundNode = SetRequired<ReactFlowNode<NodeProps, 'compound'>, 'type'>
21
+ export type CompoundNode = AddNodeData<SharedFlowTypes.CompoundNode, RelationshipsOfNodeData>
47
22
 
48
23
  export type NonEmptyNode = ElementNode | CompoundNode
49
24
 
50
- export type EmptyNode = SetRequired<
51
- ReactFlowNode<{
52
- column: 'incomers' | 'subjects' | 'outgoers'
53
- hovered?: boolean
54
- dimmed?: boolean
55
- /**
56
- * @default true
57
- */
58
- initialAnimation?: boolean
59
- }, 'empty'>,
60
- 'type'
61
- >
25
+ export type EmptyNode = AddNodeData<SharedFlowTypes.EmptyNode, RelationshipsOfNodeData>
62
26
 
63
27
  export type Node = NonEmptyNode | EmptyNode
64
28
 
65
- export type Edge = Omit<ReactFlowEdge, 'data' | 'type'> & {
66
- data: {
67
- relations: [Relation, ...Relation[]]
68
- includedInCurrentView: boolean
69
- hovered?: boolean
70
- dimmed?: 'immediate' | boolean
71
- }
72
- type: 'relation'
29
+ /**
30
+ * Data that is exclusive to the relationships-of overlay. It will be merged into the edge types
31
+ * provided by SharedFlowTypes.
32
+ */
33
+ type RelationshipsOfEdgeData = {
34
+ existsInCurrentView: boolean
73
35
  }
74
36
 
75
- export type Instance = ReactFlowInstance<Node, Edge>
37
+ // Extend the edge types provided by SharedFlowTypes with RelationshipsOfEdgeData
76
38
 
77
- export type InternalNode = ReactFlowInternalNode<Node>
39
+ export type Edge = AddEdgeData<SharedFlowTypes.Edge, RelationshipsOfEdgeData>
78
40
  }
@@ -11,7 +11,7 @@ import {
11
11
  type LikeC4Model,
12
12
  nonNullable,
13
13
  parentFqn,
14
- type RelationID
14
+ type RelationId
15
15
  } from '@likec4/core'
16
16
  import { MarkerType } from '@xyflow/system'
17
17
  import { useMemo } from 'react'
@@ -38,7 +38,7 @@ import {
38
38
  tap
39
39
  } from 'remeda'
40
40
  import { useLikeC4Model } from '../../likec4model'
41
- import type { XYFlowTypes } from './_types'
41
+ import type { RelationshipsOfFlowTypes } from './_types'
42
42
 
43
43
  const columns = ['incomers', 'subjects', 'outgoers'] as const
44
44
  type ColumnKey = typeof columns[number]
@@ -118,15 +118,12 @@ function createGraph() {
118
118
  return g
119
119
  }
120
120
 
121
- type LikeC4ModelElement = LikeC4Model.ElementModel
122
- // type LikeC4ModelElement = LikeC4ViewModel.Element
123
-
124
121
  type Context = {
125
122
  scope: 'global' | 'view'
126
123
  g: dagre.graphlib.Graph
127
124
  subjectId: Fqn
128
125
  diagramNodes: Map<Fqn, DiagramNode>
129
- subjectElement: LikeC4ModelElement
126
+ subjectElement: LikeC4Model.Element
130
127
  // likec4model: LikeC4Model
131
128
  // subject: XYFlowTypes.ElementNode
132
129
  // Model
@@ -137,11 +134,11 @@ type Context = {
137
134
  outgoers: Set<Fqn>
138
135
  }
139
136
  columns: {
140
- incomers: Map<Fqn, XYFlowTypes.Node>
141
- subjects: Map<Fqn, XYFlowTypes.Node>
142
- outgoers: Map<Fqn, XYFlowTypes.Node>
137
+ incomers: Map<Fqn, RelationshipsOfFlowTypes.Node>
138
+ subjects: Map<Fqn, RelationshipsOfFlowTypes.Node>
139
+ outgoers: Map<Fqn, RelationshipsOfFlowTypes.Node>
143
140
  }
144
- edges: XYFlowTypes.Edge[]
141
+ edges: RelationshipsOfFlowTypes.Edge[]
145
142
  }
146
143
 
147
144
  const sized = (height: number = Sizes.hodeHeight) => ({
@@ -149,7 +146,7 @@ const sized = (height: number = Sizes.hodeHeight) => ({
149
146
  height
150
147
  })
151
148
 
152
- const graphId = (node: XYFlowTypes.Node) => ({
149
+ const graphId = (node: RelationshipsOfFlowTypes.Node) => ({
153
150
  id: node.id,
154
151
  port: node.type === 'compound' ? `${node.id}::port` : node.id,
155
152
  body: `${node.id}`,
@@ -157,9 +154,9 @@ const graphId = (node: XYFlowTypes.Node) => ({
157
154
  })
158
155
 
159
156
  function nodeData(
160
- element: LikeC4Model.ElementModel,
157
+ element: LikeC4Model.Element,
161
158
  ctx: Context
162
- ): Omit<XYFlowTypes.NonEmptyNode['data'], 'column'> {
159
+ ): Omit<RelationshipsOfFlowTypes.NonEmptyNode['data'], 'column'> {
163
160
  // We try to inherit style from existing diagram node
164
161
  let diagramNode = ctx.diagramNodes.get(element.id)
165
162
 
@@ -167,7 +164,7 @@ function nodeData(
167
164
  // color from it if there is no diagram node
168
165
  const ancestor = diagramNode ?? (ctx.scope === 'view'
169
166
  ? pipe(
170
- element.ancestors(),
167
+ element.ancestors().toArray(),
171
168
  map(ancestor => ctx.diagramNodes.get(ancestor.id)),
172
169
  filter(isTruthy),
173
170
  first()
@@ -180,14 +177,14 @@ function nodeData(
180
177
  element: {
181
178
  kind: element.kind,
182
179
  title: diagramNode?.title ?? element.title,
183
- description: diagramNode?.description ?? element.element.description,
180
+ description: diagramNode?.description ?? element.description,
184
181
  color: diagramNode?.color ?? ancestor?.color ?? element.color,
185
182
  shape: diagramNode?.shape ?? element.shape
186
183
  },
187
- navigateTo: diagramNode?.navigateTo ?? first(element.viewsOf())?.id ?? null,
184
+ navigateTo: diagramNode?.navigateTo ?? element.defaultView?.id ?? null,
188
185
  ports: {
189
- left: [],
190
- right: []
186
+ in: [],
187
+ out: []
191
188
  }
192
189
  }
193
190
  }
@@ -195,7 +192,7 @@ function nodeData(
195
192
  function createEmptyNode(
196
193
  column: ColumnKey,
197
194
  ctx: Context
198
- ): XYFlowTypes.EmptyNode {
195
+ ): RelationshipsOfFlowTypes.EmptyNode {
199
196
  const id = `${column}__empty` as Fqn
200
197
  const xynodes = ctx.columns[column]
201
198
  let node = xynodes.get(id)
@@ -203,12 +200,13 @@ function createEmptyNode(
203
200
  invariant(node.type === 'empty', 'Node is not empty')
204
201
  return node
205
202
  }
206
- const xynode: XYFlowTypes.EmptyNode = {
203
+ const xynode: RelationshipsOfFlowTypes.EmptyNode = {
207
204
  type: 'empty',
208
205
  id,
209
206
  position: { x: 0, y: 0 },
210
207
  data: {
211
- column
208
+ column,
209
+ existsInCurrentView: true
212
210
  },
213
211
  zIndex: ZIndexes.empty
214
212
  }
@@ -227,11 +225,11 @@ function createEmptyNode(
227
225
 
228
226
  function createNode(
229
227
  column: ColumnKey,
230
- nodeType: Exclude<XYFlowTypes.Node['type'], 'empty'>,
231
- element: LikeC4Model.ElementModel,
228
+ nodeType: Exclude<RelationshipsOfFlowTypes.Node['type'], 'empty'>,
229
+ element: LikeC4Model.Element,
232
230
  ctx: Context,
233
231
  depth: number = 0
234
- ): XYFlowTypes.ElementNode | XYFlowTypes.CompoundNode {
232
+ ): RelationshipsOfFlowTypes.ElementNode | RelationshipsOfFlowTypes.CompoundNode {
235
233
  const xynodes = ctx.columns[column]
236
234
  let node = xynodes.get(element.id)
237
235
  if (node) {
@@ -245,7 +243,7 @@ function createNode(
245
243
 
246
244
  // Create parent node
247
245
  const parent = pipe(
248
- element.ancestors(),
246
+ element.ancestors().toArray(),
249
247
  takeWhile(ancestor => !isAncestor(ancestor.id, ctx.subjectId)),
250
248
  find(ancestor =>
251
249
  ctx.diagramNodes.has(ancestor.id) || ctx.connected[column].has(ancestor.id)
@@ -254,7 +252,7 @@ function createNode(
254
252
  found => found ? createNode(column, 'compound', found, ctx, depth + 2) : null
255
253
  )
256
254
 
257
- const xynode: XYFlowTypes.NonEmptyNode = {
255
+ const xynode: RelationshipsOfFlowTypes.NonEmptyNode = {
258
256
  type: nodeType,
259
257
  id: `${column}::${element.id}`,
260
258
  position: { x: 0, y: 0 },
@@ -292,7 +290,7 @@ function createNode(
292
290
  * And return a function to get node bounds for xyflow
293
291
  */
294
292
  function applyDagreLayout(g: dagre.graphlib.Graph) {
295
- type NodeBounds = Required<Pick<XYFlowTypes.Node, 'position' | 'width' | 'height'>>
293
+ type NodeBounds = Required<Pick<RelationshipsOfFlowTypes.Node, 'position' | 'width' | 'height'>>
296
294
  dagre.layout(g)
297
295
  return function nodeBounds(nodeId: string): NodeBounds {
298
296
  const { x, y, width, height } = g.node(nodeId)
@@ -310,18 +308,18 @@ function applyDagreLayout(g: dagre.graphlib.Graph) {
310
308
  function addEdge(
311
309
  ctx: Context,
312
310
  props: {
313
- includedInCurrentView: boolean
311
+ existsInCurrentView: boolean
314
312
  source: string
315
313
  target: string
316
- relations: XYFlowTypes.Edge['data']['relations']
314
+ relations: RelationshipsOfFlowTypes.Edge['data']['relations']
317
315
  }
318
316
  ) {
319
- const { source, target, relations, includedInCurrentView } = props
317
+ const { source, target, relations, existsInCurrentView } = props
320
318
  const ids = relations.map(r => r.id).join('_')
321
319
  const label = only(relations)?.title ?? 'untitled'
322
320
 
323
321
  const isMultiple = relations.length > 1
324
- const edge: XYFlowTypes.Edge = {
322
+ const edge: RelationshipsOfFlowTypes.Edge = {
325
323
  id: `rel${ctx.edges.length + 1}_${ids}`,
326
324
  type: 'relation',
327
325
  source,
@@ -329,7 +327,7 @@ function addEdge(
329
327
  sourceHandle: target,
330
328
  targetHandle: source,
331
329
  data: {
332
- includedInCurrentView,
330
+ existsInCurrentView: existsInCurrentView,
333
331
  relations
334
332
  },
335
333
  label: isMultiple ? `${relations.length} relationships` : label,
@@ -363,9 +361,9 @@ function layout(
363
361
  ): {
364
362
  viewIncludesSubject: boolean
365
363
  notIncludedRelations: number
366
- subject: LikeC4ModelElement
367
- nodes: XYFlowTypes.Node[]
368
- edges: XYFlowTypes.Edge[]
364
+ subject: LikeC4Model.Element
365
+ nodes: RelationshipsOfFlowTypes.Node[]
366
+ edges: RelationshipsOfFlowTypes.Edge[]
369
367
  bounds: {
370
368
  x: number
371
369
  y: number
@@ -375,13 +373,14 @@ function layout(
375
373
  } {
376
374
  const diagramNodes = new Map(view.nodes.map(n => [n.id, n]))
377
375
  const subjectElement = likec4model.element(subjectId)
376
+
378
377
  const viewIncludesSubject = diagramNodes.has(subjectId)
379
378
 
380
379
  const viewRelationships = new Set(
381
380
  view.edges.flatMap(e => e.relations)
382
381
  )
383
382
  // Relations that are not included in the view
384
- const notIncludedRelations = new Set<RelationID>()
383
+ const notIncludedRelations = new Set<RelationId>()
385
384
 
386
385
  if (!viewIncludesSubject) {
387
386
  // Reset scope to global if subject is not in the view
@@ -401,16 +400,18 @@ function layout(
401
400
 
402
401
  if (scope === 'global') {
403
402
  relationships = {
404
- incoming: subjectElement.incoming().map(r => r.relationship),
405
- outgoing: subjectElement.outgoing().map(r => r.relationship)
403
+ incoming: subjectElement.incoming().map(r => r.$relationship).toArray(),
404
+ outgoing: subjectElement.outgoing().map(r => r.$relationship).toArray()
406
405
  }
407
406
  } else {
408
- const subjectViewModel = likec4model.view(view.id).element(subjectId)
407
+ const subjectViewModel = likec4model.view(view.id).node(subjectId)
409
408
  relationships = {
410
409
  incoming: subjectViewModel.incoming()
411
- .flatMap(c => c.relationships().map(r => r.relationship)),
410
+ .flatMap(c => c.relationships('model').map(r => r.$relationship))
411
+ .toArray(),
412
412
  outgoing: subjectViewModel.outgoing()
413
- .flatMap(c => c.relationships().map(r => r.relationship))
413
+ .flatMap(c => c.relationships('model').map(r => r.$relationship))
414
+ .toArray()
414
415
  }
415
416
  }
416
417
 
@@ -445,7 +446,7 @@ function layout(
445
446
  })
446
447
 
447
448
  if (viewIncludesSubject) {
448
- const subjectViewModel = likec4model.view(view.id).element(subjectId)
449
+ const subjectViewModel = likec4model.view(view.id).node(subjectId)
449
450
  subjectViewModel.incomers().forEach(incomer => {
450
451
  ctx.connected.incomers.add(incomer.id)
451
452
  })
@@ -501,7 +502,7 @@ function layout(
501
502
  relation,
502
503
  source,
503
504
  target,
504
- includedInCurrentView: viewRelationships.has(relation.id),
505
+ existsInCurrentView: viewRelationships.has(relation.id),
505
506
  id: `${source.id}:${target.id}`
506
507
  })
507
508
  })
@@ -513,14 +514,8 @@ function layout(
513
514
  const { source, target } = grouped[0]
514
515
  const relations = map(grouped, g => g.relation)
515
516
 
516
- source.data.ports.right.push({
517
- id: target.id,
518
- type: 'out'
519
- })
520
- target.data.ports.left.push({
521
- id: source.id,
522
- type: 'in'
523
- })
517
+ source.data.ports.out.push(target.id)
518
+ target.data.ports.in.push(source.id)
524
519
 
525
520
  const isAnyCompound = source.type === 'compound' || target.type === 'compound'
526
521
 
@@ -531,7 +526,7 @@ function layout(
531
526
 
532
527
  addEdge(ctx, {
533
528
  // if view does not include subject - do not highlight
534
- includedInCurrentView: !viewIncludesSubject || grouped.every(g => g.includedInCurrentView),
529
+ existsInCurrentView: !viewIncludesSubject || grouped.every(g => g.existsInCurrentView),
535
530
  source: source.id,
536
531
  target: target.id,
537
532
  relations
@@ -556,7 +551,7 @@ function layout(
556
551
  if (subject.type !== 'element') {
557
552
  continue
558
553
  }
559
- const subjectPortsCount = Math.max(subject.data.ports.left.length, subject.data.ports.right.length)
554
+ const subjectPortsCount = Math.max(subject.data.ports.in.length, subject.data.ports.out.length)
560
555
  if (subjectPortsCount > 2) {
561
556
  g.node(subject.id).height = Sizes.hodeHeight + (subjectPortsCount - 3) * 14
562
557
  }
@@ -629,13 +624,13 @@ function layout(
629
624
  }
630
625
 
631
626
  // Sort ports in subject vertically
632
- const sortedPorts = (ports: XYFlowTypes.Port[]) => {
627
+ const sortedPorts = (ports: string[]) => {
633
628
  return pipe(
634
629
  ports,
635
630
  map(port => {
636
631
  return {
637
632
  port,
638
- topY: nodeBounds(port.id).position.y
633
+ topY: nodeBounds(port).position.y
639
634
  }
640
635
  }),
641
636
  sortBy(prop('topY')),
@@ -659,11 +654,11 @@ function layout(
659
654
  continue
660
655
  }
661
656
  // Sort ports by their position
662
- if (node.data.ports.left.length > 1) {
663
- node.data.ports.left = sortedPorts(node.data.ports.left)
657
+ if (node.data.ports.in.length > 1) {
658
+ node.data.ports.in = sortedPorts(node.data.ports.in)
664
659
  }
665
- if (node.data.ports.right.length > 1) {
666
- node.data.ports.right = sortedPorts(node.data.ports.right)
660
+ if (node.data.ports.out.length > 1) {
661
+ node.data.ports.out = sortedPorts(node.data.ports.out)
667
662
  }
668
663
  }
669
664