@likec4/diagram 1.43.0 → 1.44.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 (301) hide show
  1. package/bundle/index.js +5746 -4674
  2. package/dist/LikeC4Diagram.d.ts +1 -1
  3. package/dist/LikeC4Diagram.js +13 -10
  4. package/dist/LikeC4Diagram.props.d.ts +16 -7
  5. package/dist/LikeC4ProjectsProvider.js +1 -1
  6. package/dist/LikeC4View.d.ts +5 -0
  7. package/dist/LikeC4View.js +22 -11
  8. package/dist/ReactLikeC4.js +2 -2
  9. package/dist/StaticLikeC4Diagram.js +1 -1
  10. package/dist/_virtual/_commonjsHelpers.js +3 -0
  11. package/dist/_virtual/assign-dea9f7c8.cjs.js +3 -0
  12. package/dist/_virtual/log-ec8d4df4.cjs.js +3 -0
  13. package/dist/_virtual/raise-da5b247f.cjs.js +3 -0
  14. package/dist/_virtual/xstate-actions.cjs.js +5 -0
  15. package/dist/_virtual/xstate-actions.cjs2.js +3 -0
  16. package/dist/_virtual/xstate-dev.cjs.js +3 -0
  17. package/dist/_virtual/xstate-guards.cjs.js +5 -0
  18. package/dist/_virtual/xstate-guards.cjs2.js +3 -0
  19. package/dist/base/Background.d.ts +2 -1
  20. package/dist/base/Background.js +11 -2
  21. package/dist/base/Base.d.ts +28 -0
  22. package/dist/base/BaseXYFlow.d.ts +5 -5
  23. package/dist/base/BaseXYFlow.js +38 -44
  24. package/dist/base/index.d.ts +6 -2
  25. package/dist/base/types.d.ts +1 -28
  26. package/dist/base/updateEdges.js +4 -3
  27. package/dist/base/updateNodes.js +3 -2
  28. package/dist/base-primitives/compound/CompoundActionButton.js +1 -1
  29. package/dist/base-primitives/compound/CompoundDetailsButton.js +1 -1
  30. package/dist/base-primitives/edge/EdgeActionButton.js +1 -1
  31. package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
  32. package/dist/base-primitives/edge/EdgeContainer.js +4 -0
  33. package/dist/base-primitives/edge/EdgeLabel.d.ts +1 -0
  34. package/dist/base-primitives/edge/EdgeLabel.js +2 -0
  35. package/dist/base-primitives/edge/EdgeLabelContainer.d.ts +1 -1
  36. package/dist/base-primitives/edge/EdgeLabelContainer.js +4 -0
  37. package/dist/base-primitives/edge/EdgePath.d.ts +4 -0
  38. package/dist/base-primitives/edge/EdgePath.js +9 -5
  39. package/dist/base-primitives/element/ElementActionButtons.d.ts +3 -2
  40. package/dist/base-primitives/element/ElementActionButtons.js +1 -1
  41. package/dist/base-primitives/element/ElementDetailsButton.js +2 -5
  42. package/dist/base-primitives/element/ElementNodeContainer.css.js +15 -27
  43. package/dist/base-primitives/element/ElementTags.js +2 -1
  44. package/dist/base-primitives/memoEdge.js +4 -2
  45. package/dist/base-primitives/memoNode.d.ts +1 -1
  46. package/dist/base-primitives/memoNode.js +3 -3
  47. package/dist/components/ErrorFallback.js +52 -35
  48. package/dist/components/Link.js +2 -2
  49. package/dist/context/DiagramEventHandlers.js +2 -1
  50. package/dist/context/DiagramFeatures.d.ts +24 -6
  51. package/dist/context/DiagramFeatures.js +28 -56
  52. package/dist/context/IconRenderer.js +6 -6
  53. package/dist/context/LikeC4ModelContext.js +3 -10
  54. package/dist/context/TagStylesContext.js +2 -18
  55. package/dist/context/index.d.ts +1 -1
  56. package/dist/custom/customNodes.js +3 -2
  57. package/dist/custom/hooks.d.ts +1 -1
  58. package/dist/custom/index.d.ts +1 -1
  59. package/dist/custom/index.js +4 -4
  60. package/dist/editor/LikeC4EditorContext.d.ts +21 -0
  61. package/dist/editor/index.d.ts +2 -0
  62. package/dist/hooks/index.d.ts +2 -1
  63. package/dist/hooks/safeContext.d.ts +6 -3
  64. package/dist/hooks/safeContext.js +10 -3
  65. package/dist/hooks/useCallbackRef.d.ts +1 -0
  66. package/dist/hooks/useCallbackRef.js +13 -0
  67. package/dist/hooks/useCurrentView.d.ts +11 -0
  68. package/dist/hooks/{useCurrentViewId.js → useCurrentView.js} +7 -3
  69. package/dist/hooks/useCurrentViewModel.js +4 -1
  70. package/dist/hooks/useDiagram.d.ts +7 -113
  71. package/dist/hooks/useDiagram.js +7 -127
  72. package/dist/hooks/useDiagramCompareLayout.d.ts +35 -0
  73. package/dist/hooks/useDiagramCompareLayout.js +60 -0
  74. package/dist/hooks/useUpdateEffect.js +2 -4
  75. package/dist/hooks/useXYFlow.d.ts +1 -0
  76. package/dist/hooks/useXYFlow.js +4 -7
  77. package/dist/index.d.ts +2 -2
  78. package/dist/index.js +4 -3
  79. package/dist/likec4diagram/DiagramUI.js +14 -7
  80. package/dist/likec4diagram/DiagramXYFlow.d.ts +2 -2
  81. package/dist/likec4diagram/DiagramXYFlow.js +54 -51
  82. package/dist/likec4diagram/convert-to-xyflow.d.ts +0 -1
  83. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +249 -220
  84. package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +7 -2
  85. package/dist/likec4diagram/custom/edges/edges.css.js +3 -4
  86. package/dist/likec4diagram/custom/edges/useControlPoints.d.ts +8 -0
  87. package/dist/likec4diagram/custom/edges/useControlPoints.js +58 -0
  88. package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.d.ts +7 -0
  89. package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.js +60 -0
  90. package/dist/likec4diagram/custom/edges/utils.d.ts +0 -12
  91. package/dist/likec4diagram/custom/nodes/CompoundActions.js +4 -1
  92. package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -1
  93. package/dist/likec4diagram/custom/nodes/ElementActions.js +15 -10
  94. package/dist/likec4diagram/custom/nodes/ElementNodeDrifts.d.ts +4 -0
  95. package/dist/likec4diagram/custom/nodes/ElementNodeDrifts.js +46 -0
  96. package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +4 -1
  97. package/dist/likec4diagram/custom/nodes/nodes.d.ts +9 -1
  98. package/dist/likec4diagram/custom/nodes/nodes.js +13 -9
  99. package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.d.ts +1 -1
  100. package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.js +1 -1
  101. package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +2 -1
  102. package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.js +4 -3
  103. package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +1 -11
  104. package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +7 -51
  105. package/dist/likec4diagram/custom/nodes/toolbar/types.d.ts +5 -0
  106. package/dist/likec4diagram/custom/nodes/toolbar/types.js +7 -0
  107. package/dist/likec4diagram/custom/nodes/toolbar/useHandlers.d.ts +8 -0
  108. package/dist/likec4diagram/custom/nodes/toolbar/useHandlers.js +44 -0
  109. package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +5 -7
  110. package/dist/likec4diagram/state/DiagramActorProvider.d.ts +3 -2
  111. package/dist/likec4diagram/state/DiagramActorProvider.js +96 -70
  112. package/dist/likec4diagram/state/assign.d.ts +4 -2
  113. package/dist/likec4diagram/state/assign.js +39 -103
  114. package/dist/likec4diagram/state/createViewChange.d.ts +3 -0
  115. package/dist/likec4diagram/state/createViewChange.js +90 -0
  116. package/dist/likec4diagram/state/diagram-api.d.ts +113 -0
  117. package/dist/likec4diagram/state/diagram-api.js +134 -0
  118. package/dist/likec4diagram/state/hotkeyActor.d.ts +7 -0
  119. package/dist/likec4diagram/state/hotkeyActor.js +17 -1
  120. package/dist/likec4diagram/state/machine.actions.d.ts +2099 -0
  121. package/dist/likec4diagram/state/machine.actions.js +735 -0
  122. package/dist/likec4diagram/state/machine.d.ts +3717 -0
  123. package/dist/likec4diagram/state/machine.js +141 -0
  124. package/dist/likec4diagram/state/machine.setup.d.ts +284 -0
  125. package/dist/likec4diagram/state/machine.setup.js +71 -0
  126. package/dist/likec4diagram/state/machine.state.initializing.d.ts +183 -0
  127. package/dist/likec4diagram/state/machine.state.initializing.js +55 -0
  128. package/dist/likec4diagram/state/machine.state.navigating.d.ts +117 -0
  129. package/dist/likec4diagram/state/machine.state.navigating.js +45 -0
  130. package/dist/likec4diagram/state/machine.state.ready.d.ts +3666 -0
  131. package/dist/likec4diagram/state/machine.state.ready.js +437 -0
  132. package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +220 -63
  133. package/dist/likec4diagram/state/syncManualLayoutActor.js +218 -143
  134. package/dist/likec4diagram/state/types.d.ts +4 -7
  135. package/dist/likec4diagram/state/utils.d.ts +4 -2
  136. package/dist/likec4diagram/state/utils.js +4 -1
  137. package/dist/likec4diagram/types.d.ts +6 -1
  138. package/dist/likec4diagram/ui/LayoutDriftFrame.d.ts +2 -0
  139. package/dist/likec4diagram/ui/LayoutDriftFrame.js +66 -0
  140. package/dist/likec4diagram/ui/index.d.ts +1 -0
  141. package/dist/likec4diagram/ui/notation/NotationPanel.js +5 -4
  142. package/dist/likec4diagram/useLayoutConstraints.d.ts +10 -5
  143. package/dist/likec4diagram/useLayoutConstraints.js +225 -54
  144. package/dist/likec4diagram/xyflow-diagram/diagram-view.d.ts +0 -1
  145. package/dist/likec4diagram/xyflow-diagram/diagram-view.js +15 -15
  146. package/dist/navigationpanel/NavigationPanel.js +11 -7
  147. package/dist/navigationpanel/NavigationPanelControls.d.ts +2 -1
  148. package/dist/navigationpanel/NavigationPanelControls.js +23 -17
  149. package/dist/navigationpanel/NavigationPanelDropdown.d.ts +2 -1
  150. package/dist/navigationpanel/NavigationPanelDropdown.js +62 -42
  151. package/dist/navigationpanel/_common.d.ts +1 -1
  152. package/dist/navigationpanel/_common.js +4 -2
  153. package/dist/navigationpanel/actor.d.ts +11 -7
  154. package/dist/navigationpanel/actor.js +5 -4
  155. package/dist/navigationpanel/comparepanel/CompareActionsMenu.d.ts +3 -0
  156. package/dist/navigationpanel/comparepanel/CompareActionsMenu.js +59 -0
  157. package/dist/navigationpanel/comparepanel/ComparePanel.d.ts +2 -0
  158. package/dist/navigationpanel/comparepanel/ComparePanel.js +42 -0
  159. package/dist/navigationpanel/comparepanel/ComparePanelControls.d.ts +1 -0
  160. package/dist/navigationpanel/comparepanel/ComparePanelControls.js +60 -0
  161. package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.d.ts +5 -0
  162. package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.js +38 -0
  163. package/dist/navigationpanel/comparepanel/index.d.ts +1 -0
  164. package/dist/navigationpanel/controls/{ViewDetailsCard.d.ts → DetailsControls.d.ts} +1 -1
  165. package/dist/navigationpanel/controls/{ViewDetailsCard.js → DetailsControls.js} +18 -14
  166. package/dist/navigationpanel/controls/LayoutWarning.d.ts +2 -0
  167. package/dist/navigationpanel/controls/LayoutWarning.js +102 -0
  168. package/dist/navigationpanel/controls/NavigationButtons.js +4 -3
  169. package/dist/navigationpanel/controls/OpenSource.js +2 -2
  170. package/dist/navigationpanel/controls/SearchControl.d.ts +2 -1
  171. package/dist/navigationpanel/controls/SearchControl.js +15 -17
  172. package/dist/navigationpanel/controls/ToggleReadonly.d.ts +1 -1
  173. package/dist/navigationpanel/controls/ToggleReadonly.js +19 -16
  174. package/dist/navigationpanel/controls/index.d.ts +2 -1
  175. package/dist/navigationpanel/dropdown/ProjectsMenu.d.ts +2 -2
  176. package/dist/navigationpanel/dropdown/ProjectsMenu.js +5 -5
  177. package/dist/navigationpanel/editorpanel/CenterCamera.js +5 -2
  178. package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.d.ts +1 -1
  179. package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.js +21 -20
  180. package/dist/navigationpanel/editorpanel/EditorPanel.js +3 -3
  181. package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.d.ts +2 -2
  182. package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +16 -13
  183. package/dist/navigationpanel/editorpanel/ToggleReadonly.d.ts +1 -0
  184. package/dist/navigationpanel/editorpanel/ToggleReadonly.js +15 -0
  185. package/dist/navigationpanel/styles.css.d.ts +2 -2
  186. package/dist/navigationpanel/styles.css.js +4 -4
  187. package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +14 -8
  188. package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +10 -10
  189. package/dist/navigationpanel/walkthrough/DynamicViewControls.js +31 -14
  190. package/dist/navigationpanel/walkthrough/WalkthroughPanel.d.ts +2 -1
  191. package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +66 -49
  192. package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/actions/dist/xstate-actions.cjs.js +37 -0
  193. package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dev/dist/xstate-dev.cjs.js +59 -0
  194. package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dist/assign-dea9f7c8.cjs.js +140 -0
  195. package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dist/log-ec8d4df4.cjs.js +401 -0
  196. package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dist/raise-da5b247f.cjs.js +2716 -0
  197. package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/guards/dist/xstate-guards.cjs.js +26 -0
  198. package/dist/overlays/element-details/ElementDetails.js +7 -7
  199. package/dist/overlays/element-details/ElementDetailsCard.js +7 -5
  200. package/dist/overlays/element-details/MetadataValue.js +2 -2
  201. package/dist/overlays/element-details/TabPanelDeployments.js +6 -4
  202. package/dist/overlays/element-details/TabPanelRelationships.js +3 -3
  203. package/dist/overlays/element-details/TabPanelStructure.js +1 -1
  204. package/dist/overlays/element-details/actor.d.ts +3 -2
  205. package/dist/overlays/overlaysActor.d.ts +304 -62
  206. package/dist/overlays/overlaysActor.js +132 -131
  207. package/dist/overlays/relationship-details/RelationshipDetails.js +4 -3
  208. package/dist/overlays/relationship-details/SelectEdge.js +2 -2
  209. package/dist/overlays/relationship-details/actor.d.ts +14 -2
  210. package/dist/overlays/relationship-details/actor.js +17 -3
  211. package/dist/overlays/relationship-details/custom/ElementActions.js +8 -5
  212. package/dist/overlays/relationship-details/custom/edgeTypes.js +4 -1
  213. package/dist/overlays/relationship-details/custom/nodeTypes.js +4 -1
  214. package/dist/overlays/relationship-details/hooks.js +1 -1
  215. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +6 -4
  216. package/dist/overlays/relationships-browser/SelectElement.js +2 -2
  217. package/dist/overlays/relationships-browser/actor.d.ts +239 -173
  218. package/dist/overlays/relationships-browser/actor.js +132 -110
  219. package/dist/overlays/relationships-browser/custom/ElementActions.js +44 -37
  220. package/dist/overlays/relationships-browser/custom/edgeTypes.js +4 -1
  221. package/dist/overlays/relationships-browser/custom/nodeTypes.js +4 -1
  222. package/dist/overlays/relationships-browser/hooks.js +7 -6
  223. package/dist/search/Search.js +2 -1
  224. package/dist/search/components/ElementsColumn.js +5 -3
  225. package/dist/search/components/PickView.js +1 -1
  226. package/dist/search/components/SearchByTags.js +21 -44
  227. package/dist/search/components/SearchInput.js +1 -1
  228. package/dist/search/components/ViewsColum.js +6 -4
  229. package/dist/shadowroot/ShadowRoot.js +1 -1
  230. package/dist/styles.css2.js +1 -1
  231. package/dist/utils/index.d.ts +4 -4
  232. package/dist/utils/vector.d.ts +78 -21
  233. package/dist/utils/vector.js +91 -24
  234. package/dist/utils/view-bounds.d.ts +8 -0
  235. package/dist/utils/view-bounds.js +57 -0
  236. package/dist/utils/xyflow.d.ts +49 -7
  237. package/dist/utils/xyflow.js +63 -11
  238. package/package.json +19 -18
  239. package/panda.buildinfo.json +107 -66
  240. package/styles-min.css +1 -1
  241. package/styles.css +1 -1
  242. package/dist/hooks/useCurrentViewId.d.ts +0 -6
  243. package/dist/likec4diagram/custom/edges/utils.js +0 -23
  244. package/dist/likec4diagram/state/diagram-machine.d.ts +0 -2590
  245. package/dist/likec4diagram/state/diagram-machine.js +0 -1180
  246. package/dist/navigationpanel/editorpanel/LayoutDriftNotification.d.ts +0 -1
  247. package/dist/navigationpanel/editorpanel/LayoutDriftNotification.js +0 -56
  248. package/dist/utils/get-view-bounds.d.ts +0 -3
  249. package/dist/utils/get-view-bounds.js +0 -14
  250. /package/dist/base/{types.js → Base.js} +0 -0
  251. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +0 -0
  252. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +0 -0
  253. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconAlertTriangle.js +0 -0
  254. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowDownRight.js +0 -0
  255. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowLeft.js +0 -0
  256. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +0 -0
  257. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconBolt.js +0 -0
  258. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconBrowser.js +0 -0
  259. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js +0 -0
  260. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronDown.js +0 -0
  261. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +0 -0
  262. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronRight.js +0 -0
  263. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +0 -0
  264. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconCylinder.js +0 -0
  265. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconDeviceMobile.js +0 -0
  266. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconDirectionSignFilled.js +0 -0
  267. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconExternalLink.js +0 -0
  268. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconFileSymlink.js +0 -0
  269. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconFocusCentered.js +0 -0
  270. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconFolderFilled.js +0 -0
  271. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconHelpCircle.js +0 -0
  272. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconId.js +0 -0
  273. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconInfoCircle.js +0 -0
  274. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignBottom.js +0 -0
  275. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignCenter.js +0 -0
  276. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignLeft.js +0 -0
  277. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignMiddle.js +0 -0
  278. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignRight.js +0 -0
  279. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignTop.js +0 -0
  280. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutBoardSplit.js +0 -0
  281. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutCollage.js +0 -0
  282. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutDashboard.js +0 -0
  283. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLink.js +0 -0
  284. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLock.js +0 -0
  285. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLockOpen2.js +0 -0
  286. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerPlayFilled.js +0 -0
  287. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipBackFilled.js +0 -0
  288. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipForwardFilled.js +0 -0
  289. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerStopFilled.js +0 -0
  290. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconRectangularPrism.js +0 -0
  291. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconReorder.js +0 -0
  292. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconRouteOff.js +0 -0
  293. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +0 -0
  294. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconSelector.js +0 -0
  295. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconStack2.js +0 -0
  296. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconStarFilled.js +0 -0
  297. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconTarget.js +0 -0
  298. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconTransform.js +0 -0
  299. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconUser.js +0 -0
  300. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconX.js +0 -0
  301. /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconZoomScan.js +0 -0
