@likec4/diagram 1.39.5 → 1.40.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-CW_KClZe.js → chunk-CDr-4Ymp.js} +936 -903
- package/bundle/custom.js +61 -60
- package/bundle/index.js +2667 -539
- package/dist/LikeC4Diagram.d.ts +1 -1
- package/dist/LikeC4Diagram.js +7 -4
- package/dist/LikeC4Diagram.props.d.ts +6 -1
- package/dist/base/const.d.ts +9 -0
- package/dist/base/const.js +10 -1
- package/dist/base/index.d.ts +1 -0
- package/dist/base/primitives/edge/EdgeLabel.js +2 -1
- package/dist/base/primitives/edge/EdgeLabelContainer.js +10 -4
- package/dist/base/primitives/edge/EdgePath.js +17 -8
- package/dist/base/primitives/edge/edge.css.d.ts +0 -1
- package/dist/base/primitives/edge/edge.css.js +6 -14
- package/dist/base/primitives/element/ElementActionButtons.js +1 -3
- package/dist/base/primitives/element/ElementNodeContainer.d.ts +0 -6
- package/dist/base/primitives/element/ElementNodeContainer.js +3 -26
- package/dist/base/primitives/element/ElementTitle.js +2 -2
- package/dist/base/types.d.ts +3 -3
- package/dist/bundle/LikeC4View.js +4 -12
- package/dist/bundle/LikeC4View.props.d.ts +12 -3
- package/dist/bundle/custom.js +1 -1
- package/dist/custom/customNodes.d.ts +6 -0
- package/dist/custom/customNodes.js +2 -1
- package/dist/custom/index.js +1 -1
- package/dist/hooks/useDiagram.d.ts +5 -1
- package/dist/hooks/useDiagram.js +3 -0
- package/dist/hooks/useXYFlow.d.ts +4 -439
- package/dist/likec4diagram/DiagramUI.js +1 -1
- package/dist/likec4diagram/DiagramXYFlow.js +8 -4
- package/dist/likec4diagram/convert-to-xyflow.d.ts +14 -0
- package/dist/likec4diagram/convert-to-xyflow.js +29 -0
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +3 -3
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +0 -1
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.d.ts +3 -0
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +71 -0
- package/dist/likec4diagram/custom/index.js +7 -2
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -1
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.d.ts +4 -0
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +157 -0
- package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +1 -2
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +31 -27
- package/dist/likec4diagram/types.d.ts +41 -7
- package/dist/likec4diagram/xyflow-diagram/diagram-view.d.ts +11 -0
- package/dist/likec4diagram/{useViewToNodesEdges.js → xyflow-diagram/diagram-view.js} +4 -13
- package/dist/likec4diagram/xyflow-sequence/_types.d.ts +41 -0
- package/dist/likec4diagram/xyflow-sequence/const.d.ts +17 -0
- package/dist/likec4diagram/xyflow-sequence/const.js +16 -0
- package/dist/likec4diagram/xyflow-sequence/layouter.d.ts +46 -0
- package/dist/likec4diagram/xyflow-sequence/layouter.js +408 -0
- package/dist/likec4diagram/xyflow-sequence/sequence-view.d.ts +7 -0
- package/dist/likec4diagram/xyflow-sequence/sequence-view.js +273 -0
- package/dist/likec4diagram/xyflow-sequence/utils.d.ts +14 -0
- package/dist/likec4diagram/xyflow-sequence/utils.js +92 -0
- package/dist/navigationpanel/NavigationPanelControls.js +2 -2
- package/dist/navigationpanel/controls/ViewDetailsCard.js +5 -2
- package/dist/navigationpanel/dropdown/ProjectsMenu.js +53 -44
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.d.ts +1 -2
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +10 -41
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +292 -0
- package/dist/navigationpanel/walkthrough/DynamicViewControls.js +119 -0
- package/dist/navigationpanel/walkthrough/index.d.ts +2 -1
- package/dist/overlays/relationship-details/RelationshipDetails.js +4 -1
- package/dist/state/DiagramActorProvider.d.ts +3 -2
- package/dist/state/DiagramActorProvider.js +19 -11
- package/dist/state/assign.js +11 -4
- package/dist/state/diagram-machine.d.ts +224 -194
- package/dist/state/diagram-machine.js +170 -63
- package/dist/state/utils.d.ts +7 -1
- package/dist/state/utils.js +67 -7
- package/dist/styles-min.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css2.js +1 -1
- package/package.json +8 -7
- package/panda.buildinfo.json +30 -9
- package/src/LikeC4Diagram.props.ts +14 -1
- package/src/LikeC4Diagram.tsx +7 -4
- package/src/base/const.ts +12 -0
- package/src/base/index.ts +2 -0
- package/src/base/primitives/edge/EdgeLabel.tsx +23 -19
- package/src/base/primitives/edge/EdgeLabelContainer.tsx +12 -7
- package/src/base/primitives/edge/EdgePath.tsx +25 -14
- package/src/base/primitives/edge/edge.css.ts +5 -14
- package/src/base/primitives/element/ElementActionButtons.tsx +1 -3
- package/src/base/primitives/element/ElementNodeContainer.tsx +3 -30
- package/src/base/primitives/element/ElementTitle.tsx +2 -3
- package/src/base/types.ts +7 -5
- package/src/bundle/LikeC4View.props.ts +14 -3
- package/src/bundle/LikeC4View.tsx +4 -14
- package/src/bundle/ReactLikeC4.tsx +1 -2
- package/src/custom/customNodes.ts +7 -0
- package/src/hooks/useDiagram.ts +10 -0
- package/src/likec4diagram/DiagramUI.tsx +1 -1
- package/src/likec4diagram/DiagramXYFlow.tsx +10 -5
- package/src/likec4diagram/convert-to-xyflow.ts +45 -0
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +0 -1
- package/src/likec4diagram/custom/edges/SequenceStepEdge.tsx +65 -0
- package/src/likec4diagram/custom/index.ts +7 -1
- package/src/likec4diagram/custom/nodes/ElementActions.tsx +4 -2
- package/src/likec4diagram/custom/nodes/SequenceActorNode.tsx +175 -0
- package/src/likec4diagram/custom/nodes/index.ts +1 -0
- package/src/likec4diagram/custom/nodes/nodes.tsx +1 -1
- package/src/likec4diagram/relationship-popover/RelationshipPopover.tsx +36 -30
- package/src/likec4diagram/types.ts +96 -13
- package/src/likec4diagram/{useViewToNodesEdges.ts → xyflow-diagram/diagram-view.ts} +7 -28
- package/src/likec4diagram/xyflow-sequence/_types.ts +45 -0
- package/src/likec4diagram/xyflow-sequence/const.ts +37 -0
- package/src/likec4diagram/xyflow-sequence/layouter.ts +567 -0
- package/src/likec4diagram/xyflow-sequence/sequence-view.ts +337 -0
- package/src/likec4diagram/xyflow-sequence/utils.ts +112 -0
- package/src/navigationpanel/NavigationPanelControls.tsx +2 -2
- package/src/navigationpanel/controls/ViewDetailsCard.tsx +5 -2
- package/src/navigationpanel/dropdown/ProjectsMenu.tsx +5 -1
- package/src/navigationpanel/walkthrough/ActiveWalkthroughControls.tsx +5 -40
- package/src/navigationpanel/walkthrough/DynamicViewControls.tsx +125 -0
- package/src/navigationpanel/walkthrough/index.tsx +2 -1
- package/src/overlays/relationship-details/RelationshipDetails.tsx +5 -2
- package/src/state/DiagramActorProvider.tsx +21 -10
- package/src/state/assign.ts +18 -5
- package/src/state/diagram-machine.ts +207 -75
- package/src/state/utils.ts +81 -7
- package/dist/likec4diagram/useViewToNodesEdges.d.ts +0 -12
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { invariant } from '@likec4/core';
|
|
3
|
+
import { css } from '@likec4/styles/css';
|
|
4
|
+
import { Button, SegmentedControl } from '@mantine/core';
|
|
5
|
+
import * as m from 'motion/react-m';
|
|
6
|
+
import { forwardRef } from 'react';
|
|
7
|
+
import { useDiagramContext, useDiagram } from '../../hooks/useDiagram.js';
|
|
8
|
+
import { Tooltip } from '../_common.js';
|
|
9
|
+
import { useNavigationActor } from '../hooks.js';
|
|
10
|
+
import IconPlayerPlayFilled from '../../node_modules/.pnpm/@tabler_icons-react@3.34.1_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerPlayFilled.js';
|
|
11
|
+
|
|
12
|
+
const TriggerWalkthroughButton = forwardRef((props, ref) => /* @__PURE__ */ jsx(
|
|
13
|
+
Button,
|
|
14
|
+
{
|
|
15
|
+
variant: "filled",
|
|
16
|
+
size: "xs",
|
|
17
|
+
fw: "500",
|
|
18
|
+
...props,
|
|
19
|
+
ref,
|
|
20
|
+
component: m.button,
|
|
21
|
+
layoutId: "trigger-dynamic-walkthrough",
|
|
22
|
+
className: css({
|
|
23
|
+
flexShrink: 0
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
));
|
|
27
|
+
function StartWalkthroughButton({ onClick }) {
|
|
28
|
+
const diagram = useDiagram();
|
|
29
|
+
const actor = useNavigationActor();
|
|
30
|
+
return /* @__PURE__ */ jsx(Tooltip, { label: "Start Dynamic View Walkthrough", children: /* @__PURE__ */ jsx(
|
|
31
|
+
TriggerWalkthroughButton,
|
|
32
|
+
{
|
|
33
|
+
onClick: (e) => {
|
|
34
|
+
e.stopPropagation();
|
|
35
|
+
actor.closeDropdown();
|
|
36
|
+
diagram.startWalkthrough();
|
|
37
|
+
},
|
|
38
|
+
size: "compact-xs",
|
|
39
|
+
h: 26,
|
|
40
|
+
classNames: {
|
|
41
|
+
label: css({
|
|
42
|
+
display: {
|
|
43
|
+
base: "none",
|
|
44
|
+
"@/md": "[inherit]"
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
section: css({
|
|
48
|
+
marginInlineStart: {
|
|
49
|
+
base: "0",
|
|
50
|
+
"@/md": "2"
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
},
|
|
54
|
+
rightSection: /* @__PURE__ */ jsx(IconPlayerPlayFilled, { size: 10 }),
|
|
55
|
+
children: "Start"
|
|
56
|
+
}
|
|
57
|
+
) });
|
|
58
|
+
}
|
|
59
|
+
function DynamicViewModeSwitcher({
|
|
60
|
+
value,
|
|
61
|
+
onChange
|
|
62
|
+
}) {
|
|
63
|
+
return /* @__PURE__ */ jsx(m.div, { layout: "position", children: /* @__PURE__ */ jsx(
|
|
64
|
+
SegmentedControl,
|
|
65
|
+
{
|
|
66
|
+
size: "xs",
|
|
67
|
+
value,
|
|
68
|
+
component: m.div,
|
|
69
|
+
onChange: (variant) => {
|
|
70
|
+
invariant(variant === "diagram" || variant === "sequence", "Invalid dynamic view variant");
|
|
71
|
+
onChange(variant);
|
|
72
|
+
},
|
|
73
|
+
classNames: {
|
|
74
|
+
label: css({
|
|
75
|
+
fontSize: "xxs"
|
|
76
|
+
})
|
|
77
|
+
},
|
|
78
|
+
data: [
|
|
79
|
+
{
|
|
80
|
+
value: "diagram",
|
|
81
|
+
label: "Diagram"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
value: "sequence",
|
|
85
|
+
label: "Sequence"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
) });
|
|
90
|
+
}
|
|
91
|
+
function DynamicViewControls() {
|
|
92
|
+
const dynamicViewVariant = useDiagramContext((c) => c.dynamicViewVariant);
|
|
93
|
+
const diagram = useDiagram();
|
|
94
|
+
const actor = useNavigationActor();
|
|
95
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
96
|
+
/* @__PURE__ */ jsx(
|
|
97
|
+
DynamicViewModeSwitcher,
|
|
98
|
+
{
|
|
99
|
+
value: dynamicViewVariant,
|
|
100
|
+
onChange: (mode) => {
|
|
101
|
+
diagram.switchDynamicViewVariant(mode);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"dynamic-view-mode-switcher"
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ jsx(
|
|
107
|
+
StartWalkthroughButton,
|
|
108
|
+
{
|
|
109
|
+
onClick: () => {
|
|
110
|
+
actor.closeDropdown();
|
|
111
|
+
diagram.startWalkthrough();
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"trigger-dynamic-walkthrough"
|
|
115
|
+
)
|
|
116
|
+
] });
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { DynamicViewControls, TriggerWalkthroughButton };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { ActiveWalkthroughControls
|
|
1
|
+
export { ActiveWalkthroughControls } from './ActiveWalkthroughControls';
|
|
2
|
+
export { DynamicViewControls } from './DynamicViewControls';
|
|
@@ -104,7 +104,10 @@ const RelationshipDetailsInner = memo(() => {
|
|
|
104
104
|
id: browser.rootElementId,
|
|
105
105
|
nodes,
|
|
106
106
|
edges,
|
|
107
|
-
className: cx(
|
|
107
|
+
className: cx(
|
|
108
|
+
initialized ? "initialized" : "not-initialized",
|
|
109
|
+
"likec4-relationship-details"
|
|
110
|
+
),
|
|
108
111
|
nodeTypes,
|
|
109
112
|
edgeTypes,
|
|
110
113
|
onNodesChange: useCallbackRef((changes) => {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { DiagramView, WhereOperator } from '@likec4/core/types';
|
|
1
|
+
import { DiagramView, DynamicViewDisplayVariant, WhereOperator } from '@likec4/core/types';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
3
|
import { ViewPadding } from '../LikeC4Diagram.props';
|
|
4
|
-
export declare function DiagramActorProvider({ view, zoomable, pannable, fitViewPadding, nodesSelectable, where, children, }: PropsWithChildren<{
|
|
4
|
+
export declare function DiagramActorProvider({ view, zoomable, pannable, fitViewPadding, nodesSelectable, where, children, dynamicViewVariant: _defaultVariant, }: PropsWithChildren<{
|
|
5
5
|
view: DiagramView;
|
|
6
6
|
zoomable: boolean;
|
|
7
7
|
pannable: boolean;
|
|
8
8
|
fitViewPadding: ViewPadding;
|
|
9
9
|
nodesSelectable: boolean;
|
|
10
10
|
where: WhereOperator | null;
|
|
11
|
+
dynamicViewVariant: DynamicViewDisplayVariant | undefined;
|
|
11
12
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,13 +3,13 @@ import { useCustomCompareEffect } from '@react-hookz/web';
|
|
|
3
3
|
import { useActorRef, useSelector } from '@xstate/react';
|
|
4
4
|
import { useStoreApi } from '@xyflow/react';
|
|
5
5
|
import { shallowEqual, deepEqual } from 'fast-equals';
|
|
6
|
-
import { useRef, useEffect } from 'react';
|
|
6
|
+
import { useRef, useMemo, useEffect } from 'react';
|
|
7
7
|
import { ErrorBoundary } from '../components/ErrorFallback.js';
|
|
8
8
|
import { useDiagramEventHandlers } from '../context/DiagramEventHandlers.js';
|
|
9
9
|
import { useEnabledFeatures, DiagramFeatures } from '../context/DiagramFeatures.js';
|
|
10
10
|
import { DiagramActorContextProvider } from '../hooks/safeContext.js';
|
|
11
11
|
import { useCurrentViewId } from '../hooks/useCurrentViewId.js';
|
|
12
|
-
import {
|
|
12
|
+
import { convertToXYFlow } from '../likec4diagram/convert-to-xyflow.js';
|
|
13
13
|
import { CurrentViewModelContext } from '../likec4model/LikeC4ModelContext.js';
|
|
14
14
|
import { useLikeC4Model } from '../likec4model/useLikeC4Model.js';
|
|
15
15
|
import { diagramMachine } from './diagram-machine.js';
|
|
@@ -25,6 +25,9 @@ const selectToggledFeatures = (state) => {
|
|
|
25
25
|
}
|
|
26
26
|
return state.context.toggledFeatures;
|
|
27
27
|
};
|
|
28
|
+
const selectDynamicViewVariant = (state) => {
|
|
29
|
+
return state.context.dynamicViewVariant;
|
|
30
|
+
};
|
|
28
31
|
function DiagramActorProvider({
|
|
29
32
|
view,
|
|
30
33
|
zoomable,
|
|
@@ -32,7 +35,8 @@ function DiagramActorProvider({
|
|
|
32
35
|
fitViewPadding,
|
|
33
36
|
nodesSelectable,
|
|
34
37
|
where,
|
|
35
|
-
children
|
|
38
|
+
children,
|
|
39
|
+
dynamicViewVariant: _defaultVariant
|
|
36
40
|
}) {
|
|
37
41
|
const { handlersRef } = useDiagramEventHandlers();
|
|
38
42
|
const xystore = useStoreApi();
|
|
@@ -62,7 +66,8 @@ function DiagramActorProvider({
|
|
|
62
66
|
zoomable,
|
|
63
67
|
pannable,
|
|
64
68
|
fitViewPadding,
|
|
65
|
-
nodesSelectable
|
|
69
|
+
nodesSelectable,
|
|
70
|
+
dynamicViewVariant: _defaultVariant
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
73
|
);
|
|
@@ -81,14 +86,17 @@ function DiagramActorProvider({
|
|
|
81
86
|
[zoomable, pannable, fitViewPadding, nodesSelectable],
|
|
82
87
|
deepEqual
|
|
83
88
|
);
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
where,
|
|
87
|
-
nodesSelectable
|
|
88
|
-
|
|
89
|
+
const dynamicViewVariant = useSelector(actorRef, selectDynamicViewVariant);
|
|
90
|
+
const update = useMemo(
|
|
91
|
+
() => convertToXYFlow({ view, where, nodesSelectable, dynamicViewVariant }),
|
|
92
|
+
[view, where, nodesSelectable, dynamicViewVariant]
|
|
93
|
+
);
|
|
89
94
|
useEffect(() => {
|
|
90
|
-
actorRef.send({
|
|
91
|
-
|
|
95
|
+
actorRef.send({
|
|
96
|
+
type: "update.view",
|
|
97
|
+
...update
|
|
98
|
+
});
|
|
99
|
+
}, [actorRef, update]);
|
|
92
100
|
const toggledFeatures = useSelector(actorRef, selectToggledFeatures, shallowEqual);
|
|
93
101
|
return /* @__PURE__ */ jsxs(DiagramActorContextProvider, { value: actorRef, children: [
|
|
94
102
|
/* @__PURE__ */ jsx(DiagramFeatures, { overrides: toggledFeatures, children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(CurrentViewModelProvider, { children }) }) }),
|
package/dist/state/assign.js
CHANGED
|
@@ -4,6 +4,7 @@ import { deepEqual } from 'fast-equals';
|
|
|
4
4
|
import { omit, mergeDeep, isEmpty } from 'remeda';
|
|
5
5
|
import { assertEvent } from 'xstate';
|
|
6
6
|
import { Base } from '../base/types.js';
|
|
7
|
+
import { SeqParallelAreaColor } from '../likec4diagram/xyflow-sequence/const.js';
|
|
7
8
|
import { VectorImpl, vector } from '../utils/vector.js';
|
|
8
9
|
|
|
9
10
|
function lastClickedNode(params) {
|
|
@@ -52,12 +53,12 @@ function mergeXYNodesEdges({ context, event }) {
|
|
|
52
53
|
const currentEdges = context.xyedges;
|
|
53
54
|
xyedges = event.xyedges.map((update) => {
|
|
54
55
|
const existing = currentEdges.find((n) => n.id === update.id);
|
|
55
|
-
if (existing) {
|
|
56
|
-
if (deepEqual(existing.hidden ?? false, update.hidden ?? false) && deepEqual(existing.data, update.data)) {
|
|
56
|
+
if (existing && existing.type === update.type) {
|
|
57
|
+
if (deepEqual(existing.hidden ?? false, update.hidden ?? false) && deepEqual(existing.data, update.data) && deepEqual(existing.source, update.source) && deepEqual(existing.target, update.target) && deepEqual(existing.sourceHandle, update.sourceHandle) && deepEqual(existing.targetHandle, update.targetHandle)) {
|
|
57
58
|
return existing;
|
|
58
59
|
}
|
|
59
60
|
return {
|
|
60
|
-
...existing,
|
|
61
|
+
...omit(existing, ["sourceHandle", "targetHandle"]),
|
|
61
62
|
...update,
|
|
62
63
|
data: {
|
|
63
64
|
...existing.data,
|
|
@@ -338,11 +339,17 @@ function updateActiveWalkthrough({ context }) {
|
|
|
338
339
|
const active = stepId === edge.id || !!parallelPrefix && edge.id.startsWith(parallelPrefix);
|
|
339
340
|
return Base.setData(edge, {
|
|
340
341
|
active,
|
|
341
|
-
dimmed:
|
|
342
|
+
dimmed: stepId !== edge.id
|
|
342
343
|
});
|
|
343
344
|
}),
|
|
344
345
|
xynodes: context.xynodes.map((node) => {
|
|
345
346
|
const dimmed = step.source !== node.id && step.target !== node.id;
|
|
347
|
+
if (node.type === "seq-parallel") {
|
|
348
|
+
return Base.setData(node, {
|
|
349
|
+
color: parallelPrefix === node.data.parallelPrefix ? SeqParallelAreaColor.active : SeqParallelAreaColor.default,
|
|
350
|
+
dimmed
|
|
351
|
+
});
|
|
352
|
+
}
|
|
346
353
|
return Base.setDimmed(node, dimmed);
|
|
347
354
|
})
|
|
348
355
|
};
|