@likec4/diagram 1.38.0 → 1.39.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 (86) hide show
  1. package/bundle/{chunk-BZV0K82k.js → chunk-Bg7UjtMS.js} +332 -326
  2. package/bundle/custom.js +59 -59
  3. package/bundle/index.js +244 -170
  4. package/dist/LikeC4Diagram.props.d.ts +15 -8
  5. package/dist/base/BaseXYFlow.js +5 -5
  6. package/dist/base/index.d.ts +1 -2
  7. package/dist/base/primitives/MarkdownBlock.js +2 -1
  8. package/dist/base/primitives/customEdge.d.ts +3 -3
  9. package/dist/base/primitives/element/ElementTitle.js +2 -10
  10. package/dist/base/types.d.ts +62 -5
  11. package/dist/base/types.js +54 -0
  12. package/dist/bundle/LikeC4View.d.ts +2 -2
  13. package/dist/bundle/LikeC4View.props.d.ts +4 -3
  14. package/dist/bundle/ReactLikeC4.d.ts +4 -4
  15. package/dist/custom/customNodes.d.ts +2 -1
  16. package/dist/hooks/useXYFlow.d.ts +28 -29
  17. package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +4 -5
  18. package/dist/likec4diagram/custom/nodes/ElementActions.js +1 -1
  19. package/dist/likec4diagram/types.d.ts +2 -1
  20. package/dist/likec4diagram/useViewToNodesEdges.js +1 -1
  21. package/dist/likec4model/LikeC4ModelContext.d.ts +5 -2
  22. package/dist/likec4model/useLikeC4ElementsTree.js +1 -1
  23. package/dist/likec4model/useLikeC4Model.d.ts +7 -20
  24. package/dist/navigationpanel/NavigationPanel.js +3 -1
  25. package/dist/navigationpanel/NavigationPanelDropdown.js +1 -1
  26. package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +6 -4
  27. package/dist/navigationpanel/walkthrough/WalkthroughPanel.d.ts +1 -0
  28. package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +83 -0
  29. package/dist/overlays/element-details/actor.d.ts +556 -557
  30. package/dist/overlays/relationship-details/RelationshipDetails.d.ts +2 -3
  31. package/dist/overlays/relationship-details/actor.d.ts +1 -1
  32. package/dist/overlays/relationship-details/actor.js +7 -7
  33. package/dist/overlays/relationship-details/compute.js +2 -1
  34. package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +2 -3
  35. package/dist/overlays/relationship-details/hooks.d.ts +18 -19
  36. package/dist/overlays/relationship-details/layout.js +2 -1
  37. package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +2 -3
  38. package/dist/overlays/relationships-browser/actor.d.ts +12 -12
  39. package/dist/overlays/relationships-browser/actor.js +8 -8
  40. package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +2 -3
  41. package/dist/overlays/relationships-browser/layout.js +2 -1
  42. package/dist/search/components/ElementsColumn.js +1 -1
  43. package/dist/state/DiagramActorProvider.js +2 -2
  44. package/dist/state/assign.js +6 -6
  45. package/dist/state/diagram-machine.js +14 -14
  46. package/dist/styles-min.css +1 -1
  47. package/dist/styles-xyflow.css +1 -1
  48. package/dist/styles.css +1 -1
  49. package/dist/styles.css2.js +1 -1
  50. package/dist/utils/xyflow.js +2 -2
  51. package/package.json +16 -16
  52. package/panda.buildinfo.json +14 -11
  53. package/src/LikeC4Diagram.props.ts +16 -16
  54. package/src/base/index.ts +1 -2
  55. package/src/base/primitives/MarkdownBlock.tsx +1 -0
  56. package/src/base/primitives/customEdge.ts +5 -5
  57. package/src/base/primitives/element/ElementTitle.tsx +10 -22
  58. package/src/base/types.ts +122 -13
  59. package/src/bundle/LikeC4View.props.ts +4 -3
  60. package/src/bundle/LikeC4View.tsx +6 -6
  61. package/src/bundle/ReactLikeC4.tsx +7 -6
  62. package/src/custom/customNodes.ts +3 -1
  63. package/src/hooks/useSetState.ts +2 -2
  64. package/src/likec4diagram/custom/nodes/ElementActions.tsx +2 -1
  65. package/src/likec4diagram/types.ts +1 -1
  66. package/src/likec4diagram/useViewToNodesEdges.ts +1 -1
  67. package/src/likec4model/LikeC4ModelContext.tsx +5 -2
  68. package/src/likec4model/useLikeC4ElementsTree.ts +3 -3
  69. package/src/likec4model/useLikeC4Model.ts +8 -5
  70. package/src/navigationpanel/NavigationPanel.tsx +2 -0
  71. package/src/navigationpanel/NavigationPanelDropdown.tsx +1 -1
  72. package/src/navigationpanel/walkthrough/ActiveWalkthroughControls.tsx +3 -1
  73. package/src/navigationpanel/walkthrough/WalkthroughPanel.tsx +88 -0
  74. package/src/overlays/relationship-details/compute.ts +3 -12
  75. package/src/overlays/relationship-details/layout.ts +3 -3
  76. package/src/overlays/relationships-browser/actor.ts +2 -1
  77. package/src/overlays/relationships-browser/layout.ts +3 -3
  78. package/src/search/components/ElementsColumn.tsx +3 -3
  79. package/src/utils/xyflow.ts +2 -2
  80. package/dist/base/types.Base.d.ts +0 -54
  81. package/dist/base/types.Base.js +0 -48
  82. package/dist/likec4diagram/custom/edges/NotePopover.d.ts +0 -4
  83. package/src/base/types.Base.ts +0 -104
  84. package/src/likec4diagram/custom/edges/NotePopover.tsx +0 -95
  85. /package/dist/{likec4diagram/custom/edges/NotePopover.css.d.ts → navigationpanel/walkthrough/WalkthroughPanel.css.d.ts} +0 -0
  86. /package/src/{likec4diagram/custom/edges/NotePopover.css.ts → navigationpanel/walkthrough/WalkthroughPanel.css.ts} +0 -0
