@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.
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,192 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ const Open = (props) => /* @__PURE__ */ jsx(
3
+ "marker",
4
+ {
5
+ viewBox: "-4 -4 14 16",
6
+ refX: 5,
7
+ refY: 4,
8
+ markerWidth: "7",
9
+ markerHeight: "8",
10
+ preserveAspectRatio: "xMaxYMid meet",
11
+ orient: "auto-start-reverse",
12
+ ...props,
13
+ children: /* @__PURE__ */ jsx(
14
+ "path",
15
+ {
16
+ d: "M0,0 L7,4 L0,8 L4,4 Z",
17
+ stroke: "context-stroke",
18
+ fill: "context-stroke",
19
+ strokeDasharray: 0,
20
+ strokeWidth: 1,
21
+ strokeLinecap: "round"
22
+ }
23
+ )
24
+ }
25
+ );
26
+ const Arrow = (props) => /* @__PURE__ */ jsx(
27
+ "marker",
28
+ {
29
+ viewBox: "-1 -1 12 10",
30
+ refX: 4,
31
+ refY: 3,
32
+ markerWidth: "8",
33
+ markerHeight: "6",
34
+ preserveAspectRatio: "xMaxYMid meet",
35
+ orient: "auto-start-reverse",
36
+ ...props,
37
+ children: /* @__PURE__ */ jsx(
38
+ "path",
39
+ {
40
+ d: "M 0 0 L 8 3 L 0 6 L 1 3 z",
41
+ fill: "context-stroke",
42
+ strokeWidth: 0
43
+ }
44
+ )
45
+ }
46
+ );
47
+ const Crow = (props) => /* @__PURE__ */ jsx(
48
+ "marker",
49
+ {
50
+ viewBox: "-1 -1 12 12",
51
+ refX: 8,
52
+ refY: 4,
53
+ markerWidth: "8",
54
+ markerHeight: "8",
55
+ preserveAspectRatio: "xMaxYMid meet",
56
+ orient: "auto-start-reverse",
57
+ ...props,
58
+ children: /* @__PURE__ */ jsx(
59
+ "path",
60
+ {
61
+ d: "M 8 0 L 0 4 L 8 8 M 8 4 L 0 4",
62
+ fill: "none",
63
+ strokeWidth: 1
64
+ }
65
+ )
66
+ }
67
+ );
68
+ const OArrow = (props) => /* @__PURE__ */ jsx(
69
+ "marker",
70
+ {
71
+ viewBox: "-1 -1 12 10",
72
+ refX: 4,
73
+ refY: 3,
74
+ markerWidth: "8",
75
+ markerHeight: "6",
76
+ preserveAspectRatio: "xMaxYMid meet",
77
+ orient: "auto-start-reverse",
78
+ ...props,
79
+ children: /* @__PURE__ */ jsx(
80
+ "path",
81
+ {
82
+ d: "M 0 0 L 8 3 L 0 6 L 1 3 z",
83
+ stroke: "context-stroke",
84
+ fill: "var(--likec4-background-color)",
85
+ strokeWidth: 1.25,
86
+ strokeLinejoin: "miter",
87
+ strokeLinecap: "square"
88
+ }
89
+ )
90
+ }
91
+ );
92
+ const Diamond = (props) => /* @__PURE__ */ jsx(
93
+ "marker",
94
+ {
95
+ viewBox: "-4 -4 16 14",
96
+ refX: 5,
97
+ refY: 4,
98
+ markerWidth: "10",
99
+ markerHeight: "8",
100
+ preserveAspectRatio: "xMaxYMid meet",
101
+ orient: "auto-start-reverse",
102
+ ...props,
103
+ children: /* @__PURE__ */ jsx(
104
+ "path",
105
+ {
106
+ d: "M5,0 L10,4 L5,8 L0,4 Z",
107
+ fill: "context-stroke",
108
+ strokeWidth: 0,
109
+ strokeLinecap: "round"
110
+ }
111
+ )
112
+ }
113
+ );
114
+ const ODiamond = (props) => /* @__PURE__ */ jsx(
115
+ "marker",
116
+ {
117
+ viewBox: "-4 -4 16 14",
118
+ refX: 6,
119
+ refY: 4,
120
+ markerWidth: "10",
121
+ markerHeight: "8",
122
+ preserveAspectRatio: "xMaxYMid meet",
123
+ orient: "auto-start-reverse",
124
+ ...props,
125
+ children: /* @__PURE__ */ jsx(
126
+ "path",
127
+ {
128
+ d: "M5,0 L10,4 L5,8 L0,4 Z",
129
+ stroke: "context-stroke",
130
+ fill: "var(--likec4-background-color)",
131
+ strokeWidth: 1.25,
132
+ strokeLinecap: "round"
133
+ }
134
+ )
135
+ }
136
+ );
137
+ const Dot = (props) => /* @__PURE__ */ jsx(
138
+ "marker",
139
+ {
140
+ viewBox: "0 0 10 10",
141
+ refX: 4,
142
+ refY: 4,
143
+ markerWidth: "6",
144
+ markerHeight: "6",
145
+ ...props,
146
+ children: /* @__PURE__ */ jsx(
147
+ "circle",
148
+ {
149
+ strokeWidth: 0,
150
+ fill: "context-stroke",
151
+ cx: 4,
152
+ cy: 4,
153
+ r: 3
154
+ }
155
+ )
156
+ }
157
+ );
158
+ const ODot = (props) => /* @__PURE__ */ jsx(
159
+ "marker",
160
+ {
161
+ viewBox: "0 0 10 10",
162
+ refX: 4,
163
+ refY: 4,
164
+ markerWidth: "6",
165
+ markerHeight: "6",
166
+ ...props,
167
+ children: /* @__PURE__ */ jsx(
168
+ "circle",
169
+ {
170
+ strokeWidth: 1.25,
171
+ stroke: "context-stroke",
172
+ fill: "var(--likec4-background-color)",
173
+ cx: 4,
174
+ cy: 4,
175
+ r: 3
176
+ }
177
+ )
178
+ }
179
+ );
180
+ const EdgeMarkers = {
181
+ Arrow,
182
+ Crow,
183
+ OArrow,
184
+ Open,
185
+ Diamond,
186
+ ODiamond,
187
+ Dot,
188
+ ODot
189
+ };
190
+ export {
191
+ EdgeMarkers
192
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Fits the view when diagram changes
3
+ */
4
+ export declare function FitViewOnDiagramChange(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,72 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useDebouncedEffect } from "@react-hookz/web";
3
+ import { shallowEqual } from "fast-equals";
4
+ import { useState, useRef } from "react";
5
+ import { useDiagramState, useDiagramStoreApi } from "../hooks/useDiagramState.js";
6
+ import { useXYStore } from "../hooks/useXYFlow.js";
7
+ function selectXYFlowSize(state) {
8
+ return `${Math.round(state.width)}:${Math.round(state.height)}`;
9
+ }
10
+ function selectDiagramsize({ view, fitViewPadding }) {
11
+ return [
12
+ view.bounds.x,
13
+ view.bounds.y,
14
+ view.bounds.width,
15
+ view.bounds.height,
16
+ fitViewPadding
17
+ ].map(Math.round).join(":");
18
+ }
19
+ function FitViewOnViewportResize({ diagramApi }) {
20
+ const xyflowsize = useXYStore(selectXYFlowSize);
21
+ const viewsize = useDiagramState(selectDiagramsize);
22
+ const dimensions = xyflowsize + viewsize;
23
+ const prevDimensionsRef = useRef(dimensions);
24
+ useDebouncedEffect(
25
+ () => {
26
+ const { focusedNodeId, fitDiagram } = diagramApi.getState();
27
+ if (focusedNodeId || prevDimensionsRef.current === dimensions) {
28
+ return;
29
+ }
30
+ prevDimensionsRef.current = dimensions;
31
+ fitDiagram(250);
32
+ },
33
+ [dimensions, diagramApi],
34
+ 250
35
+ );
36
+ return null;
37
+ }
38
+ function selector({ view, activeWalkthrough, viewportChanged, fitViewPadding }) {
39
+ return {
40
+ layoutId: view.id + "_" + view.autoLayout + "_" + fitViewPadding,
41
+ isActiveWalkthrough: !!activeWalkthrough,
42
+ viewportNotMoved: !viewportChanged
43
+ };
44
+ }
45
+ function FitViewOnDiagramChange() {
46
+ const {
47
+ layoutId,
48
+ isActiveWalkthrough,
49
+ viewportNotMoved
50
+ } = useDiagramState(selector, shallowEqual);
51
+ const diagramApi = useDiagramStoreApi();
52
+ const [currentLayoutId, setCurrent] = useState(layoutId);
53
+ const requiresFit = layoutId !== currentLayoutId;
54
+ useDebouncedEffect(
55
+ () => {
56
+ if (layoutId === currentLayoutId) {
57
+ return;
58
+ }
59
+ setCurrent(layoutId);
60
+ diagramApi.getState().fitDiagram(450);
61
+ },
62
+ [requiresFit, diagramApi],
63
+ 50
64
+ );
65
+ if (viewportNotMoved && !isActiveWalkthrough && !requiresFit) {
66
+ return /* @__PURE__ */ jsx(FitViewOnViewportResize, { diagramApi });
67
+ }
68
+ return null;
69
+ }
70
+ export {
71
+ FitViewOnDiagramChange
72
+ };
@@ -0,0 +1 @@
1
+ export declare function SelectEdgesOnNodeFocus(): null;
@@ -0,0 +1,96 @@
1
+ import { nonNullable } from "@likec4/core";
2
+ import { useHotkeys } from "@mantine/hooks";
3
+ import { getBoundsOfRects, getViewportForBounds } from "@xyflow/system";
4
+ import { useDiagramStoreApi, useDiagramState } from "../hooks/useDiagramState.js";
5
+ import { MinZoom } from "./const.js";
6
+ import { nodeToRect } from "./utils.js";
7
+ import { useUpdateEffect } from "../hooks/useUpdateEffect.js";
8
+ function SelectEdgesOnNodeFocus() {
9
+ const diagramStore = useDiagramStoreApi();
10
+ const focusedNodeId = useDiagramState((s) => s.focusedNodeId);
11
+ useUpdateEffect(() => {
12
+ if (!focusedNodeId) {
13
+ diagramStore.getState().xystore.getState().resetSelectedElements();
14
+ return;
15
+ }
16
+ const container = diagramStore.getState().getContainer();
17
+ if (!container) {
18
+ return;
19
+ }
20
+ const edgeChanges = [];
21
+ const nodeChanges = [];
22
+ const {
23
+ edgeLookup,
24
+ nodeLookup,
25
+ panZoom,
26
+ transform,
27
+ triggerNodeChanges,
28
+ triggerEdgeChanges
29
+ } = diagramStore.getState().xystore.getState();
30
+ let focusBounds = nodeToRect(nonNullable(nodeLookup.get(focusedNodeId)));
31
+ for (const [, edge] of edgeLookup) {
32
+ if (edge.source === focusedNodeId || edge.target === focusedNodeId) {
33
+ const anotherNodeId = edge.source === focusedNodeId ? edge.target : edge.source;
34
+ const nd = nonNullable(nodeLookup.get(anotherNodeId));
35
+ focusBounds = getBoundsOfRects(focusBounds, nodeToRect(nd));
36
+ }
37
+ if (edge.selected) {
38
+ edgeChanges.push({
39
+ id: edge.id,
40
+ type: "select",
41
+ selected: false
42
+ });
43
+ }
44
+ }
45
+ for (const [, node] of nodeLookup) {
46
+ if (node.selected && node.id !== focusedNodeId) {
47
+ nodeChanges.push({
48
+ id: node.id,
49
+ type: "select",
50
+ selected: false
51
+ });
52
+ }
53
+ }
54
+ nodeChanges.push({
55
+ id: focusedNodeId,
56
+ type: "select",
57
+ selected: true
58
+ });
59
+ if (edgeChanges.length > 0) {
60
+ triggerEdgeChanges(edgeChanges);
61
+ }
62
+ triggerNodeChanges(nodeChanges);
63
+ const { width, height } = container.getBoundingClientRect();
64
+ const maxZoom = Math.max(1, transform[2]);
65
+ const viewport = getViewportForBounds(
66
+ {
67
+ x: focusBounds.x - 16,
68
+ y: focusBounds.y - 16,
69
+ width: focusBounds.width + 32,
70
+ height: focusBounds.height + 32
71
+ },
72
+ width,
73
+ height,
74
+ MinZoom,
75
+ maxZoom,
76
+ 0
77
+ );
78
+ panZoom == null ? void 0 : panZoom.setViewport(viewport, {
79
+ duration: 350
80
+ });
81
+ }, [focusedNodeId]);
82
+ useHotkeys(
83
+ focusedNodeId !== null ? [
84
+ ["Escape", (e) => {
85
+ e.stopPropagation();
86
+ const { resetFocusAndLastClicked, fitDiagram } = diagramStore.getState();
87
+ resetFocusAndLastClicked();
88
+ fitDiagram();
89
+ }, { preventDefault: true }]
90
+ ] : []
91
+ );
92
+ return null;
93
+ }
94
+ export {
95
+ SelectEdgesOnNodeFocus
96
+ };
@@ -0,0 +1,8 @@
1
+ import { CSSProperties, PropsWithChildren } from 'react';
2
+ type XYFlowWrapperProps = PropsWithChildren<{
3
+ colorMode?: 'system' | 'light' | 'dark';
4
+ className?: string | undefined;
5
+ style?: CSSProperties | undefined;
6
+ }>;
7
+ export declare function XYFlow({ colorMode, className, children, style }: XYFlowWrapperProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,145 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useOnViewportChange, ReactFlow } from "@xyflow/react";
3
+ import { shallowEqual } from "fast-equals";
4
+ import "react";
5
+ import { useDiagramState } from "../hooks/useDiagramState.js";
6
+ import { useXYStoreApi } from "../hooks/useXYFlow.js";
7
+ import { MaxZoom, MinZoom } from "./const.js";
8
+ import { RelationshipEdge } from "./edges/RelationshipEdge.js";
9
+ import { useLayoutConstraints } from "./useLayoutConstraints.js";
10
+ import { useXYFlowEvents } from "./useXYFlowEvents.js";
11
+ import { ElementNodeMemo } from "./nodes/element/ElementNode.js";
12
+ import { CompoundNodeMemo } from "./nodes/compound/CompoundNode.js";
13
+ const nodeTypes = {
14
+ element: ElementNodeMemo,
15
+ compound: CompoundNodeMemo
16
+ };
17
+ const edgeTypes = {
18
+ relationship: RelationshipEdge
19
+ };
20
+ const selector = (s) => ({
21
+ nodes: s.xynodes,
22
+ edges: s.xyedges,
23
+ onInit: s.onInit,
24
+ onNodesChange: s.onNodesChange,
25
+ onEdgesChange: s.onEdgesChange,
26
+ nodesSelectable: s.nodesSelectable || s.focusedNodeId !== null,
27
+ nodesDraggable: s.nodesDraggable,
28
+ fitView: s.fitViewEnabled,
29
+ fitViewPadding: s.fitViewPadding,
30
+ // hasOnNavigateTo: !!s.onNavigateTo,
31
+ // hasOnNodeClick: !!s.onNodeClick,
32
+ hasOnNodeContextMenu: !!s.onNodeContextMenu,
33
+ hasOnCanvasContextMenu: !!s.onCanvasContextMenu,
34
+ hasOnEdgeContextMenu: !!s.onEdgeContextMenu,
35
+ hasOnEdgeClick: !!s.onEdgeClick,
36
+ zoomable: s.zoomable,
37
+ pannable: s.pannable,
38
+ // If fitView is not enabled
39
+ // And diagram starts with a negative x or y - we need to translate viewprot
40
+ translateX: s.fitViewEnabled ? 0 : -Math.min(s.view.bounds.x, 0),
41
+ translateY: s.fitViewEnabled ? 0 : -Math.min(s.view.bounds.y, 0)
42
+ });
43
+ function XYFlow({
44
+ colorMode = "system",
45
+ className,
46
+ children,
47
+ style
48
+ }) {
49
+ const xyflowApi = useXYStoreApi();
50
+ const {
51
+ nodes,
52
+ edges,
53
+ onInit,
54
+ onNodesChange,
55
+ onEdgesChange,
56
+ nodesSelectable,
57
+ nodesDraggable,
58
+ fitView,
59
+ fitViewPadding,
60
+ pannable,
61
+ zoomable,
62
+ hasOnNodeContextMenu,
63
+ hasOnCanvasContextMenu,
64
+ hasOnEdgeContextMenu,
65
+ translateX,
66
+ translateY
67
+ } = useDiagramState(selector, shallowEqual);
68
+ const layoutConstraints = useLayoutConstraints();
69
+ const {
70
+ onNodeContextMenu,
71
+ onPaneContextMenu,
72
+ onEdgeContextMenu,
73
+ ...handlers
74
+ } = useXYFlowEvents();
75
+ useOnViewportChange({
76
+ onEnd: ({ x, y, zoom }) => {
77
+ const roundedX = Math.round(x), roundedY = Math.round(y);
78
+ if (x !== roundedX || y !== roundedY) {
79
+ xyflowApi.setState({ transform: [roundedX, roundedY, zoom] });
80
+ }
81
+ }
82
+ });
83
+ return /* @__PURE__ */ jsx(
84
+ ReactFlow,
85
+ {
86
+ className,
87
+ style,
88
+ ...colorMode && { colorMode },
89
+ nodes,
90
+ edges,
91
+ onNodesChange,
92
+ onEdgesChange,
93
+ onInit,
94
+ nodeTypes,
95
+ edgeTypes,
96
+ zoomOnPinch: zoomable,
97
+ zoomOnScroll: !pannable && zoomable,
98
+ ...!zoomable && {
99
+ zoomActivationKeyCode: null
100
+ },
101
+ zoomOnDoubleClick: false,
102
+ maxZoom: zoomable ? MaxZoom : 1,
103
+ minZoom: zoomable ? MinZoom : 1,
104
+ fitView: false,
105
+ fitViewOptions: {
106
+ minZoom: MinZoom,
107
+ maxZoom: 1,
108
+ padding: fitViewPadding,
109
+ includeHiddenNodes: true
110
+ },
111
+ ...!fitView && {
112
+ viewport: {
113
+ x: translateX,
114
+ y: translateY,
115
+ zoom: 1
116
+ }
117
+ },
118
+ preventScrolling: zoomable || pannable,
119
+ defaultMarkerColor: "var(--xy-edge-stroke)",
120
+ noDragClassName: "nodrag",
121
+ noPanClassName: "nopan",
122
+ panOnScroll: pannable,
123
+ panOnDrag: pannable,
124
+ ...!pannable && {
125
+ selectionKeyCode: null
126
+ },
127
+ elementsSelectable: nodesSelectable,
128
+ nodesFocusable: nodesDraggable || nodesSelectable,
129
+ edgesFocusable: false,
130
+ nodesDraggable,
131
+ ...nodesDraggable && layoutConstraints,
132
+ nodeDragThreshold: 4,
133
+ elevateNodesOnSelect: false,
134
+ selectNodesOnDrag: false,
135
+ ...hasOnNodeContextMenu && { onNodeContextMenu },
136
+ ...hasOnCanvasContextMenu && { onPaneContextMenu },
137
+ ...hasOnEdgeContextMenu && { onEdgeContextMenu },
138
+ ...handlers,
139
+ children
140
+ }
141
+ );
142
+ }
143
+ export {
144
+ XYFlow
145
+ };
@@ -0,0 +1,10 @@
1
+ import { BackgroundProps } from '@xyflow/react';
2
+ import { OverrideProperties } from 'type-fest';
3
+ export type XYBackgroundVariant = 'dots' | 'lines' | 'cross';
4
+ export type XYBackground = XYBackgroundVariant | OverrideProperties<BackgroundProps, {
5
+ variant: XYBackgroundVariant;
6
+ }>;
7
+ export type XYBackgroundProps = {
8
+ background: XYBackground;
9
+ };
10
+ export declare function XYFlowBackground({ background }: XYBackgroundProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { nonexhaustive } from "@likec4/core";
3
+ import { Background, BackgroundVariant } from "@xyflow/react";
4
+ function literalToEnum(value) {
5
+ switch (value) {
6
+ case "dots":
7
+ return BackgroundVariant.Dots;
8
+ case "lines":
9
+ return BackgroundVariant.Lines;
10
+ case "cross":
11
+ return BackgroundVariant.Cross;
12
+ default:
13
+ nonexhaustive(value);
14
+ }
15
+ }
16
+ function XYFlowBackground({ background }) {
17
+ if (typeof background === "string") {
18
+ return /* @__PURE__ */ jsx(Background, { variant: literalToEnum(background), size: 2, gap: 20 });
19
+ }
20
+ const { variant, ...rest } = background;
21
+ return /* @__PURE__ */ jsx(Background, { variant: literalToEnum(variant), ...rest });
22
+ }
23
+ export {
24
+ XYFlowBackground
25
+ };
@@ -0,0 +1,8 @@
1
+ import { LikeC4DiagramProperties } from '../LikeC4Diagram.props';
2
+ import { NamedExoticComponent } from 'react';
3
+ type XYFlowInnerProps = {
4
+ background: NonNullable<LikeC4DiagramProperties['background']>;
5
+ showDiagramTitle: boolean;
6
+ };
7
+ export declare const XYFlowInner: NamedExoticComponent<XYFlowInnerProps>;
8
+ export {};
@@ -0,0 +1,41 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { deepEqual } from "fast-equals";
3
+ import { memo } from "react";
4
+ import { isNonNullish } from "remeda";
5
+ import { useDiagramState } from "../hooks/useDiagramState.js";
6
+ import DiagramTitlePanel from "../ui/DiagramTitlePanel.js";
7
+ import { DynamicViewWalkthrough } from "../ui/DynamicViewWalkthrough.js";
8
+ import { TopLeftPanel } from "../ui/top-left/TopLeftPanel.js";
9
+ import { XYFlowBackground } from "./XYFlowBackground.js";
10
+ import { NotationPanel } from "../ui/notation/NotationPanel.js";
11
+ const XYFlowInner = /* @__PURE__ */ memo(function XYFlowInnerR({
12
+ background,
13
+ showDiagramTitle
14
+ }) {
15
+ const {
16
+ showNotations,
17
+ isDynamicView,
18
+ showTopLeft,
19
+ isDynamicViewActive,
20
+ enableDynamicViewWalkthrough
21
+ } = useDiagramState((s) => ({
22
+ showNotations: s.showNotations,
23
+ isDynamicView: s.isDynamicView,
24
+ showTopLeft: s.controls || s.showNavigationButtons && !!s.onNavigateTo || !!s.onBurgerMenuClick,
25
+ enableDynamicViewWalkthrough: s.enableDynamicViewWalkthrough,
26
+ isDynamicViewActive: isNonNullish(s.activeWalkthrough)
27
+ }));
28
+ const isBgWithPattern = background !== "transparent" && background !== "solid";
29
+ const isDiagramTitleVisible = showDiagramTitle && !isDynamicViewActive;
30
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
31
+ isBgWithPattern && /* @__PURE__ */ jsx(XYFlowBackground, { background }),
32
+ showTopLeft && /* @__PURE__ */ jsx(TopLeftPanel, {}),
33
+ isDiagramTitleVisible && /* @__PURE__ */ jsx(DiagramTitlePanel, {}),
34
+ isDynamicView && enableDynamicViewWalkthrough && /* @__PURE__ */ jsx(DynamicViewWalkthrough, {}),
35
+ showNotations && /* @__PURE__ */ jsx(NotationPanel, {})
36
+ ] });
37
+ }, deepEqual);
38
+ XYFlowInner.displayName = "XYFlowInner";
39
+ export {
40
+ XYFlowInner
41
+ };
@@ -0,0 +1,7 @@
1
+ export declare const ZIndexes: {
2
+ readonly Compound: 2;
3
+ readonly Edge: 4;
4
+ readonly Element: 6;
5
+ };
6
+ export declare const MinZoom = 0.1;
7
+ export declare const MaxZoom = 2;
@@ -0,0 +1,12 @@
1
+ const ZIndexes = {
2
+ Compound: 2,
3
+ Edge: 4,
4
+ Element: 6
5
+ };
6
+ const MinZoom = 0.1;
7
+ const MaxZoom = 2;
8
+ export {
9
+ MaxZoom,
10
+ MinZoom,
11
+ ZIndexes
12
+ };
@@ -0,0 +1,7 @@
1
+ import { BoxProps } from '@mantine/core';
2
+ import { DiagramFlowTypes } from '../types';
3
+ export interface EdgeLabelProps extends Omit<BoxProps, 'label'> {
4
+ isDimmed: boolean;
5
+ edgeData: DiagramFlowTypes.DiagramEdgeData;
6
+ }
7
+ export declare const EdgeLabel: ({ isDimmed, edgeData: { label, edge, }, ...props }: EdgeLabelProps) => import("react/jsx-runtime").JSX.Element;