@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.
Files changed (134) hide show
  1. package/bundle/index.js +18160 -17671
  2. package/dist/LikeC4Diagram.js +7 -5
  3. package/dist/LikeC4Diagram.props.d.ts +9 -8
  4. package/dist/LikeC4Styles.js +0 -3
  5. package/dist/LikeC4View.d.ts +3 -3
  6. package/dist/LikeC4View.js +7 -3
  7. package/dist/ReactLikeC4.d.ts +2 -2
  8. package/dist/base/Base.d.ts +1 -1
  9. package/dist/base/updateEdges.js +25 -15
  10. package/dist/base/updateNodes.d.ts +14 -0
  11. package/dist/base/updateNodes.js +51 -18
  12. package/dist/base-primitives/Markdown.d.ts +30 -4
  13. package/dist/base-primitives/Markdown.js +3 -2
  14. package/dist/base-primitives/compound/CompoundActionButton.d.ts +3 -2
  15. package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +3 -2
  16. package/dist/base-primitives/edge/EdgeActionButton.d.ts +3 -2
  17. package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
  18. package/dist/base-primitives/edge/EdgeContainer.js +4 -1
  19. package/dist/base-primitives/edge/EdgeLabel.d.ts +2 -2
  20. package/dist/base-primitives/edge/EdgePath.js +24 -4
  21. package/dist/base-primitives/element/ElementActionButtons.d.ts +3 -2
  22. package/dist/base-primitives/element/ElementActionButtons.js +2 -2
  23. package/dist/base-primitives/element/ElementData.d.ts +3 -3
  24. package/dist/base-primitives/element/ElementData.js +13 -7
  25. package/dist/base-primitives/element/ElementDetailsButton.d.ts +3 -2
  26. package/dist/base-primitives/element/ElementDetailsButton.js +3 -0
  27. package/dist/base-primitives/element/ElementShape.js +5 -5
  28. package/dist/base-primitives/element/ElementTags.d.ts +6 -4
  29. package/dist/context/DiagramFeatures.d.ts +1 -0
  30. package/dist/context/TagStylesContext.js +1 -1
  31. package/dist/custom/hooks.d.ts +2 -2
  32. package/dist/custom/index.js +1 -1
  33. package/dist/hooks/index.d.ts +2 -1
  34. package/dist/hooks/useDiagramCompareLayout.js +7 -2
  35. package/dist/hooks/useLikeC4Project.d.ts +6 -1
  36. package/dist/hooks/useLikeC4Project.js +14 -2
  37. package/dist/hooks/useMediaPrint.d.ts +6 -0
  38. package/dist/likec4diagram/DiagramXYFlow.js +11 -6
  39. package/dist/likec4diagram/custom/edges/EdgeDrifts.d.ts +6 -0
  40. package/dist/likec4diagram/custom/edges/EdgeDrifts.js +38 -0
  41. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +24 -14
  42. package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +3 -1
  43. package/dist/likec4diagram/custom/edges/useControlPoints.js +3 -3
  44. package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.js +5 -5
  45. package/dist/likec4diagram/custom/nodes/NodeDrifts.d.ts +6 -0
  46. package/dist/likec4diagram/custom/nodes/{ElementNodeDrifts.js → NodeDrifts.js} +8 -4
  47. package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +4 -2
  48. package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
  49. package/dist/likec4diagram/custom/nodes/nodes.js +64 -23
  50. package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +3 -3
  51. package/dist/likec4diagram/relationship-popover/actor.d.ts +1 -1
  52. package/dist/likec4diagram/state/DiagramActorProvider.d.ts +2 -2
  53. package/dist/likec4diagram/state/DiagramActorProvider.js +0 -1
  54. package/dist/likec4diagram/state/assign.d.ts +10 -6
  55. package/dist/likec4diagram/state/assign.js +17 -192
  56. package/dist/likec4diagram/state/createViewChange.js +15 -26
  57. package/dist/likec4diagram/state/diagram-api.d.ts +2 -6
  58. package/dist/likec4diagram/state/diagram-api.js +2 -10
  59. package/dist/likec4diagram/state/hotkeyActor.d.ts +0 -7
  60. package/dist/likec4diagram/state/hotkeyActor.js +1 -17
  61. package/dist/likec4diagram/state/machine.actions.d.ts +430 -746
  62. package/dist/likec4diagram/state/machine.actions.js +193 -284
  63. package/dist/likec4diagram/state/machine.actions.layout.d.ts +579 -0
  64. package/dist/likec4diagram/state/machine.actions.layout.js +129 -0
  65. package/dist/likec4diagram/state/machine.d.ts +17 -3712
  66. package/dist/likec4diagram/state/machine.js +59 -73
  67. package/dist/likec4diagram/state/machine.setup.d.ts +61 -18
  68. package/dist/likec4diagram/state/machine.setup.js +27 -5
  69. package/dist/likec4diagram/state/machine.state.initializing.d.ts +25 -0
  70. package/dist/likec4diagram/state/machine.state.initializing.js +5 -5
  71. package/dist/likec4diagram/state/machine.state.navigating.d.ts +5 -108
  72. package/dist/likec4diagram/state/machine.state.navigating.js +167 -34
  73. package/dist/likec4diagram/state/machine.state.ready.d.ts +2316 -2851
  74. package/dist/likec4diagram/state/machine.state.ready.focused.d.ts +386 -0
  75. package/dist/likec4diagram/state/machine.state.ready.focused.js +85 -0
  76. package/dist/likec4diagram/state/machine.state.ready.idle.d.ts +474 -0
  77. package/dist/likec4diagram/state/machine.state.ready.idle.js +96 -0
  78. package/dist/likec4diagram/state/machine.state.ready.js +144 -319
  79. package/dist/likec4diagram/state/machine.state.ready.printing.d.ts +128 -0
  80. package/dist/likec4diagram/state/machine.state.ready.printing.js +40 -0
  81. package/dist/likec4diagram/state/machine.state.ready.walkthrough.d.ts +511 -0
  82. package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +177 -0
  83. package/dist/likec4diagram/state/mediaPrintActor.d.ts +12 -0
  84. package/dist/likec4diagram/state/mediaPrintActor.js +18 -0
  85. package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +6 -240
  86. package/dist/likec4diagram/state/syncManualLayoutActor.js +150 -89
  87. package/dist/likec4diagram/state/types.d.ts +5 -7
  88. package/dist/likec4diagram/state/utils.d.ts +15 -2
  89. package/dist/likec4diagram/state/utils.js +43 -3
  90. package/dist/likec4diagram/types.d.ts +8 -13
  91. package/dist/likec4diagram/ui/notation/NotationPanel.css.js +5 -2
  92. package/dist/likec4diagram/useLayoutConstraints.js +107 -102
  93. package/dist/likec4diagram/xyflow-diagram/diagram-view.js +12 -15
  94. package/dist/likec4diagram/xyflow-sequence/sequence-layout.js +11 -8
  95. package/dist/navigationpanel/NavigationPanel.js +5 -1
  96. package/dist/navigationpanel/actor.d.ts +4 -204
  97. package/dist/navigationpanel/actor.js +1 -1
  98. package/dist/navigationpanel/controls/ToggleReadonly.js +8 -3
  99. package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +66 -66
  100. package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +4 -3
  101. package/dist/overlays/element-details/ElementDetailsCard.css.js +3 -3
  102. package/dist/overlays/element-details/MetadataValue.d.ts +2 -1
  103. package/dist/overlays/element-details/actor.d.ts +8 -83
  104. package/dist/overlays/element-details/actor.js +0 -8
  105. package/dist/overlays/overlay/Overlay.js +10 -10
  106. package/dist/overlays/overlaysActor.d.ts +7 -392
  107. package/dist/overlays/overlaysActor.js +67 -46
  108. package/dist/overlays/relationship-details/_types.d.ts +3 -4
  109. package/dist/overlays/relationship-details/actor.d.ts +6 -562
  110. package/dist/overlays/relationship-details/actor.js +1 -0
  111. package/dist/overlays/relationship-details/layout-to-xyflow.js +3 -5
  112. package/dist/overlays/relationship-details/layout.d.ts +3 -3
  113. package/dist/overlays/relationship-details/layout.js +4 -4
  114. package/dist/overlays/relationships-browser/_types.d.ts +2 -3
  115. package/dist/overlays/relationships-browser/actor.d.ts +7 -739
  116. package/dist/overlays/relationships-browser/layout.d.ts +2 -2
  117. package/dist/overlays/relationships-browser/layout.js +3 -3
  118. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +0 -3
  119. package/dist/overlays/types.d.ts +12 -13
  120. package/dist/search/components/_shared.css.d.ts +1 -1
  121. package/dist/search/searchActor.d.ts +3 -66
  122. package/dist/shadowroot/ShadowRoot.d.ts +5 -7
  123. package/dist/shadowroot/ShadowRoot.js +7 -5
  124. package/dist/styles.css2.js +1 -1
  125. package/dist/utils/vector.d.ts +5 -0
  126. package/dist/utils/vector.js +7 -0
  127. package/dist/utils/view-bounds.js +7 -6
  128. package/dist/utils/xyflow.d.ts +4 -2
  129. package/dist/utils/xyflow.js +18 -50
  130. package/package.json +19 -18
  131. package/panda.buildinfo.json +17 -5
  132. package/styles-min.css +1 -1
  133. package/styles.css +1 -1
  134. package/dist/likec4diagram/custom/nodes/ElementNodeDrifts.d.ts +0 -4
