@likec4/diagram 1.31.0 → 1.32.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-BBzMXzCg.js → chunk-BvTQaUYl.js} +1675 -1207
- package/bundle/custom.js +50 -47
- package/bundle/index.js +2482 -2438
- package/dist/LikeC4CustomColors.d.ts +2 -7
- package/dist/LikeC4CustomColors.js +17 -6
- package/dist/LikeC4Diagram.d.ts +3 -2
- package/dist/LikeC4Diagram.js +10 -14
- package/dist/LikeC4Diagram.props.d.ts +28 -22
- package/dist/LikeC4ModelProvider.d.ts +5 -4
- package/dist/StaticLikeC4Diagram.d.ts +3 -2
- package/dist/StaticLikeC4Diagram.js +2 -2
- package/dist/base/BaseXYFlow.js +5 -5
- package/dist/base/const.d.ts +1 -1
- package/dist/base/const.js +1 -1
- package/dist/base/index.d.ts +2 -1
- package/dist/base/primitives/compound/CompoundActionButton.js +2 -1
- package/dist/base/primitives/compound/CompoundDetailsButton.js +2 -1
- package/dist/base/primitives/compound/CompoundTitle.d.ts +1 -1
- package/dist/base/primitives/compound/CompoundTitle.js +2 -1
- package/dist/base/primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base/primitives/edge/EdgeLabel.css.js +1 -0
- package/dist/base/primitives/edge/EdgeLabel.d.ts +3 -3
- package/dist/base/primitives/edge/EdgeLabel.js +6 -4
- package/dist/base/primitives/edge/EdgeLabelContainer.d.ts +1 -1
- package/dist/base/primitives/edge/EdgeMarkers.d.ts +1 -1
- package/dist/base/primitives/edge/EdgePath.d.ts +1 -1
- package/dist/base/primitives/element/ElementActionButtons.js +10 -9
- package/dist/base/primitives/element/ElementDetailsButton.js +2 -1
- package/dist/base/primitives/element/ElementShape.d.ts +1 -1
- package/dist/base/primitives/element/ElementTags.d.ts +14 -0
- package/dist/base/primitives/element/ElementTags.js +176 -0
- package/dist/base/primitives/element/ElementTitle.d.ts +5 -4
- package/dist/base/primitives/element/ElementTitle.js +6 -6
- package/dist/base/primitives/index.d.ts +1 -0
- package/dist/base/types.Base.d.ts +54 -0
- package/dist/base/types.Base.js +48 -0
- package/dist/base/types.d.ts +2 -52
- package/dist/bundle/LikeC4View.d.ts +2 -1
- package/dist/bundle/LikeC4View.js +8 -6
- package/dist/bundle/LikeC4View.props.d.ts +15 -4
- package/dist/bundle/ReactLikeC4.d.ts +4 -7
- package/dist/bundle/ReactLikeC4.js +3 -2
- package/dist/bundle/index.js +1 -1
- package/dist/components/ErrorFallback.d.ts +2 -0
- package/dist/components/ErrorFallback.js +29 -0
- package/dist/context/DiagramEventHandlers.d.ts +6 -5
- package/dist/context/DiagramFeatures.d.ts +2 -2
- package/dist/context/DiagramFeatures.js +3 -31
- package/dist/context/EnsureMantine.js +1 -1
- package/dist/context/IconRenderer.js +1 -4
- package/dist/context/RootContainer.js +5 -1
- package/dist/context/TagStylesContext.d.ts +7 -0
- package/dist/context/TagStylesContext.js +85 -0
- package/dist/custom/components.d.ts +1 -1
- package/dist/custom/customNodes.d.ts +27 -17
- package/dist/custom/hooks.d.ts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useDiagram.d.ts +73 -38
- package/dist/hooks/useDiagram.js +7 -3
- package/dist/hooks/useMantinePortalProps.d.ts +2 -2
- package/dist/hooks/useSearchActor.d.ts +2 -0
- package/dist/hooks/useSearchActor.js +10 -0
- package/dist/hooks/useUpdateEffect.js +3 -0
- package/dist/hooks/useXYFlow.d.ts +39 -37
- package/dist/hooks/useXYFlow.js +5 -1
- package/dist/index.js +1 -1
- package/dist/likec4diagram/DiagramUI.js +7 -2
- package/dist/likec4diagram/DiagramXYFlow.d.ts +4 -3
- package/dist/likec4diagram/DiagramXYFlow.js +104 -107
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +7 -6
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +8 -0
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +7 -5
- package/dist/likec4diagram/custom/index.d.ts +7 -6
- package/dist/likec4diagram/custom/nodes/nodes.js +39 -26
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +3 -3
- package/dist/likec4diagram/types.d.ts +5 -5
- package/dist/likec4diagram/ui/controls/Controls.js +12 -4
- package/dist/likec4diagram/ui/notation/NotationPanel.js +1 -1
- package/dist/likec4diagram/useViewToNodesEdges.d.ts +5 -3
- package/dist/likec4diagram/useViewToNodesEdges.js +20 -30
- package/dist/likec4model/LikeC4ModelContext.d.ts +2 -2
- package/dist/likec4model/useLikeC4ElementsTree.js +1 -1
- package/dist/likec4model/useLikeC4Model.d.ts +22 -10
- package/dist/likec4model/useLikeC4Model.js +11 -7
- package/dist/overlays/Overlays.js +4 -27
- package/dist/overlays/element-details/ElementDetailsCard.d.ts +1 -1
- package/dist/overlays/element-details/ElementDetailsCard.js +19 -12
- package/dist/overlays/element-details/TabPanelDeployments.d.ts +1 -1
- package/dist/overlays/element-details/TabPanelDeployments.js +1 -1
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +1 -1
- package/dist/overlays/element-details/TabPanelStructure.d.ts +1 -1
- package/dist/overlays/element-details/actor.d.ts +288 -286
- package/dist/overlays/overlay/Overlay.css.d.ts +57 -2
- package/dist/overlays/overlay/Overlay.css.js +76 -39
- package/dist/overlays/overlay/Overlay.d.ts +12 -0
- package/dist/overlays/overlay/Overlay.js +36 -25
- package/dist/overlays/overlaysActor.d.ts +1 -1
- package/dist/overlays/relationship-details/RelationshipDetails.d.ts +3 -2
- package/dist/overlays/relationship-details/RelationshipDetails.js +3 -3
- package/dist/overlays/relationship-details/_types.d.ts +2 -2
- package/dist/overlays/relationship-details/actor.js +7 -7
- package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +3 -2
- package/dist/overlays/relationship-details/custom/nodeTypes.js +4 -0
- package/dist/overlays/relationship-details/hooks.d.ts +10 -9
- package/dist/overlays/relationship-details/layout-to-xyflow.js +1 -0
- package/dist/overlays/relationship-details/layout.js +3 -1
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +3 -2
- package/dist/overlays/relationships-browser/SelectElement.js +1 -1
- package/dist/overlays/relationships-browser/_types.d.ts +2 -2
- package/dist/overlays/relationships-browser/actor.d.ts +1 -1
- package/dist/overlays/relationships-browser/actor.js +7 -7
- package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +3 -2
- package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +8 -5
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +4 -0
- package/dist/overlays/relationships-browser/layout.d.ts +2 -2
- package/dist/overlays/relationships-browser/layout.js +10 -6
- package/dist/overlays/relationships-browser/useViewToNodesEdges.js +4 -3
- package/dist/search/Search.d.ts +5 -0
- package/dist/search/Search.js +192 -0
- package/dist/{likec4diagram/ui/search → search/components}/ElementsColumn.css.js +0 -1
- package/dist/search/components/ElementsColumn.d.ts +2 -0
- package/dist/{likec4diagram/ui/search → search/components}/ElementsColumn.js +21 -19
- package/dist/search/components/PickView.d.ts +4 -0
- package/dist/search/components/PickView.js +135 -0
- package/dist/search/components/SearchByTags.d.ts +1 -0
- package/dist/search/components/SearchByTags.js +116 -0
- package/dist/search/components/SearchInput.d.ts +2 -0
- package/dist/{likec4diagram/ui/search → search/components}/SearchInput.js +53 -34
- package/dist/{likec4diagram/ui/search → search/components}/ViewsColum.d.ts +3 -2
- package/dist/{likec4diagram/ui/search → search/components}/ViewsColum.js +14 -13
- package/dist/{likec4diagram/ui/search → search/components}/_shared.css.js +26 -35
- package/dist/{likec4diagram/ui/search/LikeC4Search.css.d.ts → search/components/styles.css.d.ts} +0 -2
- package/dist/search/components/styles.css.js +60 -0
- package/dist/{likec4diagram/ui/search → search/components}/utils.d.ts +1 -0
- package/dist/{likec4diagram/ui/search → search/components}/utils.js +7 -1
- package/dist/search/hooks.d.ts +16 -0
- package/dist/search/hooks.js +35 -0
- package/dist/search/searchActor.d.ts +90 -0
- package/dist/search/searchActor.js +75 -0
- package/dist/state/DiagramActorProvider.d.ts +9 -7
- package/dist/state/DiagramActorProvider.js +24 -18
- package/dist/state/assign.d.ts +0 -1
- package/dist/state/assign.js +9 -19
- package/dist/state/diagram-machine.d.ts +430 -176
- package/dist/state/diagram-machine.js +119 -54
- package/dist/state/syncManualLayoutActor.d.ts +2 -2
- package/dist/state/types.d.ts +2 -0
- package/dist/state/utils.d.ts +2 -0
- package/dist/state/utils.js +3 -0
- 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/package.json +18 -18
- package/panda.buildinfo.json +171 -148
- package/src/LikeC4CustomColors.tsx +21 -6
- package/src/LikeC4Diagram.props.ts +35 -30
- package/src/LikeC4Diagram.tsx +19 -20
- package/src/LikeC4ModelProvider.tsx +6 -5
- package/src/StaticLikeC4Diagram.tsx +8 -6
- package/src/base/const.ts +1 -1
- package/src/base/index.ts +2 -1
- package/src/base/primitives/compound/CompoundActionButton.tsx +2 -1
- package/src/base/primitives/compound/CompoundDetailsButton.tsx +2 -1
- package/src/base/primitives/compound/CompoundTitle.tsx +3 -2
- package/src/base/primitives/edge/EdgeContainer.tsx +2 -1
- package/src/base/primitives/edge/EdgeLabel.css.ts +1 -0
- package/src/base/primitives/edge/EdgeLabel.tsx +20 -15
- package/src/base/primitives/edge/EdgeLabelContainer.tsx +1 -1
- package/src/base/primitives/edge/EdgeMarkers.tsx +2 -1
- package/src/base/primitives/edge/EdgePath.tsx +1 -1
- package/src/base/primitives/element/ElementActionButtons.tsx +11 -10
- package/src/base/primitives/element/ElementDetailsButton.tsx +2 -1
- package/src/base/primitives/element/ElementShape.tsx +2 -1
- package/src/base/primitives/element/ElementTags.tsx +182 -0
- package/src/base/primitives/element/ElementTitle.tsx +21 -15
- package/src/base/primitives/index.ts +1 -0
- package/src/base/types.Base.ts +104 -0
- package/src/base/types.ts +2 -99
- package/src/bundle/LikeC4View.props.ts +17 -4
- package/src/bundle/LikeC4View.tsx +17 -19
- package/src/bundle/ReactLikeC4.tsx +14 -26
- package/src/components/ErrorFallback.tsx +30 -0
- package/src/context/DiagramEventHandlers.tsx +5 -4
- package/src/context/DiagramFeatures.tsx +3 -22
- package/src/context/EnsureMantine.tsx +1 -1
- package/src/context/IconRenderer.tsx +1 -4
- package/src/context/RootContainer.tsx +9 -3
- package/src/context/TagStylesContext.tsx +96 -0
- package/src/custom/components.ts +2 -0
- package/src/custom/customNodes.tsx +24 -14
- package/src/custom/hooks.ts +1 -0
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useCurrentViewId.ts +1 -4
- package/src/hooks/useDiagram.ts +104 -12
- package/src/hooks/useMantinePortalProps.ts +10 -1
- package/src/hooks/useSearchActor.ts +11 -0
- package/src/hooks/useUpdateEffect.ts +7 -4
- package/src/hooks/useXYFlow.ts +5 -0
- package/src/likec4diagram/DiagramUI.tsx +5 -0
- package/src/likec4diagram/DiagramXYFlow.tsx +115 -118
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +9 -0
- package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +10 -9
- package/src/likec4diagram/custom/nodes/nodes.tsx +45 -43
- package/src/likec4diagram/custom/nodes/toolbar/_shared.tsx +11 -3
- package/src/likec4diagram/types.ts +5 -3
- package/src/likec4diagram/ui/controls/Controls.tsx +11 -4
- package/src/likec4diagram/ui/notation/NotationPanel.tsx +2 -2
- package/src/likec4diagram/useViewToNodesEdges.ts +34 -36
- package/src/likec4model/LikeC4ModelContext.ts +2 -2
- package/src/likec4model/useLikeC4ElementsTree.ts +1 -1
- package/src/likec4model/useLikeC4Model.ts +18 -16
- package/src/overlays/Overlays.tsx +5 -32
- package/src/overlays/element-details/ElementDetailsCard.tsx +25 -18
- package/src/overlays/element-details/TabPanelDeployments.tsx +3 -2
- package/src/overlays/element-details/TabPanelRelationships.tsx +2 -1
- package/src/overlays/element-details/TabPanelStructure.tsx +1 -1
- package/src/overlays/element-details/actor.ts +2 -2
- package/src/overlays/overlay/Overlay.css.ts +75 -38
- package/src/overlays/overlay/Overlay.tsx +43 -26
- package/src/overlays/overlaysActor.ts +1 -1
- package/src/overlays/relationship-details/RelationshipDetails.tsx +4 -4
- package/src/overlays/relationship-details/_types.ts +2 -1
- package/src/overlays/relationship-details/custom/nodeTypes.tsx +4 -0
- package/src/overlays/relationship-details/layout-to-xyflow.ts +1 -0
- package/src/overlays/relationship-details/layout.ts +3 -1
- package/src/overlays/relationships-browser/SelectElement.tsx +1 -1
- package/src/overlays/relationships-browser/_types.ts +2 -1
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +4 -0
- package/src/overlays/relationships-browser/layout.ts +12 -7
- package/src/overlays/relationships-browser/useViewToNodesEdges.ts +4 -4
- package/src/search/Search.tsx +237 -0
- package/src/{likec4diagram/ui/search → search/components}/ElementsColumn.css.ts +0 -29
- package/src/{likec4diagram/ui/search → search/components}/ElementsColumn.tsx +24 -22
- package/src/search/components/PickView.tsx +140 -0
- package/src/search/components/SearchByTags.tsx +109 -0
- package/src/{likec4diagram/ui/search → search/components}/SearchInput.tsx +63 -36
- package/src/{likec4diagram/ui/search → search/components}/ViewsColum.tsx +17 -18
- package/src/{likec4diagram/ui/search → search/components}/_shared.css.ts +26 -37
- package/src/{likec4diagram/ui/search/LikeC4Search.css.ts → search/components/styles.css.ts} +9 -36
- package/src/{likec4diagram/ui/search → search/components}/utils.ts +7 -0
- package/src/search/hooks.ts +41 -0
- package/src/search/searchActor.ts +99 -0
- package/src/state/DiagramActorProvider.tsx +36 -25
- package/src/state/assign.ts +10 -10
- package/src/state/diagram-machine.ts +115 -52
- package/src/state/syncManualLayoutActor.ts +1 -1
- package/src/state/types.ts +2 -0
- package/src/state/utils.ts +4 -0
- package/dist/base/types.js +0 -54
- package/dist/likec4diagram/ui/search/ElementsColumn.d.ts +0 -1
- package/dist/likec4diagram/ui/search/LikeC4Search.css.js +0 -87
- package/dist/likec4diagram/ui/search/LikeC4Search.d.ts +0 -2
- package/dist/likec4diagram/ui/search/LikeC4Search.js +0 -267
- package/dist/likec4diagram/ui/search/SearchInput.d.ts +0 -1
- package/dist/likec4diagram/ui/search/state.d.ts +0 -19
- package/dist/likec4diagram/ui/search/state.js +0 -63
- package/src/likec4diagram/ui/search/LikeC4Search.tsx +0 -301
- package/src/likec4diagram/ui/search/state.ts +0 -78
- /package/dist/{likec4diagram/ui/search → search/components}/ElementsColumn.css.d.ts +0 -0
- /package/dist/{likec4diagram/ui/search → search/components}/ViewsColumn.css.d.ts +0 -0
- /package/dist/{likec4diagram/ui/search → search/components}/ViewsColumn.css.js +0 -0
- /package/dist/{likec4diagram/ui/search → search/components}/_shared.css.d.ts +0 -0
- /package/src/{likec4diagram/ui/search → search/components}/ViewsColumn.css.ts +0 -0
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { nonNullable, invariant,
|
|
1
|
+
import { nonNullable, invariant, nonexhaustive, BBox, 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';
|
|
5
5
|
import { setup, assign, enqueueActions, sendTo, assertEvent, cancel, stopChild, raise, spawnChild, and, or } from 'xstate';
|
|
6
6
|
import { MinZoom } from '../base/const.js';
|
|
7
|
-
import { Base } from '../base/types.js';
|
|
8
7
|
import { AllDisabled } from '../context/DiagramFeatures.js';
|
|
9
8
|
import { createLayoutConstraints } from '../likec4diagram/useLayoutConstraints.js';
|
|
10
9
|
import { overlaysActorLogic } from '../overlays/overlaysActor.js';
|
|
10
|
+
import { searchActorLogic } from '../search/searchActor.js';
|
|
11
11
|
import { getAligner, toNodeRect } from './aligners.js';
|
|
12
|
-
import { lastClickedNode, updateNavigationHistory, mergeXYNodesEdges, updateEdgeData, updateNodeData,
|
|
12
|
+
import { updateActiveWalkthrough, focusNodesEdges, lastClickedNode, updateNavigationHistory, mergeXYNodesEdges, updateEdgeData, updateNodeData, resetEdgeControlPoints, navigateForward, navigateBack } from './assign.js';
|
|
13
13
|
import { hotkeyActorLogic } from './hotkeyActor.js';
|
|
14
14
|
import { DiagramToggledFeaturesPersistence } from './persistence.js';
|
|
15
15
|
import { syncManualLayoutActorLogic } from './syncManualLayoutActor.js';
|
|
16
16
|
import { findDiagramNode, typedSystem, focusedBounds } from './utils.js';
|
|
17
|
+
import { setData, setDimmed, setHovered } from '../base/types.Base.js';
|
|
17
18
|
|
|
18
19
|
const _diagramMachine = setup({
|
|
19
20
|
types: {
|
|
@@ -25,7 +26,8 @@ const _diagramMachine = setup({
|
|
|
25
26
|
actors: {
|
|
26
27
|
syncManualLayoutActorLogic,
|
|
27
28
|
hotkeyActorLogic,
|
|
28
|
-
overlaysActorLogic
|
|
29
|
+
overlaysActorLogic,
|
|
30
|
+
searchActorLogic
|
|
29
31
|
},
|
|
30
32
|
guards: {
|
|
31
33
|
"isReady": ({ context }) => context.initialized.xydata && context.initialized.xyflow,
|
|
@@ -33,8 +35,9 @@ const _diagramMachine = setup({
|
|
|
33
35
|
"enabled: FocusMode": ({ context }) => context.features.enableFocusMode,
|
|
34
36
|
"enabled: Readonly": ({ context }) => context.features.enableReadOnly,
|
|
35
37
|
"enabled: RelationshipDetails": ({ context }) => context.features.enableRelationshipDetails,
|
|
38
|
+
"enabled: Search": ({ context }) => context.features.enableSearch,
|
|
36
39
|
"not readonly": ({ context }) => !context.features.enableReadOnly,
|
|
37
|
-
"is dynamic view": ({ context }) => context.view.
|
|
40
|
+
"is dynamic view": ({ context }) => context.view._type === "dynamic",
|
|
38
41
|
"is another view": ({ context, event }) => {
|
|
39
42
|
assertEvent(event, ["update.view", "navigate.to"]);
|
|
40
43
|
if (event.type === "update.view") {
|
|
@@ -84,10 +87,10 @@ const _diagramMachine = setup({
|
|
|
84
87
|
if (!nodeId || !context.features.enableVscode) return;
|
|
85
88
|
const diagramNode = findDiagramNode(context, nodeId);
|
|
86
89
|
if (!diagramNode) return;
|
|
87
|
-
if (
|
|
88
|
-
enqueue.raise({ type: "open.source", deployment:
|
|
89
|
-
} else if (
|
|
90
|
-
enqueue.raise({ type: "open.source", element:
|
|
90
|
+
if (diagramNode.deploymentRef) {
|
|
91
|
+
enqueue.raise({ type: "open.source", deployment: diagramNode.deploymentRef });
|
|
92
|
+
} else if (diagramNode.modelRef) {
|
|
93
|
+
enqueue.raise({ type: "open.source", element: diagramNode.modelRef });
|
|
91
94
|
}
|
|
92
95
|
}),
|
|
93
96
|
"xyflow:fitDiagram": ({ context }, params) => {
|
|
@@ -95,7 +98,7 @@ const _diagramMachine = setup({
|
|
|
95
98
|
bounds = context.view.bounds,
|
|
96
99
|
duration = 450
|
|
97
100
|
} = params ?? {};
|
|
98
|
-
const { width, height, panZoom, transform } = context.xystore.getState();
|
|
101
|
+
const { width, height, panZoom, transform } = nonNullable(context.xystore).getState();
|
|
99
102
|
const maxZoom = Math.max(1, transform[2]);
|
|
100
103
|
const viewport = getViewportForBounds(
|
|
101
104
|
bounds,
|
|
@@ -111,7 +114,7 @@ const _diagramMachine = setup({
|
|
|
111
114
|
},
|
|
112
115
|
"xyflow:fitFocusedBounds": ({ context }) => {
|
|
113
116
|
const { bounds, duration = 450 } = focusedBounds({ context });
|
|
114
|
-
const { width, height, panZoom, transform } = context.xystore.getState();
|
|
117
|
+
const { width, height, panZoom, transform } = nonNullable(context.xystore).getState();
|
|
115
118
|
const maxZoom = Math.max(1, transform[2]);
|
|
116
119
|
const viewport = getViewportForBounds(
|
|
117
120
|
bounds,
|
|
@@ -136,7 +139,7 @@ const _diagramMachine = setup({
|
|
|
136
139
|
viewport,
|
|
137
140
|
duration = 350
|
|
138
141
|
} = params;
|
|
139
|
-
const
|
|
142
|
+
const panZoom = context.xystore?.getState().panZoom;
|
|
140
143
|
panZoom?.setViewport(viewport, duration > 0 ? { duration } : void 0);
|
|
141
144
|
},
|
|
142
145
|
"xyflow:alignNodeFromToAfterNavigate": ({ context }, params) => {
|
|
@@ -156,7 +159,7 @@ const _diagramMachine = setup({
|
|
|
156
159
|
},
|
|
157
160
|
"layout.align": ({ context }, params) => {
|
|
158
161
|
const { mode } = params;
|
|
159
|
-
const
|
|
162
|
+
const xystore = nonNullable(context.xystore, "xystore is not initialized");
|
|
160
163
|
const { nodeLookup, parentLookup } = xystore.getState();
|
|
161
164
|
const selectedNodes = new Set(nodeLookup.values().filter((n) => n.selected).map((n) => n.id));
|
|
162
165
|
const nodesToAlign = [...selectedNodes.difference(new Set(parentLookup.keys()))];
|
|
@@ -179,12 +182,7 @@ const _diagramMachine = setup({
|
|
|
179
182
|
}
|
|
180
183
|
constraints.updateXYFlowNodes();
|
|
181
184
|
},
|
|
182
|
-
"
|
|
183
|
-
assertEvent(event, "update.features");
|
|
184
|
-
const { features } = event;
|
|
185
|
-
enqueue.assign({
|
|
186
|
-
features: { ...features }
|
|
187
|
-
});
|
|
185
|
+
"ensure overlays actor state": enqueueActions(({ enqueue, context: { features }, system }) => {
|
|
188
186
|
const enableOverlays = features.enableElementDetails || features.enableRelationshipDetails || features.enableRelationshipBrowser;
|
|
189
187
|
const hasRunning = typedSystem(system).overlaysActorRef;
|
|
190
188
|
if (enableOverlays && !hasRunning) {
|
|
@@ -198,6 +196,31 @@ const _diagramMachine = setup({
|
|
|
198
196
|
enqueue.stopChild("overlays");
|
|
199
197
|
}
|
|
200
198
|
}),
|
|
199
|
+
"ensure search actor state": enqueueActions(({ enqueue, context: { features: { enableSearch } }, system }) => {
|
|
200
|
+
const hasRunning = typedSystem(system).searchActorRef;
|
|
201
|
+
if (enableSearch && !hasRunning) {
|
|
202
|
+
enqueue.spawnChild("searchActorLogic", { id: "search", systemId: "search" });
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (!enableSearch && hasRunning) {
|
|
206
|
+
enqueue.sendTo(hasRunning, {
|
|
207
|
+
type: "close"
|
|
208
|
+
});
|
|
209
|
+
enqueue.stopChild("search");
|
|
210
|
+
}
|
|
211
|
+
}),
|
|
212
|
+
"updateFeatures": assign(({ event }) => {
|
|
213
|
+
assertEvent(event, "update.features");
|
|
214
|
+
return {
|
|
215
|
+
features: { ...event.features }
|
|
216
|
+
};
|
|
217
|
+
}),
|
|
218
|
+
"closeSearch": sendTo(
|
|
219
|
+
({ system }) => typedSystem(system).searchActorRef,
|
|
220
|
+
{
|
|
221
|
+
type: "close"
|
|
222
|
+
}
|
|
223
|
+
),
|
|
201
224
|
"closeAllOverlays": sendTo(
|
|
202
225
|
({ system }) => typedSystem(system).overlaysActorRef,
|
|
203
226
|
{
|
|
@@ -221,7 +244,7 @@ const _diagramMachine = setup({
|
|
|
221
244
|
return {
|
|
222
245
|
xynodes: context.xynodes.map((n) => {
|
|
223
246
|
if (n.id === params.node.id) {
|
|
224
|
-
return
|
|
247
|
+
return setHovered(n, true);
|
|
225
248
|
}
|
|
226
249
|
return n;
|
|
227
250
|
})
|
|
@@ -231,7 +254,7 @@ const _diagramMachine = setup({
|
|
|
231
254
|
return {
|
|
232
255
|
xynodes: context.xynodes.map((n) => {
|
|
233
256
|
if (n.id === params.node.id) {
|
|
234
|
-
return
|
|
257
|
+
return setHovered(n, false);
|
|
235
258
|
}
|
|
236
259
|
return n;
|
|
237
260
|
})
|
|
@@ -241,7 +264,7 @@ const _diagramMachine = setup({
|
|
|
241
264
|
return {
|
|
242
265
|
xyedges: context.xyedges.map((e) => {
|
|
243
266
|
if (e.id === params.edge.id) {
|
|
244
|
-
return
|
|
267
|
+
return setHovered(e, true);
|
|
245
268
|
}
|
|
246
269
|
return e;
|
|
247
270
|
})
|
|
@@ -251,30 +274,50 @@ const _diagramMachine = setup({
|
|
|
251
274
|
return {
|
|
252
275
|
xyedges: context.xyedges.map((e) => {
|
|
253
276
|
if (e.id === params.edge.id) {
|
|
254
|
-
return
|
|
277
|
+
return setHovered(e, false);
|
|
255
278
|
}
|
|
256
279
|
return e;
|
|
257
280
|
})
|
|
258
281
|
};
|
|
259
282
|
}),
|
|
283
|
+
"focus on nodes and edges": assign(focusNodesEdges),
|
|
260
284
|
"notations.highlight": assign(({ context }, params) => {
|
|
261
285
|
const kinds = params.kind ? [params.kind] : params.notation.kinds;
|
|
262
286
|
const xynodes = context.xynodes.map((n) => {
|
|
263
287
|
const node = findDiagramNode(context, n.id);
|
|
264
288
|
if (node && node.notation === params.notation.title && node.shape === params.notation.shape && node.color === params.notation.color && kinds.includes(node.kind)) {
|
|
265
|
-
return
|
|
289
|
+
return setDimmed(n, false);
|
|
266
290
|
}
|
|
267
|
-
return
|
|
291
|
+
return setDimmed(n, "immediate");
|
|
268
292
|
});
|
|
269
293
|
return {
|
|
270
294
|
xynodes,
|
|
271
|
-
xyedges: context.xyedges.map(
|
|
295
|
+
xyedges: context.xyedges.map(setDimmed("immediate"))
|
|
272
296
|
};
|
|
273
|
-
})
|
|
297
|
+
}),
|
|
298
|
+
"tag.highlight": assign(({ context, event }) => {
|
|
299
|
+
assertEvent(event, "tag.highlight");
|
|
300
|
+
return {
|
|
301
|
+
xynodes: context.xynodes.map((n) => {
|
|
302
|
+
if (n.data.tags?.includes(event.tag)) {
|
|
303
|
+
return setDimmed(n, false);
|
|
304
|
+
}
|
|
305
|
+
return setDimmed(n, "immediate");
|
|
306
|
+
})
|
|
307
|
+
};
|
|
308
|
+
}),
|
|
309
|
+
"undim everything": assign(({ context }) => ({
|
|
310
|
+
xynodes: context.xynodes.map(setDimmed(false)),
|
|
311
|
+
xyedges: context.xyedges.map(setData({
|
|
312
|
+
dimmed: false,
|
|
313
|
+
active: false
|
|
314
|
+
}))
|
|
315
|
+
})),
|
|
316
|
+
"update active walkthrough": assign(updateActiveWalkthrough)
|
|
274
317
|
}
|
|
275
318
|
}).createMachine({
|
|
276
319
|
initial: "initializing",
|
|
277
|
-
context: ({ input
|
|
320
|
+
context: ({ input }) => ({
|
|
278
321
|
...input,
|
|
279
322
|
xyedges: [],
|
|
280
323
|
xynodes: [],
|
|
@@ -329,7 +372,7 @@ const _diagramMachine = setup({
|
|
|
329
372
|
}
|
|
330
373
|
}
|
|
331
374
|
},
|
|
332
|
-
|
|
375
|
+
isReady: {
|
|
333
376
|
always: [{
|
|
334
377
|
guard: "isReady",
|
|
335
378
|
actions: [
|
|
@@ -405,8 +448,8 @@ const _diagramMachine = setup({
|
|
|
405
448
|
"open.elementDetails": {
|
|
406
449
|
actions: sendTo(({ system }) => typedSystem(system).overlaysActorRef, ({ context, event }) => {
|
|
407
450
|
let initiatedFrom = null;
|
|
408
|
-
const fromNodeId = event.fromNode ?? context.view.nodes.find((n) =>
|
|
409
|
-
const internalNode = fromNodeId ? context.xystore.getState().nodeLookup.get(fromNodeId) : null;
|
|
451
|
+
const fromNodeId = event.fromNode ?? context.view.nodes.find((n) => n.modelRef === event.fqn)?.id;
|
|
452
|
+
const internalNode = fromNodeId ? nonNullable(context.xystore).getState().nodeLookup.get(fromNodeId) : null;
|
|
410
453
|
if (fromNodeId && internalNode) {
|
|
411
454
|
const nodeRect = nodeToRect(internalNode);
|
|
412
455
|
const zoom = context.xyflow.getZoom();
|
|
@@ -497,10 +540,13 @@ const _diagramMachine = setup({
|
|
|
497
540
|
}
|
|
498
541
|
},
|
|
499
542
|
"notations.unhighlight": {
|
|
500
|
-
actions:
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
543
|
+
actions: "undim everything"
|
|
544
|
+
},
|
|
545
|
+
"tag.highlight": {
|
|
546
|
+
actions: "tag.highlight"
|
|
547
|
+
},
|
|
548
|
+
"tag.unhighlight": {
|
|
549
|
+
actions: "undim everything"
|
|
504
550
|
},
|
|
505
551
|
"saveManualLayout.*": {
|
|
506
552
|
guard: "not readonly",
|
|
@@ -513,6 +559,13 @@ const _diagramMachine = setup({
|
|
|
513
559
|
}
|
|
514
560
|
nonexhaustive(event);
|
|
515
561
|
})
|
|
562
|
+
},
|
|
563
|
+
"open.search": {
|
|
564
|
+
guard: "enabled: Search",
|
|
565
|
+
actions: sendTo(({ system }) => typedSystem(system).searchActorRef, ({ event }) => ({
|
|
566
|
+
type: "open",
|
|
567
|
+
search: event.search
|
|
568
|
+
}))
|
|
516
569
|
}
|
|
517
570
|
},
|
|
518
571
|
exit: [
|
|
@@ -592,8 +645,8 @@ const _diagramMachine = setup({
|
|
|
592
645
|
},
|
|
593
646
|
focused: {
|
|
594
647
|
entry: [
|
|
648
|
+
"focus on nodes and edges",
|
|
595
649
|
assign((s) => ({
|
|
596
|
-
...focusNodesEdges(s),
|
|
597
650
|
viewportBeforeFocus: { ...s.context.viewport }
|
|
598
651
|
})),
|
|
599
652
|
"open source of focused or last clicked node",
|
|
@@ -605,10 +658,10 @@ const _diagramMachine = setup({
|
|
|
605
658
|
if (context.viewportBeforeFocus) {
|
|
606
659
|
enqueue({ type: "xyflow:setViewport", params: { viewport: context.viewportBeforeFocus } });
|
|
607
660
|
} else {
|
|
608
|
-
enqueue(
|
|
661
|
+
enqueue("xyflow:fitDiagram");
|
|
609
662
|
}
|
|
663
|
+
enqueue("undim everything");
|
|
610
664
|
enqueue.assign({
|
|
611
|
-
...unfocusNodesEdges({ context}),
|
|
612
665
|
viewportBeforeFocus: null,
|
|
613
666
|
focusedNode: null
|
|
614
667
|
});
|
|
@@ -636,7 +689,7 @@ const _diagramMachine = setup({
|
|
|
636
689
|
assign({
|
|
637
690
|
focusedNode: ({ event }) => event.nodeId
|
|
638
691
|
}),
|
|
639
|
-
|
|
692
|
+
"focus on nodes and edges",
|
|
640
693
|
"open source of focused or last clicked node",
|
|
641
694
|
"xyflow:fitFocusedBounds"
|
|
642
695
|
]
|
|
@@ -651,9 +704,10 @@ const _diagramMachine = setup({
|
|
|
651
704
|
target: "idle"
|
|
652
705
|
},
|
|
653
706
|
"notations.unhighlight": {
|
|
654
|
-
actions:
|
|
655
|
-
|
|
656
|
-
|
|
707
|
+
actions: "focus on nodes and edges"
|
|
708
|
+
},
|
|
709
|
+
"tag.unhighlight": {
|
|
710
|
+
actions: "focus on nodes and edges"
|
|
657
711
|
}
|
|
658
712
|
}
|
|
659
713
|
},
|
|
@@ -671,7 +725,7 @@ const _diagramMachine = setup({
|
|
|
671
725
|
};
|
|
672
726
|
}
|
|
673
727
|
}),
|
|
674
|
-
|
|
728
|
+
"update active walkthrough",
|
|
675
729
|
"xyflow:fitFocusedBounds"
|
|
676
730
|
],
|
|
677
731
|
on: {
|
|
@@ -702,7 +756,7 @@ const _diagramMachine = setup({
|
|
|
702
756
|
parallelPrefix: getParallelStepsPrefix(nextStepId)
|
|
703
757
|
}
|
|
704
758
|
});
|
|
705
|
-
enqueue
|
|
759
|
+
enqueue("update active walkthrough");
|
|
706
760
|
enqueue("xyflow:fitFocusedBounds");
|
|
707
761
|
})
|
|
708
762
|
},
|
|
@@ -719,14 +773,15 @@ const _diagramMachine = setup({
|
|
|
719
773
|
}
|
|
720
774
|
};
|
|
721
775
|
}),
|
|
722
|
-
|
|
776
|
+
"update active walkthrough",
|
|
723
777
|
"xyflow:fitFocusedBounds"
|
|
724
778
|
]
|
|
725
779
|
},
|
|
726
780
|
"notations.unhighlight": {
|
|
727
|
-
actions:
|
|
728
|
-
|
|
729
|
-
|
|
781
|
+
actions: "update active walkthrough"
|
|
782
|
+
},
|
|
783
|
+
"tag.unhighlight": {
|
|
784
|
+
actions: "update active walkthrough"
|
|
730
785
|
},
|
|
731
786
|
"walkthrough.end": {
|
|
732
787
|
target: "idle"
|
|
@@ -746,11 +801,11 @@ const _diagramMachine = setup({
|
|
|
746
801
|
if (context.viewportBeforeFocus) {
|
|
747
802
|
enqueue({ type: "xyflow:setViewport", params: { viewport: context.viewportBeforeFocus } });
|
|
748
803
|
} else {
|
|
749
|
-
enqueue(
|
|
804
|
+
enqueue("xyflow:fitDiagram");
|
|
750
805
|
}
|
|
806
|
+
enqueue("undim everything");
|
|
751
807
|
enqueue.assign({
|
|
752
808
|
activeWalkthrough: null,
|
|
753
|
-
...unfocusNodesEdges({ context}),
|
|
754
809
|
viewportBeforeFocus: null
|
|
755
810
|
});
|
|
756
811
|
})
|
|
@@ -762,6 +817,7 @@ const _diagramMachine = setup({
|
|
|
762
817
|
id: "navigating",
|
|
763
818
|
entry: [
|
|
764
819
|
"closeAllOverlays",
|
|
820
|
+
"closeSearch",
|
|
765
821
|
"stopSyncLayout",
|
|
766
822
|
{
|
|
767
823
|
type: "trigger:NavigateTo",
|
|
@@ -788,7 +844,7 @@ const _diagramMachine = setup({
|
|
|
788
844
|
} else {
|
|
789
845
|
enqueue({
|
|
790
846
|
type: "xyflow:setViewportCenter",
|
|
791
|
-
params:
|
|
847
|
+
params: BBox.center(event.view.bounds)
|
|
792
848
|
});
|
|
793
849
|
}
|
|
794
850
|
enqueue.assign(updateNavigationHistory);
|
|
@@ -841,6 +897,7 @@ const _diagramMachine = setup({
|
|
|
841
897
|
const isAnotherView = check("is another view");
|
|
842
898
|
if (isAnotherView) {
|
|
843
899
|
enqueue("closeAllOverlays");
|
|
900
|
+
enqueue("closeSearch");
|
|
844
901
|
enqueue("stopSyncLayout");
|
|
845
902
|
enqueue.assign({
|
|
846
903
|
focusedNode: null
|
|
@@ -861,7 +918,7 @@ const _diagramMachine = setup({
|
|
|
861
918
|
} else {
|
|
862
919
|
enqueue({
|
|
863
920
|
type: "xyflow:setViewportCenter",
|
|
864
|
-
params:
|
|
921
|
+
params: BBox.center(event.view.bounds)
|
|
865
922
|
});
|
|
866
923
|
enqueue.raise({ type: "fitDiagram", duration: 200 }, { id: "fitDiagram", delay: 25 });
|
|
867
924
|
}
|
|
@@ -885,13 +942,19 @@ const _diagramMachine = setup({
|
|
|
885
942
|
actions: assign(({ event }) => ({ ...event.inputs }))
|
|
886
943
|
},
|
|
887
944
|
"update.features": {
|
|
888
|
-
actions:
|
|
945
|
+
actions: [
|
|
946
|
+
"updateFeatures",
|
|
947
|
+
"ensure overlays actor state",
|
|
948
|
+
"ensure search actor state"
|
|
949
|
+
]
|
|
889
950
|
}
|
|
890
951
|
},
|
|
891
952
|
exit: [
|
|
892
953
|
"stopSyncLayout",
|
|
893
954
|
cancel("fitDiagram"),
|
|
894
955
|
stopChild("hotkey"),
|
|
956
|
+
stopChild("overlays"),
|
|
957
|
+
stopChild("search"),
|
|
895
958
|
assign({
|
|
896
959
|
xyflow: null,
|
|
897
960
|
xystore: null,
|
|
@@ -905,7 +968,9 @@ const _diagramMachine = setup({
|
|
|
905
968
|
})
|
|
906
969
|
]
|
|
907
970
|
});
|
|
908
|
-
|
|
971
|
+
function nodeRef(node) {
|
|
972
|
+
return node.modelRef ?? node.deploymentRef;
|
|
973
|
+
}
|
|
909
974
|
function findCorrespondingNode(context, event) {
|
|
910
975
|
const fromNodeId = context.lastOnNavigate?.fromNode;
|
|
911
976
|
const fromNode = fromNodeId && context.view.nodes.find((n) => n.id === fromNodeId);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ViewChange, ViewId } from '@likec4/core';
|
|
1
|
+
import { ViewChange, ViewId } from '@likec4/core/types';
|
|
2
2
|
import { ActorLogicFrom, ActorRef, MachineSnapshot, StateMachine, NonReducibleUnknown, EventObject, MetaObject, ActorRefFromLogic, AnyActorLogic, ConditionalRequired, InputFrom, RequiredLogicInput, IsNotNever, AnyActorRef, StateValue, AnyEventObject, ActionFunction } from 'xstate';
|
|
3
3
|
import { Context as DiagramContext, Events as DiagramEvents } from './diagram-machine';
|
|
4
4
|
export type Input = {
|
|
@@ -27,7 +27,7 @@ declare const _syncManualLayoutActorLogic: StateMachine<Readonly<Input>, Events,
|
|
|
27
27
|
}, {
|
|
28
28
|
type: "same view";
|
|
29
29
|
params: unknown;
|
|
30
|
-
}, "timeout", "paused" | "
|
|
30
|
+
}, "timeout", "paused" | "stopped" | "synced" | "pending" | "idle", "pending" | "ready", Input, NonReducibleUnknown, EventObject, MetaObject, {
|
|
31
31
|
readonly initial: "idle";
|
|
32
32
|
readonly context: ({ input }: {
|
|
33
33
|
spawn: {
|
package/dist/state/types.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ActorRefFromLogic, ActorSystem, EventFromLogic, SnapshotFrom } from 'xstate';
|
|
2
2
|
import { OverlaysActorRef } from '../overlays/overlaysActor';
|
|
3
|
+
import { SearchActorRef } from '../search/searchActor';
|
|
3
4
|
import { DiagramMachineLogic } from './diagram-machine';
|
|
4
5
|
import { SyncLayoutActorLogic } from './syncManualLayoutActor';
|
|
5
6
|
export type System = ActorSystem<{
|
|
6
7
|
actors: {
|
|
7
8
|
diagram: ActorRefFromLogic<DiagramMachineLogic>;
|
|
8
9
|
overlays: OverlaysActorRef;
|
|
10
|
+
search: SearchActorRef;
|
|
9
11
|
};
|
|
10
12
|
}>;
|
|
11
13
|
export interface DiagramActorRef extends ActorRefFromLogic<DiagramMachineLogic> {
|
package/dist/state/utils.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BBox, DiagramEdge, DiagramNode } from '@likec4/core/types';
|
|
2
2
|
import { ActorSystem } from 'xstate';
|
|
3
3
|
import { OverlaysActorRef } from '../overlays/overlaysActor';
|
|
4
|
+
import { SearchActorRef } from '../search/searchActor';
|
|
4
5
|
import { Context } from './diagram-machine';
|
|
5
6
|
import { DiagramActorRef } from './types';
|
|
6
7
|
export declare function typedSystem(system: ActorSystem<any>): {
|
|
7
8
|
readonly overlaysActorRef: OverlaysActorRef | null;
|
|
8
9
|
readonly diagramActorRef: DiagramActorRef | null;
|
|
10
|
+
readonly searchActorRef: SearchActorRef | null;
|
|
9
11
|
};
|
|
10
12
|
export declare function findDiagramNode(ctx: Context, xynodeId: string): DiagramNode | null;
|
|
11
13
|
export declare function findDiagramEdge(ctx: Context, xyedgeId: string): DiagramEdge | null;
|