@likec4/diagram 1.20.3 → 1.21.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 (105) hide show
  1. package/README.md +2 -2
  2. package/dist/base/BaseXYFlow.js +1 -2
  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 +2 -2
  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 +2 -2
  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 +7 -2
  16. package/dist/base/primitives/element/ElementNodeContainer.js +34 -1
  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 +11 -5
  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/index.d.ts +0 -1
  28. package/dist/hooks/useDiagram.d.ts +1 -2
  29. package/dist/hooks/useXYFlow.js +1 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/likec4diagram/DiagramUI.d.ts +1 -2
  32. package/dist/likec4diagram/DiagramUI.js +3 -4
  33. package/dist/likec4diagram/XYFlow.js +1 -1
  34. package/dist/likec4diagram/custom/edges/NotePopover.js +1 -1
  35. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +1 -1
  36. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +5 -4
  37. package/dist/likec4diagram/custom/nodes/nodeTypes.js +8 -8
  38. package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +2 -2
  39. package/dist/likec4diagram/state/assign.js +1 -1
  40. package/dist/likec4diagram/state/machine.js +5 -5
  41. package/dist/likec4diagram/types.d.ts +2 -2
  42. package/dist/likec4diagram/ui/controls/Controls.js +1 -1
  43. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +5 -4
  44. package/dist/likec4diagram/ui/index.d.ts +2 -0
  45. package/dist/likec4diagram/ui/walkthrough/DynamicViewWalkthrough.js +2 -2
  46. package/dist/likec4diagram/useViewToNodesEdges.js +1 -1
  47. package/dist/overlays/Overlays.js +43 -22
  48. package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -3
  49. package/dist/overlays/element-details/ElementDetailsCard.js +38 -39
  50. package/dist/overlays/element-details/TabPanelDeployments.js +5 -3
  51. package/dist/overlays/element-details/TabPanelRelationships.js +14 -30
  52. package/dist/overlays/overlay/Overlay.css.js +2 -1
  53. package/dist/overlays/overlay/Overlay.js +2 -2
  54. package/dist/overlays/relationship-details/SelectEdge.js +1 -1
  55. package/dist/overlays/relationship-details/_types.d.ts +3 -3
  56. package/dist/overlays/relationship-details/actor.js +1 -1
  57. package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +3 -3
  58. package/dist/overlays/relationship-details/custom/nodeTypes.js +2 -2
  59. package/dist/overlays/relationship-details/useLayoutedDetails.js +1 -4
  60. package/dist/overlays/relationships-browser/-useRelationshipsView.js +0 -3
  61. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +3 -3
  62. package/dist/overlays/relationships-browser/_types.d.ts +3 -3
  63. package/dist/overlays/relationships-browser/actor.js +16 -16
  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/BaseXYFlow.tsx +0 -1
  70. package/src/base/example/_types.ts +3 -2
  71. package/src/base/example/useViewToNodesEdges.ts +2 -1
  72. package/src/base/primitives/compound/CompoundTitle.css.ts +27 -1
  73. package/src/base/primitives/compound/CompoundTitle.tsx +12 -2
  74. package/src/base/primitives/element/ElementNodeContainer.css.ts +4 -7
  75. package/src/base/primitives/element/ElementNodeContainer.tsx +41 -1
  76. package/src/base/primitives/element/ElementShape.css.ts +5 -0
  77. package/src/base/primitives/element/ElementTitle.css.ts +25 -29
  78. package/src/base/primitives/element/ElementTitle.tsx +10 -4
  79. package/src/base/primitives/element/styles.css.ts +52 -0
  80. package/src/globals.css.ts +2 -0
  81. package/src/hooks/index.ts +0 -1
  82. package/src/hooks/useDiagram.ts +1 -1
  83. package/src/index.ts +15 -1
  84. package/src/likec4diagram/DiagramUI.tsx +3 -6
  85. package/src/likec4diagram/XYFlow.tsx +2 -2
  86. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +0 -1
  87. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.ts +1 -0
  88. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +4 -2
  89. package/src/likec4diagram/types.ts +2 -2
  90. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +110 -107
  91. package/src/likec4diagram/ui/index.ts +2 -0
  92. package/src/likec4diagram/ui/notation/NotationPanel.tsx +2 -3
  93. package/src/likec4diagram/useViewToNodesEdges.ts +1 -1
  94. package/src/overlays/Overlays.tsx +62 -282
  95. package/src/overlays/element-details/ElementDetailsCard.tsx +214 -261
  96. package/src/overlays/element-details/TabPanelDeployments.tsx +4 -4
  97. package/src/overlays/element-details/TabPanelRelationships.tsx +13 -75
  98. package/src/overlays/overlay/Overlay.tsx +1 -1
  99. package/src/overlays/relationship-details/_types.ts +3 -3
  100. package/src/overlays/relationship-details/useLayoutedDetails.ts +1 -1
  101. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +44 -55
  102. package/src/overlays/relationships-browser/_types.ts +12 -2
  103. package/src/overlays/relationships-browser/actor.ts +11 -10
  104. package/src/overlays/relationships-browser/useViewToNodesEdges.ts +2 -1
  105. package/dist/hooks/useCurrentViewId.js +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/diagram",