@@ -1,318 +1,96 @@
1
- import { isStepEdgeId, getParallelStepsPrefix } from '@likec4/core';
2
- import { clamp, first } from 'remeda';
3
- import { assertEvent } from 'xstate';
4
- import { SeqParallelAreaColor } from '../xyflow-sequence/const.js';
5
- import { navigateForward, navigateBack } from './assign.js';
6
- import { cancelFitDiagram, undimEverything, tagHighlight, notationsHighlight, onEdgeDoubleClick, onEdgeMouseLeave, onEdgeMouseEnter, onNodeMouseLeave, onNodeMouseEnter, toggleFeature, ensureSyncLayout, emitOpenSource, openElementDetails, raiseFitDiagram, stopSyncLayout, disableCompareWithLatest, startEditing, resetEdgesControlPoints, stopEditing, layoutAlign, updateActiveWalkthroughState, xyflow, emitEdgeClick, emitWalkthroughStep, emitWalkthroughStarted, emitWalkthroughStopped, focusOnNodesAndEdges, resetLastClickedNode, emitPaneClick, assignFocusedNode, openSourceOfFocusedOrLastClickedNode, emitNodeClick, assignLastClickedNode } from './machine.actions.js';
7
- import { machine } from './machine.setup.js';
8
- import { typedSystem } from './utils.js';
1
+ import { BBox } from '@likec4/core';
2
+ import { resetLastClickedNode, emitEdgeClick, assignLastClickedNode, emitNodeClick, emitPaneClick, undimEverything, tagHighlight, notationsHighlight, startEditing, onEdgeDoubleClick, stopEditing, onEdgeMouseLeave, onEdgeMouseEnter, onNodeMouseLeave, onNodeMouseEnter, updateFeatures, ensureOverlaysActor, ensureSearchActor, ensureSyncLayoutActor, assignToggledFeatures, emitOpenSource, openElementDetails, stopSyncLayout, disableCompareWithLatest, resetEdgesControlPoints, layoutAlign, handleNavigate, closeAllOverlays, closeSearch, updateXYNodesEdges, sendSynced } from './machine.actions.js';
3
+ import { machine, targetState } from './machine.setup.js';
4
+ import { focused } from './machine.state.ready.focused.js';
5
+ import { idle } from './machine.state.ready.idle.js';
6
+ import { printing } from './machine.state.ready.printing.js';
7
+ import { walkthrough } from './machine.state.ready.walkthrough.js';
8
+ import { typedSystem, calcViewportForBounds } from './utils.js';
9
9
  import { x as xstateActions_cjsExports } from '../../_virtual/xstate-actions.cjs.js';
