sequential-workflow-designer 0.37.0 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -106,10 +106,10 @@ Add the below code to your head section in HTML document.
106
106
  ```html
107
107
  <head>
108
108
  ...
109
- <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.37.0/css/designer.css" rel="stylesheet" />
110
- <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.37.0/css/designer-light.css" rel="stylesheet" />
111
- <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.37.0/css/designer-dark.css" rel="stylesheet" />
112
- <script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.37.0/dist/index.umd.js"></script>
109
+ <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.37.1/css/designer.css" rel="stylesheet" />
110
+ <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.37.1/css/designer-light.css" rel="stylesheet" />
111
+ <link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.37.1/css/designer-dark.css" rel="stylesheet" />
112
+ <script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.37.1/dist/index.umd.js"></script>
113
113
  </head>
114
114
  ```
115
115
 
package/dist/index.umd.js CHANGED
@@ -1891,7 +1891,7 @@
1891
1891
  }
1892
1892
  };
1893
1893
  }
1894
- const createSwitchStepComponentViewFactory = (cfg, branchNameResolver) => (parent, stepContext, viewContext) => {
1894
+ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver, branchNameLabelResolver) => (parent, stepContext, viewContext) => {
1895
1895
  return viewContext.createRegionComponentView(parent, COMPONENT_CLASS_NAME$1, (g, regionViewBuilder) => {
1896
1896
  const step = stepContext.step;
1897
1897
  const paddingTop = cfg.paddingTop1 + cfg.paddingTop2;
@@ -1914,9 +1914,10 @@
1914
1914
  let totalBranchesWidth = 0;
1915
1915
  let maxBranchesHeight = 0;
1916
1916
  branchNames.forEach((branchName, i) => {
1917
+ const label = branchNameLabelResolver ? branchNameLabelResolver(branchName, step) : branchName;
1918
+ const translatedLabel = viewContext.i18n(`stepComponent.${step.type}.branchName`, label);
1917
1919
  const labelY = paddingTop + cfg.nameLabel.height + cfg.connectionHeight;
1918
- const translatedBranchName = viewContext.i18n(`stepComponent.${step.type}.branchName`, branchName);
1919
- const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedBranchName, 'secondary');
1920
+ const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary');
1920
1921
  const component = viewContext.createSequenceComponent(g, step.branches[branchName]);
1921
1922
  const halfOfWidestBranchElement = Math.max(labelView.width, cfg.minBranchWidth) / 2;
1922
1923
  const branchOffsetLeft = Math.max(halfOfWidestBranchElement - component.view.joinX, 0) + cfg.paddingX;
@@ -2594,10 +2595,10 @@
2594
2595
  return new SwitchStepExtension(configuration);
2595
2596
  }
2596
2597
  constructor(configuration) {
2597
- var _a, _b, _c, _d, _e;
2598
+ var _a, _b, _c, _d, _e, _f;
2598
2599
  this.configuration = configuration;
2599
2600
  this.componentType = (_b = (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.componentType) !== null && _b !== void 0 ? _b : 'switch';
2600
- this.createComponentView = createSwitchStepComponentViewFactory((_d = (_c = this.configuration) === null || _c === void 0 ? void 0 : _c.view) !== null && _d !== void 0 ? _d : defaultViewConfiguration$2, (_e = this.configuration) === null || _e === void 0 ? void 0 : _e.branchNamesResolver);
2601
+ this.createComponentView = createSwitchStepComponentViewFactory((_d = (_c = this.configuration) === null || _c === void 0 ? void 0 : _c.view) !== null && _d !== void 0 ? _d : defaultViewConfiguration$2, (_e = this.configuration) === null || _e === void 0 ? void 0 : _e.branchNamesResolver, (_f = this.configuration) === null || _f === void 0 ? void 0 : _f.branchNameLabelResolver);
2601
2602
  }
2602
2603
  }
2603
2604
 
package/lib/cjs/index.cjs CHANGED
@@ -1706,7 +1706,7 @@ function createView(g, width, height, joinX, viewContext, sequenceComponents, la
1706
1706
  }
1707
1707
  };
1708
1708
  }
1709
- const createSwitchStepComponentViewFactory = (cfg, branchNameResolver) => (parent, stepContext, viewContext) => {
1709
+ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver, branchNameLabelResolver) => (parent, stepContext, viewContext) => {
1710
1710
  return viewContext.createRegionComponentView(parent, COMPONENT_CLASS_NAME$1, (g, regionViewBuilder) => {
1711
1711
  const step = stepContext.step;
1712
1712
  const paddingTop = cfg.paddingTop1 + cfg.paddingTop2;
@@ -1729,9 +1729,10 @@ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver) => (paren
1729
1729
  let totalBranchesWidth = 0;
1730
1730
  let maxBranchesHeight = 0;
1731
1731
  branchNames.forEach((branchName, i) => {
1732
+ const label = branchNameLabelResolver ? branchNameLabelResolver(branchName, step) : branchName;
1733
+ const translatedLabel = viewContext.i18n(`stepComponent.${step.type}.branchName`, label);
1732
1734
  const labelY = paddingTop + cfg.nameLabel.height + cfg.connectionHeight;
1733
- const translatedBranchName = viewContext.i18n(`stepComponent.${step.type}.branchName`, branchName);
1734
- const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedBranchName, 'secondary');
1735
+ const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary');
1735
1736
  const component = viewContext.createSequenceComponent(g, step.branches[branchName]);
1736
1737
  const halfOfWidestBranchElement = Math.max(labelView.width, cfg.minBranchWidth) / 2;
1737
1738
  const branchOffsetLeft = Math.max(halfOfWidestBranchElement - component.view.joinX, 0) + cfg.paddingX;
@@ -2409,10 +2410,10 @@ class SwitchStepExtension {
2409
2410
  return new SwitchStepExtension(configuration);
2410
2411
  }
2411
2412
  constructor(configuration) {
2412
- var _a, _b, _c, _d, _e;
2413
+ var _a, _b, _c, _d, _e, _f;
2413
2414
  this.configuration = configuration;
2414
2415
  this.componentType = (_b = (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.componentType) !== null && _b !== void 0 ? _b : 'switch';
2415
- this.createComponentView = createSwitchStepComponentViewFactory((_d = (_c = this.configuration) === null || _c === void 0 ? void 0 : _c.view) !== null && _d !== void 0 ? _d : defaultViewConfiguration$2, (_e = this.configuration) === null || _e === void 0 ? void 0 : _e.branchNamesResolver);
2416
+ this.createComponentView = createSwitchStepComponentViewFactory((_d = (_c = this.configuration) === null || _c === void 0 ? void 0 : _c.view) !== null && _d !== void 0 ? _d : defaultViewConfiguration$2, (_e = this.configuration) === null || _e === void 0 ? void 0 : _e.branchNamesResolver, (_f = this.configuration) === null || _f === void 0 ? void 0 : _f.branchNameLabelResolver);
2416
2417
  }
2417
2418
  }
2418
2419
 
package/lib/esm/index.js CHANGED
@@ -1705,7 +1705,7 @@ function createView(g, width, height, joinX, viewContext, sequenceComponents, la
1705
1705
  }
1706
1706
  };
1707
1707
  }
1708
- const createSwitchStepComponentViewFactory = (cfg, branchNameResolver) => (parent, stepContext, viewContext) => {
1708
+ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver, branchNameLabelResolver) => (parent, stepContext, viewContext) => {
1709
1709
  return viewContext.createRegionComponentView(parent, COMPONENT_CLASS_NAME$1, (g, regionViewBuilder) => {
1710
1710
  const step = stepContext.step;
1711
1711
  const paddingTop = cfg.paddingTop1 + cfg.paddingTop2;
@@ -1728,9 +1728,10 @@ const createSwitchStepComponentViewFactory = (cfg, branchNameResolver) => (paren
1728
1728
  let totalBranchesWidth = 0;
1729
1729
  let maxBranchesHeight = 0;
1730
1730
  branchNames.forEach((branchName, i) => {
1731
+ const label = branchNameLabelResolver ? branchNameLabelResolver(branchName, step) : branchName;
1732
+ const translatedLabel = viewContext.i18n(`stepComponent.${step.type}.branchName`, label);
1731
1733
  const labelY = paddingTop + cfg.nameLabel.height + cfg.connectionHeight;
1732
- const translatedBranchName = viewContext.i18n(`stepComponent.${step.type}.branchName`, branchName);
1733
- const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedBranchName, 'secondary');
1734
+ const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedLabel, 'secondary');
1734
1735
  const component = viewContext.createSequenceComponent(g, step.branches[branchName]);
1735
1736
  const halfOfWidestBranchElement = Math.max(labelView.width, cfg.minBranchWidth) / 2;
1736
1737
  const branchOffsetLeft = Math.max(halfOfWidestBranchElement - component.view.joinX, 0) + cfg.paddingX;
@@ -2408,10 +2409,10 @@ class SwitchStepExtension {
2408
2409
  return new SwitchStepExtension(configuration);
2409
2410
  }
2410
2411
  constructor(configuration) {
2411
- var _a, _b, _c, _d, _e;
2412
+ var _a, _b, _c, _d, _e, _f;
2412
2413
  this.configuration = configuration;
2413
2414
  this.componentType = (_b = (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.componentType) !== null && _b !== void 0 ? _b : 'switch';
2414
- this.createComponentView = createSwitchStepComponentViewFactory((_d = (_c = this.configuration) === null || _c === void 0 ? void 0 : _c.view) !== null && _d !== void 0 ? _d : defaultViewConfiguration$2, (_e = this.configuration) === null || _e === void 0 ? void 0 : _e.branchNamesResolver);
2415
+ this.createComponentView = createSwitchStepComponentViewFactory((_d = (_c = this.configuration) === null || _c === void 0 ? void 0 : _c.view) !== null && _d !== void 0 ? _d : defaultViewConfiguration$2, (_e = this.configuration) === null || _e === void 0 ? void 0 : _e.branchNamesResolver, (_f = this.configuration) === null || _f === void 0 ? void 0 : _f.branchNameLabelResolver);
2415
2416
  }
2416
2417
  }
2417
2418
 
package/lib/index.d.ts CHANGED
@@ -721,6 +721,7 @@ interface SwitchStepComponentViewConfiguration {
721
721
  }
722
722
 
723
723
  type BranchNamesResolver = (step: BranchedStep) => string[];
724
+ type BranchNameLabelResolver = (branchName: string, step: Step) => string;
724
725
  interface SwitchStepExtensionConfiguration {
725
726
  componentType?: string;
726
727
  view?: SwitchStepComponentViewConfiguration;
@@ -730,9 +731,15 @@ interface SwitchStepExtensionConfiguration {
730
731
  * You can use this to provide custom ordering or filtering of branch names.
731
732
  */
732
733
  branchNamesResolver?: BranchNamesResolver;
734
+ /**
735
+ * A function that takes a branch name and a step, and returns the label to display for that branch.
736
+ * If not provided, the branch name itself will be used as the label.
737
+ * Before rendering, the label is translated using the i18n callback.
738
+ */
739
+ branchNameLabelResolver?: BranchNameLabelResolver;
733
740
  }
734
741
 
735
- declare const createSwitchStepComponentViewFactory: (cfg: SwitchStepComponentViewConfiguration, branchNameResolver: BranchNamesResolver | undefined) => StepComponentViewFactory;
742
+ declare const createSwitchStepComponentViewFactory: (cfg: SwitchStepComponentViewConfiguration, branchNameResolver: BranchNamesResolver | undefined, branchNameLabelResolver: BranchNameLabelResolver | undefined) => StepComponentViewFactory;
736
743
 
737
744
  interface TaskStepComponentViewConfiguration {
738
745
  paddingLeft: number;
@@ -1487,4 +1494,4 @@ declare class Designer<TDefinition extends Definition = Definition> {
1487
1494
  }
1488
1495
 
1489
1496
  export { Badges, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickCommandType, ComponentContext, ComponentDom, ControlBarApi, CustomActionController, DefaultRegionComponentViewExtension, DefaultRegionView, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerDesignerExtension, DefaultViewportControllerExtension, DefinitionChangeType, Designer, DesignerApi, DesignerContext, DesignerState, Dom, Editor, EditorApi, Icons, InputView, JoinView, KeyboardAction, LabelView, LineGridDesignerExtension, ObjectCloner, OutputView, PathBarApi, PlaceholderController, PlaceholderDirection, PlaceholderGapOrientation, RectPlaceholder, RectPlaceholderDesignerExtension, RectPlaceholderView, SelectStepBehaviorEndToken, ServicesResolver, SimpleEvent, StartStopRootComponentDesignerExtension, StartStopRootComponentExtension, StepComponent, StepExtensionResolver, StepsDesignerExtension, TYPE, ToolboxApi, Uid, ValidationErrorBadgeExtension, Vector, ViewportApi, WorkspaceApi, createContainerStepComponentViewFactory, createLaunchPadStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, getAbsolutePosition, race };
1490
- export type { Attributes, Badge, BadgeExtension, BadgeView, BadgesDecorator, BadgesResult, BaseClickCommand, Behavior, BehaviorEndToken, BranchNamesResolver, ClickBehaviorWrapper, ClickBehaviorWrapperExtension, ClickCommand, ClickDetails, Component, ComponentView, ContainerStepComponentViewConfiguration, ContainerStepExtensionConfiguration, ContextMenuExtension, ContextMenuItem, ContextMenuItemsProvider, CustomAction, CustomActionHandler, CustomActionHandlerContext, Daemon, DaemonExtension, DefaultViewportControllerConfiguration, DefaultViewportControllerExtensionConfiguration, DefinitionChangedEvent, DefinitionChangedEventDetails, DesignerConfiguration, DesignerExtension, DraggedComponent, DraggedComponentExtension, DuplicatedStepId, EditorsConfiguration, FoundPlaceholders, Grid, GridExtension, I18n, KeyboardConfiguration, LaunchPadStepComponentViewConfiguration, LaunchPadStepExtensionConfiguration, LineGridConfiguration, NextScale, OpenFolderClickCommand, Placeholder, PlaceholderConfiguration, PlaceholderExtension, PlaceholderView, PreferenceChange, PreferenceStorage, PreferencesChangedEvent, RectPlaceholderConfiguration, RegionComponentViewContentFactory, RegionComponentViewExtension, RegionView, RegionViewFactory, RootComponentExtension, RootEditorContext, RootEditorProvider, RootValidator, SelectStepClickCommand, SelectedStepIdProvider, SequenceComponent, SequenceComponentExtension, SequenceContext, SequencePlaceIndicator, Services, SetPreferencesClickCommand, SimpleEventListener, StartStopRootComponentExtensionConfiguration, StartStopRootComponentViewConfiguration, StateModifierDependency, StepBadgesDecoratorExtension, StepComponentView, StepComponentViewContext, StepComponentViewFactory, StepComponentViewWrapperExtension, StepContext, StepDefinition, StepDescriptionProvider, StepEditorContext, StepEditorProvider, StepExtension, StepIconUrlProvider, StepLabelProvider, StepValidator, StepsConfiguration, StepsDesignerExtensionConfiguration, SwitchStepComponentViewConfiguration, SwitchStepExtensionConfiguration, TaskStepComponentViewConfiguration, TaskStepExtensionConfiguration, ToolboxConfiguration, ToolboxGroupConfiguration, TriggerCustomActionClickCommand, UiComponent, UiComponentExtension, UidGenerator, UndoStack, UndoStackItem, ValidationErrorBadgeExtensionConfiguration, ValidationErrorBadgeViewConfiguration, ValidatorConfiguration, Viewport, ViewportController, ViewportControllerExtension, WheelController, WheelControllerExtension, WorkspaceRootSequence };
1497
+ export type { Attributes, Badge, BadgeExtension, BadgeView, BadgesDecorator, BadgesResult, BaseClickCommand, Behavior, BehaviorEndToken, BranchNameLabelResolver, BranchNamesResolver, ClickBehaviorWrapper, ClickBehaviorWrapperExtension, ClickCommand, ClickDetails, Component, ComponentView, ContainerStepComponentViewConfiguration, ContainerStepExtensionConfiguration, ContextMenuExtension, ContextMenuItem, ContextMenuItemsProvider, CustomAction, CustomActionHandler, CustomActionHandlerContext, Daemon, DaemonExtension, DefaultViewportControllerConfiguration, DefaultViewportControllerExtensionConfiguration, DefinitionChangedEvent, DefinitionChangedEventDetails, DesignerConfiguration, DesignerExtension, DraggedComponent, DraggedComponentExtension, DuplicatedStepId, EditorsConfiguration, FoundPlaceholders, Grid, GridExtension, I18n, KeyboardConfiguration, LaunchPadStepComponentViewConfiguration, LaunchPadStepExtensionConfiguration, LineGridConfiguration, NextScale, OpenFolderClickCommand, Placeholder, PlaceholderConfiguration, PlaceholderExtension, PlaceholderView, PreferenceChange, PreferenceStorage, PreferencesChangedEvent, RectPlaceholderConfiguration, RegionComponentViewContentFactory, RegionComponentViewExtension, RegionView, RegionViewFactory, RootComponentExtension, RootEditorContext, RootEditorProvider, RootValidator, SelectStepClickCommand, SelectedStepIdProvider, SequenceComponent, SequenceComponentExtension, SequenceContext, SequencePlaceIndicator, Services, SetPreferencesClickCommand, SimpleEventListener, StartStopRootComponentExtensionConfiguration, StartStopRootComponentViewConfiguration, StateModifierDependency, StepBadgesDecoratorExtension, StepComponentView, StepComponentViewContext, StepComponentViewFactory, StepComponentViewWrapperExtension, StepContext, StepDefinition, StepDescriptionProvider, StepEditorContext, StepEditorProvider, StepExtension, StepIconUrlProvider, StepLabelProvider, StepValidator, StepsConfiguration, StepsDesignerExtensionConfiguration, SwitchStepComponentViewConfiguration, SwitchStepExtensionConfiguration, TaskStepComponentViewConfiguration, TaskStepExtensionConfiguration, ToolboxConfiguration, ToolboxGroupConfiguration, TriggerCustomActionClickCommand, UiComponent, UiComponentExtension, UidGenerator, UndoStack, UndoStackItem, ValidationErrorBadgeExtensionConfiguration, ValidationErrorBadgeViewConfiguration, ValidatorConfiguration, Viewport, ViewportController, ViewportControllerExtension, WheelController, WheelControllerExtension, WorkspaceRootSequence };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sequential-workflow-designer",
3
3
  "description": "Customizable no-code component for building flow-based programming applications.",
4
- "version": "0.37.0",
4
+ "version": "0.37.1",
5
5
  "type": "module",
6
6
  "main": "./lib/esm/index.js",
7
7
  "types": "./lib/index.d.ts",