@likec4/diagram 1.23.1 → 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.
Files changed (118) hide show
  1. package/dist/LikeC4Diagram.css.d.ts +5 -0
  2. package/dist/LikeC4Diagram.css.js +1 -0
  3. package/dist/LikeC4Diagram.d.ts +1 -1
  4. package/dist/LikeC4Diagram.js +6 -2
  5. package/dist/LikeC4Diagram.props.d.ts +6 -0
  6. package/dist/StaticLikeC4Diagram.js +2 -1
  7. package/dist/base/BaseXYFlow.d.ts +1 -1
  8. package/dist/base/BaseXYFlow.js +12 -3
  9. package/dist/base/const.d.ts +1 -1
  10. package/dist/base/const.js +1 -1
  11. package/dist/base/primitives/compound/CompoundActionButton.css.js +2 -0
  12. package/dist/base/primitives/compound/CompoundDetailsButton.css.js +2 -0
  13. package/dist/base/primitives/compound/CompoundNodeContainer.css.d.ts +0 -1
  14. package/dist/base/primitives/compound/CompoundNodeContainer.css.js +4 -4
  15. package/dist/base/primitives/compound/CompoundNodeContainer.js +35 -22
  16. package/dist/base/primitives/compound/CompoundTitle.css.js +3 -1
  17. package/dist/base/primitives/customNode.js +1 -1
  18. package/dist/base/primitives/edge/EdgeContainer.js +5 -4
  19. package/dist/base/primitives/edge/EdgeLabel.css.d.ts +0 -1
  20. package/dist/base/primitives/edge/EdgeLabel.css.js +2 -5
  21. package/dist/base/primitives/edge/EdgeLabel.js +5 -5
  22. package/dist/base/primitives/edge/edge.css.d.ts +1 -1
  23. package/dist/base/primitives/edge/edge.css.js +4 -5
  24. package/dist/base/primitives/element/ElementActionButtons.css.js +2 -0
  25. package/dist/base/primitives/element/ElementActionButtons.js +4 -3
  26. package/dist/base/primitives/element/ElementDetailsButton.css.js +2 -0
  27. package/dist/base/primitives/element/ElementNodeContainer.css.js +2 -0
  28. package/dist/base/primitives/element/ElementNodeContainer.js +3 -1
  29. package/dist/base/primitives/element/ElementShape.css.js +4 -2
  30. package/dist/base/primitives/element/ElementShape.js +2 -3
  31. package/dist/base/primitives/element/ElementTitle.css.js +2 -0
  32. package/dist/base/primitives/element/styles.css.js +2 -0
  33. package/dist/components/SearchControl.css.js +2 -0
  34. package/dist/context/FramerMotionConfig.d.ts +9 -1
  35. package/dist/context/FramerMotionConfig.js +5 -2
  36. package/dist/context/RootContainer.js +13 -1
  37. package/dist/diagram.css +1 -1
  38. package/dist/globals.css.d.ts +2 -0
  39. package/dist/hooks/safeContext.js +1 -0
  40. package/dist/hooks/useDiagram.d.ts +415 -693
  41. package/dist/hooks/useDiagram.js +1 -0
  42. package/dist/hooks/useIsReducedGraphics.d.ts +4 -0
  43. package/dist/hooks/useIsReducedGraphics.js +8 -0
  44. package/dist/hooks/useXYFlow.js +1 -1
  45. package/dist/likec4diagram/DiagramUI.d.ts +2 -1
  46. package/dist/likec4diagram/DiagramUI.js +5 -3
  47. package/dist/likec4diagram/custom/nodes/nodeTypes.js +2 -2
  48. package/dist/likec4diagram/ui/controls/styles.css.js +2 -0
  49. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.css.js +2 -0
  50. package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.js +3 -4
  51. package/dist/likec4diagram/ui/search/LikeC4Search.css.js +2 -0
  52. package/dist/overlays/element-details/ElementDetailsCard.js +12 -8
  53. package/dist/overlays/element-details/actor.d.ts +9084 -2569
  54. package/dist/overlays/overlay/Overlay.js +6 -3
  55. package/dist/overlays/relationship-details/RelationshipDetails.js +31 -17
  56. package/dist/overlays/relationship-details/actor.d.ts +228 -3
  57. package/dist/overlays/relationship-details/actor.js +86 -14
  58. package/dist/overlays/relationship-details/hooks.d.ts +3 -0
  59. package/dist/overlays/relationship-details/hooks.js +6 -2
  60. package/dist/overlays/relationships-browser/-useRelationshipsView.js +12 -3
  61. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +12 -3
  62. package/dist/overlays/relationships-browser/actor.d.ts +271 -54
  63. package/dist/overlays/relationships-browser/actor.js +86 -23
  64. package/dist/state/DiagramActorProvider.js +12 -2
  65. package/dist/state/diagram-machine.d.ts +426 -694
  66. package/dist/state/diagram-machine.js +89 -68
  67. package/dist/state/persistence.d.ts +5 -0
  68. package/dist/state/persistence.js +23 -0
  69. package/package.json +9 -9
  70. package/src/LikeC4Diagram.css.ts +13 -5
  71. package/src/LikeC4Diagram.props.ts +7 -0
  72. package/src/LikeC4Diagram.tsx +33 -24
  73. package/src/StaticLikeC4Diagram.tsx +2 -1
  74. package/src/base/BaseXYFlow.tsx +14 -9
  75. package/src/base/const.ts +1 -1
  76. package/src/base/primitives/compound/CompoundActionButton.css.ts +6 -0
  77. package/src/base/primitives/compound/CompoundDetailsButton.css.ts +4 -0
  78. package/src/base/primitives/compound/CompoundNodeContainer.css.ts +41 -59
  79. package/src/base/primitives/compound/CompoundNodeContainer.tsx +42 -22
  80. package/src/base/primitives/compound/CompoundTitle.css.ts +14 -13
  81. package/src/base/primitives/customNode.ts +3 -2
  82. package/src/base/primitives/edge/EdgeContainer.tsx +4 -3
  83. package/src/base/primitives/edge/EdgeLabel.css.ts +17 -11
  84. package/src/base/primitives/edge/EdgeLabel.tsx +4 -4
  85. package/src/base/primitives/edge/edge.css.ts +47 -27
  86. package/src/base/primitives/element/ElementActionButtons.css.ts +4 -0
  87. package/src/base/primitives/element/ElementActionButtons.tsx +4 -2
  88. package/src/base/primitives/element/ElementDetailsButton.css.ts +6 -8
  89. package/src/base/primitives/element/ElementNodeContainer.css.ts +18 -21
  90. package/src/base/primitives/element/ElementNodeContainer.tsx +3 -1
  91. package/src/base/primitives/element/ElementShape.css.ts +10 -6
  92. package/src/base/primitives/element/ElementShape.tsx +2 -2
  93. package/src/components/SearchControl.css.ts +11 -4
  94. package/src/context/FramerMotionConfig.tsx +13 -2
  95. package/src/context/RootContainer.tsx +9 -2
  96. package/src/globals.css.ts +3 -0
  97. package/src/hooks/safeContext.tsx +2 -1
  98. package/src/hooks/useDiagram.ts +1 -0
  99. package/src/hooks/useIsReducedGraphics.ts +5 -0
  100. package/src/hooks/useXYFlow.ts +1 -1
  101. package/src/likec4diagram/DiagramUI.tsx +5 -3
  102. package/src/likec4diagram/custom/nodes/nodeTypes.tsx +2 -2
  103. package/src/likec4diagram/ui/controls/styles.css.ts +11 -1
  104. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.css.ts +10 -3
  105. package/src/likec4diagram/ui/diagram-title/DiagramTitlePanel.tsx +6 -3
  106. package/src/likec4diagram/ui/search/LikeC4Search.css.ts +1 -0
  107. package/src/overlays/element-details/ElementDetailsCard.tsx +238 -231
  108. package/src/overlays/overlay/Overlay.css.ts +1 -9
  109. package/src/overlays/overlay/Overlay.tsx +6 -3
  110. package/src/overlays/relationship-details/RelationshipDetails.tsx +83 -66
  111. package/src/overlays/relationship-details/actor.ts +106 -13
  112. package/src/overlays/relationship-details/hooks.ts +6 -2
  113. package/src/overlays/relationships-browser/-useRelationshipsView.ts +10 -0
  114. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +16 -8
  115. package/src/overlays/relationships-browser/actor.ts +92 -22
  116. package/src/state/DiagramActorProvider.tsx +13 -2
  117. package/src/state/diagram-machine.ts +88 -65
  118. 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;