3
- "version": "1.20.3",
3
+ "version": "1.21.1",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -39,10 +39,11 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@dagrejs/dagre": "1.1.4",
42
- "@likec4/core": "1.20.3",
43
- "@mantine/vanilla-extract": "7.15.2",
42
+ "@likec4/core": "1.21.1",
43
+ "@mantine/vanilla-extract": "7.16.2",
44
44
  "@react-hookz/web": "^25.0.1",
45
45
  "@tabler/icons-react": "3.29.0",
46
+ "@vanilla-extract/dynamic": "^2.1.2",
46
47
  "@xstate/react": "^5.0.2",
47
48
  "@xstate/store": "^2.6.2",
48
49
  "@xyflow/react": "12.4.2",
@@ -54,23 +55,23 @@
54
55
  "fast-equals": "^5.2.2",
55
56
  "framer-motion": "^11.18.2",
56
57
  "khroma": "^2.1.0",
57
- "react-error-boundary": "^4.1.2",
58
- "remeda": "^2.19.0",
58
+ "react-error-boundary": "^5.0.0",
59
+ "remeda": "^2.20.1",
59
60
  "type-fest": "4.28.1",
60
61
  "xstate": "^5.19.2"
61
62
  },
62
63
  "peerDependencies": {
63
- "@mantine/core": "^7.15.2",
64
- "@mantine/hooks": "^7.15.2",
65
- "@mantine/spotlight": "^7.15.2",
64
+ "@mantine/core": "^7.16.2",
65
+ "@mantine/hooks": "^7.16.2",
66
+ "@mantine/spotlight": "^7.16.2",
66
67
  "react": "^18.0.0 || ^19.0.0",
67
68
  "react-dom": "^18.0.0 || ^19.0.0"
68
69
  },
69
70
  "devDependencies": {
70
- "@likec4/tsconfig": "1.20.3",
71
- "@mantine/core": "7.15.2",
72
- "@mantine/hooks": "7.15.2",
73
- "@mantine/spotlight": "7.15.2",
71
+ "@likec4/tsconfig": "1.21.1",
72
+ "@mantine/core": "7.16.2",
73
+ "@mantine/hooks": "7.16.2",
74
+ "@mantine/spotlight": "7.16.2",
74
75
  "@statelyai/inspect": "^0.4.0",
75
76
  "@types/bezier-js": "^4.1.3",
76
77
  "@types/d3-shape": "^3.1.7",
@@ -78,12 +79,11 @@
78
79
  "@types/react-dom": "~19.0.3",
79
80
  "@vanilla-extract/css": "^1.17.1",
80
81
  "@vanilla-extract/css-utils": "^0.1.4",
81
- "@vanilla-extract/dynamic": "^2.1.2",
82
82
  "react": "~19.0.0",
83
83
  "react-dom": "~19.0.0",
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
  }