@@ -1,7 +1,7 @@
1
- import { invariant, hasAtLeast } from '@likec4/core';
1
+ import { invariant } from '@likec4/core/utils';
2
2
  import { getNodeDimensions } from '@xyflow/system';
3
3
  import { Bezier } from 'bezier-js';
4
- import { isArray } from 'remeda';
4
+ import { isArray, hasAtLeast } from 'remeda';
5
5
 
6
6
  function bezierControlPoints(diagramEdge) {
7
7
  let [start, ...bezierPoints] = diagramEdge.points;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/diagram",
3
- "version": "1.38.0",
3
+ "version": "1.39.0",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -68,14 +68,14 @@
68
68
  },
69
69
  "dependencies": {
70
70
  "@dagrejs/dagre": "1.1.5",
71
- "@floating-ui/dom": "^1.7.3",
71
+ "@floating-ui/dom": "^1.7.4",
72
72
  "@mantine/core": "8.2.4",
73
73
  "@mantine/hooks": "8.2.4",
74
74
  "@nanostores/react": "1.0.0",
75
75
  "@react-hookz/web": "^25.1.1",
76
76
  "@xstate/react": "^5.0.5",
77
- "@xyflow/react": "12.8.3",
78
- "@xyflow/system": "0.0.67",
77
+ "@xyflow/react": "12.8.4",
78
+ "@xyflow/system": "0.0.68",
79
79
  "bezier-js": "^6.1.4",
80
80
  "d3-shape": "^3.2.0",
81
81
  "esm-env": "^1.2.2",
@@ -88,11 +88,11 @@
88
88
  "remeda": "^2.23.1",
89
89
  "type-fest": "^4.41.0",
90
90
  "xstate": "^5.20.2",
91
- "@likec4/core": "1.38.0",
92
- "@likec4/styles": "1.38.0"
91
+ "@likec4/core": "1.39.0",
92
+ "@likec4/styles": "1.39.0"
93
93
  },
94
94
  "peerDependencies": {
95
- "@pandacss/dev": "^1.0.1",
95
+ "@pandacss/dev": "^1.1.0",
96
96
  "react": "^18.x || ^19.x",
97
97
  "react-dom": "^18.x || ^19.x"
98
98
  },
@@ -102,24 +102,24 @@
102
102
  }
103
103
  },
104
104
  "devDependencies": {
105
- "@pandacss/dev": "^1.0.1",
105
+ "@pandacss/dev": "^1.1.0",
106
106
  "@statelyai/inspect": "^0.4.0",
107
107
  "@tabler/icons-react": "3.34.1",
108
108
  "@types/bezier-js": "^4.1.3",
109
109
  "@types/d3-shape": "^3.1.7",
110
- "@types/node": "~20.19.2",
111
- "@types/react": "19.1.10",
112
- "@types/react-dom": "19.1.7",
110
+ "@types/node": "~20.19.11",
111
+ "@types/react": "19.1.12",
112
+ "@types/react-dom": "19.1.9",
113
113
  "@vitejs/plugin-react": "^4.6.0",
114
- "postcss": "8.5.5",
115
- "react": "^19.1.1",
116
- "react-dom": "^19.1.1",
114
+ "postcss": "8.5.6",
115
+ "react": "19.1.1",
116
+ "react-dom": "19.1.1",
117
117
  "typescript": "5.9.2",
118
118
  "vite": "^6.3.5",
119
119
  "vite-plugin-dts": "^4.5.4",
120
120
  "vitest": "3.2.4",
121
121
  "wireit": "0.14.12",
122
- "@likec4/tsconfig": "1.38.0"
122
+ "@likec4/tsconfig": "1.39.0"
123
123
  },
