Skip to content

Commit 2503075

Browse files
authored
0.14.1. (#43)
1 parent 8c1ed07 commit 2503075

File tree

9 files changed

+40
-17
lines changed

9 files changed

+40
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.14.1
2+
3+
This version adds the `formatPropertyValue` method to: `PropertyContext`, `DefaultValueContext`, `ScopedPropertyContext` and `ValueContext` classes.
4+
15
## 0.14.0
26

37
From now, the nullable any variable editor and the nullable variable editor display the expected variable types to select. This version also allows changes to the labels in the dropdown menu of the dynamic value editor.

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.21.2",
2020
"sequential-workflow-machine": "^0.4.0",
21-
"sequential-workflow-editor-model": "^0.14.0",
22-
"sequential-workflow-editor": "^0.14.0"
21+
"sequential-workflow-editor-model": "^0.14.1",
22+
"sequential-workflow-editor": "^0.14.1"
2323
},
2424
"devDependencies": {
2525
"ts-loader": "^9.4.2",

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.14.0",
3+
"version": "0.14.1",
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.14.0",
49+
"sequential-workflow-editor-model": "^0.14.1",
5050
"sequential-workflow-model": "^0.2.0"
5151
},
5252
"peerDependencies": {
53-
"sequential-workflow-editor-model": "^0.14.0",
53+
"sequential-workflow-editor-model": "^0.14.1",
5454
"sequential-workflow-model": "^0.2.0"
5555
},
5656
"devDependencies": {

model/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sequential-workflow-editor-model",
3-
"version": "0.14.0",
3+
"version": "0.14.1",
44
"homepage": "https://nocode-js.com/",
55
"author": {
66
"name": "NoCode JS",

model/src/context/default-value-context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ export class DefaultValueContext<TProperties extends Properties = Properties> {
1616
) {}
1717

1818
public readonly getPropertyValue = this.propertyContext.getPropertyValue;
19+
public readonly formatPropertyValue = this.propertyContext.formatPropertyValue;
1920
public readonly activateStep = this.activator.activateStep;
2021
}

model/src/context/property-context.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,37 @@ export class PropertyContext<TProperties extends Properties = Properties> {
1818
private readonly definitionModel: DefinitionModel
1919
) {}
2020

21+
/**
22+
* Get the value of a property by name.
23+
* @param name The name of the property.
24+
* @returns The value of the property.
25+
*/
2126
public readonly getPropertyValue = <Key extends keyof TProperties>(name: Key): TProperties[Key] => {
2227
return readPropertyValue(name, this.propertyModel, this.object);
2328
};
2429

30+
/**
31+
* @returns The supported value types for variables.
32+
*/
2533
public readonly getValueTypes = (): ValueType[] => {
2634
return this.definitionModel.valueTypes;
2735
};
36+
37+
/**
38+
* Format a property value using a formatter function.
39+
* @param name The name of the property.
40+
* @param formatter The formatter function.
41+
* @param undefinedValue The value to return if the property value is `null` or `undefined`.
42+
*/
43+
public readonly formatPropertyValue = <Key extends keyof TProperties>(
44+
name: Key,
45+
formatter: (value: NonNullable<TProperties[Key]>) => string,
46+
undefinedValue?: string
47+
): string => {
48+
const value = this.getPropertyValue(name);
49+
if (value === undefined || value === null) {
50+
return undefinedValue || '?';
51+
}
52+
return formatter(value);
53+
};
2854
}

model/src/context/scoped-property-context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export class ScopedPropertyContext<TProperties extends Properties> {
2121
) {}
2222

2323
public readonly getPropertyValue = this.propertyContext.getPropertyValue;
24+
public readonly formatPropertyValue = this.propertyContext.formatPropertyValue;
2425
public readonly getValueTypes = this.propertyContext.getValueTypes;
2526

2627
public readonly hasVariable = (variableName: string, valueType: string | null): boolean => {

model/src/context/value-context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class ValueContext<TValueModel extends ValueModel = ValueModel, TProperti
2626
) {}
2727

2828
public readonly getPropertyValue = this.scopedPropertyContext.getPropertyValue;
29+
public readonly formatPropertyValue = this.scopedPropertyContext.formatPropertyValue;
2930
public readonly getValueTypes = this.scopedPropertyContext.getValueTypes;
3031
public readonly hasVariable = this.scopedPropertyContext.hasVariable;
3132
public readonly findFirstUndefinedVariable = this.scopedPropertyContext.findFirstUndefinedVariable;

model/src/value-models/generated-string/generated-string-context.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,5 @@ export class GeneratedStringContext<TProperties extends Properties = Properties>
1717
) {}
1818

1919
public readonly getPropertyValue = this.context.getPropertyValue;
20-
21-
public formatPropertyValue<Key extends keyof TProperties>(
22-
name: Key,
23-
formatter: (value: NonNullable<TProperties[Key]>) => string
24-
): string {
25-
const value = this.getPropertyValue(name);
26-
if (value === undefined || value === null) {
27-
return '?';
28-
}
29-
return formatter(value);
30-
}
20+
public readonly formatPropertyValue = this.context.formatPropertyValue;
3121
}

0 commit comments

Comments
 (0)