@likec4/diagram 1.38.1 → 1.39.1
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-BZV0K82k.js → chunk-CaxOLfbm.js} +277 -271
- package/bundle/custom.js +39 -39
- package/bundle/index.js +354 -240
- package/dist/LikeC4Diagram.js +4 -2
- package/dist/LikeC4Diagram.props.d.ts +15 -8
- package/dist/LikeC4Styles.d.ts +3 -1
- package/dist/LikeC4Styles.js +52 -20
- package/dist/base/BaseXYFlow.js +5 -5
- package/dist/base/index.d.ts +1 -2
- package/dist/base/primitives/MarkdownBlock.js +2 -1
- package/dist/base/primitives/customEdge.d.ts +3 -3
- package/dist/base/primitives/edge/EdgeLabel.js +1 -2
- package/dist/base/primitives/element/ElementTitle.js +2 -10
- package/dist/base/types.d.ts +62 -5
- package/dist/base/types.js +54 -0
- package/dist/bundle/LikeC4View.d.ts +2 -2
- package/dist/bundle/LikeC4View.props.d.ts +4 -3
- package/dist/bundle/ReactLikeC4.d.ts +4 -4
- package/dist/context/RootContainer.d.ts +2 -1
- package/dist/context/RootContainer.js +1 -2
- package/dist/custom/customNodes.d.ts +2 -1
- package/dist/globals.css.js +1 -1
- package/dist/hooks/useXYFlow.d.ts +28 -29
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +4 -5
- package/dist/likec4diagram/custom/nodes/ElementActions.js +1 -1
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +75 -68
- package/dist/likec4diagram/relationship-popover/styles.css.js +8 -5
- package/dist/likec4diagram/types.d.ts +2 -1
- package/dist/likec4diagram/useViewToNodesEdges.js +1 -1
- package/dist/likec4model/LikeC4ModelContext.d.ts +5 -2
- package/dist/likec4model/useLikeC4ElementsTree.js +1 -1
- package/dist/likec4model/useLikeC4Model.d.ts +7 -20
- package/dist/navigationpanel/NavigationPanel.js +3 -1
- package/dist/navigationpanel/NavigationPanelDropdown.js +1 -1
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +6 -4
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.d.ts +1 -0
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +83 -0
- package/dist/overlays/element-details/actor.d.ts +556 -557
- package/dist/overlays/relationship-details/RelationshipDetails.d.ts +2 -3
- package/dist/overlays/relationship-details/actor.d.ts +1 -1
- package/dist/overlays/relationship-details/actor.js +7 -7
- package/dist/overlays/relationship-details/compute.js +2 -1
- package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +2 -3
- package/dist/overlays/relationship-details/hooks.d.ts +18 -19
- package/dist/overlays/relationship-details/layout.js +2 -1
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +2 -3
- package/dist/overlays/relationships-browser/actor.d.ts +12 -12
- package/dist/overlays/relationships-browser/actor.js +8 -8
- package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +2 -3
- package/dist/overlays/relationships-browser/layout.js +2 -1
- package/dist/search/components/ElementsColumn.js +1 -1
- package/dist/state/DiagramActorProvider.js +2 -2
- package/dist/state/assign.js +6 -6
- package/dist/state/diagram-machine.js +14 -14
- package/dist/styles-min.css +1 -1
- package/dist/styles-xyflow.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css2.js +1 -1
- package/dist/utils/xyflow.js +2 -2
- package/package.json +16 -16
- package/panda.buildinfo.json +30 -27
- package/src/LikeC4Diagram.props.ts +16 -16
- package/src/LikeC4Diagram.tsx +4 -2
- package/src/LikeC4Styles.tsx +50 -22
- package/src/base/index.ts +1 -2
- package/src/base/primitives/MarkdownBlock.tsx +1 -0
- package/src/base/primitives/customEdge.ts +5 -5
- package/src/base/primitives/edge/EdgeLabel.tsx +1 -2
- package/src/base/primitives/element/ElementTitle.tsx +10 -22
- package/src/base/types.ts +122 -13
- package/src/bundle/LikeC4View.props.ts +4 -3
- package/src/bundle/LikeC4View.tsx +6 -6
- package/src/bundle/ReactLikeC4.tsx +7 -6
- package/src/context/RootContainer.tsx +2 -2
- package/src/custom/customNodes.ts +3 -1
- package/src/globals.css +2 -2
- package/src/hooks/useSetState.ts +2 -2
- package/src/likec4diagram/custom/nodes/ElementActions.tsx +2 -1
- package/src/likec4diagram/relationship-popover/RelationshipPopover.tsx +49 -41
- package/src/likec4diagram/relationship-popover/styles.css.ts +8 -5
- package/src/likec4diagram/types.ts +1 -1
- package/src/likec4diagram/useViewToNodesEdges.ts +1 -1
- package/src/likec4model/LikeC4ModelContext.tsx +5 -2
- package/src/likec4model/useLikeC4ElementsTree.ts +3 -3
- package/src/likec4model/useLikeC4Model.ts +8 -5
- package/src/navigationpanel/NavigationPanel.tsx +2 -0
- package/src/navigationpanel/NavigationPanelDropdown.tsx +1 -1
- package/src/navigationpanel/walkthrough/ActiveWalkthroughControls.tsx +3 -1
- package/src/navigationpanel/walkthrough/WalkthroughPanel.tsx +88 -0
- package/src/overlays/relationship-details/compute.ts +3 -12
- package/src/overlays/relationship-details/layout.ts +3 -3
- package/src/overlays/relationships-browser/actor.ts +2 -1
- package/src/overlays/relationships-browser/layout.ts +3 -3
- package/src/search/components/ElementsColumn.tsx +3 -3
- package/src/utils/xyflow.ts +2 -2
- package/dist/base/types.Base.d.ts +0 -54
- package/dist/base/types.Base.js +0 -48
- package/dist/likec4diagram/custom/edges/NotePopover.d.ts +0 -4
- package/src/base/types.Base.ts +0 -104
- package/src/likec4diagram/custom/edges/NotePopover.tsx +0 -95
- /package/dist/{likec4diagram/custom/edges/NotePopover.css.d.ts → navigationpanel/walkthrough/WalkthroughPanel.css.d.ts} +0 -0
- /package/src/{likec4diagram/custom/edges/NotePopover.css.ts → navigationpanel/walkthrough/WalkthroughPanel.css.ts} +0 -0
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,
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DiagramEdge, DiagramNode, LayoutedView, ViewChange, WhereOperator } from '@likec4/core/types';
|
|
2
2
|
import { ReactFlowProps as XYFlowProps } from '@xyflow/react';
|
|
3
3
|
import { MouseEvent as ReactMouseEvent, ReactNode } from 'react';
|
|
4
4
|
import { SetRequired } from 'type-fest';
|
|
5
5
|
import { ControlsCustomLayout } from './context/ControlsCustomLayout';
|
|
6
6
|
import { CustomNodes } from './custom/customNodes';
|
|
7
|
+
import type * as t from '@likec4/core/types';
|
|
8
|
+
type Any = t.aux.Any;
|
|
9
|
+
type ViewId<A> = t.aux.ViewId<A>;
|
|
10
|
+
type Fqn<A> = t.aux.Fqn<A>;
|
|
11
|
+
type RelationId = t.aux.RelationId;
|
|
12
|
+
type DeploymentFqn<A> = t.aux.DeploymentFqn<A>;
|
|
13
|
+
type StrictViewId<A> = t.aux.StrictViewId<A>;
|
|
7
14
|
export type { CustomNodes, WhereOperator };
|
|
8
15
|
export type DiagramNodeWithNavigate<A extends Any> = SetRequired<DiagramNode<A>, 'navigateTo'>;
|
|
9
16
|
export type ElementIconRendererProps = {
|
|
@@ -15,7 +22,7 @@ export type ElementIconRendererProps = {
|
|
|
15
22
|
className?: string;
|
|
16
23
|
};
|
|
17
24
|
export type ElementIconRenderer = (props: ElementIconRendererProps) => ReactNode;
|
|
18
|
-
export type OnNavigateTo<A extends Any = Any> = (to:
|
|
25
|
+
export type OnNavigateTo<A extends Any = Any> = (to: ViewId<A>, event?: ReactMouseEvent, element?: DiagramNodeWithNavigate<A>) => void;
|
|
19
26
|
export type OnNodeClick<A extends Any = Any> = (node: DiagramNode<A>, event: ReactMouseEvent) => void;
|
|
20
27
|
export type OnEdgeClick<A extends Any = Any> = (edge: DiagramEdge<A>, event: ReactMouseEvent) => void;
|
|
21
28
|
/**
|
|
@@ -221,18 +228,18 @@ export interface LikeC4DiagramProperties<A extends Any = Any> {
|
|
|
221
228
|
*/
|
|
222
229
|
reactFlowProps?: OverrideReactFlowProps | undefined;
|
|
223
230
|
}
|
|
224
|
-
export type OpenSourceParams<A extends
|
|
225
|
-
element:
|
|
231
|
+
export type OpenSourceParams<A extends Any = Any> = {
|
|
232
|
+
element: Fqn<A>;
|
|
226
233
|
property?: string;
|
|
227
234
|
} | {
|
|
228
|
-
relation:
|
|
235
|
+
relation: RelationId;
|
|
229
236
|
} | {
|
|
230
|
-
deployment:
|
|
237
|
+
deployment: DeploymentFqn<A>;
|
|
231
238
|
property?: string;
|
|
232
239
|
} | {
|
|
233
|
-
view:
|
|
240
|
+
view: StrictViewId<A>;
|
|
234
241
|
};
|
|
235
|
-
export interface LikeC4DiagramEventHandlers<A extends
|
|
242
|
+
export interface LikeC4DiagramEventHandlers<A extends Any = Any> {
|
|
236
243
|
onChange?: OnChange | null | undefined;
|
|
237
244
|
onNavigateTo?: OnNavigateTo<A> | null | undefined;
|
|
238
245
|
onNodeClick?: OnNodeClick<A> | null | undefined;
|
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
|
}
|
package/dist/base/BaseXYFlow.js
CHANGED
|
@@ -9,7 +9,7 @@ import { roundDpr } from '../utils/roundDpr.js';
|
|
|
9
9
|
import { stopPropagation } from '../utils/xyflow.js';
|
|
10
10
|
import { Background } from './Background.js';
|
|
11
11
|
import { MinZoom, MaxZoom } from './const.js';
|
|
12
|
-
import {
|
|
12
|
+
import { Base } from './types.js';
|
|
13
13
|
|
|
14
14
|
const BaseXYFlow = ({
|
|
15
15
|
nodes,
|
|
@@ -104,7 +104,7 @@ const BaseXYFlow = ({
|
|
|
104
104
|
onNodesChange([{
|
|
105
105
|
id: node.id,
|
|
106
106
|
type: "replace",
|
|
107
|
-
item: setHovered(node, true)
|
|
107
|
+
item: Base.setHovered(node, true)
|
|
108
108
|
}]);
|
|
109
109
|
}
|
|
110
110
|
}),
|
|
@@ -117,7 +117,7 @@ const BaseXYFlow = ({
|
|
|
117
117
|
onNodesChange([{
|
|
118
118
|
id: node.id,
|
|
119
119
|
type: "replace",
|
|
120
|
-
item: setHovered(node, false)
|
|
120
|
+
item: Base.setHovered(node, false)
|
|
121
121
|
}]);
|
|
122
122
|
}
|
|
123
123
|
}),
|
|
@@ -130,7 +130,7 @@ const BaseXYFlow = ({
|
|
|
130
130
|
onEdgesChange([{
|
|
131
131
|
id: edge.id,
|
|
132
132
|
type: "replace",
|
|
133
|
-
item: setHovered(edge, true)
|
|
133
|
+
item: Base.setHovered(edge, true)
|
|
134
134
|
}]);
|
|
135
135
|
}
|
|
136
136
|
}),
|
|
@@ -143,7 +143,7 @@ const BaseXYFlow = ({
|
|
|
143
143
|
onEdgesChange([{
|
|
144
144
|
id: edge.id,
|
|
145
145
|
type: "replace",
|
|
146
|
-
item: setHovered(edge, false)
|
|
146
|
+
item: Base.setHovered(edge, false)
|
|
147
147
|
}]);
|
|
148
148
|
}
|
|
149
149
|
}),
|
package/dist/base/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { BaseXYFlow, type BaseXYFlowProps } from './BaseXYFlow';
|
|
2
|
-
export { type EdgeProps, type NodeProps, type NonOptional, type ReactFlowEdge, type ReactFlowNode, } from './types';
|
|
3
|
-
export * as Base from './types.Base';
|
|
2
|
+
export { Base, type EdgeProps, type NodeProps, type NonOptional, type ReactFlowEdge, type ReactFlowNode, } from './types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare const edgePropsEqual: <P extends
|
|
4
|
-
export declare function customEdge<P extends Record<string, unknown> =
|
|
2
|
+
import { EdgeProps } from '../types';
|
|
3
|
+
export declare const edgePropsEqual: <P extends EdgeProps<any>>(prev: P, next: P) => boolean;
|
|
4
|
+
export declare function customEdge<P extends Record<string, unknown> = {}>(Edge: FunctionComponent<EdgeProps<P>>): FunctionComponent<EdgeProps<P>>;
|
|
@@ -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: [
|
|
@@ -56,7 +56,7 @@ function ElementTitle({ id, data, iconSize }) {
|
|
|
56
56
|
children: data.technology
|
|
57
57
|
}
|
|
58
58
|
),
|
|
59
|
-
data.description?.nonEmpty &&
|
|
59
|
+
data.description?.nonEmpty && /* @__PURE__ */ jsx(
|
|
60
60
|
MarkdownBlock,
|
|
61
61
|
{
|
|
62
62
|
className: cx(classes.description, "likec4-element-description"),
|
|
@@ -66,15 +66,7 @@ function ElementTitle({ id, data, iconSize }) {
|
|
|
66
66
|
maxHeight: data.description.isMarkdown ? "8rem" : void 0,
|
|
67
67
|
lineClamp: isSmOrXs ? 3 : 5
|
|
68
68
|
}
|
|
69
|
-
)
|
|
70
|
-
Text,
|
|
71
|
-
{
|
|
72
|
-
component: "div",
|
|
73
|
-
className: cx(classes.description, "likec4-element-description"),
|
|
74
|
-
lineClamp: isSmOrXs ? 3 : 5,
|
|
75
|
-
children: data.description.text
|
|
76
|
-
}
|
|
77
|
-
))
|
|
69
|
+
)
|
|
78
70
|
] })
|
|
79
71
|
]
|
|
80
72
|
}
|
package/dist/base/types.d.ts
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
|
-
import { Edge as RFEdge, EdgeProps as ReactFlowEdgeProps, Node as RFNode, NodeProps as ReactFlowNodeProps } from '@xyflow/react';
|
|
2
1
|
import { OptionalKeysOf, SetRequired, Simplify } from 'type-fest';
|
|
3
|
-
import * as
|
|
2
|
+
import type * as RF from '@xyflow/react';
|
|
3
|
+
type RFNode<NodeData extends Record<string, unknown> = Record<string, unknown>, NodeType extends string | undefined = string | undefined> = RF.Node<NodeData, NodeType>;
|
|
4
|
+
type RFEdge<EdgeData extends Record<string, unknown> = Record<string, unknown>, EdgeType extends string | undefined = string | undefined> = RF.Edge<EdgeData, EdgeType>;
|
|
5
|
+
type ReactFlowNodeProps<NodeData extends Record<string, unknown> = Record<string, unknown>, NodeType extends string | undefined = string | undefined> = RF.NodeProps<RFNode<NodeData, NodeType>>;
|
|
6
|
+
type ReactFlowEdgeProps<EdgeData extends Record<string, unknown> = Record<string, unknown>, EdgeType extends string | undefined = string | undefined> = RF.EdgeProps<RFEdge<EdgeData, EdgeType>>;
|
|
7
|
+
export declare namespace Base {
|
|
8
|
+
export type Dimmed = 'immediate' | boolean;
|
|
9
|
+
export type NodeData = {
|
|
10
|
+
/**
|
|
11
|
+
* Whether the cursor is hovering over the node
|
|
12
|
+
*/
|
|
13
|
+
hovered?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the node is dimmed
|
|
16
|
+
* 'immediate' means that the node is dimmed without delay
|
|
17
|
+
*/
|
|
18
|
+
dimmed?: Dimmed;
|
|
19
|
+
};
|
|
20
|
+
export type Node = RFNode<NodeData>;
|
|
21
|
+
export type NodeProps = ReactFlowNodeProps<RFNode<NodeData, any>>;
|
|
22
|
+
export type EdgeData = {
|
|
23
|
+
/**
|
|
24
|
+
* Whether the cursor is hovering over the edge
|
|
25
|
+
*/
|
|
26
|
+
hovered?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the edge is active (animated and highlighted)
|
|
29
|
+
*/
|
|
30
|
+
active?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the edge is dimmed
|
|
33
|
+
* 'immediate' means that the edge is dimmed without delay
|
|
34
|
+
*/
|
|
35
|
+
dimmed?: Dimmed;
|
|
36
|
+
};
|
|
37
|
+
export type Edge = Simplify<Omit<RFEdge, 'data'> & {
|
|
38
|
+
data: EdgeData;
|
|
39
|
+
}>;
|
|
40
|
+
type WithDimmed = {
|
|
41
|
+
data: {
|
|
42
|
+
dimmed?: Dimmed;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
type WithHovered = {
|
|
46
|
+
data: {
|
|
47
|
+
hovered?: boolean;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export function setDimmed<T extends WithDimmed>(value: T, dimmed: 'immediate' | boolean): T;
|
|
51
|
+
export function setDimmed(dimmed: 'immediate' | boolean): <T extends WithDimmed>(value: T) => T;
|
|
52
|
+
export function setHovered<T extends WithHovered>(value: T, hovered: boolean): T;
|
|
53
|
+
export function setHovered(hovered: boolean): <T extends WithHovered>(value: T) => T;
|
|
54
|
+
type WithData<D> = {
|
|
55
|
+
data: D;
|
|
56
|
+
};
|
|
57
|
+
export function setData<E extends WithData<any>>(value: E, state: Partial<E['data']>): E;
|
|
58
|
+
export function setData<E extends WithData<any>>(state: Partial<E['data']>): (value: E) => E;
|
|
59
|
+
export {};
|
|
60
|
+
}
|
|
4
61
|
/**
|
|
5
62
|
* To cooperate with `exactOptionalPropertyTypes` in `tsconfig.json`
|
|
6
63
|
*
|
|
@@ -26,11 +83,11 @@ export type NonOptional<T extends object, Keys extends OptionalKeysOf<T> = Optio
|
|
|
26
83
|
/**
|
|
27
84
|
* ReactFlow Custom Node properties with BaseNodeData at least
|
|
28
85
|
*/
|
|
29
|
-
export type NodeProps<T extends Record<string, unknown> = {}, NodeType extends string = string> = Simplify<ReactFlowNodeProps<
|
|
86
|
+
export type NodeProps<T extends Record<string, unknown> = {}, NodeType extends string = string> = Simplify<ReactFlowNodeProps<Base.NodeData & T, NodeType>>;
|
|
30
87
|
/**
|
|
31
88
|
* ReactFlow Custom Edge properties with BaseEdgeData at least
|
|
32
89
|
*/
|
|
33
|
-
export type EdgeProps<T extends Record<string, unknown> = {}, EdgeType extends string = string> = SetRequired<Simplify<ReactFlowEdgeProps<
|
|
90
|
+
export type EdgeProps<T extends Record<string, unknown> = {}, EdgeType extends string = string> = SetRequired<Simplify<ReactFlowEdgeProps<Base.EdgeData & T, EdgeType>>, 'data'>;
|
|
34
91
|
export type ReactFlowNode<Data extends Record<string, unknown>, NodeType extends string> = SetRequired<RFNode<Data, NodeType>, 'type' | 'initialWidth' | 'initialHeight'>;
|
|
35
92
|
export type ReactFlowEdge<Data extends Record<string, unknown>, EdgeType extends string> = SetRequired<RFEdge<Data, EdgeType>, 'type' | 'data'>;
|
|
36
|
-
export
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { hasSubObject } from 'remeda';
|
|
2
|
+
|
|
3
|
+
var Base;
|
|
4
|
+
((Base2) => {
|
|
5
|
+
const _setDimmed = (v, dimmed) => (v.data.dimmed ?? false) === dimmed ? v : {
|
|
6
|
+
...v,
|
|
7
|
+
data: {
|
|
8
|
+
...v.data,
|
|
9
|
+
dimmed
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
function setDimmed(arg1, arg2) {
|
|
13
|
+
if (arg2 !== void 0) {
|
|
14
|
+
return _setDimmed(arg1, arg2);
|
|
15
|
+
}
|
|
16
|
+
return (v) => _setDimmed(v, arg1);
|
|
17
|
+
}
|
|
18
|
+
Base2.setDimmed = setDimmed;
|
|
19
|
+
const _setHovered = (v, hovered) => (v.data.hovered ?? false) === hovered ? v : {
|
|
20
|
+
...v,
|
|
21
|
+
data: {
|
|
22
|
+
...v.data,
|
|
23
|
+
hovered
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
function setHovered(arg1, arg2) {
|
|
27
|
+
if (arg2 !== void 0) {
|
|
28
|
+
return _setHovered(arg1, arg2);
|
|
29
|
+
}
|
|
30
|
+
return (v) => _setHovered(v, arg1);
|
|
31
|
+
}
|
|
32
|
+
Base2.setHovered = setHovered;
|
|
33
|
+
function _setData(value, state) {
|
|
34
|
+
if (hasSubObject(value.data, state)) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
...value,
|
|
39
|
+
data: {
|
|
40
|
+
...value.data,
|
|
41
|
+
...state
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function setData(arg1, arg2) {
|
|
46
|
+
if (arg2 !== void 0) {
|
|
47
|
+
return _setData(arg1, arg2);
|
|
48
|
+
}
|
|
49
|
+
return (edge) => _setData(edge, arg1);
|
|
50
|
+
}
|
|
51
|
+
Base2.setData = setData;
|
|
52
|
+
})(Base || (Base = {}));
|
|
53
|
+
|
|
54
|
+
export { Base };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Any, UnknownLayouted } from '@likec4/core/types';
|
|
2
1
|
import { LikeC4ViewProps } from './LikeC4View.props';
|
|
3
|
-
|
|
2
|
+
import type * as t from '@likec4/core/types';
|
|
3
|
+
export declare function LikeC4View<A extends t.aux.Any = t.aux.UnknownLayouted>({ viewId, ...props }: LikeC4ViewProps<A>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WhereOperator } from '@likec4/core/types';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
3
|
import { CustomNodes, ElementIconRenderer, OverrideReactFlowProps, PaddingWithUnit, ViewPadding } from '../LikeC4Diagram.props';
|
|
4
|
-
|
|
4
|
+
import type * as t from '@likec4/core/types';
|
|
5
|
+
export interface LikeC4ViewProps<A extends t.aux.Any = t.aux.UnknownLayouted> {
|
|
5
6
|
/**
|
|
6
7
|
* View to display.
|
|
7
8
|
*/
|
|
8
|
-
viewId: aux.ViewId<A>;
|
|
9
|
+
viewId: t.aux.ViewId<A>;
|
|
9
10
|
/**
|
|
10
11
|
* Enable/disable panning
|
|
11
12
|
* @default false
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Any, aux, UnknownLayouted } from '@likec4/core/types';
|
|
2
1
|
import { CSSProperties } from 'react';
|
|
3
2
|
import { LikeC4DiagramProps } from '../LikeC4Diagram';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import type * as t from '@likec4/core/types';
|
|
4
|
+
export type ReactLikeC4Props<A extends t.aux.Any = t.aux.UnknownLayouted> = Omit<LikeC4DiagramProps<A>, 'view'> & {
|
|
5
|
+
viewId: t.aux.ViewId<A>;
|
|
6
6
|
/**
|
|
7
7
|
* Keep aspect ratio of the diagram
|
|
8
8
|
* Disable if you need to manage the viewport (use className)
|
|
@@ -27,7 +27,7 @@ export type ReactLikeC4Props<A extends Any> = Omit<LikeC4DiagramProps<A>, 'view'
|
|
|
27
27
|
/** Function to generate nonce attribute added to all generated `<style />` tags */
|
|
28
28
|
styleNonce?: string | (() => string) | undefined;
|
|
29
29
|
};
|
|
30
|
-
export declare function ReactLikeC4<A extends Any = UnknownLayouted>({ viewId, ...props }: ReactLikeC4Props<A>): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare function ReactLikeC4<A extends t.aux.Any = t.aux.UnknownLayouted>({ viewId, ...props }: ReactLikeC4Props<A>): import("react/jsx-runtime").JSX.Element;
|
|
31
31
|
export declare namespace ReactLikeC4 {
|
|
32
32
|
var displayName: string;
|
|
33
33
|
}
|
|
@@ -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(() => {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { NodeModel } from '@likec4/core/model';
|
|
2
|
-
import {
|
|
2
|
+
import { aux } from '@likec4/core/types';
|
|
3
3
|
import { FunctionComponent } from 'react';
|
|
4
4
|
import { NodeProps } from '../base/types';
|
|
5
5
|
import { Types } from '../likec4diagram/types';
|
|
6
|
+
type Any = aux.Any;
|
|
6
7
|
type CustomDiagramNodeProps = {
|
|
7
8
|
nodeProps: NodeProps<Types.NodeData, string>;
|
|
8
9
|
nodeModel: NodeModel;
|
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 };
|