@likec4/diagram 1.18.0 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/LICENSE +1 -1
  2. package/dist/LikeC4CustomColors.d.ts +7 -0
  3. package/dist/LikeC4CustomColors.js +30 -0
  4. package/dist/LikeC4Diagram.css.d.ts +5 -0
  5. package/dist/LikeC4Diagram.css.js +13 -0
  6. package/dist/LikeC4Diagram.d.ts +6 -0
  7. package/dist/LikeC4Diagram.js +194 -0
  8. package/dist/LikeC4Diagram.props.d.ts +166 -0
  9. package/dist/LikeC4ModelProvider.d.ts +9 -0
  10. package/dist/LikeC4ModelProvider.js +12 -0
  11. package/dist/LikeC4Search.css.d.ts +1 -0
  12. package/dist/LikeC4Search.css.js +5 -0
  13. package/dist/LikeC4Search.d.ts +2 -0
  14. package/dist/LikeC4Search.js +96 -0
  15. package/dist/StaticLikeC4Diagram.d.ts +3 -0
  16. package/dist/StaticLikeC4Diagram.js +41 -0
  17. package/dist/_virtual/_commonjsHelpers.js +6 -0
  18. package/dist/controls/Text.d.ts +2 -0
  19. package/dist/controls/Text.js +7 -0
  20. package/dist/controls/action-button-bar/ActionButtonBar.css.d.ts +1 -0
  21. package/dist/controls/action-button-bar/ActionButtonBar.css.js +5 -0
  22. package/dist/controls/action-button-bar/ActionButtonBar.d.ts +9 -0
  23. package/dist/controls/action-button-bar/ActionButtonBar.js +100 -0
  24. package/dist/controls/action-button-bar/useActionButtonBarCtx.d.ts +10 -0
  25. package/dist/controls/action-button-bar/useActionButtonBarCtx.js +9 -0
  26. package/dist/controls/action-buttons/ActionButton.css.d.ts +1 -0
  27. package/dist/controls/action-buttons/ActionButton.css.js +5 -0
  28. package/dist/controls/action-buttons/ActionButton.d.ts +9 -0
  29. package/dist/controls/action-buttons/ActionButton.js +66 -0
  30. package/dist/controls/action-buttons/ActionButtons.d.ts +12 -0
  31. package/dist/controls/action-buttons/ActionButtons.js +99 -0
  32. package/dist/globals.css.d.ts +1 -0
  33. package/dist/globals.css.js +92 -0
  34. package/dist/hooks/index.d.ts +5 -0
  35. package/dist/hooks/useDiagramState.d.ts +6 -0
  36. package/dist/hooks/useDiagramState.js +27 -0
  37. package/dist/hooks/useMantinePortalProps.d.ts +9 -0
  38. package/dist/hooks/useMantinePortalProps.js +9 -0
  39. package/dist/hooks/useSetState.d.ts +2 -0
  40. package/dist/hooks/useSetState.js +19 -0
  41. package/dist/hooks/useUpdateEffect.d.ts +4 -0
  42. package/dist/hooks/useUpdateEffect.js +32 -0
  43. package/dist/hooks/useXYFlow.d.ts +270 -0
  44. package/dist/hooks/useXYFlow.js +20 -0
  45. package/dist/index.d.ts +11 -0
  46. package/dist/index.js +25 -0
  47. package/dist/likec4model/LikeC4ModelContext.d.ts +3 -0
  48. package/dist/likec4model/LikeC4ModelContext.js +5 -0
  49. package/dist/likec4model/index.d.ts +2 -0
  50. package/dist/likec4model/useLikeC4ElementsTree.d.ts +12 -0
  51. package/dist/likec4model/useLikeC4ElementsTree.js +25 -0
  52. package/dist/likec4model/useLikeC4Model.d.ts +20 -0
  53. package/dist/likec4model/useLikeC4Model.js +55 -0
  54. package/dist/overlays/OverlayContext.d.ts +10 -0
  55. package/dist/overlays/OverlayContext.js +9 -0
  56. package/dist/overlays/Overlays.css.d.ts +3 -0
  57. package/dist/overlays/Overlays.css.js +7 -0
  58. package/dist/overlays/Overlays.d.ts +2 -0
  59. package/dist/overlays/Overlays.js +137 -0
  60. package/dist/overlays/edge-details/EdgeDetailsXYFlow.d.ts +5 -0
  61. package/dist/overlays/edge-details/EdgeDetailsXYFlow.js +185 -0
  62. package/dist/overlays/edge-details/SelectEdge.css.d.ts +7 -0
  63. package/dist/overlays/edge-details/SelectEdge.css.js +17 -0
  64. package/dist/overlays/edge-details/SelectEdge.d.ts +5 -0
  65. package/dist/overlays/edge-details/SelectEdge.js +129 -0
  66. package/dist/overlays/edge-details/_types.d.ts +14 -0
  67. package/dist/overlays/edge-details/use-layouted-edge-details.d.ts +21 -0
  68. package/dist/overlays/edge-details/use-layouted-edge-details.js +270 -0
  69. package/dist/overlays/edge-details/xyflow/CompoundNode.d.ts +5 -0
  70. package/dist/overlays/edge-details/xyflow/CompoundNode.js +76 -0
  71. package/dist/overlays/edge-details/xyflow/ElementNode.d.ts +5 -0
  72. package/dist/overlays/edge-details/xyflow/ElementNode.js +159 -0
  73. package/dist/overlays/edge-details/xyflow/RelationshipEdge.d.ts +3 -0
  74. package/dist/overlays/edge-details/xyflow/RelationshipEdge.js +84 -0
  75. package/dist/overlays/edge-details/xyflow/styles.css.d.ts +9 -0
  76. package/dist/overlays/edge-details/xyflow/styles.css.js +21 -0
  77. package/dist/overlays/element-details/ElementDetailsCard.css.d.ts +16 -0
  78. package/dist/overlays/element-details/ElementDetailsCard.css.js +33 -0
  79. package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -0
  80. package/dist/overlays/element-details/ElementDetailsCard.js +484 -0
  81. package/dist/overlays/element-details/TabPanelDeployments.css.d.ts +4 -0
  82. package/dist/overlays/element-details/TabPanelDeployments.css.js +11 -0
  83. package/dist/overlays/element-details/TabPanelDeployments.d.ts +7 -0
  84. package/dist/overlays/element-details/TabPanelDeployments.js +173 -0
  85. package/dist/overlays/element-details/TabPanelRelationships.css.d.ts +5 -0
  86. package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -0
  87. package/dist/overlays/element-details/TabPanelRelationships.d.ts +8 -0
  88. package/dist/overlays/element-details/TabPanelRelationships.js +157 -0
  89. package/dist/overlays/element-details/TabPanelStructure.css.d.ts +2 -0
  90. package/dist/overlays/element-details/TabPanelStructure.css.js +7 -0
  91. package/dist/overlays/element-details/TabPanelStructure.d.ts +25 -0
  92. package/dist/overlays/element-details/TabPanelStructure.js +91 -0
  93. package/dist/overlays/index.d.ts +1 -0
  94. package/dist/overlays/relationships-of/RelationshipsOverlay.d.ts +5 -0
  95. package/dist/overlays/relationships-of/RelationshipsOverlay.js +193 -0
  96. package/dist/overlays/relationships-of/RelationshipsXYFlow.d.ts +19 -0
  97. package/dist/overlays/relationships-of/RelationshipsXYFlow.js +290 -0
  98. package/dist/overlays/relationships-of/SelectElement.css.d.ts +2 -0
  99. package/dist/overlays/relationships-of/SelectElement.css.js +7 -0
  100. package/dist/overlays/relationships-of/SelectElement.d.ts +7 -0
  101. package/dist/overlays/relationships-of/SelectElement.js +126 -0
  102. package/dist/overlays/relationships-of/_types.d.ts +28 -0
  103. package/dist/overlays/relationships-of/use-layouted-relationships.d.ts +22 -0
  104. package/dist/overlays/relationships-of/use-layouted-relationships.js +496 -0
  105. package/dist/overlays/relationships-of/xyflow/CompoundNode.d.ts +6 -0
  106. package/dist/overlays/relationships-of/xyflow/CompoundNode.js +120 -0
  107. package/dist/overlays/relationships-of/xyflow/ElementNode.d.ts +6 -0
  108. package/dist/overlays/relationships-of/xyflow/ElementNode.js +194 -0
  109. package/dist/overlays/relationships-of/xyflow/EmptyNode.d.ts +5 -0
  110. package/dist/overlays/relationships-of/xyflow/EmptyNode.js +18 -0
  111. package/dist/overlays/relationships-of/xyflow/RelationshipEdge.d.ts +3 -0
  112. package/dist/overlays/relationships-of/xyflow/RelationshipEdge.js +123 -0
  113. package/dist/overlays/relationships-of/xyflow/styles.css.d.ts +14 -0
  114. package/dist/overlays/relationships-of/xyflow/styles.css.js +24 -0
  115. package/dist/overlays/shared/xyflow/RelationshipEdge.css.d.ts +4 -0
  116. package/dist/overlays/shared/xyflow/RelationshipEdge.css.js +12 -0
  117. package/dist/overlays/shared/xyflow/_types.d.ts +77 -0
  118. package/dist/state/DiagramContext.d.ts +1609 -0
  119. package/dist/state/DiagramContext.js +101 -0
  120. package/dist/state/aligners.d.ts +42 -0
  121. package/dist/state/aligners.js +349 -0
  122. package/dist/state/diagram-to-xyflow.d.ts +11 -0
  123. package/dist/state/diagram-to-xyflow.js +113 -0
  124. package/dist/state/diagramStore.d.ts +1705 -0
  125. package/dist/state/diagramStore.js +808 -0
  126. package/dist/state/diagramStore.layout.d.ts +4 -0
  127. package/dist/state/diagramStore.layout.js +56 -0
  128. package/dist/style.css +1 -0
  129. package/dist/theme-vars.css.d.ts +72 -0
  130. package/dist/theme-vars.css.js +6 -0
  131. package/dist/theme-vars.css.ts.vanilla.css.js +1 -0
  132. package/dist/theme-vars.d.ts +3 -0
  133. package/dist/theme-vars.js +5 -0
  134. package/dist/ui/DiagramTitlePanel.css.d.ts +4 -0
  135. package/dist/ui/DiagramTitlePanel.css.js +11 -0
  136. package/dist/ui/DiagramTitlePanel.d.ts +1 -0
  137. package/dist/ui/DiagramTitlePanel.js +159 -0
  138. package/dist/ui/DynamicViewWalkthrough.css.d.ts +4 -0
  139. package/dist/ui/DynamicViewWalkthrough.css.js +11 -0
  140. package/dist/ui/DynamicViewWalkthrough.d.ts +1 -0
  141. package/dist/ui/DynamicViewWalkthrough.js +156 -0
  142. package/dist/ui/EnsureMantine.d.ts +7 -0
  143. package/dist/ui/EnsureMantine.js +14 -0
  144. package/dist/ui/FramerMotionConfig.d.ts +2 -0
  145. package/dist/ui/FramerMotionConfig.js +14 -0
  146. package/dist/ui/Link.d.ts +4 -0
  147. package/dist/ui/Link.js +36 -0
  148. package/dist/ui/notation/NotationPanel.css.d.ts +6 -0
  149. package/dist/ui/notation/NotationPanel.css.js +16 -0
  150. package/dist/ui/notation/NotationPanel.d.ts +1 -0
  151. package/dist/ui/notation/NotationPanel.js +250 -0
  152. package/dist/ui/notation/index.d.ts +1 -0
  153. package/dist/ui/top-left/ChangeAutoLayoutButton.d.ts +2 -0
  154. package/dist/ui/top-left/ChangeAutoLayoutButton.js +159 -0
  155. package/dist/ui/top-left/ManualLayoutToolsButton.d.ts +2 -0
  156. package/dist/ui/top-left/ManualLayoutToolsButton.js +137 -0
  157. package/dist/ui/top-left/TopLeftPanel.d.ts +4 -0
  158. package/dist/ui/top-left/TopLeftPanel.js +211 -0
  159. package/dist/ui/top-left/_shared.d.ts +7 -0
  160. package/dist/ui/top-left/_shared.js +22 -0
  161. package/dist/ui/top-left/styles.css.d.ts +8 -0
  162. package/dist/ui/top-left/styles.css.js +17 -0
  163. package/dist/utils/types.d.ts +8 -0
  164. package/dist/utils/vector.d.ts +24 -0
  165. package/dist/utils/vector.js +55 -0
  166. package/dist/xyflow/EdgeMarkers.d.ts +12 -0
  167. package/dist/xyflow/EdgeMarkers.js +192 -0
  168. package/dist/xyflow/FitviewOnDiagramChange.d.ts +4 -0
  169. package/dist/xyflow/FitviewOnDiagramChange.js +72 -0
  170. package/dist/xyflow/SelectEdgesOnNodeFocus.d.ts +1 -0
  171. package/dist/xyflow/SelectEdgesOnNodeFocus.js +96 -0
  172. package/dist/xyflow/XYFlow.d.ts +8 -0
  173. package/dist/xyflow/XYFlow.js +145 -0
  174. package/dist/xyflow/XYFlowBackground.d.ts +10 -0
  175. package/dist/xyflow/XYFlowBackground.js +25 -0
  176. package/dist/xyflow/XYFlowInner.d.ts +8 -0
  177. package/dist/xyflow/XYFlowInner.js +41 -0
  178. package/dist/xyflow/const.d.ts +7 -0
  179. package/dist/xyflow/const.js +12 -0
  180. package/dist/xyflow/edges/EdgeLabel.d.ts +7 -0
  181. package/dist/xyflow/edges/EdgeLabel.js +160 -0
  182. package/dist/xyflow/edges/RelationshipEdge.d.ts +6 -0
  183. package/dist/xyflow/edges/RelationshipEdge.js +443 -0
  184. package/dist/xyflow/edges/RelationshipsDropdownMenu.css.d.ts +4 -0
  185. package/dist/xyflow/edges/RelationshipsDropdownMenu.css.js +11 -0
  186. package/dist/xyflow/edges/RelationshipsDropdownMenu.d.ts +13 -0
  187. package/dist/xyflow/edges/RelationshipsDropdownMenu.js +211 -0
  188. package/dist/xyflow/edges/edges.css.d.ts +17 -0
  189. package/dist/xyflow/edges/edges.css.js +37 -0
  190. package/dist/xyflow/edges/utils.d.ts +16 -0
  191. package/dist/xyflow/edges/utils.js +24 -0
  192. package/dist/xyflow/nodes/AnimateVariants.d.ts +1313 -0
  193. package/dist/xyflow/nodes/AnimateVariants.js +123 -0
  194. package/dist/xyflow/nodes/Node.css.d.ts +3 -0
  195. package/dist/xyflow/nodes/Node.css.js +9 -0
  196. package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +14 -0
  197. package/dist/xyflow/nodes/compound/CompoundNode.css.js +27 -0
  198. package/dist/xyflow/nodes/compound/CompoundNode.d.ts +6 -0
  199. package/dist/xyflow/nodes/compound/CompoundNode.js +216 -0
  200. package/dist/xyflow/nodes/compound/index.d.ts +1 -0
  201. package/dist/xyflow/nodes/element/ElementLink.css.d.ts +3 -0
  202. package/dist/xyflow/nodes/element/ElementLink.d.ts +6 -0
  203. package/dist/xyflow/nodes/element/ElementNode.d.ts +6 -0
  204. package/dist/xyflow/nodes/element/ElementNode.js +190 -0
  205. package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +17 -0
  206. package/dist/xyflow/nodes/element/ElementShapeSvg.js +175 -0
  207. package/dist/xyflow/nodes/element/element.css.d.ts +18 -0
  208. package/dist/xyflow/nodes/element/element.css.js +31 -0
  209. package/dist/xyflow/nodes/element/index.d.ts +1 -0
  210. package/dist/xyflow/nodes/shared/ElementIcon.d.ts +8 -0
  211. package/dist/xyflow/nodes/shared/ElementIcon.js +38 -0
  212. package/dist/xyflow/nodes/shared/Toolbar.d.ts +9 -0
  213. package/dist/xyflow/nodes/shared/Toolbar.js +436 -0
  214. package/dist/xyflow/types.d.ts +36 -0
  215. package/dist/xyflow/useLayoutConstraints.d.ts +42 -0
  216. package/dist/xyflow/useLayoutConstraints.js +226 -0
  217. package/dist/xyflow/useXYFlowEvents.d.ts +160 -0
  218. package/dist/xyflow/useXYFlowEvents.js +275 -0
  219. package/dist/xyflow/utils.d.ts +22 -0
  220. package/dist/xyflow/utils.js +72 -0
  221. package/package.json +34 -27
  222. package/src/LikeC4Diagram.tsx +4 -4
  223. package/src/LikeC4Search.css.ts +12 -0
  224. package/src/LikeC4Search.tsx +39 -90
  225. package/src/controls/Text.ts +5 -0
  226. package/src/controls/action-button-bar/ActionButtonBar.css.ts +13 -0
  227. package/src/controls/action-button-bar/ActionButtonBar.tsx +138 -0
  228. package/src/controls/action-button-bar/useActionButtonBarCtx.ts +13 -0
  229. package/src/controls/action-buttons/ActionButton.css.ts +29 -0
  230. package/src/controls/action-buttons/ActionButton.tsx +66 -0
  231. package/src/controls/action-buttons/ActionButtons.tsx +138 -0
  232. package/src/hooks/useXYFlow.ts +8 -8
  233. package/src/index.ts +12 -6
  234. package/src/likec4model/index.ts +12 -2
  235. package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -12
  236. package/src/overlays/edge-details/_types.ts +13 -37
  237. package/src/overlays/edge-details/use-layouted-edge-details.ts +16 -14
  238. package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
  239. package/src/overlays/edge-details/xyflow/ElementNode.tsx +4 -11
  240. package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +3 -3
  241. package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
  242. package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +23 -23
  243. package/src/overlays/relationships-of/_types.ts +20 -58
  244. package/src/overlays/relationships-of/use-layouted-relationships.ts +36 -40
  245. package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +9 -13
  246. package/src/overlays/relationships-of/xyflow/ElementNode.tsx +12 -15
  247. package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
  248. package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -14
  249. package/src/overlays/shared/xyflow/RelationshipEdge.css.ts +60 -0
  250. package/src/overlays/shared/xyflow/_types.ts +87 -0
  251. package/src/state/diagram-to-xyflow.ts +6 -7
  252. package/src/state/diagramStore.layout.ts +3 -4
  253. package/src/state/diagramStore.ts +35 -37
  254. package/src/theme-vars.css.ts +81 -0
  255. package/src/theme-vars.ts +8 -81
  256. package/src/ui/DiagramTitlePanel.tsx +6 -6
  257. package/src/utils/types.ts +6 -0
  258. package/src/xyflow/SelectEdgesOnNodeFocus.tsx +3 -3
  259. package/src/xyflow/XYFlow.tsx +2 -2
  260. package/src/xyflow/edges/EdgeLabel.tsx +25 -18
  261. package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
  262. package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +3 -3
  263. package/src/xyflow/edges/edges.css.ts +68 -74
  264. package/src/xyflow/edges/utils.ts +6 -6
  265. package/src/xyflow/nodes/AnimateVariants.ts +143 -0
  266. package/src/xyflow/nodes/Node.css.ts +44 -0
  267. package/src/xyflow/nodes/compound/CompoundNode.css.ts +1 -64
  268. package/src/xyflow/nodes/compound/CompoundNode.tsx +69 -182
  269. package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
  270. package/src/xyflow/nodes/element/ElementNode.tsx +64 -266
  271. package/src/xyflow/nodes/element/element.css.ts +0 -57
  272. package/src/xyflow/nodes/shared/Toolbar.tsx +30 -30
  273. package/src/xyflow/types.ts +48 -51
  274. package/src/xyflow/useLayoutConstraints.ts +9 -9
  275. package/src/xyflow/useXYFlowEvents.ts +13 -30
  276. package/src/xyflow/utils.ts +2 -2
  277. package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
