@likec4/core 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 (80) hide show
  1. package/dist/builder/index.cjs +24 -18
  2. package/dist/builder/index.d.cts +11 -5
  3. package/dist/builder/index.d.mts +11 -5
  4. package/dist/builder/index.d.ts +11 -5
  5. package/dist/builder/index.mjs +10 -4
  6. package/dist/compute-view/index.cjs +6 -6
  7. package/dist/compute-view/index.d.cts +4 -4
  8. package/dist/compute-view/index.d.mts +4 -4
  9. package/dist/compute-view/index.d.ts +4 -4
  10. package/dist/compute-view/index.mjs +6 -6
  11. package/dist/index.cjs +53 -14
  12. package/dist/index.d.cts +6 -6
  13. package/dist/index.d.mts +6 -6
  14. package/dist/index.d.ts +6 -6
  15. package/dist/index.mjs +47 -11
  16. package/dist/model/index.cjs +1 -1
  17. package/dist/model/index.d.cts +5 -5
  18. package/dist/model/index.d.mts +5 -5
  19. package/dist/model/index.d.ts +5 -5
  20. package/dist/model/index.mjs +1 -1
  21. package/dist/shared/{core.Cmfo_N4F.d.mts → core.5Z5cpENq.d.mts} +5 -4
  22. package/dist/shared/{core.D4wZW7zR.d.ts → core.BJfq046m.d.ts} +5 -4
  23. package/dist/shared/{core.C0ygs98j.d.cts → core.BS_nXBsP.d.cts} +9 -2
  24. package/dist/shared/{core.CajOK_t3.d.mts → core.BYs5deiY.d.cts} +1 -1
  25. package/dist/shared/{core.Bezy7K65.mjs → core.BfZZXtur.mjs} +2 -2
  26. package/dist/shared/{core.CwZmAghJ.d.cts → core.BgPZ8Tl8.d.cts} +5 -4
  27. package/dist/shared/{core.FACQZmma.cjs → core.BjR0D3IO.cjs} +15 -15
  28. package/dist/shared/{core.uxHtIZaH.cjs → core.CAkSSvJ6.cjs} +11 -5
  29. package/dist/shared/{core.El-gigOM.mjs → core.CE-kCVHA.mjs} +1 -1
  30. package/dist/shared/{core.DjMYkPMQ.d.mts → core.CJaCUZQ9.d.mts} +9 -2
  31. package/dist/shared/{core.88YY6vtF.d.mts → core.CT1nzYjO.d.cts} +2 -2
  32. package/dist/shared/{core.0PxLtLpP.mjs → core.CYNYaH2U.mjs} +5 -2
  33. package/dist/shared/{core.CCyhaU-4.mjs → core.CeefT_JU.mjs} +6 -6
  34. package/dist/shared/{core.BG1hfxpq.mjs → core.Cz9Oy_FA.mjs} +475 -409
  35. package/dist/shared/{core.BIZD3l1g.d.cts → core.D0KD4FiT.d.mts} +1 -1
  36. package/dist/shared/{core.DRfrKNT6.cjs → core.D91uYrqI.cjs} +551 -485
  37. package/dist/shared/{core.BtISRjMA.d.ts → core.DQCc-Jxk.d.ts} +1 -1
  38. package/dist/shared/{core.Db_OTRdC.cjs → core.DnPc_NDM.cjs} +1 -1
  39. package/dist/shared/{core.CNUzoKM7.d.ts → core.Dp3HTiRV.d.ts} +2 -2
  40. package/dist/shared/{core.CKYxnFEl.cjs → core.DqQrj2oQ.cjs} +2 -2
  41. package/dist/shared/{core.Bs71hdR4.d.ts → core.DsDq-blc.d.ts} +9 -2
  42. package/dist/shared/{core.Lh2RFJf1.d.cts → core.DuuS_BrY.d.mts} +2 -2
  43. package/dist/shared/{core.BJfn72tj.d.ts → core.QP35c488.d.cts} +33 -1
  44. package/dist/shared/{core.BJfn72tj.d.cts → core.QP35c488.d.mts} +33 -1
  45. package/dist/shared/{core.BJfn72tj.d.mts → core.QP35c488.d.ts} +33 -1
  46. package/dist/types/index.cjs +4 -1
  47. package/dist/types/index.d.cts +4 -4
  48. package/dist/types/index.d.mts +4 -4
  49. package/dist/types/index.d.ts +4 -4
  50. package/dist/types/index.mjs +1 -1
  51. package/dist/utils/index.cjs +3 -3
  52. package/dist/utils/index.d.cts +2 -2
  53. package/dist/utils/index.d.mts +2 -2
  54. package/dist/utils/index.d.ts +2 -2
  55. package/dist/utils/index.mjs +3 -3
  56. package/package.json +6 -6
  57. package/src/builder/Builder.ts +11 -5
  58. package/src/builder/Builder.view-common.ts +1 -0
  59. package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +16 -4
  60. package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +21 -5
  61. package/src/builder/_types.ts +9 -0
  62. package/src/compute-view/deployment-view/predicates/{elements.ts → deploymentRefs.ts} +32 -21
  63. package/src/compute-view/deployment-view/predicates/index.ts +1 -1
  64. package/src/compute-view/deployment-view/predicates/utils.ts +56 -1
  65. package/src/compute-view/deployment-view/predicates/wildcard.ts +20 -9
  66. package/src/compute-view/memory/AbstractStageExclude.ts +1 -1
  67. package/src/compute-view/utils/applyCustomElementProperties.ts +18 -1
  68. package/src/compute-view/utils/applyViewRuleStyles.ts +9 -0
  69. package/src/compute-view/utils/buildComputedNodes.ts +13 -9
  70. package/src/index.ts +1 -1
  71. package/src/model/DeploymentElementModel.ts +5 -2
  72. package/src/model/ElementModel.ts +10 -0
  73. package/src/{colors → theme}/element.ts +9 -9
  74. package/src/{colors → theme}/index.ts +41 -5
  75. package/src/{colors → theme}/relationships.ts +9 -9
  76. package/src/types/element.ts +19 -1
  77. package/src/types/expression.ts +4 -1
  78. package/src/types/index.ts +6 -0
  79. package/src/types/theme.ts +22 -1
  80. package/src/types/view.ts +5 -1
