Skip to content

Commit ada0b2a

Browse files
authored
Merge pull request #314 from eccenca/fix/useCorrectEdgesAndArrows-CMEM-6721
Use correct edges and arrows for React Flow v12 (CMEM-6721)
2 parents 1ded734 + 54091d4 commit ada0b2a

37 files changed

Lines changed: 659 additions & 1070 deletions

CHANGELOG.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,39 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
88

99
This is a major release, and it might be not compatible with your current usage of our library. Please read about the necessary changes in the section about how to migrate.
1010

11+
### Added
12+
13+
- `<EdgeStraight />`
14+
- it's basically `<EdgeDefault />` without any special configs
15+
- `<EdgeBezier />`
16+
- only supported for v12, in v9 as straight edge is used
17+
- use `curvature` property in the edge `data` object to define the bezier layout (0..1, default: 0.25)
18+
- `<EdgeDefaultV12 />`
19+
- the `data` object provides `markerAppearance` to set and remove the edge arrows
20+
- `<EdgeNew />`
21+
- component for React Flow v12, displaying new connection lines
22+
23+
### Removed
24+
25+
- support for React Flow v10 was completely removed
26+
1127
### Fixed
1228

1329
- `<Modal />`:
14-
- Add 'nopan', 'nowheel' and 'nodrag' classes to Modal's overlay classes in order to always prevent react-flow to react to drag and pan actions in modals.
30+
- Add 'nopan', 'nowheel' and 'nodrag' classes to Modal's overlay classes in order to always prevent react-flow to react to drag and pan actions in modals.
31+
32+
### Changed
33+
34+
- `<EdgeDefault />` and `<EdgeStep />`
35+
- support now v9 and v12 of react flow
36+
- `<ReactFlowExtended />`
37+
- use `<EdgeNew />` by default for new connection lines, you can overwrite it by setting `connectionLineComponent` to `undefined`
38+
39+
### Deprecated
40+
41+
- support for React Flow v9 will be removed in v26
42+
- `<EdgeDefs />`
43+
- use `<ReactFlowMarkers />` or build it on single `<ReactFlowMarker />`
1544

1645
## [24.4.0] - 2025-08-07
1746

@@ -130,7 +159,7 @@ If you use Jest then you can use the same aliases for the `moduleNameMapper` con
130159

131160
### Migration from v24 to v25
132161

133-
- remove deprecated components, properties and imports from your project, if the info cannot be found here then it was already mentioned in **Deprecated** sections of the v24.* changelogs.
162+
- remove deprecated components, properties and imports from your project, if the info cannot be found here then it was already mentioned in **Deprecated** sections of the v24.\* changelogs.
134163
- we changed the integration of the supported react flow versions, formerly names `legacy` and `next` resources were renamed to more precise `v9` and `v10`, please see all info in the section about changes
135164

136165
## [24.1.0] - 2025-04-16

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
"react": "^16.13.1",
9595
"react-dom": "^16.13.1",
9696
"react-flow-renderer": "9.7.4",
97-
"react-flow-renderer-lts": "npm:react-flow-renderer@^10.3.17",
9897
"react-inlinesvg": "^3.0.3",
9998
"react-markdown": "^10.1.0",
10099
"react-markdown-deprecated": "npm:react-markdown@^8.0.7",

src/cmem/react-flow/ReactFlow/ReactFlow.stories.tsx

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ import {
66
FlowElement,
77
Position,
88
} from "react-flow-renderer";
9-
import {
10-
Background as BackgroundV10,
11-
BackgroundVariant as BackgroundVariantV10,
12-
Edge as Edge10,
13-
Node as Node10,
14-
OnInit as OnInitV10,
15-
ReactFlowInstance as ReactFlowInstanceV10,
16-
useEdgesState as useEdgesState10,
17-
useNodesState as useNodesState10,
18-
} from "react-flow-renderer-lts";
199
import { Meta, StoryFn } from "@storybook/react";
2010
import { fn } from "@storybook/test";
2111
import {
@@ -31,7 +21,6 @@ import {
3121
ApplicationContainer,
3222
EdgeTools,
3323
MiniMap,
34-
MiniMapV10,
3524
MiniMapV12,
3625
NodeTools,
3726
ReactFlowExtended,
@@ -425,7 +414,7 @@ export default {
425414
},
426415
flowVersion: {
427416
control: "select",
428-
options: [undefined, "v9", "v10", "v12"],
417+
options: [undefined, "v9", "v12"],
429418
},
430419
},
431420
} as Meta<typeof ReactFlowExtended>;
@@ -490,33 +479,6 @@ const ReactFlowExampleV9: FC<ReactFlowExtendedProps> = (args) => {
490479
);
491480
};
492481

