Skip to content

Commit c4940c6

Browse files
authored
0.9.0. (#19)
* 0.9.0.
1 parent 160adc9 commit c4940c6

37 files changed

+301
-68
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.9.0
2+
3+
* Improved validation for the `boolean` value model.
4+
* Improved validation for the `branches` value model.
5+
* Internal changes preparing for the upcoming pro version.
6+
17
## 0.8.0
28

39
Updated the `sequential-workflow-model` dependency to the version `0.2.0`.

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.38.2",
1818
"sequential-workflow-model": "^0.2.0",
19-
"sequential-workflow-designer": "^0.14.1",
19+
"sequential-workflow-designer": "^0.16.0",
2020
"sequential-workflow-machine": "^0.4.0",
21-
"sequential-workflow-editor-model": "^0.8.0",
22-
"sequential-workflow-editor": "^0.8.0"
21+
"sequential-workflow-editor-model": "^0.9.0",
22+
"sequential-workflow-editor": "^0.9.0"
2323
},
2424
"devDependencies": {
2525
"ts-loader": "^9.4.2",

editor/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sequential-workflow-editor",
3-
"version": "0.8.0",
3+
"version": "0.9.0",
44
"type": "module",
55
"main": "./lib/esm/index.js",
66
"types": "./lib/index.d.ts",
@@ -46,11 +46,11 @@
4646
"prettier:fix": "prettier --write ./src ./css"
4747
},
4848
"dependencies": {
49-
"sequential-workflow-editor-model": "^0.8.0",
49+
"sequential-workflow-editor-model": "^0.9.0",
5050
"sequential-workflow-model": "^0.2.0"
5151
},
5252
"peerDependencies": {
53-
"sequential-workflow-editor-model": "^0.8.0",
53+
"sequential-workflow-editor-model": "^0.9.0",
5454
"sequential-workflow-model": "^0.2.0"
5555
},
5656
"devDependencies": {
@@ -79,4 +79,4 @@
7979
"lowcode",
8080
"flow"
8181
]
82-
}
82+
}

editor/src/components/dynamic-list-component.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ export interface DynamicListComponent<TItem> extends Component {
88
add(item: TItem): void;
99
}
1010