@@ -7,7 +7,43 @@ export const defaultTheme: LikeC4Theme = {
7
7
  elements: ElementColors,
8
8
  relationships: RelationshipColors,
9
9
  font: 'Arial',
10
- shadow: '#0a0a0a'
10
+ shadow: '#0a0a0a',
11
+ sizes: {
12
+ xs: {
13
+ width: 180,
14
+ height: 100,
15
+ },
16
+ sm: {
17
+ width: 240,
18
+ height: 135,
19
+ },
20
+ md: {
21
+ width: 320,
22
+ height: 180,
23
+ },
24
+ lg: {
25
+ width: 420,
26
+ height: 234,
27
+ },
28
+ xl: {
29
+ width: 520,
30
+ height: 290,
31
+ },
32
+ },
33
+ spacing: {
34
+ xs: 8, // 0.5rem
35
+ sm: 10, // 0.625rem
36
+ md: 16, // 1rem
37
+ lg: 24, // 1.5rem = 16px + 8px
38
+ xl: 32, // 2rem
39
+ },
40
+ textSizes: {
41
+ xs: 12,
42
+ sm: 14,
43
+ md: 19,
44
+ lg: 24,
45
+ xl: 32,
46
+ },
11
47
  }
12
48
 
13
49
  export function computeColorValues(color: HexColorLiteral): ThemeColorValues {
@@ -19,18 +55,18 @@ export function computeColorValues(color: HexColorLiteral): ThemeColorValues {
19
55
  fill: colors[6] as HexColorLiteral,
20
56
  stroke: colors[7] as HexColorLiteral,
21
57
  hiContrast: colors[0] as HexColorLiteral,
22
- loContrast: colors[1] as HexColorLiteral
58
+ loContrast: colors[1] as HexColorLiteral,
23
59
  },
24
60
  relationships: {
25
61
  lineColor: colors[4] as HexColorLiteral,
26
62
  labelColor: colors[3] as HexColorLiteral,
27
- labelBgColor: colors[9] as HexColorLiteral
28
- }
63
+ labelBgColor: colors[9] as HexColorLiteral,
64
+ },
29
65
  }
30
66
  } else {
31
67
  return {
32
68
  elements: defaultTheme.elements['primary'],
33
- relationships: defaultTheme.relationships['primary']
69
+ relationships: defaultTheme.relationships['primary'],
34
70
  }
35
71
  }
36
72
  }
