sequential-workflow-designer 0.24.8 → 0.26.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/cjs/index.cjs CHANGED
@@ -200,27 +200,17 @@ function race(timeout, a, b, c, d) {
200
200
  }
201
201
 
202
202
  class ControlBarApi {
203
- static create(state, historyController, stateModifier, viewportApi) {
204
- const api = new ControlBarApi(state, historyController, stateModifier, viewportApi);
203
+ static create(state, historyController, stateModifier) {
204
+ const api = new ControlBarApi(state, historyController, stateModifier);
205
205
  race(0, state.onIsReadonlyChanged, state.onSelectedStepIdChanged, state.onIsDragDisabledChanged, api.isUndoRedoSupported() ? state.onDefinitionChanged : undefined).subscribe(api.onStateChanged.forward);
206
206
  return api;
207
207
  }
208
- constructor(state, historyController, stateModifier, viewportApi) {
208
+ constructor(state, historyController, stateModifier) {
209
209
  this.state = state;
210
210
  this.historyController = historyController;
211
211
  this.stateModifier = stateModifier;
212
- this.viewportApi = viewportApi;
213
212
  this.onStateChanged = new SimpleEvent();
214
213
  }
215
- resetViewport() {
216
- this.viewportApi.resetViewport();
217
- }
218
- zoomIn() {
219
- this.viewportApi.zoom(true);
220
- }
221
- zoomOut() {
222
- this.viewportApi.zoom(false);
223
- }
224
214
  isDragDisabled() {
225
215
  return this.state.isDragDisabled;
226
216
  }
@@ -670,16 +660,91 @@ class ToolboxDataProvider {
670
660
  }
671
661
  }
672
662
 
663
+ function animate(interval, handler) {
664
+ const iv = setInterval(tick, 15);
665
+ const startTime = Date.now();
666
+ const anim = {
667
+ isAlive: true,
668
+ stop: () => {
669
+ anim.isAlive = false;
670
+ clearInterval(iv);
671
+ }
672
+ };
673
+ function tick() {
674
+ const progress = Math.min((Date.now() - startTime) / interval, 1);
675
+ handler(progress);
676
+ if (progress === 1) {
677
+ anim.stop();
678
+ }
679
+ }
680
+ return anim;
681
+ }
682
+
683
+ class ViewportAnimator {
684
+ constructor(state) {
685
+ this.state = state;
686
+ }
687
+ execute(target) {
688
+ if (this.animation && this.animation.isAlive) {
689
+ this.animation.stop();
690
+ }
691
+ const startPosition = this.state.viewport.position;
692
+ const startScale = this.state.viewport.scale;
693
+ const deltaPosition = startPosition.subtract(target.position);
694
+ const deltaScale = startScale - target.scale;
695
+ this.animation = animate(150, progress => {
696
+ const newScale = startScale - deltaScale * progress;
697
+ this.state.setViewport({
698
+ position: startPosition.subtract(deltaPosition.multiplyByScalar(progress)),
699
+ scale: newScale
700
+ });
701
+ });
702
+ }
703
+ }
704
+
705
+ class ZoomByWheelCalculator {
706
+ static calculate(controller, current, canvasPosition, e) {
707
+ if (e.deltaY === 0) {
708
+ return null;
709
+ }
710
+ const nextScale = controller.getNextScale(current.scale, e.deltaY < 0);
711
+ let scale;
712
+ const absDeltaY = Math.abs(e.deltaY);
713
+ if (absDeltaY < controller.smoothDeltaYLimit) {
714
+ const fraction = absDeltaY / controller.smoothDeltaYLimit;
715
+ const step = nextScale.next - nextScale.current;
716
+ scale = current.scale + step * fraction;
717
+ }
718
+ else {
719
+ scale = nextScale.next;
720
+ }
721
+ const mousePoint = new Vector(e.pageX, e.pageY).subtract(canvasPosition);
722
+ // The real point is point on canvas with no scale.
723
+ const mouseRealPoint = mousePoint.divideByScalar(current.scale).subtract(current.position.divideByScalar(current.scale));
724
+ const position = mouseRealPoint.multiplyByScalar(-scale).add(mousePoint);
725
+ return { position, scale };
726
+ }
727
+ }
728
+
673
729
  class ViewportApi {
674
- constructor(workspaceController, viewportController) {
730
+ constructor(state, workspaceController, viewportController) {
731
+ this.state = state;
675
732
  this.workspaceController = workspaceController;
676
733
  this.viewportController = viewportController;
734
+ this.animator = new ViewportAnimator(this.state);
735
+ }
736
+ limitScale(scale) {
737
+ return this.viewportController.limitScale(scale);
677
738
  }
678
739
  resetViewport() {
679
- this.viewportController.setDefault();
740
+ const defaultViewport = this.viewportController.getDefault();
741
+ this.state.setViewport(defaultViewport);
680
742
  }
681
743
  zoom(direction) {
682
- this.viewportController.zoom(direction);
744
+ const viewport = this.viewportController.getZoomed(direction);
745
+ if (viewport) {
746
+ this.state.setViewport(viewport);
747
+ }
683
748
  }
684
749
  moveViewportToStep(stepId) {
685
750
  const component = this.workspaceController.getComponentByStepId(stepId);
@@ -687,7 +752,15 @@ class ViewportApi {
687
752
  const clientPosition = component.view.getClientPosition();
688
753
  const componentPosition = clientPosition.subtract(canvasPosition);
689
754
  const componentSize = new Vector(component.view.width, component.view.height);
690
- this.viewportController.focusOnComponent(componentPosition, componentSize);
755
+ const viewport = this.viewportController.getFocusedOnComponent(componentPosition, componentSize);
756
+ this.animator.execute(viewport);
757
+ }
758
+ handleWheelEvent(e) {
759
+ const canvasPosition = this.workspaceController.getCanvasPosition();
760
+ const newViewport = ZoomByWheelCalculator.calculate(this.viewportController, this.state.viewport, canvasPosition, e);
761
+ if (newViewport) {
762
+ this.state.setViewport(newViewport);
763
+ }
691
764
  }
692
765
  }
693
766
 
@@ -696,6 +769,12 @@ class WorkspaceApi {
696
769
  this.state = state;
697
770
  this.workspaceController = workspaceController;
698
771
  }
772
+ getViewport() {
773
+ return this.state.viewport;
774
+ }
775
+ setViewport(viewport) {
776
+ this.state.setViewport(viewport);
777
+ }
699
778
  getCanvasPosition() {
700
779
  return this.workspaceController.getCanvasPosition();
701
780
  }
@@ -705,12 +784,6 @@ class WorkspaceApi {
705
784
  getRootComponentSize() {
706
785
  return this.workspaceController.getRootComponentSize();
707
786
  }
708
- getViewport() {
709
- return this.state.viewport;
710
- }
711
- setViewport(viewport) {
712
- this.state.setViewport(viewport);
713
- }
714
787
  updateRootComponent() {
715
788
  this.workspaceController.updateRootComponent();
716
789
  }
@@ -726,9 +799,8 @@ class DesignerApi {
726
799
  static create(context) {
727
800
  const workspace = new WorkspaceApi(context.state, context.workspaceController);
728
801
  const viewportController = context.services.viewportController.create(workspace);
729
- const viewport = new ViewportApi(context.workspaceController, viewportController);
730
802
  const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
731
- return new DesignerApi(context.configuration.shadowRoot, 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);
803
+ 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);
732
804
  }
733
805
  constructor(shadowRoot, controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
734
806
  this.shadowRoot = shadowRoot;
@@ -743,36 +815,15 @@ class DesignerApi {
743
815
  }
744
816
  }
745
817
 
746
- class DefinitionValidator {
747
- constructor(configuration, state) {
748
- this.configuration = configuration;
749
- this.state = state;
750
- }
751
- validateStep(step, parentSequence) {
752
- var _a;
753
- if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.step) {
754
- return this.configuration.step(step, parentSequence, this.state.definition);
755
- }
756
- return true;
757
- }
758
- validateRoot() {
759
- var _a;
760
- if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.root) {
761
- return this.configuration.root(this.state.definition);
762
- }
763
- return true;
764
- }
765
- }
766
-
767
- class IconProvider {
768
- constructor(configuration) {
769
- this.configuration = configuration;
818
+ const TYPE = 'selectStep';
819
+ class SelectStepBehaviorEndToken {
820
+ static is(token) {
821
+ return Boolean(token) && token.type === TYPE;
770
822
  }
771
- getIconUrl(step) {
772
- if (this.configuration.iconUrlProvider) {
773
- return this.configuration.iconUrlProvider(step.componentType, step.type);
774
- }
775
- return null;
823
+ constructor(stepId, time) {
824
+ this.stepId = stepId;
825
+ this.time = time;
826
+ this.type = TYPE;
776
827
  }
777
828
  }
778
829
 
@@ -837,321 +888,76 @@ function createG(parentElement) {
837
888
  return g;
838
889
  }
839
890
 
840
- exports.ClickCommandType = void 0;
841
- (function (ClickCommandType) {
842
- ClickCommandType[ClickCommandType["selectStep"] = 1] = "selectStep";
843
- ClickCommandType[ClickCommandType["rerenderStep"] = 2] = "rerenderStep";
844
- ClickCommandType[ClickCommandType["openFolder"] = 3] = "openFolder";
845
- ClickCommandType[ClickCommandType["triggerCustomAction"] = 4] = "triggerCustomAction";
846
- })(exports.ClickCommandType || (exports.ClickCommandType = {}));
847
- exports.PlaceholderDirection = void 0;
848
- (function (PlaceholderDirection) {
849
- PlaceholderDirection[PlaceholderDirection["none"] = 0] = "none";
850
- PlaceholderDirection[PlaceholderDirection["in"] = 1] = "in";
851
- PlaceholderDirection[PlaceholderDirection["out"] = 2] = "out";
852
- })(exports.PlaceholderDirection || (exports.PlaceholderDirection = {}));
853
-
854
- class StepComponent {
855
- static create(view, stepContext, componentContext) {
856
- const badges = Badges.createForStep(stepContext, view, componentContext);
857
- return new StepComponent(view, stepContext.step, stepContext.parentSequence, view.hasOutput, badges);
891
+ class ValidationErrorBadgeView {
892
+ static create(parent, cfg) {
893
+ const g = Dom.svg('g');
894
+ const halfOfSize = cfg.size / 2;
895
+ const circle = Dom.svg('path', {
896
+ class: 'sqd-validation-error',
897
+ d: `M 0 ${-halfOfSize} l ${halfOfSize} ${cfg.size} l ${-cfg.size} 0 Z`
898
+ });
899
+ Dom.translate(circle, halfOfSize, halfOfSize);
900
+ g.appendChild(circle);
901
+ const icon = Icons.appendPath(g, 'sqd-validation-error-icon-path', Icons.alert, cfg.iconSize);
902
+ const offsetX = (cfg.size - cfg.iconSize) / 2;
903
+ const offsetY = offsetX * 1.5;
904
+ Dom.translate(icon, offsetX, offsetY);
905
+ parent.appendChild(g);
906
+ return new ValidationErrorBadgeView(parent, g, cfg.size, cfg.size);
858
907
  }
859
- constructor(view, step, parentSequence, hasOutput, badges) {
860
- this.view = view;
861
- this.step = step;
862
- this.parentSequence = parentSequence;
863
- this.hasOutput = hasOutput;
864
- this.badges = badges;
908
+ constructor(parent, g, width, height) {
909
+ this.parent = parent;
910
+ this.g = g;
911
+ this.width = width;
912
+ this.height = height;
865
913
  }
866
- findById(stepId) {
867
- if (this.step.id === stepId) {
868
- return this;
869
- }
870
- if (this.view.sequenceComponents) {
871
- for (const component of this.view.sequenceComponents) {
872
- const result = component.findById(stepId);
873
- if (result) {
874
- return result;
875
- }
876
- }
877
- }
878
- return null;
914
+ destroy() {
915
+ this.parent.removeChild(this.g);
879
916
  }
880
- resolveClick(click) {
881
- if (this.view.sequenceComponents) {
882
- for (const component of this.view.sequenceComponents) {
883
- const result = component.resolveClick(click);
884
- if (result) {
885
- return result;
886
- }
917
+ }
918
+
919
+ class ValidatorFactory {
920
+ static createForStep(stepContext, view, componentContext) {
921
+ return () => {
922
+ if (!componentContext.validator.validateStep(stepContext.step, stepContext.parentSequence)) {
923
+ return false;
887
924
  }
888
- }
889
- const badgeResult = this.badges.resolveClick(click);
890
- if (badgeResult) {
891
- return badgeResult;
892
- }
893
- const viewResult = this.view.resolveClick(click);
894
- if (viewResult) {
895
- return viewResult === true
896
- ? {
897
- type: exports.ClickCommandType.selectStep,
898
- component: this
925
+ if (view.haveCollapsedChildren) {
926
+ let allChildrenValid = true;
927
+ componentContext.definitionWalker.forEachChildren(stepContext.step, (step, _, parentSequence) => {
928
+ if (!componentContext.validator.validateStep(step, parentSequence)) {
929
+ allChildrenValid = false;
930
+ return false;
931
+ }
932
+ });
933
+ if (!allChildrenValid) {
934
+ return false;
899
935
  }
900
- : viewResult;
901
- }
902
- return null;
903
- }
904
- resolvePlaceholders(skipComponent, result) {
905
- if (skipComponent !== this) {
906
- if (this.view.sequenceComponents) {
907
- this.view.sequenceComponents.forEach(component => component.resolvePlaceholders(skipComponent, result));
908
- }
909
- if (this.view.placeholders) {
910
- this.view.placeholders.forEach(ph => result.placeholders.push(ph));
911
936
  }
912
- result.components.push(this);
913
- }
937
+ return true;
938
+ };
914
939
  }
915
- setIsDragging(isDragging) {
916
- this.view.setIsDragging(isDragging);
940
+ static createForRoot(componentContext) {
941
+ return () => {
942
+ return componentContext.validator.validateRoot();
943
+ };
917
944
  }
918
- setIsSelected(isSelected) {
919
- this.view.setIsSelected(isSelected);
945
+ }
946
+
947
+ class ValidationErrorBadge {
948
+ static createForStep(parentElement, view, stepContext, componentContext, configuration) {
949
+ const validator = ValidatorFactory.createForStep(stepContext, view, componentContext);
950
+ return new ValidationErrorBadge(parentElement, validator, configuration);
920
951
  }
921
- setIsDisabled(isDisabled) {
922
- this.view.setIsDisabled(isDisabled);
952
+ static createForRoot(parentElement, componentContext, configuration) {
953
+ const validator = ValidatorFactory.createForRoot(componentContext);
954
+ return new ValidationErrorBadge(parentElement, validator, configuration);
923
955
  }
924
- updateBadges(result) {
925
- if (this.view.sequenceComponents) {
926
- this.view.sequenceComponents.forEach(component => component.updateBadges(result));
927
- }
928
- this.badges.update(result);
929
- }
930
- }
931
-
932
- class StepComponentViewContextFactory {
933
- static create(stepContext, componentContext) {
934
- const preferenceKeyPrefix = stepContext.step.id + ':';
935
- return {
936
- i18n: componentContext.i18n,
937
- getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
938
- getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
939
- createSequenceComponent: (parentElement, sequence) => {
940
- const sequenceContext = {
941
- sequence,
942
- depth: stepContext.depth + 1,
943
- isInputConnected: true,
944
- isOutputConnected: stepContext.isOutputConnected,
945
- isPreview: stepContext.isPreview
946
- };
947
- return componentContext.services.sequenceComponent.create(parentElement, sequenceContext, componentContext);
948
- },
949
- createRegionComponentView(parentElement, componentClassName, contentFactory) {
950
- return componentContext.services.regionComponentView.create(parentElement, componentClassName, stepContext, this, contentFactory);
951
- },
952
- createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
953
- getPreference: (key) => componentContext.preferenceStorage.getItem(preferenceKeyPrefix + key),
954
- setPreference: (key, value) => componentContext.preferenceStorage.setItem(preferenceKeyPrefix + key, value)
955
- };
956
- }
957
- }
958
-
959
- class StepComponentFactory {
960
- constructor(stepExtensionResolver) {
961
- this.stepExtensionResolver = stepExtensionResolver;
962
- }
963
- create(parentElement, stepContext, componentContext) {
964
- const viewContext = StepComponentViewContextFactory.create(stepContext, componentContext);
965
- const extension = this.stepExtensionResolver.resolve(stepContext.step.componentType);
966
- const view = extension.createComponentView(parentElement, stepContext, viewContext);
967
- const wrappedView = componentContext.services.stepComponentViewWrapper.wrap(view, stepContext);
968
- return StepComponent.create(wrappedView, stepContext, componentContext);
969
- }
970
- }
971
-
972
- class ComponentContext {
973
- static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
974
- const validator = new DefinitionValidator(configuration.validator, state);
975
- const iconProvider = new IconProvider(configuration.steps);
976
- const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
977
- return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
978
- }
979
- constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
980
- this.shadowRoot = shadowRoot;
981
- this.validator = validator;
982
- this.iconProvider = iconProvider;
983
- this.placeholderController = placeholderController;
984
- this.stepComponentFactory = stepComponentFactory;
985
- this.definitionWalker = definitionWalker;
986
- this.services = services;
987
- this.preferenceStorage = preferenceStorage;
988
- this.i18n = i18n;
989
- }
990
- }
991
-
992
- class CustomActionController {
993
- constructor(configuration, state, stateModifier) {
994
- this.configuration = configuration;
995
- this.state = state;
996
- this.stateModifier = stateModifier;
997
- }
998
- trigger(action, step, sequence) {
999
- const handler = this.configuration.customActionHandler;
1000
- if (!handler) {
1001
- console.warn(`Custom action handler is not defined (action type: ${action.type})`);
1002
- return;
1003
- }
1004
- const context = this.createCustomActionHandlerContext();
1005
- handler(action, step, sequence, context);
1006
- }
1007
- createCustomActionHandlerContext() {
1008
- return {
1009
- notifyStepNameChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepNameChanged, stepId, false),
1010
- notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepPropertyChanged, stepId, false),
1011
- notifyStepInserted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepInserted, stepId, true),
1012
- notifyStepMoved: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepMoved, stepId, true),
1013
- notifyStepDeleted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepDeleted, stepId, true)
1014
- };
1015
- }
1016
- notifyStepChanged(changeType, stepId, updateDependencies) {
1017
- if (!stepId) {
1018
- throw new Error('Step id is empty');
1019
- }
1020
- this.state.notifyDefinitionChanged(changeType, stepId);
1021
- if (updateDependencies) {
1022
- this.stateModifier.updateDependencies();
1023
- }
1024
- }
1025
- }
1026
-
1027
- class EditorView {
1028
- static create(parent) {
1029
- return new EditorView(parent);
1030
- }
1031
- constructor(parent) {
1032
- this.parent = parent;
1033
- this.currentContainer = null;
1034
- }
1035
- setContent(content, className) {
1036
- const container = Dom.element('div', {
1037
- class: className
1038
- });
1039
- container.appendChild(content);
1040
- if (this.currentContainer) {
1041
- this.parent.removeChild(this.currentContainer);
1042
- }
1043
- this.parent.appendChild(container);
1044
- this.currentContainer = container;
1045
- }
1046
- destroy() {
1047
- if (this.currentContainer) {
1048
- this.parent.removeChild(this.currentContainer);
1049
- }
1050
- }
1051
- }
1052
-
1053
- class Editor {
1054
- static create(parent, api, stepEditorClassName, stepEditorProvider, rootEditorClassName, rootEditorProvider, customSelectedStepIdProvider) {
1055
- const view = EditorView.create(parent);
1056
- function render(step) {
1057
- const definition = api.getDefinition();
1058
- let content;
1059
- let className;
1060
- if (step) {
1061
- const stepContext = api.createStepEditorContext(step.id);
1062
- content = stepEditorProvider(step, stepContext, definition, api.isReadonly());
1063
- className = stepEditorClassName;
1064
- }
1065
- else {
1066
- const rootContext = api.createRootEditorContext();
1067
- content = rootEditorProvider(definition, rootContext, api.isReadonly());
1068
- className = rootEditorClassName;
1069
- }
1070
- view.setContent(content, className);
1071
- }
1072
- const renderer = api.runRenderer(step => render(step), customSelectedStepIdProvider);
1073
- return new Editor(view, renderer);
1074
- }
1075
- constructor(view, renderer) {
1076
- this.view = view;
1077
- this.renderer = renderer;
1078
- }
1079
- destroy() {
1080
- this.view.destroy();
1081
- this.renderer.destroy();
1082
- }
1083
- }
1084
-
1085
- class ValidationErrorBadgeView {
1086
- static create(parent, cfg) {
1087
- const g = Dom.svg('g');
1088
- const halfOfSize = cfg.size / 2;
1089
- const circle = Dom.svg('path', {
1090
- class: 'sqd-validation-error',
1091
- d: `M 0 ${-halfOfSize} l ${halfOfSize} ${cfg.size} l ${-cfg.size} 0 Z`
1092
- });
1093
- Dom.translate(circle, halfOfSize, halfOfSize);
1094
- g.appendChild(circle);
1095
- const icon = Icons.appendPath(g, 'sqd-validation-error-icon-path', Icons.alert, cfg.iconSize);
1096
- const offsetX = (cfg.size - cfg.iconSize) / 2;
1097
- const offsetY = offsetX * 1.5;
1098
- Dom.translate(icon, offsetX, offsetY);
1099
- parent.appendChild(g);
1100
- return new ValidationErrorBadgeView(parent, g, cfg.size, cfg.size);
1101
- }
1102
- constructor(parent, g, width, height) {
1103
- this.parent = parent;
1104
- this.g = g;
1105
- this.width = width;
1106
- this.height = height;
1107
- }
1108
- destroy() {
1109
- this.parent.removeChild(this.g);
1110
- }
1111
- }
1112
-
1113
- class ValidatorFactory {
1114
- static createForStep(stepContext, view, componentContext) {
1115
- return () => {
1116
- if (!componentContext.validator.validateStep(stepContext.step, stepContext.parentSequence)) {
1117
- return false;
1118
- }
1119
- if (view.haveCollapsedChildren) {
1120
- let allChildrenValid = true;
1121
- componentContext.definitionWalker.forEachChildren(stepContext.step, (step, _, parentSequence) => {
1122
- if (!componentContext.validator.validateStep(step, parentSequence)) {
1123
- allChildrenValid = false;
1124
- return false;
1125
- }
1126
- });
1127
- if (!allChildrenValid) {
1128
- return false;
1129
- }
1130
- }
1131
- return true;
1132
- };
1133
- }
1134
- static createForRoot(componentContext) {
1135
- return () => {
1136
- return componentContext.validator.validateRoot();
1137
- };
1138
- }
1139
- }
1140
-
1141
- class ValidationErrorBadge {
1142
- static createForStep(parentElement, view, stepContext, componentContext, configuration) {
1143
- const validator = ValidatorFactory.createForStep(stepContext, view, componentContext);
1144
- return new ValidationErrorBadge(parentElement, validator, configuration);
1145
- }
1146
- static createForRoot(parentElement, componentContext, configuration) {
1147
- const validator = ValidatorFactory.createForRoot(componentContext);
1148
- return new ValidationErrorBadge(parentElement, validator, configuration);
1149
- }
1150
- constructor(parentElement, validator, configuration) {
1151
- this.parentElement = parentElement;
1152
- this.validator = validator;
1153
- this.configuration = configuration;
1154
- this.view = null;
956
+ constructor(parentElement, validator, configuration) {
957
+ this.parentElement = parentElement;
958
+ this.validator = validator;
959
+ this.configuration = configuration;
960
+ this.view = null;
1155
961
  }
1156
962
  update(result) {
1157
963
  const isValid = this.validator();
@@ -1171,7 +977,7 @@ class ValidationErrorBadge {
1171
977
  }
1172
978
  }
1173
979
 
1174
- const defaultConfiguration$6 = {
980
+ const defaultConfiguration$7 = {
1175
981
  view: {
1176
982
  size: 22,
1177
983
  iconSize: 12
@@ -1179,7 +985,7 @@ const defaultConfiguration$6 = {
1179
985
  };
1180
986
  class ValidationErrorBadgeExtension {
1181
987
  static create(configuration) {
1182
- return new ValidationErrorBadgeExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$6);
988
+ return new ValidationErrorBadgeExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$7);
1183
989
  }
1184
990
  constructor(configuration) {
1185
991
  this.configuration = configuration;
@@ -1479,6 +1285,20 @@ class DefaultSequenceComponent {
1479
1285
  }
1480
1286
  }
1481
1287
 
1288
+ exports.ClickCommandType = void 0;
1289
+ (function (ClickCommandType) {
1290
+ ClickCommandType[ClickCommandType["selectStep"] = 1] = "selectStep";
1291
+ ClickCommandType[ClickCommandType["rerenderStep"] = 2] = "rerenderStep";
1292
+ ClickCommandType[ClickCommandType["openFolder"] = 3] = "openFolder";
1293
+ ClickCommandType[ClickCommandType["triggerCustomAction"] = 4] = "triggerCustomAction";
1294
+ })(exports.ClickCommandType || (exports.ClickCommandType = {}));
1295
+ exports.PlaceholderDirection = void 0;
1296
+ (function (PlaceholderDirection) {
1297
+ PlaceholderDirection[PlaceholderDirection["none"] = 0] = "none";
1298
+ PlaceholderDirection[PlaceholderDirection["in"] = 1] = "in";
1299
+ PlaceholderDirection[PlaceholderDirection["out"] = 2] = "out";
1300
+ })(exports.PlaceholderDirection || (exports.PlaceholderDirection = {}));
1301
+
1482
1302
  class StartStopRootComponentView {
1483
1303
  static create(parent, sequence, parentPlaceIndicator, context, cfg) {
1484
1304
  const g = Dom.svg('g', {
@@ -1575,7 +1395,7 @@ class StartStopRootComponent {
1575
1395
  }
1576
1396
  }
1577
1397
 
1578
- const defaultConfiguration$5 = {
1398
+ const defaultConfiguration$6 = {
1579
1399
  view: {
1580
1400
  size: 30,
1581
1401
  defaultIconSize: 22,
@@ -1587,7 +1407,7 @@ const defaultConfiguration$5 = {
1587
1407
  };
1588
1408
  class StartStopRootComponentExtension {
1589
1409
  static create(configuration) {
1590
- return new StartStopRootComponentExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$5);
1410
+ return new StartStopRootComponentExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$6);
1591
1411
  }
1592
1412
  constructor(configuration) {
1593
1413
  this.configuration = configuration;
@@ -1821,15 +1641,15 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
1821
1641
  };
1822
1642
 
1823
1643
  class CenteredViewportCalculator {
1824
- static center(margin, canvasSize, rootComponentSize) {
1644
+ static center(padding, canvasSize, rootComponentSize) {
1825
1645
  if (canvasSize.x === 0 || canvasSize.y === 0) {
1826
1646
  return {
1827
1647
  position: new Vector(0, 0),
1828
1648
  scale: 1
1829
1649
  };
1830
1650
  }
1831
- const canvasSafeWidth = Math.max(canvasSize.x - margin * 2, 0);
1832
- const canvasSafeHeight = Math.max(canvasSize.y - margin * 2, 0);
1651
+ const canvasSafeWidth = Math.max(canvasSize.x - padding * 2, 0);
1652
+ const canvasSafeHeight = Math.max(canvasSize.y - padding * 2, 0);
1833
1653
  const scale = Math.min(Math.min(canvasSafeWidth / rootComponentSize.x, canvasSafeHeight / rootComponentSize.y), 1);
1834
1654
  const width = rootComponentSize.x * scale;
1835
1655
  const height = rootComponentSize.y * scale;
@@ -1840,7 +1660,7 @@ class CenteredViewportCalculator {
1840
1660
  scale
1841
1661
  };
1842
1662
  }
1843
- static focusOnComponent(canvasSize, viewport, componentPosition, componentSize) {
1663
+ static getFocusedOnComponent(canvasSize, viewport, componentPosition, componentSize) {
1844
1664
  const realPosition = viewport.position.divideByScalar(viewport.scale).subtract(componentPosition.divideByScalar(viewport.scale));
1845
1665
  const componentOffset = componentSize.divideByScalar(2);
1846
1666
  const position = realPosition.add(canvasSize.divideByScalar(2)).subtract(componentOffset);
@@ -1848,82 +1668,15 @@ class CenteredViewportCalculator {
1848
1668
  }
1849
1669
  }
1850
1670
 
1851
- class NextQuantifiedNumber {
1852
- constructor(values) {
1853
- this.values = values;
1854
- }
1855
- next(value, direction) {
1856
- let bestIndex = 0;
1857
- let bestDistance = Number.MAX_VALUE;
1858
- for (let i = 0; i < this.values.length; i++) {
1859
- const distance = Math.abs(this.values[i] - value);
1860
- if (bestDistance > distance) {
1861
- bestIndex = i;
1862
- bestDistance = distance;
1863
- }
1864
- }
1865
- let index;
1866
- if (direction) {
1867
- index = Math.min(bestIndex + 1, this.values.length - 1);
1868
- }
1869
- else {
1870
- index = Math.max(bestIndex - 1, 0);
1871
- }
1872
- return {
1873
- current: this.values[bestIndex],
1874
- next: this.values[index]
1875
- };
1876
- }
1877
- }
1878
-
1879
- const SCALES = [0.06, 0.08, 0.1, 0.12, 0.16, 0.2, 0.26, 0.32, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1];
1880
- const MAX_DELTA_Y$1 = 16;
1881
- const quantifiedScale = new NextQuantifiedNumber(SCALES);
1882
- class QuantifiedScaleViewportCalculator {
1883
- static zoom(current, direction) {
1884
- const nextScale = quantifiedScale.next(current.scale, direction);
1885
- return {
1886
- position: current.position,
1887
- scale: nextScale.next
1888
- };
1889
- }
1890
- static zoomByWheel(current, e, canvasPosition) {
1891
- if (e.deltaY === 0) {
1892
- return null;
1893
- }
1894
- const nextScale = quantifiedScale.next(current.scale, e.deltaY < 0);
1895
- let scale;
1896
- const absDeltaY = Math.abs(e.deltaY);
1897
- if (absDeltaY < MAX_DELTA_Y$1) {
1898
- const fraction = absDeltaY / MAX_DELTA_Y$1;
1899
- const step = nextScale.next - nextScale.current;
1900
- scale = current.scale + step * fraction;
1901
- }
1902
- else {
1903
- scale = nextScale.next;
1904
- }
1905
- const mousePoint = new Vector(e.pageX, e.pageY).subtract(canvasPosition);
1906
- // The real point is point on canvas with no scale.
1907
- const mouseRealPoint = mousePoint.divideByScalar(current.scale).subtract(current.position.divideByScalar(current.scale));
1908
- const position = mouseRealPoint.multiplyByScalar(-scale).add(mousePoint);
1909
- return { position, scale };
1910
- }
1911
- }
1912
-
1913
- class ClassicWheelController {
1914
- static create(api) {
1915
- return new ClassicWheelController(api);
1671
+ class ClassicWheelController {
1672
+ static create(api) {
1673
+ return new ClassicWheelController(api);
1916
1674
  }
1917
1675
  constructor(api) {
1918
1676
  this.api = api;
1919
1677
  }
1920
1678
  onWheel(e) {
1921
- const viewport = this.api.getViewport();
1922
- const canvasPosition = this.api.getCanvasPosition();
1923
- const newViewport = QuantifiedScaleViewportCalculator.zoomByWheel(viewport, e, canvasPosition);
1924
- if (newViewport) {
1925
- this.api.setViewport(newViewport);
1926
- }
1679
+ this.api.handleWheelEvent(e);
1927
1680
  }
1928
1681
  }
1929
1682
 
@@ -1933,83 +1686,172 @@ class ClassicWheelControllerExtension {
1933
1686
  }
1934
1687
  }
1935
1688
 
1936
- function animate(interval, handler) {
1937
- const iv = setInterval(tick, 15);
1938
- const startTime = Date.now();
1939
- const anim = {
1940
- isAlive: true,
1941
- stop: () => {
1942
- anim.isAlive = false;
1943
- clearInterval(iv);
1689
+ class NextQuantifiedNumber {
1690
+ constructor(values) {
1691
+ this.values = values;
1692
+ }
1693
+ next(value, direction) {
1694
+ let bestIndex = 0;
1695
+ let bestDistance = Number.MAX_VALUE;
1696
+ for (let i = 0; i < this.values.length; i++) {
1697
+ const distance = Math.abs(this.values[i] - value);
1698
+ if (bestDistance > distance) {
1699
+ bestIndex = i;
1700
+ bestDistance = distance;
1701
+ }
1944
1702
  }
1945
- };
1946
- function tick() {
1947
- const progress = Math.min((Date.now() - startTime) / interval, 1);
1948
- handler(progress);
1949
- if (progress === 1) {
1950
- anim.stop();
1703
+ let index;
1704
+ if (direction) {
1705
+ index = Math.min(bestIndex + 1, this.values.length - 1);
1951
1706
  }
1952
- }
1953
- return anim;
1954
- }
1955
-
1956
- class ViewportAnimator {
1957
- constructor(api) {
1958
- this.api = api;
1959
- }
1960
- execute(target) {
1961
- if (this.animation && this.animation.isAlive) {
1962
- this.animation.stop();
1707
+ else {
1708
+ index = Math.max(bestIndex - 1, 0);
1963
1709
  }
1964
- const viewport = this.api.getViewport();
1965
- const startPosition = viewport.position;
1966
- const startScale = viewport.scale;
1967
- const deltaPosition = startPosition.subtract(target.position);
1968
- const deltaScale = startScale - target.scale;
1969
- this.animation = animate(150, progress => {
1970
- const newScale = startScale - deltaScale * progress;
1971
- this.api.setViewport({
1972
- position: startPosition.subtract(deltaPosition.multiplyByScalar(progress)),
1973
- scale: newScale
1974
- });
1975
- });
1710
+ return {
1711
+ current: this.values[bestIndex],
1712
+ next: this.values[index]
1713
+ };
1714
+ }
1715
+ limit(scale) {
1716
+ const min = this.values[0];
1717
+ const max = this.values[this.values.length - 1];
1718
+ return Math.min(Math.max(scale, min), max);
1976
1719
  }
1977
1720
  }
1978
1721
 
1979
- const CENTER_MARGIN = 10;
1722
+ const defaultConfiguration$5 = {
1723
+ scales: [0.06, 0.08, 0.1, 0.12, 0.16, 0.2, 0.26, 0.32, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1],
1724
+ smoothDeltaYLimit: 16,
1725
+ padding: 10
1726
+ };
1980
1727
  class DefaultViewportController {
1981
- static create(api) {
1982
- return new DefaultViewportController(api);
1728
+ static create(api, configuration) {
1729
+ const config = configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$5;
1730
+ const nqn = new NextQuantifiedNumber(config.scales);
1731
+ return new DefaultViewportController(config.smoothDeltaYLimit, nqn, api, config.padding);
1983
1732
  }
1984
- constructor(api) {
1733
+ constructor(smoothDeltaYLimit, nqn, api, padding) {
1734
+ this.smoothDeltaYLimit = smoothDeltaYLimit;
1735
+ this.nqn = nqn;
1985
1736
  this.api = api;
1986
- this.animator = new ViewportAnimator(this.api);
1737
+ this.padding = padding;
1987
1738
  }
1988
- setDefault() {
1739
+ getDefault() {
1989
1740
  const rootComponentSize = this.api.getRootComponentSize();
1990
1741
  const canvasSize = this.api.getCanvasSize();
1991
- const target = CenteredViewportCalculator.center(CENTER_MARGIN, canvasSize, rootComponentSize);
1992
- this.api.setViewport(target);
1742
+ return CenteredViewportCalculator.center(this.padding, canvasSize, rootComponentSize);
1993
1743
  }
1994
- zoom(direction) {
1995
- const viewport = this.api.getViewport();
1996
- const target = QuantifiedScaleViewportCalculator.zoom(viewport, direction);
1997
- this.api.setViewport(target);
1744
+ getZoomed(direction) {
1745
+ const current = this.api.getViewport();
1746
+ const nextScale = this.nqn.next(current.scale, direction);
1747
+ if (nextScale) {
1748
+ return {
1749
+ position: current.position,
1750
+ scale: nextScale.next
1751
+ };
1752
+ }
1753
+ return null;
1998
1754
  }
1999
- focusOnComponent(componentPosition, componentSize) {
1755
+ getFocusedOnComponent(componentPosition, componentSize) {
2000
1756
  const viewport = this.api.getViewport();
2001
1757
  const canvasSize = this.api.getCanvasSize();
2002
- const target = CenteredViewportCalculator.focusOnComponent(canvasSize, viewport, componentPosition, componentSize);
2003
- this.animateTo(target);
1758
+ return CenteredViewportCalculator.getFocusedOnComponent(canvasSize, viewport, componentPosition, componentSize);
2004
1759
  }
2005
- animateTo(viewport) {
2006
- this.animator.execute(viewport);
1760
+ getNextScale(scale, direction) {
1761
+ return this.nqn.next(scale, direction);
1762
+ }
1763
+ limitScale(scale) {
1764
+ return this.nqn.limit(scale);
2007
1765
  }
2008
1766
  }
2009
1767
 
2010
1768
  class DefaultViewportControllerExtension {
2011
- constructor() {
2012
- this.create = DefaultViewportController.create;
1769
+ static create(configuration) {
1770
+ return new DefaultViewportControllerExtension(configuration);
1771
+ }
1772
+ constructor(configuration) {
1773
+ this.configuration = configuration;
1774
+ }
1775
+ create(api) {
1776
+ return DefaultViewportController.create(api, this.configuration);
1777
+ }
1778
+ }
1779
+
1780
+ class StepComponent {
1781
+ static create(view, stepContext, componentContext) {
1782
+ const badges = Badges.createForStep(stepContext, view, componentContext);
1783
+ return new StepComponent(view, stepContext.step, stepContext.parentSequence, view.hasOutput, badges);
1784
+ }
1785
+ constructor(view, step, parentSequence, hasOutput, badges) {
1786
+ this.view = view;
1787
+ this.step = step;
1788
+ this.parentSequence = parentSequence;
1789
+ this.hasOutput = hasOutput;
1790
+ this.badges = badges;
1791
+ }
1792
+ findById(stepId) {
1793
+ if (this.step.id === stepId) {
1794
+ return this;
1795
+ }
1796
+ if (this.view.sequenceComponents) {
1797
+ for (const component of this.view.sequenceComponents) {
1798
+ const result = component.findById(stepId);
1799
+ if (result) {
1800
+ return result;
1801
+ }
1802
+ }
1803
+ }
1804
+ return null;
1805
+ }
1806
+ resolveClick(click) {
1807
+ if (this.view.sequenceComponents) {
1808
+ for (const component of this.view.sequenceComponents) {
1809
+ const result = component.resolveClick(click);
1810
+ if (result) {
1811
+ return result;
1812
+ }
1813
+ }
1814
+ }
1815
+ const badgeResult = this.badges.resolveClick(click);
1816
+ if (badgeResult) {
1817
+ return badgeResult;
1818
+ }
1819
+ const viewResult = this.view.resolveClick(click);
1820
+ if (viewResult) {
1821
+ return viewResult === true
1822
+ ? {
1823
+ type: exports.ClickCommandType.selectStep,
1824
+ component: this
1825
+ }
1826
+ : viewResult;
1827
+ }
1828
+ return null;
1829
+ }
1830
+ resolvePlaceholders(skipComponent, result) {
1831
+ if (skipComponent !== this) {
1832
+ if (this.view.sequenceComponents) {
1833
+ this.view.sequenceComponents.forEach(component => component.resolvePlaceholders(skipComponent, result));
1834
+ }
1835
+ if (this.view.placeholders) {
1836
+ this.view.placeholders.forEach(ph => result.placeholders.push(ph));
1837
+ }
1838
+ result.components.push(this);
1839
+ }
1840
+ }
1841
+ setIsDragging(isDragging) {
1842
+ this.view.setIsDragging(isDragging);
1843
+ }
1844
+ setIsSelected(isSelected) {
1845
+ this.view.setIsSelected(isSelected);
1846
+ }
1847
+ setIsDisabled(isDisabled) {
1848
+ this.view.setIsDisabled(isDisabled);
1849
+ }
1850
+ updateBadges(result) {
1851
+ if (this.view.sequenceComponents) {
1852
+ this.view.sequenceComponents.forEach(component => component.updateBadges(result));
1853
+ }
1854
+ this.badges.update(result);
2013
1855
  }
2014
1856
  }
2015
1857
 
@@ -2132,24 +1974,375 @@ class DefaultRegionView {
2132
1974
  Dom.toggleClass(region, isSelected, 'sqd-selected');
2133
1975
  });
2134
1976
  }
2135
- }
2136
- function drawLine(parent, x1, y1, x2, y2) {
2137
- const line = Dom.svg('line', {
2138
- class: 'sqd-region',
2139
- x1,
2140
- y1,
2141
- x2,
2142
- y2
2143
- });
2144
- parent.insertBefore(line, parent.firstChild);
2145
- return line;
1977
+ }
1978
+ function drawLine(parent, x1, y1, x2, y2) {
1979
+ const line = Dom.svg('line', {
1980
+ class: 'sqd-region',
1981
+ x1,
1982
+ y1,
1983
+ x2,
1984
+ y2
1985
+ });
1986
+ parent.insertBefore(line, parent.firstChild);
1987
+ return line;
1988
+ }
1989
+
1990
+ class DefaultRegionComponentViewExtension {
1991
+ create(parentElement, componentClassName, stepContext, _, contentFactory) {
1992
+ const g = ComponentDom.stepG(componentClassName, stepContext.step.type, stepContext.step.id);
1993
+ parentElement.appendChild(g);
1994
+ return contentFactory(g, DefaultRegionView.create);
1995
+ }
1996
+ }
1997
+
1998
+ class DefaultViewportControllerDesignerExtension {
1999
+ static create(configuration) {
2000
+ return new DefaultViewportControllerDesignerExtension(DefaultViewportControllerExtension.create(configuration));
2001
+ }
2002
+ constructor(viewportController) {
2003
+ this.viewportController = viewportController;
2004
+ }
2005
+ }
2006
+
2007
+ class LineGrid {
2008
+ static create(size) {
2009
+ const path = Dom.svg('path', {
2010
+ class: 'sqd-line-grid-path',
2011
+ fill: 'none'
2012
+ });
2013
+ return new LineGrid(size, path);
2014
+ }
2015
+ constructor(size, element) {
2016
+ this.size = size;
2017
+ this.element = element;
2018
+ }
2019
+ setScale(_, scaledSize) {
2020
+ Dom.attrs(this.element, {
2021
+ d: `M ${scaledSize.x} 0 L 0 0 0 ${scaledSize.y}`
2022
+ });
2023
+ }
2024
+ }
2025
+
2026
+ const defaultConfiguration$4 = {
2027
+ gridSizeX: 48,
2028
+ gridSizeY: 48
2029
+ };
2030
+ class LineGridExtension {
2031
+ static create(configuration) {
2032
+ return new LineGridExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$4);
2033
+ }
2034
+ constructor(configuration) {
2035
+ this.configuration = configuration;
2036
+ }
2037
+ create() {
2038
+ const size = new Vector(this.configuration.gridSizeX, this.configuration.gridSizeY);
2039
+ return LineGrid.create(size);
2040
+ }
2041
+ }
2042
+
2043
+ class LineGridDesignerExtension {
2044
+ static create(configuration) {
2045
+ const grid = LineGridExtension.create(configuration);
2046
+ return new LineGridDesignerExtension(grid);
2047
+ }
2048
+ constructor(grid) {
2049
+ this.grid = grid;
2050
+ }
2051
+ }
2052
+
2053
+ class StartStopRootComponentDesignerExtension {
2054
+ static create(configuration) {
2055
+ return new StartStopRootComponentDesignerExtension(StartStopRootComponentExtension.create(configuration));
2056
+ }
2057
+ constructor(rootComponent) {
2058
+ this.rootComponent = rootComponent;
2059
+ }
2060
+ }
2061
+
2062
+ const defaultConfiguration$3 = {
2063
+ view: {
2064
+ paddingTop: 20,
2065
+ paddingX: 20,
2066
+ inputSize: 18,
2067
+ inputIconSize: 14,
2068
+ label: {
2069
+ height: 22,
2070
+ paddingX: 10,
2071
+ minWidth: 50,
2072
+ radius: 10
2073
+ }
2074
+ }
2075
+ };
2076
+ class ContainerStepExtension {
2077
+ static create(configuration) {
2078
+ return new ContainerStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$3);
2079
+ }
2080
+ constructor(configuration) {
2081
+ this.configuration = configuration;
2082
+ this.componentType = 'container';
2083
+ this.createComponentView = createContainerStepComponentViewFactory(this.configuration.view);
2084
+ }
2085
+ }
2086
+
2087
+ const defaultConfiguration$2 = {
2088
+ view: {
2089
+ minContainerWidth: 40,
2090
+ paddingX: 20,
2091
+ paddingTop: 20,
2092
+ connectionHeight: 16,
2093
+ inputSize: 18,
2094
+ inputIconSize: 14,
2095
+ branchNameLabel: {
2096
+ height: 22,
2097
+ paddingX: 10,
2098
+ minWidth: 50,
2099
+ radius: 10
2100
+ },
2101
+ nameLabel: {
2102
+ height: 22,
2103
+ paddingX: 10,
2104
+ minWidth: 50,
2105
+ radius: 10
2106
+ }
2107
+ }
2108
+ };
2109
+ class SwitchStepExtension {
2110
+ static create(configuration) {
2111
+ return new SwitchStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$2);
2112
+ }
2113
+ constructor(configuration) {
2114
+ this.configuration = configuration;
2115
+ this.componentType = 'switch';
2116
+ this.createComponentView = createSwitchStepComponentViewFactory(this.configuration.view);
2117
+ }
2118
+ }
2119
+
2120
+ const defaultConfiguration$1 = {
2121
+ view: {
2122
+ paddingLeft: 12,
2123
+ paddingRight: 12,
2124
+ paddingY: 10,
2125
+ textMarginLeft: 12,
2126
+ minTextWidth: 70,
2127
+ iconSize: 22,
2128
+ radius: 5,
2129
+ inputSize: 14,
2130
+ outputSize: 10
2131
+ }
2132
+ };
2133
+ class TaskStepExtension {
2134
+ static create(configuration) {
2135
+ return new TaskStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$1);
2136
+ }
2137
+ constructor(configuration) {
2138
+ this.configuration = configuration;
2139
+ this.componentType = 'task';
2140
+ this.createComponentView = createTaskStepComponentViewFactory(false, this.configuration.view);
2141
+ }
2142
+ }
2143
+
2144
+ class StepsDesignerExtension {
2145
+ static create(configuration) {
2146
+ const steps = [];
2147
+ if (configuration.container) {
2148
+ steps.push(ContainerStepExtension.create(configuration.container));
2149
+ }
2150
+ if (configuration.switch) {
2151
+ steps.push(SwitchStepExtension.create(configuration.switch));
2152
+ }
2153
+ if (configuration.task) {
2154
+ steps.push(TaskStepExtension.create(configuration.task));
2155
+ }
2156
+ return new StepsDesignerExtension(steps);
2157
+ }
2158
+ constructor(steps) {
2159
+ this.steps = steps;
2160
+ }
2161
+ }
2162
+
2163
+ class DefinitionValidator {
2164
+ constructor(configuration, state) {
2165
+ this.configuration = configuration;
2166
+ this.state = state;
2167
+ }
2168
+ validateStep(step, parentSequence) {
2169
+ var _a;
2170
+ if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.step) {
2171
+ return this.configuration.step(step, parentSequence, this.state.definition);
2172
+ }
2173
+ return true;
2174
+ }
2175
+ validateRoot() {
2176
+ var _a;
2177
+ if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.root) {
2178
+ return this.configuration.root(this.state.definition);
2179
+ }
2180
+ return true;
2181
+ }
2182
+ }
2183
+
2184
+ class IconProvider {
2185
+ constructor(configuration) {
2186
+ this.configuration = configuration;
2187
+ }
2188
+ getIconUrl(step) {
2189
+ if (this.configuration.iconUrlProvider) {
2190
+ return this.configuration.iconUrlProvider(step.componentType, step.type);
2191
+ }
2192
+ return null;
2193
+ }
2194
+ }
2195
+
2196
+ class StepComponentViewContextFactory {
2197
+ static create(stepContext, componentContext) {
2198
+ const preferenceKeyPrefix = stepContext.step.id + ':';
2199
+ return {
2200
+ i18n: componentContext.i18n,
2201
+ getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
2202
+ getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
2203
+ createSequenceComponent: (parentElement, sequence) => {
2204
+ const sequenceContext = {
2205
+ sequence,
2206
+ depth: stepContext.depth + 1,
2207
+ isInputConnected: true,
2208
+ isOutputConnected: stepContext.isOutputConnected,
2209
+ isPreview: stepContext.isPreview
2210
+ };
2211
+ return componentContext.services.sequenceComponent.create(parentElement, sequenceContext, componentContext);
2212
+ },
2213
+ createRegionComponentView(parentElement, componentClassName, contentFactory) {
2214
+ return componentContext.services.regionComponentView.create(parentElement, componentClassName, stepContext, this, contentFactory);
2215
+ },
2216
+ createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
2217
+ getPreference: (key) => componentContext.preferenceStorage.getItem(preferenceKeyPrefix + key),
2218
+ setPreference: (key, value) => componentContext.preferenceStorage.setItem(preferenceKeyPrefix + key, value)
2219
+ };
2220
+ }
2221
+ }
2222
+
2223
+ class StepComponentFactory {
2224
+ constructor(stepExtensionResolver) {
2225
+ this.stepExtensionResolver = stepExtensionResolver;
2226
+ }
2227
+ create(parentElement, stepContext, componentContext) {
2228
+ const viewContext = StepComponentViewContextFactory.create(stepContext, componentContext);
2229
+ const extension = this.stepExtensionResolver.resolve(stepContext.step.componentType);
2230
+ const view = extension.createComponentView(parentElement, stepContext, viewContext);
2231
+ const wrappedView = componentContext.services.stepComponentViewWrapper.wrap(view, stepContext);
2232
+ return StepComponent.create(wrappedView, stepContext, componentContext);
2233
+ }
2234
+ }
2235
+
2236
+ class ComponentContext {
2237
+ static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
2238
+ const validator = new DefinitionValidator(configuration.validator, state);
2239
+ const iconProvider = new IconProvider(configuration.steps);
2240
+ const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
2241
+ return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
2242
+ }
2243
+ constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
2244
+ this.shadowRoot = shadowRoot;
2245
+ this.validator = validator;
2246
+ this.iconProvider = iconProvider;
2247
+ this.placeholderController = placeholderController;
2248
+ this.stepComponentFactory = stepComponentFactory;
2249
+ this.definitionWalker = definitionWalker;
2250
+ this.services = services;
2251
+ this.preferenceStorage = preferenceStorage;
2252
+ this.i18n = i18n;
2253
+ }
2254
+ }
2255
+
2256
+ class CustomActionController {
2257
+ constructor(configuration, state, stateModifier) {
2258
+ this.configuration = configuration;
2259
+ this.state = state;
2260
+ this.stateModifier = stateModifier;
2261
+ }
2262
+ trigger(action, step, sequence) {
2263
+ const handler = this.configuration.customActionHandler;
2264
+ if (!handler) {
2265
+ console.warn(`Custom action handler is not defined (action type: ${action.type})`);
2266
+ return;
2267
+ }
2268
+ const context = this.createCustomActionHandlerContext();
2269
+ handler(action, step, sequence, context);
2270
+ }
2271
+ createCustomActionHandlerContext() {
2272
+ return {
2273
+ notifyStepNameChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepNameChanged, stepId, false),
2274
+ notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepPropertyChanged, stepId, false),
2275
+ notifyStepInserted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepInserted, stepId, true),
2276
+ notifyStepMoved: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepMoved, stepId, true),
2277
+ notifyStepDeleted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepDeleted, stepId, true)
2278
+ };
2279
+ }
2280
+ notifyStepChanged(changeType, stepId, updateDependencies) {
2281
+ if (!stepId) {
2282
+ throw new Error('Step id is empty');
2283
+ }
2284
+ this.state.notifyDefinitionChanged(changeType, stepId);
2285
+ if (updateDependencies) {
2286
+ this.stateModifier.updateDependencies();
2287
+ }
2288
+ }
2289
+ }
2290
+
2291
+ class EditorView {
2292
+ static create(parent) {
2293
+ return new EditorView(parent);
2294
+ }
2295
+ constructor(parent) {
2296
+ this.parent = parent;
2297
+ this.currentContainer = null;
2298
+ }
2299
+ setContent(content, className) {
2300
+ const container = Dom.element('div', {
2301
+ class: className
2302
+ });
2303
+ container.appendChild(content);
2304
+ if (this.currentContainer) {
2305
+ this.parent.removeChild(this.currentContainer);
2306
+ }
2307
+ this.parent.appendChild(container);
2308
+ this.currentContainer = container;
2309
+ }
2310
+ destroy() {
2311
+ if (this.currentContainer) {
2312
+ this.parent.removeChild(this.currentContainer);
2313
+ }
2314
+ }
2146
2315
  }
2147
2316
 
2148
- class DefaultRegionComponentViewExtension {
2149
- create(parentElement, componentClassName, stepContext, _, contentFactory) {
2150
- const g = ComponentDom.stepG(componentClassName, stepContext.step.type, stepContext.step.id);
2151
- parentElement.appendChild(g);
2152
- return contentFactory(g, DefaultRegionView.create);
2317
+ class Editor {
2318
+ static create(parent, api, stepEditorClassName, stepEditorProvider, rootEditorClassName, rootEditorProvider, customSelectedStepIdProvider) {
2319
+ const view = EditorView.create(parent);
2320
+ function render(step) {
2321
+ const definition = api.getDefinition();
2322
+ let content;
2323
+ let className;
2324
+ if (step) {
2325
+ const stepContext = api.createStepEditorContext(step.id);
2326
+ content = stepEditorProvider(step, stepContext, definition, api.isReadonly());
2327
+ className = stepEditorClassName;
2328
+ }
2329
+ else {
2330
+ const rootContext = api.createRootEditorContext();
2331
+ content = rootEditorProvider(definition, rootContext, api.isReadonly());
2332
+ className = rootEditorClassName;
2333
+ }
2334
+ view.setContent(content, className);
2335
+ }
2336
+ const renderer = api.runRenderer(step => render(step), customSelectedStepIdProvider);
2337
+ return new Editor(view, renderer);
2338
+ }
2339
+ constructor(view, renderer) {
2340
+ this.view = view;
2341
+ this.renderer = renderer;
2342
+ }
2343
+ destroy() {
2344
+ this.view.destroy();
2345
+ this.renderer.destroy();
2153
2346
  }
2154
2347
  }
2155
2348
 
@@ -2169,10 +2362,26 @@ function readTouchPosition(e) {
2169
2362
  return new Vector(touch.pageX, touch.pageY);
2170
2363
  }
2171
2364
  throw new Error('Unknown touch position');
2365
+ }
2366
+ function calculateFingerDistance(e) {
2367
+ if (e.touches.length === 2) {
2368
+ const t0 = e.touches[0];
2369
+ const t1 = e.touches[1];
2370
+ return Math.hypot(t0.clientX - t1.clientX, t0.clientY - t1.clientY);
2371
+ }
2372
+ throw new Error('Cannot calculate finger distance');
2373
+ }
2374
+ function readFingerCenterPoint(e) {
2375
+ if (e.touches.length === 2) {
2376
+ const t0 = e.touches[0];
2377
+ const t1 = e.touches[1];
2378
+ return new Vector((t0.pageX + t1.pageX) / 2, (t0.pageY + t1.pageY) / 2);
2379
+ }
2380
+ throw new Error('Cannot calculate finger center point');
2172
2381
  }
2173
2382
 
2174
- const notInitializedError = 'State is not initialized';
2175
- const nonPassiveOptions = {
2383
+ const notInitializedError$1 = 'State is not initialized';
2384
+ const nonPassiveOptions$1 = {
2176
2385
  passive: false
2177
2386
  };
2178
2387
  class BehaviorController {
@@ -2182,6 +2391,8 @@ class BehaviorController {
2182
2391
  constructor(dom, shadowRoot) {
2183
2392
  this.dom = dom;
2184
2393
  this.shadowRoot = shadowRoot;
2394
+ this.previousEndToken = null;
2395
+ this.state = null;
2185
2396
  this.onMouseMove = (e) => {
2186
2397
  e.preventDefault();
2187
2398
  e.stopPropagation();
@@ -2202,7 +2413,7 @@ class BehaviorController {
2202
2413
  e.preventDefault();
2203
2414
  e.stopPropagation();
2204
2415
  if (!this.state) {
2205
- throw new Error(notInitializedError);
2416
+ throw new Error(notInitializedError$1);
2206
2417
  }
2207
2418
  const position = (_a = this.state.lastPosition) !== null && _a !== void 0 ? _a : this.state.startPosition;
2208
2419
  const element = this.dom.elementFromPoint(position.x, position.y);
@@ -2233,27 +2444,27 @@ class BehaviorController {
2233
2444
  }
2234
2445
  bind(target) {
2235
2446
  target.addEventListener('mousemove', this.onMouseMove, false);
2236
- target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2447
+ target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions$1);
2237
2448
  target.addEventListener('mouseup', this.onMouseUp, false);
2238
- target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2239
- target.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2449
+ target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions$1);
2450
+ target.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions$1);
2240
2451
  }
2241
2452
  unbind(target) {
2242
2453
  target.removeEventListener('mousemove', this.onMouseMove, false);
2243
- target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2454
+ target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions$1);
2244
2455
  target.removeEventListener('mouseup', this.onMouseUp, false);
2245
- target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2246
- target.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2456
+ target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions$1);
2457
+ target.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions$1);
2247
2458
  }
2248
2459
  move(position) {
2249
2460
  if (!this.state) {
2250
- throw new Error(notInitializedError);
2461
+ throw new Error(notInitializedError$1);
2251
2462
  }
2252
2463
  this.state.lastPosition = position;
2253
2464
  const delta = this.state.startPosition.subtract(position);
2254
2465
  const newBehavior = this.state.behavior.onMove(delta);
2255
2466
  if (newBehavior) {
2256
- this.state.behavior.onEnd(true, null);
2467
+ this.state.behavior.onEnd(true, null, null);
2257
2468
  this.state.behavior = newBehavior;
2258
2469
  this.state.startPosition = position;
2259
2470
  this.state.behavior.onStart(this.state.startPosition);
@@ -2261,14 +2472,15 @@ class BehaviorController {
2261
2472
  }
2262
2473
  stop(interrupt, element) {
2263
2474
  if (!this.state) {
2264
- throw new Error(notInitializedError);
2475
+ throw new Error(notInitializedError$1);
2265
2476
  }
2266
2477
  if (this.shadowRoot) {
2267
2478
  this.unbind(this.shadowRoot);
2268
2479
  }
2269
2480
  this.unbind(window);
2270
- this.state.behavior.onEnd(interrupt, element);
2271
- this.state = undefined;
2481
+ const endToken = this.state.behavior.onEnd(interrupt, element, this.previousEndToken);
2482
+ this.state = null;
2483
+ this.previousEndToken = endToken || null;
2272
2484
  }
2273
2485
  }
2274
2486
 
@@ -2836,20 +3048,26 @@ class WorkspaceView {
2836
3048
  getCanvasSize() {
2837
3049
  return new Vector(this.canvas.clientWidth, this.canvas.clientHeight);
2838
3050
  }
2839
- bindClick(handler) {
3051
+ bindMouseDown(handler) {
2840
3052
  this.canvas.addEventListener('mousedown', e => {
2841
3053
  e.preventDefault();
2842
3054
  handler(readMousePosition(e), e.target, e.button, e.altKey);
2843
3055
  }, false);
3056
+ }
3057
+ bindTouchStart(clickHandler, pinchToZoomHandler) {
2844
3058
  this.canvas.addEventListener('touchstart', e => {
2845
3059
  var _a;
2846
3060
  e.preventDefault();
3061
+ if (e.touches.length === 2) {
3062
+ pinchToZoomHandler(calculateFingerDistance(e), readFingerCenterPoint(e));
3063
+ return;
3064
+ }
2847
3065
  const clientPosition = readTouchClientPosition(e);
2848
3066
  const dom = (_a = this.shadowRoot) !== null && _a !== void 0 ? _a : document;
2849
3067
  const element = dom.elementFromPoint(clientPosition.x, clientPosition.y);
2850
3068
  if (element) {
2851
3069
  const position = readTouchPosition(e);
2852
- handler(position, element, 0, false);
3070
+ clickHandler(position, element, 0, false);
2853
3071
  }
2854
3072
  }, listenerOptions$1);
2855
3073
  }
@@ -2938,9 +3156,11 @@ class SelectStepBehavior {
2938
3156
  }
2939
3157
  }
2940
3158
  onEnd(interrupt) {
2941
- if (!interrupt) {
2942
- this.stateModifier.trySelectStep(this.pressedStepComponent.step, this.pressedStepComponent.parentSequence);
3159
+ if (interrupt) {
3160
+ return;
2943
3161
  }
3162
+ this.stateModifier.trySelectStep(this.pressedStepComponent.step, this.pressedStepComponent.parentSequence);
3163
+ return new SelectStepBehaviorEndToken(this.pressedStepComponent.step.id, Date.now());
2944
3164
  }
2945
3165
  }
2946
3166
 
@@ -3226,17 +3446,97 @@ class ContextMenuItemsBuilder {
3226
3446
  }
3227
3447
  }
3228
3448
 
3449
+ const nonPassiveOptions = {
3450
+ passive: false
3451
+ };
3452
+ const notInitializedError = 'State is not initialized';
3453
+ class PinchToZoomController {
3454
+ static create(workspaceApi, viewportApi, shadowRoot) {
3455
+ return new PinchToZoomController(workspaceApi, viewportApi, shadowRoot);
3456
+ }
3457
+ constructor(workspaceApi, viewportApi, shadowRoot) {
3458
+ this.workspaceApi = workspaceApi;
3459
+ this.viewportApi = viewportApi;
3460
+ this.shadowRoot = shadowRoot;
3461
+ this.state = null;
3462
+ this.onTouchMove = (e) => {
3463
+ e.preventDefault();
3464
+ if (!this.state) {
3465
+ throw new Error(notInitializedError);
3466
+ }
3467
+ const touchEvent = e;
3468
+ const distance = calculateFingerDistance(touchEvent);
3469
+ const centerPoint = readFingerCenterPoint(touchEvent);
3470
+ const deltaCenterPoint = centerPoint.subtract(this.state.lastCenterPoint);
3471
+ const scale = this.viewportApi.limitScale(this.state.startScale * (distance / this.state.startDistance));
3472
+ const zoomPoint = centerPoint.subtract(this.state.canvasPosition);
3473
+ const zoomRealPoint = zoomPoint
3474
+ .divideByScalar(this.state.lastViewport.scale)
3475
+ .subtract(this.state.lastViewport.position.divideByScalar(this.state.lastViewport.scale));
3476
+ const position = zoomRealPoint
3477
+ .multiplyByScalar(-scale)
3478
+ .add(zoomPoint)
3479
+ .add(deltaCenterPoint.divideByScalar(this.state.lastViewport.scale));
3480
+ const newViewport = {
3481
+ position,
3482
+ scale
3483
+ };
3484
+ this.workspaceApi.setViewport(newViewport);
3485
+ this.state.lastCenterPoint = centerPoint;
3486
+ this.state.lastViewport = newViewport;
3487
+ };
3488
+ this.onTouchEnd = (e) => {
3489
+ e.preventDefault();
3490
+ if (!this.state) {
3491
+ throw new Error(notInitializedError);
3492
+ }
3493
+ if (this.shadowRoot) {
3494
+ this.unbind(this.shadowRoot);
3495
+ }
3496
+ this.unbind(window);
3497
+ this.state = null;
3498
+ };
3499
+ }
3500
+ start(startDistance, centerPoint) {
3501
+ if (this.state) {
3502
+ throw new Error(`State is already initialized`);
3503
+ }
3504
+ if (this.shadowRoot) {
3505
+ this.bind(this.shadowRoot);
3506
+ }
3507
+ this.bind(window);
3508
+ const viewport = this.workspaceApi.getViewport();
3509
+ this.state = {
3510
+ canvasPosition: this.workspaceApi.getCanvasPosition(),
3511
+ startScale: viewport.scale,
3512
+ startDistance,
3513
+ lastViewport: viewport,
3514
+ lastCenterPoint: centerPoint
3515
+ };
3516
+ }
3517
+ bind(target) {
3518
+ target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
3519
+ target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
3520
+ }
3521
+ unbind(target) {
3522
+ target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
3523
+ target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
3524
+ }
3525
+ }
3526
+
3229
3527
  class Workspace {
3230
3528
  static create(parent, designerContext, api) {
3231
3529
  var _a;
3232
3530
  const view = WorkspaceView.create(parent, designerContext.componentContext);
3233
3531
  const clickBehaviorResolver = new ClickBehaviorResolver(designerContext);
3234
- const wheelController = designerContext.services.wheelController.create(api.workspace);
3532
+ const clickBehaviorWrapper = designerContext.services.clickBehaviorWrapperExtension.create(designerContext.customActionController);
3533
+ const wheelController = designerContext.services.wheelController.create(api.viewport, api.workspace);
3534
+ const pinchToZoomController = PinchToZoomController.create(api.workspace, api.viewport, api.shadowRoot);
3235
3535
  const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
3236
3536
  ? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
3237
3537
  : undefined);
3238
3538
  const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
3239
- const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, contextMenuController, clickBehaviorResolver, api.viewport, designerContext.services);
3539
+ const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, api.viewport, designerContext.services);
3240
3540
  setTimeout(() => {
3241
3541
  workspace.updateRootComponent();
3242
3542
  api.viewport.resetViewport();
@@ -3246,19 +3546,22 @@ class Workspace {
3246
3546
  race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged, designerContext.state.onFolderPathChanged).subscribe(r => {
3247
3547
  workspace.onStateChanged(r[0], r[1], r[2]);
3248
3548
  });
3249
- view.bindClick(workspace.onClick);
3549
+ view.bindMouseDown(workspace.onClick);
3550
+ view.bindTouchStart(workspace.onClick, workspace.onPinchToZoom);
3250
3551
  view.bindWheel(workspace.onWheel);
3251
3552
  view.bindContextMenu(workspace.onContextMenu);
3252
3553
  return workspace;
3253
3554
  }
3254
- constructor(view, definitionWalker, state, behaviorController, wheelController, contextMenuController, clickBehaviorResolver, viewportApi, services) {
3555
+ constructor(view, definitionWalker, state, behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, viewportApi, services) {
3255
3556
  this.view = view;
3256
3557
  this.definitionWalker = definitionWalker;
3257
3558
  this.state = state;
3258
3559
  this.behaviorController = behaviorController;
3259
3560
  this.wheelController = wheelController;
3561
+ this.pinchToZoomController = pinchToZoomController;
3260
3562
  this.contextMenuController = contextMenuController;
3261
3563
  this.clickBehaviorResolver = clickBehaviorResolver;
3564
+ this.clickBehaviorWrapper = clickBehaviorWrapper;
3262
3565
  this.viewportApi = viewportApi;
3263
3566
  this.services = services;
3264
3567
  this.onRendered = new SimpleEvent();
@@ -3272,9 +3575,13 @@ class Workspace {
3272
3575
  const forceMove = isMiddleButton || altKey;
3273
3576
  const commandOrNull = this.resolveClick(target, position);
3274
3577
  const behavior = this.clickBehaviorResolver.resolve(commandOrNull, target, forceMove);
3275
- this.behaviorController.start(position, behavior);
3578
+ const wrappedBehavior = this.clickBehaviorWrapper.wrap(behavior, commandOrNull);
3579
+ this.behaviorController.start(position, wrappedBehavior);
3276
3580
  }
3277
3581
  };
3582
+ this.onPinchToZoom = (distance, centerPoint) => {
3583
+ this.pinchToZoomController.start(distance, centerPoint);
3584
+ };
3278
3585
  this.onWheel = (e) => {
3279
3586
  e.preventDefault();
3280
3587
  e.stopPropagation();
@@ -3587,7 +3894,7 @@ class ControlBar {
3587
3894
  static create(parent, api) {
3588
3895
  const isUndoRedoSupported = api.controlBar.isUndoRedoSupported();
3589
3896
  const view = ControlBarView.create(parent, isUndoRedoSupported, api.i18n);
3590
- const bar = new ControlBar(view, api.controlBar, isUndoRedoSupported);
3897
+ const bar = new ControlBar(view, api.controlBar, api.viewport, isUndoRedoSupported);
3591
3898
  view.bindResetButtonClick(() => bar.onResetButtonClicked());
3592
3899
  view.bindZoomInButtonClick(() => bar.onZoomInButtonClicked());
3593
3900
  view.bindZoomOutButtonClick(() => bar.onZoomOutButtonClicked());
@@ -3601,9 +3908,10 @@ class ControlBar {
3601
3908
  bar.refreshButtons();
3602
3909
  return bar;
3603
3910
  }
3604
- constructor(view, controlBarApi, isUndoRedoSupported) {
3911
+ constructor(view, controlBarApi, viewportApi, isUndoRedoSupported) {
3605
3912
  this.view = view;
3606
3913
  this.controlBarApi = controlBarApi;
3914
+ this.viewportApi = viewportApi;
3607
3915
  this.isUndoRedoSupported = isUndoRedoSupported;
3608
3916
  }
3609
3917
  updateLayout() {
@@ -3613,13 +3921,13 @@ class ControlBar {
3613
3921
  //
3614
3922
  }
3615
3923
  onResetButtonClicked() {
3616
- this.controlBarApi.resetViewport();
3924
+ this.viewportApi.resetViewport();
3617
3925
  }
3618
3926
  onZoomInButtonClicked() {
3619
- this.controlBarApi.zoomIn();
3927
+ this.viewportApi.zoom(true);
3620
3928
  }
3621
3929
  onZoomOutButtonClicked() {
3622
- this.controlBarApi.zoomOut();
3930
+ this.viewportApi.zoom(false);
3623
3931
  }
3624
3932
  onMoveButtonClicked() {
3625
3933
  this.controlBarApi.toggleIsDragDisabled();
@@ -4137,31 +4445,6 @@ class ToolboxExtension {
4137
4445
  }
4138
4446
  }
4139
4447
 
4140
- const defaultConfiguration$4 = {
4141
- view: {
4142
- paddingTop: 20,
4143
- paddingX: 20,
4144
- inputSize: 18,
4145
- inputIconSize: 14,
4146
- label: {
4147
- height: 22,
4148
- paddingX: 10,
4149
- minWidth: 50,
4150
- radius: 10
4151
- }
4152
- }
4153
- };
4154
- class ContainerStepExtension {
4155
- static create(configuration) {
4156
- return new ContainerStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$4);
4157
- }
4158
- constructor(configuration) {
4159
- this.configuration = configuration;
4160
- this.componentType = 'container';
4161
- this.createComponentView = createContainerStepComponentViewFactory(this.configuration.view);
4162
- }
4163
- }
4164
-
4165
4448
  class DefaultPlaceholderControllerExtension {
4166
4449
  create() {
4167
4450
  return {
@@ -4170,7 +4453,7 @@ class DefaultPlaceholderControllerExtension {
4170
4453
  }
4171
4454
  }
4172
4455
 
4173
- const defaultConfiguration$3 = {
4456
+ const defaultConfiguration = {
4174
4457
  gapWidth: 88,
4175
4458
  gapHeight: 24,
4176
4459
  radius: 6,
@@ -4178,7 +4461,7 @@ const defaultConfiguration$3 = {
4178
4461
  };
4179
4462
  class RectPlaceholderExtension {
4180
4463
  static create(configuration) {
4181
- return new RectPlaceholderExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$3);
4464
+ return new RectPlaceholderExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration);
4182
4465
  }
4183
4466
  constructor(configuration) {
4184
4467
  this.configuration = configuration;
@@ -4192,63 +4475,6 @@ class RectPlaceholderExtension {
4192
4475
  }
4193
4476
  }
4194
4477
 
4195
- const defaultConfiguration$2 = {
4196
- view: {
4197
- minContainerWidth: 40,
4198
- paddingX: 20,
4199
- paddingTop: 20,
4200
- connectionHeight: 16,
4201
- inputSize: 18,
4202
- inputIconSize: 14,
4203
- branchNameLabel: {
4204
- height: 22,
4205
- paddingX: 10,
4206
- minWidth: 50,
4207
- radius: 10
4208
- },
4209
- nameLabel: {
4210
- height: 22,
4211
- paddingX: 10,
4212
- minWidth: 50,
4213
- radius: 10
4214
- }
4215
- }
4216
- };
4217
- class SwitchStepExtension {
4218
- static create(configuration) {
4219
- return new SwitchStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$2);
4220
- }
4221
- constructor(configuration) {
4222
- this.configuration = configuration;
4223
- this.componentType = 'switch';
4224
- this.createComponentView = createSwitchStepComponentViewFactory(this.configuration.view);
4225
- }
4226
- }
4227
-
4228
- const defaultConfiguration$1 = {
4229
- view: {
4230
- paddingLeft: 12,
4231
- paddingRight: 12,
4232
- paddingY: 10,
4233
- textMarginLeft: 12,
4234
- minTextWidth: 70,
4235
- iconSize: 22,
4236
- radius: 5,
4237
- inputSize: 14,
4238
- outputSize: 10
4239
- }
4240
- };
4241
- class TaskStepExtension {
4242
- static create(configuration) {
4243
- return new TaskStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$1);
4244
- }
4245
- constructor(configuration) {
4246
- this.configuration = configuration;
4247
- this.componentType = 'task';
4248
- this.createComponentView = createTaskStepComponentViewFactory(false, this.configuration.view);
4249
- }
4250
- }
4251
-
4252
4478
  class DefaultSequenceComponentExtension {
4253
4479
  constructor() {
4254
4480
  this.create = DefaultSequenceComponent.create;
@@ -4261,39 +4487,15 @@ class DefaultStepComponentViewWrapperExtension {
4261
4487
  }
4262
4488
  }
4263
4489
 
4264
- class LineGrid {
4265
- static create(size) {
4266
- const path = Dom.svg('path', {
4267
- class: 'sqd-line-grid-path',
4268
- fill: 'none'
4269
- });
4270
- return new LineGrid(size, path);
4271
- }
4272
- constructor(size, element) {
4273
- this.size = size;
4274
- this.element = element;
4275
- }
4276
- setScale(_, scaledSize) {
4277
- Dom.attrs(this.element, {
4278
- d: `M ${scaledSize.x} 0 L 0 0 0 ${scaledSize.y}`
4279
- });
4490
+ class DefaultClickBehaviorWrapper {
4491
+ constructor() {
4492
+ this.wrap = (behavior) => behavior;
4280
4493
  }
4281
4494
  }
4282
4495
 
4283
- const defaultConfiguration = {
4284
- gridSizeX: 48,
4285
- gridSizeY: 48
4286
- };
4287
- class LineGridExtension {
4288
- static create(configuration) {
4289
- return new LineGridExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration);
4290
- }
4291
- constructor(configuration) {
4292
- this.configuration = configuration;
4293
- }
4496
+ class DefaultClickBehaviorWrapperExtension {
4294
4497
  create() {
4295
- const size = new Vector(this.configuration.gridSizeX, this.configuration.gridSizeY);
4296
- return LineGrid.create(size);
4498
+ return new DefaultClickBehaviorWrapper();
4297
4499
  }
4298
4500
  }
4299
4501
 
@@ -4313,6 +4515,9 @@ function merge(services, extensions) {
4313
4515
  if (ext.stepComponentViewWrapper) {
4314
4516
  services.stepComponentViewWrapper = ext.stepComponentViewWrapper;
4315
4517
  }
4518
+ if (ext.clickBehaviorWrapperExtension) {
4519
+ services.clickBehaviorWrapperExtension = ext.clickBehaviorWrapperExtension;
4520
+ }
4316
4521
  if (ext.badges) {
4317
4522
  services.badges = (services.badges || []).concat(ext.badges);
4318
4523
  }
@@ -4364,6 +4569,9 @@ function setDefaults(services, configuration) {
4364
4569
  if (!services.stepComponentViewWrapper) {
4365
4570
  services.stepComponentViewWrapper = new DefaultStepComponentViewWrapperExtension();
4366
4571
  }
4572
+ if (!services.clickBehaviorWrapperExtension) {
4573
+ services.clickBehaviorWrapperExtension = new DefaultClickBehaviorWrapperExtension();
4574
+ }
4367
4575
  if (!services.badges) {
4368
4576
  services.badges = [];
4369
4577
  }
@@ -4398,7 +4606,7 @@ function setDefaults(services, configuration) {
4398
4606
  services.regionComponentView = new DefaultRegionComponentViewExtension();
4399
4607
  }
4400
4608
  if (!services.viewportController) {
4401
- services.viewportController = new DefaultViewportControllerExtension();
4609
+ services.viewportController = DefaultViewportControllerExtension.create();
4402
4610
  }
4403
4611
  if (!services.grid) {
4404
4612
  services.grid = LineGridExtension.create();
@@ -4660,35 +4868,6 @@ class Designer {
4660
4868
  }
4661
4869
  }
4662
4870
 
4663
- class LineGridDesignerExtension {
4664
- static create(configuration) {
4665
- const grid = LineGridExtension.create(configuration);
4666
- return new LineGridDesignerExtension(grid);
4667
- }
4668
- constructor(grid) {
4669
- this.grid = grid;
4670
- }
4671
- }
4672
-
4673
- class StepsDesignerExtension {
4674
- static create(configuration) {
4675
- const steps = [];
4676
- if (configuration.container) {
4677
- steps.push(ContainerStepExtension.create(configuration.container));
4678
- }
4679
- if (configuration.switch) {
4680
- steps.push(SwitchStepExtension.create(configuration.switch));
4681
- }
4682
- if (configuration.task) {
4683
- steps.push(TaskStepExtension.create(configuration.task));
4684
- }
4685
- return new StepsDesignerExtension(steps);
4686
- }
4687
- constructor(steps) {
4688
- this.steps = steps;
4689
- }
4690
- }
4691
-
4692
4871
  exports.Badges = Badges;
4693
4872
  exports.CenteredViewportCalculator = CenteredViewportCalculator;
4694
4873
  exports.ClassicWheelControllerExtension = ClassicWheelControllerExtension;
@@ -4701,6 +4880,7 @@ exports.DefaultRegionView = DefaultRegionView;
4701
4880
  exports.DefaultSequenceComponent = DefaultSequenceComponent;
4702
4881
  exports.DefaultSequenceComponentView = DefaultSequenceComponentView;
4703
4882
  exports.DefaultViewportController = DefaultViewportController;
4883
+ exports.DefaultViewportControllerDesignerExtension = DefaultViewportControllerDesignerExtension;
4704
4884
  exports.DefaultViewportControllerExtension = DefaultViewportControllerExtension;
4705
4885
  exports.Designer = Designer;
4706
4886
  exports.DesignerApi = DesignerApi;
@@ -4717,19 +4897,22 @@ exports.LineGridDesignerExtension = LineGridDesignerExtension;
4717
4897
  exports.ObjectCloner = ObjectCloner;
4718
4898
  exports.OutputView = OutputView;
4719
4899
  exports.PathBarApi = PathBarApi;
4720
- exports.QuantifiedScaleViewportCalculator = QuantifiedScaleViewportCalculator;
4721
4900
  exports.RectPlaceholder = RectPlaceholder;
4722
4901
  exports.RectPlaceholderView = RectPlaceholderView;
4902
+ exports.SelectStepBehaviorEndToken = SelectStepBehaviorEndToken;
4723
4903
  exports.ServicesResolver = ServicesResolver;
4724
4904
  exports.SimpleEvent = SimpleEvent;
4905
+ exports.StartStopRootComponentDesignerExtension = StartStopRootComponentDesignerExtension;
4725
4906
  exports.StartStopRootComponentExtension = StartStopRootComponentExtension;
4726
4907
  exports.StepComponent = StepComponent;
4727
4908
  exports.StepExtensionResolver = StepExtensionResolver;
4728
4909
  exports.StepsDesignerExtension = StepsDesignerExtension;
4910
+ exports.TYPE = TYPE;
4729
4911
  exports.ToolboxApi = ToolboxApi;
4730
4912
  exports.Uid = Uid;
4731
4913
  exports.ValidationErrorBadgeExtension = ValidationErrorBadgeExtension;
4732
4914
  exports.Vector = Vector;
4915
+ exports.ViewportApi = ViewportApi;
4733
4916
  exports.WorkspaceApi = WorkspaceApi;
4734
4917
  exports.createContainerStepComponentViewFactory = createContainerStepComponentViewFactory;
4735
4918
  exports.createSwitchStepComponentViewFactory = createSwitchStepComponentViewFactory;