@likec4/diagram 1.18.0 → 1.19.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 (277) hide show
  1. package/LICENSE +1 -1
  2. package/dist/LikeC4CustomColors.d.ts +7 -0
  3. package/dist/LikeC4CustomColors.js +30 -0
  4. package/dist/LikeC4Diagram.css.d.ts +5 -0
  5. package/dist/LikeC4Diagram.css.js +13 -0
  6. package/dist/LikeC4Diagram.d.ts +6 -0
  7. package/dist/LikeC4Diagram.js +194 -0
  8. package/dist/LikeC4Diagram.props.d.ts +166 -0
  9. package/dist/LikeC4ModelProvider.d.ts +9 -0
  10. package/dist/LikeC4ModelProvider.js +12 -0
  11. package/dist/LikeC4Search.css.d.ts +1 -0
  12. package/dist/LikeC4Search.css.js +5 -0
  13. package/dist/LikeC4Search.d.ts +2 -0
  14. package/dist/LikeC4Search.js +96 -0
  15. package/dist/StaticLikeC4Diagram.d.ts +3 -0
  16. package/dist/StaticLikeC4Diagram.js +41 -0
  17. package/dist/_virtual/_commonjsHelpers.js +6 -0
  18. package/dist/controls/Text.d.ts +2 -0
  19. package/dist/controls/Text.js +7 -0
  20. package/dist/controls/action-button-bar/ActionButtonBar.css.d.ts +1 -0
  21. package/dist/controls/action-button-bar/ActionButtonBar.css.js +5 -0
  22. package/dist/controls/action-button-bar/ActionButtonBar.d.ts +9 -0
  23. package/dist/controls/action-button-bar/ActionButtonBar.js +100 -0
  24. package/dist/controls/action-button-bar/useActionButtonBarCtx.d.ts +10 -0
  25. package/dist/controls/action-button-bar/useActionButtonBarCtx.js +9 -0
  26. package/dist/controls/action-buttons/ActionButton.css.d.ts +1 -0
  27. package/dist/controls/action-buttons/ActionButton.css.js +5 -0
  28. package/dist/controls/action-buttons/ActionButton.d.ts +9 -0
  29. package/dist/controls/action-buttons/ActionButton.js +66 -0
  30. package/dist/controls/action-buttons/ActionButtons.d.ts +12 -0
  31. package/dist/controls/action-buttons/ActionButtons.js +99 -0
  32. package/dist/globals.css.d.ts +1 -0
  33. package/dist/globals.css.js +92 -0
  34. package/dist/hooks/index.d.ts +5 -0
  35. package/dist/hooks/useDiagramState.d.ts +6 -0
  36. package/dist/hooks/useDiagramState.js +27 -0
  37. package/dist/hooks/useMantinePortalProps.d.ts +9 -0
  38. package/dist/hooks/useMantinePortalProps.js +9 -0
  39. package/dist/hooks/useSetState.d.ts +2 -0
  40. package/dist/hooks/useSetState.js +19 -0
  41. package/dist/hooks/useUpdateEffect.d.ts +4 -0
  42. package/dist/hooks/useUpdateEffect.js +32 -0
  43. package/dist/hooks/useXYFlow.d.ts +270 -0
  44. package/dist/hooks/useXYFlow.js +20 -0
  45. package/dist/index.d.ts +11 -0
  46. package/dist/index.js +25 -0
  47. package/dist/likec4model/LikeC4ModelContext.d.ts +3 -0
  48. package/dist/likec4model/LikeC4ModelContext.js +5 -0
  49. package/dist/likec4model/index.d.ts +2 -0
  50. package/dist/likec4model/useLikeC4ElementsTree.d.ts +12 -0
  51. package/dist/likec4model/useLikeC4ElementsTree.js +25 -0
  52. package/dist/likec4model/useLikeC4Model.d.ts +20 -0
  53. package/dist/likec4model/useLikeC4Model.js +55 -0
  54. package/dist/overlays/OverlayContext.d.ts +10 -0
  55. package/dist/overlays/OverlayContext.js +9 -0
  56. package/dist/overlays/Overlays.css.d.ts +3 -0
  57. package/dist/overlays/Overlays.css.js +7 -0
  58. package/dist/overlays/Overlays.d.ts +2 -0
  59. package/dist/overlays/Overlays.js +137 -0
  60. package/dist/overlays/edge-details/EdgeDetailsXYFlow.d.ts +5 -0
  61. package/dist/overlays/edge-details/EdgeDetailsXYFlow.js +185 -0
  62. package/dist/overlays/edge-details/SelectEdge.css.d.ts +7 -0
  63. package/dist/overlays/edge-details/SelectEdge.css.js +17 -0
  64. package/dist/overlays/edge-details/SelectEdge.d.ts +5 -0
  65. package/dist/overlays/edge-details/SelectEdge.js +129 -0
  66. package/dist/overlays/edge-details/_types.d.ts +14 -0
  67. package/dist/overlays/edge-details/use-layouted-edge-details.d.ts +21 -0
  68. package/dist/overlays/edge-details/use-layouted-edge-details.js +270 -0
  69. package/dist/overlays/edge-details/xyflow/CompoundNode.d.ts +5 -0
  70. package/dist/overlays/edge-details/xyflow/CompoundNode.js +76 -0
  71. package/dist/overlays/edge-details/xyflow/ElementNode.d.ts +5 -0
  72. package/dist/overlays/edge-details/xyflow/ElementNode.js +159 -0
  73. package/dist/overlays/edge-details/xyflow/RelationshipEdge.d.ts +3 -0
  74. package/dist/overlays/edge-details/xyflow/RelationshipEdge.js +84 -0
  75. package/dist/overlays/edge-details/xyflow/styles.css.d.ts +9 -0
  76. package/dist/overlays/edge-details/xyflow/styles.css.js +21 -0
  77. package/dist/overlays/element-details/ElementDetailsCard.css.d.ts +16 -0
  78. package/dist/overlays/element-details/ElementDetailsCard.css.js +33 -0
  79. package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -0
  80. package/dist/overlays/element-details/ElementDetailsCard.js +484 -0
  81. package/dist/overlays/element-details/TabPanelDeployments.css.d.ts +4 -0
  82. package/dist/overlays/element-details/TabPanelDeployments.css.js +11 -0
  83. package/dist/overlays/element-details/TabPanelDeployments.d.ts +7 -0
  84. package/dist/overlays/element-details/TabPanelDeployments.js +173 -0
  85. package/dist/overlays/element-details/TabPanelRelationships.css.d.ts +5 -0
  86. package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -0
  87. package/dist/overlays/element-details/TabPanelRelationships.d.ts +8 -0
  88. package/dist/overlays/element-details/TabPanelRelationships.js +157 -0
  89. package/dist/overlays/element-details/TabPanelStructure.css.d.ts +2 -0
  90. package/dist/overlays/element-details/TabPanelStructure.css.js +7 -0
  91. package/dist/overlays/element-details/TabPanelStructure.d.ts +25 -0
  92. package/dist/overlays/element-details/TabPanelStructure.js +91 -0
  93. package/dist/overlays/index.d.ts +1 -0
  94. package/dist/overlays/relationships-of/RelationshipsOverlay.d.ts +5 -0
  95. package/dist/overlays/relationships-of/RelationshipsOverlay.js +193 -0
  96. package/dist/overlays/relationships-of/RelationshipsXYFlow.d.ts +19 -0
  97. package/dist/overlays/relationships-of/RelationshipsXYFlow.js +290 -0
  98. package/dist/overlays/relationships-of/SelectElement.css.d.ts +2 -0
  99. package/dist/overlays/relationships-of/SelectElement.css.js +7 -0
  100. package/dist/overlays/relationships-of/SelectElement.d.ts +7 -0
  101. package/dist/overlays/relationships-of/SelectElement.js +126 -0
  102. package/dist/overlays/relationships-of/_types.d.ts +28 -0
  103. package/dist/overlays/relationships-of/use-layouted-relationships.d.ts +22 -0
  104. package/dist/overlays/relationships-of/use-layouted-relationships.js +496 -0
  105. package/dist/overlays/relationships-of/xyflow/CompoundNode.d.ts +6 -0
  106. package/dist/overlays/relationships-of/xyflow/CompoundNode.js +120 -0
  107. package/dist/overlays/relationships-of/xyflow/ElementNode.d.ts +6 -0
  108. package/dist/overlays/relationships-of/xyflow/ElementNode.js +194 -0
  109. package/dist/overlays/relationships-of/xyflow/EmptyNode.d.ts +5 -0
  110. package/dist/overlays/relationships-of/xyflow/EmptyNode.js +18 -0
  111. package/dist/overlays/relationships-of/xyflow/RelationshipEdge.d.ts +3 -0
  112. package/dist/overlays/relationships-of/xyflow/RelationshipEdge.js +123 -0
  113. package/dist/overlays/relationships-of/xyflow/styles.css.d.ts +14 -0
  114. package/dist/overlays/relationships-of/xyflow/styles.css.js +24 -0
  115. package/dist/overlays/shared/xyflow/RelationshipEdge.css.d.ts +4 -0
  116. package/dist/overlays/shared/xyflow/RelationshipEdge.css.js +12 -0
  117. package/dist/overlays/shared/xyflow/_types.d.ts +77 -0
  118. package/dist/state/DiagramContext.d.ts +1609 -0
  119. package/dist/state/DiagramContext.js +101 -0
  120. package/dist/state/aligners.d.ts +42 -0
  121. package/dist/state/aligners.js +349 -0
  122. package/dist/state/diagram-to-xyflow.d.ts +11 -0
  123. package/dist/state/diagram-to-xyflow.js +113 -0
  124. package/dist/state/diagramStore.d.ts +1705 -0
  125. package/dist/state/diagramStore.js +808 -0
  126. package/dist/state/diagramStore.layout.d.ts +4 -0
  127. package/dist/state/diagramStore.layout.js +56 -0
  128. package/dist/style.css +1 -0
  129. package/dist/theme-vars.css.d.ts +72 -0
  130. package/dist/theme-vars.css.js +6 -0
  131. package/dist/theme-vars.css.ts.vanilla.css.js +1 -0
  132. package/dist/theme-vars.d.ts +3 -0
  133. package/dist/theme-vars.js +5 -0
  134. package/dist/ui/DiagramTitlePanel.css.d.ts +4 -0
  135. package/dist/ui/DiagramTitlePanel.css.js +11 -0
  136. package/dist/ui/DiagramTitlePanel.d.ts +1 -0
  137. package/dist/ui/DiagramTitlePanel.js +159 -0
  138. package/dist/ui/DynamicViewWalkthrough.css.d.ts +4 -0
  139. package/dist/ui/DynamicViewWalkthrough.css.js +11 -0
  140. package/dist/ui/DynamicViewWalkthrough.d.ts +1 -0
  141. package/dist/ui/DynamicViewWalkthrough.js +156 -0
  142. package/dist/ui/EnsureMantine.d.ts +7 -0
  143. package/dist/ui/EnsureMantine.js +14 -0
  144. package/dist/ui/FramerMotionConfig.d.ts +2 -0
  145. package/dist/ui/FramerMotionConfig.js +14 -0
  146. package/dist/ui/Link.d.ts +4 -0
  147. package/dist/ui/Link.js +36 -0
  148. package/dist/ui/notation/NotationPanel.css.d.ts +6 -0
  149. package/dist/ui/notation/NotationPanel.css.js +16 -0
  150. package/dist/ui/notation/NotationPanel.d.ts +1 -0
  151. package/dist/ui/notation/NotationPanel.js +250 -0
  152. package/dist/ui/notation/index.d.ts +1 -0
  153. package/dist/ui/top-left/ChangeAutoLayoutButton.d.ts +2 -0
  154. package/dist/ui/top-left/ChangeAutoLayoutButton.js +159 -0
  155. package/dist/ui/top-left/ManualLayoutToolsButton.d.ts +2 -0
  156. package/dist/ui/top-left/ManualLayoutToolsButton.js +137 -0
  157. package/dist/ui/top-left/TopLeftPanel.d.ts +4 -0
  158. package/dist/ui/top-left/TopLeftPanel.js +211 -0
  159. package/dist/ui/top-left/_shared.d.ts +7 -0
  160. package/dist/ui/top-left/_shared.js +22 -0
  161. package/dist/ui/top-left/styles.css.d.ts +8 -0
  162. package/dist/ui/top-left/styles.css.js +17 -0
  163. package/dist/utils/types.d.ts +8 -0
  164. package/dist/utils/vector.d.ts +24 -0
  165. package/dist/utils/vector.js +55 -0
  166. package/dist/xyflow/EdgeMarkers.d.ts +12 -0
  167. package/dist/xyflow/EdgeMarkers.js +192 -0
  168. package/dist/xyflow/FitviewOnDiagramChange.d.ts +4 -0
  169. package/dist/xyflow/FitviewOnDiagramChange.js +72 -0
  170. package/dist/xyflow/SelectEdgesOnNodeFocus.d.ts +1 -0
  171. package/dist/xyflow/SelectEdgesOnNodeFocus.js +96 -0
  172. package/dist/xyflow/XYFlow.d.ts +8 -0
  173. package/dist/xyflow/XYFlow.js +145 -0
  174. package/dist/xyflow/XYFlowBackground.d.ts +10 -0
  175. package/dist/xyflow/XYFlowBackground.js +25 -0
  176. package/dist/xyflow/XYFlowInner.d.ts +8 -0
  177. package/dist/xyflow/XYFlowInner.js +41 -0
  178. package/dist/xyflow/const.d.ts +7 -0
  179. package/dist/xyflow/const.js +12 -0
  180. package/dist/xyflow/edges/EdgeLabel.d.ts +7 -0
  181. package/dist/xyflow/edges/EdgeLabel.js +160 -0
  182. package/dist/xyflow/edges/RelationshipEdge.d.ts +6 -0
  183. package/dist/xyflow/edges/RelationshipEdge.js +443 -0
  184. package/dist/xyflow/edges/RelationshipsDropdownMenu.css.d.ts +4 -0
  185. package/dist/xyflow/edges/RelationshipsDropdownMenu.css.js +11 -0
  186. package/dist/xyflow/edges/RelationshipsDropdownMenu.d.ts +13 -0
  187. package/dist/xyflow/edges/RelationshipsDropdownMenu.js +211 -0
  188. package/dist/xyflow/edges/edges.css.d.ts +17 -0
  189. package/dist/xyflow/edges/edges.css.js +37 -0
  190. package/dist/xyflow/edges/utils.d.ts +16 -0
  191. package/dist/xyflow/edges/utils.js +24 -0
  192. package/dist/xyflow/nodes/AnimateVariants.d.ts +1313 -0
  193. package/dist/xyflow/nodes/AnimateVariants.js +123 -0
  194. package/dist/xyflow/nodes/Node.css.d.ts +3 -0
  195. package/dist/xyflow/nodes/Node.css.js +9 -0
  196. package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +14 -0
  197. package/dist/xyflow/nodes/compound/CompoundNode.css.js +27 -0
  198. package/dist/xyflow/nodes/compound/CompoundNode.d.ts +6 -0
  199. package/dist/xyflow/nodes/compound/CompoundNode.js +216 -0
  200. package/dist/xyflow/nodes/compound/index.d.ts +1 -0
  201. package/dist/xyflow/nodes/element/ElementLink.css.d.ts +3 -0
  202. package/dist/xyflow/nodes/element/ElementLink.d.ts +6 -0
  203. package/dist/xyflow/nodes/element/ElementNode.d.ts +6 -0
  204. package/dist/xyflow/nodes/element/ElementNode.js +190 -0
  205. package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +17 -0
  206. package/dist/xyflow/nodes/element/ElementShapeSvg.js +175 -0
  207. package/dist/xyflow/nodes/element/element.css.d.ts +18 -0
  208. package/dist/xyflow/nodes/element/element.css.js +31 -0
  209. package/dist/xyflow/nodes/element/index.d.ts +1 -0
  210. package/dist/xyflow/nodes/shared/ElementIcon.d.ts +8 -0
  211. package/dist/xyflow/nodes/shared/ElementIcon.js +38 -0
  212. package/dist/xyflow/nodes/shared/Toolbar.d.ts +9 -0
  213. package/dist/xyflow/nodes/shared/Toolbar.js +436 -0
  214. package/dist/xyflow/types.d.ts +36 -0
  215. package/dist/xyflow/useLayoutConstraints.d.ts +42 -0
  216. package/dist/xyflow/useLayoutConstraints.js +226 -0
  217. package/dist/xyflow/useXYFlowEvents.d.ts +160 -0
  218. package/dist/xyflow/useXYFlowEvents.js +275 -0
  219. package/dist/xyflow/utils.d.ts +22 -0
  220. package/dist/xyflow/utils.js +72 -0
  221. package/package.json +34 -27
  222. package/src/LikeC4Diagram.tsx +4 -4
  223. package/src/LikeC4Search.css.ts +12 -0
  224. package/src/LikeC4Search.tsx +39 -90
  225. package/src/controls/Text.ts +5 -0
  226. package/src/controls/action-button-bar/ActionButtonBar.css.ts +13 -0
  227. package/src/controls/action-button-bar/ActionButtonBar.tsx +138 -0
  228. package/src/controls/action-button-bar/useActionButtonBarCtx.ts +13 -0
  229. package/src/controls/action-buttons/ActionButton.css.ts +29 -0
  230. package/src/controls/action-buttons/ActionButton.tsx +66 -0
  231. package/src/controls/action-buttons/ActionButtons.tsx +138 -0
  232. package/src/hooks/useXYFlow.ts +8 -8
  233. package/src/index.ts +12 -6
  234. package/src/likec4model/index.ts +12 -2
  235. package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -12
  236. package/src/overlays/edge-details/_types.ts +13 -37
  237. package/src/overlays/edge-details/use-layouted-edge-details.ts +16 -14
  238. package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
  239. package/src/overlays/edge-details/xyflow/ElementNode.tsx +4 -11
  240. package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +3 -3
  241. package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
  242. package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +23 -23
  243. package/src/overlays/relationships-of/_types.ts +20 -58
  244. package/src/overlays/relationships-of/use-layouted-relationships.ts +36 -40
  245. package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +9 -13
  246. package/src/overlays/relationships-of/xyflow/ElementNode.tsx +12 -15
  247. package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
  248. package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -14
  249. package/src/overlays/shared/xyflow/RelationshipEdge.css.ts +60 -0
  250. package/src/overlays/shared/xyflow/_types.ts +87 -0
  251. package/src/state/diagram-to-xyflow.ts +6 -7
  252. package/src/state/diagramStore.layout.ts +3 -4
  253. package/src/state/diagramStore.ts +35 -37
  254. package/src/theme-vars.css.ts +81 -0
  255. package/src/theme-vars.ts +8 -81
  256. package/src/ui/DiagramTitlePanel.tsx +6 -6
  257. package/src/utils/types.ts +6 -0
  258. package/src/xyflow/SelectEdgesOnNodeFocus.tsx +3 -3
  259. package/src/xyflow/XYFlow.tsx +2 -2
  260. package/src/xyflow/edges/EdgeLabel.tsx +25 -18
  261. package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
  262. package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +3 -3
  263. package/src/xyflow/edges/edges.css.ts +68 -74
  264. package/src/xyflow/edges/utils.ts +6 -6
  265. package/src/xyflow/nodes/AnimateVariants.ts +143 -0
  266. package/src/xyflow/nodes/Node.css.ts +44 -0
  267. package/src/xyflow/nodes/compound/CompoundNode.css.ts +1 -64
  268. package/src/xyflow/nodes/compound/CompoundNode.tsx +69 -182
  269. package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
  270. package/src/xyflow/nodes/element/ElementNode.tsx +64 -266
  271. package/src/xyflow/nodes/element/element.css.ts +0 -57
  272. package/src/xyflow/nodes/shared/Toolbar.tsx +30 -30
  273. package/src/xyflow/types.ts +48 -51
  274. package/src/xyflow/useLayoutConstraints.ts +9 -9
  275. package/src/xyflow/useXYFlowEvents.ts +13 -30
  276. package/src/xyflow/utils.ts +2 -2
  277. package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
