@likec4/diagram 1.28.1 → 1.29.1
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 +292 -258
- package/dist/_virtual/index.js +1 -1
- package/dist/base/primitives/customEdge.js +1 -1
- package/dist/base/primitives/edge/EdgeLabel.css.d.ts +3 -0
- package/dist/base/primitives/edge/EdgeLabel.css.js +3 -0
- package/dist/base/primitives/edge/EdgeLabel.d.ts +1 -1
- package/dist/base/primitives/edge/EdgeLabel.js +2 -1
- package/dist/components/SearchControl.css.js +8 -2
- package/dist/hooks/safeContext.d.ts +2 -5
- package/dist/hooks/safeContext.js +2 -1
- package/dist/hooks/useDiagram.d.ts +711 -146
- package/dist/likec4diagram/ui/controls/Controls.js +3 -3
- package/dist/node_modules/.pnpm/{react@19.0.0 → react@19.1.0}/node_modules/react/cjs/react.production.js +14 -6
- package/dist/overlays/element-details/ElementDetails.js +1 -1
- package/dist/state/DiagramActorProvider.js +2 -2
- package/dist/state/diagram-machine.d.ts +715 -142
- package/dist/state/diagram-machine.js +48 -6
- package/dist/styles.css.js +1 -1
- package/package.json +15 -15
- package/src/LikeC4Diagram.tsx +0 -1
- package/src/base/primitives/customEdge.ts +1 -0
- package/src/base/primitives/edge/EdgeLabel.css.ts +3 -0
- package/src/base/primitives/edge/EdgeLabel.tsx +2 -1
- package/src/components/SearchControl.css.ts +7 -1
- package/src/hooks/safeContext.tsx +3 -1
- package/src/likec4diagram/ui/controls/Controls.tsx +3 -3
- package/src/overlays/element-details/ElementDetails.tsx +2 -2
- package/src/state/DiagramActorProvider.tsx +3 -3
- package/src/state/diagram-machine.ts +48 -5
- /package/dist/node_modules/.pnpm/{react@19.0.0 → react@19.1.0}/node_modules/react/index.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { nonNullable, invariant, DiagramNode, nonexhaustive, getBBoxCenter, getParallelStepsPrefix } from '@likec4/core';
|
|
1
|
+
import { nonNullable, invariant, DiagramNode, nonexhaustive, getBBoxCenter, isStepEdgeId, getParallelStepsPrefix } from '@likec4/core';
|
|
2
2
|
import { getViewportForBounds, applyEdgeChanges, applyNodeChanges } from '@xyflow/react';
|
|
3
3
|
import { nodeToRect } from '@xyflow/system';
|
|
4
4
|
import { hasAtLeast, prop, clamp, first } from 'remeda';
|
|
@@ -32,6 +32,7 @@ const diagramMachine = setup({
|
|
|
32
32
|
"enabled: FitView": ({ context }) => context.features.enableFitView,
|
|
33
33
|
"enabled: FocusMode": ({ context }) => context.features.enableFocusMode,
|
|
34
34
|
"enabled: Readonly": ({ context }) => context.features.enableReadOnly,
|
|
35
|
+
"enabled: RelationshipDetails": ({ context }) => context.features.enableRelationshipDetails,
|
|
35
36
|
"not readonly": ({ context }) => !context.features.enableReadOnly,
|
|
36
37
|
"is dynamic view": ({ context }) => context.view.__ === "dynamic",
|
|
37
38
|
"is another view": ({ context, event }) => {
|
|
@@ -59,6 +60,10 @@ const diagramMachine = setup({
|
|
|
59
60
|
"click: node has connections": ({ context, event }) => {
|
|
60
61
|
assertEvent(event, "xyflow.nodeClick");
|
|
61
62
|
return context.xyedges.some((e) => e.source === event.node.id || e.target === event.node.id);
|
|
63
|
+
},
|
|
64
|
+
"click: selected edge": ({ event }) => {
|
|
65
|
+
assertEvent(event, "xyflow.edgeClick");
|
|
66
|
+
return event.edge.selected === true || event.edge.data.active === true;
|
|
62
67
|
}
|
|
63
68
|
},
|
|
64
69
|
actions: {
|
|
@@ -562,7 +567,27 @@ const diagramMachine = setup({
|
|
|
562
567
|
focusedNode: ({ event }) => event.nodeId
|
|
563
568
|
}),
|
|
564
569
|
target: "focused"
|
|
565
|
-
}
|
|
570
|
+
},
|
|
571
|
+
"xyflow.edgeClick": [{
|
|
572
|
+
guard: and([
|
|
573
|
+
"is dynamic view",
|
|
574
|
+
"click: selected edge"
|
|
575
|
+
]),
|
|
576
|
+
actions: raise(({ event }) => ({
|
|
577
|
+
type: "walkthrough.start",
|
|
578
|
+
stepId: event.edge.id
|
|
579
|
+
}))
|
|
580
|
+
}, {
|
|
581
|
+
guard: and([
|
|
582
|
+
"enabled: RelationshipDetails",
|
|
583
|
+
"click: selected edge"
|
|
584
|
+
]),
|
|
585
|
+
actions: sendTo(({ system }) => typedSystem(system).overlaysActorRef, ({ context, event }) => ({
|
|
586
|
+
type: "open.relationshipDetails",
|
|
587
|
+
viewId: context.view.id,
|
|
588
|
+
edgeId: event.edge.id
|
|
589
|
+
}))
|
|
590
|
+
}]
|
|
566
591
|
}
|
|
567
592
|
},
|
|
568
593
|
focused: {
|
|
@@ -575,18 +600,18 @@ const diagramMachine = setup({
|
|
|
575
600
|
spawnChild("hotkeyActorLogic", { id: "hotkey" }),
|
|
576
601
|
"xyflow:fitFocusedBounds"
|
|
577
602
|
],
|
|
578
|
-
exit: enqueueActions(({ enqueue, context }) => {
|
|
603
|
+
exit: enqueueActions(({ enqueue, context, event }) => {
|
|
579
604
|
enqueue.stopChild("hotkey");
|
|
580
605
|
if (context.viewportBeforeFocus) {
|
|
581
606
|
enqueue({ type: "xyflow:setViewport", params: { viewport: context.viewportBeforeFocus } });
|
|
582
607
|
} else {
|
|
583
608
|
enqueue({ type: "xyflow:fitDiagram" });
|
|
584
609
|
}
|
|
585
|
-
enqueue.assign(
|
|
586
|
-
...unfocusNodesEdges(
|
|
610
|
+
enqueue.assign({
|
|
611
|
+
...unfocusNodesEdges({ context}),
|
|
587
612
|
viewportBeforeFocus: null,
|
|
588
613
|
focusedNode: null
|
|
589
|
-
})
|
|
614
|
+
});
|
|
590
615
|
}),
|
|
591
616
|
on: {
|
|
592
617
|
"xyflow.nodeClick": [
|
|
@@ -681,6 +706,23 @@ const diagramMachine = setup({
|
|
|
681
706
|
enqueue("xyflow:fitFocusedBounds");
|
|
682
707
|
})
|
|
683
708
|
},
|
|
709
|
+
"xyflow.edgeClick": {
|
|
710
|
+
actions: [
|
|
711
|
+
assign(({ event, context }) => {
|
|
712
|
+
if (!isStepEdgeId(event.edge.id) || event.edge.id === context.activeWalkthrough?.stepId) {
|
|
713
|
+
return {};
|
|
714
|
+
}
|
|
715
|
+
return {
|
|
716
|
+
activeWalkthrough: {
|
|
717
|
+
stepId: event.edge.id,
|
|
718
|
+
parallelPrefix: getParallelStepsPrefix(event.edge.id)
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
}),
|
|
722
|
+
assign(updateActiveWalkthrough),
|
|
723
|
+
"xyflow:fitFocusedBounds"
|
|
724
|
+
]
|
|
725
|
+
},
|
|
684
726
|
"notations.unhighlight": {
|
|
685
727
|
actions: assign((s) => ({
|
|
686
728
|
...updateActiveWalkthrough(s)
|