@likec4/diagram 1.28.0 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/bundle/index.js +1040 -1190
  2. package/dist/LikeC4CustomColors.js +2 -2
  3. package/dist/LikeC4Diagram.js +2 -2
  4. package/dist/LikeC4ModelProvider.js +1 -1
  5. package/dist/_virtual/index.js +5 -0
  6. package/dist/_virtual/index2.js +3 -0
  7. package/dist/_virtual/react.production.js +3 -0
  8. package/dist/base/BaseXYFlow.js +5 -5
  9. package/dist/base/primitives/compound/CompoundActionButton.js +1 -1
  10. package/dist/base/primitives/compound/CompoundDetailsButton.js +1 -1
  11. package/dist/base/primitives/compound/CompoundNodeContainer.d.ts +1 -1
  12. package/dist/base/primitives/compound/CompoundNodeContainer.js +2 -2
  13. package/dist/base/primitives/customEdge.d.ts +1 -1
  14. package/dist/base/primitives/customEdge.js +3 -3
  15. package/dist/base/primitives/customNode.js +2 -2
  16. package/dist/base/primitives/edge/EdgeContainer.js +1 -1
  17. package/dist/base/primitives/edge/EdgeLabel.css.d.ts +3 -0
  18. package/dist/base/primitives/edge/EdgeLabel.css.js +3 -0
  19. package/dist/base/primitives/edge/EdgeLabel.d.ts +1 -1
  20. package/dist/base/primitives/edge/EdgeLabel.js +3 -2
  21. package/dist/base/primitives/edge/EdgeLabelContainer.js +1 -1
  22. package/dist/base/primitives/edge/EdgePath.d.ts +10 -42
  23. package/dist/base/primitives/edge/EdgePath.js +23 -16
  24. package/dist/base/primitives/edge/edge.css.js +1 -1
  25. package/dist/base/primitives/element/ElementActionButtons.js +1 -2
  26. package/dist/base/primitives/element/ElementDetailsButton.js +1 -2
  27. package/dist/base/primitives/element/ElementNodeContainer.js +3 -3
  28. package/dist/base/updateEdges.js +7 -2
  29. package/dist/base/updateNodes.js +11 -3
  30. package/dist/bundle/LikeC4View.js +3 -3
  31. package/dist/bundle/ReactLikeC4.js +1 -1
  32. package/dist/bundle/ShadowRoot.js +3 -3
  33. package/dist/bundle/styles.css.js +3 -3
  34. package/dist/context/ControlsCustomLayout.js +1 -1
  35. package/dist/context/DiagramEventHandlers.js +5 -5
  36. package/dist/context/DiagramFeatures.js +7 -7
  37. package/dist/context/EnsureMantine.js +2 -2
  38. package/dist/context/FramerMotionConfig.js +2 -2
  39. package/dist/context/IconRenderer.js +4 -4
  40. package/dist/context/ReduceGraphics.js +2 -2
  41. package/dist/context/RootContainer.js +5 -9
  42. package/dist/hooks/safeContext.d.ts +2 -5
  43. package/dist/hooks/safeContext.js +5 -4
  44. package/dist/hooks/useCurrentViewId.js +1 -1
  45. package/dist/hooks/useDiagram.d.ts +715 -150
  46. package/dist/hooks/useDiagram.js +2 -2
  47. package/dist/hooks/useMantinePortalProps.js +2 -2
  48. package/dist/hooks/useSetState.js +3 -3
  49. package/dist/hooks/useUpdateEffect.js +1 -1
  50. package/dist/hooks/useXYFlow.d.ts +2 -2
  51. package/dist/likec4diagram/DiagramUI.js +2 -2
  52. package/dist/likec4diagram/DiagramXYFlow.js +2 -2
  53. package/dist/likec4diagram/custom/edges/NotePopover.js +2 -2
  54. package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +2 -2
  55. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +7 -7
  56. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +6 -6
  57. package/dist/likec4diagram/custom/index.d.ts +1 -2
  58. package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.js +2 -2
  59. package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +3 -3
  60. package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +2 -2
  61. package/dist/likec4diagram/ui/controls/ChangeAutoLayoutButton.js +4 -4
  62. package/dist/likec4diagram/ui/controls/Controls.js +9 -9
  63. package/dist/likec4diagram/ui/controls/NavigationButtons.js +1 -1
  64. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +1 -1
  65. package/dist/likec4diagram/ui/notation/NotationPanel.js +4 -4
  66. package/dist/likec4diagram/ui/search/ElementsColumn.js +88 -77
  67. package/dist/likec4diagram/ui/search/LikeC4Search.d.ts +2 -1
  68. package/dist/likec4diagram/ui/search/LikeC4Search.js +27 -24
  69. package/dist/likec4diagram/ui/search/SearchInput.js +1 -1
  70. package/dist/likec4diagram/ui/search/ViewsColum.js +3 -2
  71. package/dist/likec4diagram/ui/search/state.js +11 -9
  72. package/dist/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.js +1 -1
  73. package/dist/likec4diagram/useLayoutConstraints.js +3 -3
  74. package/dist/likec4model/LikeC4ModelContext.js +2 -2
  75. package/dist/likec4model/useLikeC4ElementsTree.js +2 -2
  76. package/dist/likec4model/useLikeC4Model.js +2 -2
  77. package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react.production.js +548 -0
  78. package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/index.js +15 -0
  79. package/dist/overlays/Overlays.js +6 -6
  80. package/dist/overlays/element-details/ElementDetails.js +1 -1
  81. package/dist/overlays/element-details/ElementDetailsCard.js +5 -5
  82. package/dist/overlays/element-details/TabPanelDeployments.js +7 -4
  83. package/dist/overlays/element-details/TabPanelRelationships.js +2 -2
  84. package/dist/overlays/element-details/TabPanelStructure.js +6 -3
  85. package/dist/overlays/element-details/actor.d.ts +2 -2
  86. package/dist/overlays/element-details/actorContext.js +3 -3
  87. package/dist/overlays/overlay/Overlay.js +8 -7
  88. package/dist/overlays/relationship-details/RelationshipDetails.d.ts +1 -1
  89. package/dist/overlays/relationship-details/RelationshipDetails.js +28 -23
  90. package/dist/overlays/relationship-details/SelectEdge.js +3 -6
  91. package/dist/overlays/relationship-details/actor.d.ts +4 -1
  92. package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +1 -1
  93. package/dist/overlays/relationship-details/custom/edgeTypes.js +1 -1
  94. package/dist/overlays/relationship-details/hooks.d.ts +4 -1
  95. package/dist/overlays/relationship-details/hooks.js +4 -4
  96. package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +1 -1
  97. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +9 -11
  98. package/dist/overlays/relationships-browser/SelectElement.js +8 -5
  99. package/dist/overlays/relationships-browser/actor.d.ts +2 -1
  100. package/dist/overlays/relationships-browser/actor.js +6 -12
  101. package/dist/overlays/relationships-browser/const.d.ts +2 -1
  102. package/dist/overlays/relationships-browser/const.js +6 -1
  103. package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +1 -1
  104. package/dist/overlays/relationships-browser/custom/edgeTypes.js +3 -4
  105. package/dist/overlays/relationships-browser/custom/nodeTypes.js +1 -1
  106. package/dist/overlays/relationships-browser/hooks.d.ts +2 -1
  107. package/dist/overlays/relationships-browser/hooks.js +4 -4
  108. package/dist/overlays/relationships-browser/layout.js +2 -2
  109. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +1 -2
  110. package/dist/state/DiagramActorProvider.js +7 -5
  111. package/dist/state/diagram-machine.d.ts +719 -146
  112. package/dist/state/diagram-machine.js +51 -10
  113. package/dist/styles.css.js +1 -1
  114. package/package.json +20 -16
  115. package/src/LikeC4Diagram.tsx +0 -1
  116. package/src/base/BaseXYFlow.tsx +2 -2
  117. package/src/base/primitives/compound/CompoundActionButton.tsx +1 -1
  118. package/src/base/primitives/compound/CompoundDetailsButton.tsx +1 -1
  119. package/src/base/primitives/compound/CompoundNodeContainer.tsx +1 -1
  120. package/src/base/primitives/customEdge.ts +1 -0
  121. package/src/base/primitives/edge/EdgeLabel.css.ts +3 -0
  122. package/src/base/primitives/edge/EdgeLabel.tsx +2 -1
  123. package/src/base/primitives/edge/EdgePath.tsx +22 -14
  124. package/src/base/primitives/edge/edge.css.ts +1 -1
  125. package/src/base/primitives/element/ElementActionButtons.tsx +2 -2
  126. package/src/base/primitives/element/ElementDetailsButton.tsx +2 -2
  127. package/src/base/primitives/element/ElementNodeContainer.tsx +1 -1
  128. package/src/base/updateEdges.ts +6 -9
  129. package/src/base/updateNodes.ts +10 -14
  130. package/src/context/FramerMotionConfig.tsx +1 -1
  131. package/src/context/RootContainer.tsx +0 -4
  132. package/src/hooks/safeContext.tsx +3 -1
  133. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +2 -2
  134. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +1 -1
  135. package/src/likec4diagram/ui/controls/Controls.tsx +56 -58
  136. package/src/likec4diagram/ui/controls/NavigationButtons.tsx +1 -1
  137. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +1 -1
  138. package/src/likec4diagram/ui/notation/NotationPanel.tsx +1 -1
  139. package/src/likec4diagram/ui/search/ElementsColumn.tsx +94 -71
  140. package/src/likec4diagram/ui/search/LikeC4Search.tsx +48 -55
  141. package/src/likec4diagram/ui/search/ViewsColum.tsx +2 -2
  142. package/src/likec4diagram/ui/search/state.ts +8 -6
  143. package/src/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.tsx +1 -1
  144. package/src/overlays/Overlays.tsx +2 -2
  145. package/src/overlays/element-details/ElementDetails.tsx +2 -2
  146. package/src/overlays/element-details/ElementDetailsCard.tsx +1 -1
  147. package/src/overlays/element-details/TabPanelDeployments.tsx +2 -0
  148. package/src/overlays/element-details/TabPanelStructure.tsx +2 -1
  149. package/src/overlays/overlay/Overlay.tsx +2 -1
  150. package/src/overlays/relationship-details/RelationshipDetails.tsx +25 -16
  151. package/src/overlays/relationship-details/SelectEdge.tsx +0 -14
  152. package/src/overlays/relationship-details/actor.ts +2 -1
  153. package/src/overlays/relationship-details/custom/edgeTypes.tsx +1 -1
  154. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +1 -3
  155. package/src/overlays/relationships-browser/SelectElement.tsx +2 -0
  156. package/src/overlays/relationships-browser/actor.ts +8 -13
  157. package/src/overlays/relationships-browser/const.ts +8 -1
  158. package/src/overlays/relationships-browser/custom/edgeTypes.tsx +2 -3
  159. package/src/overlays/relationships-browser/custom/nodeTypes.tsx +1 -1
  160. package/src/overlays/relationships-browser/useViewToNodesEdges.ts +1 -2
  161. package/src/state/DiagramActorProvider.tsx +7 -4
  162. package/src/state/diagram-machine.ts +50 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/diagram",