@@ -1,130 +1,30 @@
1
- import { DiagramNode, type ThemeColor } from '@likec4/core'
2
- import { ActionIcon, type ActionIconProps, Box, Text as MantineText, Tooltip } from '@mantine/core'
1
+ import { type ThemeColor, DiagramNode } from '@likec4/core'
2
+ import { Box } from '@mantine/core'
3
3
  import { useDebouncedValue } from '@mantine/hooks'
4
- import { IconId, IconTransform, IconZoomScan } from '@tabler/icons-react'
5
- import { Handle, type NodeProps, Position } from '@xyflow/react'
4
+ import { type NodeProps, Handle, Position } from '@xyflow/react'
6
5
  import clsx from 'clsx'
7
6
  import { deepEqual as eq } from 'fast-equals'
8
- import { type HTMLMotionProps, m, type Variants } from 'framer-motion'
9
- import React, { memo, type PropsWithoutRef, useCallback, useState } from 'react'
10
- import { isNumber, isTruthy } from 'remeda'
7
+ import { m } from 'framer-motion'
8
+ import { memo, useState } from 'react'
9
+ import { isTruthy } from 'remeda'
10
+ import { ActionButtonBar } from '../../../controls/action-button-bar/ActionButtonBar'
11
+ import {
12
+ BrowseRelationshipsButton,
13
+ NavigateToButton,
14
+ OpenDetailsButton,
15
+ } from '../../../controls/action-buttons/ActionButtons'
16
+ import { Text } from '../../../controls/Text'
11
17
  import { useDiagramState } from '../../../hooks/useDiagramState'
