@likec4/diagram 1.27.0 → 1.27.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/index.js +2343 -6880
- package/dist/LikeC4Diagram.js +3 -9
- package/dist/LikeC4Diagram.props.d.ts +5 -3
- package/dist/StaticLikeC4Diagram.js +1 -1
- package/dist/_virtual/set.js +5 -0
- package/dist/_virtual/set2.js +3 -0
- package/dist/base/BaseXYFlow.d.ts +2 -1
- package/dist/base/primitives/compound/CompoundNodeContainer.d.ts +1 -1
- package/dist/base/primitives/compound/CompoundNodeContainer.js +1 -2
- package/dist/base/primitives/edge/EdgeLabel.css.js +1 -4
- package/dist/base/primitives/edge/EdgeLabelContainer.js +1 -1
- package/dist/base/primitives/edge/EdgePath.js +0 -3
- package/dist/base/primitives/edge/edge.css.js +2 -0
- package/dist/base/primitives/element/ElementActionButtons.js +5 -10
- package/dist/base/primitives/element/ElementNodeContainer.css.js +5 -4
- package/dist/base/primitives/element/ElementShape.css.js +1 -12
- package/dist/base/primitives/element/ElementTitle.css.js +3 -2
- package/dist/base/types.js +2 -2
- package/dist/base/updateEdges.js +1 -9
- package/dist/base/updateNodes.js +1 -12
- package/dist/bundle/LikeC4View.js +2 -2
- package/dist/bundle/LikeC4View.props.d.ts +7 -7
- package/dist/components/Link.js +1 -1
- package/dist/hooks/useCurrentViewId.js +8 -2
- package/dist/hooks/useDiagram.d.ts +2659 -1996
- package/dist/hooks/useDiagram.js +16 -8
- package/dist/likec4diagram/DiagramXYFlow.js +10 -9
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +30 -41
- package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.js +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/styles.css.js +6 -1
- package/dist/likec4diagram/ui/controls/LayoutDriftNotification.js +13 -5
- package/dist/likec4diagram/ui/notation/NotationPanel.css.js +3 -3
- package/dist/likec4diagram/ui/notation/NotationPanel.js +10 -4
- package/dist/likec4diagram/useLayoutConstraints.d.ts +11 -10
- package/dist/likec4diagram/useLayoutConstraints.js +64 -61
- package/dist/node_modules/.pnpm/mnemonist@0.40.3_patch_hash_5c12abb43fcff6fd81e53021b89075d53249640d165a2556cc1e58d71201a13a/node_modules/mnemonist/set.js +369 -0
- package/dist/overlays/Overlays.js +5 -3
- package/dist/overlays/element-details/actor.d.ts +2769 -173
- package/dist/overlays/overlay/Overlay.css.d.ts +26 -2
- package/dist/overlays/overlay/Overlay.css.js +83 -16
- package/dist/overlays/overlay/Overlay.d.ts +7 -6
- package/dist/overlays/overlay/Overlay.js +39 -32
- package/dist/overlays/overlaysActor.js +2 -2
- package/dist/overlays/relationship-details/RelationshipDetails.js +113 -70
- package/dist/overlays/relationship-details/SelectEdge.d.ts +1 -1
- package/dist/overlays/relationship-details/SelectEdge.js +15 -9
- package/dist/overlays/relationship-details/_types.d.ts +4 -1
- package/dist/overlays/relationship-details/actor.d.ts +415 -128
- package/dist/overlays/relationship-details/actor.js +162 -53
- package/dist/overlays/relationship-details/compute.d.ts +12 -0
- package/dist/overlays/relationship-details/compute.js +139 -0
- package/dist/overlays/relationship-details/custom/ElementActions.js +27 -5
- package/dist/overlays/relationship-details/custom/edgeTypes.js +1 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +2 -1
- package/dist/overlays/relationship-details/hooks.d.ts +336 -6
- package/dist/overlays/relationship-details/hooks.js +9 -7
- package/dist/overlays/relationship-details/layout-to-xyflow.d.ts +12 -0
- package/dist/overlays/relationship-details/layout-to-xyflow.js +149 -0
- package/dist/overlays/relationship-details/layout.d.ts +22 -0
- package/dist/overlays/relationship-details/layout.js +314 -0
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +3 -1
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +2 -2
- package/dist/overlays/relationships-browser/SelectElement.js +4 -4
- package/dist/overlays/relationships-browser/_types.d.ts +2 -0
- package/dist/overlays/relationships-browser/actor.d.ts +130 -14
- package/dist/overlays/relationships-browser/actor.js +30 -16
- package/dist/overlays/relationships-browser/custom/ElementActions.js +5 -3
- package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +3 -1
- package/dist/overlays/relationships-browser/custom/edgeTypes.js +1 -1
- package/dist/overlays/relationships-browser/hooks.d.ts +3 -1
- package/dist/overlays/relationships-browser/hooks.js +1 -1
- package/dist/overlays/relationships-browser/{-useRelationshipsView.d.ts → layout.d.ts} +2 -0
- package/dist/overlays/relationships-browser/{-useRelationshipsView.js → layout.js} +19 -2
- package/dist/overlays/relationships-browser/useViewToNodesEdges.d.ts +1 -1
- package/dist/overlays/relationships-browser/useViewToNodesEdges.js +3 -1
- package/dist/packages/core/src/compute-view/relationships-view/compute.js +1 -1
- package/dist/packages/core/src/model/connection/model/ConnectionModel.js +121 -0
- package/dist/packages/core/src/model/connection/model/find.js +39 -0
- package/dist/packages/core/src/model/connection/ops.js +7 -0
- package/dist/packages/core/src/utils/const.js +3 -0
- package/dist/packages/core/src/utils/fqn.js +9 -1
- package/dist/packages/core/src/utils/iterable/find.js +21 -0
- package/dist/packages/core/src/utils/iterable/some.js +21 -0
- package/dist/packages/core/src/utils/set.js +48 -0
- package/dist/packages/core/src/utils/string-hash.js +13 -0
- package/dist/state/DiagramActorProvider.d.ts +4 -2
- package/dist/state/DiagramActorProvider.js +30 -37
- package/dist/state/assign.js +2 -2
- package/dist/state/diagram-machine.d.ts +1731 -1040
- package/dist/state/diagram-machine.js +126 -60
- package/dist/state/syncManualLayoutActor.d.ts +1 -1
- package/dist/styles.css.js +1 -1
- package/package.json +11 -11
- package/src/LikeC4Diagram.props.ts +7 -3
- package/src/LikeC4Diagram.tsx +2 -8
- package/src/StaticLikeC4Diagram.tsx +1 -1
- package/src/base/BaseXYFlow.tsx +2 -1
- package/src/base/primitives/compound/CompoundNodeContainer.tsx +1 -3
- package/src/base/primitives/edge/EdgeLabel.css.ts +1 -4
- package/src/base/primitives/edge/EdgeLabelContainer.tsx +1 -1
- package/src/base/primitives/edge/EdgePath.tsx +0 -3
- package/src/base/primitives/edge/edge.css.ts +2 -0
- package/src/base/primitives/element/ElementActionButtons.tsx +6 -7
- package/src/base/primitives/element/ElementNodeContainer.css.ts +5 -4
- package/src/base/primitives/element/ElementShape.css.ts +1 -12
- package/src/base/primitives/element/ElementTitle.css.ts +3 -2
- package/src/base/types.ts +2 -7
- package/src/base/updateEdges.ts +8 -8
- package/src/base/updateNodes.ts +11 -11
- package/src/bundle/LikeC4View.props.ts +7 -7
- package/src/bundle/LikeC4View.tsx +2 -2
- package/src/components/Link.tsx +3 -1
- package/src/hooks/useCurrentViewId.ts +4 -2
- package/src/hooks/useDiagram.ts +18 -9
- package/src/likec4diagram/DiagramXYFlow.tsx +11 -9
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +39 -48
- package/src/likec4diagram/custom/nodes/toolbar/Toolbar.tsx +2 -2
- package/src/likec4diagram/custom/nodes/toolbar/styles.css.ts +5 -0
- package/src/likec4diagram/ui/controls/LayoutDriftNotification.tsx +8 -4
- package/src/likec4diagram/ui/notation/NotationPanel.css.ts +2 -2
- package/src/likec4diagram/ui/notation/NotationPanel.tsx +8 -6
- package/src/likec4diagram/useLayoutConstraints.ts +84 -89
- package/src/overlays/Overlays.tsx +5 -3
- package/src/overlays/overlay/Overlay.css.ts +83 -15
- package/src/overlays/overlay/Overlay.tsx +52 -41
- package/src/overlays/overlaysActor.ts +1 -1
- package/src/overlays/relationship-details/RelationshipDetails.tsx +131 -68
- package/src/overlays/relationship-details/SelectEdge.tsx +19 -12
- package/src/overlays/relationship-details/_types.ts +3 -1
- package/src/overlays/relationship-details/actor.ts +217 -68
- package/src/overlays/relationship-details/compute.ts +186 -0
- package/src/overlays/relationship-details/custom/ElementActions.tsx +27 -18
- package/src/overlays/relationship-details/custom/edgeTypes.tsx +1 -1
- package/src/overlays/relationship-details/hooks.ts +10 -8
- package/src/overlays/relationship-details/layout-to-xyflow.ts +195 -0
- package/src/overlays/relationship-details/layout.ts +470 -0
- package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +2 -2
- package/src/overlays/relationships-browser/SelectElement.tsx +5 -5
- package/src/overlays/relationships-browser/_types.ts +2 -0
- package/src/overlays/relationships-browser/actor.ts +39 -14
- package/src/overlays/relationships-browser/custom/ElementActions.tsx +5 -3
- package/src/overlays/relationships-browser/custom/edgeTypes.tsx +1 -1
- package/src/overlays/relationships-browser/hooks.ts +2 -2
- package/src/overlays/relationships-browser/{-useRelationshipsView.ts → layout.ts} +23 -13
- package/src/overlays/relationships-browser/useViewToNodesEdges.ts +3 -1
- package/src/state/DiagramActorProvider.tsx +40 -50
- package/src/state/assign.ts +2 -2
- package/src/state/diagram-machine.ts +151 -75
- package/dist/overlays/relationship-details/useLayoutedDetails.d.ts +0 -19
- package/dist/overlays/relationship-details/useLayoutedDetails.js +0 -267
- package/src/overlays/relationship-details/useLayoutedDetails.ts +0 -376
|
@@ -1,4 +1,28 @@
|
|
|
1
|
+
import { SlotRecipeRuntimeFn } from '@likec4/styles/types';
|
|
1
2
|
export declare const backdropBlur = "--_blur";
|
|
2
3
|
export declare const backdropOpacity = "--_opacity";
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const level = "--_level";
|
|
5
|
+
export declare const overlay: SlotRecipeRuntimeFn<"body" | "dialog", {
|
|
6
|
+
level: {
|
|
7
|
+
0: {
|
|
8
|
+
dialog: {
|
|
9
|
+
"--_level": "0";
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
1: {
|
|
13
|
+
dialog: {
|
|
14
|
+
"--_level": "1";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
2: {
|
|
18
|
+
dialog: {
|
|
19
|
+
"--_level": "2";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
3: {
|
|
23
|
+
dialog: {
|
|
24
|
+
"--_level": "3";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { css } from '@likec4/styles/css';
|
|
1
|
+
import { sva, css } from '@likec4/styles/css';
|
|
2
2
|
|
|
3
3
|
const backdropBlur = "--_blur";
|
|
4
4
|
const backdropOpacity = "--_opacity";
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const level = "--_level";
|
|
6
|
+
const offset = "--_offset";
|
|
7
|
+
const inset = "--_inset";
|
|
8
|
+
const borderRadius = "--_border-radius";
|
|
9
|
+
const dialog = css.raw({
|
|
7
10
|
boxSizing: "border-box",
|
|
8
11
|
margin: 0,
|
|
9
12
|
position: "fixed",
|
|
10
|
-
inset: "3rem",
|
|
11
13
|
width: "auto",
|
|
12
14
|
height: "auto",
|
|
13
15
|
maxWidth: "100vw",
|
|
@@ -16,9 +18,11 @@ const dialog = css({
|
|
|
16
18
|
shadow: "xl",
|
|
17
19
|
border: "transparent",
|
|
18
20
|
outline: "none",
|
|
19
|
-
borderRadius
|
|
20
|
-
padding: "6px",
|
|
21
|
+
borderRadius: `var(${borderRadius})`,
|
|
21
22
|
[backdropBlur]: "0px",
|
|
23
|
+
[level]: "0",
|
|
24
|
+
[offset]: "0px",
|
|
25
|
+
[inset]: "calc((1 + var(--_level) * 0.5) * var(--_offset))",
|
|
22
26
|
[backdropOpacity]: "0%",
|
|
23
27
|
_backdrop: {
|
|
24
28
|
cursor: "zoom-out",
|
|
@@ -28,30 +32,93 @@ const dialog = css({
|
|
|
28
32
|
_light: `[rgb(15 15 15/ var(${backdropOpacity}))]`
|
|
29
33
|
}
|
|
30
34
|
},
|
|
31
|
-
mdDown: {
|
|
32
|
-
borderRadius: "sm",
|
|
33
|
-
inset: "2rem",
|
|
34
|
-
width: "calc(100vw - 4rem)",
|
|
35
|
-
height: "calc(100vh - 4rem)"
|
|
36
|
-
},
|
|
37
35
|
smDown: {
|
|
36
|
+
[borderRadius]: "0px",
|
|
38
37
|
border: "none",
|
|
39
38
|
inset: 0,
|
|
40
39
|
padding: 0,
|
|
40
|
+
// [offset]: '0px',
|
|
41
|
+
// [inset]: '0px',
|
|
41
42
|
width: "100vw",
|
|
42
43
|
height: "100vh"
|
|
44
|
+
},
|
|
45
|
+
sm: {
|
|
46
|
+
inset: "[var(--_inset) var(--_offset) var(--_offset) var(--_inset)]",
|
|
47
|
+
width: "calc(100vw - var(--_offset) - var(--_inset))",
|
|
48
|
+
height: "calc(100vh - var(--_offset) - var(--_inset))",
|
|
49
|
+
[borderRadius]: "6px",
|
|
50
|
+
padding: "6px",
|
|
51
|
+
[offset]: "1rem"
|
|
52
|
+
},
|
|
53
|
+
md: {
|
|
54
|
+
[offset]: "1rem"
|
|
55
|
+
},
|
|
56
|
+
lg: {
|
|
57
|
+
[offset]: "2rem"
|
|
58
|
+
},
|
|
59
|
+
xl: {
|
|
60
|
+
[offset]: "4rem"
|
|
43
61
|
}
|
|
62
|
+
// inset: '[calc(2rem + var(--_level, 0) * 1rem), 2rem, 2rem, 2rem]',
|
|
63
|
+
// width: 'calc(100vw - 4rem)',
|
|
64
|
+
// height: 'calc(100vh - 4rem - var(--_level, 0) * 1rem)',
|
|
65
|
+
// },
|
|
66
|
+
// lg: {
|
|
67
|
+
// inset: '[calc(4rem + var(--_level, 0) * 1rem), 4rem, 4rem, 4rem]',
|
|
68
|
+
// width: 'calc(100vw - 8rem)',
|
|
69
|
+
// height: 'calc(100vh - 8rem)',
|
|
70
|
+
// },
|
|
71
|
+
// xl: {
|
|
72
|
+
// [borderRadius]: '8px',
|
|
73
|
+
// padding: '8px',
|
|
74
|
+
// inset: '[calc(5rem + var(--_level, 0) * 1rem), 5rem, 5rem, 5rem]',
|
|
75
|
+
// width: 'calc(100vw - 10rem)',
|
|
76
|
+
// height: 'calc(100vh - 10rem - var(--_level, 0) * 1rem)',
|
|
77
|
+
// },
|
|
44
78
|
});
|
|
45
|
-
const body = css({
|
|
79
|
+
const body = css.raw({
|
|
46
80
|
position: "relative",
|
|
47
81
|
containerName: "overlay-dialog",
|
|
48
82
|
containerType: "size",
|
|
49
83
|
border: `0 solid transparent`,
|
|
50
|
-
borderRadius: `calc(${borderRadius} - 2px)`,
|
|
51
84
|
background: "mantine.colors.body",
|
|
52
85
|
overflow: "hidden",
|
|
53
86
|
width: "100%",
|
|
54
|
-
height: "100%"
|
|
87
|
+
height: "100%",
|
|
88
|
+
sm: {
|
|
89
|
+
borderRadius: `calc(var(${borderRadius}) - 2px)`
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const overlay = sva({
|
|
93
|
+
slots: ["dialog", "body"],
|
|
94
|
+
base: {
|
|
95
|
+
dialog,
|
|
96
|
+
body
|
|
97
|
+
},
|
|
98
|
+
variants: {
|
|
99
|
+
level: {
|
|
100
|
+
0: {
|
|
101
|
+
dialog: {
|
|
102
|
+
[level]: "0"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
1: {
|
|
106
|
+
dialog: {
|
|
107
|
+
[level]: "1"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
2: {
|
|
111
|
+
dialog: {
|
|
112
|
+
[level]: "2"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
3: {
|
|
116
|
+
dialog: {
|
|
117
|
+
[level]: "3"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
55
122
|
});
|
|
56
123
|
|
|
57
|
-
export { backdropBlur, backdropOpacity,
|
|
124
|
+
export { backdropBlur, backdropOpacity, level, overlay };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ForwardRefExoticComponent, ReactNode, RefAttributes } from 'react';
|
|
2
|
+
export declare const Overlay: ForwardRefExoticComponent<{
|
|
3
|
+
overlayLevel?: 0 | 1 | 2 | 3;
|
|
4
|
+
className?: string;
|
|
4
5
|
classes?: {
|
|
5
6
|
dialog?: string;
|
|
6
7
|
body?: string;
|
|
7
8
|
};
|
|
8
9
|
onClose: () => void;
|
|
9
10
|
onClick?: never;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
} & {
|
|
12
|
+
children?: ReactNode | undefined;
|
|
13
|
+
} & RefAttributes<HTMLDialogElement>>;
|
|
@@ -3,16 +3,17 @@ import { cx } from '@likec4/styles/css';
|
|
|
3
3
|
import { RemoveScroll, Box } from '@mantine/core';
|
|
4
4
|
import { useMergedRef } from '@mantine/hooks';
|
|
5
5
|
import { useSyncedRef, useDebouncedCallback, useTimeoutEffect } from '@react-hookz/web';
|
|
6
|
-
import { m } from 'framer-motion';
|
|
6
|
+
import { useReducedMotionConfig, m } from 'framer-motion';
|
|
7
7
|
import { forwardRef, useState, useRef, useLayoutEffect } from 'react';
|
|
8
|
-
import {
|
|
8
|
+
import { overlay, backdropOpacity, backdropBlur } from './Overlay.css.js';
|
|
9
9
|
import { stopPropagation } from '../../utils/xyflow.js';
|
|
10
10
|
|
|
11
11
|
const Overlay = forwardRef(
|
|
12
|
-
({ children, onClose, className, classes, ...rest }, ref) => {
|
|
12
|
+
({ children, onClose, className, classes, overlayLevel = 0, ...rest }, ref) => {
|
|
13
13
|
const [opened, setOpened] = useState(false);
|
|
14
14
|
const dialogRef = useRef(null);
|
|
15
15
|
const isClosingRef = useRef(false);
|
|
16
|
+
const motionNotReduced = useReducedMotionConfig() !== true;
|
|
16
17
|
const onCloseRef = useSyncedRef(onClose);
|
|
17
18
|
const close = useDebouncedCallback(
|
|
18
19
|
() => {
|
|
@@ -37,42 +38,48 @@ const Overlay = forwardRef(
|
|
|
37
38
|
if (!dialogRef.current?.open) {
|
|
38
39
|
dialogRef.current?.showModal();
|
|
39
40
|
}
|
|
40
|
-
},
|
|
41
|
+
}, 20);
|
|
41
42
|
useTimeoutEffect(() => {
|
|
42
43
|
setOpened(true);
|
|
43
44
|
}, 120);
|
|
45
|
+
const styles = overlay({
|
|
46
|
+
level: overlayLevel
|
|
47
|
+
});
|
|
44
48
|
return /* @__PURE__ */ jsx(
|
|
45
49
|
m.dialog,
|
|
46
50
|
{
|
|
47
51
|
ref: useMergedRef(dialogRef, ref),
|
|
48
|
-
className: cx(RemoveScroll.classNames.fullWidth, dialog, classes?.dialog, className),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
className: cx(RemoveScroll.classNames.fullWidth, styles.dialog, classes?.dialog, className),
|
|
53
|
+
layout: true,
|
|
54
|
+
...motionNotReduced ? {
|
|
55
|
+
initial: {
|
|
56
|
+
[backdropBlur]: "0px",
|
|
57
|
+
[backdropOpacity]: "0%",
|
|
58
|
+
scale: overlayLevel > 0 ? 0.9 : 1.075,
|
|
59
|
+
opacity: 0
|
|
60
|
+
},
|
|
61
|
+
animate: {
|
|
62
|
+
[backdropBlur]: overlayLevel > 0 ? "4px" : "8px",
|
|
63
|
+
[backdropOpacity]: overlayLevel > 0 ? "50%" : "60%",
|
|
64
|
+
scale: 1,
|
|
65
|
+
opacity: 1,
|
|
66
|
+
translateY: 0,
|
|
67
|
+
transition: {
|
|
68
|
+
delay: 0.075
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
exit: {
|
|
72
|
+
scale: 1.3,
|
|
73
|
+
opacity: 0,
|
|
74
|
+
translateY: -10,
|
|
75
|
+
[backdropBlur]: "0px",
|
|
76
|
+
[backdropOpacity]: "0%"
|
|
77
|
+
}
|
|
78
|
+
} : {
|
|
79
|
+
initial: {
|
|
80
|
+
[backdropBlur]: "8px",
|
|
81
|
+
[backdropOpacity]: "60%"
|
|
66
82
|
}
|
|
67
|
-
},
|
|
68
|
-
exit: {
|
|
69
|
-
scale: 1.3,
|
|
70
|
-
opacity: 0,
|
|
71
|
-
[backdropBlur]: "0px",
|
|
72
|
-
[backdropOpacity]: "0%"
|
|
73
|
-
// transition: {
|
|
74
|
-
// duration: 0.2,
|
|
75
|
-
// },
|
|
76
83
|
},
|
|
77
84
|
onClick: (e) => {
|
|
78
85
|
e.stopPropagation();
|
|
@@ -88,7 +95,7 @@ const Overlay = forwardRef(
|
|
|
88
95
|
close();
|
|
89
96
|
},
|
|
90
97
|
...rest,
|
|
91
|
-
children: /* @__PURE__ */ jsx(RemoveScroll, { forwardProps: true, removeScrollBar: false, children: /* @__PURE__ */ jsx(Box, { className: cx(body, "overlay-body", classes?.body), children: opened && /* @__PURE__ */ jsx(Fragment, { children }) }) })
|
|
98
|
+
children: /* @__PURE__ */ jsx(RemoveScroll, { forwardProps: true, removeScrollBar: false, children: /* @__PURE__ */ jsx(Box, { className: cx(styles.body, "overlay-body", classes?.body), children: opened && /* @__PURE__ */ jsx(Fragment, { children }) }) })
|
|
92
99
|
}
|
|
93
100
|
);
|
|
94
101
|
}
|
|
@@ -88,8 +88,8 @@ const overlaysActorLogic = setup({
|
|
|
88
88
|
const currentOverlay = last(context.overlays);
|
|
89
89
|
if (currentOverlay?.type === "relationshipDetails") {
|
|
90
90
|
enqueue.sendTo(currentOverlay.id, {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
...event,
|
|
92
|
+
type: "navigate.to"
|
|
93
93
|
});
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { invariant, nonNullable, ifind, isAncestor } from '@likec4/core';
|
|
2
3
|
import { ActionIcon, Group } from '@mantine/core';
|
|
3
|
-
import {
|
|
4
|
+
import { useCallbackRef, useStateHistory } from '@mantine/hooks';
|
|
4
5
|
import { IconX, IconChevronLeft, IconChevronRight } from '@tabler/icons-react';
|
|
5
|
-
import {
|
|
6
|
+
import { useSelector } from '@xstate/react';
|
|
7
|
+
import { ReactFlowProvider, Panel, useStoreApi, useReactFlow } from '@xyflow/react';
|
|
6
8
|
import clsx from 'clsx';
|
|
9
|
+
import { deepEqual } from 'fast-equals';
|
|
7
10
|
import { LayoutGroup, AnimatePresence, m } from 'framer-motion';
|
|
8
|
-
import { useRef, memo, useEffect } from 'react';
|
|
11
|
+
import { useRef, memo, useMemo, useEffect } from 'react';
|
|
12
|
+
import 'remeda';
|
|
9
13
|
import { BaseXYFlow } from '../../base/BaseXYFlow.js';
|
|
10
|
-
import {
|
|
14
|
+
import { useLikeC4Model } from '../../likec4model/useLikeC4Model.js';
|
|
15
|
+
import { computeEdgeDetailsViewData, computeRelationshipDetailsViewData } from './compute.js';
|
|
16
|
+
import { RelationshipDetailsActorContext, useRelationshipDetails, useRelationshipDetailsState, useRelationshipDetailsActor } from './hooks.js';
|
|
17
|
+
import { layoutRelationshipDetails } from './layout.js';
|
|
11
18
|
import { SelectEdge } from './SelectEdge.js';
|
|
12
|
-
import { useLayoutedDetails } from './useLayoutedDetails.js';
|
|
13
19
|
import { RelationshipEdge } from './custom/edgeTypes.js';
|
|
14
20
|
import { CompoundNode, ElementNode } from './custom/nodeTypes.js';
|
|
15
21
|
|
|
@@ -28,50 +34,68 @@ function RelationshipDetails({ actorRef }) {
|
|
|
28
34
|
defaultEdges: []
|
|
29
35
|
};
|
|
30
36
|
}
|
|
31
|
-
return /* @__PURE__ */ jsx(RelationshipDetailsActorContext.Provider, { value: actorRef, children: /* @__PURE__ */
|
|
37
|
+
return /* @__PURE__ */ jsx(RelationshipDetailsActorContext.Provider, { value: actorRef, children: /* @__PURE__ */ jsxs(ReactFlowProvider, { ...initialRef.current, children: [
|
|
38
|
+
/* @__PURE__ */ jsx(LayoutGroup, { id: actorRef.sessionId, inherit: false, children: /* @__PURE__ */ jsx(AnimatePresence, { children: /* @__PURE__ */ jsx(RelationshipDetailsInner, {}) }) }),
|
|
39
|
+
/* @__PURE__ */ jsx(SyncRelationshipDetailsXYFlow, {})
|
|
40
|
+
] }) });
|
|
32
41
|
}
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
const selectSubject = (state) => ({
|
|
43
|
+
...state.context.subject,
|
|
44
|
+
viewId: state.context.viewId
|
|
45
|
+
});
|
|
46
|
+
function SyncRelationshipDetailsXYFlow() {
|
|
47
|
+
const actor = useRelationshipDetailsActor();
|
|
48
|
+
const subject = useSelector(actor, selectSubject, deepEqual);
|
|
49
|
+
const likec4model = useLikeC4Model(true);
|
|
50
|
+
const view = likec4model.findView(subject.viewId) ?? null;
|
|
51
|
+
const data = useMemo(() => {
|
|
52
|
+
let data2;
|
|
53
|
+
if ("edgeId" in subject) {
|
|
54
|
+
invariant(view, `view ${subject.viewId} not found`);
|
|
55
|
+
const edge = nonNullable(view.findEdge(subject.edgeId), `edge ${subject.edgeId} not found in ${subject.viewId}`);
|
|
56
|
+
data2 = computeEdgeDetailsViewData([edge.id], view);
|
|
57
|
+
} else {
|
|
58
|
+
data2 = computeRelationshipDetailsViewData({
|
|
59
|
+
source: likec4model.element(subject.source),
|
|
60
|
+
target: likec4model.element(subject.target)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return layoutRelationshipDetails(data2, view);
|
|
64
|
+
}, [
|
|
65
|
+
subject,
|
|
66
|
+
view,
|
|
67
|
+
likec4model
|
|
68
|
+
]);
|
|
69
|
+
const store = useStoreApi();
|
|
70
|
+
const instance = useReactFlow();
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (instance.viewportInitialized) {
|
|
73
|
+
actor.send({ type: "xyflow.init", instance, store });
|
|
74
|
+
}
|
|
75
|
+
}, [store, instance.viewportInitialized, actor]);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
actor.send({ type: "update.layoutData", data });
|
|
78
|
+
}, [data, actor]);
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const selector = ({ context }) => ({
|
|
82
|
+
// subject: context.subject,
|
|
83
|
+
// view: state.context.view,
|
|
84
|
+
initialized: context.initialized.xydata && context.initialized.xyflow,
|
|
85
|
+
nodes: context.xynodes,
|
|
86
|
+
edges: context.xyedges
|
|
39
87
|
});
|
|
40
88
|
const RelationshipDetailsInner = memo(() => {
|
|
41
89
|
const browser = useRelationshipDetails();
|
|
42
90
|
const {
|
|
43
|
-
edgeId,
|
|
44
|
-
view,
|
|
45
91
|
initialized,
|
|
46
92
|
nodes,
|
|
47
93
|
edges
|
|
48
|
-
} = useRelationshipDetailsState(selector);
|
|
49
|
-
const {
|
|
50
|
-
edge,
|
|
51
|
-
xynodes,
|
|
52
|
-
xyedges,
|
|
53
|
-
bounds
|
|
54
|
-
} = useLayoutedDetails(edgeId, view);
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
browser.send({ type: "update.xydata", xynodes, xyedges });
|
|
57
|
-
}, [xynodes, xyedges]);
|
|
58
|
-
const [historyEdgeId, historyOps, { history, current }] = useStateHistory(edgeId);
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
if (historyEdgeId !== edgeId) {
|
|
61
|
-
historyOps.set(edgeId);
|
|
62
|
-
}
|
|
63
|
-
}, [edgeId]);
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (historyEdgeId !== edgeId) {
|
|
66
|
-
browser.navigateTo(historyEdgeId);
|
|
67
|
-
}
|
|
68
|
-
}, [historyEdgeId]);
|
|
69
|
-
const hasStepBack = current > 0;
|
|
70
|
-
const hasStepForward = current + 1 < history.length;
|
|
94
|
+
} = useRelationshipDetailsState(selector, deepEqual);
|
|
71
95
|
return /* @__PURE__ */ jsxs(
|
|
72
96
|
BaseXYFlow,
|
|
73
97
|
{
|
|
74
|
-
id:
|
|
98
|
+
id: browser.rootElementId,
|
|
75
99
|
nodes,
|
|
76
100
|
edges,
|
|
77
101
|
className: clsx(initialized ? "initialized" : "not-initialized"),
|
|
@@ -84,29 +108,32 @@ const RelationshipDetailsInner = memo(() => {
|
|
|
84
108
|
browser.send({ type: "xyflow.applyEdgeChanges", changes });
|
|
85
109
|
}),
|
|
86
110
|
fitViewPadding: 0.05,
|
|
87
|
-
onInit: useCallbackRef((instance) => {
|
|
88
|
-
browser.send({ type: "xyflow.init", instance });
|
|
89
|
-
}),
|
|
90
111
|
onNodeClick: useCallbackRef((e, node) => {
|
|
91
112
|
e.stopPropagation();
|
|
92
113
|
browser.send({ type: "xyflow.nodeClick", node });
|
|
93
114
|
}),
|
|
94
|
-
onEdgeClick: useCallbackRef((e,
|
|
115
|
+
onEdgeClick: useCallbackRef((e, edge) => {
|
|
95
116
|
e.stopPropagation();
|
|
96
|
-
browser.send({ type: "xyflow.edgeClick", edge
|
|
117
|
+
browser.send({ type: "xyflow.edgeClick", edge });
|
|
97
118
|
}),
|
|
98
119
|
onPaneClick: useCallbackRef((e) => {
|
|
99
|
-
e.stopPropagation();
|
|
100
120
|
browser.send({ type: "xyflow.paneClick" });
|
|
101
121
|
}),
|
|
122
|
+
onDoubleClick: useCallbackRef((e) => {
|
|
123
|
+
browser.send({ type: "xyflow.paneDblClick" });
|
|
124
|
+
}),
|
|
102
125
|
onViewportResize: useCallbackRef(() => {
|
|
103
126
|
browser.send({ type: "xyflow.resized" });
|
|
104
127
|
}),
|
|
105
|
-
onEdgeMouseEnter: useCallbackRef((_event,
|
|
106
|
-
|
|
128
|
+
onEdgeMouseEnter: useCallbackRef((_event, edge) => {
|
|
129
|
+
if (!edge.data.hovered) {
|
|
130
|
+
browser.send({ type: "xyflow.edgeMouseEnter", edge });
|
|
131
|
+
}
|
|
107
132
|
}),
|
|
108
|
-
onEdgeMouseLeave: useCallbackRef((_event,
|
|
109
|
-
|
|
133
|
+
onEdgeMouseLeave: useCallbackRef((_event, edge) => {
|
|
134
|
+
if (edge.data.hovered) {
|
|
135
|
+
browser.send({ type: "xyflow.edgeMouseLeave", edge });
|
|
136
|
+
}
|
|
110
137
|
}),
|
|
111
138
|
onSelectionChange: useCallbackRef((params) => {
|
|
112
139
|
browser.send({ type: "xyflow.selectionChange", ...params });
|
|
@@ -116,17 +143,7 @@ const RelationshipDetailsInner = memo(() => {
|
|
|
116
143
|
pannable: true,
|
|
117
144
|
zoomable: true,
|
|
118
145
|
children: [
|
|
119
|
-
/* @__PURE__ */ jsx(
|
|
120
|
-
TopLeftPanel,
|
|
121
|
-
{
|
|
122
|
-
edge,
|
|
123
|
-
view,
|
|
124
|
-
hasStepBack,
|
|
125
|
-
hasStepForward,
|
|
126
|
-
onStepBack: () => historyOps.back(),
|
|
127
|
-
onStepForward: () => historyOps.forward()
|
|
128
|
-
}
|
|
129
|
-
),
|
|
146
|
+
/* @__PURE__ */ jsx(TopLeftPanel, {}),
|
|
130
147
|
/* @__PURE__ */ jsx(Panel, { position: "top-right", children: /* @__PURE__ */ jsx(
|
|
131
148
|
ActionIcon,
|
|
132
149
|
{
|
|
@@ -143,15 +160,41 @@ const RelationshipDetailsInner = memo(() => {
|
|
|
143
160
|
}
|
|
144
161
|
);
|
|
145
162
|
});
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
163
|
+
const topLeftPanelselector = ({ context }) => ({
|
|
164
|
+
subject: context.subject,
|
|
165
|
+
viewId: context.viewId
|
|
166
|
+
});
|
|
167
|
+
const TopLeftPanel = memo(() => {
|
|
168
|
+
const { subject, viewId } = useRelationshipDetailsState(topLeftPanelselector, deepEqual);
|
|
169
|
+
const likec4model = useLikeC4Model(true);
|
|
170
|
+
const view = likec4model.findView(viewId);
|
|
171
|
+
if (!view || !view.isDiagram()) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
let edge = "edgeId" in subject ? view.findEdge(subject.edgeId) : ifind(view.edges(), (e) => e.source.element?.id === subject.source && e.target.element?.id === subject.target) ?? ifind(view.edges(), (e) => {
|
|
175
|
+
return (e.source.element?.id === subject.source || isAncestor(e.source.element?.id ?? "--", subject.source)) && (e.target.element?.id === subject.target || isAncestor(e.target.element?.id ?? "", subject.target));
|
|
176
|
+
});
|
|
177
|
+
if (!edge) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
return /* @__PURE__ */ jsx(TopLeftPanelInner, { edge: edge.$edge, view: view.$view });
|
|
181
|
+
});
|
|
182
|
+
const TopLeftPanelInner = ({ edge, view }) => {
|
|
183
|
+
const browser = useRelationshipDetails();
|
|
184
|
+
const edgeId = edge.id;
|
|
185
|
+
const [historyEdgeId, historyOps, { history, current }] = useStateHistory(edge.id);
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
if (historyEdgeId !== edgeId) {
|
|
188
|
+
historyOps.set(edgeId);
|
|
189
|
+
}
|
|
190
|
+
}, [edgeId]);
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
if (historyEdgeId !== edgeId) {
|
|
193
|
+
browser.navigateTo(historyEdgeId);
|
|
194
|
+
}
|
|
195
|
+
}, [historyEdgeId]);
|
|
196
|
+
const hasStepBack = current > 0;
|
|
197
|
+
const hasStepForward = current + 1 < history.length;
|
|
155
198
|
return /* @__PURE__ */ jsx(Panel, { position: "top-left", children: /* @__PURE__ */ jsx(Group, { gap: 4, wrap: "nowrap", children: /* @__PURE__ */ jsxs(AnimatePresence, { mode: "popLayout", children: [
|
|
156
199
|
hasStepBack && /* @__PURE__ */ jsx(
|
|
157
200
|
m.div,
|
|
@@ -170,7 +213,7 @@ const TopLeftPanel = ({
|
|
|
170
213
|
color: "gray",
|
|
171
214
|
onClick: (e) => {
|
|
172
215
|
e.stopPropagation();
|
|
173
|
-
|
|
216
|
+
historyOps.back();
|
|
174
217
|
},
|
|
175
218
|
children: /* @__PURE__ */ jsx(IconChevronLeft, {})
|
|
176
219
|
}
|
|
@@ -195,7 +238,7 @@ const TopLeftPanel = ({
|
|
|
195
238
|
color: "gray",
|
|
196
239
|
onClick: (e) => {
|
|
197
240
|
e.stopPropagation();
|
|
198
|
-
|
|
241
|
+
historyOps.forward();
|
|
199
242
|
},
|
|
200
243
|
children: /* @__PURE__ */ jsx(IconChevronRight, {})
|
|
201
244
|
}
|
|
@@ -11,22 +11,28 @@ const SelectEdge = ({
|
|
|
11
11
|
edge,
|
|
12
12
|
view
|
|
13
13
|
}) => {
|
|
14
|
-
const
|
|
14
|
+
const browser = useRelationshipDetails();
|
|
15
15
|
const viewport = useRef(null);
|
|
16
16
|
useMantinePortalProps();
|
|
17
17
|
useComputedColorScheme();
|
|
18
18
|
const edgeSource$1 = view.nodes.find((n) => n.id === edge.source);
|
|
19
19
|
const edgeTarget$1 = view.nodes.find((n) => n.id === edge.target);
|
|
20
|
-
const edges = view.edges.
|
|
20
|
+
const edges = view.edges.flatMap((edge2) => {
|
|
21
21
|
const source = view.nodes.find((n) => n.id === edge2.source);
|
|
22
22
|
const target = view.nodes.find((n) => n.id === edge2.target);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
if (source && target) {
|
|
24
|
+
return {
|
|
25
|
+
id: edge2.id,
|
|
26
|
+
source,
|
|
27
|
+
target,
|
|
28
|
+
label: edge2.label
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return [];
|
|
29
32
|
});
|
|
33
|
+
if (!edgeSource$1 || !edgeTarget$1 || edges.length === 0) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
30
36
|
return /* @__PURE__ */ jsxs(
|
|
31
37
|
Popover,
|
|
32
38
|
{
|
|
@@ -87,7 +93,7 @@ const SelectEdge = ({
|
|
|
87
93
|
"data-selected": e.id === edge.id,
|
|
88
94
|
onClick: (event) => {
|
|
89
95
|
event.stopPropagation();
|
|
90
|
-
|
|
96
|
+
browser.navigateTo(e.id);
|
|
91
97
|
},
|
|
92
98
|
children: [
|
|
93
99
|
/* @__PURE__ */ jsx(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Color, DiagramNode, Fqn, IconUrl, RelationId, RelationshipLineType, ViewId } from '@likec4/core';
|
|
2
2
|
import { Base, NonOptional, ReactFlowEdge, ReactFlowNode } from '../../base/types';
|
|
3
3
|
export declare namespace RelationshipDetailsTypes {
|
|
4
|
+
type Column = 'sources' | 'targets';
|
|
4
5
|
/**
|
|
5
6
|
* The node's incoming and outgoing ports
|
|
6
7
|
*/
|
|
@@ -9,11 +10,13 @@ export declare namespace RelationshipDetailsTypes {
|
|
|
9
10
|
out: string[];
|
|
10
11
|
};
|
|
11
12
|
type ElementNodeData = Base.NodeData<NonOptional<Pick<DiagramNode, 'title' | 'technology' | 'description' | 'color' | 'shape' | 'width' | 'height' | 'navigateTo' | 'style'>> & {
|
|
13
|
+
column: Column;
|
|
12
14
|
fqn: Fqn;
|
|
13
15
|
icon: IconUrl;
|
|
14
16
|
ports: Ports;
|
|
15
17
|
}>;
|
|
16
|
-
type CompoundNodeData = Base.NodeData<NonOptional<Pick<DiagramNode, 'title' | 'color' | '
|
|
18
|
+
type CompoundNodeData = Base.NodeData<NonOptional<Pick<DiagramNode, 'title' | 'color' | 'style'>> & {
|
|
19
|
+
column: Column;
|
|
17
20
|
fqn: Fqn;
|
|
18
21
|
depth: number;
|
|
19
22
|
icon?: IconUrl;
|