@likec4/diagram 1.35.0 → 1.36.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 (224) hide show
  1. package/bundle/{chunk-C0Eg81Gj.js → chunk-DHvr-RGh.js} +323 -311
  2. package/bundle/custom.js +52 -52
  3. package/bundle/index.js +1594 -749
  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/DiagramUI.js +2 -1
  59. package/dist/likec4diagram/custom/edges/NotePopover.css.js +2 -2
  60. package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +2 -2
  61. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +1 -1
  62. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.js +7 -7
  63. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +3 -3
  64. package/dist/likec4diagram/custom/edges/edges.css.js +4 -4
  65. package/dist/likec4diagram/custom/index.d.ts +2 -2
  66. package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +2 -2
  67. package/dist/likec4diagram/ui/controls/styles.css.js +5 -5
  68. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +4 -4
  69. package/dist/likec4diagram/ui/notation/NotationPanel.css.js +11 -11
  70. package/dist/likec4diagram/ui/notation/NotationPanel.js +2 -5
  71. package/dist/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.css.js +10 -10
  72. package/dist/likec4model/LikeC4ModelContext.d.ts +2 -1
  73. package/dist/likec4model/LikeC4ModelContext.js +10 -2
  74. package/dist/likec4model/LikeC4ProjectsContext.d.ts +7 -0
  75. package/dist/likec4model/LikeC4ProjectsContext.js +5 -0
  76. package/dist/likec4model/index.d.ts +1 -0
  77. package/dist/likec4model/useCurrentViewModel.d.ts +1 -0
  78. package/dist/likec4model/useCurrentViewModel.js +4 -1
  79. package/dist/likec4model/useLikeC4Project.d.ts +22 -0
  80. package/dist/likec4model/useLikeC4Project.js +23 -0
  81. package/dist/navigationpanel/NavigationPanel.js +15 -17
  82. package/dist/navigationpanel/NavigationPanelControls.js +34 -21
  83. package/dist/navigationpanel/NavigationPanelDropdown.js +33 -17
  84. package/dist/navigationpanel/_common.js +4 -1
  85. package/dist/navigationpanel/actor.d.ts +11 -15
  86. package/dist/navigationpanel/actor.js +14 -15
  87. package/dist/navigationpanel/controls/BurgerButton.js +5 -7
  88. package/dist/navigationpanel/controls/NavigationButtons.js +37 -24
  89. package/dist/navigationpanel/controls/OpenSource.js +1 -1
  90. package/dist/navigationpanel/controls/SearchControl.js +6 -4
  91. package/dist/navigationpanel/controls/ToggleReadonly.js +3 -3
  92. package/dist/navigationpanel/controls/ViewDetailsCard.d.ts +2 -0
  93. package/dist/navigationpanel/controls/ViewDetailsCard.js +232 -0
  94. package/dist/navigationpanel/controls/index.d.ts +1 -0
  95. package/dist/navigationpanel/dropdown/ProjectsMenu.d.ts +2 -0
  96. package/dist/navigationpanel/dropdown/ProjectsMenu.js +75 -0
  97. package/dist/navigationpanel/editorpanel/EditorPanel.js +3 -3
  98. package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +19 -20
  99. package/dist/navigationpanel/editorpanel/styles.js +5 -5
  100. package/dist/navigationpanel/hooks.d.ts +2 -2
  101. package/dist/navigationpanel/styles.css.js +0 -2
  102. package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +12 -7
  103. 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
  104. 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
  105. package/dist/overlays/element-details/ElementDetailsCard.css.js +18 -17
  106. package/dist/overlays/element-details/ElementDetailsCard.js +8 -13
  107. package/dist/overlays/element-details/TabPanelDeployments.css.js +5 -4
  108. package/dist/overlays/element-details/TabPanelRelationships.css.js +7 -7
  109. package/dist/overlays/overlay/Overlay.css.d.ts +3 -3
  110. package/dist/overlays/overlay/Overlay.css.js +8 -7
  111. package/dist/overlays/relationship-details/SelectEdge.css.js +8 -8
  112. package/dist/overlays/relationships-browser/SelectElement.css.js +1 -1
  113. package/dist/search/Search.js +6 -6
  114. package/dist/search/components/ElementsColumn.css.js +5 -5
  115. package/dist/search/components/SearchByTags.js +3 -2
  116. package/dist/search/components/ViewsColum.js +1 -1
  117. package/dist/search/components/ViewsColumn.css.js +1 -1
  118. package/dist/search/components/_shared.css.js +3 -3
  119. package/dist/search/components/styles.css.js +5 -5
  120. package/dist/state/DiagramActorProvider.js +43 -25
  121. package/dist/state/diagram-machine.d.ts +29 -247
  122. package/dist/state/diagram-machine.js +16 -16
  123. package/dist/styles-min.css +1 -1
  124. package/dist/styles.css +1 -1
  125. package/dist/styles.css2.js +1 -1
  126. package/package.json +10 -8
  127. package/panda.buildinfo.json +254 -326
  128. package/src/LikeC4Diagram.props.ts +2 -2
  129. package/src/LikeC4Diagram.tsx +2 -2
  130. package/src/LikeC4ModelProvider.tsx +4 -4
  131. package/src/LikeC4ProjectsProvider.tsx +41 -0
  132. package/src/LikeC4Styles.tsx +107 -0
  133. package/src/StaticLikeC4Diagram.tsx +3 -3
  134. package/src/base/BaseXYFlow.tsx +24 -29
  135. package/src/base/primitives/MarkdownBlock.tsx +11 -3
  136. package/src/base/primitives/compound/CompoundActionButton.tsx +2 -2
  137. package/src/base/primitives/compound/CompoundDetailsButton.tsx +2 -2
  138. package/src/base/primitives/compound/CompoundNodeContainer.css.ts +4 -13
  139. package/src/base/primitives/compound/CompoundNodeContainer.tsx +0 -3
  140. package/src/base/primitives/compound/CompoundTitle.tsx +8 -8
  141. package/src/base/primitives/compound/actionbtns.css.ts +6 -6
  142. package/src/base/primitives/edge/EdgeActionButton.tsx +2 -2
  143. package/src/base/primitives/edge/EdgeContainer.tsx +3 -6
  144. package/src/base/primitives/edge/EdgeLabel.css.ts +4 -83
  145. package/src/base/primitives/edge/EdgeLabel.tsx +16 -10
  146. package/src/base/primitives/edge/EdgeLabelContainer.tsx +1 -6
  147. package/src/base/primitives/edge/EdgeMarkers.tsx +3 -3
  148. package/src/base/primitives/edge/edge.css.ts +0 -60
  149. package/src/base/primitives/element/ElementActionButtons.tsx +2 -2
  150. package/src/base/primitives/element/ElementDetailsButton.tsx +7 -7
  151. package/src/base/primitives/element/ElementNodeContainer.css.ts +4 -4
  152. package/src/base/primitives/element/ElementNodeContainer.tsx +0 -3
  153. package/src/base/primitives/element/ElementShape.css.ts +11 -11
  154. package/src/base/primitives/element/ElementTags.tsx +17 -14
  155. package/src/bundle/LikeC4View.props.ts +1 -2
  156. package/src/bundle/LikeC4View.tsx +10 -3
  157. package/src/bundle/ReactLikeC4.tsx +1 -2
  158. package/src/bundle/ViewNotFound.tsx +1 -1
  159. package/src/bundle/index.ts +2 -1
  160. package/src/bundle/styles.css.ts +1 -1
  161. package/src/components/ErrorFallback.tsx +1 -1
  162. package/src/components/GithubIcon.tsx +16 -0
  163. package/src/components/Link.tsx +102 -113
  164. package/src/components/NavigationLink.tsx +2 -1
  165. package/src/components/SearchControl.css.ts +5 -5
  166. package/src/context/DiagramEventHandlers.tsx +12 -12
  167. package/src/globals.css +71 -0
  168. package/src/index.ts +5 -0
  169. package/src/likec4diagram/DiagramUI.tsx +8 -2
  170. package/src/likec4diagram/custom/edges/NotePopover.css.ts +2 -2
  171. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +1 -1
  172. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.ts +7 -7
  173. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +3 -3
  174. package/src/likec4diagram/custom/edges/edges.css.ts +4 -4
  175. package/src/likec4diagram/custom/nodes/toolbar/CompoundToolbar.tsx +2 -2
  176. package/src/likec4diagram/ui/controls/styles.css.ts +5 -5
  177. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +4 -5
  178. package/src/likec4diagram/ui/notation/NotationPanel.css.ts +11 -11
  179. package/src/likec4diagram/ui/notation/NotationPanel.tsx +1 -4
  180. package/src/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.css.ts +10 -10
  181. package/src/likec4model/{LikeC4ModelContext.ts → LikeC4ModelContext.tsx} +9 -1
  182. package/src/likec4model/LikeC4ProjectsContext.ts +9 -0
  183. package/src/likec4model/index.ts +8 -0
  184. package/src/likec4model/useCurrentViewModel.ts +4 -0
  185. package/src/likec4model/useLikeC4Project.ts +61 -0
  186. package/src/navigationpanel/NavigationPanel.tsx +16 -17
  187. package/src/navigationpanel/NavigationPanelControls.tsx +24 -46
  188. package/src/navigationpanel/NavigationPanelDropdown.tsx +32 -16
  189. package/src/navigationpanel/_common.tsx +4 -1
  190. package/src/navigationpanel/actor.ts +14 -15
  191. package/src/navigationpanel/controls/BurgerButton.tsx +5 -7
  192. package/src/navigationpanel/controls/NavigationButtons.tsx +9 -1
  193. package/src/navigationpanel/controls/OpenSource.tsx +1 -1
  194. package/src/navigationpanel/controls/SearchControl.tsx +6 -4
  195. package/src/navigationpanel/controls/ToggleReadonly.tsx +3 -3
  196. package/src/navigationpanel/controls/ViewDetailsCard.tsx +244 -0
  197. package/src/navigationpanel/controls/index.ts +1 -0
  198. package/src/navigationpanel/dropdown/ProjectsMenu.tsx +74 -0
  199. package/src/navigationpanel/editorpanel/EditorPanel.tsx +3 -3
  200. package/src/navigationpanel/editorpanel/ManualLayoutToolsButton.tsx +19 -22
  201. package/src/navigationpanel/editorpanel/styles.ts +5 -5
  202. package/src/navigationpanel/hooks.tsx +2 -2
  203. package/src/navigationpanel/styles.css.ts +0 -2
  204. package/src/navigationpanel/walkthrough/ActiveWalkthroughControls.tsx +9 -4
  205. package/src/overlays/element-details/ElementDetailsCard.css.ts +17 -17
  206. package/src/overlays/element-details/ElementDetailsCard.tsx +8 -13
  207. package/src/overlays/element-details/TabPanelDeployments.css.ts +4 -4
  208. package/src/overlays/element-details/TabPanelRelationships.css.ts +7 -7
  209. package/src/overlays/overlay/Overlay.css.ts +7 -7
  210. package/src/overlays/relationship-details/SelectEdge.css.ts +8 -8
  211. package/src/overlays/relationships-browser/SelectElement.css.ts +1 -1
  212. package/src/search/Search.tsx +6 -6
  213. package/src/search/components/ElementsColumn.css.ts +5 -5
  214. package/src/search/components/SearchByTags.tsx +2 -2
  215. package/src/search/components/ViewsColum.tsx +1 -1
  216. package/src/search/components/ViewsColumn.css.ts +1 -1
  217. package/src/search/components/_shared.css.ts +3 -3
  218. package/src/search/components/styles.css.ts +5 -5
  219. package/src/state/DiagramActorProvider.tsx +56 -30
  220. package/src/state/diagram-machine.ts +22 -16
  221. package/dist/LikeC4CustomColors.d.ts +0 -2
  222. package/dist/LikeC4CustomColors.js +0 -45
  223. package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +0 -45
  224. package/src/LikeC4CustomColors.tsx +0 -85
