Skip to content

Commit ce40b6b

Browse files
authored
0.30.1. (#194)
1 parent 8f4fcfc commit ce40b6b

File tree

14 files changed

+96
-64
lines changed

14 files changed

+96
-64
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# 0.30.1
2+
3+
Added a configurable branch name resolver for the switch step component, allowing you to define custom logic for resolving branch names [#193](https://github.com/nocode-js/sequential-workflow-designer/issues/193).
4+
5+
```ts
6+
import { StepsDesignerExtension } from 'sequential-workflow-designer';
7+
8+
const extensions = [
9+
StepsDesignerExtension.create({
10+
switch: {
11+
branchNamesResolver: (step) => Object.keys(step.branches)
12+
}
13+
})
14+
];
15+
```
16+
117
# 0.30.0
218

319
This version introduces a new step component: `launchPad`.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ Add the below code to your head section in HTML document.
106106
```html
107107
<head>
108108
...
109-
<link href="https://cdn.jsdelivr.net/npm/[email protected].0/css/designer.css" rel="stylesheet">
110-
<link href="https://cdn.jsdelivr.net/npm/[email protected].0/css/designer-light.css" rel="stylesheet">
111-
<link href="https://cdn.jsdelivr.net/npm/[email protected].0/css/designer-dark.css" rel="stylesheet">
112-
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/index.umd.js"></script>
109+
<link href="https://cdn.jsdelivr.net/npm/[email protected].1/css/designer.css" rel="stylesheet">
110+
<link href="https://cdn.jsdelivr.net/npm/[email protected].1/css/designer-light.css" rel="stylesheet">
111+
<link href="https://cdn.jsdelivr.net/npm/[email protected].1/css/designer-dark.css" rel="stylesheet">
112+
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/index.umd.js"></script>
113113
```
114114

115115
Call the designer by:

angular/designer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sequential-workflow-designer-angular",
33
"description": "Angular wrapper for Sequential Workflow Designer component.",
4-
"version": "0.30.0",
4+
"version": "0.30.1",
55
"author": {
66
"name": "NoCode JS",
77
"url": "https://nocode-js.com/"
@@ -15,7 +15,7 @@
1515
"peerDependencies": {
1616
"@angular/common": "12 - 19",
1717
"@angular/core": "12 - 19",
18-
"sequential-workflow-designer": "^0.30.0"
18+
"sequential-workflow-designer": "^0.30.1"
1919
},
2020
"dependencies": {
2121
"tslib": "^2.3.0"

demos/angular-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"@angular/platform-browser-dynamic": "^17.3.9",
2727
"@angular/router": "^17.3.9",
2828
"rxjs": "~7.8.0",
29-
"sequential-workflow-designer": "^0.30.0",
30-
"sequential-workflow-designer-angular": "^0.30.0",
29+
"sequential-workflow-designer": "^0.30.1",
30+
"sequential-workflow-designer-angular": "^0.30.1",
3131
"tslib": "^2.3.0",
3232
"zone.js": "~0.14.6"
3333
},

demos/react-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"dependencies": {
77
"react": "^18.2.0",
88
"react-dom": "^18.2.0",
9-
"sequential-workflow-designer": "^0.30.0",
10-
"sequential-workflow-designer-react": "^0.30.0"
9+
"sequential-workflow-designer": "^0.30.1",
10+
"sequential-workflow-designer-react": "^0.30.1"
1111
},
1212
"devDependencies": {
1313
"@types/jest": "^29.2.5",

demos/svelte-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"eslint": "eslint ./src --ext .ts"
1717
},
1818
"dependencies": {
19-
"sequential-workflow-designer": "^0.30.0",
20-
"sequential-workflow-designer-svelte": "^0.30.0"
19+
"sequential-workflow-designer": "^0.30.1",
20+
"sequential-workflow-designer-svelte": "^0.30.1"
2121
},
2222
"devDependencies": {
2323
"@sveltejs/adapter-static": "^2.0.3",

designer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sequential-workflow-designer",
33
"description": "Customizable no-code component for building flow-based programming applications.",
4-
"version": "0.30.0",
4+
"version": "0.30.1",
55
"type": "module",
66
"main": "./lib/esm/index.js",
77
"types": "./lib/index.d.ts",

designer/src/workspace/switch-step/switch-step-component-view.spec.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,23 @@ describe('SwitchStepComponentView', () => {
3838
minWidth: 50,
3939
radius: 10
4040
};
41-
const factory = createSwitchStepComponentViewFactory({
42-
minBranchWidth: 40,
43-
paddingX: 20,
44-
paddingTop1: 0,
45-
paddingTop2: 20,
46-
connectionHeight: 16,
47-
noBranchPaddingBottom: 24,
48-
inputSize: 18,
49-
inputIconSize: 14,
50-
inputRadius: 4,
51-
autoHideInputOnDrag: true,
52-
branchNameLabel: labelViewCfg,
53-
nameLabel: labelViewCfg
54-
});
41+
const factory = createSwitchStepComponentViewFactory(
42+
{
43+
minBranchWidth: 40,
44+
paddingX: 20,
45+
paddingTop1: 0,
46+
paddingTop2: 20,
47+
connectionHeight: 16,
48+
noBranchPaddingBottom: 24,
49+
inputSize: 18,
50+
inputIconSize: 14,
51+
inputRadius: 4,
52+
autoHideInputOnDrag: true,
53+
branchNameLabel: labelViewCfg,
54+
nameLabel: labelViewCfg
55+
},
56+
undefined
57+
);
5558
factory(parent, stepContext, viewContext);
5659

5760
expect(parent.children.length).not.toEqual(0);

designer/src/workspace/switch-step/switch-step-component-view.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { InputView } from '../common-views/input-view';
77
import { ClickDetails, StepComponentView, ClickCommand, SequenceComponent } from '../component';
88
import { RegionView, StepComponentViewContext, StepComponentViewFactory, StepContext } from '../../designer-extension';
99
import { SwitchStepComponentViewConfiguration } from './switch-step-component-view-configuration';
10+
import { BranchNamesResolver } from './switch-step-extension-configuration';
1011

1112
const COMPONENT_CLASS_NAME = 'switch';
1213

@@ -57,15 +58,15 @@ function createView(
5758
}
5859

5960
export const createSwitchStepComponentViewFactory =
60-
(cfg: SwitchStepComponentViewConfiguration): StepComponentViewFactory =>
61+
(cfg: SwitchStepComponentViewConfiguration, branchNameResolver: BranchNamesResolver | undefined): StepComponentViewFactory =>
6162
(parent: SVGElement, stepContext: StepContext<BranchedStep>, viewContext: StepComponentViewContext): StepComponentView => {
6263
return viewContext.createRegionComponentView(parent, COMPONENT_CLASS_NAME, (g, regionViewBuilder) => {
6364
const step = stepContext.step;
6465
const paddingTop = cfg.paddingTop1 + cfg.paddingTop2;
6566

6667
const name = viewContext.getStepName();
6768
const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary');
68-
const branchNames = Object.keys(step.branches);
69+
const branchNames = branchNameResolver ? branchNameResolver(step) : Object.keys(step.branches);
6970

7071
if (branchNames.length === 0) {
7172
const width = Math.max(nameLabelView.width, cfg.minBranchWidth) + cfg.paddingX * 2;
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
import { BranchedStep } from 'sequential-workflow-model';
12
import { SwitchStepComponentViewConfiguration } from './switch-step-component-view-configuration';
23

4+
export type BranchNamesResolver = (step: BranchedStep) => string[];
5+
36
export interface SwitchStepExtensionConfiguration {
4-
view: SwitchStepComponentViewConfiguration;
7+
view?: SwitchStepComponentViewConfiguration;
8+
9+
/**
10+
* A function that takes a `BranchedStep` and returns an array of branch names.
11+
* If not provided, the default is: `Object.keys(step.branches)`.
12+
* You can use this to provide custom ordering or filtering of branch names.
13+
*/
14+
branchNamesResolver?: BranchNamesResolver;
515
}

0 commit comments

Comments
 (0)