sequential-workflow-designer 0.19.3 → 0.20.0

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/lib/esm/index.js CHANGED
@@ -599,13 +599,15 @@ class StepTypeValidator {
599
599
  }
600
600
 
601
601
  class ToolboxDataProvider {
602
- constructor(iconProvider, configuration) {
602
+ constructor(iconProvider, i18n, configuration) {
603
603
  this.iconProvider = iconProvider;
604
+ this.i18n = i18n;
604
605
  this.configuration = configuration;
605
606
  this.createItemData = (step) => {
606
607
  StepTypeValidator.validate(step.type);
607
608
  const iconUrl = this.iconProvider.getIconUrl(step);
608
- const label = this.configuration && this.configuration.labelProvider ? this.configuration.labelProvider(step) : step.name;
609
+ const rawLabel = this.configuration && this.configuration.labelProvider ? this.configuration.labelProvider(step) : step.name;
610
+ const label = this.i18n(`toolbox.item.${step.type}.label`, rawLabel);
609
611
  const description = this.configuration && this.configuration.descriptionProvider ? this.configuration.descriptionProvider(step) : label;
610
612
  const lowerCaseLabel = label.toLowerCase();
611
613
  return {
@@ -703,10 +705,10 @@ class DesignerApi {
703
705
  const workspace = new WorkspaceApi(context.state, context.workspaceController);
704
706
  const viewportController = context.services.viewportController.create(workspace);
705
707
  const viewport = new ViewportApi(context.workspaceController, viewportController);
706
- const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.configuration.toolbox);
707
- return new DesignerApi(ControlBarApi.create(context.state, context.historyController, context.stateModifier, viewport), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, viewport, new PathBarApi(context.state, context.definitionWalker), context.definitionWalker);
708
+ const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
709
+ return new DesignerApi(ControlBarApi.create(context.state, context.historyController, context.stateModifier, viewport), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, viewport, new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
708
710
  }
709
- constructor(controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker) {
711
+ constructor(controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
710
712
  this.controlBar = controlBar;
711
713
  this.toolbox = toolbox;
712
714
  this.editor = editor;
@@ -714,6 +716,7 @@ class DesignerApi {
714
716
  this.viewport = viewport;
715
717
  this.pathBar = pathBar;
716
718
  this.definitionWalker = definitionWalker;
719
+ this.i18n = i18n;
717
720
  }
718
721
  }
719
722
 
@@ -916,6 +919,7 @@ class StepComponentViewContextFactory {
916
919
  static create(stepContext, componentContext) {
917
920
  return {
918
921
  getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
922
+ getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
919
923
  createSequenceComponent: (parentElement, sequence) => {
920
924
  const sequenceContext = {
921
925
  sequence,
@@ -925,7 +929,8 @@ class StepComponentViewContextFactory {
925
929
  };
926
930
  return componentContext.services.sequenceComponent.create(parentElement, sequenceContext, componentContext);
927
931
  },
928
- createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder)
932
+ createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
933
+ i18n: componentContext.i18n
929
934
  };
930
935
  }
931
936
  }
@@ -944,18 +949,19 @@ class StepComponentFactory {
944
949
  }
945
950
 
946
951
  class ComponentContext {
947
- static create(stepsConfiguration, validatorConfiguration, state, stepExtensionResolver, services) {
952
+ static create(stepsConfiguration, validatorConfiguration, state, stepExtensionResolver, i18n, services) {
948
953
  const validator = new DefinitionValidator(validatorConfiguration, state);
949
954
  const iconProvider = new IconProvider(stepsConfiguration);
950
955
  const placeholderController = services.placeholderController.create();
951
956
  const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
952
- return new ComponentContext(validator, iconProvider, placeholderController, stepComponentFactory, services);
957
+ return new ComponentContext(validator, iconProvider, placeholderController, stepComponentFactory, i18n, services);
953
958
  }
954
- constructor(validator, iconProvider, placeholderController, stepComponentFactory, services) {
959
+ constructor(validator, iconProvider, placeholderController, stepComponentFactory, i18n, services) {
955
960
  this.validator = validator;
956
961
  this.iconProvider = iconProvider;
957
962
  this.placeholderController = placeholderController;
958
963
  this.stepComponentFactory = stepComponentFactory;
964
+ this.i18n = i18n;
959
965
  this.services = services;
960
966
  }
961
967
  }
@@ -1137,6 +1143,15 @@ class ValidationErrorBadgeExtension {
1137
1143
  }
1138
1144
  }
1139
1145
 
1146
+ class ComponentDom {
1147
+ static stepG(componentClassName, type, id) {
1148
+ return Dom.svg('g', {
1149
+ class: `sqd-step-${componentClassName} sqd-type-${type}`,
1150
+ 'data-step-id': id
1151
+ });
1152
+ }
1153
+ }
1154
+
1140
1155
  class InputView {
1141
1156
  static createRectInput(parent, x, y, size, iconSize, iconUrl) {
1142
1157
  const g = Dom.svg('g');
@@ -1342,43 +1357,6 @@ function drawLine(parent, x1, y1, x2, y2) {
1342
1357
  return line;
1343
1358
  }
1344
1359
 
1345
- class RectPlaceholderView {
1346
- static create(parent, width, height, radius, iconSize, direction) {
1347
- const g = Dom.svg('g', {
1348
- visibility: 'hidden',
1349
- class: 'sqd-placeholder'
1350
- });
1351
- parent.appendChild(g);
1352
- const rect = Dom.svg('rect', {
1353
- class: 'sqd-placeholder-rect',
1354
- width,
1355
- height,
1356
- rx: radius,
1357
- ry: radius
1358
- });
1359
- g.appendChild(rect);
1360
- if (direction) {
1361
- const iconD = direction === PlaceholderDirection.in ? Icons.folderIn : Icons.folderOut;
1362
- const icon = Icons.appendPath(g, 'sqd-placeholder-icon-path', iconD, iconSize);
1363
- Dom.translate(icon, (width - iconSize) / 2, (height - iconSize) / 2);
1364
- }
1365
- parent.appendChild(g);
1366
- return new RectPlaceholderView(rect, g);
1367
- }
1368
- constructor(rect, g) {
1369
- this.rect = rect;
1370
- this.g = g;
1371
- }
1372
- setIsHover(isHover) {
1373
- Dom.toggleClass(this.g, isHover, 'sqd-hover');
1374
- }
1375
- setIsVisible(isVisible) {
1376
- Dom.attrs(this.g, {
1377
- visibility: isVisible ? 'visible' : 'hidden'
1378
- });
1379
- }
1380
- }
1381
-
1382
1360
  class DefaultSequenceComponentView {
1383
1361
  static create(parent, sequenceContext, componentContext) {
1384
1362
  const phWidth = componentContext.services.placeholder.gapSize.x;
@@ -1507,11 +1485,10 @@ class DefaultSequenceComponent {
1507
1485
 
1508
1486
  const createContainerStepComponentViewFactory = (cfg) => (parentElement, stepContext, viewContext) => {
1509
1487
  const { step } = stepContext;
1510
- const g = Dom.svg('g', {
1511
- class: `sqd-step-container sqd-type-${step.type}`
1512
- });
1488
+ const g = ComponentDom.stepG('container', step.type, step.id);
1513
1489
  parentElement.appendChild(g);
1514
- const labelView = LabelView.create(g, cfg.paddingTop, cfg.label, step.name, 'primary');
1490
+ const name = viewContext.getStepName();
1491
+ const labelView = LabelView.create(g, cfg.paddingTop, cfg.label, name, 'primary');
1515
1492
  const sequenceComponent = viewContext.createSequenceComponent(g, step.sequence);
1516
1493
  const halfOfWidestElement = labelView.width / 2;
1517
1494
  const offsetLeft = Math.max(halfOfWidestElement - sequenceComponent.view.joinX, 0) + cfg.paddingX;
@@ -1555,9 +1532,7 @@ const createContainerStepComponentViewFactory = (cfg) => (parentElement, stepCon
1555
1532
 
1556
1533
  const createSwitchStepComponentViewFactory = (cfg) => (parent, stepContext, viewContext) => {
1557
1534
  const { step } = stepContext;
1558
- const g = Dom.svg('g', {
1559
- class: `sqd-step-switch sqd-type-${step.type}`
1560
- });
1535
+ const g = ComponentDom.stepG('switch', step.type, step.id);
1561
1536
  parent.appendChild(g);
1562
1537
  const branchNames = Object.keys(step.branches);
1563
1538
  const branchComponents = branchNames.map(branchName => {
@@ -1565,9 +1540,11 @@ const createSwitchStepComponentViewFactory = (cfg) => (parent, stepContext, view
1565
1540
  });
1566
1541
  const branchLabelViews = branchNames.map(branchName => {
1567
1542
  const labelY = cfg.paddingTop + cfg.nameLabel.height + cfg.connectionHeight;
1568
- return LabelView.create(g, labelY, cfg.branchNameLabel, branchName, 'secondary');
1543
+ const translatedBranchName = viewContext.i18n(`stepComponent.${step.type}.branchName`, branchName);
1544
+ return LabelView.create(g, labelY, cfg.branchNameLabel, translatedBranchName, 'secondary');
1569
1545
  });
1570
- const nameLabelView = LabelView.create(g, cfg.paddingTop, cfg.nameLabel, step.name, 'primary');
1546
+ const name = viewContext.getStepName();
1547
+ const nameLabelView = LabelView.create(g, cfg.paddingTop, cfg.nameLabel, name, 'primary');
1571
1548
  let prevOffsetX = 0;
1572
1549
  const branchSizes = branchComponents.map((component, i) => {
1573
1550
  const halfOfWidestBranchElement = Math.max(branchLabelViews[i].width, cfg.minContainerWidth) / 2;
@@ -1658,9 +1635,7 @@ const createSwitchStepComponentViewFactory = (cfg) => (parent, stepContext, view
1658
1635
 
1659
1636
  const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElement, stepContext, viewContext) => {
1660
1637
  const { step } = stepContext;
1661
- const g = Dom.svg('g', {
1662
- class: `sqd-step-task sqd-type-${step.type}`
1663
- });
1638
+ const g = ComponentDom.stepG('task', step.type, step.id);
1664
1639
  parentElement.appendChild(g);
1665
1640
  const boxHeight = cfg.paddingY * 2 + cfg.iconSize;
1666
1641
  const text = Dom.svg('text', {
@@ -1668,7 +1643,7 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
1668
1643
  y: boxHeight / 2,
1669
1644
  class: 'sqd-step-task-text'
1670
1645
  });
1671
- text.textContent = step.name;
1646
+ text.textContent = viewContext.getStepName();
1672
1647
  g.appendChild(text);
1673
1648
  const textWidth = Math.max(text.getBBox().width, cfg.minTextWidth);
1674
1649
  const boxWidth = cfg.iconSize + cfg.paddingLeft + cfg.paddingRight + cfg.textMarginLeft + textWidth;
@@ -1940,6 +1915,43 @@ class StepExtensionResolver {
1940
1915
  }
1941
1916
  }
1942
1917
 
1918
+ class RectPlaceholderView {
1919
+ static create(parent, width, height, radius, iconSize, direction) {
1920
+ const g = Dom.svg('g', {
1921
+ visibility: 'hidden',
1922
+ class: 'sqd-placeholder'
1923
+ });
1924
+ parent.appendChild(g);
1925
+ const rect = Dom.svg('rect', {
1926
+ class: 'sqd-placeholder-rect',
1927
+ width,
1928
+ height,
1929
+ rx: radius,
1930
+ ry: radius
1931
+ });
1932
+ g.appendChild(rect);
1933
+ if (direction) {
1934
+ const iconD = direction === PlaceholderDirection.in ? Icons.folderIn : Icons.folderOut;
1935
+ const icon = Icons.appendPath(g, 'sqd-placeholder-icon-path', iconD, iconSize);
1936
+ Dom.translate(icon, (width - iconSize) / 2, (height - iconSize) / 2);
1937
+ }
1938
+ parent.appendChild(g);
1939
+ return new RectPlaceholderView(rect, g);
1940
+ }
1941
+ constructor(rect, g) {
1942
+ this.rect = rect;
1943
+ this.g = g;
1944
+ }
1945
+ setIsHover(isHover) {
1946
+ Dom.toggleClass(this.g, isHover, 'sqd-hover');
1947
+ }
1948
+ setIsVisible(isVisible) {
1949
+ Dom.attrs(this.g, {
1950
+ visibility: isVisible ? 'visible' : 'hidden'
1951
+ });
1952
+ }
1953
+ }
1954
+
1943
1955
  class RectPlaceholder {
1944
1956
  static create(parent, size, direction, sequence, index, configuration) {
1945
1957
  const view = RectPlaceholderView.create(parent, size.x, size.y, configuration.radius, configuration.iconSize, direction);
@@ -2467,7 +2479,7 @@ class WorkspaceControllerWrapper {
2467
2479
 
2468
2480
  class DesignerContext {
2469
2481
  static create(parent, startDefinition, configuration, services) {
2470
- var _a, _b, _c;
2482
+ var _a, _b, _c, _d;
2471
2483
  const definition = ObjectCloner.deepClone(startDefinition);
2472
2484
  const layoutController = new LayoutController(parent);
2473
2485
  const isReadonly = !!configuration.isReadonly;
@@ -2479,22 +2491,24 @@ class DesignerContext {
2479
2491
  const behaviorController = new BehaviorController();
2480
2492
  const stepExtensionResolver = StepExtensionResolver.create(services);
2481
2493
  const definitionWalker = (_c = configuration.definitionWalker) !== null && _c !== void 0 ? _c : new DefinitionWalker();
2494
+ const i18n = (_d = configuration.i18n) !== null && _d !== void 0 ? _d : ((_, defaultValue) => defaultValue);
2482
2495
  const stateModifier = StateModifier.create(definitionWalker, state, configuration);
2483
2496
  const customActionController = new CustomActionController(configuration, state, stateModifier);
2484
2497
  let historyController = undefined;
2485
2498
  if (configuration.undoStackSize) {
2486
2499
  historyController = HistoryController.create(configuration.undoStack, state, stateModifier, configuration);
2487
2500
  }
2488
- const componentContext = ComponentContext.create(configuration.steps, configuration.validator, state, stepExtensionResolver, services);
2489
- return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, stateModifier, layoutController, workspaceController, behaviorController, customActionController, historyController);
2501
+ const componentContext = ComponentContext.create(configuration.steps, configuration.validator, state, stepExtensionResolver, i18n, services);
2502
+ return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, behaviorController, customActionController, historyController);
2490
2503
  }
2491
- constructor(theme, state, configuration, services, componentContext, definitionWalker, stateModifier, layoutController, workspaceController, behaviorController, customActionController, historyController) {
2504
+ constructor(theme, state, configuration, services, componentContext, definitionWalker, i18n, stateModifier, layoutController, workspaceController, behaviorController, customActionController, historyController) {
2492
2505
  this.theme = theme;
2493
2506
  this.state = state;
2494
2507
  this.configuration = configuration;
2495
2508
  this.services = services;
2496
2509
  this.componentContext = componentContext;
2497
2510
  this.definitionWalker = definitionWalker;
2511
+ this.i18n = i18n;
2498
2512
  this.stateModifier = stateModifier;
2499
2513
  this.layoutController = layoutController;
2500
2514
  this.workspaceController = workspaceController;
@@ -2907,8 +2921,9 @@ class ContextMenuController {
2907
2921
  }
2908
2922
 
2909
2923
  class ContextMenuItemsBuilder {
2910
- constructor(viewportApi, stateModifier, state, customMenuItemsProvider) {
2924
+ constructor(viewportApi, i18n, stateModifier, state, customMenuItemsProvider) {
2911
2925
  this.viewportApi = viewportApi;
2926
+ this.i18n = i18n;
2912
2927
  this.stateModifier = stateModifier;
2913
2928
  this.state = state;
2914
2929
  this.customMenuItemsProvider = customMenuItemsProvider;
@@ -2919,15 +2934,16 @@ class ContextMenuItemsBuilder {
2919
2934
  const ssc = commandOrNull;
2920
2935
  const step = ssc.component.step;
2921
2936
  const parentSequence = ssc.component.parentSequence;
2937
+ const name = this.i18n(`step.${step.type}.name`, step.name);
2922
2938
  items.push({
2923
- label: step.name,
2939
+ label: name,
2924
2940
  order: 0
2925
2941
  });
2926
2942
  this.tryAppendCustomItems(items, step, parentSequence);
2927
2943
  if (this.stateModifier.isSelectable(step, parentSequence)) {
2928
2944
  if (this.state.selectedStepId === step.id) {
2929
2945
  items.push({
2930
- label: `Unselect`,
2946
+ label: this.i18n('contextMenu.unselect', 'Unselect'),
2931
2947
  order: 10,
2932
2948
  callback: () => {
2933
2949
  this.state.setSelectedStepId(null);
@@ -2936,7 +2952,7 @@ class ContextMenuItemsBuilder {
2936
2952
  }
2937
2953
  else {
2938
2954
  items.push({
2939
- label: 'Select',
2955
+ label: this.i18n('contextMenu.select', 'Select'),
2940
2956
  order: 20,
2941
2957
  callback: () => {
2942
2958
  this.stateModifier.trySelectStepById(step.id);
@@ -2947,7 +2963,7 @@ class ContextMenuItemsBuilder {
2947
2963
  if (!this.state.isReadonly) {
2948
2964
  if (this.stateModifier.isDeletable(step.id)) {
2949
2965
  items.push({
2950
- label: 'Delete',
2966
+ label: this.i18n('contextMenu.delete', 'Delete'),
2951
2967
  order: 30,
2952
2968
  callback: () => {
2953
2969
  this.stateModifier.tryDelete(step.id);
@@ -2956,7 +2972,7 @@ class ContextMenuItemsBuilder {
2956
2972
  }
2957
2973
  if (this.stateModifier.isDuplicable(step, parentSequence)) {
2958
2974
  items.push({
2959
- label: 'Duplicate',
2975
+ label: this.i18n('contextMenu.duplicate', 'Duplicate'),
2960
2976
  order: 40,
2961
2977
  callback: () => {
2962
2978
  this.stateModifier.tryDuplicate(step, parentSequence);
@@ -2969,7 +2985,7 @@ class ContextMenuItemsBuilder {
2969
2985
  this.tryAppendCustomItems(items, null, this.state.definition.sequence);
2970
2986
  }
2971
2987
  items.push({
2972
- label: 'Reset view',
2988
+ label: this.i18n('contextMenu.resetView', 'Reset view'),
2973
2989
  order: 50,
2974
2990
  callback: () => {
2975
2991
  this.viewportApi.resetViewport();
@@ -2994,7 +3010,7 @@ class Workspace {
2994
3010
  const view = WorkspaceView.create(parent, designerContext.componentContext);
2995
3011
  const clickBehaviorResolver = new ClickBehaviorResolver(designerContext);
2996
3012
  const wheelController = designerContext.services.wheelController.create(api.workspace);
2997
- const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
3013
+ const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
2998
3014
  ? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
2999
3015
  : undefined);
3000
3016
  const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
@@ -3241,28 +3257,28 @@ class DefaultDraggedComponentExtension {
3241
3257
  }
3242
3258
 
3243
3259
  class ControlBarView {
3244
- static create(parent, isUndoRedoSupported) {
3260
+ static create(parent, isUndoRedoSupported, i18n) {
3245
3261
  const root = Dom.element('div', {
3246
3262
  class: 'sqd-control-bar'
3247
3263
  });
3248
- const resetButton = createButton(Icons.center, 'Reset view');
3264
+ const resetButton = createButton(Icons.center, i18n('controlBar.resetView', 'Reset view'));
3249
3265
  root.appendChild(resetButton);
3250
- const zoomInButton = createButton(Icons.zoomIn, 'Zoom in');
3266
+ const zoomInButton = createButton(Icons.zoomIn, i18n('controlBar.zoomIn', 'Zoom in'));
3251
3267
  root.appendChild(zoomInButton);
3252
- const zoomOutButton = createButton(Icons.zoomOut, 'Zoom out');
3268
+ const zoomOutButton = createButton(Icons.zoomOut, i18n('controlBar.zoomOut', 'Zoom out'));
3253
3269
  root.appendChild(zoomOutButton);
3254
3270
  let undoButton = null;
3255
3271
  let redoButton = null;
3256
3272
  if (isUndoRedoSupported) {
3257
- undoButton = createButton(Icons.undo, 'Undo');
3273
+ undoButton = createButton(Icons.undo, i18n('controlBar.undo', 'Undo'));
3258
3274
  root.appendChild(undoButton);
3259
- redoButton = createButton(Icons.redo, 'Redo');
3275
+ redoButton = createButton(Icons.redo, i18n('controlBar.redo', 'Redo'));
3260
3276
  root.appendChild(redoButton);
3261
3277
  }
3262
- const disableDragButton = createButton(Icons.move, 'Turn on/off drag and drop');
3278
+ const disableDragButton = createButton(Icons.move, i18n('controlBar.turnOnOffDragAndDrop', 'Turn on/off drag and drop'));
3263
3279
  disableDragButton.classList.add('sqd-disabled');
3264
3280
  root.appendChild(disableDragButton);
3265
- const deleteButton = createButton(Icons.delete, 'Delete selected step');
3281
+ const deleteButton = createButton(Icons.delete, i18n('controlBar.deleteSelectedStep', 'Delete selected step'));
3266
3282
  deleteButton.classList.add('sqd-delete');
3267
3283
  deleteButton.classList.add('sqd-hidden');
3268
3284
  root.appendChild(deleteButton);
@@ -3343,7 +3359,7 @@ function createButton(d, title) {
3343
3359
  class ControlBar {
3344
3360
  static create(parent, api) {
3345
3361
  const isUndoRedoSupported = api.controlBar.isUndoRedoSupported();
3346
- const view = ControlBarView.create(parent, isUndoRedoSupported);
3362
+ const view = ControlBarView.create(parent, isUndoRedoSupported, api.i18n);
3347
3363
  const bar = new ControlBar(view, api.controlBar, isUndoRedoSupported);
3348
3364
  view.bindResetButtonClick(() => bar.onResetButtonClicked());
3349
3365
  view.bindZoomInButtonClick(() => bar.onZoomInButtonClicked());
@@ -3473,19 +3489,16 @@ class KeyboardDaemonExtension {
3473
3489
  }
3474
3490
 
3475
3491
  class SmartEditorView {
3476
- static create(parent, api, configuration) {
3492
+ static create(parent, api, i18n, configuration) {
3477
3493
  const root = Dom.element('div', {
3478
3494
  class: 'sqd-smart-editor'
3479
3495
  });
3480
3496
  const toggle = Dom.element('div', {
3481
3497
  class: 'sqd-smart-editor-toggle',
3482
- title: 'Toggle editor'
3498
+ title: i18n('smartEditor.toggle', 'Toggle editor')
3483
3499
  });
3484
3500
  parent.appendChild(toggle);
3485
3501
  parent.appendChild(root);
3486
- if (configuration.globalEditorProvider) {
3487
- throw new Error('globalEditorProvider is renamed to rootEditorProvider');
3488
- }
3489
3502
  const editor = Editor.create(root, api, 'sqd-editor sqd-step-editor', configuration.stepEditorProvider, 'sqd-editor sqd-root-editor', configuration.rootEditorProvider, null);
3490
3503
  return new SmartEditorView(root, toggle, editor);
3491
3504
  }
@@ -3516,7 +3529,7 @@ class SmartEditorView {
3516
3529
 
3517
3530
  class SmartEditor {
3518
3531
  static create(parent, api, configuration) {
3519
- const view = SmartEditorView.create(parent, api.editor, configuration);
3532
+ const view = SmartEditorView.create(parent, api.editor, api.i18n, configuration);
3520
3533
  const editor = new SmartEditor(view, api.editor, api.workspace);
3521
3534
  editor.updateVisibility();
3522
3535
  view.bindToggleClick(() => editor.onToggleClicked());
@@ -3759,7 +3772,7 @@ class ToolboxItem {
3759
3772
  }
3760
3773
 
3761
3774
  class ToolboxView {
3762
- static create(parent, api) {
3775
+ static create(parent, api, i18n) {
3763
3776
  const root = Dom.element('div', {
3764
3777
  class: 'sqd-toolbox'
3765
3778
  });
@@ -3769,14 +3782,14 @@ class ToolboxView {
3769
3782
  const headerTitle = Dom.element('div', {
3770
3783
  class: 'sqd-toolbox-header-title'
3771
3784
  });
3772
- headerTitle.innerText = 'Toolbox';
3785
+ headerTitle.innerText = i18n('toolbox.title', 'Toolbox');
3773
3786
  const body = Dom.element('div', {
3774
3787
  class: 'sqd-toolbox-body'
3775
3788
  });
3776
3789
  const filterInput = Dom.element('input', {
3777
3790
  class: 'sqd-toolbox-filter',
3778
3791
  type: 'text',
3779
- placeholder: 'Search...'
3792
+ placeholder: i18n('toolbox.search', 'Search...')
3780
3793
  });
3781
3794
  root.appendChild(header);
3782
3795
  root.appendChild(body);
@@ -3836,9 +3849,9 @@ class ToolboxView {
3836
3849
  }
3837
3850
 
3838
3851
  class Toolbox {
3839
- static create(root, api) {
3852
+ static create(root, api, i18n) {
3840
3853
  const allGroups = api.getAllGroups();
3841
- const view = ToolboxView.create(root, api);
3854
+ const view = ToolboxView.create(root, api, i18n);
3842
3855
  const toolbox = new Toolbox(view, api, allGroups);
3843
3856
  toolbox.render();
3844
3857
  toolbox.onIsCollapsedChanged();
@@ -3873,7 +3886,7 @@ class Toolbox {
3873
3886
 
3874
3887
  class ToolboxExtension {
3875
3888
  create(root, api) {
3876
- return Toolbox.create(root, api.toolbox);
3889
+ return Toolbox.create(root, api.toolbox, api.i18n);
3877
3890
  }
3878
3891
  }
3879
3892
 
@@ -4518,4 +4531,4 @@ class StepsDesignerExtension {
4518
4531
  }
4519
4532
  }
4520
4533
 
4521
- export { Badges, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickCommandType, ComponentContext, ControlBarApi, CustomActionController, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerExtension, DefinitionChangeType, Designer, DesignerApi, DesignerContext, DesignerState, Dom, Editor, EditorApi, Icons, InputView, JoinView, KeyboardAction, LabelView, LineGridDesignerExtension, ObjectCloner, OutputView, PathBarApi, PlaceholderDirection, QuantifiedScaleViewportCalculator, RectPlaceholder, RectPlaceholderView, RegionView, ServicesResolver, SimpleEvent, StepComponent, StepExtensionResolver, StepsDesignerExtension, ToolboxApi, Uid, ValidationErrorBadgeExtension, Vector, WorkspaceApi, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, getAbsolutePosition, race };
4534
+ export { Badges, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickCommandType, ComponentContext, ComponentDom, ControlBarApi, CustomActionController, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerExtension, DefinitionChangeType, Designer, DesignerApi, DesignerContext, DesignerState, Dom, Editor, EditorApi, Icons, InputView, JoinView, KeyboardAction, LabelView, LineGridDesignerExtension, ObjectCloner, OutputView, PathBarApi, PlaceholderDirection, QuantifiedScaleViewportCalculator, RectPlaceholder, RectPlaceholderView, RegionView, ServicesResolver, SimpleEvent, StepComponent, StepExtensionResolver, StepsDesignerExtension, ToolboxApi, Uid, ValidationErrorBadgeExtension, Vector, WorkspaceApi, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, getAbsolutePosition, race };
package/lib/index.d.ts CHANGED
@@ -272,8 +272,9 @@ declare class ComponentContext {
272
272
  readonly iconProvider: IconProvider;
273
273
  readonly placeholderController: PlaceholderController;
274
274
  readonly stepComponentFactory: StepComponentFactory;
275
+ readonly i18n: I18n;
275
276
  readonly services: Services;
276
- static create(stepsConfiguration: StepsConfiguration, validatorConfiguration: ValidatorConfiguration | undefined, state: DesignerState, stepExtensionResolver: StepExtensionResolver, services: Services): ComponentContext;
277
+ static create(stepsConfiguration: StepsConfiguration, validatorConfiguration: ValidatorConfiguration | undefined, state: DesignerState, stepExtensionResolver: StepExtensionResolver, i18n: I18n, services: Services): ComponentContext;
277
278
  private constructor();
278
279
  }
279
280
 
@@ -342,6 +343,7 @@ declare class DesignerContext {
342
343
  readonly services: Services;
343
344
  readonly componentContext: ComponentContext;
344
345
  readonly definitionWalker: DefinitionWalker;
346
+ readonly i18n: I18n;
345
347
  readonly stateModifier: StateModifier;
346
348
  readonly layoutController: LayoutController;
347
349
  readonly workspaceController: WorkspaceControllerWrapper;
@@ -349,7 +351,7 @@ declare class DesignerContext {
349
351
  readonly customActionController: CustomActionController;
350
352
  readonly historyController: HistoryController | undefined;
351
353
  static create(parent: HTMLElement, startDefinition: Definition, configuration: DesignerConfiguration, services: Services): DesignerContext;
352
- constructor(theme: string, state: DesignerState, configuration: DesignerConfiguration, services: Services, componentContext: ComponentContext, definitionWalker: DefinitionWalker, stateModifier: StateModifier, layoutController: LayoutController, workspaceController: WorkspaceControllerWrapper, behaviorController: BehaviorController, customActionController: CustomActionController, historyController: HistoryController | undefined);
354
+ constructor(theme: string, state: DesignerState, configuration: DesignerConfiguration, services: Services, componentContext: ComponentContext, definitionWalker: DefinitionWalker, i18n: I18n, stateModifier: StateModifier, layoutController: LayoutController, workspaceController: WorkspaceControllerWrapper, behaviorController: BehaviorController, customActionController: CustomActionController, historyController: HistoryController | undefined);
353
355
  setWorkspaceController(controller: WorkspaceController): void;
354
356
  }
355
357
 
@@ -405,8 +407,9 @@ declare class PathBarApi {
405
407
 
406
408
  declare class ToolboxDataProvider {
407
409
  private readonly iconProvider;
410
+ private readonly i18n;
408
411
  private readonly configuration;
409
- constructor(iconProvider: IconProvider, configuration: ToolboxConfiguration | false);
412
+ constructor(iconProvider: IconProvider, i18n: I18n, configuration: ToolboxConfiguration | false);
410
413
  getAllGroups(): ToolboxGroupData[];
411
414
  private readonly createItemData;
412
415
  applyFilter(allGroups: ToolboxGroupData[], filter: string | undefined): ToolboxGroupData[];
@@ -475,6 +478,7 @@ declare class DesignerApi {
475
478
  readonly viewport: ViewportApi;
476
479
  readonly pathBar: PathBarApi;
477
480
  readonly definitionWalker: DefinitionWalker;
481
+ readonly i18n: I18n;
478
482
  static create(context: DesignerContext): DesignerApi;
479
483
  private constructor();
480
484
  }
@@ -509,6 +513,10 @@ declare class ValidationErrorBadgeExtension implements BadgeExtension {
509
513
  readonly createStartValue: () => boolean;
510
514
  }
511
515
 
516
+ declare class ComponentDom {
517
+ static stepG(componentClassName: string, type: string, id: string): SVGGElement;
518
+ }
519
+
512
520
  declare class InputView {
513
521
  private readonly root;
514
522
  static createRectInput(parent: SVGElement, x: number, y: number, size: number, iconSize: number, iconUrl: string | null): InputView;
@@ -555,15 +563,6 @@ declare class RegionView {
555
563
  setIsSelected(isSelected: boolean): void;
556
564
  }
557
565
 
558
- declare class RectPlaceholderView implements PlaceholderView {
559
- readonly rect: SVGElement;
560
- readonly g: SVGGElement;
561
- static create(parent: SVGElement, width: number, height: number, radius: number, iconSize: number, direction: PlaceholderDirection): RectPlaceholderView;
562
- private constructor();
563
- setIsHover(isHover: boolean): void;
564
- setIsVisible(isVisible: boolean): void;
565
- }
566
-
567
566
  declare class DefaultSequenceComponentView implements ComponentView {
568
567
  readonly g: SVGGElement;
569
568
  readonly width: number;
@@ -686,6 +685,15 @@ interface RectPlaceholderConfiguration {
686
685
  iconSize: number;
687
686
  }
688
687
 
688
+ declare class RectPlaceholderView implements PlaceholderView {
689
+ readonly rect: SVGElement;
690
+ readonly g: SVGGElement;
691
+ static create(parent: SVGElement, width: number, height: number, radius: number, iconSize: number, direction: PlaceholderDirection): RectPlaceholderView;
692
+ private constructor();
693
+ setIsHover(isHover: boolean): void;
694
+ setIsVisible(isVisible: boolean): void;
695
+ }
696
+
689
697
  declare class RectPlaceholder implements Placeholder {
690
698
  readonly view: RectPlaceholderView;
691
699
  readonly parentSequence: Sequence;
@@ -720,9 +728,11 @@ interface StepExtension<S extends Step = Step> {
720
728
  }
721
729
  type StepComponentViewFactory = StepExtension['createComponentView'];
722
730
  interface StepComponentViewContext {
731
+ getStepName(): string;
723
732
  getStepIconUrl(): string | null;
724
733
  createSequenceComponent(parentElement: SVGElement, sequence: Sequence): SequenceComponent;
725
734
  createPlaceholderForArea(parentElement: SVGElement, size: Vector, direction: PlaceholderDirection, sequence: Sequence, index: number): Placeholder;
735
+ i18n: I18n;
726
736
  }
727
737
  interface StepContext<S extends Step = Step> {
728
738
  parentSequence: Sequence;
@@ -888,8 +898,13 @@ interface DesignerConfiguration<TDefinition extends Definition = Definition> {
888
898
  * @description Custom generator of unique identifiers.
889
899
  */
890
900
  uidGenerator?: UidGenerator;
901
+ /**
902
+ * @description Custom translation function.
903
+ */
904
+ i18n?: I18n;
891
905
  }
892
906
  type UidGenerator = () => string;
907
+ type I18n = (key: string, defaultValue: string) => string;
893
908
  type CustomActionHandler = (action: CustomAction, step: Step | null, sequence: Sequence, context: CustomActionHandlerContext) => void;
894
909
  interface CustomAction {
895
910
  type: string;
@@ -1210,4 +1225,4 @@ declare class StepsDesignerExtension implements DesignerExtension {
1210
1225
  protected constructor(steps: StepExtension<Step>[]);
1211
1226
  }
1212
1227
 
1213
- export { Attributes, Badge, BadgeExtension, BadgeView, Badges, BadgesResult, BaseClickCommand, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickCommand, ClickCommandType, ClickDetails, Component, ComponentContext, ComponentView, ContainerStepComponentViewConfiguration, ContainerStepExtensionConfiguration, ContextMenuExtension, ContextMenuItem, ContextMenuItemsProvider, ControlBarApi, CustomAction, CustomActionController, CustomActionHandler, CustomActionHandlerContext, Daemon, DaemonExtension, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerExtension, DefinitionChangeType, DefinitionChangedEvent, Designer, DesignerApi, DesignerConfiguration, DesignerContext, DesignerExtension, DesignerState, Dom, DraggedComponent, DraggedComponentExtension, Editor, EditorApi, EditorsConfiguration, Grid, GridExtension, Icons, InputView, JoinView, KeyboardAction, KeyboardConfiguration, LabelView, LineGridConfiguration, LineGridDesignerExtension, ObjectCloner, OpenFolderClickCommand, OutputView, PathBarApi, Placeholder, PlaceholderController, PlaceholderControllerExtension, PlaceholderDirection, PlaceholderExtension, PlaceholderView, QuantifiedScaleViewportCalculator, RectPlaceholder, RectPlaceholderConfiguration, RectPlaceholderView, RegionView, RerenderStepClickCommand, RootComponentExtension, RootEditorContext, RootEditorProvider, RootValidator, SelectStepClickCommand, SelectedStepIdProvider, SequenceComponent, SequenceComponentExtension, SequenceContext, SequencePlaceIndicator, Services, ServicesResolver, SimpleEvent, SimpleEventListener, StateModifierDependency, StepComponent, StepComponentView, StepComponentViewContext, StepComponentViewFactory, StepComponentViewWrapperExtension, StepContext, StepDefinition, StepDescriptionProvider, StepEditorContext, StepEditorProvider, StepExtension, StepExtensionResolver, StepIconUrlProvider, StepLabelProvider, StepValidator, StepsConfiguration, StepsDesignerExtension, StepsDesignerExtensionConfiguration, SwitchStepComponentViewConfiguration, SwitchStepExtensionConfiguration, TaskStepComponentViewConfiguration, TaskStepExtensionConfiguration, ToolboxApi, ToolboxConfiguration, ToolboxGroupConfiguration, TriggerCustomActionClickCommand, UiComponent, UiComponentExtension, Uid, UidGenerator, UndoStack, UndoStackItem, ValidationErrorBadgeExtension, ValidationErrorBadgeExtensionConfiguration, ValidationErrorBadgeViewConfiguration, ValidatorConfiguration, Vector, Viewport, ViewportController, ViewportControllerExtension, WheelController, WheelControllerExtension, WorkspaceApi, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, getAbsolutePosition, race };
1228
+ export { Attributes, Badge, BadgeExtension, BadgeView, Badges, BadgesResult, BaseClickCommand, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickCommand, ClickCommandType, ClickDetails, Component, ComponentContext, ComponentDom, ComponentView, ContainerStepComponentViewConfiguration, ContainerStepExtensionConfiguration, ContextMenuExtension, ContextMenuItem, ContextMenuItemsProvider, ControlBarApi, CustomAction, CustomActionController, CustomActionHandler, CustomActionHandlerContext, Daemon, DaemonExtension, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerExtension, DefinitionChangeType, DefinitionChangedEvent, Designer, DesignerApi, DesignerConfiguration, DesignerContext, DesignerExtension, DesignerState, Dom, DraggedComponent, DraggedComponentExtension, Editor, EditorApi, EditorsConfiguration, Grid, GridExtension, I18n, Icons, InputView, JoinView, KeyboardAction, KeyboardConfiguration, LabelView, LineGridConfiguration, LineGridDesignerExtension, ObjectCloner, OpenFolderClickCommand, OutputView, PathBarApi, Placeholder, PlaceholderController, PlaceholderControllerExtension, PlaceholderDirection, PlaceholderExtension, PlaceholderView, QuantifiedScaleViewportCalculator, RectPlaceholder, RectPlaceholderConfiguration, RectPlaceholderView, RegionView, RerenderStepClickCommand, RootComponentExtension, RootEditorContext, RootEditorProvider, RootValidator, SelectStepClickCommand, SelectedStepIdProvider, SequenceComponent, SequenceComponentExtension, SequenceContext, SequencePlaceIndicator, Services, ServicesResolver, SimpleEvent, SimpleEventListener, StateModifierDependency, StepComponent, StepComponentView, StepComponentViewContext, StepComponentViewFactory, StepComponentViewWrapperExtension, StepContext, StepDefinition, StepDescriptionProvider, StepEditorContext, StepEditorProvider, StepExtension, StepExtensionResolver, StepIconUrlProvider, StepLabelProvider, StepValidator, StepsConfiguration, StepsDesignerExtension, StepsDesignerExtensionConfiguration, SwitchStepComponentViewConfiguration, SwitchStepExtensionConfiguration, TaskStepComponentViewConfiguration, TaskStepExtensionConfiguration, ToolboxApi, ToolboxConfiguration, ToolboxGroupConfiguration, TriggerCustomActionClickCommand, UiComponent, UiComponentExtension, Uid, UidGenerator, UndoStack, UndoStackItem, ValidationErrorBadgeExtension, ValidationErrorBadgeExtensionConfiguration, ValidationErrorBadgeViewConfiguration, ValidatorConfiguration, Vector, Viewport, ViewportController, ViewportControllerExtension, WheelController, WheelControllerExtension, WorkspaceApi, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, getAbsolutePosition, race };
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.19.3",
4
+ "version": "0.20.0",
5
5
  "type": "module",
6
6
  "main": "./lib/esm/index.js",
7
7
  "types": "./lib/index.d.ts",