@likec4/diagram 1.20.3 → 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 (90) 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/useViewToNodesEdges.js +1 -1
  44. package/dist/overlays/Overlays.js +42 -21
  45. package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -3
  46. package/dist/overlays/element-details/ElementDetailsCard.js +38 -39
  47. package/dist/overlays/element-details/TabPanelDeployments.js +1 -1
  48. package/dist/overlays/element-details/TabPanelRelationships.js +14 -30
  49. package/dist/overlays/overlay/Overlay.css.js +2 -1
  50. package/dist/overlays/overlay/Overlay.js +2 -2
  51. package/dist/overlays/relationship-details/SelectEdge.js +1 -1
  52. package/dist/overlays/relationship-details/_types.d.ts +3 -3
  53. package/dist/overlays/relationship-details/actor.js +1 -1
  54. package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +3 -3
  55. package/dist/overlays/relationship-details/custom/nodeTypes.js +2 -2
  56. package/dist/overlays/relationship-details/useLayoutedDetails.js +1 -4
  57. package/dist/overlays/relationships-browser/-useRelationshipsView.js +0 -3
  58. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +3 -3
  59. package/dist/overlays/relationships-browser/_types.d.ts +3 -3
  60. package/dist/overlays/relationships-browser/actor.js +16 -16
  61. package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +3 -2
  62. package/dist/overlays/relationships-browser/custom/nodeTypes.js +3 -3
  63. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +3 -2
  64. package/dist/style.css +1 -1
  65. package/package.json +12 -12
  66. package/src/base/example/_types.ts +3 -2
  67. package/src/base/example/useViewToNodesEdges.ts +2 -1
  68. package/src/base/primitives/compound/CompoundTitle.css.ts +27 -1
  69. package/src/base/primitives/compound/CompoundTitle.tsx +12 -2
  70. package/src/base/primitives/element/ElementNodeContainer.tsx +21 -1
  71. package/src/base/primitives/element/ElementShape.css.ts +5 -0
  72. package/src/base/primitives/element/ElementTitle.css.ts +17 -24
  73. package/src/base/primitives/element/ElementTitle.tsx +4 -2
  74. package/src/base/primitives/element/styles.css.ts +74 -0
  75. package/src/hooks/useDiagram.ts +1 -1
  76. package/src/likec4diagram/DiagramUI.tsx +2 -2
  77. package/src/likec4diagram/XYFlow.tsx +2 -2
  78. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +3 -2
  79. package/src/likec4diagram/types.ts +2 -2
  80. package/src/likec4diagram/useViewToNodesEdges.ts +1 -1
  81. package/src/overlays/Overlays.tsx +61 -281
  82. package/src/overlays/element-details/ElementDetailsCard.tsx +213 -257
  83. package/src/overlays/element-details/TabPanelRelationships.tsx +13 -75
  84. package/src/overlays/overlay/Overlay.tsx +1 -1
  85. package/src/overlays/relationship-details/_types.ts +3 -3
  86. package/src/overlays/relationship-details/useLayoutedDetails.ts +1 -1
  87. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +44 -55
  88. package/src/overlays/relationships-browser/_types.ts +12 -2
  89. package/src/overlays/relationships-browser/actor.ts +11 -10
  90. package/src/overlays/relationships-browser/useViewToNodesEdges.ts +2 -1
@@ -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
 
@@ -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