@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,13 @@
1
+ import type { Variants } from 'framer-motion'
2
+ import { createContext, useContext } from 'react'
3
+
4
+ export const ActionButtonBarContext = createContext<
5
+ {
6
+ variants: Variants
7
+ ['data-animate-target']?: string
8
+ } | null
9
+ >(null)
10
+
11
+ export function useActionButtonBarCtx() {
12
+ return useContext(ActionButtonBarContext)
13
+ }
@@ -0,0 +1,29 @@
1
+ import { style } from '@vanilla-extract/css'
2
+ import { mantine, vars, whereLight } from '../../theme-vars'
3
+
4
+ export const btn = style({
5
+ pointerEvents: 'all',
6
+ color: vars.element.loContrast,
7
+ cursor: 'pointer',
8
+ backgroundColor: 'var(--ai-bg)',
9
+ 'vars': {
10
+ '--ai-bg-idle': `color-mix(in srgb , ${vars.element.fill}, transparent 99%)`,
11
+ '--ai-bg': `var(--ai-bg-idle)`,
12
+ '--ai-bg-hover': `color-mix(in srgb , ${vars.element.fill} 65%, ${vars.element.stroke})`,
13
+ '--ai-hover': `color-mix(in srgb , ${vars.element.fill} 50%, ${vars.element.stroke})`,
14
+ },
15
+ ':hover': {
16
+ boxShadow: mantine.shadows.md,
17
+ },
18
+ selectors: {
19
+ [`${whereLight} .likec4-compound-transparent &`]: {
20
+ color: vars.element.stroke,
21
+ opacity: 0.85,
22
+ vars: {
23
+ '--ai-bg-hover': `color-mix(in srgb , ${vars.element.fill}, transparent 20%)`,
24
+ '--ai-hover': `color-mix(in srgb , ${vars.element.fill}, transparent 10%)`,
25
+ '--ai-bg': `color-mix(in srgb , ${vars.element.fill}, transparent 99%)`,
26
+ },
27
+ },
28
+ },
29
+ })
@@ -0,0 +1,66 @@
1
+ import { type ActionIconProps, ActionIcon, Tooltip } from '@mantine/core'
2
+ import clsx from 'clsx'
3
+ import { type HTMLMotionProps, type Variants, m } from 'framer-motion'
4
+ import type { PropsWithoutRef } from 'react'
5
+ import { stopPropagation } from '../../xyflow/utils'
6
+ import { useActionButtonBarCtx } from '../action-button-bar/useActionButtonBarCtx'
7
+ import * as css from './ActionButton.css'
8
+
9
+ export type ActionButtonProps = PropsWithoutRef<
10
+ Omit<ActionIconProps & HTMLMotionProps<'div'>, 'onClick' | 'children'> & {
11
+ onClick: (e: React.MouseEvent) => void
12
+ IconComponent: React.ComponentType<any>
13
+ tooltipLabel?: string
14
+ }
15
+ >
16
+
17
+ const variants = {
18
+ idle: {
19
+ '--icon-scale': 'scale(1)',
20
+ '--ai-bg': 'var(--ai-bg-idle)',
21
+ },
22
+ hovered: {
23
+ '--icon-scale': 'scale(1)',
24
+ '--ai-bg': 'var(--ai-bg-hover)',
25
+ },
26
+ selected: {},
27
+ } satisfies Variants
28
+ variants['selected'] = variants['hovered']
29
+
30
+ export const ActionButton = ({
31
+ onClick: action,
32
+ IconComponent,
33
+ tooltipLabel,
34
+ ...props
35
+ }: ActionButtonProps) => {
36
+ const ctx = useActionButtonBarCtx() ?? {
37
+ variants: variants,
38
+ }
39
+ return (
40
+ <Tooltip
41
+ fz="xs"
42
+ color="dark"
43
+ label={tooltipLabel ?? ''}
44
+ disabled={!tooltipLabel}
45
+ withinPortal={false}
46
+ offset={2}
47
+ openDelay={600}>
48
+ <ActionIcon
49
+ component={m.div}
50
+ className={clsx('nodrag nopan', css.btn)}
51
+ radius="md"
52
+ role="button"
53
+ onClick={action}
54
+ onDoubleClick={stopPropagation}
55
+ {...ctx}
56
+ {...props}
57
+ >
58
+ <IconComponent
59
+ style={{
60
+ width: '70%',
61
+ transform: 'var(--icon-scale)',
62
+ }} />
63
+ </ActionIcon>
64
+ </Tooltip>
65
+ )
66
+ }
@@ -0,0 +1,138 @@
1
+ import type { Fqn } from '@likec4/core'
2
+ import { IconFileSymlink, IconId, IconTransform, IconZoomScan } from '@tabler/icons-react'
3
+ import { useCallback } from 'react'
4
+ import { useDiagramState, useDiagramStoreApi } from '../../hooks'
5
+ import { type ActionButtonProps, ActionButton } from './ActionButton'
6
+
7
+ export type NodeActionButtonProps = Omit<ActionButtonProps, 'onClick' | 'IconComponent' | 'tooltipLabel'> & {
8
+ fqn: Fqn
9
+ }
10
+
11
+ // Browse Relationships
12
+
13
+ export const BrowseRelationshipsButton = ({
14
+ fqn,
15
+ ...props
16
+ }: NodeActionButtonProps) => {
17
+ const {
18
+ openOverlay,
19
+ } = useDiagramState(s => ({
20
+ openOverlay: s.openOverlay,
21
+ }))
22
+
23
+ const onBrowseRelationships = useCallback((e: React.MouseEvent) => {
24
+ e.stopPropagation()
25
+ openOverlay({ relationshipsOf: fqn })
26
+ }, [openOverlay, fqn])
27
+
28
+ return (
29
+ <ActionButton
30
+ {...props}
31
+ onClick={onBrowseRelationships}
32
+ IconComponent={IconTransform}
33
+ tooltipLabel="Browse relationships"
34
+ />
35
+ )
36
+ }
37
+
38
+ // Navigate to
39
+ // It triggers the onNavigateTo event from the xynode (node should have a navigateTo property)
40
+ export type NavigateToButtonProps = Omit<ActionButtonProps, 'onClick' | 'IconComponent' | 'tooltipLabel'> & {
41
+ xynodeId: string
42
+ }
43
+ export const NavigateToButton = ({
44
+ xynodeId,
45
+ ...props
46
+ }: NavigateToButtonProps) => {
47
+ const store = useDiagramStoreApi()
48
+
49
+ const onNavigateTo = useCallback((e: React.MouseEvent) => {
50
+ e.stopPropagation()
51
+ store.getState().triggerOnNavigateTo(xynodeId, e)
52
+ }, [store, xynodeId])
53
+
54
+ return (
55
+ <ActionButton
56
+ {...props}
57
+ onClick={onNavigateTo}
58
+ IconComponent={IconZoomScan}
59
+ tooltipLabel="Open scoped view"
60
+ />
61
+ )
62
+ }
63
+
64
+ // Open details
65
+ const VariantsDetailsBtn = {
66
+ idle: {
67
+ '--ai-bg': 'var(--ai-bg-idle)',
68
+ scale: 1,
69
+ opacity: 0.5,
70
+ originX: 0.45,
71
+ originY: 0.55,
72
+ },
73
+ selected: {},
74
+ hovered: {
75
+ scale: 1.2,
76
+ opacity: 0.7,
77
+ },
78
+ 'hovered:details': {
79
+ scale: 1.44,
80
+ opacity: 1,
81
+ },
82
+ 'tap:details': {
83
+ scale: 1.15,
84
+ },
85
+ }
86
+ VariantsDetailsBtn['selected'] = VariantsDetailsBtn['hovered']
87
+
88
+ export const OpenDetailsButton = ({
89
+ fqn,
90
+ ...props
91
+ }: NodeActionButtonProps) => {
92
+ const {
93
+ openOverlay,
94
+ } = useDiagramState(s => ({
95
+ openOverlay: s.openOverlay,
96
+ }))
97
+
98
+ const onOpenDetails = useCallback((e: React.MouseEvent) => {
99
+ e.stopPropagation()
100
+ openOverlay({ elementDetails: fqn })
101
+ }, [openOverlay, fqn])
102
+
103
+ return (
104
+ <ActionButton
105
+ variants={VariantsDetailsBtn}
106
+ onClick={onOpenDetails}
107
+ IconComponent={IconId}
108
+ tooltipLabel="Open details"
109
+ data-animate-target="details"
110
+ {...props}
111
+ />
112
+ )
113
+ }
114
+
115
+ // Open element source
116
+
117
+ export const OpenSourceButton = ({
118
+ fqn,
119
+ ...props
120
+ }: NodeActionButtonProps) => {
121
+ const diagramApi = useDiagramStoreApi()
122
+
123
+ const onOpenSource = useCallback((e: React.MouseEvent) => {
124
+ e.stopPropagation()
125
+ diagramApi.getState().onOpenSource?.({
126
+ element: fqn,
127
+ })
128
+ }, [diagramApi, fqn])
129
+
130
+ return (
131
+ <ActionButton
132
+ {...props}
133
+ onClick={onOpenSource}
134
+ IconComponent={IconFileSymlink}
135
+ tooltipLabel="Open source"
136
+ />
137
+ )
138
+ }
@@ -2,10 +2,16 @@ import { shallowEqual } from 'fast-equals'
2
2
  import { useContext } from 'react'
