@likec4/diagram 1.27.1 → 1.27.3

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 (123) hide show
  1. package/bundle/index.js +2152 -6757
  2. package/dist/LikeC4Diagram.js +1 -1
  3. package/dist/LikeC4Diagram.props.d.ts +5 -3
  4. package/dist/StaticLikeC4Diagram.js +1 -1
  5. package/dist/_virtual/set.js +5 -0
  6. package/dist/_virtual/set2.js +3 -0
  7. package/dist/base/BaseXYFlow.d.ts +2 -1
  8. package/dist/base/primitives/compound/CompoundNodeContainer.d.ts +1 -1
  9. package/dist/base/primitives/compound/CompoundNodeContainer.js +0 -1
  10. package/dist/base/primitives/edge/EdgeLabelContainer.js +3 -2
  11. package/dist/base/primitives/element/ElementActionButtons.js +8 -11
  12. package/dist/base/primitives/element/ElementNodeContainer.css.js +4 -4
  13. package/dist/base/updateEdges.js +1 -9
  14. package/dist/base/updateNodes.js +1 -12
  15. package/dist/bundle/LikeC4View.js +2 -2
  16. package/dist/bundle/LikeC4View.props.d.ts +7 -7
  17. package/dist/hooks/useCurrentViewId.js +8 -2
  18. package/dist/hooks/useDiagram.d.ts +1522 -685
  19. package/dist/hooks/useDiagram.js +21 -24
  20. package/dist/likec4diagram/DiagramXYFlow.js +6 -6
  21. package/dist/likec4diagram/ui/notation/NotationPanel.css.js +3 -3
  22. package/dist/likec4diagram/ui/notation/NotationPanel.js +10 -4
  23. package/dist/node_modules/.pnpm/mnemonist@0.40.3_patch_hash_5c12abb43fcff6fd81e53021b89075d53249640d165a2556cc1e58d71201a13a/node_modules/mnemonist/set.js +369 -0
  24. package/dist/overlays/Overlays.js +3 -1
  25. package/dist/overlays/element-details/actor.d.ts +2769 -173
  26. package/dist/overlays/overlay/Overlay.css.d.ts +26 -2
  27. package/dist/overlays/overlay/Overlay.css.js +66 -18
  28. package/dist/overlays/overlay/Overlay.d.ts +7 -6
  29. package/dist/overlays/overlay/Overlay.js +12 -10
  30. package/dist/overlays/overlaysActor.js +2 -2
  31. package/dist/overlays/relationship-details/RelationshipDetails.js +113 -70
  32. package/dist/overlays/relationship-details/SelectEdge.d.ts +1 -1
  33. package/dist/overlays/relationship-details/SelectEdge.js +15 -9
  34. package/dist/overlays/relationship-details/_types.d.ts +4 -1
  35. package/dist/overlays/relationship-details/actor.d.ts +425 -128
  36. package/dist/overlays/relationship-details/actor.js +157 -53
  37. package/dist/overlays/relationship-details/compute.d.ts +12 -0
  38. package/dist/overlays/relationship-details/compute.js +139 -0
  39. package/dist/overlays/relationship-details/custom/ElementActions.js +27 -5
  40. package/dist/overlays/relationship-details/custom/edgeTypes.js +1 -1
  41. package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +2 -1
  42. package/dist/overlays/relationship-details/hooks.d.ts +336 -6
  43. package/dist/overlays/relationship-details/hooks.js +11 -12
  44. package/dist/overlays/relationship-details/layout-to-xyflow.d.ts +12 -0
  45. package/dist/overlays/relationship-details/layout-to-xyflow.js +145 -0
  46. package/dist/overlays/relationship-details/layout.d.ts +22 -0
  47. package/dist/overlays/relationship-details/layout.js +314 -0
  48. package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +3 -1
  49. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +2 -2
  50. package/dist/overlays/relationships-browser/_types.d.ts +2 -0
  51. package/dist/overlays/relationships-browser/actor.d.ts +130 -14
  52. package/dist/overlays/relationships-browser/actor.js +30 -16
  53. package/dist/overlays/relationships-browser/custom/ElementActions.js +5 -3
  54. package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +3 -1
  55. package/dist/overlays/relationships-browser/custom/edgeTypes.js +1 -1
  56. package/dist/overlays/relationships-browser/hooks.d.ts +3 -1
  57. package/dist/overlays/relationships-browser/hooks.js +6 -9
  58. package/dist/overlays/relationships-browser/{-useRelationshipsView.d.ts → layout.d.ts} +3 -1
  59. package/dist/overlays/relationships-browser/{-useRelationshipsView.js → layout.js} +21 -8
  60. package/dist/overlays/relationships-browser/useViewToNodesEdges.d.ts +1 -1
  61. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +3 -1
  62. package/dist/packages/core/src/compute-view/relationships-view/compute.js +1 -1
  63. package/dist/packages/core/src/model/connection/model/ConnectionModel.js +121 -0
  64. package/dist/packages/core/src/model/connection/model/find.js +39 -0
  65. package/dist/packages/core/src/model/connection/ops.js +7 -0
  66. package/dist/packages/core/src/utils/const.js +3 -0
  67. package/dist/packages/core/src/utils/fqn.js +9 -1
  68. package/dist/packages/core/src/utils/iterable/find.js +21 -0
  69. package/dist/packages/core/src/utils/iterable/some.js +21 -0
  70. package/dist/packages/core/src/utils/set.js +48 -0
  71. package/dist/packages/core/src/utils/string-hash.js +13 -0
  72. package/dist/state/diagram-machine.d.ts +1552 -703
  73. package/dist/state/diagram-machine.js +39 -3
  74. package/dist/state/syncManualLayoutActor.d.ts +1 -1
  75. package/dist/styles.css.js +1 -1
  76. package/dist/utils/index.d.ts +0 -1
  77. package/package.json +11 -11
  78. package/src/LikeC4Diagram.props.ts +7 -3
  79. package/src/LikeC4Diagram.tsx +1 -1
  80. package/src/StaticLikeC4Diagram.tsx +1 -1
  81. package/src/base/BaseXYFlow.tsx +2 -1
  82. package/src/base/primitives/compound/CompoundNodeContainer.tsx +0 -2
  83. package/src/base/primitives/edge/EdgeLabelContainer.tsx +7 -5
  84. package/src/base/primitives/element/ElementActionButtons.tsx +10 -11
  85. package/src/base/primitives/element/ElementNodeContainer.css.ts +4 -4
  86. package/src/base/updateEdges.ts +8 -8
  87. package/src/base/updateNodes.ts +11 -11
  88. package/src/bundle/LikeC4View.props.ts +7 -7
  89. package/src/bundle/LikeC4View.tsx +2 -2
  90. package/src/hooks/useCurrentViewId.ts +4 -2
  91. package/src/hooks/useDiagram.ts +22 -24
  92. package/src/likec4diagram/DiagramXYFlow.tsx +6 -6
  93. package/src/likec4diagram/ui/notation/NotationPanel.css.ts +2 -2
  94. package/src/likec4diagram/ui/notation/NotationPanel.tsx +8 -6
  95. package/src/overlays/Overlays.tsx +4 -2
  96. package/src/overlays/overlay/Overlay.css.ts +67 -17
  97. package/src/overlays/overlay/Overlay.tsx +27 -24
  98. package/src/overlays/overlaysActor.ts +1 -1
  99. package/src/overlays/relationship-details/RelationshipDetails.tsx +131 -68
  100. package/src/overlays/relationship-details/SelectEdge.tsx +19 -12
  101. package/src/overlays/relationship-details/_types.ts +3 -1
  102. package/src/overlays/relationship-details/actor.ts +212 -68
  103. package/src/overlays/relationship-details/compute.ts +186 -0
  104. package/src/overlays/relationship-details/custom/ElementActions.tsx +27 -18
  105. package/src/overlays/relationship-details/custom/edgeTypes.tsx +1 -1
  106. package/src/overlays/relationship-details/hooks.ts +12 -13
  107. package/src/overlays/relationship-details/layout-to-xyflow.ts +172 -0
  108. package/src/overlays/relationship-details/layout.ts +470 -0
  109. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +2 -2
  110. package/src/overlays/relationships-browser/_types.ts +2 -0
  111. package/src/overlays/relationships-browser/actor.ts +39 -14
  112. package/src/overlays/relationships-browser/custom/ElementActions.tsx +5 -3
  113. package/src/overlays/relationships-browser/custom/edgeTypes.tsx +1 -1
  114. package/src/overlays/relationships-browser/hooks.ts +7 -10
  115. package/src/overlays/relationships-browser/{-useRelationshipsView.ts → layout.ts} +26 -33
  116. package/src/overlays/relationships-browser/useViewToNodesEdges.ts +3 -1
  117. package/src/state/diagram-machine.ts +51 -6
  118. package/src/utils/index.ts +0 -1
  119. package/dist/overlays/relationship-details/useLayoutedDetails.d.ts +0 -19
  120. package/dist/overlays/relationship-details/useLayoutedDetails.js +0 -267
  121. package/dist/utils/types.d.ts +0 -8
  122. package/src/overlays/relationship-details/useLayoutedDetails.ts +0 -376
  123. package/src/utils/types.ts +0 -6
