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/dist/index.umd.js CHANGED
@@ -202,27 +202,17 @@
202
202
  }
203
203
 
204
204
  class ControlBarApi {
205
- static create(state, historyController, stateModifier, viewportApi) {
206
- const api = new ControlBarApi(state, historyController, stateModifier, viewportApi);
205
+ static create(state, historyController, stateModifier) {
206
+ const api = new ControlBarApi(state, historyController, stateModifier);
207
207
  race(0, state.onIsReadonlyChanged, state.onSelectedStepIdChanged, state.onIsDragDisabledChanged, api.isUndoRedoSupported() ? state.onDefinitionChanged : undefined).subscribe(api.onStateChanged.forward);
208
208
  return api;
209
209
  }
210
- constructor(state, historyController, stateModifier, viewportApi) {
210
+ constructor(state, historyController, stateModifier) {
211
211
  this.state = state;
212
212
  this.historyController = historyController;
213
213
  this.stateModifier = stateModifier;
214
- this.viewportApi = viewportApi;
215
214
  this.onStateChanged = new SimpleEvent();
216
215
  }
217
- resetViewport() {
218
- this.viewportApi.resetViewport();
219
- }
220
- zoomIn() {
221
- this.viewportApi.zoom(true);
222
- }
223
- zoomOut() {
224
- this.viewportApi.zoom(false);
225
- }
226
216
  isDragDisabled() {
227
217
  return this.state.isDragDisabled;
228
218
  }
@@ -672,16 +662,91 @@
672
662
  }
673
663
  }
674
664
 
665
+ function animate(interval, handler) {
666
+ const iv = setInterval(tick, 15);
667
+ const startTime = Date.now();
668
+ const anim = {
669
+ isAlive: true,
670
+ stop: () => {
671
+ anim.isAlive = false;
672
+ clearInterval(iv);
673
+ }
674
+ };
675
+ function tick() {
676
+ const progress = Math.min((Date.now() - startTime) / interval, 1);
677
+ handler(progress);
678
+ if (progress === 1) {
679
+ anim.stop();
680
+ }
681
+ }
682
+ return anim;
683
+ }
684
+
685
+ class ViewportAnimator {
686
+ constructor(state) {
687
+ this.state = state;
688
+ }
689
+ execute(target) {
690
+ if (this.animation && this.animation.isAlive) {
691
+ this.animation.stop();
692
+ }
693
+ const startPosition = this.state.viewport.position;
694
+ const startScale = this.state.viewport.scale;
695
+ const deltaPosition = startPosition.subtract(target.position);
696
+ const deltaScale = startScale - target.scale;
697
+ this.animation = animate(150, progress => {
698
+ const newScale = startScale - deltaScale * progress;
699
+ this.state.setViewport({
700
+ position: startPosition.subtract(deltaPosition.multiplyByScalar(progress)),
701
+ scale: newScale
702
+ });
703
+ });
704
+ }
705
+ }
706
+
707
+ class ZoomByWheelCalculator {
708
+ static calculate(controller, current, canvasPosition, e) {
709
+ if (e.deltaY === 0) {
710
+ return null;
711
+ }
712
+ const nextScale = controller.getNextScale(current.scale, e.deltaY < 0);
713
+ let scale;
714
+ const absDeltaY = Math.abs(e.deltaY);
715
+ if (absDeltaY < controller.smoothDeltaYLimit) {
716
+ const fraction = absDeltaY / controller.smoothDeltaYLimit;
717
+ const step = nextScale.next - nextScale.current;
718
+ scale = current.scale + step * fraction;
719
+ }
720
+ else {
721
+ scale = nextScale.next;
722
+ }
723
+ const mousePoint = new Vector(e.pageX, e.pageY).subtract(canvasPosition);
724
+ // The real point is point on canvas with no scale.
725
+ const mouseRealPoint = mousePoint.divideByScalar(current.scale).subtract(current.position.divideByScalar(current.scale));
726
+ const position = mouseRealPoint.multiplyByScalar(-scale).add(mousePoint);
727
+ return { position, scale };
728
+ }
729
+ }
730
+
675
731
  class ViewportApi {
676
- constructor(workspaceController, viewportController) {
732
+ constructor(state, workspaceController, viewportController) {
733
+ this.state = state;
677
734
  this.workspaceController = workspaceController;
678
735
  this.viewportController = viewportController;
736
+ this.animator = new ViewportAnimator(this.state);
737
+ }
738
+ limitScale(scale) {
739
+ return this.viewportController.limitScale(scale);
679
740
  }
680
741
  resetViewport() {
681
- this.viewportController.setDefault();
742
+ const defaultViewport = this.viewportController.getDefault();
743
+ this.state.setViewport(defaultViewport);
682
744
  }
683
745
  zoom(direction) {
684
- this.viewportController.zoom(direction);
746
+ const viewport = this.viewportController.getZoomed(direction);
747
+ if (viewport) {
748
+ this.state.setViewport(viewport);
749
+ }
685
750
  }
686
751
  moveViewportToStep(stepId) {
687
752
  const component = this.workspaceController.getComponentByStepId(stepId);
@@ -689,7 +754,15 @@
689
754
  const clientPosition = component.view.getClientPosition();
690
755
  const componentPosition = clientPosition.subtract(canvasPosition);
691
756
  const componentSize = new Vector(component.view.width, component.view.height);
692
- this.viewportController.focusOnComponent(componentPosition, componentSize);
757
+ const viewport = this.viewportController.getFocusedOnComponent(componentPosition, componentSize);
758
+ this.animator.execute(viewport);
759
+ }
760
+ handleWheelEvent(e) {
761
+ const canvasPosition = this.workspaceController.getCanvasPosition();
762
+ const newViewport = ZoomByWheelCalculator.calculate(this.viewportController, this.state.viewport, canvasPosition, e);
763
+ if (newViewport) {
764
+ this.state.setViewport(newViewport);
765
+ }
693
766
  }
694
767
  }
695
768
 
@@ -698,6 +771,12 @@
698
771
  this.state = state;
699
772
  this.workspaceController = workspaceController;
700
773
  }
774
+ getViewport() {
775
+ return this.state.viewport;
776
+ }
777
+ setViewport(viewport) {
778
+ this.state.setViewport(viewport);
779
+ }
701
780
  getCanvasPosition() {
702
781
  return this.workspaceController.getCanvasPosition();
703
782
  }
@@ -707,12 +786,6 @@
707
786
  getRootComponentSize() {
708
787
  return this.workspaceController.getRootComponentSize();
709
788
  }
710
- getViewport() {
711
- return this.state.viewport;
712
- }
713
- setViewport(viewport) {
714
- this.state.setViewport(viewport);
715
- }
716
789
  updateRootComponent() {
717
790
  this.workspaceController.updateRootComponent();
718
791
  }
@@ -728,9 +801,8 @@
728
801
  static create(context) {
729
802
  const workspace = new WorkspaceApi(context.state, context.workspaceController);
730
803
  const viewportController = context.services.viewportController.create(workspace);
731
- const viewport = new ViewportApi(context.workspaceController, viewportController);
732
804
  const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
733
- 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);
805
+ 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);
734
806
  }
735
807
  constructor(shadowRoot, controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
736
808
  this.shadowRoot = shadowRoot;
@@ -745,36 +817,15 @@
745
817
  }
746
818
  }
747
819
 
