Skip to content

0.10.0. #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions demos/webpack-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions editor/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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": {
Expand Down
11 changes: 11 additions & 0 deletions editor/src/components/button-component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
27 changes: 24 additions & 3 deletions editor/src/components/button-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Icons } from '../core/icons';

export interface ButtonComponent extends Component {
onClick: SimpleEvent<void>;
setIcon(d: string): void;
setLabel(label: string): void;
}

export interface ButtonComponentConfiguration {
Expand All @@ -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<void>();

let className = 'swe-button';
Expand All @@ -33,16 +51,19 @@ 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;
}
view.addEventListener('click', onClicked, false);

return {
view,
onClick
onClick,
setIcon,
setLabel
};
}
16 changes: 13 additions & 3 deletions editor/src/components/input-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ export interface InputComponent extends Component {
onChanged: SimpleEvent<string>;
setValue(value: string): void;
getValue(): string;
setReadonly(readonly: boolean): void;
}

export interface InputConfiguration {
type?: 'text' | 'number';
type?: 'text' | 'number' | 'password';
isReadonly?: boolean;
placeholder?: string;
}
Expand All @@ -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'
Expand All @@ -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', () => {
Expand All @@ -44,6 +53,7 @@ export function inputComponent(startValue: string, configuration?: InputConfigur
view,
onChanged,
setValue,
getValue
getValue,
setReadonly
};
}
2 changes: 1 addition & 1 deletion model/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
84 changes: 0 additions & 84 deletions model/src/value-models/depreciated.ts

This file was deleted.

1 change: 0 additions & 1 deletion model/src/value-models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ export * from './sequence';
export * from './string';
export * from './string-dictionary';
export * from './variable-definitions';
export * from './depreciated';