@likec4/diagram 1.35.0 → 1.36.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 (214) hide show
  1. package/bundle/{chunk-C0Eg81Gj.js → chunk-7MPUJFHj.js} +315 -311
  2. package/bundle/custom.js +52 -52
  3. package/bundle/index.js +1583 -739
  4. package/dist/LikeC4Diagram.js +6 -6
  5. package/dist/LikeC4Diagram.props.d.ts +2 -3
  6. package/dist/LikeC4ModelProvider.d.ts +3 -3
  7. package/dist/LikeC4ProjectsProvider.d.ts +17 -0
  8. package/dist/LikeC4ProjectsProvider.js +22 -0
  9. package/dist/LikeC4Styles.d.ts +1 -0
  10. package/dist/LikeC4Styles.js +94 -0
  11. package/dist/StaticLikeC4Diagram.d.ts +3 -3
  12. package/dist/base/BaseXYFlow.js +23 -26
  13. package/dist/base/primitives/MarkdownBlock.d.ts +7 -1
  14. package/dist/base/primitives/MarkdownBlock.js +1 -1
  15. package/dist/base/primitives/compound/CompoundActionButton.js +2 -2
  16. package/dist/base/primitives/compound/CompoundDetailsButton.js +2 -2
  17. package/dist/base/primitives/compound/CompoundNodeContainer.css.js +4 -4
  18. package/dist/base/primitives/compound/CompoundNodeContainer.js +1 -4
  19. package/dist/base/primitives/compound/CompoundTitle.js +9 -8
  20. package/dist/base/primitives/compound/actionbtns.css.js +6 -6
  21. package/dist/base/primitives/edge/EdgeActionButton.js +2 -2
  22. package/dist/base/primitives/edge/EdgeContainer.js +4 -7
  23. package/dist/base/primitives/edge/EdgeLabel.css.d.ts +0 -22
  24. package/dist/base/primitives/edge/EdgeLabel.css.js +6 -84
  25. package/dist/base/primitives/edge/EdgeLabel.js +16 -6
  26. package/dist/base/primitives/edge/EdgeLabelContainer.js +1 -6
  27. package/dist/base/primitives/edge/EdgeMarkers.js +3 -3
  28. package/dist/base/primitives/edge/edge.css.d.ts +0 -2
  29. package/dist/base/primitives/edge/edge.css.js +1 -55
  30. package/dist/base/primitives/element/ElementActionButtons.js +2 -2
  31. package/dist/base/primitives/element/ElementDetailsButton.js +8 -7
  32. package/dist/base/primitives/element/ElementNodeContainer.css.js +4 -4
  33. package/dist/base/primitives/element/ElementNodeContainer.js +1 -4
  34. package/dist/base/primitives/element/ElementShape.css.js +11 -11
  35. package/dist/base/primitives/element/ElementTags.d.ts +1 -0
  36. package/dist/base/primitives/element/ElementTags.js +17 -14
  37. package/dist/bundle/LikeC4View.d.ts +1 -1
  38. package/dist/bundle/LikeC4View.js +7 -1
  39. package/dist/bundle/LikeC4View.props.d.ts +1 -2
  40. package/dist/bundle/ReactLikeC4.d.ts +1 -1
  41. package/dist/bundle/ViewNotFound.js +1 -1
  42. package/dist/bundle/index.d.ts +2 -1
  43. package/dist/bundle/index.js +1 -0
  44. package/dist/bundle/styles.css.js +1 -1
  45. package/dist/components/ErrorFallback.js +1 -1
  46. package/dist/components/GithubIcon.d.ts +2 -0
  47. package/dist/components/GithubIcon.js +17 -0
  48. package/dist/components/Link.d.ts +4 -3
  49. package/dist/components/Link.js +84 -87
  50. package/dist/components/NavigationLink.d.ts +2 -2
  51. package/dist/components/SearchControl.css.js +6 -5
  52. package/dist/context/DiagramEventHandlers.d.ts +6 -6
  53. package/dist/context/DiagramEventHandlers.js +4 -7
  54. package/dist/globals.css.js +3 -0
  55. package/dist/hooks/useXYFlow.d.ts +10 -10
  56. package/dist/index.d.ts +1 -0
  57. package/dist/index.js +1 -0
  58. package/dist/likec4diagram/custom/edges/NotePopover.css.js +2 -2
  59. package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +2 -2
  60. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +1 -1
  61. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.js +7 -7
  62. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +3 -3
  63. package/dist/likec4diagram/custom/edges/edges.css.js +4 -4
  64. package/dist/likec4diagram/custom/index.d.ts +2 -2
  65. package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +2 -2
  66. package/dist/likec4diagram/ui/controls/styles.css.js +5 -5
  67. package/dist/likec4diagram/ui/notation/NotationPanel.css.js +11 -11
  68. package/dist/likec4diagram/ui/notation/NotationPanel.js +2 -5
  69. package/dist/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.css.js +10 -10
  70. package/dist/likec4model/LikeC4ProjectsContext.d.ts +7 -0
  71. package/dist/likec4model/LikeC4ProjectsContext.js +5 -0
  72. package/dist/likec4model/index.d.ts +1 -0
  73. package/dist/likec4model/useLikeC4Project.d.ts +22 -0
  74. package/dist/likec4model/useLikeC4Project.js +23 -0
  75. package/dist/navigationpanel/NavigationPanel.js +15 -17
  76. package/dist/navigationpanel/NavigationPanelControls.js +34 -21
  77. package/dist/navigationpanel/NavigationPanelDropdown.js +33 -17
  78. package/dist/navigationpanel/_common.js +4 -1
  79. package/dist/navigationpanel/actor.d.ts +11 -15
  80. package/dist/navigationpanel/actor.js +14 -15
  81. package/dist/navigationpanel/controls/BurgerButton.js +5 -7
  82. package/dist/navigationpanel/controls/NavigationButtons.js +37 -24
  83. package/dist/navigationpanel/controls/OpenSource.js +1 -1
  84. package/dist/navigationpanel/controls/SearchControl.js +6 -4
  85. package/dist/navigationpanel/controls/ToggleReadonly.js +3 -3
  86. package/dist/navigationpanel/controls/ViewDetailsCard.d.ts +2 -0
  87. package/dist/navigationpanel/controls/ViewDetailsCard.js +232 -0
  88. package/dist/navigationpanel/controls/index.d.ts +1 -0
  89. package/dist/navigationpanel/dropdown/ProjectsMenu.d.ts +2 -0
  90. package/dist/navigationpanel/dropdown/ProjectsMenu.js +75 -0
  91. package/dist/navigationpanel/editorpanel/EditorPanel.js +3 -3
  92. package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +19 -20
  93. package/dist/navigationpanel/editorpanel/styles.js +5 -5
  94. package/dist/navigationpanel/hooks.d.ts +2 -2
  95. package/dist/navigationpanel/styles.css.js +0 -2
  96. package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +12 -7
  97. package/dist/node_modules/.pnpm/@tabler_icons-react@3.34.1_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronDown.js +14 -0
  98. package/dist/node_modules/.pnpm/@tabler_icons-react@3.34.1_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconLink.js +14 -0
  99. package/dist/overlays/element-details/ElementDetailsCard.css.js +18 -17
  100. package/dist/overlays/element-details/ElementDetailsCard.js +8 -13
  101. package/dist/overlays/element-details/TabPanelDeployments.css.js +5 -4
  102. package/dist/overlays/element-details/TabPanelRelationships.css.js +7 -7
  103. package/dist/overlays/overlay/Overlay.css.d.ts +3 -3
  104. package/dist/overlays/overlay/Overlay.css.js +8 -7
  105. package/dist/overlays/relationship-details/SelectEdge.css.js +8 -8
  106. package/dist/overlays/relationships-browser/SelectElement.css.js +1 -1
  107. package/dist/search/Search.js +6 -6
  108. package/dist/search/components/ElementsColumn.css.js +5 -5
  109. package/dist/search/components/SearchByTags.js +3 -2
  110. package/dist/search/components/ViewsColum.js +1 -1
  111. package/dist/search/components/ViewsColumn.css.js +1 -1
  112. package/dist/search/components/_shared.css.js +3 -3
  113. package/dist/search/components/styles.css.js +5 -5
  114. package/dist/state/DiagramActorProvider.js +34 -15
  115. package/dist/state/diagram-machine.d.ts +29 -247
  116. package/dist/state/diagram-machine.js +16 -16
  117. package/dist/styles-min.css +1 -1
  118. package/dist/styles.css +1 -1
  119. package/dist/styles.css2.js +1 -1
  120. package/package.json +10 -8
  121. package/panda.buildinfo.json +254 -326
  122. package/src/LikeC4Diagram.props.ts +2 -2
  123. package/src/LikeC4Diagram.tsx +2 -2
  124. package/src/LikeC4ModelProvider.tsx +4 -4
  125. package/src/LikeC4ProjectsProvider.tsx +41 -0
  126. package/src/LikeC4Styles.tsx +107 -0
  127. package/src/StaticLikeC4Diagram.tsx +3 -3
  128. package/src/base/BaseXYFlow.tsx +24 -29
  129. package/src/base/primitives/MarkdownBlock.tsx +11 -3
  130. package/src/base/primitives/compound/CompoundActionButton.tsx +2 -2
  131. package/src/base/primitives/compound/CompoundDetailsButton.tsx +2 -2
  132. package/src/base/primitives/compound/CompoundNodeContainer.css.ts +4 -13
  133. package/src/base/primitives/compound/CompoundNodeContainer.tsx +0 -3
  134. package/src/base/primitives/compound/CompoundTitle.tsx +8 -8
  135. package/src/base/primitives/compound/actionbtns.css.ts +6 -6
  136. package/src/base/primitives/edge/EdgeActionButton.tsx +2 -2
  137. package/src/base/primitives/edge/EdgeContainer.tsx +3 -6
  138. package/src/base/primitives/edge/EdgeLabel.css.ts +4 -83
  139. package/src/base/primitives/edge/EdgeLabel.tsx +16 -10
  140. package/src/base/primitives/edge/EdgeLabelContainer.tsx +1 -6
  141. package/src/base/primitives/edge/EdgeMarkers.tsx +3 -3
  142. package/src/base/primitives/edge/edge.css.ts +0 -60
  143. package/src/base/primitives/element/ElementActionButtons.tsx +2 -2
  144. package/src/base/primitives/element/ElementDetailsButton.tsx +7 -7
  145. package/src/base/primitives/element/ElementNodeContainer.css.ts +4 -4
  146. package/src/base/primitives/element/ElementNodeContainer.tsx +0 -3
  147. package/src/base/primitives/element/ElementShape.css.ts +11 -11
  148. package/src/base/primitives/element/ElementTags.tsx +17 -14
  149. package/src/bundle/LikeC4View.props.ts +1 -2
  150. package/src/bundle/LikeC4View.tsx +10 -3
  151. package/src/bundle/ReactLikeC4.tsx +1 -2
  152. package/src/bundle/ViewNotFound.tsx +1 -1
  153. package/src/bundle/index.ts +2 -1
  154. package/src/bundle/styles.css.ts +1 -1
  155. package/src/components/ErrorFallback.tsx +1 -1
  156. package/src/components/GithubIcon.tsx +16 -0
  157. package/src/components/Link.tsx +102 -113
  158. package/src/components/NavigationLink.tsx +2 -1
  159. package/src/components/SearchControl.css.ts +5 -5
  160. package/src/context/DiagramEventHandlers.tsx +12 -12
  161. package/src/globals.css +71 -0
  162. package/src/index.ts +5 -0
  163. package/src/likec4diagram/custom/edges/NotePopover.css.ts +2 -2
  164. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +1 -1
  165. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.ts +7 -7
  166. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +3 -3
  167. package/src/likec4diagram/custom/edges/edges.css.ts +4 -4
  168. package/src/likec4diagram/custom/nodes/toolbar/CompoundToolbar.tsx +2 -2
  169. package/src/likec4diagram/ui/controls/styles.css.ts +5 -5
  170. package/src/likec4diagram/ui/notation/NotationPanel.css.ts +11 -11
  171. package/src/likec4diagram/ui/notation/NotationPanel.tsx +1 -4
  172. package/src/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.css.ts +10 -10
  173. package/src/likec4model/LikeC4ProjectsContext.ts +9 -0
  174. package/src/likec4model/index.ts +8 -0
  175. package/src/likec4model/useLikeC4Project.ts +61 -0
  176. package/src/navigationpanel/NavigationPanel.tsx +16 -17
  177. package/src/navigationpanel/NavigationPanelControls.tsx +24 -46
  178. package/src/navigationpanel/NavigationPanelDropdown.tsx +32 -16
  179. package/src/navigationpanel/_common.tsx +4 -1
  180. package/src/navigationpanel/actor.ts +14 -15
  181. package/src/navigationpanel/controls/BurgerButton.tsx +5 -7
  182. package/src/navigationpanel/controls/NavigationButtons.tsx +9 -1
  183. package/src/navigationpanel/controls/OpenSource.tsx +1 -1
  184. package/src/navigationpanel/controls/SearchControl.tsx +6 -4
  185. package/src/navigationpanel/controls/ToggleReadonly.tsx +3 -3
  186. package/src/navigationpanel/controls/ViewDetailsCard.tsx +244 -0
  187. package/src/navigationpanel/controls/index.ts +1 -0
  188. package/src/navigationpanel/dropdown/ProjectsMenu.tsx +74 -0
  189. package/src/navigationpanel/editorpanel/EditorPanel.tsx +3 -3
  190. package/src/navigationpanel/editorpanel/ManualLayoutToolsButton.tsx +19 -22
  191. package/src/navigationpanel/editorpanel/styles.ts +5 -5
  192. package/src/navigationpanel/hooks.tsx +2 -2
  193. package/src/navigationpanel/styles.css.ts +0 -2
  194. package/src/navigationpanel/walkthrough/ActiveWalkthroughControls.tsx +9 -4
  195. package/src/overlays/element-details/ElementDetailsCard.css.ts +17 -17
  196. package/src/overlays/element-details/ElementDetailsCard.tsx +8 -13
  197. package/src/overlays/element-details/TabPanelDeployments.css.ts +4 -4
  198. package/src/overlays/element-details/TabPanelRelationships.css.ts +7 -7
  199. package/src/overlays/overlay/Overlay.css.ts +7 -7
  200. package/src/overlays/relationship-details/SelectEdge.css.ts +8 -8
  201. package/src/overlays/relationships-browser/SelectElement.css.ts +1 -1
  202. package/src/search/Search.tsx +6 -6
  203. package/src/search/components/ElementsColumn.css.ts +5 -5
  204. package/src/search/components/SearchByTags.tsx +2 -2
  205. package/src/search/components/ViewsColum.tsx +1 -1
  206. package/src/search/components/ViewsColumn.css.ts +1 -1
  207. package/src/search/components/_shared.css.ts +3 -3
  208. package/src/search/components/styles.css.ts +5 -5
  209. package/src/state/DiagramActorProvider.tsx +45 -20
  210. package/src/state/diagram-machine.ts +22 -16
  211. package/dist/LikeC4CustomColors.d.ts +0 -2
  212. package/dist/LikeC4CustomColors.js +0 -45
  213. package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +0 -45
  214. package/src/LikeC4CustomColors.tsx +0 -85
