@likec4/diagram 1.24.0 → 1.24.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/dist/LikeC4Diagram.css.d.ts +5 -0
- package/dist/LikeC4Diagram.css.js +1 -0
- package/dist/LikeC4Diagram.d.ts +1 -1
- package/dist/LikeC4Diagram.js +6 -2
- package/dist/LikeC4Diagram.props.d.ts +6 -0
- package/dist/base/BaseXYFlow.d.ts +1 -1
- package/dist/base/BaseXYFlow.js +12 -3
- package/dist/base/const.d.ts +1 -1
- package/dist/base/const.js +1 -1
- package/dist/base/primitives/compound/CompoundActionButton.css.js +2 -0
- package/dist/base/primitives/compound/CompoundDetailsButton.css.js +2 -0
- package/dist/base/primitives/compound/CompoundNodeContainer.css.d.ts +0 -1
- package/dist/base/primitives/compound/CompoundNodeContainer.css.js +4 -4
- package/dist/base/primitives/compound/CompoundNodeContainer.js +35 -22
- package/dist/base/primitives/compound/CompoundTitle.css.js +3 -1
- package/dist/base/primitives/customNode.js +1 -1
- package/dist/base/primitives/edge/EdgeContainer.js +5 -4
- package/dist/base/primitives/edge/EdgeLabel.css.d.ts +0 -1
- package/dist/base/primitives/edge/EdgeLabel.css.js +2 -5
- package/dist/base/primitives/edge/EdgeLabel.js +5 -5
- package/dist/base/primitives/edge/edge.css.d.ts +1 -1
- package/dist/base/primitives/edge/edge.css.js +4 -5
- package/dist/base/primitives/element/ElementActionButtons.css.js +2 -0
- package/dist/base/primitives/element/ElementActionButtons.js +4 -3
- package/dist/base/primitives/element/ElementDetailsButton.css.js +2 -0
- package/dist/base/primitives/element/ElementNodeContainer.css.js +2 -0
- package/dist/base/primitives/element/ElementNodeContainer.js +3 -1
- package/dist/base/primitives/element/ElementShape.css.js +4 -2
- package/dist/base/primitives/element/ElementShape.js +2 -3
- package/dist/base/primitives/element/ElementTitle.css.js +2 -0
- package/dist/base/primitives/element/styles.css.js +2 -0
- package/dist/components/SearchControl.css.js +2 -0
- package/dist/context/FramerMotionConfig.d.ts +9 -1
- package/dist/context/FramerMotionConfig.js +5 -2
- package/dist/context/RootContainer.js +13 -1
- package/dist/diagram.css +1 -1
- package/dist/globals.css.d.ts +2 -0
- package/dist/hooks/safeContext.js +1 -0
- package/dist/hooks/useDiagram.d.ts +554 -864
- package/dist/hooks/useDiagram.js +1 -0
- package/dist/hooks/useIsReducedGraphics.d.ts +4 -0
- package/dist/hooks/useIsReducedGraphics.js +8 -0
- package/dist/hooks/useXYFlow.js +1 -1
- package/dist/likec4diagram/DiagramUI.d.ts +2 -1
- package/dist/likec4diagram/DiagramUI.js +5 -3
- package/dist/likec4diagram/custom/nodes/nodeTypes.js +2 -2
- package/dist/likec4diagram/ui/controls/styles.css.js +2 -0
- package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.css.js +2 -0
- package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +3 -4
- package/dist/likec4diagram/ui/search/LikeC4Search.css.js +2 -0
- package/dist/overlays/element-details/ElementDetailsCard.js +12 -8
- package/dist/overlays/element-details/actor.d.ts +9084 -2569
- package/dist/overlays/overlay/Overlay.js +6 -3
- package/dist/overlays/relationship-details/RelationshipDetails.js +31 -17
- package/dist/overlays/relationship-details/actor.d.ts +228 -3
- package/dist/overlays/relationship-details/actor.js +86 -14
- package/dist/overlays/relationship-details/hooks.d.ts +3 -0
- package/dist/overlays/relationship-details/hooks.js +6 -2
- package/dist/overlays/relationships-browser/-useRelationshipsView.js +12 -3
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +12 -3
- package/dist/overlays/relationships-browser/actor.d.ts +271 -54
- package/dist/overlays/relationships-browser/actor.js +86 -23
- package/dist/state/DiagramActorProvider.js +12 -2
- package/dist/state/diagram-machine.d.ts +563 -867
- package/dist/state/diagram-machine.js +82 -81
- package/dist/state/persistence.d.ts +5 -0
- package/dist/state/persistence.js +23 -0
- package/package.json +9 -9
- package/src/LikeC4Diagram.css.ts +13 -5
- package/src/LikeC4Diagram.props.ts +7 -0
- package/src/LikeC4Diagram.tsx +33 -24
- package/src/base/BaseXYFlow.tsx +14 -9
- package/src/base/const.ts +1 -1
- package/src/base/primitives/compound/CompoundActionButton.css.ts +6 -0
- package/src/base/primitives/compound/CompoundDetailsButton.css.ts +4 -0
- package/src/base/primitives/compound/CompoundNodeContainer.css.ts +41 -59
- package/src/base/primitives/compound/CompoundNodeContainer.tsx +42 -22
- package/src/base/primitives/compound/CompoundTitle.css.ts +14 -13
- package/src/base/primitives/customNode.ts +3 -2
- package/src/base/primitives/edge/EdgeContainer.tsx +4 -3
- package/src/base/primitives/edge/EdgeLabel.css.ts +17 -11
- package/src/base/primitives/edge/EdgeLabel.tsx +4 -4
- package/src/base/primitives/edge/edge.css.ts +47 -27
- package/src/base/primitives/element/ElementActionButtons.css.ts +4 -0
- package/src/base/primitives/element/ElementActionButtons.tsx +4 -2
- package/src/base/primitives/element/ElementDetailsButton.css.ts +6 -8
- package/src/base/primitives/element/ElementNodeContainer.css.ts +18 -21
- package/src/base/primitives/element/ElementNodeContainer.tsx +3 -1
- package/src/base/primitives/element/ElementShape.css.ts +10 -6
- package/src/base/primitives/element/ElementShape.tsx +2 -2
- package/src/components/SearchControl.css.ts +11 -4
- package/src/context/FramerMotionConfig.tsx +13 -2
- package/src/context/RootContainer.tsx +9 -2
- package/src/globals.css.ts +3 -0
- package/src/hooks/safeContext.tsx +2 -1
- package/src/hooks/useDiagram.ts +1 -0
- package/src/hooks/useIsReducedGraphics.ts +5 -0
- package/src/hooks/useXYFlow.ts +1 -1
- package/src/likec4diagram/DiagramUI.tsx +5 -3
- package/src/likec4diagram/custom/nodes/nodeTypes.tsx +2 -2
- package/src/likec4diagram/ui/controls/styles.css.ts +11 -1
- package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.css.ts +10 -3
- package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +6 -3
- package/src/likec4diagram/ui/search/LikeC4Search.css.ts +1 -0
- package/src/overlays/element-details/ElementDetailsCard.tsx +238 -231
- package/src/overlays/overlay/Overlay.css.ts +1 -9
- package/src/overlays/overlay/Overlay.tsx +6 -3
- package/src/overlays/relationship-details/RelationshipDetails.tsx +83 -66
- package/src/overlays/relationship-details/actor.ts +106 -13
- package/src/overlays/relationship-details/hooks.ts +6 -2
- package/src/overlays/relationships-browser/-useRelationshipsView.ts +10 -0
- package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +16 -8
- package/src/overlays/relationships-browser/actor.ts +92 -22
- package/src/state/DiagramActorProvider.tsx +13 -2
- package/src/state/diagram-machine.ts +80 -79
- package/src/state/persistence.ts +22 -0
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { whereNotReducedGraphics, whereReducedGraphics } from './globals.css';
|
|
1
2
|
export declare const cssReactFlow: string;
|
|
3
|
+
export declare const reactFlowReducedGraphics: string;
|
|
4
|
+
export declare const reactFlow: string;
|
|
5
|
+
export { whereNotReducedGraphics, whereReducedGraphics };
|
|
2
6
|
export declare const notInitialized: string;
|
|
3
7
|
export declare const cssDisablePan: string;
|
|
4
8
|
export declare const cssTransparentBg: string;
|
|
5
9
|
export declare const hiddenIfZoomTooSmall: string;
|
|
10
|
+
export declare const hiddenIfReducedGraphics: string;
|
package/dist/LikeC4Diagram.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { LikeC4DiagramEventHandlers, LikeC4DiagramProperties } from './LikeC4Diagram.props';
|
|
2
2
|
export type LikeC4DiagramProps = LikeC4DiagramProperties & LikeC4DiagramEventHandlers;
|
|
3
|
-
export declare function LikeC4Diagram({ view, className, fitView, fitViewPadding, readonly, pannable, zoomable, background, enableFocusMode, enableElementDetails, enableRelationshipDetails, enableRelationshipBrowser, nodesSelectable, nodesDraggable, controls, showDiagramTitle, showNotations, enableDynamicViewWalkthrough, enableSearch, initialWidth, initialHeight, experimentalEdgeEditing, onCanvasClick, onCanvasContextMenu, onCanvasDblClick, onEdgeClick, onChange, onEdgeContextMenu, onNavigateTo, onNodeClick, onNodeContextMenu, onOpenSource, onBurgerMenuClick, renderIcon, where, showNavigationButtons, }: LikeC4DiagramProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function LikeC4Diagram({ view, className, fitView, fitViewPadding, readonly, pannable, zoomable, background, enableFocusMode, enableElementDetails, enableRelationshipDetails, enableRelationshipBrowser, nodesSelectable, nodesDraggable, controls, showDiagramTitle, showNotations, enableDynamicViewWalkthrough, enableSearch, initialWidth, initialHeight, experimentalEdgeEditing, reduceGraphics, onCanvasClick, onCanvasContextMenu, onCanvasDblClick, onEdgeClick, onChange, onEdgeContextMenu, onNavigateTo, onNodeClick, onNodeContextMenu, onOpenSource, onBurgerMenuClick, renderIcon, where, showNavigationButtons, }: LikeC4DiagramProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/LikeC4Diagram.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { ReactFlowProvider } from "@xyflow/react";
|
|
3
3
|
import { useRef } from "react";
|
|
4
4
|
import { isEmpty } from "remeda";
|
|
5
|
+
import { ReducedGraphicsContext } from "./hooks/useIsReducedGraphics.js";
|
|
5
6
|
import { LikeC4CustomColors } from "./LikeC4CustomColors.js";
|
|
6
7
|
import { useViewToNodesEdges } from "./likec4diagram/useViewToNodesEdges.js";
|
|
7
8
|
import { LikeC4DiagramXYFlow } from "./likec4diagram/XYFlow.js";
|
|
@@ -36,6 +37,7 @@ function LikeC4Diagram({
|
|
|
36
37
|
initialWidth,
|
|
37
38
|
initialHeight,
|
|
38
39
|
experimentalEdgeEditing = false,
|
|
40
|
+
reduceGraphics = "auto",
|
|
39
41
|
onCanvasClick,
|
|
40
42
|
onCanvasContextMenu,
|
|
41
43
|
onCanvasDblClick,
|
|
@@ -51,6 +53,7 @@ function LikeC4Diagram({
|
|
|
51
53
|
where,
|
|
52
54
|
showNavigationButtons = !!onNavigateTo
|
|
53
55
|
}) {
|
|
56
|
+
var _a, _b;
|
|
54
57
|
const hasLikec4model = !!useLikeC4Model();
|
|
55
58
|
const initialRef = useRef(null);
|
|
56
59
|
const xyNodesEdges = useViewToNodesEdges({
|
|
@@ -67,6 +70,7 @@ function LikeC4Diagram({
|
|
|
67
70
|
initialHeight: initialHeight ?? view.bounds.height
|
|
68
71
|
};
|
|
69
72
|
}
|
|
73
|
+
const isReducedGraphicsMode = reduceGraphics === "auto" ? (((_a = view.bounds) == null ? void 0 : _a.width) ?? 1) * (((_b = view.bounds) == null ? void 0 : _b.height) ?? 1) > 6e6 : reduceGraphics;
|
|
70
74
|
return /* @__PURE__ */ jsx(EnsureMantine, { children: /* @__PURE__ */ jsx(FramerMotionConfig, { children: /* @__PURE__ */ jsx(IconRendererProvider, { value: renderIcon ?? null, children: /* @__PURE__ */ jsx(
|
|
71
75
|
DiagramFeatures,
|
|
72
76
|
{
|
|
@@ -104,7 +108,7 @@ function LikeC4Diagram({
|
|
|
104
108
|
onOpenSource,
|
|
105
109
|
onBurgerMenuClick
|
|
106
110
|
},
|
|
107
|
-
children: /* @__PURE__ */ jsxs(RootContainer, { className, children: [
|
|
111
|
+
children: /* @__PURE__ */ jsx(ReducedGraphicsContext, { value: isReducedGraphicsMode, children: /* @__PURE__ */ jsxs(RootContainer, { className, children: [
|
|
108
112
|
!isEmpty(view.customColorDefinitions) && /* @__PURE__ */ jsx(LikeC4CustomColors, { customColors: view.customColorDefinitions }),
|
|
109
113
|
/* @__PURE__ */ jsx(
|
|
110
114
|
ReactFlowProvider,
|
|
@@ -133,7 +137,7 @@ function LikeC4Diagram({
|
|
|
133
137
|
)
|
|
134
138
|
}
|
|
135
139
|
)
|
|
136
|
-
] })
|
|
140
|
+
] }) })
|
|
137
141
|
}
|
|
138
142
|
)
|
|
139
143
|
}
|
|
@@ -124,6 +124,12 @@ export interface LikeC4DiagramProperties {
|
|
|
124
124
|
* @default false
|
|
125
125
|
*/
|
|
126
126
|
experimentalEdgeEditing?: boolean | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* Improve performance by hiding certain elements and reducing visual effects (disable mix-blend, shadows, animations)
|
|
129
|
+
*
|
|
130
|
+
* @default 'auto' - will be set to true if view has more then 3000 * 2000 pixels
|
|
131
|
+
*/
|
|
132
|
+
reduceGraphics?: 'auto' | boolean | undefined;
|
|
127
133
|
/**
|
|
128
134
|
* Render icon for an element, bundled or remote
|
|
129
135
|
* By default, if icon is http:// or https://, it will be rendered as an image
|
|
@@ -10,5 +10,5 @@ export type BaseXYFlowProps<NodeType extends Base.Node, EdgeType extends Base.Ed
|
|
|
10
10
|
background?: 'transparent' | 'solid' | XYBackground;
|
|
11
11
|
fitViewPadding?: number;
|
|
12
12
|
onViewportResize?: undefined | (() => void);
|
|
13
|
-
} & SetRequired<Omit<ReactFlowProps<NodeType, EdgeType>, 'defaultNodes' | 'defaultEdges' | 'panOnScroll' | 'panOnDrag' | 'preventScrolling' | 'zoomOnPinch' | 'zoomActivationKeyCode' | 'zoomOnScroll' | 'elementsSelectable' | '
|
|
13
|
+
} & SetRequired<Omit<ReactFlowProps<NodeType, EdgeType>, 'defaultNodes' | 'defaultEdges' | 'panOnScroll' | 'panOnDrag' | 'preventScrolling' | 'zoomOnPinch' | 'zoomActivationKeyCode' | 'zoomOnScroll' | 'elementsSelectable' | 'onNodeDoubleClick' | 'onEdgeDoubleClick' | 'fitViewOptions'>, 'nodes' | 'edges' | 'onNodesChange' | 'onEdgesChange'>>;
|
|
14
14
|
export declare const BaseXYFlow: <NodeType extends Base.Node, EdgeType extends Base.Edge>({ nodes, edges, onEdgesChange, onNodesChange, className, pannable, zoomable, nodesSelectable, nodesDraggable, background, children, colorMode, fitViewPadding, fitView, zoomOnDoubleClick, onViewportResize, ...props }: BaseXYFlowProps<NodeType, EdgeType>) => import("react/jsx-runtime").JSX.Element;
|
package/dist/base/BaseXYFlow.js
CHANGED
|
@@ -2,14 +2,16 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallbackRef } from "@mantine/hooks";
|
|
3
3
|
import { ReactFlow, useStoreApi, useOnViewportChange, useStore } from "@xyflow/react";
|
|
4
4
|
import clsx from "clsx";
|
|
5
|
+
import { shallowEqual } from "fast-equals";
|
|
5
6
|
import { useMemo } from "react";
|
|
7
|
+
import { useIsReducedGraphics } from "../hooks/useIsReducedGraphics.js";
|
|
8
|
+
import { useUpdateEffect } from "../hooks/useUpdateEffect.js";
|
|
6
9
|
import { useIsZoomTooSmall } from "../hooks/useXYFlow.js";
|
|
7
10
|
import { cssReactFlow, cssDisablePan, cssTransparentBg } from "../LikeC4Diagram.css.js";
|
|
8
11
|
import { stopPropagation } from "../utils/xyflow.js";
|
|
9
12
|
import { Background } from "./Background.js";
|
|
10
13
|
import { MinZoom, MaxZoom } from "./const.js";
|
|
11
14
|
import { Base } from "./types.js";
|
|
12
|
-
import { useUpdateEffect } from "../hooks/useUpdateEffect.js";
|
|
13
15
|
const BaseXYFlow = ({
|
|
14
16
|
nodes,
|
|
15
17
|
edges,
|
|
@@ -31,6 +33,7 @@ const BaseXYFlow = ({
|
|
|
31
33
|
}) => {
|
|
32
34
|
const isBgWithPattern = background !== "transparent" && background !== "solid";
|
|
33
35
|
const isZoomTooSmall = useIsZoomTooSmall();
|
|
36
|
+
const reduceGraphics = useIsReducedGraphics();
|
|
34
37
|
return /* @__PURE__ */ jsxs(
|
|
35
38
|
ReactFlow,
|
|
36
39
|
{
|
|
@@ -43,7 +46,12 @@ const BaseXYFlow = ({
|
|
|
43
46
|
background === "transparent" && cssTransparentBg,
|
|
44
47
|
className
|
|
45
48
|
),
|
|
46
|
-
|
|
49
|
+
...isZoomTooSmall && {
|
|
50
|
+
["data-likec4-zoom-small"]: true
|
|
51
|
+
},
|
|
52
|
+
...reduceGraphics && {
|
|
53
|
+
["data-likec4-reduced-graphics"]: true
|
|
54
|
+
},
|
|
47
55
|
zoomOnPinch: zoomable,
|
|
48
56
|
zoomOnScroll: !pannable && zoomable,
|
|
49
57
|
...!zoomable && {
|
|
@@ -68,6 +76,7 @@ const BaseXYFlow = ({
|
|
|
68
76
|
...!pannable && {
|
|
69
77
|
selectionKeyCode: null
|
|
70
78
|
},
|
|
79
|
+
onlyRenderVisibleElements: reduceGraphics,
|
|
71
80
|
elementsSelectable: nodesSelectable,
|
|
72
81
|
nodesFocusable: nodesDraggable || nodesSelectable,
|
|
73
82
|
edgesFocusable: false,
|
|
@@ -136,7 +145,7 @@ const selectDimensions = ({ width, height }) => ({ width, height });
|
|
|
136
145
|
const ViewportResizeHanlder = ({
|
|
137
146
|
onViewportResize
|
|
138
147
|
}) => {
|
|
139
|
-
const { width, height } = useStore(selectDimensions);
|
|
148
|
+
const { width, height } = useStore(selectDimensions, shallowEqual);
|
|
140
149
|
useUpdateEffect(onViewportResize, [width, height]);
|
|
141
150
|
return /* @__PURE__ */ jsx(Fragment, {});
|
|
142
151
|
};
|
package/dist/base/const.d.ts
CHANGED
package/dist/base/const.js
CHANGED
|
@@ -3,6 +3,5 @@ export declare const varBorderRadius: `var(--${string})` | `var(--${string}, ${s
|
|
|
3
3
|
export declare const varBorderTransparency: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
4
4
|
export declare const varBorderColor: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
5
5
|
export declare const container: string;
|
|
6
|
-
export declare const compoundBg: string;
|
|
7
6
|
export declare const compoundBorder: string;
|
|
8
7
|
export declare const indicator: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
/* empty css */
|
|
1
3
|
/* empty css */
|
|
2
4
|
var varCompoundOpacity = "var(--_7cmew10)";
|
|
3
5
|
var varBorderTransparency = "var(--_7cmew12)";
|
|
4
6
|
var container = "_7cmew15";
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var indicator = "_7cmew1b";
|
|
7
|
+
var compoundBorder = "_7cmew16";
|
|
8
|
+
var indicator = "_7cmew1a";
|
|
8
9
|
export {
|
|
9
|
-
compoundBg,
|
|
10
10
|
compoundBorder,
|
|
11
11
|
container,
|
|
12
12
|
indicator,
|
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createPolymorphicComponent, Box } from "@mantine/core";
|
|
3
|
-
import {
|
|
3
|
+
import { useDebouncedValue } from "@mantine/hooks";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { m } from "framer-motion";
|
|
6
6
|
import { forwardRef } from "react";
|
|
7
7
|
import { isNumber, clamp } from "remeda";
|
|
8
|
-
import {
|
|
8
|
+
import { useIsReducedGraphics } from "../../../hooks/useIsReducedGraphics.js";
|
|
9
|
+
import { compoundBorder, indicator, container, varCompoundOpacity, varBorderTransparency } from "./CompoundNodeContainer.css.js";
|
|
10
|
+
function getVarName(variable) {
|
|
11
|
+
var matches = variable.match(/^var\((.*)\)$/);
|
|
12
|
+
if (matches) {
|
|
13
|
+
return matches[1];
|
|
14
|
+
}
|
|
15
|
+
return variable;
|
|
16
|
+
}
|
|
17
|
+
const opacityVar = getVarName(varCompoundOpacity);
|
|
18
|
+
const borderTransparencyVar = getVarName(varBorderTransparency);
|
|
9
19
|
const CompoundNodeContainer = createPolymorphicComponent(
|
|
10
20
|
forwardRef(({
|
|
11
21
|
nodeProps: {
|
|
22
|
+
selected: isSelected = false,
|
|
12
23
|
data: {
|
|
13
24
|
hovered: isHovered = false,
|
|
14
25
|
dimmed: isDimmed = false,
|
|
15
|
-
style,
|
|
16
26
|
...data
|
|
17
27
|
}
|
|
18
28
|
},
|
|
19
29
|
children,
|
|
30
|
+
style,
|
|
20
31
|
...rest
|
|
21
32
|
}, ref) => {
|
|
22
|
-
const
|
|
23
|
-
|
|
33
|
+
const isReducedGraphics = useIsReducedGraphics();
|
|
34
|
+
const isTransparent = isNumber(data.style.opacity) && data.style.opacity < 100;
|
|
35
|
+
let _opacity = clamp((data.style.opacity ?? 100) / 100, {
|
|
24
36
|
min: 0,
|
|
25
37
|
max: 1
|
|
26
38
|
});
|
|
27
|
-
if (isTransparent && isHovered) {
|
|
28
|
-
|
|
39
|
+
if (isTransparent && isHovered && !isReducedGraphics) {
|
|
40
|
+
_opacity = Math.min(_opacity + 0.11, 1);
|
|
29
41
|
}
|
|
42
|
+
const [opacity] = useDebouncedValue(Math.round(_opacity * 100) / 100, isHovered ? 200 : 50);
|
|
30
43
|
const MAX_TRANSPARENCY = 40;
|
|
31
44
|
const borderTransparency = clamp(MAX_TRANSPARENCY - opacity * MAX_TRANSPARENCY, {
|
|
32
45
|
min: 0,
|
|
@@ -48,13 +61,23 @@ const CompoundNodeContainer = createPolymorphicComponent(
|
|
|
48
61
|
"data-compound-transparent": isTransparent,
|
|
49
62
|
"data-likec4-dimmed": isDimmed,
|
|
50
63
|
"data-likec4-shape": data.shape,
|
|
51
|
-
style:
|
|
52
|
-
|
|
53
|
-
[
|
|
54
|
-
|
|
64
|
+
style: {
|
|
65
|
+
...style,
|
|
66
|
+
[opacityVar]: opacity,
|
|
67
|
+
[borderTransparencyVar]: `${borderTransparency}%`
|
|
68
|
+
},
|
|
55
69
|
...rest,
|
|
56
70
|
children: [
|
|
57
|
-
|
|
71
|
+
isTransparent && !isSelected && data.style.border !== "none" && /* @__PURE__ */ jsx(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
className: compoundBorder,
|
|
75
|
+
style: {
|
|
76
|
+
borderStyle: data.style.border ?? "dashed"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
isSelected && /* @__PURE__ */ jsx("svg", { className: indicator, children: /* @__PURE__ */ jsx(
|
|
58
81
|
"rect",
|
|
59
82
|
{
|
|
60
83
|
x: 0,
|
|
@@ -64,16 +87,6 @@ const CompoundNodeContainer = createPolymorphicComponent(
|
|
|
64
87
|
rx: 6
|
|
65
88
|
}
|
|
66
89
|
) }),
|
|
67
|
-
/* @__PURE__ */ jsx("div", { className: compoundBg }),
|
|
68
|
-
isTransparent && style.border !== "none" && /* @__PURE__ */ jsx(
|
|
69
|
-
"div",
|
|
70
|
-
{
|
|
71
|
-
className: compoundBorder,
|
|
72
|
-
style: {
|
|
73
|
-
borderStyle: style.border ?? "dashed"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
),
|
|
77
90
|
children
|
|
78
91
|
]
|
|
79
92
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deepEqual } from "fast-equals";
|
|
2
2
|
import { memo } from "react";
|
|
3
|
-
const nodePropsEqual = (prev, next) => prev.id === next.id && deepEqual(prev.selected ?? false, next.selected ?? false) && deepEqual(prev.dragging ?? false, next.dragging ?? false) && deepEqual(prev.width ?? 0, next.width ?? 0) && deepEqual(prev.height ?? 0, next.height ?? 0) && deepEqual(prev.zIndex, next.zIndex) && deepEqual(prev.
|
|
3
|
+
const nodePropsEqual = (prev, next) => prev.id === next.id && deepEqual(prev.selected ?? false, next.selected ?? false) && deepEqual(prev.dragging ?? false, next.dragging ?? false) && deepEqual(prev.width ?? 0, next.width ?? 0) && deepEqual(prev.height ?? 0, next.height ?? 0) && deepEqual(prev.zIndex, next.zIndex) && deepEqual(prev.data, next.data);
|
|
4
4
|
function customNode(Node) {
|
|
5
5
|
return memo(Node, nodePropsEqual);
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import "react";
|
|
4
|
-
import {
|
|
4
|
+
import { edgeContainer } from "./edge.css.js";
|
|
5
5
|
function EdgeContainer({
|
|
6
6
|
className,
|
|
7
7
|
data: {
|
|
@@ -16,8 +16,7 @@ function EdgeContainer({
|
|
|
16
16
|
"g",
|
|
17
17
|
{
|
|
18
18
|
className: clsx(
|
|
19
|
-
|
|
20
|
-
isDimmed && dimmed,
|
|
19
|
+
edgeContainer,
|
|
21
20
|
className
|
|
22
21
|
),
|
|
23
22
|
"data-likec4-color": data.color ?? "gray",
|
|
@@ -25,7 +24,9 @@ function EdgeContainer({
|
|
|
25
24
|
"data-edge-active": isActive,
|
|
26
25
|
"data-edge-animated": isActive,
|
|
27
26
|
"data-edge-hovered": isHovered,
|
|
28
|
-
|
|
27
|
+
...isDimmed !== false && {
|
|
28
|
+
"data-edge-dimmed": isDimmed
|
|
29
|
+
},
|
|
29
30
|
children
|
|
30
31
|
}
|
|
31
32
|
);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { dimmed, edgeVars } from './edge.css';
|
|
2
1
|
export declare const stepEdgeNumber: string;
|
|
3
2
|
export declare const varLabelX: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
4
3
|
export declare const varLabelY: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
/* empty css */
|
|
1
2
|
/* empty css */
|
|
2
3
|
/* empty css */
|
|
3
4
|
/* empty css */
|
|
4
|
-
var dimmed = "nrg7w92";
|
|
5
|
-
var edgeVars = "nrg7w91";
|
|
6
5
|
var stepEdgeNumber = "_1fqbh3j0";
|
|
7
6
|
var varTranslate = "var(--_1fqbh3j3)";
|
|
8
|
-
var edgeLabelContainer = "_1fqbh3j4";
|
|
7
|
+
var edgeLabelContainer = "_1fqbh3j4 nrg7w91";
|
|
9
8
|
var edgeLabel = "_1fqbh3j5";
|
|
10
9
|
var secondColumn = "_1fqbh3j6";
|
|
11
10
|
var edgeLabelText = "_1fqbh3j7";
|
|
@@ -13,12 +12,10 @@ var edgeLabelTechnology = "_1fqbh3j8";
|
|
|
13
12
|
var actionBtn = "_1fqbh3jb";
|
|
14
13
|
export {
|
|
15
14
|
actionBtn,
|
|
16
|
-
dimmed,
|
|
17
15
|
edgeLabel,
|
|
18
16
|
edgeLabelContainer,
|
|
19
17
|
edgeLabelTechnology,
|
|
20
18
|
edgeLabelText,
|
|
21
|
-
edgeVars,
|
|
22
19
|
secondColumn,
|
|
23
20
|
stepEdgeNumber,
|
|
24
21
|
varTranslate
|
|
@@ -8,7 +8,7 @@ import { forwardRef } from "react";
|
|
|
8
8
|
import { isTruthy, isNumber } from "remeda";
|
|
9
9
|
import { useIsZoomTooSmall } from "../../../hooks/useXYFlow.js";
|
|
10
10
|
import { ZIndexes } from "../../const.js";
|
|
11
|
-
import { edgeLabel, stepEdgeNumber, secondColumn, edgeLabelText, edgeLabelTechnology, varTranslate,
|
|
11
|
+
import { edgeLabel, stepEdgeNumber, secondColumn, edgeLabelText, edgeLabelTechnology, varTranslate, edgeLabelContainer } from "./EdgeLabel.css.js";
|
|
12
12
|
const toCssVarValue = (value) => {
|
|
13
13
|
if (value === void 0) return void 0;
|
|
14
14
|
return isNumber(value) ? `${value}px` : value;
|
|
@@ -21,7 +21,7 @@ const EdgeLabel = createPolymorphicComponent(
|
|
|
21
21
|
technology,
|
|
22
22
|
hovered: isHovered = false,
|
|
23
23
|
active: isActive = false,
|
|
24
|
-
dimmed:
|
|
24
|
+
dimmed: isDimmed = false,
|
|
25
25
|
labelBBox,
|
|
26
26
|
...data
|
|
27
27
|
}
|
|
@@ -48,16 +48,16 @@ const EdgeLabel = createPolymorphicComponent(
|
|
|
48
48
|
{
|
|
49
49
|
className: clsx(
|
|
50
50
|
"nodrag nopan",
|
|
51
|
-
edgeVars,
|
|
52
51
|
edgeLabelContainer,
|
|
53
|
-
!!dimmed$1 && dimmed,
|
|
54
52
|
className
|
|
55
53
|
),
|
|
56
54
|
"data-likec4-color": data.color ?? "gray",
|
|
57
55
|
"data-edge-active": isActive,
|
|
58
56
|
"data-edge-animated": isActive,
|
|
59
57
|
"data-edge-hovered": isHovered,
|
|
60
|
-
|
|
58
|
+
...isDimmed !== false && {
|
|
59
|
+
"data-edge-dimmed": isDimmed
|
|
60
|
+
},
|
|
61
61
|
style: {
|
|
62
62
|
top: toCssVarValue(labelY),
|
|
63
63
|
left: toCssVarValue(labelX),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const mixColor: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
2
2
|
export declare const edgeVars: string;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const edgeContainer: string;
|
|
4
4
|
export declare const edgePathBg: string;
|
|
5
5
|
export declare const markerContext: string;
|
|
6
6
|
export declare const cssEdgePath: string;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
/* empty css */
|
|
1
2
|
/* empty css */
|
|
2
3
|
/* empty css */
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var edgePathBg = "nrg7w93";
|
|
4
|
+
var edgeContainer = "nrg7w92 nrg7w91";
|
|
5
|
+
var edgePathBg = "nrg7w93 _2h8g8h4 _2h8g8h5";
|
|
6
6
|
var markerContext = "nrg7w94";
|
|
7
7
|
var cssEdgePath = "nrg7w96";
|
|
8
8
|
export {
|
|
9
9
|
cssEdgePath,
|
|
10
|
-
|
|
10
|
+
edgeContainer,
|
|
11
11
|
edgePathBg,
|
|
12
|
-
edgeVars,
|
|
13
12
|
markerContext
|
|
14
13
|
};
|
|
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Box, ActionIcon } from "@mantine/core";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { m } from "framer-motion";
|
|
5
|
-
import {
|
|
5
|
+
import { useIsZoomTooSmall } from "../../../hooks/useXYFlow.js";
|
|
6
6
|
import { stopPropagation } from "../../../utils/xyflow.js";
|
|
7
7
|
import { actionIcon, actionButtons, container } from "./ElementActionButtons.css.js";
|
|
8
8
|
function ElementActionButtons({
|
|
@@ -13,10 +13,11 @@ function ElementActionButtons({
|
|
|
13
13
|
},
|
|
14
14
|
buttons
|
|
15
15
|
}) {
|
|
16
|
-
|
|
16
|
+
const zoomTooSmall = useIsZoomTooSmall();
|
|
17
|
+
if (!buttons.length || zoomTooSmall) {
|
|
17
18
|
return null;
|
|
18
19
|
}
|
|
19
|
-
return /* @__PURE__ */ jsx(Box, { className: clsx(container
|
|
20
|
+
return /* @__PURE__ */ jsx(Box, { className: clsx(container), children: /* @__PURE__ */ jsx(
|
|
20
21
|
Box,
|
|
21
22
|
{
|
|
22
23
|
component: m.div,
|
|
@@ -4,6 +4,7 @@ import { createPolymorphicComponent, Box } from "@mantine/core";
|
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { m } from "framer-motion";
|
|
6
6
|
import { forwardRef } from "react";
|
|
7
|
+
import { useIsReducedGraphics } from "../../../hooks/useIsReducedGraphics.js";
|
|
7
8
|
import { container } from "./ElementNodeContainer.css.js";
|
|
8
9
|
function nodeSizes({
|
|
9
10
|
size,
|
|
@@ -42,6 +43,7 @@ const ElementNodeContainer = createPolymorphicComponent(
|
|
|
42
43
|
children,
|
|
43
44
|
...rest
|
|
44
45
|
}, ref) => {
|
|
46
|
+
const nonReducedGraphics = !useIsReducedGraphics();
|
|
45
47
|
let scale = 1;
|
|
46
48
|
switch (true) {
|
|
47
49
|
case isHovered:
|
|
@@ -66,7 +68,7 @@ const ElementNodeContainer = createPolymorphicComponent(
|
|
|
66
68
|
"likec4-element-node"
|
|
67
69
|
]),
|
|
68
70
|
initial: false,
|
|
69
|
-
...selectable && {
|
|
71
|
+
...selectable && nonReducedGraphics && {
|
|
70
72
|
animate: {
|
|
71
73
|
scale
|
|
72
74
|
},
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
/* empty css */
|
|
1
3
|
/* empty css */
|
|
2
4
|
/* empty css */
|
|
3
|
-
var indicator = "_4zok2q2";
|
|
5
|
+
var indicator = "_4zok2q2 _2h8g8h4";
|
|
4
6
|
var fillElementFill = "_4zok2q3";
|
|
5
7
|
var fillMixStroke = "_4zok2q5";
|
|
6
|
-
var shapeSvgMultiple = "_4zok2q8 _4zok2q7";
|
|
8
|
+
var shapeSvgMultiple = "_4zok2q8 _4zok2q7 _2h8g8h4";
|
|
7
9
|
var shapeSvg = "_4zok2q9 _4zok2q7";
|
|
8
10
|
export {
|
|
9
11
|
fillElementFill,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { nonexhaustive } from "@likec4/core";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
-
import { hiddenIfZoomTooSmall } from "../../../LikeC4Diagram.css.js";
|
|
5
4
|
import { toDomPrecision } from "../../../utils/xyflow.js";
|
|
6
5
|
import { shapeSvgMultiple, shapeSvg, fillMixStroke, fillElementFill, indicator } from "./ElementShape.css.js";
|
|
7
6
|
function cylinderSVGPath(diameter, height, tilt = 0.065) {
|
|
@@ -152,7 +151,7 @@ function ElementShape({ data, width, height, isMultiple = false, withSelectedInd
|
|
|
152
151
|
let w = !!width && width > 10 ? width : data.width;
|
|
153
152
|
let h = !!height && height > 10 ? height : data.height;
|
|
154
153
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
155
|
-
isMultiple && /* @__PURE__ */ jsx("svg", { className: clsx(shapeSvgMultiple
|
|
154
|
+
isMultiple && /* @__PURE__ */ jsx("svg", { className: clsx(shapeSvgMultiple), viewBox: `0 0 ${w} ${h}`, children: /* @__PURE__ */ jsx(ElementShapeSvg, { shape: data.shape, w, h }) }),
|
|
156
155
|
/* @__PURE__ */ jsxs("svg", { className: shapeSvg, viewBox: `0 0 ${w} ${h}`, children: [
|
|
157
156
|
withSelectedIndicator && /* @__PURE__ */ jsx(SelectedIndicator, { shape: data.shape, w, h }),
|
|
158
157
|
/* @__PURE__ */ jsx(ElementShapeSvg, { shape: data.shape, w, h })
|
|
@@ -184,7 +183,7 @@ function SelectedIndicator({ shape, w, h }) {
|
|
|
184
183
|
break;
|
|
185
184
|
}
|
|
186
185
|
}
|
|
187
|
-
return /* @__PURE__ */ jsx("g", { className:
|
|
186
|
+
return /* @__PURE__ */ jsx("g", { className: indicator, children: svg });
|
|
188
187
|
}
|
|
189
188
|
export {
|
|
190
189
|
ElementShape,
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
export declare const FramerMotionConfig: ({ children }: PropsWithChildren
|
|
2
|
+
export declare const FramerMotionConfig: ({ reducedMotion, children, }: PropsWithChildren<{
|
|
3
|
+
/**
|
|
4
|
+
* If true, will respect the device prefersReducedMotion setting by switching
|
|
5
|
+
* transform animations off.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
reducedMotion?: "always" | "never" | "user";
|
|
10
|
+
}>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,10 +2,13 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMantineStyleNonce } from "@mantine/core";
|
|
3
3
|
import { LazyMotion, domMax, MotionConfig } from "framer-motion";
|
|
4
4
|
import "react";
|
|
5
|
-
const FramerMotionConfig = ({
|
|
5
|
+
const FramerMotionConfig = ({
|
|
6
|
+
reducedMotion = "user",
|
|
7
|
+
children
|
|
8
|
+
}) => {
|
|
6
9
|
var _a;
|
|
7
10
|
const nonce = (_a = useMantineStyleNonce()) == null ? void 0 : _a();
|
|
8
|
-
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(MotionConfig, { ...nonce && { nonce }, children }) });
|
|
11
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(MotionConfig, { reducedMotion, ...nonce && { nonce }, children }) });
|
|
9
12
|
};
|
|
10
13
|
export {
|
|
11
14
|
FramerMotionConfig
|