@likec4/diagram 1.20.2 → 1.21.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 (95) hide show
  1. package/README.md +2 -2
  2. package/dist/base/BaseXYFlow.js +1 -1
  3. package/dist/base/example/_types.d.ts +3 -3
  4. package/dist/base/example/custom.d.ts +3 -2
  5. package/dist/base/primitives/compound/CompoundActionButton.js +1 -1
  6. package/dist/base/primitives/compound/CompoundDetailsButton.js +1 -1
  7. package/dist/base/primitives/compound/CompoundNodeContainer.js +1 -1
  8. package/dist/base/primitives/compound/CompoundTitle.css.d.ts +1 -0
  9. package/dist/base/primitives/compound/CompoundTitle.css.js +2 -0
  10. package/dist/base/primitives/compound/CompoundTitle.d.ts +2 -2
  11. package/dist/base/primitives/compound/CompoundTitle.js +17 -6
  12. package/dist/base/primitives/edge/EdgeLabel.js +1 -1
  13. package/dist/base/primitives/element/ElementActionButtons.js +1 -1
  14. package/dist/base/primitives/element/ElementDetailsButton.js +1 -1
  15. package/dist/base/primitives/element/ElementNodeContainer.d.ts +1 -1
  16. package/dist/base/primitives/element/ElementNodeContainer.js +15 -0
  17. package/dist/base/primitives/element/ElementShape.js +1 -1
  18. package/dist/base/primitives/element/ElementTitle.css.d.ts +0 -1
  19. package/dist/base/primitives/element/ElementTitle.css.js +8 -8
  20. package/dist/base/primitives/element/ElementTitle.d.ts +1 -1
  21. package/dist/base/primitives/element/ElementTitle.js +4 -2
  22. package/dist/base/primitives/element/styles.css.d.ts +3 -0
  23. package/dist/base/primitives/element/styles.css.js +6 -0
  24. package/dist/context/DiagramEventHandlers.js +1 -1
  25. package/dist/context/DiagramFeatures.js +1 -1
  26. package/dist/context/RootContainer.js +1 -1
  27. package/dist/hooks/useDiagram.d.ts +1 -2
  28. package/dist/hooks/useXYFlow.js +1 -1
  29. package/dist/likec4diagram/DiagramUI.d.ts +1 -2
  30. package/dist/likec4diagram/DiagramUI.js +3 -3
  31. package/dist/likec4diagram/XYFlow.js +1 -1
  32. package/dist/likec4diagram/custom/edges/NotePopover.js +1 -1
  33. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +1 -1
  34. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +4 -4
  35. package/dist/likec4diagram/custom/nodes/nodeTypes.js +8 -8
  36. package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +2 -2
  37. package/dist/likec4diagram/state/assign.js +1 -1
  38. package/dist/likec4diagram/state/machine.js +5 -5
  39. package/dist/likec4diagram/types.d.ts +2 -2
  40. package/dist/likec4diagram/ui/controls/Controls.js +1 -1
  41. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +1 -1
  42. package/dist/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.js +2 -2
  43. package/dist/likec4diagram/useLayoutConstraints.d.ts +2 -1
  44. package/dist/likec4diagram/useLayoutConstraints.js +14 -15
  45. package/dist/likec4diagram/useViewToNodesEdges.js +1 -1
  46. package/dist/overlays/Overlays.js +42 -21
  47. package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -3
  48. package/dist/overlays/element-details/ElementDetailsCard.js +38 -39
  49. package/dist/overlays/element-details/TabPanelDeployments.js +1 -1
  50. package/dist/overlays/element-details/TabPanelRelationships.js +16 -32
  51. package/dist/overlays/overlay/Overlay.css.js +2 -1
  52. package/dist/overlays/overlay/Overlay.js +2 -2
  53. package/dist/overlays/relationship-details/SelectEdge.js +1 -1
  54. package/dist/overlays/relationship-details/_types.d.ts +3 -3
  55. package/dist/overlays/relationship-details/actor.js +1 -1
  56. package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +3 -3
  57. package/dist/overlays/relationship-details/custom/nodeTypes.js +2 -2
  58. package/dist/overlays/relationship-details/useLayoutedDetails.js +1 -4
  59. package/dist/overlays/relationships-browser/-useRelationshipsView.js +0 -3
  60. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +3 -3
  61. package/dist/overlays/relationships-browser/_types.d.ts +3 -3
  62. package/dist/overlays/relationships-browser/actor.js +16 -16
  63. package/dist/overlays/relationships-browser/custom/ElementActions.js +12 -2
  64. package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +3 -2
  65. package/dist/overlays/relationships-browser/custom/nodeTypes.js +3 -3
  66. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +3 -2
  67. package/dist/style.css +1 -1
  68. package/package.json +14 -14
  69. package/src/base/example/_types.ts +3 -2
  70. package/src/base/example/useViewToNodesEdges.ts +2 -1
  71. package/src/base/primitives/compound/CompoundTitle.css.ts +27 -1
  72. package/src/base/primitives/compound/CompoundTitle.tsx +12 -2
  73. package/src/base/primitives/element/ElementNodeContainer.tsx +21 -1
  74. package/src/base/primitives/element/ElementShape.css.ts +5 -0
  75. package/src/base/primitives/element/ElementTitle.css.ts +17 -24
  76. package/src/base/primitives/element/ElementTitle.tsx +4 -2
  77. package/src/base/primitives/element/styles.css.ts +74 -0
  78. package/src/hooks/useDiagram.ts +1 -1
  79. package/src/likec4diagram/DiagramUI.tsx +2 -2
  80. package/src/likec4diagram/XYFlow.tsx +2 -2
  81. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +3 -2
  82. package/src/likec4diagram/types.ts +2 -2
  83. package/src/likec4diagram/useLayoutConstraints.ts +23 -19
  84. package/src/likec4diagram/useViewToNodesEdges.ts +1 -1
  85. package/src/overlays/Overlays.tsx +61 -281
  86. package/src/overlays/element-details/ElementDetailsCard.tsx +213 -257
  87. package/src/overlays/element-details/TabPanelRelationships.tsx +15 -77
  88. package/src/overlays/overlay/Overlay.tsx +1 -1
  89. package/src/overlays/relationship-details/_types.ts +3 -3
  90. package/src/overlays/relationship-details/useLayoutedDetails.ts +1 -1
  91. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +44 -55
  92. package/src/overlays/relationships-browser/_types.ts +12 -2
  93. package/src/overlays/relationships-browser/actor.ts +11 -10
  94. package/src/overlays/relationships-browser/custom/ElementActions.tsx +12 -2
  95. package/src/overlays/relationships-browser/useViewToNodesEdges.ts +2 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/diagram",
