@eccenca/gui-elements 24.2.0 → 24.4.0
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/CHANGELOG.md +47 -0
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js +12 -9
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js +10 -9
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.js +2 -2
- package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.js.map +1 -1
- package/dist/cjs/components/Icon/IconButton.js +1 -0
- package/dist/cjs/components/Icon/IconButton.js.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.js +12 -7
- package/dist/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/cjs/extensions/codemirror/CodeMirror.js +83 -21
- package/dist/cjs/extensions/codemirror/CodeMirror.js.map +1 -1
- package/dist/cjs/extensions/codemirror/tests/codemirrorTestHelper.js +22 -1
- package/dist/cjs/extensions/codemirror/tests/codemirrorTestHelper.js.map +1 -1
- package/dist/cjs/extensions/react-flow/edges/EdgeDefaultV12.js +56 -0
- package/dist/cjs/extensions/react-flow/edges/EdgeDefaultV12.js.map +1 -0
- package/dist/cjs/extensions/react-flow/edges/EdgeDefs.js +14 -0
- package/dist/cjs/extensions/react-flow/edges/EdgeDefs.js.map +1 -0
- package/dist/cjs/extensions/react-flow/handles/HandleDefault.js +3 -0
- package/dist/cjs/extensions/react-flow/handles/HandleDefault.js.map +1 -1
- package/dist/cjs/extensions/react-flow/index.js +3 -0
- package/dist/cjs/extensions/react-flow/index.js.map +1 -1
- package/dist/cjs/extensions/react-flow/nodes/NodeContent.js +49 -28
- package/dist/cjs/extensions/react-flow/nodes/NodeContent.js.map +1 -1
- package/dist/cjs/extensions/react-flow/versionsupport.js +6 -0
- package/dist/cjs/extensions/react-flow/versionsupport.js.map +1 -1
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js +12 -9
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js +10 -9
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.js +2 -2
- package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.js.map +1 -1
- package/dist/esm/components/Icon/IconButton.js +1 -0
- package/dist/esm/components/Icon/IconButton.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js +14 -9
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/extensions/codemirror/CodeMirror.js +84 -22
- package/dist/esm/extensions/codemirror/CodeMirror.js.map +1 -1
- package/dist/esm/extensions/codemirror/tests/codemirrorTestHelper.js +20 -0
- package/dist/esm/extensions/codemirror/tests/codemirrorTestHelper.js.map +1 -1
- package/dist/esm/extensions/react-flow/edges/EdgeDefaultV12.js +77 -0
- package/dist/esm/extensions/react-flow/edges/EdgeDefaultV12.js.map +1 -0
- package/dist/esm/extensions/react-flow/edges/EdgeDefs.js +8 -0
- package/dist/esm/extensions/react-flow/edges/EdgeDefs.js.map +1 -0
- package/dist/esm/extensions/react-flow/handles/HandleDefault.js +3 -0
- package/dist/esm/extensions/react-flow/handles/HandleDefault.js.map +1 -1
- package/dist/esm/extensions/react-flow/index.js +3 -0
- package/dist/esm/extensions/react-flow/index.js.map +1 -1
- package/dist/esm/extensions/react-flow/nodes/NodeContent.js +66 -44
- package/dist/esm/extensions/react-flow/nodes/NodeContent.js.map +1 -1
- package/dist/esm/extensions/react-flow/versionsupport.js +6 -0
- package/dist/esm/extensions/react-flow/versionsupport.js.map +1 -1
- package/dist/types/cmem/ActivityControl/ActivityControlWidget.d.ts +4 -0
- package/dist/types/components/AutoSuggestion/AutoSuggestion.d.ts +7 -1
- package/dist/types/components/AutoSuggestion/ExtendedCodeEditor.d.ts +5 -1
- package/dist/types/components/Tooltip/Tooltip.d.ts +7 -1
- package/dist/types/extensions/codemirror/CodeMirror.d.ts +3 -2
- package/dist/types/extensions/codemirror/tests/codemirrorTestHelper.d.ts +3 -1
- package/dist/types/extensions/react-flow/edges/EdgeDefaultV12.d.ts +38 -0
- package/dist/types/extensions/react-flow/edges/EdgeDefs.d.ts +2 -0
- package/dist/types/extensions/react-flow/handles/HandleDefault.d.ts +4 -1
- package/dist/types/extensions/react-flow/index.d.ts +3 -0
- package/dist/types/extensions/react-flow/nodes/NodeContent.d.ts +5 -4
- package/dist/types/extensions/react-flow/versionsupport.d.ts +3 -2
- package/package.json +6 -3
- package/src/cmem/ActivityControl/ActivityControlWidget.stories.tsx +45 -5
- package/src/cmem/ActivityControl/ActivityControlWidget.tsx +47 -9
- package/src/cmem/ActivityControl/tests/ActivityControlWidget.test.tsx +99 -0
- package/src/components/AutoSuggestion/AutoSuggestion.tsx +30 -16
- package/src/components/AutoSuggestion/ExtendedCodeEditor.tsx +8 -0
- package/src/components/Icon/IconButton.tsx +1 -0
- package/src/components/Tooltip/Tooltip.tsx +24 -13
- package/src/extensions/codemirror/CodeMirror.tsx +102 -26
- package/src/extensions/codemirror/tests/codemirrorTestHelper.ts +20 -1
- package/src/extensions/react-flow/_react-flow.scss +1 -0
- package/src/extensions/react-flow/_react-flow_v12.scss +5 -0
- package/src/extensions/react-flow/edges/EdgeDefaultV12.tsx +154 -0
- package/src/extensions/react-flow/edges/EdgeDefs.tsx +30 -0
- package/src/extensions/react-flow/edges/_edges.scss +18 -0
- package/src/extensions/react-flow/edges/stories/EdgeDefaultV12.stories.tsx +183 -0
- package/src/extensions/react-flow/handles/HandleDefault.tsx +12 -4
- package/src/extensions/react-flow/index.ts +3 -0
- package/src/extensions/react-flow/nodes/NodeContent.tsx +85 -48
- package/src/extensions/react-flow/nodes/NodeDefaultV12.tsx +53 -0
- package/src/extensions/react-flow/nodes/stories/NodeContentV12.stories.tsx +270 -0
- package/src/extensions/react-flow/versionsupport.ts +7 -2
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import React, { useCallback, useState } from "react";
|
|
2
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
3
|
+
import { addEdge, Edge, OnConnect, Position, ReactFlow, useEdgesState, useNodesState } from "@xyflow/react";
|
|
4
|
+
|
|
5
|
+
import { NodeDefaultV12 } from "../../nodes/NodeDefaultV12";
|
|
6
|
+
import { EdgeDefaultV12, EdgeDefaultV12DataProps as EdgeData } from "../EdgeDefaultV12";
|
|
7
|
+
import { EdgeDefs } from "../EdgeDefs";
|
|
8
|
+
|
|
9
|
+
import { EdgeLabel, EdgeLabelObject } from "./../../../../../index";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* this is only a mock to get it as sub element in the table
|
|
13
|
+
*/
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
15
|
+
const EdgeDefaultDataProps = (data: EdgeData) => {
|
|
16
|
+
return <></>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const edgeTypes = {
|
|
20
|
+
default: EdgeDefaultV12,
|
|
21
|
+
};
|
|
22
|
+
const nodeTypes = {
|
|
23
|
+
default: NodeDefaultV12,
|
|
24
|
+
};
|
|
25
|
+
export default {
|
|
26
|
+
title: "Extensions/React Flow V12/Edge",
|
|
27
|
+
component: EdgeDefaultV12,
|
|
28
|
+
subcomponents: { EdgeDefaultDataProps },
|
|
29
|
+
} as Meta<typeof EdgeDefaultV12>;
|
|
30
|
+
|
|
31
|
+
const EdgeDefault = (args: Edge) => {
|
|
32
|
+
const [reactflowInstance, setReactflowInstance] = useState(null);
|
|
33
|
+
|
|
34
|
+
const [nodes, , onNodesChange] = useNodesState([
|
|
35
|
+
{
|
|
36
|
+
id: args.source,
|
|
37
|
+
type: "default",
|
|
38
|
+
data: {
|
|
39
|
+
label: "Default source",
|
|
40
|
+
content: "Example content.",
|
|
41
|
+
minimalShape: "none",
|
|
42
|
+
handles: [
|
|
43
|
+
{
|
|
44
|
+
id: args.source,
|
|
45
|
+
type: "source",
|
|
46
|
+
tooltip: "this is a source handle",
|
|
47
|
+
position: Position.Right,
|
|
48
|
+
onClick: (params) => {
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.log("onClick source", params);
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
position: { x: 50, y: 200 },
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: args.target,
|
|
59
|
+
type: "default",
|
|
60
|
+
data: {
|
|
61
|
+
label: "Default target",
|
|
62
|
+
content: "Example content.",
|
|
63
|
+
minimalShape: "none",
|
|
64
|
+
handles: [
|
|
65
|
+
{
|
|
66
|
+
id: args.target,
|
|
67
|
+
type: "target",
|
|
68
|
+
tooltip: "this is a target handle",
|
|
69
|
+
position: Position.Left,
|
|
70
|
+
onClick: (params) => {
|
|
71
|
+
// eslint-disable-next-line no-console
|
|
72
|
+
console.log("onClick target", params);
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
position: { x: 600, y: 200 },
|
|
78
|
+
},
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
const [edges, setEdges, onEdgesChange] = useEdgesState([
|
|
82
|
+
{
|
|
83
|
+
...args,
|
|
84
|
+
// sourceX: 150,
|
|
85
|
+
// sourceY: 0,
|
|
86
|
+
// targetX: 250,
|
|
87
|
+
// targetY: 0,
|
|
88
|
+
sourcePosition: Position.Left,
|
|
89
|
+
targetPosition: Position.Right,
|
|
90
|
+
},
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
const onConnect: OnConnect = useCallback((params) => setEdges((eds) => addEdge(params, eds)), []);
|
|
94
|
+
|
|
95
|
+
const onLoad = useCallback(
|
|
96
|
+
(rfi) => {
|
|
97
|
+
if (!reactflowInstance) {
|
|
98
|
+
setReactflowInstance(rfi);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
[reactflowInstance]
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<div style={{ width: "1000px", height: "800px" }}>
|
|
106
|
+
<EdgeDefs />
|
|
107
|
+
<ReactFlow
|
|
108
|
+
nodes={nodes}
|
|
109
|
+
edges={edges}
|
|
110
|
+
onLoad={onLoad}
|
|
111
|
+
edgeTypes={edgeTypes}
|
|
112
|
+
nodeTypes={nodeTypes}
|
|
113
|
+
onNodesChange={onNodesChange}
|
|
114
|
+
onEdgesChange={onEdgesChange}
|
|
115
|
+
onConnect={onConnect}
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const Template: StoryFn<typeof EdgeDefault> = (args) => <EdgeDefault {...args} />;
|
|
122
|
+
|
|
123
|
+
const defaultEdge: Edge = {
|
|
124
|
+
id: "default",
|
|
125
|
+
label: "edge",
|
|
126
|
+
source: "node-1",
|
|
127
|
+
target: "node-2",
|
|
128
|
+
data: {
|
|
129
|
+
edgeSvgProps: {
|
|
130
|
+
className: "storybook__test__classname",
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const Default = Template.bind({});
|
|
136
|
+
Default.args = defaultEdge;
|
|
137
|
+
|
|
138
|
+
export const CustomLabel = Template.bind({});
|
|
139
|
+
CustomLabel.args = {
|
|
140
|
+
...Default.args,
|
|
141
|
+
id: "customlabel",
|
|
142
|
+
label: undefined,
|
|
143
|
+
data: {
|
|
144
|
+
renderLabel: (edgeCenter: [number, number, number, number]) => (
|
|
145
|
+
<EdgeLabelObject edgeCenter={edgeCenter}>
|
|
146
|
+
<EdgeLabel text="Custom label that is very long" />
|
|
147
|
+
</EdgeLabelObject>
|
|
148
|
+
),
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const InverseEdge = Template.bind({});
|
|
153
|
+
InverseEdge.args = {
|
|
154
|
+
...Default.args,
|
|
155
|
+
id: "inverse",
|
|
156
|
+
data: {
|
|
157
|
+
inversePath: true,
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const AdjustStrokeType = Template.bind({});
|
|
162
|
+
AdjustStrokeType.args = {
|
|
163
|
+
...Default.args,
|
|
164
|
+
data: {
|
|
165
|
+
strokeType: "double",
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export const AdjustIntent = Template.bind({});
|
|
170
|
+
AdjustIntent.args = {
|
|
171
|
+
...Default.args,
|
|
172
|
+
data: {
|
|
173
|
+
intent: "warning",
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const AdjustHighlight = Template.bind({});
|
|
178
|
+
AdjustHighlight.args = {
|
|
179
|
+
...Default.args,
|
|
180
|
+
data: {
|
|
181
|
+
highlightColor: ["default", "alternate"],
|
|
182
|
+
},
|
|
183
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { memo } from "react";
|
|
2
2
|
import { Handle as HandleLegacy, HandleProps as ReactFlowHandleLegacyProps } from "react-flow-renderer";
|
|
3
3
|
import { Handle as HandleNext, HandleProps as ReactFlowHandleNextProps } from "react-flow-renderer-lts";
|
|
4
|
+
import { Handle as HandleV12, HandleProps as ReactFlowHandleV12Props } from "@xyflow/react";
|
|
4
5
|
import { Classes as BlueprintClasses } from "@blueprintjs/core";
|
|
5
6
|
|
|
6
7
|
import { intentClassName, IntentTypes } from "../../../common/Intent";
|
|
@@ -36,8 +37,8 @@ interface HandleExtensionProps
|
|
|
36
37
|
|
|
37
38
|
export interface HandleProps extends HandleExtensionProps, ReactFlowHandleLegacyProps {}
|
|
38
39
|
export interface HandleNextProps extends HandleExtensionProps, ReactFlowHandleNextProps {}
|
|
39
|
-
|
|
40
|
-
export type HandleDefaultProps = HandleProps | HandleNextProps;
|
|
40
|
+
export interface HandleV12Props extends HandleExtensionProps, ReactFlowHandleV12Props {}
|
|
41
|
+
export type HandleDefaultProps = HandleProps | HandleNextProps | HandleV12Props;
|
|
41
42
|
|
|
42
43
|
export const HandleDefault = memo(
|
|
43
44
|
({ flowVersion, data, tooltip, children, category, intent, ...handleProps }: HandleDefaultProps) => {
|
|
@@ -126,16 +127,23 @@ export const HandleDefault = memo(
|
|
|
126
127
|
switch (flowVersionCheck) {
|
|
127
128
|
case "legacy":
|
|
128
129
|
return (
|
|
129
|
-
<HandleLegacy ref={handleDefaultRef} {...handleConfig}>
|
|
130
|
+
<HandleLegacy ref={handleDefaultRef} {...(handleConfig as HandleProps)}>
|
|
130
131
|
{handleContent}
|
|
131
132
|
</HandleLegacy>
|
|
132
133
|
);
|
|
133
134
|
case "next":
|
|
134
135
|
return (
|
|
135
|
-
<HandleNext ref={handleDefaultRef} {...handleConfig}>
|
|
136
|
+
<HandleNext ref={handleDefaultRef} {...(handleConfig as HandleNextProps)}>
|
|
136
137
|
{handleContent}
|
|
137
138
|
</HandleNext>
|
|
138
139
|
);
|
|
140
|
+
case "v12":
|
|
141
|
+
return (
|
|
142
|
+
<HandleV12 ref={handleDefaultRef} {...(handleConfig as HandleV12Props)}>
|
|
143
|
+
{handleContent}
|
|
144
|
+
</HandleV12>
|
|
145
|
+
);
|
|
146
|
+
|
|
139
147
|
default:
|
|
140
148
|
return <></>;
|
|
141
149
|
}
|
|
@@ -10,9 +10,12 @@ export * from "./edges/EdgeDefault";
|
|
|
10
10
|
export * from "./edges/EdgeStep";
|
|
11
11
|
export * from "./edges/EdgeTools";
|
|
12
12
|
export * from "./edges/EdgeLabel";
|
|
13
|
+
export * from "./edges/EdgeDefs";
|
|
14
|
+
export * from "./edges/EdgeDefaultV12";
|
|
13
15
|
export * from "./markers/ReactFlowMarkers";
|
|
14
16
|
export * from "./minimap/MiniMap";
|
|
15
17
|
export * from "./minimap/utils";
|
|
18
|
+
export * from "./versionsupport";
|
|
16
19
|
|
|
17
20
|
// deprecated exports
|
|
18
21
|
export { nodeTypes } from "./nodes/nodeTypes"; // @deprecated removed in v25
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Position, useStoreState as getStoreStateFlowLegacy } from "react-flow-renderer";
|
|
3
3
|
import { useStore as getStoreStateFlowNext } from "react-flow-renderer-lts";
|
|
4
|
+
import { useStore as useStoreFlowV12 } from "@xyflow/react";
|
|
4
5
|
import Color from "color";
|
|
5
6
|
import { Resizable } from "re-resizable";
|
|
6
7
|
|
|
7
8
|
import { intentClassName, IntentTypes } from "../../../common/Intent";
|
|
8
|
-
import { DepictionProps } from "../../../components
|
|
9
|
+
import { DepictionProps } from "../../../components";
|
|
9
10
|
import { ValidIconName } from "../../../components/Icon/canonicalIconNames";
|
|
10
11
|
import { CLASSPREFIX as eccgui } from "../../../configuration/constants";
|
|
11
|
-
import { Depiction, Icon, OverflowText } from "../../../index";
|
|
12
|
+
import { Depiction, HandleDefaultProps, Icon, OverflowText } from "../../../index";
|
|
13
|
+
import { HandleDefault, HandleNextProps, HandleProps, HandleV12Props } from "../handles/HandleDefault";
|
|
12
14
|
import { ReacFlowVersionSupportProps, useReactFlowVersion } from "../versionsupport";
|
|
13
15
|
|
|
14
|
-
import { HandleDefault, HandleNextProps, HandleProps } from "./../handles/HandleDefault";
|
|
15
16
|
import { NodeContentExtensionProps } from "./NodeContentExtension";
|
|
16
17
|
import { NodeDefaultProps } from "./NodeDefault";
|
|
17
18
|
import { NodeHighlightColor } from "./sharedTypes";
|
|
@@ -20,7 +21,12 @@ type NodeContentHandleLegacyProps = HandleProps;
|
|
|
20
21
|
|
|
21
22
|
type NodeContentHandleNextProps = HandleNextProps;
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
type NodeContentHandleV12Props = HandleV12Props;
|
|
25
|
+
|
|
26
|
+
export type NodeContentHandleProps =
|
|
27
|
+
| NodeContentHandleLegacyProps
|
|
28
|
+
| NodeContentHandleNextProps
|
|
29
|
+
| NodeContentHandleV12Props;
|
|
24
30
|
|
|
25
31
|
export type NodeDimensions = {
|
|
26
32
|
width?: number;
|
|
@@ -150,7 +156,7 @@ export interface NodeContentProps<NODE_DATA, NODE_CONTENT_PROPS = any>
|
|
|
150
156
|
* Array of property definition objects for `Handle` components that need to be created for the node.
|
|
151
157
|
* @see https://reactflow.dev/docs/api/handle/
|
|
152
158
|
*/
|
|
153
|
-
handles?:
|
|
159
|
+
handles?: NodeContentHandleProps[];
|
|
154
160
|
/**
|
|
155
161
|
* Set the minimal number of handles on left or right side of the node to activate the recalculation of the minimal height of the node.
|
|
156
162
|
*/
|
|
@@ -223,26 +229,33 @@ export interface NodeContentProps<NODE_DATA, NODE_CONTENT_PROPS = any>
|
|
|
223
229
|
|
|
224
230
|
interface MemoHandlerLegacyProps extends HandleProps {
|
|
225
231
|
posdirection: string;
|
|
226
|
-
style:
|
|
227
|
-
|
|
228
|
-
};
|
|
232
|
+
style: React.CSSProperties;
|
|
233
|
+
flowVersion: "legacy";
|
|
229
234
|
}
|
|
230
235
|
|
|
231
236
|
interface MemoHandlerNextProps extends HandleNextProps {
|
|
232
237
|
posdirection: string;
|
|
233
|
-
style:
|
|
234
|
-
|
|
235
|
-
|
|
238
|
+
style: React.CSSProperties;
|
|
239
|
+
flowVersion: "next";
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
interface MemoHandlerV12Props extends HandleV12Props {
|
|
243
|
+
posdirection: string;
|
|
244
|
+
style: React.CSSProperties;
|
|
245
|
+
flowVersion: "v12";
|
|
236
246
|
}
|
|
237
247
|
|
|
238
|
-
type MemoHandlerProps = MemoHandlerLegacyProps | MemoHandlerNextProps;
|
|
248
|
+
type MemoHandlerProps = MemoHandlerLegacyProps | MemoHandlerNextProps | MemoHandlerV12Props;
|
|
239
249
|
|
|
240
|
-
const defaultHandles = (flowVersion: ReacFlowVersionSupportProps["flowVersion"]) => {
|
|
250
|
+
const defaultHandles = (flowVersion: ReacFlowVersionSupportProps["flowVersion"]): NodeContentHandleProps[] => {
|
|
241
251
|
switch (flowVersion) {
|
|
242
252
|
case "legacy":
|
|
243
253
|
return [{ type: "target" }, { type: "source" }] as NodeContentHandleLegacyProps[];
|
|
244
254
|
case "next":
|
|
245
255
|
return [{ type: "target" }, { type: "source" }] as NodeContentHandleNextProps[];
|
|
256
|
+
case "v12":
|
|
257
|
+
return [{ type: "target" }, { type: "source" }] as NodeContentHandleV12Props[];
|
|
258
|
+
|
|
246
259
|
default:
|
|
247
260
|
return [];
|
|
248
261
|
}
|
|
@@ -265,7 +278,8 @@ const addHandles = (
|
|
|
265
278
|
nodeStyle: any,
|
|
266
279
|
flowVersion: any = "legacy"
|
|
267
280
|
) => {
|
|
268
|
-
return handles[position].map((handle:
|
|
281
|
+
return handles[position].map((handle: HandleDefaultProps, idx: number) => {
|
|
282
|
+
// FIXME: remove? orig v12 change: return handles[position].map((handle: any, idx: any) => {
|
|
269
283
|
const { style = {}, ...otherHandleProps } = handle;
|
|
270
284
|
const styleAdditions: { [key: string]: string } = {
|
|
271
285
|
color: nodeStyle.borderColor ?? undefined,
|
|
@@ -280,17 +294,22 @@ const addHandles = (
|
|
|
280
294
|
isConnectable: typeof handle.isConnectable !== "undefined" ? handle.isConnectable : isConnectable,
|
|
281
295
|
},
|
|
282
296
|
};
|
|
297
|
+
|
|
283
298
|
return <MemoHandler flowVersion={flowVersion} {...handleProperties} key={"handle" + idx} />;
|
|
284
299
|
});
|
|
285
300
|
};
|
|
286
301
|
|
|
302
|
+
function compareStyleDirection(styleA: React.CSSProperties, styleB: React.CSSProperties, direction: string) {
|
|
303
|
+
return styleA[direction as keyof React.CSSProperties] === styleB[direction as keyof React.CSSProperties];
|
|
304
|
+
}
|
|
305
|
+
|
|
287
306
|
const MemoHandler = React.memo(
|
|
288
307
|
(props: MemoHandlerProps) => <HandleDefault {...props} />,
|
|
289
308
|
(prev, next) => {
|
|
290
309
|
return (
|
|
291
310
|
// we only test a few properties to control re-rendering
|
|
292
311
|
// need to be extended if also other properties need to be changed late
|
|
293
|
-
prev.style
|
|
312
|
+
compareStyleDirection(prev.style, next.style, prev.posdirection) &&
|
|
294
313
|
prev.isConnectable === next.isConnectable &&
|
|
295
314
|
prev.intent === next.intent &&
|
|
296
315
|
prev.category === next.category
|
|
@@ -360,15 +379,24 @@ export function NodeContent<CONTENT_PROPS = any>({
|
|
|
360
379
|
const [width, setWidth] = React.useState<number | undefined>(nodeDimensions?.width ?? undefined);
|
|
361
380
|
const [height, setHeight] = React.useState<number | undefined>(nodeDimensions?.height ?? undefined);
|
|
362
381
|
// Keeps the initial size of the element
|
|
363
|
-
const originalSize = React.useRef<NodeDimensions>({})
|
|
382
|
+
const originalSize = React.useRef<NodeDimensions>({});
|
|
364
383
|
|
|
365
384
|
let zoom = 1;
|
|
366
385
|
if (isResizable)
|
|
367
386
|
try {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
387
|
+
switch (flowVersionCheck) {
|
|
388
|
+
case "legacy":
|
|
389
|
+
[, , zoom] = getStoreStateFlowLegacy((state) => state.transform);
|
|
390
|
+
break;
|
|
391
|
+
case "next":
|
|
392
|
+
[, , zoom] = getStoreStateFlowNext((state) => state.transform);
|
|
393
|
+
break;
|
|
394
|
+
case "v12":
|
|
395
|
+
// we are calling a hook here conditionally. Not recommended, by the flowversion check is
|
|
396
|
+
// is basically compile time determined. So we just do it.
|
|
397
|
+
[, , zoom] = useStoreFlowV12((state) => state.transform);
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
372
400
|
} catch (error) {
|
|
373
401
|
// do not handle error but at least push it to the console
|
|
374
402
|
// eslint-disable-next-line no-console
|
|
@@ -376,18 +404,13 @@ export function NodeContent<CONTENT_PROPS = any>({
|
|
|
376
404
|
}
|
|
377
405
|
const [adjustedContentProps, setAdjustedContentProps] = React.useState<Partial<CONTENT_PROPS>>({});
|
|
378
406
|
const nodeContentRef = React.useRef<any>();
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
flowVersionCheck === "legacy" ? ([] as NodeContentHandleLegacyProps[]) : ([] as NodeContentHandleNextProps[]);
|
|
387
|
-
handleStack[Position.Bottom] =
|
|
388
|
-
flowVersionCheck === "legacy" ? ([] as NodeContentHandleLegacyProps[]) : ([] as NodeContentHandleNextProps[]);
|
|
389
|
-
handleStack[Position.Left] =
|
|
390
|
-
flowVersionCheck === "legacy" ? ([] as NodeContentHandleLegacyProps[]) : ([] as NodeContentHandleNextProps[]);
|
|
407
|
+
|
|
408
|
+
const handleStack: Record<string, HandleDefaultProps[]> = {
|
|
409
|
+
[Position.Top]: [],
|
|
410
|
+
[Position.Right]: [],
|
|
411
|
+
[Position.Bottom]: [],
|
|
412
|
+
[Position.Left]: [],
|
|
413
|
+
};
|
|
391
414
|
|
|
392
415
|
const saveOriginalSize = () => {
|
|
393
416
|
const currentClassNames = nodeContentRef.current.classList;
|
|
@@ -396,13 +419,16 @@ export function NodeContent<CONTENT_PROPS = any>({
|
|
|
396
419
|
}
|
|
397
420
|
originalSize.current.width = nodeContentRef.current.offsetWidth as number;
|
|
398
421
|
originalSize.current.height = nodeContentRef.current.offsetHeight as number;
|
|
399
|
-
}
|
|
422
|
+
};
|
|
400
423
|
|
|
401
424
|
React.useEffect(() => {
|
|
402
|
-
if
|
|
425
|
+
if (
|
|
426
|
+
nodeContentRef.current &&
|
|
427
|
+
(!(originalSize.current.width || originalSize.current.height) || !(width || height))
|
|
428
|
+
) {
|
|
403
429
|
saveOriginalSize();
|
|
404
430
|
}
|
|
405
|
-
}, [!!nodeContentRef.current, !(originalSize.current.width || originalSize.current.height), !(width || height)])
|
|
431
|
+
}, [!!nodeContentRef.current, !(originalSize.current.width || originalSize.current.height), !(width || height)]);
|
|
406
432
|
|
|
407
433
|
// Update width and height when node dimensions parameters has changed
|
|
408
434
|
React.useEffect(() => {
|
|
@@ -414,9 +440,11 @@ export function NodeContent<CONTENT_PROPS = any>({
|
|
|
414
440
|
|
|
415
441
|
const isResizingActive = React.useCallback((): boolean => {
|
|
416
442
|
const currentClassNames = nodeContentRef.current.classList;
|
|
417
|
-
return
|
|
418
|
-
resizeDirections.
|
|
419
|
-
|
|
443
|
+
return (
|
|
444
|
+
resizeDirections.right === currentClassNames.contains("is-resizable-horizontal") ||
|
|
445
|
+
resizeDirections.bottom === currentClassNames.contains("is-resizable-vertical")
|
|
446
|
+
);
|
|
447
|
+
}, []);
|
|
420
448
|
|
|
421
449
|
// force default size when resizing is activated but no dimensions are set
|
|
422
450
|
React.useEffect(() => {
|
|
@@ -424,13 +452,21 @@ export function NodeContent<CONTENT_PROPS = any>({
|
|
|
424
452
|
|
|
425
453
|
if (isResizable && !resizingActive) {
|
|
426
454
|
if (!width || !height) {
|
|
427
|
-
const newWidth = validateWidth(width ?? originalSize.current?.width as number);
|
|
428
|
-
const newHeight = validateHeight(height ?? originalSize.current?.height as number);
|
|
455
|
+
const newWidth = validateWidth(width ?? (originalSize.current?.width as number));
|
|
456
|
+
const newHeight = validateHeight(height ?? (originalSize.current?.height as number));
|
|
429
457
|
setWidth(newWidth);
|
|
430
458
|
setHeight(newHeight);
|
|
431
459
|
}
|
|
432
460
|
}
|
|
433
|
-
}, [
|
|
461
|
+
}, [
|
|
462
|
+
nodeContentRef.current,
|
|
463
|
+
onNodeResize,
|
|
464
|
+
minimalShape,
|
|
465
|
+
resizeDirections?.bottom,
|
|
466
|
+
resizeDirections?.right,
|
|
467
|
+
width,
|
|
468
|
+
height,
|
|
469
|
+
]); // need to be done everytime a property is changed and the element is re-rendered, otherwise the resizing class is lost
|
|
434
470
|
|
|
435
471
|
// conditional enhancements for activated resizing
|
|
436
472
|
React.useEffect(() => {
|
|
@@ -444,7 +480,7 @@ export function NodeContent<CONTENT_PROPS = any>({
|
|
|
444
480
|
if (currentClassNames.contains("is-resizable-vertical")) {
|
|
445
481
|
currentClassNames.remove("is-resizable-vertical");
|
|
446
482
|
}
|
|
447
|
-
|
|
483
|
+
|
|
448
484
|
if (resizeDirections.right) {
|
|
449
485
|
currentClassNames.add("is-resizable-horizontal");
|
|
450
486
|
}
|
|
@@ -487,15 +523,16 @@ export function NodeContent<CONTENT_PROPS = any>({
|
|
|
487
523
|
return 0;
|
|
488
524
|
})
|
|
489
525
|
.forEach((handle) => {
|
|
490
|
-
if (handle.
|
|
491
|
-
handleStack[handle.position].push(handle);
|
|
492
|
-
} else if (handle.category === "configuration") {
|
|
526
|
+
if ("category" in handle && handle.category === "configuration") {
|
|
493
527
|
handleStack[Position.Top].push(handle);
|
|
528
|
+
} else if (handle.position) {
|
|
529
|
+
handleStack[handle.position].push(handle);
|
|
494
530
|
} else {
|
|
495
|
-
|
|
531
|
+
const handleType = handle as { type?: string };
|
|
532
|
+
if (handleType.type === "target") {
|
|
496
533
|
handleStack[targetPosition].push(handle);
|
|
497
534
|
}
|
|
498
|
-
if (
|
|
535
|
+
if (handleType.type === "source") {
|
|
499
536
|
handleStack[sourcePosition].push(handle);
|
|
500
537
|
}
|
|
501
538
|
}
|
|
@@ -631,7 +668,7 @@ export function NodeContent<CONTENT_PROPS = any>({
|
|
|
631
668
|
)}
|
|
632
669
|
</div>
|
|
633
670
|
{(menuButtons || (showExecutionButtons && executionButtons)) && (
|
|
634
|
-
<div className={`${eccgui}-graphviz__node__header-menu`}>
|
|
671
|
+
<div className={`${eccgui}-graphviz__node__header-menu nodrag`}>
|
|
635
672
|
{showExecutionButtons && typeof executionButtons === "function"
|
|
636
673
|
? executionButtons(adjustedContentProps, setAdjustedContentProps)
|
|
637
674
|
: null}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { memo } from "react";
|
|
2
|
+
import { NodeProps as ReactFlowNodeProps, Position } from "react-flow-renderer";
|
|
3
|
+
|
|
4
|
+
import { Tooltip } from "../../../index";
|
|
5
|
+
|
|
6
|
+
import { NodeContent, NodeContentProps } from "./NodeContent";
|
|
7
|
+
|
|
8
|
+
export interface NodeDefaultProps<NODE_DATA, NODE_CONTENT_PROPS = any> extends ReactFlowNodeProps {
|
|
9
|
+
/**
|
|
10
|
+
* Contains all properties for our implementation of the React-Flow node.
|
|
11
|
+
* For details pls see the `NodeContent` element documentation.
|
|
12
|
+
*/
|
|
13
|
+
data: NodeContentProps<NODE_DATA, NODE_CONTENT_PROPS>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This element cannot be used directly, it must be connected via a `nodeTypes` definition.
|
|
18
|
+
* @see https://reactflow.dev/docs/api/nodes/
|
|
19
|
+
* @deprecated (v26) will be removed when `NodeDefault` supports v12 directly
|
|
20
|
+
*/
|
|
21
|
+
export const NodeDefaultV12 = memo((node: NodeDefaultProps<any>) => {
|
|
22
|
+
const {
|
|
23
|
+
data,
|
|
24
|
+
targetPosition = Position.Left,
|
|
25
|
+
sourcePosition = Position.Right,
|
|
26
|
+
isConnectable = true,
|
|
27
|
+
selected,
|
|
28
|
+
} = node;
|
|
29
|
+
|
|
30
|
+
const nodeEl = (
|
|
31
|
+
<NodeContent {...{ flowVersion: "v12", ...data, targetPosition, sourcePosition, isConnectable, selected }} />
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
if (!selected && data?.minimalShape !== "none" && !!data?.getMinimalTooltipData) {
|
|
35
|
+
const tooltipData = data?.getMinimalTooltipData(node);
|
|
36
|
+
if (!!tooltipData.label || !!tooltipData.content) {
|
|
37
|
+
return (
|
|
38
|
+
<Tooltip
|
|
39
|
+
content={
|
|
40
|
+
<>
|
|
41
|
+
{tooltipData.label && <div>{tooltipData.label}</div>}
|
|
42
|
+
{tooltipData.content && <div>{tooltipData.content}</div>}
|
|
43
|
+
</>
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
{nodeEl}
|
|
47
|
+
</Tooltip>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return nodeEl;
|
|
53
|
+
});
|