10
10
  import { x as xstateGuards_cjsExports } from '../../_virtual/xstate-guards.cjs.js';
11
- import { Base } from '../../base/Base.js';
11
+ import { setViewport, fitDiagram, cancelFitDiagram, raiseFitDiagram } from './machine.actions.layout.js';
12
12
 
13
- const navigating = "#navigating";
14
- const idle = machine.createStateConfig({
15
- id: "idle",
16
- on: {
17
- "xyflow.nodeClick": [
18
- {
19
- guard: xstateGuards_cjsExports.and([
20
- "enabled: FocusMode",
21
- "click: node has connections",
22
- xstateGuards_cjsExports.or([
23
- "click: same node",
24
- "click: selected node"
25
- ])
26
- ]),
27
- actions: [
28
- assignLastClickedNode(),
29
- assignFocusedNode(),
30
- emitNodeClick()
31
- ],
32
- target: "focused"
33
- },
34
- {
35
- guard: xstateGuards_cjsExports.and([
36
- "enabled: Readonly",
37
- "enabled: ElementDetails",
38
- "click: node has modelFqn",
39
- xstateGuards_cjsExports.or([
40
- "click: same node",
41
- "click: selected node"
42
- ])
43
- ]),
44
- actions: [
45
- assignLastClickedNode(),
46
- openSourceOfFocusedOrLastClickedNode(),
47
- openElementDetails(),
48
- emitNodeClick()
49
- ]
50
- },
51
- {
52
- actions: [
53
- assignLastClickedNode(),
54
- openSourceOfFocusedOrLastClickedNode(),
55
- emitNodeClick()
56
- ]
57
- }
58
- ],
59
- "xyflow.paneClick": {
60
- actions: [
61
- resetLastClickedNode(),
62
- emitPaneClick()
63
- ]
64
- },
65
- "xyflow.paneDblClick": {
66
- actions: [
67
- resetLastClickedNode(),
68
- xyflow.fitDiagram(),
69
- xstateActions_cjsExports.enqueueActions(({ context, enqueue }) => {
70
- enqueue(
71
- emitOpenSource({ view: context.view.id })
72
- );
73
- })
74
- ]
75
- },
76
- "focus.node": {
77
- guard: "enabled: FocusMode",
78
- actions: assignFocusedNode(),
79
- target: "focused"
80
- },
81
- "xyflow.edgeClick": {
82
- guard: xstateGuards_cjsExports.and([
83
- "enabled: Readonly",
84
- "is dynamic view",
85
- "enabled: DynamicViewWalkthrough",
86
- "click: selected edge"
87
- ]),
88
- actions: [
89
- xstateActions_cjsExports.raise(({ event }) => ({
90
- type: "walkthrough.start",
91
- stepId: event.edge.id
92
- })),
93
- emitEdgeClick()
94
- ]
13
+ const updateView = () => machine.enqueueActions(
14
+ ({ enqueue, event, context, self }) => {
15
+ if (event.type !== "update.view") {
16
+ console.warn(`Ignoring unexpected event type: ${event.type} in action 'update.view'`);
17
+ return;
95
18
  }
96
- }
97
- });
98
- const focused = machine.createStateConfig({
99
- entry: [
100
- focusOnNodesAndEdges(),
101
- xstateActions_cjsExports.assign((s) => ({
102
- viewportBeforeFocus: { ...s.context.viewport }
103
- })),
104
- openSourceOfFocusedOrLastClickedNode(),
105
- xstateActions_cjsExports.spawnChild("hotkeyActorLogic", { id: "hotkey" }),
106
- xyflow.fitFocusedBounds()
107
- ],
108
- exit: xstateActions_cjsExports.enqueueActions(({ enqueue, context }) => {
109
- enqueue.stopChild("hotkey");
110
- if (context.viewportBeforeFocus) {
111
- enqueue(xyflow.setViewport({ viewport: context.viewportBeforeFocus }));
112
- } else {
113
- enqueue.raise({ type: "fitDiagram" }, { id: "fitDiagram", delay: 20 });
19
+ const nextView = event.view;
20
+ const isAnotherView = nextView.id !== context.view.id;
21
+ if (isAnotherView) {
22
+ console.warn("updateView called for another view - ignoring", { event });
23
+ return;
114
24
  }
115
- enqueue(undimEverything());
116
- enqueue.assign({
117
- viewportBeforeFocus: null,
118
- focusedNode: null
119
- });
120
- }),
121
- on: {
122
- "xyflow.nodeClick": [
123
- {
124
- guard: xstateGuards_cjsExports.and([
125
- "click: focused node",
126
- "click: node has modelFqn"
127
- ]),
128
- actions: [
129
- openElementDetails(),
130
- emitNodeClick()
131
- ]
132
- },
133
- {
134
- guard: "click: focused node",
135
- actions: emitNodeClick(),
136
- target: "#idle"
137
- },
138
- {
139
- actions: [
140
- assignLastClickedNode(),
141
- xstateActions_cjsExports.raise(({ event }) => ({
142
- type: "focus.node",
143
- nodeId: event.node.id
144
- })),
145
- emitNodeClick()
146
- ]
147
- }
148
- ],
149
- "focus.node": {
150
- actions: [
151
- assignFocusedNode(),
152
- focusOnNodesAndEdges(),
153
- openSourceOfFocusedOrLastClickedNode(),
154
- xyflow.fitFocusedBounds()
155
- ]
156
- },
157
- "key.esc": {
158
- target: "idle"
159
- },
160
- "xyflow.paneClick": {
161
- actions: [
162
- resetLastClickedNode(),
163
- emitPaneClick()
164
- ],
165
- target: "idle"
166
- },
167
- "notations.unhighlight": {
168
- actions: focusOnNodesAndEdges()
169
- },
170
- "tag.unhighlight": {
171
- actions: focusOnNodesAndEdges()
25
+ enqueue(updateXYNodesEdges());
26
+ if (event.source === "internal") {
27
+ return;
172
28
  }
173
- }
174
- });
175
- const walkthrough = machine.createStateConfig({
176
- entry: [
177
- xstateActions_cjsExports.spawnChild("hotkeyActorLogic", { id: "hotkey" }),
178
- xstateActions_cjsExports.assign({
179
- viewportBeforeFocus: ({ context }) => context.viewport,
180
- activeWalkthrough: ({ context, event }) => {
181
- assertEvent(event, "walkthrough.start");
182
- const stepId = event.stepId ?? first(context.xyedges).id;
183
- return {
184
- stepId,
185
- parallelPrefix: getParallelStepsPrefix(stepId)
186
- };
29
+ enqueue(sendSynced());
30
+ let recenter = !context.viewportChangedManually;
31
+ if (context.toggledFeatures.enableCompareWithLatest === true && context.view._layout !== nextView._layout) {
32
+ if (nextView._layout === "auto" && context.viewportOnAutoLayout) {
33
+ enqueue(
34
+ setViewport({
35
+ viewport: context.viewportOnAutoLayout,
36
+ duration: 0
37
+ })
38
+ );
39
+ return;
40
+ }
41
+ if (nextView._layout === "manual" && context.viewportOnManualLayout) {
42
+ enqueue(
43
+ setViewport({
44
+ viewport: context.viewportOnManualLayout,
45
+ duration: 0
46
+ })
47
+ );
48
+ return;
187
49
  }
188
- }),
189
- updateActiveWalkthroughState(),
190
- xyflow.fitFocusedBounds(),
191
- emitWalkthroughStarted()
192
- ],
193
- exit: xstateActions_cjsExports.enqueueActions(({ enqueue, context }) => {
194
- enqueue.stopChild("hotkey");
195
- if (context.viewportBeforeFocus) {
196
- enqueue(xyflow.setViewport({ viewport: context.viewportBeforeFocus }));
197
- } else {
198
- enqueue(raiseFitDiagram({ delay: 10 }));
199
- }
200
- if (context.dynamicViewVariant === "sequence" && context.activeWalkthrough?.parallelPrefix) {
201
- enqueue.assign({
202
- xynodes: context.xynodes.map((n) => {
203
- if (n.type === "seq-parallel") {
204
- return Base.setData(n, {
205
- color: SeqParallelAreaColor.default
206
- });
207
- }
208
- return n;
209
- })
210
- });
211
50
  }
212
- enqueue(undimEverything());
213
- enqueue.assign({
214
- activeWalkthrough: null,
215
- viewportBeforeFocus: null
216
- });
217
- enqueue(emitWalkthroughStopped());
218
- }),
219
- on: {
220
- "key.esc": {
221
- target: "idle"
222
- },
223
- "key.arrow.left": {
224
- actions: xstateActions_cjsExports.raise({ type: "walkthrough.step", direction: "previous" })
225
- },
226
- "key.arrow.right": {
227
- actions: xstateActions_cjsExports.raise({ type: "walkthrough.step", direction: "next" })
228
- },
229
- "walkthrough.step": {
230
- actions: [
231
- xstateActions_cjsExports.assign(({ context, event }) => {
232
- const { stepId } = context.activeWalkthrough;
233
- const stepIndex = context.xyedges.findIndex((e) => e.id === stepId);
234
- const nextStepIndex = clamp(event.direction === "next" ? stepIndex + 1 : stepIndex - 1, {
235
- min: 0,
236
- max: context.xyedges.length - 1
237
- });
238
- if (nextStepIndex === stepIndex) {
239
- return {};
240
- }
241
- const nextStepId = context.xyedges[nextStepIndex].id;
242
- return {
243
- activeWalkthrough: {
244
- stepId: nextStepId,
245
- parallelPrefix: getParallelStepsPrefix(nextStepId)
246
- }
247
- };
248
- }),
249
- updateActiveWalkthroughState(),
250
- xyflow.fitFocusedBounds(),
251
- emitWalkthroughStep()
252
- ]
253
- },
254
- "xyflow.edgeClick": {
255
- actions: [
256
- xstateActions_cjsExports.assign(({ event, context }) => {
257
- if (!isStepEdgeId(event.edge.id) || event.edge.id === context.activeWalkthrough?.stepId) {
258
- return {};
259
- }
260
- return {
261
- activeWalkthrough: {
262
- stepId: event.edge.id,
263
- parallelPrefix: getParallelStepsPrefix(event.edge.id)
264
- }
265
- };
266
- }),
267
- updateActiveWalkthroughState(),
268
- xyflow.fitFocusedBounds(),
269
- emitEdgeClick(),
270
- emitWalkthroughStep()
271
- ]
272
- },
273
- "notations.unhighlight": {
274
- actions: updateActiveWalkthroughState()
275
- },
276
- "tag.unhighlight": {
277
- actions: updateActiveWalkthroughState()
278
- },
279
- "walkthrough.end": {
280
- target: "idle"
281
- },
282
- "xyflow.paneDblClick": {
283
- target: "idle"
284
- },
285
- // We received another view, close overlay and process event again
286
- "update.view": {
287
- guard: "is another view",
288
- actions: xstateActions_cjsExports.raise(({ event }) => event, { delay: 50 }),
289
- target: "idle"
51
+ recenter = recenter || nextView._type === "dynamic" && context.view._type === "dynamic" && nextView.variant !== context.view.variant;
52
+ recenter = recenter || context.toggledFeatures.enableCompareWithLatest === true && !!nextView._layout && context.view._layout !== nextView._layout;
53
+ if (recenter) {
54
+ enqueue(cancelFitDiagram());
55
+ const nextViewport = calcViewportForBounds(
56
+ context,
57
+ event.view.bounds
58
+ );
59
+ let zoom = Math.min(nextViewport.zoom, context.viewport.zoom);
60
+ const center = BBox.center(event.view.bounds);
61
+ context.xyflow.setCenter(
62
+ Math.round(center.x),
63
+ Math.round(center.y),
64
+ { zoom }
65
+ );
66
+ enqueue(raiseFitDiagram());
290
67
  }
291
68
  }
292
- });
69
+ );
293
70
  const ready = machine.createStateConfig({
294
71
  initial: "idle",
72
+ entry: [
73
+ xstateActions_cjsExports.spawnChild("mediaPrintActorLogic", { id: "mediaPrint" }),
74
+ ensureSyncLayoutActor(),
75
+ ensureOverlaysActor(),
76
+ ensureSearchActor()
77
+ ],
78
+ exit: [
79
+ cancelFitDiagram(),
80
+ xstateActions_cjsExports.stopChild("mediaPrint"),
81
+ closeAllOverlays(),
82
+ closeSearch(),
83
+ stopSyncLayout()
84
+ ],
85
+ states: {
86
+ idle,
87
+ focused,
88
+ walkthrough,
89
+ printing
90
+ },
295
91
  on: {
296
- "navigate.to": {
297
- guard: "is another view",
298
- actions: xstateActions_cjsExports.assign({
299
- lastOnNavigate: ({ context, event }) => ({
300
- fromView: context.view.id,
301
- toView: event.viewId,
302
- fromNode: event.fromNode ?? null
303
- })
304
- }),
305
- target: navigating
306
- },
307
- "navigate.back": {
308
- guard: ({ context }) => context.navigationHistory.currentIndex > 0,
309
- actions: xstateActions_cjsExports.assign(navigateBack),
310
- target: navigating
311
- },
312
- "navigate.forward": {
313
- guard: ({ context }) => context.navigationHistory.currentIndex < context.navigationHistory.history.length - 1,
314
- actions: xstateActions_cjsExports.assign(navigateForward),
315
- target: navigating
92
+ "navigate.*": {
93
+ actions: handleNavigate()
316
94
  },
317
95
  "layout.align": {
318
96
  guard: "not readonly",
@@ -325,7 +103,7 @@ const ready = machine.createStateConfig({
325
103
  "layout.resetEdgeControlPoints": {
326
104
  guard: "not readonly",
327
105
  actions: [
328
- startEditing("node"),
106
+ startEditing("edge"),
329
107
  resetEdgesControlPoints(),
330
108
  stopEditing(true)
331
109
  ]
@@ -335,13 +113,13 @@ const ready = machine.createStateConfig({
335
113
  actions: [
336
114
  stopSyncLayout(),
337
115
  disableCompareWithLatest(),
338
- ensureSyncLayout(),
339
116
  xstateActions_cjsExports.emit({
340
117
  type: "onChange",
341
118
  change: {
342
119
  op: "reset-manual-layout"
343
120
  }
344
- })
121
+ }),
122
+ ensureSyncLayoutActor()
345
123
  ]
346
124
  },
347
125
  "xyflow.resized": {
@@ -376,16 +154,25 @@ const ready = machine.createStateConfig({
376
154
  }))
377
155
  },
378
156
  "open.source": {
157
+ guard: "enabled: OpenSource",
379
158
  actions: emitOpenSource()
380
159
  },
381
160
  "walkthrough.start": {
382
161
  guard: "is dynamic view",
383
- target: ".walkthrough"
162
+ target: targetState.walkthrough
384
163
  },
385
164
  "toggle.feature": {
386
165
  actions: [
387
- toggleFeature(),
388
- ensureSyncLayout()
166
+ assignToggledFeatures(),
167
+ ensureSyncLayoutActor()
168
+ ]
169
+ },
170
+ "update.features": {
171
+ actions: [
172
+ updateFeatures(),
173
+ ensureOverlaysActor(),
174
+ ensureSearchActor(),
175
+ ensureSyncLayoutActor()
389
176
  ]
390
177
  },
391
178
  "xyflow.nodeMouseEnter": {
@@ -401,8 +188,15 @@ const ready = machine.createStateConfig({
401
188
  actions: onEdgeMouseLeave()
402
189
  },
403
190
  "xyflow.edgeDoubleClick": {
404
- guard: "not readonly",
405
- actions: onEdgeDoubleClick()
191
+ guard: xstateGuards_cjsExports.and([
192
+ "not readonly",
193
+ ({ event }) => !!event.edge.data.controlPoints && event.edge.data.controlPoints.length > 0
194
+ ]),
195
+ actions: [
196
+ startEditing("edge"),
197
+ onEdgeDoubleClick(),
198
+ stopEditing(true)
199
+ ]
406
200
  },
407
201
  "notations.highlight": {
408
202
  actions: notationsHighlight()
@@ -422,16 +216,47 @@ const ready = machine.createStateConfig({
422
216
  type: "open",
423
217
  search: event.search
424
218
  }))
219
+ },
220
+ "xyflow.paneClick": {
221
+ actions: [
222
+ resetLastClickedNode(),
223
+ emitPaneClick()
224
+ ]
225
+ },
226
+ "xyflow.nodeClick": {
227
+ actions: [
228
+ assignLastClickedNode(),
229
+ emitNodeClick()
230
+ ]
231
+ },
232
+ "xyflow.edgeClick": {
233
+ actions: [
234
+ resetLastClickedNode(),
235
+ emitEdgeClick()
236
+ ]
237
+ },
238
+ "xyflow.fitDiagram": {
239
+ guard: "enabled: FitView",
240
+ actions: fitDiagram()
241
+ },
242
+ "xyflow.setViewport": {
243
+ actions: setViewport()
244
+ },
245
+ "update.view": [
246
+ // Redirect to navigating state if received another view
247
+ {
248
+ guard: "is another view",
249
+ target: targetState.navigating
250
+ },
251
+ // Otherwise, just update the view in place
252
+ {
253
+ actions: updateView()
254
+ }
255
+ ],
256
+ "media.print.on": {
257
+ target: targetState.printing
425
258
  }
426
- },
427
- exit: [
428
- cancelFitDiagram()
429
- ],
430
- states: {
431
- idle,
432
- focused,
433
- walkthrough
434
259
  }
435
260
  });
436
261
 
437
- export { focused, idle, ready, walkthrough };
262
+ export { ready };
@@ -0,0 +1,128 @@
1
+ import { CancelAction, ActionFunction, Values, LogAction } from 'xstate';
2
+ import { Context, Events, EmittedEvents } from './machine.setup';
3
+ import { SyncLayoutActorLogic } from './syncManualLayoutActor';
4
+ import { HotkeyActorLogic } from './hotkeyActor';
5
+ import { OverlaysActorLogic } from '../../overlays/overlaysActor';
6
+ import { SearchActorLogic } from '../../search/searchActor';
7
+ import { MediaPrintActorLogic } from './mediaPrintActor';
8
+ /**
9
+ * State when the diagram is being prepared for printing.
10
+ * Adjusts the viewport to fit the entire diagram for optimal printing.
11
+ * Restores the previous viewport upon exiting the state.
12
+ */
13
+ export declare const printing: {
14
+ id: string;
15
+ entry: CancelAction<Context, Events, undefined, Events>[];
16
+ exit: ActionFunction<Context, Events, Events, undefined, Values<{
17
+ syncManualLayoutActorLogic: {
18
+ src: "syncManualLayoutActorLogic";
19
+ logic: SyncLayoutActorLogic;
20
+ id: "syncLayout";
21
+ };
22
+ hotkeyActorLogic: {
23
+ src: "hotkeyActorLogic";
24
+ logic: HotkeyActorLogic;
25
+ id: "hotkey";
26
+ };
27
+ overlaysActorLogic: {
28
+ src: "overlaysActorLogic";
29
+ logic: OverlaysActorLogic;
30
+ id: "overlays";
31
+ };
32
+ searchActorLogic: {
33
+ src: "searchActorLogic";
34
+ logic: SearchActorLogic;
35
+ id: "search";
36
+ };
37
+ mediaPrintActorLogic: {
38
+ src: "mediaPrintActorLogic";
39
+ logic: MediaPrintActorLogic;
40
+ id: "mediaPrint";
41
+ };
42
+ }>, never, Values<{
43
+ isReady: {
44
+ type: "isReady";
45
+ params: unknown;
46
+ };
47
+ "enabled: FitView": {
48
+ type: "enabled: FitView";
49
+ params: unknown;
50
+ };
51
+ "enabled: FocusMode": {
52
+ type: "enabled: FocusMode";
53
+ params: unknown;
54
+ };
55
+ "enabled: Readonly": {
56
+ type: "enabled: Readonly";
57
+ params: unknown;
58
+ };
59
+ "enabled: RelationshipDetails": {
60
+ type: "enabled: RelationshipDetails";
61
+ params: unknown;
62
+ };
63
+ "enabled: Search": {
64
+ type: "enabled: Search";
65
+ params: unknown;
66
+ };
67
+ "enabled: ElementDetails": {
68
+ type: "enabled: ElementDetails";
69
+ params: unknown;
70
+ };
71
+ "enabled: OpenSource": {
72
+ type: "enabled: OpenSource";
73
+ params: unknown;
74
+ };
75
+ "enabled: DynamicViewWalkthrough": {
76
+ type: "enabled: DynamicViewWalkthrough";
77
+ params: unknown;
78
+ };
79
+ "enabled: Overlays": {
80
+ type: "enabled: Overlays";
81
+ params: unknown;
82
+ };
83
+ "not readonly": {
84
+ type: "not readonly";
85
+ params: unknown;
86
+ };
87
+ "is dynamic view": {
88
+ type: "is dynamic view";
89
+ params: unknown;
90
+ };
91
+ "is another view": {
92
+ type: "is another view";
93
+ params: unknown;
94
+ };
95
+ "click: node has modelFqn": {
96
+ type: "click: node has modelFqn";
97
+ params: unknown;
98
+ };
99
+ "click: selected node": {
100
+ type: "click: selected node";
101
+ params: unknown;
102
+ };
103
+ "click: same node": {
104
+ type: "click: same node";
105
+ params: unknown;
106
+ };
107
+ "click: focused node": {
108
+ type: "click: focused node";
109
+ params: unknown;
110
+ };
111
+ "click: node has connections": {
112
+ type: "click: node has connections";
113
+ params: unknown;
114
+ };
115
+ "click: selected edge": {
116
+ type: "click: selected edge";
117
+ params: unknown;
118
+ };
119
+ }>, never, EmittedEvents>[];
120
+ on: {
121
+ 'media.print.off': {
122
+ target: string;
123
+ };
124
+ '*': {
125
+ actions: LogAction<Context, Events, undefined, Events>[];
126
+ };
127
+ };
128
+ };
@@ -0,0 +1,40 @@
1
+ import { log, enqueueActions } from 'xstate';
2
+ import { machine, targetState } from './machine.setup.js';
3
+ import { returnViewportBefore, cancelFitDiagram, assignViewportBefore, setViewport } from './machine.actions.layout.js';
4
+
5
+ const printing = machine.createStateConfig({
6
+ id: targetState.printing.slice(1),
7
+ entry: [
8
+ cancelFitDiagram(),
9
+ assignViewportBefore(),
10
+ enqueueActions(({ enqueue, context }) => {
11
+ const bounds = context.view.bounds;
12
+ const OFFSET = 16;
13
+ enqueue(
14
+ setViewport({
15
+ viewport: {
16
+ x: bounds.x + OFFSET,
17
+ y: bounds.y + OFFSET,
18
+ zoom: 1
19
+ },
20
+ duration: 0
21
+ })
22
+ );
23
+ })
24
+ ],
25
+ exit: [
26
+ returnViewportBefore({ delay: 0, duration: 0 })
27
+ ],
28
+ on: {
29
+ "media.print.off": {
30
+ target: targetState.idle
31
+ },
32
+ "*": {
33
+ actions: [
34
+ log(({ event }) => `Printing state - ignoring event: ${event.type}`)
35
+ ]
36
+ }
37
+ }
38
+ });
39
+
40
+ export { printing };