@likec4/diagram 1.31.0 → 1.32.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 (264) hide show
  1. package/bundle/{chunk-BBzMXzCg.js → chunk-BvTQaUYl.js} +1675 -1207
  2. package/bundle/custom.js +50 -47
  3. package/bundle/index.js +2482 -2438
  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 +28 -22
  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 +8 -6
  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 +3 -2
  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 +27 -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 +104 -107
  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 +3 -3
  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/useLikeC4ElementsTree.js +1 -1
  83. package/dist/likec4model/useLikeC4Model.d.ts +22 -10
  84. package/dist/likec4model/useLikeC4Model.js +11 -7
  85. package/dist/overlays/Overlays.js +4 -27
  86. package/dist/overlays/element-details/ElementDetailsCard.d.ts +1 -1
  87. package/dist/overlays/element-details/ElementDetailsCard.js +19 -12
  88. package/dist/overlays/element-details/TabPanelDeployments.d.ts +1 -1
  89. package/dist/overlays/element-details/TabPanelDeployments.js +1 -1
  90. package/dist/overlays/element-details/TabPanelRelationships.d.ts +1 -1
  91. package/dist/overlays/element-details/TabPanelStructure.d.ts +1 -1
  92. package/dist/overlays/element-details/actor.d.ts +288 -286
  93. package/dist/overlays/overlay/Overlay.css.d.ts +57 -2
  94. package/dist/overlays/overlay/Overlay.css.js +76 -39
  95. package/dist/overlays/overlay/Overlay.d.ts +12 -0
  96. package/dist/overlays/overlay/Overlay.js +36 -25
  97. package/dist/overlays/overlaysActor.d.ts +1 -1
  98. package/dist/overlays/relationship-details/RelationshipDetails.d.ts +3 -2
  99. package/dist/overlays/relationship-details/RelationshipDetails.js +3 -3
  100. package/dist/overlays/relationship-details/_types.d.ts +2 -2
  101. package/dist/overlays/relationship-details/actor.js +7 -7
  102. package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +3 -2
  103. package/dist/overlays/relationship-details/custom/nodeTypes.js +4 -0
  104. package/dist/overlays/relationship-details/hooks.d.ts +10 -9
  105. package/dist/overlays/relationship-details/layout-to-xyflow.js +1 -0
  106. package/dist/overlays/relationship-details/layout.js +3 -1
  107. package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +3 -2
  108. package/dist/overlays/relationships-browser/SelectElement.js +1 -1
  109. package/dist/overlays/relationships-browser/_types.d.ts +2 -2
  110. package/dist/overlays/relationships-browser/actor.d.ts +1 -1
  111. package/dist/overlays/relationships-browser/actor.js +7 -7
  112. package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +3 -2
  113. package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +8 -5
  114. package/dist/overlays/relationships-browser/custom/nodeTypes.js +4 -0
  115. package/dist/overlays/relationships-browser/layout.d.ts +2 -2
  116. package/dist/overlays/relationships-browser/layout.js +10 -6
  117. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +4 -3
  118. package/dist/search/Search.d.ts +5 -0
  119. package/dist/search/Search.js +192 -0
  120. package/dist/{likec4diagram/ui/search → search/components}/ElementsColumn.css.js +0 -1
  121. package/dist/search/components/ElementsColumn.d.ts +2 -0
  122. package/dist/{likec4diagram/ui/search → search/components}/ElementsColumn.js +21 -19
  123. package/dist/search/components/PickView.d.ts +4 -0
  124. package/dist/search/components/PickView.js +135 -0
  125. package/dist/search/components/SearchByTags.d.ts +1 -0
  126. package/dist/search/components/SearchByTags.js +116 -0
  127. package/dist/search/components/SearchInput.d.ts +2 -0
  128. package/dist/{likec4diagram/ui/search → search/components}/SearchInput.js +53 -34
  129. package/dist/{likec4diagram/ui/search → search/components}/ViewsColum.d.ts +3 -2
  130. package/dist/{likec4diagram/ui/search → search/components}/ViewsColum.js +14 -13
  131. package/dist/{likec4diagram/ui/search → search/components}/_shared.css.js +26 -35
  132. package/dist/{likec4diagram/ui/search/LikeC4Search.css.d.ts → search/components/styles.css.d.ts} +0 -2
  133. package/dist/search/components/styles.css.js +60 -0
  134. package/dist/{likec4diagram/ui/search → search/components}/utils.d.ts +1 -0
  135. package/dist/{likec4diagram/ui/search → search/components}/utils.js +7 -1
  136. package/dist/search/hooks.d.ts +16 -0
  137. package/dist/search/hooks.js +35 -0
  138. package/dist/search/searchActor.d.ts +90 -0
  139. package/dist/search/searchActor.js +75 -0
  140. package/dist/state/DiagramActorProvider.d.ts +9 -7
  141. package/dist/state/DiagramActorProvider.js +24 -18
  142. package/dist/state/assign.d.ts +0 -1
  143. package/dist/state/assign.js +9 -19
  144. package/dist/state/diagram-machine.d.ts +430 -176
  145. package/dist/state/diagram-machine.js +119 -54
  146. package/dist/state/syncManualLayoutActor.d.ts +2 -2
  147. package/dist/state/types.d.ts +2 -0
  148. package/dist/state/utils.d.ts +2 -0
  149. package/dist/state/utils.js +3 -0
  150. package/dist/styles-min.css +1 -1
  151. package/dist/styles-xyflow.css +1 -1
  152. package/dist/styles.css +1 -1
  153. package/dist/styles.css2.js +1 -1
  154. package/package.json +18 -18
  155. package/panda.buildinfo.json +171 -148
  156. package/src/LikeC4CustomColors.tsx +21 -6
  157. package/src/LikeC4Diagram.props.ts +35 -30
  158. package/src/LikeC4Diagram.tsx +19 -20
  159. package/src/LikeC4ModelProvider.tsx +6 -5
  160. package/src/StaticLikeC4Diagram.tsx +8 -6
  161. package/src/base/const.ts +1 -1
  162. package/src/base/index.ts +2 -1
  163. package/src/base/primitives/compound/CompoundActionButton.tsx +2 -1
  164. package/src/base/primitives/compound/CompoundDetailsButton.tsx +2 -1
  165. package/src/base/primitives/compound/CompoundTitle.tsx +3 -2
  166. package/src/base/primitives/edge/EdgeContainer.tsx +2 -1
  167. package/src/base/primitives/edge/EdgeLabel.css.ts +1 -0
  168. package/src/base/primitives/edge/EdgeLabel.tsx +20 -15
  169. package/src/base/primitives/edge/EdgeLabelContainer.tsx +1 -1
  170. package/src/base/primitives/edge/EdgeMarkers.tsx +2 -1
  171. package/src/base/primitives/edge/EdgePath.tsx +1 -1
  172. package/src/base/primitives/element/ElementActionButtons.tsx +11 -10
  173. package/src/base/primitives/element/ElementDetailsButton.tsx +2 -1
  174. package/src/base/primitives/element/ElementShape.tsx +2 -1
  175. package/src/base/primitives/element/ElementTags.tsx +182 -0
  176. package/src/base/primitives/element/ElementTitle.tsx +21 -15
  177. package/src/base/primitives/index.ts +1 -0
  178. package/src/base/types.Base.ts +104 -0
  179. package/src/base/types.ts +2 -99
  180. package/src/bundle/LikeC4View.props.ts +17 -4
  181. package/src/bundle/LikeC4View.tsx +17 -19
  182. package/src/bundle/ReactLikeC4.tsx +14 -26
  183. package/src/components/ErrorFallback.tsx +30 -0
  184. package/src/context/DiagramEventHandlers.tsx +5 -4
  185. package/src/context/DiagramFeatures.tsx +3 -22
  186. package/src/context/EnsureMantine.tsx +1 -1
  187. package/src/context/IconRenderer.tsx +1 -4
  188. package/src/context/RootContainer.tsx +9 -3
  189. package/src/context/TagStylesContext.tsx +96 -0
  190. package/src/custom/components.ts +2 -0
  191. package/src/custom/customNodes.tsx +24 -14
  192. package/src/custom/hooks.ts +1 -0
  193. package/src/hooks/index.ts +1 -1
  194. package/src/hooks/useCurrentViewId.ts +1 -4
  195. package/src/hooks/useDiagram.ts +104 -12
  196. package/src/hooks/useMantinePortalProps.ts +10 -1
  197. package/src/hooks/useSearchActor.ts +11 -0
  198. package/src/hooks/useUpdateEffect.ts +7 -4
  199. package/src/hooks/useXYFlow.ts +5 -0
  200. package/src/likec4diagram/DiagramUI.tsx +5 -0
  201. package/src/likec4diagram/DiagramXYFlow.tsx +115 -118
  202. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +9 -0
  203. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +10 -9
  204. package/src/likec4diagram/custom/nodes/nodes.tsx +45 -43
  205. package/src/likec4diagram/custom/nodes/toolbar/_shared.tsx +11 -3
  206. package/src/likec4diagram/types.ts +5 -3
  207. package/src/likec4diagram/ui/controls/Controls.tsx +11 -4
  208. package/src/likec4diagram/ui/notation/NotationPanel.tsx +2 -2
  209. package/src/likec4diagram/useViewToNodesEdges.ts +34 -36
  210. package/src/likec4model/LikeC4ModelContext.ts +2 -2
  211. package/src/likec4model/useLikeC4ElementsTree.ts +1 -1
  212. package/src/likec4model/useLikeC4Model.ts +18 -16
  213. package/src/overlays/Overlays.tsx +5 -32
  214. package/src/overlays/element-details/ElementDetailsCard.tsx +25 -18
  215. package/src/overlays/element-details/TabPanelDeployments.tsx +3 -2
  216. package/src/overlays/element-details/TabPanelRelationships.tsx +2 -1
  217. package/src/overlays/element-details/TabPanelStructure.tsx +1 -1
  218. package/src/overlays/element-details/actor.ts +2 -2
  219. package/src/overlays/overlay/Overlay.css.ts +75 -38
  220. package/src/overlays/overlay/Overlay.tsx +43 -26
  221. package/src/overlays/overlaysActor.ts +1 -1
  222. package/src/overlays/relationship-details/RelationshipDetails.tsx +4 -4
  223. package/src/overlays/relationship-details/_types.ts +2 -1
  224. package/src/overlays/relationship-details/custom/nodeTypes.tsx +4 -0
  225. package/src/overlays/relationship-details/layout-to-xyflow.ts +1 -0
  226. package/src/overlays/relationship-details/layout.ts +3 -1
  227. package/src/overlays/relationships-browser/SelectElement.tsx +1 -1
  228. package/src/overlays/relationships-browser/_types.ts +2 -1
  229. package/src/overlays/relationships-browser/custom/nodeTypes.tsx +4 -0
  230. package/src/overlays/relationships-browser/layout.ts +12 -7
  231. package/src/overlays/relationships-browser/useViewToNodesEdges.ts +4 -4
  232. package/src/search/Search.tsx +237 -0
  233. package/src/{likec4diagram/ui/search → search/components}/ElementsColumn.css.ts +0 -29
  234. package/src/{likec4diagram/ui/search → search/components}/ElementsColumn.tsx +24 -22
  235. package/src/search/components/PickView.tsx +140 -0
  236. package/src/search/components/SearchByTags.tsx +109 -0
  237. package/src/{likec4diagram/ui/search → search/components}/SearchInput.tsx +63 -36
  238. package/src/{likec4diagram/ui/search → search/components}/ViewsColum.tsx +17 -18
  239. package/src/{likec4diagram/ui/search → search/components}/_shared.css.ts +26 -37
  240. package/src/{likec4diagram/ui/search/LikeC4Search.css.ts → search/components/styles.css.ts} +9 -36
  241. package/src/{likec4diagram/ui/search → search/components}/utils.ts +7 -0
  242. package/src/search/hooks.ts +41 -0
  243. package/src/search/searchActor.ts +99 -0
  244. package/src/state/DiagramActorProvider.tsx +36 -25
  245. package/src/state/assign.ts +10 -10
  246. package/src/state/diagram-machine.ts +115 -52
  247. package/src/state/syncManualLayoutActor.ts +1 -1
  248. package/src/state/types.ts +2 -0
  249. package/src/state/utils.ts +4 -0
  250. package/dist/base/types.js +0 -54
  251. package/dist/likec4diagram/ui/search/ElementsColumn.d.ts +0 -1
  252. package/dist/likec4diagram/ui/search/LikeC4Search.css.js +0 -87
  253. package/dist/likec4diagram/ui/search/LikeC4Search.d.ts +0 -2
  254. package/dist/likec4diagram/ui/search/LikeC4Search.js +0 -267
  255. package/dist/likec4diagram/ui/search/SearchInput.d.ts +0 -1
  256. package/dist/likec4diagram/ui/search/state.d.ts +0 -19
  257. package/dist/likec4diagram/ui/search/state.js +0 -63
  258. package/src/likec4diagram/ui/search/LikeC4Search.tsx +0 -301
  259. package/src/likec4diagram/ui/search/state.ts +0 -78
  260. /package/dist/{likec4diagram/ui/search → search/components}/ElementsColumn.css.d.ts +0 -0
  261. /package/dist/{likec4diagram/ui/search → search/components}/ViewsColumn.css.d.ts +0 -0
  262. /package/dist/{likec4diagram/ui/search → search/components}/ViewsColumn.css.js +0 -0
  263. /package/dist/{likec4diagram/ui/search → search/components}/_shared.css.d.ts +0 -0
  264. /package/src/{likec4diagram/ui/search → search/components}/ViewsColumn.css.ts +0 -0
