Skip to content

Commit 36795f9

Browse files
authored
0.14.7. (#52)
1 parent 9836556 commit 36795f9

File tree

7 files changed

+25
-13
lines changed

7 files changed

+25
-13
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## O.14.7
2+
3+
Added an `index` argument to the `itemComponentFactory` callback in the `dynamicListComponent` function.
4+
15
## O.14.6
26

37
Added comments to describe the `BranchedStepModelBuilder`, `SequentialStepModelBuilder` and `RootModelBuilder` classes.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Pro:
2222

2323
* [📖 Pro Editors](https://nocode-js.com/examples/sequential-workflow-editor-pro/webpack-pro-app/public/editors.html)
2424
* [📫 Template System](https://nocode-js.com/examples/sequential-workflow-editor-pro/webpack-pro-app/public/template-system.html)
25+
* [🎱 Dynamic Variables](https://nocode-js.com/examples/sequential-workflow-editor-pro/webpack-pro-app/public/dynamic-variables.html)
2526

2627
## 🚀 Installation
2728

demos/webpack-app/package.json

+2-2
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.6",
22-
"sequential-workflow-editor": "^0.14.6"
21+
"sequential-workflow-editor-model": "^0.14.7",
22+
"sequential-workflow-editor": "^0.14.7"
2323
},
2424
"devDependencies": {
2525
"ts-loader": "^9.4.2",

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

editor/src/components/dynamic-list-component.spec.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
import { SimpleEvent, ValueContext } from 'sequential-workflow-editor-model';
1+
import { I18n, SimpleEvent, ValueContext } from 'sequential-workflow-editor-model';
22
import { Html } from '../core/html';
33
import { dynamicListComponent } from './dynamic-list-component';
44

55
interface TestItem {
66
id: number;
77
}
88

9-
function testItemComponentFactory(item: TestItem) {
9+
function testItemComponentFactory(item: TestItem, _: I18n, index: number) {
10+
const view = Html.element('span', {
11+
class: `test-item-${item.id}`
12+
});
13+
view.setAttribute('data-index', String(index));
1014
return {
11-
view: Html.element('span', {
12-
class: `test-item-${item.id}`
13-
}),
15+
view,
1416
onItemChanged: new SimpleEvent<TestItem>(),
1517
onDeleteClicked: new SimpleEvent<void>(),
1618
validate: () => {
@@ -32,7 +34,9 @@ describe('DynamicListComponent', () => {
3234

3335
expect(children.length).toBe(3);
3436
expect(children[0].className).toBe('test-item-123');
37+
expect(children[0].getAttribute('data-index')).toBe('0');
3538
expect(children[1].className).toBe('test-item-456');
39+
expect(children[1].getAttribute('data-index')).toBe('1');
3640
expect(children[2].className).toBe('swe-validation-error');
3741
});
3842

@@ -47,13 +51,16 @@ describe('DynamicListComponent', () => {
4751

4852
expect(children.length).toBe(2);
4953
expect(children[0].className).toBe('test-item-135');
54+
expect(children[0].getAttribute('data-index')).toBe('0');
5055
expect(children[1].className).toBe('swe-validation-error');
5156

5257
component.add({ id: 246 });
5358

5459
expect(children.length).toBe(3);
5560
expect(children[0].className).toBe('test-item-135');
61+
expect(children[0].getAttribute('data-index')).toBe('0');
5662
expect(children[1].className).toBe('test-item-246');
63+
expect(children[1].getAttribute('data-index')).toBe('1');
5764
expect(children[2].className).toBe('swe-validation-error');
5865
});
5966

editor/src/components/dynamic-list-component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface DynamicListItemComponent<TItem> extends Component {
2323

2424
export function dynamicListComponent<TItem, TItemComponent extends DynamicListItemComponent<TItem> = DynamicListItemComponent<TItem>>(
2525
initialItems: TItem[],
26-
itemComponentFactory: (item: TItem, i18n: I18n) => TItemComponent,
26+
itemComponentFactory: (item: TItem, i18n: I18n, index: number) => TItemComponent,
2727
context: ValueContext,
2828
configuration?: DynamicListComponentConfiguration<TItem>
2929
): DynamicListComponent<TItem, TItemComponent> {
@@ -74,7 +74,7 @@ export function dynamicListComponent<TItem, TItemComponent extends DynamicListIt
7474

7575
if (items.length > 0) {
7676
items.forEach((item, index) => {
77-
const component = itemComponentFactory(item, context.i18n);
77+
const component = itemComponentFactory(item, context.i18n, index);
7878
component.onItemChanged.subscribe(item => onItemChanged(item, index));
7979
component.onDeleteClicked.subscribe(() => onItemDeleted(index));
8080
view.insertBefore(component.view, validation.view);

model/package.json

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

0 commit comments

Comments
 (0)