@@ -1,3 +1,4 @@
1
+ /* empty css */
1
2
  /* empty css */
2
3
  var cssReactFlow = "_2h8g8h0";
3
4
  var cssDisablePan = "_2h8g8h2";
@@ -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;
@@ -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
@@ -27,11 +27,12 @@ function StaticLikeC4Diagram({
27
27
  enableRelationshipDetails,
28
28
  enableRelationshipBrowser,
29
29
  enableDynamicViewWalkthrough: false,
30
+ showNavigationButtons: false,
30
31
  experimentalEdgeEditing: false,
31
32
  enableFocusMode: false,
33
+ enableSearch: false,
32
34
  nodesSelectable: false,
33
35
  nodesDraggable: false,
34
- enableSearch: false,
35
36
  ...rest
36
37
  }
37
38
  );
@@ -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' | 'onNodeMouseEnter' | 'onNodeMouseLeave' | 'onEdgeMouseEnter' | 'onEdgeMouseLeave' | 'fitViewOptions'>, 'nodes' | 'edges' | 'onNodesChange' | 'onEdgesChange'>>;
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;
@@ -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
- "data-likec4-zoom-small": isZoomTooSmall,
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
  };
@@ -4,5 +4,5 @@ export declare const ZIndexes: {
4
4
  readonly Element: 6;
5
5
  readonly Max: 8;
6
6
  };
