@likec4/diagram 1.27.2 → 1.27.3
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 +153 -175
- package/dist/base/primitives/edge/EdgeLabelContainer.js +3 -2
- package/dist/base/primitives/element/ElementActionButtons.js +6 -4
- package/dist/hooks/useDiagram.d.ts +5 -1
- package/dist/hooks/useDiagram.js +9 -20
- package/dist/likec4diagram/DiagramXYFlow.js +6 -6
- package/dist/overlays/overlay/Overlay.css.js +3 -3
- package/dist/overlays/overlay/Overlay.js +1 -3
- package/dist/overlays/relationship-details/actor.d.ts +15 -5
- package/dist/overlays/relationship-details/actor.js +1 -6
- package/dist/overlays/relationship-details/hooks.js +2 -5
- package/dist/overlays/relationship-details/layout-to-xyflow.js +0 -4
- package/dist/overlays/relationships-browser/hooks.js +5 -8
- package/dist/overlays/relationships-browser/layout.d.ts +1 -1
- package/dist/overlays/relationships-browser/layout.js +2 -6
- package/dist/styles.css.js +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/package.json +4 -4
- package/src/base/primitives/edge/EdgeLabelContainer.tsx +7 -5
- package/src/base/primitives/element/ElementActionButtons.tsx +7 -7
- package/src/hooks/useDiagram.ts +8 -19
- package/src/likec4diagram/DiagramXYFlow.tsx +6 -6
- package/src/overlays/Overlays.tsx +1 -1
- package/src/overlays/overlay/Overlay.css.ts +3 -3
- package/src/overlays/overlay/Overlay.tsx +2 -4
- package/src/overlays/relationship-details/actor.ts +1 -6
- package/src/overlays/relationship-details/hooks.ts +2 -5
- package/src/overlays/relationship-details/layout-to-xyflow.ts +2 -25
- package/src/overlays/relationships-browser/hooks.ts +5 -8
- package/src/overlays/relationships-browser/layout.ts +3 -20
- package/src/utils/index.ts +0 -1
- package/dist/utils/types.d.ts +0 -8
- package/src/utils/types.ts +0 -6
|
@@ -74,9 +74,10 @@ function EdgeLabelContainer({
|
|
|
74
74
|
children: /* @__PURE__ */ jsx(
|
|
75
75
|
"div",
|
|
76
76
|
{
|
|
77
|
-
|
|
77
|
+
style: {
|
|
78
78
|
display: "contents"
|
|
79
|
-
}
|
|
79
|
+
},
|
|
80
|
+
// Work around to keep same global selector data-likec4-dimmed
|
|
80
81
|
...isDimmed !== false && {
|
|
81
82
|
"data-likec4-dimmed": isDimmed
|
|
82
83
|
},
|
|
@@ -56,17 +56,19 @@ function ElementActionButtons({
|
|
|
56
56
|
"data-likec4-hovered": isHovered,
|
|
57
57
|
className: cx("nodrag nopan", actionButtons),
|
|
58
58
|
children: buttons.map((button, index) => /* @__PURE__ */ jsx(
|
|
59
|
-
|
|
59
|
+
ActionIcon,
|
|
60
60
|
{
|
|
61
|
+
component: m.button,
|
|
62
|
+
layout: true,
|
|
63
|
+
className: actionBtn({}),
|
|
61
64
|
initial: false,
|
|
62
65
|
whileTap: { scale: 1 },
|
|
63
66
|
whileHover: {
|
|
64
67
|
scale: 1.3
|
|
65
68
|
},
|
|
66
|
-
|
|
67
|
-
onClick: stopPropagation,
|
|
69
|
+
onClick: button.onClick,
|
|
68
70
|
onDoubleClick: stopPropagation,
|
|
69
|
-
children:
|
|
71
|
+
children: button.icon
|
|
70
72
|
},
|
|
71
73
|
`action-button-${id}-${button.key ?? index}`
|
|
72
74
|
))
|
|
@@ -9775,7 +9775,11 @@ export declare function useDiagram(): {
|
|
|
9775
9775
|
readonly 'xyflow.applyEdgeChanges': {
|
|
9776
9776
|
readonly actions: ActionFunction<DiagramContext, {
|
|
9777
9777
|
type: "xyflow.applyEdgeChanges";
|
|
9778
|
-
changes: EdgeChange<
|
|
9778
|
+
changes: EdgeChange<
|
|
9779
|
+
/**
|
|
9780
|
+
* @warning Do not use in render phase
|
|
9781
|
+
*/
|
|
9782
|
+
Types.Edge>[];
|
|
9779
9783
|
}, Events, undefined, Values<{
|
|
9780
9784
|
syncManualLayoutActorLogic: {
|
|
9781
9785
|
src: "syncManualLayoutActorLogic";
|
package/dist/hooks/useDiagram.js
CHANGED
|
@@ -2,44 +2,33 @@ import '@likec4/core';
|
|
|
2
2
|
import { useCallbackRef } from '@mantine/hooks';
|
|
3
3
|
import { useSelector } from '@xstate/react';
|
|
4
4
|
import { shallowEqual } from 'fast-equals';
|
|
5
|
-
import {
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
6
|
import { findDiagramEdge, findDiagramNode } from '../state/utils.js';
|
|
7
7
|
import { useDiagramActorRef } from './safeContext.js';
|
|
8
8
|
|
|
9
9
|
function useDiagram() {
|
|
10
10
|
const actor = useDiagramActorRef();
|
|
11
|
-
const [, startTransition] = useTransition();
|
|
12
11
|
return useMemo(() => ({
|
|
13
12
|
actor,
|
|
14
13
|
send: actor.send,
|
|
15
14
|
navigateTo: (viewId, fromNode) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
...fromNode && { fromNode }
|
|
21
|
-
});
|
|
15
|
+
actor.send({
|
|
16
|
+
type: "navigate.to",
|
|
17
|
+
viewId,
|
|
18
|
+
...fromNode && { fromNode }
|
|
22
19
|
});
|
|
23
20
|
},
|
|
24
21
|
navigate: (direction) => {
|
|
25
|
-
|
|
26
|
-
actor.send({ type: `navigate.${direction}` });
|
|
27
|
-
});
|
|
22
|
+
actor.send({ type: `navigate.${direction}` });
|
|
28
23
|
},
|
|
29
24
|
fitDiagram: (duration = 350) => {
|
|
30
|
-
|
|
31
|
-
actor.send({ type: "fitDiagram", duration });
|
|
32
|
-
});
|
|
25
|
+
actor.send({ type: "fitDiagram", duration });
|
|
33
26
|
},
|
|
34
27
|
openRelationshipsBrowser: (fqn) => {
|
|
35
|
-
|
|
36
|
-
actor.send({ type: "open.relationshipsBrowser", fqn });
|
|
37
|
-
});
|
|
28
|
+
actor.send({ type: "open.relationshipsBrowser", fqn });
|
|
38
29
|
},
|
|
39
30
|
openSource: (params) => {
|
|
40
|
-
|
|
41
|
-
actor.send({ type: "open.source", ...params });
|
|
42
|
-
});
|
|
31
|
+
actor.send({ type: "open.source", ...params });
|
|
43
32
|
},
|
|
44
33
|
openElementDetails: (fqn, fromNode) => {
|
|
45
34
|
actor.send({ type: "open.elementDetails", fqn, fromNode });
|
|
@@ -57,15 +57,13 @@ const LikeC4DiagramXYFlow = memo(({
|
|
|
57
57
|
onCanvasDblClick
|
|
58
58
|
} = useDiagramEventHandlers();
|
|
59
59
|
const notReadOnly = !enableReadOnly, isReducedGraphics = useIsReducedGraphics(), layoutConstraints = useLayoutConstraints(), $isPanning = usePanningAtom(), isPanning = useTimeout(() => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
}, isReducedGraphics ? 150 : 350), notPanning = useDebouncedCallback(() => {
|
|
60
|
+
$isPanning.set(true);
|
|
61
|
+
}, isReducedGraphics ? 100 : 200), notPanning = useDebouncedCallback(() => {
|
|
64
62
|
isPanning.clear();
|
|
65
63
|
if ($isPanning.get()) {
|
|
66
64
|
$isPanning.set(false);
|
|
67
65
|
}
|
|
68
|
-
},
|
|
66
|
+
}, 200), onMove = useCallbackRef((event) => {
|
|
69
67
|
if (!event) {
|
|
70
68
|
return;
|
|
71
69
|
}
|
|
@@ -74,7 +72,9 @@ const LikeC4DiagramXYFlow = memo(({
|
|
|
74
72
|
}
|
|
75
73
|
notPanning();
|
|
76
74
|
}), onMoveEnd = useCallbackRef((event, viewport) => {
|
|
77
|
-
|
|
75
|
+
if (!!event) {
|
|
76
|
+
notPanning.flush();
|
|
77
|
+
}
|
|
78
78
|
diagram.send({ type: "xyflow.viewportMoved", viewport, manually: !!event });
|
|
79
79
|
}), onViewportResize = useCallbackRef(() => {
|
|
80
80
|
diagram.send({ type: "xyflow.resized" });
|
|
@@ -22,7 +22,7 @@ const dialog = css.raw({
|
|
|
22
22
|
[backdropBlur]: "0px",
|
|
23
23
|
[level]: "0",
|
|
24
24
|
[offset]: "0px",
|
|
25
|
-
[inset]: "calc((1 + var(--_level) * 0.
|
|
25
|
+
[inset]: "calc((1 + var(--_level) * 0.75) * var(--_offset))",
|
|
26
26
|
[backdropOpacity]: "0%",
|
|
27
27
|
_backdrop: {
|
|
28
28
|
cursor: "zoom-out",
|
|
@@ -43,8 +43,8 @@ const dialog = css.raw({
|
|
|
43
43
|
height: "100vh"
|
|
44
44
|
},
|
|
45
45
|
sm: {
|
|
46
|
-
inset: "[var(--_inset) var(--
|
|
47
|
-
width: "calc(100vw -
|
|
46
|
+
inset: "[var(--_inset) var(--_inset) var(--_offset) var(--_inset)]",
|
|
47
|
+
width: "calc(100vw - 2 * var(--_inset))",
|
|
48
48
|
height: "calc(100vh - var(--_offset) - var(--_inset))",
|
|
49
49
|
[borderRadius]: "6px",
|
|
50
50
|
padding: "6px",
|
|
@@ -63,15 +63,13 @@ const Overlay = forwardRef(
|
|
|
63
63
|
[backdropOpacity]: overlayLevel > 0 ? "50%" : "60%",
|
|
64
64
|
scale: 1,
|
|
65
65
|
opacity: 1,
|
|
66
|
-
translateY: 0,
|
|
67
66
|
transition: {
|
|
68
67
|
delay: 0.075
|
|
69
68
|
}
|
|
70
69
|
},
|
|
71
70
|
exit: {
|
|
72
|
-
scale: 1.
|
|
71
|
+
scale: 1.2,
|
|
73
72
|
opacity: 0,
|
|
74
|
-
translateY: -10,
|
|
75
73
|
[backdropBlur]: "0px",
|
|
76
74
|
[backdropOpacity]: "0%"
|
|
77
75
|
}
|
|
@@ -455,12 +455,22 @@ export declare const relationshipDetailsLogic: StateMachine<Readonly<{
|
|
|
455
455
|
}>, {
|
|
456
456
|
type: "update.layoutData";
|
|
457
457
|
data: LayoutResult;
|
|
458
|
-
}, undefined, Events>, {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
458
|
+
}, undefined, Events>, ActionFunction<Readonly<{
|
|
459
|
+
subject: Subject;
|
|
460
|
+
viewId: ViewId;
|
|
461
|
+
xyflow: XYFLowInstance | null;
|
|
462
|
+
xystore: XYStoreApi | null;
|
|
463
|
+
initialized: {
|
|
464
|
+
xydata: boolean;
|
|
465
|
+
xyflow: boolean;
|
|
462
466
|
};
|
|
463
|
-
|
|
467
|
+
xynodes: RelationshipDetailsTypes.Node[];
|
|
468
|
+
xyedges: RelationshipDetailsTypes.Edge[];
|
|
469
|
+
bounds: BBox;
|
|
470
|
+
}>, {
|
|
471
|
+
type: "update.layoutData";
|
|
472
|
+
data: LayoutResult;
|
|
473
|
+
}, Events, undefined, never, never, never, never, never>, ActionFunction<Readonly<{
|
|
464
474
|
subject: Subject;
|
|
465
475
|
viewId: ViewId;
|
|
466
476
|
xyflow: XYFLowInstance | null;
|
|
@@ -218,12 +218,7 @@ const relationshipDetailsLogic = setup({
|
|
|
218
218
|
actions: [
|
|
219
219
|
"updateLayoutData",
|
|
220
220
|
cancel("fitDiagram"),
|
|
221
|
-
{
|
|
222
|
-
type: "xyflow:fitDiagram",
|
|
223
|
-
params: {
|
|
224
|
-
duration: 0
|
|
225
|
-
}
|
|
226
|
-
},
|
|
221
|
+
raise({ type: "fitDiagram", duration: 0 }, { id: "fitDiagram", delay: 50 }),
|
|
227
222
|
raise({ type: "xyflow.updateNodeInternals" }, { delay: 75 })
|
|
228
223
|
]
|
|
229
224
|
},
|
|
@@ -2,7 +2,7 @@ import { nonNullable } from '@likec4/core';
|
|
|
2
2
|
import { useCallbackRef } from '@mantine/hooks';
|
|
3
3
|
import { useSelector } from '@xstate/react';
|
|
4
4
|
import { shallowEqual } from 'fast-equals';
|
|
5
|
-
import { createContext,
|
|
5
|
+
import { createContext, useMemo, useContext } from 'react';
|
|
6
6
|
|
|
7
7
|
const RelationshipDetailsActorContext = createContext(null);
|
|
8
8
|
function useRelationshipDetailsActor() {
|
|
@@ -15,7 +15,6 @@ function useRelationshipDetailsState(selector, compare = shallowEqual) {
|
|
|
15
15
|
}
|
|
16
16
|
function useRelationshipDetails() {
|
|
17
17
|
const actor = useRelationshipDetailsActor();
|
|
18
|
-
const [, startTransition] = useTransition();
|
|
19
18
|
return useMemo(() => ({
|
|
20
19
|
actor,
|
|
21
20
|
get rootElementId() {
|
|
@@ -31,9 +30,7 @@ function useRelationshipDetails() {
|
|
|
31
30
|
}
|
|
32
31
|
},
|
|
33
32
|
fitDiagram: () => {
|
|
34
|
-
|
|
35
|
-
actor.send({ type: "fitDiagram" });
|
|
36
|
-
});
|
|
33
|
+
actor.send({ type: "fitDiagram" });
|
|
37
34
|
},
|
|
38
35
|
close: () => {
|
|
39
36
|
if (actor._parent) {
|
|
@@ -2,7 +2,7 @@ import { nonNullable } from '@likec4/core';
|
|
|
2
2
|
import { useCallbackRef } from '@mantine/hooks';
|
|
3
3
|
import { useSelector } from '@xstate/react';
|
|
4
4
|
import { shallowEqual } from 'fast-equals';
|
|
5
|
-
import { createContext,
|
|
5
|
+
import { createContext, useMemo, useContext } from 'react';
|
|
6
6
|
|
|
7
7
|
const RelationshipsBrowserActorContext = createContext(null);
|
|
8
8
|
function useRelationshipsBrowserActor() {
|
|
@@ -14,7 +14,6 @@ function useRelationshipsBrowserState(selector, compare = shallowEqual) {
|
|
|
14
14
|
}
|
|
15
15
|
function useRelationshipsBrowser() {
|
|
16
16
|
const actor = useRelationshipsBrowserActor();
|
|
17
|
-
const [, startTransition] = useTransition();
|
|
18
17
|
return useMemo(() => ({
|
|
19
18
|
actor,
|
|
20
19
|
get rootElementId() {
|
|
@@ -35,12 +34,10 @@ function useRelationshipsBrowser() {
|
|
|
35
34
|
});
|
|
36
35
|
},
|
|
37
36
|
navigateTo: (subject, fromNode) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
fromNode
|
|
43
|
-
});
|
|
37
|
+
actor.send({
|
|
38
|
+
type: "navigate.to",
|
|
39
|
+
subject,
|
|
40
|
+
fromNode
|
|
44
41
|
});
|
|
45
42
|
},
|
|
46
43
|
fitDiagram: () => {
|
|
@@ -11,7 +11,7 @@ export type LayoutRelationshipsViewResult = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare namespace LayoutRelationshipsViewResult {
|
|
13
13
|
const Empty: ElementKind;
|
|
14
|
-
type Node = DiagramNode & {
|
|
14
|
+
type Node = Omit<DiagramNode, 'deploymentRef' | 'inEdges' | 'outEdges'> & {
|
|
15
15
|
column: RelationshipsBrowserTypes.Column;
|
|
16
16
|
ports: RelationshipsBrowserTypes.Ports;
|
|
17
17
|
existsInCurrentView: boolean;
|
|
@@ -13,7 +13,7 @@ const Sizes = {
|
|
|
13
13
|
edgesep: 25
|
|
14
14
|
},
|
|
15
15
|
edgeLabel: {
|
|
16
|
-
width:
|
|
16
|
+
width: 140,
|
|
17
17
|
height: 10,
|
|
18
18
|
minlen: 1,
|
|
19
19
|
weight: 1
|
|
@@ -235,7 +235,7 @@ function layoutRelationshipsView(data, scope) {
|
|
|
235
235
|
for (const edge of g.edges()) {
|
|
236
236
|
g.setEdge(edge, {
|
|
237
237
|
...Sizes.edgeLabel,
|
|
238
|
-
width: edgeCount >
|
|
238
|
+
width: edgeCount > 25 ? 800 : 400
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
}
|
|
@@ -346,8 +346,6 @@ function layoutRelationshipsView(data, scope) {
|
|
|
346
346
|
width,
|
|
347
347
|
height
|
|
348
348
|
},
|
|
349
|
-
inEdges: [],
|
|
350
|
-
outEdges: [],
|
|
351
349
|
children: [],
|
|
352
350
|
width,
|
|
353
351
|
height,
|
|
@@ -393,8 +391,6 @@ function layoutRelationshipsView(data, scope) {
|
|
|
393
391
|
...element.$element.style
|
|
394
392
|
},
|
|
395
393
|
navigateTo,
|
|
396
|
-
inEdges: [],
|
|
397
|
-
outEdges: [],
|
|
398
394
|
...children.length > 0 && { depth: nodeDepth(id) },
|
|
399
395
|
children,
|
|
400
396
|
width,
|