@likec4/diagram 1.39.0 → 1.39.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/{chunk-Bg7UjtMS.js → chunk-CaxOLfbm.js} +58 -58
- package/bundle/custom.js +22 -22
- package/bundle/index.js +162 -120
- package/dist/LikeC4Diagram.js +4 -2
- package/dist/LikeC4Styles.d.ts +3 -1
- package/dist/LikeC4Styles.js +52 -20
- package/dist/base/primitives/edge/EdgeLabel.js +1 -2
- package/dist/bundle/LikeC4View.js +6 -3
- package/dist/context/RootContainer.d.ts +2 -1
- package/dist/context/RootContainer.js +1 -2
- package/dist/globals.css.js +1 -1
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +75 -68
- package/dist/likec4diagram/relationship-popover/styles.css.js +8 -5
- package/dist/styles-min.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css2.js +1 -1
- package/package.json +4 -4
- package/panda.buildinfo.json +16 -16
- package/src/LikeC4Diagram.tsx +4 -2
- package/src/LikeC4Styles.tsx +50 -22
- package/src/base/primitives/edge/EdgeLabel.tsx +1 -2
- package/src/bundle/LikeC4View.tsx +7 -3
- package/src/context/RootContainer.tsx +2 -2
- package/src/globals.css +2 -2
- package/src/hooks/useReducedGraphics.ts +0 -7
- package/src/likec4diagram/relationship-popover/RelationshipPopover.tsx +49 -41
- package/src/likec4diagram/relationship-popover/styles.css.ts +8 -5
package/dist/LikeC4Diagram.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useId } from '@mantine/hooks';
|
|
2
3
|
import { ReactFlowProvider } from '@xyflow/react';
|
|
3
4
|
import { useRef } from 'react';
|
|
4
5
|
import { ControlsCustomLayoutProvider } from './context/ControlsCustomLayout.js';
|
|
@@ -57,6 +58,7 @@ function LikeC4Diagram({
|
|
|
57
58
|
renderNodes,
|
|
58
59
|
children
|
|
59
60
|
}) {
|
|
61
|
+
const id = useId().replace("mantine-", "likec4-");
|
|
60
62
|
const initialRef = useRef(null);
|
|
61
63
|
if (initialRef.current == null) {
|
|
62
64
|
initialRef.current = {
|
|
@@ -109,8 +111,8 @@ function LikeC4Diagram({
|
|
|
109
111
|
onBurgerMenuClick
|
|
110
112
|
},
|
|
111
113
|
children: /* @__PURE__ */ jsxs(ReduceGraphicsContext, { reduceGraphics: isReducedGraphicsMode, children: [
|
|
112
|
-
/* @__PURE__ */ jsx(LikeC4Styles, {}),
|
|
113
|
-
/* @__PURE__ */ jsx(RootContainer, { className, reduceGraphics: isReducedGraphicsMode, children: /* @__PURE__ */ jsx(
|
|
114
|
+
/* @__PURE__ */ jsx(LikeC4Styles, { id }),
|
|
115
|
+
/* @__PURE__ */ jsx(RootContainer, { id, className, reduceGraphics: isReducedGraphicsMode, children: /* @__PURE__ */ jsx(
|
|
114
116
|
ReactFlowProvider,
|
|
115
117
|
{
|
|
116
118
|
fitView,
|
package/dist/LikeC4Styles.d.ts
CHANGED
package/dist/LikeC4Styles.js
CHANGED
|
@@ -11,7 +11,7 @@ const scheme = (scheme2) => `[data-mantine-color-scheme="${scheme2}"]`;
|
|
|
11
11
|
const whenDark = scheme("dark");
|
|
12
12
|
const whenLight = scheme("light");
|
|
13
13
|
const MAX_DEPTH = 5;
|
|
14
|
-
const generateCompoundColors = (name, colors, depth) => {
|
|
14
|
+
const generateCompoundColors = (rootSelector, name, colors, depth) => {
|
|
15
15
|
const compoundDarkColor = (color) => toHex(
|
|
16
16
|
scale(color, {
|
|
17
17
|
l: -22 - 5 * depth,
|
|
@@ -24,7 +24,7 @@ const generateCompoundColors = (name, colors, depth) => {
|
|
|
24
24
|
s: -3 - 6 * depth
|
|
25
25
|
})
|
|
26
26
|
);
|
|
27
|
-
const selector = `:where([data-likec4-color="${name}"][data-compound-depth="${depth}"])`;
|
|
27
|
+
const selector = `:where(${rootSelector} [data-likec4-color="${name}"][data-compound-depth="${depth}"])`;
|
|
28
28
|
return `
|
|
29
29
|
${selector} {
|
|
30
30
|
--likec4-palette-fill: ${compoundLightColor(colors.elements.fill)};
|
|
@@ -36,8 +36,8 @@ ${whenDark} ${selector} {
|
|
|
36
36
|
}
|
|
37
37
|
`.trim();
|
|
38
38
|
};
|
|
39
|
-
function toStyle(name, colors) {
|
|
40
|
-
const selector = `:where([data-likec4-color=${name}])`;
|
|
39
|
+
function toStyle(rootSelector, name, colors) {
|
|
40
|
+
const selector = `:where(${rootSelector} [data-likec4-color=${name}])`;
|
|
41
41
|
return [
|
|
42
42
|
`
|
|
43
43
|
${selector} {
|
|
@@ -57,36 +57,68 @@ ${whenDark} ${selector} {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
`.trim(),
|
|
60
|
-
...range(1, MAX_DEPTH + 1).map((depth) => generateCompoundColors(name, colors, depth))
|
|
60
|
+
...range(1, MAX_DEPTH + 1).map((depth) => generateCompoundColors(rootSelector, name, colors, depth))
|
|
61
61
|
].join("\n");
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
(color) => toStyle(color, {
|
|
65
|
-
elements: defaultTheme.elements[color],
|
|
66
|
-
relationships: defaultTheme.relationships[color]
|
|
67
|
-
})
|
|
68
|
-
).join("\n");
|
|
69
|
-
function generateCustomColorStyles(customColors) {
|
|
63
|
+
function generateCustomColorStyles(customColors, rootSelector) {
|
|
70
64
|
return pipe(
|
|
71
65
|
entries(customColors),
|
|
72
|
-
map(([name, color]) => toStyle(name, color)),
|
|
66
|
+
map(([name, color]) => toStyle(rootSelector, name, color)),
|
|
73
67
|
join("\n")
|
|
74
68
|
);
|
|
75
69
|
}
|
|
76
|
-
function
|
|
70
|
+
function generateBuiltInColorStyles(rootSelector) {
|
|
71
|
+
return pipe(
|
|
72
|
+
ThemeColors,
|
|
73
|
+
map(
|
|
74
|
+
(color) => toStyle(rootSelector, color, {
|
|
75
|
+
elements: defaultTheme.elements[color],
|
|
76
|
+
relationships: defaultTheme.relationships[color]
|
|
77
|
+
})
|
|
78
|
+
),
|
|
79
|
+
join("\n")
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
function LikeC4Styles({ id }) {
|
|
83
|
+
const rootSelector = `#${id}`;
|
|
77
84
|
const nonce = useMantineStyleNonce()?.();
|
|
78
85
|
const { customColors } = useLikeC4Specification();
|
|
79
|
-
const customColorsStyles = customColors ? generateCustomColorStyles(customColors) : "";
|
|
80
|
-
|
|
86
|
+
const customColorsStyles = customColors ? generateCustomColorStyles(customColors, rootSelector) : "";
|
|
87
|
+
const builtInColors = generateBuiltInColorStyles(rootSelector);
|
|
88
|
+
return /* @__PURE__ */ jsx(
|
|
89
|
+
MemoizedStyles,
|
|
90
|
+
{
|
|
91
|
+
id,
|
|
92
|
+
nonce,
|
|
93
|
+
customColorsStyles,
|
|
94
|
+
builtInColors
|
|
95
|
+
}
|
|
96
|
+
);
|
|
81
97
|
}
|
|
82
|
-
const MemoizedStyles = memo(({ nonce, customColorsStyles, builtInColors
|
|
83
|
-
/* @__PURE__ */ jsx(
|
|
84
|
-
|
|
98
|
+
const MemoizedStyles = memo(({ id, nonce, customColorsStyles, builtInColors }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
"style",
|
|
101
|
+
{
|
|
102
|
+
type: "text/css",
|
|
103
|
+
"data-likec4-global": id,
|
|
104
|
+
dangerouslySetInnerHTML: { __html: globalsCss.replaceAll(".likec4-root", `#${id}.likec4-root`) },
|
|
105
|
+
nonce
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
/* @__PURE__ */ jsx(
|
|
109
|
+
"style",
|
|
110
|
+
{
|
|
111
|
+
type: "text/css",
|
|
112
|
+
"data-likec4-colors": id,
|
|
113
|
+
dangerouslySetInnerHTML: { __html: builtInColors },
|
|
114
|
+
nonce
|
|
115
|
+
}
|
|
116
|
+
),
|
|
85
117
|
customColorsStyles && /* @__PURE__ */ jsx(
|
|
86
118
|
"style",
|
|
87
119
|
{
|
|
88
120
|
type: "text/css",
|
|
89
|
-
"data-likec4-custom-colors":
|
|
121
|
+
"data-likec4-custom-colors": id,
|
|
90
122
|
dangerouslySetInnerHTML: { __html: customColorsStyles },
|
|
91
123
|
nonce
|
|
92
124
|
}
|
|
@@ -35,8 +35,7 @@ const EdgeLabel = forwardRef(({
|
|
|
35
35
|
className: cx(classes.root, "likec4-edge-label", className),
|
|
36
36
|
"data-edge-id": id,
|
|
37
37
|
animate: {
|
|
38
|
-
|
|
39
|
-
scale: isHovered && !selected ? 1.08 : 1
|
|
38
|
+
scale: isHovered && !selected ? 1.06 : 1
|
|
40
39
|
},
|
|
41
40
|
...rest,
|
|
42
41
|
children: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { cx } from '@likec4/styles/css';
|
|
3
3
|
import { Box, ActionIcon } from '@mantine/core';
|
|
4
|
-
import { shallowEqual } from '@mantine/hooks';
|
|
4
|
+
import { useCallbackRef, shallowEqual } from '@mantine/hooks';
|
|
5
5
|
import { memo, useState } from 'react';
|
|
6
6
|
import { isBoolean } from 'remeda';
|
|
7
7
|
import { FramerMotionConfig } from '../context/FramerMotionConfig.js';
|
|
@@ -70,6 +70,9 @@ const LikeC4ViewInner = memo(({
|
|
|
70
70
|
const colorScheme = useColorScheme(explicitColorScheme);
|
|
71
71
|
const [shadowRootProps, cssstyle] = useShadowRootStyle(keepAspectRatio, view);
|
|
72
72
|
const [browserViewId, onNavigateTo] = useState(null);
|
|
73
|
+
const onNavigateToThisView = useCallbackRef(() => {
|
|
74
|
+
onNavigateTo(view.id);
|
|
75
|
+
});
|
|
73
76
|
const browserView = browserViewId ? likec4model.findView(browserViewId)?.$view : null;
|
|
74
77
|
const notations = view.notation?.nodes ?? [];
|
|
75
78
|
const hasNotations = notations.length > 0;
|
|
@@ -136,8 +139,8 @@ const LikeC4ViewInner = memo(({
|
|
|
136
139
|
enableSearch: false,
|
|
137
140
|
...isBrowserEnabled && {
|
|
138
141
|
onNavigateTo,
|
|
139
|
-
onCanvasClick:
|
|
140
|
-
onNodeClick:
|
|
142
|
+
onCanvasClick: onNavigateToThisView,
|
|
143
|
+
onNodeClick: onNavigateToThisView
|
|
141
144
|
},
|
|
142
145
|
reactFlowProps,
|
|
143
146
|
renderNodes,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PropsWithChildren, RefObject } from 'react';
|
|
2
|
-
export declare function RootContainer({ className, reduceGraphics, children, }: PropsWithChildren<{
|
|
2
|
+
export declare function RootContainer({ id, className, reduceGraphics, children, }: PropsWithChildren<{
|
|
3
|
+
id: string;
|
|
3
4
|
className?: string | undefined;
|
|
4
5
|
reduceGraphics?: boolean;
|
|
5
6
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { cx } from '@likec4/styles/css';
|
|
3
3
|
import { Box } from '@likec4/styles/jsx';
|
|
4
|
-
import { useId } from '@mantine/hooks';
|
|
5
4
|
import { useRef, useEffect, createContext, useContext, createRef } from 'react';
|
|
6
5
|
import { usePanningAtom } from './ReduceGraphics.js';
|
|
7
6
|
import { TagStylesProvider } from './TagStylesContext.js';
|
|
8
7
|
|
|
9
8
|
const RootContainerContext = createContext(createRef());
|
|
10
9
|
function RootContainer({
|
|
10
|
+
id,
|
|
11
11
|
className,
|
|
12
12
|
reduceGraphics = false,
|
|
13
13
|
children
|
|
14
14
|
}) {
|
|
15
|
-
const id = useId();
|
|
16
15
|
const ref = useRef(null);
|
|
17
16
|
const $isPanning = usePanningAtom();
|
|
18
17
|
useEffect(() => {
|
package/dist/globals.css.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const globalsCss = ".likec4-shadow-root dialog{color:var(--mantine-color-text)}.likec4-root{overflow:hidden;position:relative;padding:0;margin:0;width:100%;height:100%;border:0px solid transparent;container-name:likec4-root;container-type:size}.likec4-root .react-flow:is(.not-initialized){opacity:0}.likec4-root .react-flow{contain:paint;--xy-background-color: var(--colors-likec4-background);--xy-background-pattern-color: var(--colors-likec4-background-pattern, var(--colors-likec4-background))}.likec4-root .react-flow:is(.bg-transparent){background:transparent!important;--xy-background-color: transparent !important}.likec4-root .react-flow .react-flow__pane{user-select:none;--webkit-user-select: none}.likec4-static-view .react-flow .react-flow__attribution{display:none}:where(.likec4-root .mantine-ActionIcon-icon) .tabler-icon{width:75%;height:75%}.likec4-root .likec4-edge-label-container{top:0;left:0;position:absolute;width:auto;height:auto}.likec4-root :where(.react-flow__node,.react-flow__edge):has([data-likec4-dimmed]){opacity:.25}.likec4-root .likec4-edge-label-container:is([data-likec4-dimmed]){opacity:.25}.likec4-root:not([data-likec4-reduced-graphics]) :where(.react-flow__node,.react-flow__edge):has([data-likec4-dimmed]){filter:grayscale(85%)
|
|
1
|
+
const globalsCss = ".likec4-shadow-root dialog{color:var(--mantine-color-text)}.likec4-root{overflow:hidden;position:relative;padding:0;margin:0;width:100%;height:100%;border:0px solid transparent;container-name:likec4-root;container-type:size}.likec4-root .react-flow:is(.not-initialized){opacity:0}.likec4-root .react-flow{contain:paint;--xy-background-color: var(--colors-likec4-background);--xy-background-pattern-color: var(--colors-likec4-background-pattern, var(--colors-likec4-background))}.likec4-root .react-flow:is(.bg-transparent){background:transparent!important;--xy-background-color: transparent !important}.likec4-root .react-flow .react-flow__pane{user-select:none;--webkit-user-select: none}.likec4-static-view .react-flow .react-flow__attribution{display:none}:where(.likec4-root .mantine-ActionIcon-icon) .tabler-icon{width:75%;height:75%}.likec4-root .likec4-edge-label-container{top:0;left:0;position:absolute;width:auto;height:auto}.likec4-root :where(.react-flow__node,.react-flow__edge):has([data-likec4-dimmed]){opacity:.25}.likec4-root .likec4-edge-label-container:is([data-likec4-dimmed]){opacity:.25}.likec4-root:not([data-likec4-reduced-graphics]) :where(.react-flow__node,.react-flow__edge):has([data-likec4-dimmed]){filter:grayscale(85%)}.likec4-root:not([data-likec4-reduced-graphics]) .likec4-edge-label-container:is([data-likec4-dimmed]){filter:grayscale(85%)}.likec4-root:not([data-likec4-reduced-graphics]) :where(.react-flow__node,.react-flow__edge):has([data-likec4-dimmed=true]){transition-property:opacity,filter;transition-timing-function:cubic-bezier(.5,0,.2,1);transition-duration:.6s}.likec4-root:not([data-likec4-reduced-graphics]) .likec4-edge-label-container:is([data-likec4-dimmed=true]){transition-property:opacity,filter;transition-timing-function:cubic-bezier(.5,0,.2,1);transition-duration:.6s}.likec4-root .react-flow :where(.react-flow__nodes,.react-flow__edges,.react-flow__edgelabel-renderer){display:contents}.likec4-root .react-flow__node.draggable:has(.likec4-compound-node){cursor:default}[data-mantine-color-scheme=dark] .likec4-root:not([data-likec4-reduced-graphics]) :where(.react-flow__edges,.react-flow__edgelabel-renderer)>:where(svg,.likec4-edge-label-container){mix-blend-mode:plus-lighter}[data-mantine-color-scheme=light] .likec4-root:not([data-likec4-reduced-graphics]) :where(.react-flow__edges,.react-flow__edgelabel-renderer)>:where(svg,.likec4-edge-label-container){mix-blend-mode:screen}.likec4-root :where(.likec4-edge-container,.likec4-edge-label-container){--xy-edge-stroke-width: 3;--xy-edge-stroke: var(--likec4-palette-relation-stroke);--xy-edge-stroke-selected: var(--likec4-palette-relation-stroke-selected);--xy-edge-label-color: var(--likec4-palette-relation-label);--xy-edge-label-background-color: var(--likec4-palette-relation-label-bg)}.likec4-root :where(.likec4-edge-container,.likec4-edge-label-container):is([data-likec4-hovered=true],[data-edge-active=true]){--xy-edge-stroke-width: 4;--xy-edge-stroke: var(--likec4-palette-relation-stroke-selected)}[data-mantine-color-scheme=dark] .likec4-root :where(.likec4-edge-container,.likec4-edge-label-container){--xy-edge-label-background-color: color-mix(in srgb, var(--likec4-palette-relation-label-bg) 50%, transparent)}[data-mantine-color-scheme=light] .likec4-root :where(.likec4-edge-container,.likec4-edge-label-container){--xy-edge-label-color: color-mix(in srgb, var(--likec4-palette-relation-label), rgba(255 255 255 / .85) 40%);--xy-edge-label-background-color: color-mix(in srgb, var(--likec4-palette-relation-label-bg) 60%, transparent)}";
|
|
2
2
|
|
|
3
3
|
export { globalsCss as default };
|
|
@@ -4,18 +4,16 @@ import { nameFromFqn } from '@likec4/core';
|
|
|
4
4
|
import { cx, css } from '@likec4/styles/css';
|
|
5
5
|
import { VStack, styled, HStack, Box } from '@likec4/styles/jsx';
|
|
6
6
|
import { bleed } from '@likec4/styles/patterns';
|
|
7
|
-
import { Portal, ScrollAreaAutosize, Button, Divider,
|
|
7
|
+
import { Portal, ScrollAreaAutosize, Button, Divider, TooltipGroup, Tooltip as Tooltip$1, Text, ActionIcon } from '@mantine/core';
|
|
8
8
|
import { useActorRef, useSelector } from '@xstate/react';
|
|
9
9
|
import { shallowEqual } from 'fast-equals';
|
|
10
|
-
import { memo, useCallback, useRef, useState,
|
|
10
|
+
import { memo, useEffect, useCallback, useRef, useState, Fragment as Fragment$1, forwardRef } from 'react';
|
|
11
11
|
import { pipe, map, filter, isTruthy, partition, clamp } from 'remeda';
|
|
12
12
|
import { Link } from '../../components/Link.js';
|
|
13
13
|
import { useDiagramEventHandlers } from '../../context/DiagramEventHandlers.js';
|
|
14
14
|
import { useEnabledFeatures } from '../../context/DiagramFeatures.js';
|
|
15
15
|
import { useDiagram, useDiagramContext, useOnDiagramEvent } from '../../hooks/useDiagram.js';
|
|
16
16
|
import { useMantinePortalProps } from '../../hooks/useMantinePortalProps.js';
|
|
17
|
-
import { useUpdateEffect } from '../../hooks/useUpdateEffect.js';
|
|
18
|
-
import { useXYStore } from '../../hooks/useXYFlow.js';
|
|
19
17
|
import { findDiagramEdge, findDiagramNode } from '../../state/utils.js';
|
|
20
18
|
import { RelationshipPopoverActorLogic } from './actor.js';
|
|
21
19
|
import { endpoint, title } from './styles.css.js';
|
|
@@ -47,9 +45,9 @@ const RelationshipPopover = memo(() => {
|
|
|
47
45
|
const diagram = useDiagram();
|
|
48
46
|
const { viewId, selected } = useDiagramContext(selectDiagramContext);
|
|
49
47
|
const openedEdgeId = useSelector(actorRef, (s) => s.hasTag("opened") ? s.context.edgeId : null);
|
|
50
|
-
|
|
48
|
+
useOnDiagramEvent("viewChange", () => {
|
|
51
49
|
actorRef.send({ type: "close" });
|
|
52
|
-
}
|
|
50
|
+
});
|
|
53
51
|
useOnDiagramEvent("edgeMouseEnter", ({ edge }) => {
|
|
54
52
|
actorRef.send({ type: "xyedge.mouseEnter", edgeId: edge.data.id });
|
|
55
53
|
});
|
|
@@ -62,7 +60,7 @@ const RelationshipPopover = memo(() => {
|
|
|
62
60
|
useOnDiagramEvent("walkthroughStarted", () => {
|
|
63
61
|
actorRef.send({ type: "close" });
|
|
64
62
|
});
|
|
65
|
-
|
|
63
|
+
useEffect(() => {
|
|
66
64
|
if (selected) {
|
|
67
65
|
actorRef.send({ type: "xyedge.select", edgeId: selected });
|
|
68
66
|
} else {
|
|
@@ -121,7 +119,7 @@ const RelationshipPopover = memo(() => {
|
|
|
121
119
|
const getEdgeLabelElement = (edgeId, container) => {
|
|
122
120
|
return container?.querySelector(`.likec4-edge-label[data-edge-id="${edgeId}"]`) ?? null;
|
|
123
121
|
};
|
|
124
|
-
const
|
|
122
|
+
const POPOVER_PADDING = 8;
|
|
125
123
|
const RelationshipPopoverInternal = ({
|
|
126
124
|
viewId,
|
|
127
125
|
diagramEdge,
|
|
@@ -135,10 +133,9 @@ const RelationshipPopoverInternal = ({
|
|
|
135
133
|
const { onOpenSource } = useDiagramEventHandlers();
|
|
136
134
|
const { portalProps } = useMantinePortalProps();
|
|
137
135
|
const [referenceEl, setReferenceEl] = useState(null);
|
|
138
|
-
const viewport = useXYStore(selectTransform);
|
|
139
136
|
useEffect(() => {
|
|
140
137
|
setReferenceEl(getEdgeLabelElement(diagramEdge.id, portalProps?.target));
|
|
141
|
-
}, [diagramEdge
|
|
138
|
+
}, [diagramEdge]);
|
|
142
139
|
useEffect(() => {
|
|
143
140
|
const reference = referenceEl;
|
|
144
141
|
const popper = ref.current;
|
|
@@ -148,11 +145,11 @@ const RelationshipPopoverInternal = ({
|
|
|
148
145
|
let wasCanceled = false;
|
|
149
146
|
const update = () => {
|
|
150
147
|
computePosition(reference, popper, {
|
|
151
|
-
placement: "bottom",
|
|
148
|
+
placement: "bottom-start",
|
|
152
149
|
middleware: [
|
|
153
150
|
offset(2),
|
|
154
151
|
autoPlacement({
|
|
155
|
-
padding:
|
|
152
|
+
padding: POPOVER_PADDING,
|
|
156
153
|
allowedPlacements: [
|
|
157
154
|
"bottom-start",
|
|
158
155
|
"bottom-end",
|
|
@@ -165,19 +162,19 @@ const RelationshipPopoverInternal = ({
|
|
|
165
162
|
]
|
|
166
163
|
}),
|
|
167
164
|
size({
|
|
168
|
-
padding:
|
|
165
|
+
padding: POPOVER_PADDING,
|
|
169
166
|
apply({ availableHeight, availableWidth, elements }) {
|
|
170
167
|
if (wasCanceled) {
|
|
171
168
|
return;
|
|
172
169
|
}
|
|
173
170
|
Object.assign(elements.floating.style, {
|
|
174
|
-
maxWidth: `${clamp(roundDpr(availableWidth), { min:
|
|
171
|
+
maxWidth: `${clamp(roundDpr(availableWidth), { min: 200, max: 400 })}px`,
|
|
175
172
|
maxHeight: `${clamp(roundDpr(availableHeight), { min: 0, max: 500 })}px`
|
|
176
173
|
});
|
|
177
174
|
}
|
|
178
175
|
}),
|
|
179
176
|
hide({
|
|
180
|
-
padding:
|
|
177
|
+
padding: POPOVER_PADDING * 2
|
|
181
178
|
})
|
|
182
179
|
]
|
|
183
180
|
}).then(({ x, y, middlewareData }) => {
|
|
@@ -188,7 +185,10 @@ const RelationshipPopoverInternal = ({
|
|
|
188
185
|
popper.style.visibility = middlewareData.hide?.referenceHidden ? "hidden" : "visible";
|
|
189
186
|
});
|
|
190
187
|
};
|
|
191
|
-
const cleanup = autoUpdate(reference, popper, update
|
|
188
|
+
const cleanup = autoUpdate(reference, popper, update, {
|
|
189
|
+
ancestorResize: false,
|
|
190
|
+
animationFrame: true
|
|
191
|
+
});
|
|
192
192
|
return () => {
|
|
193
193
|
wasCanceled = true;
|
|
194
194
|
cleanup();
|
|
@@ -252,7 +252,7 @@ const RelationshipPopoverInternal = ({
|
|
|
252
252
|
styles: {
|
|
253
253
|
viewport: {
|
|
254
254
|
overscrollBehavior: "contain",
|
|
255
|
-
minWidth:
|
|
255
|
+
minWidth: 180
|
|
256
256
|
}
|
|
257
257
|
},
|
|
258
258
|
className: cx(
|
|
@@ -272,9 +272,9 @@ const RelationshipPopoverInternal = ({
|
|
|
272
272
|
VStack,
|
|
273
273
|
{
|
|
274
274
|
css: {
|
|
275
|
-
gap: "3
|
|
275
|
+
gap: "3",
|
|
276
276
|
padding: "4",
|
|
277
|
-
paddingTop: "2
|
|
277
|
+
paddingTop: "2"
|
|
278
278
|
},
|
|
279
279
|
children: [
|
|
280
280
|
/* @__PURE__ */ jsx(
|
|
@@ -296,12 +296,19 @@ const RelationshipPopoverInternal = ({
|
|
|
296
296
|
}
|
|
297
297
|
),
|
|
298
298
|
direct.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
299
|
-
/* @__PURE__ */ jsx(
|
|
299
|
+
/* @__PURE__ */ jsx(Label, { children: "DIRECT RELATIONSHIPS" }),
|
|
300
300
|
direct.map(renderRelationship)
|
|
301
301
|
] }),
|
|
302
302
|
nested.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
/* @__PURE__ */ jsx(
|
|
304
|
+
Label,
|
|
305
|
+
{
|
|
306
|
+
css: {
|
|
307
|
+
mt: direct.length > 0 ? "2" : "0"
|
|
308
|
+
},
|
|
309
|
+
children: "RESOLVED FROM NESTED"
|
|
310
|
+
}
|
|
311
|
+
),
|
|
305
312
|
nested.map(renderRelationship)
|
|
306
313
|
] })
|
|
307
314
|
]
|
|
@@ -319,8 +326,8 @@ const Relationship = forwardRef(({
|
|
|
319
326
|
onNavigateTo,
|
|
320
327
|
onOpenSource
|
|
321
328
|
}, ref) => {
|
|
322
|
-
const sourceId =
|
|
323
|
-
const targetId =
|
|
329
|
+
const sourceId = getEndpointId(r, "source", sourceNode);
|
|
330
|
+
const targetId = getEndpointId(r, "target", targetNode);
|
|
324
331
|
const navigateTo = onNavigateTo && r.navigateTo?.id !== viewId ? r.navigateTo?.id : void 0;
|
|
325
332
|
const links = r.links;
|
|
326
333
|
return /* @__PURE__ */ jsxs(
|
|
@@ -330,8 +337,8 @@ const Relationship = forwardRef(({
|
|
|
330
337
|
className: bleed({
|
|
331
338
|
block: "2",
|
|
332
339
|
inline: "2",
|
|
333
|
-
|
|
334
|
-
|
|
340
|
+
paddingY: "2.5",
|
|
341
|
+
paddingX: "2",
|
|
335
342
|
gap: "1",
|
|
336
343
|
rounded: "sm",
|
|
337
344
|
backgroundColor: {
|
|
@@ -342,44 +349,42 @@ const Relationship = forwardRef(({
|
|
|
342
349
|
}
|
|
343
350
|
}),
|
|
344
351
|
children: [
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
-
/* @__PURE__ */ jsx(Text, { component: "div", "data-likec4-color": sourceNode.color, className: endpoint, children: sourceId }),
|
|
352
|
+
/* @__PURE__ */ jsx(HStack, { gap: "0.5", children: /* @__PURE__ */ jsxs(TooltipGroup, { openDelay: 200, children: [
|
|
353
|
+
/* @__PURE__ */ jsx(Tooltip, { label: sourceId.full, offset: 2, position: "top-start", children: /* @__PURE__ */ jsx(Text, { component: "div", "data-likec4-color": sourceNode.color, className: endpoint, children: sourceId.short }) }),
|
|
347
354
|
/* @__PURE__ */ jsx(IconArrowRight, { stroke: 2.5, size: "11px", opacity: 0.65 }),
|
|
348
|
-
/* @__PURE__ */ jsx(Text, { component: "div", "data-likec4-color": targetNode.color, className: endpoint, children: targetId }),
|
|
349
|
-
/* @__PURE__ */
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
] })
|
|
382
|
-
] }),
|
|
355
|
+
/* @__PURE__ */ jsx(Tooltip, { label: targetId.full, offset: 2, position: "top-start", children: /* @__PURE__ */ jsx(Text, { component: "div", "data-likec4-color": targetNode.color, className: endpoint, children: targetId.short }) }),
|
|
356
|
+
navigateTo && /* @__PURE__ */ jsx(Tooltip, { label: "Open dynamic view", children: /* @__PURE__ */ jsx(
|
|
357
|
+
ActionIcon,
|
|
358
|
+
{
|
|
359
|
+
size: "sm",
|
|
360
|
+
radius: "sm",
|
|
361
|
+
variant: "default",
|
|
362
|
+
onClick: (event) => {
|
|
363
|
+
event.stopPropagation();
|
|
364
|
+
onNavigateTo?.(navigateTo);
|
|
365
|
+
},
|
|
366
|
+
style: {
|
|
367
|
+
alignSelf: "flex-end"
|
|
368
|
+
},
|
|
369
|
+
role: "button",
|
|
370
|
+
children: /* @__PURE__ */ jsx(IconZoomScan, { size: "80%", stroke: 2 })
|
|
371
|
+
}
|
|
372
|
+
) }),
|
|
373
|
+
onOpenSource && /* @__PURE__ */ jsx(Tooltip, { label: "Open source", children: /* @__PURE__ */ jsx(
|
|
374
|
+
ActionIcon,
|
|
375
|
+
{
|
|
376
|
+
size: "sm",
|
|
377
|
+
radius: "sm",
|
|
378
|
+
variant: "default",
|
|
379
|
+
onClick: (event) => {
|
|
380
|
+
event.stopPropagation();
|
|
381
|
+
onOpenSource();
|
|
382
|
+
},
|
|
383
|
+
role: "button",
|
|
384
|
+
children: /* @__PURE__ */ jsx(IconFileSymlink, { size: "80%", stroke: 2 })
|
|
385
|
+
}
|
|
386
|
+
) })
|
|
387
|
+
] }) }),
|
|
383
388
|
/* @__PURE__ */ jsx(Box, { className: title, children: r.title || "untitled" }),
|
|
384
389
|
r.kind && /* @__PURE__ */ jsxs(HStack, { gap: "2", children: [
|
|
385
390
|
/* @__PURE__ */ jsx(Label, { children: "kind" }),
|
|
@@ -415,13 +420,13 @@ const Relationship = forwardRef(({
|
|
|
415
420
|
}
|
|
416
421
|
);
|
|
417
422
|
});
|
|
418
|
-
const Label = styled("
|
|
423
|
+
const Label = styled("div", {
|
|
419
424
|
base: {
|
|
420
|
-
display: "
|
|
425
|
+
display: "block",
|
|
421
426
|
fontSize: "xxs",
|
|
422
427
|
fontWeight: 500,
|
|
423
428
|
userSelect: "none",
|
|
424
|
-
lineHeight: "
|
|
429
|
+
lineHeight: "sm",
|
|
425
430
|
color: "mantine.colors.dimmed"
|
|
426
431
|
}
|
|
427
432
|
});
|
|
@@ -433,9 +438,11 @@ const Tooltip = Tooltip$1.withProps({
|
|
|
433
438
|
offset: 8,
|
|
434
439
|
withinPortal: false
|
|
435
440
|
});
|
|
436
|
-
function
|
|
441
|
+
function getEndpointId(r, endpoint, diagramNode) {
|
|
437
442
|
const diagramNodeId = r.isDeploymentRelation() ? diagramNode.id : diagramNode.modelRef || "";
|
|
438
|
-
|
|
443
|
+
const full = r[endpoint].id;
|
|
444
|
+
const short = nameFromFqn(diagramNodeId) + full.slice(diagramNodeId.length);
|
|
445
|
+
return { full, short };
|
|
439
446
|
}
|
|
440
447
|
|
|
441
448
|
export { RelationshipPopover };
|
|
@@ -5,13 +5,16 @@ const endpoint = css({
|
|
|
5
5
|
fontSize: "xxs",
|
|
6
6
|
fontWeight: 500,
|
|
7
7
|
whiteSpace: "nowrap",
|
|
8
|
-
|
|
8
|
+
paddingX: "1",
|
|
9
|
+
paddingY: "0.5",
|
|
9
10
|
borderRadius: "[2px]",
|
|
10
|
-
background:
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
background: {
|
|
12
|
+
_light: "var(--likec4-palette-fill)/90",
|
|
13
|
+
_dark: "var(--likec4-palette-fill)/60"
|
|
14
|
+
},
|
|
15
|
+
lineHeight: "1",
|
|
13
16
|
color: {
|
|
14
|
-
_light:
|
|
17
|
+
_light: "var(--likec4-palette-hiContrast)",
|
|
15
18
|
_dark: "var(--likec4-palette-loContrast)"
|
|
16
19
|
}
|
|
17
20
|
});
|