748
- class DefinitionValidator {
749
- constructor(configuration, state) {
750
- this.configuration = configuration;
751
- this.state = state;
752
- }
753
- validateStep(step, parentSequence) {
754
- var _a;
755
- if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.step) {
756
- return this.configuration.step(step, parentSequence, this.state.definition);
757
- }
758
- return true;
759
- }
760
- validateRoot() {
761
- var _a;
762
- if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.root) {
763
- return this.configuration.root(this.state.definition);
764
- }
765
- return true;
766
- }
767
- }
768
-
769
- class IconProvider {
770
- constructor(configuration) {
771
- this.configuration = configuration;
820
+ const TYPE = 'selectStep';
821
+ class SelectStepBehaviorEndToken {
822
+ static is(token) {
823
+ return Boolean(token) && token.type === TYPE;
772
824
  }
773
- getIconUrl(step) {
774
- if (this.configuration.iconUrlProvider) {
775
- return this.configuration.iconUrlProvider(step.componentType, step.type);
776
- }
777
- return null;
825
+ constructor(stepId, time) {
826
+ this.stepId = stepId;
827
+ this.time = time;
828
+ this.type = TYPE;
778
829
  }
779
830
  }
780
831
 
@@ -839,321 +890,76 @@
839
890
  return g;
840
891
  }
841
892
 
842
- exports.ClickCommandType = void 0;
843
- (function (ClickCommandType) {
844
- ClickCommandType[ClickCommandType["selectStep"] = 1] = "selectStep";
845
- ClickCommandType[ClickCommandType["rerenderStep"] = 2] = "rerenderStep";
846
- ClickCommandType[ClickCommandType["openFolder"] = 3] = "openFolder";
847
- ClickCommandType[ClickCommandType["triggerCustomAction"] = 4] = "triggerCustomAction";
848
- })(exports.ClickCommandType || (exports.ClickCommandType = {}));
849
- exports.PlaceholderDirection = void 0;
850
- (function (PlaceholderDirection) {
851
- PlaceholderDirection[PlaceholderDirection["none"] = 0] = "none";
852
- PlaceholderDirection[PlaceholderDirection["in"] = 1] = "in";
853
- PlaceholderDirection[PlaceholderDirection["out"] = 2] = "out";
854
- })(exports.PlaceholderDirection || (exports.PlaceholderDirection = {}));
855
-
856
- class StepComponent {
857
- static create(view, stepContext, componentContext) {
858
- const badges = Badges.createForStep(stepContext, view, componentContext);
859
- return new StepComponent(view, stepContext.step, stepContext.parentSequence, view.hasOutput, badges);
893
+ class ValidationErrorBadgeView {
894
+ static create(parent, cfg) {
895
+ const g = Dom.svg('g');
896
+ const halfOfSize = cfg.size / 2;
897
+ const circle = Dom.svg('path', {
898
+ class: 'sqd-validation-error',
899
+ d: `M 0 ${-halfOfSize} l ${halfOfSize} ${cfg.size} l ${-cfg.size} 0 Z`
900
+ });
901
+ Dom.translate(circle, halfOfSize, halfOfSize);
902
+ g.appendChild(circle);
903
+ const icon = Icons.appendPath(g, 'sqd-validation-error-icon-path', Icons.alert, cfg.iconSize);
904
+ const offsetX = (cfg.size - cfg.iconSize) / 2;
905
+ const offsetY = offsetX * 1.5;
906
+ Dom.translate(icon, offsetX, offsetY);
907
+ parent.appendChild(g);
908
+ return new ValidationErrorBadgeView(parent, g, cfg.size, cfg.size);
860
909
  }
861
- constructor(view, step, parentSequence, hasOutput, badges) {
862
- this.view = view;
863
- this.step = step;
864
- this.parentSequence = parentSequence;
865
- this.hasOutput = hasOutput;
866
- this.badges = badges;
910
+ constructor(parent, g, width, height) {
911
+ this.parent = parent;
912
+ this.g = g;
913
+ this.width = width;
914
+ this.height = height;
867
915
  }
868
- findById(stepId) {
869
- if (this.step.id === stepId) {
870
- return this;
871
- }
872
- if (this.view.sequenceComponents) {
873
- for (const component of this.view.sequenceComponents) {
874
- const result = component.findById(stepId);
875
- if (result) {
876
- return result;
877
- }
878
- }
879
- }
880
- return null;
916
+ destroy() {
917
+ this.parent.removeChild(this.g);
881
918
  }
882
- resolveClick(click) {
883
- if (this.view.sequenceComponents) {
884
- for (const component of this.view.sequenceComponents) {
885
- const result = component.resolveClick(click);
886
- if (result) {
887
- return result;
888
- }
919
+ }
920
+
921
+ class ValidatorFactory {
922
+ static createForStep(stepContext, view, componentContext) {
923
+ return () => {
924
+ if (!componentContext.validator.validateStep(stepContext.step, stepContext.parentSequence)) {
925
+ return false;
889
926
  }
890
- }
891
- const badgeResult = this.badges.resolveClick(click);
892
- if (badgeResult) {
893
- return badgeResult;
894
- }
895
- const viewResult = this.view.resolveClick(click);
896
- if (viewResult) {
897
- return viewResult === true
898
- ? {
899
- type: exports.ClickCommandType.selectStep,
900
- component: this
927
+ if (view.haveCollapsedChildren) {
928
+ let allChildrenValid = true;
929
+ componentContext.definitionWalker.forEachChildren(stepContext.step, (step, _, parentSequence) => {
930
+ if (!componentContext.validator.validateStep(step, parentSequence)) {
931
+ allChildrenValid = false;
932
+ return false;
933
+ }
934
+ });
935
+ if (!allChildrenValid) {
936
+ return false;
901
937
  }
902
- : viewResult;
903
- }
904
- return null;
905
- }
906
- resolvePlaceholders(skipComponent, result) {
907
- if (skipComponent !== this) {
908
- if (this.view.sequenceComponents) {
909
- this.view.sequenceComponents.forEach(component => component.resolvePlaceholders(skipComponent, result));
910
- }
911
- if (this.view.placeholders) {
912
- this.view.placeholders.forEach(ph => result.placeholders.push(ph));
913
938
  }
914
- result.components.push(this);
915
- }
939
+ return true;
940
+ };
916
941
  }
917
- setIsDragging(isDragging) {
918
- this.view.setIsDragging(isDragging);
942
+ static createForRoot(componentContext) {
943
+ return () => {
944
+ return componentContext.validator.validateRoot();
945
+ };
919
946
  }
920
- setIsSelected(isSelected) {
921
- this.view.setIsSelected(isSelected);
947
+ }
948
+
949
+ class ValidationErrorBadge {
950
+ static createForStep(parentElement, view, stepContext, componentContext, configuration) {
951
+ const validator = ValidatorFactory.createForStep(stepContext, view, componentContext);
952
+ return new ValidationErrorBadge(parentElement, validator, configuration);
922
953
  }
923
- setIsDisabled(isDisabled) {
924
- this.view.setIsDisabled(isDisabled);
954
+ static createForRoot(parentElement, componentContext, configuration) {
955
+ const validator = ValidatorFactory.createForRoot(componentContext);
956
+ return new ValidationErrorBadge(parentElement, validator, configuration);
925
957
  }
926
- updateBadges(result) {
927
- if (this.view.sequenceComponents) {
928
- this.view.sequenceComponents.forEach(component => component.updateBadges(result));
929
- }
930
- this.badges.update(result);
931
- }
932
- }
933
-
934
- class StepComponentViewContextFactory {
935
- static create(stepContext, componentContext) {
936
- const preferenceKeyPrefix = stepContext.step.id + ':';
937
- return {
938
- i18n: componentContext.i18n,
939
- getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
940
- getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
941
- createSequenceComponent: (parentElement, sequence) => {
942
- const sequenceContext = {
943
- sequence,
944
- depth: stepContext.depth + 1,
945
- isInputConnected: true,
946
- isOutputConnected: stepContext.isOutputConnected,
947
- isPreview: stepContext.isPreview
948
- };
949
- return componentContext.services.sequenceComponent.create(parentElement, sequenceContext, componentContext);
950
- },
951
- createRegionComponentView(parentElement, componentClassName, contentFactory) {
952
- return componentContext.services.regionComponentView.create(parentElement, componentClassName, stepContext, this, contentFactory);
953
- },
954
- createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
955
- getPreference: (key) => componentContext.preferenceStorage.getItem(preferenceKeyPrefix + key),
956
- setPreference: (key, value) => componentContext.preferenceStorage.setItem(preferenceKeyPrefix + key, value)
957
- };
958
- }
959
- }
960
-
961
- class StepComponentFactory {
962
- constructor(stepExtensionResolver) {
963
- this.stepExtensionResolver = stepExtensionResolver;
964
- }
965
- create(parentElement, stepContext, componentContext) {
966
- const viewContext = StepComponentViewContextFactory.create(stepContext, componentContext);
967
- const extension = this.stepExtensionResolver.resolve(stepContext.step.componentType);
968
- const view = extension.createComponentView(parentElement, stepContext, viewContext);
969
- const wrappedView = componentContext.services.stepComponentViewWrapper.wrap(view, stepContext);
970
- return StepComponent.create(wrappedView, stepContext, componentContext);
971
- }
972
- }
973
-
974
- class ComponentContext {
975
- static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
976
- const validator = new DefinitionValidator(configuration.validator, state);
977
- const iconProvider = new IconProvider(configuration.steps);
978
- const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
979
- return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
980
- }
981
- constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
982
- this.shadowRoot = shadowRoot;
983
- this.validator = validator;
984
- this.iconProvider = iconProvider;
985
- this.placeholderController = placeholderController;
986
- this.stepComponentFactory = stepComponentFactory;
987
- this.definitionWalker = definitionWalker;
988
- this.services = services;
989
- this.preferenceStorage = preferenceStorage;
990
- this.i18n = i18n;
991
- }
992
- }
993
-
994
- class CustomActionController {
995
- constructor(configuration, state, stateModifier) {
996
- this.configuration = configuration;
997
- this.state = state;
998
- this.stateModifier = stateModifier;
999
- }
1000
- trigger(action, step, sequence) {
1001
- const handler = this.configuration.customActionHandler;
1002
- if (!handler) {
1003
- console.warn(`Custom action handler is not defined (action type: ${action.type})`);
1004
- return;
1005
- }
1006
- const context = this.createCustomActionHandlerContext();
1007
- handler(action, step, sequence, context);
1008
- }
1009
- createCustomActionHandlerContext() {
1010
- return {
1011
- notifyStepNameChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepNameChanged, stepId, false),
1012
- notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepPropertyChanged, stepId, false),
1013
- notifyStepInserted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepInserted, stepId, true),
1014
- notifyStepMoved: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepMoved, stepId, true),
1015
- notifyStepDeleted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepDeleted, stepId, true)
1016
- };
1017
- }
1018
- notifyStepChanged(changeType, stepId, updateDependencies) {
1019
- if (!stepId) {
1020
- throw new Error('Step id is empty');
1021
- }
1022
- this.state.notifyDefinitionChanged(changeType, stepId);
1023
- if (updateDependencies) {
1024
- this.stateModifier.updateDependencies();
1025
- }
1026
- }
1027
- }
1028
-
1029
- class EditorView {
1030
- static create(parent) {
1031
- return new EditorView(parent);
1032
- }
1033
- constructor(parent) {
1034
- this.parent = parent;
1035
- this.currentContainer = null;
1036
- }
1037
- setContent(content, className) {
1038
- const container = Dom.element('div', {
1039
- class: className
1040
- });
1041
- container.appendChild(content);
1042
- if (this.currentContainer) {
1043
- this.parent.removeChild(this.currentContainer);
1044
- }
1045
- this.parent.appendChild(container);
1046
- this.currentContainer = container;
1047
- }
1048
- destroy() {
1049
- if (this.currentContainer) {
1050
- this.parent.removeChild(this.currentContainer);
1051
- }
1052
- }
1053
- }
1054
-
1055
- class Editor {
1056
- static create(parent, api, stepEditorClassName, stepEditorProvider, rootEditorClassName, rootEditorProvider, customSelectedStepIdProvider) {
1057
- const view = EditorView.create(parent);
1058
- function render(step) {
1059
- const definition = api.getDefinition();
1060
- let content;
1061
- let className;
1062
- if (step) {
1063
- const stepContext = api.createStepEditorContext(step.id);
1064
- content = stepEditorProvider(step, stepContext, definition, api.isReadonly());
1065
- className = stepEditorClassName;
1066
- }
1067
- else {
1068
- const rootContext = api.createRootEditorContext();
1069
- content = rootEditorProvider(definition, rootContext, api.isReadonly());
1070
- className = rootEditorClassName;
1071
- }
1072
- view.setContent(content, className);
1073
- }
1074
- const renderer = api.runRenderer(step => render(step), customSelectedStepIdProvider);
1075
- return new Editor(view, renderer);
1076
- }
1077
- constructor(view, renderer) {
1078
- this.view = view;
1079
- this.renderer = renderer;
1080
- }
1081
- destroy() {
1082
- this.view.destroy();
1083
- this.renderer.destroy();
1084
- }
1085
- }
1086
-
1087
- class ValidationErrorBadgeView {
1088
- static create(parent, cfg) {
1089
- const g = Dom.svg('g');
1090
- const halfOfSize = cfg.size / 2;
1091
- const circle = Dom.svg('path', {
1092
- class: 'sqd-validation-error',
1093
- d: `M 0 ${-halfOfSize} l ${halfOfSize} ${cfg.size} l ${-cfg.size} 0 Z`
1094
- });
1095
- Dom.translate(circle, halfOfSize, halfOfSize);
1096
- g.appendChild(circle);
1097
- const icon = Icons.appendPath(g, 'sqd-validation-error-icon-path', Icons.alert, cfg.iconSize);
1098
- const offsetX = (cfg.size - cfg.iconSize) / 2;
1099
- const offsetY = offsetX * 1.5;
1100
- Dom.translate(icon, offsetX, offsetY);
1101
- parent.appendChild(g);
1102
- return new ValidationErrorBadgeView(parent, g, cfg.size, cfg.size);
1103
- }
1104
- constructor(parent, g, width, height) {
1105
- this.parent = parent;
1106
- this.g = g;
1107
- this.width = width;
1108
- this.height = height;
1109
- }
1110
- destroy() {
1111
- this.parent.removeChild(this.g);
1112
- }
1113
- }
1114
-
1115
- class ValidatorFactory {
1116
- static createForStep(stepContext, view, componentContext) {
1117
- return () => {
1118
- if (!componentContext.validator.validateStep(stepContext.step, stepContext.parentSequence)) {
1119
- return false;
1120
- }
1121
- if (view.haveCollapsedChildren) {
1122
- let allChildrenValid = true;
1123
- componentContext.definitionWalker.forEachChildren(stepContext.step, (step, _, parentSequence) => {
1124
- if (!componentContext.validator.validateStep(step, parentSequence)) {
1125
- allChildrenValid = false;
1126
- return false;
1127
- }
1128
- });
1129
- if (!allChildrenValid) {
1130
- return false;
1131
- }
1132
- }
1133
- return true;
1134
- };
1135
- }
1136
- static createForRoot(componentContext) {
1137
- return () => {
1138
- return componentContext.validator.validateRoot();
1139
- };
1140
- }
1141
- }
1142
-
1143
- class ValidationErrorBadge {
1144
- static createForStep(parentElement, view, stepContext, componentContext, configuration) {
1145
- const validator = ValidatorFactory.createForStep(stepContext, view, componentContext);
1146
- return new ValidationErrorBadge(parentElement, validator, configuration);
1147
- }
1148
- static createForRoot(parentElement, componentContext, configuration) {
1149
- const validator = ValidatorFactory.createForRoot(componentContext);
1150
- return new ValidationErrorBadge(parentElement, validator, configuration);
1151
- }
1152
- constructor(parentElement, validator, configuration) {
1153
- this.parentElement = parentElement;
1154
- this.validator = validator;
1155
- this.configuration = configuration;
1156
- this.view = null;
958
+ constructor(parentElement, validator, configuration) {
959
+ this.parentElement = parentElement;
960
+ this.validator = validator;
961
+ this.configuration = configuration;
962
+ this.view = null;
1157
963
  }
1158
964
  update(result) {
1159
965
  const isValid = this.validator();
@@ -1173,7 +979,7 @@
1173
979
  }
1174
980
  }
1175
981
 
1176
- const defaultConfiguration$6 = {
982
+ const defaultConfiguration$7 = {
1177
983
  view: {
1178
984
  size: 22,
1179
985
  iconSize: 12
@@ -1181,7 +987,7 @@
1181
987
  };
1182
988
  class ValidationErrorBadgeExtension {
1183
989
  static create(configuration) {
1184
- return new ValidationErrorBadgeExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$6);
990
+ return new ValidationErrorBadgeExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$7);
1185
991
  }
1186
992
  constructor(configuration) {
1187
993
  this.configuration = configuration;
@@ -1481,6 +1287,20 @@
1481
1287
  }
1482
1288
  }
1483
1289
 
1290
+ exports.ClickCommandType = void 0;
1291
+ (function (ClickCommandType) {
1292
+ ClickCommandType[ClickCommandType["selectStep"] = 1] = "selectStep";
1293
+ ClickCommandType[ClickCommandType["rerenderStep"] = 2] = "rerenderStep";
1294
+ ClickCommandType[ClickCommandType["openFolder"] = 3] = "openFolder";
1295
+ ClickCommandType[ClickCommandType["triggerCustomAction"] = 4] = "triggerCustomAction";
1296
+ })(exports.ClickCommandType || (exports.ClickCommandType = {}));
1297
+ exports.PlaceholderDirection = void 0;
1298
+ (function (PlaceholderDirection) {
1299
+ PlaceholderDirection[PlaceholderDirection["none"] = 0] = "none";
1300
+ PlaceholderDirection[PlaceholderDirection["in"] = 1] = "in";
1301
+ PlaceholderDirection[PlaceholderDirection["out"] = 2] = "out";
1302
+ })(exports.PlaceholderDirection || (exports.PlaceholderDirection = {}));
1303
+
1484
1304
  class StartStopRootComponentView {
1485
1305
  static create(parent, sequence, parentPlaceIndicator, context, cfg) {
1486
1306
  const g = Dom.svg('g', {
@@ -1577,7 +1397,7 @@
1577
1397
  }
1578
1398
  }
1579
1399
 
1580
- const defaultConfiguration$5 = {
1400
+ const defaultConfiguration$6 = {
1581
1401
  view: {
1582
1402
  size: 30,
1583
1403
  defaultIconSize: 22,
@@ -1589,7 +1409,7 @@
1589
1409
  };
1590
1410
  class StartStopRootComponentExtension {
1591
1411
  static create(configuration) {
1592
- return new StartStopRootComponentExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$5);
1412
+ return new StartStopRootComponentExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$6);
1593
1413
  }
1594
1414
  constructor(configuration) {
1595
1415
  this.configuration = configuration;
@@ -1823,15 +1643,15 @@
1823
1643
  };
1824
1644
 
1825
1645
  class CenteredViewportCalculator {
1826
- static center(margin, canvasSize, rootComponentSize) {
1646
+ static center(padding, canvasSize, rootComponentSize) {
1827
1647
  if (canvasSize.x === 0 || canvasSize.y === 0) {
1828
1648
  return {
1829
1649
  position: new Vector(0, 0),
1830
1650
  scale: 1
1831
1651
  };
1832
1652
  }
1833
- const canvasSafeWidth = Math.max(canvasSize.x - margin * 2, 0);
1834
- const canvasSafeHeight = Math.max(canvasSize.y - margin * 2, 0);
1653
+ const canvasSafeWidth = Math.max(canvasSize.x - padding * 2, 0);
1654
+ const canvasSafeHeight = Math.max(canvasSize.y - padding * 2, 0);
1835
1655
  const scale = Math.min(Math.min(canvasSafeWidth / rootComponentSize.x, canvasSafeHeight / rootComponentSize.y), 1);
1836
1656
  const width = rootComponentSize.x * scale;
1837
1657
  const height = rootComponentSize.y * scale;
@@ -1842,7 +1662,7 @@
1842
1662
  scale
1843
1663
  };
1844
1664
  }
1845
- static focusOnComponent(canvasSize, viewport, componentPosition, componentSize) {
1665
+ static getFocusedOnComponent(canvasSize, viewport, componentPosition, componentSize) {
1846
1666
  const realPosition = viewport.position.divideByScalar(viewport.scale).subtract(componentPosition.divideByScalar(viewport.scale));
1847
1667
  const componentOffset = componentSize.divideByScalar(2);
1848
1668
  const position = realPosition.add(canvasSize.divideByScalar(2)).subtract(componentOffset);
@@ -1850,82 +1670,15 @@
1850
1670
  }
1851
1671
  }
1852
1672
 
1853
- class NextQuantifiedNumber {
1854
- constructor(values) {
1855
- this.values = values;
1856
- }
1857
- next(value, direction) {
1858
- let bestIndex = 0;
1859
- let bestDistance = Number.MAX_VALUE;
1860
- for (let i = 0; i < this.values.length; i++) {
1861
- const distance = Math.abs(this.values[i] - value);
1862
- if (bestDistance > distance) {
1863
- bestIndex = i;
1864
- bestDistance = distance;
1865
- }
1866
- }
1867
- let index;
1868
- if (direction) {
1869
- index = Math.min(bestIndex + 1, this.values.length - 1);
1870
- }
1871
- else {
1872
- index = Math.max(bestIndex - 1, 0);
1873
- }
1874
- return {
1875
- current: this.values[bestIndex],
1876
- next: this.values[index]
1877
- };
1878
- }
1879
- }
1880
-
1881
- 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];
1882
- const MAX_DELTA_Y$1 = 16;
1883
- const quantifiedScale = new NextQuantifiedNumber(SCALES);
1884
- class QuantifiedScaleViewportCalculator {
1885
- static zoom(current, direction) {
1886
- const nextScale = quantifiedScale.next(current.scale, direction);
1887
- return {
1888
- position: current.position,
1889
- scale: nextScale.next
1890
- };
1891
- }
1892
- static zoomByWheel(current, e, canvasPosition) {
1893
- if (e.deltaY === 0) {
1894
- return null;
1895
- }
1896
- const nextScale = quantifiedScale.next(current.scale, e.deltaY < 0);
1897
- let scale;
1898
- const absDeltaY = Math.abs(e.deltaY);
1899
- if (absDeltaY < MAX_DELTA_Y$1) {
1900
- const fraction = absDeltaY / MAX_DELTA_Y$1;
1901
- const step = nextScale.next - nextScale.current;
1902
- scale = current.scale + step * fraction;
1903
- }
1904
- else {
1905
- scale = nextScale.next;
1906
- }
1907
- const mousePoint = new Vector(e.pageX, e.pageY).subtract(canvasPosition);
1908
- // The real point is point on canvas with no scale.
1909
- const mouseRealPoint = mousePoint.divideByScalar(current.scale).subtract(current.position.divideByScalar(current.scale));
1910
- const position = mouseRealPoint.multiplyByScalar(-scale).add(mousePoint);
1911
- return { position, scale };
1912
- }
1913
- }
1914
-
1915
- class ClassicWheelController {
1916
- static create(api) {
1917
- return new ClassicWheelController(api);
1673
+ class ClassicWheelController {
1674
+ static create(api) {
1675
+ return new ClassicWheelController(api);
1918
1676
  }
1919
1677
  constructor(api) {
1920
1678
  this.api = api;
1921
1679
  }
1922
1680
  onWheel(e) {
1923
- const viewport = this.api.getViewport();
1924
- const canvasPosition = this.api.getCanvasPosition();
1925
- const newViewport = QuantifiedScaleViewportCalculator.zoomByWheel(viewport, e, canvasPosition);
1926
- if (newViewport) {
1927
- this.api.setViewport(newViewport);
1928
- }
1681
+ this.api.handleWheelEvent(e);
1929
1682
  }
1930
1683
  }
1931
1684
 
@@ -1935,83 +1688,172 @@
1935
1688
  }
1936
1689
  }
1937
1690
 
1938
- function animate(interval, handler) {
1939
- const iv = setInterval(tick, 15);
1940
- const startTime = Date.now();
1941
- const anim = {
1942
- isAlive: true,
1943
- stop: () => {
1944
- anim.isAlive = false;
1945
- clearInterval(iv);
1691
+ class NextQuantifiedNumber {
1692
+ constructor(values) {
1693
+ this.values = values;
1694
+ }
1695
+ next(value, direction) {
1696
+ let bestIndex = 0;
1697
+ let bestDistance = Number.MAX_VALUE;
1698
+ for (let i = 0; i < this.values.length; i++) {
1699
+ const distance = Math.abs(this.values[i] - value);
1700
+ if (bestDistance > distance) {
1701
+ bestIndex = i;
1702
+ bestDistance = distance;
1703
+ }
1946
1704
  }
1947
- };
1948
- function tick() {
1949
- const progress = Math.min((Date.now() - startTime) / interval, 1);
1950
- handler(progress);
1951
- if (progress === 1) {
1952
- anim.stop();
1705
+ let index;
1706
+ if (direction) {
1707
+ index = Math.min(bestIndex + 1, this.values.length - 1);
1953
1708
  }
1954
- }
1955
- return anim;
1956
- }
1957
-
1958
- class ViewportAnimator {
1959
- constructor(api) {
1960
- this.api = api;
1961
- }
1962
- execute(target) {
1963
- if (this.animation && this.animation.isAlive) {
1964
- this.animation.stop();
1709
+ else {
1710
+ index = Math.max(bestIndex - 1, 0);
1965
1711
  }
1966
- const viewport = this.api.getViewport();
1967
- const startPosition = viewport.position;
1968
- const startScale = viewport.scale;
1969
- const deltaPosition = startPosition.subtract(target.position);
1970
- const deltaScale = startScale - target.scale;
1971
- this.animation = animate(150, progress => {
1972
- const newScale = startScale - deltaScale * progress;
1973
- this.api.setViewport({
1974
- position: startPosition.subtract(deltaPosition.multiplyByScalar(progress)),
1975
- scale: newScale
1976
- });
1977
- });
1712
+ return {
1713
+ current: this.values[bestIndex],
1714
+ next: this.values[index]
1715
+ };
1716
+ }
1717
+ limit(scale) {
1718
+ const min = this.values[0];
1719
+ const max = this.values[this.values.length - 1];
1720
+ return Math.min(Math.max(scale, min), max);
1978
1721
  }
1979
1722
  }
1980
1723
 
1981
- const CENTER_MARGIN = 10;
1724
+ const defaultConfiguration$5 = {
1725
+ 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],
1726
+ smoothDeltaYLimit: 16,
1727
+ padding: 10
1728
+ };
1982
1729
  class DefaultViewportController {
1983
- static create(api) {
1984
- return new DefaultViewportController(api);
1730
+ static create(api, configuration) {
1731
+ const config = configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$5;
1732
+ const nqn = new NextQuantifiedNumber(config.scales);
1733
+ return new DefaultViewportController(config.smoothDeltaYLimit, nqn, api, config.padding);
1985
1734
  }
1986
- constructor(api) {
1735
+ constructor(smoothDeltaYLimit, nqn, api, padding) {
1736
+ this.smoothDeltaYLimit = smoothDeltaYLimit;
1737
+ this.nqn = nqn;
1987
1738
  this.api = api;
1988
- this.animator = new ViewportAnimator(this.api);
1739
+ this.padding = padding;
1989
1740
  }
1990
- setDefault() {
1741
+ getDefault() {
1991
1742
  const rootComponentSize = this.api.getRootComponentSize();
1992
1743
  const canvasSize = this.api.getCanvasSize();
1993
- const target = CenteredViewportCalculator.center(CENTER_MARGIN, canvasSize, rootComponentSize);
1994
- this.api.setViewport(target);
1744
+ return CenteredViewportCalculator.center(this.padding, canvasSize, rootComponentSize);
1995
1745
  }
1996
- zoom(direction) {
1997
- const viewport = this.api.getViewport();
1998
- const target = QuantifiedScaleViewportCalculator.zoom(viewport, direction);
1999
- this.api.setViewport(target);
1746
+ getZoomed(direction) {
1747
+ const current = this.api.getViewport();
1748
+ const nextScale = this.nqn.next(current.scale, direction);
1749
+ if (nextScale) {
1750
+ return {
1751
+ position: current.position,
1752
+ scale: nextScale.next
1753
+ };
1754
+ }
1755
+ return null;
2000
1756
  }
2001
- focusOnComponent(componentPosition, componentSize) {
1757
+ getFocusedOnComponent(componentPosition, componentSize) {
2002
1758
  const viewport = this.api.getViewport();
2003
1759
  const canvasSize = this.api.getCanvasSize();
2004
- const target = CenteredViewportCalculator.focusOnComponent(canvasSize, viewport, componentPosition, componentSize);
2005
- this.animateTo(target);
1760
+ return CenteredViewportCalculator.getFocusedOnComponent(canvasSize, viewport, componentPosition, componentSize);
2006
1761
  }
2007
- animateTo(viewport) {
2008
- this.animator.execute(viewport);
1762
+ getNextScale(scale, direction) {
1763
+ return this.nqn.next(scale, direction);
1764
+ }
1765
+ limitScale(scale) {
1766
+ return this.nqn.limit(scale);
2009
1767
  }
2010
1768
  }
2011
1769
 
2012
1770
  class DefaultViewportControllerExtension {
2013
- constructor() {
2014
- this.create = DefaultViewportController.create;
1771
+ static create(configuration) {
1772
+ return new DefaultViewportControllerExtension(configuration);
1773
+ }
1774
+ constructor(configuration) {
1775
+ this.configuration = configuration;
1776
+ }
1777
+ create(api) {
1778
+ return DefaultViewportController.create(api, this.configuration);
1779
+ }
1780
+ }
1781
+
1782
+ class StepComponent {
1783
+ static create(view, stepContext, componentContext) {
1784
+ const badges = Badges.createForStep(stepContext, view, componentContext);
1785
+ return new StepComponent(view, stepContext.step, stepContext.parentSequence, view.hasOutput, badges);
1786
+ }
1787
+ constructor(view, step, parentSequence, hasOutput, badges) {
1788
+ this.view = view;
1789
+ this.step = step;
1790
+ this.parentSequence = parentSequence;
1791
+ this.hasOutput = hasOutput;
1792
+ this.badges = badges;
1793
+ }
1794
+ findById(stepId) {
1795
+ if (this.step.id === stepId) {
1796
+ return this;
1797
+ }
1798
+ if (this.view.sequenceComponents) {
1799
+ for (const component of this.view.sequenceComponents) {
1800
+ const result = component.findById(stepId);
1801
+ if (result) {
1802
+ return result;
1803
+ }
1804
+ }
1805
+ }
1806
+ return null;
1807
+ }
1808
+ resolveClick(click) {
1809
+ if (this.view.sequenceComponents) {
1810
+ for (const component of this.view.sequenceComponents) {
1811
+ const result = component.resolveClick(click);
1812
+ if (result) {
1813
+ return result;
1814
+ }
1815
+ }
1816
+ }
1817
+ const badgeResult = this.badges.resolveClick(click);
1818
+ if (badgeResult) {
1819
+ return badgeResult;
1820
+ }
1821
+ const viewResult = this.view.resolveClick(click);
1822
+ if (viewResult) {
1823
+ return viewResult === true
1824
+ ? {
1825
+ type: exports.ClickCommandType.selectStep,
1826
+ component: this
1827
+ }
1828
+ : viewResult;
1829
+ }
1830
+ return null;
1831
+ }
1832
+ resolvePlaceholders(skipComponent, result) {
1833
+ if (skipComponent !== this) {
1834
+ if (this.view.sequenceComponents) {
1835
+ this.view.sequenceComponents.forEach(component => component.resolvePlaceholders(skipComponent, result));
1836
+ }
1837
+ if (this.view.placeholders) {
1838
+ this.view.placeholders.forEach(ph => result.placeholders.push(ph));
1839
+ }
1840
+ result.components.push(this);
1841
+ }
1842
+ }
1843
+ setIsDragging(isDragging) {
1844
+ this.view.setIsDragging(isDragging);
1845
+ }
1846
+ setIsSelected(isSelected) {
1847
+ this.view.setIsSelected(isSelected);
1848
+ }
1849
+ setIsDisabled(isDisabled) {
1850
+ this.view.setIsDisabled(isDisabled);
1851
+ }
1852
+ updateBadges(result) {
1853
+ if (this.view.sequenceComponents) {
1854
+ this.view.sequenceComponents.forEach(component => component.updateBadges(result));
1855
+ }
1856
+ this.badges.update(result);
2015
1857
  }
2016
1858
  }
2017
1859
 
@@ -2134,24 +1976,375 @@
2134
1976
  Dom.toggleClass(region, isSelected, 'sqd-selected');
2135
1977
  });
2136
1978
  }
2137
- }
2138
- function drawLine(parent, x1, y1, x2, y2) {
2139
- const line = Dom.svg('line', {
2140
- class: 'sqd-region',
2141
- x1,
2142
- y1,
2143
- x2,
2144
- y2
2145
- });
2146
- parent.insertBefore(line, parent.firstChild);
2147
- return line;
1979
+ }
1980
+ function drawLine(parent, x1, y1, x2, y2) {
1981
+ const line = Dom.svg('line', {
1982
+ class: 'sqd-region',
1983
+ x1,
1984
+ y1,
1985
+ x2,
1986
+ y2
1987
+ });
1988
+ parent.insertBefore(line, parent.firstChild);
1989
+ return line;
1990
+ }
1991
+
1992
+ class DefaultRegionComponentViewExtension {
1993
+ create(parentElement, componentClassName, stepContext, _, contentFactory) {
1994
+ const g = ComponentDom.stepG(componentClassName, stepContext.step.type, stepContext.step.id);
1995
+ parentElement.appendChild(g);
1996
+ return contentFactory(g, DefaultRegionView.create);
1997
+ }
1998
+ }
1999
+
2000
+ class DefaultViewportControllerDesignerExtension {
2001
+ static create(configuration) {
2002
+ return new DefaultViewportControllerDesignerExtension(DefaultViewportControllerExtension.create(configuration));
2003
+ }
2004
+ constructor(viewportController) {
2005
+ this.viewportController = viewportController;
2006
+ }
2007
+ }
2008
+
2009
+ class LineGrid {
2010
+ static create(size) {
2011
+ const path = Dom.svg('path', {
2012
+ class: 'sqd-line-grid-path',
2013
+ fill: 'none'
2014
+ });
2015
+ return new LineGrid(size, path);
2016
+ }
2017
+ constructor(size, element) {
2018
+ this.size = size;
2019
+ this.element = element;
2020
+ }
2021
+ setScale(_, scaledSize) {
2022
+ Dom.attrs(this.element, {
2023
+ d: `M ${scaledSize.x} 0 L 0 0 0 ${scaledSize.y}`
2024
+ });
2025
+ }
2026
+ }
2027
+
2028
+ const defaultConfiguration$4 = {
2029
+ gridSizeX: 48,
2030
+ gridSizeY: 48
2031
+ };
2032
+ class LineGridExtension {
2033
+ static create(configuration) {
2034
+ return new LineGridExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$4);
2035
+ }
2036
+ constructor(configuration) {
2037
+ this.configuration = configuration;
2038
+ }
2039
+ create() {
2040
+ const size = new Vector(this.configuration.gridSizeX, this.configuration.gridSizeY);
2041
+ return LineGrid.create(size);
2042
+ }
2043
+ }
2044
+
2045
+ class LineGridDesignerExtension {
2046
+ static create(configuration) {
2047
+ const grid = LineGridExtension.create(configuration);
2048
+ return new LineGridDesignerExtension(grid);
2049
+ }
2050
+ constructor(grid) {
2051
+ this.grid = grid;
2052
+ }
2053
+ }
2054
+
2055
+ class StartStopRootComponentDesignerExtension {
2056
+ static create(configuration) {
2057
+ return new StartStopRootComponentDesignerExtension(StartStopRootComponentExtension.create(configuration));
2058
+ }
2059
+ constructor(rootComponent) {
2060
+ this.rootComponent = rootComponent;
2061
+ }
2062
+ }
2063
+
2064
+ const defaultConfiguration$3 = {
2065
+ view: {
2066
+ paddingTop: 20,
2067
+ paddingX: 20,
2068
+ inputSize: 18,
2069
+ inputIconSize: 14,
2070
+ label: {
2071
+ height: 22,
2072
+ paddingX: 10,
2073
+ minWidth: 50,
2074
+ radius: 10
2075
+ }
2076
+ }
2077
+ };
2078
+ class ContainerStepExtension {
2079
+ static create(configuration) {
2080
+ return new ContainerStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$3);
2081
+ }
2082
+ constructor(configuration) {
2083
+ this.configuration = configuration;
2084
+ this.componentType = 'container';
2085
+ this.createComponentView = createContainerStepComponentViewFactory(this.configuration.view);
2086
+ }
2087
+ }
2088
+
2089
+ const defaultConfiguration$2 = {
2090
+ view: {
2091
+ minContainerWidth: 40,
2092
+ paddingX: 20,
2093
+ paddingTop: 20,
2094
+ connectionHeight: 16,
2095
+ inputSize: 18,
2096
+ inputIconSize: 14,
2097
+ branchNameLabel: {
2098
+ height: 22,
2099
+ paddingX: 10,
2100
+ minWidth: 50,
2101
+ radius: 10
2102
+ },
2103
+ nameLabel: {
2104
+ height: 22,
2105
+ paddingX: 10,
2106
+ minWidth: 50,
2107
+ radius: 10
2108
+ }
2109
+ }
2110
+ };
2111
+ class SwitchStepExtension {
2112
+ static create(configuration) {
2113
+ return new SwitchStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$2);
2114
+ }
2115
+ constructor(configuration) {
2116
+ this.configuration = configuration;
2117
+ this.componentType = 'switch';
2118
+ this.createComponentView = createSwitchStepComponentViewFactory(this.configuration.view);
2119
+ }
2120
+ }
2121
+
2122
+ const defaultConfiguration$1 = {
2123
+ view: {
2124
+ paddingLeft: 12,
2125
+ paddingRight: 12,
2126
+ paddingY: 10,
2127
+ textMarginLeft: 12,
2128
+ minTextWidth: 70,
2129
+ iconSize: 22,
2130
+ radius: 5,
2131
+ inputSize: 14,
2132
+ outputSize: 10
2133
+ }
2134
+ };
2135
+ class TaskStepExtension {
2136
+ static create(configuration) {
2137
+ return new TaskStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$1);
2138
+ }
2139
+ constructor(configuration) {
2140
+ this.configuration = configuration;
2141
+ this.componentType = 'task';
2142
+ this.createComponentView = createTaskStepComponentViewFactory(false, this.configuration.view);
2143
+ }
2144
+ }
2145
+
2146
+ class StepsDesignerExtension {
2147
+ static create(configuration) {
2148
+ const steps = [];
2149
+ if (configuration.container) {
2150
+ steps.push(ContainerStepExtension.create(configuration.container));
2151
+ }
2152
+ if (configuration.switch) {
2153
+ steps.push(SwitchStepExtension.create(configuration.switch));
2154
+ }
2155
+ if (configuration.task) {
2156
+ steps.push(TaskStepExtension.create(configuration.task));
2157
+ }
2158
+ return new StepsDesignerExtension(steps);
2159
+ }
2160
+ constructor(steps) {
2161
+ this.steps = steps;
2162
+ }
2163
+ }
2164
+
2165
+ class DefinitionValidator {
2166
+ constructor(configuration, state) {
2167
+ this.configuration = configuration;
2168
+ this.state = state;
2169
+ }
2170
+ validateStep(step, parentSequence) {
2171
+ var _a;
2172
+ if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.step) {
2173
+ return this.configuration.step(step, parentSequence, this.state.definition);
2174
+ }
2175
+ return true;
2176
+ }
2177
+ validateRoot() {
2178
+ var _a;
2179
+ if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.root) {
2180
+ return this.configuration.root(this.state.definition);
2181
+ }
2182
+ return true;
2183
+ }
2184
+ }
2185
+
2186
+ class IconProvider {
2187
+ constructor(configuration) {
2188
+ this.configuration = configuration;
2189
+ }
2190
+ getIconUrl(step) {
2191
+ if (this.configuration.iconUrlProvider) {
2192
+ return this.configuration.iconUrlProvider(step.componentType, step.type);
2193
+ }
2194
+ return null;
2195
+ }
2196
+ }
2197
+
2198
+ class StepComponentViewContextFactory {
2199
+ static create(stepContext, componentContext) {
2200
+ const preferenceKeyPrefix = stepContext.step.id + ':';
2201
+ return {
2202
+ i18n: componentContext.i18n,
2203
+ getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
2204
+ getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
2205
+ createSequenceComponent: (parentElement, sequence) => {
2206
+ const sequenceContext = {
2207
+ sequence,
2208
+ depth: stepContext.depth + 1,
2209
+ isInputConnected: true,
2210
+ isOutputConnected: stepContext.isOutputConnected,
2211
+ isPreview: stepContext.isPreview
2212
+ };
2213
+ return componentContext.services.sequenceComponent.create(parentElement, sequenceContext, componentContext);
2214
+ },
2215
+ createRegionComponentView(parentElement, componentClassName, contentFactory) {
2216
+ return componentContext.services.regionComponentView.create(parentElement, componentClassName, stepContext, this, contentFactory);
2217
+ },
2218
+ createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
2219
+ getPreference: (key) => componentContext.preferenceStorage.getItem(preferenceKeyPrefix + key),
2220
+ setPreference: (key, value) => componentContext.preferenceStorage.setItem(preferenceKeyPrefix + key, value)
2221
+ };
2222
+ }
2223
+ }
2224
+
2225
+ class StepComponentFactory {
2226
+ constructor(stepExtensionResolver) {
2227
+ this.stepExtensionResolver = stepExtensionResolver;
2228
+ }
2229
+ create(parentElement, stepContext, componentContext) {
2230
+ const viewContext = StepComponentViewContextFactory.create(stepContext, componentContext);
2231
+ const extension = this.stepExtensionResolver.resolve(stepContext.step.componentType);
2232
+ const view = extension.createComponentView(parentElement, stepContext, viewContext);
2233
+ const wrappedView = componentContext.services.stepComponentViewWrapper.wrap(view, stepContext);
2234
+ return StepComponent.create(wrappedView, stepContext, componentContext);
2235
+ }
2236
+ }
2237
+
2238
+ class ComponentContext {
2239
+ static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
2240
+ const validator = new DefinitionValidator(configuration.validator, state);
2241
+ const iconProvider = new IconProvider(configuration.steps);
2242
+ const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
2243
+ return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
2244
+ }
2245
+ constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
2246
+ this.shadowRoot = shadowRoot;
2247
+ this.validator = validator;
2248
+ this.iconProvider = iconProvider;
2249
+ this.placeholderController = placeholderController;
2250
+ this.stepComponentFactory = stepComponentFactory;
2251
+ this.definitionWalker = definitionWalker;
2252
+ this.services = services;
2253
+ this.preferenceStorage = preferenceStorage;
2254
+ this.i18n = i18n;
2255
+ }
2256
+ }
2257
+
2258
+ class CustomActionController {
2259
+ constructor(configuration, state, stateModifier) {
2260
+ this.configuration = configuration;
2261
+ this.state = state;
2262
+ this.stateModifier = stateModifier;
2263
+ }
2264
+ trigger(action, step, sequence) {
2265
+ const handler = this.configuration.customActionHandler;
2266
+ if (!handler) {
2267
+ console.warn(`Custom action handler is not defined (action type: ${action.type})`);
2268
+ return;
2269
+ }
2270
+ const context = this.createCustomActionHandlerContext();
2271
+ handler(action, step, sequence, context);
2272
+ }
2273
+ createCustomActionHandlerContext() {
2274
+ return {
2275
+ notifyStepNameChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepNameChanged, stepId, false),
2276
+ notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepPropertyChanged, stepId, false),
2277
+ notifyStepInserted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepInserted, stepId, true),
2278
+ notifyStepMoved: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepMoved, stepId, true),
2279
+ notifyStepDeleted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepDeleted, stepId, true)
2280
+ };
2281
+ }
2282
+ notifyStepChanged(changeType, stepId, updateDependencies) {
2283
+ if (!stepId) {
2284
+ throw new Error('Step id is empty');
2285
+ }
2286
+ this.state.notifyDefinitionChanged(changeType, stepId);
2287
+ if (updateDependencies) {
2288
+ this.stateModifier.updateDependencies();
2289
+ }
2290
+ }
2291
+ }
2292
+
2293
+ class EditorView {
2294
+ static create(parent) {
2295
+ return new EditorView(parent);
2296
+ }
2297
+ constructor(parent) {
2298
+ this.parent = parent;
2299
+ this.currentContainer = null;
2300
+ }
2301
+ setContent(content, className) {
2302
+ const container = Dom.element('div', {
2303
+ class: className
2304
+ });
2305
+ container.appendChild(content);
2306
+ if (this.currentContainer) {
2307
+ this.parent.removeChild(this.currentContainer);
2308
+ }
2309
+ this.parent.appendChild(container);
2310
+ this.currentContainer = container;
2311
+ }
2312
+ destroy() {
2313
+ if (this.currentContainer) {
2314
+ this.parent.removeChild(this.currentContainer);
2315
+ }
2316
+ }
2148
2317
  }
2149
2318
 
2150
- class DefaultRegionComponentViewExtension {
2151
- create(parentElement, componentClassName, stepContext, _, contentFactory) {
2152
- const g = ComponentDom.stepG(componentClassName, stepContext.step.type, stepContext.step.id);
2153
- parentElement.appendChild(g);
2154
- return contentFactory(g, DefaultRegionView.create);
2319
+ class Editor {
2320
+ static create(parent, api, stepEditorClassName, stepEditorProvider, rootEditorClassName, rootEditorProvider, customSelectedStepIdProvider) {
2321
+ const view = EditorView.create(parent);
2322
+ function render(step) {
2323
+ const definition = api.getDefinition();
2324
+ let content;
2325
+ let className;
2326
+ if (step) {
2327
+ const stepContext = api.createStepEditorContext(step.id);
2328
+ content = stepEditorProvider(step, stepContext, definition, api.isReadonly());
2329
+ className = stepEditorClassName;
2330
+ }
2331
+ else {
2332
+ const rootContext = api.createRootEditorContext();
2333
+ content = rootEditorProvider(definition, rootContext, api.isReadonly());
2334
+ className = rootEditorClassName;
2335
+ }
2336
+ view.setContent(content, className);
2337
+ }
2338
+ const renderer = api.runRenderer(step => render(step), customSelectedStepIdProvider);
2339
+ return new Editor(view, renderer);
2340
+ }
2341
+ constructor(view, renderer) {
2342
+ this.view = view;
2343
+ this.renderer = renderer;
2344
+ }
2345
+ destroy() {
2346
+ this.view.destroy();
2347
+ this.renderer.destroy();
2155
2348
  }
2156
2349
  }
2157
2350
 
@@ -2354,10 +2547,26 @@
2354
2547
  return new Vector(touch.pageX, touch.pageY);
2355
2548
  }
2356
2549
  throw new Error('Unknown touch position');
2550
+ }
2551
+ function calculateFingerDistance(e) {
2552
+ if (e.touches.length === 2) {
2553
+ const t0 = e.touches[0];
2554
+ const t1 = e.touches[1];
2555
+ return Math.hypot(t0.clientX - t1.clientX, t0.clientY - t1.clientY);
2556
+ }
2557
+ throw new Error('Cannot calculate finger distance');
2558
+ }
2559
+ function readFingerCenterPoint(e) {
2560
+ if (e.touches.length === 2) {
2561
+ const t0 = e.touches[0];
2562
+ const t1 = e.touches[1];
2563
+ return new Vector((t0.pageX + t1.pageX) / 2, (t0.pageY + t1.pageY) / 2);
2564
+ }
2565
+ throw new Error('Cannot calculate finger center point');
2357
2566
  }
2358
2567
 
2359
- const notInitializedError = 'State is not initialized';
2360
- const nonPassiveOptions = {
2568
+ const notInitializedError$1 = 'State is not initialized';
2569
+ const nonPassiveOptions$1 = {
2361
2570
  passive: false
2362
2571
  };
2363
2572
  class BehaviorController {
@@ -2367,6 +2576,8 @@
2367
2576
  constructor(dom, shadowRoot) {
2368
2577
  this.dom = dom;
2369
2578
  this.shadowRoot = shadowRoot;
2579
+ this.previousEndToken = null;
2580
+ this.state = null;
2370
2581
  this.onMouseMove = (e) => {
2371
2582
  e.preventDefault();
2372
2583
  e.stopPropagation();
@@ -2387,7 +2598,7 @@
2387
2598
  e.preventDefault();
2388
2599
  e.stopPropagation();
2389
2600
  if (!this.state) {
2390
- throw new Error(notInitializedError);
2601
+ throw new Error(notInitializedError$1);
2391
2602
  }
2392
2603
  const position = (_a = this.state.lastPosition) !== null && _a !== void 0 ? _a : this.state.startPosition;
2393
2604
  const element = this.dom.elementFromPoint(position.x, position.y);
@@ -2418,27 +2629,27 @@
2418
2629
  }
2419
2630
  bind(target) {
2420
2631
  target.addEventListener('mousemove', this.onMouseMove, false);
2421
- target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2632
+ target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions$1);
2422
2633
  target.addEventListener('mouseup', this.onMouseUp, false);
2423
- target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2424
- target.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2634
+ target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions$1);
2635
+ target.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions$1);
2425
2636
  }
2426
2637
  unbind(target) {
2427
2638
  target.removeEventListener('mousemove', this.onMouseMove, false);
2428
- target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
2639
+ target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions$1);
2429
2640
  target.removeEventListener('mouseup', this.onMouseUp, false);
2430
- target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
2431
- target.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
2641
+ target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions$1);
2642
+ target.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions$1);
2432
2643
  }
2433
2644
  move(position) {
2434
2645
  if (!this.state) {
2435
- throw new Error(notInitializedError);
2646
+ throw new Error(notInitializedError$1);
2436
2647
  }
2437
2648
  this.state.lastPosition = position;
2438
2649
  const delta = this.state.startPosition.subtract(position);
2439
2650
  const newBehavior = this.state.behavior.onMove(delta);
2440
2651
  if (newBehavior) {
2441
- this.state.behavior.onEnd(true, null);
2652
+ this.state.behavior.onEnd(true, null, null);
2442
2653
  this.state.behavior = newBehavior;
2443
2654
  this.state.startPosition = position;
2444
2655
  this.state.behavior.onStart(this.state.startPosition);
@@ -2446,14 +2657,15 @@
2446
2657
  }
2447
2658
  stop(interrupt, element) {
2448
2659
  if (!this.state) {
2449
- throw new Error(notInitializedError);
2660
+ throw new Error(notInitializedError$1);
2450
2661
  }
2451
2662
  if (this.shadowRoot) {
2452
2663
  this.unbind(this.shadowRoot);
2453
2664
  }
2454
2665
  this.unbind(window);
2455
- this.state.behavior.onEnd(interrupt, element);
2456
- this.state = undefined;
2666
+ const endToken = this.state.behavior.onEnd(interrupt, element, this.previousEndToken);
2667
+ this.state = null;
2668
+ this.previousEndToken = endToken || null;
2457
2669
  }
2458
2670
  }
2459
2671
 
@@ -3021,20 +3233,26 @@
3021
3233
  getCanvasSize() {
3022
3234
  return new Vector(this.canvas.clientWidth, this.canvas.clientHeight);
3023
3235
  }
3024
- bindClick(handler) {
3236
+ bindMouseDown(handler) {
3025
3237
  this.canvas.addEventListener('mousedown', e => {
3026
3238
  e.preventDefault();
3027
3239
  handler(readMousePosition(e), e.target, e.button, e.altKey);
3028
3240
  }, false);
3241
+ }
3242
+ bindTouchStart(clickHandler, pinchToZoomHandler) {
3029
3243
  this.canvas.addEventListener('touchstart', e => {
3030
3244
  var _a;
3031
3245
  e.preventDefault();
3246
+ if (e.touches.length === 2) {
3247
+ pinchToZoomHandler(calculateFingerDistance(e), readFingerCenterPoint(e));
3248
+ return;
3249
+ }
3032
3250
  const clientPosition = readTouchClientPosition(e);
3033
3251
  const dom = (_a = this.shadowRoot) !== null && _a !== void 0 ? _a : document;
3034
3252
  const element = dom.elementFromPoint(clientPosition.x, clientPosition.y);
3035
3253
  if (element) {
3036
3254
  const position = readTouchPosition(e);
3037
- handler(position, element, 0, false);
3255
+ clickHandler(position, element, 0, false);
3038
3256
  }
3039
3257
  }, listenerOptions$1);
3040
3258
  }
@@ -3123,9 +3341,11 @@
3123
3341
  }
3124
3342
  }
