@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/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 };
@@ -0,0 +1,355 @@
1
+ .wf-shell {
2
+ padding: 0;
3
+ padding-right: var(--wf-shell-padding-right, 0px);
4
+ height: 100%;
5
+ min-height: 0;
6
+ display: flex;
7
+ flex-direction: column;
8
+ position: relative;
9
+ transition: padding-right 0.25s ease;
10
+ --wf-edge: #6c757d;
11
+ --wf-edge-adder: #0d6efd;
12
+ --wf-edge-loop: #f59f00;
13
+ --wf-edge-label: #495057;
14
+ --wf-handle-border: #3f3f3f;
15
+ --wf-handle-bg: #fff;
16
+ --wf-handle-source-bg: #5a5a5a;
17
+ --wf-drawer-width: 50vw;
18
+ --wf-drawer-offset: -4px;
19
+ }
20
+
21
+ .wf-toolbar {
22
+ display: flex;
23
+ justify-content: space-between;
24
+ align-items: center;
25
+ padding: 10px 12px;
26
+ border-bottom: 1px solid #e2e6ea;
27
+ background: transparent;
28
+ }
29
+
30
+ .wf-toolbar__actions button,
31
+ .wf-toolbar__actions a {
32
+ margin-left: 8px;
33
+ }
34
+
35
+ .wf-canvas {
36
+ height: 100%;
37
+ flex: 1;
38
+ min-height: 0;
39
+ background: #fafbfc;
40
+ }
41
+
42
+ /* Ensure nodes visually sit above edge labels/buttons */
43
+ .wf-shell .react-flow__node {
44
+ z-index: 5;
45
+ }
46
+
47
+ .wf-shell .react-flow__edge-labels {
48
+ z-index: 2;
49
+ }
50
+ .react-flow .react-flow__edges svg {
51
+ overflow: visible !important;
52
+ z-index: 1040;
53
+ }
54
+
55
+ .wf-empty {
56
+ padding: 12px;
57
+ color: #6c757d;
58
+ }
59
+
60
+ .wf-node {
61
+ background: var(--xy-node-background-color-default, #fff);
62
+ /* border: var(--xy-node-border-default); */
63
+ border: 1px solid #777777;
64
+ border-radius: 10px;
65
+ padding: 10px;
66
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
67
+ min-width: 200px;
68
+ cursor: pointer;
69
+ max-width: 240px;
70
+ }
71
+
72
+ .wf-modal .card-body {
73
+ flex: 1 1 auto;
74
+ min-height: 0;
75
+ overflow: auto;
76
+ }
77
+ .wf-node__header {
78
+ display: flex;
79
+ justify-content: space-between;
80
+ align-items: flex-start;
81
+ margin-bottom: 4px;
82
+ }
83
+
84
+ .wf-node__title-row {
85
+ display: flex;
86
+ gap: 8px;
87
+ align-items: baseline;
88
+ flex-wrap: wrap;
89
+ }
90
+
91
+ .wf-node__title {
92
+ font-weight: 700;
93
+ font-size: 14px;
94
+ }
95
+
96
+ .wf-node__action {
97
+ font-weight: 600;
98
+ color: #0d6efd;
99
+ font-size: 12px;
100
+ }
101
+
102
+ .wf-node__desc {
103
+ font-size: 12px;
104
+ color: #495057;
105
+ margin-bottom: 4px;
106
+ }
107
+
108
+ .wf-node__summary {
109
+ font-size: 12px;
110
+ color: var(--xy-node-color-default, #495057);
111
+ margin: 4px 0 6px;
112
+ padding-left: 16px;
113
+ }
114
+
115
+ .wf-node__summary li {
116
+ margin-bottom: 2px;
117
+ }
118
+
119
+ .wf-node__meta {
120
+ font-size: 12px;
121
+ color: #6c757d;
122
+ }
123
+
124
+ .wf-label {
125
+ font-weight: 600;
126
+ }
127
+
128
+ .wf-node__footer {
129
+ display: flex;
130
+ flex-wrap: wrap;
131
+ gap: 6px;
132
+ margin-top: 8px;
133
+ }
134
+
135
+ .wf-start-node {
136
+ padding: 10px;
137
+ border-radius: 10px;
138
+ background: linear-gradient(135deg, #0d6efd, #5ab2ff);
139
+ color: #fff;
140
+ box-shadow: 0 4px 12px rgba(13, 110, 253, 0.2);
141
+ min-width: 100px;
142
+ display: flex;
143
+ flex-direction: column;
144
+ align-items: center;
145
+ text-align: center;
146
+ }
147
+
148
+ .wf-start-title {
149
+ font-weight: 700;
150
+ }
151
+
152
+ .wf-start-actions button {
153
+ color: #0d6efd;
154
+ background: #fff;
155
+ border-color: #fff;
156
+ }
157
+
158
+ .wf-add-node {
159
+ width: 32px;
160
+ height: 32px;
161
+ border-radius: 50%;
162
+ background: var(--xy-node-background-color-default, #fff);
163
+ border: 1px dashed var(--xy-node-border-default, #adb5bd);
164
+ color: #0d6efd;
165
+ font-weight: 700;
166
+ display: flex;
167
+ align-items: center;
168
+ justify-content: center;
169
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
170
+ cursor: pointer;
171
+ }
172
+
173
+ .wf-add-node:focus {
174
+ outline: 2px solid #0d6efd;
175
+ outline-offset: 2px;
176
+ }
177
+
178
+ .wf-drawer {
179
+ position: fixed;
180
+ top: 0;
181
+ right: 0;
182
+ height: 100%;
183
+ width: min(95vw, max(var(--wf-drawer-width), 600px));
184
+ background: var(--bs-body-bg, #fff);
185
+ color: var(--bs-body-color, #212529);
186
+ border-left: 1px solid var(--bs-card-border-color, #e2e6ea);
187
+ display: flex;
188
+ flex-direction: column;
189
+ z-index: 1050;
190
+ box-shadow: -10px 0 30px rgba(0, 0, 0, 0.12);
191
+ transform: translateX(100%);
192
+ transition: transform 0.25s ease;
193
+ overflow: visible;
194
+ }
195
+
196
+ .wf-drawer--open {
197
+ transform: translateX(0);
198
+ }
199
+
200
+ .wf-drawer__resize {
201
+ position: absolute;
202
+ left: -6px;
203
+ top: 0;
204
+ width: 10px;
205
+ height: 100%;
206
+ cursor: ew-resize;
207
+ z-index: 1;
208
+ background: linear-gradient(
209
+ 90deg,
210
+ rgba(0, 0, 0, 0) 0%,
211
+ rgba(0, 0, 0, 0.08) 50%,
212
+ rgba(0, 0, 0, 0) 100%
213
+ );
214
+ }
215
+
216
+ .wf-drawer__header {
217
+ padding: 16px 18px 12px;
218
+ border-bottom: 1px solid var(--bs-card-border-color, #e2e6ea);
219
+ }
220
+
221
+ .wf-drawer__body {
222
+ padding: 16px 18px;
223
+ flex: 1 1 auto;
224
+ min-height: 0;
225
+ overflow-y: auto;
226
+ }
227
+
228
+ .wf-drawer__footer {
229
+ padding: 12px 18px;
230
+ border-top: 1px solid var(--bs-card-border-color, #e2e6ea);
231
+ }
232
+
233
+ .wf-modal-backdrop {
234
+ position: fixed;
235
+ top: 0;
236
+ left: 0;
237
+ right: 0;
238
+ bottom: 0;
239
+ background: rgba(0, 0, 0, 0.45);
240
+ display: flex;
241
+ align-items: center;
242
+ justify-content: center;
243
+ z-index: 1050;
244
+ }
245
+
246
+ .wf-modal {
247
+ /* background: var(--bs-body-bg, #fff); */
248
+ /* color: var(--bs-body-color, #212529); */
249
+ border-radius: 10px;
250
+ /* border: 1px solid var(--bs-card-border-color, #e2e6ea); */
251
+ width: min(900px, 90vw);
252
+ max-height: 90vh;
253
+ display: flex;
254
+ flex-direction: column;
255
+ overflow: hidden;
256
+ /* box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); */
257
+ }
258
+
259
+ @media (max-width: 768px) {
260
+ .wf-shell--drawer-open {
261
+ padding-right: var(--wf-shell-padding-right, 0px);
262
+ }
263
+
264
+ .wf-drawer {
265
+ width: min(480px, 100vw);
266
+ }
267
+ }
268
+
269
+ .wf-shell .react-flow__edge-path {
270
+ stroke: var(--wf-edge);
271
+ fill: none;
272
+ stroke-width: 1.5px;
273
+ }
274
+
275
+ .wf-shell .wf-edge-selected .react-flow__edge-path {
276
+ stroke: var(--wf-edge-selected, #0d6efd) !important;
277
+ stroke-width: 2.4px;
278
+ filter: drop-shadow(0 0 4px rgba(13, 110, 253, 0.35));
279
+ }
280
+
281
+ .wf-shell .react-flow__connection-path {
282
+ stroke-width: 1.5px;
283
+ }
284
+
285
+ .wf-shell .react-flow__edge-text {
286
+ fill: var(--wf-edge-label);
287
+ }
288
+
289
+ .wf-shell .react-flow__handle {
290
+ background: var(--wf-handle-bg);
291
+ border-color: var(--wf-handle-border);
292
+ }
293
+
294
+ .wf-shell .react-flow__handle.wf-handle-source {
295
+ background: var(--wf-handle-source-bg) !important;
296
+ border-color: var(--wf-handle-source-bg) !important;
297
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
298
+ }
299
+ .wf-shell .react-flow__handle.wf-handle-source-loop {
300
+ background: var(--wf-edge-loop) !important;
301
+ border-color: var(--wf-edge-loop) !important;
302
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
303
+ }
304
+ .wf-shell .react-flow__handle.wf-handle-target-loop {
305
+ border-color: var(--wf-edge-loop) !important;
306
+ }
307
+
308
+ .wf-edge-add-button {
309
+ width: 18px;
310
+ height: 18px;
311
+ border-radius: 50%;
312
+ border: 1px solid #adb5bd;
313
+ background: #ffffff;
314
+ color: #6c757d;
315
+ font-size: 12px;
316
+ line-height: 1;
317
+ display: flex;
318
+ align-items: center;
319
+ justify-content: center;
320
+ cursor: pointer;
321
+ padding: 0;
322
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
323
+ }
324
+
325
+ .wf-edge-add-button:hover {
326
+ background: #f1f3f5;
327
+ color: #495057;
328
+ }
329
+
330
+ .wf-edge-add-button:focus {
331
+ outline: 2px solid #adb5bd;
332
+ outline-offset: 2px;
333
+ }
334
+
335
+ [data-bs-theme="dark"] .wf-shell {
336
+ --wf-edge: #aeb3bd;
337
+ --wf-edge-adder: #6ea8fe;
338
+ --wf-edge-loop: #f0ad4e;
339
+ --wf-edge-label: #c0c4cf;
340
+ --wf-handle-border: #c0c4cf;
341
+ --wf-handle-bg: #2f3139;
342
+ --wf-handle-source-bg: #8a8a8a;
343
+ }
344
+
345
+ /* Temporary vars fallbacks */
346
+ .wf-drawer {
347
+ --bs-body-bg: #fff;
348
+ --bs-body-color: #212529;
349
+ --bs-card-border-color: #e2e6ea;
350
+ }
351
+ [data-bs-theme="dark"] .wf-drawer {
352
+ --bs-body-bg: #303030;
353
+ --bs-body-color: #fff;
354
+ --bs-card-border-color: #44484e;
355
+ }
@@ -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
+ };