@@ -1,3 +1,5 @@
1
+ import { focusable } from './_shared.css.js';
2
+
1
3
  function stopAndPrevent(e) {
2
4
  e.stopPropagation();
3
5
  e.preventDefault();
@@ -16,5 +18,9 @@ function moveFocusToSearchInput() {
16
18
  input.setSelectionRange(length, length);
17
19
  }
18
20
  }
21
+ function focusToFirstFoundElement() {
22
+ let firstFoundElement = document.querySelector(`[data-likec4-search] .${focusable}`);
23
+ firstFoundElement?.focus();
24
+ }
19
25
 
20
- export { centerY, moveFocusToSearchInput, stopAndPrevent };
26
+ export { centerY, focusToFirstFoundElement, moveFocusToSearchInput, stopAndPrevent };
@@ -0,0 +1,16 @@
1
+ import { SearchActorRef } from './searchActor';
2
+ import { Fqn } from '@likec4/core';
3
+ export declare const SearchActorContext: ({ children, value }: {
4
+ value: {
5
+ searchActorRef: SearchActorRef;
6
+ close: (cb?: () => void) => void;
7
+ };
8
+ children: React.ReactNode;
9
+ }) => import("react/jsx-runtime").JSX.Element, useSearchActor: () => {
10
+ searchActorRef: SearchActorRef;
11
+ close: (cb?: () => void) => void;
12
+ };
13
+ export declare function useSearch(): [string, (search: string) => void];
14
+ export declare function useNormalizedSearch(): string;
15
+ export declare function useUpdateSearch(): (search: string) => void;
16
+ export declare function usePickViewFor(): Fqn | null;
@@ -0,0 +1,35 @@
1
+ import { createSafeContext } from '@mantine/core';
2
+ import { useSelector } from '@xstate/react';
3
+ import { useCallback, useDeferredValue } from 'react';
4
+
5
+ const [SearchActorContext, useSearchActor] = createSafeContext("SearchActorContext");
6
+ const selectSearchValue = (s) => s.context.searchValue;
7
+ function useSearch() {
8
+ const { searchActorRef } = useSearchActor();
9
+ const searchValue = useSelector(searchActorRef, selectSearchValue);
10
+ const updateSearch = useCallback((search) => {
11
+ searchActorRef.send({ type: "change.search", search });
12
+ }, [searchActorRef]);
13
+ return [searchValue, updateSearch];
14
+ }
15
+ const selectNormalizedSearchValue = (s) => {
16
+ const v = s.context.searchValue.trim().toLowerCase();
17
+ return v.length > 1 ? v : "";
18
+ };
19
+ function useNormalizedSearch() {
20
+ const { searchActorRef } = useSearchActor();
21
+ return useDeferredValue(useSelector(searchActorRef, selectNormalizedSearchValue));
22
+ }
23
+ function useUpdateSearch() {
24
+ const { searchActorRef } = useSearchActor();
25
+ return useCallback((search) => {
26
+ searchActorRef.send({ type: "change.search", search });
27
+ }, [searchActorRef]);
28
+ }
29
+ const selectPickViewFor = (s) => s.context.pickViewFor;
30
+ function usePickViewFor() {
31
+ const { searchActorRef } = useSearchActor();
32
+ return useSelector(searchActorRef, selectPickViewFor);
33
+ }
34
+
35
+ export { SearchActorContext, useNormalizedSearch, usePickViewFor, useSearch, useSearchActor, useUpdateSearch };
@@ -0,0 +1,90 @@
1
+ import { Fqn } from '@likec4/core/types';
2
+ import { ActorLogicFrom, ActorRefFrom, SnapshotFrom, StateMachine, Values, NonReducibleUnknown, EventObject, MetaObject, ActionFunction } from 'xstate';
3
+ export type SearchActorEvent = {
4
+ type: 'open';
5
+ search?: string | undefined;
6
+ } | {
7
+ type: 'close';
8
+ } | {
9
+ type: 'change.search';
10
+ search: string;
11
+ } | {
12
+ type: 'pickview.open';
13
+ elementFqn: Fqn;
14
+ } | {
15
+ type: 'pickview.close';
16
+ };
17
+ export interface SearchContext {
18
+ openedWithSearch: string | null;
19
+ searchValue: string;
20
+ pickViewFor: Fqn | null;
21
+ }
22
+ declare const _searchActorLogic: StateMachine<SearchContext, SearchActorEvent, {}, never, Values<{
23
+ "change searchValue": {
24
+ type: "change searchValue";
25
+ params: NonReducibleUnknown;
26
+ };
27
+ "reset pickViewFor": {
28
+ type: "reset pickViewFor";
29
+ params: NonReducibleUnknown;
30
+ };
31
+ }>, never, never, "inactive" | "opened" | "pickView", string, NonReducibleUnknown, NonReducibleUnknown, EventObject, MetaObject, {
32
+ readonly id: "search";
33
+ readonly context: {
34
+ readonly openedWithSearch: null;
35
+ readonly searchValue: "";
36
+ readonly pickViewFor: null;
37
+ };
38
+ readonly initial: "inactive";
39
+ readonly on: {
40
+ readonly close: {
41
+ readonly target: ".inactive";
42
+ readonly actions: "reset pickViewFor";
43
+ };
44
+ };
45
+ readonly states: {
46
+ readonly inactive: {
47
+ readonly on: {
48
+ readonly open: {
49
+ readonly target: "opened";
50
+ readonly actions: readonly [ ActionFunction<SearchContext, {
51
+ type: "open";
52
+ search?: string | undefined;
53
+ }, SearchActorEvent, undefined, never, never, never, never, never>];
54
+ };
55
+ };
56
+ };
57
+ readonly opened: {
58
+ readonly on: {
59
+ readonly open: {
60
+ readonly actions: "change searchValue";
61
+ };
62
+ readonly 'change.search': {
63
+ readonly actions: "change searchValue";
64
+ };
65
+ readonly 'pickview.open': {
66
+ readonly target: "pickView";
67
+ readonly actions: ActionFunction<SearchContext, {
68
+ type: "pickview.open";
69
+ elementFqn: Fqn;
70
+ }, SearchActorEvent, undefined, never, never, never, never, never>;
71
+ };
72
+ };
73
+ };
74
+ readonly pickView: {
75
+ readonly on: {
76
+ readonly 'pickview.close': {
77
+ readonly target: "opened";
78
+ readonly actions: "reset pickViewFor";
79
+ };
80
+ };
81
+ };
82
+ };
83
+ }>;
84
+ export interface SearchActorLogic extends ActorLogicFrom<typeof _searchActorLogic> {
85
+ }
86
+ export declare const searchActorLogic: SearchActorLogic;
87
+ export type SearchActorSnapshot = SnapshotFrom<SearchActorLogic>;
88
+ export interface SearchActorRef extends ActorRefFrom<SearchActorLogic> {
89
+ }
90
+ export {};
@@ -0,0 +1,75 @@
1
+ import { setup, assign, assertEvent } from 'xstate';
2
+
3
+ const _searchActorLogic = setup({
4
+ types: {
5
+ context: {},
6
+ events: {}
7
+ },
8
+ actions: {
9
+ "change searchValue": assign({
10
+ searchValue: ({ event, context }) => {
11
+ assertEvent(event, ["change.search", "open"]);
12
+ return event.search ?? context.searchValue;
13
+ }
14
+ }),
15
+ "reset pickViewFor": assign({
16
+ pickViewFor: () => null
17
+ })
18
+ }
19
+ }).createMachine({
20
+ id: "search",
21
+ context: {
22
+ openedWithSearch: null,
23
+ searchValue: "",
24
+ pickViewFor: null
25
+ },
26
+ initial: "inactive",
27
+ on: {
28
+ "close": {
29
+ target: ".inactive",
30
+ actions: "reset pickViewFor"
31
+ }
32
+ },
33
+ states: {
34
+ inactive: {
35
+ on: {
36
+ "open": {
37
+ target: "opened",
38
+ actions: [
39
+ assign({
40
+ openedWithSearch: ({ event }) => event.search ?? null,
41
+ searchValue: ({ event, context }) => event.search ?? context.searchValue
42
+ })
43
+ ]
44
+ }
45
+ }
46
+ },
47
+ opened: {
48
+ on: {
49
+ "open": {
50
+ actions: "change searchValue"
51
+ },
52
+ "change.search": {
53
+ actions: "change searchValue"
54
+ },
55
+ "pickview.open": {
56
+ target: "pickView",
57
+ actions: assign({
58
+ pickViewFor: ({ event }) => event.elementFqn
59
+ })
60
+ }
61
+ }
62
+ },
63
+ pickView: {
64
+ on: {
65
+ "pickview.close": {
66
+ target: "opened",
67
+ actions: "reset pickViewFor"
68
+ }
69
+ }
70
+ }
71
+ }
72
+ });
73
+ const searchActorLogic = _searchActorLogic;
74
+
75
+ export { searchActorLogic };
@@ -1,9 +1,11 @@
1
- import { WhereOperator } from '@likec4/core';
1
+ import { DiagramView, WhereOperator } from '@likec4/core/types';
2
2
  import { PropsWithChildren } from 'react';