3125
3343
  onEnd(interrupt) {
3126
- if (!interrupt) {
3127
- this.stateModifier.trySelectStep(this.pressedStepComponent.step, this.pressedStepComponent.parentSequence);
3344
+ if (interrupt) {
3345
+ return;
3128
3346
  }
3347
+ this.stateModifier.trySelectStep(this.pressedStepComponent.step, this.pressedStepComponent.parentSequence);
3348
+ return new SelectStepBehaviorEndToken(this.pressedStepComponent.step.id, Date.now());
3129
3349
  }
3130
3350
  }
3131
3351
 
@@ -3411,17 +3631,97 @@
3411
3631
  }
3412
3632
  }
3413
3633
 
3634
+ const nonPassiveOptions = {
3635
+ passive: false
3636
+ };
3637
+ const notInitializedError = 'State is not initialized';
3638
+ class PinchToZoomController {
3639
+ static create(workspaceApi, viewportApi, shadowRoot) {
3640
+ return new PinchToZoomController(workspaceApi, viewportApi, shadowRoot);
3641
+ }
3642
+ constructor(workspaceApi, viewportApi, shadowRoot) {
3643
+ this.workspaceApi = workspaceApi;
3644
+ this.viewportApi = viewportApi;
3645
+ this.shadowRoot = shadowRoot;
3646
+ this.state = null;
3647
+ this.onTouchMove = (e) => {
3648
+ e.preventDefault();
3649
+ if (!this.state) {
3650
+ throw new Error(notInitializedError);
3651
+ }
3652
+ const touchEvent = e;
3653
+ const distance = calculateFingerDistance(touchEvent);
3654
+ const centerPoint = readFingerCenterPoint(touchEvent);
3655
+ const deltaCenterPoint = centerPoint.subtract(this.state.lastCenterPoint);
3656
+ const scale = this.viewportApi.limitScale(this.state.startScale * (distance / this.state.startDistance));
3657
+ const zoomPoint = centerPoint.subtract(this.state.canvasPosition);
3658
+ const zoomRealPoint = zoomPoint
3659
+ .divideByScalar(this.state.lastViewport.scale)
3660
+ .subtract(this.state.lastViewport.position.divideByScalar(this.state.lastViewport.scale));
3661
+ const position = zoomRealPoint
3662
+ .multiplyByScalar(-scale)
3663
+ .add(zoomPoint)
3664
+ .add(deltaCenterPoint.divideByScalar(this.state.lastViewport.scale));
3665
+ const newViewport = {
3666
+ position,
3667
+ scale
3668
+ };
3669
+ this.workspaceApi.setViewport(newViewport);
3670
+ this.state.lastCenterPoint = centerPoint;
3671
+ this.state.lastViewport = newViewport;
3672
+ };
3673
+ this.onTouchEnd = (e) => {
3674
+ e.preventDefault();
3675
+ if (!this.state) {
3676
+ throw new Error(notInitializedError);
3677
+ }
3678
+ if (this.shadowRoot) {
3679
+ this.unbind(this.shadowRoot);
3680
+ }
3681
+ this.unbind(window);
3682
+ this.state = null;
3683
+ };
3684
+ }
3685
+ start(startDistance, centerPoint) {
3686
+ if (this.state) {
3687
+ throw new Error(`State is already initialized`);
3688
+ }
3689
+ if (this.shadowRoot) {
3690
+ this.bind(this.shadowRoot);
3691
+ }
3692
+ this.bind(window);
3693
+ const viewport = this.workspaceApi.getViewport();
3694
+ this.state = {
3695
+ canvasPosition: this.workspaceApi.getCanvasPosition(),
3696
+ startScale: viewport.scale,
3697
+ startDistance,
3698
+ lastViewport: viewport,
3699
+ lastCenterPoint: centerPoint
3700
+ };
3701
+ }
3702
+ bind(target) {
3703
+ target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
3704
+ target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
3705
+ }
3706
+ unbind(target) {
3707
+ target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
3708
+ target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
3709
+ }
3710
+ }
3711
+
3414
3712
  class Workspace {
3415
3713
  static create(parent, designerContext, api) {
3416
3714
  var _a;
3417
3715
  const view = WorkspaceView.create(parent, designerContext.componentContext);
3418
3716
  const clickBehaviorResolver = new ClickBehaviorResolver(designerContext);
3419
- const wheelController = designerContext.services.wheelController.create(api.workspace);
3717
+ const clickBehaviorWrapper = designerContext.services.clickBehaviorWrapperExtension.create(designerContext.customActionController);
3718
+ const wheelController = designerContext.services.wheelController.create(api.viewport, api.workspace);
3719
+ const pinchToZoomController = PinchToZoomController.create(api.workspace, api.viewport, api.shadowRoot);
3420
3720
  const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
3421
3721
  ? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
3422
3722
  : undefined);
3423
3723
  const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
3424
- const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, contextMenuController, clickBehaviorResolver, api.viewport, designerContext.services);
3724
+ const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, api.viewport, designerContext.services);
3425
3725
  setTimeout(() => {
3426
3726
  workspace.updateRootComponent();
3427
3727
  api.viewport.resetViewport();
@@ -3431,19 +3731,22 @@
3431
3731
  race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged, designerContext.state.onFolderPathChanged).subscribe(r => {
3432
3732
  workspace.onStateChanged(r[0], r[1], r[2]);
3433
3733
  });
3434
- view.bindClick(workspace.onClick);
3734
+ view.bindMouseDown(workspace.onClick);
3735
+ view.bindTouchStart(workspace.onClick, workspace.onPinchToZoom);
3435
3736
  view.bindWheel(workspace.onWheel);
3436
3737
  view.bindContextMenu(workspace.onContextMenu);
3437
3738
  return workspace;
3438
3739
  }
