@likec4/diagram 1.35.0 → 1.36.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 (224) hide show
  1. package/bundle/{chunk-C0Eg81Gj.js → chunk-DHvr-RGh.js} +323 -311
  2. package/bundle/custom.js +52 -52
  3. package/bundle/index.js +1594 -749
  4. package/dist/LikeC4Diagram.js +6 -6
  5. package/dist/LikeC4Diagram.props.d.ts +2 -3
  6. package/dist/LikeC4ModelProvider.d.ts +3 -3
  7. package/dist/LikeC4ProjectsProvider.d.ts +17 -0
  8. package/dist/LikeC4ProjectsProvider.js +22 -0
  9. package/dist/LikeC4Styles.d.ts +1 -0
  10. package/dist/LikeC4Styles.js +94 -0
  11. package/dist/StaticLikeC4Diagram.d.ts +3 -3
  12. package/dist/base/BaseXYFlow.js +23 -26
  13. package/dist/base/primitives/MarkdownBlock.d.ts +7 -1
  14. package/dist/base/primitives/MarkdownBlock.js +1 -1
  15. package/dist/base/primitives/compound/CompoundActionButton.js +2 -2
  16. package/dist/base/primitives/compound/CompoundDetailsButton.js +2 -2
  17. package/dist/base/primitives/compound/CompoundNodeContainer.css.js +4 -4
  18. package/dist/base/primitives/compound/CompoundNodeContainer.js +1 -4
  19. package/dist/base/primitives/compound/CompoundTitle.js +9 -8
  20. package/dist/base/primitives/compound/actionbtns.css.js +6 -6
  21. package/dist/base/primitives/edge/EdgeActionButton.js +2 -2
  22. package/dist/base/primitives/edge/EdgeContainer.js +4 -7
  23. package/dist/base/primitives/edge/EdgeLabel.css.d.ts +0 -22
  24. package/dist/base/primitives/edge/EdgeLabel.css.js +6 -84
  25. package/dist/base/primitives/edge/EdgeLabel.js +16 -6
  26. package/dist/base/primitives/edge/EdgeLabelContainer.js +1 -6
  27. package/dist/base/primitives/edge/EdgeMarkers.js +3 -3
  28. package/dist/base/primitives/edge/edge.css.d.ts +0 -2
  29. package/dist/base/primitives/edge/edge.css.js +1 -55
  30. package/dist/base/primitives/element/ElementActionButtons.js +2 -2
  31. package/dist/base/primitives/element/ElementDetailsButton.js +8 -7
  32. package/dist/base/primitives/element/ElementNodeContainer.css.js +4 -4
  33. package/dist/base/primitives/element/ElementNodeContainer.js +1 -4
  34. package/dist/base/primitives/element/ElementShape.css.js +11 -11
  35. package/dist/base/primitives/element/ElementTags.d.ts +1 -0
  36. package/dist/base/primitives/element/ElementTags.js +17 -14
  37. package/dist/bundle/LikeC4View.d.ts +1 -1
  38. package/dist/bundle/LikeC4View.js +7 -1
  39. package/dist/bundle/LikeC4View.props.d.ts +1 -2
  40. package/dist/bundle/ReactLikeC4.d.ts +1 -1
  41. package/dist/bundle/ViewNotFound.js +1 -1
  42. package/dist/bundle/index.d.ts +2 -1
  43. package/dist/bundle/index.js +1 -0
  44. package/dist/bundle/styles.css.js +1 -1
  45. package/dist/components/ErrorFallback.js +1 -1
  46. package/dist/components/GithubIcon.d.ts +2 -0
  47. package/dist/components/GithubIcon.js +17 -0
  48. package/dist/components/Link.d.ts +4 -3
  49. package/dist/components/Link.js +84 -87
  50. package/dist/components/NavigationLink.d.ts +2 -2
  51. package/dist/components/SearchControl.css.js +6 -5
  52. package/dist/context/DiagramEventHandlers.d.ts +6 -6
  53. package/dist/context/DiagramEventHandlers.js +4 -7
  54. package/dist/globals.css.js +3 -0
  55. package/dist/hooks/useXYFlow.d.ts +10 -10
  56. package/dist/index.d.ts +1 -0
  57. package/dist/index.js +1 -0
  58. package/dist/likec4diagram/DiagramUI.js +2 -1
  59. package/dist/likec4diagram/custom/edges/NotePopover.css.js +2 -2
  60. package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +2 -2
  61. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +1 -1
  62. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.js +7 -7
  63. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +3 -3
  64. package/dist/likec4diagram/custom/edges/edges.css.js +4 -4
  65. package/dist/likec4diagram/custom/index.d.ts +2 -2
  66. package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +2 -2
  67. package/dist/likec4diagram/ui/controls/styles.css.js +5 -5
  68. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +4 -4
  69. package/dist/likec4diagram/ui/notation/NotationPanel.css.js +11 -11
  70. package/dist/likec4diagram/ui/notation/NotationPanel.js +2 -5
  71. package/dist/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.css.js +10 -10
  72. package/dist/likec4model/LikeC4ModelContext.d.ts +2 -1
  73. package/dist/likec4model/LikeC4ModelContext.js +10 -2
  74. package/dist/likec4model/LikeC4ProjectsContext.d.ts +7 -0
  75. package/dist/likec4model/LikeC4ProjectsContext.js +5 -0
  76. package/dist/likec4model/index.d.ts +1 -0
  77. package/dist/likec4model/useCurrentViewModel.d.ts +1 -0
  78. package/dist/likec4model/useCurrentViewModel.js +4 -1
  79. package/dist/likec4model/useLikeC4Project.d.ts +22 -0
  80. package/dist/likec4model/useLikeC4Project.js +23 -0
  81. package/dist/navigationpanel/NavigationPanel.js +15 -17
  82. package/dist/navigationpanel/NavigationPanelControls.js +34 -21
  83. package/dist/navigationpanel/NavigationPanelDropdown.js +33 -17
  84. package/dist/navigationpanel/_common.js +4 -1
  85. package/dist/navigationpanel/actor.d.ts +11 -15
  86. package/dist/navigationpanel/actor.js +14 -15
  87. package/dist/navigationpanel/controls/BurgerButton.js +5 -7
  88. package/dist/navigationpanel/controls/NavigationButtons.js +37 -24
  89. package/dist/navigationpanel/controls/OpenSource.js +1 -1
  90. package/dist/navigationpanel/controls/SearchControl.js +6 -4
  91. package/dist/navigationpanel/controls/ToggleReadonly.js +3 -3
  92. package/dist/navigationpanel/controls/ViewDetailsCard.d.ts +2 -0
  93. package/dist/navigationpanel/controls/ViewDetailsCard.js +232 -0
  94. package/dist/navigationpanel/controls/index.d.ts +1 -0
  95. package/dist/navigationpanel/dropdown/ProjectsMenu.d.ts +2 -0
  96. package/dist/navigationpanel/dropdown/ProjectsMenu.js +75 -0
  97. package/dist/navigationpanel/editorpanel/EditorPanel.js +3 -3
  98. package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +19 -20
  99. package/dist/navigationpanel/editorpanel/styles.js +5 -5
  100. package/dist/navigationpanel/hooks.d.ts +2 -2
  101. package/dist/navigationpanel/styles.css.js +0 -2
  102. package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +12 -7
  103. package/dist/node_modules/.pnpm/@tabler_icons-react@3.34.1_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronDown.js +14 -0
  104. package/dist/node_modules/.pnpm/@tabler_icons-react@3.34.1_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconLink.js +14 -0
  105. package/dist/overlays/element-details/ElementDetailsCard.css.js +18 -17
  106. package/dist/overlays/element-details/ElementDetailsCard.js +8 -13
  107. package/dist/overlays/element-details/TabPanelDeployments.css.js +5 -4
  108. package/dist/overlays/element-details/TabPanelRelationships.css.js +7 -7
  109. package/dist/overlays/overlay/Overlay.css.d.ts +3 -3
  110. package/dist/overlays/overlay/Overlay.css.js +8 -7
  111. package/dist/overlays/relationship-details/SelectEdge.css.js +8 -8
  112. package/dist/overlays/relationships-browser/SelectElement.css.js +1 -1
  113. package/dist/search/Search.js +6 -6
  114. package/dist/search/components/ElementsColumn.css.js +5 -5
  115. package/dist/search/components/SearchByTags.js +3 -2
  116. package/dist/search/components/ViewsColum.js +1 -1
  117. package/dist/search/components/ViewsColumn.css.js +1 -1
  118. package/dist/search/components/_shared.css.js +3 -3
  119. package/dist/search/components/styles.css.js +5 -5
  120. package/dist/state/DiagramActorProvider.js +43 -25
  121. package/dist/state/diagram-machine.d.ts +29 -247
  122. package/dist/state/diagram-machine.js +16 -16
  123. package/dist/styles-min.css +1 -1
  124. package/dist/styles.css +1 -1
  125. package/dist/styles.css2.js +1 -1
  126. package/package.json +10 -8
  127. package/panda.buildinfo.json +254 -326
  128. package/src/LikeC4Diagram.props.ts +2 -2
  129. package/src/LikeC4Diagram.tsx +2 -2
  130. package/src/LikeC4ModelProvider.tsx +4 -4
  131. package/src/LikeC4ProjectsProvider.tsx +41 -0
  132. package/src/LikeC4Styles.tsx +107 -0
  133. package/src/StaticLikeC4Diagram.tsx +3 -3
  134. package/src/base/BaseXYFlow.tsx +24 -29
  135. package/src/base/primitives/MarkdownBlock.tsx +11 -3
  136. package/src/base/primitives/compound/CompoundActionButton.tsx +2 -2
  137. package/src/base/primitives/compound/CompoundDetailsButton.tsx +2 -2
  138. package/src/base/primitives/compound/CompoundNodeContainer.css.ts +4 -13
  139. package/src/base/primitives/compound/CompoundNodeContainer.tsx +0 -3
  140. package/src/base/primitives/compound/CompoundTitle.tsx +8 -8
  141. package/src/base/primitives/compound/actionbtns.css.ts +6 -6
  142. package/src/base/primitives/edge/EdgeActionButton.tsx +2 -2
  143. package/src/base/primitives/edge/EdgeContainer.tsx +3 -6
  144. package/src/base/primitives/edge/EdgeLabel.css.ts +4 -83
  145. package/src/base/primitives/edge/EdgeLabel.tsx +16 -10
  146. package/src/base/primitives/edge/EdgeLabelContainer.tsx +1 -6
  147. package/src/base/primitives/edge/EdgeMarkers.tsx +3 -3
  148. package/src/base/primitives/edge/edge.css.ts +0 -60
  149. package/src/base/primitives/element/ElementActionButtons.tsx +2 -2
  150. package/src/base/primitives/element/ElementDetailsButton.tsx +7 -7
  151. package/src/base/primitives/element/ElementNodeContainer.css.ts +4 -4
  152. package/src/base/primitives/element/ElementNodeContainer.tsx +0 -3
  153. package/src/base/primitives/element/ElementShape.css.ts +11 -11
  154. package/src/base/primitives/element/ElementTags.tsx +17 -14
  155. package/src/bundle/LikeC4View.props.ts +1 -2
  156. package/src/bundle/LikeC4View.tsx +10 -3
  157. package/src/bundle/ReactLikeC4.tsx +1 -2
  158. package/src/bundle/ViewNotFound.tsx +1 -1
  159. package/src/bundle/index.ts +2 -1
  160. package/src/bundle/styles.css.ts +1 -1
  161. package/src/components/ErrorFallback.tsx +1 -1
  162. package/src/components/GithubIcon.tsx +16 -0
  163. package/src/components/Link.tsx +102 -113
  164. package/src/components/NavigationLink.tsx +2 -1
  165. package/src/components/SearchControl.css.ts +5 -5
  166. package/src/context/DiagramEventHandlers.tsx +12 -12
  167. package/src/globals.css +71 -0
  168. package/src/index.ts +5 -0
  169. package/src/likec4diagram/DiagramUI.tsx +8 -2
  170. package/src/likec4diagram/custom/edges/NotePopover.css.ts +2 -2
  171. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +1 -1
  172. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.ts +7 -7
  173. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +3 -3
  174. package/src/likec4diagram/custom/edges/edges.css.ts +4 -4
  175. package/src/likec4diagram/custom/nodes/toolbar/CompoundToolbar.tsx +2 -2
  176. package/src/likec4diagram/ui/controls/styles.css.ts +5 -5
  177. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +4 -5
  178. package/src/likec4diagram/ui/notation/NotationPanel.css.ts +11 -11
  179. package/src/likec4diagram/ui/notation/NotationPanel.tsx +1 -4
  180. package/src/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.css.ts +10 -10
  181. package/src/likec4model/{LikeC4ModelContext.ts → LikeC4ModelContext.tsx} +9 -1
  182. package/src/likec4model/LikeC4ProjectsContext.ts +9 -0
  183. package/src/likec4model/index.ts +8 -0
  184. package/src/likec4model/useCurrentViewModel.ts +4 -0
  185. package/src/likec4model/useLikeC4Project.ts +61 -0
  186. package/src/navigationpanel/NavigationPanel.tsx +16 -17
  187. package/src/navigationpanel/NavigationPanelControls.tsx +24 -46
  188. package/src/navigationpanel/NavigationPanelDropdown.tsx +32 -16
  189. package/src/navigationpanel/_common.tsx +4 -1
  190. package/src/navigationpanel/actor.ts +14 -15
  191. package/src/navigationpanel/controls/BurgerButton.tsx +5 -7
  192. package/src/navigationpanel/controls/NavigationButtons.tsx +9 -1
  193. package/src/navigationpanel/controls/OpenSource.tsx +1 -1
  194. package/src/navigationpanel/controls/SearchControl.tsx +6 -4
  195. package/src/navigationpanel/controls/ToggleReadonly.tsx +3 -3
  196. package/src/navigationpanel/controls/ViewDetailsCard.tsx +244 -0
  197. package/src/navigationpanel/controls/index.ts +1 -0
  198. package/src/navigationpanel/dropdown/ProjectsMenu.tsx +74 -0
  199. package/src/navigationpanel/editorpanel/EditorPanel.tsx +3 -3
  200. package/src/navigationpanel/editorpanel/ManualLayoutToolsButton.tsx +19 -22
  201. package/src/navigationpanel/editorpanel/styles.ts +5 -5
  202. package/src/navigationpanel/hooks.tsx +2 -2
  203. package/src/navigationpanel/styles.css.ts +0 -2
  204. package/src/navigationpanel/walkthrough/ActiveWalkthroughControls.tsx +9 -4
  205. package/src/overlays/element-details/ElementDetailsCard.css.ts +17 -17
  206. package/src/overlays/element-details/ElementDetailsCard.tsx +8 -13
  207. package/src/overlays/element-details/TabPanelDeployments.css.ts +4 -4
  208. package/src/overlays/element-details/TabPanelRelationships.css.ts +7 -7
  209. package/src/overlays/overlay/Overlay.css.ts +7 -7
  210. package/src/overlays/relationship-details/SelectEdge.css.ts +8 -8
  211. package/src/overlays/relationships-browser/SelectElement.css.ts +1 -1
  212. package/src/search/Search.tsx +6 -6
  213. package/src/search/components/ElementsColumn.css.ts +5 -5
  214. package/src/search/components/SearchByTags.tsx +2 -2
  215. package/src/search/components/ViewsColum.tsx +1 -1
  216. package/src/search/components/ViewsColumn.css.ts +1 -1
  217. package/src/search/components/_shared.css.ts +3 -3
  218. package/src/search/components/styles.css.ts +5 -5
  219. package/src/state/DiagramActorProvider.tsx +56 -30
  220. package/src/state/diagram-machine.ts +22 -16
  221. package/dist/LikeC4CustomColors.d.ts +0 -2
  222. package/dist/LikeC4CustomColors.js +0 -45
  223. package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +0 -45
  224. package/src/LikeC4CustomColors.tsx +0 -85
