@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
@@ -0,0 +1,72 @@
1
+ import { invariant, hasAtLeast } from "@likec4/core";
2
+ import { getNodeDimensions } from "@xyflow/system";
3
+ import { Bezier } from "../node_modules/bezier-js/src/bezier.js";
4
+ import { isArray } from "remeda";
5
+ function toDomPrecision(v) {
6
+ if (v === null) {
7
+ return 0.01;
8
+ }
9
+ return Math.round(v * 100) / 100;
10
+ }
11
+ const nodeToRect = (nd) => ({
12
+ x: nd.internals.positionAbsolute.x,
13
+ y: nd.internals.positionAbsolute.y,
14
+ width: nd.measured.width ?? nd.width ?? nd.data.element.width,
15
+ height: nd.measured.height ?? nd.height ?? nd.data.element.height
16
+ });
17
+ const isInside = (test, target) => {
18
+ return test.x >= target.x && test.y >= target.y && test.x + test.width <= target.x + target.width && test.y + test.height <= target.y + target.height;
19
+ };
20
+ function bezierControlPoints(diagramEdge) {
21
+ let [start, ...bezierPoints] = diagramEdge.points;
22
+ invariant(start, "start should be defined");
23
+ const handles = [
24
+ // start
25
+ ];
26
+ while (hasAtLeast(bezierPoints, 3)) {
27
+ const [cp1, cp2, end, ...rest] = bezierPoints;
28
+ const bezier = new Bezier(start[0], start[1], cp1[0], cp1[1], cp2[0], cp2[1], end[0], end[1]);
29
+ const inflections = bezier.inflections();
30
+ if (inflections.length === 0) {
31
+ inflections.push(0.5);
32
+ }
33
+ inflections.forEach((t) => {
34
+ const { x, y } = bezier.get(t);
35
+ handles.push({
36
+ x: Math.round(x),
37
+ y: Math.round(y)
38
+ });
39
+ });
40
+ bezierPoints = rest;
41
+ start = end;
42
+ }
43
+ invariant(bezierPoints.length === 0, "all points should be consumed");
44
+ return handles;
45
+ }
46
+ const isClose = (a, b) => {
47
+ return Math.abs(a - b) < 3.1;
48
+ };
49
+ function isSamePoint(a, b) {
50
+ const [ax, ay] = isArray(a) ? a : [a.x, a.y];
51
+ const [bx, by] = isArray(b) ? b : [b.x, b.y];
52
+ return isClose(ax, bx) && isClose(ay, by);
53
+ }
54
+ function stopPropagation(e) {
55
+ return e.stopPropagation();
56
+ }
57
+ function centerXYInternalNode(nd) {
58
+ const { width, height } = getNodeDimensions(nd);
59
+ return {
60
+ x: nd.internals.positionAbsolute.x + width / 2,
61
+ y: nd.internals.positionAbsolute.y + height / 2
62
+ };
63
+ }
64
+ export {
65
+ bezierControlPoints,
66
+ centerXYInternalNode,
67
+ isInside,
68
+ isSamePoint,
69
+ nodeToRect,
70
+ stopPropagation,
71
+ toDomPrecision
72
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/diagram",
3
- "version": "1.17.1",
3
+ "version": "1.19.0",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -11,9 +11,7 @@
11
11
  "directory": "packages/diagram"
12
12
  },
13
13
  "files": [
14
- "package.json",
15
- "LICENSE",
16
- "README.md",
14
+ "dist",
17
15
  "src",
18
16
  "!**/*.spec.*",
19
17
  "!**/*.d.ts.map"
@@ -21,57 +19,68 @@
21
19
  "sideEffects": false,
22
20
  "type": "module",
23
21
  "exports": {
24
- ".": "./src/index.ts"
22
+ ".": {
23
+ "development": "./src/index.ts",
24
+ "default": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "default": "./dist/index.js"
28
+ }
29
+ },
30
+ "./style.css": "./dist/style.css"
25
31
  },
26
32
  "packageManager": "yarn@4.5.3",