3439
- constructor(view, definitionWalker, state, behaviorController, wheelController, contextMenuController, clickBehaviorResolver, viewportApi, services) {
3740
+ constructor(view, definitionWalker, state, behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, viewportApi, services) {
3440
3741
  this.view = view;
3441
3742
  this.definitionWalker = definitionWalker;
3442
3743
  this.state = state;
3443
3744
  this.behaviorController = behaviorController;
3444
3745
  this.wheelController = wheelController;
3746
+ this.pinchToZoomController = pinchToZoomController;
3445
3747
  this.contextMenuController = contextMenuController;
3446
3748
  this.clickBehaviorResolver = clickBehaviorResolver;
3749
+ this.clickBehaviorWrapper = clickBehaviorWrapper;
3447
3750
  this.viewportApi = viewportApi;
3448
3751
  this.services = services;
3449
3752
  this.onRendered = new SimpleEvent();
@@ -3457,9 +3760,13 @@
3457
3760
  const forceMove = isMiddleButton || altKey;
3458
3761
  const commandOrNull = this.resolveClick(target, position);
3459
3762
  const behavior = this.clickBehaviorResolver.resolve(commandOrNull, target, forceMove);
3460
- this.behaviorController.start(position, behavior);
3763
+ const wrappedBehavior = this.clickBehaviorWrapper.wrap(behavior, commandOrNull);
3764
+ this.behaviorController.start(position, wrappedBehavior);
3461
3765
  }
3462
3766
  };