3
- "version": "1.20.2",
3
+ "version": "1.21.0",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -39,8 +39,8 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@dagrejs/dagre": "1.1.4",
42
- "@likec4/core": "1.20.2",
43
- "@mantine/vanilla-extract": "7.15.2",
42
+ "@likec4/core": "1.21.0",
43
+ "@mantine/vanilla-extract": "7.16.2",
44
44
  "@react-hookz/web": "^25.0.1",
45
45
  "@tabler/icons-react": "3.29.0",
46
46
  "@xstate/react": "^5.0.2",
@@ -52,31 +52,31 @@
52
52
  "d3-shape": "^3.2.0",
53
53
  "esm-env": "^1.2.2",
54
54
  "fast-equals": "^5.2.2",
55
- "framer-motion": "^11.16.0",
55
+ "framer-motion": "^11.18.2",
56
56
  "khroma": "^2.1.0",
57
57
  "react-error-boundary": "^4.1.2",
58
- "remeda": "^2.19.0",
58
+ "remeda": "^2.20.1",
59
59
  "type-fest": "4.28.1",
60
60
  "xstate": "^5.19.2"
61
61
  },
62
62
  "peerDependencies": {
63
- "@mantine/core": "^7.15.2",
64
- "@mantine/hooks": "^7.15.2",
65
- "@mantine/spotlight": "^7.15.2",
63
+ "@mantine/core": "^7.16.2",
64
+ "@mantine/hooks": "^7.16.2",
65
+ "@mantine/spotlight": "^7.16.2",
66
66
  "react": "^18.0.0 || ^19.0.0",
67
67
  "react-dom": "^18.0.0 || ^19.0.0"
68
68
  },
