@saltcorn/workflow-editor 1.6.0-alpha.4

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/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@saltcorn/workflow-editor",
3
+ "version": "1.6.0-alpha.4",
4
+ "description": "React Flow-based workflow editor for Saltcorn",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "build": "webpack --mode production",
8
+ "builddev": "webpack --mode none",
9
+ "watch": "webpack --mode none --watch",
10
+ "test": "echo \"NO TESTS\""
11
+ },
12
+ "repository": "github:saltcorn/saltcorn",
13
+ "author": "Saltcorn",
14
+ "license": "MIT",
15
+ "devDependencies": {
16
+ "@babel/core": "7.25.2",
17
+ "@babel/preset-env": "7.25.2",
18
+ "@babel/preset-react": "7.24.7",
19
+ "babel-loader": "8.1.0",
20
+ "classnames": "2.2.6",
21
+ "css-loader": "6.11.0",
22
+ "process": "0.11.10",
23
+ "react": "18.3.1",
24
+ "react-dom": "18.3.1",
25
+ "@xyflow/react": "^12.10.0",
26
+ "style-loader": "3.3.4",
27
+ "webpack": "5.97.1",
28
+ "webpack-cli": "6.0.1"
29
+ },
30
+ "overrides": {
31
+ "immer": "9.0.6",
32
+ "glob-parent": "^5.1.2",
33
+ "undici": "7.12.0",
34
+ "parse5": "7.2.1",
35
+ "parse5-htmlparser2-tree-adapter": "7.0.0"
36
+ }
37
+ }
@@ -0,0 +1,70 @@
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
+ zIndex: 10,
52
+ }}
53
+ className="nodrag nopan"
54
+ >
55
+ <button
56
+ type="button"
57
+ className="wf-edge-add-button"
58
+ onClick={handleAddBetween}
59
+ aria-label={data.startLabel || "Add step"}
60
+ >
61
+ +
62
+ </button>
63
+ </div>
64
+ </EdgeLabelRenderer>
65
+ ) : null}
66
+ </>
67
+ );
68
+ };
69
+
70
+ export default WorkflowEdge;