@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/.babelrc +3 -0
- package/dist/workflow_bundle.js +3 -0
- package/dist/workflow_bundle.js.LICENSE.txt +61 -0
- package/dist/workflow_bundle.js.map +1 -0
- package/package.json +37 -0
- package/src/WorkflowEdge.jsx +70 -0
- package/src/WorkflowEditor.jsx +1368 -0
- package/src/index.js +31 -0
- package/src/workflow.css +233 -0
- package/webpack.config.js +39 -0
package/src/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* global document */
|
|
2
|
+
const React = require("react");
|
|
3
|
+
const ReactDOM = require("react-dom");
|
|
4
|
+
const WorkflowEditor =
|
|
5
|
+
require("./WorkflowEditor").default || require("./WorkflowEditor");
|
|
6
|
+
let createRoot;
|
|
7
|
+
try {
|
|
8
|
+
({ createRoot } = require("react-dom/client"));
|
|
9
|
+
} catch (e) {
|
|
10
|
+
createRoot = null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function renderWorkflowEditor(id, encoded) {
|
|
14
|
+
const mount = document.getElementById(id);
|
|
15
|
+
if (!mount) return;
|
|
16
|
+
let data;
|
|
17
|
+
try {
|
|
18
|
+
data = JSON.parse(decodeURIComponent(encoded));
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error("Unable to parse workflow data", e);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (createRoot) {
|
|
24
|
+
const root = createRoot(mount);
|
|
25
|
+
root.render(React.createElement(WorkflowEditor, { data }));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
ReactDOM.render(React.createElement(WorkflowEditor, { data }), mount);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = { renderWorkflowEditor };
|
package/src/workflow.css
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
.wf-shell {
|
|
2
|
+
padding: 0;
|
|
3
|
+
height: 100%;
|
|
4
|
+
min-height: 0;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
--wf-edge: #6c757d;
|
|
8
|
+
--wf-edge-adder: #0d6efd;
|
|
9
|
+
--wf-edge-loop: #f59f00;
|
|
10
|
+
--wf-edge-label: #495057;
|
|
11
|
+
--wf-handle-border: #3f3f3f;
|
|
12
|
+
--wf-handle-bg: #fff;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.wf-toolbar {
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
align-items: center;
|
|
19
|
+
padding: 10px 12px;
|
|
20
|
+
border-bottom: 1px solid #e2e6ea;
|
|
21
|
+
background: transparent;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.wf-toolbar__actions button,
|
|
25
|
+
.wf-toolbar__actions a {
|
|
26
|
+
margin-left: 8px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.wf-canvas {
|
|
30
|
+
height: 100%;
|
|
31
|
+
flex: 1;
|
|
32
|
+
min-height: 0;
|
|
33
|
+
background: #fafbfc;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.wf-empty {
|
|
37
|
+
padding: 12px;
|
|
38
|
+
color: #6c757d;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.wf-node {
|
|
42
|
+
background: var(--xy-node-background-color-default, #fff);
|
|
43
|
+
/* border: var(--xy-node-border-default); */
|
|
44
|
+
border: 1px solid #777777;
|
|
45
|
+
border-radius: 10px;
|
|
46
|
+
padding: 10px;
|
|
47
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
|
|
48
|
+
min-width: 200px;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
max-width: 240px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.wf-modal .card-body {
|
|
54
|
+
flex: 1 1 auto;
|
|
55
|
+
min-height: 0;
|
|
56
|
+
overflow: auto;
|
|
57
|
+
}
|
|
58
|
+
.wf-node__header {
|
|
59
|
+
display: flex;
|
|
60
|
+
justify-content: space-between;
|
|
61
|
+
align-items: flex-start;
|
|
62
|
+
margin-bottom: 4px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.wf-node__title-row {
|
|
66
|
+
display: flex;
|
|
67
|
+
gap: 8px;
|
|
68
|
+
align-items: baseline;
|
|
69
|
+
flex-wrap: wrap;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.wf-node__title {
|
|
73
|
+
font-weight: 700;
|
|
74
|
+
font-size: 14px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.wf-node__action {
|
|
78
|
+
font-weight: 600;
|
|
79
|
+
color: #0d6efd;
|
|
80
|
+
font-size: 12px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.wf-node__desc {
|
|
84
|
+
font-size: 12px;
|
|
85
|
+
color: #495057;
|
|
86
|
+
margin-bottom: 4px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.wf-node__summary {
|
|
90
|
+
font-size: 12px;
|
|
91
|
+
color: var(--xy-node-color-default, #495057);
|
|
92
|
+
margin: 4px 0 6px;
|
|
93
|
+
padding-left: 16px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.wf-node__summary li {
|
|
97
|
+
margin-bottom: 2px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.wf-node__meta {
|
|
101
|
+
font-size: 12px;
|
|
102
|
+
color: #6c757d;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.wf-label {
|
|
106
|
+
font-weight: 600;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.wf-node__footer {
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-wrap: wrap;
|
|
112
|
+
gap: 6px;
|
|
113
|
+
margin-top: 8px;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.wf-start-node {
|
|
117
|
+
padding: 10px;
|
|
118
|
+
border-radius: 10px;
|
|
119
|
+
background: linear-gradient(135deg, #0d6efd, #5ab2ff);
|
|
120
|
+
color: #fff;
|
|
121
|
+
box-shadow: 0 4px 12px rgba(13, 110, 253, 0.2);
|
|
122
|
+
min-width: 100px;
|
|
123
|
+
display: flex;
|
|
124
|
+
flex-direction: column;
|
|
125
|
+
align-items: center;
|
|
126
|
+
text-align: center;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.wf-start-title {
|
|
130
|
+
font-weight: 700;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.wf-start-actions button {
|
|
134
|
+
color: #0d6efd;
|
|
135
|
+
background: #fff;
|
|
136
|
+
border-color: #fff;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.wf-add-node {
|
|
140
|
+
width: 32px;
|
|
141
|
+
height: 32px;
|
|
142
|
+
border-radius: 50%;
|
|
143
|
+
background: var(--xy-node-background-color-default, #fff);
|
|
144
|
+
border: 1px dashed var(--xy-node-border-default, #adb5bd);
|
|
145
|
+
color: #0d6efd;
|
|
146
|
+
font-weight: 700;
|
|
147
|
+
display: flex;
|
|
148
|
+
align-items: center;
|
|
149
|
+
justify-content: center;
|
|
150
|
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
|
151
|
+
cursor: pointer;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.wf-add-node:focus {
|
|
155
|
+
outline: 2px solid #0d6efd;
|
|
156
|
+
outline-offset: 2px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.wf-modal-backdrop {
|
|
160
|
+
position: fixed;
|
|
161
|
+
top: 0;
|
|
162
|
+
left: 0;
|
|
163
|
+
right: 0;
|
|
164
|
+
bottom: 0;
|
|
165
|
+
background: rgba(0, 0, 0, 0.45);
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
justify-content: center;
|
|
169
|
+
z-index: 1050;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.wf-modal {
|
|
173
|
+
/* background: var(--bs-card-bg, #fff); */
|
|
174
|
+
/* color: var(--bs-body-color, #212529); */
|
|
175
|
+
border-radius: 10px;
|
|
176
|
+
/* border: 1px solid var(--bs-card-border-color, #e2e6ea); */
|
|
177
|
+
width: min(900px, 90vw);
|
|
178
|
+
max-height: 90vh;
|
|
179
|
+
display: flex;
|
|
180
|
+
flex-direction: column;
|
|
181
|
+
overflow: hidden;
|
|
182
|
+
/* box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); */
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.wf-shell .react-flow__edge-path {
|
|
186
|
+
stroke: var(--wf-edge);
|
|
187
|
+
fill: none;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.wf-shell .react-flow__edge-text {
|
|
191
|
+
fill: var(--wf-edge-label);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.wf-shell .react-flow__handle {
|
|
195
|
+
background: var(--wf-handle-bg);
|
|
196
|
+
border-color: var(--wf-handle-border);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.wf-edge-add-button {
|
|
200
|
+
width: 18px;
|
|
201
|
+
height: 18px;
|
|
202
|
+
border-radius: 50%;
|
|
203
|
+
border: 1px solid #adb5bd;
|
|
204
|
+
background: #ffffff;
|
|
205
|
+
color: #6c757d;
|
|
206
|
+
font-size: 12px;
|
|
207
|
+
line-height: 1;
|
|
208
|
+
display: flex;
|
|
209
|
+
align-items: center;
|
|
210
|
+
justify-content: center;
|
|
211
|
+
cursor: pointer;
|
|
212
|
+
padding: 0;
|
|
213
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.wf-edge-add-button:hover {
|
|
217
|
+
background: #f1f3f5;
|
|
218
|
+
color: #495057;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.wf-edge-add-button:focus {
|
|
222
|
+
outline: 2px solid #adb5bd;
|
|
223
|
+
outline-offset: 2px;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
[data-bs-theme="dark"] .wf-shell {
|
|
227
|
+
--wf-edge: #aeb3bd;
|
|
228
|
+
--wf-edge-adder: #6ea8fe;
|
|
229
|
+
--wf-edge-loop: #f0ad4e;
|
|
230
|
+
--wf-edge-label: #c0c4cf;
|
|
231
|
+
--wf-handle-border: #c0c4cf;
|
|
232
|
+
--wf-handle-bg: #2f3139;
|
|
233
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const webpack = require("webpack");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
entry: "./src/index.js",
|
|
6
|
+
module: {
|
|
7
|
+
rules: [
|
|
8
|
+
{
|
|
9
|
+
test: /\.(js|jsx)$/,
|
|
10
|
+
exclude: /node_modules/,
|
|
11
|
+
use: {
|
|
12
|
+
loader: "babel-loader",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
test: /\.css$/i,
|
|
17
|
+
use: ["style-loader", "css-loader"],
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
output: {
|
|
22
|
+
filename: "workflow_bundle.js",
|
|
23
|
+
library: "workflow",
|
|
24
|
+
},
|
|
25
|
+
resolve: {
|
|
26
|
+
extensions: [".js", ".jsx"],
|
|
27
|
+
alias: { // Fix: Ensure only one copy of React is used
|
|
28
|
+
react: path.resolve(__dirname, "node_modules/react"),
|
|
29
|
+
"react-dom": path.resolve(__dirname, "node_modules/react-dom"),
|
|
30
|
+
},
|
|
31
|
+
fallback: { "process/browser": require.resolve("process/browser") },
|
|
32
|
+
},
|
|
33
|
+
plugins: [
|
|
34
|
+
new webpack.ProvidePlugin({
|
|
35
|
+
process: "process/browser",
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
devtool: "source-map",
|
|
39
|
+
};
|