69
69
  "devDependencies": {
70
- "@likec4/tsconfig": "1.20.2",
71
- "@mantine/core": "7.15.2",
72
- "@mantine/hooks": "7.15.2",
73
- "@mantine/spotlight": "7.15.2",
70
+ "@likec4/tsconfig": "1.21.0",
71
+ "@mantine/core": "7.16.2",
72
+ "@mantine/hooks": "7.16.2",
73
+ "@mantine/spotlight": "7.16.2",
74
74
  "@statelyai/inspect": "^0.4.0",
75
75
  "@types/bezier-js": "^4.1.3",
76
76
  "@types/d3-shape": "^3.1.7",
77
77
  "@types/react": "~19.0.8",
78
78
  "@types/react-dom": "~19.0.3",
79
- "@vanilla-extract/css": "^1.17.0",
79
+ "@vanilla-extract/css": "^1.17.1",
80
80
  "@vanilla-extract/css-utils": "^0.1.4",
81
81
  "@vanilla-extract/dynamic": "^2.1.2",
82
82
  "react": "~19.0.0",
@@ -84,6 +84,6 @@
84
84
  "typescript": "^5.7.3",
85
85
  "vite": "5.4.14",
86
86
  "vite-plugin-dts": "^4.5.0",
87
- "vitest": "^2.1.8"
87
+ "vitest": "^3.0.4"
88
88
  }
89
89
  }
@@ -1,4 +1,4 @@
1
- import type { Color, DiagramNode, Fqn } from '@likec4/core'
1
+ import type { Color, DiagramNode, Fqn, IconUrl } from '@likec4/core'
2
2
  import type { Base, NonOptional, ReactFlowEdge, ReactFlowNode } from '../types'
3
3
 
