@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,12 +1,12 @@
1
1
  import type {
2
2
  Any,
3
+ aux,
3
4
  DiagramEdge,
4
5
  DiagramNode,
5
6
  LayoutedView,
6
7
  ViewChange,
7
8
  WhereOperator,
8
9
  } from '@likec4/core/types'
9
- import type * as aux from '@likec4/core/types/_aux'
10
10
  import type { ReactFlowProps as XYFlowProps } from '@xyflow/react'
11
11
  import type { MouseEvent as ReactMouseEvent, ReactNode } from 'react'
12
12
  import type { SetRequired } from 'type-fest'
@@ -319,7 +319,7 @@ export type OpenSourceParams<A extends aux.Any = aux.Any> =
319
319
  view: aux.StrictViewId<A>
320
320
  }
321
321
 
322
- export interface LikeC4DiagramEventHandlers<A extends aux.Any> {
322
+ export interface LikeC4DiagramEventHandlers<A extends aux.Any = aux.Any> {
323
323
  onChange?: OnChange | null | undefined
324
324
  onNavigateTo?: OnNavigateTo<A> | null | undefined
325
325
  onNodeClick?: OnNodeClick<A> | null | undefined
@@ -11,10 +11,10 @@ import {
11
11
  } from './context'
12
12
  import { ControlsCustomLayoutProvider } from './context/ControlsCustomLayout'
13
13
  import { ReduceGraphicsContext } from './context/ReduceGraphics'
14
- import { LikeC4CustomColors } from './LikeC4CustomColors'
15
14
  import { type LikeC4DiagramEventHandlers, type LikeC4DiagramProperties } from './LikeC4Diagram.props'
16
15
  import { LikeC4DiagramXYFlow } from './likec4diagram/DiagramXYFlow'
17
16
  import type { Types } from './likec4diagram/types'
17
+ import { LikeC4Styles } from './LikeC4Styles'
18
18
  import { DiagramActorProvider } from './state/DiagramActorProvider'
19
19
 
20
20
  export type LikeC4DiagramProps<A extends Any = Any> = PropsWithChildren<
@@ -129,8 +129,8 @@ export function LikeC4Diagram<A extends Any = Any>({
129
129
  onBurgerMenuClick,
130
130
  }}>
131
131
  <ReduceGraphicsContext reduceGraphics={isReducedGraphicsMode}>
132
+ <LikeC4Styles />
132
133
  <RootContainer className={className} reduceGraphics={isReducedGraphicsMode}>
133
- <LikeC4CustomColors />
134
134
  <XYFlowProvider
135
135
  fitView={fitView}
136
136
  {...initialRef.current}
@@ -1,11 +1,11 @@
1
- import type { LikeC4Model } from '@likec4/core/model'
1
+ import { LikeC4Model } from '@likec4/core/model'
2
2
  import type { aux } from '@likec4/core/types'
3
3
  import { type PropsWithChildren } from 'react'
4
4
  import { LikeC4ModelContext } from './likec4model/LikeC4ModelContext'
5
5
 
6
- export type LikeC4ModelProviderProps<A extends aux.Any = aux.Unknown> = PropsWithChildren<{
6
+ export interface LikeC4ModelProviderProps<A extends aux.Any = aux.Unknown> {
7
7
  likec4model: LikeC4Model<A>
8
- }>
8
+ }
9
9
 
10
10
  /**
11
11
  * Ensures LikeC4Model context
@@ -13,7 +13,7 @@ export type LikeC4ModelProviderProps<A extends aux.Any = aux.Unknown> = PropsWit
13
13
  export function LikeC4ModelProvider<A extends aux.Any = aux.Unknown>({
14
14
  children,
15
15
  likec4model,
16
- }: LikeC4ModelProviderProps<A>) {
16
+ }: PropsWithChildren<LikeC4ModelProviderProps<A>>) {
17
17
  return (
18
18
  <LikeC4ModelContext.Provider value={likec4model}>
19
19
  {children}
@@ -0,0 +1,41 @@
1
+ import type { LikeC4Project, ProjectId } from '@likec4/core/types'
2
+ import { useCallbackRef } from '@mantine/hooks'
3
+ import { useCustomCompareMemo } from '@react-hookz/web'
4
+ import { shallowEqual } from 'fast-equals'
5
+ import { type PropsWithChildren, useContext } from 'react'
6
+ import { LikeC4ProjectsContext } from './likec4model/LikeC4ProjectsContext'
7
+
8
+ export interface LikeC4ProjectsProviderProps {
9
+ /**
10
+ * Projects to be used in the navigation panel.
11
+ * Current project is taken from the LikeC4Model
12
+ */
13
+ projects: ReadonlyArray<LikeC4Project>
14
+
15
+ /**
16
+ * Optional callback when another project is selected.
17
+ */
18
+ onProjectChange?: (id: ProjectId) => void
19
+ }
20
+
21
+ /**
22
+ * Ensures LikeC4Projects context
23
+ */
24
+ export function LikeC4ProjectsProvider({
25
+ children,
26
+ projects,
27
+ onProjectChange: _onProjectChange,
28
+ }: PropsWithChildren<LikeC4ProjectsProviderProps>) {
29
+ const outerScope = useContext(LikeC4ProjectsContext)
30
+ if (outerScope) {
31
+ console.warn('LikeC4ProjectsProvider should not be nested inside another one')
32
+ }
33
+
34
+ const onProjectChange = useCallbackRef(_onProjectChange)
35
+ const value = useCustomCompareMemo(() => ({ projects, onProjectChange }), [projects, onProjectChange], shallowEqual)
36
+ return (
37
+ <LikeC4ProjectsContext.Provider value={value}>
38
+ {children}
39
+ </LikeC4ProjectsContext.Provider>
40
+ )
41
+ }
@@ -0,0 +1,107 @@
1
+ import {
2
+ type CustomColorDefinitions,
3
+ type ThemeColorValues,
4
+ defaultTheme,
5
+ ThemeColors,
6
+ } from '@likec4/core'
7
+ import { useMantineStyleNonce } from '@mantine/core'
8
+ import { mix, scale, toHex, toRgba } from 'khroma'
9
+ import { entries, join, map, pipe, range } from 'remeda'
10
+ import globalsCss from './globals.css?inline'
11
+ import { useLikeC4Specification } from './likec4model'
12
+
13
+ const scheme = (scheme: 'dark' | 'light') => `[data-mantine-color-scheme="${scheme}"]`
14
+
15
+ const whenDark = scheme('dark')
16
+ const whenLight = scheme('light')
17
+
18
+ const MAX_DEPTH = 5
19
+ const generateCompoundColors = (name: string, colors: ThemeColorValues, depth: number) => {
20
+ const compoundDarkColor = (color: string) =>
21
+ toHex(
22
+ scale(color, {
23
+ l: -22 - 5 * depth,
24
+ s: -10 - 6 * depth,
25
+ }),
26
+ )
27
+ const compoundLightColor = (color: string) =>
28
+ toHex(
29
+ scale(color, {
30
+ l: -20 - 3 * depth,
31
+ s: -3 - 6 * depth,
32
+ }),
33
+ )
34
+ const selector = `:where([data-likec4-color="${name}"][data-compound-depth="${depth}"])`
35
+
36
+ return `
37
+ ${selector} {
38
+ --likec4-palette-fill: ${compoundLightColor(colors.elements.fill)};
39
+ --likec4-palette-stroke: ${compoundLightColor(colors.elements.stroke)};
40
+ }
41
+ ${whenDark} ${selector} {
42
+ --likec4-palette-fill: ${compoundDarkColor(colors.elements.fill)};
43
+ --likec4-palette-stroke: ${compoundDarkColor(colors.elements.stroke)};
44
+ }
45
+ `.trim()
46
+ }
47
+
48
+ function toStyle(name: string, colors: ThemeColorValues): string {
49
+ const selector = `:where([data-likec4-color=${name}])`
50
+ return [
51
+ `
52
+ ${selector} {
53
+ --likec4-palette-fill: ${colors.elements.fill};
54
+ --likec4-palette-stroke: ${colors.elements.stroke};
55
+ --likec4-palette-hiContrast: ${colors.elements.hiContrast};
56
+ --likec4-palette-loContrast: ${colors.elements.loContrast};
57
+ --likec4-palette-relation-stroke: ${colors.relationships.lineColor};
58
+ --likec4-palette-relation-label: ${colors.relationships.labelColor};
59
+ --likec4-palette-relation-label-bg: ${colors.relationships.labelBgColor};
60
+ }
61
+ ${whenLight} ${selector} {
62
+ --likec4-palette-relation-stroke-selected: ${toRgba(mix(colors.relationships.lineColor, 'black', 85))};
63
+ }
64
+ ${whenDark} ${selector} {
65
+ --likec4-palette-relation-stroke-selected: ${toRgba(mix(colors.relationships.lineColor, 'white', 70))};
66
+ }
67
+
68
+ `.trim(),
69
+ ...range(1, MAX_DEPTH + 1).map((depth) => generateCompoundColors(name, colors, depth)),
70
+ ].join('\n')
71
+ }
72
+
73
+ const builtInColors = ThemeColors.map((color) =>
74
+ toStyle(color, {
75
+ elements: defaultTheme.elements[color],
76
+ relationships: defaultTheme.relationships[color],
77
+ })
78
+ ).join('\n')
79
+
80
+ function generateCustomColorStyles(customColors: CustomColorDefinitions) {
81
+ return pipe(
82
+ entries(customColors),
83
+ map(([name, color]) => toStyle(name, color)),
84
+ join('\n'),
85
+ )
86
+ }
87
+
88
+ export function LikeC4Styles() {
89
+ const nonce = useMantineStyleNonce()?.()
90
+
91
+ const customColors = useLikeC4Specification().customColors
92
+ const customColorsStyles = customColors ? generateCustomColorStyles(customColors) : ''
93
+
94
+ return (
95
+ <>
96
+ <style type="text/css" data-likec4-global dangerouslySetInnerHTML={{ __html: globalsCss }} nonce={nonce} />
97
+ <style type="text/css" data-likec4-colors dangerouslySetInnerHTML={{ __html: builtInColors }} nonce={nonce} />
98
+ {customColorsStyles && (
99
+ <style
100
+ type="text/css"
101
+ data-likec4-custom-colors
102
+ dangerouslySetInnerHTML={{ __html: customColorsStyles }}
103
+ nonce={nonce} />
104
+ )}
105
+ </>
106
+ )
107
+ }
@@ -1,8 +1,8 @@
1
- import type * as aux from '@likec4/core/types/_aux'
1
+ import type { Any, UnknownLayouted } from '@likec4/core/types'
2
2
  import { LikeC4Diagram } from './LikeC4Diagram'
3
3
  import type { LikeC4DiagramProperties } from './LikeC4Diagram.props'
4
4
 
5
- export type StaticLikeC4DiagramProps<A extends aux.Any> = Pick<
5
+ export type StaticLikeC4DiagramProps<A extends Any> = Pick<
6
6
  LikeC4DiagramProperties<A>,
7
7
  | 'view'
8
8
  | 'className'
@@ -21,7 +21,7 @@ export type StaticLikeC4DiagramProps<A extends aux.Any> = Pick<
21
21
  | 'where'
22
22
  >
23
23
 
24
- export function StaticLikeC4Diagram<A extends aux.Any = aux.UnknownLayouted>({
24
+ export function StaticLikeC4Diagram<A extends Any = UnknownLayouted>({
25
25
  view,
26
26
  fitView = true,
27
27
  fitViewPadding = '8px',
@@ -1,4 +1,4 @@
1
- import { css, cx } from '@likec4/styles/css'
1
+ import { css, cva, cx } from '@likec4/styles/css'
2
2
  import { useCallbackRef } from '@mantine/hooks'
3
3
  import {
4
4
  type ReactFlowProps,
@@ -6,7 +6,7 @@ import {
6
6
  ReactFlow,
7
7
  useStore,
8
8
  } from '@xyflow/react'
9
- import { Fragment, useMemo } from 'react'
9
+ import { Fragment } from 'react'
10
10
  import type { SetRequired, Simplify } from 'type-fest'
11
11
  import { useUpdateEffect } from '../hooks/useUpdateEffect'
12
12
  import { useIsZoomTooSmall, useXYStoreApi } from '../hooks/useXYFlow'
@@ -44,32 +44,26 @@ export type BaseXYFlowProps<NodeType extends Base.Node, EdgeType extends Base.Ed
44
44
  >
45
45
  >
46
46
 
47
- const cssTransparentBg = css({
48
- background: 'transparent !important',
49
- ['--xy-background-color']: 'transparent !important',
50
- })
51
-
52
- const cssReactFlow = css({
53
- // '@supports': {
54
- // // https://wojtek.im/journal/targeting-safari-with-css-media-query
55
- // '(hanging-punctuation: first) and (font: -apple-system-body) and (-webkit-appearance: none)': {
56
- // // TODO: this workaround disables animations in Safari (to improve performance)
57
- // vars: {
58
- // [vars.safariAnimationHook]: '',
59
- // },
60
- // },
61
- // },
62
-
63
- ['--xy-background-color']: '{colors.mantine.colors.body}',
64
- ['--xy-background-pattern-color']: {
65
- _dark: '{colors.mantine.colors.dark[5]}',
66
- _light: '{colors.mantine.colors.gray[4]}',
67
- },
68
- '& .react-flow__pane': {
69
- WebkitUserSelect: 'none',
47
+ const cssReactFlow = cva({
48
+ base: {
49
+ '& .react-flow__pane': {
50
+ WebkitUserSelect: 'none',
51
+ },
52
+ '& .react-flow__attribution': {
53
+ display: 'none',
54
+ },
70
55
  },
71
- '& .react-flow__attribution': {
72
- display: 'none',
56
+ variants: {
57
+ transparent: {
58
+ true: {
59
+ background: 'transparent !important',
60
+ ['--xy-background-color']: 'transparent !important',
61
+ },
62
+ false: {
63
+ ['--xy-background-color']: '{colors.likec4.background}',
64
+ ['--xy-background-pattern-color']: '{colors.likec4.background.pattern}',
65
+ },
66
+ },
73
67
  },
74
68
  })
75
69
 
@@ -106,8 +100,9 @@ export const BaseXYFlow = <
106
100
  nodes={nodes}
107
101
  edges={edges}
108
102
  className={cx(
109
- cssReactFlow,
110
- background === 'transparent' && cssTransparentBg,
103
+ cssReactFlow({
104
+ transparent: background === 'transparent',
105
+ }),
111
106
  className,
112
107
  )}
113
108
  {...isZoomTooSmall && {
@@ -1,7 +1,8 @@
1
1
  import { type RichTextOrEmpty as RichTextType } from '@likec4/core/types'
2
2
  import { cx } from '@likec4/styles/css'
3
3
  import { type BoxProps, Box } from '@likec4/styles/jsx'
4
- import { type MarkdownBlockVariant, markdownBlock } from '@likec4/styles/recipes'
4
+ import { markdownBlock } from '@likec4/styles/recipes'
5
+ import type { JsxStyleProps } from '@likec4/styles/types'
5
6
  import { Text } from '@mantine/core'
6
7
  import { forwardRef } from 'react'
7
8
 
@@ -14,10 +15,17 @@ export type MarkdownBlockProps = Omit<BoxProps, 'dangerouslySetInnerHTML' | 'chi
14
15
  */
15
16
  uselikec4palette?: boolean
16
17
  /**
17
- * Scale factor for the font size.
18
+ * Scale factor for the block
18
19
  * @default 1
19
20
  */
20
21
  textScale?: number
22
+
23
+ /**
24
+ * Font size for the block
25
+ * @default 'md'
26
+ */
27
+ fontSize?: JsxStyleProps['fontSize']
28
+
21
29
  /**
22
30
  * If true, the component will not render anything if the value is empty.
23
31
  * @default false
@@ -44,7 +52,7 @@ export const MarkdownBlock = forwardRef<HTMLDivElement, MarkdownBlockProps>(({
44
52
  }
45
53
  const content = value.nonEmpty
46
54
  ? { dangerouslySetInnerHTML: { __html: value.html } }
47
- : { children: <Text component="span" fz={'xs'} c="dimmed">{emptyText}</Text> }
55
+ : { children: <Text component="span" fz={'xs'} c="dimmed" style={{ userSelect: 'none' }}>{emptyText}</Text> }
48
56
  return (
49
57
  <Box
50
58
  ref={ref}
@@ -32,8 +32,8 @@ export function CompoundActionButton({
32
32
  className={cx(
33
33
  css({
34
34
  position: 'absolute',
35
- top: '5px',
36
- left: '4px',
35
+ top: '[5px]',
36
+ left: '[4px]',
37
37
  _smallZoom: {
38
38
  display: 'none',
39
39
  },
@@ -32,8 +32,8 @@ export function CompoundDetailsButton({
32
32
  className={cx(
33
33
  css({
34
34
  position: 'absolute',
35
- top: '[2px]',
36
- right: '[2px]',
35
+ top: '0.5',
36
+ right: '0.5',
37
37
  _smallZoom: {
38
38
  display: 'none',
39
39
  },
@@ -1,14 +1,5 @@
1
1
  import { css, sva } from '@likec4/styles/css'
2
2
 
3
- // export const _compoundOpacity = '--_compound-opacity'
4
- // const compoundOpacity = `var(${_compoundOpacity})`
5
- // // const varCompoundOpacity = createVar('compound-opacity')
6
-
7
- // export const _borderTransparency = '--_compound-border-transparency'
8
- // const borderTransparency = `var(${_borderTransparency})`
9
-
10
- // export const _borderWidth =
11
- // const borderWidth = `var(${_borderWidth})`
12
3
  export const borderWidth = {
13
4
  var: '--_border-width',
14
5
  ref: 'var(--_border-width, 2px)',
@@ -46,7 +37,7 @@ const root = css.raw({
46
37
  width: '100%',
47
38
  height: '100%',
48
39
  border: 'transparent',
49
- background: 'likec4.palette.fill',
40
+ background: 'var(--likec4-palette-fill)',
50
41
  backgroundClip: 'padding-box',
51
42
  transitionDelay: '.075ms',
52
43
  },
@@ -84,7 +75,7 @@ const compoundBorder = css.raw({
84
75
  background: 'transparent',
85
76
  borderStyle: 'dashed',
86
77
  borderWidth: `[${borderWidth.ref}]`,
87
- borderColor: `[color-mix(in srgb, {colors.likec4.palette.stroke} ${borderOpacityPercent.ref}, transparent)]`,
78
+ borderColor: `[color-mix(in srgb, var(--likec4-palette-stroke) ${borderOpacityPercent.ref}, transparent)]`,
88
79
  })
89
80
 
90
81
  const indicatorSvg = css.raw({
@@ -108,12 +99,12 @@ const indicatorSvg = css.raw({
108
99
  })
109
100
 
110
101
  const indicatorRect = css.raw({
111
- stroke: `[color-mix(in srgb, {colors.likec4.palette.stroke} 60%, {colors.likec4.palette.hiContrast})]`,
102
+ stroke: `[color-mix(in srgb, var(--likec4-palette-stroke) 60%, var(--likec4-palette-hiContrast))]`,
112
103
  strokeWidth: '4',
113
104
  fill: '[none]',
114
105
  animationStyle: 'indicator',
115
106
  _light: {
116
- stroke: `[color-mix(in srgb, {colors.likec4.palette.stroke} 80%, {colors.likec4.palette.hiContrast})]`,
107
+ stroke: `[color-mix(in srgb, var(--likec4-palette-stroke) 80%, var(--likec4-palette-hiContrast))]`,
117
108
  },
118
109
  })
119
110
 
@@ -62,9 +62,6 @@ export function CompoundNodeContainer({
62
62
  return (
63
63
  <m.div
64
64
  className={cx(
65
- css({
66
- likec4Palette: `${data.color}.${depth}`,
67
- }),
68
65
  classes.root,
69
66
  'likec4-compound-node',
70
67
  className,
@@ -19,10 +19,10 @@ const titleContainer = css({
19
19
  position: 'absolute',
20
20
  display: 'flex',
21
21
  alignItems: 'center',
22
- gap: '6px',
23
- left: '14px',
24
- top: '4px',
25
- right: '30px',
22
+ gap: '1.5', // 6px
23
+ left: '[14px]',
24
+ top: '[4px]',
25
+ right: '[30px]',
26
26
  width: 'auto',
27
27
  minHeight: '30px',
28
28
  [`:where(.react-flow__node.draggable) &`]: {
@@ -30,7 +30,7 @@ const titleContainer = css({
30
30
  cursor: 'grab',
31
31
  },
32
32
  [`.likec4-compound-node:has(.compound-action) &`]: {
33
- paddingLeft: '22px',
33
+ paddingLeft: '[22px]',
34
34
  },
35
35
  })
36
36
 
@@ -41,11 +41,11 @@ const titleText = css({
41
41
  fontSize: '15px',
42
42
  textTransform: 'uppercase',
43
43
  letterSpacing: '0.2px',
44
- color: 'likec4.palette.loContrast',
44
+ color: 'var(--likec4-palette-loContrast)',
45
45
  '[data-compound-title-inverse] &': {
46
46
  color: {
47
- base: '[color-mix(in srgb, {colors.likec4.palette.loContrast} 60%, {colors.likec4.palette.fill})]',
48
- _light: 'likec4.palette.stroke',
47
+ base: '[color-mix(in srgb, var(--likec4-palette-loContrast) 60%, var(--likec4-palette-fill))]',
48
+ _light: 'var(--likec4-palette-stroke)',
49
49
  },
50
50
  },
51
51
  })
@@ -5,14 +5,14 @@ export const compoundActionBtn = cva({
5
5
  transitionDuration: 'normal',
6
6
  '[data-compound-title-inverse] &': {
7
7
  _dark: {
8
- '--actionbtn-color': 'color-mix(in srgb, {colors.likec4.palette.loContrast} 60%, {colors.likec4.palette.fill})',
8
+ '--actionbtn-color': 'color-mix(in srgb, var(--likec4-palette-loContrast) 60%, var(--likec4-palette-fill))',
9
9
  },
10
10
  _light: {
11
- '--actionbtn-color': '{colors.likec4.palette.stroke}',
12
- '--actionbtn-color-hovered': '{colors.likec4.palette.stroke}',
13
- '--actionbtn-color-hovered-btn': '{colors.likec4.palette.hiContrast}',
14
- '--actionbtn-bg-hovered': `{colors.likec4.palette.fill/50}`,
15
- '--actionbtn-bg-hovered-btn': `{colors.likec4.palette.fill}`,
11
+ '--actionbtn-color': 'var(--likec4-palette-stroke)',
12
+ '--actionbtn-color-hovered': 'var(--likec4-palette-stroke)',
13
+ '--actionbtn-color-hovered-btn': 'var(--likec4-palette-hiContrast)',
14
+ '--actionbtn-bg-hovered': `var(--likec4-palette-fill)/50`,
15
+ '--actionbtn-bg-hovered-btn': `var(--likec4-palette-fill)`,
16
16
  },
17
17
  },
18
18
  },
@@ -1,8 +1,8 @@
1
1
  import { cx } from '@likec4/styles/css'
2
+ import { edgeActionBtn } from '@likec4/styles/recipes'
2
3
  import { ActionIcon } from '@mantine/core'
3
4
  import { IconZoomScan } from '@tabler/icons-react'
4
5
  import { stopPropagation } from '../../../utils/xyflow'
5
- import { actionBtn } from './edge.css'
6
6
 
7
7
  type EdgeActionBtnProps = {
8
8
  icon?: React.ReactNode
@@ -12,7 +12,7 @@ type EdgeActionBtnProps = {
12
12
  export function EdgeActionButton({ icon, onClick }: EdgeActionBtnProps) {
13
13
  return (
14
14
  <ActionIcon
15
- className={cx('nodrag nopan', actionBtn)}
15
+ className={cx('nodrag nopan', edgeActionBtn())}
16
16
  onPointerDownCapture={stopPropagation}
17
17
  onClick={onClick}
18
18
  role="button"
@@ -1,6 +1,6 @@
1
1
  import { invariant } from '@likec4/core'
2
2
  import type { DiagramEdge } from '@likec4/core/types'
3
- import { css, cx } from '@likec4/styles/css'
3
+ import { cx } from '@likec4/styles/css'
4
4
  import { type PropsWithChildren } from 'react'
5
5
  import type { UndefinedOnPartialDeep } from 'type-fest'
6
6
  import type { EdgeProps } from '../../types'
@@ -38,12 +38,9 @@ export function EdgeContainer({
38
38
  }: EdgeContainerProps) {
39
39
  const props = {
40
40
  className: cx(
41
- css({
42
- likec4RelationPalette: color,
43
- }),
44
- styles.edgeVars,
45
- styles.edgeContainer,
46
41
  className,
42
+ styles.edgeContainer,
43
+ 'likec4-edge-container',
47
44
  ),
48
45
  'data-likec4-color': color,
49
46
  'data-edge-dir': data.dir ?? 'forward',
@@ -4,8 +4,8 @@ const labelBorderRadius = '4px'
4
4
 
5
5
  export const edgeNoteCloseButton = css({
6
6
  position: 'absolute',
7
- top: 4,
8
- right: 4,
7
+ top: '1',
8
+ right: '1',
9
9
  })
10
10
 
11
11
  export const edgeNoteText = css({
@@ -26,8 +26,8 @@ export const translate = {
26
26
  } as const
27
27
 
28
28
  export const edgeLabelContainer = css({
29
- top: 0,
30
- left: 0,
29
+ top: '0',
30
+ left: '0',
31
31
  position: 'absolute',
32
32
  pointerEvents: 'all',
33
33
  cursor: 'pointer',
@@ -62,82 +62,3 @@ export const edgeLabelContainer = css({
62
62
  display: 'none',
63
63
  },
64
64
  })
65
-
66
- export const labelsva = sva({
67
- slots: ['root', 'stepNumber', 'labelContents', 'labelText', 'labelTechnology'],
68
- base: {
69
- root: {
70
- pointerEvents: 'all',
71
- fontFamily: 'likec4.relation',
72
- padding: '3px 5px 5px 5px',
73
- display: 'flex',
74
- flexDirection: 'column',
75
- alignItems: 'center',
76
- width: 'max-content',
77
- maxWidth: '100%',
78
- gap: '4px',
79
- },
80
- stepNumber: {
81
- alignSelf: 'stretch',
82
- flex: '0 0 auto',
83
- fontWeight: 600,
84
- fontSize: '14px',
85
- lineHeight: '1',
86
- padding: '5px 5px',
87
- textAlign: 'center',
88
- minWidth: '22px',
89
- borderTopLeftRadius: labelBorderRadius,
90
- borderBottomLeftRadius: labelBorderRadius,
91
- background: `[color-mix(in srgb, {colors.likec4.relation.label.bg}, {colors.likec4.mixColor} 10%)]`,
92
- fontVariantNumeric: 'tabular-nums',
93
- // _dark: {
94
- [':where([data-likec4-color="gray"]) &']: {
95
- _dark: {
96
- background: `[color-mix(in srgb, {colors.likec4.relation.label.bg}, {colors.likec4.mixColor} 15%)]`,
97
- },
98
- },
99
- },
100
- labelContents: {
101
- display: 'contents',
102
- _empty: {
103
- display: 'none !important',
104
- },
105
- },
106
- labelText: {
107
- whiteSpaceCollapse: 'preserve-breaks',
108
- fontSize: '14px',
109
- lineHeight: '1.185',
110
- },
111
- labelTechnology: {
112
- textAlign: 'center',
113
- whiteSpaceCollapse: 'preserve-breaks',
114
- fontSize: '11px',
115
- lineHeight: '1',
116
- opacity: 0.75,
117
- },
118
- },
119
- variants: {
120
- isStepEdge: {
121
- false: {},
122
- true: {
123
- root: {
124
- flexDirection: 'row',
125
- gap: '4px',
126
- padding: '0px',
127
- },
128
- labelContents: {
129
- display: 'flex',
130
- flexDirection: 'column',
131
- alignItems: 'center',
132
- padding: '2px 5px 4px 0px',
133
- },
134
- labelText: {
135
- padding: '2px 6px 4px 0px',
136
- },
137
- },
138
- },
139
- },
140
- defaultVariants: {
141
- isStepEdge: false,
142
- },
143
- })