@@ -4,7 +4,7 @@ import { container } from '@likec4/styles/patterns';
4
4
  const whenContainerIsNarrow = `@container likec4-tree (max-width: 450px)`;
5
5
  const treeNode = css({
6
6
  outline: "none",
7
- marginBottom: "8px"
7
+ marginBottom: "2"
8
8
  });
9
9
  const treeRoot = css(
10
10
  container.raw({
@@ -19,10 +19,10 @@ const treeLabel = css({
19
19
  display: "flex",
20
20
  alignItems: "baseline",
21
21
  outline: "none !important",
22
- gap: "4px"
22
+ gap: "1"
23
23
  });
24
24
  const treeSubtree = css({
25
- marginTop: "8px"
25
+ marginTop: "2"
26
26
  });
27
27
  const elementExpandIcon = css({
28
28
  color: "mantine.colors.dimmed"
@@ -31,7 +31,7 @@ const elementTitleAndId = css({
31
31
  [whenContainerIsNarrow]: {
32
32
  flexDirection: "column-reverse",
33
33
  alignItems: "flex-start",
34
- gap: 2
34
+ gap: "0.5"
35
35
  }
36
36
  });
37
37
  const elementId = css({
@@ -41,7 +41,7 @@ const elementId = css({
41
41
  display: "block",
42
42
  fontWeight: 500,
43
43
  whiteSpace: "nowrap",
44
- padding: "1px 5px",
44
+ padding: "[1px 5px]",
45
45
  borderRadius: "4px",
46
46
  background: `mantine.colors.dark[9]/30`,
47
47
  _light: {
@@ -29,7 +29,7 @@ function SearchByTags() {
29
29
  ref,
30
30
  css: {
31
31
  gap: "md",
32
- paddingLeft: 48,
32
+ paddingLeft: "[48px]",
33
33
  flexWrap: "nowrap"
34
34
  },
35
35
  children: [
@@ -37,7 +37,8 @@ function SearchByTags() {
37
37
  HStack,
38
38
  {
39
39
  css: {
40
- gap: 6,
40
+ gap: "1.5",
41
+ // 6px
41
42
  flexWrap: "wrap",
42
43
  opacity: isFiltered ? 1 : 0.3,
43
44
  grayscale: isFiltered ? 0 : 0.9,
@@ -28,7 +28,7 @@ const ViewsColumn = memo(() => {
28
28
  if (search.startsWith("#")) {
29
29
  return view.tags.some((tag) => tag.toLocaleLowerCase().includes(search.slice(1)));
30
30
  }
31
- return (view.title ?? "" + view.$view.description ?? "").toLocaleLowerCase().includes(search);
31
+ return `${view.title} ${view.$view.description}`.toLocaleLowerCase().includes(search);
32
32
  });
33
33
  }
34
34
  }
@@ -16,7 +16,7 @@ const viewButton = cx(
16
16
  _viewBtn
17
17
  );
18
18
  css({
19
- marginTop: "4px",
19
+ marginTop: "1",
20
20
  // transition: transitions.fast,
21
21
  // color: `[var(${descriptionColor}, {colors.mantine.colors.dimmed})]`,
22
22
  fontSize: "13px",
@@ -11,9 +11,9 @@ const button = css.raw({
11
11
  width: "100%",
12
12
  background: "mantine.colors.body",
13
13
  rounded: "sm",
14
- padding: `12px 8px 12px 14px`,
14
+ padding: `[12px 8px 12px 14px]`,
15
15
  minHeight: "60px",
16
- gap: 8,
16
+ gap: "2",
17
17
  // alignItems: 'flex-start',
18
18
  // transition: `all 50ms ${easings.inOut}`,
19
19
  border: `1px solid`,
@@ -126,7 +126,7 @@ const descriptionColor = css.raw({
126
126
  }
127
127
  });
128
128
  const description = css.raw(descriptionColor, {
129
- marginTop: "4px",
129
+ marginTop: "1",
130
130
  fontSize: "12px",
131
131
  lineHeight: "1.4",
132
132
  [`:where([data-disabled]) &`]: {
@@ -16,7 +16,7 @@ const input = css({
16
16
  });
17
17
  const pickviewBackdrop = css({
18
18
  position: "absolute",
19
- inset: 0,
19
+ inset: "0",
20
20
  width: "100%",
21
21
  height: "100%",
22
22
  backgroundColor: "[rgb(34 34 34 / 0.7)]",
@@ -29,8 +29,8 @@ const pickviewBackdrop = css({
29
29
  });
30
30
  const pickview = css({
31
31
  position: "absolute",
32
- top: "2rem",
33
- left: "50%",
32
+ top: "[2rem]",
33
+ left: "[50%]",
34
34
  width: "100%",
35
35
  maxWidth: "600px",
36
36
  minWidth: "200px",
@@ -38,9 +38,9 @@ const pickview = css({
38
38
  zIndex: 903
39
39
  });
40
40
  const pickviewGroup = css({
41
- marginTop: "8px",
41
+ marginTop: "2",
42
42
  "& + &": {
43
- marginTop: "32px"
43
+ marginTop: "[32px]"
44
44
  }
45
45
  });
46
46
  css({
@@ -5,10 +5,9 @@ import { useStoreApi } from '@xyflow/react';
5
5
  import { shallowEqual, deepEqual } from 'fast-equals';
6
6
  import { useRef, useEffect, useState } from 'react';
7
7
  import { ErrorBoundary } from '../components/ErrorFallback.js';
8
- import { useDiagramEventHandlersRef } from '../context/DiagramEventHandlers.js';
8
+ import { useDiagramEventHandlers } from '../context/DiagramEventHandlers.js';
9
9
  import { useEnabledFeatures, DiagramFeatures } from '../context/DiagramFeatures.js';
10
10
  import { DiagramActorContextProvider } from '../hooks/safeContext.js';
11
- import { useCurrentViewId } from '../hooks/useCurrentViewId.js';
12
11
  import { useViewToNodesEdges } from '../likec4diagram/useViewToNodesEdges.js';
13
12
  import { CurrentViewModelContext } from '../likec4model/LikeC4ModelContext.js';
14
13
  import { useLikeC4Model } from '../likec4model/useLikeC4Model.js';
@@ -33,24 +32,11 @@ function DiagramActorProvider({
33
32
  where,
34
33
  children
35
34
  }) {
36
- const handlersRef = useDiagramEventHandlersRef();
35
+ const { handlersRef } = useDiagramEventHandlers();
37
36
  const xystore = useStoreApi();
38
37
  const machineRef = useRef(null);
39
38
  if (!machineRef.current) {
40
39
  machineRef.current = diagramMachine.provide({
41
- actions: {
42
- "trigger:NavigateTo": (_, { viewId }) => {
43
- setTimeout(() => {
44
- handlersRef.current.onNavigateTo?.(viewId);
45
- }, 40);
46
- },
47
- "trigger:OnChange": (_, params) => {
48
- handlersRef.current.onChange?.(params);
49
- },
50
- "trigger:OpenSource": (_, params) => {
51
- handlersRef.current.onOpenSource?.(params);
52
- }
53
- },
54
40
  actors: {
55
41
  syncManualLayoutActorLogic: syncManualLayoutActorLogic.provide({
56
42
  actions: {
@@ -78,6 +64,7 @@ function DiagramActorProvider({
78
64
  }
79
65
  }
80
66
  );
67
+ useActorEventHandlers(actorRef);
81
68
  const features = useEnabledFeatures();
82
69
  useCustomCompareEffect(
83
70
  () => {
@@ -102,32 +89,63 @@ function DiagramActorProvider({
102
89
  actorRef.send({ type: "update.view", view, xyedges, xynodes });
103
90
  }, [view, xyedges, xynodes]);
104
91
  const toggledFeatures = useSelector(actorRef, selectToggledFeatures, shallowEqual);
105
- return /* @__PURE__ */ jsx(DiagramActorContextProvider, { value: actorRef, children: /* @__PURE__ */ jsx(DiagramFeatures, { overrides: toggledFeatures, children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(CurrentViewModelProvider, { children }) }) }) });
92
+ return /* @__PURE__ */ jsx(DiagramActorContextProvider, { value: actorRef, children: /* @__PURE__ */ jsx(DiagramFeatures, { overrides: toggledFeatures, children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(CurrentViewModelProvider, { viewId: view.id, children }) }) }) });
106
93
  }
107
94
  function CurrentViewModelProvider({
108
- children
95
+ children,
96
+ viewId
109
97
  }) {
110
- const viewId = useCurrentViewId();
111
98
  const likec4model = useLikeC4Model();
112
- const [viewmodel, setViewmodel] = useState(() => likec4model.view(viewId));
99
+ const [viewmodel, setViewmodel] = useState(() => likec4model.findView(viewId));
113
100
  useEffect(() => {
114
101
  setViewmodel((current) => {
115
102
  const nextviewmodel = likec4model.findView(viewId);
116
103
  if (!nextviewmodel) {
117
- console.error(`View "${viewId}" not found in likec4model, current viewmodel: ${current.id}`, {
104
+ console.error(`View "${viewId}" not found in likec4model, current viewmodel: ${current?.id}`, {
118
105
  currentViewModel: current,
119
106
  likec4model
120
107
  });
121
108
  return current;
122
109
  }
110
+ if (!nextviewmodel.isDiagram()) {
111
+ console.warn(`View "${viewId}" is not diagram.
112
+ Make sure you have LikeC4ModelProvider with layouted model.`);
113
+ }
123
114
  return nextviewmodel;
124
115
  });
125
116
  }, [likec4model, viewId]);
126
- if (!viewmodel.isDiagram()) {
127
- console.warn(`View "${viewId}" is not diagram.
128
- Make sure you have LikeC4ModelProvider with layouted model.`);
129
- }
130
117
  return /* @__PURE__ */ jsx(CurrentViewModelContext.Provider, { value: viewmodel, children });
131
118
  }
119
+ function useActorEventHandlers(actorRef) {
120
+ const {
121
+ onChange,
122
+ onNavigateTo,
123
+ onOpenSource
124
+ } = useDiagramEventHandlers();
125
+ useEffect(() => {
126
+ if (!onChange) return;
127
+ const subscription = actorRef.on("viewChange", ({ change }) => onChange({ change }));
128
+ return () => subscription.unsubscribe();
129
+ }, [actorRef, onChange]);
130
+ useEffect(() => {
131
+ if (!onNavigateTo) return;
132
+ let frame;
133
+ const subscription = actorRef.on("navigateTo", ({ viewId }) => {
134
+ cancelAnimationFrame(frame);
135
+ frame = requestAnimationFrame(() => {
136
+ onNavigateTo(viewId);
137
+ });
138
+ });
139
+ return () => {
140
+ cancelAnimationFrame(frame);
141
+ subscription.unsubscribe();
142
+ };
143
+ }, [actorRef, onNavigateTo]);
144
+ useEffect(() => {
145
+ if (!onOpenSource) return;
146
+ const subscription = actorRef.on("openSource", ({ params }) => onOpenSource(params));
147
+ return () => subscription.unsubscribe();
148
+ }, [actorRef, onOpenSource]);
149
+ }
132
150
 
133
151
  export { DiagramActorProvider };
@@ -1,8 +1,8 @@
1
- import { DiagramView, EdgeId, Fqn, NodeId, NodeNotation as ElementNotation, StepEdgeId, ViewChange, ViewId, XYPoint, BBox, NonEmptyArray, Point, Color, RelationshipArrowType, RelationshipLineType } from '@likec4/core';
1
+ import { DiagramView, EdgeId, Fqn, NodeId, NodeNotation as ElementNotation, StepEdgeId, ViewChange, ViewId, XYPoint, BBox, NonEmptyArray, Point, Color, RelationshipArrowType, RelationshipLineType, MarkdownOrString } from '@likec4/core';
2
2
  import { ReactFlowInstance, useStoreApi } from '@xyflow/react';
3
3
  import { EdgeChange, NodeChange, Rect, Viewport, EdgeMarkerType, HandleType, XYPosition } from '@xyflow/system';
4
4
  import { PartialDeep } from 'type-fest';
5
- import { ActorLogicFrom, ActorRef, AnyEventObject, Snapshot, StateMachine, ActorRefFromLogic, Values, NonReducibleUnknown, EventObject, MetaObject, ConditionalRequired, InputFrom, RequiredActorOptions, IsNotNever, GetConcreteByKey, AnyActorLogic, RequiredLogicInput, MachineSnapshot, AnyActorRef, StateValue, ActionFunction, CancelAction, StopAction } from 'xstate';
5
+ import { ActorLogicFrom, ActorRef, AnyEventObject, Snapshot, StateMachine, ActorRefFromLogic, Values, NonReducibleUnknown, MetaObject, ConditionalRequired, InputFrom, RequiredActorOptions, IsNotNever, GetConcreteByKey, AnyActorLogic, RequiredLogicInput, MachineSnapshot, AnyActorRef, StateValue, ActionFunction, CancelAction, StopAction } from 'xstate';
6
6
  import { Base } from '../base/types';
7
7
  import { EnabledFeatures, FeatureName } from '../context/DiagramFeatures';
8
8
  import { OpenSourceParams, ViewPadding } from '../LikeC4Diagram.props';
@@ -192,6 +192,16 @@ export type Events = HotKeyEvent | {
192
192
  feature: FeatureName;
193
193
  forceValue?: boolean;
194
194
  };
195
+ export type EmittedEvents = {
196
+ type: 'navigateTo';
197
+ viewId: ViewId;
198
+ } | {
199
+ type: 'viewChange';
200
+ change: ViewChange;
201
+ } | {
202
+ type: 'openSource';
203
+ params: OpenSourceParams;
204
+ };
195
205
  export type ActionArg = {
196
206
  context: Context;
197
207
  event: Events;
@@ -283,9 +293,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
283
293
  };
284
294
  "trigger:NavigateTo": {
285
295
  type: "trigger:NavigateTo";
286
- params: {
287
- viewId: ViewId;
288
- };
296
+ params: NonReducibleUnknown;
289
297
  };
290
298
  "trigger:OpenSource": {
291
299
  type: "trigger:OpenSource";
@@ -419,7 +427,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
419
427
  };
420
428
  }>, never, "isReady" | "initializing" | "navigating" | {
421
429
  ready: "idle" | "walkthrough" | "focused";
422
- }, string, Input, NonReducibleUnknown, EventObject, MetaObject, {
430
+ }, string, Input, NonReducibleUnknown, EmittedEvents, MetaObject, {
423
431
  readonly initial: "initializing";
424
432
  readonly context: ({ input }: {
425
433
  spawn: {
@@ -901,7 +909,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
901
909
  tail: RelationshipArrowType | undefined;
902
910
  labelBBox: BBox | null | undefined;
903
911
  navigateTo: ViewId<string> | null | undefined;
904
- notes: string | undefined;
912
+ notes: MarkdownOrString | undefined;
905
913
  labelXY: XYPosition | null;
906
914
  controlPoints: XYPosition[] | undefined | null;
907
915
  };
@@ -951,7 +959,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
951
959
  tail: RelationshipArrowType | undefined;
952
960
  labelBBox: BBox | null | undefined;
953
961
  navigateTo: ViewId<string> | null | undefined;
954
- notes: string | undefined;
962
+ notes: MarkdownOrString | undefined;
955
963
  labelXY: XYPosition | null;
956
964
  controlPoints: XYPosition[] | undefined | null;
957
965
  };
@@ -1008,7 +1016,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
1008
1016
  tail: RelationshipArrowType | undefined;
1009
1017
  labelBBox: BBox | null | undefined;
1010
1018
  navigateTo: ViewId<string> | null | undefined;
1011
- notes: string | undefined;
1019
+ notes: MarkdownOrString | undefined;
1012
1020
  labelXY: XYPosition | null;
1013
1021
  controlPoints: XYPosition[] | undefined | null;
1014
1022
  };
@@ -1058,7 +1066,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
1058
1066
  tail: RelationshipArrowType | undefined;
1059
1067
  labelBBox: BBox | null | undefined;
1060
1068
  navigateTo: ViewId<string> | null | undefined;
1061
- notes: string | undefined;
1069
+ notes: MarkdownOrString | undefined;
1062
1070
  labelXY: XYPosition | null;
1063
1071
  controlPoints: XYPosition[] | undefined | null;
1064
1072
  };
@@ -1355,9 +1363,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
1355
1363
  };
1356
1364
  "trigger:NavigateTo": {
1357
1365
  type: "trigger:NavigateTo";
1358
- params: {
1359
- viewId: ViewId;
1360
- };
1366
+ params: NonReducibleUnknown;
1361
1367
  };
1362
1368
  "trigger:OpenSource": {
1363
1369
  type: "trigger:OpenSource";
@@ -1489,7 +1495,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
1489
1495
  type: "click: selected edge";
1490
1496
  params: unknown;
1491
1497
  };
1492
- }>, never, EventObject>;
1498
+ }>, never, EmittedEvents>;
1493
1499
  readonly on: {
1494
1500
  readonly 'xyflow.nodeClick': readonly [{
1495
1501
  readonly guard: "click: focused node";
@@ -1729,9 +1735,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
1729
1735
  };
1730
1736
  "trigger:NavigateTo": {
1731
1737
  type: "trigger:NavigateTo";
1732
- params: {
1733
- viewId: ViewId;
1734
- };
1738
+ params: NonReducibleUnknown;
1735
1739
  };
1736
1740
  "trigger:OpenSource": {
1737
1741
  type: "trigger:OpenSource";
@@ -1863,7 +1867,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
1863
1867
  type: "click: selected edge";
1864
1868
  params: unknown;
1865
1869
  };
1866
- }>, never, EventObject>;
1870
+ }>, never, EmittedEvents>;
1867
1871
  };
1868
1872
  readonly 'xyflow.edgeClick': {
1869
1873
  readonly actions: readonly [ ActionFunction<Context, {
@@ -1997,9 +2001,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
1997
2001
  };
1998
2002
  "trigger:NavigateTo": {
1999
2003
  type: "trigger:NavigateTo";
2000
- params: {
2001
- viewId: ViewId;
2002
- };
2004
+ params: NonReducibleUnknown;
2003
2005
  };
2004
2006
  "trigger:OpenSource": {
2005
2007
  type: "trigger:OpenSource";
@@ -2131,229 +2133,13 @@ declare const _diagramMachine: StateMachine<Context, Events, {
2131
2133
  type: "click: selected edge";
2132
2134
  params: unknown;
2133
2135
  };
2134
- }>, never, EventObject>;
2136
+ }>, never, EmittedEvents>;
2135
2137
  };
2136
2138
  };
2137
2139
  };
2138
2140
  readonly navigating: {
2139
2141
  readonly id: "navigating";
2140
- readonly entry: readonly ["closeAllOverlays", "closeSearch", "stopSyncLayout", ActionFunction<Context, Events, Events, undefined, Values<{
2141
- syncManualLayoutActorLogic: {
2142
- src: "syncManualLayoutActorLogic";
2143
- logic: SyncLayoutActorLogic;
2144
- id: "syncLayout";
2145
- };
2146
- hotkeyActorLogic: {
2147
- src: "hotkeyActorLogic";
2148
- logic: HotkeyActorLogic;
2149
- id: "hotkey";
2150
- };
2151
- overlaysActorLogic: {
2152
- src: "overlaysActorLogic";
2153
- logic: OverlaysActorLogic;
2154
- id: "overlays";
2155
- };
2156
- searchActorLogic: {
2157
- src: "searchActorLogic";
2158
- logic: SearchActorLogic;
2159
- id: "search";
2160
- };
2161
- }>, Values<{
2162
- onNodeMouseEnter: {
2163
- type: "onNodeMouseEnter";
2164
- params: {
2165
- node: Types.Node;
2166
- };
2167
- };
2168
- onNodeMouseLeave: {
2169
- type: "onNodeMouseLeave";
2170
- params: {
2171
- node: Types.Node;
2172
- };
2173
- };
2174
- onEdgeMouseEnter: {
2175
- type: "onEdgeMouseEnter";
2176
- params: {
2177
- edge: Types.Edge;
2178
- };
2179
- };
2180
- onEdgeMouseLeave: {
2181
- type: "onEdgeMouseLeave";
2182
- params: {
2183
- edge: Types.Edge;
2184
- };
2185
- };
2186
- "trigger:OnChange": {
2187
- type: "trigger:OnChange";
2188
- params: {
2189
- change: ViewChange;
2190
- };
2191
- };
2192
- "layout.align": {
2193
- type: "layout.align";
2194
- params: {
2195
- mode: AlignmentMode;
2196
- };
2197
- };
2198
- "notations.highlight": {
2199
- type: "notations.highlight";
2200
- params: {
2201
- notation: ElementNotation;
2202
- kind?: string;
2203
- };
2204
- };
2205
- "tag.highlight": {
2206
- type: "tag.highlight";
2207
- params: NonReducibleUnknown;
2208
- };
2209
- "xyflow:fitDiagram": {
2210
- type: "xyflow:fitDiagram";
2211
- params: {
2212
- duration?: number;
2213
- bounds?: BBox;
2214
- } | undefined;
2215
- };
2216
- closeAllOverlays: {
2217
- type: "closeAllOverlays";
2218
- params: NonReducibleUnknown;
2219
- };
2220
- "trigger:NavigateTo": {
2221
- type: "trigger:NavigateTo";
2222
- params: {
2223
- viewId: ViewId;
2224
- };
2225
- };
2226
- "trigger:OpenSource": {
2227
- type: "trigger:OpenSource";
2228
- params: OpenSourceParams;
2229
- };
2230
- "assign lastClickedNode": {
2231
- type: "assign lastClickedNode";
2232
- params: NonReducibleUnknown;
2233
- };
2234
- "open source of focused or last clicked node": {
2235
- type: "open source of focused or last clicked node";
2236
- params: NonReducibleUnknown;
2237
- };
2238
- "xyflow:fitFocusedBounds": {
2239
- type: "xyflow:fitFocusedBounds";
2240
- params: unknown;
2241
- };
2242
- "xyflow:setViewportCenter": {
2243
- type: "xyflow:setViewportCenter";
2244
- params: {
2245
- x: number;
2246
- y: number;
2247
- };
2248
- };
2249
- "xyflow:setViewport": {
2250
- type: "xyflow:setViewport";
2251
- params: {
2252
- viewport: Viewport;
2253
- duration?: number;
2254
- };
2255
- };
2256
- "xyflow:alignNodeFromToAfterNavigate": {
2257
- type: "xyflow:alignNodeFromToAfterNavigate";
2258
- params: {
2259
- fromNode: NodeId;
2260
- toPosition: XYPoint;
2261
- };
2262
- };
2263
- "ensure overlays actor state": {
2264
- type: "ensure overlays actor state";
2265
- params: NonReducibleUnknown;
2266
- };
2267
- "ensure search actor state": {
2268
- type: "ensure search actor state";
2269
- params: NonReducibleUnknown;
2270
- };
2271
- updateFeatures: {
2272
- type: "updateFeatures";
2273
- params: NonReducibleUnknown;
2274
- };
2275
- closeSearch: {
2276
- type: "closeSearch";
2277
- params: NonReducibleUnknown;
2278
- };
2279
- startSyncLayout: {
2280
- type: "startSyncLayout";
2281
- params: NonReducibleUnknown;
2282
- };
2283
- stopSyncLayout: {
2284
- type: "stopSyncLayout";
2285
- params: NonReducibleUnknown;
2286
- };
2287
- "focus on nodes and edges": {
2288
- type: "focus on nodes and edges";
2289
- params: NonReducibleUnknown;
2290
- };
2291
- "undim everything": {
2292
- type: "undim everything";
2293
- params: NonReducibleUnknown;
2294
- };
2295
- "update active walkthrough": {
2296
- type: "update active walkthrough";
2297
- params: NonReducibleUnknown;
2298
- };
2299
- }>, Values<{
2300
- isReady: {
2301
- type: "isReady";
2302
- params: unknown;
2303
- };
2304
- "enabled: FitView": {
2305
- type: "enabled: FitView";
2306
- params: unknown;
2307
- };
2308
- "enabled: FocusMode": {
2309
- type: "enabled: FocusMode";
2310
- params: unknown;
2311
- };
2312
- "enabled: Readonly": {
2313
- type: "enabled: Readonly";
2314
- params: unknown;
2315
- };
2316
- "enabled: RelationshipDetails": {
2317
- type: "enabled: RelationshipDetails";
2318
- params: unknown;
2319
- };
2320
- "enabled: Search": {
2321
- type: "enabled: Search";
2322
- params: unknown;
2323
- };
2324
- "not readonly": {
2325
- type: "not readonly";
2326
- params: unknown;
2327
- };
2328
- "is dynamic view": {
2329
- type: "is dynamic view";
2330
- params: unknown;
2331
- };
2332
- "is another view": {
2333
- type: "is another view";
2334
- params: unknown;
2335
- };
2336
- "click: selected node": {
2337
- type: "click: selected node";
2338
- params: unknown;
2339
- };
2340
- "click: same node": {
2341
- type: "click: same node";
2342
- params: unknown;
2343
- };
2344
- "click: focused node": {
2345
- type: "click: focused node";
2346
- params: unknown;
2347
- };
2348
- "click: node has connections": {
2349
- type: "click: node has connections";
2350
- params: unknown;
2351
- };
2352
- "click: selected edge": {
2353
- type: "click: selected edge";
2354
- params: unknown;
2355
- };
2356
- }>, never, EventObject>];
2142
+ readonly entry: readonly ["closeAllOverlays", "closeSearch", "stopSyncLayout", "trigger:NavigateTo"];
2357
2143
  readonly on: {
2358
2144
  readonly 'update.view': {
2359
2145
  readonly actions: ActionFunction<Context, {
@@ -2443,9 +2229,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
2443
2229
  };
2444
2230
  "trigger:NavigateTo": {
2445
2231
  type: "trigger:NavigateTo";
2446
- params: {
2447
- viewId: ViewId;
2448
- };
2232
+ params: NonReducibleUnknown;
2449
2233
  };
2450
2234
  "trigger:OpenSource": {
2451
2235
  type: "trigger:OpenSource";
@@ -2577,7 +2361,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
2577
2361
  type: "click: selected edge";
2578
2362
  params: unknown;
2579
2363
  };
2580
- }>, never, EventObject>;
2364
+ }>, never, EmittedEvents>;
2581
2365
  readonly target: "#idle";
2582
2366
  };
2583
2367
  };
@@ -2841,9 +2625,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
2841
2625
  };
2842
2626
  "trigger:NavigateTo": {
2843
2627
  type: "trigger:NavigateTo";
2844
- params: {
2845
- viewId: ViewId;
2846
- };
2628
+ params: NonReducibleUnknown;
2847
2629
  };
2848
2630
  "trigger:OpenSource": {
2849
2631
  type: "trigger:OpenSource";
@@ -2975,7 +2757,7 @@ declare const _diagramMachine: StateMachine<Context, Events, {
2975
2757
  type: "click: selected edge";
2976
2758
  params: unknown;
2977
2759
  };
2978
- }>, never, EventObject>];
2760
+ }>, never, EmittedEvents>];
2979
2761
  };
2980
2762
  readonly 'update.inputs': {
2981
2763
  readonly actions: ActionFunction<Context, {