@@ -85,7 +85,6 @@ export const BaseXYFlow = <
85
85
  nodes={nodes}
86
86
  edges={edges}
87
87
  className={clsx(
88
- 'likec4-diagram',
89
88
  css.cssReactFlow,
90
89
  pannable !== true && css.cssDisablePan,
91
90
  background === 'transparent' && css.cssTransparentBg,
@@ -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,12 +1,9 @@
1
1
  import { createVar, fallbackVar, globalStyle, style } from '@vanilla-extract/css'
2
- import { vars } from '../../../theme-vars'
2
+ import { easings, vars } from '../../../theme-vars'
3
3
 
4
4
  export const stokeFillMix = createVar('stroke-fill-mix')
5
5
 
6
6
  export const container = style({
7
- // position: 'absolute',
8
- // top: 0,
9
- // left: 0,
10
7
  position: 'relative',
11
8
  width: '100%',
12
9
  height: '100%',
@@ -30,7 +27,7 @@ export const container = style({
30
27
  top: '100%',
31
28
  left: 0,
32
29
  right: 0,
33
- height: 20,
30
+ height: 24,
34
31
  background: 'transparent',
35
32
  pointerEvents: 'all',
36
33
  },
@@ -38,7 +35,7 @@ export const container = style({
38
35
 
39
36
  globalStyle(`.react-flow__node:has(${container}[data-likec4-dimmed="true"])`, {
40
37
  opacity: 0.25,
41
- transition: 'opacity 400ms ease-in-out, filter 500ms ease-in-out',
38
+ transition: `opacity 400ms ${easings.inOut}, filter 500ms ${easings.inOut}`,
42
39
  transitionDelay: '50ms',
43
40
  filter: `grayscale(0.85) ${fallbackVar(vars.safariAnimationHook, 'blur(2px)')}`,
44
41
  willChange: 'opacity, filter',
@@ -46,7 +43,7 @@ globalStyle(`.react-flow__node:has(${container}[data-likec4-dimmed="true"])`, {
46
43
 
47
44
  globalStyle(`.react-flow__node:has(${container}[data-likec4-dimmed="immediate"])`, {
48
45
  opacity: 0.25,
49
- transition: 'opacity 100ms ease-in-out, filter 100ms ease-in-out',
46
+ transition: `opacity 100ms ${easings.inOut}, filter 100ms ${easings.inOut}`,
50
47
  filter: `grayscale(0.85) ${fallbackVar(vars.safariAnimationHook, 'blur(2px)')}`,
51
48
  willChange: 'opacity, filter',
52
49
  })
@@ -1,4 +1,10 @@
1
- import type { DiagramNode } from '@likec4/core'
1
+ import {
2
+ type DiagramNode,
3
+ type ElementStyle,
4
+ DefaultPaddingSize,
5
+ DefaultShapeSize,
6
+ DefaultTextSize,
7
+ } from '@likec4/core'
2
8
  import { type BoxProps, Box, createPolymorphicComponent } from '@mantine/core'
3
9
  import clsx from 'clsx'
4
10
  import { m } from 'framer-motion'
@@ -10,6 +16,7 @@ type RequiredData = Pick<
10
16
  DiagramNode,
11
17
  | 'color'
12
18
  | 'shape'
19
+ | 'style'
13
20
  >
14
21
 
15
22
  type ElementNodeContainerProps =
@@ -18,6 +25,30 @@ type ElementNodeContainerProps =
18
25
  nodeProps: NodeProps<RequiredData>
19
26
  }>
20
27
 
28
+ export function nodeSizes({
29
+ size,
30
+ padding,
31
+ textSize,
32
+ }: ElementStyle) {
33
+ if (!size && !!textSize) {
34
+ size = textSize
35
+ }
36
+ if (!textSize && !!size) {
37
+ textSize = size
38
+ }
39
+ if (!padding && !!size) {
40
+ padding = size
41
+ }
42
+ size ??= DefaultShapeSize
43
+ textSize ??= DefaultTextSize
44
+ padding ??= DefaultPaddingSize
45
+ return {
46
+ size,
47
+ padding,
48
+ textSize,
49
+ }
50
+ }
51
+
21
52
  export const ElementNodeContainer = createPolymorphicComponent<'div', ElementNodeContainerProps>(
22
53
  forwardRef<HTMLDivElement, ElementNodeContainerProps>(({
23
54
  nodeProps: {
@@ -42,6 +73,12 @@ export const ElementNodeContainer = createPolymorphicComponent<'div', ElementNod
42
73
  break
43
74
  }
44
75
 
76
+ const {
77
+ size,
78
+ padding,
79
+ textSize,
80
+ } = nodeSizes(data.style)
81
+
45
82
  return (
46
83
  <Box
47
84
  component={m.div}
@@ -60,6 +97,9 @@ export const ElementNodeContainer = createPolymorphicComponent<'div', ElementNod
60
97
  data-hovered={isHovered}
61
98
  data-likec4-color={data.color}
62
99
  data-likec4-shape={data.shape}
100
+ data-likec4-shape-size={size}
101
+ data-likec4-padding={padding}
102
+ data-likec4-text-size={textSize}
63
103
  data-likec4-dimmed={isDimmed}
64
104
  {...rest}
65
105
  >
@@ -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',
@@ -36,8 +37,8 @@ export const description = style({
36
37
  textOverflow: 'ellipsis',
37
38
  overflow: 'hidden',
38
39
  selectors: {
39
- [`:where(${hasIcon}) &`]: {
40
- textWrap: 'wrap',
40
+ [`:where([data-likec4-shape-size="xs"]) &`]: {
41
+ display: 'none',
41
42
  },
42
43
  },
43
44
  })
@@ -48,7 +49,7 @@ export const technology = style({
48
49
  fontOpticalSizing: 'auto',
49
50
  fontStyle: 'normal',
50
51
  fontWeight: 400,
51
- fontSize: 12,
52
+ fontSize: calc(textSize).multiply(0.635).toString(),
52
53
  lineHeight: 1.125,
53
54
  textAlign: textAlign,
54
55
  textWrap: 'balance',
@@ -58,26 +59,31 @@ export const technology = style({
58
59
  [`:where([data-hovered='true']) &`]: {
59
60
  opacity: 1,
60
61
  },
62
+ [`:where([data-likec4-shape-size="xs"], [data-likec4-shape-size="sm"]) &`]: {
63
+ display: 'none',
64
+ },
61
65
  },
62
66
  })
63
67
 
64
68
  export const elementDataContainer = style({
65
69
  flex: '1',
66
70
  height: 'fit-content',
71
+ width: 'fit-content',
72
+ margin: '0 auto',
67
73
  display: 'flex',
68
74
  alignItems: 'center',
69
75
  justifyContent: 'center',
70
76
  flexDirection: 'row',
71
- padding: rem(24),
77
+ paddingTop: paddingSize,
78
+ paddingBottom: paddingSize,
79
+ paddingLeft: calc(paddingSize).add('8px').toString(),
80
+ paddingRight: calc(paddingSize).add('8px').toString(),
72
81
  overflow: 'hidden',
73
- gap: rem(10),
74
- vars: {
75
- [iconSize]: '48px',
76
- },
82
+ gap: rem(12),
77
83
  selectors: {
78
84
  ':where([data-likec4-shape="queue"], [data-likec4-shape="mobile"]) &': {
79
- paddingLeft: 40,
80
- paddingRight: 20,
85
+ paddingLeft: 46,
86
+ paddingRight: 16,
81
87
  },
82
88
  ':where([data-likec4-shape="cylinder"], [data-likec4-shape="storage"]) &': {
83
89
  paddingTop: 30,
@@ -86,26 +92,16 @@ export const elementDataContainer = style({
86
92
  paddingTop: 32,
87
93
  paddingBottom: 28,
88
94
  },
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
95
  },
104
96
  })
97
+ globalStyle(`:where([data-likec4-shape-size="lg"], [data-likec4-shape-size="xl"]) ${elementDataContainer}`, {
98
+ gap: rem(16),
99
+ })
105
100
 
106
101
  export const elementTextData = style({
107
102
  height: 'fit-content',
108
- width: 'max-content',
103
+ width: 'fit-content',
104
+ flex: '0 1 auto',
109
105
  display: 'flex',
110
106
  flexDirection: 'column',
111
107
  alignItems: 'stretch',
@@ -121,7 +117,7 @@ export const elementTextData = style({
121
117
  gap: rem(6),
122
118
  },
123
119
  [`:where(${hasIcon}) &`]: {
124
- minWidth: 'calc(100% - 160px)',
120
+ minWidth: `calc(50% + ${iconSize})`,
125
121
  alignItems: 'flex-start',
126
122
  'vars': {
127
123
  [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'
@@ -6,7 +6,9 @@ import { isNumber, isTruthy } from 'remeda'
6
6
  import { IconRenderer } from '../../../context/IconRenderer'
7
7
  import { hiddenIfZoomTooSmall } from '../../../LikeC4Diagram.css'
8
8
  import type { NodeProps } from '../../types'
9
+ import { nodeSizes } from './ElementNodeContainer'
9
10
  import * as css from './ElementTitle.css'
11
+ import { iconSize as varIconSize } from './styles.css'
10
12
 
11
13
  type Data =
12
14
  & Pick<
@@ -15,6 +17,7 @@ type Data =
15
17
  | 'technology'
16
18
  | 'description'
17
19
  | 'color'
20
+ | 'style'
18
21
  >
19
22
  & {
20
23
  icon?: string | null
@@ -33,6 +36,9 @@ export function ElementTitle({ id, data, iconSize }: ElementTitleProps) {
33
36
  },
34
37
  className: css.elementIcon,
35
38
  })
39
+ const size = nodeSizes(data.style).size
40
+ const isSm = size === 'sm'
41
+ const isSmOrXs = isSm || size === 'xs'
36
42
  return (
37
43
  <Box
38
44
  className={clsx(
@@ -42,7 +48,7 @@ export function ElementTitle({ id, data, iconSize }: ElementTitleProps) {
42
48
  )}
43
49
  style={{
44
50
  ...isNumber(iconSize) && assignInlineVars({
45
- [css.iconSize]: `${iconSize}px`,
51
+ [varIconSize]: `${iconSize}px`,
46
52
  }),
47
53
  }}
48
54
  >
@@ -51,7 +57,7 @@ export function ElementTitle({ id, data, iconSize }: ElementTitleProps) {
51
57
  <Text
52
58
  component="h3"
53
59
  className={clsx(css.title, 'likec4-element-title')}
54
- lineClamp={3}>
60
+ lineClamp={isSmOrXs ? 2 : 3}>
55
61
  {data.title}
56
62
  </Text>
57
63
 
@@ -67,7 +73,7 @@ export function ElementTitle({ id, data, iconSize }: ElementTitleProps) {
67
73
  <Text
68
74
  component="div"
69
75
  className={clsx(css.description, 'likec4-element-description')}
70
- lineClamp={5}>
76
+ lineClamp={isSmOrXs ? 3 : 5}>
71
77
  {data.description}
72
78
  </Text>
73
79
  )}
@@ -0,0 +1,52 @@
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"]`, {
29
+ vars: {
30
+ [iconSize]: '82px',
31
+ },
32
+ })
33
+ globalStyle(`${container}[data-likec4-shape-size="xl"]`, {
34
+ vars: {
35
+ [iconSize]: '90px',
36
+ },
37
+ })
38
+
39
+ const sizes = ['xs', 'sm', 'lg', 'xl'] as const
40
+ sizes.forEach((size) => {
41
+ globalStyle(`${container}[data-likec4-text-size="${size}"]`, {
42
+ vars: {
43
+ [textSize]: rem(defaultTheme.textSizes[size]),
44
+ },
45
+ })
46
+
47
+ globalStyle(`${container}[data-likec4-padding="${size}"]`, {
48
+ vars: {
49
+ [paddingSize]: rem(defaultTheme.spacing[size]),
50
+ },
51
+ })
52
+ })
@@ -7,6 +7,8 @@ import { mantine, vars, whereDark } from './theme-vars'
7
7
  export const rootClassName = 'likec4-diagram-root'
8
8
 
9
9
  globalStyle(`.${rootClassName}`, {
10
+ containerName: 'likec4-diagram-root',
11
+ containerType: 'size',
10
12
  overflow: 'hidden',
11
13
  position: 'relative',
12
14
  width: '100%',
@@ -1,5 +1,4 @@
1
1
  export { useCurrentViewId } from './useCurrentViewId'
2
- export type { DiagramContext } from './useDiagramContext'
3
2
  export { useMantinePortalProps } from './useMantinePortalProps'
4
3
  export { useSetState } from './useSetState'
5
4
  export { useUpdateEffect } from './useUpdateEffect'
@@ -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()
package/src/index.ts CHANGED
@@ -16,7 +16,21 @@ export { useSetState } from './hooks/useSetState'
16
16
  export { useUpdateEffect } from './hooks/useUpdateEffect'
17
17
  export { vars, xyvars } from './theme-vars'
18
18
 
19
- export type * from './LikeC4Diagram.props'
19
+ export type {
20
+ ChangeEvent,
21
+ DiagramNodeWithNavigate,
22
+ ElementIconRenderer,
23
+ LikeC4ColorScheme,
24
+ LikeC4DiagramEventHandlers,
25
+ LikeC4DiagramProperties,
26
+ OnCanvasClick,
27
+ OnChange,
28
+ OnEdgeClick,
29
+ OnNavigateTo,
30
+ OnNodeClick,
31
+ OpenSourceParams,
32
+ WhereOperator,
33
+ } from './LikeC4Diagram.props'
20
34
 
21
35
  export { StaticLikeC4Diagram } from './StaticLikeC4Diagram'
22
36
  export type { StaticLikeC4DiagramProps } from './StaticLikeC4Diagram'
@@ -1,12 +1,9 @@
1
- import { memo } from 'react'
2
1
  import { IfEnabled } from '../context'
3
2
  import { LikeC4Search } from '../LikeC4Search'
4
3
  import { Overlays } from '../overlays/Overlays'
5
- import { Controls, DiagramTitlePanel } from './ui'
6
- import NotationPanel from './ui/notation'
7
- import { DynamicViewWalkthrough } from './ui/walkthrough/DynamicViewWalkthrough'
4
+ import { Controls, DiagramTitlePanel, DynamicViewWalkthrough, NotationPanel } from './ui'
8
5
 
9
- export const DiagramUI = memo(() => {
6
+ export function DiagramUI() {
10
7
  return (
11
8
  <>
12
9
  <Controls />
@@ -25,4 +22,4 @@ export const DiagramUI = memo(() => {
25
22
  </IfEnabled>
26
23
  </>
27
24
  )
28
- })
25
+ }
@@ -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'
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  type EdgeId,
3
- type NodeId,
4
3
  isStepEdgeId,
5
4
  nonNullable,
6
5
  } from '@likec4/core'
@@ -2,6 +2,7 @@ import { style } from '@vanilla-extract/css'
2
2
  import { mantine, vars } from '../../../theme-vars'
3
3
 
4
4
  export const menuDropdown = style({
5
+ overflowY: 'scroll',
5
6
  minWidth: 250,
6
7
  maxWidth: 'min(90vw, 500px)',
7
8
  })