@@ -3,52 +3,52 @@ import type { RelationshipThemeColors, RelationshipThemeColorValues } from '../t
3
3
  const gray = {
4
4
  lineColor: '#6E6E6E',
5
5
  labelBgColor: '#18191b',
6
- labelColor: '#C6C6C6'
6
+ labelColor: '#C6C6C6',
7
7
  } satisfies RelationshipThemeColorValues
8
8
  const slate = {
9
9
  lineColor: '#64748b', // 500
10
10
  labelBgColor: '#0f172a', // 900
11
- labelColor: '#cbd5e1' // 300
11
+ labelColor: '#cbd5e1', // 300
12
12
  } satisfies RelationshipThemeColorValues
13
13
 
14
14
  const blue = {
15
15
  lineColor: '#3b82f6', // 500
16
16
  labelBgColor: '#172554', // 950
17
- labelColor: '#60a5fa' // 400
17
+ labelColor: '#60a5fa', // 400
18
18
  } satisfies RelationshipThemeColorValues
19
19
 
20
20
  const sky = {
21
21
  lineColor: '#0ea5e9', // 500
22
22
  labelBgColor: '#082f49', // 950
23
- labelColor: '#38bdf8' // 400
23
+ labelColor: '#38bdf8', // 400
24
24
  } satisfies RelationshipThemeColorValues
25
25
 
26
26
  export const RelationshipColors = {
27
27
  amber: {
28
28
  lineColor: '#b45309',
29
29
  labelBgColor: '#78350f',
30
- labelColor: '#FFE0C2'
30
+ labelColor: '#FFE0C2',
31
31
  },
32
32
  blue,
33
33
  gray,
34
34
  green: {
35
35
  lineColor: '#15803d', // 700
36
36
  labelBgColor: '#052e16', // 950
37
- labelColor: '#22c55e' // 500
37
+ labelColor: '#22c55e', // 500
38
38
  },
39
39
  indigo: {
40
40
  lineColor: '#6366f1', // 500
41
41
  labelBgColor: '#1e1b4b', // 950
42
- labelColor: '#818cf8' // 400
42
+ labelColor: '#818cf8', // 400
43
43
  },
44
44
  muted: slate,
45
45
  primary: blue,
46
46
  red: {
47
47
  lineColor: '#AC4D39',
48
48
  labelBgColor: '#b91c1c',
49
- labelColor: '#f5b2a3'
49
+ labelColor: '#f5b2a3',
50
50
  },
51
51
  secondary: sky,
52
52
  sky,
53
- slate
53
+ slate,
54
54
  } satisfies RelationshipThemeColors
@@ -1,6 +1,6 @@
1
1
  import type { Tagged, TupleToUnion } from 'type-fest'
2
2
  import type { IconUrl, NonEmptyArray } from './_common'
3
- import type { Color, ThemeColor } from './theme'
3
+ import type { Color, ShapeSize, SpacingSize, TextSize, ThemeColor } from './theme'
4
4
 
5
5
  // Full-qualified-name
6
6
  export type Fqn<Id extends string = string> = Tagged<Id, 'Fqn'>