3767
+ this.onPinchToZoom = (distance, centerPoint) => {
3768
+ this.pinchToZoomController.start(distance, centerPoint);
3769
+ };
3463
3770
  this.onWheel = (e) => {
3464
3771
  e.preventDefault();
3465
3772
  e.stopPropagation();
@@ -3772,7 +4079,7 @@
3772
4079
  static create(parent, api) {
3773
4080
  const isUndoRedoSupported = api.controlBar.isUndoRedoSupported();
3774
4081
  const view = ControlBarView.create(parent, isUndoRedoSupported, api.i18n);
3775
- const bar = new ControlBar(view, api.controlBar, isUndoRedoSupported);
4082
+ const bar = new ControlBar(view, api.controlBar, api.viewport, isUndoRedoSupported);
3776
4083
  view.bindResetButtonClick(() => bar.onResetButtonClicked());
3777
4084
  view.bindZoomInButtonClick(() => bar.onZoomInButtonClicked());
3778
4085
  view.bindZoomOutButtonClick(() => bar.onZoomOutButtonClicked());
@@ -3786,9 +4093,10 @@
3786
4093
  bar.refreshButtons();
3787
4094
  return bar;
3788
4095
  }
3789
- constructor(view, controlBarApi, isUndoRedoSupported) {
4096
+ constructor(view, controlBarApi, viewportApi, isUndoRedoSupported) {
3790
4097
  this.view = view;
3791
4098
  this.controlBarApi = controlBarApi;
4099
+ this.viewportApi = viewportApi;
3792
4100
  this.isUndoRedoSupported = isUndoRedoSupported;
3793
4101
  }
3794
4102
  updateLayout() {
@@ -3798,13 +4106,13 @@
3798
4106
  //
3799
4107
  }
3800
4108
  onResetButtonClicked() {
3801
- this.controlBarApi.resetViewport();
4109
+ this.viewportApi.resetViewport();
3802
4110
  }
3803
4111
  onZoomInButtonClicked() {
3804
- this.controlBarApi.zoomIn();
4112
+ this.viewportApi.zoom(true);
3805
4113
  }
3806
4114
  onZoomOutButtonClicked() {
3807
- this.controlBarApi.zoomOut();
4115
+ this.viewportApi.zoom(false);
3808
4116
  }
3809
4117
  onMoveButtonClicked() {
3810
4118
  this.controlBarApi.toggleIsDragDisabled();
@@ -4322,31 +4630,6 @@
4322
4630
  }
4323
4631
  }
4324
4632
 
4325
- const defaultConfiguration$4 = {
4326
- view: {
4327
- paddingTop: 20,
4328
- paddingX: 20,
4329
- inputSize: 18,
4330
- inputIconSize: 14,
4331
- label: {
4332
- height: 22,
4333
- paddingX: 10,
4334
- minWidth: 50,
4335
- radius: 10
4336
- }
4337
- }
4338
- };
4339
- class ContainerStepExtension {
4340
- static create(configuration) {
4341
- return new ContainerStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$4);
4342
- }
4343
- constructor(configuration) {
4344
- this.configuration = configuration;
4345
- this.componentType = 'container';
4346
- this.createComponentView = createContainerStepComponentViewFactory(this.configuration.view);
4347
- }
4348
- }
4349
-
4350
4633
  class DefaultPlaceholderControllerExtension {
4351
4634
  create() {
4352
4635
  return {
@@ -4355,7 +4638,7 @@
4355
4638
  }
4356
4639
  }
4357
4640
 
4358
- const defaultConfiguration$3 = {
4641
+ const defaultConfiguration = {
4359
4642
  gapWidth: 88,
4360
4643
  gapHeight: 24,
4361
4644
  radius: 6,
@@ -4363,7 +4646,7 @@
4363
4646
  };
4364
4647
  class RectPlaceholderExtension {
4365
4648
  static create(configuration) {
4366
- return new RectPlaceholderExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$3);
4649
+ return new RectPlaceholderExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration);
4367
4650
  }
4368
4651
  constructor(configuration) {
4369
4652
  this.configuration = configuration;
@@ -4377,63 +4660,6 @@
4377
4660
  }
4378
4661
  }
