@likec4/diagram 1.44.0 → 1.45.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/index.js +18160 -17671
- package/dist/LikeC4Diagram.js +7 -5
- package/dist/LikeC4Diagram.props.d.ts +9 -8
- package/dist/LikeC4Styles.js +0 -3
- package/dist/LikeC4View.d.ts +3 -3
- package/dist/LikeC4View.js +7 -3
- package/dist/ReactLikeC4.d.ts +2 -2
- package/dist/base/Base.d.ts +1 -1
- package/dist/base/updateEdges.js +25 -15
- package/dist/base/updateNodes.d.ts +14 -0
- package/dist/base/updateNodes.js +51 -18
- package/dist/base-primitives/Markdown.d.ts +30 -4
- package/dist/base-primitives/Markdown.js +3 -2
- package/dist/base-primitives/compound/CompoundActionButton.d.ts +3 -2
- package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +3 -2
- package/dist/base-primitives/edge/EdgeActionButton.d.ts +3 -2
- package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeContainer.js +4 -1
- package/dist/base-primitives/edge/EdgeLabel.d.ts +2 -2
- package/dist/base-primitives/edge/EdgePath.js +24 -4
- package/dist/base-primitives/element/ElementActionButtons.d.ts +3 -2
- package/dist/base-primitives/element/ElementActionButtons.js +2 -2
- package/dist/base-primitives/element/ElementData.d.ts +3 -3
- package/dist/base-primitives/element/ElementData.js +13 -7
- package/dist/base-primitives/element/ElementDetailsButton.d.ts +3 -2
- package/dist/base-primitives/element/ElementDetailsButton.js +3 -0
- package/dist/base-primitives/element/ElementShape.js +5 -5
- package/dist/base-primitives/element/ElementTags.d.ts +6 -4
- package/dist/context/DiagramFeatures.d.ts +1 -0
- package/dist/context/TagStylesContext.js +1 -1
- package/dist/custom/hooks.d.ts +2 -2
- package/dist/custom/index.js +1 -1
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/useDiagramCompareLayout.js +7 -2
- package/dist/hooks/useLikeC4Project.d.ts +6 -1
- package/dist/hooks/useLikeC4Project.js +14 -2
- package/dist/hooks/useMediaPrint.d.ts +6 -0
- package/dist/likec4diagram/DiagramXYFlow.js +11 -6
- package/dist/likec4diagram/custom/edges/EdgeDrifts.d.ts +6 -0
- package/dist/likec4diagram/custom/edges/EdgeDrifts.js +38 -0
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +24 -14
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +3 -1
- package/dist/likec4diagram/custom/edges/useControlPoints.js +3 -3
- package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.js +5 -5
- package/dist/likec4diagram/custom/nodes/NodeDrifts.d.ts +6 -0
- package/dist/likec4diagram/custom/nodes/{ElementNodeDrifts.js → NodeDrifts.js} +8 -4
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +4 -2
- package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
- package/dist/likec4diagram/custom/nodes/nodes.js +64 -23
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +3 -3
- package/dist/likec4diagram/relationship-popover/actor.d.ts +1 -1
- package/dist/likec4diagram/state/DiagramActorProvider.d.ts +2 -2
- package/dist/likec4diagram/state/DiagramActorProvider.js +0 -1
- package/dist/likec4diagram/state/assign.d.ts +10 -6
- package/dist/likec4diagram/state/assign.js +17 -192
- package/dist/likec4diagram/state/createViewChange.js +15 -26
- package/dist/likec4diagram/state/diagram-api.d.ts +2 -6
- package/dist/likec4diagram/state/diagram-api.js +2 -10
- package/dist/likec4diagram/state/hotkeyActor.d.ts +0 -7
- package/dist/likec4diagram/state/hotkeyActor.js +1 -17
- package/dist/likec4diagram/state/machine.actions.d.ts +430 -746
- package/dist/likec4diagram/state/machine.actions.js +193 -284
- package/dist/likec4diagram/state/machine.actions.layout.d.ts +579 -0
- package/dist/likec4diagram/state/machine.actions.layout.js +129 -0
- package/dist/likec4diagram/state/machine.d.ts +17 -3712
- package/dist/likec4diagram/state/machine.js +59 -73
- package/dist/likec4diagram/state/machine.setup.d.ts +61 -18
- package/dist/likec4diagram/state/machine.setup.js +27 -5
- package/dist/likec4diagram/state/machine.state.initializing.d.ts +25 -0
- package/dist/likec4diagram/state/machine.state.initializing.js +5 -5
- package/dist/likec4diagram/state/machine.state.navigating.d.ts +5 -108
- package/dist/likec4diagram/state/machine.state.navigating.js +167 -34
- package/dist/likec4diagram/state/machine.state.ready.d.ts +2316 -2851
- package/dist/likec4diagram/state/machine.state.ready.focused.d.ts +386 -0
- package/dist/likec4diagram/state/machine.state.ready.focused.js +85 -0
- package/dist/likec4diagram/state/machine.state.ready.idle.d.ts +474 -0
- package/dist/likec4diagram/state/machine.state.ready.idle.js +96 -0
- package/dist/likec4diagram/state/machine.state.ready.js +144 -319
- package/dist/likec4diagram/state/machine.state.ready.printing.d.ts +128 -0
- package/dist/likec4diagram/state/machine.state.ready.printing.js +40 -0
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.d.ts +511 -0
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +177 -0
- package/dist/likec4diagram/state/mediaPrintActor.d.ts +12 -0
- package/dist/likec4diagram/state/mediaPrintActor.js +18 -0
- package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +6 -240
- package/dist/likec4diagram/state/syncManualLayoutActor.js +150 -89
- package/dist/likec4diagram/state/types.d.ts +5 -7
- package/dist/likec4diagram/state/utils.d.ts +15 -2
- package/dist/likec4diagram/state/utils.js +43 -3
- package/dist/likec4diagram/types.d.ts +8 -13
- package/dist/likec4diagram/ui/notation/NotationPanel.css.js +5 -2
- package/dist/likec4diagram/useLayoutConstraints.js +107 -102
- package/dist/likec4diagram/xyflow-diagram/diagram-view.js +12 -15
- package/dist/likec4diagram/xyflow-sequence/sequence-layout.js +11 -8
- package/dist/navigationpanel/NavigationPanel.js +5 -1
- package/dist/navigationpanel/actor.d.ts +4 -204
- package/dist/navigationpanel/actor.js +1 -1
- package/dist/navigationpanel/controls/ToggleReadonly.js +8 -3
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +66 -66
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +4 -3
- package/dist/overlays/element-details/ElementDetailsCard.css.js +3 -3
- package/dist/overlays/element-details/MetadataValue.d.ts +2 -1
- package/dist/overlays/element-details/actor.d.ts +8 -83
- package/dist/overlays/element-details/actor.js +0 -8
- package/dist/overlays/overlay/Overlay.js +10 -10
- package/dist/overlays/overlaysActor.d.ts +7 -392
- package/dist/overlays/overlaysActor.js +67 -46
- package/dist/overlays/relationship-details/_types.d.ts +3 -4
- package/dist/overlays/relationship-details/actor.d.ts +6 -562
- package/dist/overlays/relationship-details/actor.js +1 -0
- package/dist/overlays/relationship-details/layout-to-xyflow.js +3 -5
- package/dist/overlays/relationship-details/layout.d.ts +3 -3
- package/dist/overlays/relationship-details/layout.js +4 -4
- package/dist/overlays/relationships-browser/_types.d.ts +2 -3
- package/dist/overlays/relationships-browser/actor.d.ts +7 -739
- package/dist/overlays/relationships-browser/layout.d.ts +2 -2
- package/dist/overlays/relationships-browser/layout.js +3 -3
- package/dist/overlays/relationships-browser/useViewToNodesEdges.js +0 -3
- package/dist/overlays/types.d.ts +12 -13
- package/dist/search/components/_shared.css.d.ts +1 -1
- package/dist/search/searchActor.d.ts +3 -66
- package/dist/shadowroot/ShadowRoot.d.ts +5 -7
- package/dist/shadowroot/ShadowRoot.js +7 -5
- package/dist/styles.css2.js +1 -1
- package/dist/utils/vector.d.ts +5 -0
- package/dist/utils/vector.js +7 -0
- package/dist/utils/view-bounds.js +7 -6
- package/dist/utils/xyflow.d.ts +4 -2
- package/dist/utils/xyflow.js +18 -50
- package/package.json +19 -18
- package/panda.buildinfo.json +17 -5
- package/styles-min.css +1 -1
- package/styles.css +1 -1
- package/dist/likec4diagram/custom/nodes/ElementNodeDrifts.d.ts +0 -4
|
@@ -1,44 +1,177 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { BBox } from '@likec4/core/types';
|
|
2
|
+
import { invariant, nonNullable } from '@likec4/core/utils';
|
|
3
|
+
import { enqueueActions, assertEvent } from 'xstate';
|
|
4
|
+
import { mergeXYNodesEdges } from './assign.js';
|
|
5
|
+
import { disableCompareWithLatest } from './machine.actions.js';
|
|
6
|
+
import { machine, targetState } from './machine.setup.js';
|
|
7
|
+
import { calcViewportForBounds, findCorrespondingNode, nodeRef } from './utils.js';
|
|
8
|
+
import { cancelFitDiagram, raiseSetViewport, raiseFitDiagram } from './machine.actions.layout.js';
|
|
5
9
|
|
|
10
|
+
const handleBrowserForwardBackward = () => machine.assign(({ context, event }) => {
|
|
11
|
+
assertEvent(event, "update.view");
|
|
12
|
+
let {
|
|
13
|
+
lastOnNavigate,
|
|
14
|
+
navigationHistory: {
|
|
15
|
+
currentIndex,
|
|
16
|
+
history
|
|
17
|
+
}
|
|
18
|
+
} = context;
|
|
19
|
+
const stepCurrent = history[currentIndex];
|
|
20
|
+
if (!stepCurrent || stepCurrent.viewId === event.view.id || !!lastOnNavigate) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
const stepBack = currentIndex > 0 ? nonNullable(history[currentIndex - 1]) : null;
|
|
24
|
+
if (stepBack && stepBack.viewId === event.view.id) {
|
|
25
|
+
return {
|
|
26
|
+
navigationHistory: {
|
|
27
|
+
currentIndex: currentIndex - 1,
|
|
28
|
+
history
|
|
29
|
+
},
|
|
30
|
+
lastOnNavigate: null
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const stepForward = currentIndex < history.length - 1 ? nonNullable(history[currentIndex + 1]) : null;
|
|
34
|
+
if (stepForward && stepForward.viewId === event.view.id) {
|
|
35
|
+
return {
|
|
36
|
+
navigationHistory: {
|
|
37
|
+
currentIndex: currentIndex + 1,
|
|
38
|
+
history
|
|
39
|
+
},
|
|
40
|
+
lastOnNavigate: null
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (event.view._type === "element" && event.view.viewOf) {
|
|
44
|
+
const toRef = event.view.viewOf;
|
|
45
|
+
const existingNode = context.xynodes.find((n) => nodeRef(n) === toRef);
|
|
46
|
+
if (existingNode) {
|
|
47
|
+
return {
|
|
48
|
+
lastOnNavigate: {
|
|
49
|
+
fromView: context.view.id,
|
|
50
|
+
toView: event.view.id,
|
|
51
|
+
fromNode: existingNode.id
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return {};
|
|
57
|
+
});
|
|
6
58
|
const navigating = machine.createStateConfig({
|
|
7
|
-
id:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
59
|
+
id: targetState.navigating.slice(1),
|
|
60
|
+
always: {
|
|
61
|
+
target: targetState.idle,
|
|
62
|
+
actions: [
|
|
63
|
+
cancelFitDiagram(),
|
|
64
|
+
handleBrowserForwardBackward(),
|
|
65
|
+
disableCompareWithLatest(),
|
|
66
|
+
enqueueActions(({ enqueue, context, event }) => {
|
|
67
|
+
assertEvent(event, "update.view");
|
|
68
|
+
const {
|
|
69
|
+
xyflow,
|
|
70
|
+
xystore,
|
|
71
|
+
navigationHistory: {
|
|
72
|
+
currentIndex,
|
|
73
|
+
history
|
|
74
|
+
}
|
|
75
|
+
} = context;
|
|
76
|
+
invariant(xyflow, "xyflow is not initialized");
|
|
77
|
+
const calcZoomTowardsNextViewport = (nextViewport2) => {
|
|
78
|
+
const zoom = xyflow.getZoom();
|
|
79
|
+
const coef = nextViewport2.zoom < zoom ? 0.7 : 0.3;
|
|
80
|
+
return zoom + (nextViewport2.zoom - zoom) * coef;
|
|
81
|
+
};
|
|
82
|
+
const fromHistory = history[currentIndex];
|
|
83
|
+
if (fromHistory && fromHistory.viewId === event.view.id) {
|
|
84
|
+
console.log("Navigating: fromHistory", fromHistory);
|
|
85
|
+
enqueue.assign({
|
|
86
|
+
...mergeXYNodesEdges(context, event),
|
|
87
|
+
dynamicViewVariant: fromHistory.dynamicViewVariant ?? context.dynamicViewVariant,
|
|
88
|
+
viewportChangedManually: fromHistory.viewportChangedManually
|
|
89
|
+
});
|
|
90
|
+
const wasFocused = fromHistory.focusedNode;
|
|
91
|
+
const wasActiveWalkthrough = fromHistory.activeWalkthrough;
|
|
92
|
+
const viewportBefore = fromHistory.viewportBefore;
|
|
93
|
+
if (viewportBefore && (wasFocused || wasActiveWalkthrough)) {
|
|
94
|
+
enqueue.assign({
|
|
95
|
+
viewport: viewportBefore.value,
|
|
96
|
+
viewportChangedManually: viewportBefore.wasChangedManually,
|
|
97
|
+
viewportBefore: null
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const center = BBox.center(event.view.bounds);
|
|
101
|
+
const zoom = calcZoomTowardsNextViewport(fromHistory.viewport);
|
|
102
|
+
xyflow.setCenter(
|
|
103
|
+
center.x,
|
|
104
|
+
center.y,
|
|
105
|
+
{ zoom, duration: 0 }
|
|
106
|
+
);
|
|
107
|
+
if (wasFocused) {
|
|
108
|
+
enqueue.raise({
|
|
109
|
+
type: "focus.node",
|
|
110
|
+
nodeId: wasFocused
|
|
111
|
+
}, { delay: 50 });
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (wasActiveWalkthrough) {
|
|
115
|
+
enqueue.raise({
|
|
116
|
+
type: "walkthrough.start",
|
|
117
|
+
stepId: wasActiveWalkthrough
|
|
118
|
+
}, { delay: 50 });
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
enqueue(raiseSetViewport({
|
|
122
|
+
delay: 80,
|
|
123
|
+
viewport: fromHistory.viewport
|
|
124
|
+
}));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const nextViewport = calcViewportForBounds(
|
|
128
|
+
context,
|
|
129
|
+
event.view.bounds
|
|
130
|
+
);
|
|
19
131
|
const { fromNode, toNode } = findCorrespondingNode(context, event);
|
|
20
132
|
if (fromNode && toNode) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
133
|
+
const elFrom = xyflow.getInternalNode(fromNode.id);
|
|
134
|
+
const fromPoint = xyflow.flowToScreenPosition({
|
|
135
|
+
x: elFrom.internals.positionAbsolute.x,
|
|
136
|
+
y: elFrom.internals.positionAbsolute.y
|
|
137
|
+
});
|
|
138
|
+
const toPoint = xyflow.flowToScreenPosition({
|
|
139
|
+
x: toNode.data.x,
|
|
140
|
+
y: toNode.data.y
|
|
141
|
+
});
|
|
142
|
+
xystore.getState().panBy({
|
|
143
|
+
x: Math.round(fromPoint.x - toPoint.x),
|
|
144
|
+
y: Math.round(fromPoint.y - toPoint.y)
|
|
145
|
+
});
|
|
30
146
|
} else {
|
|
31
|
-
|
|
32
|
-
|
|
147
|
+
const zoom = calcZoomTowardsNextViewport(nextViewport);
|
|
148
|
+
const center = BBox.center(event.view.bounds);
|
|
149
|
+
xyflow.setCenter(
|
|
150
|
+
center.x,
|
|
151
|
+
center.y,
|
|
152
|
+
{ zoom, duration: 0 }
|
|
33
153
|
);
|
|
34
154
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
155
|
+
const updatedHistory = currentIndex < history.length - 1 ? history.slice(0, currentIndex + 1) : [...history];
|
|
156
|
+
updatedHistory.push({
|
|
157
|
+
viewId: event.view.id,
|
|
158
|
+
viewport: { ...nextViewport },
|
|
159
|
+
viewportChangedManually: false
|
|
160
|
+
});
|
|
161
|
+
enqueue.assign({
|
|
162
|
+
...mergeXYNodesEdges(context, event),
|
|
163
|
+
viewportChangedManually: false,
|
|
164
|
+
lastOnNavigate: null,
|
|
165
|
+
navigationHistory: {
|
|
166
|
+
currentIndex: updatedHistory.length - 1,
|
|
167
|
+
history: updatedHistory
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
enqueue(raiseFitDiagram({
|
|
171
|
+
delay: 100
|
|
172
|
+
}));
|
|
173
|
+
})
|
|
174
|
+
]
|
|
42
175
|
}
|
|
43
176
|
});
|
|
44
177
|
|