@likec4/diagram 1.17.1 → 1.19.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 (300) 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 +40 -31
  222. package/src/LikeC4Diagram.props.ts +21 -12
  223. package/src/LikeC4Diagram.tsx +8 -10
  224. package/src/LikeC4Search.css.ts +12 -0
  225. package/src/LikeC4Search.tsx +45 -93
  226. package/src/controls/Text.ts +5 -0
  227. package/src/controls/action-button-bar/ActionButtonBar.css.ts +13 -0
  228. package/src/controls/action-button-bar/ActionButtonBar.tsx +138 -0
  229. package/src/controls/action-button-bar/useActionButtonBarCtx.ts +13 -0
  230. package/src/controls/action-buttons/ActionButton.css.ts +29 -0
  231. package/src/controls/action-buttons/ActionButton.tsx +66 -0
  232. package/src/controls/action-buttons/ActionButtons.tsx +138 -0
  233. package/src/hooks/useDiagramState.ts +8 -3
  234. package/src/hooks/useXYFlow.ts +9 -8
  235. package/src/index.ts +12 -6
  236. package/src/likec4model/index.ts +12 -2
  237. package/src/likec4model/useLikeC4ElementsTree.ts +6 -13
  238. package/src/likec4model/useLikeC4Model.ts +21 -11
  239. package/src/overlays/Overlays.tsx +96 -63
  240. package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -10
  241. package/src/overlays/edge-details/_types.ts +13 -33
  242. package/src/overlays/edge-details/use-layouted-edge-details.ts +35 -26
  243. package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
  244. package/src/overlays/edge-details/xyflow/ElementNode.tsx +8 -13
  245. package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +7 -7
  246. package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
  247. package/src/overlays/element-details/ElementDetailsCard.tsx +91 -78
  248. package/src/overlays/element-details/TabPanelDeployments.css.ts +69 -0
  249. package/src/overlays/element-details/TabPanelDeployments.tsx +217 -0
  250. package/src/overlays/element-details/TabPanelRelationships.tsx +8 -9
  251. package/src/overlays/element-details/TabPanelStructure.tsx +10 -10
  252. package/src/overlays/relationships-of/RelationshipsOverlay.tsx +1 -1
  253. package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +26 -34
  254. package/src/overlays/relationships-of/SelectElement.tsx +2 -2
  255. package/src/overlays/relationships-of/_types.ts +20 -58
  256. package/src/overlays/relationships-of/use-layouted-relationships.ts +54 -59
  257. package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +10 -16
  258. package/src/overlays/relationships-of/xyflow/ElementNode.tsx +24 -21
  259. package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
  260. package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -15
  261. package/src/overlays/shared/xyflow/RelationshipEdge.css.ts +60 -0
  262. package/src/overlays/shared/xyflow/_types.ts +87 -0
  263. package/src/state/diagram-to-xyflow.ts +6 -7
  264. package/src/state/diagramStore.layout.ts +3 -4
  265. package/src/state/diagramStore.ts +63 -48
  266. package/src/theme-vars.css.ts +81 -0
  267. package/src/theme-vars.ts +8 -81
  268. package/src/ui/DiagramTitlePanel.tsx +7 -34
  269. package/src/ui/Link.tsx +40 -0
  270. package/src/ui/notation/NotationPanel.tsx +4 -2
  271. package/src/ui/top-left/ChangeAutoLayoutButton.tsx +2 -2
  272. package/src/ui/top-left/TopLeftPanel.tsx +5 -5
  273. package/src/utils/types.ts +6 -0
  274. package/src/xyflow/SelectEdgesOnNodeFocus.tsx +3 -3
  275. package/src/xyflow/XYFlow.tsx +2 -2
  276. package/src/xyflow/edges/EdgeLabel.tsx +26 -19
  277. package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
  278. package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +23 -10
  279. package/src/xyflow/edges/edges.css.ts +68 -74
  280. package/src/xyflow/edges/utils.ts +6 -6
  281. package/src/xyflow/nodes/AnimateVariants.ts +143 -0
  282. package/src/xyflow/nodes/Node.css.ts +44 -0
  283. package/src/xyflow/nodes/compound/CompoundNode.css.ts +27 -75
  284. package/src/xyflow/nodes/compound/CompoundNode.tsx +82 -163
  285. package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
  286. package/src/xyflow/nodes/element/ElementNode.tsx +73 -252
  287. package/src/xyflow/nodes/element/element.css.ts +40 -64
  288. package/src/xyflow/nodes/shared/ElementIcon.tsx +1 -1
  289. package/src/xyflow/nodes/shared/Toolbar.tsx +51 -35
  290. package/src/xyflow/types.ts +48 -51
  291. package/src/xyflow/useLayoutConstraints.ts +10 -10
  292. package/src/xyflow/useXYFlowEvents.ts +31 -35
  293. package/src/xyflow/utils.ts +2 -2
  294. package/src/ui/OptionsPanel.css.ts +0 -9
  295. package/src/ui/OptionsPanel.tsx +0 -70
  296. package/src/ui/options/EdgeOptions.tsx +0 -142
  297. package/src/ui/options/NodeOptions.tsx +0 -362
  298. package/src/xyflow/nodes/element/ElementDetails.css.ts +0 -101
  299. package/src/xyflow/nodes/element/ElementDetails.tsx +0 -393
  300. package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
