Skip to content

Commit 6c316c7

Browse files
authored
0.11.0. (#26)
1 parent 0124d4e commit 6c316c7

23 files changed

+165
-130
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 0.11.0
2+
3+
This version normalizes names of functions in `ValueContext` and `PropertyValidatorContext` classes.
4+
5+
The `CustomValidatorContext` class is deleted now, please use the `PropertyValidatorContext` class instead.
6+
7+
The `PropertyModelBuilder` class has deleted the `customValidator` function, please use the `validator` function instead.
8+
19
## 0.10.0
210

311
This version deletes all deprecated `*ValueModel` functions. From now, use only `create*ValueModel` functions.

demos/webpack-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"sequential-workflow-model": "^0.2.0",
1919
"sequential-workflow-designer": "^0.16.1",
2020
"sequential-workflow-machine": "^0.4.0",
21-
"sequential-workflow-editor-model": "^0.10.0",
22-
"sequential-workflow-editor": "^0.10.0"
21+
"sequential-workflow-editor-model": "^0.11.0",
22+
"sequential-workflow-editor": "^0.11.0"
2323
},
2424
"devDependencies": {
2525
"ts-loader": "^9.4.2",

demos/webpack-app/src/playground/model/set-string-value-step-model.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ export const setStringValueStepModel = createStepModel<SetStringValueStep>('setS
4949
validate(context) {
5050
const value = context.getValue();
5151
if (value.modelId === 'string') {
52-
const variables = TextVariableParser.parse(value.value as string);
53-
const notFoundIndex = context.hasVariables(variables).findIndex(v => !v);
54-
if (notFoundIndex >= 0) {
55-
return `Variable $${variables[notFoundIndex]} is not defined`;
52+
const variableNames = TextVariableParser.parse(value.value as string);
53+
const undefinedVariableName = context.findFirstUndefinedVariable(variableNames);
54+
if (undefinedVariableName) {
55+
return `Variable $${undefinedVariableName} is not defined`;
5656
}
5757
}
5858
return null;

editor/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sequential-workflow-editor",
3-
"version": "0.10.0",
3+
"version": "0.11.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.10.0",
49+
"sequential-workflow-editor-model": "^0.11.0",
5050
"sequential-workflow-model": "^0.2.0"
5151
},
5252
"peerDependencies": {
53-
"sequential-workflow-editor-model": "^0.10.0",
53+
"sequential-workflow-editor-model": "^0.11.0",
5454
"sequential-workflow-model": "^0.2.0"
5555
},
5656
"devDependencies": {

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import { Html } from '../core/html';
33
import { Component } from './component';
44
import { validationErrorComponent } from './validation-error-component';
55

6-
export interface DynamicListComponent<TItem> extends Component {
6+
export interface DynamicListComponent<TItem, TItemComponent extends DynamicListItemComponent<TItem> = DynamicListItemComponent<TItem>>
7+
extends Component {
78
onChanged: SimpleEvent<TItem[]>;
89
add(item: TItem): void;
10+
forEach(callback: (component: TItemComponent) => void): void;
911
}
1012

1113
export interface DynamicListComponentConfiguration<TItem> {
@@ -19,12 +21,12 @@ export interface DynamicListItemComponent<TItem> extends Component {
1921
validate(error: string | null): void;
2022
}
2123

22-
export function dynamicListComponent<TItem>(
24+
export function dynamicListComponent<TItem, TItemComponent extends DynamicListItemComponent<TItem> = DynamicListItemComponent<TItem>>(
2325
initialItems: TItem[],
24-
itemComponentFactory: (item: TItem) => DynamicListItemComponent<TItem>,
26+
itemComponentFactory: (item: TItem) => TItemComponent,
2527
context: ValueContext,
2628
configuration?: DynamicListComponentConfiguration<TItem>
27-
): DynamicListComponent<TItem> {
29+
): DynamicListComponent<TItem, TItemComponent> {
2830
const onChanged = new SimpleEvent<TItem[]>();
2931
const items = [...initialItems];
3032

@@ -58,6 +60,10 @@ export function dynamicListComponent<TItem>(
5860
reloadList();
5961
}
6062

63+
function forEach(callback: (component: TItemComponent) => void) {
64+
components.forEach(callback);
65+
}
66+
6167
function reloadList() {
6268
if (emptyRow) {
6369
view.removeChild(emptyRow);
@@ -99,13 +105,14 @@ export function dynamicListComponent<TItem>(
99105
const validation = validationErrorComponent();
100106
view.appendChild(validation.view);
101107

102-
const components: DynamicListItemComponent<TItem>[] = [];
108+
const components: TItemComponent[] = [];
103109

104110
reloadList();
105111

106112
return {
107113
onChanged,
108114
view,
109-
add
115+
add,
116+
forEach
110117
};
111118
}

editor/src/property-editor/property-editor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class PropertyEditor implements Component {
1919
definitionContext: DefinitionContext,
2020
editorServices: EditorServices
2121
): PropertyEditor {
22-
const valueContext = ValueContext.create(propertyModel.value, propertyModel, definitionContext);
22+
const valueContext = ValueContext.createFromDefinitionContext(propertyModel.value, propertyModel, definitionContext);
2323
const valueEditorFactory = editorServices.valueEditorFactoryResolver.resolve(propertyModel.value.id, propertyModel.value.editorId);
2424
const valueEditor = valueEditorFactory(valueContext, editorServices);
2525
let hint: PropertyHintComponent | null = null;
@@ -64,7 +64,8 @@ export class PropertyEditor implements Component {
6464

6565
let validationError: PropertyValidationErrorComponent | null = null;
6666
if (propertyModel.validator) {
67-
const validatorContext = PropertyValidatorContext.create(propertyModel, definitionContext);
67+
const valueContext = ValueContext.createFromDefinitionContext(propertyModel.value, propertyModel, definitionContext);
68+
const validatorContext = PropertyValidatorContext.create(valueContext);
6869
validationError = propertyValidationErrorComponent(propertyModel.validator, validatorContext);
6970
view.appendChild(validationError.view);
7071
}

editor/src/value-editors/any-variables/any-variable-item-component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import { formatVariableNameWithType } from '../../core/variable-name-formatter';
77
import { DynamicListItemComponent } from '../../components/dynamic-list-component';
88
import { Icons } from '../../core/icons';
99

10-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
11-
export interface AnyVariableItemComponent extends DynamicListItemComponent<AnyVariable> {}
10+
export type AnyVariableItemComponent = DynamicListItemComponent<AnyVariable>;
1211

1312
export function anyVariableItemComponent(variable: AnyVariable): AnyVariableItemComponent {
1413
function validate(error: string | null) {

editor/src/value-editors/dynamic/dynamic-value-editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function dynamicValueEditor(context: ValueContext<DynamicValueModel>, ser
3636

3737
function onTypeChanged() {
3838
const newModel = subModels[subModelSelect.getSelectedIndex()];
39-
const defaultValueContext = DefaultValueContext.createFromValueContext(services.activator, context);
39+
const defaultValueContext = DefaultValueContext.create(services.activator, context.scopedPropertyContext.propertyContext);
4040
const defaultValue = {
4141
modelId: newModel.id,
4242
value: newModel.getDefaultValue(defaultValueContext)

editor/src/value-editors/string-dictionary/string-dictionary-item-component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import { buttonComponent } from '../../components/button-component';
77
import { DynamicListItemComponent } from '../../components/dynamic-list-component';
88
import { Icons } from '../../core/icons';
99

10-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
11-
export interface StringDictionaryItemComponent extends DynamicListItemComponent<StringDictionaryItem> {}
10+
export type StringDictionaryItemComponent = DynamicListItemComponent<StringDictionaryItem>;
1211

1312
export function stringDictionaryItemComponent(item: StringDictionaryItem): StringDictionaryItemComponent {
1413
function validate(error: string | null) {

editor/src/value-editors/variable-definitions/variable-definition-item-component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { Icons } from '../../core/icons';
1010
import { prependedInputComponent } from '../../components/prepended-input-component';
1111
import { inputComponent } from '../../components/input-component';
1212

13-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
14-
export interface VariableDefinitionItemComponent extends DynamicListItemComponent<VariableDefinition> {}
13+
export type VariableDefinitionItemComponent = DynamicListItemComponent<VariableDefinition>;
1514

1615
export function variableDefinitionItemComponent(
1716
variable: VariableDefinition,

0 commit comments

Comments
 (0)