@@ -1,4 +1,3 @@
1
- export type { AddEdgeData, AddNodeData } from './types';
2
1
  export { vector, VectorImpl } from './vector';
3
2
  export type { Vector } from './vector';
4
3
  export { bezierControlPoints, bezierPath, centerXYInternalNode, distance, distanceBetweenPoints, isInside, isSamePoint, nodeToRect, stopPropagation, toDomPrecision, } from './xyflow';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/diagram",
3
- "version": "1.27.1",
3
+ "version": "1.27.3",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -42,19 +42,19 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@dagrejs/dagre": "1.1.4",
45
- "@mantine/core": "7.17.2",
46
- "@mantine/hooks": "7.17.2",
45
+ "@mantine/core": "7.17.3",
46
+ "@mantine/hooks": "7.17.3",
47
47
  "@nanostores/react": "0.8.4",
48
48
  "@react-hookz/web": "^25.1.0",
49
49
  "@tabler/icons-react": "3.31.0",
50
50
  "@xstate/react": "^5.0.3",
51
- "@xyflow/react": "^12.4.4",
52
- "@xyflow/system": "^0.0.52",
51
+ "@xyflow/react": "^12.5.2",
52
+ "@xyflow/system": "^0.0.53",
53
53
  "bezier-js": "^6.1.4",
