@likec4/diagram 1.39.4 → 1.40.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.
- package/bundle/{chunk-CW_KClZe.js → chunk-CDr-4Ymp.js} +936 -903
- package/bundle/custom.js +61 -60
- package/bundle/index.js +2667 -539
- package/dist/LikeC4Diagram.d.ts +1 -1
- package/dist/LikeC4Diagram.js +7 -4
- package/dist/LikeC4Diagram.props.d.ts +6 -1
- package/dist/base/const.d.ts +9 -0
- package/dist/base/const.js +10 -1
- package/dist/base/index.d.ts +1 -0
- package/dist/base/primitives/edge/EdgeLabel.js +2 -1
- package/dist/base/primitives/edge/EdgeLabelContainer.js +10 -4
- package/dist/base/primitives/edge/EdgePath.js +17 -8
- package/dist/base/primitives/edge/edge.css.d.ts +0 -1
- package/dist/base/primitives/edge/edge.css.js +6 -14
- package/dist/base/primitives/element/ElementActionButtons.js +1 -3
- package/dist/base/primitives/element/ElementNodeContainer.d.ts +0 -6
- package/dist/base/primitives/element/ElementNodeContainer.js +3 -26
- package/dist/base/primitives/element/ElementTitle.js +2 -2
- package/dist/base/types.d.ts +3 -3
- package/dist/bundle/LikeC4View.js +4 -12
- package/dist/bundle/LikeC4View.props.d.ts +12 -3
- package/dist/bundle/custom.js +1 -1
- package/dist/custom/customNodes.d.ts +6 -0
- package/dist/custom/customNodes.js +2 -1
- package/dist/custom/index.js +1 -1
- package/dist/hooks/useDiagram.d.ts +5 -1
- package/dist/hooks/useDiagram.js +3 -0
- package/dist/hooks/useXYFlow.d.ts +4 -439
- package/dist/likec4diagram/DiagramUI.js +1 -1
- package/dist/likec4diagram/DiagramXYFlow.js +8 -4
- package/dist/likec4diagram/convert-to-xyflow.d.ts +14 -0
- package/dist/likec4diagram/convert-to-xyflow.js +29 -0
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +3 -3
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +0 -1
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.d.ts +3 -0
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +71 -0
- package/dist/likec4diagram/custom/index.js +7 -2
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -1
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.d.ts +4 -0
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +157 -0
- package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +1 -2
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +31 -27
- package/dist/likec4diagram/types.d.ts +41 -7
- package/dist/likec4diagram/xyflow-diagram/diagram-view.d.ts +11 -0
- package/dist/likec4diagram/{useViewToNodesEdges.js → xyflow-diagram/diagram-view.js} +4 -13
- package/dist/likec4diagram/xyflow-sequence/_types.d.ts +41 -0
- package/dist/likec4diagram/xyflow-sequence/const.d.ts +17 -0
- package/dist/likec4diagram/xyflow-sequence/const.js +16 -0
- package/dist/likec4diagram/xyflow-sequence/layouter.d.ts +46 -0
- package/dist/likec4diagram/xyflow-sequence/layouter.js +408 -0
- package/dist/likec4diagram/xyflow-sequence/sequence-view.d.ts +7 -0
- package/dist/likec4diagram/xyflow-sequence/sequence-view.js +273 -0
- package/dist/likec4diagram/xyflow-sequence/utils.d.ts +14 -0
- package/dist/likec4diagram/xyflow-sequence/utils.js +92 -0
- package/dist/navigationpanel/NavigationPanelControls.js +2 -2
- package/dist/navigationpanel/controls/ViewDetailsCard.js +5 -2
- package/dist/navigationpanel/dropdown/ProjectsMenu.js +53 -44
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.d.ts +1 -2
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +10 -41
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +292 -0
- package/dist/navigationpanel/walkthrough/DynamicViewControls.js +119 -0
- package/dist/navigationpanel/walkthrough/index.d.ts +2 -1
- package/dist/overlays/relationship-details/RelationshipDetails.js +4 -1
- package/dist/state/DiagramActorProvider.d.ts +3 -2
- package/dist/state/DiagramActorProvider.js +19 -11
- package/dist/state/assign.js +11 -4
- package/dist/state/diagram-machine.d.ts +224 -194
- package/dist/state/diagram-machine.js +170 -63
- package/dist/state/utils.d.ts +7 -1
- package/dist/state/utils.js +67 -7
- package/dist/styles-min.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css2.js +1 -1
- package/package.json +8 -7
- package/panda.buildinfo.json +30 -9
- package/src/LikeC4Diagram.props.ts +14 -1
- package/src/LikeC4Diagram.tsx +7 -4
- package/src/base/const.ts +12 -0
- package/src/base/index.ts +2 -0
- package/src/base/primitives/edge/EdgeLabel.tsx +23 -19
- package/src/base/primitives/edge/EdgeLabelContainer.tsx +12 -7
- package/src/base/primitives/edge/EdgePath.tsx +25 -14
- package/src/base/primitives/edge/edge.css.ts +5 -14
- package/src/base/primitives/element/ElementActionButtons.tsx +1 -3
- package/src/base/primitives/element/ElementNodeContainer.tsx +3 -30
- package/src/base/primitives/element/ElementTitle.tsx +2 -3
- package/src/base/types.ts +7 -5
- package/src/bundle/LikeC4View.props.ts +14 -3
- package/src/bundle/LikeC4View.tsx +4 -14
- package/src/bundle/ReactLikeC4.tsx +1 -2
- package/src/custom/customNodes.ts +7 -0
- package/src/hooks/useDiagram.ts +10 -0
- package/src/likec4diagram/DiagramUI.tsx +1 -1
- package/src/likec4diagram/DiagramXYFlow.tsx +10 -5
- package/src/likec4diagram/convert-to-xyflow.ts +45 -0
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +0 -1
- package/src/likec4diagram/custom/edges/SequenceStepEdge.tsx +65 -0
- package/src/likec4diagram/custom/index.ts +7 -1
- package/src/likec4diagram/custom/nodes/ElementActions.tsx +4 -2
- package/src/likec4diagram/custom/nodes/SequenceActorNode.tsx +175 -0
- package/src/likec4diagram/custom/nodes/index.ts +1 -0
- package/src/likec4diagram/custom/nodes/nodes.tsx +1 -1
- package/src/likec4diagram/relationship-popover/RelationshipPopover.tsx +36 -30
- package/src/likec4diagram/types.ts +96 -13
- package/src/likec4diagram/{useViewToNodesEdges.ts → xyflow-diagram/diagram-view.ts} +7 -28
- package/src/likec4diagram/xyflow-sequence/_types.ts +45 -0
- package/src/likec4diagram/xyflow-sequence/const.ts +37 -0
- package/src/likec4diagram/xyflow-sequence/layouter.ts +567 -0
- package/src/likec4diagram/xyflow-sequence/sequence-view.ts +337 -0
- package/src/likec4diagram/xyflow-sequence/utils.ts +112 -0
- package/src/navigationpanel/NavigationPanelControls.tsx +2 -2
- package/src/navigationpanel/controls/ViewDetailsCard.tsx +5 -2
- package/src/navigationpanel/dropdown/ProjectsMenu.tsx +5 -1
- package/src/navigationpanel/walkthrough/ActiveWalkthroughControls.tsx +5 -40
- package/src/navigationpanel/walkthrough/DynamicViewControls.tsx +125 -0
- package/src/navigationpanel/walkthrough/index.tsx +2 -1
- package/src/overlays/relationship-details/RelationshipDetails.tsx +5 -2
- package/src/state/DiagramActorProvider.tsx +21 -10
- package/src/state/assign.ts +18 -5
- package/src/state/diagram-machine.ts +207 -75
- package/src/state/utils.ts +81 -7
- package/dist/likec4diagram/useViewToNodesEdges.d.ts +0 -12
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
BBox,
|
|
3
|
+
DeploymentFqn,
|
|
4
|
+
DiagramEdge,
|
|
5
|
+
DiagramNode,
|
|
6
|
+
ExclusiveUnion,
|
|
7
|
+
Fqn,
|
|
8
|
+
IconUrl,
|
|
9
|
+
RichTextOrEmpty,
|
|
10
|
+
ViewId,
|
|
11
|
+
} from '@likec4/core/types'
|
|
2
12
|
import type { XYPosition } from '@xyflow/system'
|
|
3
13
|
import type { OptionalKeysOf, Simplify } from 'type-fest'
|
|
4
14
|
import type { Base, ReactFlowEdge, ReactFlowNode } from '../base/types'
|
|
@@ -44,14 +54,16 @@ export namespace Types {
|
|
|
44
54
|
/**
|
|
45
55
|
* Represents element from logical model
|
|
46
56
|
*/
|
|
47
|
-
export type ElementNodeData =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
export type ElementNodeData = Simplify<
|
|
58
|
+
LeafNodeData & {
|
|
59
|
+
modelFqn: Fqn
|
|
60
|
+
deploymentFqn?: never
|
|
61
|
+
/**
|
|
62
|
+
* If set - this node has navigation to another view and diagram has handler for this
|
|
63
|
+
*/
|
|
64
|
+
navigateTo: ViewId | null
|
|
65
|
+
}
|
|
66
|
+
>
|
|
55
67
|
|
|
56
68
|
/**
|
|
57
69
|
* Represents element from deployment model
|
|
@@ -65,6 +77,32 @@ export namespace Types {
|
|
|
65
77
|
modelFqn: Fqn | null
|
|
66
78
|
}
|
|
67
79
|
|
|
80
|
+
export type SequenceActorNodePort = {
|
|
81
|
+
id: string
|
|
82
|
+
cx: number
|
|
83
|
+
cy: number
|
|
84
|
+
height: number
|
|
85
|
+
type: 'target' | 'source'
|
|
86
|
+
position: 'left' | 'right' | 'top' | 'bottom'
|
|
87
|
+
}
|
|
88
|
+
export type SequenceActorNodeData = Simplify<
|
|
89
|
+
& LeafNodeData
|
|
90
|
+
& {
|
|
91
|
+
navigateTo: ViewId | null
|
|
92
|
+
// If set - this node refers to a model element
|
|
93
|
+
modelFqn: Fqn | null
|
|
94
|
+
ports: Array<SequenceActorNodePort>
|
|
95
|
+
viewHeight: number
|
|
96
|
+
}
|
|
97
|
+
>
|
|
98
|
+
|
|
99
|
+
export type SequenceParallelAreaData = Simplify<
|
|
100
|
+
& LeafNodeData
|
|
101
|
+
& {
|
|
102
|
+
parallelPrefix: string
|
|
103
|
+
}
|
|
104
|
+
>
|
|
105
|
+
|
|
68
106
|
export type CompoundNodeData =
|
|
69
107
|
& Base.NodeData
|
|
70
108
|
& NonOptional<
|
|
@@ -117,13 +155,32 @@ export namespace Types {
|
|
|
117
155
|
|
|
118
156
|
export type ElementNode = ReactFlowNode<ElementNodeData, 'element'>
|
|
119
157
|
export type DeploymentElementNode = ReactFlowNode<DeploymentElementNodeData, 'deployment'>
|
|
158
|
+
|
|
159
|
+
export type SequenceActorNode = ReactFlowNode<SequenceActorNodeData, 'seq-actor'>
|
|
160
|
+
export type SequenceParallelArea = ReactFlowNode<SequenceParallelAreaData, 'seq-parallel'>
|
|
161
|
+
|
|
120
162
|
export type CompoundElementNode = ReactFlowNode<CompoundElementNodeData, 'compound-element'>
|
|
121
163
|
export type CompoundDeploymentNode = ReactFlowNode<CompoundDeploymentNodeData, 'compound-deployment'>
|
|
122
164
|
export type ViewGroupNode = ReactFlowNode<ViewGroupNodeData, 'view-group'>
|
|
123
165
|
|
|
124
|
-
export type Node =
|
|
166
|
+
export type Node =
|
|
167
|
+
| ElementNode
|
|
168
|
+
| DeploymentElementNode
|
|
169
|
+
| CompoundElementNode
|
|
170
|
+
| CompoundDeploymentNode
|
|
171
|
+
| ViewGroupNode
|
|
172
|
+
| SequenceActorNode
|
|
173
|
+
| SequenceParallelArea
|
|
125
174
|
|
|
126
|
-
export type NodeData =
|
|
175
|
+
export type NodeData = ExclusiveUnion<{
|
|
176
|
+
ElementNodeData: ElementNodeData
|
|
177
|
+
DeploymentElementNodeData: DeploymentElementNodeData
|
|
178
|
+
CompoundElementNodeData: CompoundElementNodeData
|
|
179
|
+
CompoundDeploymentNodeData: CompoundDeploymentNodeData
|
|
180
|
+
ViewGroupNodeData: ViewGroupNodeData
|
|
181
|
+
SequenceActorNodeData: SequenceActorNodeData
|
|
182
|
+
SequenceParallelAreaData: SequenceParallelAreaData
|
|
183
|
+
}>
|
|
127
184
|
|
|
128
185
|
export type RelationshipEdgeData = Simplify<
|
|
129
186
|
& Base.EdgeData
|
|
@@ -150,8 +207,34 @@ export namespace Types {
|
|
|
150
207
|
}
|
|
151
208
|
>
|
|
152
209
|
|
|
210
|
+
export type SequenceStepEdgeData = Simplify<
|
|
211
|
+
& Base.EdgeData
|
|
212
|
+
& NonOptional<
|
|
213
|
+
Pick<
|
|
214
|
+
DiagramEdge,
|
|
215
|
+
| 'id'
|
|
216
|
+
| 'label'
|
|
217
|
+
| 'technology'
|
|
218
|
+
| 'points'
|
|
219
|
+
| 'dir'
|
|
220
|
+
| 'color'
|
|
221
|
+
| 'line'
|
|
222
|
+
| 'head'
|
|
223
|
+
| 'tail'
|
|
224
|
+
| 'navigateTo'
|
|
225
|
+
>
|
|
226
|
+
>
|
|
227
|
+
& {
|
|
228
|
+
notes: RichTextOrEmpty
|
|
229
|
+
labelXY: XYPosition | null
|
|
230
|
+
labelBBox: BBox
|
|
231
|
+
controlPoints: XYPosition[] | undefined | null
|
|
232
|
+
}
|
|
233
|
+
>
|
|
234
|
+
|
|
153
235
|
export type RelationshipEdge = ReactFlowEdge<RelationshipEdgeData, 'relationship'>
|
|
236
|
+
export type SequenceStepEdge = ReactFlowEdge<SequenceStepEdgeData, 'seq-step'>
|
|
154
237
|
|
|
155
|
-
export type Edge = RelationshipEdge
|
|
156
|
-
export type EdgeData = RelationshipEdgeData
|
|
238
|
+
export type Edge = RelationshipEdge | SequenceStepEdge
|
|
239
|
+
export type EdgeData = RelationshipEdgeData | SequenceStepEdgeData
|
|
157
240
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type BBox,
|
|
2
3
|
type DiagramEdge,
|
|
3
4
|
type DiagramNode,
|
|
4
5
|
type DiagramView,
|
|
@@ -13,18 +14,16 @@ import {
|
|
|
13
14
|
RichText,
|
|
14
15
|
whereOperatorAsPredicate,
|
|
15
16
|
} from '@likec4/core'
|
|
16
|
-
import { useCustomCompareMemo } from '@react-hookz/web'
|
|
17
|
-
import { deepEqual, shallowEqual } from 'fast-equals'
|
|
18
17
|
import { hasAtLeast, pick } from 'remeda'
|
|
19
|
-
import { ZIndexes } from '
|
|
20
|
-
import type { Types } from '
|
|
18
|
+
import { ZIndexes } from '../../base/const'
|
|
19
|
+
import type { Types } from '../types'
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
view: Pick<DiagramView, 'id' | 'nodes' | 'edges' | '_type'>
|
|
21
|
+
export function diagramToXY(opts: {
|
|
22
|
+
view: Pick<DiagramView, 'id' | 'nodes' | 'edges' | 'bounds' | '_type'>
|
|
25
23
|
where: WhereOperator | null
|
|
26
24
|
nodesSelectable: boolean
|
|
27
25
|
}): {
|
|
26
|
+
bounds: BBox
|
|
28
27
|
xynodes: Types.Node[]
|
|
29
28
|
xyedges: Types.Edge[]
|
|
30
29
|
} {
|
|
@@ -269,28 +268,8 @@ function viewToNodesEdge(opts: {
|
|
|
269
268
|
}
|
|
270
269
|
|
|
271
270
|
return {
|
|
271
|
+
bounds: view.bounds,
|
|
272
272
|
xynodes,
|
|
273
273
|
xyedges,
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
-
type ViewToNodesEdgeInput = {
|
|
277
|
-
view: DiagramView
|
|
278
|
-
where: WhereOperator | null
|
|
279
|
-
nodesSelectable: boolean
|
|
280
|
-
}
|
|
281
|
-
const viewToNodesEdgeEqual = (a: ViewToNodesEdgeInput, b: ViewToNodesEdgeInput) => (
|
|
282
|
-
a.view.id === b.view.id
|
|
283
|
-
&& a.view._type === b.view._type
|
|
284
|
-
&& a.nodesSelectable === b.nodesSelectable
|
|
285
|
-
&& shallowEqual(a.view.nodes, b.view.nodes)
|
|
286
|
-
&& shallowEqual(a.view.edges, b.view.edges)
|
|
287
|
-
&& deepEqual(a.where, b.where)
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
export function useViewToNodesEdges(params: ViewToNodesEdgeInput) {
|
|
291
|
-
return useCustomCompareMemo(
|
|
292
|
-
() => viewToNodesEdge(params),
|
|
293
|
-
[params],
|
|
294
|
-
([a], [b]) => !!a && !!b && viewToNodesEdgeEqual(a, b),
|
|
295
|
-
)
|
|
296
|
-
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { DiagramEdge, DiagramNode, EdgeId } from '@likec4/core/types'
|
|
2
|
+
|
|
3
|
+
export type Step = {
|
|
4
|
+
id: EdgeId
|
|
5
|
+
from: {
|
|
6
|
+
column: number
|
|
7
|
+
row: number
|
|
8
|
+
}
|
|
9
|
+
to: {
|
|
10
|
+
column: number
|
|
11
|
+
row: number
|
|
12
|
+
}
|
|
13
|
+
source: DiagramNode
|
|
14
|
+
target: DiagramNode
|
|
15
|
+
label: null | {
|
|
16
|
+
height: number
|
|
17
|
+
width: number
|
|
18
|
+
text: string | null
|
|
19
|
+
}
|
|
20
|
+
isSelfLoop: boolean
|
|
21
|
+
isBack: boolean
|
|
22
|
+
parallelPrefix: string | null
|
|
23
|
+
offset: number // offset for continuing edges
|
|
24
|
+
edge: DiagramEdge
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type Compound = {
|
|
28
|
+
node: DiagramNode
|
|
29
|
+
from: DiagramNode
|
|
30
|
+
to: DiagramNode
|
|
31
|
+
|
|
32
|
+
nested: Compound[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type ParallelRect = {
|
|
36
|
+
parallelPrefix: string
|
|
37
|
+
min: {
|
|
38
|
+
column: number
|
|
39
|
+
row: number
|
|
40
|
+
}
|
|
41
|
+
max: {
|
|
42
|
+
column: number
|
|
43
|
+
row: number
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ThemeColor } from '@likec4/core/types'
|
|
2
|
+
|
|
3
|
+
// minimum space between actors
|
|
4
|
+
export const ACTOR_GAP = 60
|
|
5
|
+
|
|
6
|
+
// minimum space between columns
|
|
7
|
+
export const COLUMN_GAP = 32
|
|
8
|
+
|
|
9
|
+
// minimum height of a step row
|
|
10
|
+
export const MIN_ROW_HEIGHT = 80
|
|
11
|
+
|
|
12
|
+
// height of ports, edges connected to center of ports
|
|
13
|
+
export const PORT_HEIGHT = 32
|
|
14
|
+
|
|
15
|
+
// margin from step label to step box
|
|
16
|
+
export const STEP_LABEL_MARGIN = 50
|
|
17
|
+
|
|
18
|
+
// offset from actor box
|
|
19
|
+
export const FIRST_STEP_OFFSET = 30
|
|
20
|
+
|
|
21
|
+
// offset for continuing steps
|
|
22
|
+
// A -> B,
|
|
23
|
+
// C -> D (sequential)
|
|
24
|
+
// A -> B -> C (continuous)
|
|
25
|
+
export const CONTINUOUS_OFFSET = 22
|
|
26
|
+
|
|
27
|
+
export const SeqZIndex = {
|
|
28
|
+
compound: 0,
|
|
29
|
+
parallel: 1,
|
|
30
|
+
actor: 10,
|
|
31
|
+
step: 20,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const SeqParallelAreaColor = {
|
|
35
|
+
default: 'gray',
|
|
36
|
+
active: 'amber',
|
|
37
|
+
} satisfies Record<string, ThemeColor>
|