4379
4662
 
4380
- const defaultConfiguration$2 = {
4381
- view: {
4382
- minContainerWidth: 40,
4383
- paddingX: 20,
4384
- paddingTop: 20,
4385
- connectionHeight: 16,
4386
- inputSize: 18,
4387
- inputIconSize: 14,
4388
- branchNameLabel: {
4389
- height: 22,
4390
- paddingX: 10,
4391
- minWidth: 50,
4392
- radius: 10
4393
- },
4394
- nameLabel: {
4395
- height: 22,
4396
- paddingX: 10,
4397
- minWidth: 50,
4398
- radius: 10
4399
- }
4400
- }
4401
- };
4402
- class SwitchStepExtension {
4403
- static create(configuration) {
4404
- return new SwitchStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$2);
4405
- }
4406
- constructor(configuration) {
4407
- this.configuration = configuration;
4408
- this.componentType = 'switch';
4409
- this.createComponentView = createSwitchStepComponentViewFactory(this.configuration.view);
4410
- }
4411
- }
4412
-
4413
- const defaultConfiguration$1 = {
4414
- view: {
4415
- paddingLeft: 12,
4416
- paddingRight: 12,
4417
- paddingY: 10,
4418
- textMarginLeft: 12,
4419
- minTextWidth: 70,
4420
- iconSize: 22,
4421
- radius: 5,
4422
- inputSize: 14,
4423
- outputSize: 10
4424
- }
4425
- };
4426
- class TaskStepExtension {
4427
- static create(configuration) {
4428
- return new TaskStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$1);
4429
- }
4430
- constructor(configuration) {
4431
- this.configuration = configuration;
4432
- this.componentType = 'task';
4433
- this.createComponentView = createTaskStepComponentViewFactory(false, this.configuration.view);
4434
- }
4435
- }
4436
-
4437
4663
  class DefaultSequenceComponentExtension {
4438
4664
  constructor() {
4439
4665
  this.create = DefaultSequenceComponent.create;
@@ -4446,39 +4672,15 @@
4446
4672
  }
4447
4673
  }