3
- "version": "1.28.0",
3
+ "version": "1.29.0",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -42,29 +42,31 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@dagrejs/dagre": "1.1.4",
45
- "@mantine/core": "7.17.3",
46
- "@mantine/hooks": "7.17.3",
47
- "@nanostores/react": "0.8.4",
48
- "@react-hookz/web": "^25.1.0",
45
+ "@mantine/core": "7.17.4",
46
+ "@mantine/hooks": "7.17.4",
47
+ "@nanostores/react": "1.0.0",
48
+ "@react-hookz/web": "^25.1.1",
49
49
  "@tabler/icons-react": "3.31.0",
50
50
  "@xstate/react": "^5.0.3",
51
- "@xyflow/react": "^12.5.3",
52
- "@xyflow/system": "^0.0.53",
51
+ "@xyflow/react": "^12.5.5",
52
+ "@xyflow/system": "^0.0.55",
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.6.3",
58
- "nanostores": "0.11.4",
59
- "react": "^19.0.0",
60
- "react-dom": "^19.0.0",
57
+ "motion": "^12.7.3",
58
+ "nanostores": "1.0.1",
61
59
  "react-error-boundary": "^5.0.0",
62
60
  "react-shadow": "^20.6.0",
63
61
  "remeda": "^2.21.2",
