@likec4/diagram 1.31.0 → 1.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/bundle/{chunk-BBzMXzCg.js → chunk-DlHyKoeo.js} +1700 -1206
  2. package/bundle/custom.js +51 -47
  3. package/bundle/index.js +5495 -5428
  4. package/dist/LikeC4CustomColors.d.ts +2 -7
  5. package/dist/LikeC4CustomColors.js +17 -6
  6. package/dist/LikeC4Diagram.d.ts +3 -2
  7. package/dist/LikeC4Diagram.js +10 -14
  8. package/dist/LikeC4Diagram.props.d.ts +41 -24
  9. package/dist/LikeC4ModelProvider.d.ts +5 -4
  10. package/dist/StaticLikeC4Diagram.d.ts +3 -2
  11. package/dist/StaticLikeC4Diagram.js +2 -2
  12. package/dist/base/BaseXYFlow.js +5 -5
  13. package/dist/base/const.d.ts +1 -1
  14. package/dist/base/const.js +1 -1
  15. package/dist/base/index.d.ts +2 -1
  16. package/dist/base/primitives/compound/CompoundActionButton.js +2 -1
  17. package/dist/base/primitives/compound/CompoundDetailsButton.js +2 -1
  18. package/dist/base/primitives/compound/CompoundTitle.d.ts +1 -1
  19. package/dist/base/primitives/compound/CompoundTitle.js +2 -1
  20. package/dist/base/primitives/edge/EdgeContainer.d.ts +1 -1
  21. package/dist/base/primitives/edge/EdgeLabel.css.js +1 -0
  22. package/dist/base/primitives/edge/EdgeLabel.d.ts +3 -3
  23. package/dist/base/primitives/edge/EdgeLabel.js +6 -4
  24. package/dist/base/primitives/edge/EdgeLabelContainer.d.ts +1 -1
  25. package/dist/base/primitives/edge/EdgeMarkers.d.ts +1 -1
  26. package/dist/base/primitives/edge/EdgePath.d.ts +1 -1
  27. package/dist/base/primitives/element/ElementActionButtons.js +10 -9
  28. package/dist/base/primitives/element/ElementDetailsButton.js +2 -1
  29. package/dist/base/primitives/element/ElementShape.d.ts +1 -1
  30. package/dist/base/primitives/element/ElementTags.d.ts +14 -0
  31. package/dist/base/primitives/element/ElementTags.js +176 -0
  32. package/dist/base/primitives/element/ElementTitle.d.ts +5 -4
  33. package/dist/base/primitives/element/ElementTitle.js +6 -6
  34. package/dist/base/primitives/index.d.ts +1 -0
  35. package/dist/base/types.Base.d.ts +54 -0
  36. package/dist/base/types.Base.js +48 -0
  37. package/dist/base/types.d.ts +2 -52
  38. package/dist/bundle/LikeC4View.d.ts +2 -1
  39. package/dist/bundle/LikeC4View.js +22 -19
  40. package/dist/bundle/LikeC4View.props.d.ts +15 -4
  41. package/dist/bundle/ReactLikeC4.d.ts +4 -7
  42. package/dist/bundle/ReactLikeC4.js +10 -8
  43. package/dist/bundle/index.js +1 -1
  44. package/dist/components/ErrorFallback.d.ts +2 -0
  45. package/dist/components/ErrorFallback.js +29 -0
  46. package/dist/context/DiagramEventHandlers.d.ts +6 -5
  47. package/dist/context/DiagramFeatures.d.ts +2 -2
  48. package/dist/context/DiagramFeatures.js +3 -31
  49. package/dist/context/EnsureMantine.js +1 -1
  50. package/dist/context/IconRenderer.js +1 -4
  51. package/dist/context/RootContainer.js +5 -1
  52. package/dist/context/TagStylesContext.d.ts +7 -0
  53. package/dist/context/TagStylesContext.js +85 -0
  54. package/dist/custom/components.d.ts +1 -1
  55. package/dist/custom/customNodes.d.ts +32 -17
  56. package/dist/custom/hooks.d.ts +1 -1
  57. package/dist/hooks/index.d.ts +1 -1
  58. package/dist/hooks/useDiagram.d.ts +73 -38
  59. package/dist/hooks/useDiagram.js +7 -3
  60. package/dist/hooks/useMantinePortalProps.d.ts +2 -2
  61. package/dist/hooks/useSearchActor.d.ts +2 -0
  62. package/dist/hooks/useSearchActor.js +10 -0
  63. package/dist/hooks/useUpdateEffect.js +3 -0
  64. package/dist/hooks/useXYFlow.d.ts +39 -37
  65. package/dist/hooks/useXYFlow.js +5 -1
  66. package/dist/index.js +1 -1
  67. package/dist/likec4diagram/DiagramUI.js +7 -2
  68. package/dist/likec4diagram/DiagramXYFlow.d.ts +4 -3
  69. package/dist/likec4diagram/DiagramXYFlow.js +107 -110
  70. package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +7 -6
  71. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +8 -0
  72. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +7 -5
  73. package/dist/likec4diagram/custom/index.d.ts +7 -6
  74. package/dist/likec4diagram/custom/nodes/nodes.js +39 -26
  75. package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +7 -7
  76. package/dist/likec4diagram/types.d.ts +5 -5
  77. package/dist/likec4diagram/ui/controls/Controls.js +12 -4
  78. package/dist/likec4diagram/ui/notation/NotationPanel.js +1 -1
  79. package/dist/likec4diagram/useViewToNodesEdges.d.ts +5 -3
  80. package/dist/likec4diagram/useViewToNodesEdges.js +20 -30
  81. package/dist/likec4model/LikeC4ModelContext.d.ts +2 -2
  82. package/dist/likec4model/index.d.ts +1 -1
  83. package/dist/likec4model/useLikeC4ElementsTree.js +1 -1
  84. package/dist/likec4model/useLikeC4Model.d.ts +23 -10
  85. package/dist/likec4model/useLikeC4Model.js +22 -7
  86. package/dist/overlays/Overlays.js +4 -27
  87. package/dist/overlays/element-details/ElementDetailsCard.d.ts +1 -1
  88. package/dist/overlays/element-details/ElementDetailsCard.js +19 -12
  89. package/dist/overlays/element-details/TabPanelDeployments.d.ts +1 -1
  90. package/dist/overlays/element-details/TabPanelDeployments.js +1 -1
  91. package/dist/overlays/element-details/TabPanelRelationships.d.ts +1 -1
  92. package/dist/overlays/element-details/TabPanelStructure.d.ts +1 -1
  93. package/dist/overlays/element-details/actor.d.ts +288 -286
  94. package/dist/overlays/overlay/Overlay.css.d.ts +57 -2
  95. package/dist/overlays/overlay/Overlay.css.js +76 -39
  96. package/dist/overlays/overlay/Overlay.d.ts +12 -0
  97. package/dist/overlays/overlay/Overlay.js +58 -27
  98. package/dist/overlays/overlaysActor.d.ts +1 -1
  99. package/dist/overlays/relationship-details/RelationshipDetails.d.ts +3 -2
  100. package/dist/overlays/relationship-details/RelationshipDetails.js +3 -3
  101. package/dist/overlays/relationship-details/_types.d.ts +2 -2
  102. package/dist/overlays/relationship-details/actor.js +7 -7
  103. package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +3 -2
  104. package/dist/overlays/relationship-details/custom/nodeTypes.js +4 -0
  105. package/dist/overlays/relationship-details/hooks.d.ts +10 -9
  106. package/dist/overlays/relationship-details/layout-to-xyflow.js +1 -0
  107. package/dist/overlays/relationship-details/layout.js +3 -1
  108. package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +3 -2
  109. package/dist/overlays/relationships-browser/SelectElement.js +1 -1
  110. package/dist/overlays/relationships-browser/_types.d.ts +2 -2
  111. package/dist/overlays/relationships-browser/actor.d.ts +1 -1
  112. package/dist/overlays/relationships-browser/actor.js +7 -7
  113. package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +3 -2
  114. package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +8 -5
  115. package/dist/overlays/relationships-browser/custom/nodeTypes.js +4 -0
  116. package/dist/overlays/relationships-browser/layout.d.ts +2 -2
  117. package/dist/overlays/relationships-browser/layout.js +10 -6
  118. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +4 -3
  119. package/dist/search/Search.d.ts +4 -0
  120. package/dist/search/Search.js +173 -0
  121. package/dist/{likec4diagram/ui/search → search/components}/ElementsColumn.css.js +0 -1
  122. package/dist/search/components/ElementsColumn.d.ts +2 -0
  123. package/dist/{likec4diagram/ui/search → search/components}/ElementsColumn.js +26 -25
  124. package/dist/search/components/PickView.d.ts +4 -0
  125. package/dist/search/components/PickView.js +135 -0
  126. package/dist/search/components/SearchByTags.d.ts +1 -0
  127. package/dist/search/components/SearchByTags.js +119 -0
  128. package/dist/search/components/SearchInput.d.ts +2 -0
  129. package/dist/{likec4diagram/ui/search → search/components}/SearchInput.js +61 -40
  130. package/dist/{likec4diagram/ui/search → search/components}/ViewsColum.d.ts +3 -2
  131. package/dist/{likec4diagram/ui/search → search/components}/ViewsColum.js +25 -17
  132. package/dist/{likec4diagram/ui/search → search/components}/_shared.css.js +26 -35
  133. package/dist/{likec4diagram/ui/search/LikeC4Search.css.d.ts → search/components/styles.css.d.ts} +0 -2
  134. package/dist/search/components/styles.css.js +60 -0
  135. package/dist/search/components/utils.d.ts +5 -0
  136. package/dist/search/components/utils.js +58 -0
  137. package/dist/search/hooks.d.ts +10 -0
  138. package/dist/search/hooks.js +35 -0
  139. package/dist/search/searchActor.d.ts +90 -0
  140. package/dist/search/searchActor.js +75 -0
  141. package/dist/state/DiagramActorProvider.d.ts +9 -7
  142. package/dist/state/DiagramActorProvider.js +24 -18
  143. package/dist/state/assign.d.ts +0 -1
  144. package/dist/state/assign.js +9 -19
  145. package/dist/state/diagram-machine.d.ts +645 -183
  146. package/dist/state/diagram-machine.js +127 -60
  147. package/dist/state/syncManualLayoutActor.d.ts +2 -2
  148. package/dist/state/types.d.ts +2 -0
  149. package/dist/state/utils.d.ts +2 -0
  150. package/dist/state/utils.js +3 -0
  151. package/dist/styles-min.css +1 -1
  152. package/dist/styles-xyflow.css +1 -1
  153. package/dist/styles.css +1 -1
  154. package/dist/styles.css2.js +1 -1
  155. package/package.json +20 -19
  156. package/panda.buildinfo.json +171 -148
  157. package/src/LikeC4CustomColors.tsx +21 -6
  158. package/src/LikeC4Diagram.props.ts +48 -32
  159. package/src/LikeC4Diagram.tsx +19 -20
  160. package/src/LikeC4ModelProvider.tsx +6 -5
  161. package/src/StaticLikeC4Diagram.tsx +8 -6
  162. package/src/base/const.ts +1 -1
  163. package/src/base/index.ts +2 -1
  164. package/src/base/primitives/compound/CompoundActionButton.tsx +2 -1
  165. package/src/base/primitives/compound/CompoundDetailsButton.tsx +2 -1
  166. package/src/base/primitives/compound/CompoundTitle.tsx +3 -2
  167. package/src/base/primitives/edge/EdgeContainer.tsx +2 -1
  168. package/src/base/primitives/edge/EdgeLabel.css.ts +1 -0
  169. package/src/base/primitives/edge/EdgeLabel.tsx +20 -15
  170. package/src/base/primitives/edge/EdgeLabelContainer.tsx +1 -1
  171. package/src/base/primitives/edge/EdgeMarkers.tsx +2 -1
  172. package/src/base/primitives/edge/EdgePath.tsx +1 -1
  173. package/src/base/primitives/element/ElementActionButtons.tsx +11 -10
  174. package/src/base/primitives/element/ElementDetailsButton.tsx +2 -1
  175. package/src/base/primitives/element/ElementShape.tsx +2 -1
  176. package/src/base/primitives/element/ElementTags.tsx +182 -0
  177. package/src/base/primitives/element/ElementTitle.tsx +21 -15
  178. package/src/base/primitives/index.ts +1 -0
  179. package/src/base/types.Base.ts +104 -0
  180. package/src/base/types.ts +2 -99
  181. package/src/bundle/LikeC4View.props.ts +17 -4
  182. package/src/bundle/LikeC4View.tsx +27 -36
  183. package/src/bundle/ReactLikeC4.tsx +16 -36
  184. package/src/components/ErrorFallback.tsx +30 -0
  185. package/src/context/DiagramEventHandlers.tsx +5 -4
  186. package/src/context/DiagramFeatures.tsx +3 -22
  187. package/src/context/EnsureMantine.tsx +1 -1
  188. package/src/context/IconRenderer.tsx +1 -4
  189. package/src/context/RootContainer.tsx +9 -3
  190. package/src/context/TagStylesContext.tsx +96 -0
  191. package/src/custom/components.ts +2 -0
  192. package/src/custom/customNodes.tsx +29 -14
  193. package/src/custom/hooks.ts +2 -0
  194. package/src/hooks/index.ts +1 -1
  195. package/src/hooks/useCurrentViewId.ts +1 -4
  196. package/src/hooks/useDiagram.ts +104 -12
  197. package/src/hooks/useMantinePortalProps.ts +10 -1
  198. package/src/hooks/useSearchActor.ts +11 -0
  199. package/src/hooks/useUpdateEffect.ts +7 -4
  200. package/src/hooks/useXYFlow.ts +5 -0
  201. package/src/likec4diagram/DiagramUI.tsx +5 -0
  202. package/src/likec4diagram/DiagramXYFlow.tsx +118 -121
  203. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +9 -0
  204. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +10 -9
  205. package/src/likec4diagram/custom/nodes/nodes.tsx +45 -43
  206. package/src/likec4diagram/custom/nodes/toolbar/_shared.tsx +11 -3
  207. package/src/likec4diagram/types.ts +5 -3
  208. package/src/likec4diagram/ui/controls/Controls.tsx +11 -4
  209. package/src/likec4diagram/ui/notation/NotationPanel.tsx +2 -2
  210. package/src/likec4diagram/useViewToNodesEdges.ts +34 -36
  211. package/src/likec4model/LikeC4ModelContext.ts +2 -2
  212. package/src/likec4model/index.ts +2 -0
  213. package/src/likec4model/useLikeC4ElementsTree.ts +1 -1
  214. package/src/likec4model/useLikeC4Model.ts +32 -16
  215. package/src/overlays/Overlays.tsx +5 -32
  216. package/src/overlays/element-details/ElementDetailsCard.tsx +25 -18
  217. package/src/overlays/element-details/TabPanelDeployments.tsx +3 -2
  218. package/src/overlays/element-details/TabPanelRelationships.tsx +2 -1
  219. package/src/overlays/element-details/TabPanelStructure.tsx +1 -1
  220. package/src/overlays/element-details/actor.ts +2 -2
  221. package/src/overlays/overlay/Overlay.css.ts +75 -38
  222. package/src/overlays/overlay/Overlay.tsx +61 -29
  223. package/src/overlays/overlaysActor.ts +1 -1
  224. package/src/overlays/relationship-details/RelationshipDetails.tsx +4 -4
  225. package/src/overlays/relationship-details/_types.ts +2 -1
  226. package/src/overlays/relationship-details/custom/nodeTypes.tsx +4 -0
  227. package/src/overlays/relationship-details/layout-to-xyflow.ts +1 -0
  228. package/src/overlays/relationship-details/layout.ts +3 -1
  229. package/src/overlays/relationships-browser/SelectElement.tsx +1 -1
  230. package/src/overlays/relationships-browser/_types.ts +2 -1
  231. package/src/overlays/relationships-browser/custom/nodeTypes.tsx +4 -0
  232. package/src/overlays/relationships-browser/layout.ts +12 -7
  233. package/src/overlays/relationships-browser/useViewToNodesEdges.ts +4 -4
  234. package/src/search/Search.tsx +220 -0
  235. package/src/{likec4diagram/ui/search → search/components}/ElementsColumn.css.ts +0 -29
  236. package/src/{likec4diagram/ui/search → search/components}/ElementsColumn.tsx +28 -29
  237. package/src/search/components/PickView.tsx +134 -0
  238. package/src/search/components/SearchByTags.tsx +112 -0
  239. package/src/{likec4diagram/ui/search → search/components}/SearchInput.tsx +72 -42
  240. package/src/{likec4diagram/ui/search → search/components}/ViewsColum.tsx +29 -22
  241. package/src/{likec4diagram/ui/search → search/components}/_shared.css.ts +26 -37
  242. package/src/{likec4diagram/ui/search/LikeC4Search.css.ts → search/components/styles.css.ts} +9 -36
  243. package/src/search/components/utils.ts +64 -0
  244. package/src/search/hooks.ts +38 -0
  245. package/src/search/searchActor.ts +99 -0
  246. package/src/state/DiagramActorProvider.tsx +37 -25
  247. package/src/state/assign.ts +10 -10
  248. package/src/state/diagram-machine.ts +123 -58
  249. package/src/state/syncManualLayoutActor.ts +1 -1
  250. package/src/state/types.ts +2 -0
  251. package/src/state/utils.ts +4 -0
  252. package/dist/base/types.js +0 -54
  253. package/dist/likec4diagram/ui/search/ElementsColumn.d.ts +0 -1
  254. package/dist/likec4diagram/ui/search/LikeC4Search.css.js +0 -87
  255. package/dist/likec4diagram/ui/search/LikeC4Search.d.ts +0 -2
  256. package/dist/likec4diagram/ui/search/LikeC4Search.js +0 -267
  257. package/dist/likec4diagram/ui/search/SearchInput.d.ts +0 -1
  258. package/dist/likec4diagram/ui/search/state.d.ts +0 -19
  259. package/dist/likec4diagram/ui/search/state.js +0 -63
  260. package/dist/likec4diagram/ui/search/utils.d.ts +0 -3
  261. package/dist/likec4diagram/ui/search/utils.js +0 -20
  262. package/src/likec4diagram/ui/search/LikeC4Search.tsx +0 -301
  263. package/src/likec4diagram/ui/search/state.ts +0 -78
  264. package/src/likec4diagram/ui/search/utils.ts +0 -20
  265. /package/dist/{likec4diagram/ui/search → search/components}/ElementsColumn.css.d.ts +0 -0
  266. /package/dist/{likec4diagram/ui/search → search/components}/ViewsColumn.css.d.ts +0 -0
  267. /package/dist/{likec4diagram/ui/search → search/components}/ViewsColumn.css.js +0 -0
  268. /package/dist/{likec4diagram/ui/search → search/components}/_shared.css.d.ts +0 -0
  269. /package/src/{likec4diagram/ui/search → search/components}/ViewsColumn.css.ts +0 -0