4448
4674
 
4449
- class LineGrid {
4450
- static create(size) {
4451
- const path = Dom.svg('path', {
4452
- class: 'sqd-line-grid-path',
4453
- fill: 'none'
4454
- });
4455
- return new LineGrid(size, path);
4456
- }
4457
- constructor(size, element) {
4458
- this.size = size;
4459
- this.element = element;
4460
- }
4461
- setScale(_, scaledSize) {
4462
- Dom.attrs(this.element, {
4463
- d: `M ${scaledSize.x} 0 L 0 0 0 ${scaledSize.y}`
4464
- });
4675
+ class DefaultClickBehaviorWrapper {
4676
+ constructor() {
4677
+ this.wrap = (behavior) => behavior;
4465
4678
  }
4466
4679
  }
4467
4680
 
4468
- const defaultConfiguration = {
4469
- gridSizeX: 48,
4470
- gridSizeY: 48
4471
- };
4472
- class LineGridExtension {
4473
- static create(configuration) {
4474
- return new LineGridExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration);
4475
- }
4476
- constructor(configuration) {
4477
- this.configuration = configuration;
4478
- }
4681
+ class DefaultClickBehaviorWrapperExtension {
4479
4682
  create() {
4480
- const size = new Vector(this.configuration.gridSizeX, this.configuration.gridSizeY);
4481
- return LineGrid.create(size);
4683
+ return new DefaultClickBehaviorWrapper();
4482
4684
  }
4483
4685
  }
4484
4686
 
@@ -4498,6 +4700,9 @@
4498
4700
  if (ext.stepComponentViewWrapper) {
4499
4701
  services.stepComponentViewWrapper = ext.stepComponentViewWrapper;
4500
4702
  }
4703
+ if (ext.clickBehaviorWrapperExtension) {
4704
+ services.clickBehaviorWrapperExtension = ext.clickBehaviorWrapperExtension;
4705
+ }
4501
4706
  if (ext.badges) {
4502
4707
  services.badges = (services.badges || []).concat(ext.badges);
4503
4708
  }
@@ -4549,6 +4754,9 @@
4549
4754
  if (!services.stepComponentViewWrapper) {
4550
4755
  services.stepComponentViewWrapper = new DefaultStepComponentViewWrapperExtension();
4551
4756
  }
4757
+ if (!services.clickBehaviorWrapperExtension) {
4758
+ services.clickBehaviorWrapperExtension = new DefaultClickBehaviorWrapperExtension();
4759
+ }
4552
4760
  if (!services.badges) {
4553
4761
  services.badges = [];
4554
4762
  }
@@ -4583,7 +4791,7 @@
4583
4791
  services.regionComponentView = new DefaultRegionComponentViewExtension();
4584
4792
  }
4585
4793
  if (!services.viewportController) {
4586
- services.viewportController = new DefaultViewportControllerExtension();
4794
+ services.viewportController = DefaultViewportControllerExtension.create();
4587
4795
  }
4588
4796
  if (!services.grid) {
4589
4797
  services.grid = LineGridExtension.create();
@@ -4845,35 +5053,6 @@
4845
5053
  }
4846
5054
  }