54
54
  "clsx": "^2.1.1",
55
55
  "d3-shape": "^3.2.0",
56
56
  "fast-equals": "^5.2.2",
57
- "framer-motion": "^12.5.0",
57
+ "framer-motion": "^12.6.2",
58
58
  "nanostores": "0.11.4",
59
59
  "react": "^19.0.0",
60
60
  "react-dom": "^19.0.0",
@@ -63,8 +63,8 @@
63
63
  "remeda": "^2.21.2",
64
64
  "type-fest": "^4.38.0",
65
65
  "xstate": "^5.19.2",
66
- "@likec4/styles": "1.27.1",
67
- "@likec4/core": "1.27.1"
66
+ "@likec4/core": "1.27.3",
67
+ "@likec4/styles": "1.27.3"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@pandacss/dev": "^0.53.3",
@@ -73,15 +73,15 @@
73
73
  "@types/d3-shape": "^3.1.7",
74
74
  "@types/react": "^19.0.12",
75
75
  "@types/react-dom": "^19.0.4",
76
- "@types/node": "^20.17.27",
76
+ "@types/node": "^20.17.28",
77
77
  "@vitejs/plugin-react": "^4.3.4",
78
78
  "postcss": "^8.5.3",
79
79
  "typescript": "^5.8.2",
80
- "vite": "^6.2.3",
80
+ "vite": "^6.2.4",
81
81
  "vite-plugin-dts": "^4.5.3",
82
82
  "vitest": "^3.0.9",
83
83
  "wireit": "^0.14.11",
84
- "@likec4/tsconfig": "1.27.1"
84
+ "@likec4/tsconfig": "1.27.3"
85
85
  },