@@ -1,119 +1,108 @@
1
1
  import type { Link as LinkData } from '@likec4/core'
2
- import { css, cva, cx } from '@likec4/styles/css'
3
- import { ActionIcon, Anchor, Box, CopyButton, Text } from '@mantine/core'
2
+ import { css, cx } from '@likec4/styles/css'
3
+ import { type BadgeProps, ActionIcon, Badge, CopyButton } from '@mantine/core'
4
4
  import { IconCheck, IconCopy } from '@tabler/icons-react'
5
- import { stopPropagation } from '../utils'
5
+ import { forwardRef } from 'react'
6
+ import { GithubIcon } from './GithubIcon'
6
7
 
7
- const link = cva({
8
- base: {
9
- display: 'flex',
10
- overflow: 'hidden',
11
- alignItems: 'center',
12
- gap: 'micro',
13
- justifyContent: 'stretch',
14
- transitionProperty: 'all',
15
- transitionDuration: 'fast',
16
- transitionTimingFunction: 'inOut',
17
- border: `1px dashed {colors.mantine.colors.defaultBorder}`,
18
- rounded: 'sm',
19
- cursor: 'pointer',
20
- color: 'mantine.colors.gray[7]',
21
- _dark: {
22
- color: 'mantine.colors.dark[1]',
23
- },
24
- _hover: {
25
- transitionTimingFunction: 'out',
26
- color: 'mantine.colors.defaultColor',
27
- background: 'mantine.colors.defaultHover',
28
- },
29
- },
30
- variants: {
31
- size: {
32
- sm: {
33
- minHeight: '22px',
34
- padding: '2px 8px 2px 2px',
35
- },
36
- md: {
37
- minHeight: '30px',
38
- padding: '3px 16px 3px 3px',
39
- },
40
- },
41
- },
42
- })
8
+ const GITHUB_PREFIX = 'https://github.com/'
43
9
 