4847
5055
 
4848
- class LineGridDesignerExtension {
4849
- static create(configuration) {
4850
- const grid = LineGridExtension.create(configuration);
4851
- return new LineGridDesignerExtension(grid);
4852
- }
4853
- constructor(grid) {
4854
- this.grid = grid;
4855
- }
4856
- }
4857
-
4858
- class StepsDesignerExtension {
4859
- static create(configuration) {
4860
- const steps = [];
4861
- if (configuration.container) {
4862
- steps.push(ContainerStepExtension.create(configuration.container));
4863
- }
4864
- if (configuration.switch) {
4865
- steps.push(SwitchStepExtension.create(configuration.switch));
4866
- }
4867
- if (configuration.task) {
4868
- steps.push(TaskStepExtension.create(configuration.task));
4869
- }
4870
- return new StepsDesignerExtension(steps);
4871
- }
4872
- constructor(steps) {
4873
- this.steps = steps;
4874
- }
4875
- }
4876
-
4877
5056
  exports.Badges = Badges;
4878
5057
  exports.CenteredViewportCalculator = CenteredViewportCalculator;
4879
5058
  exports.ClassicWheelControllerExtension = ClassicWheelControllerExtension;
@@ -4886,6 +5065,7 @@
4886
5065
  exports.DefaultSequenceComponent = DefaultSequenceComponent;
4887
5066
  exports.DefaultSequenceComponentView = DefaultSequenceComponentView;
4888
5067
  exports.DefaultViewportController = DefaultViewportController;
5068
+ exports.DefaultViewportControllerDesignerExtension = DefaultViewportControllerDesignerExtension;
4889
5069
  exports.DefaultViewportControllerExtension = DefaultViewportControllerExtension;
4890
5070
  exports.DefinitionWalker = DefinitionWalker;
4891
5071
  exports.Designer = Designer;
@@ -4903,19 +5083,22 @@
4903
5083
  exports.ObjectCloner = ObjectCloner;
4904
5084
  exports.OutputView = OutputView;
4905
5085
  exports.PathBarApi = PathBarApi;
4906
- exports.QuantifiedScaleViewportCalculator = QuantifiedScaleViewportCalculator;
4907
5086
  exports.RectPlaceholder = RectPlaceholder;
4908
5087
  exports.RectPlaceholderView = RectPlaceholderView;
5088
+ exports.SelectStepBehaviorEndToken = SelectStepBehaviorEndToken;
4909
5089
  exports.ServicesResolver = ServicesResolver;
4910
5090
  exports.SimpleEvent = SimpleEvent;
5091
+ exports.StartStopRootComponentDesignerExtension = StartStopRootComponentDesignerExtension;
4911
5092
  exports.StartStopRootComponentExtension = StartStopRootComponentExtension;
4912
5093
  exports.StepComponent = StepComponent;
4913
5094
  exports.StepExtensionResolver = StepExtensionResolver;
4914
5095
  exports.StepsDesignerExtension = StepsDesignerExtension;
5096
+ exports.TYPE = TYPE;
4915
5097
  exports.ToolboxApi = ToolboxApi;
4916
5098
  exports.Uid = Uid;
4917
5099
  exports.ValidationErrorBadgeExtension = ValidationErrorBadgeExtension;
4918
5100
  exports.Vector = Vector;
5101
+ exports.ViewportApi = ViewportApi;
4919
5102
  exports.WorkspaceApi = WorkspaceApi;
4920
5103
  exports.createContainerStepComponentViewFactory = createContainerStepComponentViewFactory;
4921
5104
  exports.createSwitchStepComponentViewFactory = createSwitchStepComponentViewFactory;