27
33
  "scripts": {
28
34
  "typecheck": "tsc --noEmit",
35
+ "build": "vite build",
29
36
  "lint": "run -T eslint src/ --fix",
30
37
  "clean": "rm -r -f -g 'dist/*' .tsbuildinfo",
31
38
  "test": "vitest run --no-isolate"
32
39
  },
33
40
  "dependencies": {
34
- "@dagrejs/dagre": "^1.1.4",
35
- "@likec4/core": "1.17.1",
36
- "@mantine/vanilla-extract": "7.14.1",
41
+ "@dagrejs/dagre": "1.1.4",
42
+ "@likec4/core": "1.19.0",
43
+ "@mantine/vanilla-extract": "7.15.2",
37
44
  "@react-hookz/web": "^24.0.4",
38
45
  "@tabler/icons-react": "3.17.0",
39
- "@vanilla-extract/css": "^1.16.1",
40
- "@vanilla-extract/css-utils": "^0.1.4",
41
- "@vanilla-extract/dynamic": "^2.1.2",
42
- "@xyflow/react": "12.3.5",
43
- "@xyflow/system": "0.0.46",
44
- "bezier-js": "^6.1.4",
46
+ "@xyflow/react": "12.3.6",
47
+ "@xyflow/system": "0.0.47",
45
48
  "clsx": "^2.1.1",
46
49
  "d3-shape": "^3.2.0",
47
- "esm-env": "^1.1.4",
50
+ "esm-env": "^1.2.1",
48
51
  "fast-equals": "^5.0.1",
49
- "framer-motion": "^11.11.17",
52
+ "framer-motion": "^11.14.1",
50
53
  "khroma": "^2.1.0",
51
- "remeda": "^2.17.3",
52
- "type-fest": "4.27.1",
54
+ "react-error-boundary": "^4.1.2",
55
+ "remeda": "^2.17.4",
56
+ "type-fest": "4.28.1",
53
57
  "zustand": "^4.5.5"
54
58
  },
55
59
  "peerDependencies": {
56
- "@mantine/core": "^7.14.1",
57
- "@mantine/hooks": "^7.14.1",
58
- "@mantine/spotlight": "^7.14.1",
60
+ "@mantine/core": "^7.15.2",
61
+ "@mantine/hooks": "^7.15.2",
62
+ "@mantine/spotlight": "^7.15.2",
59
63
  "react": "^18.3.1",
60
64
  "react-dom": "^18.3.1"
61
65
  },
62
66
  "devDependencies": {
63
- "@likec4/tsconfig": "1.17.1",
64
- "@mantine/core": "7.14.1",
65
- "@mantine/hooks": "7.14.1",
66
- "@mantine/spotlight": "7.14.1",
67
+ "@likec4/tsconfig": "1.19.0",
68
+ "@mantine/core": "7.15.2",
69
+ "@mantine/hooks": "7.15.2",
70
+ "@mantine/spotlight": "7.15.2",
67
71
  "@types/bezier-js": "^4.1.3",
68
72
  "@types/d3-shape": "^3.1.6",
69
- "@types/react": "^18.3.11",
70
- "@types/react-dom": "^18.3.1",
71
- "execa": "^9.3.1",
72
- "react": "^18.3.1",
73
- "react-dom": "^18.3.1",
73
+ "@types/react": "18.3.11",
74
+ "@types/react-dom": "18.3.1",
75
+ "@vanilla-extract/css": "^1.16.1",
76
+ "@vanilla-extract/css-utils": "^0.1.4",
77
+ "@vanilla-extract/dynamic": "^2.1.2",
78
+ "bezier-js": "^6.1.4",
79
+ "react": "18.3.1",
80
+ "react-dom": "18.3.1",
74
81
  "typescript": "^5.7.2",
75
- "vitest": "^2.1.5"
82
+ "vite": "5.4.11",
83
+ "vite-plugin-dts": "^4.4.0",
84
+ "vitest": "^2.1.8"
76
85
  }
77
86
  }
@@ -3,9 +3,9 @@ import type {
3
3
  DiagramNode,
4
4
  DiagramView,
5
5
  Fqn,
6
- RelationID,
6
+ RelationId,
7
7
  ViewChange,
8
- ViewID,
8
+ ViewId,
9
9
  WhereOperator
10
10
  } from '@likec4/core'
