@saltcorn/workflow-editor 1.6.0-alpha.10
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/.babelrc +3 -0
- package/dist/workflow_bundle.js +53599 -0
- package/dist/workflow_bundle.js.LICENSE.txt +61 -0
- package/dist/workflow_bundle.js.map +1 -0
- package/package.json +38 -0
- package/src/WorkflowEdge.jsx +69 -0
- package/src/WorkflowEditor.jsx +1787 -0
- package/src/index.js +31 -0
- package/src/workflow.css +355 -0
- package/webpack.config.js +39 -0
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@saltcorn/workflow-editor",
|
|
3
|
+
"version": "1.6.0-alpha.10",
|
|
4
|
+
"description": "React Flow-based workflow editor for Saltcorn",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"homepage": "https://saltcorn.com",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "webpack --mode production",
|
|
9
|
+
"builddev": "webpack --mode none",
|
|
10
|
+
"watch": "webpack --mode none --watch",
|
|
11
|
+
"test": "echo \"NO TESTS\""
|
|
12
|
+
},
|
|
13
|
+
"repository": "github:saltcorn/saltcorn",
|
|
14
|
+
"author": "RUTAYISIRE MANZI Gerard Valentin",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@babel/core": "7.25.2",
|
|
18
|
+
"@babel/preset-env": "7.25.2",
|
|
19
|
+
"@babel/preset-react": "7.24.7",
|
|
20
|
+
"babel-loader": "8.1.0",
|
|
21
|
+
"classnames": "2.2.6",
|
|
22
|
+
"css-loader": "6.11.0",
|
|
23
|
+
"process": "0.11.10",
|
|
24
|
+
"react": "18.3.1",
|
|
25
|
+
"react-dom": "18.3.1",
|
|
26
|
+
"@xyflow/react": "^12.10.0",
|
|
27
|
+
"style-loader": "3.3.4",
|
|
28
|
+
"webpack": "5.97.1",
|
|
29
|
+
"webpack-cli": "6.0.1"
|
|
30
|
+
},
|
|
31
|
+
"overrides": {
|
|
32
|
+
"immer": "9.0.6",
|
|
33
|
+
"glob-parent": "^5.1.2",
|
|
34
|
+
"undici": "7.12.0",
|
|
35
|
+
"parse5": "7.2.1",
|
|
36
|
+
"parse5-htmlparser2-tree-adapter": "7.0.0"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
BaseEdge,
|
|
4
|
+
EdgeLabelRenderer,
|
|
5
|
+
getSmoothStepPath,
|
|
6
|
+
} from "@xyflow/react";
|
|
7
|
+
|
|
8
|
+
const WorkflowEdge = (props) => {
|
|
9
|
+
const {
|
|
10
|
+
id,
|
|
11
|
+
sourceX,
|
|
12
|
+
sourceY,
|
|
13
|
+
targetX,
|
|
14
|
+
targetY,
|
|
15
|
+
sourcePosition,
|
|
16
|
+
targetPosition,
|
|
17
|
+
source,
|
|
18
|
+
target,
|
|
19
|
+
style,
|
|
20
|
+
markerEnd,
|
|
21
|
+
data = {},
|
|
22
|
+
} = props;
|
|
23
|
+
|
|
24
|
+
const handleAddBetween = (event) => {
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
if (!data || typeof data.onAddBetween !== "function") return;
|
|
27
|
+
data.onAddBetween({ source, target });
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const canInsertBetween = !!data.canInsertBetween;
|
|
31
|
+
|
|
32
|
+
const [edgePath, labelX, labelY] = getSmoothStepPath({
|
|
33
|
+
sourceX,
|
|
34
|
+
sourceY,
|
|
35
|
+
sourcePosition,
|
|
36
|
+
targetX,
|
|
37
|
+
targetY,
|
|
38
|
+
targetPosition,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<BaseEdge id={id} path={edgePath} style={style} markerEnd={markerEnd} />
|
|
44
|
+
{canInsertBetween ? (
|
|
45
|
+
<EdgeLabelRenderer>
|
|
46
|
+
<div
|
|
47
|
+
style={{
|
|
48
|
+
position: "absolute",
|
|
49
|
+
transform: `translate(-50%, -50%) translate(${labelX}px, ${labelY}px)`,
|
|
50
|
+
pointerEvents: "all",
|
|
51
|
+
}}
|
|
52
|
+
className="nodrag nopan"
|
|
53
|
+
>
|
|
54
|
+
<button
|
|
55
|
+
type="button"
|
|
56
|
+
className="wf-edge-add-button"
|
|
57
|
+
onClick={handleAddBetween}
|
|
58
|
+
aria-label={data.startLabel || "Add step"}
|
|
59
|
+
>
|
|
60
|
+
+
|
|
61
|
+
</button>
|
|
62
|
+
</div>
|
|
63
|
+
</EdgeLabelRenderer>
|
|
64
|
+
) : null}
|
|
65
|
+
</>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default WorkflowEdge;
|