44
- const titleBox = css({
45
- flex: '1 1 100%',
46
- transition: `transform 100ms {easings.inOut}`,
47
- _groupHover: {
48
- transitionTimingFunction: 'out',
49
- transitionDelay: '50ms',
50
- transform: 'translateX(1px)',
51
- },
52
- })
10
+ export const Link = forwardRef<HTMLDivElement, Omit<BadgeProps, 'children' | 'classNames'> & { value: LinkData }>(
11
+ ({ value, className, ...props }, ref) => {
12
+ // If the url is already a full url, use it as is.
13
+ // Otherwise, it's a relative url and we need to make it absolute.
14
+ const url = value.url.includes('://') ? value.url : new window.URL(value.url, window.location.href).toString()
15
+ let isGithub = url.startsWith(GITHUB_PREFIX)
53
16
 
54
- export function Link({
55
- value,
56
- size = 'md',
57
- }: {
58
- size?: 'sm' | 'md'
59
- value: LinkData
60
- }) {
61
- const isNormalSize = size === 'md'
62
- // If the url is already a full url, use it as is.
63
- // Otherwise, it's a relative url and we need to make it absolute.
64
- const url = value.url.includes('://') ? value.url : new window.URL(value.url, window.location.href).toString()
65
- return (
66
- <CopyButton value={url}>
67
- {({ copied, copy }) => (
68
- <Anchor
69
- href={url}
70
- target="_blank"
71
- underline="never"
72
- className={cx(
73
- 'group',
74
- link({ size }),
75
- )}
76
- onClick={stopPropagation}>
77
- <ActionIcon
78
- className={css({
79
- flex: '0',
80
- })}
81
- tabIndex={-1}
82
- size={isNormalSize ? 24 : 20}
83
- variant={copied ? 'light' : 'subtle'}
84
- color={copied ? 'teal' : 'gray'}
85
- onClick={e => {
86
- e.stopPropagation()
87
- e.preventDefault()
88
- copy()
89
- }}
90
- >
91
- {copied ? <IconCheck /> : <IconCopy style={{ width: '65%', opacity: 0.65 }} />}
92
- </ActionIcon>
93
- <Box className={titleBox}>
94
- <Text
95
- component="div"
96
- fz={isNormalSize ? 'xs' : 11}
97
- truncate
98
- lh={isNormalSize ? 1.3 : 1.2}
99
- fw={value.title ? 500 : 400}>
100
- {value.title || url}
101
- </Text>
102
- {value.title && (
103
- <Text component="div" fz={isNormalSize ? 10 : 9} c={'dimmed'} lh={isNormalSize ? 1.2 : 1.1} truncate>
104
- {url}
105
- </Text>
17
+ return (
18
+ <Badge
19
+ ref={ref}
20
+ variant="default"
21
+ radius="sm"
22
+ size="sm"
23
+ tt="none"
24
+ leftSection={value.title ? <>{value.title}</> : null}
25
+ rightSection={
26
+ <CopyButton value={url} timeout={1500}>
27
+ {({ copy, copied }) => (
28
+ <ActionIcon
29
+ className={css({
30
+ opacity: copied ? 1 : 0.45,
31
+ transition: 'fast',
32
+ _hover: {
33
+ opacity: 1,
34
+ },
35
+ })}
36
+ tabIndex={-1}
37
+ size={'20'}
38
+ variant={copied ? 'light' : 'transparent'}
39
+ color={copied ? 'teal' : 'gray'}
40
+ data-active={copied}
41
+ onClick={e => {
42
+ e.stopPropagation()
43
+ e.preventDefault()
44
+ copy()
45
+ }}
46
+ >
47
+ {copied ? <IconCheck /> : <IconCopy stroke={2.5} />}
48
+ </ActionIcon>
106
49
  )}
107
- </Box>
108
- </Anchor>
109
- )}
110
- </CopyButton>
111
- )
112
- // <Anchor href={value.url} fz={'sm'}>
113
- // {value.title || url}
114
- // </Anchor><Button variant='default' size='sm'>
115
- // {value.title || value.url}
116
- // </Button>
117
- // </Box>
118
- // )
119
- }
50
+ </CopyButton>
51
+ }
52
+ {...props}
53
+ className={cx(className, 'group')}
54
+ classNames={{
55
+ root: css({
56
+ flexWrap: 'nowrap',
57
+ minHeight: 24,
58
+ maxWidth: 500,
59
+ userSelect: 'all',
60
+ pr: '0',
61
+ _hover: {
62
+ backgroundColor: {
63
+ base: 'mantine.colors.gray[1]',
64
+ _dark: 'mantine.colors.dark[5]',
65
+ },
66
+ },
67
+ }),
68
+ section: css({
69
+ '&:is([data-position="left"])': {
70
+ color: 'mantine.colors.dimmed',
71
+ userSelect: 'none',
72
+ pointerEvents: 'none',
73
+ _groupHover: {
74
+ color: '[inherit]',
75
+ opacity: .7,
76
+ },
77
+ },
78
+ }),
79
+ label: css({
80
+ '& > a': {
81
+ color: '[inherit]',
82
+ cursor: 'pointer',
83
+ transition: 'fast',
84
+ opacity: {
85
+ base: 0.7,
86
+ _hover: 1,
87
+ },
88
+ textDecoration: {
89
+ base: 'none',
90
+ _hover: 'underline',
91
+ },
92
+ },
93
+ }),
94
+ }}
95
+ >
96
+ <a href={url} target="_blank">
97
+ {isGithub && (
98
+ <GithubIcon
99
+ height="12"
100
+ width="12"
101
+ style={{ verticalAlign: 'middle', marginRight: '4px' }} />
102
+ )}
103
+ {isGithub ? url.replace(GITHUB_PREFIX, '') : url}
104
+ </a>
105
+ </Badge>
106
+ )
107
+ },
108
+ )
@@ -2,9 +2,10 @@ import { cx } from '@likec4/styles/css'
2
2
  import { navigationLink } from '@likec4/styles/recipes'
3
3
  import { type NavLinkProps, NavLink } from '@mantine/core'
4
4
  import { forwardRef } from 'react'
5
+ import { type ComponentPropsWithoutRef } from 'react'
5
6
 
6
7
  export interface NavigationLinkProps
7
- extends NavLinkProps, Omit<React.ComponentPropsWithoutRef<'button'>, keyof NavLinkProps>
8
+ extends Omit<NavLinkProps, 'classNames'>, Omit<ComponentPropsWithoutRef<'button'>, keyof NavLinkProps>
8
9
  {
9
10
  truncateLabel?: boolean
10
11
  }
@@ -3,7 +3,7 @@ import { css } from '@likec4/styles/css'
3
3
  export const root = css({
4
4
  height: '30px',
5
5
  paddingLeft: 'sm',
6
- paddingRight: '4px',
6
+ paddingRight: '1',
7
7
  borderRadius: 'sm',
8
8
  // TODO
9
9
  // color: fallbackVar('var(--search-color)', 'mantine.colors.placeholder)',
@@ -41,14 +41,14 @@ export const root = css({
41
41
  export const placeholder = css({
42
42
  fontSize: 'sm', // mantine.fontSizes.sm,
43
43
  fontWeight: 500,
44
- paddingRight: '10px',
44
+ paddingRight: '2.5', // 10px
45
45
  color: 'mantine.colors.placeholder',
46
46
  flex: '1',
47
47
  sm: {
48
- paddingRight: '30px',
48
+ paddingRight: '[30px]',
49
49
  },
50
50
  md: {
51
- paddingRight: '50px',
51
+ paddingRight: '[50px]',
52
52
  },
53
53
  })
54
54
 
@@ -56,7 +56,7 @@ export const shortcut = css({
56
56
  fontSize: '11px',
57
57
  fontWeight: 600,
58
58
  lineHeight: 1,
59
- padding: '4px 7px',
59
+ padding: '[4px 7px]',
60
60
  borderRadius: 'sm',
61
61
  border: '1px solid',
62
62
  transition: 'fast',
@@ -1,4 +1,4 @@
1
- import type { Any } from '@likec4/core/types'
1
+ import type { aux } from '@likec4/core/types'
2
2
  import { useSyncedRef } from '@react-hookz/web'
3
3
  import { type PropsWithChildren, type RefObject, createContext, useContext, useMemo } from 'react'
4
4
  import { isFunction, mapToObj } from 'remeda'
@@ -22,18 +22,18 @@ const HandlerNames = [
22
22
  'onCanvasDblClick',
23
23
  ] as const
24
24
 
25
- type DiagramEventHandlersContextValue = RequiredOrNull<LikeC4DiagramEventHandlers<Any>> & {
26
- handlersRef: RefObject<LikeC4DiagramEventHandlers<Any>>
25
+ export type DiagramEventHandlersContext = RequiredOrNull<LikeC4DiagramEventHandlers<aux.Any>> & {
26
+ handlersRef: RefObject<LikeC4DiagramEventHandlers<aux.Any>>
27
27
  }
28
28
 
29
- const DiagramEventHandlersContext = createContext<DiagramEventHandlersContextValue>({
29
+ const DiagramEventHandlersReactContext = createContext<DiagramEventHandlersContext>({
30
30
  ...mapToObj(HandlerNames, (name) => [name, null]),
31
31
  handlersRef: {
32
32
  current: {},
33
33
  },
34
34
  })
35
35
 
36
- export function DiagramEventHandlers<A extends Any>({
36
+ export function DiagramEventHandlers<A extends aux.Any>({
37
37
  handlers,
38
38
  children,
39
39
  }: PropsWithChildren<{ handlers: LikeC4DiagramEventHandlers<A> }>) {
@@ -41,7 +41,7 @@ export function DiagramEventHandlers<A extends Any>({
41
41
 
42
42
  const deps = HandlerNames.map((name) => isFunction(handlers[name]))
43
43
 
44
- const value = useMemo((): DiagramEventHandlersContextValue => ({
44
+ const value = useMemo((): DiagramEventHandlersContext => ({
45
45
  ...mapToObj(HandlerNames, (name) => {
46
46
  if (handlersRef.current[name]) {
47
47
  // @ts-expect-error TODO: fix this
@@ -53,16 +53,16 @@ export function DiagramEventHandlers<A extends Any>({
53
53
  }), [handlersRef, ...deps])
54
54
 
55
55
  return (
56
- <DiagramEventHandlersContext.Provider value={value}>
56
+ <DiagramEventHandlersReactContext.Provider value={value}>
57
57
  {children}
58
- </DiagramEventHandlersContext.Provider>
58
+ </DiagramEventHandlersReactContext.Provider>
59
59
  )
60
60
  }
61
61
 
62
- export function useDiagramEventHandlers() {
63
- return useContext(DiagramEventHandlersContext)
62
+ export function useDiagramEventHandlers(): DiagramEventHandlersContext {
63
+ return useContext(DiagramEventHandlersReactContext)
64
64
  }
65
65
 
66
- export function useDiagramEventHandlersRef() {
67
- return useContext(DiagramEventHandlersContext).handlersRef
66
+ export function useDiagramEventHandlersRef<A extends aux.Any = aux.Any>(): RefObject<LikeC4DiagramEventHandlers<A>> {
67
+ return useContext(DiagramEventHandlersReactContext).handlersRef
68
68
  }
@@ -0,0 +1,71 @@
1
+ .likec4-root {
2
+ overflow: hidden;
3
+ position: relative;
4
+ padding: 0;
5
+ margin: 0;
6
+ width: 100%;
7
+ height: 100%;
8
+ border: 0px solid transparent;
9
+ container-name: likec4-root;
10
+ container-type: size;
11
+ }
12
+ .likec4-root .react-flow:is(.not-initialized) {
13
+ opacity: 0;
14
+ }
15
+ :where(.likec4-root .mantine-ActionIcon-icon) .tabler-icon {
16
+ width: 75%;
17
+ height: 75%;
18
+ }
19
+
20
+ .likec4-root :where(.react-flow__node, .react-flow__edge, .likec4-edge-label-container):has([data-likec4-dimmed]) {
21
+ opacity: 0.25;
22
+ }
23
+
24
+ .likec4-root:not([data-likec4-reduced-graphics])
25
+ :where(.react-flow__node, .react-flow__edge, .likec4-edge-label-container):has([data-likec4-dimmed]) {
26
+ filter: grayscale(85%) blur(3px);
27
+ }
28
+
29
+ .likec4-root:not([data-likec4-reduced-graphics])
30
+ :where(.react-flow__node, .react-flow__edge, .likec4-edge-label-container):has([data-likec4-dimmed="true"]) {
31
+ transition-property: opacity, filter;
32
+ transition-timing-function: cubic-bezier(0.50, 0, 0.2, 1);
33
+ transition-duration: 600ms;
34
+ }
35
+
36
+ [data-mantine-color-scheme="dark"]
37
+ .likec4-root:not([data-likec4-reduced-graphics])
38
+ :where(.react-flow__edges, .react-flow__edgelabel-renderer)
39
+ > svg {
40
+ mix-blend-mode: plus-lighter;
41
+ }
42
+
43
+ [data-mantine-color-scheme="light"]
44
+ .likec4-root:not([data-likec4-reduced-graphics])
45
+ :where(.react-flow__edges, .react-flow__edgelabel-renderer)
46
+ > svg {
47
+ mix-blend-mode: screen;
48
+ }
49
+
50
+ .likec4-root :where(.likec4-edge-container, .likec4-edge-label-container) {
51
+ --xy-edge-stroke-width: 3;
52
+ --xy-edge-stroke: var(--likec4-palette-relation-stroke);
53
+ --xy-edge-stroke-selected: var(--likec4-palette-relation-stroke-selected);
54
+ --xy-edge-label-color: var(--likec4-palette-relation-label);
55
+ --xy-edge-label-background-color: var(--likec4-palette-relation-label-bg);
56
+ }
57
+
58
+ .likec4-root
59
+ :where(.likec4-edge-container, .likec4-edge-label-container):is([data-likec4-hovered="true"], [data-edge-active="true"]) {
60
+ --xy-edge-stroke-width: 4;
61
+ --xy-edge-stroke: var(--likec4-palette-relation-stroke-selected);
62
+ }
63
+
64
+ [data-mantine-color-scheme="dark"] .likec4-root :where(.likec4-edge-container, .likec4-edge-label-container) {
65
+ --xy-edge-label-background-color: color-mix(in srgb, var(--likec4-palette-relation-label-bg) 50%, transparent);
66
+ }
67
+
68
+ [data-mantine-color-scheme="light"] .likec4-root :where(.likec4-edge-container, .likec4-edge-label-container) {
69
+ --xy-edge-label-color: color-mix(in srgb, var(--likec4-palette-relation-label), rgba(255 255 255 / 0.85) 40%);
70
+ --xy-edge-label-background-color: color-mix(in srgb, var(--likec4-palette-relation-label-bg) 60%, transparent);
71
+ }
package/src/index.ts CHANGED
@@ -17,6 +17,11 @@ export {
17
17
  type LikeC4ModelProviderProps,
18
18
  } from './LikeC4ModelProvider'
19
19
 
20
+ export {
21
+ LikeC4ProjectsProvider,
22
+ type LikeC4ProjectsProviderProps,
23
+ } from './LikeC4ProjectsProvider'
24
+
20
25
  export * from './custom/hooks'
21
26
 
22
27
  export type {
@@ -2,6 +2,7 @@ import { memo } from 'react'
2
2
  import { useEnabledFeatures } from '../context'
3
3
  import { useOverlaysActorRef } from '../hooks/useOverlaysActor'
4
4
  import { useSearchActorRef } from '../hooks/useSearchActor'
5
+ import { EnsureCurrentViewModel } from '../likec4model/LikeC4ModelContext'
5
6
  import { NavigationPanel } from '../navigationpanel'
6
7
  import { Overlays } from '../overlays/Overlays'
7
8
  import { Search } from '../search/Search'
@@ -15,13 +16,18 @@ export const DiagramUI = memo(() => {
15
16
  enableDynamicViewWalkthrough,
16
17
  enableSearch,
17
18
  } = useEnabledFeatures()
18
-
19
19
  const overlaysActorRef = useOverlaysActorRef()
20
20
  const searchActorRef = useSearchActorRef()
21
21
 
22
22
  return (
23
23
  <>
24
- {enableControls === 'next' ? <NavigationPanel /> : <Controls />}
24
+ {enableControls === 'next'
25
+ ? (
26
+ <EnsureCurrentViewModel>
27
+ <NavigationPanel />
28
+ </EnsureCurrentViewModel>
29
+ )
30
+ : <Controls />}
25
31
  {overlaysActorRef && <Overlays overlaysActorRef={overlaysActorRef} />}
26
32
  {enableNotations && <NotationPanel />}
27
33
  {enableControls !== 'next' && (
@@ -3,8 +3,8 @@ import { css } from '@likec4/styles/css'
3
3
 
4
4
  export const edgeNoteCloseButton = css({
5
5
  position: 'absolute',
6
- top: 1,
7
- right: 1,
6
+ top: '[1px]',
7
+ right: '[1px]',
8
8
  zIndex: 9,
9
9
  })
10
10
 
@@ -324,7 +324,7 @@ export const RelationshipEdge = customEdge<Types.RelationshipEdgeData>((props) =
324
324
  const notes = props.data.notes
325
325
  if (notes && activeWalkthroughStep === props.id) {
326
326
  edgeLabel = (
327
- <NotePopover notes={notes}>
327
+ <NotePopover notes={notes.txt ?? notes.md}>
328
328
  {edgeLabel}
329
329
  </NotePopover>
330
330
  )
@@ -7,7 +7,7 @@ export const menuDropdown = css({
7
7
  })
8
8
 
9
9
  export const menuItemRelationship = css({
10
- gap: 4,
10
+ gap: '1',
11
11
  })
12
12
 
13
13
  export const endpoint = css({
@@ -15,17 +15,17 @@ export const endpoint = css({
15
15
  fontSize: 'xxs',
16
16
  fontWeight: 500,
17
17
  whiteSpace: 'nowrap',
18
- padding: '2px 4px',
19
- borderRadius: 2,
20
- background: `likec4.palette.fill/30`,
18
+ padding: '[2px 4px]',
19
+ borderRadius: '[2px]',
20
+ background: `var(--likec4-palette-fill)/30`,
21
21
  lineHeight: '[1.11]',
22
22
  mixBlendMode: 'hard-light',
23
23
  color: {
24
- _light: `[color-mix(in srgb, {colors.likec4.palette.stroke}, {colors.likec4.mixColor} 60%)]`,
25
- _dark: 'likec4.palette.loContrast',
24
+ _light: `[color-mix(in srgb, var(--likec4-palette-stroke), {colors.likec4.mixColor} 60%)]`,
25
+ _dark: 'var(--likec4-palette-loContrast)',
26
26
  },
27
27
  // _dark: {
28
- // background: `likec4.palette.fill/60`,
28
+ // background: `var(--likec4-palette-fill)/60`,
29
29
  // },
30
30
  })
31
31
 
@@ -5,7 +5,7 @@ import {
5
5
  nameFromFqn,
6
6
  } from '@likec4/core'
7
7
  import type { LikeC4Model } from '@likec4/core/model'
8
- import { css, cx } from '@likec4/styles/css'
8
+ import { cx } from '@likec4/styles/css'
9
9
  import {
10
10
  type StackProps,
11
11
  ActionIcon,
@@ -203,11 +203,11 @@ const Relationship = forwardRef<
203
203
  return (
204
204
  <Stack ref={ref} className={cx(styles.menuItemRelationship, className)} {...props}>
205
205
  <Group gap={4}>
206
- <Text component="div" className={cx(css({ likec4Palette: sourceNode.color }), styles.endpoint)}>
206
+ <Text component="div" data-likec4-color={sourceNode.color} className={styles.endpoint}>
207
207
  {sourceId}
208
208
  </Text>
209
209
  <IconArrowRight stroke={2.5} size={'11px'} opacity={0.65} />
210
- <Text component="div" className={cx(css({ likec4Palette: targetNode.color }), styles.endpoint)}>
210
+ <Text component="div" data-likec4-color={targetNode.color} className={styles.endpoint}>
211
211
  {targetId}
212
212
  </Text>
213
213
  {(navigateTo || !!onOpenSource) && (
@@ -6,14 +6,14 @@ export const controlPointsContainer = css({
6
6
  overflow: 'visible',
7
7
  position: 'absolute',
8
8
  pointerEvents: 'none',
9
- top: 0,
10
- left: 0,
9
+ top: '0',
10
+ left: '0',
11
11
  mixBlendMode: 'normal',
12
12
  })
13
13
 
14
14
  export const controlPoint = css({
15
- fill: `likec4.relation.stroke`,
16
- stroke: `likec4.relation.stroke`,
15
+ fill: `var(--likec4-palette-relation-stroke)`,
16
+ stroke: `var(--likec4-palette-relation-stroke)`,
17
17
  fillOpacity: 0.75,
18
18
  strokeWidth: 1,
19
19
  cursor: 'grab',
@@ -105,8 +105,8 @@ function BorderStyleOption({
105
105
  }}
106
106
  styles={{
107
107
  label: {
108
- paddingTop: 2,
109
- paddingBottom: 2,
108
+ paddingTop: '0.5',
109
+ paddingBottom: '0.5',
110
110
  },
111
111
  }}
112
112
  data={[
@@ -1,16 +1,16 @@
1
1
  import { css } from '@likec4/styles/css'
2
2
 
3
3
  export const navigationButtons = css({
4
- gap: 'micro',
4
+ gap: 'xxs',
5
5
  _empty: {
6
6
  display: 'none',
7
7
  },
8
8
  })
9
9
 
10
10
  export const panel = css({
11
- top: '1rem',
12
- left: '1rem',
13
- margin: 0,
11
+ top: 'md',
12
+ left: 'md',
13
+ margin: '0',
14
14
  pointerEvents: 'none',
15
15
  '& :where(button, .action-icon, [role=\'dialog\'])': {
16
16
  pointerEvents: 'all',
@@ -47,7 +47,7 @@ export const autolayoutButton = css({
47
47
  flex: '1 1 40%',
48
48
  textAlign: 'center',
49
49
  fontWeight: 500,
50
- padding: '4px 6px',
50
+ padding: '[4px 6px]',
51
51
  fontSize: '11px',
52
52
  zIndex: 1,
53
53
  })
@@ -1,4 +1,3 @@
1
- import { RichText } from '@likec4/core/types'
2
1
  import { cx as clsx } from '@likec4/styles/css'
3
2
  import { Button, Card, CardSection, Group, Spoiler, Stack, Text } from '@mantine/core'
4
3
  import { useLocalStorage } from '@mantine/hooks'
@@ -7,7 +6,7 @@ import { AnimatePresence, m } from 'motion/react'
7
6
  import { MarkdownBlock } from '../../../base/primitives'
8
7
  import { Link } from '../../../components/Link'
9
8
  import { useDiagramContext } from '../../../hooks/useDiagram'
10
- import { useCurrentViewModel } from '../../../likec4model'
9
+ import { useOptionalCurrentViewModel } from '../../../likec4model/useCurrentViewModel'
11
10
  import type { DiagramContext } from '../../../state/types'
12
11
  import * as styles from './DiagramTitlePanel.css'
13
12
 
@@ -22,13 +21,13 @@ function selector(context: DiagramContext) {
22
21
  }
23
22
 
24
23
  export function DiagramTitlePanel() {
25
- const view = useCurrentViewModel()
24
+ const view = useOptionalCurrentViewModel()
26
25
  const { isNotActiveWalkthrough } = useDiagramContext(selector)
27
26
  const [isCollapsed, setCollapsed] = useLocalStorage({
28
27
  key: 'diagram-title-webview-collapsed',
29
28
  defaultValue: false,
30
29
  })
31
- const title = view.title ?? 'untitled'
30
+ const title = view?.title ?? 'untitled'
32
31
  const toggle = () => setCollapsed(v => !v)
33
32
 
34
33
  return (
@@ -49,7 +48,7 @@ export function DiagramTitlePanel() {
49
48
  </div>
50
49
  </ViewportPortal> */
51
50
  }
52
- {isNotActiveWalkthrough && (
51
+ {view && isNotActiveWalkthrough && (
53
52
  <m.div
54
53
  initial={{ opacity: 0.05, scale: 0.7 }}
55
54
  animate={{ opacity: 1, scale: 1 }}