@@ -1,19 +1,20 @@
1
- import { nonNullable, invariant, DiagramNode, nonexhaustive, getBBoxCenter, isStepEdgeId, getParallelStepsPrefix } from '@likec4/core';
1
+ import { nonNullable, invariant, nonexhaustive, BBox, isStepEdgeId, getParallelStepsPrefix } from '@likec4/core';
2
2
  import { getViewportForBounds, applyEdgeChanges, applyNodeChanges } from '@xyflow/react';
3
3
  import { nodeToRect } from '@xyflow/system';
4
4
  import { hasAtLeast, prop, clamp, first } from 'remeda';
5
5
  import { setup, assign, enqueueActions, sendTo, assertEvent, cancel, stopChild, raise, spawnChild, and, or } from 'xstate';
6
6
  import { MinZoom } from '../base/const.js';
7
- import { Base } from '../base/types.js';
8
7
  import { AllDisabled } from '../context/DiagramFeatures.js';
9
8
  import { createLayoutConstraints } from '../likec4diagram/useLayoutConstraints.js';
10
9
  import { overlaysActorLogic } from '../overlays/overlaysActor.js';
10
+ import { searchActorLogic } from '../search/searchActor.js';
11
11
  import { getAligner, toNodeRect } from './aligners.js';
12
- import { lastClickedNode, updateNavigationHistory, mergeXYNodesEdges, updateEdgeData, updateNodeData, unfocusNodesEdges, updateActiveWalkthrough, focusNodesEdges, resetEdgeControlPoints, navigateForward, navigateBack } from './assign.js';
12
+ import { updateActiveWalkthrough, focusNodesEdges, lastClickedNode, updateNavigationHistory, mergeXYNodesEdges, updateEdgeData, updateNodeData, resetEdgeControlPoints, navigateForward, navigateBack } from './assign.js';
13
13
  import { hotkeyActorLogic } from './hotkeyActor.js';
