diff --git a/CHANGELOG.md b/CHANGELOG.md index 04e67aa..4807dd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.14.0 + +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. + ## 0.13.2 This version adds missing translations for the `variableDefinitions` value editor. diff --git a/demos/webpack-app/package.json b/demos/webpack-app/package.json index e505e36..241681b 100644 --- a/demos/webpack-app/package.json +++ b/demos/webpack-app/package.json @@ -18,8 +18,8 @@ "sequential-workflow-model": "^0.2.0", "sequential-workflow-designer": "^0.21.2", "sequential-workflow-machine": "^0.4.0", - "sequential-workflow-editor-model": "^0.13.2", - "sequential-workflow-editor": "^0.13.2" + "sequential-workflow-editor-model": "^0.14.0", + "sequential-workflow-editor": "^0.14.0" }, "devDependencies": { "ts-loader": "^9.4.2", diff --git a/demos/webpack-app/src/editors/app.ts b/demos/webpack-app/src/editors/app.ts index e361e0f..344b2b5 100644 --- a/demos/webpack-app/src/editors/app.ts +++ b/demos/webpack-app/src/editors/app.ts @@ -47,8 +47,8 @@ export class App { }); if (location.hash) { - const type = location.hash.substring(1); - const step = designer.getDefinition().sequence.find(s => s.type === type); + const type = location.hash.substring(1).toLowerCase(); + const step = designer.getDefinition().sequence.find(s => s.type.toLowerCase() === type); if (step) { designer.selectStepById(step.id); } diff --git a/docs/I18N-KEYS.md b/docs/I18N-KEYS.md index a95d769..402e56b 100644 --- a/docs/I18N-KEYS.md +++ b/docs/I18N-KEYS.md @@ -21,9 +21,10 @@ This document lists all the I18N keys used in the Sequential Workflow Editor. "generatedString.differentValue": "Generator returns different value than the current value", "nullableAnyVariable.invalidVariableType": "The variable :name has invalid type", "nullableAnyVariable.select": "- Select -", + "nullableAnyVariable.selectTypes": "- Select: :types -", "nullableAnyVariable.variableIsLost": "The variable :name is lost", "nullableAnyVariable.variableIsRequired": "The variable is required", - "nullableVariable.select": "- Select -", + "nullableVariable.selectType": "- Select: :type -", "nullableVariable.variableIsLost": "The variable :name is not found", "nullableVariable.variableIsRequired": "The variable is required", "nullableVariableDefinition.expectedType": "Variable type must be :type", diff --git a/editor/package.json b/editor/package.json index ed19193..3425a97 100644 --- a/editor/package.json +++ b/editor/package.json @@ -1,6 +1,6 @@ { "name": "sequential-workflow-editor", - "version": "0.13.2", + "version": "0.14.0", "type": "module", "main": "./lib/esm/index.js", "types": "./lib/index.d.ts", @@ -46,11 +46,11 @@ "prettier:fix": "prettier --write ./src ./css" }, "dependencies": { - "sequential-workflow-editor-model": "^0.13.2", + "sequential-workflow-editor-model": "^0.14.0", "sequential-workflow-model": "^0.2.0" }, "peerDependencies": { - "sequential-workflow-editor-model": "^0.13.2", + "sequential-workflow-editor-model": "^0.14.0", "sequential-workflow-model": "^0.2.0" }, "devDependencies": { diff --git a/editor/src/value-editors/nullable-any-variable/nullable-any-variable-editor.ts b/editor/src/value-editors/nullable-any-variable/nullable-any-variable-editor.ts index f70a5b4..0ddbdc3 100644 --- a/editor/src/value-editors/nullable-any-variable/nullable-any-variable-editor.ts +++ b/editor/src/value-editors/nullable-any-variable/nullable-any-variable-editor.ts @@ -35,10 +35,15 @@ export function nullableAnyVariableValueEditor( const select = selectComponent({ stretched: true }); - select.setValues([ - context.i18n('nullableAnyVariable.select', '- Select -'), - ...variables.map(variable => formatVariableNameWithType(variable.name, variable.type)) - ]); + + const expectedTypes = context.model.configuration.valueTypes ? context.model.configuration.valueTypes.join(', ') : null; + const actionText = expectedTypes + ? context.i18n('nullableAnyVariable.selectTypes', '- Select: :types -', { + types: expectedTypes + }) + : context.i18n('nullableAnyVariable.select', '- Select -'); + + select.setValues([actionText, ...variables.map(variable => formatVariableNameWithType(variable.name, variable.type))]); if (startValue) { select.selectIndex(variables.findIndex(variable => variable.name === startValue.name) + 1); } else { diff --git a/editor/src/value-editors/nullable-variable/nullable-variable-value-editor.ts b/editor/src/value-editors/nullable-variable/nullable-variable-value-editor.ts index 8f6817e..7c725d6 100644 --- a/editor/src/value-editors/nullable-variable/nullable-variable-value-editor.ts +++ b/editor/src/value-editors/nullable-variable/nullable-variable-value-editor.ts @@ -32,7 +32,9 @@ export function nullableVariableValueEditor(context: ValueContext formatVariableNameWithType(variable.name, variable.type)) ]); if (startValue) { diff --git a/model/package.json b/model/package.json index ffd743b..0e05a83 100644 --- a/model/package.json +++ b/model/package.json @@ -1,6 +1,6 @@ { "name": "sequential-workflow-editor-model", - "version": "0.13.2", + "version": "0.14.0", "homepage": "https://nocode-js.com/", "author": { "name": "NoCode JS", diff --git a/model/src/value-models/any-variables/any-variables-value-model.ts b/model/src/value-models/any-variables/any-variables-value-model.ts index 4f9d3d8..323d2e3 100644 --- a/model/src/value-models/any-variables/any-variables-value-model.ts +++ b/model/src/value-models/any-variables/any-variables-value-model.ts @@ -4,7 +4,9 @@ import { AnyVariables, ValueType } from '../../types'; import { ValueContext } from '../../context'; export interface AnyVariablesValueModelConfiguration { + label?: string; valueTypes?: ValueType[]; + editorId?: string; } export type AnyVariablesValueModel = ValueModel; @@ -16,7 +18,8 @@ export const createAnyVariablesValueModel = ( ): ValueModelFactoryFromModel => ({ create: (path: Path) => ({ id: anyVariablesValueModelId, - label: 'Variables', + label: configuration.label ?? 'Variables', + editorId: configuration.editorId, path, configuration, getDefaultValue() { diff --git a/model/src/value-models/boolean/boolean-value-model-configuration.ts b/model/src/value-models/boolean/boolean-value-model-configuration.ts index 9cc42af..18bbe9e 100644 --- a/model/src/value-models/boolean/boolean-value-model-configuration.ts +++ b/model/src/value-models/boolean/boolean-value-model-configuration.ts @@ -1,4 +1,5 @@ export interface BooleanValueModelConfiguration { + label?: string; defaultValue?: boolean; editorId?: string; } diff --git a/model/src/value-models/boolean/boolean-value-model.ts b/model/src/value-models/boolean/boolean-value-model.ts index 6a9b50b..7b0cd87 100644 --- a/model/src/value-models/boolean/boolean-value-model.ts +++ b/model/src/value-models/boolean/boolean-value-model.ts @@ -11,7 +11,7 @@ export const createBooleanValueModel = (configuration: BooleanValueModelConfigur create: (path: Path) => ({ id: booleanValueModelId, editorId: configuration.editorId, - label: 'Boolean', + label: configuration.label ?? 'Boolean', path, configuration, getDefaultValue() { diff --git a/model/src/value-models/choice/choice-value-model.ts b/model/src/value-models/choice/choice-value-model.ts index 5d41f2b..69dabc6 100644 --- a/model/src/value-models/choice/choice-value-model.ts +++ b/model/src/value-models/choice/choice-value-model.ts @@ -3,8 +3,10 @@ import { Path } from '../../core/path'; import { ValueContext } from '../../context'; export interface ChoiceValueModelConfiguration { + label?: string; choices: TValue[]; defaultValue?: TValue; + editorId?: string; } export type ChoiceValueModel = ValueModel>; @@ -21,7 +23,8 @@ export function createChoiceValueModel( return { create: (path: Path) => ({ id: choiceValueModelId, - label: 'Choice', + label: configuration.label ?? 'Choice', + editorId: configuration.editorId, path, configuration, getDefaultValue() { diff --git a/model/src/value-models/generated-string/generated-string-value-model.ts b/model/src/value-models/generated-string/generated-string-value-model.ts index 118a04f..0884cbc 100644 --- a/model/src/value-models/generated-string/generated-string-value-model.ts +++ b/model/src/value-models/generated-string/generated-string-value-model.ts @@ -6,7 +6,9 @@ import { GeneratedStringContext } from './generated-string-context'; import { DefaultValueContext } from '../../context/default-value-context'; export interface GeneratedStringValueModelConfiguration { + label?: string; generator(context: GeneratedStringContext): string; + editorId?: string; } export type GeneratedStringVariableValueModel = ValueModel< @@ -22,7 +24,8 @@ export function createGeneratedStringValueModel ({ id: generatedStringValueModelId, - label: 'Generated string', + label: configuration.label ?? 'Generated string', + editorId: configuration.editorId, path, configuration, getDefaultValue(context: DefaultValueContext) { diff --git a/model/src/value-models/nullable-any-variable/nullable-any-variable-value-model.ts b/model/src/value-models/nullable-any-variable/nullable-any-variable-value-model.ts index a9d9166..64b5332 100644 --- a/model/src/value-models/nullable-any-variable/nullable-any-variable-value-model.ts +++ b/model/src/value-models/nullable-any-variable/nullable-any-variable-value-model.ts @@ -4,8 +4,10 @@ import { NullableAnyVariable, ValueType } from '../../types'; import { ValueContext } from '../../context'; export interface NullableAnyVariableValueModelConfiguration { + label?: string; isRequired?: boolean; valueTypes?: ValueType[]; + editorId?: string; } export type NullableAnyVariableValueModel = ValueModel; @@ -17,7 +19,8 @@ export const createNullableAnyVariableValueModel = ( ): ValueModelFactoryFromModel => ({ create: (path: Path) => ({ id: nullableAnyVariableValueModelId, - label: 'Variable', + label: configuration.label ?? 'Variable', + editorId: configuration.editorId, path, configuration, getDefaultValue() { diff --git a/model/src/value-models/nullable-variable/nullable-variable-value-model.ts b/model/src/value-models/nullable-variable/nullable-variable-value-model.ts index c362fa9..b84e997 100644 --- a/model/src/value-models/nullable-variable/nullable-variable-value-model.ts +++ b/model/src/value-models/nullable-variable/nullable-variable-value-model.ts @@ -5,8 +5,10 @@ import { ValueType } from '../../types'; import { ValueContext } from '../../context'; export interface NullableVariableValueModelConfiguration { + label?: string; valueType: ValueType; isRequired?: boolean; + editorId?: string; } export type NullableVariableValueModel = ValueModel; @@ -18,7 +20,8 @@ export const createNullableVariableValueModel = ( ): ValueModelFactoryFromModel => ({ create: (path: Path) => ({ id: nullableVariableValueModelId, - label: 'Variable', + label: configuration.label ?? 'Variable', + editorId: configuration.editorId, path, configuration, getDefaultValue(): NullableVariable { diff --git a/model/src/value-models/number/number-value-model-configuration.ts b/model/src/value-models/number/number-value-model-configuration.ts index 4273e1e..155c687 100644 --- a/model/src/value-models/number/number-value-model-configuration.ts +++ b/model/src/value-models/number/number-value-model-configuration.ts @@ -1,4 +1,5 @@ export interface NumberValueModelConfiguration { + label?: string; defaultValue?: number; min?: number; max?: number; diff --git a/model/src/value-models/number/number-value-model.ts b/model/src/value-models/number/number-value-model.ts index 949e9a2..18ad47e 100644 --- a/model/src/value-models/number/number-value-model.ts +++ b/model/src/value-models/number/number-value-model.ts @@ -10,8 +10,8 @@ export const numberValueModelId = 'number'; export const createNumberValueModel = (configuration: NumberValueModelConfiguration): ValueModelFactoryFromModel => ({ create: (path: Path) => ({ id: numberValueModelId, + label: configuration.label ?? 'Number', editorId: configuration.editorId, - label: 'Number', path, configuration, getDefaultValue() { diff --git a/model/src/value-models/string-dictionary/string-dictionary-value-model-configuration.ts b/model/src/value-models/string-dictionary/string-dictionary-value-model-configuration.ts index 1414752..24e715f 100644 --- a/model/src/value-models/string-dictionary/string-dictionary-value-model-configuration.ts +++ b/model/src/value-models/string-dictionary/string-dictionary-value-model-configuration.ts @@ -1,4 +1,6 @@ export interface StringDictionaryValueModelConfiguration { + label?: string; uniqueKeys?: boolean; valueMinLength?: number; + editorId?: string; } diff --git a/model/src/value-models/string-dictionary/string-dictionary-value-model.ts b/model/src/value-models/string-dictionary/string-dictionary-value-model.ts index 0489436..a0cfc10 100644 --- a/model/src/value-models/string-dictionary/string-dictionary-value-model.ts +++ b/model/src/value-models/string-dictionary/string-dictionary-value-model.ts @@ -13,7 +13,8 @@ export const createStringDictionaryValueModel = ( ): ValueModelFactoryFromModel => ({ create: (path: Path) => ({ id: stringDictionaryValueModelId, - label: 'Dictionary', + label: configuration.label ?? 'Dictionary', + editorId: configuration.editorId, path, configuration, getDefaultValue() { diff --git a/model/src/value-models/string/string-value-model-configuration.ts b/model/src/value-models/string/string-value-model-configuration.ts index 4580def..0cb9290 100644 --- a/model/src/value-models/string/string-value-model-configuration.ts +++ b/model/src/value-models/string/string-value-model-configuration.ts @@ -1,4 +1,5 @@ export interface StringValueModelConfiguration { + label?: string; minLength?: number; defaultValue?: string; pattern?: RegExp; diff --git a/model/src/value-models/string/string-value-model.ts b/model/src/value-models/string/string-value-model.ts index 935f767..37cbd84 100644 --- a/model/src/value-models/string/string-value-model.ts +++ b/model/src/value-models/string/string-value-model.ts @@ -10,8 +10,8 @@ export const stringValueModelId = 'string'; export const createStringValueModel = (configuration: StringValueModelConfiguration): ValueModelFactoryFromModel => ({ create: (path: Path) => ({ id: stringValueModelId, + label: configuration.label ?? 'String', editorId: configuration.editorId, - label: 'String', path, configuration, getDefaultValue() {