493-
const ReactFlowExampleV10: FC<ReactFlowExtendedProps> = (args) => {
494-
const [reactFlowInstance, setReactFlowInstance] = React.useState<ReactFlowInstanceV10 | undefined>(undefined);
495-
const [nodes, ,] = useNodesState10(nodeExamples[args.configuration ?? "unspecified"].nodes as Node10[]);
496-
const [edges, ,] = useEdgesState10(nodeExamples[args.configuration ?? "unspecified"].edges as Edge10[]);
497-
498-
const onInit: OnInitV10 = React.useCallback((_reactFlowInstance: ReactFlowInstanceV10) => {
499-
setReactFlowInstance(_reactFlowInstance);
500-
}, []);
501-
502-
const reactFlowExtendedProps = {
503-
...args,
504-
defaultZoom: 1,
505-
nodes,
506-
edges,
507-
onInit,
508-
} as ReactFlowExtendedProps;
509-
510-
return (
511-
<ApplicationContainer monitorDropzonesFor={args.dropzoneFor} style={{ background: "white" }}>
512-
<ReactFlowExtended {...reactFlowExtendedProps}>
513-
<MiniMapV10 flowInstance={reactFlowInstance} enableNavigation={true} />
514-
<BackgroundV10 variant={BackgroundVariantV10.Lines} gap={16} />
515-
</ReactFlowExtended>
516-
</ApplicationContainer>
517-
);
518-
};
519-
520482
const ReactFlowExampleV12: FC<ReactFlowExtendedProps> = (args) => {
521483
const [nodes, ,] = useNodesState12(nodeExamples[args.configuration ?? "unspecified"].nodes as Node12[]);
522484
const [edges, ,] = useEdgesState12(nodeExamples[args.configuration ?? "unspecified"].edges as Edge12[]);
@@ -549,8 +511,6 @@ const ReactFlowExample: FC<ReactFlowExtendedProps> = (args) => {
549511
case undefined:
550512
case "v9":
551513
return <ReactFlowExampleV9 {...args} />;
552-
case "v10":
553-
return <ReactFlowExampleV10 {...args} />;
554514
case "v12":
555515
return <ReactFlowExampleV12 {...args} />;
556516
default:

src/cmem/react-flow/ReactFlow/ReactFlow.tsx

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import React, {ReactElement, Ref} from "react";
22
import { KeyCode as KeyCodeV9 } from "react-flow-renderer";
3-
import { KeyCode as KeyCodeV10 } from "react-flow-renderer-lts";
43
import { KeyCode as KeyCodeV12} from "@xyflow/react";
54

65
import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
76
import { ReactFlowMarkers } from "../../../extensions/react-flow/markers/ReactFlowMarkers";
87
import { ReactFlowVersions } from "../../../extensions/react-flow/versionsupport";
98
import { ReactFlowHotkeyContext } from "../extensions/ReactFlowHotkeyContext";
109
import { useReactFlowScrollOnDragV9 } from "../extensions/scrollOnDragHook";
11-
import { useReactFlowScrollOnDragV10 } from "../extensions/scrollOnDragHookV10";
1210

1311
import * as graphConfig from "./../configuration/graph";
1412
import * as linkingConfig from "./../configuration/linking";
1513
import * as unspecifiedConfig from "./../configuration/unspecified";
1614
import * as workflowConfig from "./../configuration/workflow";
1715
import { ReactFlowV9Container, ReactFlowV9ContainerProps } from "./ReactFlowV9";
18-
import { ReactFlowV10Container, ReactFlowV10ContainerProps } from "./ReactFlowV10";
1916
import { ReactFlowV12Container, ReactFlowV12ContainerProps } from "./ReactFlowV12";
2017

2118
export interface ReactFlowExtendedExtraProps {
@@ -55,13 +52,6 @@ interface ReactFlowExtendedVersion9SupportProps {
5552
flowVersion?: ReactFlowVersions.V9;
5653
}
5754

58-
interface ReactFlowExtendedVersion10SupportProps {
59-
/**
60-
* Set version of `ReactFlow` that is used internally.
61-
*/
62-
flowVersion: ReactFlowVersions.V10;
63-
}
64-
6555
interface ReactFlowExtendedVersion12SupportProps {
6656
/**
6757
* Set version of `ReactFlow` that is used internally.
@@ -74,16 +64,15 @@ interface ReactFlowExtendedVersion12SupportProps {
7464
}
7565

7666
export type ReactFlowExtendedPropsV9 = ReactFlowExtendedVersion9SupportProps & ReactFlowV9ContainerProps & ReactFlowExtendedExtraProps & ReactFlowExtendedScrollProps
77-
export type ReactFlowExtendedPropsV10 = ReactFlowExtendedVersion10SupportProps & ReactFlowV10ContainerProps & ReactFlowExtendedExtraProps & ReactFlowExtendedScrollProps
7867
export type ReactFlowExtendedPropsV12 = ReactFlowExtendedVersion12SupportProps & ReactFlowV12ContainerProps & ReactFlowExtendedExtraProps
7968

80-
export type ReactFlowExtendedProps = ReactFlowExtendedPropsV9 | ReactFlowExtendedPropsV10 | ReactFlowExtendedPropsV12
69+
export type ReactFlowExtendedProps = ReactFlowExtendedPropsV9 | ReactFlowExtendedPropsV12
8170

8271
/**
8372
* `ReactFlow` container extension that includes pre-configured nodes and edges for
8473
* Corporate Memory tools.
8574
*
86-
* @param T The concrete type of the corresponding version, i.e. either one of ReactFlowExtendedPropsV9, ReactFlowExtendedPropsV10 or ReactFlowExtendedPropsV12
75+
* @param T The concrete type of the corresponding version, i.e. either one of ReactFlowExtendedPropsV9 or ReactFlowExtendedPropsV12
8776
*/
8877
const ReactFlowExtendedPlain = <T extends ReactFlowExtendedProps>({
8978
configuration = "unspecified",
@@ -157,14 +146,6 @@ const ReactFlowExtendedPlain = <T extends ReactFlowExtendedProps>({
157146
zoomActivationKeyCode: hotKeysDisabled ? undefined : (zoomActivationKeyCode as KeyCodeV9),
158147
};
159148
break;
160-
case "v10":
161-
keyCodeConfig = {
162-
selectionKeyCode: hotKeysDisabled ? undefined : (selectionKeyCode as KeyCodeV10),
163-
deleteKeyCode: hotKeysDisabled ? undefined : (deleteKeyCode as KeyCodeV10),
164-
multiSelectionKeyCode: hotKeysDisabled ? undefined : (multiSelectionKeyCode as KeyCodeV10),
165-
zoomActivationKeyCode: hotKeysDisabled ? undefined : (zoomActivationKeyCode as KeyCodeV10),
166-
};
167-
break;
168149
case "v12":
169150
keyCodeConfig = {
170151
selectionKeyCode: hotKeysDisabled ? null : (selectionKeyCode as KeyCodeV12),
@@ -183,12 +164,6 @@ const ReactFlowExtendedPlain = <T extends ReactFlowExtendedProps>({
183164
scrollOnDrag,
184165
});
185166
break;
186-
case "v10":
187-
scrollOnDragFunctions = useReactFlowScrollOnDragV10({
188-
reactFlowProps: originalProps as ReactFlowV10ContainerProps,
189-
scrollOnDrag,
190-
});
191-
break;
192167
// should not be necessary for v12
193168
}
194169

@@ -207,13 +182,6 @@ const ReactFlowExtendedPlain = <T extends ReactFlowExtendedProps>({
207182
<ReactFlowMarkers />
208183
</ReactFlowV9Container>
209184
);
210-
case "v10":
211-
return (
212-
<ReactFlowV10Container ref={innerRef} {...(containerConfig as ReactFlowV10ContainerProps)}>
213-
{children}
214-
<ReactFlowMarkers />
215-
</ReactFlowV10Container>
216-
);
217185
case "v12":
218186
return (
219187
<ReactFlowV12Container ref={innerRef} {...(containerConfig as ReactFlowV12ContainerProps)}>

src/cmem/react-flow/ReactFlow/ReactFlowV10.tsx

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/cmem/react-flow/ReactFlow/ReactFlowV12.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from "@xyflow/react";
1010

1111
import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
12+
import { EdgeNew } from "./../../../extensions/react-flow/edges/EdgeNew";
1213

1314
export type ReactFlowV12ContainerProps = ReactFlowV12Props;
1415

@@ -43,6 +44,7 @@ export const ReactFlowV12Container = React.forwardRef<HTMLDivElement, ReactFlowV
4344
<ReactFlowV12
4445
ref={innerRef}
4546
className={`${eccgui}-graphviz__canvas--reactflow12` + (className ? ` ${className}` : "")}
47+
connectionLineComponent={EdgeNew}
4648
{...originalProps}
4749
{...missingNodesChangeCallback}
4850
{...missingEdgesChangeCallback}

src/cmem/react-flow/configuration/graph.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import { EdgeDefault } from "./../../../extensions/react-flow/edges/EdgeDefault";
1+
import { EdgeBezier } from "./../../../extensions/react-flow/edges/EdgeBezier";
22
import { NodeDefault } from "./../../../extensions/react-flow/nodes/NodeDefault";
33
import { GRAPH_NODE_TYPES } from "./typing";
4-
import {ComponentType} from "react";
5-
import {NodeProps} from "react-flow-renderer-lts";
4+
//import {ComponentType} from "react";
5+
//import {NodeProps} from "react-flow-renderer-lts";
66

77
const edgeTypes = {
8-
default: EdgeDefault,
9-
implicit: EdgeDefault,
10-
import: EdgeDefault,
11-
subclass: EdgeDefault,
12-
subproperty: EdgeDefault,
13-
rdftype: EdgeDefault,
14-
success: EdgeDefault,
15-
warning: EdgeDefault,
16-
danger: EdgeDefault,
8+
default: EdgeBezier,
9+
implicit: EdgeBezier,
10+
import: EdgeBezier,
11+
subclass: EdgeBezier,
12+
subproperty: EdgeBezier,
13+
rdftype: EdgeBezier,
14+
success: EdgeBezier,
15+
warning: EdgeBezier,
16+
danger: EdgeBezier,
1717
};
1818

19-
const nodeTypes: Record<GRAPH_NODE_TYPES, React.ReactNode & ComponentType<NodeProps>> = {
19+
const nodeTypes: Record<GRAPH_NODE_TYPES, React.ReactNode /*& ComponentType<NodeProps>*/> = {
2020
default: NodeDefault,
2121
graph: NodeDefault,
2222
class: NodeDefault,

src/cmem/react-flow/configuration/linking.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { EdgeStep } from "./../../../extensions/react-flow/edges/EdgeStep";
22
import { NodeDefault } from "./../../../extensions/react-flow/nodes/NodeDefault";
33
import { StickyNoteNode } from "./../nodes/StickyNoteNode";
44
import { LINKING_NODE_TYPES } from "./typing";
5-
import {ComponentType} from "react";
6-
import {NodeProps} from "react-flow-renderer-lts";
5+
//import {ComponentType} from "react";
6+
//import {NodeProps} from "react-flow-renderer-lts";
77

88
const edgeTypes = {
99
default: EdgeStep,
@@ -14,7 +14,7 @@ const edgeTypes = {
1414
danger: EdgeStep,
1515
};
1616

17-
const nodeTypes: Record<LINKING_NODE_TYPES, React.ReactNode & ComponentType<NodeProps>> = {
17+
const nodeTypes: Record<LINKING_NODE_TYPES, React.ReactNode /*& ComponentType<NodeProps>*/> = {
1818
default: NodeDefault,
1919
sourcepath: NodeDefault,
2020
targetpath: NodeDefault,

src/cmem/react-flow/configuration/unspecified.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { EdgeDefault } from "./../../../extensions/react-flow/edges/EdgeDefault";
22
import { EdgeStep } from "./../../../extensions/react-flow/edges/EdgeStep";
3+
import { EdgeStraight } from "./../../../extensions/react-flow/edges/EdgeStraight";
34
import { NodeDefault } from "./../../../extensions/react-flow/nodes/NodeDefault";
45

56
export const edgeTypes = {
67
default: EdgeDefault,
7-
straight: EdgeDefault,
8+
straight: EdgeStraight,
89
step: EdgeStep,
910
};
1011

src/cmem/react-flow/configuration/workflow.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { EdgeStep } from "./../../../extensions/react-flow/edges/EdgeStep";
22
import { NodeDefault } from "./../../../extensions/react-flow/nodes/NodeDefault";
33
import { StickyNoteNode } from "./../nodes/StickyNoteNode";
44
import { WORKFLOW_NODE_TYPES } from "./typing";
5-
import {ComponentType} from "react";
6-
import {NodeProps} from "react-flow-renderer-lts";
5+
//import {ComponentType} from "react";
6+
//import {NodeProps} from "react-flow-renderer-lts";
77

88
const edgeTypes = {
99
default: EdgeStep,
@@ -12,7 +12,7 @@ const edgeTypes = {
1212
danger: EdgeStep,
1313
};
1414

15-
const nodeTypes: Record<WORKFLOW_NODE_TYPES, React.ReactNode & ComponentType<NodeProps>> = {
15+
const nodeTypes: Record<WORKFLOW_NODE_TYPES, React.ReactNode /*& ComponentType<NodeProps>*/> = {
1616
default: NodeDefault,
1717
dataset: NodeDefault,
1818
linking: NodeDefault,

0 commit comments

Comments
 (0)