diff --git a/CHANGELOG.md b/CHANGELOG.md index 8156b0f..a82ed72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.0 + +This version deletes all deprecated `*ValueModel` functions. From now, use only `create*ValueModel` functions. + ## 0.9.3 Added `hasVariable` and `hasVariables` methods to the `PropertyValidatorContext` class. diff --git a/demos/webpack-app/package.json b/demos/webpack-app/package.json index e2f72a0..321c942 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.16.1", "sequential-workflow-machine": "^0.4.0", - "sequential-workflow-editor-model": "^0.9.3", - "sequential-workflow-editor": "^0.9.3" + "sequential-workflow-editor-model": "^0.10.0", + "sequential-workflow-editor": "^0.10.0" }, "devDependencies": { "ts-loader": "^9.4.2", diff --git a/editor/package.json b/editor/package.json index 88debe8..5c059a1 100644 --- a/editor/package.json +++ b/editor/package.json @@ -1,6 +1,6 @@ { "name": "sequential-workflow-editor", - "version": "0.9.3", + "version": "0.10.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.9.3", + "sequential-workflow-editor-model": "^0.10.0", "sequential-workflow-model": "^0.2.0" }, "peerDependencies": { - "sequential-workflow-editor-model": "^0.9.3", + "sequential-workflow-editor-model": "^0.10.0", "sequential-workflow-model": "^0.2.0" }, "devDependencies": { diff --git a/editor/src/components/button-component.spec.ts b/editor/src/components/button-component.spec.ts index 6cd3cc7..3e22929 100644 --- a/editor/src/components/button-component.spec.ts +++ b/editor/src/components/button-component.spec.ts @@ -12,4 +12,15 @@ describe('ButtonComponent', () => { expect(button.view.innerText).toBe('Some button'); expect(clicked).toBe(true); }); + + it('replaces icon', () => { + const button = buttonComponent('Icon button', { icon: 'm200' }); + const getD = () => button.view.children[0].children[0].getAttribute('d'); + + expect(getD()).toBe('m200'); + + button.setIcon('m100'); + + expect(getD()).toBe('m100'); + }); }); diff --git a/editor/src/components/button-component.ts b/editor/src/components/button-component.ts index 9d2436f..c494b95 100644 --- a/editor/src/components/button-component.ts +++ b/editor/src/components/button-component.ts @@ -5,6 +5,8 @@ import { Icons } from '../core/icons'; export interface ButtonComponent extends Component { onClick: SimpleEvent; + setIcon(d: string): void; + setLabel(label: string): void; } export interface ButtonComponentConfiguration { @@ -19,6 +21,22 @@ export function buttonComponent(label: string, configuration?: ButtonComponentCo onClick.forward(); } + function setIcon(d: string) { + if (icon) { + icon.getElementsByTagName('path')[0].setAttribute('d', d); + } else { + throw new Error('This button does not have icon'); + } + } + + function setLabel(label: string) { + if (configuration?.icon) { + throw new Error('Cannot change label on button with icon'); + } else { + view.innerText = label; + } + } + const onClick = new SimpleEvent(); let className = 'swe-button'; @@ -33,9 +51,10 @@ export function buttonComponent(label: string, configuration?: ButtonComponentCo title: label, 'aria-label': label }); + let icon: SVGElement | undefined; if (configuration?.icon) { - const svg = Icons.createSvg(configuration.icon, 'swe-button-icon'); - view.appendChild(svg); + icon = Icons.createSvg(configuration.icon, 'swe-button-icon'); + view.appendChild(icon); } else { view.innerText = label; } @@ -43,6 +62,8 @@ export function buttonComponent(label: string, configuration?: ButtonComponentCo return { view, - onClick + onClick, + setIcon, + setLabel }; } diff --git a/editor/src/components/input-component.ts b/editor/src/components/input-component.ts index a2213c6..901d974 100644 --- a/editor/src/components/input-component.ts +++ b/editor/src/components/input-component.ts @@ -6,10 +6,11 @@ export interface InputComponent extends Component { onChanged: SimpleEvent; setValue(value: string): void; getValue(): string; + setReadonly(readonly: boolean): void; } export interface InputConfiguration { - type?: 'text' | 'number'; + type?: 'text' | 'number' | 'password'; isReadonly?: boolean; placeholder?: string; } @@ -25,6 +26,14 @@ export function inputComponent(startValue: string, configuration?: InputConfigur return view.value; } + function setReadonly(readonly: boolean) { + if (readonly) { + view.setAttribute('readonly', 'readonly'); + } else { + view.removeAttribute('readonly'); + } + } + const view = Html.element('input', { class: 'swe-input swe-stretched', type: configuration?.type ?? 'text' @@ -33,7 +42,7 @@ export function inputComponent(startValue: string, configuration?: InputConfigur view.setAttribute('placeholder', configuration.placeholder); } if (configuration?.isReadonly) { - view.setAttribute('readonly', 'readonly'); + setReadonly(true); } view.value = startValue; view.addEventListener('input', () => { @@ -44,6 +53,7 @@ export function inputComponent(startValue: string, configuration?: InputConfigur view, onChanged, setValue, - getValue + getValue, + setReadonly }; } diff --git a/model/package.json b/model/package.json index 8d0a6dc..68ad45b 100644 --- a/model/package.json +++ b/model/package.json @@ -1,6 +1,6 @@ { "name": "sequential-workflow-editor-model", - "version": "0.9.3", + "version": "0.10.0", "homepage": "https://nocode-js.com/", "author": { "name": "NoCode JS", diff --git a/model/src/value-models/depreciated.ts b/model/src/value-models/depreciated.ts deleted file mode 100644 index 85d88f1..0000000 --- a/model/src/value-models/depreciated.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { createAnyVariablesValueModel } from './any-variables'; -import { createBooleanValueModel } from './boolean'; -import { createBranchesValueModel } from './branches'; -import { createChoiceValueModel } from './choice'; -import { createDynamicValueModel } from './dynamic'; -import { createGeneratedStringValueModel } from './generated-string'; -import { createNullableAnyVariableValueModel } from './nullable-any-variable'; -import { createNullableVariableValueModel } from './nullable-variable'; -import { createNullableVariableDefinitionValueModel } from './nullable-variable-definition'; -import { createNumberValueModel } from './number'; -import { createSequenceValueModel } from './sequence'; -import { createStringValueModel } from './string'; -import { createStringDictionaryValueModel } from './string-dictionary'; -import { createVariableDefinitionsValueModel } from './variable-definitions'; - -/** - * @deprecated Use `createAnyVariablesValueModel` instead. - */ -export const anyVariablesValueModel = createAnyVariablesValueModel; - -/** - * @deprecated Use `createBooleanValueModel` instead. - */ -export const booleanValueModel = createBooleanValueModel; - -/** - * @deprecated Use `createBranchesValueModel` instead. - */ -export const branchesValueModel = createBranchesValueModel; - -/** - * @deprecated Use `createChoiceValueModel` instead. - */ -export const choiceValueModel = createChoiceValueModel; - -/** - * @deprecated Use `createDynamicValueModel` instead. - */ -export const dynamicValueModel = createDynamicValueModel; - -/** - * @deprecated Use `createGeneratedStringValueModel` instead. - */ -export const generatedStringValueModel = createGeneratedStringValueModel; - -/** - * @deprecated Use `createNullableAnyVariableValueModel` instead. - */ -export const nullableAnyVariableValueModel = createNullableAnyVariableValueModel; - -/** - * @deprecated Use `createNullableVariableValueModel` instead. - */ -export const nullableVariableValueModel = createNullableVariableValueModel; - -/** - * @deprecated Use `createNullableVariableDefinitionValueModel` instead. - */ -export const nullableVariableDefinitionValueModel = createNullableVariableDefinitionValueModel; - -/** - * @deprecated Use `createNumberValueModel` instead. - */ -export const numberValueModel = createNumberValueModel; - -/** - * @deprecated Use `createSequenceValueModel` instead. - */ -export const sequenceValueModel = createSequenceValueModel; - -/** - * @deprecated Use `createStringValueModel` instead. - */ -export const stringValueModel = createStringValueModel; - -/** - * @deprecated Use `createStringDictionaryValueModel` instead. - */ -export const stringDictionaryValueModel = createStringDictionaryValueModel; - -/** - * @deprecated Use `createVariableDefinitionsValueModel` instead. - */ -export const variableDefinitionsValueModel = createVariableDefinitionsValueModel; diff --git a/model/src/value-models/index.ts b/model/src/value-models/index.ts index 8befc3e..f286881 100644 --- a/model/src/value-models/index.ts +++ b/model/src/value-models/index.ts @@ -12,4 +12,3 @@ export * from './sequence'; export * from './string'; export * from './string-dictionary'; export * from './variable-definitions'; -export * from './depreciated';