3
3
  import { useStoreWithEqualityFn as useZustandStore } from 'zustand/traditional'
4
4
 
5
+ import type { ViewId } from '@likec4/core'
5
6
  import { DiagramContext } from '../state/DiagramContext'
6
7
  import type { DiagramState, DiagramStoreApi } from '../state/diagramStore'
7
8
 
8
- function useDiagramState<StateSlice = unknown>(
9
+ const selectViewId = (state: DiagramState) => state.view.id
10
+ export function useCurrentViewId(): ViewId {
11
+ return useDiagramState(selectViewId)
12
+ }
13
+
14
+ export function useDiagramState<StateSlice = unknown>(
9
15
  selector: (state: DiagramState) => StateSlice,
10
16
  equalityFn?: (a: StateSlice, b: StateSlice) => boolean
11
17
  ): StateSlice {
@@ -18,7 +24,7 @@ function useDiagramState<StateSlice = unknown>(
18
24
  return useZustandStore(store, selector, equalityFn ?? shallowEqual)
19
25
  }
20
26
 
21
- function useDiagramStoreApi(): DiagramStoreApi {
27
+ export function useDiagramStoreApi(): DiagramStoreApi {
22
28
  const store = useContext(DiagramContext)
23
29
 
24
30
  if (store === null) {
@@ -28,4 +34,3 @@ function useDiagramStoreApi(): DiagramStoreApi {
28
34
  return store
29
35
  }
30
36
  export type { DiagramState, DiagramStoreApi }
31
- export { useDiagramState, useDiagramStoreApi }
@@ -1,14 +1,15 @@
1
- import { useNodesData, useReactFlow, useStore, useStoreApi } from '@xyflow/react'
1
+ import { useInternalNode, useNodesData, useReactFlow, useStore, useStoreApi } from '@xyflow/react'
2
2
  import { deepEqual, shallowEqual } from 'fast-equals'
3
3
  import { useCallback } from 'react'
4
- import type { XYFlowEdge, XYFlowNode, XYFlowState } from '../xyflow/types'
4
+ import type { DiagramFlowTypes } from '../xyflow/types'
5
5
 
6
- export const useXYFlow = useReactFlow<XYFlowNode, XYFlowEdge>
6
+ export const useXYFlow = useReactFlow<DiagramFlowTypes.Node, DiagramFlowTypes.Edge>
7
7
 
8
- export const useXYNodesData = useNodesData<XYFlowNode>
8
+ export const useXYNodesData = useNodesData<DiagramFlowTypes.Node>
9
+ export const useXYInternalNode = useInternalNode<DiagramFlowTypes.Node>
9
10
 
10
11
  export function useXYStore<StateSlice = unknown>(
11
- selector: (state: XYFlowState) => StateSlice,
12
+ selector: (state: DiagramFlowTypes.XYFlowState) => StateSlice,
12
13
  equalityFn?: (a: StateSlice, b: StateSlice) => boolean
13
14
  ): StateSlice {
14
15
  return useStore(
@@ -16,15 +17,15 @@ export function useXYStore<StateSlice = unknown>(
16
17
  equalityFn ?? shallowEqual
17
18
  )
18
19
  }
19
- export const useXYStoreApi = useStoreApi<XYFlowNode, XYFlowEdge>
20
+ export const useXYStoreApi = useStoreApi<DiagramFlowTypes.Node, DiagramFlowTypes.Edge>
20
21
  export type XYStoreApi = ReturnType<typeof useXYStoreApi>
21
22
 
22
- export function useXYEdgesData(edgeIds: string[]): Pick<XYFlowEdge, 'id' | 'data'>[] {
23
+ export function useXYEdgesData(edgeIds: string[]): Pick<DiagramFlowTypes.Edge, 'id' | 'data'>[] {
23
24
  const ids = edgeIds.join(',')
24
25
  const edgesData = useXYStore(
25
26
  useCallback(
26
27
  (s) => {
27
- const data = [] as Pick<XYFlowEdge, 'id' | 'data'>[]
28
+ const data = [] as Pick<DiagramFlowTypes.Edge, 'id' | 'data'>[]
28
29
  for (const id of edgeIds) {
29
30
  const edge = s.edgeLookup.get(id)
30
31
  if (edge) {
package/src/index.ts CHANGED
@@ -1,20 +1,26 @@
1
1
  import '@xyflow/react/dist/style.css'
2
2
 
3
3
  export { LikeC4Diagram } from './LikeC4Diagram'
4
+ export type { LikeC4DiagramProps } from './LikeC4Diagram'
5
+
4
6
  export {
5
7
  useLikeC4DiagramView,
8
+ useLikeC4ElementModel,
9
+ useLikeC4ElementsTree,
6
10
  useLikeC4Model,
7
11
  useLikeC4View,
8
12
  useLikeC4ViewModel,
9
- useLikeC4Views
10
- } from './likec4model/useLikeC4Model'
13
+ useLikeC4Views,
14
+ } from './likec4model'
11
15
  export { LikeC4ModelProvider } from './LikeC4ModelProvider'
12
- export { StaticLikeC4Diagram } from './StaticLikeC4Diagram'
13
16
 
14
17
  export { useSetState } from './hooks/useSetState'
15
18
  export { useUpdateEffect } from './hooks/useUpdateEffect'
16
- export type * from './LikeC4Diagram'
19
+ export { vars, xyvars } from './theme-vars'
20
+
17
21
  export type * from './LikeC4Diagram.props'
18
- export type * from './LikeC4ModelProvider'
19
- export type * from './StaticLikeC4Diagram'
22
+
20
23
  export type * from './xyflow/types'
24
+
25
+ export { StaticLikeC4Diagram } from './StaticLikeC4Diagram'
26
+ export type { StaticLikeC4DiagramProps } from './StaticLikeC4Diagram'
@@ -1,2 +1,12 @@
1
- export * from './useLikeC4ElementsTree'
2
- export * from './useLikeC4Model'
1
+ export {
2
+ useLikeC4ElementsTree,
3
+ } from './useLikeC4ElementsTree'
4
+ export {
5
+ useLikeC4CurrentViewModel,
6
+ useLikeC4DiagramView,
7
+ useLikeC4ElementModel,
8
+ useLikeC4Model,
9
+ useLikeC4View,
10
+ useLikeC4ViewModel,
11
+ useLikeC4Views,
12
+ } from './useLikeC4Model'
@@ -1,11 +1,4 @@
1
- import {
2
- compareNatural,
3
- type Fqn,
4
- type LikeC4DiagramModel,
5
- type LikeC4Model,
6
- type LikeC4ViewModel,
7
- type ViewID
8
- } from '@likec4/core'
1
+ import { compareNatural, type Fqn, type LikeC4Model, type ViewId } from '@likec4/core'
9
2
  import { useMemo } from 'react'
10
3
  import { useLikeC4Model } from './useLikeC4Model'
11
4
 
@@ -18,12 +11,12 @@ interface LikeC4ModelTreeNodeData {
18
11
  const sortByLabel = (a: LikeC4ModelTreeNodeData, b: LikeC4ModelTreeNodeData) => compareNatural(a.label, b.label)
19
12
 
20
13
  function buildNode(
21
- element: LikeC4Model.ElementModel | LikeC4DiagramModel.Element | LikeC4ViewModel.Element
14
+ element: LikeC4Model.Node | LikeC4Model.Element
22
15
  ): LikeC4ModelTreeNodeData {
23
16
  return {
24
17
  label: element.title,
25
18
  value: element.id,
26
- children: element.children().map(buildNode).sort(sortByLabel)
19
+ children: [...element.children()].map(buildNode).sort(sortByLabel)
27
20
  }
28
21
  }
29
22
 
@@ -31,14 +24,14 @@ function buildNode(
31
24
  * Returns a tree of elements in the model.
32
25
  * If `viewId` is provided, returns the tree of elements in the view.
33
26
  */
34
- export function useLikeC4ElementsTree(viewId?: ViewID): LikeC4ModelTreeNodeData[] {
27
+ export function useLikeC4ElementsTree(viewId?: ViewId): LikeC4ModelTreeNodeData[] {
35
28
  const model = useLikeC4Model(true)
36
29
  return useMemo(() => {
37
30
  if (viewId) {
38
31
  const view = model.view(viewId)
39
- return view.roots().map(buildNode).sort(sortByLabel)
32
+ return [...view.roots()].map(buildNode).sort(sortByLabel)
40
33
  } else {
41
- return model.roots().map(buildNode).sort(sortByLabel)
34
+ return [...model.roots()].map(buildNode).sort(sortByLabel)
42
35
  }
43
36
  }, [model, viewId ?? null])
44
37
  }
@@ -1,7 +1,8 @@
1
- import { type ComputedView, type DiagramView, type LikeC4Model, type ViewID } from '@likec4/core'
1
+ import { type ComputedView, type DiagramView, type Fqn, LikeC4Model, type ViewId } from '@likec4/core'
2
2
  import { useContext } from 'react'
3
3
  import { isDefined, isNonNullish, isString } from 'remeda'
4
4
  import type { LiteralUnion } from 'type-fest'
5
+ import { useCurrentViewId } from '../hooks'
5
6
  import { LikeC4ModelContext } from './LikeC4ModelContext'
6
7
 
7
8
  export function useLikeC4Model(): LikeC4Model | null
@@ -9,11 +10,11 @@ export function useLikeC4Model(strict: true): LikeC4Model
9
10
  export function useLikeC4Model(strict: boolean): LikeC4Model | null
10
11
  export function useLikeC4Model(strict: true, type: 'layouted'): LikeC4Model.Layouted
11
12
  export function useLikeC4Model(strict: true, type: 'computed'): LikeC4Model.Computed
12
- export function useLikeC4Model(strict: true, type: LikeC4Model['type'] | undefined): LikeC4Model
13
+ export function useLikeC4Model(strict: true, type: 'layouted' | 'computed' | undefined): LikeC4Model
13
14
  export function useLikeC4Model(strict: boolean, type: 'layouted'): LikeC4Model.Layouted | null
14
15
  export function useLikeC4Model(strict: boolean, type: 'computed'): LikeC4Model.Computed | null
15
- export function useLikeC4Model(strict: boolean, type: LikeC4Model['type'] | undefined): LikeC4Model | null
16
- export function useLikeC4Model(strict?: boolean, type?: LikeC4Model['type']) {
16
+ export function useLikeC4Model(strict: boolean, type: 'layouted' | 'computed' | undefined): LikeC4Model | null
17
+ export function useLikeC4Model(strict?: boolean, type?: 'layouted' | 'computed') {
17
18
  const model = useContext(LikeC4ModelContext)
18
19
 
19
20
  if (isString(type) && isNonNullish(model) && model.type !== type) {
@@ -26,33 +27,42 @@ export function useLikeC4Model(strict?: boolean, type?: LikeC4Model['type']) {
26
27
  return model
27
28
  }
28
29
 
29
- export function useLikeC4Views(): LikeC4Model.SourceModel['views'] {
30
- return useLikeC4Model(true).sourcemodel.views
30
+ export function useLikeC4Views(): Record<ViewId, ComputedView | DiagramView> {
31
+ return useLikeC4Model(true).$model.views
31
32
  }
32
33
 
33
- export function useLikeC4ViewModel(viewId: LiteralUnion<ViewID, string>): LikeC4Model.ViewModel {
34
+ export function useLikeC4ViewModel(viewId: LiteralUnion<ViewId, string>): LikeC4Model.View {
35
+ return useLikeC4Model(true).view(viewId)
36
+ }
37
+
38
+ export function useLikeC4CurrentViewModel(): LikeC4Model.View {
39
+ const viewId = useCurrentViewId()
34
40
  return useLikeC4Model(true).view(viewId)
35
41
  }
36
42
 
37
43
  /**
38
44
  * Parsed view, computed or layouted
39
45
  */
40
- export function useLikeC4View(viewId: LiteralUnion<ViewID, string>): ComputedView | DiagramView | null {
46
+ export function useLikeC4View(viewId: LiteralUnion<ViewId, string>): ComputedView | DiagramView | null {
41
47
  const model = useLikeC4Model(true)
42
48
  try {
43
- return model.view(viewId).view
49
+ return model.view(viewId).$view
44
50
  } catch (error) {
45
51
  console.warn(error)
46
52
  return null
47
53
  }
48
54
  }
49
55
 
50
- export function useLikeC4DiagramView(viewId: LiteralUnion<ViewID, string>): DiagramView | null {
56
+ export function useLikeC4DiagramView(viewId: LiteralUnion<ViewId, string>): DiagramView | null {
51
57
  const model = useLikeC4Model(true, 'layouted')
52
58
  try {
53
- return model.view(viewId).view
59
+ return model.view(viewId).$view
54
60
  } catch (error) {
55
61
  console.warn(error)
56
62
  return null
57
63
  }
58
64
  }
65
+
66
+ export function useLikeC4ElementModel(fqn: LiteralUnion<Fqn, string>): LikeC4Model.Element {
67
+ return useLikeC4Model(true).element(fqn)
68
+ }
@@ -1,9 +1,10 @@
1
- import { ActionIcon, Box, FocusTrap, RemoveScroll } from '@mantine/core'
1
+ import { ActionIcon, Box, Button, FocusTrap, Group, Notification, RemoveScroll, Text } from '@mantine/core'
2
2
  import { useHotkeys } from '@mantine/hooks'
3
3
  import { IconX } from '@tabler/icons-react'
4
4
  import { ReactFlowProvider as XYFlowProvider } from '@xyflow/react'
5
5
  import { AnimatePresence, m } from 'framer-motion'
6
6
  import { memo, type PropsWithChildren, useEffect, useMemo, useRef } from 'react'
7
+ import { ErrorBoundary, type FallbackProps } from 'react-error-boundary'
7
8
  import { isNullish } from 'remeda'
8
9
  import { type DiagramState, useDiagramState, useDiagramStoreApi } from '../hooks/useDiagramState'
9
10
  import { EdgeDetailsXYFlow } from './edge-details/EdgeDetailsXYFlow'
@@ -12,6 +13,36 @@ import { OverlayContext, useOverlayDialog } from './OverlayContext'
12
13
  import * as css from './Overlays.css'
13
14
  import { RelationshipsOverlay } from './relationships-of/RelationshipsOverlay'
14
15
 
16
+ function Fallback({ error, resetErrorBoundary }: FallbackProps) {
17
+ // Call resetErrorBoundary() to reset the error boundary and retry the render.
18
+ const errorString = error instanceof Error ? error.message : 'Unknown error'
19
+ return (
20
+ <Box className={css.container} p={'lg'}>
21
+ <Notification
22
+ icon={<IconX style={{ width: 16, height: 16 }} />}
23
+ styles={{
24
+ icon: {
25
+ alignSelf: 'flex-start'
26
+ }
27
+ }}
28
+ color={'red'}
29
+ title={'Oops, something went wrong'}
30
+ py={'lg'}
31
+ withCloseButton={false}>
32
+ <Text
33
+ style={{
34
+ whiteSpace: 'preserve-breaks'
35
+ }}>
36
+ {errorString}
37
+ </Text>
38
+ <Group gap={'xs'} mt="sm">
39
+ <Button color="gray" size="xs" variant="light" onClick={() => resetErrorBoundary()}>Reset</Button>
40
+ </Group>
41
+ </Notification>
42
+ </Box>
43
+ )
44
+ }
45
+
15
46
  export const Overlays = memo(() => {
16
47
  const diagramStore = useDiagramStoreApi()
17
48
  const {
@@ -53,68 +84,70 @@ export const Overlays = memo(() => {
53
84
 
54
85
  return (
55
86
  <OverlayContext.Provider value={ctxValue}>
56
- <AnimatePresence initial={false} key={viewId} onExitComplete={onExitComplete}>
57
- {activeOverlay?.elementDetails && (
58
- <ElementDetailsCard key={'details card'} fqn={activeOverlay.elementDetails} />
59
- )}
60
- </AnimatePresence>
61
- <AnimatePresence initial={false} onExitComplete={onExitComplete}>
62
- {activeOverlay && isNullish(activeOverlay.elementDetails) && (
63
- <RemoveScroll forwardProps>
64
- <Box
65
- component={m.div}
66
- className={css.container}
67
- data-likec4-color="gray"
68
- initial={{
69
- '--backdrop-blur': '0px',
70
- '--backdrop-opacity': '0%',
71
- opacity: 0,
72
- translateY: -15
73
- }}
74
- animate={{
75
- '--backdrop-blur': '10px',
76
- '--backdrop-opacity': '70%',
77
- opacity: 1,
78
- translateY: 0
79
- }}
80
- exit={{
81
- '--backdrop-blur': '1px',
82
- '--backdrop-opacity': '0%',
83
- translateY: -5,
84
- opacity: 0,
85
- transition: {
86
- duration: .2
87
- }
88
- }}
89
- >
90
- <FocusTrap>
91
- {activeOverlay.relationshipsOf && <RelationshipsOverlay subjectId={activeOverlay.relationshipsOf} />}
92
- {activeOverlay.edgeDetails && (
93
- <XYFlowProvider
94
- defaultNodes={[]}
95
- defaultEdges={[]}>
96
- <EdgeDetailsXYFlow edgeId={activeOverlay.edgeDetails} />
97
- </XYFlowProvider>
98
- )}
99
- <Box pos={'absolute'} top={'1rem'} right={'1rem'}>
100
- <ActionIcon
101
- variant="default"
102
- // color="gray"
103
- size={'lg'}
104
- // data-autofocus
105
- // autoFocus
106
- onClick={(e) => {
107
- e.stopPropagation()
108
- ctxValue.close()
109
- }}>
110
- <IconX />
111
- </ActionIcon>
112
- </Box>
113
- </FocusTrap>
114
- </Box>
115
- </RemoveScroll>
116
- )}
117
- </AnimatePresence>
87
+ <ErrorBoundary FallbackComponent={Fallback} onReset={() => ctxValue.close()}>
88
+ <AnimatePresence initial={false} key={viewId} onExitComplete={onExitComplete}>
89
+ {activeOverlay?.elementDetails && (
90
+ <ElementDetailsCard key={'details card'} fqn={activeOverlay.elementDetails} />
91
+ )}
92
+ </AnimatePresence>
93
+ <AnimatePresence initial={false} onExitComplete={onExitComplete}>
94
+ {activeOverlay && isNullish(activeOverlay.elementDetails) && (
95
+ <RemoveScroll forwardProps>
96
+ <Box
97
+ component={m.div}
98
+ className={css.container}
99
+ data-likec4-color="gray"
100
+ initial={{
101
+ '--backdrop-blur': '0px',
102
+ '--backdrop-opacity': '0%',
103
+ opacity: 0,
104
+ translateY: -15
105
+ }}
106
+ animate={{
107
+ '--backdrop-blur': '10px',
108
+ '--backdrop-opacity': '70%',
109
+ opacity: 1,
110
+ translateY: 0
111
+ }}
112
+ exit={{
113
+ '--backdrop-blur': '1px',
114
+ '--backdrop-opacity': '0%',
115
+ translateY: -5,
116
+ opacity: 0,
117
+ transition: {
118
+ duration: .2
119
+ }
120
+ }}
121
+ >
122
+ <FocusTrap>
123
+ {activeOverlay.relationshipsOf && <RelationshipsOverlay subjectId={activeOverlay.relationshipsOf} />}
124
+ {activeOverlay.edgeDetails && (
125
+ <XYFlowProvider
126
+ defaultNodes={[]}
127
+ defaultEdges={[]}>
128
+ <EdgeDetailsXYFlow edgeId={activeOverlay.edgeDetails} />
129
+ </XYFlowProvider>
130
+ )}
131
+ <Box pos={'absolute'} top={'1rem'} right={'1rem'}>
132
+ <ActionIcon
133
+ variant="default"
134
+ // color="gray"
135
+ size={'lg'}
136
+ // data-autofocus
137
+ // autoFocus
138
+ onClick={(e) => {
139
+ e.stopPropagation()
140
+ ctxValue.close()
141
+ }}>
142
+ <IconX />
143
+ </ActionIcon>
144
+ </Box>
145
+ </FocusTrap>
146
+ </Box>
147
+ </RemoveScroll>
148
+ )}
149
+ </AnimatePresence>
150
+ </ErrorBoundary>
118
151
  </OverlayContext.Provider>
119
152
  )
120
153
  })