@@ -1,132 +1,12 @@
1
- import { useCallbackRef } from '@mantine/hooks';
2
1
  import { useSelector } from '@xstate/react';
3
2
  import { shallowEqual } from 'fast-equals';
4
- import { useMemo, useCallback, useRef, useEffect } from 'react';
5
- import { findDiagramEdge, findDiagramNode } from '../likec4diagram/state/utils.js';
3
+ import { useCallback, useRef, useEffect } from 'react';
6
4
  import { useDiagramActorRef } from './safeContext.js';
5
+ export { useDiagram } from './safeContext.js';
7
6
 
8
- function useDiagram() {
9
- const actor = useDiagramActorRef();
10
- return useMemo(() => ({
11
- actor,
12
- send: (event) => actor.send(event),
13
- navigateTo: (viewId, fromNode) => {
14
- actor.send({
15
- type: "navigate.to",
16
- viewId,
17
- ...fromNode && { fromNode }
18
- });
19
- },
20
- navigate: (direction) => {
21
- actor.send({ type: `navigate.${direction}` });
22
- },
23
- fitDiagram: (duration = 350) => {
24
- actor.send({ type: "fitDiagram", duration });
25
- },
26
- openRelationshipsBrowser: (fqn) => {
27
- actor.send({ type: "open.relationshipsBrowser", fqn });
28
- },
29
- openSource: (params) => {
30
- actor.send({ type: "open.source", ...params });
31
- },
32
- openElementDetails: (fqn, fromNode) => {
33
- actor.send({ type: "open.elementDetails", fqn, fromNode });
34
- },
35
- openRelationshipDetails: (...params) => {
36
- if (params.length === 1) {
37
- actor.send({ type: "open.relationshipDetails", params: { edgeId: params[0] } });
38
- } else {
39
- actor.send({ type: "open.relationshipDetails", params: { source: params[0], target: params[1] } });
40
- }
41
- },
42
- updateNodeData: (nodeId, data) => {
43
- actor.send({ type: "update.nodeData", nodeId, data });
44
- },
45
- updateEdgeData: (edgeId, data) => {
46
- actor.send({
47
- type: "update.edgeData",
48
- edgeId,
49
- data
50
- });
51
- },
52
- scheduleSaveManualLayout: () => {
53
- actor.send({ type: "saveManualLayout.schedule" });
54
- },
55
- /**
56
- * @returns true if there was pending request to save layout
57
- */
58
- cancelSaveManualLayout: () => {
59
- const syncState = actor.getSnapshot().children.syncLayout?.getSnapshot().value;
60
- actor.send({ type: "saveManualLayout.cancel" });
61
- return syncState === "pending" || syncState === "paused";
62
- },
63
- align: (mode) => {
64
- actor.send({ type: "layout.align", mode });
65
- },
66
- resetEdgeControlPoints: () => {
67
- actor.send({ type: "layout.resetEdgeControlPoints" });
68
- },
69
- focusNode: (nodeId) => {
70
- actor.send({ type: "focus.node", nodeId });
71
- },
72
- /**
73
- * @warning Do not use in render phase
74
- */
75
- get currentView() {
76
- return actor.getSnapshot().context.view;
77
- },
78
- /**
79
- * @warning Do not use in render phase
80
- */
81
- getSnapshot: () => actor.getSnapshot(),
82
- /**
83
- * @warning Do not use in render phase
84
- */
85
- getContext: () => actor.getSnapshot().context,
86
- /**
87
- * @warning Do not use in render phase
88
- */
89
- findDiagramNode: (xynodeId) => {
90
- return findDiagramNode(actor.getSnapshot().context, xynodeId);
91
- },
92
- findEdge: (xyedgeId) => {
93
- return actor.getSnapshot().context.xyedges.find((e) => e.data.id === xyedgeId) ?? null;
94
- },
95
- /**
96
- * @warning Do not use in render phase
97
- */
98
- findDiagramEdge: (xyedgeId) => {
99
- return findDiagramEdge(actor.getSnapshot().context, xyedgeId);
100
- },
101
- startWalkthrough: () => {
102
- actor.send({ type: "walkthrough.start" });
103
- },
104
- walkthroughStep: (direction = "next") => {
105
- actor.send({ type: "walkthrough.step", direction });
106
- },
107
- stopWalkthrough: () => {
108
- actor.send({ type: "walkthrough.end" });
109
- },
110
- toggleFeature: (feature, forceValue) => {
111
- actor.send({ type: "toggle.feature", feature, ...forceValue !== void 0 && { forceValue } });
112
- },
113
- highlightNotation: (notation, kind) => {
114
- actor.send({ type: "notations.highlight", notation, ...kind && { kind } });
115
- },
116
- unhighlightNotation: () => {
117
- actor.send({ type: "notations.unhighlight" });
118
- },
119
- openSearch: (searchValue) => {
120
- actor.send({ type: "open.search", ...searchValue && { search: searchValue } });
121
- },
122
- switchDynamicViewVariant: (variant) => {
123
- actor.send({ type: "switch.dynamicViewVariant", variant });
124
- }
125
- }), [actor]);
126
- }
127
7
  function useDiagramActorSnapshot(selector, compare = shallowEqual) {
128
8
  const actorRef = useDiagramActorRef();
129
- return useSelector(actorRef, useCallbackRef(selector), compare);
9
+ return useSelector(actorRef, selector, compare);
130
10
  }