64
62
  "type-fest": "^4.39.1",
65
63
  "xstate": "^5.19.2",
66
- "@likec4/core": "1.28.0",
67
- "@likec4/styles": "1.28.0"
64
+ "@likec4/core": "1.29.0",
65
+ "@likec4/styles": "1.29.0"
66
+ },
67
+ "peerDependencies": {
68
+ "react": "^18.x || ^19.x",
69
+ "react-dom": "^18.x || ^19.x"
68
70
  },
69
71
  "devDependencies": {
70
72
  "@pandacss/dev": "^0.53.3",
@@ -73,15 +75,17 @@
73
75
  "@types/d3-shape": "^3.1.7",
74
76
  "@types/react": "^19.0.12",
75
77
  "@types/react-dom": "^19.0.4",
76
- "@types/node": "^20.17.28",
78
+ "@types/node": "^20.17.30",
77
79
  "@vitejs/plugin-react": "^4.3.4",
78
80
  "postcss": "^8.5.3",
81
+ "react": "^19.0.0",
82
+ "react-dom": "^19.0.0",
79
83
  "typescript": "^5.8.3",
80
84
  "vite": "^6.2.5",
81
85
  "vite-plugin-dts": "^4.5.3",
82
86
  "vitest": "^3.1.1",
83
- "wireit": "^0.14.11",
84
- "@likec4/tsconfig": "1.28.0"
87
+ "wireit": "^0.14.12",
88
+ "@likec4/tsconfig": "1.29.0"
85
89
  },
