Skip to content

Commit d945354

Browse files
authored
0.6.0. (#12)
* 0.6.0.
1 parent 9fd55a8 commit d945354

File tree

61 files changed

+1135
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1135
-264
lines changed

CHANGELOG.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
## 0.6.0
2+
3+
* This version brings small visual improvements.
4+
* Added a new value model: string dictionary (`stringDictionaryValueModel({ ... })`). This value model allows you to specify a dictionary of string values.
5+
* The string value model now supports multiline mode.
6+
7+
```ts
8+
stringValueModel({ multiline: true })
9+
stringValueModel({ multiline: 10 })
10+
```
11+
12+
**Breaking changes:**
13+
14+
The createStepEditorProvider() method of the EditorProvider class now returns a new type of editor provider. This method no longer accepts any arguments.
15+
16+
```ts
17+
type StepEditorProvider = (step: Step, context: StepEditorContext, definition: Definition) => HTMLElement;
18+
19+
EditorProvider.createStepEditorProvider(): StepEditorProvider;
20+
```
21+
122
## 0.5.0
223

324
The `DefinitionValidator` class supports the validation of the whole definition. Use the `validate` method to validate a definition deeply. This method will validate all steps in the definition at once. Now you may easily validate a definition in the back-end before saving it to the storage.
@@ -20,7 +41,7 @@ if (validator.validate(definition)) {
2041

2142
## 0.4.0
2243

23-
* Added new value model: `generatedString` (`generatedStringValueEditor({ ... })`). The new value model allows you to generate a string value for some property, depending on the values of other properties. Mainly this feature is designed to generate a step name automatically.
44+
* Added a new value model: `generatedString` (`generatedStringValueEditor({ ... })`). The new value model allows you to generate a string value for some property, depending on the values of other properties. Mainly this feature is designed to generate a step name automatically.
2445
* The `StepModel` interface has one new property: `label`. The label is used to display a step name in the editor and the toolbox.
2546

2647
**Breaking changes:**
@@ -40,7 +61,7 @@ Added new value model: boolean (`booleanValueModel({ ... })`).
4061

4162
## 0.3.0
4263

43-
* Added new value model: nullable any variable (`nullableAnyVariableValueModel({ ... })`). This value model allows you to select any variable. Additionally, you can specify a variable type that can be selected by a user.
64+
* Added a new value model: nullable any variable (`nullableAnyVariableValueModel({ ... })`). This value model allows you to select any variable. Additionally, you can specify a variable type that can be selected by a user.
4465
* Added new optional property: `valueTypes` to `VariableDefinitionsValueModelConfiguration` interface. Now it's possible to force the types of variables during creation of variables by a user.
4566

4667
**Breaking changes:**

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Powerful workflow editor builder for sequential workflows. Written in TypeScript
1111
## 👀 Examples
1212

1313
* [🛠 Playground](https://nocode-js.github.io/sequential-workflow-editor/webpack-app/public/playground.html)
14+
* [📖 Editors](https://nocode-js.github.io/sequential-workflow-editor/webpack-app/public/editors.html)
1415

1516
## 🚀 Installation
1617

@@ -105,10 +106,10 @@ We have everything to attach the editor provider to a designer. For the Sequenti
105106
```ts
106107
import { Designer } from 'sequential-workflow-designer';
107108

108-
const designer: Designer<MyDefinition> = Designer.create(placeholder, startDefinition, {
109+
const designer = Designer.create(placeholder, startDefinition, {
109110
editors: {
110111
globalEditorProvider: editorProvider.createRootEditorProvider(),
111-
stepEditorProvider: editorProvider.createStepEditorProvider(() => designer.getDefinition())
112+
stepEditorProvider: editorProvider.createStepEditorProvider()
112113
},
113114
validator: {
114115
step: editorProvider.createStepValidator(),

demos/webpack-app/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"dependencies": {
1717
"xstate": "^4.37.2",
1818
"sequential-workflow-model": "^0.1.4",
19-
"sequential-workflow-designer": "^0.13.4",
19+
"sequential-workflow-designer": "^0.13.5",
2020
"sequential-workflow-machine": "^0.2.0",
21-
"sequential-workflow-editor-model": "^0.5.0",
22-
"sequential-workflow-editor": "^0.5.0"
21+
"sequential-workflow-editor-model": "^0.6.0",
22+
"sequential-workflow-editor": "^0.6.0"
2323
},
2424
"devDependencies": {
2525
"ts-loader": "^9.4.2",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
html,
2+
body,
3+
#designer {
4+
margin: 0;
5+
padding: 0;
6+
width: 100vw;
7+
height: 100vh;
8+
overflow: hidden;
9+
}
10+
body,
11+
input,
12+
textarea {
13+
font: 14px/1.3em Arial, Verdana, sans-serif;
14+
}
15+
.sqd-global-editor {
16+
padding: 10px;
17+
line-height: 1.3em;
18+
box-sizing: border-box;
19+
}
20+
a {
21+
color: #000;
22+
text-decoration: underline;
23+
}
24+
a:hover {
25+
text-decoration: none;
26+
}

demos/webpack-app/public/assets/style.css renamed to demos/webpack-app/public/assets/playground.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ body {
55
width: 100vw;
66
height: 100vh;
77
overflow: hidden;
8+
}
9+
body,
10+
input,
11+
textarea {
812
font: 14px/1.3em Arial, Verdana, sans-serif;
913
}
1014
body {

demos/webpack-app/public/editors.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>📖 Editors - Sequential Workflow Editor</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
7+
<link rel="icon" href="./assets/favicon.ico" />
8+
<script src="./builds/editors.js" defer></script>
9+
<link rel="stylesheet" href="./assets/editors.css" />
10+
</head>
11+
<body>
12+
<div id="designer"></div>
13+
</body>
14+
</html>

demos/webpack-app/public/playground.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<title>🛠 Playground - Sequential Workflow Editor</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
77
<link rel="icon" href="./assets/favicon.ico" />
8-
<link rel="stylesheet" href="./assets/style.css" />
8+
<link rel="stylesheet" href="./assets/playground.css" />
99
<script src="./builds/playground.js" defer></script>
1010
</head>
1111
<body>

demos/webpack-app/src/editors/app.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { Designer, Uid } from 'sequential-workflow-designer';
2+
import { EditorProvider } from 'sequential-workflow-editor';
3+
import { definitionModel } from './model/definition-model';
4+
5+
import 'sequential-workflow-designer/css/designer.css';
6+
import 'sequential-workflow-designer/css/designer-light.css';
7+
import 'sequential-workflow-editor/css/editor.css';
8+
9+
export class App {
10+
public static create(): App {
11+
const placeholder = document.getElementById('designer') as HTMLElement;
12+
13+
const editorProvider = EditorProvider.create(definitionModel, {
14+
uidGenerator: Uid.next
15+
});
16+
17+
const designer = Designer.create(placeholder, editorProvider.activateDefinition(), {
18+
controlBar: true,
19+
editors: {
20+
globalEditorProvider: () => {
21+
const editor = document.createElement('div');
22+
editor.innerHTML =
23+
'This demo showcases all the supported editors by the Sequential Workflow Editor. <a href="https://github.com/nocode-js/sequential-workflow-editor">GitHub</a>';
24+
return editor;
25+
},
26+
stepEditorProvider: editorProvider.createStepEditorProvider()
27+
},
28+
validator: {
29+
step: editorProvider.createStepValidator(),
30+
root: editorProvider.createRootValidator()
31+
},
32+
steps: {
33+
iconUrlProvider: () => './assets/icon-task.svg'
34+
},
35+
toolbox: {
36+
groups: editorProvider.getToolboxGroups(),
37+
labelProvider: editorProvider.createStepLabelProvider()
38+
}
39+
});
40+
41+
if (location.hash) {
42+
const type = location.hash.substring(1);
43+
const step = designer.getDefinition().sequence.find(s => s.type === type);
44+
if (step) {
45+
designer.selectStepById(step.id);
46+
}
47+
}
48+
49+
return new App();
50+
}
51+
}
52+
53+
document.addEventListener('DOMContentLoaded', App.create, false);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { AnyVariables, anyVariablesValueModel, createStepModel } from 'sequential-workflow-editor-model';
2+
import { Step } from 'sequential-workflow-model';
3+
4+
export interface AnyVariablesStepModel extends Step {
5+
type: 'anyVariables';
6+
componentType: 'task';
7+
properties: {
8+
zeroConfig: AnyVariables;
9+
onlyBoolean: AnyVariables;
10+
};
11+
}
12+
13+
export const anyVariablesStepModel = createStepModel<AnyVariablesStepModel>('anyVariables', 'task', step => {
14+
step.property('zeroConfig').value(anyVariablesValueModel({}));
15+
step.property('onlyBoolean').value(
16+
anyVariablesValueModel({
17+
valueTypes: ['boolean']
18+
})
19+
);
20+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { booleanValueModel, createStepModel } from 'sequential-workflow-editor-model';
2+
import { Step } from 'sequential-workflow-model';
3+
4+
export interface BooleanStepModel extends Step {
5+
type: 'boolean';
6+
componentType: 'task';
7+
properties: {
8+
zeroConfig: boolean;
9+
defaultValueTrue: boolean;
10+
defaultValueFalse: boolean;
11+
};
12+
}
13+
14+
export const booleanStepModel = createStepModel<BooleanStepModel>('boolean', 'task', step => {
15+
step.property('zeroConfig').value(booleanValueModel({}));
16+
step.property('defaultValueTrue').value(
17+
booleanValueModel({
18+
defaultValue: true
19+
})
20+
);
21+
step.property('defaultValueFalse').value(
22+
booleanValueModel({
23+
defaultValue: false
24+
})
25+
);
26+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { choiceValueModel, createStepModel } from 'sequential-workflow-editor-model';
2+
import { Step } from 'sequential-workflow-model';
3+
4+
export interface ChoiceStepModel extends Step {
5+
type: 'choice';
6+
componentType: 'task';
7+
properties: {
8+
minimalConfig: string;
9+
defaultValueGreen: string;
10+
};
11+
}
12+
13+
export const choiceStepModel = createStepModel<ChoiceStepModel>('choice', 'task', step => {
14+
const choices = ['red', 'blue', 'green'];
15+
16+
step.property('minimalConfig').value(choiceValueModel({ choices }));
17+
step.property('defaultValueGreen').value(choiceValueModel({ choices, defaultValue: 'green' }));
18+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { createDefinitionModel } from 'sequential-workflow-editor-model';
2+
import { stepModels } from './step-models';
3+
import { rootModel } from './root-model';
4+
5+
export const definitionModel = createDefinitionModel(model => {
6+
model.valueTypes(['string', 'number', 'boolean']);
7+
model.root(rootModel);
8+
model.steps(stepModels);
9+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Dynamic, booleanValueModel, createStepModel, dynamicValueModel, stringValueModel } from 'sequential-workflow-editor-model';
2+
import { Step } from 'sequential-workflow-model';
3+
4+
export interface DynamicStepModel extends Step {
5+
type: 'dynamic';
6+
componentType: 'task';
7+
properties: {
8+
example: Dynamic<string | boolean>;
9+
};
10+
}
11+
12+
export const dynamicStepModel = createStepModel<DynamicStepModel>('dynamic', 'task', step => {
13+
step.property('example').value(
14+
dynamicValueModel({
15+
models: [stringValueModel({}), booleanValueModel({})]
16+
})
17+
);
18+
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { createStepModel, generatedStringValueModel, numberValueModel } from 'sequential-workflow-editor-model';
2+
import { Step } from 'sequential-workflow-model';
3+
4+
export interface GeneratedStringStepModel extends Step {
5+
type: 'generatedString';
6+
componentType: 'task';
7+
properties: {
8+
x: number;
9+
example: string;
10+
};
11+
}
12+
13+
export const generatedStringStepModel = createStepModel<GeneratedStringStepModel>('generatedString', 'task', step => {
14+
step.property('x').value(numberValueModel({}));
15+
16+
step.property('example')
17+
.dependentProperty('x')
18+
.value(
19+
generatedStringValueModel({
20+
generator(context) {
21+
const x = context.getPropertyValue('x');
22+
switch (x) {
23+
case 0:
24+
return 'Only zero :(';
25+
case 1:
26+
return 'One! Nice! :)';
27+
case 2:
28+
return 'Two! Cool number! :))))';
29+
}
30+
if (x < 0) {
31+
return 'No no no! Negative number :(';
32+
}
33+
return 'Give me other number!';
34+
}
35+
})
36+
);
37+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { NullableAnyVariable, createStepModel, nullableAnyVariableValueModel } from 'sequential-workflow-editor-model';
2+
import { Step } from 'sequential-workflow-model';
3+
4+
export interface NullableAnyVariableStepModel extends Step {
5+
type: 'nullableAnyVariable';
6+
componentType: 'task';
7+
properties: {
8+
zeroConfig: NullableAnyVariable;
9+
required: NullableAnyVariable;
10+
onlyNumber: NullableAnyVariable;
11+
};
12+
}
13+
14+
export const nullableAnyVariableStepModel = createStepModel<NullableAnyVariableStepModel>('nullableAnyVariable', 'task', step => {
15+
step.property('zeroConfig').value(nullableAnyVariableValueModel({}));
16+
step.property('required').value(
17+
nullableAnyVariableValueModel({
18+
isRequired: true
19+
})
20+
);
21+
step.property('onlyNumber').value(
22+
nullableAnyVariableValueModel({
23+
valueTypes: ['number']
24+
})
25+
);
26+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { NullableVariableDefinition, createStepModel, nullableVariableDefinitionValueModel } from 'sequential-workflow-editor-model';
2+
import { Step } from 'sequential-workflow-model';
3+
4+
export interface NullableVariableDefinitionStepModel extends Step {
5+
type: 'nullableVariableDefinition';
6+
componentType: 'task';
7+
properties: {
8+
minimalConfig: NullableVariableDefinition;
9+
required: NullableVariableDefinition;
10+
defaultValue: NullableVariableDefinition;
11+
};
12+
}
13+
14+
export const nullableVariableDefinitionStepModel = createStepModel<NullableVariableDefinitionStepModel>(
15+
'nullableVariableDefinition',
16+
'task',
17+
step => {
18+
step.property('minimalConfig').value(
19+
nullableVariableDefinitionValueModel({
20+
valueType: 'number'
21+
})
22+
);
23+
step.property('required').value(
24+
nullableVariableDefinitionValueModel({
25+
valueType: 'number',
26+
isRequired: true
27+
})
28+
);
29+
30+
step.property('defaultValue').value(
31+
nullableVariableDefinitionValueModel({
32+
valueType: 'number',
33+
defaultValue: {
34+
name: 'index',
35+
type: 'number'
36+
}
37+
})
38+
);
39+
}
40+
);

0 commit comments

Comments
 (0)