131
11
  function useDiagramContext(selector, compare = shallowEqual, deps) {
132
12
  const actorRef = useDiagramActorRef();
@@ -138,13 +18,13 @@ function useOnDiagramEvent(event, callback) {
138
18
  const callbackRef = useRef(callback);
139
19
  callbackRef.current = callback;
140
20
  useEffect(() => {
141
- const subscription = actorRef.on(event, (event2) => {
142
- callbackRef.current(event2);
21
+ const subscription = actorRef.on(event, (payload) => {
22
+ callbackRef.current(payload);
143
23
  });
144
24
  return () => {
145
25
  subscription.unsubscribe();
146
26
  };
147
- }, [actorRef]);
27
+ }, [actorRef, event]);
148
28
  }
149
29
 
150
- export { useDiagram, useDiagramActorRef, useDiagramActorSnapshot, useDiagramContext, useOnDiagramEvent };
30
+ export { useDiagramActorRef, useDiagramActorSnapshot, useDiagramContext, useOnDiagramEvent };
@@ -0,0 +1,35 @@
1
+ import { DiagramActorSnapshot } from '../likec4diagram/state/types';
2
+ import type * as t from '@likec4/core/types';
3
+ declare const selectCompareLayoutState: ({ context }: DiagramActorSnapshot) => {
4
+ isEnabled: false;
5
+ isEditable: false;
6
+ isActive: false;
7
+ drifts: never[];
8
+ layout: t.LayoutType;
9
+ } | {
10
+ isEnabled: true;
11
+ isEditable: boolean;
12
+ isActive: boolean;
13
+ drifts: t.NonEmptyReadonlyArray<t.LayoutedViewDriftReason>;
14
+ layout: t.LayoutType;
15
+ };
16
+ type DiagramCompareLayoutState = ReturnType<typeof selectCompareLayoutState>;
17
+ type DiagramCompareLayoutOps = {
18
+ /**
19
+ * Toggles the compare mode on or off.
20
+ */
21
+ toggleCompare: (force?: 'on' | 'off') => void;
22
+ /**
23
+ * Switches the layout type between 'auto' and 'manual'.
24
+ */
25
+ switchLayout: (layoutType: t.LayoutType) => void;
26
+ /**
27
+ * Resets the manual layout to its default state.
28
+ */
29
+ resetManualLayout: () => void;
30
+ };
31
+ export declare function useDiagramCompareLayout(): [
32
+ DiagramCompareLayoutState,
33
+ DiagramCompareLayoutOps
34
+ ];
35
+ export {};
@@ -0,0 +1,60 @@
1
+ import { useSelector } from '@xstate/react';
2
+ import { shallowEqual } from 'fast-equals';
3
+ import { useDiagramActorRef } from './safeContext.js';
4
+ import { useCallbackRef } from './useCallbackRef.js';
5
+
6
+ const selectCompareLayoutState = ({ context }) => {
7
+ const drifts = context.view.drifts ?? null;
8
+ if (!context.features.enableCompareWithLatest || !drifts) {
9
+ return {
10
+ isEnabled: false,
11
+ isEditable: false,
12
+ isActive: false,
13
+ drifts: [],
14
+ layout: context.view._layout ?? "auto"
15
+ };
16
+ }
17
+ return {
18
+ isEnabled: true,
19
+ isEditable: !context.features.enableReadOnly,
20
+ isActive: context.toggledFeatures.enableCompareWithLatest === true,
21
+ drifts,
22
+ layout: context.view._layout ?? "auto"
23
+ };
24
+ };
25
+ function useDiagramCompareLayout() {
26
+ const actorRef = useDiagramActorRef();
27
+ const state = useSelector(actorRef, selectCompareLayoutState, shallowEqual);
28
+ const switchLayout = useCallbackRef((layoutType) => {
29
+ if (!state.isEnabled) {
30
+ console.warn("Compare with latest feature is not enabled");
31
+ return;
32
+ }
33
+ actorRef.send({ type: "emit.onLayoutTypeChange", layoutType });
34
+ });
35
+ const toggleCompare = useCallbackRef((force) => {
36
+ if (!state.isEnabled) {
37
+ console.warn("Compare with latest feature is not enabled");
38
+ return;
39
+ }
40
+ const nextIsActive = force ? force === "on" : !state.isActive;
41
+ if (state.isActive && !nextIsActive && state.layout === "auto") {
42
+ switchLayout("manual");
43
+ }
44
+ actorRef.send({
45
+ type: "toggle.feature",
46
+ feature: "CompareWithLatest",
47
+ forceValue: nextIsActive
48
+ });
49
+ });
50
+ const resetManualLayout = useCallbackRef(() => {
51
+ if (!state.isEnabled) {
52
+ console.warn("Compare with latest feature is not enabled");
53
+ return;
54
+ }
55
+ actorRef.send({ type: "layout.resetManualLayout" });
56
+ });
57
+ return [state, { toggleCompare, switchLayout, resetManualLayout }];
58
+ }
59
+
60
+ export { useDiagramCompareLayout };
@@ -11,12 +11,10 @@ const depsShallowEqual = (d1, d2) => {
11
11
  return false;
12
12
  }
13
13
  for (const [i, element] of d1.entries()) {
14
- if (element === d2[i]) {
14
+ if (element === d2[i] || shallowEqual(element, d2[i])) {
15
15
  continue;
16
16
  }
17
- if (!shallowEqual(element, d2[i])) {
18
- return false;
19
- }
17
+ return false;
20
18
  }
21
19
  return true;
22
20
  };
@@ -8,6 +8,7 @@ export declare function useXYStoreApi(): XYStoreApi;
8
8
  export type XYStoreApi = {
9
9
  getState: () => XYStoreState;
10
10
  setState: (state: Partial<XYStoreState> | ((state: XYStoreState) => Partial<XYStoreState>)) => void;
11
+ subscribe: (listener: (state: XYStoreState, prevState: XYStoreState) => void) => () => void;
11
12
  };
12
13
  export type XYInternalNode = InternalNode<Types.AnyNode>;
13
14
  export declare function useXYInternalNode(id: string): XYInternalNode | undefined;
@@ -1,6 +1,6 @@
1
- import { useCallbackRef } from '@mantine/hooks';
2
- import { useStore, useStoreApi, useReactFlow, useInternalNode } from '@xyflow/react';
1
+ import { useStore, useStoreApi, useReactFlow } from '@xyflow/react';
3
2
  import { shallowEqual } from 'fast-equals';
3
+ import { useCallbackRef } from './useCallbackRef.js';
4
4
 
5
5
  function useXYFlow() {
6
6
  return useReactFlow();
@@ -8,15 +8,12 @@ function useXYFlow() {
8
8
  function useXYStore(selector, equalityFn) {
9
9
  return useStore(
10
10
  useCallbackRef(selector),
11
- shallowEqual
11
+ equalityFn ?? shallowEqual
12
12
  );
13
13
  }
14
14
  function useXYStoreApi() {
15
15
  return useStoreApi();
16
16
  }
17
- function useXYInternalNode(id) {
18
- return useInternalNode(id);
19
- }
20
17
  const selectCurrentZoom = (state) => Math.round(state.transform[2] * 100) / 100;
21
18
  function useCurrentZoom() {
22
19
  return useStore(selectCurrentZoom);
@@ -26,4 +23,4 @@ function useIsZoomTooSmall() {
26
23
  return useStore(selectZoom);
27
24
  }
28
25
 
29
- export { useCurrentZoom, useIsZoomTooSmall, useXYFlow, useXYInternalNode, useXYStore, useXYStoreApi };
26
+ export { useCurrentZoom, useIsZoomTooSmall, useXYFlow, useXYStore, useXYStoreApi };
package/dist/index.d.ts CHANGED
@@ -14,5 +14,5 @@ export { StaticLikeC4Diagram } from './StaticLikeC4Diagram';
14
14
  export { LikeC4View } from './LikeC4View';
15
15
  export type { LikeC4BrowserProps, LikeC4ViewProps } from './LikeC4View';
16
16
  export { ReactLikeC4, type ReactLikeC4Props } from './ReactLikeC4';
17
- export { useCurrentViewId } from './hooks/useCurrentViewId';
18
- export { getViewBounds } from './utils/get-view-bounds';
17
+ export { useCurrentViewId } from './hooks/useCurrentView';
18
+ export { pickViewBounds } from './utils/view-bounds';
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ export { IconRendererProvider } from './context/IconRenderer.js';
2
2
  export { LikeC4Diagram } from './LikeC4Diagram.js';
3
3
  export { LikeC4ModelProvider } from './LikeC4ModelProvider.js';
4
4
  export { LikeC4ProjectsProvider } from './LikeC4ProjectsProvider.js';
5
- export { useDiagram, useDiagramContext, useOnDiagramEvent } from './hooks/useDiagram.js';
5
+ export { useDiagramContext, useOnDiagramEvent } from './hooks/useDiagram.js';
6
6
  export { useLikeC4Model, useLikeC4Specification, useLikeC4ViewModel } from './hooks/useLikeC4Model.js';
7
7
  export { useCurrentViewModel } from './hooks/useCurrentViewModel.js';
8
8
  export { useHasProjects, useLikeC4ProjectId, useLikeC4Projects, useLikeC4ProjectsContext } from './hooks/useLikeC4Project.js';
@@ -11,5 +11,6 @@ export { useUpdateEffect } from './hooks/useUpdateEffect.js';
11
11
  export { StaticLikeC4Diagram } from './StaticLikeC4Diagram.js';
12
12
  export { LikeC4View } from './LikeC4View.js';
13
13
  export { ReactLikeC4 } from './ReactLikeC4.js';
14
- export { useCurrentViewId } from './hooks/useCurrentViewId.js';
15
- export { getViewBounds } from './utils/get-view-bounds.js';
14
+ export { useCurrentViewId } from './hooks/useCurrentView.js';
15
+ export { pickViewBounds } from './utils/view-bounds.js';
16
+ export { useDiagram } from './hooks/safeContext.js';
@@ -1,33 +1,40 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { useRerender } from '@react-hookz/web';
3
- import { memo } from 'react';
3
+ import { memo, useCallback } from 'react';
4
4
  import { ErrorBoundary } from '../components/ErrorFallback.js';
5
- import { EnsureCurrentViewModel } from '../context/LikeC4ModelContext.js';
5
+ import { useEnabledFeatures } from '../context/DiagramFeatures.js';
6
6
  import { useOverlaysActorRef } from '../hooks/useOverlaysActor.js';
7
7
  import { useSearchActorRef } from '../hooks/useSearchActor.js';
8
8
  import { Overlays } from '../overlays/Overlays.js';
9
9
  import { Search } from '../search/Search.js';
10
10
  import { RelationshipPopover } from './relationship-popover/RelationshipPopover.js';
11
- import { useEnabledFeatures } from '../context/DiagramFeatures.js';
12
11
  import { NavigationPanel } from '../navigationpanel/NavigationPanel.js';
13
12
  import { NotationPanel } from './ui/notation/NotationPanel.js';
13
+ import { LayoutDriftFrame } from './ui/LayoutDriftFrame.js';
14
14
 
15
15
  const LikeC4DiagramUI = memo(() => {
16
16
  const {
17
17
  enableControls,
18
18
  enableNotations,
19
19
  enableSearch,
20
- enableRelationshipDetails
20
+ enableRelationshipDetails,
21
+ enableReadOnly,
22
+ enableCompareWithLatest
21
23
  } = useEnabledFeatures();
22
24
  const rerender = useRerender();
23
25
  const overlaysActorRef = useOverlaysActorRef();
24
26
  const searchActorRef = useSearchActorRef();
25
- return /* @__PURE__ */ jsxs(ErrorBoundary, { onReset: rerender, children: [
26
- enableControls && /* @__PURE__ */ jsx(EnsureCurrentViewModel, { children: /* @__PURE__ */ jsx(NavigationPanel, {}) }),
27
+ const handleReset = useCallback(() => {
28
+ console.warn("DiagramUI: resetting error boundary and rerendering...");
29
+ rerender();
30
+ }, []);
31
+ return /* @__PURE__ */ jsxs(ErrorBoundary, { onReset: handleReset, children: [
32
+ enableControls && /* @__PURE__ */ jsx(NavigationPanel, {}),
27
33
  overlaysActorRef && /* @__PURE__ */ jsx(Overlays, { overlaysActorRef }),
28
34
  enableNotations && /* @__PURE__ */ jsx(NotationPanel, {}),
29
35
  enableSearch && searchActorRef && /* @__PURE__ */ jsx(Search, { searchActorRef }),
30
- enableRelationshipDetails && /* @__PURE__ */ jsx(RelationshipPopover, {})
36
+ enableRelationshipDetails && enableReadOnly && /* @__PURE__ */ jsx(RelationshipPopover, {}),
37
+ enableCompareWithLatest && /* @__PURE__ */ jsx(LayoutDriftFrame, {})
31
38
  ] });
32
39
  });
33
40
  LikeC4DiagramUI.displayName = "DiagramUI";
@@ -1,5 +1,5 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { Simplify } from 'type-fest';
3
3
  import { LikeC4DiagramProperties } from '../LikeC4Diagram.props';
4
- export type LikeC4DiagramXYFlowProps = PropsWithChildren<Simplify<Pick<LikeC4DiagramProperties<any>, 'background' | 'nodesDraggable' | 'nodesSelectable' | 'reactFlowProps' | 'renderNodes'>>>;
5
- export declare function LikeC4DiagramXYFlow({ background, nodesDraggable, nodesSelectable, reactFlowProps, children, renderNodes, }: LikeC4DiagramXYFlowProps): import("react/jsx-runtime").JSX.Element;
4
+ export type LikeC4DiagramXYFlowProps = PropsWithChildren<Simplify<Pick<LikeC4DiagramProperties<any>, 'background' | 'reactFlowProps' | 'renderNodes'>>>;
5
+ export declare function LikeC4DiagramXYFlow({ background, reactFlowProps, children, renderNodes, }: LikeC4DiagramXYFlowProps): import("react/jsx-runtime").JSX.Element;
@@ -1,18 +1,20 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { nonNullable } from '@likec4/core';
3
3
  import { cx } from '@likec4/styles/css';
4
- import { useTimeout, useDebouncedCallback, useCallbackRef } from '@mantine/hooks';
4
+ import { useTimeout, useDebouncedCallback } from '@mantine/hooks';
5
5
  import { useCustomCompareMemo } from '@react-hookz/web';
6
- import { deepEqual, shallowEqual } from 'fast-equals';
6
+ import { shallowEqual } from 'fast-equals';
7
7
  import { isEmpty } from 'remeda';
8
8
  import { memoNode } from '../base-primitives/memoNode.js';
9
9
  import { BaseXYFlow } from '../base/BaseXYFlow.js';
10
10
  import { useIsReducedGraphics, usePanningAtom } from '../context/RootContainerContext.js';
11
- import { useDiagram, useDiagramContext } from '../hooks/useDiagram.js';
11
+ import { useDiagramActorSnapshot } from '../hooks/useDiagram.js';
12
12
  import { depsShallowEqual, useUpdateEffect } from '../hooks/useUpdateEffect.js';
13
13
  import { BuiltinEdges, BuiltinNodes } from './custom/index.js';
14
14
  import { useLayoutConstraints } from './useLayoutConstraints.js';
15
+ import { useDiagram } from '../hooks/safeContext.js';
15
16
  import { useDiagramEventHandlers } from '../context/DiagramEventHandlers.js';
17
+ import { useCallbackRef } from '../hooks/useCallbackRef.js';
16
18
 
17
19
  const edgeTypes = {
18
20
  relationship: BuiltinEdges.RelationshipEdge,
@@ -41,41 +43,48 @@ function prepareNodeTypes(nodeTypes) {
41
43
  "seq-parallel": nodeTypes.seqParallel ?? builtinNodes["seq-parallel"]
42
44
  };
43
45
  }
44
- const selectXYProps = (ctx) => ({
45
- initialized: ctx.initialized.xydata && ctx.initialized.xyflow,
46
- nodes: ctx.xynodes,
47
- edges: ctx.xyedges,
48
- pannable: ctx.pannable,
49
- zoomable: ctx.zoomable,
50
- fitViewPadding: ctx.fitViewPadding,
51
- enableFitView: ctx.features.enableFitView,
52
- enableReadOnly: ctx.features.enableReadOnly || ctx.toggledFeatures.enableReadOnly || ctx.dynamicViewVariant === "sequence" && ctx.view._type === "dynamic",
53
- ...!ctx.features.enableFitView && {
54
- viewport: {
55
- x: -Math.min(ctx.view.bounds.x, 0),
56
- y: -Math.min(ctx.view.bounds.y, 0),
57
- zoom: 1
46
+ const selectXYProps = ({ context: ctx, children }) => {
47
+ const toggledFeatures = ctx.toggledFeatures;
48
+ const enableReadOnly = ctx.features.enableReadOnly || toggledFeatures.enableReadOnly === true;
49
+ const isNotEditingEdge = enableReadOnly || children.syncLayout?.getSnapshot().context.editing !== "edge";
50
+ return {
51
+ enableReadOnly,
52
+ initialized: ctx.initialized.xydata && ctx.initialized.xyflow,
53
+ nodes: ctx.xynodes,
54
+ edges: ctx.xyedges,
55
+ pannable: ctx.pannable,
56
+ zoomable: ctx.zoomable,
57
+ nodesDraggable: !enableReadOnly && ctx.nodesDraggable,
58
+ nodesSelectable: ctx.nodesSelectable && isNotEditingEdge,
59
+ fitViewPadding: ctx.fitViewPadding,
60
+ enableFitView: ctx.toggledFeatures.enableFitView ?? ctx.features.enableFitView,
61
+ ...!ctx.features.enableFitView && {
62
+ viewport: {
63
+ x: -Math.min(ctx.view.bounds.x, 0),
64
+ y: -Math.min(ctx.view.bounds.y, 0),
65
+ zoom: 1
66
+ }
58
67
  }
59
- }
60
- });
61
- const equalsXYProps = (a, b) => a.initialized === b.initialized && a.pannable === b.pannable && a.zoomable === b.zoomable && a.enableFitView === b.enableFitView && a.enableReadOnly === b.enableReadOnly && deepEqual(a.fitViewPadding, b.fitViewPadding) && shallowEqual(a.nodes, b.nodes) && shallowEqual(a.edges, b.edges) && shallowEqual(a.viewport ?? null, b.viewport ?? null);
68
+ };
69
+ };
70
+ const equalsXYProps = (a, b) => a.enableReadOnly === b.enableReadOnly && a.initialized === b.initialized && a.pannable === b.pannable && a.zoomable === b.zoomable && a.nodesDraggable === b.nodesDraggable && a.nodesSelectable === b.nodesSelectable && a.enableFitView === b.enableFitView && shallowEqual(a.fitViewPadding, b.fitViewPadding) && shallowEqual(a.nodes, b.nodes) && shallowEqual(a.edges, b.edges) && shallowEqual(a.viewport ?? null, b.viewport ?? null);
62
71
  function LikeC4DiagramXYFlow({
63
72
  background = "dots",
64
- nodesDraggable = false,
65
- nodesSelectable = false,
66
73
  reactFlowProps = {},
67
74
  children,
68
75
  renderNodes
69
76
  }) {
70
77
  const diagram = useDiagram();
71
- const {
78
+ let {
79
+ enableReadOnly,
72
80
  initialized,
73
81
  nodes,
74
82
  edges,
75
- enableReadOnly,
76
83
  enableFitView,
84
+ nodesDraggable,
85
+ nodesSelectable,
77
86
  ...props
78
- } = useDiagramContext(selectXYProps, equalsXYProps);
87
+ } = useDiagramActorSnapshot(selectXYProps, equalsXYProps);
79
88
  const {
80
89
  onNodeContextMenu,
81
90
  onCanvasContextMenu,
@@ -85,13 +94,11 @@ function LikeC4DiagramXYFlow({
85
94
  onCanvasClick,
86
95
  onCanvasDblClick
87
96
  } = useDiagramEventHandlers();
88
- const notReadOnly = !enableReadOnly, isReducedGraphics = useIsReducedGraphics(), layoutConstraints = useLayoutConstraints(), $isPanning = usePanningAtom(), isPanning = useTimeout(() => {
97
+ const isReducedGraphics = useIsReducedGraphics(), layoutConstraints = useLayoutConstraints(), $isPanning = usePanningAtom(), isPanning = useTimeout(() => {
89
98
  $isPanning.set(true);
90
99
  }, isReducedGraphics ? 120 : 400), notPanning = useDebouncedCallback(() => {
91
100
  isPanning.clear();
92
- if ($isPanning.get()) {
93
- $isPanning.set(false);
94
- }
101
+ $isPanning.set(false);
95
102
  }, isReducedGraphics ? 350 : 200), onMove = useCallbackRef((event) => {
96
103
  if (!event) {
97
104
  return;
@@ -139,6 +146,10 @@ function LikeC4DiagramXYFlow({
139
146
  diagram.send({ type: "xyflow.edgeClick", edge });
140
147
  onEdgeClick?.(diagram.findDiagramEdge(edge.id), e);
141
148
  }),
149
+ onEdgeDoubleClick: useCallbackRef((e, edge) => {
150
+ e.stopPropagation();
151
+ diagram.send({ type: "xyflow.edgeDoubleClick", edge });
152
+ }),
142
153
  onPaneClick: useCallbackRef((e) => {
143
154
  e.stopPropagation();
144
155
  diagram.send({ type: "xyflow.paneClick" });
@@ -150,29 +161,21 @@ function LikeC4DiagramXYFlow({
150
161
  diagram.send({ type: "xyflow.paneDblClick" });
151
162
  onCanvasDblClick?.(e);
152
163
  }),
153
- onNodeMouseEnter: useCallbackRef((_event, node) => {
154
- _event.stopPropagation();
155
- if (!node.data.hovered) {
156
- diagram.send({ type: "xyflow.nodeMouseEnter", node });
157
- }
164
+ onNodeMouseEnter: useCallbackRef((event, node) => {
165
+ event.stopPropagation();
166
+ diagram.send({ type: "xyflow.nodeMouseEnter", node });
158
167
  }),
159
- onNodeMouseLeave: useCallbackRef((_event, node) => {
160
- _event.stopPropagation();
161
- if (node.data.hovered) {
162
- diagram.send({ type: "xyflow.nodeMouseLeave", node });
163
- }
168
+ onNodeMouseLeave: useCallbackRef((event, node) => {
169
+ event.stopPropagation();
170
+ diagram.send({ type: "xyflow.nodeMouseLeave", node });
164
171
  }),
165
172
  onEdgeMouseEnter: useCallbackRef((event, edge) => {
166
173
  event.stopPropagation();
167
- if (!edge.data.hovered) {
168
- diagram.send({ type: "xyflow.edgeMouseEnter", edge, event });
169
- }
174
+ diagram.send({ type: "xyflow.edgeMouseEnter", edge, event });
170
175
  }),
171
176
  onEdgeMouseLeave: useCallbackRef((event, edge) => {
172
177
  event.stopPropagation();
173
- if (edge.data.hovered) {
174
- diagram.send({ type: "xyflow.edgeMouseLeave", edge, event });
175
- }
178
+ diagram.send({ type: "xyflow.edgeMouseLeave", edge, event });
176
179
  }),
177
180
  onMove,
178
181
  onMoveEnd,
@@ -193,16 +196,16 @@ function LikeC4DiagramXYFlow({
193
196
  );
194
197
  onEdgeContextMenu?.(diagramEdge, event);
195
198
  }),
196
- onPaneContextMenu: useCallbackRef((event) => {
197
- onCanvasContextMenu?.(event);
198
- }),
199
+ ...onCanvasContextMenu && {
200
+ onPaneContextMenu: onCanvasContextMenu
201
+ },
199
202
  ...enableFitView && {
200
203
  onViewportResize
201
204
  },
202
- nodesDraggable: notReadOnly && nodesDraggable,
205
+ nodesDraggable,
203
206
  nodesSelectable,
204
- edgesFocusable: false,
205
- ...notReadOnly && nodesDraggable && layoutConstraints,
207
+ elevateEdgesOnSelect: !enableReadOnly,
208
+ ...nodesDraggable && layoutConstraints,
206
209
  ...props,
207
210
  ...reactFlowProps,
208
211
  children
@@ -3,7 +3,6 @@ import { Types } from './types';
3
3
  type ConvertToXYFlowInput = {
4
4
  view: LayoutedView;
5
5
  where: WhereOperator | null;
6
- nodesSelectable: boolean;
7
6
  dynamicViewVariant: DynamicViewDisplayVariant;
8
7
  };
9
8
  export declare function convertToXYFlow({ dynamicViewVariant, ...params }: ConvertToXYFlowInput): {