3
- import { Input } from './diagram-machine';
4
- type ActorContextInput = Omit<Input, 'xystore' | 'xynodes' | 'xyedges'>;
5
- export declare function DiagramActorProvider({ input: { view, ...inputs }, where, children, }: PropsWithChildren<{
6
- input: ActorContextInput;
7
- where?: WhereOperator<string, string> | undefined;
3
+ import { PaddingWithUnit } from '../LikeC4Diagram.props';
4
+ export declare function DiagramActorProvider({ view, zoomable, pannable, fitViewPadding, nodesSelectable, where, children, }: PropsWithChildren<{
5
+ view: DiagramView;
6
+ zoomable: boolean;
7
+ pannable: boolean;
8
+ fitViewPadding: PaddingWithUnit;
9
+ nodesSelectable: boolean;
10
+ where: WhereOperator | null;
8
11
  }>): import("react/jsx-runtime").JSX.Element;
9
- export {};
@@ -1,35 +1,35 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { useDeepCompareEffect } from '@react-hookz/web';
3
2
  import { useActorRef, useSelector } from '@xstate/react';
4
3
  import { useStoreApi } from '@xyflow/react';
5
4
  import { shallowEqual } from 'fast-equals';
6
- import { useEffect } from 'react';
5
+ import { useRef, useEffect } from 'react';
7
6
  import { useDiagramEventHandlersRef } from '../context/DiagramEventHandlers.js';
8
7
  import { useEnabledFeatures, DiagramFeatures } from '../context/DiagramFeatures.js';
9
8
  import { DiagramActorContextProvider } from '../hooks/safeContext.js';
10
- import { useUpdateEffect } from '../hooks/useUpdateEffect.js';
11
9
  import { useViewToNodesEdges } from '../likec4diagram/useViewToNodesEdges.js';
12
10
  import { diagramMachine } from './diagram-machine.js';
13
11
  import { syncManualLayoutActorLogic } from './syncManualLayoutActor.js';
14
12
 
15
13
  const selectToggledFeatures = (state) => state.context.toggledFeatures;
16
14
  function DiagramActorProvider({
17
- input: {
18
- view,
19
- ...inputs
20
- },
15
+ view,
16
+ zoomable,
17
+ pannable,
18
+ fitViewPadding,
19
+ nodesSelectable,
21
20
  where,
22
21
  children
23
22
  }) {
24
23
  const handlersRef = useDiagramEventHandlersRef();
25
24
  const xystore = useStoreApi();
26
- const actorRef = useActorRef(
27
- diagramMachine.provide({
25
+ const machineRef = useRef(null);
26
+ if (!machineRef.current) {
27
+ machineRef.current = diagramMachine.provide({
28
28
  actions: {
29
29
  "trigger:NavigateTo": (_, { viewId }) => {
30
30
  setTimeout(() => {
31
31
  handlersRef.current.onNavigateTo?.(viewId);
32
- }, 50);
32
+ }, 30);
33
33
  },
34
34
  "trigger:OnChange": (_, params) => {
35
35
  handlersRef.current.onChange?.(params);
@@ -47,31 +47,37 @@ function DiagramActorProvider({
47
47
  }
48
48
  })
49
49
  }
50
- }),
50
+ });
51
+ }
52
+ const actorRef = useActorRef(
53
+ machineRef.current,
51
54
  {
52
- id: `diagram:${view.id}`,
55
+ id: `diagram`,
53
56
  systemId: "diagram",
54
57
  // ...inspector,
55
58
  input: {
56
59
  xystore,
57
60
  view,
58
- ...inputs
61
+ zoomable,
62
+ pannable,
63
+ fitViewPadding,
64
+ nodesSelectable
59
65
  }
60
66
  }
61
67
  );
62
68
  const features = useEnabledFeatures();
63
- useUpdateEffect(() => {
64
- actorRef.send({ type: "update.inputs", inputs });
65
- }, [inputs]);
66
69
  useEffect(() => {
67
70
  actorRef.send({ type: "update.features", features });
68
71
  }, [features]);
72
+ useEffect(() => {
73
+ actorRef.send({ type: "update.inputs", inputs: { zoomable, pannable, fitViewPadding, nodesSelectable } });
74
+ }, [zoomable, pannable, fitViewPadding, nodesSelectable]);
69
75
  const { xyedges, xynodes } = useViewToNodesEdges({
70
76
  view,
71
77
  where,
72
- nodesSelectable: inputs.nodesSelectable
78
+ nodesSelectable
73
79
  });
74
- useDeepCompareEffect(() => {
80
+ useEffect(() => {
75
81
  actorRef.send({ type: "update.view", view, xyedges, xynodes });
76
82
  }, [view, xyedges, xynodes]);
77
83
  const toggledFeatures = useSelector(actorRef, selectToggledFeatures, shallowEqual);
@@ -8,7 +8,6 @@ export declare function lastClickedNode(params: {
8
8
  }): DiagramContext['lastClickedNode'];
9
9
  export declare function mergeXYNodesEdges({ context, event }: ActionArg): Partial<DiagramContext>;
10
10
  export declare function focusNodesEdges(params: ActionArg): Partial<DiagramContext>;
11
- export declare function unfocusNodesEdges({ context }: ActionArg): Partial<DiagramContext>;
12
11
  export declare function updateNavigationHistory({ context, event }: ActionArg): Partial<DiagramContext>;
13
12
  export declare function navigateBack({ context }: ActionArg): Partial<DiagramContext>;
14
13
  export declare function navigateForward({ context }: ActionArg): Partial<DiagramContext>;
@@ -3,8 +3,8 @@ import { getNodeDimensions } from '@xyflow/system';
3
3
  import { deepEqual } from 'fast-equals';
4
4
  import { omit, mergeDeep, isEmpty } from 'remeda';
5
5
  import { assertEvent } from 'xstate';
6
- import { Base } from '../base/types.js';
7
6
  import { VectorImpl, vector } from '../utils/vector.js';
7
+ import { setDimmed, setData } from '../base/types.Base.js';
8
8
 
9
9
  function lastClickedNode(params) {
10
10
  const { lastClickedNode: lastClickedNode2 } = params.context;
@@ -101,31 +101,21 @@ function focusNodesEdges(params) {
101
101
  if (edge.source === focusedNode || edge.target === focusedNode) {
102
102
  focused.add(edge.source);
103
103
  focused.add(edge.target);
104
- return Base.setData(edge, {
104
+ return setData(edge, {
105
105
  dimmed: false,
106
106
  active: true
107
107
  });
108
108
  }
109
- return Base.setData(edge, {
109
+ return setData(edge, {
110
110
  dimmed: true,
111
111
  active: false
112
112
  });
113
113
  });
114
114
  return {
115
- xynodes: _xynodes.map((n) => Base.setDimmed(n, !focused.has(n.id))),
115
+ xynodes: _xynodes.map((n) => setDimmed(n, !focused.has(n.id))),
116
116
  xyedges
117
117
  };
118
118
  }
119
- function unfocusNodesEdges({ context }) {
120
- const { xynodes, xyedges } = context;
121
- return {
122
- xynodes: xynodes.map(Base.setDimmed(false)),
123
- xyedges: xyedges.map(Base.setData({
124
- dimmed: false,
125
- active: false
126
- }))
127
- };
128
- }
129
119
  function updateNavigationHistory({ context, event }) {
130
120
  assertEvent(event, "update.view");
131
121
  let {
@@ -296,8 +286,8 @@ function resetEdgeControlPoints({ context }) {
296
286
  const loopSize = 80;
297
287
  const centerOfTopBoundary = new VectorImpl(0, source.height || 0).mul(-0.5).add(sourceCenter);
298
288
  return [
299
- centerOfTopBoundary.add(new VectorImpl(-80 / 2.5, -80)),
300
- centerOfTopBoundary.add(new VectorImpl(loopSize / 2.5, -80))
289
+ centerOfTopBoundary.add(new VectorImpl(-loopSize / 2.5, -loopSize)),
290
+ centerOfTopBoundary.add(new VectorImpl(loopSize / 2.5, -loopSize))
301
291
  ];
302
292
  }
303
293
  const sourceToTargetVector = targetCenter.sub(sourceCenter);
@@ -332,16 +322,16 @@ function updateActiveWalkthrough({ context }) {
332
322
  return {
333
323
  xyedges: context.xyedges.map((edge) => {
334
324
  const active = stepId === edge.id || !!parallelPrefix && edge.id.startsWith(parallelPrefix);
335
- return Base.setData(edge, {
325
+ return setData(edge, {
336
326
  active,
337
327
  dimmed: !active
338
328
  });
339
329
  }),
340
330
  xynodes: context.xynodes.map((node) => {
341
331
  const dimmed = step.source !== node.id && step.target !== node.id;
342
- return Base.setDimmed(node, dimmed);
332
+ return setDimmed(node, dimmed);
343
333
  })
344
334
  };
345
335
  }
346
336
 
347
- export { focusNodesEdges, lastClickedNode, mergeXYNodesEdges, navigateBack, navigateForward, resetEdgeControlPoints, unfocusNodesEdges, updateActiveWalkthrough, updateEdgeData, updateNavigationHistory, updateNodeData };
337
+ export { focusNodesEdges, lastClickedNode, mergeXYNodesEdges, navigateBack, navigateForward, resetEdgeControlPoints, updateActiveWalkthrough, updateEdgeData, updateNavigationHistory, updateNodeData };