86
86
  "scripts": {
87
87
  "generate": "panda codegen",
@@ -83,6 +83,9 @@ export type OverrideReactFlowProps = Pick<
83
83
  | 'nodeDragThreshold'
84
84
  >
85
85
 
86
+ export type PaddingUnit = 'px' | '%'
87
+ export type PaddingWithUnit = `${number}${PaddingUnit}` | number
88
+
86
89
  export interface LikeC4DiagramProperties {
87
90
  view: DiagramView
88
91
 
@@ -114,11 +117,12 @@ export interface LikeC4DiagramProperties {
114
117
  * @default true
115
118
  */
116
119
  fitView?: boolean | undefined
120
+
117
121
  /**
118
- * Seems like this is percentage of the view size
119
- * @default 0
122
+ * Padding around the diagram
123
+ * @default '8px'
120
124
  */
121
- fitViewPadding?: number | undefined
125
+ fitViewPadding?: PaddingWithUnit | undefined
122
126
 
123
127
  /**
124
128
  * @default false if readonly
@@ -35,7 +35,7 @@ export function LikeC4Diagram({
35
35
  view,
36
36
  className,
37
37
  fitView = true,
38
- fitViewPadding = 0,
38
+ fitViewPadding = '8px',
39
39
  readonly = true,
40
40
  pannable = true,
41
41
  zoomable = true,
@@ -21,7 +21,7 @@ export type StaticLikeC4DiagramProps = Pick<
21
21
  export function StaticLikeC4Diagram({
22
22
  view,
23
23
  fitView = true,
24
- fitViewPadding = 0,
24
+ fitViewPadding = '8px',
25
25
  enableElementDetails = false,
26
26
  enableRelationshipDetails = false,
27
27
  enableRelationshipBrowser = enableRelationshipDetails,
@@ -10,6 +10,7 @@ import { Fragment, useMemo } from 'react'
10
10
  import type { SetRequired, Simplify } from 'type-fest'
11
11
  import { useUpdateEffect } from '../hooks/useUpdateEffect'
12
12
  import { useIsZoomTooSmall, useXYStoreApi } from '../hooks/useXYFlow'
13
+ import type { PaddingWithUnit } from '../LikeC4Diagram.props'
13
14
  import { stopPropagation } from '../utils/xyflow'
14
15
  import { type XYBackground, Background } from './Background'
15
16
  import { MaxZoom, MinZoom } from './const'
@@ -22,7 +23,7 @@ export type BaseXYFlowProps<NodeType extends Base.Node, EdgeType extends Base.Ed
22
23
  nodesSelectable?: boolean
23
24
  nodesDraggable?: boolean
24
25
  background?: 'transparent' | 'solid' | XYBackground
25
- fitViewPadding?: number
26
+ fitViewPadding?: PaddingWithUnit | undefined
26
27
  onViewportResize?: undefined | (() => void)
27
28
  }
28
29
  & SetRequired<
@@ -11,7 +11,6 @@ type RequiredData = Pick<
11
11
  DiagramNode,
12
12
  | 'color'
13
13
  | 'depth'
14
- | 'shape'
15
14
  | 'style'
16
15
  >
17
16
 
@@ -73,7 +72,6 @@ export function CompoundNodeContainer({
73
72
  data-likec4-hovered={isHovered}
74
73
  data-likec4-color={data.color}
75
74
  data-compound-depth={depth}
76
- data-likec4-shape={data.shape}
77
75
  {...isTransparent && {
78
76
  'data-compound-transparent': true,
79
77
  'data-compound-title-inverse': opacity < 0.5,
@@ -101,14 +101,16 @@ export function EdgeLabelContainer({
101
101
  }}
102
102
  {...rest}
103
103
  >
104
- {/* Work around to keep same global selector data-likec4-dimmed */}
105
104
  <div
106
- className={css({
105
+ style={{
107
106
  display: 'contents',
108
- })}
109
- {...isDimmed !== false && {
110
- 'data-likec4-dimmed': isDimmed,
111
107
  }}
108
+ {
109
+ // Work around to keep same global selector data-likec4-dimmed
110
+ ...isDimmed !== false && {
111
+ 'data-likec4-dimmed': isDimmed,
112
+ }
113
+ }
112
114
  >
113
115
  {children}
114
116
  </div>
@@ -63,23 +63,22 @@ export function ElementActionButtons({
63
63
  className={cx('nodrag nopan', actionButtons)}
64
64
  >
65
65
  {buttons.map((button, index) => (
66
- <m.div
66
+ <ActionIcon
67
+ component={m.button}
68
+ layout
69
+ className={actionBtn({})}
67
70
  key={`action-button-${id}-${button.key ?? index}`}
68
71
  initial={false}
69
72
  whileTap={{ scale: 1 }}
70
73
  whileHover={{
71
- scale: 1.35,
74
+ scale: 1.3,
72
75
  }}
76
+ // Otherwise node receives click event and is selected
77
+ onClick={button.onClick}
78
+ onDoubleClick={stopPropagation}
73
79
  >
74
- <ActionIcon
75
- className={actionBtn({})}
76
- onClick={button.onClick}
77
- // Otherwise node receives click event and is selected
78
- onDoubleClick={stopPropagation}
79
- >
80
- {button.icon}
81
- </ActionIcon>
82
- </m.div>
80
+ {button.icon}
81
+ </ActionIcon>
83
82
  ))}
84
83
  </Box>
85
84
  </Box>
@@ -13,12 +13,12 @@ export const container = style({
13
13
  alignItems: 'center',
14
14
  justifyContent: 'center',
15
15
  pointerEvents: 'none',
16
- _after: {
16
+ _before: {
17
17
  content: '" "',
18
18
  position: 'absolute',
19
- top: '100%',
19
+ top: 'calc(100% - 4px)',
20
20
  left: 0,
21
- right: 0,
21
+ width: '100%',
22
22
  height: '24px',
23
23
  background: '[transparent]',
24
24
  pointerEvents: 'all',
@@ -43,7 +43,7 @@ export const container = style({
43
43
  // // filter: `grayscale(0.85) ${fallbackVar(vars.safariAnimationHook, 'blur(2px)')}`,
44
44
  // },
45
45
  _reduceGraphicsOnPan: {
46
- _after: {
46
+ _before: {
47
47
  display: 'none',
48
48
  },
49
49
  },
@@ -17,14 +17,14 @@ function _update<E extends Base.Edge>(current: E[], update: E[]): E[] {
17
17
  ) {
18
18
  return existing
19
19
  }
20
- return {
21
- ...omit(existing, ['hidden', 'zIndex']),
22
- ...next,
23
- data: {
24
- ...existing.data,
25
- ...next.data,
26
- },
27
- }
20
+ // return {
21
+ // ...omit(existing, ['hidden', 'zIndex']),
22
+ // ...next,
23
+ // data: {
24
+ // ...existing.data,
25
+ // ...next.data,
26
+ // },
27
+ // }
28
28
  }
29
29
  return next
30
30
  })
@@ -20,17 +20,17 @@ function _update<N extends Base.Node>(current: N[], updated: N[]): N[] {
20
20
  ) {
21
21
  return existing
22
22
  }
23
- return {
24
- ...omit(existing, ['measured', 'parentId', 'hidden', 'zIndex']),
25
- ...update,
26
- // Force dimensions from update
27
- width: update.initialWidth,
28
- height: update.initialHeight,
29
- data: {
30
- ...existing.data,
31
- ...update.data,
32
- },
33
- } as N
23
+ // return {
24
+ // ...omit(existing, ['measured', 'parentId', 'hidden', 'zIndex']),
25
+ // ...update,
26
+ // // Force dimensions from update
27
+ // width: update.initialWidth,
28
+ // height: update.initialHeight,
29
+ // data: {
30
+ // ...existing.data,
31
+ // ...update.data,
32
+ // },
33
+ // } as N
34
34
  }
35
35
  return update
36
36
  })
@@ -1,6 +1,6 @@
1
1
  import type { WhereOperator } from '@likec4/core'
2
2
  import type { CSSProperties } from 'react'
3
- import type { ElementIconRenderer, OverrideReactFlowProps } from '../LikeC4Diagram.props'
3
+ import type { ElementIconRenderer, OverrideReactFlowProps, PaddingWithUnit } from '../LikeC4Diagram.props'
4
4
 
5
5
  export interface LikeC4ViewProps<ViewId = string, Tag = string, Kind = string> {
6
6
  /**
@@ -66,10 +66,10 @@ export interface LikeC4ViewProps<ViewId = string, Tag = string, Kind = string> {
66
66
  fitView?: boolean | undefined
67
67
 
68
68
  /**
69
- * Seems like this is percentage of the view size
70
- * @default 0.1
69
+ * Padding around the diagram
70
+ * @default '8px'
71
71
  */
72
- fitViewPadding?: number | undefined
72
+ fitViewPadding?: PaddingWithUnit | undefined
73
73
 
74
74
  /**
75
75
  * Display diagram title / description
@@ -163,10 +163,10 @@ export interface LikeC4BrowserProps {
163
163
  background?: 'dots' | 'lines' | 'cross' | 'transparent' | 'solid' | undefined
164
164
 
165
165
  /**
166
- * Seems like this is percentage of the view size
167
- * @default 0.1
166
+ * Padding around the diagram
167
+ * @default '16px'
168
168
  */
169
- fitViewPadding?: number | undefined
169
+ fitViewPadding?: PaddingWithUnit | undefined
170
170
 
171
171
  /**
172
172
  * Show/hide panel with top left controls,
@@ -61,7 +61,7 @@ const LikeC4ViewInner = memo<LikeC4ViewInnerProps>(({
61
61
  injectFontCss = true,
62
62
  controls = false,
63
63
  fitView = true,
64
- fitViewPadding = 0.1,
64
+ fitViewPadding = '8px',
65
65
  background = 'transparent',
66
66
  browser = true,
67
67
  showDiagramTitle = false,
@@ -169,7 +169,7 @@ const LikeC4ViewInner = memo<LikeC4ViewInnerProps>(({
169
169
  controls
170
170
  readonly
171
171
  fitView
172
- fitViewPadding={fitViewPadding}
172
+ fitViewPadding={'16px'}
173
173
  {...props}
174
174
  {...browserProps}
175
175
  showNotations={(browserProps.showNotations ?? true) &&
@@ -1,8 +1,10 @@
1
1
  import type { ViewId } from '@likec4/core'
2
+ import { useSelector } from '@xstate/react'
2
3
  import type { DiagramActorSnapshot } from '../state/types'
3
- import { useDiagramActorSnapshot } from './useDiagram'
4
+ import { useDiagramActorRef } from './useDiagram'
4
5
 
5
6
  const selectViewId = (s: DiagramActorSnapshot) => s.context.view.id
6
7
  export function useCurrentViewId(): ViewId {
7
- return useDiagramActorSnapshot(selectViewId)
8
+ const actorRef = useDiagramActorRef()
9
+ return useSelector(actorRef, selectViewId)
8
10
  }
@@ -1,4 +1,4 @@
1
- import { type DiagramView, type EdgeId, type Fqn, type NodeId, type ViewId } from '@likec4/core'
1
+ import { type DiagramView, type EdgeId, type ElementNotation, type Fqn, type NodeId, type ViewId } from '@likec4/core'
2
2
  import { useCallbackRef } from '@mantine/hooks'
3
3
  import { useSelector as useXstateSelector } from '@xstate/react'
4
4
  import { shallowEqual } from 'fast-equals'
@@ -16,46 +16,37 @@ export { useDiagramActorRef }
16
16
 
17
17
  export function useDiagram() {
18
18
  const actor = useDiagramActorRef()
19
- const [, startTransition] = useTransition()
20
19
  return useMemo(() => ({
21
20
  actor,
22
21
  send: actor.send,
23
22
  navigateTo: (viewId: ViewId, fromNode?: NodeId) => {
24
- startTransition(() => {
25
- actor.send({
26
- type: 'navigate.to',
27
- viewId,
28
- ...(fromNode && { fromNode }),
29
- })
23
+ actor.send({
24
+ type: 'navigate.to',
25
+ viewId,
26
+ ...(fromNode && { fromNode }),
30
27
  })
31
28
  },
32
29
  navigate: (direction: 'back' | 'forward') => {
33
- startTransition(() => {
34
- actor.send({ type: `navigate.${direction}` })
35
- })
30
+ actor.send({ type: `navigate.${direction}` })
36
31
  },
37
32
  fitDiagram: (duration = 350) => {
38
- startTransition(() => {
39
- actor.send({ type: 'fitDiagram', duration })
40
- })
33
+ actor.send({ type: 'fitDiagram', duration })
41
34
  },
42
35
  openRelationshipsBrowser: (fqn: Fqn) => {
43
- startTransition(() => {
44
- actor.send({ type: 'open.relationshipsBrowser', fqn })
45
- })
36
+ actor.send({ type: 'open.relationshipsBrowser', fqn })
46
37
  },
47
38
  openSource: (params: OpenSourceParams) => {
48
39
  actor.send({ type: 'open.source', ...params })
49
40
  },
50
41
  openElementDetails: (fqn: Fqn, fromNode?: NodeId) => {
51
- startTransition(() => {
52
- actor.send({ type: 'open.elementDetails', fqn, fromNode })
53
- })
42
+ actor.send({ type: 'open.elementDetails', fqn, fromNode })
54
43
  },
55
- openRelationshipDetails: (edgeId: EdgeId) => {
56
- startTransition(() => {
57
- actor.send({ type: 'open.relationshipDetails', edgeId })
58
- })
44
+ openRelationshipDetails: (...params: [edgeId: EdgeId] | [source: Fqn, target: Fqn]) => {
45
+ if (params.length === 1) {
46
+ actor.send({ type: 'open.relationshipDetails', params: { edgeId: params[0] } })
47
+ } else {
48
+ actor.send({ type: 'open.relationshipDetails', params: { source: params[0], target: params[1] } })
49
+ }
59
50
  },
60
51
 
61
52
  updateNodeData: (nodeId: NodeId, data: PartialDeep<Types.NodeData>) => {
@@ -135,6 +126,13 @@ export function useDiagram() {
135
126
  toggleFeature: (feature: FeatureName, forceValue?: boolean) => {
136
127
  actor.send({ type: 'toggle.feature', feature, ...(forceValue !== undefined && { forceValue }) })
137
128
  },
129
+
130
+ highlightNotation: (notation: ElementNotation, kind?: string) => {
131
+ actor.send({ type: 'notations.highlight', notation, ...(kind && { kind }) })
132
+ },
133
+ unhighlightNotation: () => {
134
+ actor.send({ type: 'notations.unhighlight' })
135
+ },
138
136
  }), [actor])
139
137
  }
140
138
 
@@ -91,16 +91,14 @@ export const LikeC4DiagramXYFlow = memo<LikeC4DiagramXYFlowProps>(({
91
91
  layoutConstraints = useLayoutConstraints(),
92
92
  $isPanning = usePanningAtom(),
93
93
  isPanning = useTimeout(() => {
94
- if (!$isPanning.get()) {
95
- $isPanning.set(true)
96
- }
97
- }, isReducedGraphics ? 150 : 350),
94
+ $isPanning.set(true)
95
+ }, isReducedGraphics ? 100 : 200),
98
96
  notPanning = useDebouncedCallback(() => {
99
97
  isPanning.clear()
100
98
  if ($isPanning.get()) {
101
99
  $isPanning.set(false)
102
100
  }
103
- }, 120),
101
+ }, 200),
104
102
  onMove: OnMove = useCallbackRef((event) => {
105
103
  if (!event) {
106
104
  return
@@ -111,7 +109,9 @@ export const LikeC4DiagramXYFlow = memo<LikeC4DiagramXYFlowProps>(({
111
109
  notPanning()
112
110
  }),
113
111
  onMoveEnd: OnMoveEnd = useCallbackRef((event, viewport) => {
114
- notPanning.flush()
112
+ if (!!event) {
113
+ notPanning.flush()
114
+ }
115
115
  diagram.send({ type: 'xyflow.viewportMoved', viewport, manually: !!event })
116
116
  }),
117
117
  onViewportResize = useCallbackRef(() => {
@@ -98,6 +98,6 @@ export const shapeBadge = css({
98
98
  ['--badge-padding-x']: '3px',
99
99
  ['--badge-height']: '13.5px',
100
100
  ['--badge-lh']: '1',
101
- // ['--badge-bg']: vars.element.fill,
102
- // ['--badge-color']: vars.element.hiContrast
101
+ ['--badge-bg']: '{colors.likec4.palette.fill}',
102
+ ['--badge-color']: '{colors.likec4.palette.hiContrast}',
103
103
  })
@@ -54,13 +54,14 @@ const ElementNotation = ({ value }: { value: ElementNotationData }) => {
54
54
  likec4Palette: color,
55
55
  }),
56
56
  )}
57
+ data-likec4-color={color}
57
58
  onMouseEnter={() => {
58
59
  setOnlyKind(null)
59
- // diagramStore.getState().highlightByElementNotation(value)
60
+ diagram.highlightNotation(value)
60
61
  }}
61
62
  onMouseLeave={() => {
62
63
  setOnlyKind(null)
63
- // diagramStore.setState({ dimmed: new Set() })
64
+ diagram.unhighlightNotation()
64
65
  }}
65
66
  >
66
67
  <Group
@@ -88,17 +89,18 @@ const ElementNotation = ({ value }: { value: ElementNotationData }) => {
88
89
  {value.kinds.map((kind) => (
89
90
  <Badge
90
91
  key={kind}
91
- className={styles.shapeBadge}
92
+ className={cx(
93
+ styles.shapeBadge,
94
+ )}
92
95
  onMouseEnter={() => {
93
96
  setOnlyKind(kind)
94
- // diagramStore.getState().highlightByElementNotation(value, kind)
97
+ diagram.highlightNotation(value, kind)
95
98
  }}
96
99
  onMouseLeave={() => {
97
100
  setOnlyKind(null)
98
- // diagramStore.getState().highlightByElementNotation(value)
101
+ diagram.highlightNotation(value)
99
102
  }}
100
103
  opacity={isNonNullish(onlyKind) && onlyKind !== kind ? 0.25 : 1}
101
- color={isNonNullish(onlyKind) && onlyKind !== kind ? 'gray' : token('colors.likec4.palette.fill')}
102
104
  >
103
105
  {kind}
104
106
  </Badge>
@@ -2,7 +2,7 @@ import { nonexhaustive } from '@likec4/core'
2
2
  import { Box, Button, Code, Group, Notification, ScrollAreaAutosize } from '@mantine/core'
3
3
  import { IconX } from '@tabler/icons-react'
4
4
  import { useSelector } from '@xstate/react'
5
- import { AnimatePresence, LayoutGroup, useReducedMotion, useReducedMotionConfig } from 'framer-motion'
5
+ import { AnimatePresence, LayoutGroup, useReducedMotionConfig } from 'framer-motion'
6
6
  import { animate } from 'framer-motion/dom'
7
7
  import { memo, useEffect, useMemo } from 'react'
8
8
  import { type FallbackProps, ErrorBoundary } from 'react-error-boundary'
@@ -102,12 +102,13 @@ export const Overlays = memo(({ overlaysActorRef }: { overlaysActorRef: Overlays
102
102
  overlaysActorRef.send({ type: 'close', actorId: actorRef.id })
103
103
  }
104
104
 
105
- const overlaysReact = overlays.map((overlay) => {
105
+ const overlaysReact = overlays.map((overlay, index) => {
106
106
  switch (overlay.type) {
107
107
  case 'relationshipsBrowser':
108
108
  return (
109
109
  <Overlay
110
110
  key={overlay.actorRef.sessionId}
111
+ overlayLevel={Math.min(index, 3) as 0 | 1 | 2 | 3}
111
112
  onClose={() => close(overlay.actorRef)}>
112
113
  <RelationshipsBrowser actorRef={overlay.actorRef} />
113
114
  </Overlay>
@@ -115,6 +116,7 @@ export const Overlays = memo(({ overlaysActorRef }: { overlaysActorRef: Overlays
115
116
  case 'relationshipDetails':
116
117
  return (
117
118
  <Overlay
119
+ overlayLevel={Math.min(index, 3) as 0 | 1 | 2 | 3}
118
120
  key={overlay.actorRef.sessionId}
119
121
  onClose={() => close(overlay.actorRef)}>
120
122
  <RelationshipDetails actorRef={overlay.actorRef} />