86
90
  "scripts": {
87
91
  "generate": "panda codegen",
@@ -15,7 +15,6 @@ import { LikeC4CustomColors } from './LikeC4CustomColors'
15
15
  import { type LikeC4DiagramEventHandlers, type LikeC4DiagramProperties } from './LikeC4Diagram.props'
16
16
  import { LikeC4DiagramXYFlow } from './likec4diagram/DiagramXYFlow'
17
17
  import type { Types } from './likec4diagram/types'
18
- import { useViewToNodesEdges } from './likec4diagram/useViewToNodesEdges'
19
18
  import { useLikeC4Model } from './likec4model'
20
19
  import { DiagramActorProvider } from './state/DiagramActorProvider'
21
20
 
@@ -143,8 +143,8 @@ export const BaseXYFlow = <
143
143
  edgesFocusable={false}
144
144
  nodesDraggable={nodesDraggable}
145
145
  nodeDragThreshold={4}
146
- nodeClickDistance={1.9}
147
- paneClickDistance={1.9}
146
+ nodeClickDistance={3}
147
+ paneClickDistance={3}
148
148
  elevateNodesOnSelect={false} // or edges are not visible after select\
149
149
  selectNodesOnDrag={false}
150
150
  onNodesChange={onNodesChange}
@@ -3,7 +3,7 @@ import { actionBtn } from '@likec4/styles/recipes'
3
3
  import { ActionIcon, Box } from '@mantine/core'
4
4
  import { useDebouncedValue } from '@mantine/hooks'
5
5
  import { IconZoomScan } from '@tabler/icons-react'
6
- import { m } from 'framer-motion'
6
+ import * as m from 'motion/react-m'
7
7
  import { stopPropagation } from '../../../utils/xyflow'
8
8
  import type { NodeProps } from '../../types'
9
9
  import { compoundActionBtn } from './actionbtns.css'
@@ -3,7 +3,7 @@ import { actionBtn } from '@likec4/styles/recipes'
3
3
  import { ActionIcon, Box } from '@mantine/core'
4
4
  import { useDebouncedValue } from '@mantine/hooks'
5
5
  import { IconId } from '@tabler/icons-react'
6
- import { m } from 'framer-motion'
6
+ import * as m from 'motion/react-m'
7
7
  import { stopPropagation } from '../../../utils/xyflow'
8
8
  import type { NodeProps } from '../../types'
9
9
  import { compoundActionBtn } from './actionbtns.css'
@@ -1,6 +1,6 @@
1
1
  import type { DiagramNode } from '@likec4/core'
2
2
  import { css, cx } from '@likec4/styles/css'
3
- import { type HTMLMotionProps, m } from 'framer-motion'
3
+ import { type HTMLMotionProps, m } from 'motion/react'
4
4
  import { type PropsWithChildren } from 'react'
5
5
  import { clamp, isNumber } from 'remeda'
6
6
  import { useIsReducedGraphics } from '../../../hooks/useReducedGraphics'
@@ -13,6 +13,7 @@ export const edgePropsEqual = <P extends Record<string, unknown> = Base.EdgeData
13
13
  ) => (
14
14
  prev.id === next.id
15
15
  && eq(prev.selected ?? false, next.selected ?? false)
16
+ && eq(prev.animated ?? false, next.animated ?? false)
16
17
  && eq(prev.source, next.source)
17
18
  && eq(prev.sourceHandleId ?? null, next.sourceHandleId ?? null)
18
19
  && eq(prev.sourcePosition, next.sourcePosition)
@@ -125,6 +125,9 @@ export const labelsva = sva({
125
125
  padding: '0px',
126
126
  },
127
127
  labelContents: {
128
+ display: 'flex',
129
+ flexDirection: 'column',
130
+ alignItems: 'center',
128
131
  padding: '2px 5px 4px 0px',
129
132
  },
130
133
  labelText: {
@@ -1,6 +1,7 @@
1
1
  import { type DiagramEdge, extractStep, isStepEdgeId } from '@likec4/core'
2
2
  import { cx } from '@likec4/styles/css'
3
- import { type BoxProps, Box, Text } from '@mantine/core'
3
+ import { type BoxProps, Box } from '@likec4/styles/jsx'
4
+ import { Text } from '@mantine/core'
4
5
  import { type PropsWithChildren } from 'react'
5
6
  import { isTruthy } from 'remeda'
6
7
  import type { UndefinedOnPartialDeep } from 'type-fest'
@@ -1,5 +1,5 @@
1
1
  import type { DiagramEdge } from '@likec4/core'
2
- import { cx } from '@likec4/styles/css'
2
+ import { css, cx } from '@likec4/styles/css'
3
3
  import { type PointerEventHandler, forwardRef } from 'react'
4
4
  import type { UndefinedOnPartialDeep } from 'type-fest'
5
5
  import type { EdgeProps } from '../../types'
@@ -16,25 +16,28 @@ type Data = UndefinedOnPartialDeep<
16
16
  >
17
17
  >
18
18
 
19
- type EdgePathProps = EdgeProps<Data> & {
19
+ type EdgePathProps = {
20
+ edgeProps: EdgeProps<Data>
20
21
  svgPath: string
21
22
  strokeWidth?: number
22
23
  onEdgePointerDown?: PointerEventHandler<SVGGElement> | undefined
23
24
  }
24
25
 
25
26
  export const EdgePath = forwardRef<SVGPathElement, EdgePathProps>(({
26
- id,
27
- data: {
28
- line,
29
- dir,
30
- tail,
31
- head,
27
+ edgeProps: {
28
+ id,
29
+ data: {
30
+ line,
31
+ dir,
32
+ tail,
33
+ head,
34
+ },
35
+ style,
36
+ interactionWidth,
32
37
  },
38
+ onEdgePointerDown,
33
39
  strokeWidth,
34
40
  svgPath,
35
- style,
36
- interactionWidth,
37
- onEdgePointerDown,
38
41
  }, svgPathRef) => {
39
42
  let markerStartName = arrowTypeToMarker(tail)
40
43
  let markerEndName = arrowTypeToMarker(head ?? 'normal')
@@ -69,10 +72,15 @@ export const EdgePath = forwardRef<SVGPathElement, EdgePathProps>(({
69
72
  return (
70
73
  <>
71
74
  <path
72
- className={cx('react-flow__edge-interaction', hideOnReducedGraphics)}
75
+ className={cx(
76
+ 'react-flow__edge-interaction',
77
+ hideOnReducedGraphics,
78
+ css({
79
+ fill: '[none]',
80
+ strokeOpacity: 0,
81
+ }),
82
+ )}
73
83
  d={svgPath}
74
- fill="none"
75
- stroke={'transparent'}
76
84
  strokeWidth={interactionWidth ?? 10}
77
85
  />
78
86
  <g className={markerContext} onPointerDown={onEdgePointerDown}>
@@ -71,7 +71,7 @@ export const markerContext = css({
71
71
  })
72
72
 
73
73
  export const cssEdgePath = css({
74
- fill: '[none]',
74
+ fill: '[none!]',
75
75
  strokeDashoffset: 10,
76
76
  _noReduceGraphics: {
77
77
  transition: 'stroke 130ms ease-out,stroke-width 130ms ease-out',
@@ -2,7 +2,7 @@ import { css, cx } from '@likec4/styles/css'
2
2
  import { actionBtn } from '@likec4/styles/recipes'
3
3
  import { ActionIcon, Box } from '@mantine/core'
4
4
  import { useId } from '@mantine/hooks'
5
- import { m } from 'framer-motion'
5
+ import * as m from 'motion/react-m'
6
6
  import { useIsZoomTooSmall } from '../../../hooks/useXYFlow'
7
7
  import { stopPropagation } from '../../../utils/xyflow'
8
8
  import type { NodeProps } from '../../types'
@@ -67,7 +67,7 @@ export function ElementActionButtons({
67
67
  {buttons.map((button, index) => (
68
68
  <ActionIcon
69
69
  component={m.button}
70
- layout
70
+ // layout
71
71
  className={actionBtn({})}
72
72
  key={`${id}-${button.key ?? index}`}
73
73
  initial={false}
@@ -3,7 +3,7 @@ import { actionBtn } from '@likec4/styles/recipes'
3
3
  import { ActionIcon, Box } from '@mantine/core'
4
4
  import { useId } from '@mantine/hooks'
5
5
  import { IconId } from '@tabler/icons-react'
6
- import { m } from 'framer-motion'
6
+ import * as m from 'motion/react-m'
7
7
  import { stopPropagation } from '../../../utils/xyflow'
8
8
  import type { NodeProps } from '../../types'
9
9
 
@@ -49,7 +49,7 @@ export function ElementDetailsButton({
49
49
  key={id}
50
50
  className={cx('nodrag nopan', actionBtn({ variant: 'transparent' }))}
51
51
  component={m.button}
52
- layout
52
+ // layout
53
53
  initial={false}
54
54
  style={{
55
55
  originX: 0.45,
@@ -7,7 +7,7 @@ import {
7
7
  } from '@likec4/core'
8
8
  import { css, cx } from '@likec4/styles/css'
9
9
  import { type BoxProps, Box, createPolymorphicComponent } from '@mantine/core'
10
- import { m } from 'framer-motion'
10
+ import * as m from 'motion/react-m'
11
11
  import { type PropsWithChildren, forwardRef } from 'react'
12
12
  import type { NodeProps } from '../../types'
13
13
  import * as styles from './ElementNodeContainer.css'
@@ -5,7 +5,7 @@ import type { Base } from './types'
5
5
  function _update<E extends Base.Edge>(current: E[], update: E[]): E[] {
6
6
  return update.map((next) => {
7
7
  const existing = current.find(n => n.id === next.id)
8
- if (existing && existing.type === next.type) {
8
+ if (existing && eq(existing.type, next.type)) {
9
9
  if (
10
10
  eq(existing.hidden ?? false, next.hidden ?? false)
11
11
  && eq(existing.source, next.source)
@@ -17,14 +17,11 @@ 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: next.data,
24
+ }
28
25
  }
29
26
  return next
30
27
  })
@@ -6,11 +6,10 @@ import type { Base } from './types'
6
6
  function _update<N extends Base.Node>(current: N[], updated: N[]): N[] {
7
7
  return updated.map((update) => {
8
8
  const existing = current.find(n => n.id === update.id)
9
- if (existing) {
9
+ if (existing && eq(existing.type, update.type)) {
10
10
  const { width: existingWidth, height: existingHeight } = getNodeDimensions(existing)
11
11
  if (
12
- eq(existing.type, update.type)
13
- && eq(existingWidth, update.initialWidth)
12
+ eq(existingWidth, update.initialWidth)
14
13
  && eq(existingHeight, update.initialHeight)
15
14
  && eq(existing.parentId ?? null, update.parentId ?? null)
16
15
  && eq(existing.hidden ?? false, update.hidden ?? false)
@@ -20,17 +19,14 @@ function _update<N extends Base.Node>(current: N[], updated: N[]): N[] {
20
19
  ) {
21
20
  return existing
22
21
  }
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
22
+ return {
23
+ ...omit(existing, ['measured', 'parentId', 'hidden', 'zIndex']),
24
+ ...update,
25
+ // Force dimensions from update
26
+ width: update.initialWidth,
27
+ height: update.initialHeight,
28
+ data: update.data,
29
+ } as N
34
30
  }
35
31
  return update
36
32
  })
@@ -1,5 +1,5 @@
1
1
  import { useMantineStyleNonce } from '@mantine/core'
2
- import { domMax, LazyMotion, MotionConfig } from 'framer-motion'
2
+ import { domMax, LazyMotion, MotionConfig } from 'motion/react'
3
3
  import { type PropsWithChildren } from 'react'
4
4
 
5
5
  export const FramerMotionConfig = ({
@@ -29,10 +29,6 @@ export function RootContainer({
29
29
  return (
30
30
  <Box
31
31
  className={cx('likec4-root', className)}
32
- css={{
33
- // '--likec4-background-color': 'mantine.colors.body',
34
- // '--colors-likec4-background': 'var(--mantine-color-body)',
35
- }}
36
32
  ref={ref}
37
33
  {...reduceGraphics && {
38
34
  ['data-likec4-reduced-graphics']: true,
@@ -4,9 +4,11 @@ import type { DiagramActorRef } from '../state/types'
4
4
  /**
5
5
  * To improve experience with HMR, we use `createSafeContext` as a boundary for hoooks
6
6
  */
7
- export const DiagramActorSafeContext = createContext<DiagramActorRef>(null as any)
7
+ const DiagramActorSafeContext = createContext<DiagramActorRef>(null as any)
8
8
  DiagramActorSafeContext.displayName = 'DiagramActorSafeContext'
9
9
 
10
+ export const DiagramActorContextProvider = DiagramActorSafeContext.Provider
11
+
10
12
  export const useDiagramActorRef = () => {
11
13
  const ctx = useContext(DiagramActorSafeContext)
12
14
  if (ctx === null) {
@@ -336,7 +336,7 @@ export const RelationshipEdge = customEdge<Types.RelationshipEdgeData>((props) =
336
336
  <>
337
337
  <EdgeContainer {...props} className={clsx(isControlPointDragging && edgesCss.controlDragging)}>
338
338
  <EdgePath
339
- {...props}
339
+ edgeProps={props}
340
340
  svgPath={edgePath}
341
341
  ref={svgPathRef}
342
342
  {...enableEdgeEditing && {
@@ -374,7 +374,7 @@ export const RelationshipEdge = customEdge<Types.RelationshipEdgeData>((props) =
374
374
  <circle
375
375
  onPointerDown={e => onControlPointerDown(i, e)}
376
376
  className={clsx('nodrag nopan', edgesCss.controlPoint)}
377
- key={i}
377
+ key={'controlPoints' + edgeId + '#' + i}
378
378
  cx={Math.round(p.x)}
379
379
  cy={Math.round(p.y)}
380
380
  r={3}
@@ -89,7 +89,7 @@ export const RelationshipsDropdownMenu = memo((
89
89
  diagramEdge.relations,
90
90
  map(id => {
91
91
  try {
92
- return likec4model.relationship(id)
92
+ return likec4model.findRelationship(id)
93
93
  } catch (e) {
94
94
  // View was cached, but likec4model based on new data
95
95
  console.error(
@@ -1,7 +1,7 @@
1
+ import { cx } from '@likec4/styles/css'
1
2
  import { ActionIconGroup, Badge, Box, Group, Loader, Stack } from '@mantine/core'
2
3
  import { IconFileSymlink, IconFocusCentered, IconMenu2 } from '@tabler/icons-react'
3
- import { clsx } from 'clsx'
4
- import { AnimatePresence, LayoutGroup, m } from 'framer-motion'
4
+ import { LayoutGroup, m } from 'motion/react'
5
5
  import { memo } from 'react'
6
6
  import { useDiagramEventHandlers, useEnabledFeatures } from '../../../context'
7
7
  import { type ControlsCustomLayout, useControlsCustomLayout } from '../../../context/ControlsCustomLayout'
@@ -42,7 +42,7 @@ const ControlsDefaultLayout: ControlsCustomLayout = ({
42
42
  translateY: -10,
43
43
  }}
44
44
  align="flex-start"
45
- className={clsx(
45
+ className={cx(
46
46
  'react-flow__panel',
47
47
  css.panel,
48
48
  'likec4-top-left-panel',
@@ -53,7 +53,7 @@ const ControlsDefaultLayout: ControlsCustomLayout = ({
53
53
  <Stack align="flex-start" gap="xs">
54
54
  <LayoutGroup>
55
55
  <Group
56
- className={clsx(css.navigationButtons, 'likec4-navigation-webview')}
56
+ className={cx(css.navigationButtons, 'likec4-navigation-webview')}
57
57
  gap={'xs'}>
58
58
  {burgerMenu}
59
59
  {navigationButtons}
@@ -90,60 +90,58 @@ export const Controls = memo(() => {
90
90
  const portalProps = useMantinePortalProps()
91
91
  const ControlsLayout = useControlsCustomLayout() ?? ControlsDefaultLayout
92
92
  return (
93
- <LayoutGroup inherit={false}>
94
- <AnimatePresence initial={false} mode="wait">
95
- {isNotActiveWalkthrough && (
96
- <ControlsLayout
97
- burgerMenu={onBurgerMenuClick && (
98
- <ActionIcon
99
- onClick={e => {
100
- e.stopPropagation()
101
- onBurgerMenuClick()
102
- }}>
103
- <IconMenu2 />
104
- </ActionIcon>
105
- )}
106
- navigationButtons={enableNavigationButtons && <NavigationButtons />}
107
- search={enableSearch && <LikeC4Search />}
108
- syncInProgressBadge={<SyncLayoutBadge />}
109
- actionsGroup={
110
- <ActionIconGroup className={css.actionIconGroup} orientation="vertical">
111
- {enableVscode && (
112
- <Tooltip label="Open source" {...portalProps}>
113
- <ActionIcon
114
- onClick={e => {
115
- e.stopPropagation()
116
- onOpenSource?.({ view: viewId })
117
- }}>
118
- <IconFileSymlink stroke={1.5} />
119
- </ActionIcon>
120
- </Tooltip>
121
- )}
122
- {enableControls && <ToggleReadonly />}
123
- {enableControls && hasLayoutDrift && <LayoutDriftNotification {...portalProps} />}
124
- {enableControls && notReadOnly && (
125
- <>
126
- <ChangeAutoLayoutButton {...portalProps} />
127
- <ManualLayoutToolsButton {...portalProps} />
128
- </>
129
- )}
130
- {enableControls && (
131
- <Tooltip label={viewportChanged ? 'Center camera' : 'Camera is centered'} {...portalProps}>
132
- <ActionIcon
133
- onClick={e => {
134
- e.stopPropagation()
135
- diagram.fitDiagram()
136
- }}>
137
- <IconFocusCentered />
138
- </ActionIcon>
139
- </Tooltip>
140
- )}
141
- </ActionIconGroup>
142
- }
143
- />
144
- )}
145
- </AnimatePresence>
146
- </LayoutGroup>
93
+ <>
94
+ {isNotActiveWalkthrough && (
95
+ <ControlsLayout
96
+ burgerMenu={onBurgerMenuClick && (
97
+ <ActionIcon
98
+ onClick={e => {
99
+ e.stopPropagation()
100
+ onBurgerMenuClick()
101
+ }}>
102
+ <IconMenu2 />
103
+ </ActionIcon>
104
+ )}
105
+ navigationButtons={enableNavigationButtons && <NavigationButtons />}
106
+ search={enableSearch && <LikeC4Search />}
107
+ syncInProgressBadge={<SyncLayoutBadge />}
108
+ actionsGroup={
109
+ <ActionIconGroup className={css.actionIconGroup} orientation="vertical">
110
+ {enableVscode && (
111
+ <Tooltip label="Open source" {...portalProps}>
112
+ <ActionIcon
113
+ onClick={e => {
114
+ e.stopPropagation()
115
+ onOpenSource?.({ view: viewId })
116
+ }}>
117
+ <IconFileSymlink stroke={1.5} />
118
+ </ActionIcon>
119
+ </Tooltip>
120
+ )}
121
+ {enableControls && <ToggleReadonly />}
122
+ {enableControls && hasLayoutDrift && <LayoutDriftNotification {...portalProps} />}
123
+ {enableControls && notReadOnly && (
124
+ <>
125
+ <ChangeAutoLayoutButton {...portalProps} />
126
+ <ManualLayoutToolsButton {...portalProps} />
127
+ </>
128
+ )}
129
+ {enableControls && (
130
+ <Tooltip label={viewportChanged ? 'Center camera' : 'Camera is centered'} {...portalProps}>
131
+ <ActionIcon
132
+ onClick={e => {
133
+ e.stopPropagation()
134
+ diagram.fitDiagram()
135
+ }}>
136
+ <IconFocusCentered />
137
+ </ActionIcon>
138
+ </Tooltip>
139
+ )}
140
+ </ActionIconGroup>
141
+ }
142
+ />
143
+ )}
144
+ </>
147
145
  )
148
146
  })
149
147
 
@@ -1,6 +1,6 @@
1
1
  import { IconChevronRight } from '@tabler/icons-react'
2
2
 
3
- import { AnimatePresence, m } from 'framer-motion'
3
+ import { AnimatePresence, m } from 'motion/react'
4
4
 
5
5
  import { IconChevronLeft } from '@tabler/icons-react'
6
6
  import { useDiagram, useDiagramContext } from '../../../hooks/useDiagram'
@@ -2,7 +2,7 @@ import { Button, Card, CardSection, Group, Spoiler, Stack, Text } from '@mantine
2
2
  import { useLocalStorage } from '@mantine/hooks'
3
3
  import { IconMenu } from '@tabler/icons-react'
4
4
  import clsx from 'clsx'
5
- import { AnimatePresence, m } from 'framer-motion'
5
+ import { AnimatePresence, m } from 'motion/react'
6
6
  import { Link } from '../../../components/Link'
7
7
  import { useDiagramContext } from '../../../hooks/useDiagram'
8
8
  import * as styles from './DiagramTitlePanel.css'
@@ -20,7 +20,7 @@ import {
20
20
  import { useLocalStorage } from '@mantine/hooks'
21
21
  import { IconAlertTriangle, IconArrowDownRight, IconHelpCircle } from '@tabler/icons-react'
22
22
  import clsx from 'clsx'
23
- import { AnimatePresence, m } from 'framer-motion'
23
+ import { AnimatePresence, m } from 'motion/react'
24
24
  import { memo, useState } from 'react'
25
25
  import { ceil, isNonNullish } from 'remeda'
26
26
  import { ElementShape } from '../../../base/primitives'