12
- import type { ElementXYFlowNode } from '../../types'
13
- import { stopPropagation, toDomPrecision } from '../../utils'
18
+ import type { DiagramFlowTypes } from '../../types'
19
+ import { toDomPrecision } from '../../utils'
20
+ import { type VariantKeys, NodeVariants, useFramerAnimateVariants } from '../AnimateVariants'
21
+ import * as nodeCss from '../Node.css'
14
22
  import { ElementIcon } from '../shared/ElementIcon'
15
23
  import { ElementToolbar } from '../shared/Toolbar'
16
- import { useFramerAnimateVariants } from '../use-animate-variants'
17
24
  import * as css from './element.css'
18
25
  import { ElementShapeSvg, SelectedIndicator } from './ElementShapeSvg'
19
26
 
20
- const Text = MantineText.withProps({
21
- component: 'div'
22
- })
23
-
24
- const selectedScale = 1.015
25
-
26
- // Frame-motion variants
27
-
28
- const VariantsRoot = {
29
- idle: (_, { scale }) => ({
30
- scale: 1,
31
- transition: isNumber(scale) && scale > selectedScale
32
- ? {
33
- delay: 0.1,
34
- delayChildren: 0.06
35
- // staggerChildren: 0.07,
36
- // staggerDirection: -1
37
- }
38
- : {}
39
- }),
40
- selected: {
41
- scale: selectedScale
42
- },
43
- hovered: (_, { scale }) => ({
44
- scale: 1.06,
45
- transition: !isNumber(scale) || (scale >= 1 && scale < 1.06)
46
- ? {
47
- // delay: 0.09,
48
- delayChildren: 0.08
49
- }
50
- : {}
51
- }),
52
- tap: {
53
- scale: 0.975
54
- }
55
- } satisfies Variants
56
-
57
- const variantsBottomButton = (target: 'navigate' | 'relationships', align: 'left' | 'right' | false) => {
58
- const variants = {
59
- idle: {
60
- '--icon-scale': 'scale(1)',
61
- '--ai-bg': 'var(--ai-bg-idle)',
62
- scale: 1,
63
- opacity: 0.5,
64
- originX: 0.5,
65
- originY: 0.35,
66
- translateY: 0,
67
- ...align === 'left' && {
68
- originX: 0.75,
69
- translateX: -1
70
- },
71
- ...align === 'right' && {
72
- originX: 0.25,
73
- translateX: 1
74
- }
75
- },
76
- selected: {},
77
- hovered: {
78
- '--icon-scale': 'scale(1)',
79
- '--ai-bg': 'var(--ai-bg-hover)',
80
- translateY: 3,
81
- scale: 1.32,
82
- opacity: 1,
83
- ...align === 'left' && {
84
- translateX: -4
85
- },
86
- ...align === 'right' && {
87
- translateX: 4
88
- }
89
- },
90
- 'hovered:details': {},
91
- [`hovered:${target}`]: {
92
- '--icon-scale': 'scale(1.08)',
93
- scale: 1.45
94
- },
95
- [`tap:${target}`]: {
96
- scale: 1.15
97
- }
98
- } satisfies Variants
99
- variants['selected'] = variants['hovered']
100
- variants['hovered:details'] = variants.idle
101
- return variants
102
- }
103
-
104
- const VariantsDetailsBtn = {
105
- idle: {
106
- '--ai-bg': 'var(--ai-bg-idle)',
107
- scale: 1,
108
- opacity: 0.5,
109
- originX: 0.45,
110
- originY: 0.55
111
- },
112
- selected: {},
113
- hovered: {
114
- scale: 1.2,
115
- opacity: 0.7
116
- },
117
- 'hovered:details': {
118
- scale: 1.44,
119
- opacity: 1
120
- },
121
- 'tap:details': {
122
- scale: 1.15
123
- }
124
- } satisfies Variants
125
- VariantsDetailsBtn['selected'] = VariantsDetailsBtn['hovered']
126
-
127
- type ElementNodeProps = NodeProps<ElementXYFlowNode>
27
+ type ElementNodeProps = NodeProps<DiagramFlowTypes.ElementNode>
128
28
  const isEqualProps = (prev: ElementNodeProps, next: ElementNodeProps) => (
129
29
  prev.id === next.id
130
30
  && eq(prev.selected ?? false, next.selected ?? false)
@@ -137,52 +37,43 @@ const isEqualProps = (prev: ElementNodeProps, next: ElementNodeProps) => (
137
37
  export const ElementNodeMemo = memo<ElementNodeProps>(function ElementNode({
138
38
  id,
139
39
  data: {
140
- element
40
+ element,
141
41
  },
142
42
  dragging,
143
43
  selected = false,
144
44
  width,
145
- height
45
+ height,
146
46
  }) {
147
47
  const modelRef = DiagramNode.modelRef(element)
148
48
  // const deploymentRef = DiagramNode.deploymentRef(element)
149
49
  const {
150
50
  viewId,
151
51
  isEditable,
152
- isHovered,
153
52
  isDimmed,
154
53
  isNavigable,
155
54
  isInteractive,
156
55
  enableElementDetails,
157
56
  enableRelationshipBrowser,
158
- triggerOnNavigateTo,
159
- openOverlay,
160
57
  isInActiveOverlay,
161
- renderIcon
58
+ renderIcon,
162
59
  } = useDiagramState(s => ({
163
60
  viewId: s.view.id,
164
61
  isEditable: s.readonly !== true,
165
- isHovered: s.hoveredNodeId === id,
166
62
  isDimmed: s.dimmed.has(id),
167
63
  isInteractive: s.nodesDraggable || s.nodesSelectable || s.enableElementDetails || s.enableRelationshipBrowser
168
64
  || (!!s.onNavigateTo && !!element.navigateTo),
169
65
  isNavigable: (!!s.onNavigateTo && !!element.navigateTo),
170
66
  enableElementDetails: s.enableElementDetails,
171
67
  enableRelationshipBrowser: s.enableRelationshipBrowser,
172
- triggerOnNavigateTo: s.triggerOnNavigateTo,
173
68
  openOverlay: s.openOverlay,
174
69
  isInActiveOverlay: (s.activeOverlay?.elementDetails ?? s.activeOverlay?.relationshipsOf) === id,
175
- renderIcon: s.renderIcon
70
+ renderIcon: s.renderIcon,
176
71
  }))
177
- // For development purposes, show the toolbar when the element is selected
178
- const isHoveredOrSelected = isHovered || (import.meta.env.DEV && selected)
179
- const _isToolbarVisible = isEditable && isHoveredOrSelected
180
- const [isToolbarVisible] = useDebouncedValue(_isToolbarVisible, _isToolbarVisible ? 500 : 300)
181
72
 
182
73
  const w = toDomPrecision(width ?? element.width)
183
74
  const h = toDomPrecision(height ?? element.height)
184
75
 
185
- let animateVariant: keyof typeof VariantsRoot | string[]
76
+ let animateVariant: VariantKeys | string[]
186
77
  switch (true) {
187
78
  case isInActiveOverlay:
188
79
  animateVariant = 'idle'
@@ -193,8 +84,8 @@ export const ElementNodeMemo = memo<ElementNodeProps>(function ElementNode({
193
84
  case dragging:
194
85
  animateVariant = 'idle'
195
86
  break
196
- case isInteractive && isHovered:
197
- animateVariant = 'hovered'
87
+ case isDimmed:
88
+ animateVariant = 'dimmed'
198
89
  break
199
90
  case selected:
200
91
  animateVariant = 'selected'
@@ -202,53 +93,34 @@ export const ElementNodeMemo = memo<ElementNodeProps>(function ElementNode({
202
93
  default:
203
94
  animateVariant = 'idle'
204
95
  }
96
+
205
97
  const [animateVariants, animateHandlers] = useFramerAnimateVariants()
206
- if (isHovered && !dragging && !isInActiveOverlay) {
98
+ if (!dragging && !isInActiveOverlay) {
207
99
  animateVariant = animateVariants ?? animateVariant
208
100
  }
209
101
 
102
+ const isHovered = !!animateVariants && animateVariants.includes('hovered')
103
+
104
+ const _isToolbarVisible = (selected && !dragging) || isHovered
105
+ const [isToolbarVisible] = useDebouncedValue(_isToolbarVisible, _isToolbarVisible ? 500 : 300)
106
+
210
107
  const elementIcon = ElementIcon({
211
108
  element,
212
109
  viewId,
213
110
  className: css.elementIcon,
214
- renderIcon
111
+ renderIcon,
215
112
  })
216
113
 
217
114
  const [previewColor, setPreviewColor] = useState<ThemeColor | null>(null)
218
115
 
219
- const onNavigateTo = useCallback((e: React.MouseEvent) => {
220
- e.stopPropagation()
221
- triggerOnNavigateTo(id, e)
222
- }, [triggerOnNavigateTo, id])
223
-
224
- const onOpenDetails = useCallback((e: React.MouseEvent) => {
225
- e.stopPropagation()
226
- openOverlay({ elementDetails: element.id })
227
- }, [openOverlay, element.id])
228
-
229
- const onOpenRelationships = useCallback((e: React.MouseEvent) => {
230
- if (modelRef) {
231
- e.stopPropagation()
232
- openOverlay({ relationshipsOf: modelRef })
233
- }
234
- }, [openOverlay, modelRef])
235
-
236
116
  return (
237
117
  <>
238
- {isToolbarVisible && (
239
- <ElementToolbar
240
- element={element}
241
- isVisible={isToolbarVisible}
242
- onColorPreview={setPreviewColor}
243
- />
244
- )}
245
118
  <Box
246
119
  component={m.div}
247
120
  className={clsx([
248
121
  css.container,
249
- isDimmed && css.dimmed,
250
122
  animateVariant !== 'idle' && css.containerAnimated,
251
- 'likec4-element-node'
123
+ 'likec4-element-node',
252
124
  ])}
253
125
  key={`${viewId}:element:${id}`}
254
126
  layoutId={`${viewId}:element:${id}`}
@@ -257,15 +129,19 @@ export const ElementNodeMemo = memo<ElementNodeProps>(function ElementNode({
257
129
  data-likec4-shape={element.shape}
258
130
  data-animate-target=""
259
131
  initial={false}
260
- variants={VariantsRoot}
132
+ variants={NodeVariants(w, h)}
261
133
  animate={animateVariant}
134
+ {...isInteractive && animateHandlers}
262
135
  tabIndex={-1}
263
- {...(isInteractive && {
264
- onTapStart: animateHandlers.onTapStart,
265
- onTap: animateHandlers.onTap,
266
- onTapCancel: animateHandlers.onTapCancel
267
- })}
268
136
  >
137
+ {isEditable && (
138
+ <ElementToolbar
139
+ element={element}
140
+ isVisible={isToolbarVisible}
141
+ align="start"
142
+ onColorPreview={setPreviewColor}
143
+ />
144
+ )}
269
145
  <svg
270
146
  className={clsx(css.shapeSvg)}
271
147
  viewBox={`0 0 ${w} ${h}`}>
@@ -278,7 +154,7 @@ export const ElementNodeMemo = memo<ElementNodeProps>(function ElementNode({
278
154
  className={clsx(
279
155
  css.elementDataContainer,
280
156
  isTruthy(elementIcon) && css.hasIcon,
281
- 'likec4-element'
157
+ 'likec4-element',
282
158
  )}
283
159
  >
284
160
  {elementIcon}
@@ -303,37 +179,26 @@ export const ElementNodeMemo = memo<ElementNodeProps>(function ElementNode({
303
179
  )}
304
180
  </Box>
305
181
  </Box>
306
- {/* {isHovercards && element.links && <ElementLink element={element} />} */}
307
- <BottomButtons
308
- keyPrefix={`${viewId}:element:${id}:`}
309
- onNavigateTo={isNavigable && onNavigateTo}
310
- onOpenRelationships={enableRelationshipBrowser && !!modelRef && onOpenRelationships}
311
- {...isInteractive && animateHandlers}
312
- />
182
+ <Box className={clsx(nodeCss.bottomBtnContainer)}>
183
+ <ActionButtonBar shiftY="bottom">
184
+ {isNavigable && (
185
+ <NavigateToButton
186
+ xynodeId={id}
187
+ {...isInteractive && animateHandlers}
188
+ />
189
+ )}
190
+ {enableRelationshipBrowser && !!modelRef && (
191
+ <BrowseRelationshipsButton
192
+ fqn={modelRef}
193
+ {...isInteractive && animateHandlers}
194
+ />
195
+ )}
196
+ </ActionButtonBar>
197
+ </Box>
313
198
  {enableElementDetails && !!modelRef && (
314
- <Tooltip
315
- fz="xs"
316
- color="dark"
317
- label="Open details"
318
- withinPortal={false}
319
- offset={2}
320
- openDelay={600}>
321
- <ActionIcon
322
- key="details"
323
- component={m.div}
324
- variants={VariantsDetailsBtn}
325
- data-animate-target="details"
326
- className={clsx('nodrag nopan', css.detailsBtn)}
327
- radius="md"
328
- style={{ zIndex: 100 }}
329
- role="button"
330
- onClick={onOpenDetails}
331
- onDoubleClick={stopPropagation}
332
- {...isInteractive && animateHandlers}
333
- >
334
- <IconId stroke={1.8} style={{ width: '75%' }} />
335
- </ActionIcon>
336
- </Tooltip>
199
+ <Box className={clsx(nodeCss.topRightBtnContainer)}>
200
+ <OpenDetailsButton fqn={modelRef} {...isInteractive && animateHandlers} />
201
+ </Box>
337
202
  )}
338
203
  </Box>
339
204
  <Handle type="target" position={Position.Top} className={css.handleCenter} />
@@ -341,70 +206,3 @@ export const ElementNodeMemo = memo<ElementNodeProps>(function ElementNode({
341
206
  </>
342
207
  )
343
208
  }, isEqualProps)
344
-
345
- type BottomButtonsProps = PropsWithoutRef<
346
- ActionIconProps & HTMLMotionProps<'div'> & {
347
- keyPrefix: string
348
- onNavigateTo: ((e: React.MouseEvent) => void) | false
349
- onOpenRelationships: ((e: React.MouseEvent) => void) | false
350
- }
351
- >
352
- const BottomButtons = ({
353
- keyPrefix,
354
- onNavigateTo,
355
- onOpenRelationships,
356
- ...props
357
- }: BottomButtonsProps) => {
358
- const enableRelationships = !!onOpenRelationships
359
- const enableNavigate = !!onNavigateTo
360
-
361
- if (!enableRelationships && !enableNavigate) {
362
- return null
363
- }
364
-
365
- return (
366
- <Box className={css.bottomButtonsContainer}>
367
- {enableNavigate && (
368
- <ActionIcon
369
- {...props}
370
- key={`${keyPrefix}navigate`}
371
- data-animate-target="navigate"
372
- component={m.div}
373
- // Weird, but dts-bundle-generator fails on "enableRelationships && 'left'"
374
- variants={variantsBottomButton('navigate', enableRelationships ? 'left' : false)}
375
- className={clsx('nodrag nopan', css.navigateBtn)}
376
- radius="md"
377
- role="button"
378
- onClick={onNavigateTo}
379
- onDoubleClick={stopPropagation}
380
- >
381
- <IconZoomScan
382
- style={{
383
- width: '70%',
384
- transform: 'var(--icon-scale)'
385
- }} />
386
- </ActionIcon>
387
- )}
388
- {enableRelationships && (
389
- <ActionIcon
390
- {...props}
391
- key={`${keyPrefix}relationships`}
392
- data-animate-target="relationships"
393
- component={m.div}
394
- variants={variantsBottomButton('relationships', enableNavigate ? 'right' : false)}
395
- className={clsx('nodrag nopan', css.navigateBtn)}
396
- radius="md"
397
- role="button"
398
- onClick={onOpenRelationships}
399
- onDoubleClick={stopPropagation}
400
- >
401
- <IconTransform
402
- style={{
403
- width: '70%',
404
- transform: 'var(--icon-scale)'
405
- }} />
406
- </ActionIcon>
407
- )}
408
- </Box>
409
- )
410
- }
@@ -21,9 +21,6 @@ export const container = style({
21
21
  selectors: {
22
22
  ':where(.react-flow__node.selected) &': {
23
23
  willChange: 'transform'
24
- },
25
- '&[data-hovered="true"]': {
26
- willChange: 'transform'
27
24
  }
28
25
  },
29
26
  // Catch pointer below the element
@@ -49,16 +46,6 @@ export const containerAnimated = style({
49
46
  willChange: 'transform'
50
47
  })
51
48
 
52
- export const dimmed = style({})
53
-
54
- globalStyle(`.react-flow__node-element:has(${dimmed})`, {
55
- opacity: 0.25,
56
- transition: 'opacity 400ms ease-in-out, filter 500ms ease-in-out',
57
- transitionDelay: '50ms',
58
- filter: `grayscale(0.85) ${fallbackVar(vars.safariAnimationHook, 'blur(2px)')}`,
59
- willChange: 'opacity, filter'
60
- })
61
-
62
49
  const indicatorKeyframes = keyframes({
63
50
  'from': {
64
51
  strokeOpacity: 0.8
@@ -106,10 +93,6 @@ export const indicator = style({
106
93
  vars: {
107
94
  [indicatorStroke]: `color-mix(in srgb, ${vars.element.fill} 50%, #3c3c3c)`
108
95
  }
109
- },
110
- [`${dimmed} &`]: {
111
- visibility: 'hidden',
112
- display: 'none'
113
96
  }
114
97
  }
115
98
  })
@@ -302,10 +285,6 @@ export const shapeSvgMultiple = style({
302
285
  },
303
286
  ':where([data-likec4-shape="queue"]) &': {
304
287
  transform: 'translate(-10px,8px)'
305
- },
306
- ':where([data-hovered="true"]) &': {
307
- transition: 'opacity 300ms ease-in',
308
- opacity: 0.2
309
288
  }
310
289
  }
311
290
  })
@@ -388,39 +367,3 @@ export const bottomButtonsContainer = style({
388
367
  // transitionDelay: '20ms',
389
368
  // gap: 16
390
369
  // })
391
-
392
- const btn = style({
393
- pointerEvents: 'all',
394
- color: vars.element.loContrast,
395
- cursor: 'pointer',
396
- backgroundColor: 'var(--ai-bg)',
397
- 'vars': {
398
- '--ai-bg-idle': `color-mix(in srgb , ${vars.element.fill}, transparent 99%)`,
399
- '--ai-bg': `var(--ai-bg-idle)`,
400
- '--ai-bg-hover': `color-mix(in srgb , ${vars.element.fill} 65%, ${vars.element.stroke})`,
401
- '--ai-hover': `color-mix(in srgb , ${vars.element.fill} 50%, ${vars.element.stroke})`
402
- },
403
- ':hover': {
404
- boxShadow: mantine.shadows.md
405
- }
406
- })
407
-
408
- export const navigateBtn = style([btn, {}])
409
-
410
- export const detailsBtn = style([btn, {
411
- position: 'absolute',
412
- top: 2,
413
- right: 2,
414
- selectors: {
415
- [`:where([data-likec4-shape='browser']) &`]: {
416
- right: 5
417
- },
418
- ':where([data-likec4-shape="cylinder"], [data-likec4-shape="storage"]) &': {
419
- top: 14
420
- },
421
- ':where([data-likec4-shape="queue"]) &': {
422
- top: 1,
423
- right: 12
424
- }
425
- }
426
- }])