11-
export interface DynamicListComponentConfiguration {
11+
export interface DynamicListComponentConfiguration<TItem> {
1212
emptyMessage?: string;
13+
canDelete?: (item: TItem) => string | null;
1314
}
1415

1516
export interface DynamicListItemComponent<TItem> extends Component {
@@ -22,7 +23,7 @@ export function dynamicListComponent<TItem>(
2223
initialItems: TItem[],
2324
itemComponentFactory: (item: TItem) => DynamicListItemComponent<TItem>,
2425
context: ValueContext,
25-
configuration?: DynamicListComponentConfiguration
26+
configuration?: DynamicListComponentConfiguration<TItem>
2627
): DynamicListComponent<TItem> {
2728
const onChanged = new SimpleEvent<TItem[]>();
2829
const items = [...initialItems];
@@ -38,6 +39,14 @@ export function dynamicListComponent<TItem>(
3839
}
3940

4041
function onItemDeleted(index: number) {
42+
if (configuration && configuration.canDelete) {
43+
const error = configuration.canDelete(items[index]);
44+
if (error) {
45+
window.alert(error);
46+
return;
47+
}
48+
}
49+
4150
items.splice(index, 1);
4251
forward();
4352
reloadList();

editor/src/components/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export * from './button-component';
2+
export * from './component';
3+
export * from './dynamic-list-component';
4+
export * from './input-component';
5+
export * from './prepended-input-component';
6+
export * from './row-component';
7+
export * from './select-component';
8+
export * from './textarea-component';
9+
export * from './validation-error-component';
10+
export * from './value-editor-container-component';

editor/src/core/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
export * from './append-multiline-text';
2+
export * from './filter-value-types';
3+
export * from './filter-value-types';
14
export * from './html';
5+
export * from './icons';
6+
export * from './stacked-simple-event';
27
export * from './variable-name-formatter';

editor/src/editor-extension.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ValueEditorFactory } from './value-editors';
2+
3+
export interface EditorExtension {
4+
valueEditors?: ValueEditorExtension[];
5+
}
6+
7+
export interface ValueEditorExtension {
8+
editorId: string;
9+
factory: ValueEditorFactory;
10+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { UidGenerator } from 'sequential-workflow-editor-model';
22
import { DefinitionWalker } from 'sequential-workflow-model';
3+
import { EditorExtension } from './editor-extension';
34

45
export interface EditorProviderConfiguration {
56
uidGenerator: UidGenerator;
67
definitionWalker?: DefinitionWalker;
78
isHeaderHidden?: boolean;
9+
extensions?: EditorExtension[];
810
}

editor/src/editor-provider.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Path,
99
StepValidatorContext
1010
} from 'sequential-workflow-editor-model';
11-
import { EditorServices, ValueEditorEditorFactoryResolver } from './value-editors';
11+
import { EditorServices, ValueEditorFactoryResolver } from './value-editors';
1212
import {
1313
GlobalEditorContext,
1414
RootEditorProvider,
@@ -30,19 +30,21 @@ export class EditorProvider<TDefinition extends Definition> {
3030
const definitionWalker = configuration.definitionWalker ?? new DefinitionWalker();
3131
const activator = ModelActivator.create(definitionModel, configuration.uidGenerator);
3232
const validator = DefinitionValidator.create(definitionModel, definitionWalker);
33-
return new EditorProvider(activator, validator, definitionModel, definitionWalker, configuration);
33+
const valueEditorFactoryResolver = ValueEditorFactoryResolver.create(configuration.extensions);
34+
return new EditorProvider(activator, validator, definitionModel, definitionWalker, valueEditorFactoryResolver, configuration);
3435
}
3536

3637
private readonly services: EditorServices = {
3738
activator: this.activator,
38-
valueEditorFactoryResolver: ValueEditorEditorFactoryResolver.resolve
39+
valueEditorFactoryResolver: this.valueEditorFactoryResolver
3940
};
4041

4142
private constructor(
4243
private readonly activator: ModelActivator<TDefinition>,
4344
private readonly validator: DefinitionValidator,
4445
private readonly definitionModel: DefinitionModel,
4546
private readonly definitionWalker: DefinitionWalker,
47+
private readonly valueEditorFactoryResolver: ValueEditorFactoryResolver,
4648
private readonly configuration: EditorProviderConfiguration
4749
) {}
4850

@@ -82,11 +84,17 @@ export class EditorProvider<TDefinition extends Definition> {
8284
const editor = Editor.create(headerData, validator, propertyModels, definitionContext, this.services, typeClassName);
8385

8486
editor.onValuesChanged.subscribe((paths: Path[]) => {
85-
if (paths.some(path => path.equals(stepModel.name.value.path))) {
87+
const isNameChanged = paths.some(path => path.equals(stepModel.name.value.path));
88+
if (isNameChanged) {
8689
context.notifyNameChanged();
87-
} else {
88-
context.notifyPropertiesChanged();
90+
return;
8991
}
92+
const areBranchesChanged = paths.some(path => path.equals('branches'));
93+
if (areBranchesChanged) {
94+
context.notifyChildrenChanged();
95+
return;
96+
}
97+
context.notifyPropertiesChanged();
9098
});
9199
return editor.root;
92100
};

editor/src/editor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DefinitionContext, Path, PropertyModel, PropertyModels } from 'sequential-workflow-editor-model';
22
import { PropertyEditor } from './property-editor/property-editor';
3-
import { EditorServices, ValueEditorEditorFactoryResolver } from './value-editors';
3+
import { EditorServices } from './value-editors';
44
import { EditorHeader, EditorHeaderData } from './editor-header';
55
import { StackedSimpleEvent } from './core/stacked-simple-event';
66
import { ValidationErrorComponent, validationErrorComponent } from './components/validation-error-component';
@@ -32,7 +32,7 @@ export class Editor {
3232

3333
const editors = new Map<PropertyModel, PropertyEditor>();
3434
for (const propertyModel of propertyModels) {
35-
if (ValueEditorEditorFactoryResolver.isHidden(propertyModel.value.id)) {
35+
if (editorServices.valueEditorFactoryResolver.isHidden(propertyModel.value.id, propertyModel.value.editorId)) {
3636
continue;
3737
}
3838

0 commit comments

Comments
 (0)