11
11
  import type { MouseEvent as ReactMouseEvent, ReactNode } from 'react'
@@ -13,7 +13,7 @@ import type { XYBackground } from './xyflow/XYFlowBackground'
13
13
 
14
14
  export type { WhereOperator }
15
15
 
16
- export type DiagramNodeWithNavigate<ID extends string = ViewID> = Omit<DiagramNode, 'navigateTo'> & {
16
+ export type DiagramNodeWithNavigate<ID extends string = ViewId> = Omit<DiagramNode, 'navigateTo'> & {
17
17
  navigateTo: ID
18
18
  }
19
19
 
@@ -27,7 +27,7 @@ export type ElementIconRenderer = (props: {
27
27
  node: ElementIconNodeProps
28
28
  }) => ReactNode
29
29
 
30
- export type OnNavigateTo<ID extends string = ViewID> = (
30
+ export type OnNavigateTo<ID extends string = ViewId> = (
31
31
  to: ID,
32
32
  // These fields present if navigateTo triggered by a node click
33
33
  event?: ReactMouseEvent,
@@ -191,6 +191,22 @@ export interface LikeC4DiagramProperties {
191
191
  where?: WhereOperator<string, string> | undefined
192
192
  }
193
193
 
194
+ export type OpenSourceParams =
195
+ | {
196
+ element: Fqn
197
+ property?: string
198
+ }
199
+ | {
200
+ relation: RelationId
201
+ }
202
+ | {
203
+ deployment: Fqn
204
+ property?: string
205
+ }
206
+ | {
207
+ view: ViewId
208
+ }
209
+
194
210
  export interface LikeC4DiagramEventHandlers {
195
211
  onChange?: OnChange | null | undefined
196
212
  onNavigateTo?: OnNavigateTo | null | undefined
@@ -205,12 +221,5 @@ export interface LikeC4DiagramEventHandlers {
205
221
  // if set, will render a burger menu icon in the top left corner
206
222
  onBurgerMenuClick?: null | undefined | (() => void)
207
223
 
208
- // if set, will render a source code icon in the top left corner
209
- onOpenSourceView?: null | undefined | (() => void)
210
-
211
- // if set, will render an icon in properties webview for each element
212
- onOpenSourceElement?: null | undefined | ((fqn: Fqn) => void)
213
-
214
- // if set, will be called on edge click
215
- onOpenSourceRelation?: null | undefined | ((id: RelationID) => void)
224
+ onOpenSource?: null | undefined | ((params: OpenSourceParams) => void)
216
225
  }
@@ -1,3 +1,4 @@
1
+ import { isDeploymentView } from '@likec4/core'
1
2
  import { ReactFlowProvider as XYFlowProvider } from '@xyflow/react'
2
3
  import clsx from 'clsx'
3
4
  import { deepEqual } from 'fast-equals'
@@ -16,7 +17,7 @@ import { EnsureMantine } from './ui/EnsureMantine'
16
17
  import { FramerMotionConfig } from './ui/FramerMotionConfig'
17
18
  import { FitViewOnDiagramChange } from './xyflow/FitviewOnDiagramChange'
18
19
  import { SelectEdgesOnNodeFocus } from './xyflow/SelectEdgesOnNodeFocus'
19
- import type { XYFlowEdge, XYFlowNode } from './xyflow/types'
20
+ import type { DiagramFlowTypes } from './xyflow/types'
20
21
  import { XYFlow } from './xyflow/XYFlow'
21
22
  import { XYFlowInner } from './xyflow/XYFlowInner'
22
23
 
@@ -54,9 +55,7 @@ export function LikeC4Diagram({
54
55
  onNavigateTo,
55
56
  onNodeClick,
56
57
  onNodeContextMenu,
57
- onOpenSourceElement,
58
- onOpenSourceView,
59
- onOpenSourceRelation,
58
+ onOpenSource,
60
59
  onBurgerMenuClick,
61
60
  renderIcon,
62
61
  where,
@@ -64,8 +63,8 @@ export function LikeC4Diagram({
64
63
  }: LikeC4DiagramProps) {
65
64
  const hasLikec4model = !!useLikeC4Model()
66
65
  const initialRef = useRef({
67
- defaultNodes: [] as XYFlowNode[],
68
- defaultEdges: [] as XYFlowEdge[],
66
+ defaultNodes: [] as DiagramFlowTypes.Node[],
67
+ defaultEdges: [] as DiagramFlowTypes.Edge[],
69
68
  initialWidth: initialWidth ?? view.bounds.width,
70
69
  initialHeight: initialHeight ?? view.bounds.height
71
70
  })
@@ -112,11 +111,12 @@ export function LikeC4Diagram({
112
111
  showNavigationButtons={showNavigationButtons && !!onNavigateTo}
113
112
  showNotations={showNotations}
114
113
  enableFocusMode={enableFocusMode}
115
- enableRelationshipDetails={enableRelationshipDetails && hasLikec4model}
116
114
  enableSearch={hasLikec4model && enableSearch}
117
115
  enableElementDetails={enableElementDetails && hasLikec4model}
118
116
  enableDynamicViewWalkthrough={enableDynamicViewWalkthrough}
119
117
  enableRelationshipBrowser={enableRelationshipBrowser && hasLikec4model}
118
+ // TODO: temporary disable relationship details for deployment views
119
+ enableRelationshipDetails={enableRelationshipDetails && hasLikec4model && !isDeploymentView(view)}
120
120
  // Apply where filter only in readonly mode
121
121
  whereFilter={readonly ? (where ?? null) : null}
122
122
  renderIcon={renderIcon ?? null}
@@ -129,9 +129,7 @@ export function LikeC4Diagram({
129
129
  onChange={onChange ?? null}
130
130
  onNavigateTo={onNavigateTo ?? null}
131
131
  onCanvasDblClick={onCanvasDblClick ?? null}
132
- onOpenSourceView={onOpenSourceView ?? null}
133
- onOpenSourceElement={onOpenSourceElement ?? null}
134
- onOpenSourceRelation={onOpenSourceRelation ?? null}
132
+ onOpenSource={onOpenSource ?? null}
135
133
  onBurgerMenuClick={onBurgerMenuClick ?? null}
136
134
  >
137
135
  <LikeC4DiagramInnerMemo
@@ -0,0 +1,12 @@
1
+ import { rem } from '@mantine/core'
2
+ import { globalStyle, style } from '@vanilla-extract/css'
3
+
4
+ export const actionSection = style({
5
+ marginInlineEnd: 4
6
+ })
7
+
8
+ globalStyle(`:where(${actionSection}) .tabler-icon`, {
9
+ opacity: 0.8,
10
+ width: '70%',
11
+ height: '70%'
12
+ })
@@ -1,72 +1,16 @@
1
- import type { DiagramView } from '@likec4/core'
2
- import { Spotlight, SpotlightActionsGroup, type SpotlightActionData } from '@mantine/spotlight'
3
- import { IconRectangularPrism, IconSitemap, IconSearch } from '@tabler/icons-react'
4
- import { memo, useMemo, useState } from 'react'
1
+ import { rem } from '@mantine/core'
2
+ import { Spotlight, type SpotlightActionData } from '@mantine/spotlight'
3
+ import { IconRectangularPrism, IconSearch, IconSitemap, IconStack2 } from '@tabler/icons-react'
4
+ import { memo, useMemo } from 'react'
5
5
  import { filter, map, pipe } from 'remeda'
6
6
  import { useDiagramState, useDiagramStoreApi, useMantinePortalProps } from './hooks'
7
7
  import { useLikeC4Model } from './likec4model'
8
- import { Center, Group, Highlight, Text } from '@mantine/core'
9
-
10
- interface QueryMatch {
11
- data: SpotlightActionData,
12
- keyword: string,
13
- match: string
14
- }
15
-
16
- function filterAction(actionData: SpotlightActionData, query: string) : QueryMatch | undefined {
17
- const queryLower = query.toLowerCase();
18
- const keywords = Array.isArray(actionData.keywords) ? actionData.keywords : [];
19
- const keywordMatch = keywords
20
- .map(keyword => {
21
- const index = keyword.toLowerCase().indexOf(queryLower);
22
- return index !== -1 ? {
23
- keyword: keyword,
24
- match: keyword.substring(index, index + query.length)
25
- } : null;
26
- })
27
- .find(match => !!match);
28
- return !!keywordMatch ? {
29
- data: actionData,
30
- keyword: keywordMatch.keyword,
31
- match: keywordMatch.match
32
- } : undefined;
33
- }
34
-
35
- function buildFilteredActions(actionsData: SpotlightActionData[], query: string): JSX.Element[] {
36
- return pipe(
37
- actionsData,
38
- map(a => filterAction(a, query)),
39
- filter(qm => !!qm),
40
- map(qm => buildSpotlightAction(qm))
41
- );
42
- }
43
-
44
- function highlightMatch(match: QueryMatch): JSX.Element {
45
- return <Highlight highlight={match.match}>{match.keyword}</Highlight>
46
- }
47
-
48
- function buildSpotlightAction(matchedAction: QueryMatch): JSX.Element {
49
- const isMatchInLabel = matchedAction.keyword == matchedAction.data.label;
50
- return <Spotlight.Action onClick={matchedAction.data.onClick}>
51
- <Center style={{ marginRight: '8px '}}>
52
- {matchedAction.data.leftSection}
53
- </Center>
54
- <Group wrap="nowrap" w="100%">
55
- <div style={{ flex: 1 }}>
56
- <Text>
57
- {isMatchInLabel ? highlightMatch(matchedAction) : matchedAction.data.label}
58
- </Text>
59
- {!isMatchInLabel && <Text opacity={0.6} size="xs">{highlightMatch(matchedAction)}</Text>}
60
- </div>
61
- </Group>
62
- </Spotlight.Action>
63
- }
8
+ import * as css from './LikeC4Search.css'
64
9
 
65
10
  export const LikeC4Search = memo(() => {
66
11
  const view = useDiagramState(s => s.view)
67
12
  const model = useLikeC4Model(true)
68
13
  const store = useDiagramStoreApi()
69
- const [ query, setQuery ] = useState('')
70
14
 
71
15
  const getNodeActionsData = (): SpotlightActionData[] => {
72
16
  const { focusOnNode } = store.getState()
@@ -77,6 +21,9 @@ export const LikeC4Search = memo(() => {
77
21
  map(n => ({
78
22
  id: n.id,
79
23
  label: n.title,
24
+ ...(n.description && {
25
+ description: n.description
26
+ }),
80
27
  keywords: [
81
28
  n.title,
82
29
  ...(n.tags ?? []).map(t => `#${t}`),
@@ -85,62 +32,67 @@ export const LikeC4Search = memo(() => {
85
32
  onClick: () => focusOnNode(n.id),
86
33
  leftSection: <IconRectangularPrism />
87
34
  }))
88
- );
35
+ )
89
36
  }
90
37
 
91
38
  const getViewActionsData = (): SpotlightActionData[] => {
92
- const { onNavigateTo } = store.getState()
93
- const views = model.views()
39
+ const views = [...model.views()]
94
40
 
95
41
  return map(views, v => ({
96
42
  id: v.id,
97
43
  label: v.title ?? v.id,
44
+ ...(v.$view.description && {
45
+ description: v.$view.description
46
+ }),
98
47
  keywords: [
99
48
  v.title ?? v.id,
100
49
  ...(v.tags ?? []),
101
- ...(v.view.description ? [v.view.description] : [])
50
+ ...(v.$view.description ? [v.$view.description] : [])
102
51
  ],
103
52
  onClick: () => {
104
53
  store.setState({
105
- hoveredNodeId: null,
106
54
  lastOnNavigate: {
107
55
  fromView: view.id,
108
56
  toView: v.id,
109
57
  fromNode: null
110
58
  }
111
59
  })
112
- onNavigateTo?.(v.id)
60
+ store.getState().onNavigateTo?.(v.id)
113
61
  },
114
- leftSection: <IconSitemap />
115
- }));
62
+ leftSection: v.isDeploymentView()
63
+ ? <IconStack2 />
64
+ : <IconSitemap />
65
+ }))
116
66
  }
117
67
 
118
- const { nodeActions, viewActions } = useMemo(() => ({
119
- nodeActions: buildFilteredActions(getNodeActionsData(), query),
120
- viewActions: buildFilteredActions(getViewActionsData(), query)
121
- }),
122
- [model, store, view, query]
123
- );
68
+ const actions = useMemo(() => [
69
+ {
70
+ group: 'Elements',
71
+ actions: getNodeActionsData()
72
+ },
73
+ {
74
+ group: 'Views',
75
+ actions: getViewActionsData()
76
+ }
77
+ ], [model, store, view])
124
78
 
125
- const portalProps = useMantinePortalProps();
79
+ const portalProps = useMantinePortalProps()
126
80
  return (
127
- <Spotlight.Root
81
+ <Spotlight
128
82
  {...portalProps}
83
+ actions={actions}
84
+ nothingFound="Nothing found..."
129
85
  shortcut={['mod + f', 'mod + k']}
130
- query={query}
131
- onQueryChange={setQuery}
132
86
  scrollable
133
- maxHeight={'calc(100vh - 100px)'}
134
- >
135
- <Spotlight.Search
136
- placeholder="Search elements in current view and other views..."
137
- leftSection={<IconSearch stroke={1.5} />}
138
- />
139
- <Spotlight.ActionsList>
140
- {nodeActions.length > 0 && <SpotlightActionsGroup label="Elements">{nodeActions}</SpotlightActionsGroup> }
141
- {viewActions.length > 0 && <SpotlightActionsGroup label="Views">{viewActions}</SpotlightActionsGroup> }
142
- {nodeActions.length == 0 && viewActions.length == 0 && <Spotlight.Empty>Nothing found...</Spotlight.Empty> }
143
- </Spotlight.ActionsList>
144
- </Spotlight.Root>
145
- );
146
- });
87
+ highlightQuery
88
+ maxHeight={350}
89
+ classNames={{
90
+ actionSection: css.actionSection
91
+ }}
92
+ searchProps={{
93
+ leftSection: <IconSearch style={{ width: rem(18), height: rem(18) }} stroke={1.5} />,
94
+ placeholder: 'Search elements and views...'
95
+ }}
96
+ />
97
+ )
98
+ })
@@ -0,0 +1,5 @@
1
+ import { Text as MantineText } from '@mantine/core'
2
+
3
+ export const Text = MantineText.withProps({
4
+ component: 'div'
5
+ })
@@ -0,0 +1,13 @@
1
+ import { style } from "@vanilla-extract/css";
2
+
3
+ export const container = style({
4
+ zIndex: 100,
5
+ width: '100%',
6
+ display: 'flex',
7
+ flexDirection: 'row',
8
+ flexWrap: 'nowrap',
9
+ alignItems: 'center',
10
+ gap: 2,
11
+ justifyContent: 'center',
12
+ pointerEvents: 'none',
13
+ })
@@ -0,0 +1,138 @@
1
+ import { Box } from '@mantine/core'
2
+ import { useId } from '@mantine/hooks'
3
+ import clsx from 'clsx'
4
+ import { type Variants } from 'framer-motion'
5
+ import type { PropsWithChildren } from 'react'
6
+ import * as css from './ActionButtonBar.css'
7
+ import { ActionButtonBarContext } from './useActionButtonBarCtx'
8
+
9
+ const TRANSLATE_DIFF = 5
10
+
11
+ type ShiftX = 'left' | 'spread' | 'right'
12
+ type ShiftY = 'top' | 'spread' | 'bottom'
13
+ type ShiftMode = number | 'spread'
14
+
15
+ type ActionButtonBarProps = PropsWithChildren<{
16
+ shiftX?: ShiftX
17
+ shiftY?: ShiftY
18
+ }>
19
+
20
+ const elementVariants = (prefix: string, index: number, count: number, shiftX: ShiftMode, shiftY: ShiftMode) => {
21
+ const name = `${prefix}${index + 1}`
22
+ const translation = count > 1
23
+ ? {
24
+ x: shiftX === 'spread' ? 1 - count + index * 2 : shiftX,
25
+ y: shiftY === 'spread' ? 1 - count + index * 2 : shiftY,
26
+ }
27
+ : {
28
+ x: 0,
29
+ y: 1,
30
+ }
31
+
32
+ const variants = {
33
+ idle: {
34
+ '--icon-scale': 'scale(1)',
35
+ '--ai-bg': 'var(--ai-bg-idle)',
36
+ scale: 1,
37
+ opacity: 0.8,
38
+ translateX: 0,
39
+ translateY: 0,
40
+ originX: 0.5,
41
+ originY: 0.5,
42
+ // translateY: 0,
43
+ // ...align === 'left' && {
44
+ // originX: 0.75,
45
+ // translateX: -1
46
+ // },
47
+ // ...align === 'right' && {
48
+ // originX: 0.25,
49
+ // translateX: 1
50
+ // }
51
+ },
52
+ hovered: {
53
+ '--ai-bg': 'var(--ai-bg-hover)',
54
+ '--icon-scale': 'scale(1)',
55
+ // translateY: 3,
56
+ scale: 1.28,
57
+ opacity: 1,
58
+ translateX: translation.x * TRANSLATE_DIFF,
59
+ translateY: translation.y * TRANSLATE_DIFF,
60
+ // ...align === 'left' && {
61
+ // translateX: -4
62
+ // },
63
+ // ...align === 'right' && {
64
+ // translateX: 4
65
+ // }
66
+ },
67
+ [`hovered:${name}`]: {
68
+ '--ai-bg': 'var(--ai-hover)',
69
+ '--icon-scale': 'scale(1.08)',
70
+ scale: 1.45,
71
+ },
72
+ [`tap:${name}`]: {
73
+ '--icon-scale': 'scale(1)',
74
+ scale: 1.15,
75
+ },
76
+ selected: {},
77
+ } satisfies Variants
78
+ variants['selected'] = variants['hovered']
79
+ variants['hovered:details'] = variants['idle']
80
+ return {
81
+ variants,
82
+ ['data-animate-target']: name,
83
+ }
84
+ }
85
+
86
+ export const ActionButtonBar = ({
87
+ shiftX = 'spread',
88
+ shiftY = 'spread',
89
+ children,
90
+ }: ActionButtonBarProps) => {
91
+ const id = useId()
92
+ const childrenArray = Array.isArray(children) ? children : [children]
93
+
94
+ // determine offsets for shifting
95
+ let shiftDiffX: ShiftMode = 'spread'
96
+ if (shiftX == 'left') {
97
+ shiftDiffX = -1
98
+ }
99
+ else if (shiftX == 'right') {
100
+ shiftDiffX = 1
101
+ }
102
+
103
+ let shiftDiffY: ShiftMode = 'spread'
104
+ if (shiftY == 'top') {
105
+ shiftDiffY = -1
106
+ }
107
+ else if (shiftY == 'bottom') {
108
+ shiftDiffY = 1
109
+ }
110
+
111
+ return (
112
+ <Box className={clsx(css.container)}>
113
+ {childrenArray.map((child, i, all) => (
114
+ <ActionButtonBarContext.Provider
115
+ value={elementVariants(id, i, all.length, shiftDiffX, shiftDiffY)}>
116
+ {child}
117
+ </ActionButtonBarContext.Provider>
118
+ // <>{cloneElement(child, {
119
+ // key: i,
120
+ // variants: elementVariants(i, all.length, shiftDiffX, shiftDiffY),
121
+ // ['data-animate-target']: `i${i + 1}`,
122
+ // ...props
123
+ // })}</>
124
+ ))}
125
+ {
126
+ /* {childrenArray.filter(child => !!child).map((child, i) => (
127
+ <m.div
128
+ key={i}
129
+ variants={elementVariants(i, childrenArray.length, shiftDiffX, shiftDiffY)}
130
+ {...props}
131
+ >
132
+ {child}
133
+ </m.div>
134
+ ))} */
135
+ }
136
+ </Box>
137
+ )
138
+ }