@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,5 +1,5 @@
1
1
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
- import { DiagramNode, nameFromFqn } from '@likec4/core';
2
+ import { nameFromFqn } from '@likec4/core';
3
3
  import { cx, css } from '@likec4/styles/css';
4
4
  import { Menu, MenuTarget, MenuDropdown, MenuLabel, MenuDivider, Box, ActionIcon, MenuItem, Stack, Group, Text, TooltipGroup, Space, Tooltip as Tooltip$1 } from '@mantine/core';
5
5
  import { IconInfoCircle, IconArrowRight, IconZoomScan, IconFileSymlink } from '@tabler/icons-react';
@@ -33,13 +33,15 @@ const RelationshipsDropdownMenu = memo(({
33
33
  children
34
34
  }) => {
35
35
  const { diagramEdge, sourceNode, targetNode } = useDiagramContext(
36
- useCallback((ctx) => ({
36
+ (ctx) => ({
37
37
  diagramEdge: findDiagramEdge(ctx, edgeId),
38
38
  sourceNode: findDiagramNode(ctx, source),
39
39
  targetNode: findDiagramNode(ctx, target)
40
- }), [edgeId, source, target])
40
+ }),
41
+ void 0,
42
+ [edgeId, source, target]
41
43
  );
42
- const likec4model = useLikeC4Model(true);
44
+ const likec4model = useLikeC4Model();
43
45
  const diagram = useDiagram();
44
46
  const portalProps = useMantinePortalProps();
45
47
  const onClickOpenOverlay = useCallback((e) => {
@@ -203,7 +205,7 @@ const Relationship = forwardRef(({
203
205
  ] });
204
206
  });
205
207
  function getShortId(r, actualEndpointId, diagramNode) {
206
- const diagramNodeId = r.isDeploymentRelation() ? diagramNode.id : DiagramNode.modelRef(diagramNode) || "";
208
+ const diagramNodeId = r.isDeploymentRelation() ? diagramNode.id : diagramNode.modelRef || "";
207
209
  return nameFromFqn(diagramNodeId) + actualEndpointId.slice(diagramNodeId.length);
208
210
  }
209
211
 
@@ -2,7 +2,8 @@ import { Types } from '../types';
2
2
  import { MemoExoticComponent, FunctionComponent, CSSProperties, ReactNode } from 'react';
3
3
  import { NodeProps } from '../../base';
4
4
  import { Position, XYPosition } from '@xyflow/system';
5
- import { EdgeId, NonEmptyArray, Point, Color, RelationshipLineType, RelationshipArrowType, BBox, ViewId } from '@likec4/core';
5
+ import { EdgeData, Dimmed } from '../../base/types.Base';
6
+ import { EdgeId, NonEmptyArray, Point, Color, RelationshipArrowType, RelationshipLineType, BBox, ViewId } from '@likec4/core';
6
7
  export declare const BuiltinNodes: {
7
8
  element: MemoExoticComponent<(props: NodeProps<Types.ElementNodeData, "element">) => import("react/jsx-runtime").JSX.Element>;
8
9
  deployment: MemoExoticComponent<(props: NodeProps<Types.DeploymentElementNodeData, "deployment">) => import("react/jsx-runtime").JSX.Element>;
@@ -38,21 +39,21 @@ export declare const edgeTypes: {
38
39
  markerEnd?: string;
39
40
  pathOptions?: any;
40
41
  interactionWidth?: number;
41
- data: import("../../base").Base.EdgeData & {
42
+ data: EdgeData & {
42
43
  hovered?: boolean;
43
44
  active?: boolean;
44
- dimmed?: import("../../base").Base.Dimmed;
45
+ dimmed?: Dimmed;
45
46
  id: EdgeId;
46
47
  label: string | null;
47
48
  points: NonEmptyArray<Point>;
48
49
  color: Color | undefined;
50
+ head: RelationshipArrowType | undefined;
49
51
  line: RelationshipLineType | undefined;
50
52
  dir: "forward" | "back" | "both" | undefined;
51
- tail: RelationshipArrowType | undefined;
52
- head: RelationshipArrowType | undefined;
53
53
  technology: string | undefined;
54
+ tail: RelationshipArrowType | undefined;
54
55
  labelBBox: BBox | null | undefined;
55
- navigateTo: ViewId<string> | undefined;
56
+ navigateTo: ViewId<string> | null | undefined;
56
57
  notes: string | undefined;
57
58
  labelXY: XYPosition | null;
58
59
  controlPoints: XYPosition[] | undefined | null;
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { IfNotReadOnly, IfEnabled, useEnabledFeatures } from '../../../context/DiagramFeatures.js';
2
+ import { useEnabledFeatures } from '../../../context/DiagramFeatures.js';
3
3
  import { useDiagram } from '../../../hooks/useDiagram.js';
4
4
  import { CompoundActions } from './CompoundActions.js';
5
5
  import { DeploymentElementActions, ElementActions } from './ElementActions.js';
@@ -12,6 +12,7 @@ import { DefaultHandles } from '../../../base/primitives/NodeHandles.js';
12
12
  import { ElementNodeContainer } from '../../../base/primitives/element/ElementNodeContainer.js';
13
13
  import { ElementShape } from '../../../base/primitives/element/ElementShape.js';
14
14
  import { ElementTitle } from '../../../base/primitives/element/ElementTitle.js';
15
+ import { ElementTags } from '../../../base/primitives/element/ElementTags.js';
15
16
  import { CompoundDetailsButton } from '../../../base/primitives/compound/CompoundDetailsButton.js';
16
17
  import { ElementDetailsButton } from '../../../base/primitives/element/ElementDetailsButton.js';
17
18
 
@@ -47,41 +48,53 @@ function CompoundDetailsButtonWithHandler(props) {
47
48
  }
48
49
  );
49
50
  }
50
- const ElementNode = customNode((props) => /* @__PURE__ */ jsxs(ElementNodeContainer, { nodeProps: props, children: [
51
- /* @__PURE__ */ jsx(ElementShape, { ...props }),
52
- /* @__PURE__ */ jsx(ElementTitle, { ...props }),
53
- /* @__PURE__ */ jsx(ElementActions, { ...props }),
54
- /* @__PURE__ */ jsx(ElementDetailsButtonWithHandler, { ...props }),
55
- /* @__PURE__ */ jsx(IfNotReadOnly, { children: /* @__PURE__ */ jsx(ElementToolbar, { ...props }) }),
56
- /* @__PURE__ */ jsx(DefaultHandles, {})
57
- ] }));
51
+ const ElementNode = customNode((props) => {
52
+ const { enableElementTags, enableReadOnly } = useEnabledFeatures();
53
+ return /* @__PURE__ */ jsxs(ElementNodeContainer, { nodeProps: props, children: [
54
+ /* @__PURE__ */ jsx(ElementShape, { ...props }),
55
+ /* @__PURE__ */ jsx(ElementTitle, { ...props }),
56
+ enableElementTags && /* @__PURE__ */ jsx(ElementTags, { ...props }),
57
+ /* @__PURE__ */ jsx(ElementActions, { ...props }),
58
+ /* @__PURE__ */ jsx(ElementDetailsButtonWithHandler, { ...props }),
59
+ !enableReadOnly && /* @__PURE__ */ jsx(ElementToolbar, { ...props }),
60
+ /* @__PURE__ */ jsx(DefaultHandles, {})
61
+ ] });
62
+ });
58
63
  ElementNode.displayName = "ElementNode";
59
- const DeploymentNode = customNode((props) => /* @__PURE__ */ jsxs(ElementNodeContainer, { nodeProps: props, children: [
60
- /* @__PURE__ */ jsx(ElementShape, { ...props }),
61
- /* @__PURE__ */ jsx(ElementTitle, { ...props }),
62
- /* @__PURE__ */ jsx(DeploymentElementActions, { ...props }),
63
- /* @__PURE__ */ jsx(ElementDetailsButtonWithHandler, { ...props }),
64
- /* @__PURE__ */ jsx(IfNotReadOnly, { children: /* @__PURE__ */ jsx(DeploymentElementToolbar, { ...props }) }),
65
- /* @__PURE__ */ jsx(DefaultHandles, {})
66
- ] }));
64
+ const DeploymentNode = customNode((props) => {
65
+ const { enableElementTags, enableReadOnly } = useEnabledFeatures();
66
+ return /* @__PURE__ */ jsxs(ElementNodeContainer, { nodeProps: props, children: [
67
+ /* @__PURE__ */ jsx(ElementShape, { ...props }),
68
+ /* @__PURE__ */ jsx(ElementTitle, { ...props }),
69
+ enableElementTags && /* @__PURE__ */ jsx(ElementTags, { ...props }),
70
+ /* @__PURE__ */ jsx(DeploymentElementActions, { ...props }),
71
+ /* @__PURE__ */ jsx(ElementDetailsButtonWithHandler, { ...props }),
72
+ !enableReadOnly && /* @__PURE__ */ jsx(DeploymentElementToolbar, { ...props }),
73
+ /* @__PURE__ */ jsx(DefaultHandles, {})
74
+ ] });
75
+ });
67
76
  DeploymentNode.displayName = "DeploymentNode";
68
77
  const CompoundElementNode = customNode((props) => {
69
- useDiagram();
78
+ const { enableElementDetails, enableReadOnly } = useEnabledFeatures();
70
79
  return /* @__PURE__ */ jsxs(CompoundNodeContainer, { nodeProps: props, children: [
71
80
  /* @__PURE__ */ jsx(CompoundTitle, { ...props }),
72
81
  /* @__PURE__ */ jsx(CompoundActions, { ...props }),
73
- /* @__PURE__ */ jsx(IfEnabled, { feature: "ElementDetails", children: /* @__PURE__ */ jsx(CompoundDetailsButtonWithHandler, { ...props }) }),
74
- /* @__PURE__ */ jsx(IfNotReadOnly, { children: /* @__PURE__ */ jsx(CompoundElementToolbar, { ...props }) }),
82
+ enableElementDetails && /* @__PURE__ */ jsx(CompoundDetailsButtonWithHandler, { ...props }),
83
+ !enableReadOnly && /* @__PURE__ */ jsx(CompoundElementToolbar, { ...props }),
75
84
  /* @__PURE__ */ jsx(DefaultHandles, {})
76
85
  ] });
77
86
  });
78
87
  CompoundElementNode.displayName = "CompoundElementNode";
79
- const CompoundDeploymentNode = customNode((props) => /* @__PURE__ */ jsxs(CompoundNodeContainer, { nodeProps: props, children: [
80
- /* @__PURE__ */ jsx(CompoundTitle, { ...props }),
81
- /* @__PURE__ */ jsx(CompoundActions, { ...props }),
82
- /* @__PURE__ */ jsx(IfNotReadOnly, { children: /* @__PURE__ */ jsx(CompoundDeploymentToolbar, { ...props }) }),
83
- /* @__PURE__ */ jsx(DefaultHandles, {})
84
- ] }));
88
+ const CompoundDeploymentNode = customNode((props) => {
89
+ const { enableElementDetails, enableReadOnly } = useEnabledFeatures();
90
+ return /* @__PURE__ */ jsxs(CompoundNodeContainer, { nodeProps: props, children: [
91
+ /* @__PURE__ */ jsx(CompoundTitle, { ...props }),
92
+ /* @__PURE__ */ jsx(CompoundActions, { ...props }),
93
+ enableElementDetails && /* @__PURE__ */ jsx(CompoundDetailsButtonWithHandler, { ...props }),
94
+ !enableReadOnly && /* @__PURE__ */ jsx(CompoundDeploymentToolbar, { ...props }),
95
+ /* @__PURE__ */ jsx(DefaultHandles, {})
96
+ ] });
97
+ });
85
98
  CompoundDeploymentNode.displayName = "CompoundDeploymentNode";
86
99
  const ViewGroupNode = customNode((props) => /* @__PURE__ */ jsxs(CompoundNodeContainer, { nodeProps: props, children: [
87
100
  /* @__PURE__ */ jsx(CompoundTitle, { ...props }),
@@ -1,4 +1,4 @@
1
- import { Fqn, ThemeColor, ViewChange } from '@likec4/core';
1
+ import { DeploymentFqn, Fqn, ThemeColor, ViewChange, ColorLiteral } from '@likec4/core';
2
2
  import { MergeExclusive } from 'type-fest';
3
3
  import { NodeProps } from '../../../../base';
4
4
  import { Types } from '../../../types';
@@ -7,17 +7,17 @@ import { TooltipProps } from '@mantine/core';
7
7
  export type OnStyleChange = (style: ViewChange.ChangeElementStyle['style']) => void;
8
8
  export declare const themedColors: ({
9
9
  key: "primary";
10
- value: `#${string}`;
10
+ value: ColorLiteral;
11
11
  } | {
12
12
  key: "secondary";
13
- value: `#${string}`;
13
+ value: ColorLiteral;
14
14
  } | {
15
15
  key: "muted";
16
- value: `#${string}`;
16
+ value: ColorLiteral;
17
17
  })[];
18
18
  export declare const colors: {
19
19
  key: "blue" | "gray" | "green" | "indigo" | "red" | "amber" | "slate" | "sky";
20
- value: `#${string}`;
20
+ value: ColorLiteral;
21
21
  }[];
22
22
  export type ThemeColorKey = typeof themedColors[0]['key'];
23
23
  export type ColorKey = typeof colors[0]['key'];
@@ -25,7 +25,7 @@ export declare const Tooltip: ForwardRefExoticComponent< TooltipProps & RefAttri
25
25
  component?: any;
26
26
  renderRoot?: (props: Record<string, any>) => React.ReactNode;
27
27
  }>;
28
- export declare function useHandlers(target: Fqn, props: NodeProps<Types.NodeData>): {
28
+ export declare function useHandlers(target: Fqn | DeploymentFqn, props: NodeProps<Types.NodeData>): {
29
29
  elementColor: "blue" | "gray" | "green" | "indigo" | "red" | "amber" | "slate" | "muted" | "primary" | "secondary" | "sky";
30
30
  onColorPreview: (color: ThemeColor | null) => void;
31
31
  onChange: OnStyleChange;
@@ -36,5 +36,5 @@ export declare function BrowseRelationshipsButton({ fqn }: {
36
36
  export declare function GoToSourceButton(props: MergeExclusive<{
37
37
  elementId: Fqn;
38
38
  }, {
39
- deploymentId: Fqn;
39
+ deploymentId: DeploymentFqn;
40
40
  }>): import("react/jsx-runtime").JSX.Element | null;
@@ -1,4 +1,4 @@
1
- import { DiagramEdge, DiagramNode, Fqn, IconUrl, ViewId } from '@likec4/core';
1
+ import { DeploymentFqn, DiagramEdge, DiagramNode, Fqn, IconUrl, ViewId } from '@likec4/core/types';
2
2
  import { XYPosition } from '@xyflow/system';
3
3
  import { OptionalKeysOf, Simplify } from 'type-fest';
4
4
  import { Base, ReactFlowEdge, ReactFlowNode } from '../base/types';
@@ -8,7 +8,7 @@ type NonOptional<T extends object> = Simplify<{
8
8
  [P in OptionalKeysOf<T>]-?: T[P] | undefined;
9
9
  }>;
10
10
  export declare namespace Types {
11
- type LeafNodeData = Base.NodeData & NonOptional<Pick<DiagramNode, 'id' | 'title' | 'technology' | 'description' | 'color' | 'shape' | 'width' | 'level' | 'height' | 'style' | 'position'>> & {
11
+ type LeafNodeData = Base.NodeData & NonOptional<Pick<DiagramNode, 'id' | 'title' | 'technology' | 'description' | 'color' | 'shape' | 'width' | 'level' | 'height' | 'style' | 'tags' | 'position'>> & {
12
12
  /**
13
13
  * View this node belongs to
14
14
  */
@@ -32,10 +32,10 @@ export declare namespace Types {
32
32
  */
33
33
  type DeploymentElementNodeData = LeafNodeData & {
34
34
  navigateTo: ViewId | null;
35
- deploymentFqn: Fqn;
35
+ deploymentFqn: DeploymentFqn;
36
36
  modelFqn: Fqn | null;
37
37
  };
38
- type CompoundNodeData = Base.NodeData & NonOptional<Pick<DiagramNode, 'id' | 'title' | 'color' | 'shape' | 'style' | 'position'>> & {
38
+ type CompoundNodeData = Base.NodeData & NonOptional<Pick<DiagramNode, 'id' | 'title' | 'color' | 'shape' | 'style' | 'tags' | 'position'>> & {
39
39
  /**
40
40
  * View this node belongs to
41
41
  */
@@ -52,7 +52,7 @@ export declare namespace Types {
52
52
  navigateTo: ViewId | null;
53
53
  };
54
54
  type CompoundDeploymentNodeData = CompoundNodeData & {
55
- deploymentFqn: Fqn;
55
+ deploymentFqn: DeploymentFqn;
56
56
  /**
57
57
  * If set - this node refers to a model element
58
58
  */
@@ -4,9 +4,9 @@ import { ActionIconGroup, Group, Stack, Box, Badge, Loader } from '@mantine/core
4
4
  import { IconFileSymlink, IconFocusCentered, IconMenu2 } from '@tabler/icons-react';
5
5
  import { m, LayoutGroup } from 'motion/react';
6
6
  import { memo } from 'react';
7
+ import { SearchControl } from '../../../components/SearchControl.js';
7
8
  import { useControlsCustomLayout } from '../../../context/ControlsCustomLayout.js';
8
9
  import { useDiagramContext, useDiagram, useDiagramSyncLayoutState } from '../../../hooks/useDiagram.js';
9
- import { LikeC4Search } from '../search/LikeC4Search.js';
10
10
  import { Tooltip, ActionIcon } from './_shared.js';
11
11
  import { ChangeAutoLayoutButton } from './ChangeAutoLayoutButton.js';
12
12
  import { LayoutDriftNotification } from './LayoutDriftNotification.js';
@@ -71,8 +71,7 @@ const ControlsDefaultLayout = ({
71
71
  }
72
72
  );
73
73
  const Controls = memo(() => {
74
- const { viewId, hasLayoutDrift, viewportChanged, isNotActiveWalkthrough } = useDiagramContext((c) => ({
75
- viewId: c.view.id,
74
+ const { hasLayoutDrift, viewportChanged, isNotActiveWalkthrough } = useDiagramContext((c) => ({
76
75
  hasLayoutDrift: c.view.hasLayoutDrift ?? false,
77
76
  viewportChanged: c.viewportChangedManually,
78
77
  isNotActiveWalkthrough: c.activeWalkthrough === null
@@ -106,7 +105,15 @@ const Controls = memo(() => {
106
105
  }
107
106
  ),
108
107
  navigationButtons: enableNavigationButtons && /* @__PURE__ */ jsx(NavigationButtons, {}),
109
- search: enableSearch && /* @__PURE__ */ jsx(LikeC4Search, {}),
108
+ search: enableSearch && /* @__PURE__ */ jsx(
109
+ SearchControl,
110
+ {
111
+ onClick: (e) => {
112
+ e.stopPropagation();
113
+ diagram.openSearch();
114
+ }
115
+ }
116
+ ),
110
117
  syncInProgressBadge: /* @__PURE__ */ jsx(SyncLayoutBadge, {}),
111
118
  actionsGroup: /* @__PURE__ */ jsxs(ActionIconGroup, { className: actionIconGroup, orientation: "vertical", children: [
112
119
  enableVscode && /* @__PURE__ */ jsx(Tooltip, { label: "Open source", ...portalProps, children: /* @__PURE__ */ jsx(
@@ -114,6 +121,7 @@ const Controls = memo(() => {
114
121
  {
115
122
  onClick: (e) => {
116
123
  e.stopPropagation();
124
+ const viewId = diagram.currentView.id;
117
125
  onOpenSource?.({ view: viewId });
118
126
  },
119
127
  children: /* @__PURE__ */ jsx(IconFileSymlink, { stroke: 1.5 })
@@ -113,7 +113,7 @@ const ElementNotation = ({ value }) => {
113
113
  };
114
114
  const selector = (s) => ({
115
115
  id: s.view.id,
116
- notations: s.view.notation?.elements ?? [],
116
+ notations: s.view.notation?.nodes ?? [],
117
117
  isVisible: true
118
118
  // isVisible: isNullish(s.focusedNodeId ?? s.activeWalkthrough),
119
119
  });
@@ -1,10 +1,12 @@
1
1
  import { DiagramView, WhereOperator } from '@likec4/core';
2
2
  import { Types } from './types';
3
- export declare function useViewToNodesEdges({ view: { id, nodes, edges, __, }, ...opts }: {
3
+ type ViewToNodesEdgeInput = {
4
4
  view: DiagramView;
5
- where: WhereOperator<string, string> | undefined;
5
+ where: WhereOperator | null;
6
6
  nodesSelectable: boolean;
7
- }): {
7
+ };
8
+ export declare function useViewToNodesEdges(params: ViewToNodesEdgeInput): {
8
9
  xynodes: Types.Node[];
9
10
  xyedges: Types.Edge[];
10
11
  };
12
+ export {};
@@ -1,5 +1,6 @@
1
- import { Queue, whereOperatorAsPredicate, nonNullable, ElementKind, DiagramNode, invariant } from '@likec4/core';
2
- import { useDeepCompareMemo } from '@react-hookz/web';
1
+ import { Queue, whereOperatorAsPredicate, nonNullable, GroupElementKind, invariant } from '@likec4/core';
2
+ import { useCustomCompareMemo } from '@react-hookz/web';
3
+ import { shallowEqual, deepEqual } from 'fast-equals';
3
4
  import { pick, hasAtLeast } from 'remeda';
4
5
  import { ZIndexes } from '../base/const.js';
5
6
 
@@ -8,7 +9,7 @@ function viewToNodesEdge(opts) {
8
9
  view,
9
10
  nodesSelectable: selectable
10
11
  } = opts;
11
- view.__ === "dynamic"; const xynodes = [], xyedges = [], nodeLookup = /* @__PURE__ */ new Map();
12
+ view._type === "dynamic"; const xynodes = [], xyedges = [], nodeLookup = /* @__PURE__ */ new Map();
12
13
  const queue = Queue.from(view.nodes.reduce(
13
14
  (acc, node) => {
14
15
  nodeLookup.set(node.id, node);
@@ -37,7 +38,7 @@ function viewToNodesEdge(opts) {
37
38
  let next;
38
39
  while (next = queue.dequeue()) {
39
40
  const { node, parent } = next;
40
- const isCompound = hasAtLeast(node.children, 1) || node.kind == ElementKind.Group;
41
+ const isCompound = hasAtLeast(node.children, 1) || node.kind == GroupElementKind;
41
42
  if (isCompound) {
42
43
  for (const child of node.children) {
43
44
  queue.enqueue({ node: nodeById(child), parent: node });
@@ -54,8 +55,8 @@ function viewToNodesEdge(opts) {
54
55
  const id = ns + node.id;
55
56
  const base = {
56
57
  id,
57
- selectable: selectable && node.kind !== ElementKind.Group,
58
- focusable: selectable && node.kind !== ElementKind.Group,
58
+ selectable: selectable && node.kind !== GroupElementKind,
59
+ focusable: selectable && node.kind !== GroupElementKind,
59
60
  deletable: false,
60
61
  position,
61
62
  zIndex: isCompound ? ZIndexes.Compound : ZIndexes.Element,
@@ -65,7 +66,7 @@ function viewToNodesEdge(opts) {
65
66
  },
66
67
  initialWidth: node.width,
67
68
  initialHeight: node.height,
68
- hidden: node.kind !== ElementKind.Group && !visiblePredicate(node),
69
+ hidden: node.kind !== GroupElementKind && !visiblePredicate(node),
69
70
  ...parent && {
70
71
  parentId: ns + parent.id
71
72
  }
@@ -79,6 +80,7 @@ function viewToNodesEdge(opts) {
79
80
  style: node.style,
80
81
  depth: node.depth ?? 0,
81
82
  icon: node.icon ?? "none",
83
+ tags: node.tags ?? null,
82
84
  position: node.position
83
85
  };
84
86
  const leafNodeData = {
@@ -94,10 +96,11 @@ function viewToNodesEdge(opts) {
94
96
  shape: node.shape,
95
97
  style: node.style,
96
98
  icon: node.icon ?? null,
99
+ tags: node.tags,
97
100
  position: node.position,
98
101
  isMultiple: node.style?.multiple ?? false
99
102
  };
100
- if (node.kind === ElementKind.Group) {
103
+ if (node.kind === GroupElementKind) {
101
104
  xynodes.push({
102
105
  ...base,
103
106
  type: "view-group",
@@ -109,8 +112,8 @@ function viewToNodesEdge(opts) {
109
112
  });
110
113
  continue;
111
114
  }
112
- const modelFqn = DiagramNode.modelRef(node);
113
- const deploymentFqn = DiagramNode.deploymentRef(node);
115
+ const modelFqn = node.modelRef ?? null;
116
+ const deploymentFqn = node.deploymentRef ?? null;
114
117
  if (!modelFqn && !deploymentFqn) {
115
118
  console.error("Invalid node", node);
116
119
  throw new Error("Element should have either modelRef or deploymentRef");
@@ -221,26 +224,13 @@ function viewToNodesEdge(opts) {
221
224
  xyedges
222
225
  };
223
226
  }
224
- function useViewToNodesEdges({
225
- view: {
226
- id,
227
- nodes,
228
- edges,
229
- __ = "element"
230
- },
231
- ...opts
232
- }) {
233
- return useDeepCompareMemo(() => {
234
- return viewToNodesEdge({
235
- view: {
236
- id,
237
- nodes,
238
- edges,
239
- __
240
- },
241
- ...opts
242
- });
243
- }, [id, __, nodes, edges, opts]);
227
+ const viewToNodesEdgeEqual = (a, b) => a.view.id === b.view.id && a.view._type === b.view._type && a.nodesSelectable === b.nodesSelectable && shallowEqual(a.view.nodes, b.view.nodes) && shallowEqual(a.view.edges, b.view.edges) && deepEqual(a.where, b.where);
228
+ function useViewToNodesEdges(params) {
229
+ return useCustomCompareMemo(
230
+ () => viewToNodesEdge(params),
231
+ [params],
232
+ ([a], [b]) => !!a && !!b && viewToNodesEdgeEqual(a, b)
233
+ );
244
234
  }
245
235
 
246
236
  export { useViewToNodesEdges };
@@ -1,3 +1,3 @@
1
- import { AnyAux, LikeC4Model } from '@likec4/core/model';
1
+ import { LikeC4Model } from '@likec4/core/model';
2
2
  import { Context } from 'react';
3
- export declare const LikeC4ModelContext: Context<LikeC4Model<AnyAux> | null>;
3
+ export declare const LikeC4ModelContext: Context<LikeC4Model<any> | null>;
@@ -1,2 +1,2 @@
1
1
  export { useLikeC4ElementsTree, } from './useLikeC4ElementsTree';
2
- export { useLikeC4Model, } from './useLikeC4Model';
2
+ export { useLikeC4Model, useLikeC4Specification, useLikeC4ViewModel, } from './useLikeC4Model';
@@ -11,7 +11,7 @@ function buildNode(element) {
11
11
  };
12
12
  }
13
13
  function useLikeC4ElementsTree(viewId) {
14
- const model = useLikeC4Model(true);
14
+ const model = useLikeC4Model();
15
15
  return useMemo(() => {
16
16
  if (viewId) {
17
17
  const view = model.view(viewId);
@@ -1,10 +1,23 @@
1
- import { LikeC4Model } from '@likec4/core/model';
2
- export declare function useLikeC4Model(): LikeC4Model | null;
3
- export declare function useLikeC4Model(strict: true): LikeC4Model;
4
- export declare function useLikeC4Model(strict: boolean): LikeC4Model | null;
5
- export declare function useLikeC4Model(strict: true, type: 'layouted'): LikeC4Model.Layouted;
6
- export declare function useLikeC4Model(strict: true, type: 'computed'): LikeC4Model.Computed;
7
- export declare function useLikeC4Model(strict: true, type: 'layouted' | 'computed' | undefined): LikeC4Model;
8
- export declare function useLikeC4Model(strict: boolean, type: 'layouted'): LikeC4Model.Layouted | null;
9
- export declare function useLikeC4Model(strict: boolean, type: 'computed'): LikeC4Model.Computed | null;
10
- export declare function useLikeC4Model(strict: boolean, type: 'layouted' | 'computed' | undefined): LikeC4Model | null;
1
+ import { aux, LikeC4Model, LikeC4ViewModel } from '@likec4/core/model';
2
+ import { TagSpecification, ElementSpecification, RelationshipSpecification, CustomColorDefinitions } from '@likec4/core';
3
+ export declare function useLikeC4Model<A extends aux.Any = aux.Unknown>(): LikeC4Model<A>;
4
+ export declare function useLikeC4Model<A extends aux.Any = aux.Unknown>(type: 'layouted'): LikeC4Model.Layouted<A>;
5
+ export declare function useLikeC4Model<A extends aux.Any = aux.Unknown>(type: 'computed'): LikeC4Model.Computed<A>;
6
+ export declare function useLikeC4Model<A extends aux.Any = aux.Unknown>(type: 'layouted' | 'computed' | undefined): LikeC4Model<A>;
7
+ export declare function useLikeC4ViewModel<A extends aux.Any = aux.Unknown>(viewId: aux.LooseViewId<A>): LikeC4ViewModel<aux.toLayouted<A>> | null;
8
+ export declare function useLikeC4Specification(): {
9
+ tags: {
10
+ [x: string]: TagSpecification;
11
+ };
12
+ elements: {
13
+ [x: string]: Partial< ElementSpecification>;
14
+ };
15
+ deployments: {
16
+ [x: string]: Partial< ElementSpecification>;
17
+ };
18
+ relationships: {
19
+ [x: string]: Partial< RelationshipSpecification>;
20
+ };
21
+ metadataKeys?: string[];
22
+ customColors?: CustomColorDefinitions;
23
+ };
@@ -1,16 +1,31 @@
1
1
  import { useContext } from 'react';
2
- import { isString, isNonNullish, isDefined } from 'remeda';
2
+ import { isString } from 'remeda';
3
3
  import { LikeC4ModelContext } from './LikeC4ModelContext.js';
4
4
 
5
- function useLikeC4Model(strict, type) {
5
+ function useLikeC4Model(type) {
6
6
  const model = useContext(LikeC4ModelContext);
7
- if (isString(type) && isNonNullish(model) && model.type !== type) {
8
- throw new Error(`Invalid LikeC4ModelContext, expected "${type}" but got "${model.type}" in context`);
7
+ if (!model) {
8
+ throw new Error("LikeC4Model not found. Make sure you have LikeC4ModelProvider.");
9
9
  }
10
- if (isDefined(strict) && strict === true && !model) {
11
- throw new Error("No LikeC4Model found in context");
10
+ if (isString(type) && model.stage !== type) {
11
+ throw new Error(`Invalid LikeC4ModelContext, expected "${type}" but got "${model.stage}" in context`);
12
12
  }
13
13
  return model;
14
14
  }
15
+ function useLikeC4ViewModel(viewId) {
16
+ const model = useLikeC4Model("layouted");
17
+ const view = model.findView(viewId);
18
+ if (!view) {
19
+ return null;
20
+ }
21
+ if (!view.isDiagram()) {
22
+ throw new Error(`View "${viewId}" is not layouted`);
23
+ }
24
+ return view;
25
+ }
26
+ function useLikeC4Specification() {
27
+ const model = useLikeC4Model();
28
+ return model.$data.specification;
29
+ }
15
30
 
16
- export { useLikeC4Model };
31
+ export { useLikeC4Model, useLikeC4Specification, useLikeC4ViewModel };
@@ -1,13 +1,12 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
1
+ import { jsx } from 'react/jsx-runtime';
2
2
  import { nonexhaustive } from '@likec4/core';
3
- import { Box, Notification, ScrollAreaAutosize, Code, Group, Button } from '@mantine/core';
4
- import { IconX } from '@tabler/icons-react';
5
3
  import { useSelector } from '@xstate/react';
6
4
  import { animate } from 'motion';
7
5
  import { useReducedMotionConfig, LayoutGroup, AnimatePresence } from 'motion/react';
8
6
  import { useMemo, useEffect } from 'react';
9
7
  import { ErrorBoundary } from 'react-error-boundary';
10
8
  import { isNonNullish } from 'remeda';
9
+ import { ErrorFallback } from '../components/ErrorFallback.js';
11
10
  import { ElementDetails } from './element-details/ElementDetails.js';
12
11
  import { Overlay } from './overlay/Overlay.js';
13
12
  import { RelationshipDetails } from './relationship-details/RelationshipDetails.js';
@@ -15,28 +14,6 @@ import { RelationshipsBrowser } from './relationships-browser/RelationshipsBrows
15
14
  import { useXYStore } from '../hooks/useXYFlow.js';
16
15
  import { DiagramFeatures } from '../context/DiagramFeatures.js';
17
16
 
18
- function Fallback({ error, resetErrorBoundary }) {
19
- const errorString = error instanceof Error ? error.message : "Unknown error";
20
- return /* @__PURE__ */ jsx(Box, { pos: "fixed", top: 0, left: 0, w: "100%", p: 0, style: { zIndex: 1e3 }, children: /* @__PURE__ */ jsxs(
21
- Notification,
22
- {
23
- icon: /* @__PURE__ */ jsx(IconX, { style: { width: 16, height: 16 } }),
24
- styles: {
25
- icon: {
26
- alignSelf: "flex-start"
27
- }
28
- },
29
- color: "red",
30
- title: "Oops, something went wrong",
31
- p: "xl",
32
- withCloseButton: false,
33
- children: [
34
- /* @__PURE__ */ jsx(ScrollAreaAutosize, { maw: "100%", mah: 400, children: /* @__PURE__ */ jsx(Code, { block: true, children: errorString }) }),
35
- /* @__PURE__ */ jsx(Group, { gap: "xs", mt: "xl", children: /* @__PURE__ */ jsx(Button, { color: "gray", size: "xs", variant: "light", onClick: () => resetErrorBoundary(), children: "Reset" }) })
36
- ]
37
- }
38
- ) });
39
- }
40
17
  const selectOverlays = (s) => {
41
18
  return s.context.overlays.map((overlay) => {
42
19
  switch (overlay.type) {
@@ -72,7 +49,7 @@ function Overlays({ overlaysActorRef }) {
72
49
  ]);
73
50
  const overlays = useSelector(overlaysActorRef, selectOverlays, compareSelectOverlays);
74
51
  const isMotionReduced = useReducedMotionConfig() ?? false;
75
- const isActiveOverlay = overlays.length > 0;
52
+ const isActiveOverlay = overlays.some((overlay) => overlay.type === "elementDetails");
76
53
  useEffect(() => {
77
54
  if (!xyflowRendererDom || isMotionReduced) return;
78
55
  animate(xyflowRendererDom, {
@@ -121,7 +98,7 @@ function Overlays({ overlaysActorRef }) {
121
98
  nonexhaustive(overlay);
122
99
  }
123
100
  });
124
- return /* @__PURE__ */ jsx(DiagramFeatures.Overlays, { children: /* @__PURE__ */ jsx(ErrorBoundary, { FallbackComponent: Fallback, onReset: () => overlaysActorRef.send({ type: "close.all" }), children: /* @__PURE__ */ jsx(LayoutGroup, { children: /* @__PURE__ */ jsx(AnimatePresence, { children: overlaysReact }) }) }) });
101
+ return /* @__PURE__ */ jsx(DiagramFeatures.Overlays, { children: /* @__PURE__ */ jsx(ErrorBoundary, { FallbackComponent: ErrorFallback, onReset: () => overlaysActorRef.send({ type: "close.all" }), children: /* @__PURE__ */ jsx(LayoutGroup, { children: /* @__PURE__ */ jsx(AnimatePresence, { children: overlaysReact }) }) }) });
125
102
  }
126
103
 
127
104
  export { Overlays };
@@ -1,4 +1,4 @@
1
- import { Fqn, NodeId, ViewId } from '@likec4/core';
1
+ import { Fqn, NodeId, ViewId } from '@likec4/core/types';
2
2
  import { Rect } from '@xyflow/system';
3
3
  type ElementDetailsCardProps = {
4
4
  viewId: ViewId;