@@ -0,0 +1,436 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { defaultTheme, DiagramNode, ElementShapes } from "@likec4/core";
3
+ import { keys, Tooltip as Tooltip$1, Menu, MenuTarget, Button, MenuDropdown, MenuItem, ActionIcon, Popover, PopoverTarget, ColorSwatch, PopoverDropdown, Space, Divider, Stack, TooltipGroup, Flex, CheckIcon, rem, Slider, Paper, Box, Text, Group, SegmentedControl } from "@mantine/core";
4
+ import { IconSelector, IconCheck, IconFileSymlink, IconTransform } from "@tabler/icons-react";
5
+ import { NodeToolbar } from "@xyflow/react";
6
+ import clsx from "clsx";
7
+ import { useState, useEffect } from "react";
8
+ import { stopPropagation } from "../../utils.js";
9
+ import { useDiagramStoreApi, useDiagramState } from "../../../hooks/useDiagramState.js";
10
+ import { useMantinePortalProps } from "../../../hooks/useMantinePortalProps.js";
11
+ import { useUpdateEffect } from "../../../hooks/useUpdateEffect.js";
12
+ const {
13
+ primary,
14
+ secondary,
15
+ muted,
16
+ ...otherColors
17
+ } = defaultTheme.elements;
18
+ const themedColors = [
19
+ { key: "primary", value: primary.fill },
20
+ { key: "secondary", value: secondary.fill },
21
+ { key: "muted", value: muted.fill }
22
+ ];
23
+ const colors = keys(otherColors).map((key) => ({
24
+ key,
25
+ value: defaultTheme.elements[key].fill
26
+ }));
27
+ const Tooltip = Tooltip$1.withProps({
28
+ color: "dark",
29
+ fz: "xs",
30
+ openDelay: 400,
31
+ closeDelay: 150,
32
+ label: "",
33
+ children: null,
34
+ offset: 4
35
+ });
36
+ function CompoundToolbar({
37
+ element,
38
+ onColorPreview,
39
+ ...props
40
+ }) {
41
+ var _a;
42
+ const modelRef = DiagramNode.modelRef(element);
43
+ const deploymentRef = DiagramNode.deploymentRef(element);
44
+ const targets = [element.id];
45
+ const diagramApi = useDiagramStoreApi();
46
+ const {
47
+ hasGoToSource,
48
+ enableRelationshipBrowser
49
+ } = useDiagramState((s) => ({
50
+ hasGoToSource: !!s.onOpenSource,
51
+ enableRelationshipBrowser: s.enableRelationshipBrowser
52
+ }));
53
+ const onChange = (style) => {
54
+ diagramApi.getState().triggerChangeElementStyle({
55
+ op: "change-element-style",
56
+ style,
57
+ targets
58
+ });
59
+ };
60
+ return /* @__PURE__ */ jsxs(Toolbar, { element, ...props, children: [
61
+ /* @__PURE__ */ jsx(
62
+ ColorButton,
63
+ {
64
+ element,
65
+ isOpacityEditable: true,
66
+ onColorPreview,
67
+ onChange,
68
+ position: "left-start"
69
+ }
70
+ ),
71
+ /* @__PURE__ */ jsx(
72
+ BorderStyleOption,
73
+ {
74
+ elementBorderStyle: (_a = element.style) == null ? void 0 : _a.border,
75
+ onChange
76
+ }
77
+ ),
78
+ hasGoToSource && modelRef && /* @__PURE__ */ jsx(GoToSourceButton, { elementId: modelRef }),
79
+ hasGoToSource && !modelRef && deploymentRef && /* @__PURE__ */ jsx(GoToSourceButton, { deploymentId: deploymentRef }),
80
+ enableRelationshipBrowser && !!modelRef && /* @__PURE__ */ jsx(BrowseRelationshipsButton, { elementId: modelRef })
81
+ ] });
82
+ }
83
+ function Toolbar({ element, children, ...props }) {
84
+ return /* @__PURE__ */ jsx(NodeToolbar, { ...props, children: /* @__PURE__ */ jsx(
85
+ Paper,
86
+ {
87
+ className: clsx("nodrag", "nopan"),
88
+ px: 5,
89
+ pb: 8,
90
+ pt: 4,
91
+ radius: "sm",
92
+ shadow: "xl",
93
+ onDoubleClickCapture: stopPropagation,
94
+ onPointerDown: stopPropagation,
95
+ onClick: stopPropagation,
96
+ onDoubleClick: stopPropagation,
97
+ withBorder: true,
98
+ children: /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
99
+ /* @__PURE__ */ jsx(Box, { pl: 2, children: /* @__PURE__ */ jsx(Text, { c: "dimmed", fz: 10, fw: 500, children: element.id }) }),
100
+ /* @__PURE__ */ jsx(Group, { gap: 3, children })
101
+ ] })
102
+ }
103
+ ) });
104
+ }
105
+ function ElementToolbar({
106
+ element,
107
+ onColorPreview,
108
+ ...props
109
+ }) {
110
+ const modelRef = DiagramNode.modelRef(element);
111
+ const deploymentRef = DiagramNode.deploymentRef(element);
112
+ const targets = [element.id];
113
+ const diagramApi = useDiagramStoreApi();
114
+ const {
115
+ hasGoToSource,
116
+ enableRelationshipBrowser
117
+ } = useDiagramState((s) => ({
118
+ hasGoToSource: !!s.onOpenSource,
119
+ enableRelationshipBrowser: s.enableRelationshipBrowser
120
+ }));
121
+ const portalProps = useMantinePortalProps();
122
+ const onChange = (style) => {
123
+ diagramApi.getState().triggerChangeElementStyle({
124
+ op: "change-element-style",
125
+ style,
126
+ targets
127
+ });
128
+ };
129
+ return /* @__PURE__ */ jsxs(Toolbar, { element, ...props, children: [
130
+ /* @__PURE__ */ jsxs(
131
+ Menu,
132
+ {
133
+ openDelay: 300,
134
+ closeDelay: 450,
135
+ floatingStrategy: "fixed",
136
+ closeOnClickOutside: true,
137
+ clickOutsideEvents: ["pointerdown", "mousedown", "click"],
138
+ closeOnEscape: true,
139
+ closeOnItemClick: false,
140
+ position: "bottom-start",
141
+ offset: 2,
142
+ styles: {
143
+ item: {
144
+ padding: "calc(var(--mantine-spacing-xs) / 1.5) var(--mantine-spacing-xs)"
145
+ }
146
+ },
147
+ ...portalProps,
148
+ children: [
149
+ /* @__PURE__ */ jsx(MenuTarget, { children: /* @__PURE__ */ jsx(
150
+ Button,
151
+ {
152
+ variant: "light",
153
+ color: "gray",
154
+ size: "compact-xs",
155
+ rightSection: /* @__PURE__ */ jsx(IconSelector, { size: 12 }),
156
+ children: element.shape
157
+ }
158
+ ) }),
159
+ /* @__PURE__ */ jsx(
160
+ MenuDropdown,
161
+ {
162
+ onDoubleClick: stopPropagation,
163
+ onClick: stopPropagation,
164
+ children: ElementShapes.map((shape) => /* @__PURE__ */ jsx(
165
+ MenuItem,
166
+ {
167
+ fz: 12,
168
+ fw: 500,
169
+ value: shape,
170
+ rightSection: element.shape === shape ? /* @__PURE__ */ jsx(IconCheck, { size: 12 }) : void 0,
171
+ onClick: (e) => {
172
+ e.stopPropagation();
173
+ onChange({ shape });
174
+ },
175
+ children: shape
176
+ },
177
+ shape
178
+ ))
179
+ }
180
+ )
181
+ ]
182
+ }
183
+ ),
184
+ /* @__PURE__ */ jsx(
185
+ ColorButton,
186
+ {
187
+ element,
188
+ onColorPreview,
189
+ onChange,
190
+ position: "right-end"
191
+ }
192
+ ),
193
+ hasGoToSource && modelRef && /* @__PURE__ */ jsx(GoToSourceButton, { elementId: modelRef }),
194
+ hasGoToSource && !modelRef && deploymentRef && /* @__PURE__ */ jsx(GoToSourceButton, { deploymentId: deploymentRef }),
195
+ enableRelationshipBrowser && !!modelRef && /* @__PURE__ */ jsx(BrowseRelationshipsButton, { elementId: modelRef })
196
+ ] });
197
+ }
198
+ function GoToSourceButton(props) {
199
+ const diagramApi = useDiagramStoreApi();
200
+ const portalProps = useMantinePortalProps();
201
+ return /* @__PURE__ */ jsx(Tooltip, { label: "Open source", ...portalProps, children: /* @__PURE__ */ jsx(
202
+ ActionIcon,
203
+ {
204
+ size: "sm",
205
+ variant: "subtle",
206
+ color: "gray",
207
+ onClick: (e) => {
208
+ var _a, _b, _c, _d;
209
+ e.stopPropagation();
210
+ if (props.elementId) {
211
+ (_b = (_a = diagramApi.getState()).onOpenSource) == null ? void 0 : _b.call(_a, {
212
+ element: props.elementId
213
+ });
214
+ } else if (props.deploymentId) {
215
+ (_d = (_c = diagramApi.getState()).onOpenSource) == null ? void 0 : _d.call(_c, {
216
+ deployment: props.deploymentId
217
+ });
218
+ }
219
+ },
220
+ children: /* @__PURE__ */ jsx(IconFileSymlink, { stroke: 1.8, style: { width: "70%" } })
221
+ }
222
+ ) });
223
+ }
224
+ function ColorButton({
225
+ element,
226
+ onColorPreview,
227
+ isOpacityEditable = false,
228
+ onChange,
229
+ ...props
230
+ }) {
231
+ var _a, _b;
232
+ const elementColor = element.color ?? "primary";
233
+ return /* @__PURE__ */ jsxs(
234
+ Popover,
235
+ {
236
+ clickOutsideEvents: ["pointerdown", "mousedown", "click"],
237
+ position: "right-end",
238
+ offset: 2,
239
+ ...props,
240
+ children: [
241
+ /* @__PURE__ */ jsx(PopoverTarget, { children: /* @__PURE__ */ jsx(Button, { variant: "subtle", color: "gray", size: "compact-xs", px: 3, children: /* @__PURE__ */ jsx(
242
+ ColorSwatch,
243
+ {
244
+ color: (_a = defaultTheme.elements[elementColor]) == null ? void 0 : _a.fill,
245
+ size: 14,
246
+ withShadow: true,
247
+ style: { color: "#fff", cursor: "pointer" }
248
+ }
249
+ ) }) }),
250
+ /* @__PURE__ */ jsxs(PopoverDropdown, { p: "xs", children: [
251
+ /* @__PURE__ */ jsx(
252
+ ColorSwatches,
253
+ {
254
+ elementColor,
255
+ onColorPreview,
256
+ onChange: (color) => onChange({ color })
257
+ }
258
+ ),
259
+ isOpacityEditable && /* @__PURE__ */ jsxs(Fragment, { children: [
260
+ /* @__PURE__ */ jsx(Space, { h: "xs" }),
261
+ /* @__PURE__ */ jsx(Divider, { label: "opacity", labelPosition: "left" }),
262
+ /* @__PURE__ */ jsx(Space, { h: "xs" }),
263
+ /* @__PURE__ */ jsx(
264
+ OpacityOption,
265
+ {
266
+ elementOpacity: (_b = element.style) == null ? void 0 : _b.opacity,
267
+ onOpacityChange: (opacity) => {
268
+ onChange({ opacity });
269
+ }
270
+ }
271
+ )
272
+ ] })
273
+ ] })
274
+ ]
275
+ }
276
+ );
277
+ }
278
+ function ColorSwatches({
279
+ elementColor,
280
+ onColorPreview,
281
+ onChange
282
+ }) {
283
+ const changeColor = (color) => (e) => {
284
+ e.stopPropagation();
285
+ onColorPreview(null);
286
+ if (elementColor === color) {
287
+ return;
288
+ }
289
+ onChange(color);
290
+ };
291
+ return /* @__PURE__ */ jsx(Stack, { gap: 2, onMouseLeave: () => onColorPreview(null), children: /* @__PURE__ */ jsxs(TooltipGroup, { openDelay: 1e3, closeDelay: 300, children: [
292
+ /* @__PURE__ */ jsx(Flex, { maw: 120, gap: "6", justify: "flex-start", align: "flex-start", direction: "row", wrap: "wrap", children: themedColors.map(({ key, value }) => /* @__PURE__ */ jsx(
293
+ Tooltip$1,
294
+ {
295
+ label: key,
296
+ fz: "xs",
297
+ color: "dark",
298
+ offset: 2,
299
+ transitionProps: { duration: 140, transition: "slide-up" },
300
+ children: /* @__PURE__ */ jsx(
301
+ ColorSwatch,
302
+ {
303
+ color: value,
304
+ size: 18,
305
+ withShadow: true,
306
+ onMouseEnter: () => onColorPreview(key),
307
+ onClick: changeColor(key),
308
+ style: { color: "#fff", cursor: "pointer" },
309
+ children: elementColor === key && /* @__PURE__ */ jsx(CheckIcon, { style: { width: rem(10), height: rem(10) } })
310
+ }
311
+ )
312
+ },
313
+ key
314
+ )) }),
315
+ /* @__PURE__ */ jsx(
316
+ Flex,
317
+ {
318
+ mt: "sm",
319
+ maw: 110,
320
+ gap: "6",
321
+ justify: "flex-start",
322
+ align: "flex-start",
323
+ direction: "row",
324
+ wrap: "wrap",
325
+ children: colors.map(({ key, value }) => /* @__PURE__ */ jsx(
326
+ Tooltip$1,
327
+ {
328
+ label: key,
329
+ fz: "xs",
330
+ color: "dark",
331
+ offset: 2,
332
+ transitionProps: { duration: 140, transition: "slide-up" },
333
+ children: /* @__PURE__ */ jsx(
334
+ ColorSwatch,
335
+ {
336
+ color: value,
337
+ size: 18,
338
+ onMouseEnter: () => onColorPreview(key),
339
+ onClick: changeColor(key),
340
+ style: { color: "#fff", cursor: "pointer" },
341
+ children: elementColor === key && /* @__PURE__ */ jsx(CheckIcon, { style: { width: rem(10), height: rem(10) } })
342
+ }
343
+ )
344
+ },
345
+ key
346
+ ))
347
+ }
348
+ )
349
+ ] }) });
350
+ }
351
+ function BorderStyleOption({
352
+ elementBorderStyle = "dashed",
353
+ onChange
354
+ }) {
355
+ const [value, setValue] = useState(elementBorderStyle);
356
+ useEffect(() => {
357
+ setValue(elementBorderStyle);
358
+ }, [elementBorderStyle]);
359
+ return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
360
+ SegmentedControl,
361
+ {
362
+ size: "xs",
363
+ fullWidth: true,
364
+ withItemsBorders: false,
365
+ value,
366
+ onChange: (v) => {
367
+ const border = v;
368
+ setValue(border);
369
+ onChange({ border });
370
+ },
371
+ styles: {
372
+ label: {
373
+ paddingTop: 2,
374
+ paddingBottom: 2
375
+ }
376
+ },
377
+ data: [
378
+ { label: "Solid", value: "solid" },
379
+ { label: "Dashed", value: "dashed" },
380
+ { label: "Dotted", value: "dotted" },
381
+ { label: "None", value: "none" }
382
+ ]
383
+ }
384
+ ) });
385
+ }
386
+ function OpacityOption({
387
+ elementOpacity = 100,
388
+ onOpacityChange
389
+ }) {
390
+ const [value, setValue] = useState(elementOpacity);
391
+ useUpdateEffect(() => {
392
+ setValue(elementOpacity);
393
+ }, [elementOpacity]);
394
+ return /* @__PURE__ */ jsx(
395
+ Slider,
396
+ {
397
+ size: "sm",
398
+ color: "dark",
399
+ value,
400
+ onChange: setValue,
401
+ onChangeEnd: onOpacityChange
402
+ }
403
+ );
404
+ }
405
+ function BrowseRelationshipsButton({ elementId }) {
406
+ const diagramApi = useDiagramStoreApi();
407
+ const portalProps = useMantinePortalProps();
408
+ return /* @__PURE__ */ jsx(Tooltip, { label: "Browse relationships", ...portalProps, children: /* @__PURE__ */ jsx(
409
+ ActionIcon,
410
+ {
411
+ size: "sm",
412
+ variant: "subtle",
413
+ color: "gray",
414
+ onClick: (e) => {
415
+ e.stopPropagation();
416
+ diagramApi.getState().openOverlay({
417
+ relationshipsOf: elementId
418
+ });
419
+ },
420
+ children: /* @__PURE__ */ jsx(
421
+ IconTransform,
422
+ {
423
+ stroke: 2,
424
+ style: {
425
+ width: "72%",
426
+ height: "72%"
427
+ }
428
+ }
429
+ )
430
+ }
431
+ ) });
432
+ }
433
+ export {
434
+ CompoundToolbar,
435
+ ElementToolbar
436
+ };
@@ -0,0 +1,36 @@
1
+ import { BBox, DiagramEdge, DiagramNode, XYPoint } from '@likec4/core';
2
+ import { Edge as ReactFlowEdge, InternalNode as ReactFlowInternalNode, Node as ReactFlowNode, ReactFlowInstance, ReactFlowState } from '@xyflow/react';
3
+ import { SetRequired, Simplify } from 'type-fest';
4
+ import { SharedFlowTypes } from '../overlays/shared/xyflow/_types';
5
+ export declare namespace DiagramFlowTypes {
6
+ type NodeData = {
7
+ /**
8
+ * The DiagramNode backing this node.
9
+ */
10
+ element: DiagramNode;
11
+ };
12
+ type CompoundNodeData = NodeData & {
13
+ /**
14
+ * Whether this node is a view group.
15
+ */
16
+ isViewGroup: boolean;
17
+ };
18
+ type ElementNode = SetRequired<ReactFlowNode<SharedFlowTypes.NonEmptyNodeData & NodeData, 'element'>, 'type'>;
19
+ type CompoundNode = SetRequired<ReactFlowNode<SharedFlowTypes.NonEmptyNodeData & CompoundNodeData, 'compound'>, 'type'>;
20
+ type Node = ElementNode | CompoundNode;
21
+ type InternalNode = ReactFlowInternalNode<Node>;
22
+ type XYFlowInstance = ReactFlowInstance<Node, Edge>;
23
+ type XYFlowState = ReactFlowState<Node, Edge>;
24
+ type DiagramEdgeData = {
25
+ edge: DiagramEdge;
26
+ controlPoints: XYPoint[] | null;
27
+ label: null | {
28
+ bbox: BBox;
29
+ text: string;
30
+ };
31
+ };
32
+ type Edge = Simplify<ReactFlowEdge<DiagramEdgeData, 'relationship'> & {
33
+ type: 'relationship';
34
+ data: DiagramEdgeData;
35
+ }>;
36
+ }
@@ -0,0 +1,42 @@
1
+ import { NonEmptyArray } from '@likec4/core';
2
+ import { ReactFlowProps, XYPosition } from '@xyflow/react';
3
+ import { XYStoreApi } from '../hooks/useXYFlow';
4
+ import { DiagramFlowTypes } from './types';
5
+ declare abstract class Rect {
6
+ static readonly LeftPadding = 40;
7
+ static readonly RightPadding = 40;
8
+ static readonly TopPadding = 55;
9
+ static readonly BottomPadding = 40;
10
+ id: string;
11
+ minX: number;
12
+ minY: number;
13
+ maxX: number;
14
+ maxY: number;
15
+ get positionAbsolute(): XYPosition;
16
+ set positionAbsolute(pos: XYPosition);
17
+ get dimensions(): {
18
+ width: number;
19
+ height: number;
20
+ };
21
+ get position(): XYPosition;
22
+ protected abstract parent: Compound | null;
23
+ }
24
+ declare class Compound extends Rect {
25
+ protected readonly parent: Compound | null;
26
+ readonly children: Rect[];
27
+ constructor(xynode: DiagramFlowTypes.InternalNode, parent?: Compound | null);
28
+ }
29
+ type NodePositionUpdater = (nodes: Array<{
30
+ rect: Rect | Compound;
31
+ node: DiagramFlowTypes.InternalNode;
32
+ }>) => void;
33
+ export declare function createLayoutConstraints(xyflowApi: XYStoreApi, editingNodeIds: NonEmptyArray<string>): {
34
+ updateXYFlowNodes: () => void;
35
+ onMove: (updater: NodePositionUpdater) => void;
36
+ };
37
+ type LayoutConstraints = Required<Pick<ReactFlowProps<DiagramFlowTypes.Node>, 'onNodeDragStart' | 'onNodeDrag' | 'onNodeDragStop'>>;
38
+ /**
39
+ * Keeps the layout constraints (parent nodes and children) when dragging a node
40
+ */
41
+ export declare function useLayoutConstraints(): LayoutConstraints;
42
+ export {};