@@ -9,6 +9,7 @@ import {
9
9
  type ViewId,
10
10
  } from '@likec4/core/types'
11
11
  import { css, cx } from '@likec4/styles/css'
12
+ import { HStack } from '@likec4/styles/jsx'
12
13
  import {
13
14
  type TextProps,
14
15
  ActionIcon,
@@ -266,12 +267,8 @@ export function ElementDetailsCard({
266
267
  dragElastic={0}
267
268
  dragMomentum={false}
268
269
  dragListener={false}
269
- className={cx(
270
- css({
271
- likec4Palette: nodeModel?.color ?? elementModel.color,
272
- }),
273
- styles.card,
274
- )}
270
+ data-likec4-color={nodeModel?.color ?? elementModel.color}
271
+ className={styles.card}
275
272
  initial={{
276
273
  top,
277
274
  left,
@@ -349,9 +346,7 @@ export function ElementDetailsCard({
349
346
  <ElementTag
350
347
  key={tag}
351
348
  tag={tag}
352
- css={{
353
- cursor: 'pointer',
354
- }}
349
+ cursor="pointer"
355
350
  onClick={e => {
356
351
  e.stopPropagation()
357
352
  diagram.openSearch(`#${tag}`)
@@ -446,9 +441,9 @@ export function ElementDetailsCard({
446
441
  {elementModel.links.length > 0 && (
447
442
  <>
448
443
  <PropertyLabel>links</PropertyLabel>
449
- <Stack gap={'xs'} align="flex-start">
444
+ <HStack gap={'xs'} flexWrap="wrap">
450
445
  {elementModel.links.map((link, i) => <Link key={i} value={link} />)}
451
- </Stack>
446
+ </HStack>
452
447
  </>
453
448
  )}
454
449
  {elementModel.$element.metadata && <ElementMetata value={elementModel.$element.metadata} />}
@@ -609,7 +604,7 @@ function ElementMetata({
609
604
  gap: `[4px 4px]`,
610
605
  alignItems: 'baseline',
611
606
  justifyItems: 'stretch',
612
- paddingRight: '2xs',
607
+ paddingRight: 'xxs',
613
608
  })}>
614
609
  {entries(metadata).map(([key, value]) => (
615
610
  <div
@@ -654,7 +649,7 @@ function ElementMetata({
654
649
  <div
655
650
  className={css({
656
651
  fontSize: 'sm',
657
- padding: '2xs',
652
+ padding: 'xxs',
658
653
  whiteSpace: 'pre',
659
654
  fontFamily: '[var(--mantine-font-family-monospace)]',
660
655
  userSelect: 'all',
@@ -8,8 +8,8 @@ export const treeNode = css({
8
8
 
9
9
  export const treeNodeLabel = css({
10
10
  cursor: 'default',
11
- marginTop: 0,
12
- marginBottom: 0,
11
+ marginTop: '0',
12
+ marginBottom: '0',
13
13
  })
14
14
 
15
15
  const label = css({
@@ -44,8 +44,8 @@ export const instanceLabel = cx(
44
44
  justifyContent: 'stretch',
45
45
  flexWrap: 'nowrap',
46
46
  height: '36px',
47
- paddingInlineStart: '16px',
48
- paddingInlineEnd: '10px',
47
+ paddingInlineStart: '[16px]',
48
+ paddingInlineEnd: '2.5', // 10px
49
49
  borderRadius: 'sm',
50
50
  alignItems: 'center',
51
51
  color: 'mantine.colors.gray[7]',
@@ -5,11 +5,11 @@ export const fqn = css({
5
5
  fontSize: 'sm',
6
6
  fontWeight: 500,
7
7
  whiteSpace: 'nowrap',
8
- padding: '3px 6px',
8
+ padding: '[3px 6px]',
9
9
  borderRadius: 3,
10
- background: `likec4.palette.fill/75`,
10
+ background: `var(--likec4-palette-fill)/75`,
11
11
  lineHeight: 1.2,
12
- color: 'likec4.palette.hiContrast',
12
+ color: 'var(--likec4-palette-hiContrast)',
13
13
  // selectors: {
14
14
  // [`${whereDark} &`]: {
15
15
  // }
@@ -55,9 +55,9 @@ export const panelScope = css({
55
55
  _before: {
56
56
  content: '"scope:"',
57
57
  position: 'absolute',
58
- top: 0,
59
- left: 8,
60
- fontSize: '2xs',
58
+ top: '0',
59
+ left: '2',
60
+ fontSize: 'xxs',
61
61
  fontWeight: 500,
62
62
  lineHeight: '1',
63
63
  color: 'mantine.colors.dimmed',
@@ -75,7 +75,7 @@ export const edgeNum = css({
75
75
  display: 'inline-block',
76
76
  fontSize: 'xl',
77
77
  fontWeight: 600,
78
- padding: '1px 5px',
78
+ padding: '[1px 5px]',
79
79
  minWidth: 24,
80
80
  textAlign: 'center',
81
81
  borderRadius: 'sm',
@@ -10,7 +10,7 @@ const inset = '--_inset'
10
10
  const borderRadius = '--_border-radius'
11
11
  const dialog = css.raw({
12
12
  boxSizing: 'border-box',
13
- margin: 0,
13
+ margin: '0',
14
14
  position: 'fixed',
15
15
  width: '100vw',
16
16
  height: '100vh',
@@ -30,13 +30,13 @@ const dialog = css.raw({
30
30
  _backdrop: {
31
31
  cursor: 'zoom-out',
32
32
  },
33
- inset: 0,
34
- padding: 0,
33
+ inset: '0',
34
+ padding: '0',
35
35
  })
36
36
 
37
37
  const body = css.raw({
38
38
  position: 'relative',
39
- containerName: 'overlay-dialog',
39
+ containerName: 'likec4-dialog',
40
40
  containerType: 'size',
41
41
  border: `0 solid transparent`,
42
42
  overflow: 'hidden',
@@ -60,7 +60,7 @@ export const overlay = sva({
60
60
  width: 'calc(100vw - 2 * var(--_inset))',
61
61
  height: 'calc(100vh - var(--_offset) - var(--_inset))',
62
62
  [borderRadius]: '6px',
63
- padding: '6px',
63
+ padding: '1.5', // 6px
64
64
  [offset]: '1rem',
65
65
  },
66
66
  md: {
@@ -81,8 +81,8 @@ export const overlay = sva({
81
81
  },
82
82
  true: {
83
83
  dialog: {
84
- inset: 0,
85
- padding: 0,
84
+ inset: '0',
85
+ padding: '0',
86
86
  },
87
87
  },
88
88
  },
@@ -3,7 +3,7 @@ import { css, cx } from '@likec4/styles/css'
3
3
  const edgeEnpoint = css.raw({
4
4
  display: 'inline-flex',
5
5
  alignItems: 'center',
6
- padding: '6px 2px 0 2px',
6
+ padding: '[6px 2px 0 2px]',
7
7
  '& .mantine-Text-root': {
8
8
  color: 'mantine.colors.text/90',
9
9
  fontSize: 'xs',
@@ -13,7 +13,7 @@ const edgeEnpoint = css.raw({
13
13
  })
14
14
 
15
15
  export const edgeSource = css({
16
- paddingLeft: 4,
16
+ paddingLeft: '1',
17
17
  gridColumn: 1,
18
18
  }, edgeEnpoint)
19
19
 
@@ -23,7 +23,7 @@ export const edgeArrow = css({
23
23
 
24
24
  export const edgeTarget = css({
25
25
  gridColumn: 3,
26
- paddingRight: 4,
26
+ paddingRight: '1',
27
27
  }, edgeEnpoint)
28
28
 
29
29
  const edgeLabelclass = 'likec4-edge-label'
@@ -35,8 +35,8 @@ export const edgeLabel = cx(
35
35
  gridColumnEnd: 4,
36
36
  borderBottom: `1px solid`,
37
37
  borderBottomColor: 'mantine.colors.defaultBorder',
38
- marginBottom: '0px',
39
- padding: '0 4px 5px 4px',
38
+ marginBottom: '0',
39
+ padding: '[0 4px 5px 4px]',
40
40
  width: '100%',
41
41
  '& .mantine-Text-root': {
42
42
  fontSize: 'xxs',
@@ -51,7 +51,7 @@ export const edgeRow = css({
51
51
  display: 'contents',
52
52
  [`&:last-child .${edgeLabelclass}`]: {
53
53
  borderBottom: 'none',
54
- marginBottom: 0,
54
+ marginBottom: '0',
55
55
  },
56
56
  '& > *': {
57
57
  transition: 'all 0.15s ease-in',
@@ -67,7 +67,7 @@ export const edgeGrid = css({
67
67
  display: 'grid',
68
68
  gridTemplateColumns: '1fr 30px 1fr',
69
69
  gridAutoRows: 'min-content max-content',
70
- gap: 0,
70
+ gap: '0',
71
71
  alignItems: 'stretch',
72
72
  })
73
73
 
@@ -75,7 +75,7 @@ export const edgeDataGrid = css({
75
75
  display: 'grid',
76
76
  gridTemplateColumns: 'min-content 1fr',
77
77
  gridAutoRows: 'min-content max-content',
78
- gap: '10px 12px',
78
+ gap: '[10px 12px]',
79
79
  alignItems: 'baseline',
80
80
  justifyItems: 'start',
81
81
  })
@@ -1,7 +1,7 @@
1
1
  import { css } from '@likec4/styles/css'
2
2
 
3
3
  export const node = css({
4
- margin: 0,
4
+ margin: '0',
5
5
  })
6
6
 
7
7
  export const label = css({
@@ -40,8 +40,8 @@ const body = css({
40
40
  // containerType: 'size',
41
41
  // position: 'fixed',
42
42
  // zIndex: 901,
43
- // top: 0,
44
- // left: 0,
43
+ // top: '0',
44
+ // left: '0',
45
45
  width: '100%',
46
46
  height: '100%',
47
47
  maxHeight: '100vh',
@@ -50,10 +50,10 @@ const body = css({
50
50
  flexDirection: 'column',
51
51
  justifyContent: 'stretch',
52
52
  gap: 'sm',
53
- paddingTop: 20,
54
- paddingLeft: 16,
55
- paddingRight: 16,
56
- paddingBottom: 8,
53
+ paddingTop: '[20px]',
54
+ paddingLeft: 'md',
55
+ paddingRight: 'md',
56
+ paddingBottom: 'sm',
57
57
  background: '[transparent]',
58
58
  // backgroundColor: {
59
59
  // _dark: `[rgb(34 34 34 / 0.95)]`,
@@ -7,7 +7,7 @@ const whenContainerIsNarrow = `@container likec4-tree (max-width: 450px)`
7
7
 
8
8
  export const treeNode = css({
9
9
  outline: 'none',
10
- marginBottom: '8px',
10
+ marginBottom: '2',
11
11
  })
12
12
  export const treeRoot = css(
13
13
  container.raw({
@@ -22,10 +22,10 @@ export const treeLabel = css({
22
22
  display: 'flex',
23
23
  alignItems: 'baseline',
24
24
  outline: 'none !important',
25
- gap: '4px',
25
+ gap: '1',
26
26
  })
27
27
  export const treeSubtree = css({
28
- marginTop: '8px',
28
+ marginTop: '2',
29
29
  })
30
30
 
31
31
  // const iconSize = '--likec4-icon-size'
@@ -44,7 +44,7 @@ export const elementTitleAndId = css({
44
44
  [whenContainerIsNarrow]: {
45
45
  flexDirection: 'column-reverse',
46
46
  alignItems: 'flex-start',
47
- gap: 2,
47
+ gap: '0.5',
48
48
  },
49
49
  })
50
50
 
@@ -56,7 +56,7 @@ export const elementId = css({
56
56
  display: 'block',
57
57
  fontWeight: 500,
58
58
  whiteSpace: 'nowrap',
59
- padding: '1px 5px',
59
+ padding: '[1px 5px]',
60
60
  borderRadius: '4px',
61
61
  background: `mantine.colors.dark[9]/30`,
62
62
  _light: {
@@ -29,13 +29,13 @@ export function SearchByTags() {
29
29
  ref={ref}
30
30
  css={{
31
31
  gap: 'md',
32
- paddingLeft: 48,
32
+ paddingLeft: '[48px]',
33
33
  flexWrap: 'nowrap',
34
34
  }}
35
35
  >
36
36
  <HStack
37
37
  css={{
38
- gap: 6,
38
+ gap: '1.5', // 6px
39
39
  flexWrap: 'wrap',
40
40
  opacity: isFiltered ? 1 : .3,
41
41
  grayscale: isFiltered ? 0 : .9,
@@ -43,7 +43,7 @@ export const ViewsColumn = memo(() => {
43
43
  if (search.startsWith('#')) {
44
44
  return view.tags.some((tag) => tag.toLocaleLowerCase().includes(search.slice(1)))
45
45
  }
46
- return (view.title ?? '' + view.$view.description ?? '').toLocaleLowerCase().includes(search)
46
+ return `${view.title} ${view.$view.description}`.toLocaleLowerCase().includes(search)
47
47
  })
48
48
  }
49
49
  }
@@ -23,7 +23,7 @@ export const viewButton = cx(
23
23
  // export const viewDescription = css(description)
24
24
 
25
25
  export const viewButtonDescription = css({
26
- marginTop: '4px',
26
+ marginTop: '1',
27
27
  // transition: transitions.fast,
28
28
  // color: `[var(${descriptionColor}, {colors.mantine.colors.dimmed})]`,
29
29
  fontSize: '13px',
@@ -17,9 +17,9 @@ const button = css.raw({
17
17
  width: '100%',
18
18
  background: 'mantine.colors.body',
19
19
  rounded: 'sm',
20
- padding: `12px 8px 12px 14px`,
20
+ padding: `[12px 8px 12px 14px]`,
21
21
  minHeight: '60px',
22
- gap: 8,
22
+ gap: '2',
23
23
  // alignItems: 'flex-start',
24
24
  // transition: `all 50ms ${easings.inOut}`,
25
25
  border: `1px solid`,
@@ -139,7 +139,7 @@ const descriptionColor = css.raw({
139
139
  })
140
140
 
141
141
  const description = css.raw(descriptionColor, {
142
- marginTop: '4px',
142
+ marginTop: '1',
143
143
  fontSize: '12px',
144
144
  lineHeight: '1.4',
145
145
 
@@ -18,7 +18,7 @@ export const input = css({
18
18
 
19
19
  export const pickviewBackdrop = css({
20
20
  position: 'absolute',
21
- inset: 0,
21
+ inset: '0',
22
22
  width: '100%',
23
23
  height: '100%',
24
24
  backgroundColor: '[rgb(34 34 34 / 0.7)]',
@@ -31,8 +31,8 @@ export const pickviewBackdrop = css({
31
31
  })
32
32
  export const pickview = css({
33
33
  position: 'absolute',
34
- top: '2rem',
35
- left: '50%',
34
+ top: '[2rem]',
35
+ left: '[50%]',
36
36
  width: '100%',
37
37
  maxWidth: '600px',
38
38
  minWidth: '200px',
@@ -41,9 +41,9 @@ export const pickview = css({
41
41
  })
42
42
 
43
43
  export const pickviewGroup = css({
44
- marginTop: '8px',
44
+ marginTop: '2',
45
45
  '& + &': {
46
- marginTop: '32px',
46
+ marginTop: '[32px]',
47
47
  },
48
48
  })
49
49
 
@@ -1,11 +1,11 @@
1
1
  import type { DiagramView, WhereOperator } from '@likec4/core/types'
2
- import { useCustomCompareEffect, useDeepCompareEffect } from '@react-hookz/web'
2
+ import { useCustomCompareEffect } from '@react-hookz/web'
3
3
  import { useActorRef, useSelector } from '@xstate/react'
4
4
  import { useStoreApi } from '@xyflow/react'
5
5
  import { deepEqual, shallowEqual } from 'fast-equals'
6
6
  import { type PropsWithChildren, useEffect, useRef, useState } from 'react'
7
7
  import { ErrorBoundary } from '../components/ErrorFallback'
8
- import { useDiagramEventHandlersRef } from '../context/DiagramEventHandlers'
8
+ import { useDiagramEventHandlers } from '../context/DiagramEventHandlers'
9
9
  import { DiagramFeatures, useEnabledFeatures } from '../context/DiagramFeatures'
10
10
  import { DiagramActorContextProvider } from '../hooks/safeContext'
11
11
  import { useCurrentViewId } from '../hooks/useCurrentViewId'
@@ -16,7 +16,7 @@ import { CurrentViewModelContext } from '../likec4model/LikeC4ModelContext'
16
16
  import { useLikeC4Model } from '../likec4model/useLikeC4Model'
17
17
  import { type DiagramMachine, diagramMachine } from './diagram-machine'
18
18
  import { syncManualLayoutActorLogic } from './syncManualLayoutActor'
19
- import type { DiagramActorSnapshot } from './types'
19
+ import type { DiagramActorRef, DiagramActorSnapshot } from './types'
20
20
 
21
21
  const selectToggledFeatures = (state: DiagramActorSnapshot) => {
22
22
  if (state.context.features.enableReadOnly || state.context.activeWalkthrough) {
@@ -44,28 +44,12 @@ export function DiagramActorProvider({
44
44
  nodesSelectable: boolean
45
45
  where: WhereOperator | null
46
46
  }>) {
47
- const handlersRef = useDiagramEventHandlersRef()
47
+ const { handlersRef } = useDiagramEventHandlers()
48
48
  const xystore = useStoreApi<Types.Node, Types.Edge>()
49
49
 
50
50
  const machineRef = useRef<DiagramMachine | null>(null)
51
51
  if (!machineRef.current) {
52
52
  machineRef.current = diagramMachine.provide({
53
- actions: {
54
- 'trigger:NavigateTo': ((_, { viewId }) => {
55
- // Slightly defer callback for better responsiveness
56
- setTimeout(() => {
57
- handlersRef.current.onNavigateTo?.(viewId)
58
- }, 40)
59
- }),
60
-
61
- 'trigger:OnChange': ((_, params) => {
62
- handlersRef.current.onChange?.(params)
63
- }),
64
-
65
- 'trigger:OpenSource': ((_, params) => {
66
- handlersRef.current.onOpenSource?.(params)
67
- }),
68
- },
69
53
  actors: {
70
54
  syncManualLayoutActorLogic: syncManualLayoutActorLogic.provide({
71
55
  actions: {
@@ -95,6 +79,8 @@ export function DiagramActorProvider({
95
79
  },
96
80
  )
97
81
 
82
+ useActorEventHandlers(actorRef)
83
+
98
84
  const features = useEnabledFeatures()
99
85
  useCustomCompareEffect(
100
86
  () => {
@@ -167,3 +153,42 @@ function CurrentViewModelProvider({
167
153
  </CurrentViewModelContext.Provider>
168
154
  )
169
155
  }
156
+
157
+ function useActorEventHandlers(
158
+ actorRef: DiagramActorRef,
159
+ ) {
160
+ const {
161
+ onChange,
162
+ onNavigateTo,
163
+ onOpenSource,
164
+ } = useDiagramEventHandlers()
165
+
166
+ useEffect(() => {
167
+ if (!onChange) return
168
+ const subscription = actorRef.on('viewChange', ({ change }) => onChange({ change }))
169
+ return () => subscription.unsubscribe()
170
+ }, [actorRef, onChange])
171
+
172
+ useEffect(() => {
173
+ if (!onNavigateTo) return
174
+ let frame: number
175
+
176
+ const subscription = actorRef.on('navigateTo', ({ viewId }) => {
177
+ cancelAnimationFrame(frame)
178
+ // Slightly defer callback for better responsiveness
179
+ frame = requestAnimationFrame(() => {
180
+ onNavigateTo(viewId)
181
+ })
182
+ })
183
+ return () => {
184
+ cancelAnimationFrame(frame)
185
+ subscription.unsubscribe()
186
+ }
187
+ }, [actorRef, onNavigateTo])
188
+
189
+ useEffect(() => {
190
+ if (!onOpenSource) return
191
+ const subscription = actorRef.on('openSource', ({ params }) => onOpenSource(params))
192
+ return () => subscription.unsubscribe()
193
+ }, [actorRef, onOpenSource])
194
+ }
@@ -35,6 +35,7 @@ import {
35
35
  assertEvent,
36
36
  assign,
37
37
  cancel,
38
+ emit,
38
39
  enqueueActions,
39
40
  or,
40
41
  raise,
@@ -179,6 +180,11 @@ export type Events =
179
180
  | { type: 'tag.unhighlight' }
180
181
  | { type: 'toggle.feature'; feature: FeatureName; forceValue?: boolean }
181
182
 
183
+ export type EmittedEvents =
184
+ | { type: 'navigateTo'; viewId: ViewId }
185
+ | { type: 'viewChange'; change: ViewChange }
186
+ | { type: 'openSource'; params: OpenSourceParams }
187
+
182
188
  export type ActionArg = { context: Context; event: Events }
183
189
 
184
190
  // TODO: naming convention for actors
@@ -193,6 +199,7 @@ const _diagramMachine = setup({
193
199
  search: 'searchActorLogic'
194
200
  },
195
201
  events: {} as Events,
202
+ emitted: {} as EmittedEvents,
196
203
  },
197
204
  actors: {
198
205
  syncManualLayoutActorLogic,
@@ -241,14 +248,20 @@ const _diagramMachine = setup({
241
248
  },
242
249
  },
243
250
  actions: {
244
- 'trigger:NavigateTo': (_, _params: { viewId: ViewId }) => {
245
- // navigate to view
246
- },
247
- 'trigger:OnChange': (_, _params: { change: ViewChange }) => {
248
- // apply change
249
- },
250
- 'trigger:OpenSource': (_, _params: OpenSourceParams) => {
251
- },
251
+ 'trigger:NavigateTo': emit(({ context }) => ({
252
+ type: 'navigateTo',
253
+ viewId: nonNullable(context.lastOnNavigate, 'Invalid state, lastOnNavigate is null').toView,
254
+ })),
255
+
256
+ 'trigger:OnChange': emit((_, _params: { change: ViewChange }) => ({
257
+ type: 'viewChange',
258
+ change: _params.change,
259
+ })),
260
+
261
+ 'trigger:OpenSource': emit((_, _params: OpenSourceParams) => ({
262
+ type: 'openSource',
263
+ params: _params,
264
+ })),
252
265
 
253
266
  'assign lastClickedNode': assign(({ context, event }) => {
254
267
  assertEvent(event, 'xyflow.nodeClick')
@@ -1023,14 +1036,7 @@ const _diagramMachine = setup({
1023
1036
  'closeAllOverlays',
1024
1037
  'closeSearch',
1025
1038
  'stopSyncLayout',
1026
- enqueueActions(({ enqueue, context }) => {
1027
- enqueue({
1028
- type: 'trigger:NavigateTo',
1029
- params: {
1030
- viewId: nonNullable(context.lastOnNavigate, 'Invalid state, lastOnNavigate is null').toView,
1031
- },
1032
- })
1033
- }),
1039
+ 'trigger:NavigateTo',
1034
1040
  ],
1035
1041
  on: {
1036
1042
  'update.view': {
@@ -1,2 +0,0 @@
1
- import { MemoExoticComponent } from 'react';
2
- export declare const LikeC4CustomColors: MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element | null>;
@@ -1,45 +0,0 @@
1
- import { jsx, Fragment } from 'react/jsx-runtime';
2
- import '@likec4/core';
3
- import { useMantineStyleNonce } from '@mantine/core';
4
- import { memo, useState } from 'react';
5
- import { isEmpty, entries } from 'remeda';
6
- import { useLikeC4Specification } from './likec4model/useLikeC4Model.js';
7
- import { useUpdateEffect } from './hooks/useUpdateEffect.js';
8
-
9
- function toStyle(name, colors) {
10
- const darken = (color) => `color-mix(in srgb, ${color} 80%, black)`;
11
- return `
12
- :where([data-likec4-color=${name}]) {
13
- --colors-likec4-palette-hi-contrast: ${colors.elements.hiContrast};
14
- --colors-likec4-palette-lo-contrast: ${colors.elements.loContrast};
15
- --colors-likec4-palette-fill: ${colors.elements.fill};
16
- --colors-likec4-palette-stroke: ${colors.elements.stroke};
17
- --colors-likec4-relation-stroke: ${colors.relationships.lineColor};
18
- --colors-likec4-relation-stroke-selected: color-mix(in srgb, ${colors.relationships.lineColor}, var(--colors-likec4-mix-color) 20%);
19
- --colors-likec4-relation-label: ${colors.relationships.labelColor};
20
- --colors-likec4-relation-label-bg: ${colors.relationships.labelBgColor};
21
- }
22
- :where(.likec4-compound-node[data-likec4-color=${name}]) {
23
- --colors-likec4-palette-fill: ${darken(colors.elements.fill)};
24
- --colors-likec4-palette-stroke: ${darken(colors.elements.stroke)};
25
- }
26
- `;
27
- }
28
- function generateCustomColorStyles(customColors) {
29
- return entries(customColors).map(([name, color]) => toStyle(name, color)).join("\n").trim();
30
- }
31
- const LikeC4CustomColors = memo(() => {
32
- const customColors = useLikeC4Specification().customColors ?? {};
33
- const [styles, setStyles] = useState(() => generateCustomColorStyles(customColors));
34
- useUpdateEffect(() => {
35
- setStyles(generateCustomColorStyles(customColors));
36
- }, [customColors]);
37
- const nonce = useMantineStyleNonce()?.();
38
- if (isEmpty(customColors)) {
39
- return null;
40
- }
41
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("style", { type: "text/css", dangerouslySetInnerHTML: { __html: styles }, nonce }) });
42
- });
43
- LikeC4CustomColors.displayName = "LikeC4CustomColors";
44
-
45
- export { LikeC4CustomColors };
@@ -1,45 +0,0 @@
1
- import { NodeProps } from '../../../base';
2
- import { RelationshipsBrowserTypes } from '../_types';
3
- import { MemoExoticComponent } from 'react';
4
- import { Dimmed } from '../../../base/types.Base';
5
- import { ElementStyle, Color, Any, ViewId, Fqn, RichTextOrEmpty, IconUrl } from '@likec4/core';
6
- import { Tags } from '@likec4/core/types/_aux';
7
- export declare const ElementNode: MemoExoticComponent<(props: NodeProps<{
8
- hovered?: boolean;
9
- dimmed?: Dimmed;
10
- width: number;
11
- height: number;
12
- style: ElementStyle;
13
- color: Color;
14
- title: string;
15
- shape: "rectangle" | "person" | "browser" | "mobile" | "cylinder" | "storage" | "queue";
16
- tags: Tags<Any>;
17
- technology: string | null | undefined;
18
- navigateTo: ViewId<string> | null | undefined;
19
- column: RelationshipsBrowserTypes.Column;
20
- fqn: Fqn;
21
- icon: string | null;
22
- ports: RelationshipsBrowserTypes.Ports;
23
- existsInCurrentView: boolean;
24
- description: RichTextOrEmpty;
25
- }, string>) => import("react/jsx-runtime").JSX.Element>;
26
- export declare const CompoundNode: MemoExoticComponent<(props: NodeProps<{
27
- hovered?: boolean;
28
- dimmed?: Dimmed;
29
- style: ElementStyle;
30
- color: Color;
31
- title: string;
32
- shape: "rectangle" | "person" | "browser" | "mobile" | "cylinder" | "storage" | "queue";
33
- column: RelationshipsBrowserTypes.Column;
34
- fqn: Fqn;
35
- depth: number;
36
- icon: IconUrl;
37
- ports: RelationshipsBrowserTypes.Ports;
38
- existsInCurrentView: boolean;
39
- }, string>) => import("react/jsx-runtime").JSX.Element>;
40
- export declare const EmptyNode: MemoExoticComponent<(props: NodeProps<RelationshipsBrowserTypes.EmptyNodeData, string>) => import("react/jsx-runtime").JSX.Element>;
41
- type ElementPortsProps = NodeProps<Pick<RelationshipsBrowserTypes.ElementNodeData, 'ports' | 'height'>>;
42
- export declare const ElementPorts: ({ data: { ports, height: h } }: ElementPortsProps) => import("react/jsx-runtime").JSX.Element;
43
- type CompoundPortsProps = NodeProps<Pick<RelationshipsBrowserTypes.CompoundNodeData, 'ports'>>;
44
- export declare const CompoundPorts: ({ data }: CompoundPortsProps) => import("react/jsx-runtime").JSX.Element;
45
- export {};