124
124
  "scripts": {
125
125
  "typecheck": "tsc --build --verbose",
@@ -128,7 +128,7 @@
128
128
  "build": "echo \"use pnpm turbo run build\" || true",
129
129
  "pack": "pnpm pack",
130
130
  "test": "vitest run --no-isolate",
131
- "clean": "pnpm rimraf dist lib bundle *.tgz",
131
+ "clean": "pnpm rimraf --glob dist lib bundle *.tgz",
132
132
  "lint:package": "pnpx publint ./package.tgz"
133
133
  }
134
134
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "schemaVersion": "1.0.1",
2
+ "schemaVersion": "1.1.0",
3
3
  "styles": {
4
4
  "atomic": [
5
5
  "background]___[value:dots",
@@ -315,6 +315,15 @@
315
315
  "marginRight]___[value:sm",
316
316
  "borderColor]___[value:mantine.colors.orange[6]",
317
317
  "borderWidth]___[value:4]___[cond:md",
318
+ "top]___[value:[1px]",
319
+ "right]___[value:[1px]",
320
+ "zIndex]___[value:9",
321
+ "textAlign]___[value:left",
322
+ "textWrap]___[value:pretty",
323
+ "lineHeight]___[value:1.25",
324
+ "--text-fz]___[value:{fontSizes.sm}",
325
+ "--text-fz]___[value:{fontSizes.md}]___[cond:md",
326
+ "paddingTop]___[value:xxs",
318
327
  "boxSizing]___[value:border-box",
319
328
  "inset]___[value:0",
320
329
  "width]___[value:100vw",
@@ -729,15 +738,6 @@
729
738
  "lineClamp]___[value:2",
730
739
  "lineClamp]___[value:3",
731
740
  "maxHeight]___[value:8rem",
732
- "top]___[value:[1px]",
733
- "right]___[value:[1px]",
734
- "zIndex]___[value:9",
735
- "textAlign]___[value:left",
736
- "textWrap]___[value:pretty",
737
- "lineHeight]___[value:1.25",
738
- "--text-fz]___[value:{fontSizes.sm}",
739
- "--text-fz]___[value:{fontSizes.md}]___[cond:md",
740
- "offset]___[value:16",
741
741
  "mixBlendMode]___[value:normal",
742
742
  "fill]___[value:var(--likec4-palette-relation-stroke)",
743
743
  "stroke]___[value:var(--likec4-palette-relation-stroke)",
@@ -858,9 +858,12 @@
858
858
  ],
859
859
  "markdownBlock": [
860
860
  "uselikec4palette]___[value:false]___[recipe:markdownBlock",
861
+ "value]___[value:markdown]___[recipe:markdownBlock",
862
+ "value]___[value:plaintext]___[recipe:markdownBlock",
861
863
  "uselikec4palette]___[value:true]___[recipe:markdownBlock",
862
864
  "*]___[value:true]___[recipe:markdownBlock",
863
- "*]___[value:false]___[recipe:markdownBlock"
865
+ "*]___[value:false]___[recipe:markdownBlock",
866
+ "*]___[value:plaintext]___[recipe:markdownBlock"
864
867
  ],
865
868
  "actionBtn": [
866
869
  "size]___[value:md]___[recipe:actionBtn",
@@ -1,18 +1,18 @@
1
- import type {
2
- Any,
3
- aux,
4
- DiagramEdge,
5
- DiagramNode,
6
- LayoutedView,
7
- ViewChange,
8
- WhereOperator,
9
- } from '@likec4/core/types'
1
+ import type * as t from '@likec4/core/types'
2
+ import type { DiagramEdge, DiagramNode, LayoutedView, ViewChange, WhereOperator } from '@likec4/core/types'
10
3
  import type { ReactFlowProps as XYFlowProps } from '@xyflow/react'
11
4
  import type { MouseEvent as ReactMouseEvent, ReactNode } from 'react'
12
5
  import type { SetRequired } from 'type-fest'
13
6
  import type { ControlsCustomLayout } from './context/ControlsCustomLayout'
14
7
  import type { CustomNodes } from './custom/customNodes'
15
8
 
9
+ type Any = t.aux.Any
10
+ type ViewId<A> = t.aux.ViewId<A>
11
+ type Fqn<A> = t.aux.Fqn<A>
12
+ type RelationId = t.aux.RelationId
13
+ type DeploymentFqn<A> = t.aux.DeploymentFqn<A>
14
+ type StrictViewId<A> = t.aux.StrictViewId<A>
15
+
16
16
  export type { CustomNodes, WhereOperator }
17
17
 
18
18
  export type DiagramNodeWithNavigate<A extends Any> = SetRequired<DiagramNode<A>, 'navigateTo'>
@@ -29,7 +29,7 @@ export type ElementIconRendererProps = {
29
29
  export type ElementIconRenderer = (props: ElementIconRendererProps) => ReactNode
30
30
 
31
31
  export type OnNavigateTo<A extends Any = Any> = (
32
- to: aux.ViewId<A>,
32
+ to: ViewId<A>,
33
33
  // These fields present if navigateTo triggered by a node click
34
34
  event?: ReactMouseEvent,
35
35
  element?: DiagramNodeWithNavigate<A>,
@@ -303,23 +303,23 @@ export interface LikeC4DiagramProperties<A extends Any = Any> {
303
303
  reactFlowProps?: OverrideReactFlowProps | undefined
304
304
  }
305
305
 
306
- export type OpenSourceParams<A extends aux.Any = aux.Any> =
306
+ export type OpenSourceParams<A extends Any = Any> =
307
307
  | {
308
- element: aux.Fqn<A>
308
+ element: Fqn<A>
309
309
  property?: string
310
310
  }
311
311
  | {
312
- relation: aux.RelationId
312
+ relation: RelationId
313
313
  }
314
314
  | {
315
- deployment: aux.DeploymentFqn<A>
315
+ deployment: DeploymentFqn<A>
316
316
  property?: string
317
317
  }
318
318
  | {
319
- view: aux.StrictViewId<A>
319
+ view: StrictViewId<A>
320
320
  }
321
321
 
322
- export interface LikeC4DiagramEventHandlers<A extends aux.Any = aux.Any> {
322
+ export interface LikeC4DiagramEventHandlers<A extends Any = Any> {
323
323
  onChange?: OnChange | null | undefined
324
324
  onNavigateTo?: OnNavigateTo<A> | null | undefined
325
325
  onNodeClick?: OnNodeClick<A> | null | undefined
package/src/base/index.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  export { BaseXYFlow, type BaseXYFlowProps } from './BaseXYFlow'
2
2
 
3
3
  export {
4
+ Base,
4
5
  type EdgeProps,
5
6
  type NodeProps,
6
7
  type NonOptional,
7
8
  type ReactFlowEdge,
8
9
  type ReactFlowNode,
9
10
  } from './types'
10
-
11
- export * as Base from './types.Base'
@@ -62,6 +62,7 @@ export const MarkdownBlock = forwardRef<HTMLDivElement, MarkdownBlockProps>(({
62
62
  className={cx(
63
63
  markdownBlock({
64
64
  uselikec4palette,
65
+ value: value.isMarkdown ? 'markdown' : 'plaintext',
65
66
  }),
66
67
  className,
67
68
  )}
@@ -1,15 +1,15 @@
1
1
  import { deepEqual as eq } from 'fast-equals'
2
2
  import { type FunctionComponent, memo } from 'react'
3
- import type { Base, EdgeProps } from '../types'
3
+ import type { EdgeProps } from '../types'
4
4
 
5
5
  // If points are within 3px, consider them the same
6
6
  const isSame = (a: number, b: number) => {
7
7
  return Math.abs(a - b) < 2.5
8
8
  }
9
9
 
10
- export const edgePropsEqual = <P extends Record<string, unknown> = Base.EdgeData>(
11
- prev: EdgeProps<P>,
12
- next: EdgeProps<P>,
10
+ export const edgePropsEqual = <P extends EdgeProps<any>>(
11
+ prev: P,
12
+ next: P,
13
13
  ) => (
14
14
  prev.id === next.id
15
15
  && eq(prev.selected ?? false, next.selected ?? false)
@@ -27,7 +27,7 @@ export const edgePropsEqual = <P extends Record<string, unknown> = Base.EdgeData
27
27
  && eq(prev.data, next.data)
28
28
  )
29
29
 
30
- export function customEdge<P extends Record<string, unknown> = Base.EdgeData>(
30
+ export function customEdge<P extends Record<string, unknown> = {}>(
31
31
  Edge: FunctionComponent<EdgeProps<P>>,
32
32
  ): FunctionComponent<EdgeProps<P>> {
33
33
  return memo(Edge, edgePropsEqual)
@@ -78,28 +78,16 @@ export function ElementTitle({ id, data, iconSize }: ElementTitleProps) {
78
78
  )}
79
79
 
80
80
  {data.description?.nonEmpty && (
81
- data.description.isMarkdown
82
- ? (
83
- <MarkdownBlock
84
- className={cx(classes.description, 'likec4-element-description')}
85
- value={data.description}
86
- uselikec4palette
87
- hideIfEmpty
88
- // Workaround for lineClamp not working with nested TABLE elements (if markdown has tables)
89
- maxHeight={data.description.isMarkdown ? '8rem' : undefined}
90
- // textScale={0.95}
91
- lineClamp={isSmOrXs ? 3 : 5}
92
- />
93
- )
94
- : (
95
- <Text
96
- component="div"
97
- className={cx(classes.description, 'likec4-element-description')}
98
- lineClamp={isSmOrXs ? 3 : 5}
99
- >
100
- {data.description.text}
101
- </Text>
102
- )
81
+ <MarkdownBlock
82
+ className={cx(classes.description, 'likec4-element-description')}
83
+ value={data.description}
84
+ uselikec4palette
85
+ hideIfEmpty
86
+ // Workaround for lineClamp not working with nested TABLE elements (if markdown has tables)
87
+ maxHeight={data.description.isMarkdown ? '8rem' : undefined}
88
+ // textScale={0.95}
89
+ lineClamp={isSmOrXs ? 3 : 5}
90
+ />
103
91
  )}
104
92
  </Box>
105
93
  </Box>
package/src/base/types.ts CHANGED
@@ -1,11 +1,124 @@
1
- import type {
2
- Edge as RFEdge,
3
- EdgeProps as ReactFlowEdgeProps,
4
- Node as RFNode,
5
- NodeProps as ReactFlowNodeProps,
6
- } from '@xyflow/react'
1
+ import type * as RF from '@xyflow/react'
2
+ import { hasSubObject } from 'remeda'
7
3
  import type { OptionalKeysOf, SetRequired, Simplify } from 'type-fest'
8
- import * as Base from './types.Base'
4
+
5
+ // We do these aliases to ensure bundled type definitions are correct (see packages/likec4/react)
6
+
7
+ type RFNode<
8
+ NodeData extends Record<string, unknown> = Record<string, unknown>,
9
+ NodeType extends string | undefined = string | undefined,
10
+ > = RF.Node<NodeData, NodeType>
11
+ type RFEdge<
12
+ EdgeData extends Record<string, unknown> = Record<string, unknown>,
13
+ EdgeType extends string | undefined = string | undefined,
14
+ > = RF.Edge<EdgeData, EdgeType>
15
+ type ReactFlowNodeProps<
16
+ NodeData extends Record<string, unknown> = Record<string, unknown>,
17
+ NodeType extends string | undefined = string | undefined,
18
+ > = RF.NodeProps<RFNode<NodeData, NodeType>>
19
+ type ReactFlowEdgeProps<
20
+ EdgeData extends Record<string, unknown> = Record<string, unknown>,
21
+ EdgeType extends string | undefined = string | undefined,
22
+ > = RF.EdgeProps<RFEdge<EdgeData, EdgeType>>
23
+
24
+ export namespace Base {
25
+ // 'immediate' means that the node is dimmed without delay
26
+ export type Dimmed = 'immediate' | boolean
27
+
28
+ export type NodeData = {
29
+ /**
30
+ * Whether the cursor is hovering over the node
31
+ */
32
+ hovered?: boolean
33
+ /**
34
+ * Whether the node is dimmed
35
+ * 'immediate' means that the node is dimmed without delay
36
+ */
37
+ dimmed?: Dimmed
38
+ }
39
+ export type Node = RFNode<NodeData>
40
+
41
+ export type NodeProps = ReactFlowNodeProps<RFNode<NodeData, any>>
42
+
43
+ export type EdgeData = {
44
+ /**
45
+ * Whether the cursor is hovering over the edge
46
+ */
47
+ hovered?: boolean
48
+ /**
49
+ * Whether the edge is active (animated and highlighted)
50
+ */
51
+ active?: boolean
52
+ /**
53
+ * Whether the edge is dimmed
54
+ * 'immediate' means that the edge is dimmed without delay
55
+ */
56
+ dimmed?: Dimmed
57
+ }
58
+
59
+ // export type Edge = SetRequired<ReactFlowEdge<EdgeData, 'relation'>, 'data' | 'type'>
60
+ export type Edge = Simplify<Omit<RFEdge, 'data'> & { data: EdgeData }>
61
+
62
+ type WithDimmed = { data: { dimmed?: Dimmed } }
63
+ type WithHovered = { data: { hovered?: boolean } }
64
+
65
+ const _setDimmed = <T extends WithDimmed>(v: T, dimmed: Dimmed): T =>
66
+ (v.data.dimmed ?? false) === dimmed ? v : ({
67
+ ...v,
68
+ data: {
69
+ ...v.data,
70
+ dimmed,
71
+ },
72
+ })
73
+
74
+ export function setDimmed<T extends WithDimmed>(value: T, dimmed: 'immediate' | boolean): T
75
+ export function setDimmed(dimmed: 'immediate' | boolean): <T extends WithDimmed>(value: T) => T
76
+ export function setDimmed<T extends WithDimmed>(arg1: T | Dimmed, arg2?: Dimmed) {
77
+ if (arg2 !== undefined) {
78
+ return _setDimmed(arg1 as T, arg2)
79
+ }
80
+ return (v: T) => _setDimmed(v, arg1 as Dimmed)
81
+ }
82
+
83
+ const _setHovered = <T extends WithHovered>(v: T, hovered: boolean): T =>
84
+ (v.data.hovered ?? false) === hovered ? v : ({
85
+ ...v,
86
+ data: {
87
+ ...v.data,
88
+ hovered,
89
+ },
90
+ })
91
+ export function setHovered<T extends WithHovered>(value: T, hovered: boolean): T
92
+ export function setHovered(hovered: boolean): <T extends WithHovered>(value: T) => T
93
+ export function setHovered<T extends WithHovered>(arg1: T | boolean, arg2?: boolean) {
94
+ if (arg2 !== undefined) {
95
+ return _setHovered(arg1 as T, arg2)
96
+ }
97
+ return (v: T) => _setHovered(v, arg1 as boolean)
98
+ }
99
+
100
+ type WithData<D> = { data: D }
101
+ function _setData<D, E extends WithData<D>>(value: E, state: Partial<NoInfer<D>>): E {
102
+ if (hasSubObject(value.data as any, state as any)) {
103
+ return value
104
+ }
105
+ return {
106
+ ...value,
107
+ data: {
108
+ ...value.data,
109
+ ...state,
110
+ },
111
+ }
112
+ }
113
+ export function setData<E extends WithData<any>>(value: E, state: Partial<E['data']>): E
114
+ export function setData<E extends WithData<any>>(state: Partial<E['data']>): (value: E) => E
115
+ export function setData<E extends WithData<any>>(arg1: E | Partial<E['data']>, arg2?: any) {
116
+ if (arg2 !== undefined) {
117
+ return _setData(arg1 as E, arg2)
118
+ }
119
+ return (edge: E) => _setData(edge, arg1 as Partial<EdgeData>)
120
+ }
121
+ }
9
122
 
10
123
  /**
11
124
  * To cooperate with `exactOptionalPropertyTypes` in `tsconfig.json`
@@ -37,16 +150,14 @@ export type NonOptional<T extends object, Keys extends OptionalKeysOf<T> = Optio
37
150
  * ReactFlow Custom Node properties with BaseNodeData at least
38
151
  */
39
152
  export type NodeProps<T extends Record<string, unknown> = {}, NodeType extends string = string> = Simplify<
40
- ReactFlowNodeProps<
41
- RFNode<Base.NodeData & T, NodeType>
42
- >
153
+ ReactFlowNodeProps<Base.NodeData & T, NodeType>
43
154
  >
44
155
 
45
156
  /**
46
157
  * ReactFlow Custom Edge properties with BaseEdgeData at least
47
158
  */
48
159
  export type EdgeProps<T extends Record<string, unknown> = {}, EdgeType extends string = string> = SetRequired<
49
- Simplify<ReactFlowEdgeProps<RFEdge<Base.EdgeData & T, EdgeType>>>,
160
+ Simplify<ReactFlowEdgeProps<Base.EdgeData & T, EdgeType>>,
50
161
  'data'
51
162
  >
52
163
 
@@ -59,5 +170,3 @@ export type ReactFlowEdge<Data extends Record<string, unknown>, EdgeType extends
59
170
  RFEdge<Data, EdgeType>,
60
171
  'type' | 'data'
61
172
  >
62
-
63
- export * as Base from './types.Base'
@@ -1,4 +1,5 @@
1
- import type { Any, aux, WhereOperator } from '@likec4/core/types'
1
+ import type * as t from '@likec4/core/types'
2
+ import type { WhereOperator } from '@likec4/core/types'
2
3
  import type { CSSProperties } from 'react'
3
4
  import type {
4
5
  CustomNodes,
@@ -8,11 +9,11 @@ import type {
8
9
  ViewPadding,
9
10
  } from '../LikeC4Diagram.props'
10
11
 
11
- export interface LikeC4ViewProps<A extends Any> {
12
+ export interface LikeC4ViewProps<A extends t.aux.Any = t.aux.UnknownLayouted> {
12
13
  /**
13
14
  * View to display.
14
15
  */
15
- viewId: aux.ViewId<A>
16
+ viewId: t.aux.ViewId<A>
16
17
 
17
18
  /**
18
19
  * Enable/disable panning
@@ -1,4 +1,4 @@
1
- import type { Any, aux, DiagramView, UnknownLayouted } from '@likec4/core/types'
1
+ import type * as t from '@likec4/core/types'
2
2
  import { cx } from '@likec4/styles/css'
3
3
  import { ActionIcon, Box } from '@mantine/core'
4
4
  import { shallowEqual } from '@mantine/hooks'
@@ -15,7 +15,7 @@ import { ShadowRoot } from './ShadowRoot'
15
15
  import { cssInteractive, useColorScheme, useShadowRootStyle } from './styles.css'
16
16
  import { ErrorMessage, ViewNotFound } from './ViewNotFound'
17
17
 
18
- export function LikeC4View<A extends Any = UnknownLayouted>({
18
+ export function LikeC4View<A extends t.aux.Any = t.aux.UnknownLayouted>({
19
19
  viewId,
20
20
  ...props
21
21
  }: LikeC4ViewProps<A>) {
@@ -44,10 +44,10 @@ const DEFAULT_BROWSER_PADDING: ViewPadding = {
44
44
  right: '16px',
45
45
  }
46
46
 
47
- type LikeC4ViewInnerProps<A extends Any> = Omit<LikeC4ViewProps<A>, 'viewId'> & {
48
- view: DiagramView<A>
47
+ type LikeC4ViewInnerProps<A extends t.aux.Any> = Omit<LikeC4ViewProps<A>, 'viewId'> & {
48
+ view: t.DiagramView<A>
49
49
  }
50
- const LikeC4ViewInner = memo<LikeC4ViewInnerProps<Any>>(({
50
+ const LikeC4ViewInner = memo<LikeC4ViewInnerProps<t.aux.UnknownLayouted>>(({
51
51
  view,
52
52
  className,
53
53
  pannable = false,
@@ -81,7 +81,7 @@ const LikeC4ViewInner = memo<LikeC4ViewInnerProps<Any>>(({
81
81
 
82
82
  const [shadowRootProps, cssstyle] = useShadowRootStyle(keepAspectRatio, view)
83
83
 
84
- const [browserViewId, onNavigateTo] = useState(null as aux.ViewId<Any> | null)
84
+ const [browserViewId, onNavigateTo] = useState(null as t.aux.ViewId<t.aux.UnknownLayouted> | null)
85
85
 
86
86
  const browserView = browserViewId ? likec4model.findView(browserViewId)?.$view : null
87
87
 
@@ -1,4 +1,5 @@
1
- import type { Any, aux, DiagramView, UnknownLayouted } from '@likec4/core/types'
1
+ import type * as t from '@likec4/core/types'
2
+ import type { DiagramView } from '@likec4/core/types'
2
3
  import { cx } from '@likec4/styles/css'
3
4
  import { type CSSProperties } from 'react'
4
5
  import { isFunction, isString } from 'remeda'
@@ -8,8 +9,8 @@ import { ShadowRoot } from './ShadowRoot'
8
9
  import { useColorScheme, useShadowRootStyle } from './styles.css'
9
10
  import { ErrorMessage, ViewNotFound } from './ViewNotFound'
10
11
 
11
- export type ReactLikeC4Props<A extends Any> = Omit<LikeC4DiagramProps<A>, 'view'> & {
12
- viewId: aux.ViewId<A>
12
+ export type ReactLikeC4Props<A extends t.aux.Any = t.aux.UnknownLayouted> = Omit<LikeC4DiagramProps<A>, 'view'> & {
13
+ viewId: t.aux.ViewId<A>
13
14
 
14
15
  /**
15
16
  * Keep aspect ratio of the diagram
@@ -41,7 +42,7 @@ export type ReactLikeC4Props<A extends Any> = Omit<LikeC4DiagramProps<A>, 'view'
41
42
  styleNonce?: string | (() => string) | undefined
42
43
  }
43
44
 
44
- export function ReactLikeC4<A extends Any = UnknownLayouted>({
45
+ export function ReactLikeC4<A extends t.aux.Any = t.aux.UnknownLayouted>({
45
46
  viewId,
46
47
  ...props
47
48
  }: ReactLikeC4Props<A>) {
@@ -63,10 +64,10 @@ export function ReactLikeC4<A extends Any = UnknownLayouted>({
63
64
  return <ReactLikeC4Inner view={view.$view} {...props} />
64
65
  }
65
66
 
66
- type ReactLikeC4InnerProps<A extends Any> = Omit<ReactLikeC4Props<A>, 'viewId'> & {
67
+ type ReactLikeC4InnerProps<A extends t.aux.Any> = Omit<ReactLikeC4Props<A>, 'viewId'> & {
67
68
  view: DiagramView<A>
68
69
  }
69
- function ReactLikeC4Inner<A extends Any>({
70
+ function ReactLikeC4Inner<A extends t.aux.Any>({
70
71
  className,
71
72
  view,
72
73
  colorScheme: explicitColorScheme,
@@ -1,5 +1,5 @@
1
1
  import type { DeployedInstanceModel, DeploymentNodeModel, NodeModel } from '@likec4/core/model'
2
- import type { Any } from '@likec4/core/types'
2
+ import type { aux } from '@likec4/core/types'
3
3
  import type { FunctionComponent } from 'react'
4
4
  import { jsx } from 'react/jsx-runtime'
5
5
  import { customNode } from '../base/primitives'
@@ -7,6 +7,8 @@ import type { NodeProps } from '../base/types'
7
7
  import type { Types } from '../likec4diagram/types'
8
8
  import { useLikeC4ViewModel } from '../likec4model/useLikeC4Model'
9
9
 
10
+ type Any = aux.Any
11
+
10
12
  type CustomDiagramNodeProps = {
11
13
  nodeProps: NodeProps<Types.NodeData, string>
12
14
  nodeModel: NodeModel
@@ -9,11 +9,11 @@ export function useSetState<T extends object>(initialState: T | (() => T)) {
9
9
  _setState((current) => {
10
10
  const next = {
11
11
  ...current,
12
- ...typeof statePartial === 'function' ? statePartial(current) : statePartial
12
+ ...typeof statePartial === 'function' ? statePartial(current) : statePartial,
13
13
  }
14
14
  return shallowEqual(current, next) ? current : next
15
15
  }),
16
- []
16
+ [],
17
17
  )
18
18
  return [state, setState] as const
19
19
  }
@@ -1,6 +1,7 @@
1
- import { type NodeId, hasAtLeast } from '@likec4/core'
1
+ import type { NodeId } from '@likec4/core'
2
2
  import { IconTransform, IconZoomScan } from '@tabler/icons-react'
3
3
  import { useMemo } from 'react'
4
+ import { hasAtLeast } from 'remeda'
4
5
  import { ElementActionButtons } from '../../../base/primitives'
5
6
  import type { NodeProps } from '../../../base/types'
6
7
  import { useEnabledFeatures } from '../../../context/DiagramFeatures'
@@ -141,10 +141,10 @@ export namespace Types {
141
141
  | 'head'
142
142
  | 'tail'
143
143
  | 'navigateTo'
144
- | 'notes'
145
144
  >
146
145
  >
147
146
  & {
147
+ notes: RichTextOrEmpty
148
148
  labelXY: XYPosition | null
149
149
  controlPoints: XYPosition[] | undefined | null
150
150
  }
@@ -252,7 +252,7 @@ function viewToNodesEdge(opts: {
252
252
  id: edge.id,
253
253
  label: edge.label,
254
254
  technology: edge.technology,
255
- notes: edge.notes,
255
+ notes: RichText.from(edge.notes),
256
256
  navigateTo: edge.navigateTo,
257
257
  controlPoints: edge.controlPoints ?? null,
258
258
  labelBBox: edge.labelBBox ?? null,
@@ -1,10 +1,13 @@
1
1
  import type { LikeC4Model, LikeC4ViewModel } from '@likec4/core/model'
2
- import type { aux, DiagramView } from '@likec4/core/types'
2
+ import type * as t from '@likec4/core/types'
3
+ import type { DiagramView } from '@likec4/core/types'
3
4
  import { type PropsWithChildren, createContext, useContext } from 'react'
4
5
 
6
+ type UnknownLayouted = t.aux.UnknownLayouted
7
+
5
8
  export const LikeC4ModelContext = createContext<LikeC4Model<any> | null>(null)
6
9
 
7
- export type CurrentViewModel = LikeC4ViewModel<aux.UnknownLayouted, DiagramView<aux.UnknownLayouted>>
10
+ export type CurrentViewModel = LikeC4ViewModel<UnknownLayouted, DiagramView<UnknownLayouted>>
8
11
  export const CurrentViewModelContext = createContext<CurrentViewModel | null>(null)
9
12
 
10
13
  export function EnsureCurrentViewModel({ children }: PropsWithChildren) {
@@ -1,6 +1,6 @@
1
- import { compareNatural } from '@likec4/core'
2
- import { type LikeC4Model } from '@likec4/core/model'
3
- import { type Fqn, type ViewId } from '@likec4/core/types'
1
+ import type { LikeC4Model } from '@likec4/core/model'
2
+ import type { Fqn, ViewId } from '@likec4/core/types'
3
+ import { compareNatural } from '@likec4/core/utils'
4
4
  import { useMemo } from 'react'
5
5
  import { useLikeC4Model } from './useLikeC4Model'
6
6