Skip to content

Commit b7db804

Browse files
authored
0.13.1. (#44)
1 parent 121b356 commit b7db804

File tree

13 files changed

+134
-66
lines changed

13 files changed

+134
-66
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.13.1
2+
3+
The `canMoveStep` callback is not called when the step is moved to the same position.
4+
5+
🤩 We launched a new project: [Sequential Workflow Editor](https://github.com/nocode-js/sequential-workflow-editor). Don't write step editors manually, build them.
6+
17
## 0.13.0
28

39
The `StepTraverser` is not a part of the designer package anymore. This class is moved into the model package and it's called `DefinitionWalker` now. The responsibility of determining children of a step is not part of the `StepExtension` interface anymore.

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ Pro:
4949

5050
## 👩‍💻 Integrations
5151

52-
* [🚚 Sequential Workflow Machine](https://github.com/nocode-js/sequential-workflow-machine) - JavaScript workflow engine, powered by the xstate library.
52+
* [⛽ Sequential Workflow Editor](https://github.com/nocode-js/sequential-workflow-editor) - Powerful step editor builder. Don't write step editors manually, build them.
53+
* [🚚 Sequential Workflow Machine](https://github.com/nocode-js/sequential-workflow-machine) - Workflow engine for browser and NodeJS apps, powered by the xstate library.
5354

5455
## 🚀 Installation
5556

@@ -89,10 +90,10 @@ Add the below code to your head section in HTML document.
8990
```html
9091
<head>
9192
...
92-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.13.0/css/designer.css" rel="stylesheet">
93-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.13.0/css/designer-light.css" rel="stylesheet">
94-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.13.0/css/designer-dark.css" rel="stylesheet">
95-
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.13.0/dist/index.umd.js"></script>
93+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.13.1/css/designer.css" rel="stylesheet">
94+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.13.1/css/designer-light.css" rel="stylesheet">
95+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.13.1/css/designer-dark.css" rel="stylesheet">
96+
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.13.1/dist/index.umd.js"></script>
9697
```
9798

9899
Call the designer by:

angular/designer/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sequential-workflow-designer-angular",
33
"description": "Angular wrapper for Sequential Workflow Designer component.",
4-
"version": "0.13.0",
4+
"version": "0.13.1",
55
"author": {
66
"name": "NoCode JS",
77
"url": "https://nocode-js.com/"
@@ -15,7 +15,7 @@
1515
"peerDependencies": {
1616
"@angular/common": "12 - 16",
1717
"@angular/core": "12 - 16",
18-
"sequential-workflow-designer": "^0.13.0"
18+
"sequential-workflow-designer": "^0.13.1"
1919
},
2020
"dependencies": {
2121
"tslib": "^2.3.0"
@@ -31,4 +31,4 @@
3131
"angular",
3232
"angularjs"
3333
]
34-
}
34+
}

demos/angular-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"@angular/platform-browser-dynamic": "^15.2.2",
2525
"@angular/router": "^15.2.2",
2626
"rxjs": "~7.8.0",
27-
"sequential-workflow-designer": "^0.13.0",
28-
"sequential-workflow-designer-angular": "^0.13.0",
27+
"sequential-workflow-designer": "^0.13.1",
28+
"sequential-workflow-designer-angular": "^0.13.1",
2929
"tslib": "^2.3.0",
3030
"zone.js": "~0.13.0"
3131
},

demos/angular-app/yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5180,17 +5180,17 @@ send@0.18.0:
51805180
range-parser "~1.2.1"
51815181
statuses "2.0.1"
51825182

5183-
sequential-workflow-designer-angular@^0.13.0:
5184-
version "0.13.0"
5185-
resolved "https://registry.yarnpkg.com/sequential-workflow-designer-angular/-/sequential-workflow-designer-angular-0.13.0.tgz#a81b0307dfb4363bf8225fffca1afe566f4163a7"
5186-
integrity sha512-ujkOBZ3juh7EL9uhYYxqGSh7MNNRwBmrToExTA2spbKfASCzmvmdLoae8grI4Xx25xlAxYok836CY4V4cWMw4g==
5183+
sequential-workflow-designer-angular@^0.13.1:
5184+
version "0.13.1"
5185+
resolved "https://registry.yarnpkg.com/sequential-workflow-designer-angular/-/sequential-workflow-designer-angular-0.13.1.tgz#a8acbd9bd442a1260f7fe7840e3b97c576309bb6"
5186+
integrity sha512-p29YekTS5DIrl6ZmZpiLtvrhF5pqs3pilxzAXg++38RgjStU7wuCHbrQMO0wkGWVcuUHweMZV8Yw23PSHJhxUw==
51875187
dependencies:
51885188
tslib "^2.3.0"
51895189

5190-
sequential-workflow-designer@^0.13.0:
5191-
version "0.13.0"
5192-
resolved "https://registry.yarnpkg.com/sequential-workflow-designer/-/sequential-workflow-designer-0.13.0.tgz#2d8692fb8f309496891e52b1a4533647ca24df94"
5193-
integrity sha512-uOGAlFAVMRmOH/fBTEoXMTiPeCPm4TXKukp+LzJixIPtVIg25v9ioDYVQH1w+xiIqSVzsILQbK+WGYtbRYqeOQ==
5190+
sequential-workflow-designer@^0.13.1:
5191+
version "0.13.1"
5192+
resolved "https://registry.yarnpkg.com/sequential-workflow-designer/-/sequential-workflow-designer-0.13.1.tgz#332c5324895dd63c350a14a7de418d2f4b9a70ff"
5193+
integrity sha512-Jw/eFRC3GB4FVH6DbpRGqmQT1usQVP+s00uGcS5b+AozmhewTk/Hf1EJS9NTlknYchGbiQ3Dw6rUZqBav5/iaA==
51945194
dependencies:
51955195
sequential-workflow-model "^0.1.3"
51965196

demos/react-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"dependencies": {
66
"react": "^18.2.0",
77
"react-dom": "^18.2.0",
8-
"sequential-workflow-designer": "^0.13.0",
9-
"sequential-workflow-designer-react": "^0.13.0"
8+
"sequential-workflow-designer": "^0.13.1",
9+
"sequential-workflow-designer-react": "^0.13.1"
1010
},
1111
"devDependencies": {
1212
"@types/jest": "^29.2.5",

designer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sequential-workflow-designer",
33
"description": "Customizable no-code component for building flow-based programming applications.",
4-
"version": "0.13.0",
4+
"version": "0.13.1",
55
"type": "module",
66
"main": "./lib/esm/index.js",
77
"types": "./lib/index.d.ts",

designer/src/core/sequence-modifier.spec.ts

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,69 @@ describe('SequenceModifier', () => {
3131
properties: {}
3232
};
3333

34-
function flatABC(): Sequence {
35-
return [A, B, C];
36-
}
34+
let seq: Sequence;
3735

38-
it('moveStep() does nothing when the change is for the same index', () => {
39-
const seq = flatABC();
40-
SequenceModifier.moveStep(seq, A, seq, 0);
41-
42-
expect(seq[0]).toEqual(A);
43-
expect(seq[1]).toEqual(B);
44-
expect(seq[2]).toEqual(C);
36+
beforeEach(() => {
37+
seq = [A, B, C];
4538
});
4639

47-
it('moveStep() moves the first node to the last position', () => {
48-
const seq = flatABC();
49-
SequenceModifier.moveStep(seq, A, seq, 3);
40+
describe('tryMoveStep()', () => {
41+
it('returns null when the change is for the same index', () => {
42+
const apply = SequenceModifier.tryMoveStep(seq, A, seq, 0) as () => void;
5043

51-
expect(seq[0]).toEqual(B);
52-
expect(seq[1]).toEqual(C);
53-
expect(seq[2]).toEqual(A);
54-
});
44+
expect(apply).toBeNull();
45+
expect(seq[0]).toEqual(A);
46+
expect(seq[1]).toEqual(B);
47+
expect(seq[2]).toEqual(C);
48+
});
5549

56-
it('moveStep() moves the first node to one before the last position', () => {
57-
const seq = flatABC();
58-
SequenceModifier.moveStep(seq, A, seq, 2);
50+
it('returns null when the change for the same index + 1', () => {
51+
const apply = SequenceModifier.tryMoveStep(seq, A, seq, 1) as () => void;
5952

60-
expect(seq[0]).toEqual(B);
61-
expect(seq[1]).toEqual(A);
62-
expect(seq[2]).toEqual(C);
53+
expect(apply).toBeNull();
54+
expect(seq[0]).toEqual(A);
55+
expect(seq[1]).toEqual(B);
56+
expect(seq[2]).toEqual(C);
57+
});
58+
59+
it('moves A node to 2nd position', () => {
60+
const apply = SequenceModifier.tryMoveStep(seq, A, seq, 2) as () => void;
61+
apply();
62+
63+
expect(seq[0]).toEqual(B);
64+
expect(seq[1]).toEqual(A);
65+
expect(seq[2]).toEqual(C);
66+
});
67+
68+
it('moves A node to 3rd position', () => {
69+
const apply = SequenceModifier.tryMoveStep(seq, A, seq, 3) as () => void;
70+
apply();
71+
72+
expect(seq[0]).toEqual(B);
73+
expect(seq[1]).toEqual(C);
74+
expect(seq[2]).toEqual(A);
75+
});
76+
77+
it('moves B node to first position', () => {
78+
const apply = SequenceModifier.tryMoveStep(seq, B, seq, 0) as () => void;
79+
apply();
80+
81+
expect(seq[0]).toEqual(B);
82+
expect(seq[1]).toEqual(A);
83+
expect(seq[2]).toEqual(C);
84+
});
85+
86+
it('moves B node to 3rd position', () => {
87+
const apply = SequenceModifier.tryMoveStep(seq, B, seq, 3) as () => void;
88+
apply();
89+
90+
expect(seq[0]).toEqual(A);
91+
expect(seq[1]).toEqual(C);
92+
expect(seq[2]).toEqual(B);
93+
});
6394
});
6495

6596
it('insertStep() adds at the beginning', () => {
66-
const seq = flatABC();
6797
SequenceModifier.insertStep(D, seq, 0);
6898

6999
expect(seq[0]).toEqual(D);
@@ -73,7 +103,6 @@ describe('SequenceModifier', () => {
73103
});
74104

75105
it('deleteStep() deletes a step', () => {
76-
const seq = flatABC();
77106
SequenceModifier.deleteStep(B, seq);
78107

79108
expect(seq.length).toEqual(2);

designer/src/core/sequence-modifier.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import { Sequence, Step } from '../definition';
22

33
export class SequenceModifier {
4-
public static moveStep(sourceSequence: Sequence, step: Step, targetSequence: Sequence, targetIndex: number) {
4+
public static tryMoveStep(sourceSequence: Sequence, step: Step, targetSequence: Sequence, targetIndex: number): (() => void) | null {
55
const sourceIndex = sourceSequence.indexOf(step);
66
if (sourceIndex < 0) {
7-
throw new Error('Unknown step');
7+
throw new Error('Step not found in source sequence');
88
}
99

1010
const isSameSequence = sourceSequence === targetSequence;
11-
if (isSameSequence && sourceIndex === targetIndex) {
12-
return; // Nothing to do.
11+
if (isSameSequence) {
12+
if (sourceIndex < targetIndex) {
13+
targetIndex--;
14+
}
15+
if (sourceIndex === targetIndex) {
16+
return null; // No changes
17+
}
1318
}
1419

15-
sourceSequence.splice(sourceIndex, 1);
16-
if (isSameSequence && sourceIndex < targetIndex) {
17-
targetIndex--;
18-
}
19-
targetSequence.splice(targetIndex, 0, step);
20+
return function apply() {
21+
sourceSequence.splice(sourceIndex, 1);
22+
targetSequence.splice(targetIndex, 0, step);
23+
};
2024
}
2125

2226
public static insertStep(step: Step, targetSequence: Sequence, targetIndex: number) {

designer/src/definition-modifier.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,19 @@ export class DefinitionModifier {
5454
}
5555

5656
public tryMove(sourceSequence: Sequence, step: Step, targetSequence: Sequence, targetIndex: number): boolean {
57+
const apply = SequenceModifier.tryMoveStep(sourceSequence, step, targetSequence, targetIndex);
58+
if (!apply) {
59+
return false;
60+
}
61+
5762
const canMoveStep = this.configuration.steps.canMoveStep
5863
? this.configuration.steps.canMoveStep(sourceSequence, step, targetSequence, targetIndex)
5964
: true;
6065
if (!canMoveStep) {
6166
return false;
6267
}
6368

64-
SequenceModifier.moveStep(sourceSequence, step, targetSequence, targetIndex);
69+
apply();
6570
this.state.notifyDefinitionChanged(DefinitionChangeType.stepMoved, step.id);
6671
this.state.setSelectedStepId(step.id);
6772
return true;

examples/assets/editing-restrictions.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,28 @@ function createStep(name, properties) {
1313
};
1414
}
1515

16+
function createLoopStep() {
17+
return {
18+
id: sequentialWorkflowDesigner.Uid.next(),
19+
componentType: 'container',
20+
type: 'loop',
21+
name: 'Loop',
22+
properties: {
23+
draggable: true,
24+
deletable: true
25+
},
26+
sequence: []
27+
}
28+
}
29+
1630
function createEditor(text) {
1731
const editor = document.createElement('div');
1832
editor.innerText = text;
1933
return editor;
2034
}
2135

2236
function serializeStepParents(parents) {
23-
return parents.map(s => Array.isArray(s) ? 'sequence' : s.name).join('/');
37+
return '/' + parents.map(s => Array.isArray(s) ? 'sequence' : s.name).join('/');
2438
}
2539

2640
function load() {
@@ -36,11 +50,20 @@ function load() {
3650
};
3751
let designer;
3852
const configuration = {
39-
toolbox: false,
53+
toolbox: {
54+
groups: [
55+
{
56+
name: 'Steps',
57+
steps: [
58+
createLoopStep()
59+
]
60+
}
61+
]
62+
},
4063

4164
steps: {
42-
canInsertStep: (step) => {
43-
return window.confirm(`Can insert "${step.name}"?`);
65+
canInsertStep: (step, _, targetIndex) => {
66+
return window.confirm(`Can insert "${step.name}" (${targetIndex})?`);
4467
},
4568
isDraggable: (step) => {
4669
return step.properties.draggable;

examples/assets/lib.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function embedStylesheet(url) {
1919

2020
const baseUrl = isTestEnv()
2121
? '../designer'
22-
: '//cdn.jsdelivr.net/npm/sequential-workflow-designer@0.13.0';
22+
: '//cdn.jsdelivr.net/npm/sequential-workflow-designer@0.13.1';
2323

2424
embedScript(`${baseUrl}/dist/index.umd.js`);
2525
embedStylesheet(`${baseUrl}/css/designer.css`);

react/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sequential-workflow-designer-react",
33
"description": "React wrapper for Sequential Workflow Designer component.",
4-
"version": "0.13.0",
4+
"version": "0.13.1",
55
"type": "module",
66
"main": "./lib/esm/index.js",
77
"types": "./lib/index.d.ts",
@@ -35,7 +35,7 @@
3535
},
3636
"scripts": {
3737
"prepare": "cp ../LICENSE LICENSE",
38-
"clean": "rm -rf lib",
38+
"clean": "rm -rf lib && rm -rf build && rm -rf node_modules/.cache/rollup-plugin-typescript2",
3939
"start": "rollup -c --watch",
4040
"build": "yarn clean && rollup -c",
4141
"prettier": "prettier --check ./src",
@@ -47,7 +47,7 @@
4747
"peerDependencies": {
4848
"react": "^18.2.0",
4949
"react-dom": "^18.2.0",
50-
"sequential-workflow-designer": "^0.13.0"
50+
"sequential-workflow-designer": "^0.13.1"
5151
},
5252
"devDependencies": {
5353
"@rollup/plugin-node-resolve": "^15.0.1",
@@ -63,7 +63,7 @@
6363
"prettier": "^2.8.2",
6464
"react": "^18.2.0",
6565
"react-dom": "^18.2.0",
66-
"sequential-workflow-designer": "^0.13.0",
66+
"sequential-workflow-designer": "^0.13.1",
6767
"rollup": "^3.18.0",
6868
"rollup-plugin-dts": "^5.2.0",
6969
"rollup-plugin-typescript2": "^0.34.1",
@@ -80,4 +80,4 @@
8080
"react",
8181
"reactjs"
8282
]
83-
}
83+
}

0 commit comments

Comments
 (0)