@@ -1,142 +0,0 @@
1
- import { DefaultRelationshipColor, defaultTheme, type NonEmptyArray, type ThemeColor } from '@likec4/core'
2
- import { CheckIcon, ColorSwatch, Divider, Flex, rem, Stack, Text, Tooltip, TooltipGroup } from '@mantine/core'
3
- import { shallowEqual } from 'fast-equals'
4
- import { memo } from 'react'
5
- import { hasAtLeast, keys, takeWhile } from 'remeda'
6
- import { useDiagramStoreApi, useXYEdgesData } from '../../hooks'
7
- import { type XYFlowEdge } from '../../xyflow/types'
8
-
9
- const {
10
- primary,
11
- secondary,
12
- muted,
13
- ...otherColors
14
- } = defaultTheme.elements
15
-
16
- export const themedColors = [
17
- { key: 'primary', value: primary.fill },
18
- { key: 'secondary', value: secondary.fill },
19
- { key: 'muted', value: muted.fill }
20
- ] satisfies Array<{ key: ThemeColor; value: string }>
21
-
22
- export const colors = keys(otherColors).map(key => ({
23
- key,
24
- value: defaultTheme.elements[key].fill
25
- }))
26
-
27
- export type ThemeColorKey = typeof themedColors[0]['key']
28
- export type ColorKey = typeof colors[0]['key']
29
-
30
- type XYEdgeData = Pick<XYFlowEdge, 'id' | 'data'>
31
-
32
- export const EdgeOptions = memo<{ selectedEdgeIds: string[] }>(({ selectedEdgeIds }) => {
33
- const diagramApi = useDiagramStoreApi()
34
- const edges = useXYEdgesData(selectedEdgeIds)
35
- if (!hasAtLeast(edges, 1)) {
36
- return null
37
- }
38
- if (edges.length !== selectedEdgeIds.length) {
39
- throw new Error('EdgeOptions: edges and props.edges should have the same length')
40
- }
41
- const [firstEdge, ...rest] = edges
42
-
43
- return (
44
- <Stack gap={'xs'}>
45
- <div>
46
- <Text fz={rem(9)} fw={'500'} c={'dimmed'}>
47
- RELATIONSHIP{rest.length > 0 ? 'S' : ''}
48
- </Text>
49
- <Text size="xs" c={rest.length > 0 ? 'dimmed' : ''} truncate>
50
- {rest.length === 0 ? firstEdge.data.edge.label : `[ multiple ]`}
51
- </Text>
52
- </div>
53
- {
54
- /* {showShapeOption && (
55
- <ShapeOption
56
- nodes={edges}
57
- onShapeChange={(shape: ElementShape) => {
58
- triggerChange({ shape })
59
- }} />
60
- )} */
61
- }
62
- <Colors
63
- edges={edges}
64
- onColorChange={(_color: ColorKey | ThemeColorKey) => {
65
- // triggerChange({ color })
66
- }} />
67
- </Stack>
68
- )
69
- }, (prevProps, nextProps) => shallowEqual(prevProps.selectedEdgeIds, nextProps.selectedEdgeIds))
70
-
71
- function Colors({
72
- edges: [firstEdge, ...edges],
73
- onColorChange
74
- }: {
75
- edges: NonEmptyArray<XYEdgeData>
76
- onColorChange: (color: ColorKey | ThemeColorKey) => void
77
- }) {
78
- let selectedColor = (firstEdge.data.edge.color ?? DefaultRelationshipColor) as ThemeColor | null
79
- takeWhile(edges, edge => {
80
- const color = edge.data.edge.color ?? DefaultRelationshipColor
81
- if (color !== selectedColor) {
82
- selectedColor = null
83
- return false
84
- }
85
- return true
86
- })
87
- const changeColor = (color: ColorKey | ThemeColorKey) => () => {
88
- if (selectedColor === color) {
89
- return
90
- }
91
- onColorChange(color)
92
- }
93
- return (
94
- <div>
95
- <TooltipGroup openDelay={400} closeDelay={300}>
96
- <Divider label="color" labelPosition="left" />
97
- <Flex mt={'xs'} maw={150} gap="xs" justify="flex-start" align="flex-start" direction="row" wrap="wrap">
98
- {themedColors.map(({ key, value }) => (
99
- <Tooltip
100
- key={key}
101
- label={key}
102
- fz={'xs'}
103
- color="dark"
104
- offset={2}
105
- transitionProps={{ duration: 140, transition: 'slide-up' }}>
106
- <ColorSwatch
107
- color={value}
108
- size={20}
109
- withShadow
110
- onClick={changeColor(key)}
111
- style={{ color: '#fff', cursor: 'pointer' }}
112
- >
113
- {selectedColor === key && <CheckIcon style={{ width: rem(12), height: rem(12) }} />}
114
- </ColorSwatch>
115
- </Tooltip>
116
- ))}
117
- </Flex>
118
-
119
- <Flex mt="sm" maw={150} gap="xs" justify="flex-start" align="flex-start" direction="row" wrap="wrap">
120
- {colors.map(({ key, value }) => (
121
- <Tooltip
122
- key={key}
123
- label={key}
124
- fz={'xs'}
125
- color="dark"
126
- offset={2}
127
- transitionProps={{ duration: 140, transition: 'slide-up' }}>
128
- <ColorSwatch
129
- color={value}
130
- size={20}
131
- onClick={changeColor(key)}
132
- style={{ color: '#fff', cursor: 'pointer' }}
133
- >
134
- {selectedColor === key && <CheckIcon style={{ width: rem(12), height: rem(12) }} />}
135
- </ColorSwatch>
136
- </Tooltip>
137
- ))}
138
- </Flex>
139
- </TooltipGroup>
140
- </div>
141
- )
142
- }
@@ -1,362 +0,0 @@
1
- import {
2
- type BorderStyle,
3
- defaultTheme,
4
- type ElementShape,
5
- ElementShapes,
6
- invariant,
7
- type NonEmptyArray,
8
- type ThemeColor,
9
- type ViewChange
10
- } from '@likec4/core'
11
- import {
12
- ActionIcon,
13
- Box,
14
- CheckIcon,
15
- ColorSwatch,
16
- Divider,
17
- Flex,
18
- Group,
19
- rem,
20
- SegmentedControl,
21
- Select,
22
- Slider,
23
- Space,
24
- Stack,
25
- Text,
26
- Tooltip,
27
- TooltipGroup
28
- } from '@mantine/core'
29
- import { IconFileSymlink } from '@tabler/icons-react'
30
- import { shallowEqual } from 'fast-equals'
31
- import { memo, useState } from 'react'
32
- import { hasAtLeast, keys, takeWhile } from 'remeda'
33
- import { useDiagramStoreApi, useXYNodesData } from '../../hooks'
34
- import { useUpdateEffect } from '../../hooks/useUpdateEffect'
35
- import { XYFlowNode } from '../../xyflow/types'
36
-
37
- const {
38
- primary,
39
- secondary,
40
- muted,
41
- ...otherColors
42
- } = defaultTheme.elements
43
-
44
- export const themedColors = [
45
- { key: 'primary', value: primary.fill },
46
- { key: 'secondary', value: secondary.fill },
47
- { key: 'muted', value: muted.fill }
48
- ] satisfies Array<{ key: ThemeColor; value: string }>
49
-
50
- export const colors = keys(otherColors).map(key => ({
51
- key,
52
- value: defaultTheme.elements[key].fill
53
- }))
54
-
55
- export type ThemeColorKey = typeof themedColors[0]['key']
56
- export type ColorKey = typeof colors[0]['key']
57
-
58
- type XYNodesData = Pick<XYFlowNode, 'id' | 'data' | 'type'>
59
-
60
- /**
61
- * @deprecated
62
- */
63
- export const NodeOptions = memo<{ selectedNodeIds: string[] }>(({ selectedNodeIds }) => {
64
- // export function NodeOptions(props: { nodes: XYFlowNode[] }) {
65
- const diagramApi = useDiagramStoreApi()
66
- // const nodes = useXYNodesData(props.nodes.map(node => node.id))
67
- const nodes = useXYNodesData(selectedNodeIds)
68
- if (!hasAtLeast(nodes, 1)) {
69
- return null
70
- }
71
- if (nodes.length !== selectedNodeIds.length) {
72
- throw new Error('NodeOptions: nodes and props.nodes should have the same length')
73
- }
74
- // Makes sense to show shape option only if there is at least one element node
75
- const showShapeOption = nodes.some(node => node.type === 'element')
76
-
77
- const [firstNode, ...rest] = nodes
78
-
79
- const showGoToSource = rest.length === 0 && diagramApi.getState().onOpenSourceElement!!
80
-
81
- // Makes sense to show opacity option only if there is at least one compound node
82
- const showOpacityOption = firstNode.type === 'compound'
83
- && (rest.length === 0 || rest.every(node => node.type === 'compound'))
84
-
85
- const triggerChange = (style: ViewChange.ChangeElementStyle['style']) => {
86
- const targets = nodes.map(node => node.data.element.id)
87
- invariant(hasAtLeast(targets, 1), 'At least one target is required')
88
- diagramApi.getState().triggerChangeElementStyle({
89
- op: 'change-element-style',
90
- style,
91
- targets
92
- })
93
- }
94
-
95
- return (
96
- <Stack gap={'xs'}>
97
- <Group wrap="nowrap" align="flex-start">
98
- <Box flex={1} miw={0}>
99
- <Text fz={rem(9)} fw={'500'} c={'dimmed'}>
100
- ELEMENT{rest.length > 0 ? 'S' : ``}
101
- </Text>
102
- <Text size="xs" c={rest.length > 0 ? 'dimmed' : ''} truncate>
103
- {rest.length === 0 ? firstNode.data.element.title : `[ multiple ]`}
104
- </Text>
105
- </Box>
106
- {showGoToSource && (
107
- <Box flex={0}>
108
- <ActionIcon
109
- size={'sm'}
110
- variant="light"
111
- color="gray"
112
- onClick={e => {
113
- e.stopPropagation()
114
- diagramApi.getState().onOpenSourceElement?.(firstNode.data.element.id)
115
- }}>
116
- <IconFileSymlink
117
- stroke={1.2}
118
- style={{
119
- width: '70%',
120
- height: '70%'
121
- }} />
122
- </ActionIcon>
123
- </Box>
124
- )}
125
- </Group>
126
- {showShapeOption && (
127
- <ShapeOption
128
- nodes={nodes}
129
- onShapeChange={(shape: ElementShape) => {
130
- triggerChange({ shape })
131
- }} />
132
- )}
133
- <Colors
134
- nodes={nodes}
135
- onColorChange={(color: ColorKey | ThemeColorKey) => {
136
- triggerChange({ color })
137
- }} />
138
-
139
- {showOpacityOption && (
140
- <div key={firstNode.id}>
141
- <Divider label="opacity and border" labelPosition="left" />
142
- <Space h={'xs'} />
143
- <OpacityOption
144
- node={firstNode}
145
- onOpacityChange={(opacity: number) => {
146
- triggerChange({ opacity })
147
- }} />
148
- <Space h={'sm'} />
149
- <BorderStyleOption
150
- node={firstNode}
151
- onChange={(border: BorderStyle) => {
152
- triggerChange({ border })
153
- }}
154
- />
155
- </div>
156
- )}
157
- <NavigateToOption nodes={nodes} />
158
- </Stack>
159
- )
160
- }, (prevProps, nextProps) => shallowEqual(prevProps.selectedNodeIds, nextProps.selectedNodeIds))
161
-
162
- function Colors({
163
- nodes: [firstNode, ...nodes],
164
- onColorChange
165
- }: {
166
- nodes: NonEmptyArray<XYNodesData>
167
- onColorChange: (color: ColorKey | ThemeColorKey) => void
168
- }) {
169
- let selectedColor = firstNode.data.element.color as ThemeColor | null
170
- takeWhile(nodes, node => {
171
- if (node.data.element.color !== selectedColor) {
172
- selectedColor = null
173
- return false
174
- }
175
- return true
176
- })
177
- const changeColor = (color: ColorKey | ThemeColorKey) => () => {
178
- if (selectedColor === color) {
179
- return
180
- }
181
- onColorChange(color)
182
- }
183
- return (
184
- <div>
185
- <TooltipGroup openDelay={400} closeDelay={300}>
186
- <Divider label="color" labelPosition="left" />
187
- <Flex mt={'xs'} maw={150} gap="xs" justify="flex-start" align="flex-start" direction="row" wrap="wrap">
188
- {themedColors.map(({ key, value }) => (
189
- <Tooltip
190
- key={key}
191
- label={key}
192
- fz={'xs'}
193
- color="dark"
194
- offset={2}
195
- transitionProps={{ duration: 140, transition: 'slide-up' }}>
196
- <ColorSwatch
197
- color={value}
198
- size={20}
199
- withShadow
200
- onClick={changeColor(key)}
201
- style={{ color: '#fff', cursor: 'pointer' }}
202
- >
203
- {selectedColor === key && <CheckIcon style={{ width: rem(12), height: rem(12) }} />}
204
- </ColorSwatch>
205
- </Tooltip>
206
- ))}
207
- </Flex>
208
-
209
- <Flex mt="sm" maw={150} gap="xs" justify="flex-start" align="flex-start" direction="row" wrap="wrap">
210
- {colors.map(({ key, value }) => (
211
- <Tooltip
212
- key={key}
213
- label={key}
214
- fz={'xs'}
215
- color="dark"
216
- offset={2}
217
- transitionProps={{ duration: 140, transition: 'slide-up' }}>
218
- <ColorSwatch
219
- color={value}
220
- size={20}
221
- onClick={changeColor(key)}
222
- style={{ color: '#fff', cursor: 'pointer' }}
223
- >
224
- {selectedColor === key && <CheckIcon style={{ width: rem(12), height: rem(12) }} />}
225
- </ColorSwatch>
226
- </Tooltip>
227
- ))}
228
- </Flex>
229
- </TooltipGroup>
230
- </div>
231
- )
232
- }
233
-
234
- function ShapeOption({
235
- nodes: [firstNode, ...nodes],
236
- onShapeChange
237
- }: {
238
- nodes: NonEmptyArray<XYNodesData>
239
- onShapeChange: (shape: ElementShape) => void
240
- }) {
241
- let selectedShape = firstNode.data.element.shape as ElementShape | null
242
- takeWhile(nodes, node => {
243
- if (node.data.element.shape !== selectedShape) {
244
- selectedShape = null
245
- return false
246
- }
247
- return true
248
- })
249
-
250
- return (
251
- <div>
252
- <Divider label="shape" labelPosition="left" />
253
- <Select
254
- mt={'xs'}
255
- size="xs"
256
- variant="filled"
257
- value={selectedShape}
258
- placeholder={'[ multiple ]'}
259
- data={ElementShapes}
260
- allowDeselect={false}
261
- checkIconPosition="right"
262
- onChange={(value) => {
263
- if (!value || value === selectedShape) {
264
- return
265
- }
266
- onShapeChange(value as ElementShape)
267
- }} />
268
- </div>
269
- )
270
- }
271
-
272
- function NavigateToOption({
273
- nodes: [node, ...nodes]
274
- }: {
275
- nodes: NonEmptyArray<XYNodesData>
276
- }) {
277
- const isMultiple = nodes.length >= 1
278
- return (
279
- <div>
280
- <Divider label="navigate to" labelPosition="left" />
281
- {isMultiple && (
282
- <Text size="xs" c={'dimmed'}>
283
- {'[ multiple ]'}
284
- </Text>
285
- )}
286
- {!isMultiple && (
287
- <>
288
- <Space h={'xs'} />
289
- <Select
290
- size="xs"
291
- variant="filled"
292
- value={node.data.element.navigateTo ?? null}
293
- placeholder={'select'}
294
- data={node.data.element.navigateTo
295
- ? [{ value: node.data.element.navigateTo, label: node.data.element.navigateTo }]
296
- : []}
297
- allowDeselect={true}
298
- checkIconPosition="right"
299
- />
300
- </>
301
- )}
302
- </div>
303
- )
304
- }
305
-
306
- function OpacityOption({
307
- node,
308
- onOpacityChange
309
- }: {
310
- node: XYNodesData
311
- onOpacityChange: (opacity: number) => void
312
- }) {
313
- let selectedOpacity = node.data.element.style.opacity ?? 100
314
- const [value, setValue] = useState(selectedOpacity)
315
- useUpdateEffect(() => {
316
- setValue(selectedOpacity)
317
- }, [selectedOpacity])
318
-
319
- return (
320
- <Slider
321
- size={'sm'}
322
- color={'dark'}
323
- value={value}
324
- onChange={setValue}
325
- onChangeEnd={onOpacityChange} />
326
- )
327
- }
328
-
329
- function BorderStyleOption({
330
- node,
331
- onChange
332
- }: {
333
- node: XYNodesData
334
- onChange: (borderStyle: BorderStyle) => void
335
- }) {
336
- let selecteBorderStyle = node.data.element.style.border ?? 'dashed'
337
- const [value, setValue] = useState(selecteBorderStyle)
338
- useUpdateEffect(() => {
339
- setValue(selecteBorderStyle)
340
- }, [selecteBorderStyle])
341
-
342
- return (
343
- <Box>
344
- <SegmentedControl
345
- size="xs"
346
- fullWidth
347
- withItemsBorders={false}
348
- value={value}
349
- onChange={v => {
350
- setValue(v as BorderStyle)
351
- onChange(v as BorderStyle)
352
- }}
353
- data={[
354
- { label: 'Solid', value: 'solid' },
355
- { label: 'Dashed', value: 'dashed' },
356
- { label: 'Dotted', value: 'dotted' },
357
- { label: 'None', value: 'none' }
358
- ]}
359
- />
360
- </Box>
361
- )
362
- }
@@ -1,101 +0,0 @@
1
- import { createVar, globalStyle, style } from '@vanilla-extract/css'
2
- import { mantine, vars, whereDark, whereLight } from '../../../theme-vars'
3
-
4
- const bg = createVar('bg')
5
-
6
- export const container = style({
7
- backgroundColor: mantine.colors.body,
8
- pointerEvents: 'all',
9
- position: 'absolute',
10
- top: 0,
11
- left: 0,
12
- zIndex: 100,
13
- vars: {
14
- [bg]: `linear-gradient(180deg, ${vars.element.fill}, ${vars.element.fill} 3px, transparent 3px)`
15
- },
16
- backgroundImage: bg,
17
- selectors: {
18
- [`${whereDark} &`]: {
19
- backgroundColor: mantine.colors.dark[6],
20
- vars: {
21
- [bg]: `
22
- linear-gradient(180deg, color-mix(in srgb, ${vars.element.fill} 10%, transparent), transparent 60px),
23
- linear-gradient(180deg, ${vars.element.fill}, ${vars.element.fill} 3px, transparent 3px)
24
- `
25
- }
26
- }
27
- }
28
- })
29
-
30
- export const noPointerEvents = style({
31
- pointerEvents: 'none'
32
- })
33
-
34
- export const fqn = style({
35
- display: 'inline-block',
36
- fontSize: mantine.fontSizes.xs,
37
- fontWeight: 500,
38
- whiteSpace: 'nowrap',
39
- padding: '3px 5px',
40
- borderRadius: 2,
41
- background: `color-mix(in srgb , ${vars.element.fill}, transparent 25%)`,
42
- lineHeight: 1.2,
43
- color: vars.element.hiContrast,
44
- selectors: {
45
- [`${whereDark} &`]: {
46
- // background: `color-mix(in srgb , ${vars.element.fill}, transparent 45%)`,
47
- // color: vars.element.loContrast
48
- }
49
- }
50
- })
51
-
52
- export const edgeNum = style({
53
- display: 'inline-block',
54
- fontSize: mantine.fontSizes.sm,
55
- fontWeight: 600,
56
- padding: '1px 5px',
57
- minWidth: 24,
58
- textAlign: 'center',
59
- borderRadius: mantine.radius.sm,
60
- background: mantine.colors.dark[7],
61
- color: mantine.colors.defaultColor,
62
- selectors: {
63
- [`${whereLight} &`]: {
64
- background: mantine.colors.gray[4],
65
- color: mantine.colors.dark[6]
66
- },
67
- [`&[data-zero]`]: {
68
- color: mantine.colors.dimmed
69
- },
70
- [`${whereLight} &[data-zero]`]: {
71
- background: mantine.colors.gray[3]
72
- },
73
- [`&[data-missing]`]: {
74
- color: mantine.colors.orange[4],
75
- background: `color-mix(in srgb, ${mantine.colors.orange[8]} 20%, transparent)`
76
- },
77
- [`${whereLight} &[data-missing]`]: {
78
- color: mantine.colors.orange[8]
79
- }
80
- }
81
- })
82
-
83
- export const viewButton = style({
84
- paddingLeft: 2,
85
- height: 'auto'
86
- })
87
-
88
- globalStyle(`${viewButton} .mantine-Button-label`, {
89
- color: mantine.colors.text,
90
- fontWeight: 500,
91
- flexDirection: 'column',
92
- alignItems: 'flex-start'
93
- })
94
- globalStyle(`${viewButton} .tabler-icon`, {
95
- width: '75%',
96
- opacity: 0.75
97
- })
98
-
99
- globalStyle(`${whereLight} ${viewButton} .mantine-Button-label`, {
100
- color: mantine.colors.dark[3]
101
- })