Skip to content

Commit bcd44e9

Browse files
authored
0.13.0. (#36)
1 parent 6397a30 commit bcd44e9

28 files changed

+189
-67
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.13.0
2+
3+
This version introduces several internal changes that allowed for the creation of a new type of editor in the pro version: the hidden dependent value editor.
4+
15
## 0.12.1
26

37
This version normalizes translations.

demos/vanilla-js-app/vanilla-js.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
}
2424
</style>
2525

26-
<link href="https://cdn.jsdelivr.net/npm/[email protected].1/css/designer.css" rel="stylesheet" />
27-
<link href="https://cdn.jsdelivr.net/npm/[email protected].1/css/designer-light.css" rel="stylesheet" />
28-
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/index.umd.js"></script>
26+
<link href="https://cdn.jsdelivr.net/npm/[email protected].2/css/designer.css" rel="stylesheet" />
27+
<link href="https://cdn.jsdelivr.net/npm/[email protected].2/css/designer-light.css" rel="stylesheet" />
28+
<script src="https://cdn.jsdelivr.net/npm/[email protected].2/dist/index.umd.js"></script>
2929

3030
<script src="./assets/lib.js"></script>
3131
<script src="./assets/vanilla-js.js"></script>

demos/webpack-app/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"dependencies": {
1717
"xstate": "^4.38.2",
1818
"sequential-workflow-model": "^0.2.0",
19-
"sequential-workflow-designer": "^0.21.1",
19+
"sequential-workflow-designer": "^0.21.2",
2020
"sequential-workflow-machine": "^0.4.0",
21-
"sequential-workflow-editor-model": "^0.12.1",
22-
"sequential-workflow-editor": "^0.12.1"
21+
"sequential-workflow-editor-model": "^0.13.0",
22+
"sequential-workflow-editor": "^0.13.0"
2323
},
2424
"devDependencies": {
2525
"ts-loader": "^9.4.2",

demos/webpack-app/src/editors/app.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export class App {
2727
rootEditorProvider: () => {
2828
const editor = document.createElement('div');
2929
editor.innerHTML =
30-
'This demo showcases all the supported editors by the Sequential Workflow Editor. <a href="https://github.com/nocode-js/sequential-workflow-editor">GitHub</a>';
30+
'This demo showcases all the supported editors by the <a href="https://github.com/nocode-js/sequential-workflow-editor">Sequential Workflow Editor</a>.<br /><br />' +
31+
'Start exploring by clicking on each step.';
3132
return editor;
3233
},
3334
stepEditorProvider: editorProvider.createStepEditorProvider()

demos/webpack-app/src/editors/model/any-variables-step-model.ts

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export interface AnyVariablesStepModel extends Step {
1111
}
1212

1313
export const anyVariablesStepModel = createStepModel<AnyVariablesStepModel>('anyVariables', 'task', step => {
14+
step.description('In this step, you can select a collection of variables of any type.');
15+
1416
step.property('zeroConfig').value(createAnyVariablesValueModel({}));
1517
step.property('onlyBoolean').value(
1618
createAnyVariablesValueModel({

demos/webpack-app/src/editors/model/boolean-step-model.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export interface BooleanStepModel extends Step {
1212
}
1313

1414
export const booleanStepModel = createStepModel<BooleanStepModel>('boolean', 'task', step => {
15+
step.description('This step demonstrates properties with boolean values.');
16+
1517
step.property('zeroConfig').value(createBooleanValueModel({}));
1618
step.property('defaultValueTrue').value(
1719
createBooleanValueModel({

demos/webpack-app/src/editors/model/choice-step-model.ts

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export interface ChoiceStepModel extends Step {
1111
}
1212

1313
export const choiceStepModel = createStepModel<ChoiceStepModel>('choice', 'task', step => {
14+
step.description('In this step, you can see properties that allow you to select a value from a predefined list.');
15+
1416
step.property('minimalConfig').value(createChoiceValueModel({ choices: ['red', 'blue', 'green'] }));
1517

1618
step.property('defaultValueAllow').value(

demos/webpack-app/src/editors/model/dynamic-step-model.ts

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export interface DynamicStepModel extends Step {
1919
}
2020

2121
export const dynamicStepModel = createStepModel<DynamicStepModel>('dynamic', 'task', step => {
22+
step.description(
23+
'This step has properties with dynamic values. For each property, you can change the value type by selecting the desired type.'
24+
);
25+
2226
step.property('example').value(
2327
createDynamicValueModel({
2428
models: [createStringValueModel({}), createBooleanValueModel({})]

demos/webpack-app/src/editors/model/generated-string-step-model.ts

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export interface GeneratedStringStepModel extends Step {
1111
}
1212

1313
export const generatedStringStepModel = createStepModel<GeneratedStringStepModel>('generatedString', 'task', step => {
14+
step.description(
15+
'This step has a property whose value is generated using data from another property. To see how it works, please change the value of the "X" property to 0, 1, 2, etc.'
16+
);
17+
1418
step.property('x').value(createNumberValueModel({}));
1519

1620
step.property('example')

editor/css/editor.css

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
.swe-editor > .swe-validation-error {
3030
margin: 0 10px;
3131
}
32+
.swe-hidden {
33+
display: none;
34+
}
3235

3336
/* properties */
3437

editor/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sequential-workflow-editor",
3-
"version": "0.12.1",
3+
"version": "0.13.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.12.1",
49+
"sequential-workflow-editor-model": "^0.13.0",
5050
"sequential-workflow-model": "^0.2.0"
5151
},
5252
"peerDependencies": {
53-
"sequential-workflow-editor-model": "^0.12.1",
53+
"sequential-workflow-editor-model": "^0.13.0",
5454
"sequential-workflow-model": "^0.2.0"
5555
},
5656
"devDependencies": {

editor/src/components/property-validation-error-component.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { validationErrorComponent } from './validation-error-component';
44

55
export interface PropertyValidationErrorComponent extends Component {
66
validate(): void;
7+
isHidden(): boolean;
78
}
89

910
export function propertyValidationErrorComponent(
@@ -21,6 +22,7 @@ export function propertyValidationErrorComponent(
2122

2223
return {
2324
view: validation.view,
24-
validate
25+
validate,
26+
isHidden: validation.isHidden
2527
};
2628
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { validationErrorComponent } from './validation-error-component';
2+
3+
describe('ValidationErrorComponent', () => {
4+
it('returns correct value for isHidden() and emits changes', () => {
5+
let emitted: boolean | null = null;
6+
const component = validationErrorComponent();
7+
component.onIsHiddenChanged.subscribe(v => (emitted = v));
8+
9+
// test 1
10+
expect(component.isHidden()).toBe(true);
11+
expect(component.view.children.length).toBe(0);
12+
expect(emitted).toBeNull();
13+
14+
// test 2
15+
emitted = null;
16+
component.setDefaultError({ $: 'Expected 2 characters' });
17+
18+
expect(component.isHidden()).toBe(false);
19+
expect(component.view.children.length).toBeGreaterThan(0);
20+
expect(emitted).toBe(false);
21+
22+
// test 3
23+
emitted = null;
24+
component.setDefaultError({ $: 'Expected 3 characters' });
25+
26+
expect(component.isHidden()).toBe(false);
27+
expect(component.view.children.length).toBeGreaterThan(0);
28+
expect(emitted).toBeNull(); // Visibility did not change
29+
30+
// test 4
31+
emitted = null;
32+
component.setDefaultError(null);
33+
34+
expect(component.isHidden()).toBe(true);
35+
expect(component.view.children.length).toBe(0);
36+
expect(emitted).toBe(true);
37+
});
38+
});

editor/src/components/validation-error-component.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { ValidationResult } from 'sequential-workflow-editor-model';
1+
import { SimpleEvent, ValidationResult } from 'sequential-workflow-editor-model';
22
import { Component } from './component';
33
import { Html } from '../core/html';
44

55
export interface ValidationErrorComponent extends Component {
6+
onIsHiddenChanged: SimpleEvent<boolean>;
7+
isHidden(): boolean;
68
setError(error: string | null): void;
79
setDefaultError(result: ValidationResult): void;
810
}
@@ -11,9 +13,16 @@ export function validationErrorComponent(): ValidationErrorComponent {
1113
const view = Html.element('div', {
1214
class: 'swe-validation-error'
1315
});
16+
const onIsHiddenChanged = new SimpleEvent<boolean>();
1417
let child: HTMLElement | null = null;
1518

19+
function isHidden() {
20+
return child === null;
21+
}
22+
1623
function setError(error: string | null) {
24+
const oldState = isHidden();
25+
1726
if (child) {
1827
view.removeChild(child);
1928
child = null;
@@ -25,14 +34,21 @@ export function validationErrorComponent(): ValidationErrorComponent {
2534
child.textContent = error;
2635
view.appendChild(child);
2736
}
37+
38+
const newState = isHidden();
39+
if (oldState !== newState) {
40+
onIsHiddenChanged.forward(newState);
41+
}
2842
}
2943

3044
function setDefaultError(result: ValidationResult) {
3145
setError(result && result['$']);
3246
}
3347

3448
return {
49+
onIsHiddenChanged,
3550
view,
51+
isHidden,
3652
setError,
3753
setDefaultError
3854
};

editor/src/core/html.spec.ts

+12
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,16 @@ describe('Html', () => {
2323

2424
expect(element.getAttribute('data-test')).toBe('555');
2525
});
26+
27+
it('toggles class', () => {
28+
const element = document.createElement('div');
29+
30+
Html.toggleClass(element, true, 'foo');
31+
32+
expect(element.classList.contains('foo')).toBe(true);
33+
34+
Html.toggleClass(element, false, 'foo');
35+
36+
expect(element.classList.contains('foo')).toBe(false);
37+
});
2638
});

editor/src/core/html.ts

+8
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,12 @@ export class Html {
1717
}
1818
return element;
1919
}
20+
21+
public static toggleClass(element: Element, isEnabled: boolean, className: string) {
22+
if (isEnabled) {
23+
element.classList.add(className);
24+
} else {
25+
element.classList.remove(className);
26+
}
27+
}
2028
}

editor/src/editor.ts

-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ export class Editor {
3232

3333
const editors = new Map<PropertyModel, PropertyEditor>();
3434
for (const propertyModel of propertyModels) {
35-
if (editorServices.valueEditorFactoryResolver.isHidden(propertyModel.value.id, propertyModel.value.editorId)) {
36-
continue;
37-
}
38-
3935
const propertyEditor = PropertyEditor.create(propertyModel, stepType, definitionContext, editorServices);
4036
root.appendChild(propertyEditor.view);
4137
editors.set(propertyModel, propertyEditor);

0 commit comments

Comments
 (0)