7
- export declare const MinZoom = 0.1;
7
+ export declare const MinZoom = 0.05;
8
8
  export declare const MaxZoom = 2;
@@ -4,7 +4,7 @@ const ZIndexes = {
4
4
  Element: 6,
5
5
  Max: 8
6
6
  };
7
- const MinZoom = 0.1;
7
+ const MinZoom = 0.05;
8
8
  const MaxZoom = 2;
9
9
  export {
10
10
  MaxZoom,
@@ -1,3 +1,5 @@
1
+ /* empty css */
2
+ /* empty css */
1
3
  /* empty css */
2
4
  var container = "dbuyb70";
3
5
  var actionButton = "dbuyb71";
@@ -1,3 +1,5 @@
1
+ /* empty css */
2
+ /* empty css */
1
3
  /* empty css */
2
4
  var container = "k9mic70";
3
5
  var actionIcon = "k9mic72";
@@ -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 compoundBg = "_7cmew16";
6
- var compoundBorder = "_7cmew17";
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 { assignInlineVars } from "@vanilla-extract/dynamic";
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 { indicator, compoundBg, compoundBorder, varBorderTransparency, varCompoundOpacity, container } from "./CompoundNodeContainer.css.js";
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 isTransparent = isNumber(style.opacity) && style.opacity < 100;
23
- let opacity = clamp((style.opacity ?? 100) / 100, {
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
- opacity = Math.min(opacity + 0.11, 1);
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: assignInlineVars({
52
- [varCompoundOpacity]: opacity.toFixed(2),
53
- [varBorderTransparency]: `${borderTransparency}%`
54
- }),
64
+ style: {
65
+ ...style,
66
+ [opacityVar]: opacity,
67
+ [borderTransparencyVar]: `${borderTransparency}%`
68
+ },
55
69
  ...rest,
56
70
  children: [
57
- /* @__PURE__ */ jsx("svg", { className: indicator, children: /* @__PURE__ */ jsx(
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,5 +1,7 @@
1
+ /* empty css */
2
+ /* empty css */
1
3
  /* empty css */
2
- var compoundTitle = "_1dn4as0";
4
+ var compoundTitle = "_1dn4as0 _2h8g8h4";
3
5
  var title = "_1dn4as1";
4
6
  var icon = "_1dn4as2";
5
7
  export {
@@ -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.positionAbsoluteX, next.positionAbsoluteX) && deepEqual(prev.positionAbsoluteY, next.positionAbsoluteY) && deepEqual(prev.data, next.data);
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 { edgeVars, dimmed } from "./edge.css.js";
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
- edgeVars,
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
- "data-edge-dimmed": isDimmed,
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, edgeVars, edgeLabelContainer, dimmed } from "./EdgeLabel.css.js";
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: dimmed$1 = false,
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
- "data-edge-dimmed": dimmed$1,
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 dimmed: string;
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 edgeVars = "nrg7w91";
4
- var dimmed = "nrg7w92";
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
- dimmed,
10
+ edgeContainer,
11
11
  edgePathBg,
12
- edgeVars,
13
12
  markerContext
14
13
  };
@@ -1,3 +1,5 @@
1
+ /* empty css */
2
+ /* empty css */
1
3
  /* empty css */
2
4
  var container = "_14fvrz60";
3
5
  var actionButtons = "_14fvrz61";
@@ -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 { hiddenIfZoomTooSmall } from "../../../LikeC4Diagram.css.js";
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
- if (!buttons.length) {
16
+ const zoomTooSmall = useIsZoomTooSmall();
17
+ if (!buttons.length || zoomTooSmall) {
17
18
  return null;
18
19
  }
19
- return /* @__PURE__ */ jsx(Box, { className: clsx(container, hiddenIfZoomTooSmall), children: /* @__PURE__ */ jsx(
20
+ return /* @__PURE__ */ jsx(Box, { className: clsx(container), children: /* @__PURE__ */ jsx(
20
21
  Box,
21
22
  {
22
23
  component: m.div,
@@ -1,3 +1,5 @@
1
+ /* empty css */
2
+ /* empty css */
1
3
  /* empty css */
2
4
  var container = "_1jvuy7m0";
3
5
  var actionIconWrapper = "_1jvuy7m1";
@@ -1,3 +1,5 @@
1
+ /* empty css */
2
+ /* empty css */
1
3
  /* empty css */
2
4
  var container = "_1smoows1";
3
5
  export {
@@ -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, hiddenIfZoomTooSmall), viewBox: `0 0 ${w} ${h}`, children: /* @__PURE__ */ jsx(ElementShapeSvg, { shape: data.shape, w, h }) }),
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: clsx(indicator, hiddenIfZoomTooSmall), children: svg });
186
+ return /* @__PURE__ */ jsx("g", { className: indicator, children: svg });
188
187
  }
189
188
  export {
190
189
  ElementShape,
@@ -1,3 +1,5 @@
1
+ /* empty css */
2
+ /* empty css */
1
3
  /* empty css */
2
4
  /* empty css */
3
5
  /* empty css */
@@ -1,3 +1,5 @@
1
+ /* empty css */
2
+ /* empty css */
1
3
  /* empty css */
2
4
  /* empty css */
3
5
  var iconSize = "var(--likec4-icon-size)";
@@ -1,3 +1,5 @@
1
+ /* empty css */
2
+ /* empty css */
1
3
  /* empty css */
2
4
  var root = "xmhqho2";
3
5
  var shortcut = "xmhqho3";
@@ -1,2 +1,10 @@
1
1
  import { PropsWithChildren } from 'react';
2
- export declare const FramerMotionConfig: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
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 = ({ children }) => {
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