14
14
  import { DiagramToggledFeaturesPersistence } from './persistence.js';
15
15
  import { syncManualLayoutActorLogic } from './syncManualLayoutActor.js';
16
16
  import { findDiagramNode, typedSystem, focusedBounds } from './utils.js';
17
+ import { setData, setDimmed, setHovered } from '../base/types.Base.js';
17
18
 
18
19
  const _diagramMachine = setup({
19
20
  types: {
@@ -25,7 +26,8 @@ const _diagramMachine = setup({
25
26
  actors: {
26
27
  syncManualLayoutActorLogic,
27
28
  hotkeyActorLogic,
28
- overlaysActorLogic
29
+ overlaysActorLogic,
30
+ searchActorLogic
29
31
  },
30
32
  guards: {
31
33
  "isReady": ({ context }) => context.initialized.xydata && context.initialized.xyflow,
@@ -33,8 +35,9 @@ const _diagramMachine = setup({
33
35
  "enabled: FocusMode": ({ context }) => context.features.enableFocusMode,
34
36
  "enabled: Readonly": ({ context }) => context.features.enableReadOnly,
35
37
  "enabled: RelationshipDetails": ({ context }) => context.features.enableRelationshipDetails,
38
+ "enabled: Search": ({ context }) => context.features.enableSearch,
36
39
  "not readonly": ({ context }) => !context.features.enableReadOnly,
37
- "is dynamic view": ({ context }) => context.view.__ === "dynamic",
40
+ "is dynamic view": ({ context }) => context.view._type === "dynamic",
38
41
  "is another view": ({ context, event }) => {
39
42
  assertEvent(event, ["update.view", "navigate.to"]);
40
43
  if (event.type === "update.view") {
@@ -84,10 +87,10 @@ const _diagramMachine = setup({
84
87
  if (!nodeId || !context.features.enableVscode) return;
85
88
  const diagramNode = findDiagramNode(context, nodeId);
86
89
  if (!diagramNode) return;
87
- if (DiagramNode.deploymentRef(diagramNode)) {
88
- enqueue.raise({ type: "open.source", deployment: DiagramNode.deploymentRef(diagramNode) });
89
- } else if (DiagramNode.modelRef(diagramNode)) {
90
- enqueue.raise({ type: "open.source", element: DiagramNode.modelRef(diagramNode) });
90
+ if (diagramNode.deploymentRef) {
91
+ enqueue.raise({ type: "open.source", deployment: diagramNode.deploymentRef });
92
+ } else if (diagramNode.modelRef) {
93
+ enqueue.raise({ type: "open.source", element: diagramNode.modelRef });
91
94
  }
92
95
  }),
93
96
  "xyflow:fitDiagram": ({ context }, params) => {
@@ -95,7 +98,7 @@ const _diagramMachine = setup({
95
98
  bounds = context.view.bounds,
96
99
  duration = 450
97
100
  } = params ?? {};
98
- const { width, height, panZoom, transform } = context.xystore.getState();
101
+ const { width, height, panZoom, transform } = nonNullable(context.xystore).getState();
99
102
  const maxZoom = Math.max(1, transform[2]);
100
103
  const viewport = getViewportForBounds(
101
104
  bounds,
@@ -111,7 +114,7 @@ const _diagramMachine = setup({
111
114
  },
112
115
  "xyflow:fitFocusedBounds": ({ context }) => {
113
116
  const { bounds, duration = 450 } = focusedBounds({ context });
114
- const { width, height, panZoom, transform } = context.xystore.getState();
117
+ const { width, height, panZoom, transform } = nonNullable(context.xystore).getState();
115
118
  const maxZoom = Math.max(1, transform[2]);
116
119
  const viewport = getViewportForBounds(
117
120
  bounds,
@@ -136,7 +139,7 @@ const _diagramMachine = setup({
136
139
  viewport,
137
140
  duration = 350
138
141
  } = params;
139
- const { panZoom } = context.xystore.getState();
142
+ const panZoom = context.xystore?.getState().panZoom;
140
143
  panZoom?.setViewport(viewport, duration > 0 ? { duration } : void 0);
141
144
  },
142
145
  "xyflow:alignNodeFromToAfterNavigate": ({ context }, params) => {
@@ -156,7 +159,7 @@ const _diagramMachine = setup({
156
159
  },
157
160
  "layout.align": ({ context }, params) => {
158
161
  const { mode } = params;
159
- const { xystore } = context;
162
+ const xystore = nonNullable(context.xystore, "xystore is not initialized");
160
163
  const { nodeLookup, parentLookup } = xystore.getState();
161
164
  const selectedNodes = new Set(nodeLookup.values().filter((n) => n.selected).map((n) => n.id));
162
165
  const nodesToAlign = [...selectedNodes.difference(new Set(parentLookup.keys()))];
@@ -179,12 +182,7 @@ const _diagramMachine = setup({
179
182
  }
180
183
  constraints.updateXYFlowNodes();
181
184
  },
182
- "updateFeatures": enqueueActions(({ enqueue, system, event }) => {
183
- assertEvent(event, "update.features");
184
- const { features } = event;
185
- enqueue.assign({
186
- features: { ...features }
187
- });
185
+ "ensure overlays actor state": enqueueActions(({ enqueue, context: { features }, system }) => {
188
186
  const enableOverlays = features.enableElementDetails || features.enableRelationshipDetails || features.enableRelationshipBrowser;
189
187
  const hasRunning = typedSystem(system).overlaysActorRef;
190
188
  if (enableOverlays && !hasRunning) {
@@ -198,6 +196,31 @@ const _diagramMachine = setup({
198
196
  enqueue.stopChild("overlays");
199
197
  }
200
198
  }),
199
+ "ensure search actor state": enqueueActions(({ enqueue, context: { features: { enableSearch } }, system }) => {
200
+ const hasRunning = typedSystem(system).searchActorRef;
201
+ if (enableSearch && !hasRunning) {
202
+ enqueue.spawnChild("searchActorLogic", { id: "search", systemId: "search" });
203
+ return;
204
+ }
205
+ if (!enableSearch && hasRunning) {
206
+ enqueue.sendTo(hasRunning, {
207
+ type: "close"
208
+ });
209
+ enqueue.stopChild("search");
210
+ }
211
+ }),
212
+ "updateFeatures": assign(({ event }) => {
213
+ assertEvent(event, "update.features");
214
+ return {
215
+ features: { ...event.features }
216
+ };
217
+ }),
218
+ "closeSearch": sendTo(
219
+ ({ system }) => typedSystem(system).searchActorRef,
220
+ {
221
+ type: "close"
222
+ }
223
+ ),
201
224
  "closeAllOverlays": sendTo(
202
225
  ({ system }) => typedSystem(system).overlaysActorRef,
203
226
  {
@@ -221,7 +244,7 @@ const _diagramMachine = setup({
221
244
  return {
222
245
  xynodes: context.xynodes.map((n) => {
223
246
  if (n.id === params.node.id) {
224
- return Base.setHovered(n, true);
247
+ return setHovered(n, true);
225
248
  }
226
249
  return n;
227
250
  })
@@ -231,7 +254,7 @@ const _diagramMachine = setup({
231
254
  return {
232
255
  xynodes: context.xynodes.map((n) => {
233
256
  if (n.id === params.node.id) {
234
- return Base.setHovered(n, false);
257
+ return setHovered(n, false);
235
258
  }
236
259
  return n;
237
260
  })
@@ -241,7 +264,7 @@ const _diagramMachine = setup({
241
264
  return {
242
265
  xyedges: context.xyedges.map((e) => {
243
266
  if (e.id === params.edge.id) {
244
- return Base.setHovered(e, true);
267
+ return setHovered(e, true);
245
268
  }
246
269
  return e;
247
270
  })
@@ -251,30 +274,50 @@ const _diagramMachine = setup({
251
274
  return {
252
275
  xyedges: context.xyedges.map((e) => {
253
276
  if (e.id === params.edge.id) {
254
- return Base.setHovered(e, false);
277
+ return setHovered(e, false);
255
278
  }
256
279
  return e;
257
280
  })
258
281
  };
259
282
  }),
283
+ "focus on nodes and edges": assign(focusNodesEdges),
260
284
  "notations.highlight": assign(({ context }, params) => {
261
285
  const kinds = params.kind ? [params.kind] : params.notation.kinds;
262
286
  const xynodes = context.xynodes.map((n) => {
263
287
  const node = findDiagramNode(context, n.id);
264
288
  if (node && node.notation === params.notation.title && node.shape === params.notation.shape && node.color === params.notation.color && kinds.includes(node.kind)) {
265
- return Base.setDimmed(n, false);
289
+ return setDimmed(n, false);
266
290
  }
267
- return Base.setDimmed(n, "immediate");
291
+ return setDimmed(n, "immediate");
268
292
  });
269
293
  return {
270
294
  xynodes,
271
- xyedges: context.xyedges.map(Base.setDimmed("immediate"))
295
+ xyedges: context.xyedges.map(setDimmed("immediate"))
272
296
  };
273
- })
297
+ }),
298
+ "tag.highlight": assign(({ context, event }) => {
299
+ assertEvent(event, "tag.highlight");
300
+ return {
301
+ xynodes: context.xynodes.map((n) => {
302
+ if (n.data.tags?.includes(event.tag)) {
303
+ return setDimmed(n, false);
304
+ }
305
+ return setDimmed(n, "immediate");
306
+ })
307
+ };
308
+ }),
309
+ "undim everything": assign(({ context }) => ({
310
+ xynodes: context.xynodes.map(setDimmed(false)),
311
+ xyedges: context.xyedges.map(setData({
312
+ dimmed: false,
313
+ active: false
314
+ }))
315
+ })),
316
+ "update active walkthrough": assign(updateActiveWalkthrough)
274
317
  }
275
318
  }).createMachine({
276
319
  initial: "initializing",
277
- context: ({ input, self, spawn }) => ({
320
+ context: ({ input }) => ({
278
321
  ...input,
279
322
  xyedges: [],
280
323
  xynodes: [],
@@ -329,7 +372,7 @@ const _diagramMachine = setup({
329
372
  }
330
373
  }
331
374
  },
332
- "isReady": {
375
+ isReady: {
333
376
  always: [{
334
377
  guard: "isReady",
335
378
  actions: [
@@ -405,8 +448,8 @@ const _diagramMachine = setup({
405
448
  "open.elementDetails": {
406
449
  actions: sendTo(({ system }) => typedSystem(system).overlaysActorRef, ({ context, event }) => {
407
450
  let initiatedFrom = null;
408
- const fromNodeId = event.fromNode ?? context.view.nodes.find((n) => DiagramNode.modelRef(n) === event.fqn)?.id;
409
- const internalNode = fromNodeId ? context.xystore.getState().nodeLookup.get(fromNodeId) : null;
451
+ const fromNodeId = event.fromNode ?? context.view.nodes.find((n) => n.modelRef === event.fqn)?.id;
452
+ const internalNode = fromNodeId ? nonNullable(context.xystore).getState().nodeLookup.get(fromNodeId) : null;
410
453
  if (fromNodeId && internalNode) {
411
454
  const nodeRect = nodeToRect(internalNode);
412
455
  const zoom = context.xyflow.getZoom();
@@ -497,10 +540,13 @@ const _diagramMachine = setup({
497
540
  }
498
541
  },
499
542
  "notations.unhighlight": {
500
- actions: assign(({ context }) => ({
501
- xynodes: context.xynodes.map(Base.setDimmed(false)),
502
- xyedges: context.xyedges.map(Base.setDimmed(false))
503
- }))
543
+ actions: "undim everything"
544
+ },
545
+ "tag.highlight": {
546
+ actions: "tag.highlight"
547
+ },
548
+ "tag.unhighlight": {
549
+ actions: "undim everything"
504
550
  },
505
551
  "saveManualLayout.*": {
506
552
  guard: "not readonly",
@@ -513,6 +559,13 @@ const _diagramMachine = setup({
513
559
  }
514
560
  nonexhaustive(event);
515
561
  })
562
+ },
563
+ "open.search": {
564
+ guard: "enabled: Search",
565
+ actions: sendTo(({ system }) => typedSystem(system).searchActorRef, ({ event }) => ({
566
+ type: "open",
567
+ search: event.search
568
+ }))
516
569
  }
517
570
  },
518
571
  exit: [
@@ -592,8 +645,8 @@ const _diagramMachine = setup({
592
645
  },
593
646
  focused: {
594
647
  entry: [
648
+ "focus on nodes and edges",
595
649
  assign((s) => ({
596
- ...focusNodesEdges(s),
597
650
  viewportBeforeFocus: { ...s.context.viewport }
598
651
  })),
599
652
  "open source of focused or last clicked node",
@@ -605,10 +658,10 @@ const _diagramMachine = setup({
605
658
  if (context.viewportBeforeFocus) {
606
659
  enqueue({ type: "xyflow:setViewport", params: { viewport: context.viewportBeforeFocus } });
607
660
  } else {
608
- enqueue({ type: "xyflow:fitDiagram" });
661
+ enqueue("xyflow:fitDiagram");
609
662
  }
663
+ enqueue("undim everything");
610
664
  enqueue.assign({
611
- ...unfocusNodesEdges({ context}),
612
665
  viewportBeforeFocus: null,
613
666
  focusedNode: null
614
667
  });
@@ -636,7 +689,7 @@ const _diagramMachine = setup({
636
689
  assign({
637
690
  focusedNode: ({ event }) => event.nodeId
638
691
  }),
639
- assign(focusNodesEdges),
692
+ "focus on nodes and edges",
640
693
  "open source of focused or last clicked node",
641
694
  "xyflow:fitFocusedBounds"
642
695
  ]
@@ -651,9 +704,10 @@ const _diagramMachine = setup({
651
704
  target: "idle"
652
705
  },
653
706
  "notations.unhighlight": {
654
- actions: assign((s) => ({
655
- ...focusNodesEdges(s)
656
- }))
707
+ actions: "focus on nodes and edges"
708
+ },
709
+ "tag.unhighlight": {
710
+ actions: "focus on nodes and edges"
657
711
  }
658
712
  }
659
713
  },
@@ -671,7 +725,7 @@ const _diagramMachine = setup({
671
725
  };
672
726
  }
673
727
  }),
674
- assign(updateActiveWalkthrough),
728
+ "update active walkthrough",
675
729
  "xyflow:fitFocusedBounds"
676
730
  ],
677
731
  on: {
@@ -702,7 +756,7 @@ const _diagramMachine = setup({
702
756
  parallelPrefix: getParallelStepsPrefix(nextStepId)
703
757
  }
704
758
  });
705
- enqueue.assign(updateActiveWalkthrough);
759
+ enqueue("update active walkthrough");
706
760
  enqueue("xyflow:fitFocusedBounds");
707
761
  })
708
762
  },
@@ -719,14 +773,15 @@ const _diagramMachine = setup({
719
773
  }
720
774
  };
721
775
  }),
722
- assign(updateActiveWalkthrough),
776
+ "update active walkthrough",
723
777
  "xyflow:fitFocusedBounds"
724
778
  ]
725
779
  },
726
780
  "notations.unhighlight": {
727
- actions: assign((s) => ({
728
- ...updateActiveWalkthrough(s)
729
- }))
781
+ actions: "update active walkthrough"
782
+ },
783
+ "tag.unhighlight": {
784
+ actions: "update active walkthrough"
730
785
  },
731
786
  "walkthrough.end": {
732
787
  target: "idle"
@@ -746,11 +801,11 @@ const _diagramMachine = setup({
746
801
  if (context.viewportBeforeFocus) {
747
802
  enqueue({ type: "xyflow:setViewport", params: { viewport: context.viewportBeforeFocus } });
748
803
  } else {
749
- enqueue({ type: "xyflow:fitDiagram" });
804
+ enqueue("xyflow:fitDiagram");
750
805
  }
806
+ enqueue("undim everything");
751
807
  enqueue.assign({
752
808
  activeWalkthrough: null,
753
- ...unfocusNodesEdges({ context}),
754
809
  viewportBeforeFocus: null
755
810
  });
756
811
  })
@@ -762,13 +817,16 @@ const _diagramMachine = setup({
762
817
  id: "navigating",
763
818
  entry: [
764
819
  "closeAllOverlays",
820
+ "closeSearch",
765
821
  "stopSyncLayout",
766
- {
767
- type: "trigger:NavigateTo",
768
- params: ({ context }) => ({
769
- viewId: nonNullable(context.lastOnNavigate, "Invalid state, lastOnNavigate is null").toView
770
- })
771
- }
822
+ enqueueActions(({ enqueue, context }) => {
823
+ enqueue({
824
+ type: "trigger:NavigateTo",
825
+ params: {
826
+ viewId: nonNullable(context.lastOnNavigate, "Invalid state, lastOnNavigate is null").toView
827
+ }
828
+ });
829
+ })
772
830
  ],
773
831
  on: {
774
832
  "update.view": {
@@ -788,7 +846,7 @@ const _diagramMachine = setup({
788
846
  } else {
789
847
  enqueue({
790
848
  type: "xyflow:setViewportCenter",
791
- params: getBBoxCenter(event.view.bounds)
849
+ params: BBox.center(event.view.bounds)
792
850
  });
793
851
  }
794
852
  enqueue.assign(updateNavigationHistory);
@@ -841,6 +899,7 @@ const _diagramMachine = setup({
841
899
  const isAnotherView = check("is another view");
842
900
  if (isAnotherView) {
843
901
  enqueue("closeAllOverlays");
902
+ enqueue("closeSearch");
844
903
  enqueue("stopSyncLayout");
845
904
  enqueue.assign({
846
905
  focusedNode: null
@@ -861,7 +920,7 @@ const _diagramMachine = setup({
861
920
  } else {
862
921
  enqueue({
863
922
  type: "xyflow:setViewportCenter",
864
- params: getBBoxCenter(event.view.bounds)
923
+ params: BBox.center(event.view.bounds)
865
924
  });
866
925
  enqueue.raise({ type: "fitDiagram", duration: 200 }, { id: "fitDiagram", delay: 25 });
867
926
  }
@@ -885,13 +944,19 @@ const _diagramMachine = setup({
885
944
  actions: assign(({ event }) => ({ ...event.inputs }))
886
945
  },
887
946
  "update.features": {
888
- actions: "updateFeatures"
947
+ actions: [
948
+ "updateFeatures",
949
+ "ensure overlays actor state",
950
+ "ensure search actor state"
951
+ ]
889
952
  }
890
953
  },
891
954
  exit: [
892
955
  "stopSyncLayout",
893
956
  cancel("fitDiagram"),
894
957
  stopChild("hotkey"),
958
+ stopChild("overlays"),
959
+ stopChild("search"),
895
960
  assign({
896
961
  xyflow: null,
897
962
  xystore: null,
@@ -905,7 +970,9 @@ const _diagramMachine = setup({
905
970
  })
906
971
  ]
907
972
  });
908
- const nodeRef = (node) => DiagramNode.modelRef(node) ?? DiagramNode.deploymentRef(node);
973
+ function nodeRef(node) {
974
+ return node.modelRef ?? node.deploymentRef;
975
+ }
909
976
  function findCorrespondingNode(context, event) {
910
977
  const fromNodeId = context.lastOnNavigate?.fromNode;
911
978
  const fromNode = fromNodeId && context.view.nodes.find((n) => n.id === fromNodeId);
@@ -1,4 +1,4 @@
1
- import { ViewChange, ViewId } from '@likec4/core';
1
+ import { ViewChange, ViewId } from '@likec4/core/types';
2
2
  import { ActorLogicFrom, ActorRef, MachineSnapshot, StateMachine, NonReducibleUnknown, EventObject, MetaObject, ActorRefFromLogic, AnyActorLogic, ConditionalRequired, InputFrom, RequiredLogicInput, IsNotNever, AnyActorRef, StateValue, AnyEventObject, ActionFunction } from 'xstate';
3
3
  import { Context as DiagramContext, Events as DiagramEvents } from './diagram-machine';
4
4
  export type Input = {
@@ -27,7 +27,7 @@ declare const _syncManualLayoutActorLogic: StateMachine<Readonly<Input>, Events,
27
27
  }, {
28
28
  type: "same view";
29
29
  params: unknown;
30
- }, "timeout", "paused" | "synced" | "pending" | "stopped" | "idle", "pending" | "ready", Input, NonReducibleUnknown, EventObject, MetaObject, {
30
+ }, "timeout", "paused" | "stopped" | "synced" | "pending" | "idle", "pending" | "ready", Input, NonReducibleUnknown, EventObject, MetaObject, {
31
31
  readonly initial: "idle";
32
32
  readonly context: ({ input }: {
33
33
  spawn: {
@@ -1,11 +1,13 @@
1
1
  import { ActorRefFromLogic, ActorSystem, EventFromLogic, SnapshotFrom } from 'xstate';
2
2
  import { OverlaysActorRef } from '../overlays/overlaysActor';
3
+ import { SearchActorRef } from '../search/searchActor';
3
4
  import { DiagramMachineLogic } from './diagram-machine';
4
5
  import { SyncLayoutActorLogic } from './syncManualLayoutActor';
5
6
  export type System = ActorSystem<{
6
7
  actors: {
7
8
  diagram: ActorRefFromLogic<DiagramMachineLogic>;
8
9
  overlays: OverlaysActorRef;
10
+ search: SearchActorRef;
9
11
  };
10
12
  }>;
11
13
  export interface DiagramActorRef extends ActorRefFromLogic<DiagramMachineLogic> {
@@ -1,11 +1,13 @@
1
1
  import { BBox, DiagramEdge, DiagramNode } from '@likec4/core/types';
2
2
  import { ActorSystem } from 'xstate';
3
3
  import { OverlaysActorRef } from '../overlays/overlaysActor';
4
+ import { SearchActorRef } from '../search/searchActor';
4
5
  import { Context } from './diagram-machine';
5
6
  import { DiagramActorRef } from './types';
6
7
  export declare function typedSystem(system: ActorSystem<any>): {
7
8
  readonly overlaysActorRef: OverlaysActorRef | null;
8
9
  readonly diagramActorRef: DiagramActorRef | null;
10
+ readonly searchActorRef: SearchActorRef | null;
9
11
  };
10
12
  export declare function findDiagramNode(ctx: Context, xynodeId: string): DiagramNode | null;
11
13
  export declare function findDiagramEdge(ctx: Context, xyedgeId: string): DiagramEdge | null;
@@ -5,6 +5,9 @@ function typedSystem(system) {
5
5
  },
6
6
  get diagramActorRef() {
7
7
  return system.get("diagram") ?? null;
8
+ },
9
+ get searchActorRef() {
10
+ return system.get("search") ?? null;
8
11
  }
9
12
  };
10
13
  }