sequential-workflow-designer 0.27.4 → 0.29.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
@@ -1,4 +1,4 @@
1
- import { DefinitionWalker, StepChildrenType } from 'sequential-workflow-model';
1
+ import { StepChildrenType, DefinitionWalker } from 'sequential-workflow-model';
2
2
  export * from 'sequential-workflow-model';
3
3
 
4
4
  class Dom {
@@ -767,8 +767,9 @@ class ViewportApi {
767
767
  }
768
768
 
769
769
  class WorkspaceApi {
770
- constructor(state, workspaceController) {
770
+ constructor(state, definitionWalker, workspaceController) {
771
771
  this.state = state;
772
+ this.definitionWalker = definitionWalker;
772
773
  this.workspaceController = workspaceController;
773
774
  }
774
775
  getViewport() {
@@ -795,11 +796,29 @@ class WorkspaceApi {
795
796
  updateCanvasSize() {
796
797
  this.workspaceController.updateCanvasSize();
797
798
  }
799
+ getRootSequence() {
800
+ const stepId = this.state.tryGetLastStepIdFromFolderPath();
801
+ if (stepId) {
802
+ const parentStep = this.definitionWalker.getParentSequence(this.state.definition, stepId);
803
+ const children = this.definitionWalker.getChildren(parentStep.step);
804
+ if (!children || children.type !== StepChildrenType.sequence) {
805
+ throw new Error('Cannot find single sequence in folder step');
806
+ }
807
+ return {
808
+ sequence: children.items,
809
+ parentStep
810
+ };
811
+ }
812
+ return {
813
+ sequence: this.state.definition.sequence,
814
+ parentStep: null
815
+ };
816
+ }
798
817
  }
799
818
 
800
819
  class DesignerApi {
801
820
  static create(context) {
802
- const workspace = new WorkspaceApi(context.state, context.workspaceController);
821
+ const workspace = new WorkspaceApi(context.state, context.definitionWalker, context.workspaceController);
803
822
  const viewportController = context.services.viewportController.create(workspace);
804
823
  const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
805
824
  return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.stateModifier), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, new ViewportApi(context.state, context.workspaceController, viewportController), new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
@@ -1058,11 +1077,11 @@ class InputView {
1058
1077
  parent.appendChild(circle);
1059
1078
  return new InputView(circle);
1060
1079
  }
1061
- constructor(root) {
1062
- this.root = root;
1080
+ constructor(g) {
1081
+ this.g = g;
1063
1082
  }
1064
1083
  setIsHidden(isHidden) {
1065
- Dom.attrs(this.root, {
1084
+ Dom.attrs(this.g, {
1066
1085
  visibility: isHidden ? 'hidden' : 'visible'
1067
1086
  });
1068
1087
  }
@@ -1487,31 +1506,77 @@ const createContainerStepComponentViewFactory = (cfg) => (parentElement, stepCon
1487
1506
  };
1488
1507
 
1489
1508
  const COMPONENT_CLASS_NAME$1 = 'switch';
1509
+ function createView(g, width, height, joinX, viewContext, sequenceComponents, regionView, cfg) {
1510
+ let inputView = null;
1511
+ if (cfg.inputSize > 0) {
1512
+ const iconUrl = viewContext.getStepIconUrl();
1513
+ inputView = InputView.createRectInput(g, joinX, cfg.paddingTop1, cfg.inputSize, cfg.inputRadius, cfg.inputIconSize, iconUrl);
1514
+ }
1515
+ return {
1516
+ g,
1517
+ width,
1518
+ height,
1519
+ joinX,
1520
+ placeholders: null,
1521
+ sequenceComponents,
1522
+ hasOutput: sequenceComponents ? sequenceComponents.some(c => c.hasOutput) : true,
1523
+ getClientPosition() {
1524
+ return regionView.getClientPosition();
1525
+ },
1526
+ resolveClick(click) {
1527
+ const result = regionView.resolveClick(click);
1528
+ return result === true || (result === null && g.contains(click.element)) ? true : result;
1529
+ },
1530
+ setIsDragging(isDragging) {
1531
+ if (cfg.autoHideInputOnDrag && inputView) {
1532
+ inputView.setIsHidden(isDragging);
1533
+ }
1534
+ },
1535
+ setIsSelected(isSelected) {
1536
+ regionView.setIsSelected(isSelected);
1537
+ },
1538
+ setIsDisabled(isDisabled) {
1539
+ Dom.toggleClass(g, isDisabled, 'sqd-disabled');
1540
+ }
1541
+ };
1542
+ }
1490
1543
  const createSwitchStepComponentViewFactory = (cfg) => (parent, stepContext, viewContext) => {
1491
1544
  return viewContext.createRegionComponentView(parent, COMPONENT_CLASS_NAME$1, (g, regionViewBuilder) => {
1492
1545
  const step = stepContext.step;
1493
1546
  const paddingTop = cfg.paddingTop1 + cfg.paddingTop2;
1547
+ const name = viewContext.getStepName();
1548
+ const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary');
1494
1549
  const branchNames = Object.keys(step.branches);
1495
- const branchComponents = branchNames.map(branchName => {
1496
- return viewContext.createSequenceComponent(g, step.branches[branchName]);
1497
- });
1498
- const branchLabelViews = branchNames.map(branchName => {
1550
+ if (branchNames.length === 0) {
1551
+ const width = Math.max(nameLabelView.width, cfg.minBranchWidth) + cfg.paddingX * 2;
1552
+ const height = nameLabelView.height + paddingTop + cfg.noBranchPaddingBottom;
1553
+ const joinX = width / 2;
1554
+ const regionView = regionViewBuilder(g, [width], height);
1555
+ Dom.translate(nameLabelView.g, joinX, 0);
1556
+ JoinView.createStraightJoin(g, new Vector(joinX, 0), height);
1557
+ return createView(g, width, height, joinX, viewContext, null, regionView, cfg);
1558
+ }
1559
+ const branchComponents = [];
1560
+ const branchLabelViews = [];
1561
+ const branchSizes = [];
1562
+ let totalBranchesWidth = 0;
1563
+ let maxBranchesHeight = 0;
1564
+ branchNames.forEach(branchName => {
1565
+ const component = viewContext.createSequenceComponent(g, step.branches[branchName]);
1499
1566
  const labelY = paddingTop + cfg.nameLabel.height + cfg.connectionHeight;
1500
1567
  const translatedBranchName = viewContext.i18n(`stepComponent.${step.type}.branchName`, branchName);
1501
- return LabelView.create(g, labelY, cfg.branchNameLabel, translatedBranchName, 'secondary');
1502
- });
1503
- const name = viewContext.getStepName();
1504
- const nameLabelView = LabelView.create(g, paddingTop, cfg.nameLabel, name, 'primary');
1505
- let prevOffsetX = 0;
1506
- const branchSizes = branchComponents.map((component, i) => {
1507
- const halfOfWidestBranchElement = Math.max(branchLabelViews[i].width, cfg.minContainerWidth) / 2;
1568
+ const labelView = LabelView.create(g, labelY, cfg.branchNameLabel, translatedBranchName, 'secondary');
1569
+ const halfOfWidestBranchElement = Math.max(labelView.width, cfg.minBranchWidth) / 2;
1508
1570
  const branchOffsetLeft = Math.max(halfOfWidestBranchElement - component.view.joinX, 0) + cfg.paddingX;
1509
1571
  const branchOffsetRight = Math.max(halfOfWidestBranchElement - (component.view.width - component.view.joinX), 0) + cfg.paddingX;
1510
1572
  const width = component.view.width + branchOffsetLeft + branchOffsetRight;
1511
1573
  const joinX = component.view.joinX + branchOffsetLeft;
1512
- const offsetX = prevOffsetX;
1513
- prevOffsetX += width;
1514
- return { width, branchOffsetLeft, offsetX, joinX };
1574
+ const offsetX = totalBranchesWidth;
1575
+ totalBranchesWidth += width;
1576
+ maxBranchesHeight = Math.max(maxBranchesHeight, component.view.height);
1577
+ branchComponents.push(component);
1578
+ branchLabelViews.push(labelView);
1579
+ branchSizes.push({ width, branchOffsetLeft, offsetX, joinX });
1515
1580
  });
1516
1581
  const centerBranchIndex = Math.floor(branchNames.length / 2);
1517
1582
  const centerBranchSize = branchSizes[centerBranchIndex];
@@ -1519,8 +1584,6 @@ const createSwitchStepComponentViewFactory = (cfg) => (parent, stepContext, view
1519
1584
  if (branchNames.length % 2 !== 0) {
1520
1585
  joinX += centerBranchSize.joinX;
1521
1586
  }
1522
- const totalBranchesWidth = branchSizes.reduce((result, s) => result + s.width, 0);
1523
- const maxBranchesHeight = Math.max(...branchComponents.map(s => s.view.height));
1524
1587
  const halfOfWidestSwitchElement = nameLabelView.width / 2 + cfg.paddingX;
1525
1588
  const switchOffsetLeft = Math.max(halfOfWidestSwitchElement - joinX, 0);
1526
1589
  const switchOffsetRight = Math.max(halfOfWidestSwitchElement - (totalBranchesWidth - joinX), 0);
@@ -1542,18 +1605,16 @@ const createSwitchStepComponentViewFactory = (cfg) => (parent, stepContext, view
1542
1605
  }
1543
1606
  }
1544
1607
  });
1545
- let inputView = null;
1546
- if (cfg.inputSize > 0) {
1547
- const iconUrl = viewContext.getStepIconUrl();
1548
- inputView = InputView.createRectInput(g, shiftedJoinX, cfg.paddingTop1, cfg.inputSize, cfg.inputRadius, cfg.inputIconSize, iconUrl);
1549
- }
1550
1608
  JoinView.createStraightJoin(g, new Vector(shiftedJoinX, 0), paddingTop);
1551
- JoinView.createJoins(g, new Vector(shiftedJoinX, paddingTop + cfg.nameLabel.height), branchSizes.map(o => new Vector(switchOffsetLeft + o.offsetX + o.joinX, paddingTop + cfg.nameLabel.height + cfg.connectionHeight)));
1609
+ JoinView.createJoins(g, new Vector(shiftedJoinX, paddingTop + cfg.nameLabel.height), branchSizes.map(s => new Vector(switchOffsetLeft + s.offsetX + s.joinX, paddingTop + cfg.nameLabel.height + cfg.connectionHeight)));
1552
1610
  if (stepContext.isOutputConnected) {
1553
1611
  const ongoingSequenceIndexes = branchComponents
1554
1612
  .map((component, index) => (component.hasOutput ? index : null))
1555
1613
  .filter(index => index !== null);
1556
- const ongoingJoinTargets = ongoingSequenceIndexes.map((i) => new Vector(switchOffsetLeft + branchSizes[i].offsetX + branchSizes[i].joinX, paddingTop + cfg.connectionHeight + cfg.nameLabel.height + cfg.branchNameLabel.height + maxBranchesHeight));
1614
+ const ongoingJoinTargets = ongoingSequenceIndexes.map((i) => {
1615
+ const branchSize = branchSizes[i];
1616
+ return new Vector(switchOffsetLeft + branchSize.offsetX + branchSize.joinX, paddingTop + cfg.connectionHeight + cfg.nameLabel.height + cfg.branchNameLabel.height + maxBranchesHeight);
1617
+ });
1557
1618
  if (ongoingJoinTargets.length > 0) {
1558
1619
  JoinView.createJoins(g, new Vector(shiftedJoinX, viewHeight), ongoingJoinTargets);
1559
1620
  }
@@ -1562,33 +1623,7 @@ const createSwitchStepComponentViewFactory = (cfg) => (parent, stepContext, view
1562
1623
  regions[0] += switchOffsetLeft;
1563
1624
  regions[regions.length - 1] += switchOffsetRight;
1564
1625
  const regionView = regionViewBuilder(g, regions, viewHeight);
1565
- return {
1566
- g,
1567
- width: viewWidth,
1568
- height: viewHeight,
1569
- joinX: shiftedJoinX,
1570
- placeholders: null,
1571
- sequenceComponents: branchComponents,
1572
- hasOutput: branchComponents.some(c => c.hasOutput),
1573
- getClientPosition() {
1574
- return regionView.getClientPosition();
1575
- },
1576
- resolveClick(click) {
1577
- const result = regionView.resolveClick(click);
1578
- return result === true || (result === null && g.contains(click.element)) ? true : result;
1579
- },
1580
- setIsDragging(isDragging) {
1581
- if (cfg.autoHideInputOnDrag && inputView) {
1582
- inputView.setIsHidden(isDragging);
1583
- }
1584
- },
1585
- setIsSelected(isSelected) {
1586
- regionView.setIsSelected(isSelected);
1587
- },
1588
- setIsDisabled(isDisabled) {
1589
- Dom.toggleClass(g, isDisabled, 'sqd-disabled');
1590
- }
1591
- };
1626
+ return createView(g, viewWidth, viewHeight, shiftedJoinX, viewContext, branchComponents, regionView, cfg);
1592
1627
  });
1593
1628
  };
1594
1629
 
@@ -2113,11 +2148,12 @@ class ContainerStepExtension {
2113
2148
 
2114
2149
  const defaultConfiguration$2 = {
2115
2150
  view: {
2116
- minContainerWidth: 40,
2151
+ minBranchWidth: 88,
2117
2152
  paddingX: 20,
2118
2153
  paddingTop1: 0,
2119
2154
  paddingTop2: 22,
2120
- connectionHeight: 16,
2155
+ connectionHeight: 20,
2156
+ noBranchPaddingBottom: 24,
2121
2157
  inputSize: 18,
2122
2158
  inputIconSize: 14,
2123
2159
  inputRadius: 4,
@@ -2994,6 +3030,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2994
3030
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2995
3031
  PERFORMANCE OF THIS SOFTWARE.
2996
3032
  ***************************************************************************** */
3033
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
3034
+
2997
3035
 
2998
3036
  function __awaiter(thisArg, _arguments, P, generator) {
2999
3037
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -3003,7 +3041,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
3003
3041
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3004
3042
  step((generator = generator.apply(thisArg, _arguments || [])).next());
3005
3043
  });
3006
- }
3044
+ }
3045
+
3046
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
3047
+ var e = new Error(message);
3048
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
3049
+ };
3007
3050
 
3008
3051
  function isElementAttached(dom, element) {
3009
3052
  return !(dom.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_DISCONNECTED);
@@ -3054,11 +3097,11 @@ class WorkspaceView {
3054
3097
  this.context = context;
3055
3098
  this.onResizeHandler = () => this.onResize();
3056
3099
  }
3057
- render(sequence, parentSequencePlaceIndicator) {
3100
+ render(sequence, parentPlaceIndicator) {
3058
3101
  if (this.rootComponent) {
3059
3102
  this.foreground.removeChild(this.rootComponent.view.g);
3060
3103
  }
3061
- this.rootComponent = this.context.services.rootComponent.create(this.foreground, sequence, parentSequencePlaceIndicator, this.context);
3104
+ this.rootComponent = this.context.services.rootComponent.create(this.foreground, sequence, parentPlaceIndicator, this.context);
3062
3105
  this.refreshSize();
3063
3106
  }
3064
3107
  setPositionAndScale(position, scale) {
@@ -3218,10 +3261,14 @@ class PressingBehavior {
3218
3261
  }
3219
3262
 
3220
3263
  class RerenderStepPressingBehaviorHandler {
3221
- constructor(designerContext) {
3264
+ constructor(command, designerContext) {
3265
+ this.command = command;
3222
3266
  this.designerContext = designerContext;
3223
3267
  }
3224
3268
  handle() {
3269
+ if (this.command.beforeCallback) {
3270
+ this.command.beforeCallback();
3271
+ }
3225
3272
  this.designerContext.workspaceController.updateRootComponent();
3226
3273
  }
3227
3274
  }
@@ -3259,7 +3306,7 @@ class ClickBehaviorResolver {
3259
3306
  case ClickCommandType.selectStep:
3260
3307
  return SelectStepBehavior.create(commandOrNull.component, forceMove, this.context);
3261
3308
  case ClickCommandType.rerenderStep:
3262
- return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(this.context));
3309
+ return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(commandOrNull, this.context));
3263
3310
  case ClickCommandType.openFolder:
3264
3311
  return PressingBehavior.create(element, new OpenFolderPressingBehaviorHandler(commandOrNull, this.context));
3265
3312
  case ClickCommandType.triggerCustomAction:
@@ -3395,8 +3442,9 @@ class ContextMenuController {
3395
3442
  }
3396
3443
 
3397
3444
  class ContextMenuItemsBuilder {
3398
- constructor(viewportApi, i18n, stateModifier, state, customMenuItemsProvider) {
3445
+ constructor(viewportApi, workspaceApi, i18n, stateModifier, state, customMenuItemsProvider) {
3399
3446
  this.viewportApi = viewportApi;
3447
+ this.workspaceApi = workspaceApi;
3400
3448
  this.i18n = i18n;
3401
3449
  this.stateModifier = stateModifier;
3402
3450
  this.state = state;
@@ -3455,8 +3503,9 @@ class ContextMenuItemsBuilder {
3455
3503
  }
3456
3504
  }
3457
3505
  }
3458
- else {
3459
- this.tryAppendCustomItems(items, null, this.state.definition.sequence);
3506
+ else if (!commandOrNull) {
3507
+ const rootSequence = this.workspaceApi.getRootSequence();
3508
+ this.tryAppendCustomItems(items, null, rootSequence.sequence);
3460
3509
  }
3461
3510
  items.push({
3462
3511
  label: this.i18n('contextMenu.resetView', 'Reset view'),
@@ -3470,7 +3519,7 @@ class ContextMenuItemsBuilder {
3470
3519
  }
3471
3520
  tryAppendCustomItems(items, step, parentSequence) {
3472
3521
  if (this.customMenuItemsProvider) {
3473
- const customItems = this.customMenuItemsProvider.getItems(step, parentSequence);
3522
+ const customItems = this.customMenuItemsProvider.getItems(step, parentSequence, this.state.definition);
3474
3523
  for (const customItem of customItems) {
3475
3524
  items.push(customItem);
3476
3525
  }
@@ -3561,15 +3610,11 @@ class Workspace {
3561
3610
  const clickBehaviorWrapper = designerContext.services.clickBehaviorWrapperExtension.create(designerContext.customActionController);
3562
3611
  const wheelController = designerContext.services.wheelController.create(api.viewport, api.workspace);
3563
3612
  const pinchToZoomController = PinchToZoomController.create(api.workspace, api.viewport, api.shadowRoot);
3564
- const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
3613
+ const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.workspace, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
3565
3614
  ? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
3566
3615
  : undefined);
3567
3616
  const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
3568
- const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, api.viewport, designerContext.services);
3569
- setTimeout(() => {
3570
- workspace.updateRootComponent();
3571
- api.viewport.resetViewport();
3572
- });
3617
+ const workspace = new Workspace(view, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, api.viewport, api.workspace, designerContext.services);
3573
3618
  designerContext.setWorkspaceController(workspace);
3574
3619
  designerContext.state.onViewportChanged.subscribe(workspace.onViewportChanged);
3575
3620
  race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged, designerContext.state.onFolderPathChanged).subscribe(r => {
@@ -3579,11 +3624,11 @@ class Workspace {
3579
3624
  view.bindTouchStart(workspace.onClick, workspace.onPinchToZoom);
3580
3625
  view.bindWheel(workspace.onWheel);
3581
3626
  view.bindContextMenu(workspace.onContextMenu);
3627
+ workspace.scheduleInit();
3582
3628
  return workspace;
3583
3629
  }
3584
- constructor(view, definitionWalker, state, behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, viewportApi, services) {
3630
+ constructor(view, state, behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, viewportApi, workspaceApi, services) {
3585
3631
  this.view = view;
3586
- this.definitionWalker = definitionWalker;
3587
3632
  this.state = state;
3588
3633
  this.behaviorController = behaviorController;
3589
3634
  this.wheelController = wheelController;
@@ -3592,9 +3637,11 @@ class Workspace {
3592
3637
  this.clickBehaviorResolver = clickBehaviorResolver;
3593
3638
  this.clickBehaviorWrapper = clickBehaviorWrapper;
3594
3639
  this.viewportApi = viewportApi;
3640
+ this.workspaceApi = workspaceApi;
3595
3641
  this.services = services;
3596
3642
  this.onRendered = new SimpleEvent();
3597
3643
  this.isValid = false;
3644
+ this.initTimeout = null;
3598
3645
  this.selectedStepComponent = null;
3599
3646
  this.validationErrorBadgeIndex = null;
3600
3647
  this.onClick = (position, target, buttonIndex, altKey) => {
@@ -3624,28 +3671,23 @@ class Workspace {
3624
3671
  this.view.setPositionAndScale(viewport.position, viewport.scale);
3625
3672
  };
3626
3673
  }
3674
+ scheduleInit() {
3675
+ this.initTimeout = setTimeout(() => {
3676
+ this.initTimeout = null;
3677
+ this.updateRootComponent();
3678
+ this.viewportApi.resetViewport();
3679
+ });
3680
+ }
3627
3681
  updateRootComponent() {
3628
3682
  this.selectedStepComponent = null;
3629
- let parentSequencePlaceIndicator;
3630
- let sequence;
3631
- const stepId = this.state.tryGetLastStepIdFromFolderPath();
3632
- if (stepId) {
3633
- const parentSequence = this.definitionWalker.getParentSequence(this.state.definition, stepId);
3634
- const children = this.definitionWalker.getChildren(parentSequence.step);
3635
- if (!children || children.type !== StepChildrenType.sequence) {
3636
- throw new Error('Cannot find single sequence in folder step');
3683
+ const rootSequence = this.workspaceApi.getRootSequence();
3684
+ const parentPlaceIndicator = rootSequence.parentStep
3685
+ ? {
3686
+ sequence: rootSequence.parentStep.parentSequence,
3687
+ index: rootSequence.parentStep.index
3637
3688
  }
3638
- sequence = children.items;
3639
- parentSequencePlaceIndicator = {
3640
- sequence: parentSequence.parentSequence,
3641
- index: parentSequence.index
3642
- };
3643
- }
3644
- else {
3645
- sequence = this.state.definition.sequence;
3646
- parentSequencePlaceIndicator = null;
3647
- }
3648
- this.view.render(sequence, parentSequencePlaceIndicator);
3689
+ : null;
3690
+ this.view.render(rootSequence.sequence, parentPlaceIndicator);
3649
3691
  this.trySelectStepComponent(this.state.selectedStepId);
3650
3692
  this.updateBadges();
3651
3693
  this.onRendered.forward();
@@ -3687,6 +3729,10 @@ class Workspace {
3687
3729
  setTimeout(() => this.view.refreshSize());
3688
3730
  }
3689
3731
  destroy() {
3732
+ if (this.initTimeout) {
3733
+ clearTimeout(this.initTimeout);
3734
+ this.initTimeout = null;
3735
+ }
3690
3736
  this.contextMenuController.destroy();
3691
3737
  this.view.destroy();
3692
3738
  }
@@ -3784,8 +3830,8 @@ const SAFE_OFFSET = 10;
3784
3830
  class DefaultDraggedComponent {
3785
3831
  static create(parent, step, componentContext) {
3786
3832
  const canvas = Dom.svg('svg');
3787
- canvas.style.marginLeft = -SAFE_OFFSET + 'px';
3788
- canvas.style.marginTop = -SAFE_OFFSET + 'px';
3833
+ canvas.style.marginLeft = -10 + 'px';
3834
+ canvas.style.marginTop = -10 + 'px';
3789
3835
  parent.appendChild(canvas);
3790
3836
  const previewStepContext = {
3791
3837
  parentSequence: [],
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Definition, Step, Sequence, ComponentType, DefinitionWalker, StepOrName } from 'sequential-workflow-model';
1
+ import { Definition, Step, Sequence, ComponentType, DefinitionWalker, StepWithParentSequence, StepOrName } from 'sequential-workflow-model';
2
2
  export * from 'sequential-workflow-model';
3
3
 
4
4
  declare class Icons {
@@ -211,6 +211,7 @@ interface SelectStepClickCommand extends BaseClickCommand {
211
211
  interface RerenderStepClickCommand extends BaseClickCommand {
212
212
  type: ClickCommandType.rerenderStep;
213
213
  step: Step;
214
+ beforeCallback?: () => void;
214
215
  }
215
216
  interface OpenFolderClickCommand extends BaseClickCommand {
216
217
  type: ClickCommandType.openFolder;
@@ -479,8 +480,9 @@ declare class ViewportApi {
479
480
 
480
481
  declare class WorkspaceApi {
481
482
  private readonly state;
483
+ private readonly definitionWalker;
482
484
  private readonly workspaceController;
483
- constructor(state: DesignerState, workspaceController: WorkspaceControllerWrapper);
485
+ constructor(state: DesignerState, definitionWalker: DefinitionWalker, workspaceController: WorkspaceControllerWrapper);
484
486
  getViewport(): Viewport;
485
487
  setViewport(viewport: Viewport): void;
486
488
  getCanvasPosition(): Vector;
@@ -489,6 +491,11 @@ declare class WorkspaceApi {
489
491
  updateRootComponent(): void;
490
492
  updateBadges(): void;
491
493
  updateCanvasSize(): void;
494
+ getRootSequence(): WorkspaceRootSequence;
495
+ }
496
+ interface WorkspaceRootSequence {
497
+ sequence: Sequence;
498
+ parentStep: StepWithParentSequence | null;
492
499
  }
493
500
 
494
501
  declare class DesignerApi {
@@ -548,7 +555,7 @@ declare class ComponentDom {
548
555
  }
549
556
 
550
557
  declare class InputView {
551
- private readonly root;
558
+ readonly g: SVGElement;
552
559
  static createRectInput(parent: SVGElement, x: number, y: number, size: number, radius: number, iconSize: number, iconUrl: string | null): InputView;
553
560
  static createRoundInput(parent: SVGElement, x: number, y: number, size: number): InputView;
554
561
  private constructor();
@@ -647,7 +654,7 @@ interface LineGridConfiguration {
647
654
  }
648
655
 
649
656
  interface SwitchStepComponentViewConfiguration {
650
- minContainerWidth: number;
657
+ minBranchWidth: number;
651
658
  paddingX: number;
652
659
  /**
653
660
  * The distance between the top of the container and the center point of the input.
@@ -658,6 +665,10 @@ interface SwitchStepComponentViewConfiguration {
658
665
  */
659
666
  paddingTop2: number;
660
667
  connectionHeight: number;
668
+ /**
669
+ * The distance between the end of the label and the bottom of the container when there are no branches.
670
+ */
671
+ noBranchPaddingBottom: number;
661
672
  inputSize: number;
662
673
  inputIconSize: number;
663
674
  autoHideInputOnDrag: boolean;
@@ -891,7 +902,7 @@ interface ContextMenuExtension {
891
902
  createItemsProvider?: (customActionController: CustomActionController) => ContextMenuItemsProvider;
892
903
  }
893
904
  interface ContextMenuItemsProvider {
894
- getItems(step: Step | null, sequence: Sequence): ContextMenuItem[];
905
+ getItems(step: Step | null, parentSequence: Sequence, definition: Definition): ContextMenuItem[];
895
906
  }
896
907
  interface ContextMenuItem {
897
908
  readonly label: string;
@@ -1367,4 +1378,5 @@ declare class Designer<TDefinition extends Definition = Definition> {
1367
1378
  private getHistoryController;
1368
1379
  }
1369
1380
 
1370
- export { Attributes, Badge, BadgeExtension, BadgeView, Badges, BadgesDecorator, BadgesResult, BaseClickCommand, Behavior, BehaviorEndToken, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickBehaviorWrapper, ClickBehaviorWrapperExtension, ClickCommand, ClickCommandType, ClickDetails, Component, ComponentContext, ComponentDom, ComponentView, ContainerStepComponentViewConfiguration, ContainerStepExtensionConfiguration, ContextMenuExtension, ContextMenuItem, ContextMenuItemsProvider, ControlBarApi, CustomAction, CustomActionController, CustomActionHandler, CustomActionHandlerContext, Daemon, DaemonExtension, DefaultRegionComponentViewExtension, DefaultRegionView, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerConfiguration, DefaultViewportControllerDesignerExtension, DefaultViewportControllerExtension, DefaultViewportControllerExtensionConfiguration, DefinitionChangeType, DefinitionChangedEvent, Designer, DesignerApi, DesignerConfiguration, DesignerContext, DesignerExtension, DesignerState, Dom, DraggedComponent, DraggedComponentExtension, Editor, EditorApi, EditorsConfiguration, FoundPlaceholders, Grid, GridExtension, I18n, Icons, InputView, JoinView, KeyboardAction, KeyboardConfiguration, LabelView, LineGridConfiguration, LineGridDesignerExtension, NextScale, ObjectCloner, OpenFolderClickCommand, OutputView, PathBarApi, Placeholder, PlaceholderController, PlaceholderControllerExtension, PlaceholderDirection, PlaceholderExtension, PlaceholderView, PreferenceStorage, RectPlaceholder, RectPlaceholderConfiguration, RectPlaceholderView, RegionComponentViewContentFactory, RegionComponentViewExtension, RegionView, RegionViewFactory, RerenderStepClickCommand, RootComponentExtension, RootEditorContext, RootEditorProvider, RootValidator, SelectStepBehaviorEndToken, SelectStepClickCommand, SelectedStepIdProvider, SequenceComponent, SequenceComponentExtension, SequenceContext, SequencePlaceIndicator, Services, ServicesResolver, SimpleEvent, SimpleEventListener, StartStopRootComponentDesignerExtension, StartStopRootComponentExtension, StartStopRootComponentExtensionConfiguration, StartStopRootComponentViewConfiguration, StateModifierDependency, StepBadgesDecoratorExtension, StepComponent, StepComponentView, StepComponentViewContext, StepComponentViewFactory, StepComponentViewWrapperExtension, StepContext, StepDefinition, StepDescriptionProvider, StepEditorContext, StepEditorProvider, StepExtension, StepExtensionResolver, StepIconUrlProvider, StepLabelProvider, StepValidator, StepsConfiguration, StepsDesignerExtension, StepsDesignerExtensionConfiguration, SwitchStepComponentViewConfiguration, SwitchStepExtensionConfiguration, TYPE, TaskStepComponentViewConfiguration, TaskStepExtensionConfiguration, ToolboxApi, ToolboxConfiguration, ToolboxGroupConfiguration, TriggerCustomActionClickCommand, UiComponent, UiComponentExtension, Uid, UidGenerator, UndoStack, UndoStackItem, ValidationErrorBadgeExtension, ValidationErrorBadgeExtensionConfiguration, ValidationErrorBadgeViewConfiguration, ValidatorConfiguration, Vector, Viewport, ViewportApi, ViewportController, ViewportControllerExtension, WheelController, WheelControllerExtension, WorkspaceApi, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, getAbsolutePosition, race };
1381
+ 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, PlaceholderDirection, RectPlaceholder, RectPlaceholderView, SelectStepBehaviorEndToken, ServicesResolver, SimpleEvent, StartStopRootComponentDesignerExtension, StartStopRootComponentExtension, StepComponent, StepExtensionResolver, StepsDesignerExtension, TYPE, ToolboxApi, Uid, ValidationErrorBadgeExtension, Vector, ViewportApi, WorkspaceApi, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, getAbsolutePosition, race };
1382
+ export type { Attributes, Badge, BadgeExtension, BadgeView, BadgesDecorator, BadgesResult, BaseClickCommand, Behavior, BehaviorEndToken, ClickBehaviorWrapper, ClickBehaviorWrapperExtension, ClickCommand, ClickDetails, Component, ComponentView, ContainerStepComponentViewConfiguration, ContainerStepExtensionConfiguration, ContextMenuExtension, ContextMenuItem, ContextMenuItemsProvider, CustomAction, CustomActionHandler, CustomActionHandlerContext, Daemon, DaemonExtension, DefaultViewportControllerConfiguration, DefaultViewportControllerExtensionConfiguration, DefinitionChangedEvent, DesignerConfiguration, DesignerExtension, DraggedComponent, DraggedComponentExtension, EditorsConfiguration, FoundPlaceholders, Grid, GridExtension, I18n, KeyboardConfiguration, LineGridConfiguration, NextScale, OpenFolderClickCommand, Placeholder, PlaceholderController, PlaceholderControllerExtension, PlaceholderExtension, PlaceholderView, PreferenceStorage, RectPlaceholderConfiguration, RegionComponentViewContentFactory, RegionComponentViewExtension, RegionView, RegionViewFactory, RerenderStepClickCommand, RootComponentExtension, RootEditorContext, RootEditorProvider, RootValidator, SelectStepClickCommand, SelectedStepIdProvider, SequenceComponent, SequenceComponentExtension, SequenceContext, SequencePlaceIndicator, Services, 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.27.4",
4
+ "version": "0.29.0",
5
5
  "type": "module",
6
6
  "main": "./lib/esm/index.js",
7
7
  "types": "./lib/index.d.ts",
@@ -78,7 +78,7 @@
78
78
  "sequential-workflow-model": "^0.2.0"
79
79
  },
80
80
  "devDependencies": {
81
- "@rollup/plugin-node-resolve": "^15.0.1",
81
+ "@rollup/plugin-node-resolve": "^16.0.1",
82
82
  "@types/jasmine": "^4.3.1",
83
83
  "@typescript-eslint/eslint-plugin": "^5.47.0",
84
84
  "@typescript-eslint/parser": "^5.47.0",
@@ -90,9 +90,9 @@
90
90
  "karma-typescript": "^5.5.3",
91
91
  "karma-typescript-es6-transform": "^5.5.3",
92
92
  "prettier": "^3.2.5",
93
- "rollup": "^3.18.0",
94
- "rollup-plugin-dts": "^5.2.0",
95
- "rollup-plugin-typescript2": "^0.34.1",
93
+ "rollup": "^4.40.0",
94
+ "rollup-plugin-dts": "^6.2.1",
95
+ "rollup-plugin-typescript2": "^0.36.0",
96
96
  "typescript": "^4.9.5",
97
97
  "sass": "^1.66.1"
98
98
  },