@likec4/diagram 1.58.0 → 1.59.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/dist/LikeC4Diagram.js +1 -1
- package/dist/LikeC4Diagram.props.d.ts +1 -1
- package/dist/LikeC4Styles.js +1 -1
- package/dist/LikeC4View.js +2 -2
- package/dist/ReactLikeC4.d.ts +1 -1
- package/dist/base/Base.d.ts +3 -2
- package/dist/base/Base.js +14 -26
- package/dist/base/BaseXYFlow.d.ts +2 -1
- package/dist/base/BaseXYFlow.js +63 -4
- package/dist/base/keyboardZoom.d.ts +3 -0
- package/dist/base/keyboardZoom.js +20 -0
- package/dist/base/updateEdges.js +7 -16
- package/dist/base/updateNodes.js +3 -9
- package/dist/base-primitives/compound/CompoundActionButton.d.ts +2 -1
- package/dist/base-primitives/compound/CompoundActionButton.js +5 -2
- package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +2 -1
- package/dist/base-primitives/compound/CompoundDetailsButton.js +5 -2
- package/dist/base-primitives/compound/CompoundTitle.d.ts +7 -1
- package/dist/base-primitives/compound/CompoundTitle.js +2 -1
- package/dist/base-primitives/compound/actionbtns.css.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeActionButton.d.ts +2 -1
- package/dist/base-primitives/edge/EdgeActionButton.js +2 -1
- package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeContainer.js +4 -2
- package/dist/base-primitives/edge/EdgeLabel.d.ts +2 -0
- package/dist/base-primitives/edge/EdgeLabel.js +2 -5
- package/dist/base-primitives/element/ElementActionButtons.d.ts +1 -0
- package/dist/base-primitives/element/ElementActionButtons.js +4 -1
- package/dist/base-primitives/element/ElementData.d.ts +3 -1
- package/dist/base-primitives/element/ElementData.js +2 -1
- package/dist/base-primitives/element/ElementDetailsButton.d.ts +2 -1
- package/dist/base-primitives/element/ElementDetailsButton.js +5 -2
- package/dist/base-primitives/element/ElementNodeContainer.js +1 -1
- package/dist/base-primitives/element/ElementShape.js +3 -0
- package/dist/components/ErrorFallback.js +3 -5
- package/dist/components/Link.js +6 -6
- package/dist/components/NavigationPanel.js +1 -1
- package/dist/components/SearchControl.css.js +11 -11
- package/dist/context/TagStylesContext.d.ts +3 -3
- package/dist/context/TagStylesContext.js +16 -16
- package/dist/custom/index.d.ts +1 -0
- package/dist/custom/index.js +3 -2
- package/dist/editor/actor/actions.js +1 -1
- package/dist/editor/actor/machine.d.ts +4 -6
- package/dist/editor/actor/setup.d.ts +16 -2
- package/dist/editor/actor/setup.js +5 -4
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/safeContext.d.ts +156 -3
- package/dist/hooks/safeContext.js +60 -12
- package/dist/hooks/useCurrentViewModel.js +1 -1
- package/dist/hooks/useDiagram.d.ts +8 -0
- package/dist/hooks/useDiagram.js +9 -2
- package/dist/hooks/useEditorActor.js +1 -1
- package/dist/hooks/useLikeC4ElementsTree.js +1 -1
- package/dist/hooks/useLikeC4Model.js +1 -1
- package/dist/hooks/useXYFlow.d.ts +1 -0
- package/dist/hooks/useXYFlow.js +5 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/likec4diagram/DiagramUI.js +19 -6
- package/dist/likec4diagram/DiagramXYFlow.js +39 -14
- package/dist/likec4diagram/convert-to-xyflow.d.ts +3 -5
- package/dist/likec4diagram/convert-to-xyflow.js +29 -10
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +13 -4
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +11 -4
- package/dist/likec4diagram/custom/edges/edges.css.js +1 -1
- package/dist/likec4diagram/custom/index.d.ts +2 -1
- package/dist/likec4diagram/custom/index.js +5 -3
- package/dist/likec4diagram/custom/nodes/CompoundActions.js +1 -0
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/ElementActions.js +13 -3
- package/dist/likec4diagram/custom/nodes/NodeNotes.js +0 -4
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +32 -19
- package/dist/likec4diagram/custom/nodes/SequenceSubFlow.d.ts +2 -0
- package/dist/likec4diagram/custom/nodes/SequenceSubFlow.js +234 -0
- package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
- package/dist/likec4diagram/custom/nodes/nodes.js +20 -5
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.js +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +1 -1
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +15 -14
- package/dist/likec4diagram/relationship-popover/components.d.ts +1 -1
- package/dist/likec4diagram/state/DiagramActorProvider.js +11 -20
- package/dist/likec4diagram/state/aligners.js +1 -1
- package/dist/likec4diagram/state/assign.d.ts +1 -1
- package/dist/likec4diagram/state/assign.js +1 -1
- package/dist/likec4diagram/state/createViewChange.js +1 -1
- package/dist/likec4diagram/state/diagram-api.d.ts +18 -10
- package/dist/likec4diagram/state/diagram-api.js +333 -229
- package/dist/likec4diagram/state/machine.actions.d.ts +1026 -332
- package/dist/likec4diagram/state/machine.actions.js +115 -44
- package/dist/likec4diagram/state/machine.actions.layout.d.ts +123 -51
- package/dist/likec4diagram/state/machine.actions.layout.js +40 -33
- package/dist/likec4diagram/state/machine.d.ts +154 -16
- package/dist/likec4diagram/state/machine.js +5 -41
- package/dist/likec4diagram/state/machine.setup.d.ts +84 -19
- package/dist/likec4diagram/state/machine.setup.js +65 -12
- package/dist/likec4diagram/state/machine.state.initializing.d.ts +59 -33
- package/dist/likec4diagram/state/machine.state.navigating.js +7 -3
- package/dist/likec4diagram/state/machine.state.ready.d.ts +1540 -476
- package/dist/likec4diagram/state/machine.state.ready.focused.d.ts +294 -53
- package/dist/likec4diagram/state/machine.state.ready.focused.js +3 -3
- package/dist/likec4diagram/state/machine.state.ready.idle.d.ts +264 -73
- package/dist/likec4diagram/state/machine.state.ready.idle.js +31 -6
- package/dist/likec4diagram/state/machine.state.ready.js +22 -16
- package/dist/likec4diagram/state/machine.state.ready.printing.d.ts +23 -9
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.d.ts +288 -84
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +135 -66
- package/dist/likec4diagram/state/types.d.ts +4 -2
- package/dist/likec4diagram/state/utils.d.ts +7 -0
- package/dist/likec4diagram/state/utils.js +36 -34
- package/dist/likec4diagram/types.d.ts +47 -3
- package/dist/likec4diagram/ui/FloatingSequenceActors.d.ts +6 -0
- package/dist/likec4diagram/ui/FloatingSequenceActors.js +155 -0
- package/dist/likec4diagram/ui/LayoutDriftFrame.js +2 -2
- package/dist/likec4diagram/ui/index.d.ts +2 -0
- package/dist/likec4diagram/ui/notation/NotationPanel.css.js +5 -5
- package/dist/likec4diagram/ui/sequence-outline/SequenceOutlinePanel.d.ts +2 -0
- package/dist/likec4diagram/ui/sequence-outline/SequenceOutlinePanel.js +519 -0
- package/dist/likec4diagram/ui/sequence-outline/state.d.ts +36 -0
- package/dist/likec4diagram/ui/sequence-outline/state.js +55 -0
- package/dist/likec4diagram/xyflow-diagram/diagram-view.d.ts +1 -1
- package/dist/likec4diagram/xyflow-diagram/diagram-view.js +112 -60
- package/dist/likec4diagram/xyflow-sequence/_types.d.ts +55 -5
- package/dist/likec4diagram/xyflow-sequence/const.d.ts +5 -5
- package/dist/likec4diagram/xyflow-sequence/const.js +4 -4
- package/dist/likec4diagram/xyflow-sequence/layouter.d.ts +30 -6
- package/dist/likec4diagram/xyflow-sequence/layouter.js +561 -0
- package/dist/likec4diagram/xyflow-sequence/{sequence-layout.d.ts → sequence-view-to-xy.d.ts} +8 -2
- package/dist/likec4diagram/xyflow-sequence/{sequence-layout.js → sequence-view-to-xy.js} +111 -14
- package/dist/likec4diagram/xyflow-sequence/sequence-view.d.ts +2 -7
- package/dist/likec4diagram/xyflow-sequence/sequence-view.js +144 -0
- package/dist/likec4diagram/xyflow-sequence/utils.d.ts +9 -1
- package/dist/likec4diagram/xyflow-sequence/utils.js +96 -0
- package/dist/navigationpanel/NavigationPanel.d.ts +5 -2
- package/dist/navigationpanel/NavigationPanel.js +58 -59
- package/dist/navigationpanel/NavigationPanelDropdown.js +45 -38
- package/dist/navigationpanel/_common.js +2 -2
- package/dist/navigationpanel/actor.actions.d.ts +19 -0
- package/dist/navigationpanel/actor.actions.js +45 -0
- package/dist/navigationpanel/actor.d.ts +34 -96
- package/dist/navigationpanel/actor.js +21 -84
- package/dist/navigationpanel/actor.setup.d.ts +98 -0
- package/dist/navigationpanel/actor.setup.js +31 -0
- package/dist/navigationpanel/comparepanel/DriftsSummary.js +4 -5
- package/dist/navigationpanel/controls/DetailsControls.js +7 -8
- package/dist/navigationpanel/dropdown/ProjectsMenu.js +1 -1
- package/dist/navigationpanel/editorpanel/styles.js +8 -8
- package/dist/navigationpanel/hooks.d.ts +20 -5
- package/dist/navigationpanel/hooks.js +4 -18
- package/dist/navigationpanel/styles.css.d.ts +1 -1
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +2 -2
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +4 -4
- package/dist/navigationpanel/walkthrough/DynamicViewControls.js +23 -25
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +5 -5
- package/dist/overlays/Overlays.d.ts +4 -2
- package/dist/overlays/Overlays.js +10 -10
- package/dist/overlays/element-details/ElementDetailsCard.css.js +17 -17
- package/dist/overlays/element-details/MetadataValue.js +15 -15
- package/dist/overlays/element-details/TabPanelDeployments.css.js +5 -5
- package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -11
- package/dist/overlays/element-details/TabPanelRelationships.js +1 -1
- package/dist/overlays/element-details/TabPanelStructure.css.js +2 -2
- package/dist/overlays/element-details/TabPanelStructure.js +1 -1
- package/dist/overlays/element-details/actor.d.ts +2 -3
- package/dist/overlays/hooks.d.ts +28 -0
- package/dist/overlays/hooks.js +5 -0
- package/dist/overlays/overlay/Overlay.js +34 -25
- package/dist/overlays/overlaysActor.js +0 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.js +1 -1
- package/dist/overlays/relationship-details/layout.js +1 -1
- package/dist/overlays/relationships-browser/SelectElement.css.js +2 -2
- package/dist/overlays/relationships-browser/actor.js +79 -78
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +1 -1
- package/dist/overlays/relationships-browser/hooks.js +1 -1
- package/dist/overlays/relationships-browser/layout.js +2 -2
- package/dist/projects-overview/actor.js +4 -4
- package/dist/search/Search.js +1 -1
- package/dist/search/components/ElementsColumn.css.js +2 -2
- package/dist/search/components/ViewsColum.js +1 -1
- package/dist/search/components/_shared.css.d.ts +1 -1
- package/dist/search/components/_shared.css.js +23 -23
- package/dist/search/components/styles.css.js +4 -4
- package/dist/shadowroot/ShadowRoot.d.ts +1 -1
- package/dist/shadowroot/ShadowRoot.js +76 -28
- package/dist/styles2.js +1 -1
- package/dist/utils/defineActors.d.ts +21 -0
- package/dist/utils/defineActors.js +13 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +5 -4
- package/dist/utils/readableText.d.ts +11 -0
- package/dist/utils/readableText.js +18 -0
- package/package.json +18 -30
- package/panda.buildinfo.json +267 -288
- package/styles-min.css +1 -1
- package/styles.css +1 -1
- package/adhoc-editor/package.json +0 -4
- package/dist/adhoc-editor/EditorPanel.d.ts +0 -1
- package/dist/adhoc-editor/EditorPanel.js +0 -106
- package/dist/adhoc-editor/ElementsTree.d.ts +0 -2
- package/dist/adhoc-editor/ElementsTree.js +0 -112
- package/dist/adhoc-editor/LikeC4AdHocViewEditor.d.ts +0 -4
- package/dist/adhoc-editor/LikeC4AdHocViewEditor.js +0 -83
- package/dist/adhoc-editor/components/Tree.d.ts +0 -48
- package/dist/adhoc-editor/components/Tree.js +0 -213
- package/dist/adhoc-editor/hooks.d.ts +0 -14
- package/dist/adhoc-editor/hooks.js +0 -34
- package/dist/adhoc-editor/index.d.ts +0 -2
- package/dist/adhoc-editor/index.js +0 -2
- package/dist/adhoc-editor/state/ActorProvider.d.ts +0 -5
- package/dist/adhoc-editor/state/ActorProvider.js +0 -37
- package/dist/adhoc-editor/state/actor.d.ts +0 -13
- package/dist/adhoc-editor/state/actor.editor.d.ts +0 -56
- package/dist/adhoc-editor/state/actor.editor.js +0 -167
- package/dist/adhoc-editor/state/actor.js +0 -14
- package/dist/adhoc-editor/state/actor.layouter.d.ts +0 -51
- package/dist/adhoc-editor/state/actor.layouter.js +0 -54
- package/dist/adhoc-editor/state/actor.types.d.ts +0 -63
- package/dist/adhoc-editor/state/actor.types.js +0 -25
- package/dist/adhoc-editor/state/panel.d.ts +0 -95
- package/dist/adhoc-editor/state/panel.js +0 -124
- package/dist/adhoc-editor/state/utils.d.ts +0 -17
- package/dist/adhoc-editor/state/utils.js +0 -25
- package/dist/adhoc-editor/useElementsTree.d.ts +0 -18
- package/dist/adhoc-editor/useElementsTree.js +0 -98
- package/dist/adhoc-editor/viewrules/ViewRulesPanel.d.ts +0 -6
- package/dist/context/ShadowRootContext.d.ts +0 -3
- package/dist/context/ShadowRootContext.js +0 -5
- package/dist/shadowroot/styles.d.ts +0 -13
- package/dist/shadowroot/styles.js +0 -60
|
@@ -1,24 +1,72 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
|
+
import { shallowEqual } from "fast-equals";
|
|
4
|
+
import { isFunction } from "remeda";
|
|
5
|
+
import { useSelector } from "@xstate/react";
|
|
6
|
+
import { invariant } from "motion";
|
|
3
7
|
//#region src/hooks/safeContext.tsx
|
|
4
|
-
/**
|
|
5
|
-
* To improve experience with HMR, we move context to separate files and use as a boundary for hooks
|
|
6
|
-
*/
|
|
7
|
-
var DiagramActorSafeContext = createContext(null);
|
|
8
|
-
DiagramActorSafeContext.displayName = "DiagramActorSafeContext";
|
|
9
8
|
var DiagramApiSafeContext = createContext(null);
|
|
10
9
|
DiagramApiSafeContext.displayName = "DiagramApiSafeContext";
|
|
11
|
-
var DiagramActorContextProvider = DiagramActorSafeContext.Provider;
|
|
12
10
|
var DiagramApiContextProvider = DiagramApiSafeContext.Provider;
|
|
13
|
-
function useDiagramActorRef() {
|
|
14
|
-
const ctx = useContext(DiagramActorSafeContext);
|
|
15
|
-
if (ctx === null) throw new Error("DiagramActorRef is not provided");
|
|
16
|
-
return ctx;
|
|
17
|
-
}
|
|
18
11
|
function useDiagram() {
|
|
19
12
|
const ctx = useContext(DiagramApiSafeContext);
|
|
20
13
|
if (ctx === null) throw new Error("DiagramApi is not provided");
|
|
21
14
|
return ctx;
|
|
22
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Helper to create a safe context for an actor
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const {
|
|
21
|
+
* ContextProvider: MyActorContext,
|
|
22
|
+
* useActorRef,
|
|
23
|
+
* selectSnapshot,
|
|
24
|
+
* useActorSelector
|
|
25
|
+
* } = createSafeContextForActor<MyActorRef>()
|
|
26
|
+
*
|
|
27
|
+
* const select = selectSnapshot(
|
|
28
|
+
* s => ....,
|
|
29
|
+
* (a, b) => a === b
|
|
30
|
+
* )
|
|
31
|
+
*
|
|
32
|
+
* // Later in component:
|
|
33
|
+
* const value = useActorSelector(select)
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
function createSafeContextForActor(name) {
|
|
37
|
+
const Ctx = createContext(null);
|
|
38
|
+
function selectSnapshot(selector, compare) {
|
|
39
|
+
return [selector, compare ?? shallowEqual];
|
|
40
|
+
}
|
|
41
|
+
function selectContext(selector, compare) {
|
|
42
|
+
return [(snapshot) => selector(snapshot.context), compare ?? shallowEqual];
|
|
43
|
+
}
|
|
44
|
+
function useActorRef() {
|
|
45
|
+
const actorRef = useContext(Ctx);
|
|
46
|
+
if (actorRef === null) throw new Error(`${name}SafeContext is not provided `);
|
|
47
|
+
return actorRef;
|
|
48
|
+
}
|
|
49
|
+
function useActorSelector(arg1, arg2) {
|
|
50
|
+
let selector;
|
|
51
|
+
let compare;
|
|
52
|
+
if (arg2 !== void 0) [selector, compare] = [arg1, arg2];
|
|
53
|
+
else if (Array.isArray(arg1)) [selector, compare] = arg1;
|
|
54
|
+
else {
|
|
55
|
+
selector = arg1;
|
|
56
|
+
compare = shallowEqual;
|
|
57
|
+
}
|
|
58
|
+
compare ??= shallowEqual;
|
|
59
|
+
invariant(isFunction(selector), "selector must be a function");
|
|
60
|
+
return useSelector(useActorRef(), selector, compare);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
ContextProvider: Ctx.Provider,
|
|
64
|
+
selectSnapshot,
|
|
65
|
+
selectContext,
|
|
66
|
+
useActorSelector,
|
|
67
|
+
useActorRef
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
var { ContextProvider: DiagramActorContextProvider, selectSnapshot: selectDiagramSnapshot, selectContext: selectDiagramContext, useActorSelector: useDiagramSelector, useActorRef: useDiagramActorRef } = createSafeContextForActor("DiagramActor");
|
|
23
71
|
//#endregion
|
|
24
|
-
export { DiagramActorContextProvider, DiagramApiContextProvider, useDiagram, useDiagramActorRef };
|
|
72
|
+
export { DiagramActorContextProvider, DiagramApiContextProvider, createSafeContextForActor, selectDiagramContext, selectDiagramSnapshot, useDiagram, useDiagramActorRef, useDiagramSelector };
|
|
@@ -6,15 +6,22 @@ export { useDiagram, useDiagramActorRef };
|
|
|
6
6
|
export type { DiagramApi, DiagramContext };
|
|
7
7
|
/**
|
|
8
8
|
* Helper to create a selector for diagram actor snapshot
|
|
9
|
+
* @deprecated use {@link selectDiagramSnapshot}
|
|
9
10
|
*/
|
|
10
11
|
export declare function selectDiagramActor<T = unknown>(selector: (state: DiagramActorSnapshot) => T): (state: DiagramActorSnapshot) => T;
|
|
12
|
+
/**
|
|
13
|
+
* Read diagram actor snapshot
|
|
14
|
+
* @deprecated use {@link useDiagramSelector}
|
|
15
|
+
*/
|
|
11
16
|
export declare function useDiagramSnapshot<T = unknown>(selector: (state: DiagramActorSnapshot) => T, compare?: (a: NoInfer<T>, b: NoInfer<T>) => boolean): T;
|
|
12
17
|
/**
|
|
13
18
|
* Helper to create a selector for diagram actor snapshot
|
|
19
|
+
* @deprecated use {@link selectDiagramContext}
|
|
14
20
|
*/
|
|
15
21
|
export declare function selectDiagramActorContext<T = unknown>(selector: (state: DiagramContext) => T): (state: DiagramActorSnapshot) => T;
|
|
16
22
|
/**
|
|
17
23
|
* Read diagram context
|
|
24
|
+
* @deprecated use {@link useDiagramSelector}
|
|
18
25
|
*/
|
|
19
26
|
export declare function useDiagramContext<T = unknown>(selector: (context: DiagramContext) => T, compare?: (a: NoInfer<T>, b: NoInfer<T>) => boolean, deps?: DependencyList): T;
|
|
20
27
|
type PickEmittedEvent<T> = T extends DiagramEmittedEvents['type'] ? DiagramEmittedEvents & {
|
|
@@ -32,3 +39,4 @@ type PickEmittedEvent<T> = T extends DiagramEmittedEvents['type'] ? DiagramEmitt
|
|
|
32
39
|
export declare function useOnDiagramEvent<T extends DiagramEmittedEvents['type'] | '*'>(event: T, callback: (event: PickEmittedEvent<T>) => void, options?: {
|
|
33
40
|
once?: boolean;
|
|
34
41
|
}): void;
|
|
42
|
+
export { selectDiagramContext, selectDiagramSnapshot, useDiagramSelector, } from './safeContext';
|
package/dist/hooks/useDiagram.js
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { useCallbackRef } from "./useCallbackRef.js";
|
|
3
|
-
import { useDiagramActorRef } from "./safeContext.js";
|
|
3
|
+
import { selectDiagramContext, selectDiagramSnapshot, useDiagram, useDiagramActorRef, useDiagramSelector } from "./safeContext.js";
|
|
4
4
|
import { useCallback, useEffect, useRef } from "react";
|
|
5
5
|
import { shallowEqual } from "fast-equals";
|
|
6
6
|
import { useSelector } from "@xstate/react";
|
|
7
7
|
//#region src/hooks/useDiagram.ts
|
|
8
8
|
/**
|
|
9
9
|
* Helper to create a selector for diagram actor snapshot
|
|
10
|
+
* @deprecated use {@link selectDiagramSnapshot}
|
|
10
11
|
*/
|
|
11
12
|
function selectDiagramActor(selector) {
|
|
12
13
|
return selector;
|
|
13
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Read diagram actor snapshot
|
|
17
|
+
* @deprecated use {@link useDiagramSelector}
|
|
18
|
+
*/
|
|
14
19
|
function useDiagramSnapshot(selector, compare = shallowEqual) {
|
|
15
20
|
return useSelector(useDiagramActorRef(), selector, compare);
|
|
16
21
|
}
|
|
17
22
|
/**
|
|
18
23
|
* Helper to create a selector for diagram actor snapshot
|
|
24
|
+
* @deprecated use {@link selectDiagramContext}
|
|
19
25
|
*/
|
|
20
26
|
function selectDiagramActorContext(selector) {
|
|
21
27
|
return (state) => selector(state.context);
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
30
|
* Read diagram context
|
|
31
|
+
* @deprecated use {@link useDiagramSelector}
|
|
25
32
|
*/
|
|
26
33
|
function useDiagramContext(selector, compare = shallowEqual, deps = []) {
|
|
27
34
|
const actorRef = useDiagramActorRef();
|
|
@@ -67,4 +74,4 @@ function useOnDiagramEvent(event, callback, options) {
|
|
|
67
74
|
]);
|
|
68
75
|
}
|
|
69
76
|
//#endregion
|
|
70
|
-
export { selectDiagramActor, selectDiagramActorContext, useDiagramContext, useDiagramSnapshot, useOnDiagramEvent };
|
|
77
|
+
export { selectDiagramActor, selectDiagramActorContext, selectDiagramContext, selectDiagramSnapshot, useDiagram, useDiagramActorRef, useDiagramContext, useDiagramSelector, useDiagramSnapshot, useOnDiagramEvent };
|
|
@@ -4,6 +4,7 @@ export type XYFlowInstance = ReactFlowInstance<Types.AnyNode, Types.AnyEdge>;
|
|
|
4
4
|
export declare function useXYFlow(): XYFlowInstance;
|
|
5
5
|
export type XYStoreState = ReactFlowState<Types.AnyNode, Types.AnyEdge>;
|
|
6
6
|
export declare function useXYStore<StateSlice = unknown>(selector: (state: XYStoreState) => StateSlice, equalityFn?: (a: NoInfer<StateSlice>, b: NoInfer<StateSlice>) => boolean): StateSlice;
|
|
7
|
+
export declare function selectXYStore<StateSlice = unknown>(selector: (state: XYStoreState) => StateSlice): (state: XYStoreState) => StateSlice;
|
|
7
8
|
export declare function useXYStoreApi(): XYStoreApi;
|
|
8
9
|
export type XYStoreApi = {
|
|
9
10
|
getState: () => XYStoreState;
|
package/dist/hooks/useXYFlow.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { useCallbackRef } from "./useCallbackRef.js";
|
|
3
2
|
import { useCallback } from "react";
|
|
4
3
|
import { useReactFlow, useStore, useStoreApi } from "@xyflow/react";
|
|
5
4
|
import { shallowEqual } from "fast-equals";
|
|
@@ -8,7 +7,10 @@ function useXYFlow() {
|
|
|
8
7
|
return useReactFlow();
|
|
9
8
|
}
|
|
10
9
|
function useXYStore(selector, equalityFn) {
|
|
11
|
-
return useStore(
|
|
10
|
+
return useStore(selector, equalityFn ?? shallowEqual);
|
|
11
|
+
}
|
|
12
|
+
function selectXYStore(selector) {
|
|
13
|
+
return selector;
|
|
12
14
|
}
|
|
13
15
|
function useXYStoreApi() {
|
|
14
16
|
return useStoreApi();
|
|
@@ -21,4 +23,4 @@ function useIsZoomTooSmall() {
|
|
|
21
23
|
return useStore(selectZoom);
|
|
22
24
|
}
|
|
23
25
|
//#endregion
|
|
24
|
-
export { useCurrentZoomAtLeast, useIsZoomTooSmall, useXYFlow, useXYStore, useXYStoreApi };
|
|
26
|
+
export { selectXYStore, useCurrentZoomAtLeast, useIsZoomTooSmall, useXYFlow, useXYStore, useXYStoreApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { LikeC4ModelProvider, type LikeC4ModelProviderProps, } from './LikeC4Mod
|
|
|
5
5
|
export { LikeC4EditorProvider, type LikeC4EditorProviderProps, } from './editor/LikeC4EditorProvider';
|
|
6
6
|
export { createLikeC4Editor, type LikeC4EditorCallbacks, } from './editor/LikeC4EditorCallbacks';
|
|
7
7
|
export { LikeC4ProjectsProvider, type LikeC4ProjectsProviderProps, } from './LikeC4ProjectsProvider';
|
|
8
|
-
export { type DiagramApi, type DiagramContext, useDiagram, useDiagramContext, useOnDiagramEvent, } from './hooks/useDiagram';
|
|
8
|
+
export { type DiagramApi, type DiagramContext, selectDiagramContext, selectDiagramSnapshot, useDiagram, useDiagramContext, useDiagramSelector, useOnDiagramEvent, } from './hooks/useDiagram';
|
|
9
9
|
export { useLikeC4Model, useLikeC4Specification, useLikeC4ViewModel, } from './hooks/useLikeC4Model';
|
|
10
10
|
export { type CurrentViewModel, useCurrentViewModel, useOptionalCurrentViewModel, } from './hooks/useCurrentViewModel';
|
|
11
11
|
export { useChangeLikeC4Project, useHasProjects, useLikeC4Project, useLikeC4ProjectId, useLikeC4Projects, useLikeC4ProjectsContext, } from './hooks/useLikeC4Project';
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { IconRendererProvider } from "./context/IconRenderer.js";
|
|
|
2
2
|
import { useUpdateEffect } from "./hooks/useUpdateEffect.js";
|
|
3
3
|
import { DefaultMantineProvider } from "./context/DefaultMantineProvider.js";
|
|
4
4
|
import { FramerMotionConfig } from "./context/FramerMotionConfig.js";
|
|
5
|
-
import { useDiagram } from "./hooks/safeContext.js";
|
|
5
|
+
import { selectDiagramContext, selectDiagramSnapshot, useDiagram, useDiagramSelector } from "./hooks/safeContext.js";
|
|
6
6
|
import { useDiagramContext, useOnDiagramEvent } from "./hooks/useDiagram.js";
|
|
7
7
|
import { useCurrentView, useCurrentViewId } from "./hooks/useCurrentView.js";
|
|
8
8
|
import { useOptionalCurrentViewModel } from "./context/LikeC4ModelContext.js";
|
|
@@ -23,4 +23,4 @@ import { LikeC4View } from "./LikeC4View.js";
|
|
|
23
23
|
import { ReactLikeC4 } from "./ReactLikeC4.js";
|
|
24
24
|
import { LikeC4ProjectsOverview } from "./LikeC4ProjectsOverview.js";
|
|
25
25
|
import { SearchControl } from "./components/SearchControl.js";
|
|
26
|
-
export { DefaultMantineProvider, FramerMotionConfig, IconRendererProvider, LikeC4Diagram, LikeC4EditorProvider, LikeC4ModelProvider, LikeC4ProjectsOverview, LikeC4ProjectsProvider, LikeC4View, ReactLikeC4, SearchContext, SearchControl, SearchPanelContent, StaticLikeC4Diagram, createLikeC4Editor, normalizeSearch, pickViewBounds, bodyCss as searchBodyCss, dialogCss as searchDialogCss, useChangeLikeC4Project, useCurrentView, useCurrentViewId, useCurrentViewModel, useDiagram, useDiagramContext, useHasProjects, useLikeC4Model, useLikeC4Project, useLikeC4ProjectId, useLikeC4Projects, useLikeC4ProjectsContext, useLikeC4Specification, useLikeC4Styles, useLikeC4ViewModel, useOnDiagramEvent, useOptionalCurrentViewModel, useSearchContext, useUpdateEffect };
|
|
26
|
+
export { DefaultMantineProvider, FramerMotionConfig, IconRendererProvider, LikeC4Diagram, LikeC4EditorProvider, LikeC4ModelProvider, LikeC4ProjectsOverview, LikeC4ProjectsProvider, LikeC4View, ReactLikeC4, SearchContext, SearchControl, SearchPanelContent, StaticLikeC4Diagram, createLikeC4Editor, normalizeSearch, pickViewBounds, bodyCss as searchBodyCss, dialogCss as searchDialogCss, selectDiagramContext, selectDiagramSnapshot, useChangeLikeC4Project, useCurrentView, useCurrentViewId, useCurrentViewModel, useDiagram, useDiagramContext, useDiagramSelector, useHasProjects, useLikeC4Model, useLikeC4Project, useLikeC4ProjectId, useLikeC4Projects, useLikeC4ProjectsContext, useLikeC4Specification, useLikeC4Styles, useLikeC4ViewModel, useOnDiagramEvent, useOptionalCurrentViewModel, useSearchContext, useUpdateEffect };
|
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { useEnabledFeatures } from "../context/DiagramFeatures.js";
|
|
3
|
-
import {
|
|
3
|
+
import { selectDiagramSnapshot, useDiagramSelector } from "../hooks/safeContext.js";
|
|
4
4
|
import { ErrorBoundary } from "../components/ErrorFallback.js";
|
|
5
5
|
import { NavigationPanel } from "../navigationpanel/NavigationPanel.js";
|
|
6
6
|
import { Overlays } from "../overlays/Overlays.js";
|
|
7
7
|
import { Search } from "../search/Search.js";
|
|
8
8
|
import { RelationshipPopover } from "./relationship-popover/RelationshipPopover.js";
|
|
9
|
+
import { FloatingSequenceActors } from "./ui/FloatingSequenceActors.js";
|
|
9
10
|
import { LayoutDriftFrame } from "./ui/LayoutDriftFrame.js";
|
|
10
11
|
import { NotationPanel } from "./ui/notation/NotationPanel.js";
|
|
12
|
+
import { SequenceOutlinePanel } from "./ui/sequence-outline/SequenceOutlinePanel.js";
|
|
11
13
|
import { memo, useCallback } from "react";
|
|
12
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
15
|
import { useRerender } from "@react-hookz/web";
|
|
16
|
+
import { hasProp, isDynamicView } from "@likec4/core";
|
|
14
17
|
//#region src/likec4diagram/DiagramUI.tsx
|
|
15
|
-
var selectChildren =
|
|
18
|
+
var selectChildren = selectDiagramSnapshot((s) => ({
|
|
16
19
|
overlays: s.children.overlays ?? null,
|
|
17
|
-
search: s.children.search ?? null
|
|
20
|
+
search: s.children.search ?? null,
|
|
21
|
+
navigation: s.children.navigationPanel ?? null,
|
|
22
|
+
...isDynamicView(s.context.view) ? {
|
|
23
|
+
isSequenceView: s.context.dynamicViewVariant === "sequence",
|
|
24
|
+
isActiveWalkthrough: s.context.dynamicViewVariant === "sequence" && !!s.context.activeWalkthrough && hasProp(s.context.view, "flow")
|
|
25
|
+
} : {
|
|
26
|
+
isSequenceView: false,
|
|
27
|
+
hasSequenceFlow: false,
|
|
28
|
+
isActiveWalkthrough: false
|
|
29
|
+
}
|
|
18
30
|
}));
|
|
19
31
|
var LikeC4DiagramUI = memo(() => {
|
|
20
32
|
const { enableControls, enableNotations, enableSearch, enableRelationshipDetails, enableReadOnly, enableCompareWithLatest } = useEnabledFeatures();
|
|
21
33
|
const rerender = useRerender();
|
|
22
|
-
const actors =
|
|
34
|
+
const { isSequenceView, isActiveWalkthrough, ...actors } = useDiagramSelector(selectChildren);
|
|
23
35
|
return /* @__PURE__ */ jsxs(ErrorBoundary, {
|
|
24
36
|
onReset: useCallback(() => {
|
|
25
|
-
console.warn("DiagramUI: resetting error boundary and rerendering...");
|
|
26
37
|
rerender();
|
|
27
38
|
}, []),
|
|
28
39
|
children: [
|
|
29
|
-
|
|
40
|
+
isSequenceView && /* @__PURE__ */ jsx(FloatingSequenceActors, { isActiveWalkthrough }),
|
|
41
|
+
isActiveWalkthrough && /* @__PURE__ */ jsx(SequenceOutlinePanel, {}),
|
|
42
|
+
enableControls && actors.navigation && !isActiveWalkthrough && /* @__PURE__ */ jsx(NavigationPanel, { actorRef: actors.navigation }),
|
|
30
43
|
actors.overlays && /* @__PURE__ */ jsx(Overlays, { overlaysActorRef: actors.overlays }),
|
|
31
44
|
enableNotations && /* @__PURE__ */ jsx(NotationPanel, {}),
|
|
32
45
|
enableSearch && actors.search && /* @__PURE__ */ jsx(Search, { searchActorRef: actors.search }),
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import "../_virtual/_rolldown/runtime.js";
|
|
1
|
+
import { __name } from "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { useCallbackRef as useCallbackRef$1 } from "../hooks/useCallbackRef.js";
|
|
3
3
|
import { depsShallowEqual, useUpdateEffect as useUpdateEffect$1 } from "../hooks/useUpdateEffect.js";
|
|
4
|
+
import { MinZoom } from "../base/const.js";
|
|
4
5
|
import { BaseXYFlow } from "../base/BaseXYFlow.js";
|
|
5
6
|
import { useRootContainer } from "../context/RootContainerContext.js";
|
|
6
7
|
import { useDiagramEventHandlers } from "../context/DiagramEventHandlers.js";
|
|
7
|
-
import { useDiagram } from "../hooks/safeContext.js";
|
|
8
|
-
import { selectDiagramActor, useDiagramSnapshot } from "../hooks/useDiagram.js";
|
|
8
|
+
import { selectDiagramSnapshot, useDiagram, useDiagramSelector } from "../hooks/safeContext.js";
|
|
9
9
|
import { viewBounds } from "./state/utils.js";
|
|
10
10
|
import { deriveToggledFeatures } from "./state/machine.setup.js";
|
|
11
11
|
import { BuiltinEdges, BuiltinNodes } from "./custom/index.js";
|
|
12
12
|
import { useLayoutConstraints } from "./useLayoutConstraints.js";
|
|
13
13
|
import { cx } from "@likec4/styles/css";
|
|
14
|
-
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
import { useCustomCompareMemo } from "@react-hookz/web";
|
|
16
|
+
import { Controls } from "@xyflow/react";
|
|
17
|
+
import { shallowEqual } from "fast-equals";
|
|
16
18
|
import { isEmpty } from "remeda";
|
|
17
19
|
import { nonNullable } from "@likec4/core";
|
|
18
20
|
import { useDebouncedCallback as useDebouncedCallback$1, useTimeout } from "@mantine/hooks";
|
|
@@ -28,7 +30,8 @@ var builtinNodes = {
|
|
|
28
30
|
"compound-deployment": BuiltinNodes.CompoundDeploymentNode,
|
|
29
31
|
"view-group": BuiltinNodes.ViewGroupNode,
|
|
30
32
|
"seq-actor": BuiltinNodes.SequenceActorNode,
|
|
31
|
-
"seq-parallel": BuiltinNodes.SequenceParallelArea
|
|
33
|
+
"seq-parallel": BuiltinNodes.SequenceParallelArea,
|
|
34
|
+
"seq-subflow": BuiltinNodes.SequenceSubflowArea
|
|
32
35
|
};
|
|
33
36
|
function prepareNodeTypes(nodeTypes) {
|
|
34
37
|
if (!nodeTypes || isEmpty(nodeTypes)) return builtinNodes;
|
|
@@ -39,7 +42,8 @@ function prepareNodeTypes(nodeTypes) {
|
|
|
39
42
|
"compound-deployment": nodeTypes.compoundDeployment ?? builtinNodes["compound-deployment"],
|
|
40
43
|
"view-group": nodeTypes.viewGroup ?? builtinNodes["view-group"],
|
|
41
44
|
"seq-actor": nodeTypes.seqActor ?? builtinNodes["seq-actor"],
|
|
42
|
-
"seq-parallel": nodeTypes.seqParallel ?? builtinNodes["seq-parallel"]
|
|
45
|
+
"seq-parallel": nodeTypes.seqParallel ?? builtinNodes["seq-parallel"],
|
|
46
|
+
"seq-subflow": nodeTypes.seqSubflow ?? builtinNodes["seq-subflow"]
|
|
43
47
|
};
|
|
44
48
|
}
|
|
45
49
|
var viewportToTopLeft = (ctx) => {
|
|
@@ -50,7 +54,7 @@ var viewportToTopLeft = (ctx) => {
|
|
|
50
54
|
zoom: 1
|
|
51
55
|
};
|
|
52
56
|
};
|
|
53
|
-
var selectXYProps =
|
|
57
|
+
var selectXYProps = selectDiagramSnapshot(({ context: ctx, children }) => {
|
|
54
58
|
const { enableReadOnly } = deriveToggledFeatures(ctx);
|
|
55
59
|
const editorSnapshot = enableReadOnly ? null : children.editor?.getSnapshot();
|
|
56
60
|
const isNotEditingEdge = enableReadOnly || editorSnapshot?.context.editing?.subject !== "edge";
|
|
@@ -68,12 +72,15 @@ var selectXYProps = selectDiagramActor(({ context: ctx, children }) => {
|
|
|
68
72
|
nodesSelectable: ctx.nodesSelectable && isNotEditingEdge && !isEditorBusy,
|
|
69
73
|
fitViewPadding: ctx.fitViewPadding,
|
|
70
74
|
enableFitView: ctx.features.enableFitView,
|
|
75
|
+
enableControls: ctx.features.enableControls && ctx.features.enableFitView,
|
|
71
76
|
...!ctx.features.enableFitView && { viewport: viewportToTopLeft(ctx) }
|
|
72
77
|
};
|
|
78
|
+
}, ({ nodes: aNodes, edges: aEdges, ...a }, { nodes: bNodes, edges: bEdges, ...b }) => {
|
|
79
|
+
return shallowEqual(a, b) && shallowEqual(aNodes, bNodes) && shallowEqual(aEdges, bEdges);
|
|
73
80
|
});
|
|
74
81
|
function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, children, renderNodes }) {
|
|
75
82
|
const diagram = useDiagram();
|
|
76
|
-
let { enableReadOnly, initialized, nodes, edges, enableFitView, nodesDraggable, nodesSelectable, ...props } =
|
|
83
|
+
let { enableReadOnly, initialized, nodes, edges, enableFitView, nodesDraggable, nodesSelectable, enableControls, ...props } = useDiagramSelector(selectXYProps);
|
|
77
84
|
const { onNodeContextMenu, onCanvasContextMenu, onEdgeContextMenu, onNodeClick, onEdgeClick, onCanvasClick, onCanvasDblClick } = useDiagramEventHandlers();
|
|
78
85
|
const { reducedGraphics, $panning } = useRootContainer();
|
|
79
86
|
const isReducedGraphics = reducedGraphics;
|
|
@@ -81,13 +88,14 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
81
88
|
const $isPanning = $panning;
|
|
82
89
|
const isPanning = useTimeout(() => {
|
|
83
90
|
$isPanning.set(true);
|
|
84
|
-
}, isReducedGraphics ? 200 :
|
|
91
|
+
}, isReducedGraphics ? 200 : 1e3);
|
|
85
92
|
const notPanning = useDebouncedCallback$1(() => {
|
|
86
93
|
isPanning.clear();
|
|
87
94
|
$isPanning.set(false);
|
|
88
95
|
}, 200);
|
|
89
96
|
const onMove = useCallbackRef$1((event) => {
|
|
90
97
|
if (!event) {
|
|
98
|
+
$isPanning.set(false);
|
|
91
99
|
isPanning.clear();
|
|
92
100
|
return;
|
|
93
101
|
}
|
|
@@ -95,7 +103,11 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
95
103
|
else notPanning();
|
|
96
104
|
});
|
|
97
105
|
const onMoveEnd = useCallbackRef$1((event, viewport) => {
|
|
98
|
-
if (event)
|
|
106
|
+
if (!event) {
|
|
107
|
+
$isPanning.set(false);
|
|
108
|
+
isPanning.clear();
|
|
109
|
+
notPanning.cancel();
|
|
110
|
+
} else notPanning();
|
|
99
111
|
diagram.send({
|
|
100
112
|
type: "xyflow.viewportMoved",
|
|
101
113
|
viewport,
|
|
@@ -109,7 +121,7 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
109
121
|
useUpdateEffect$1(() => {
|
|
110
122
|
console.warn("renderNodes changed - this might degrade performance");
|
|
111
123
|
}, [nodeTypes]);
|
|
112
|
-
return /* @__PURE__ */
|
|
124
|
+
return /* @__PURE__ */ jsxs(BaseXYFlow, {
|
|
113
125
|
nodes,
|
|
114
126
|
edges,
|
|
115
127
|
className: cx(initialized ? "initialized" : "not-initialized"),
|
|
@@ -156,6 +168,7 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
156
168
|
});
|
|
157
169
|
}),
|
|
158
170
|
onDelete: useCallbackRef$1(({ nodes, edges }) => {
|
|
171
|
+
if (enableReadOnly) return;
|
|
159
172
|
diagram.editorActor().send({
|
|
160
173
|
type: "delete.nodes-edges",
|
|
161
174
|
nodeIds: nodes.map((node) => node.data.id),
|
|
@@ -212,8 +225,8 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
212
225
|
});
|
|
213
226
|
}),
|
|
214
227
|
onNodeContextMenu: useCallbackRef$1((event, node) => {
|
|
215
|
-
const diagramNode =
|
|
216
|
-
onNodeContextMenu?.(diagramNode, event);
|
|
228
|
+
const diagramNode = diagram.findDiagramNode(node.data.id);
|
|
229
|
+
if (diagramNode) onNodeContextMenu?.(diagramNode, event);
|
|
217
230
|
}),
|
|
218
231
|
onEdgeContextMenu: useCallbackRef$1((event, edge) => {
|
|
219
232
|
const diagramEdge = nonNullable(diagram.findDiagramEdge(edge.id), `diagramEdge ${edge.id} not found`);
|
|
@@ -223,13 +236,25 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
223
236
|
...enableFitView && { onViewportResize },
|
|
224
237
|
nodesDraggable,
|
|
225
238
|
nodesSelectable,
|
|
239
|
+
nodesFocusable: true,
|
|
240
|
+
edgesFocusable: true,
|
|
226
241
|
elevateEdgesOnSelect: !enableReadOnly,
|
|
227
242
|
zIndexMode: "manual",
|
|
228
243
|
...nodesDraggable && layoutConstraints,
|
|
229
244
|
...props,
|
|
230
245
|
...reactFlowProps,
|
|
231
|
-
children
|
|
246
|
+
children: [enableControls && /* @__PURE__ */ jsx(Controls$1, { padding: props.fitViewPadding }), children]
|
|
232
247
|
});
|
|
233
248
|
}
|
|
249
|
+
var Controls$1 = /* @__PURE__ */ __name(({ padding }) => /* @__PURE__ */ jsx(Controls, {
|
|
250
|
+
showInteractive: false,
|
|
251
|
+
fitViewOptions: {
|
|
252
|
+
padding,
|
|
253
|
+
minZoom: MinZoom,
|
|
254
|
+
maxZoom: 1,
|
|
255
|
+
duration: 350
|
|
256
|
+
},
|
|
257
|
+
position: "bottom-left"
|
|
258
|
+
}), "Controls");
|
|
234
259
|
//#endregion
|
|
235
260
|
export { LikeC4DiagramXYFlow };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LayoutedView, ViewId } from '@likec4/core/types';
|
|
2
|
+
import { DiagramContext } from './state/types';
|
|
2
3
|
import { Types } from './types';
|
|
3
|
-
type ConvertToXYFlowInput = {
|
|
4
|
+
type ConvertToXYFlowInput = Pick<DiagramContext, 'view' | 'where' | 'dynamicViewVariant' | 'collapsedSequenceFlows'> & {
|
|
4
5
|
currentViewId: ViewId | undefined;
|
|
5
|
-
view: LayoutedView;
|
|
6
|
-
where: WhereOperator | null;
|
|
7
|
-
dynamicViewVariant: DynamicViewDisplayVariant;
|
|
8
6
|
};
|
|
9
7
|
export declare function convertToXYFlow({ dynamicViewVariant, ...params }: ConvertToXYFlowInput): {
|
|
10
8
|
view: LayoutedView;
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { diagramToXY } from "./xyflow-diagram/diagram-view.js";
|
|
3
|
-
import { sequenceLayoutToXY } from "./xyflow-sequence/sequence-
|
|
3
|
+
import { sequenceLayoutToXY } from "./xyflow-sequence/sequence-view-to-xy.js";
|
|
4
4
|
//#region src/likec4diagram/convert-to-xyflow.ts
|
|
5
5
|
function convertToXYFlow({ dynamicViewVariant, ...params }) {
|
|
6
6
|
const view = params.view;
|
|
7
7
|
const isDynamic = view._type === "dynamic";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
if (isDynamic && dynamicViewVariant !== "sequence") {
|
|
9
|
+
const { xynodes, xyedges } = diagramToXY(params);
|
|
10
|
+
return {
|
|
11
|
+
view: view.variant !== "diagram" ? {
|
|
12
|
+
...view,
|
|
13
|
+
variant: "diagram"
|
|
14
|
+
} : view,
|
|
15
|
+
xynodes,
|
|
16
|
+
xyedges
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (isDynamic && dynamicViewVariant === "sequence") {
|
|
20
|
+
const { xynodes, xyedges, layout } = sequenceLayoutToXY({
|
|
21
|
+
view,
|
|
22
|
+
currentViewId: params.currentViewId,
|
|
23
|
+
collapsedFlows: params.collapsedSequenceFlows
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
view: {
|
|
27
|
+
...view,
|
|
28
|
+
sequenceLayout: layout,
|
|
29
|
+
variant: dynamicViewVariant
|
|
30
|
+
},
|
|
31
|
+
xynodes,
|
|
32
|
+
xyedges
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const { xynodes, xyedges } = diagramToXY(params);
|
|
17
36
|
return {
|
|
18
37
|
view,
|
|
19
38
|
xynodes,
|
|
@@ -21,6 +21,7 @@ import { useRef, useState } from "react";
|
|
|
21
21
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
22
22
|
import { useRafEffect } from "@react-hookz/web";
|
|
23
23
|
import { EdgeLabelRenderer } from "@xyflow/react";
|
|
24
|
+
import { isNumber } from "remeda";
|
|
24
25
|
//#region src/likec4diagram/custom/edges/RelationshipEdge.tsx
|
|
25
26
|
var getEdgeCenter = (path) => {
|
|
26
27
|
const dompoint = path.getPointAtLength(path.getTotalLength() * .5);
|
|
@@ -233,6 +234,10 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
233
234
|
hovered: true
|
|
234
235
|
}
|
|
235
236
|
};
|
|
237
|
+
const sequenceStepData = isNumber(props.data.stepnum) ? {
|
|
238
|
+
isSequenceStep: true,
|
|
239
|
+
stepNum: props.data.stepnum
|
|
240
|
+
} : void 0;
|
|
236
241
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(EdgeContainer, {
|
|
237
242
|
...props,
|
|
238
243
|
className: css({ "& .react-flow__edge-interaction": { cursor: enabledEditing && selected ? "copy" : void 0 } }),
|
|
@@ -258,11 +263,15 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
258
263
|
children: /* @__PURE__ */ jsx(EdgeLabel, {
|
|
259
264
|
pointerEvents: "all",
|
|
260
265
|
className: enabledEditing ? labelDraggable : void 0,
|
|
266
|
+
...sequenceStepData,
|
|
261
267
|
edgeProps: props,
|
|
262
|
-
children: navigateTo && /* @__PURE__ */ jsx(EdgeActionButton, {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
268
|
+
children: navigateTo && /* @__PURE__ */ jsx(EdgeActionButton, {
|
|
269
|
+
ariaLabel: "Navigate to view",
|
|
270
|
+
onClick: (e) => {
|
|
271
|
+
e.stopPropagation();
|
|
272
|
+
diagram.navigateTo(navigateTo);
|
|
273
|
+
}
|
|
274
|
+
})
|
|
266
275
|
})
|
|
267
276
|
})
|
|
268
277
|
]
|
|
@@ -41,8 +41,10 @@ function SequenceStepEdge(props) {
|
|
|
41
41
|
labelX = props.sourceX + LABEL_OFFSET;
|
|
42
42
|
break;
|
|
43
43
|
}
|
|
44
|
+
const { state, stepnum } = props.data;
|
|
44
45
|
return /* @__PURE__ */ jsxs(EdgeContainer, {
|
|
45
46
|
...props,
|
|
47
|
+
...state && { "data-seq-edge-state": state },
|
|
46
48
|
children: [
|
|
47
49
|
/* @__PURE__ */ jsx(EdgePath, {
|
|
48
50
|
edgeProps: props,
|
|
@@ -61,10 +63,15 @@ function SequenceStepEdge(props) {
|
|
|
61
63
|
},
|
|
62
64
|
children: /* @__PURE__ */ jsx(EdgeLabel, {
|
|
63
65
|
edgeProps: props,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
isSequenceStep: true,
|
|
67
|
+
stepNum: stepnum,
|
|
68
|
+
children: enableNavigateTo && navigateTo && /* @__PURE__ */ jsx(EdgeActionButton, {
|
|
69
|
+
ariaLabel: "Navigate to view",
|
|
70
|
+
onClick: (e) => {
|
|
71
|
+
e.stopPropagation();
|
|
72
|
+
diagram.navigateTo(navigateTo);
|
|
73
|
+
}
|
|
74
|
+
})
|
|
68
75
|
})
|
|
69
76
|
})
|
|
70
77
|
]
|
|
@@ -38,7 +38,7 @@ var controlPoint = css({
|
|
|
38
38
|
[`:where([data-likec4-selected='true']) &`]: { r: 6 },
|
|
39
39
|
[`:is([data-likec4-hovered='true']) &`]: { r: 8 },
|
|
40
40
|
_hover: {
|
|
41
|
-
fill: "mantine.
|
|
41
|
+
fill: "mantine.primary.filledHover",
|
|
42
42
|
r: 10,
|
|
43
43
|
transitionDuration: "100ms"
|
|
44
44
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SequenceStepEdge } from './edges/SequenceStepEdge';
|
|
2
|
-
import { CompoundDeploymentNode, CompoundElementNode, DeploymentNode, ElementNode, SequenceActorNode, SequenceParallelArea, ViewGroupNode } from './nodes';
|
|
2
|
+
import { CompoundDeploymentNode, CompoundElementNode, DeploymentNode, ElementNode, SequenceActorNode, SequenceParallelArea, SequenceSubflowArea, ViewGroupNode } from './nodes';
|
|
3
3
|
import { FunctionComponent } from 'react';
|
|
4
4
|
export declare const BuiltinNodes: {
|
|
5
5
|
ElementNode: typeof ElementNode;
|
|
@@ -9,6 +9,7 @@ export declare const BuiltinNodes: {
|
|
|
9
9
|
ViewGroupNode: typeof ViewGroupNode;
|
|
10
10
|
SequenceActorNode: typeof SequenceActorNode;
|
|
11
11
|
SequenceParallelArea: typeof SequenceParallelArea;
|
|
12
|
+
SequenceSubflowArea: typeof SequenceSubflowArea;
|
|
12
13
|
};
|
|
13
14
|
export declare const BuiltinEdges: {
|
|
14
15
|
RelationshipEdge: FunctionComponent<import("../types").Types.EdgeProps<"relationship">>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { RelationshipEdge } from "./edges/RelationshipEdge.js";
|
|
2
|
-
import { SequenceStepEdge } from "./edges/SequenceStepEdge.js";
|
|
3
1
|
import { CompoundDeploymentNode, CompoundElementNode, DeploymentNode, ElementNode, ViewGroupNode } from "./nodes/nodes.js";
|
|
4
2
|
import { SequenceActorNode, SequenceParallelArea } from "./nodes/SequenceActorNode.js";
|
|
3
|
+
import { SequenceSubflowArea } from "./nodes/SequenceSubFlow.js";
|
|
4
|
+
import { RelationshipEdge } from "./edges/RelationshipEdge.js";
|
|
5
|
+
import { SequenceStepEdge } from "./edges/SequenceStepEdge.js";
|
|
5
6
|
//#region src/likec4diagram/custom/index.tsx
|
|
6
7
|
var BuiltinNodes = {
|
|
7
8
|
ElementNode,
|
|
@@ -10,7 +11,8 @@ var BuiltinNodes = {
|
|
|
10
11
|
CompoundDeploymentNode,
|
|
11
12
|
ViewGroupNode,
|
|
12
13
|
SequenceActorNode,
|
|
13
|
-
SequenceParallelArea
|
|
14
|
+
SequenceParallelArea,
|
|
15
|
+
SequenceSubflowArea
|
|
14
16
|
};
|
|
15
17
|
var BuiltinEdges = {
|
|
16
18
|
RelationshipEdge,
|
|
@@ -9,6 +9,7 @@ var CompoundActions = (props) => {
|
|
|
9
9
|
const diagram = useDiagram();
|
|
10
10
|
const { navigateTo } = props.data;
|
|
11
11
|
if (navigateTo && enableNavigateTo) return /* @__PURE__ */ jsx(CompoundActionButton, {
|
|
12
|
+
ariaLabel: "Navigate to view",
|
|
12
13
|
onClick: (e) => {
|
|
13
14
|
e.stopPropagation();
|
|
14
15
|
diagram.navigateTo(navigateTo, props.id);
|