@likec4/diagram 1.36.1 → 1.38.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-DHvr-RGh.js → chunk-BZV0K82k.js} +870 -900
- package/bundle/custom.js +64 -56
- package/bundle/index.js +3565 -3327
- package/dist/LikeC4Diagram.props.d.ts +5 -5
- package/dist/LikeC4Styles.js +17 -15
- package/dist/StaticLikeC4Diagram.d.ts +1 -1
- package/dist/StaticLikeC4Diagram.js +3 -0
- package/dist/base/BaseXYFlow.d.ts +1 -1
- package/dist/base/BaseXYFlow.js +25 -27
- package/dist/base/const.d.ts +4 -4
- package/dist/base/const.js +5 -4
- package/dist/base/primitives/MarkdownBlock.js +4 -1
- package/dist/base/primitives/compound/CompoundActionButton.js +27 -42
- package/dist/base/primitives/compound/CompoundDetailsButton.js +23 -48
- package/dist/base/primitives/compound/CompoundNodeContainer.js +16 -48
- package/dist/base/primitives/compound/CompoundTitle.js +5 -80
- package/dist/base/primitives/compound/actionbtns.css.js +1 -13
- package/dist/base/primitives/customEdge.d.ts +1 -1
- package/dist/base/primitives/customNode.d.ts +4 -4
- package/dist/base/primitives/customNode.js +7 -7
- package/dist/base/primitives/edge/EdgeLabel.d.ts +5 -4
- package/dist/base/primitives/edge/EdgeLabel.js +39 -21
- package/dist/base/primitives/edge/EdgeLabelContainer.js +11 -23
- package/dist/base/primitives/edge/edge.css.js +19 -11
- package/dist/base/primitives/element/ElementShape.js +38 -18
- package/dist/base/primitives/element/ElementTags.js +7 -4
- package/dist/base/primitives/element/ElementTitle.js +10 -2
- package/dist/base/types.d.ts +17 -21
- package/dist/bundle/LikeC4View.d.ts +2 -2
- package/dist/bundle/LikeC4View.js +4 -1
- package/dist/bundle/LikeC4View.props.d.ts +2 -2
- package/dist/bundle/ReactLikeC4.d.ts +3 -3
- package/dist/bundle/custom.js +2 -1
- package/dist/bundle/index.js +2 -1
- package/dist/components/Link.js +3 -2
- package/dist/context/ReduceGraphics.js +2 -5
- package/dist/context/RootContainer.js +1 -5
- package/dist/custom/customNodes.d.ts +32 -26
- package/dist/custom/customNodes.js +12 -8
- package/dist/custom/hooks.d.ts +2 -1
- package/dist/custom/index.js +2 -1
- package/dist/globals.css.js +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useDiagram.d.ts +18 -1
- package/dist/hooks/useDiagram.js +18 -2
- package/dist/hooks/useXYFlow.d.ts +40 -21
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/likec4diagram/DiagramUI.js +5 -2
- package/dist/likec4diagram/DiagramXYFlow.js +9 -9
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +3 -3
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +27 -44
- package/dist/likec4diagram/custom/index.js +3 -3
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +8 -6
- package/dist/likec4diagram/custom/nodes/nodes.js +13 -14
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +3 -2
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +2 -2
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.d.ts +2 -0
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +441 -0
- package/dist/likec4diagram/relationship-popover/actor.d.ts +177 -0
- package/dist/likec4diagram/relationship-popover/actor.js +155 -0
- package/dist/likec4diagram/relationship-popover/styles.css.d.ts +2 -0
- package/dist/likec4diagram/{custom/edges/RelationshipsDropdownMenu.css.js → relationship-popover/styles.css.js} +4 -17
- package/dist/likec4diagram/useLayoutConstraints.js +0 -1
- package/dist/likec4model/useLikeC4ElementsTree.js +1 -1
- package/dist/likec4model/useLikeC4Project.js +15 -1
- package/dist/navigationpanel/NavigationPanelDropdown.js +1 -2
- package/dist/navigationpanel/actor.js +1 -2
- package/dist/navigationpanel/controls/NavigationButtons.js +1 -5
- package/dist/navigationpanel/controls/ViewDetailsCard.js +2 -0
- package/dist/overlays/element-details/actor.d.ts +564 -8
- package/dist/overlays/overlay/Overlay.css.d.ts +1 -1
- package/dist/overlays/relationship-details/actor.d.ts +3 -1
- package/dist/overlays/relationship-details/hooks.d.ts +19 -1
- package/dist/overlays/relationship-details/layout-to-xyflow.js +0 -1
- package/dist/overlays/relationship-details/layout.js +1 -2
- package/dist/overlays/relationships-browser/actor.d.ts +26 -2
- package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +16 -0
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +18 -8
- package/dist/overlays/relationships-browser/useViewToNodesEdges.js +0 -1
- package/dist/search/components/_shared.css.d.ts +1 -1
- package/dist/state/DiagramActorProvider.js +2 -19
- package/dist/state/assign.js +24 -10
- package/dist/state/diagram-machine.d.ts +149 -474
- package/dist/state/diagram-machine.js +94 -54
- package/dist/state/types.d.ts +1 -1
- package/dist/styles-min.css +1 -1
- package/dist/styles-xyflow.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css2.js +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/roundDpr.d.ts +1 -0
- package/dist/utils/roundDpr.js +20 -0
- package/dist/utils/xyflow.d.ts +0 -1
- package/dist/utils/xyflow.js +1 -7
- package/package.json +16 -15
- package/panda.buildinfo.json +91 -156
- package/src/LikeC4Diagram.props.ts +5 -5
- package/src/LikeC4Styles.tsx +22 -14
- package/src/StaticLikeC4Diagram.tsx +3 -0
- package/src/base/BaseXYFlow.tsx +26 -29
- package/src/base/const.ts +5 -4
- package/src/base/primitives/MarkdownBlock.tsx +6 -1
- package/src/base/primitives/compound/CompoundActionButton.tsx +31 -43
- package/src/base/primitives/compound/CompoundDetailsButton.tsx +26 -48
- package/src/base/primitives/compound/CompoundNodeContainer.tsx +15 -43
- package/src/base/primitives/compound/CompoundTitle.tsx +4 -76
- package/src/base/primitives/compound/actionbtns.css.ts +0 -12
- package/src/base/primitives/customEdge.ts +1 -1
- package/src/base/primitives/customNode.tsx +20 -24
- package/src/base/primitives/edge/EdgeLabel.tsx +23 -8
- package/src/base/primitives/edge/EdgeLabelContainer.tsx +9 -21
- package/src/base/primitives/edge/edge.css.ts +19 -11
- package/src/base/primitives/element/ElementShape.tsx +40 -18
- package/src/base/primitives/element/ElementTags.tsx +7 -4
- package/src/base/primitives/element/ElementTitle.tsx +23 -11
- package/src/base/types.ts +21 -25
- package/src/bundle/LikeC4View.props.ts +2 -2
- package/src/bundle/LikeC4View.tsx +8 -5
- package/src/bundle/ReactLikeC4.tsx +3 -3
- package/src/components/Link.tsx +3 -2
- package/src/context/RootContainer.tsx +1 -5
- package/src/context/TagStylesContext.tsx +2 -0
- package/src/custom/{customNodes.tsx → customNodes.ts} +58 -52
- package/src/custom/hooks.ts +7 -0
- package/src/globals.css +58 -5
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useDiagram.ts +39 -5
- package/src/hooks/useXYFlow.ts +3 -1
- package/src/index.ts +1 -0
- package/src/likec4diagram/DiagramUI.tsx +3 -0
- package/src/likec4diagram/DiagramXYFlow.tsx +9 -11
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +25 -49
- package/src/likec4diagram/custom/index.ts +5 -4
- package/src/likec4diagram/custom/nodes/nodes.tsx +13 -11
- package/src/likec4diagram/custom/nodes/toolbar/CompoundToolbar.tsx +3 -2
- package/src/likec4diagram/relationship-popover/RelationshipPopover.tsx +535 -0
- package/src/likec4diagram/relationship-popover/actor.ts +192 -0
- package/src/likec4diagram/{custom/edges/RelationshipsDropdownMenu.css.ts → relationship-popover/styles.css.ts} +3 -19
- package/src/likec4diagram/useLayoutConstraints.ts +0 -1
- package/src/likec4model/useLikeC4ElementsTree.ts +1 -1
- package/src/navigationpanel/NavigationPanelDropdown.tsx +1 -2
- package/src/navigationpanel/actor.ts +2 -2
- package/src/navigationpanel/controls/NavigationButtons.tsx +1 -5
- package/src/navigationpanel/controls/ViewDetailsCard.tsx +2 -0
- package/src/overlays/relationship-details/layout-to-xyflow.ts +0 -1
- package/src/overlays/relationship-details/layout.ts +4 -3
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +22 -8
- package/src/overlays/relationships-browser/useViewToNodesEdges.ts +0 -1
- package/src/state/DiagramActorProvider.tsx +2 -20
- package/src/state/assign.ts +24 -10
- package/src/state/diagram-machine.ts +101 -53
- package/src/state/types.ts +4 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/roundDpr.ts +27 -0
- package/src/utils/xyflow.ts +0 -7
- package/dist/base/primitives/compound/CompoundNodeContainer.css.d.ts +0 -35
- package/dist/base/primitives/compound/CompoundNodeContainer.css.js +0 -132
- package/dist/base/primitives/edge/EdgeLabel.css.d.ts +0 -7
- package/dist/base/primitives/edge/EdgeLabel.css.js +0 -57
- package/dist/base/primitives/element/ElementShape.css.d.ts +0 -6
- package/dist/base/primitives/element/ElementShape.css.js +0 -107
- package/dist/likec4diagram/custom/edges/NotePopover.css.js +0 -21
- package/dist/likec4diagram/custom/edges/NotePopover.js +0 -91
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.d.ts +0 -5
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.d.ts +0 -13
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +0 -215
- package/dist/likec4diagram/custom/index.d.ts +0 -62
- package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +0 -10
- package/src/base/primitives/compound/CompoundNodeContainer.css.ts +0 -138
- package/src/base/primitives/edge/EdgeLabel.css.ts +0 -64
- package/src/base/primitives/element/ElementShape.css.ts +0 -112
- package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +0 -281
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { type EdgeId } from '@likec4/core/types'
|
|
2
|
+
import {
|
|
3
|
+
type ActorLogicFrom,
|
|
4
|
+
type ActorRefFrom,
|
|
5
|
+
type SnapshotFrom,
|
|
6
|
+
assertEvent,
|
|
7
|
+
assign,
|
|
8
|
+
setup,
|
|
9
|
+
} from 'xstate'
|
|
10
|
+
|
|
11
|
+
export type RelationshipPopoverActorEvent =
|
|
12
|
+
// Events from the UI
|
|
13
|
+
| { type: 'xyedge.mouseEnter'; edgeId: EdgeId }
|
|
14
|
+
| { type: 'xyedge.mouseLeave' }
|
|
15
|
+
| { type: 'xyedge.select'; edgeId: EdgeId }
|
|
16
|
+
| { type: 'xyedge.unselect' }
|
|
17
|
+
| { type: 'close' }
|
|
18
|
+
// - From dropdown
|
|
19
|
+
| { type: 'dropdown.mouseEnter' }
|
|
20
|
+
| { type: 'dropdown.mouseLeave' }
|
|
21
|
+
|
|
22
|
+
export interface RelationshipPopoverActorContext {
|
|
23
|
+
edgeId: EdgeId | null
|
|
24
|
+
/**
|
|
25
|
+
* True if the edge was selected
|
|
26
|
+
*/
|
|
27
|
+
edgeSelected: boolean
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The timeout for opening the popover
|
|
31
|
+
* If it was closed recently (<1.5s), it will be 300ms
|
|
32
|
+
* Otherwise, it will be 800ms
|
|
33
|
+
*/
|
|
34
|
+
openTimeout: number
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const _actorLogic = setup({
|
|
38
|
+
types: {
|
|
39
|
+
context: {} as RelationshipPopoverActorContext,
|
|
40
|
+
events: {} as RelationshipPopoverActorEvent,
|
|
41
|
+
tags: 'opened',
|
|
42
|
+
},
|
|
43
|
+
delays: {
|
|
44
|
+
'open timeout': ({ context }) => context.openTimeout,
|
|
45
|
+
'close timeout': 600,
|
|
46
|
+
'long idle': 1500,
|
|
47
|
+
},
|
|
48
|
+
actions: {
|
|
49
|
+
'update edgeId': assign(({ context, event }) => {
|
|
50
|
+
assertEvent(event, ['xyedge.select', 'xyedge.mouseEnter'])
|
|
51
|
+
return {
|
|
52
|
+
edgeId: event.edgeId,
|
|
53
|
+
edgeSelected: context.edgeSelected || event.type === 'xyedge.select',
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
'increase open timeout': assign(() => ({
|
|
57
|
+
openTimeout: 800,
|
|
58
|
+
})),
|
|
59
|
+
'decrease open timeout': assign(() => ({
|
|
60
|
+
openTimeout: 300,
|
|
61
|
+
})),
|
|
62
|
+
'reset edgeId': assign({
|
|
63
|
+
edgeId: null,
|
|
64
|
+
edgeSelected: false,
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
guards: {
|
|
68
|
+
'edge was selected': ({ context }) => context.edgeSelected,
|
|
69
|
+
'edge was hovered': ({ context }) => !context.edgeSelected,
|
|
70
|
+
},
|
|
71
|
+
}).createMachine({
|
|
72
|
+
id: 'breadcrumbs',
|
|
73
|
+
context: () => ({
|
|
74
|
+
edgeId: null,
|
|
75
|
+
edgeSelected: false,
|
|
76
|
+
openTimeout: 800,
|
|
77
|
+
}),
|
|
78
|
+
initial: 'idle',
|
|
79
|
+
on: {
|
|
80
|
+
'close': {
|
|
81
|
+
target: '#idle',
|
|
82
|
+
actions: [
|
|
83
|
+
'reset edgeId',
|
|
84
|
+
'increase open timeout',
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
states: {
|
|
89
|
+
idle: {
|
|
90
|
+
id: 'idle',
|
|
91
|
+
on: {
|
|
92
|
+
'xyedge.mouseEnter': {
|
|
93
|
+
target: 'opening',
|
|
94
|
+
actions: 'update edgeId',
|
|
95
|
+
},
|
|
96
|
+
'xyedge.select': {
|
|
97
|
+
target: 'active',
|
|
98
|
+
actions: 'update edgeId',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
after: {
|
|
102
|
+
'long idle': {
|
|
103
|
+
actions: 'increase open timeout',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
opening: {
|
|
108
|
+
on: {
|
|
109
|
+
'xyedge.mouseLeave': {
|
|
110
|
+
target: 'idle',
|
|
111
|
+
},
|
|
112
|
+
'xyedge.select': {
|
|
113
|
+
target: 'active',
|
|
114
|
+
actions: 'update edgeId',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
after: {
|
|
118
|
+
'open timeout': {
|
|
119
|
+
actions: 'decrease open timeout',
|
|
120
|
+
target: 'active',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
active: {
|
|
125
|
+
tags: ['opened'],
|
|
126
|
+
initial: 'opened',
|
|
127
|
+
exit: 'reset edgeId',
|
|
128
|
+
on: {
|
|
129
|
+
'xyedge.unselect': {
|
|
130
|
+
target: 'idle',
|
|
131
|
+
actions: 'increase open timeout',
|
|
132
|
+
},
|
|
133
|
+
'xyedge.select': {
|
|
134
|
+
actions: 'update edgeId',
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
states: {
|
|
138
|
+
opened: {
|
|
139
|
+
on: {
|
|
140
|
+
'dropdown.mouseEnter': {
|
|
141
|
+
target: 'hovered',
|
|
142
|
+
},
|
|
143
|
+
'xyedge.mouseLeave': {
|
|
144
|
+
guard: 'edge was hovered',
|
|
145
|
+
target: 'closing',
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
hovered: {
|
|
150
|
+
on: {
|
|
151
|
+
'dropdown.mouseLeave': [
|
|
152
|
+
{
|
|
153
|
+
guard: 'edge was selected',
|
|
154
|
+
target: 'opened',
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
target: 'closing',
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
closing: {
|
|
163
|
+
on: {
|
|
164
|
+
'xyedge.mouseEnter': {
|
|
165
|
+
guard: 'edge was hovered',
|
|
166
|
+
target: 'opened',
|
|
167
|
+
actions: 'update edgeId',
|
|
168
|
+
},
|
|
169
|
+
'xyedge.select': {
|
|
170
|
+
target: 'opened',
|
|
171
|
+
actions: 'update edgeId',
|
|
172
|
+
},
|
|
173
|
+
'dropdown.mouseEnter': {
|
|
174
|
+
target: 'hovered',
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
after: {
|
|
178
|
+
'close timeout': {
|
|
179
|
+
target: '#idle',
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
export interface RelationshipPopoverActorLogic extends ActorLogicFrom<typeof _actorLogic> {}
|
|
189
|
+
export const RelationshipPopoverActorLogic: RelationshipPopoverActorLogic = _actorLogic
|
|
190
|
+
|
|
191
|
+
export type RelationshipPopoverActorSnapshot = SnapshotFrom<RelationshipPopoverActorLogic>
|
|
192
|
+
export interface RelationshipPopoverActorRef extends ActorRefFrom<RelationshipPopoverActorLogic> {}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import { css } from '@likec4/styles/css'
|
|
2
2
|
|
|
3
|
-
export const menuDropdown = css({
|
|
4
|
-
overflowY: 'scroll',
|
|
5
|
-
minWidth: '250px',
|
|
6
|
-
maxWidth: 'min(90vw, 500px)',
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
export const menuItemRelationship = css({
|
|
10
|
-
gap: '1',
|
|
11
|
-
})
|
|
12
|
-
|
|
13
3
|
export const endpoint = css({
|
|
14
4
|
display: 'block',
|
|
15
5
|
fontSize: 'xxs',
|
|
@@ -24,17 +14,11 @@ export const endpoint = css({
|
|
|
24
14
|
_light: `[color-mix(in srgb, var(--likec4-palette-stroke), {colors.likec4.mixColor} 60%)]`,
|
|
25
15
|
_dark: 'var(--likec4-palette-loContrast)',
|
|
26
16
|
},
|
|
27
|
-
// _dark: {
|
|
28
|
-
// background: `var(--likec4-palette-fill)/60`,
|
|
29
|
-
// },
|
|
30
17
|
})
|
|
31
18
|
|
|
32
19
|
export const title = css({
|
|
33
20
|
whiteSpaceCollapse: 'preserve-breaks',
|
|
34
|
-
fontSize: '
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export const arrowFromTo = css({
|
|
38
|
-
whiteSpaceCollapse: 'preserve-breaks',
|
|
39
|
-
fontSize: 'xs',
|
|
21
|
+
fontSize: 'sm',
|
|
22
|
+
lineHeight: 'sm',
|
|
23
|
+
userSelect: 'all',
|
|
40
24
|
})
|
|
@@ -271,7 +271,6 @@ export function useLayoutConstraints(): LayoutConstraints {
|
|
|
271
271
|
},
|
|
272
272
|
onNodeDragStop: (_event) => {
|
|
273
273
|
moved = Math.abs(_event.clientX - initial.x) > 4 || Math.abs(_event.clientY - initial.y) > 4
|
|
274
|
-
console.log('moved', moved)
|
|
275
274
|
if (wasPending || moved) {
|
|
276
275
|
diagram.scheduleSaveManualLayout()
|
|
277
276
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { compareNatural } from '@likec4/core'
|
|
1
2
|
import { type LikeC4Model } from '@likec4/core/model'
|
|
2
3
|
import { type Fqn, type 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
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { compareNaturalHierarchically, ifilter, ifirst, nonexhaustive, toArray } from '@likec4/core'
|
|
1
2
|
import { type LikeC4ViewsFolder, LikeC4ViewModel, normalizeViewPath, VIEW_FOLDERS_SEPARATOR } from '@likec4/core/model'
|
|
2
3
|
import type { ViewId } from '@likec4/core/types'
|
|
3
|
-
import { compareNaturalHierarchically, ifilter, ifirst, nonexhaustive, toArray } from '@likec4/core/utils'
|
|
4
4
|
import { css, cx } from '@likec4/styles/css'
|
|
5
5
|
import { Box, HStack, VStack } from '@likec4/styles/jsx'
|
|
6
6
|
import { hstack, vstack } from '@likec4/styles/patterns'
|
|
@@ -155,7 +155,6 @@ function SearchResults({ searchQuery }: { searchQuery: string }) {
|
|
|
155
155
|
view={v}
|
|
156
156
|
highlight={highlight}
|
|
157
157
|
onClick={e => {
|
|
158
|
-
console.log('click')
|
|
159
158
|
e.stopPropagation()
|
|
160
159
|
actor.selectView(v.id)
|
|
161
160
|
}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ViewId } from '@likec4/core/types'
|
|
1
|
+
import type { ViewId } from '@likec4/core/types'
|
|
2
2
|
import { isEmpty } from 'remeda'
|
|
3
3
|
import {
|
|
4
4
|
type ActorLogicFrom,
|
|
@@ -143,7 +143,7 @@ const _actorLogic = setup({
|
|
|
143
143
|
assertEvent(event, 'select.view')
|
|
144
144
|
return {
|
|
145
145
|
type: 'navigateTo' as const,
|
|
146
|
-
viewId:
|
|
146
|
+
viewId: event.viewId,
|
|
147
147
|
}
|
|
148
148
|
}),
|
|
149
149
|
},
|
|
@@ -150,7 +150,6 @@ export function layoutResultToXYFlow(
|
|
|
150
150
|
target: ns + target,
|
|
151
151
|
sourceHandle: edge.sourceHandle,
|
|
152
152
|
targetHandle: edge.targetHandle,
|
|
153
|
-
zIndex: ZIndexes.Edge,
|
|
154
153
|
// selectable: selectable,
|
|
155
154
|
// hidden: !visiblePredicate(edge),
|
|
156
155
|
deletable: false,
|
|
@@ -16,12 +16,13 @@ import type {
|
|
|
16
16
|
} from '@likec4/core/types'
|
|
17
17
|
|
|
18
18
|
import dagre, { type EdgeConfig, type GraphLabel } from '@dagrejs/dagre'
|
|
19
|
-
import { invariant, RichText } from '@likec4/core'
|
|
20
|
-
import type { AnyAux, ElementModel, LikeC4ViewModel, RelationshipModel } from '@likec4/core/model'
|
|
21
19
|
import {
|
|
22
20
|
DefaultMap,
|
|
23
21
|
ifind,
|
|
24
|
-
|
|
22
|
+
invariant,
|
|
23
|
+
RichText,
|
|
24
|
+
} from '@likec4/core'
|
|
25
|
+
import type { AnyAux, ElementModel, LikeC4ViewModel, RelationshipModel } from '@likec4/core/model'
|
|
25
26
|
import {
|
|
26
27
|
filter,
|
|
27
28
|
find,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Handle } from '@xyflow/react'
|
|
2
2
|
import { Position } from '@xyflow/system'
|
|
3
|
+
import type { FC } from 'react'
|
|
3
4
|
import type { NodeProps } from '../../../base'
|
|
4
5
|
import {
|
|
6
|
+
CompoundDetailsButton,
|
|
5
7
|
CompoundNodeContainer,
|
|
6
8
|
CompoundTitle,
|
|
7
|
-
customNode,
|
|
8
9
|
ElementDetailsButton,
|
|
9
10
|
ElementNodeContainer,
|
|
10
11
|
ElementShape,
|
|
@@ -17,6 +18,12 @@ import type { RelationshipsBrowserTypes } from '../_types'
|
|
|
17
18
|
import { ElementActions } from './ElementActions'
|
|
18
19
|
import { EmptyNode as EmptyNodeRender } from './EmptyNode'
|
|
19
20
|
|
|
21
|
+
type NodeTypes = {
|
|
22
|
+
element: FC<NodeProps<RelationshipsBrowserTypes.ElementNodeData>>
|
|
23
|
+
compound: FC<NodeProps<RelationshipsBrowserTypes.CompoundNodeData>>
|
|
24
|
+
empty: FC<NodeProps<RelationshipsBrowserTypes.EmptyNodeData>>
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
const ElementDetailsButtonWithHandler = (
|
|
21
28
|
props: NodeProps<RelationshipsBrowserTypes.ElementNodeData | RelationshipsBrowserTypes.CompoundNodeData>,
|
|
22
29
|
) => {
|
|
@@ -33,7 +40,7 @@ const ElementDetailsButtonWithHandler = (
|
|
|
33
40
|
)
|
|
34
41
|
}
|
|
35
42
|
|
|
36
|
-
export const ElementNode =
|
|
43
|
+
export const ElementNode: NodeTypes['element'] = (props) => {
|
|
37
44
|
const { enableElementTags } = useEnabledFeatures()
|
|
38
45
|
return (
|
|
39
46
|
<ElementNodeContainer key={props.id} layoutId={props.id} nodeProps={props}>
|
|
@@ -45,21 +52,28 @@ export const ElementNode = customNode<RelationshipsBrowserTypes.ElementNodeData>
|
|
|
45
52
|
<ElementPorts {...props} />
|
|
46
53
|
</ElementNodeContainer>
|
|
47
54
|
)
|
|
48
|
-
}
|
|
55
|
+
}
|
|
49
56
|
|
|
50
|
-
export const CompoundNode =
|
|
57
|
+
export const CompoundNode: NodeTypes['compound'] = (props) => {
|
|
58
|
+
const diagram = useDiagram()
|
|
51
59
|
return (
|
|
52
60
|
<CompoundNodeContainer key={props.id} layoutId={props.id} nodeProps={props}>
|
|
53
|
-
<ElementDetailsButtonWithHandler {...props} />
|
|
54
61
|
<CompoundTitle {...props} />
|
|
62
|
+
<CompoundDetailsButton
|
|
63
|
+
{...props}
|
|
64
|
+
onClick={e => {
|
|
65
|
+
e.stopPropagation()
|
|
66
|
+
diagram.openElementDetails(props.data.fqn)
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
55
69
|
<CompoundPorts {...props} />
|
|
56
70
|
</CompoundNodeContainer>
|
|
57
71
|
)
|
|
58
|
-
}
|
|
72
|
+
}
|
|
59
73
|
|
|
60
|
-
export const EmptyNode =
|
|
74
|
+
export const EmptyNode: NodeTypes['empty'] = (props) => {
|
|
61
75
|
return <EmptyNodeRender {...props} />
|
|
62
|
-
}
|
|
76
|
+
}
|
|
63
77
|
|
|
64
78
|
type ElementPortsProps = NodeProps<
|
|
65
79
|
Pick<
|
|
@@ -177,7 +177,6 @@ export function viewToNodesEdge(
|
|
|
177
177
|
target: ns + target,
|
|
178
178
|
sourceHandle: edge.sourceHandle,
|
|
179
179
|
targetHandle: edge.targetHandle,
|
|
180
|
-
zIndex: ZIndexes.Edge,
|
|
181
180
|
// selectable: selectable,
|
|
182
181
|
// hidden: !visiblePredicate(edge),
|
|
183
182
|
// deletable: false,
|
|
@@ -3,7 +3,7 @@ import { useCustomCompareEffect } from '@react-hookz/web'
|
|
|
3
3
|
import { useActorRef, useSelector } from '@xstate/react'
|
|
4
4
|
import { useStoreApi } from '@xyflow/react'
|
|
5
5
|
import { deepEqual, shallowEqual } from 'fast-equals'
|
|
6
|
-
import { type PropsWithChildren, useEffect, useRef
|
|
6
|
+
import { type PropsWithChildren, useEffect, useRef } from 'react'
|
|
7
7
|
import { ErrorBoundary } from '../components/ErrorFallback'
|
|
8
8
|
import { useDiagramEventHandlers } from '../context/DiagramEventHandlers'
|
|
9
9
|
import { DiagramFeatures, useEnabledFeatures } from '../context/DiagramFeatures'
|
|
@@ -129,25 +129,7 @@ function CurrentViewModelProvider({
|
|
|
129
129
|
viewId: ViewId
|
|
130
130
|
}>) {
|
|
131
131
|
const likec4model = useLikeC4Model()
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
useEffect(() => {
|
|
135
|
-
setViewmodel(current => {
|
|
136
|
-
const nextviewmodel = likec4model.findView(viewId)
|
|
137
|
-
if (!nextviewmodel) {
|
|
138
|
-
console.error(`View "${viewId}" not found in likec4model, current viewmodel: ${current?.id}`, {
|
|
139
|
-
currentViewModel: current,
|
|
140
|
-
likec4model,
|
|
141
|
-
})
|
|
142
|
-
return current
|
|
143
|
-
}
|
|
144
|
-
if (!nextviewmodel.isDiagram()) {
|
|
145
|
-
console.warn(`View "${viewId}" is not diagram.\nMake sure you have LikeC4ModelProvider with layouted model.`)
|
|
146
|
-
}
|
|
147
|
-
return nextviewmodel
|
|
148
|
-
})
|
|
149
|
-
}, [likec4model, viewId])
|
|
150
|
-
|
|
132
|
+
const viewmodel = likec4model.findView(viewId)
|
|
151
133
|
return (
|
|
152
134
|
<CurrentViewModelContext.Provider value={viewmodel}>
|
|
153
135
|
{children}
|
package/src/state/assign.ts
CHANGED
|
@@ -277,23 +277,37 @@ export function navigateForward({ context }: ActionArg): Partial<DiagramContext>
|
|
|
277
277
|
|
|
278
278
|
export function updateNodeData({ context, event }: ActionArg): Partial<DiagramContext> {
|
|
279
279
|
assertEvent(event, 'update.nodeData')
|
|
280
|
-
const xynodes = context.xynodes.map((node): Types.Node =>
|
|
281
|
-
node.id !== event.nodeId
|
|
280
|
+
const xynodes = context.xynodes.map((node): Types.Node => {
|
|
281
|
+
if (node.id !== event.nodeId) {
|
|
282
|
+
return node
|
|
283
|
+
}
|
|
284
|
+
const data = mergeDeep(node.data as any, event.data as any)
|
|
285
|
+
if (eq(data, node.data)) {
|
|
286
|
+
return node
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
282
289
|
...node,
|
|
283
|
-
data
|
|
284
|
-
}
|
|
285
|
-
)
|
|
290
|
+
data,
|
|
291
|
+
} as Types.Node
|
|
292
|
+
})
|
|
286
293
|
return { xynodes }
|
|
287
294
|
}
|
|
288
295
|
|
|
289
296
|
export function updateEdgeData({ context, event }: ActionArg): Partial<DiagramContext> {
|
|
290
297
|
assertEvent(event, 'update.edgeData')
|
|
291
|
-
const xyedges = context.xyedges.map((edge): Types.Edge =>
|
|
292
|
-
edge.id !== event.edgeId
|
|
298
|
+
const xyedges = context.xyedges.map((edge): Types.Edge => {
|
|
299
|
+
if (edge.id !== event.edgeId) {
|
|
300
|
+
return edge
|
|
301
|
+
}
|
|
302
|
+
const data = mergeDeep(edge.data as any, event.data as any)
|
|
303
|
+
if (eq(data, edge.data)) {
|
|
304
|
+
return edge
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
293
307
|
...edge,
|
|
294
|
-
data
|
|
295
|
-
}
|
|
296
|
-
)
|
|
308
|
+
data,
|
|
309
|
+
} as Types.Edge
|
|
310
|
+
})
|
|
297
311
|
return { xyedges }
|
|
298
312
|
}
|
|
299
313
|
|