@@ -30,6 +30,9 @@ export const ElementShapes = [
30
30
  export type ElementShape = TupleToUnion<typeof ElementShapes>
31
31
  export const DefaultThemeColor: ThemeColor = 'primary'
32
32
  export const DefaultElementShape: ElementShape = 'rectangle'
33
+ export const DefaultShapeSize: ShapeSize = 'md'
34
+ export const DefaultPaddingSize: SpacingSize = 'md'
35
+ export const DefaultTextSize: TextSize = 'md'
33
36
 
34
37
  export interface ElementStyle {
35
38
  readonly border?: BorderStyle
@@ -44,6 +47,17 @@ export interface ElementStyle {
44
47
  * @default false
45
48
  */
46
49
  readonly multiple?: boolean
50
+
51
+ /**
52
+ * Shape size
53
+ *
54
+ * @default 'md'
55
+ */
56
+ readonly size?: ShapeSize
57
+
58
+ readonly padding?: SpacingSize
59
+
60
+ readonly textSize?: TextSize
47
61
  }
48
62
 
49
63
  export type Tag<Tags extends string = string> = Tagged<Tags, 'Tag'>
@@ -91,7 +105,11 @@ export interface ElementKindSpecificationStyle {
91
105
  color?: Color
92
106
  border?: BorderStyle
93
107
  opacity?: number
108
+ size?: ShapeSize
109
+ padding?: SpacingSize
110
+ textSize?: TextSize
94
111
  }
112
+
95
113
  export interface ElementKindSpecification {
96
114
  readonly technology?: string
97
115
  readonly notation?: string
@@ -2,7 +2,7 @@ import type { IconUrl } from './_common'
2
2
  import type { BorderStyle, ElementKind, ElementShape, Fqn, Tag } from './element'
3
3
  import type { WhereOperator } from './operators'
4
4
  import type { RelationshipArrowType, RelationshipLineType } from './relation'
5
- import type { Color } from './theme'
5
+ import type { Color, ShapeSize } from './theme'
6
6
  import type { ViewId } from './view'
7
7
 
8
8
  interface BaseExpr {
@@ -54,6 +54,9 @@ export interface CustomElementExpr extends Omit<BaseExpr, 'custom'> {
54
54
  opacity?: number
55
55
  navigateTo?: ViewId
56
56
  multiple?: boolean
57
+ size?: ShapeSize
58
+ padding?: ShapeSize
59
+ textSize?: ShapeSize
57
60
  }
58
61
  }
59
62
 
@@ -28,6 +28,9 @@ export {
28
28
  AsFqn,
29
29
  BorderStyles,
30
30
  DefaultElementShape,
31
+ DefaultPaddingSize,
32
+ DefaultShapeSize,
33
+ DefaultTextSize,
31
34
  DefaultThemeColor,
32
35
  ElementKind,
33
36
  ElementShapes,
@@ -147,6 +150,9 @@ export type {
147
150
  LikeC4Theme,
148
151
  RelationshipThemeColors,
149
152
  RelationshipThemeColorValues,
153
+ ShapeSize,
154
+ SpacingSize,
155
+ TextSize,
150
156
  ThemeColor,
151
157
  ThemeColorValues,
152
158
  } from './theme'
@@ -11,7 +11,7 @@ const ThemeColors = [
11
11
  'primary',
12
12
  'red',
13
13
  'secondary',
14
- 'sky'
14
+ 'sky',
15
15
  ] as const
16
16
  export type ThemeColor = typeof ThemeColors[number]
17
17
 
@@ -21,6 +21,15 @@ export type ColorLiteral = HexColorLiteral
21
21
 
22
22
  export type Color = LiteralUnion<ThemeColor, string>
23
23
 
24
+ export type ShapeSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
25
+
26
+ /**
27
+ * For padding, margin, etc.
28
+ */
29
+ export type SpacingSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
30
+
31
+ export type TextSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
32
+
24
33
  export function isThemeColor(color: Color): color is ThemeColor {
25
34
  return color in ThemeColors
26
35
  }
@@ -58,4 +67,16 @@ export interface LikeC4Theme {
58
67
  shadow: ColorLiteral
59
68
  relationships: RelationshipThemeColors
60
69
  elements: ElementThemeColors
70
+ sizes: {
71
+ [key in ShapeSize]: {
72
+ width: number
73
+ height: number
74
+ }
75
+ }
76
+ spacing: {
77
+ [key in SpacingSize]: number
78
+ }
79
+ textSizes: {
80
+ [key in TextSize]: number
81
+ }
61
82
  }
package/src/types/view.ts CHANGED
@@ -14,7 +14,7 @@ import type { ElementExpression, ElementPredicateExpression, Expression } from '
14
14
  import type { ExpressionV2, FqnExpr } from './expression-v2'
15
15
  import type { GlobalPredicateId, GlobalStyleID } from './global'
16
16
  import type { RelationId, RelationshipArrowType, RelationshipKind, RelationshipLineType } from './relation'
17
- import type { Color, ThemeColorValues } from './theme'
17
+ import type { Color, ShapeSize, SpacingSize, TextSize, ThemeColorValues } from './theme'
18
18
  import type { ElementNotation } from './view-notation'
19
19
 
20
20
  export type ViewId<Id extends string = string> = Tagged<Id, 'ViewID'>
@@ -94,6 +94,10 @@ export interface ViewRuleGroup {
94
94
  border?: BorderStyle
95
95
  // 0-100
96
96
  opacity?: number
97
+ multiple?: boolean
98
+ size?: ShapeSize
99
+ padding?: SpacingSize
100
+ textSize?: TextSize
97
101
  }
98
102
 
99
103
  export function isViewRuleGroup(rule: ViewRule): rule is ViewRuleGroup {