4
4
  export namespace ExampleTypes {
@@ -13,6 +13,7 @@ export namespace ExampleTypes {
13
13
  | 'description'
14
14
  | 'color'
15
15
  | 'shape'
16
+ | 'style'
16
17
  | 'width'
17
18
  | 'height'
18
19
  | 'navigateTo'
@@ -39,7 +40,7 @@ export namespace ExampleTypes {
39
40
  // column: Column
40
41
  fqn: Fqn
41
42
  depth: number
42
- icon: string | null
43
+ icon: IconUrl
43
44
  }
44
45
  >
45
46
 
@@ -104,7 +104,7 @@ function viewToNodesEdge(
104
104
  shape: node.shape,
105
105
  style: node.style,
106
106
  depth: node.depth ?? 0,
107
- icon: node.icon ?? null,
107
+ icon: node.icon ?? 'none',
108
108
  fqn,
109
109
  ...navigateTo,
110
110
  },
@@ -126,6 +126,7 @@ function viewToNodesEdge(
126
126
  width: node.width,
127
127
  color: node.color,
128
128
  shape: node.shape,
129
+ style: node.style,
129
130
  icon: node.icon ?? null,
130
131
  ...navigateTo,
131
132
  },
@@ -1,5 +1,5 @@
1
1
  import { rem } from '@mantine/core'
2
- import { style } from '@vanilla-extract/css'
2
+ import { globalStyle, style } from '@vanilla-extract/css'
3
3
  import { vars, whereLight } from '../../../theme-vars'
4
4
 
5
5
  export const compoundTitle = style({
@@ -41,3 +41,29 @@ export const title = style({
41
41
  },
42
42
  },
43
43
  })
44
+
45
+ const iconSize = '20px'
46
+ export const icon = style({
47
+ flex: `0 0 ${iconSize}`,
48
+ height: `${iconSize}`,
49
+ width: `${iconSize}`,
50
+ display: 'flex',
51
+ alignItems: 'center',
52
+ justifyContent: 'center',
53
+ mixBlendMode: 'hard-light',
54
+ })
55
+
56
+ globalStyle(`${icon} svg, ${icon} img`, {
57
+ width: '100%',
58
+ height: 'auto',
59
+ maxHeight: '100%',
60
+ pointerEvents: 'none',
61
+ filter: `
62
+ drop-shadow(0 0 3px rgb(0 0 0 / 12%))
63
+ drop-shadow(0 1px 8px rgb(0 0 0 / 8%))
64
+ drop-shadow(1px 1px 16px rgb(0 0 0 / 3%))
65
+ `,
66
+ })
67
+ globalStyle(`${icon} img`, {
68
+ objectFit: 'contain',
69
+ })
@@ -3,17 +3,26 @@ import { Box, Text } from '@mantine/core'
3
3
  import clsx from 'clsx'
4
4
  import type { NodeProps } from '../../types'
5
5
  import * as css from './CompoundTitle.css'
6
+ import { IconRenderer } from '../../../context'
6
7
 
7
8
  type Data = Pick<
8
9
  DiagramNode,
9
10
  | 'color'
10
11
  | 'title'
12
+ | 'icon'
11
13
  >
12
14
 
13
15
  type CompoundTitleProps = NodeProps<Data>
14
16
 
15
- export function CompoundTitle({ data }: CompoundTitleProps) {
16
- const isHovered = data.hovered ?? false
17
+ export function CompoundTitle({ id, data }: CompoundTitleProps) {
18
+ const elementIcon = IconRenderer({
19
+ element: {
20
+ id,
21
+ title: data.title,
22
+ icon: data.icon,
23
+ },
24
+ className: css.icon,
25
+ })
17
26
 
18
27
  return (
19
28
  <Box
@@ -21,6 +30,7 @@ export function CompoundTitle({ data }: CompoundTitleProps) {
21
30
  css.compoundTitle,
22
31
  'likec4-compound-title',
23
32
  )}>
33
+ {elementIcon}
24
34
  <Text className={css.title} truncate="end">
25
35
  {data.title}
26
36
  </Text>
@@ -1,4 +1,4 @@
1
- import type { DiagramNode } from '@likec4/core'
1
+ import { type DiagramNode, DefaultPaddingSize, DefaultShapeSize, DefaultTextSize } from '@likec4/core'
2
2
  import { type BoxProps, Box, createPolymorphicComponent } from '@mantine/core'
3
3
  import clsx from 'clsx'
4
4
  import { m } from 'framer-motion'
@@ -10,6 +10,7 @@ type RequiredData = Pick<
10
10
  DiagramNode,
11
11
  | 'color'
12
12
  | 'shape'
13
+ | 'style'
13
14
  >
14
15
 
15
16
  type ElementNodeContainerProps =
@@ -42,6 +43,22 @@ export const ElementNodeContainer = createPolymorphicComponent<'div', ElementNod
42
43
  break
43
44
  }
44
45
 
46
+ let {
47
+ size,
48
+ padding,
49
+ textSize,
50
+ } = data.style
51
+
52
+ // if (size === DefaultShapeSize && textSize !== DefaultTextSize) {
53
+ // size = textSize
54
+ // }
55
+ if (!size && !!textSize) {
56
+ size = textSize
57
+ }
58
+ if (!textSize && !!size) {
59
+ textSize = size
60
+ }
61
+
45
62
  return (
46
63
  <Box
47
64
  component={m.div}
@@ -60,6 +77,9 @@ export const ElementNodeContainer = createPolymorphicComponent<'div', ElementNod
60
77
  data-hovered={isHovered}
61
78
  data-likec4-color={data.color}
62
79
  data-likec4-shape={data.shape}
80
+ data-likec4-shape-size={size ?? DefaultShapeSize}
81
+ data-likec4-padding={padding ?? DefaultPaddingSize}
82
+ data-likec4-text-size={textSize ?? DefaultTextSize}
63
83
  data-likec4-dimmed={isDimmed}
64
84
  {...rest}
65
85
  >
@@ -130,5 +130,10 @@ export const shapeSvg = style([shapeBase, {
130
130
  [filterShadow]: `none`,
131
131
  },
132
132
  },
133
+ [`:where([data-likec4-zoom-small="true"]) &`]: {
134
+ vars: {
135
+ [filterShadow]: `none`,
136
+ },
137
+ },
133
138
  },
134
139
  }])
@@ -1,11 +1,12 @@
1
1
  import { rem } from '@mantine/core'
2
2
  import { createVar, globalStyle, style } from '@vanilla-extract/css'
3
+ import { calc } from '@vanilla-extract/css-utils'
3
4
  import { vars } from '../../../theme-vars'
5
+ import { iconSize, paddingSize, textSize } from './styles.css'
4
6
 
5
7
  export const hasIcon = style({})
6
8
 
7
9
  const textAlign = createVar('text-align')
8
- export const iconSize = createVar('icon-size')
9
10
 
10
11
  export const title = style({
11
12
  flex: '0 0 auto',
@@ -14,7 +15,7 @@ export const title = style({
14
15
  fontStyle: 'normal',
15
16
  textAlign: textAlign,
16
17
  fontWeight: 500,
17
- fontSize: 19,
18
+ fontSize: textSize,
18
19
  lineHeight: 1.15,
19
20
  textWrap: 'balance',
20
21
  color: vars.element.hiContrast,
@@ -27,7 +28,7 @@ export const description = style({
27
28
  fontOpticalSizing: 'auto',
28
29
  fontStyle: 'normal',
29
30
  fontWeight: 400,
30
- fontSize: 14,
31
+ fontSize: calc(textSize).multiply(0.74).toString(),
31
32
  lineHeight: 1.2,
32
33
  textAlign: textAlign,
33
34
  textWrap: 'pretty',
@@ -39,6 +40,9 @@ export const description = style({
39
40
  [`:where(${hasIcon}) &`]: {
40
41
  textWrap: 'wrap',
41
42
  },
43
+ [`:where([data-likec4-shape-size="xs"], [data-likec4-shape-size="sm"]) &`]: {
44
+ display: 'none',
45
+ },
42
46
  },
43
47
  })
44
48
 
@@ -48,7 +52,7 @@ export const technology = style({
48
52
  fontOpticalSizing: 'auto',
49
53
  fontStyle: 'normal',
50
54
  fontWeight: 400,
51
- fontSize: 12,
55
+ fontSize: calc(textSize).multiply(0.635).toString(),
52
56
  lineHeight: 1.125,
53
57
  textAlign: textAlign,
54
58
  textWrap: 'balance',
@@ -58,6 +62,9 @@ export const technology = style({
58
62
  [`:where([data-hovered='true']) &`]: {
59
63
  opacity: 1,
60
64
  },
65
+ [`:where([data-likec4-shape-size="xs"], [data-likec4-shape-size="sm"]) &`]: {
66
+ display: 'none',
67
+ },
61
68
  },
62
69
  })
63
70
 
@@ -68,12 +75,9 @@ export const elementDataContainer = style({
68
75
  alignItems: 'center',
69
76
  justifyContent: 'center',
70
77
  flexDirection: 'row',
71
- padding: rem(24),
78
+ padding: paddingSize,
72
79
  overflow: 'hidden',
73
- gap: rem(10),
74
- vars: {
75
- [iconSize]: '48px',
76
- },
80
+ gap: rem(12),
77
81
  selectors: {
78
82
  ':where([data-likec4-shape="queue"], [data-likec4-shape="mobile"]) &': {
79
83
  paddingLeft: 40,
@@ -86,22 +90,11 @@ export const elementDataContainer = style({
86
90
  paddingTop: 32,
87
91
  paddingBottom: 28,
88
92
  },
89
- // [`&:is(${hasIcon})`]: {
90
- // paddingLeft: 40,
91
- // paddingRight: 20
92
- // },
93
- [`.likec4-element-node:not(:is([data-likec4-shape="queue"],[data-likec4-shape="mobile"])) &:is(${hasIcon})`]: {
94
- paddingLeft: 24,
95
- paddingRight: 18,
96
- },
97
- [`&:has(${description}, ${technology})`]: {
98
- gap: rem(16),
99
- vars: {
100
- [iconSize]: '60px',
101
- },
102
- },
103
93
  },
104
94
  })
95
+ globalStyle(`:where([data-likec4-shape-size="lg"], [data-likec4-shape-size="xl"]) ${elementDataContainer}`, {
96
+ gap: rem(16),
97
+ })
105
98
 
106
99
  export const elementTextData = style({
107
100
  height: 'fit-content',
@@ -121,7 +114,7 @@ export const elementTextData = style({
121
114
  gap: rem(6),
122
115
  },
123
116
  [`:where(${hasIcon}) &`]: {
124
- minWidth: 'calc(100% - 160px)',
117
+ minWidth: `calc(100% - ${iconSize} - ${calc(paddingSize).multiply(2).toString()})`,
125
118
  alignItems: 'flex-start',
126
119
  'vars': {
127
120
  [textAlign]: 'left',
@@ -1,4 +1,4 @@
1
- import type { DiagramNode } from '@likec4/core'
1
+ import { type DiagramNode } from '@likec4/core'
2
2
  import { Box, Text } from '@mantine/core'
3
3
  import { assignInlineVars } from '@vanilla-extract/dynamic'
4
4
  import clsx from 'clsx'
@@ -7,6 +7,7 @@ import { IconRenderer } from '../../../context/IconRenderer'
7
7
  import { hiddenIfZoomTooSmall } from '../../../LikeC4Diagram.css'
8
8
  import type { NodeProps } from '../../types'
9
9
  import * as css from './ElementTitle.css'
10
+ import { iconSize as varIconSize } from './styles.css'
10
11
 
11
12
  type Data =
12
13
  & Pick<
@@ -15,6 +16,7 @@ type Data =
15
16
  | 'technology'
16
17
  | 'description'
17
18
  | 'color'
19
+ | 'style'
18
20
  >
19
21
  & {
20
22
  icon?: string | null
@@ -42,7 +44,7 @@ export function ElementTitle({ id, data, iconSize }: ElementTitleProps) {
42
44
  )}
43
45
  style={{
44
46
  ...isNumber(iconSize) && assignInlineVars({
45
- [css.iconSize]: `${iconSize}px`,
47
+ [varIconSize]: `${iconSize}px`,
46
48
  }),
47
49
  }}
48
50
  >
@@ -0,0 +1,74 @@
1
+ import { defaultTheme } from '@likec4/core'
2
+ import { rem } from '@mantine/core'
3
+ import { createVar, globalStyle } from '@vanilla-extract/css'
4
+ import { container } from './ElementNodeContainer.css'
5
+
6
+ export const textSize = createVar('text-size')
7
+ export const paddingSize = createVar('padding-size')
8
+ export const iconSize = createVar('icon-size')
9
+
10
+ globalStyle(`${container}`, {
11
+ vars: {
12
+ [textSize]: rem(defaultTheme.textSizes.md),
13
+ [paddingSize]: rem(defaultTheme.spacing.md),
14
+ [iconSize]: '60px',
15
+ },
16
+ })
17
+
18
+ globalStyle(`${container}[data-likec4-shape-size="xs"]`, {
19
+ vars: {
20
+ [iconSize]: '24px',
21
+ },
22
+ })
23
+ globalStyle(`${container}[data-likec4-shape-size="sm"]`, {
24
+ vars: {
25
+ [iconSize]: '36px',
26
+ },
27
+ })
28
+ globalStyle(`${container}[data-likec4-shape-size="lg"], ${container}[data-likec4-shape-size="xl"]`, {
29
+ vars: {
30
+ [iconSize]: '82px',
31
+ },
32
+ })
33
+
34
+ globalStyle(`${container}[data-likec4-text-size="xs"]`, {
35
+ vars: {
36
+ [textSize]: rem(defaultTheme.textSizes.xs),
37
+ },
38
+ })
39
+ globalStyle(`${container}[data-likec4-text-size="sm"]`, {
40
+ vars: {
41
+ [textSize]: rem(defaultTheme.textSizes.sm),
42
+ },
43
+ })
44
+ globalStyle(`${container}[data-likec4-text-size="lg"]`, {
45
+ vars: {
46
+ [textSize]: rem(defaultTheme.textSizes.lg),
47
+ },
48
+ })
49
+ globalStyle(`${container}[data-likec4-text-size="xl"]`, {
50
+ vars: {
51
+ [textSize]: rem(defaultTheme.textSizes.xl),
52
+ },
53
+ })
54
+
55
+ globalStyle(`${container}[data-likec4-padding="xs"]`, {
56
+ vars: {
57
+ [paddingSize]: rem(defaultTheme.spacing.xs),
58
+ },
59
+ })
60
+ globalStyle(`${container}[data-likec4-padding="sm"]`, {
61
+ vars: {
62
+ [paddingSize]: rem(defaultTheme.spacing.sm),
63
+ },
64
+ })
65
+ globalStyle(`${container}[data-likec4-padding="lg"]`, {
66
+ vars: {
67
+ [paddingSize]: rem(defaultTheme.spacing.lg),
68
+ },
69
+ })
70
+ globalStyle(`${container}[data-likec4-padding="xl"]`, {
71
+ vars: {
72
+ [paddingSize]: rem(defaultTheme.spacing.xl),
73
+ },
74
+ })
@@ -4,8 +4,8 @@ import type { PartialDeep } from 'type-fest'
4
4
  import { useDiagramActor } from '../hooks/useDiagramActor'
5
5
  import type { OpenSourceParams } from '../LikeC4Diagram.props'
6
6
  import type { AlignmentMode } from '../likec4diagram/state/aligners'
7
+ import { DiagramContext } from '../likec4diagram/state/machine'
7
8
  import type { Types } from '../likec4diagram/types'
8
- import { DiagramContext } from './useDiagramContext'
9
9
 
10
10
  export function useDiagram() {
11
11
  const actor = useDiagramActor()
@@ -6,7 +6,7 @@ import { Controls, DiagramTitlePanel } from './ui'
6
6
  import NotationPanel from './ui/notation'
7
7
  import { DynamicViewWalkthrough } from './ui/walkthrough/DynamicViewWalkthrough'
8
8
 
9
- export const DiagramUI = memo(() => {
9
+ export function DiagramUI() {
10
10
  return (
11
11
  <>
12
12
  <Controls />
@@ -25,4 +25,4 @@ export const DiagramUI = memo(() => {
25
25
  </IfEnabled>
26
26
  </>
27
27
  )
28
- })
28
+ }
@@ -3,8 +3,8 @@ import { useCallbackRef } from '@mantine/hooks'
3
3
  import clsx from 'clsx'
4
4
  import { shallowEqual } from 'fast-equals'
5
5
  import type { EnforceOptional } from 'type-fest/source/enforce-optional'
6
- import { BaseXYFlow } from '../base'
7
- import { useDiagramEventHandlers, useEnabledFeature } from '../context'
6
+ import { BaseXYFlow } from '../base/BaseXYFlow'
7
+ import { useDiagramEventHandlers } from '../context'
8
8
  import { useDiagram } from '../hooks/useDiagram'
9
9
  import { useDiagramContext } from '../hooks/useDiagramContext'
10
10
  import type { LikeC4DiagramProperties } from '../LikeC4Diagram.props'
@@ -27,12 +27,13 @@ import { IconArrowRight, IconFileSymlink, IconInfoCircle, IconZoomScan } from '@
27
27
  import clsx from 'clsx'
28
28
  import { type MouseEventHandler, type PropsWithChildren, forwardRef, Fragment, useCallback } from 'react'
29
29
  import { filter, isTruthy, map, partition, pipe } from 'remeda'
30
- import { Link } from '../../../base'
30
+ import { Link } from '../../../base/Link'
31
31
  import { IfEnabled, useDiagramEventHandlers, useEnabledFeature } from '../../../context'
32
32
  import { useMantinePortalProps } from '../../../hooks'
33
33
  import { useDiagram } from '../../../hooks/useDiagram'
34
- import { DiagramContext, useDiagramContext } from '../../../hooks/useDiagramContext'
34
+ import { useDiagramContext } from '../../../hooks/useDiagramContext'
35
35
  import { useLikeC4Model } from '../../../likec4model'
36
+ import { DiagramContext } from '../../state/machine'
36
37
  import * as css from './RelationshipsDropdownMenu.css'
37
38
 
38
39
  const stopPropagation: MouseEventHandler = (e) => e.stopPropagation()
@@ -1,4 +1,4 @@
1
- import type { DiagramEdge, DiagramNode, Fqn, ViewId } from '@likec4/core'
1
+ import type { DiagramEdge, DiagramNode, Fqn, IconUrl, ViewId } from '@likec4/core'
2
2
  import type { XYPosition } from '@xyflow/system'
3
3
  import type { OptionalKeysOf, Simplify } from 'type-fest'
4
4
  import type { Base } from '../base'
@@ -75,7 +75,7 @@ export namespace Types {
75
75
  >
76
76
  & {
77
77
  depth: number
78
- icon: string | null
78
+ icon?: IconUrl
79
79
  }
80
80
  >
81
81
 
@@ -60,42 +60,46 @@ abstract class Rect {
60
60
  }
61
61
  }
62
62
  protected abstract parent: Compound | null
63
- }
64
-
65
- class Compound extends Rect {
66
- public readonly children = [] as Rect[]
67
63
 
68
64
  constructor(
69
65
  xynode: InternalNode,
70
- protected readonly parent: Compound | null = null,
66
+ parent: Compound | null = null,
71
67
  ) {
72
- super()
73
68
  this.id = xynode.id
74
69
 
70
+ this.positionAbsolute = !parent ? xynode.position : {
71
+ x: xynode.position.x + parent.minX,
72
+ y: xynode.position.y + parent.minY,
73
+ }
74
+
75
+ const { width, height } = getNodeDimensions(xynode)
76
+
77
+ this.maxX = this.minX + Math.ceil(width)
78
+ this.maxY = this.minY + Math.ceil(height)
79
+
75
80
  if (parent) {
76
81
  parent.children.push(this)
77
82
  }
78
83
  }
79
84
  }
80
85
 
81
- class Leaf extends Rect {
86
+ class Compound extends Rect {
87
+ public readonly children = [] as Rect[]
88
+
82
89
  constructor(
83
90
  xynode: InternalNode,
84
91
  public readonly parent: Compound | null = null,
85
92
  ) {
86
- super()
87
- this.id = xynode.id
88
-
89
- this.positionAbsolute = xynode.internals.positionAbsolute
90
-
91
- const { width, height } = getNodeDimensions(xynode)
92
-
93
- this.maxX = this.minX + Math.ceil(width)
94
- this.maxY = this.minY + Math.ceil(height)
93
+ super(xynode, parent)
94
+ }
95
+ }
95
96
 
96
- if (parent) {
97
- parent.children.push(this)
98
- }
97
+ class Leaf extends Rect {
98
+ constructor(
99
+ xynode: InternalNode,
100
+ public readonly parent: Compound | null = null,
101
+ ) {
102
+ super(xynode, parent)
99
103
  }
100
104
  }
101
105
 
@@ -120,7 +120,7 @@ function viewToNodesEdge(opts: {
120
120
  shape: node.shape,
121
121
  style: node.style,
122
122
  depth: node.depth ?? 0,
123
- icon: node.icon ?? null,
123
+ icon: node.icon ?? 'none',
124
124
  position: node.position,
125
125
  } satisfies Types.CompoundNodeData
126
126