sequential-workflow-designer 0.25.0 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/index.umd.js +682 -633
- package/lib/cjs/index.cjs +682 -633
- package/lib/esm/index.js +679 -634
- package/lib/index.d.ts +83 -55
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -202,27 +202,17 @@
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
class ControlBarApi {
|
|
205
|
-
static create(state, historyController, stateModifier
|
|
206
|
-
const api = new ControlBarApi(state, historyController, stateModifier
|
|
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
|
|
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
|
}
|
|
@@ -693,21 +683,20 @@
|
|
|
693
683
|
}
|
|
694
684
|
|
|
695
685
|
class ViewportAnimator {
|
|
696
|
-
constructor(
|
|
697
|
-
this.
|
|
686
|
+
constructor(state) {
|
|
687
|
+
this.state = state;
|
|
698
688
|
}
|
|
699
689
|
execute(target) {
|
|
700
690
|
if (this.animation && this.animation.isAlive) {
|
|
701
691
|
this.animation.stop();
|
|
702
692
|
}
|
|
703
|
-
const
|
|
704
|
-
const
|
|
705
|
-
const startScale = viewport.scale;
|
|
693
|
+
const startPosition = this.state.viewport.position;
|
|
694
|
+
const startScale = this.state.viewport.scale;
|
|
706
695
|
const deltaPosition = startPosition.subtract(target.position);
|
|
707
696
|
const deltaScale = startScale - target.scale;
|
|
708
697
|
this.animation = animate(150, progress => {
|
|
709
698
|
const newScale = startScale - deltaScale * progress;
|
|
710
|
-
this.
|
|
699
|
+
this.state.setViewport({
|
|
711
700
|
position: startPosition.subtract(deltaPosition.multiplyByScalar(progress)),
|
|
712
701
|
scale: newScale
|
|
713
702
|
});
|
|
@@ -740,23 +729,23 @@
|
|
|
740
729
|
}
|
|
741
730
|
|
|
742
731
|
class ViewportApi {
|
|
743
|
-
constructor(workspaceController, viewportController
|
|
732
|
+
constructor(state, workspaceController, viewportController) {
|
|
733
|
+
this.state = state;
|
|
744
734
|
this.workspaceController = workspaceController;
|
|
745
735
|
this.viewportController = viewportController;
|
|
746
|
-
this.
|
|
747
|
-
this.animator = new ViewportAnimator(this.api);
|
|
736
|
+
this.animator = new ViewportAnimator(this.state);
|
|
748
737
|
}
|
|
749
738
|
limitScale(scale) {
|
|
750
739
|
return this.viewportController.limitScale(scale);
|
|
751
740
|
}
|
|
752
741
|
resetViewport() {
|
|
753
742
|
const defaultViewport = this.viewportController.getDefault();
|
|
754
|
-
this.
|
|
743
|
+
this.state.setViewport(defaultViewport);
|
|
755
744
|
}
|
|
756
745
|
zoom(direction) {
|
|
757
746
|
const viewport = this.viewportController.getZoomed(direction);
|
|
758
747
|
if (viewport) {
|
|
759
|
-
this.
|
|
748
|
+
this.state.setViewport(viewport);
|
|
760
749
|
}
|
|
761
750
|
}
|
|
762
751
|
moveViewportToStep(stepId) {
|
|
@@ -769,11 +758,10 @@
|
|
|
769
758
|
this.animator.execute(viewport);
|
|
770
759
|
}
|
|
771
760
|
handleWheelEvent(e) {
|
|
772
|
-
const
|
|
773
|
-
const
|
|
774
|
-
const newViewport = ZoomByWheelCalculator.calculate(this.viewportController, viewport, canvasPosition, e);
|
|
761
|
+
const canvasPosition = this.workspaceController.getCanvasPosition();
|
|
762
|
+
const newViewport = ZoomByWheelCalculator.calculate(this.viewportController, this.state.viewport, canvasPosition, e);
|
|
775
763
|
if (newViewport) {
|
|
776
|
-
this.
|
|
764
|
+
this.state.setViewport(newViewport);
|
|
777
765
|
}
|
|
778
766
|
}
|
|
779
767
|
}
|
|
@@ -783,6 +771,12 @@
|
|
|
783
771
|
this.state = state;
|
|
784
772
|
this.workspaceController = workspaceController;
|
|
785
773
|
}
|
|
774
|
+
getViewport() {
|
|
775
|
+
return this.state.viewport;
|
|
776
|
+
}
|
|
777
|
+
setViewport(viewport) {
|
|
778
|
+
this.state.setViewport(viewport);
|
|
779
|
+
}
|
|
786
780
|
getCanvasPosition() {
|
|
787
781
|
return this.workspaceController.getCanvasPosition();
|
|
788
782
|
}
|
|
@@ -792,12 +786,6 @@
|
|
|
792
786
|
getRootComponentSize() {
|
|
793
787
|
return this.workspaceController.getRootComponentSize();
|
|
794
788
|
}
|
|
795
|
-
getViewport() {
|
|
796
|
-
return this.state.viewport;
|
|
797
|
-
}
|
|
798
|
-
setViewport(viewport) {
|
|
799
|
-
this.state.setViewport(viewport);
|
|
800
|
-
}
|
|
801
789
|
updateRootComponent() {
|
|
802
790
|
this.workspaceController.updateRootComponent();
|
|
803
791
|
}
|
|
@@ -813,9 +801,8 @@
|
|
|
813
801
|
static create(context) {
|
|
814
802
|
const workspace = new WorkspaceApi(context.state, context.workspaceController);
|
|
815
803
|
const viewportController = context.services.viewportController.create(workspace);
|
|
816
|
-
const viewport = new ViewportApi(context.workspaceController, viewportController, workspace);
|
|
817
804
|
const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
|
|
818
|
-
return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.stateModifier
|
|
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);
|
|
819
806
|
}
|
|
820
807
|
constructor(shadowRoot, controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
|
|
821
808
|
this.shadowRoot = shadowRoot;
|
|
@@ -830,36 +817,15 @@
|
|
|
830
817
|
}
|
|
831
818
|
}
|
|
832
819
|
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
}
|
|
838
|
-
validateStep(step, parentSequence) {
|
|
839
|
-
var _a;
|
|
840
|
-
if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.step) {
|
|
841
|
-
return this.configuration.step(step, parentSequence, this.state.definition);
|
|
842
|
-
}
|
|
843
|
-
return true;
|
|
844
|
-
}
|
|
845
|
-
validateRoot() {
|
|
846
|
-
var _a;
|
|
847
|
-
if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.root) {
|
|
848
|
-
return this.configuration.root(this.state.definition);
|
|
849
|
-
}
|
|
850
|
-
return true;
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
class IconProvider {
|
|
855
|
-
constructor(configuration) {
|
|
856
|
-
this.configuration = configuration;
|
|
820
|
+
const TYPE = 'selectStep';
|
|
821
|
+
class SelectStepBehaviorEndToken {
|
|
822
|
+
static is(token) {
|
|
823
|
+
return Boolean(token) && token.type === TYPE;
|
|
857
824
|
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
return null;
|
|
825
|
+
constructor(stepId, time) {
|
|
826
|
+
this.stepId = stepId;
|
|
827
|
+
this.time = time;
|
|
828
|
+
this.type = TYPE;
|
|
863
829
|
}
|
|
864
830
|
}
|
|
865
831
|
|
|
@@ -924,349 +890,104 @@
|
|
|
924
890
|
return g;
|
|
925
891
|
}
|
|
926
892
|
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
const badges = Badges.createForStep(stepContext, view, componentContext);
|
|
944
|
-
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);
|
|
945
909
|
}
|
|
946
|
-
constructor(
|
|
947
|
-
this.
|
|
948
|
-
this.
|
|
949
|
-
this.
|
|
950
|
-
this.
|
|
951
|
-
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;
|
|
952
915
|
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
return this;
|
|
956
|
-
}
|
|
957
|
-
if (this.view.sequenceComponents) {
|
|
958
|
-
for (const component of this.view.sequenceComponents) {
|
|
959
|
-
const result = component.findById(stepId);
|
|
960
|
-
if (result) {
|
|
961
|
-
return result;
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
return null;
|
|
916
|
+
destroy() {
|
|
917
|
+
this.parent.removeChild(this.g);
|
|
966
918
|
}
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
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;
|
|
974
926
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
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;
|
|
986
937
|
}
|
|
987
|
-
: viewResult;
|
|
988
|
-
}
|
|
989
|
-
return null;
|
|
990
|
-
}
|
|
991
|
-
resolvePlaceholders(skipComponent, result) {
|
|
992
|
-
if (skipComponent !== this) {
|
|
993
|
-
if (this.view.sequenceComponents) {
|
|
994
|
-
this.view.sequenceComponents.forEach(component => component.resolvePlaceholders(skipComponent, result));
|
|
995
938
|
}
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
}
|
|
999
|
-
result.components.push(this);
|
|
1000
|
-
}
|
|
939
|
+
return true;
|
|
940
|
+
};
|
|
1001
941
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
942
|
+
static createForRoot(componentContext) {
|
|
943
|
+
return () => {
|
|
944
|
+
return componentContext.validator.validateRoot();
|
|
945
|
+
};
|
|
1004
946
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
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);
|
|
1007
953
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
954
|
+
static createForRoot(parentElement, componentContext, configuration) {
|
|
955
|
+
const validator = ValidatorFactory.createForRoot(componentContext);
|
|
956
|
+
return new ValidationErrorBadge(parentElement, validator, configuration);
|
|
1010
957
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
958
|
+
constructor(parentElement, validator, configuration) {
|
|
959
|
+
this.parentElement = parentElement;
|
|
960
|
+
this.validator = validator;
|
|
961
|
+
this.configuration = configuration;
|
|
962
|
+
this.view = null;
|
|
963
|
+
}
|
|
964
|
+
update(result) {
|
|
965
|
+
const isValid = this.validator();
|
|
966
|
+
if (isValid) {
|
|
967
|
+
if (this.view) {
|
|
968
|
+
this.view.destroy();
|
|
969
|
+
this.view = null;
|
|
970
|
+
}
|
|
1014
971
|
}
|
|
1015
|
-
this.
|
|
972
|
+
else if (!this.view) {
|
|
973
|
+
this.view = ValidationErrorBadgeView.create(this.parentElement, this.configuration);
|
|
974
|
+
}
|
|
975
|
+
return isValid && result;
|
|
1016
976
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
class StepComponentViewContextFactory {
|
|
1020
|
-
static create(stepContext, componentContext) {
|
|
1021
|
-
const preferenceKeyPrefix = stepContext.step.id + ':';
|
|
1022
|
-
return {
|
|
1023
|
-
i18n: componentContext.i18n,
|
|
1024
|
-
getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
|
|
1025
|
-
getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
|
|
1026
|
-
createSequenceComponent: (parentElement, sequence) => {
|
|
1027
|
-
const sequenceContext = {
|
|
1028
|
-
sequence,
|
|
1029
|
-
depth: stepContext.depth + 1,
|
|
1030
|
-
isInputConnected: true,
|
|
1031
|
-
isOutputConnected: stepContext.isOutputConnected,
|
|
1032
|
-
isPreview: stepContext.isPreview
|
|
1033
|
-
};
|
|
1034
|
-
return componentContext.services.sequenceComponent.create(parentElement, sequenceContext, componentContext);
|
|
1035
|
-
},
|
|
1036
|
-
createRegionComponentView(parentElement, componentClassName, contentFactory) {
|
|
1037
|
-
return componentContext.services.regionComponentView.create(parentElement, componentClassName, stepContext, this, contentFactory);
|
|
1038
|
-
},
|
|
1039
|
-
createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
|
|
1040
|
-
getPreference: (key) => componentContext.preferenceStorage.getItem(preferenceKeyPrefix + key),
|
|
1041
|
-
setPreference: (key, value) => componentContext.preferenceStorage.setItem(preferenceKeyPrefix + key, value)
|
|
1042
|
-
};
|
|
977
|
+
resolveClick() {
|
|
978
|
+
return null;
|
|
1043
979
|
}
|
|
1044
980
|
}
|
|
1045
981
|
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
982
|
+
const defaultConfiguration$7 = {
|
|
983
|
+
view: {
|
|
984
|
+
size: 22,
|
|
985
|
+
iconSize: 12
|
|
1049
986
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
const wrappedView = componentContext.services.stepComponentViewWrapper.wrap(view, stepContext);
|
|
1055
|
-
return StepComponent.create(wrappedView, stepContext, componentContext);
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
class ComponentContext {
|
|
1060
|
-
static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
|
|
1061
|
-
const validator = new DefinitionValidator(configuration.validator, state);
|
|
1062
|
-
const iconProvider = new IconProvider(configuration.steps);
|
|
1063
|
-
const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
|
|
1064
|
-
return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
|
|
1065
|
-
}
|
|
1066
|
-
constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
|
|
1067
|
-
this.shadowRoot = shadowRoot;
|
|
1068
|
-
this.validator = validator;
|
|
1069
|
-
this.iconProvider = iconProvider;
|
|
1070
|
-
this.placeholderController = placeholderController;
|
|
1071
|
-
this.stepComponentFactory = stepComponentFactory;
|
|
1072
|
-
this.definitionWalker = definitionWalker;
|
|
1073
|
-
this.services = services;
|
|
1074
|
-
this.preferenceStorage = preferenceStorage;
|
|
1075
|
-
this.i18n = i18n;
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
class CustomActionController {
|
|
1080
|
-
constructor(configuration, state, stateModifier) {
|
|
1081
|
-
this.configuration = configuration;
|
|
1082
|
-
this.state = state;
|
|
1083
|
-
this.stateModifier = stateModifier;
|
|
1084
|
-
}
|
|
1085
|
-
trigger(action, step, sequence) {
|
|
1086
|
-
const handler = this.configuration.customActionHandler;
|
|
1087
|
-
if (!handler) {
|
|
1088
|
-
console.warn(`Custom action handler is not defined (action type: ${action.type})`);
|
|
1089
|
-
return;
|
|
1090
|
-
}
|
|
1091
|
-
const context = this.createCustomActionHandlerContext();
|
|
1092
|
-
handler(action, step, sequence, context);
|
|
1093
|
-
}
|
|
1094
|
-
createCustomActionHandlerContext() {
|
|
1095
|
-
return {
|
|
1096
|
-
notifyStepNameChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepNameChanged, stepId, false),
|
|
1097
|
-
notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepPropertyChanged, stepId, false),
|
|
1098
|
-
notifyStepInserted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepInserted, stepId, true),
|
|
1099
|
-
notifyStepMoved: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepMoved, stepId, true),
|
|
1100
|
-
notifyStepDeleted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepDeleted, stepId, true)
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
notifyStepChanged(changeType, stepId, updateDependencies) {
|
|
1104
|
-
if (!stepId) {
|
|
1105
|
-
throw new Error('Step id is empty');
|
|
1106
|
-
}
|
|
1107
|
-
this.state.notifyDefinitionChanged(changeType, stepId);
|
|
1108
|
-
if (updateDependencies) {
|
|
1109
|
-
this.stateModifier.updateDependencies();
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
class EditorView {
|
|
1115
|
-
static create(parent) {
|
|
1116
|
-
return new EditorView(parent);
|
|
1117
|
-
}
|
|
1118
|
-
constructor(parent) {
|
|
1119
|
-
this.parent = parent;
|
|
1120
|
-
this.currentContainer = null;
|
|
1121
|
-
}
|
|
1122
|
-
setContent(content, className) {
|
|
1123
|
-
const container = Dom.element('div', {
|
|
1124
|
-
class: className
|
|
1125
|
-
});
|
|
1126
|
-
container.appendChild(content);
|
|
1127
|
-
if (this.currentContainer) {
|
|
1128
|
-
this.parent.removeChild(this.currentContainer);
|
|
1129
|
-
}
|
|
1130
|
-
this.parent.appendChild(container);
|
|
1131
|
-
this.currentContainer = container;
|
|
1132
|
-
}
|
|
1133
|
-
destroy() {
|
|
1134
|
-
if (this.currentContainer) {
|
|
1135
|
-
this.parent.removeChild(this.currentContainer);
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
class Editor {
|
|
1141
|
-
static create(parent, api, stepEditorClassName, stepEditorProvider, rootEditorClassName, rootEditorProvider, customSelectedStepIdProvider) {
|
|
1142
|
-
const view = EditorView.create(parent);
|
|
1143
|
-
function render(step) {
|
|
1144
|
-
const definition = api.getDefinition();
|
|
1145
|
-
let content;
|
|
1146
|
-
let className;
|
|
1147
|
-
if (step) {
|
|
1148
|
-
const stepContext = api.createStepEditorContext(step.id);
|
|
1149
|
-
content = stepEditorProvider(step, stepContext, definition, api.isReadonly());
|
|
1150
|
-
className = stepEditorClassName;
|
|
1151
|
-
}
|
|
1152
|
-
else {
|
|
1153
|
-
const rootContext = api.createRootEditorContext();
|
|
1154
|
-
content = rootEditorProvider(definition, rootContext, api.isReadonly());
|
|
1155
|
-
className = rootEditorClassName;
|
|
1156
|
-
}
|
|
1157
|
-
view.setContent(content, className);
|
|
1158
|
-
}
|
|
1159
|
-
const renderer = api.runRenderer(step => render(step), customSelectedStepIdProvider);
|
|
1160
|
-
return new Editor(view, renderer);
|
|
1161
|
-
}
|
|
1162
|
-
constructor(view, renderer) {
|
|
1163
|
-
this.view = view;
|
|
1164
|
-
this.renderer = renderer;
|
|
1165
|
-
}
|
|
1166
|
-
destroy() {
|
|
1167
|
-
this.view.destroy();
|
|
1168
|
-
this.renderer.destroy();
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
class ValidationErrorBadgeView {
|
|
1173
|
-
static create(parent, cfg) {
|
|
1174
|
-
const g = Dom.svg('g');
|
|
1175
|
-
const halfOfSize = cfg.size / 2;
|
|
1176
|
-
const circle = Dom.svg('path', {
|
|
1177
|
-
class: 'sqd-validation-error',
|
|
1178
|
-
d: `M 0 ${-halfOfSize} l ${halfOfSize} ${cfg.size} l ${-cfg.size} 0 Z`
|
|
1179
|
-
});
|
|
1180
|
-
Dom.translate(circle, halfOfSize, halfOfSize);
|
|
1181
|
-
g.appendChild(circle);
|
|
1182
|
-
const icon = Icons.appendPath(g, 'sqd-validation-error-icon-path', Icons.alert, cfg.iconSize);
|
|
1183
|
-
const offsetX = (cfg.size - cfg.iconSize) / 2;
|
|
1184
|
-
const offsetY = offsetX * 1.5;
|
|
1185
|
-
Dom.translate(icon, offsetX, offsetY);
|
|
1186
|
-
parent.appendChild(g);
|
|
1187
|
-
return new ValidationErrorBadgeView(parent, g, cfg.size, cfg.size);
|
|
1188
|
-
}
|
|
1189
|
-
constructor(parent, g, width, height) {
|
|
1190
|
-
this.parent = parent;
|
|
1191
|
-
this.g = g;
|
|
1192
|
-
this.width = width;
|
|
1193
|
-
this.height = height;
|
|
1194
|
-
}
|
|
1195
|
-
destroy() {
|
|
1196
|
-
this.parent.removeChild(this.g);
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
class ValidatorFactory {
|
|
1201
|
-
static createForStep(stepContext, view, componentContext) {
|
|
1202
|
-
return () => {
|
|
1203
|
-
if (!componentContext.validator.validateStep(stepContext.step, stepContext.parentSequence)) {
|
|
1204
|
-
return false;
|
|
1205
|
-
}
|
|
1206
|
-
if (view.haveCollapsedChildren) {
|
|
1207
|
-
let allChildrenValid = true;
|
|
1208
|
-
componentContext.definitionWalker.forEachChildren(stepContext.step, (step, _, parentSequence) => {
|
|
1209
|
-
if (!componentContext.validator.validateStep(step, parentSequence)) {
|
|
1210
|
-
allChildrenValid = false;
|
|
1211
|
-
return false;
|
|
1212
|
-
}
|
|
1213
|
-
});
|
|
1214
|
-
if (!allChildrenValid) {
|
|
1215
|
-
return false;
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
return true;
|
|
1219
|
-
};
|
|
1220
|
-
}
|
|
1221
|
-
static createForRoot(componentContext) {
|
|
1222
|
-
return () => {
|
|
1223
|
-
return componentContext.validator.validateRoot();
|
|
1224
|
-
};
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
class ValidationErrorBadge {
|
|
1229
|
-
static createForStep(parentElement, view, stepContext, componentContext, configuration) {
|
|
1230
|
-
const validator = ValidatorFactory.createForStep(stepContext, view, componentContext);
|
|
1231
|
-
return new ValidationErrorBadge(parentElement, validator, configuration);
|
|
1232
|
-
}
|
|
1233
|
-
static createForRoot(parentElement, componentContext, configuration) {
|
|
1234
|
-
const validator = ValidatorFactory.createForRoot(componentContext);
|
|
1235
|
-
return new ValidationErrorBadge(parentElement, validator, configuration);
|
|
1236
|
-
}
|
|
1237
|
-
constructor(parentElement, validator, configuration) {
|
|
1238
|
-
this.parentElement = parentElement;
|
|
1239
|
-
this.validator = validator;
|
|
1240
|
-
this.configuration = configuration;
|
|
1241
|
-
this.view = null;
|
|
1242
|
-
}
|
|
1243
|
-
update(result) {
|
|
1244
|
-
const isValid = this.validator();
|
|
1245
|
-
if (isValid) {
|
|
1246
|
-
if (this.view) {
|
|
1247
|
-
this.view.destroy();
|
|
1248
|
-
this.view = null;
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
else if (!this.view) {
|
|
1252
|
-
this.view = ValidationErrorBadgeView.create(this.parentElement, this.configuration);
|
|
1253
|
-
}
|
|
1254
|
-
return isValid && result;
|
|
1255
|
-
}
|
|
1256
|
-
resolveClick() {
|
|
1257
|
-
return null;
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
const defaultConfiguration$7 = {
|
|
1262
|
-
view: {
|
|
1263
|
-
size: 22,
|
|
1264
|
-
iconSize: 12
|
|
1265
|
-
}
|
|
1266
|
-
};
|
|
1267
|
-
class ValidationErrorBadgeExtension {
|
|
1268
|
-
static create(configuration) {
|
|
1269
|
-
return new ValidationErrorBadgeExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$7);
|
|
987
|
+
};
|
|
988
|
+
class ValidationErrorBadgeExtension {
|
|
989
|
+
static create(configuration) {
|
|
990
|
+
return new ValidationErrorBadgeExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$7);
|
|
1270
991
|
}
|
|
1271
992
|
constructor(configuration) {
|
|
1272
993
|
this.configuration = configuration;
|
|
@@ -1336,54 +1057,58 @@
|
|
|
1336
1057
|
}
|
|
1337
1058
|
}
|
|
1338
1059
|
|
|
1060
|
+
const EPS = 0.5; // Epsilon, a tiny offset to avoid rendering issues
|
|
1339
1061
|
class JoinView {
|
|
1340
1062
|
static createStraightJoin(parent, start, height) {
|
|
1063
|
+
const dy = Math.sign(height);
|
|
1341
1064
|
const join = Dom.svg('line', {
|
|
1342
1065
|
class: 'sqd-join',
|
|
1343
1066
|
x1: start.x,
|
|
1344
|
-
y1: start.y,
|
|
1067
|
+
y1: start.y - EPS * dy,
|
|
1345
1068
|
x2: start.x,
|
|
1346
|
-
y2: start.y + height
|
|
1069
|
+
y2: start.y + height + EPS * dy
|
|
1347
1070
|
});
|
|
1348
1071
|
parent.insertBefore(join, parent.firstChild);
|
|
1349
1072
|
}
|
|
1350
1073
|
static createJoins(parent, start, targets) {
|
|
1351
1074
|
const firstTarget = targets[0];
|
|
1352
1075
|
const h = Math.abs(firstTarget.y - start.y) / 2; // half height
|
|
1353
|
-
const
|
|
1076
|
+
const dy = Math.sign(firstTarget.y - start.y); // direction y
|
|
1354
1077
|
switch (targets.length) {
|
|
1355
1078
|
case 1:
|
|
1356
1079
|
if (start.x === targets[0].x) {
|
|
1357
|
-
JoinView.createStraightJoin(parent, start, firstTarget.y *
|
|
1080
|
+
JoinView.createStraightJoin(parent, start, firstTarget.y * dy);
|
|
1358
1081
|
}
|
|
1359
1082
|
else {
|
|
1360
|
-
appendCurvedJoins(parent, start, targets, h,
|
|
1083
|
+
appendCurvedJoins(parent, start, targets, h, dy);
|
|
1361
1084
|
}
|
|
1362
1085
|
break;
|
|
1363
1086
|
case 2:
|
|
1364
|
-
appendCurvedJoins(parent, start, targets, h,
|
|
1087
|
+
appendCurvedJoins(parent, start, targets, h, dy);
|
|
1365
1088
|
break;
|
|
1366
1089
|
default:
|
|
1367
1090
|
{
|
|
1368
1091
|
const f = targets[0]; // first
|
|
1369
1092
|
const l = targets[targets.length - 1]; // last
|
|
1370
|
-
|
|
1371
|
-
|
|
1093
|
+
const eps = EPS * dy;
|
|
1094
|
+
appendJoin(parent, `M ${f.x} ${f.y + eps} l 0 ${-eps} q ${h * 0.3} ${h * -dy * 0.8} ${h} ${h * -dy} ` +
|
|
1095
|
+
`l ${l.x - f.x - h * 2} 0 q ${h * 0.8} ${-h * -dy * 0.3} ${h} ${-h * -dy} l 0 ${eps}`);
|
|
1372
1096
|
for (let i = 1; i < targets.length - 1; i++) {
|
|
1373
|
-
JoinView.createStraightJoin(parent, targets[i], h * -
|
|
1097
|
+
JoinView.createStraightJoin(parent, targets[i], h * -dy);
|
|
1374
1098
|
}
|
|
1375
|
-
JoinView.createStraightJoin(parent, start, h *
|
|
1099
|
+
JoinView.createStraightJoin(parent, start, h * dy);
|
|
1376
1100
|
}
|
|
1377
1101
|
break;
|
|
1378
1102
|
}
|
|
1379
1103
|
}
|
|
1380
1104
|
}
|
|
1381
|
-
function appendCurvedJoins(parent, start, targets, h,
|
|
1105
|
+
function appendCurvedJoins(parent, start, targets, h, dy) {
|
|
1106
|
+
const eps = EPS * dy;
|
|
1382
1107
|
for (const target of targets) {
|
|
1383
|
-
const l = Math.abs(target.x - start.x) - h * 2; // line
|
|
1384
|
-
const
|
|
1385
|
-
appendJoin(parent, `M ${start.x} ${start.y} q ${
|
|
1386
|
-
`l ${
|
|
1108
|
+
const l = Math.abs(target.x - start.x) - h * 2; // straight line length
|
|
1109
|
+
const dx = Math.sign(target.x - start.x); // direction x
|
|
1110
|
+
appendJoin(parent, `M ${start.x} ${start.y - eps} l 0 ${eps} q ${dx * h * 0.3} ${dy * h * 0.8} ${dx * h} ${dy * h} ` +
|
|
1111
|
+
`l ${dx * l} 0 q ${dx * h * 0.7} ${dy * h * 0.2} ${dx * h} ${dy * h} l 0 ${eps}`);
|
|
1387
1112
|
}
|
|
1388
1113
|
}
|
|
1389
1114
|
function appendJoin(parent, d) {
|
|
@@ -1566,6 +1291,20 @@
|
|
|
1566
1291
|
}
|
|
1567
1292
|
}
|
|
1568
1293
|
|
|
1294
|
+
exports.ClickCommandType = void 0;
|
|
1295
|
+
(function (ClickCommandType) {
|
|
1296
|
+
ClickCommandType[ClickCommandType["selectStep"] = 1] = "selectStep";
|
|
1297
|
+
ClickCommandType[ClickCommandType["rerenderStep"] = 2] = "rerenderStep";
|
|
1298
|
+
ClickCommandType[ClickCommandType["openFolder"] = 3] = "openFolder";
|
|
1299
|
+
ClickCommandType[ClickCommandType["triggerCustomAction"] = 4] = "triggerCustomAction";
|
|
1300
|
+
})(exports.ClickCommandType || (exports.ClickCommandType = {}));
|
|
1301
|
+
exports.PlaceholderDirection = void 0;
|
|
1302
|
+
(function (PlaceholderDirection) {
|
|
1303
|
+
PlaceholderDirection[PlaceholderDirection["none"] = 0] = "none";
|
|
1304
|
+
PlaceholderDirection[PlaceholderDirection["in"] = 1] = "in";
|
|
1305
|
+
PlaceholderDirection[PlaceholderDirection["out"] = 2] = "out";
|
|
1306
|
+
})(exports.PlaceholderDirection || (exports.PlaceholderDirection = {}));
|
|
1307
|
+
|
|
1569
1308
|
class StartStopRootComponentView {
|
|
1570
1309
|
static create(parent, sequence, parentPlaceIndicator, context, cfg) {
|
|
1571
1310
|
const g = Dom.svg('g', {
|
|
@@ -2044,28 +1783,106 @@
|
|
|
2044
1783
|
}
|
|
2045
1784
|
}
|
|
2046
1785
|
|
|
2047
|
-
class
|
|
2048
|
-
static create(
|
|
2049
|
-
const
|
|
2050
|
-
|
|
2051
|
-
const extension = services.steps[i];
|
|
2052
|
-
dict[extension.componentType] = extension;
|
|
2053
|
-
}
|
|
2054
|
-
return new StepExtensionResolver(dict);
|
|
1786
|
+
class StepComponent {
|
|
1787
|
+
static create(view, stepContext, componentContext) {
|
|
1788
|
+
const badges = Badges.createForStep(stepContext, view, componentContext);
|
|
1789
|
+
return new StepComponent(view, stepContext.step, stepContext.parentSequence, view.hasOutput, badges);
|
|
2055
1790
|
}
|
|
2056
|
-
constructor(
|
|
2057
|
-
this.
|
|
1791
|
+
constructor(view, step, parentSequence, hasOutput, badges) {
|
|
1792
|
+
this.view = view;
|
|
1793
|
+
this.step = step;
|
|
1794
|
+
this.parentSequence = parentSequence;
|
|
1795
|
+
this.hasOutput = hasOutput;
|
|
1796
|
+
this.badges = badges;
|
|
2058
1797
|
}
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
throw new Error(`Not supported component type: ${componentType}`);
|
|
1798
|
+
findById(stepId) {
|
|
1799
|
+
if (this.step.id === stepId) {
|
|
1800
|
+
return this;
|
|
2063
1801
|
}
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
1802
|
+
if (this.view.sequenceComponents) {
|
|
1803
|
+
for (const component of this.view.sequenceComponents) {
|
|
1804
|
+
const result = component.findById(stepId);
|
|
1805
|
+
if (result) {
|
|
1806
|
+
return result;
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
return null;
|
|
1811
|
+
}
|
|
1812
|
+
resolveClick(click) {
|
|
1813
|
+
if (this.view.sequenceComponents) {
|
|
1814
|
+
for (const component of this.view.sequenceComponents) {
|
|
1815
|
+
const result = component.resolveClick(click);
|
|
1816
|
+
if (result) {
|
|
1817
|
+
return result;
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
const badgeResult = this.badges.resolveClick(click);
|
|
1822
|
+
if (badgeResult) {
|
|
1823
|
+
return badgeResult;
|
|
1824
|
+
}
|
|
1825
|
+
const viewResult = this.view.resolveClick(click);
|
|
1826
|
+
if (viewResult) {
|
|
1827
|
+
return viewResult === true
|
|
1828
|
+
? {
|
|
1829
|
+
type: exports.ClickCommandType.selectStep,
|
|
1830
|
+
component: this
|
|
1831
|
+
}
|
|
1832
|
+
: viewResult;
|
|
1833
|
+
}
|
|
1834
|
+
return null;
|
|
1835
|
+
}
|
|
1836
|
+
resolvePlaceholders(skipComponent, result) {
|
|
1837
|
+
if (skipComponent !== this) {
|
|
1838
|
+
if (this.view.sequenceComponents) {
|
|
1839
|
+
this.view.sequenceComponents.forEach(component => component.resolvePlaceholders(skipComponent, result));
|
|
1840
|
+
}
|
|
1841
|
+
if (this.view.placeholders) {
|
|
1842
|
+
this.view.placeholders.forEach(ph => result.placeholders.push(ph));
|
|
1843
|
+
}
|
|
1844
|
+
result.components.push(this);
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
setIsDragging(isDragging) {
|
|
1848
|
+
this.view.setIsDragging(isDragging);
|
|
1849
|
+
}
|
|
1850
|
+
setIsSelected(isSelected) {
|
|
1851
|
+
this.view.setIsSelected(isSelected);
|
|
1852
|
+
}
|
|
1853
|
+
setIsDisabled(isDisabled) {
|
|
1854
|
+
this.view.setIsDisabled(isDisabled);
|
|
1855
|
+
}
|
|
1856
|
+
updateBadges(result) {
|
|
1857
|
+
if (this.view.sequenceComponents) {
|
|
1858
|
+
this.view.sequenceComponents.forEach(component => component.updateBadges(result));
|
|
1859
|
+
}
|
|
1860
|
+
this.badges.update(result);
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
class StepExtensionResolver {
|
|
1865
|
+
static create(services) {
|
|
1866
|
+
const dict = {};
|
|
1867
|
+
for (let i = services.steps.length - 1; i >= 0; i--) {
|
|
1868
|
+
const extension = services.steps[i];
|
|
1869
|
+
dict[extension.componentType] = extension;
|
|
1870
|
+
}
|
|
1871
|
+
return new StepExtensionResolver(dict);
|
|
1872
|
+
}
|
|
1873
|
+
constructor(dict) {
|
|
1874
|
+
this.dict = dict;
|
|
1875
|
+
}
|
|
1876
|
+
resolve(componentType) {
|
|
1877
|
+
const extension = this.dict[componentType];
|
|
1878
|
+
if (!extension) {
|
|
1879
|
+
throw new Error(`Not supported component type: ${componentType}`);
|
|
1880
|
+
}
|
|
1881
|
+
return extension;
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
class RectPlaceholderView {
|
|
2069
1886
|
static create(parent, width, height, radius, iconSize, direction) {
|
|
2070
1887
|
const g = Dom.svg('g', {
|
|
2071
1888
|
visibility: 'hidden',
|
|
@@ -2124,63 +1941,414 @@
|
|
|
2124
1941
|
resolveClick() {
|
|
2125
1942
|
return null;
|
|
2126
1943
|
}
|
|
2127
|
-
}
|
|
2128
|
-
|
|
2129
|
-
class DefaultRegionView {
|
|
2130
|
-
static create(parent, widths, height) {
|
|
2131
|
-
const totalWidth = widths.reduce((result, width) => result + width, 0);
|
|
2132
|
-
const lines = [
|
|
2133
|
-
drawLine(parent, 0, 0, totalWidth, 0),
|
|
2134
|
-
drawLine(parent, 0, 0, 0, height),
|
|
2135
|
-
drawLine(parent, 0, height, totalWidth, height),
|
|
2136
|
-
drawLine(parent, totalWidth, 0, totalWidth, height)
|
|
2137
|
-
];
|
|
2138
|
-
let offsetX = widths[0];
|
|
2139
|
-
for (let i = 1; i < widths.length; i++) {
|
|
2140
|
-
lines.push(drawLine(parent, offsetX, 0, offsetX, height));
|
|
2141
|
-
offsetX += widths[i];
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
class DefaultRegionView {
|
|
1947
|
+
static create(parent, widths, height) {
|
|
1948
|
+
const totalWidth = widths.reduce((result, width) => result + width, 0);
|
|
1949
|
+
const lines = [
|
|
1950
|
+
drawLine(parent, 0, 0, totalWidth, 0),
|
|
1951
|
+
drawLine(parent, 0, 0, 0, height),
|
|
1952
|
+
drawLine(parent, 0, height, totalWidth, height),
|
|
1953
|
+
drawLine(parent, totalWidth, 0, totalWidth, height)
|
|
1954
|
+
];
|
|
1955
|
+
let offsetX = widths[0];
|
|
1956
|
+
for (let i = 1; i < widths.length; i++) {
|
|
1957
|
+
lines.push(drawLine(parent, offsetX, 0, offsetX, height));
|
|
1958
|
+
offsetX += widths[i];
|
|
1959
|
+
}
|
|
1960
|
+
return new DefaultRegionView(lines, totalWidth, height);
|
|
1961
|
+
}
|
|
1962
|
+
constructor(lines, width, height) {
|
|
1963
|
+
this.lines = lines;
|
|
1964
|
+
this.width = width;
|
|
1965
|
+
this.height = height;
|
|
1966
|
+
}
|
|
1967
|
+
getClientPosition() {
|
|
1968
|
+
return getAbsolutePosition(this.lines[0]);
|
|
1969
|
+
}
|
|
1970
|
+
resolveClick(click) {
|
|
1971
|
+
const regionPosition = this.getClientPosition();
|
|
1972
|
+
const d = click.position.subtract(regionPosition);
|
|
1973
|
+
if (d.x >= 0 && d.y >= 0 && d.x < this.width * click.scale && d.y < this.height * click.scale) {
|
|
1974
|
+
return true;
|
|
1975
|
+
}
|
|
1976
|
+
return null;
|
|
1977
|
+
}
|
|
1978
|
+
setIsSelected(isSelected) {
|
|
1979
|
+
this.lines.forEach(region => {
|
|
1980
|
+
Dom.toggleClass(region, isSelected, 'sqd-selected');
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
function drawLine(parent, x1, y1, x2, y2) {
|
|
1985
|
+
const line = Dom.svg('line', {
|
|
1986
|
+
class: 'sqd-region',
|
|
1987
|
+
x1,
|
|
1988
|
+
y1,
|
|
1989
|
+
x2,
|
|
1990
|
+
y2
|
|
1991
|
+
});
|
|
1992
|
+
parent.insertBefore(line, parent.firstChild);
|
|
1993
|
+
return line;
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
class DefaultRegionComponentViewExtension {
|
|
1997
|
+
create(parentElement, componentClassName, stepContext, _, contentFactory) {
|
|
1998
|
+
const g = ComponentDom.stepG(componentClassName, stepContext.step.type, stepContext.step.id);
|
|
1999
|
+
parentElement.appendChild(g);
|
|
2000
|
+
return contentFactory(g, DefaultRegionView.create);
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
class DefaultViewportControllerDesignerExtension {
|
|
2005
|
+
static create(configuration) {
|
|
2006
|
+
return new DefaultViewportControllerDesignerExtension(DefaultViewportControllerExtension.create(configuration));
|
|
2007
|
+
}
|
|
2008
|
+
constructor(viewportController) {
|
|
2009
|
+
this.viewportController = viewportController;
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
class LineGrid {
|
|
2014
|
+
static create(size) {
|
|
2015
|
+
const path = Dom.svg('path', {
|
|
2016
|
+
class: 'sqd-line-grid-path',
|
|
2017
|
+
fill: 'none'
|
|
2018
|
+
});
|
|
2019
|
+
return new LineGrid(size, path);
|
|
2020
|
+
}
|
|
2021
|
+
constructor(size, element) {
|
|
2022
|
+
this.size = size;
|
|
2023
|
+
this.element = element;
|
|
2024
|
+
}
|
|
2025
|
+
setScale(_, scaledSize) {
|
|
2026
|
+
Dom.attrs(this.element, {
|
|
2027
|
+
d: `M ${scaledSize.x} 0 L 0 0 0 ${scaledSize.y}`
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
const defaultConfiguration$4 = {
|
|
2033
|
+
gridSizeX: 48,
|
|
2034
|
+
gridSizeY: 48
|
|
2035
|
+
};
|
|
2036
|
+
class LineGridExtension {
|
|
2037
|
+
static create(configuration) {
|
|
2038
|
+
return new LineGridExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$4);
|
|
2039
|
+
}
|
|
2040
|
+
constructor(configuration) {
|
|
2041
|
+
this.configuration = configuration;
|
|
2042
|
+
}
|
|
2043
|
+
create() {
|
|
2044
|
+
const size = new Vector(this.configuration.gridSizeX, this.configuration.gridSizeY);
|
|
2045
|
+
return LineGrid.create(size);
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
class LineGridDesignerExtension {
|
|
2050
|
+
static create(configuration) {
|
|
2051
|
+
const grid = LineGridExtension.create(configuration);
|
|
2052
|
+
return new LineGridDesignerExtension(grid);
|
|
2053
|
+
}
|
|
2054
|
+
constructor(grid) {
|
|
2055
|
+
this.grid = grid;
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
class StartStopRootComponentDesignerExtension {
|
|
2060
|
+
static create(configuration) {
|
|
2061
|
+
return new StartStopRootComponentDesignerExtension(StartStopRootComponentExtension.create(configuration));
|
|
2062
|
+
}
|
|
2063
|
+
constructor(rootComponent) {
|
|
2064
|
+
this.rootComponent = rootComponent;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
const defaultConfiguration$3 = {
|
|
2069
|
+
view: {
|
|
2070
|
+
paddingTop: 20,
|
|
2071
|
+
paddingX: 20,
|
|
2072
|
+
inputSize: 18,
|
|
2073
|
+
inputIconSize: 14,
|
|
2074
|
+
label: {
|
|
2075
|
+
height: 22,
|
|
2076
|
+
paddingX: 10,
|
|
2077
|
+
minWidth: 50,
|
|
2078
|
+
radius: 10
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
};
|
|
2082
|
+
class ContainerStepExtension {
|
|
2083
|
+
static create(configuration) {
|
|
2084
|
+
return new ContainerStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$3);
|
|
2085
|
+
}
|
|
2086
|
+
constructor(configuration) {
|
|
2087
|
+
this.configuration = configuration;
|
|
2088
|
+
this.componentType = 'container';
|
|
2089
|
+
this.createComponentView = createContainerStepComponentViewFactory(this.configuration.view);
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
const defaultConfiguration$2 = {
|
|
2094
|
+
view: {
|
|
2095
|
+
minContainerWidth: 40,
|
|
2096
|
+
paddingX: 20,
|
|
2097
|
+
paddingTop: 20,
|
|
2098
|
+
connectionHeight: 16,
|
|
2099
|
+
inputSize: 18,
|
|
2100
|
+
inputIconSize: 14,
|
|
2101
|
+
branchNameLabel: {
|
|
2102
|
+
height: 22,
|
|
2103
|
+
paddingX: 10,
|
|
2104
|
+
minWidth: 50,
|
|
2105
|
+
radius: 10
|
|
2106
|
+
},
|
|
2107
|
+
nameLabel: {
|
|
2108
|
+
height: 22,
|
|
2109
|
+
paddingX: 10,
|
|
2110
|
+
minWidth: 50,
|
|
2111
|
+
radius: 10
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
};
|
|
2115
|
+
class SwitchStepExtension {
|
|
2116
|
+
static create(configuration) {
|
|
2117
|
+
return new SwitchStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$2);
|
|
2118
|
+
}
|
|
2119
|
+
constructor(configuration) {
|
|
2120
|
+
this.configuration = configuration;
|
|
2121
|
+
this.componentType = 'switch';
|
|
2122
|
+
this.createComponentView = createSwitchStepComponentViewFactory(this.configuration.view);
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
const defaultConfiguration$1 = {
|
|
2127
|
+
view: {
|
|
2128
|
+
paddingLeft: 12,
|
|
2129
|
+
paddingRight: 12,
|
|
2130
|
+
paddingY: 10,
|
|
2131
|
+
textMarginLeft: 12,
|
|
2132
|
+
minTextWidth: 70,
|
|
2133
|
+
iconSize: 22,
|
|
2134
|
+
radius: 5,
|
|
2135
|
+
inputSize: 14,
|
|
2136
|
+
outputSize: 10
|
|
2137
|
+
}
|
|
2138
|
+
};
|
|
2139
|
+
class TaskStepExtension {
|
|
2140
|
+
static create(configuration) {
|
|
2141
|
+
return new TaskStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$1);
|
|
2142
|
+
}
|
|
2143
|
+
constructor(configuration) {
|
|
2144
|
+
this.configuration = configuration;
|
|
2145
|
+
this.componentType = 'task';
|
|
2146
|
+
this.createComponentView = createTaskStepComponentViewFactory(false, this.configuration.view);
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
class StepsDesignerExtension {
|
|
2151
|
+
static create(configuration) {
|
|
2152
|
+
const steps = [];
|
|
2153
|
+
if (configuration.container) {
|
|
2154
|
+
steps.push(ContainerStepExtension.create(configuration.container));
|
|
2155
|
+
}
|
|
2156
|
+
if (configuration.switch) {
|
|
2157
|
+
steps.push(SwitchStepExtension.create(configuration.switch));
|
|
2158
|
+
}
|
|
2159
|
+
if (configuration.task) {
|
|
2160
|
+
steps.push(TaskStepExtension.create(configuration.task));
|
|
2161
|
+
}
|
|
2162
|
+
return new StepsDesignerExtension(steps);
|
|
2163
|
+
}
|
|
2164
|
+
constructor(steps) {
|
|
2165
|
+
this.steps = steps;
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
class DefinitionValidator {
|
|
2170
|
+
constructor(configuration, state) {
|
|
2171
|
+
this.configuration = configuration;
|
|
2172
|
+
this.state = state;
|
|
2173
|
+
}
|
|
2174
|
+
validateStep(step, parentSequence) {
|
|
2175
|
+
var _a;
|
|
2176
|
+
if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.step) {
|
|
2177
|
+
return this.configuration.step(step, parentSequence, this.state.definition);
|
|
2178
|
+
}
|
|
2179
|
+
return true;
|
|
2180
|
+
}
|
|
2181
|
+
validateRoot() {
|
|
2182
|
+
var _a;
|
|
2183
|
+
if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.root) {
|
|
2184
|
+
return this.configuration.root(this.state.definition);
|
|
2185
|
+
}
|
|
2186
|
+
return true;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
class IconProvider {
|
|
2191
|
+
constructor(configuration) {
|
|
2192
|
+
this.configuration = configuration;
|
|
2193
|
+
}
|
|
2194
|
+
getIconUrl(step) {
|
|
2195
|
+
if (this.configuration.iconUrlProvider) {
|
|
2196
|
+
return this.configuration.iconUrlProvider(step.componentType, step.type);
|
|
2197
|
+
}
|
|
2198
|
+
return null;
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
class StepComponentViewContextFactory {
|
|
2203
|
+
static create(stepContext, componentContext) {
|
|
2204
|
+
const preferenceKeyPrefix = stepContext.step.id + ':';
|
|
2205
|
+
return {
|
|
2206
|
+
i18n: componentContext.i18n,
|
|
2207
|
+
getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
|
|
2208
|
+
getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
|
|
2209
|
+
createSequenceComponent: (parentElement, sequence) => {
|
|
2210
|
+
const sequenceContext = {
|
|
2211
|
+
sequence,
|
|
2212
|
+
depth: stepContext.depth + 1,
|
|
2213
|
+
isInputConnected: true,
|
|
2214
|
+
isOutputConnected: stepContext.isOutputConnected,
|
|
2215
|
+
isPreview: stepContext.isPreview
|
|
2216
|
+
};
|
|
2217
|
+
return componentContext.services.sequenceComponent.create(parentElement, sequenceContext, componentContext);
|
|
2218
|
+
},
|
|
2219
|
+
createRegionComponentView(parentElement, componentClassName, contentFactory) {
|
|
2220
|
+
return componentContext.services.regionComponentView.create(parentElement, componentClassName, stepContext, this, contentFactory);
|
|
2221
|
+
},
|
|
2222
|
+
createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
|
|
2223
|
+
getPreference: (key) => componentContext.preferenceStorage.getItem(preferenceKeyPrefix + key),
|
|
2224
|
+
setPreference: (key, value) => componentContext.preferenceStorage.setItem(preferenceKeyPrefix + key, value)
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
class StepComponentFactory {
|
|
2230
|
+
constructor(stepExtensionResolver) {
|
|
2231
|
+
this.stepExtensionResolver = stepExtensionResolver;
|
|
2232
|
+
}
|
|
2233
|
+
create(parentElement, stepContext, componentContext) {
|
|
2234
|
+
const viewContext = StepComponentViewContextFactory.create(stepContext, componentContext);
|
|
2235
|
+
const extension = this.stepExtensionResolver.resolve(stepContext.step.componentType);
|
|
2236
|
+
const view = extension.createComponentView(parentElement, stepContext, viewContext);
|
|
2237
|
+
const wrappedView = componentContext.services.stepComponentViewWrapper.wrap(view, stepContext);
|
|
2238
|
+
return StepComponent.create(wrappedView, stepContext, componentContext);
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
class ComponentContext {
|
|
2243
|
+
static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
|
|
2244
|
+
const validator = new DefinitionValidator(configuration.validator, state);
|
|
2245
|
+
const iconProvider = new IconProvider(configuration.steps);
|
|
2246
|
+
const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
|
|
2247
|
+
return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
|
|
2248
|
+
}
|
|
2249
|
+
constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
|
|
2250
|
+
this.shadowRoot = shadowRoot;
|
|
2251
|
+
this.validator = validator;
|
|
2252
|
+
this.iconProvider = iconProvider;
|
|
2253
|
+
this.placeholderController = placeholderController;
|
|
2254
|
+
this.stepComponentFactory = stepComponentFactory;
|
|
2255
|
+
this.definitionWalker = definitionWalker;
|
|
2256
|
+
this.services = services;
|
|
2257
|
+
this.preferenceStorage = preferenceStorage;
|
|
2258
|
+
this.i18n = i18n;
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
class CustomActionController {
|
|
2263
|
+
constructor(configuration, state, stateModifier) {
|
|
2264
|
+
this.configuration = configuration;
|
|
2265
|
+
this.state = state;
|
|
2266
|
+
this.stateModifier = stateModifier;
|
|
2267
|
+
}
|
|
2268
|
+
trigger(action, step, sequence) {
|
|
2269
|
+
const handler = this.configuration.customActionHandler;
|
|
2270
|
+
if (!handler) {
|
|
2271
|
+
console.warn(`Custom action handler is not defined (action type: ${action.type})`);
|
|
2272
|
+
return;
|
|
2273
|
+
}
|
|
2274
|
+
const context = this.createCustomActionHandlerContext();
|
|
2275
|
+
handler(action, step, sequence, context);
|
|
2276
|
+
}
|
|
2277
|
+
createCustomActionHandlerContext() {
|
|
2278
|
+
return {
|
|
2279
|
+
notifyStepNameChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepNameChanged, stepId, false),
|
|
2280
|
+
notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepPropertyChanged, stepId, false),
|
|
2281
|
+
notifyStepInserted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepInserted, stepId, true),
|
|
2282
|
+
notifyStepMoved: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepMoved, stepId, true),
|
|
2283
|
+
notifyStepDeleted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepDeleted, stepId, true)
|
|
2284
|
+
};
|
|
2285
|
+
}
|
|
2286
|
+
notifyStepChanged(changeType, stepId, updateDependencies) {
|
|
2287
|
+
if (!stepId) {
|
|
2288
|
+
throw new Error('Step id is empty');
|
|
2289
|
+
}
|
|
2290
|
+
this.state.notifyDefinitionChanged(changeType, stepId);
|
|
2291
|
+
if (updateDependencies) {
|
|
2292
|
+
this.stateModifier.updateDependencies();
|
|
2142
2293
|
}
|
|
2143
|
-
return new DefaultRegionView(lines, totalWidth, height);
|
|
2144
2294
|
}
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
class EditorView {
|
|
2298
|
+
static create(parent) {
|
|
2299
|
+
return new EditorView(parent);
|
|
2149
2300
|
}
|
|
2150
|
-
|
|
2151
|
-
|
|
2301
|
+
constructor(parent) {
|
|
2302
|
+
this.parent = parent;
|
|
2303
|
+
this.currentContainer = null;
|
|
2152
2304
|
}
|
|
2153
|
-
|
|
2154
|
-
const
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2305
|
+
setContent(content, className) {
|
|
2306
|
+
const container = Dom.element('div', {
|
|
2307
|
+
class: className
|
|
2308
|
+
});
|
|
2309
|
+
container.appendChild(content);
|
|
2310
|
+
if (this.currentContainer) {
|
|
2311
|
+
this.parent.removeChild(this.currentContainer);
|
|
2158
2312
|
}
|
|
2159
|
-
|
|
2313
|
+
this.parent.appendChild(container);
|
|
2314
|
+
this.currentContainer = container;
|
|
2160
2315
|
}
|
|
2161
|
-
|
|
2162
|
-
this.
|
|
2163
|
-
|
|
2164
|
-
}
|
|
2316
|
+
destroy() {
|
|
2317
|
+
if (this.currentContainer) {
|
|
2318
|
+
this.parent.removeChild(this.currentContainer);
|
|
2319
|
+
}
|
|
2165
2320
|
}
|
|
2166
|
-
}
|
|
2167
|
-
function drawLine(parent, x1, y1, x2, y2) {
|
|
2168
|
-
const line = Dom.svg('line', {
|
|
2169
|
-
class: 'sqd-region',
|
|
2170
|
-
x1,
|
|
2171
|
-
y1,
|
|
2172
|
-
x2,
|
|
2173
|
-
y2
|
|
2174
|
-
});
|
|
2175
|
-
parent.insertBefore(line, parent.firstChild);
|
|
2176
|
-
return line;
|
|
2177
2321
|
}
|
|
2178
2322
|
|
|
2179
|
-
class
|
|
2180
|
-
create(
|
|
2181
|
-
const
|
|
2182
|
-
|
|
2183
|
-
|
|
2323
|
+
class Editor {
|
|
2324
|
+
static create(parent, api, stepEditorClassName, stepEditorProvider, rootEditorClassName, rootEditorProvider, customSelectedStepIdProvider) {
|
|
2325
|
+
const view = EditorView.create(parent);
|
|
2326
|
+
function render(step) {
|
|
2327
|
+
const definition = api.getDefinition();
|
|
2328
|
+
let content;
|
|
2329
|
+
let className;
|
|
2330
|
+
if (step) {
|
|
2331
|
+
const stepContext = api.createStepEditorContext(step.id);
|
|
2332
|
+
content = stepEditorProvider(step, stepContext, definition, api.isReadonly());
|
|
2333
|
+
className = stepEditorClassName;
|
|
2334
|
+
}
|
|
2335
|
+
else {
|
|
2336
|
+
const rootContext = api.createRootEditorContext();
|
|
2337
|
+
content = rootEditorProvider(definition, rootContext, api.isReadonly());
|
|
2338
|
+
className = rootEditorClassName;
|
|
2339
|
+
}
|
|
2340
|
+
view.setContent(content, className);
|
|
2341
|
+
}
|
|
2342
|
+
const renderer = api.runRenderer(step => render(step), customSelectedStepIdProvider);
|
|
2343
|
+
return new Editor(view, renderer);
|
|
2344
|
+
}
|
|
2345
|
+
constructor(view, renderer) {
|
|
2346
|
+
this.view = view;
|
|
2347
|
+
this.renderer = renderer;
|
|
2348
|
+
}
|
|
2349
|
+
destroy() {
|
|
2350
|
+
this.view.destroy();
|
|
2351
|
+
this.renderer.destroy();
|
|
2184
2352
|
}
|
|
2185
2353
|
}
|
|
2186
2354
|
|
|
@@ -2412,6 +2580,8 @@
|
|
|
2412
2580
|
constructor(dom, shadowRoot) {
|
|
2413
2581
|
this.dom = dom;
|
|
2414
2582
|
this.shadowRoot = shadowRoot;
|
|
2583
|
+
this.previousEndToken = null;
|
|
2584
|
+
this.state = null;
|
|
2415
2585
|
this.onMouseMove = (e) => {
|
|
2416
2586
|
e.preventDefault();
|
|
2417
2587
|
e.stopPropagation();
|
|
@@ -2483,7 +2653,7 @@
|
|
|
2483
2653
|
const delta = this.state.startPosition.subtract(position);
|
|
2484
2654
|
const newBehavior = this.state.behavior.onMove(delta);
|
|
2485
2655
|
if (newBehavior) {
|
|
2486
|
-
this.state.behavior.onEnd(true, null);
|
|
2656
|
+
this.state.behavior.onEnd(true, null, null);
|
|
2487
2657
|
this.state.behavior = newBehavior;
|
|
2488
2658
|
this.state.startPosition = position;
|
|
2489
2659
|
this.state.behavior.onStart(this.state.startPosition);
|
|
@@ -2497,8 +2667,9 @@
|
|
|
2497
2667
|
this.unbind(this.shadowRoot);
|
|
2498
2668
|
}
|
|
2499
2669
|
this.unbind(window);
|
|
2500
|
-
this.state.behavior.onEnd(interrupt, element);
|
|
2501
|
-
this.state =
|
|
2670
|
+
const endToken = this.state.behavior.onEnd(interrupt, element, this.previousEndToken);
|
|
2671
|
+
this.state = null;
|
|
2672
|
+
this.previousEndToken = endToken || null;
|
|
2502
2673
|
}
|
|
2503
2674
|
}
|
|
2504
2675
|
|
|
@@ -3174,9 +3345,11 @@
|
|
|
3174
3345
|
}
|
|
3175
3346
|
}
|
|
3176
3347
|
onEnd(interrupt) {
|
|
3177
|
-
if (
|
|
3178
|
-
|
|
3348
|
+
if (interrupt) {
|
|
3349
|
+
return;
|
|
3179
3350
|
}
|
|
3351
|
+
this.stateModifier.trySelectStep(this.pressedStepComponent.step, this.pressedStepComponent.parentSequence);
|
|
3352
|
+
return new SelectStepBehaviorEndToken(this.pressedStepComponent.step.id, Date.now());
|
|
3180
3353
|
}
|
|
3181
3354
|
}
|
|
3182
3355
|
|
|
@@ -3489,10 +3662,7 @@
|
|
|
3489
3662
|
const zoomRealPoint = zoomPoint
|
|
3490
3663
|
.divideByScalar(this.state.lastViewport.scale)
|
|
3491
3664
|
.subtract(this.state.lastViewport.position.divideByScalar(this.state.lastViewport.scale));
|
|
3492
|
-
const position = zoomRealPoint
|
|
3493
|
-
.multiplyByScalar(-scale)
|
|
3494
|
-
.add(zoomPoint)
|
|
3495
|
-
.add(deltaCenterPoint.divideByScalar(this.state.lastViewport.scale));
|
|
3665
|
+
const position = zoomRealPoint.multiplyByScalar(-scale).add(zoomPoint).add(deltaCenterPoint);
|
|
3496
3666
|
const newViewport = {
|
|
3497
3667
|
position,
|
|
3498
3668
|
scale
|
|
@@ -3545,13 +3715,14 @@
|
|
|
3545
3715
|
var _a;
|
|
3546
3716
|
const view = WorkspaceView.create(parent, designerContext.componentContext);
|
|
3547
3717
|
const clickBehaviorResolver = new ClickBehaviorResolver(designerContext);
|
|
3718
|
+
const clickBehaviorWrapper = designerContext.services.clickBehaviorWrapperExtension.create(designerContext.customActionController);
|
|
3548
3719
|
const wheelController = designerContext.services.wheelController.create(api.viewport, api.workspace);
|
|
3549
3720
|
const pinchToZoomController = PinchToZoomController.create(api.workspace, api.viewport, api.shadowRoot);
|
|
3550
3721
|
const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
|
|
3551
3722
|
? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
|
|
3552
3723
|
: undefined);
|
|
3553
3724
|
const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
|
|
3554
|
-
const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, api.viewport, designerContext.services);
|
|
3725
|
+
const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, api.viewport, designerContext.services);
|
|
3555
3726
|
setTimeout(() => {
|
|
3556
3727
|
workspace.updateRootComponent();
|
|
3557
3728
|
api.viewport.resetViewport();
|
|
@@ -3567,7 +3738,7 @@
|
|
|
3567
3738
|
view.bindContextMenu(workspace.onContextMenu);
|
|
3568
3739
|
return workspace;
|
|
3569
3740
|
}
|
|
3570
|
-
constructor(view, definitionWalker, state, behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, viewportApi, services) {
|
|
3741
|
+
constructor(view, definitionWalker, state, behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, viewportApi, services) {
|
|
3571
3742
|
this.view = view;
|
|
3572
3743
|
this.definitionWalker = definitionWalker;
|
|
3573
3744
|
this.state = state;
|
|
@@ -3576,6 +3747,7 @@
|
|
|
3576
3747
|
this.pinchToZoomController = pinchToZoomController;
|
|
3577
3748
|
this.contextMenuController = contextMenuController;
|
|
3578
3749
|
this.clickBehaviorResolver = clickBehaviorResolver;
|
|
3750
|
+
this.clickBehaviorWrapper = clickBehaviorWrapper;
|
|
3579
3751
|
this.viewportApi = viewportApi;
|
|
3580
3752
|
this.services = services;
|
|
3581
3753
|
this.onRendered = new SimpleEvent();
|
|
@@ -3589,7 +3761,8 @@
|
|
|
3589
3761
|
const forceMove = isMiddleButton || altKey;
|
|
3590
3762
|
const commandOrNull = this.resolveClick(target, position);
|
|
3591
3763
|
const behavior = this.clickBehaviorResolver.resolve(commandOrNull, target, forceMove);
|
|
3592
|
-
this.
|
|
3764
|
+
const wrappedBehavior = this.clickBehaviorWrapper.wrap(behavior, commandOrNull);
|
|
3765
|
+
this.behaviorController.start(position, wrappedBehavior);
|
|
3593
3766
|
}
|
|
3594
3767
|
};
|
|
3595
3768
|
this.onPinchToZoom = (distance, centerPoint) => {
|
|
@@ -3907,7 +4080,7 @@
|
|
|
3907
4080
|
static create(parent, api) {
|
|
3908
4081
|
const isUndoRedoSupported = api.controlBar.isUndoRedoSupported();
|
|
3909
4082
|
const view = ControlBarView.create(parent, isUndoRedoSupported, api.i18n);
|
|
3910
|
-
const bar = new ControlBar(view, api.controlBar, isUndoRedoSupported);
|
|
4083
|
+
const bar = new ControlBar(view, api.controlBar, api.viewport, isUndoRedoSupported);
|
|
3911
4084
|
view.bindResetButtonClick(() => bar.onResetButtonClicked());
|
|
3912
4085
|
view.bindZoomInButtonClick(() => bar.onZoomInButtonClicked());
|
|
3913
4086
|
view.bindZoomOutButtonClick(() => bar.onZoomOutButtonClicked());
|
|
@@ -3921,9 +4094,10 @@
|
|
|
3921
4094
|
bar.refreshButtons();
|
|
3922
4095
|
return bar;
|
|
3923
4096
|
}
|
|
3924
|
-
constructor(view, controlBarApi, isUndoRedoSupported) {
|
|
4097
|
+
constructor(view, controlBarApi, viewportApi, isUndoRedoSupported) {
|
|
3925
4098
|
this.view = view;
|
|
3926
4099
|
this.controlBarApi = controlBarApi;
|
|
4100
|
+
this.viewportApi = viewportApi;
|
|
3927
4101
|
this.isUndoRedoSupported = isUndoRedoSupported;
|
|
3928
4102
|
}
|
|
3929
4103
|
updateLayout() {
|
|
@@ -3933,13 +4107,13 @@
|
|
|
3933
4107
|
//
|
|
3934
4108
|
}
|
|
3935
4109
|
onResetButtonClicked() {
|
|
3936
|
-
this.
|
|
4110
|
+
this.viewportApi.resetViewport();
|
|
3937
4111
|
}
|
|
3938
4112
|
onZoomInButtonClicked() {
|
|
3939
|
-
this.
|
|
4113
|
+
this.viewportApi.zoom(true);
|
|
3940
4114
|
}
|
|
3941
4115
|
onZoomOutButtonClicked() {
|
|
3942
|
-
this.
|
|
4116
|
+
this.viewportApi.zoom(false);
|
|
3943
4117
|
}
|
|
3944
4118
|
onMoveButtonClicked() {
|
|
3945
4119
|
this.controlBarApi.toggleIsDragDisabled();
|
|
@@ -4457,31 +4631,6 @@
|
|
|
4457
4631
|
}
|
|
4458
4632
|
}
|
|
4459
4633
|
|
|
4460
|
-
const defaultConfiguration$4 = {
|
|
4461
|
-
view: {
|
|
4462
|
-
paddingTop: 20,
|
|
4463
|
-
paddingX: 20,
|
|
4464
|
-
inputSize: 18,
|
|
4465
|
-
inputIconSize: 14,
|
|
4466
|
-
label: {
|
|
4467
|
-
height: 22,
|
|
4468
|
-
paddingX: 10,
|
|
4469
|
-
minWidth: 50,
|
|
4470
|
-
radius: 10
|
|
4471
|
-
}
|
|
4472
|
-
}
|
|
4473
|
-
};
|
|
4474
|
-
class ContainerStepExtension {
|
|
4475
|
-
static create(configuration) {
|
|
4476
|
-
return new ContainerStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$4);
|
|
4477
|
-
}
|
|
4478
|
-
constructor(configuration) {
|
|
4479
|
-
this.configuration = configuration;
|
|
4480
|
-
this.componentType = 'container';
|
|
4481
|
-
this.createComponentView = createContainerStepComponentViewFactory(this.configuration.view);
|
|
4482
|
-
}
|
|
4483
|
-
}
|
|
4484
|
-
|
|
4485
4634
|
class DefaultPlaceholderControllerExtension {
|
|
4486
4635
|
create() {
|
|
4487
4636
|
return {
|
|
@@ -4490,7 +4639,7 @@
|
|
|
4490
4639
|
}
|
|
4491
4640
|
}
|
|
4492
4641
|
|
|
4493
|
-
const defaultConfiguration
|
|
4642
|
+
const defaultConfiguration = {
|
|
4494
4643
|
gapWidth: 88,
|
|
4495
4644
|
gapHeight: 24,
|
|
4496
4645
|
radius: 6,
|
|
@@ -4498,7 +4647,7 @@
|
|
|
4498
4647
|
};
|
|
4499
4648
|
class RectPlaceholderExtension {
|
|
4500
4649
|
static create(configuration) {
|
|
4501
|
-
return new RectPlaceholderExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration
|
|
4650
|
+
return new RectPlaceholderExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration);
|
|
4502
4651
|
}
|
|
4503
4652
|
constructor(configuration) {
|
|
4504
4653
|
this.configuration = configuration;
|
|
@@ -4512,63 +4661,6 @@
|
|
|
4512
4661
|
}
|
|
4513
4662
|
}
|
|
4514
4663
|
|
|
4515
|
-
const defaultConfiguration$2 = {
|
|
4516
|
-
view: {
|
|
4517
|
-
minContainerWidth: 40,
|
|
4518
|
-
paddingX: 20,
|
|
4519
|
-
paddingTop: 20,
|
|
4520
|
-
connectionHeight: 16,
|
|
4521
|
-
inputSize: 18,
|
|
4522
|
-
inputIconSize: 14,
|
|
4523
|
-
branchNameLabel: {
|
|
4524
|
-
height: 22,
|
|
4525
|
-
paddingX: 10,
|
|
4526
|
-
minWidth: 50,
|
|
4527
|
-
radius: 10
|
|
4528
|
-
},
|
|
4529
|
-
nameLabel: {
|
|
4530
|
-
height: 22,
|
|
4531
|
-
paddingX: 10,
|
|
4532
|
-
minWidth: 50,
|
|
4533
|
-
radius: 10
|
|
4534
|
-
}
|
|
4535
|
-
}
|
|
4536
|
-
};
|
|
4537
|
-
class SwitchStepExtension {
|
|
4538
|
-
static create(configuration) {
|
|
4539
|
-
return new SwitchStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$2);
|
|
4540
|
-
}
|
|
4541
|
-
constructor(configuration) {
|
|
4542
|
-
this.configuration = configuration;
|
|
4543
|
-
this.componentType = 'switch';
|
|
4544
|
-
this.createComponentView = createSwitchStepComponentViewFactory(this.configuration.view);
|
|
4545
|
-
}
|
|
4546
|
-
}
|
|
4547
|
-
|
|
4548
|
-
const defaultConfiguration$1 = {
|
|
4549
|
-
view: {
|
|
4550
|
-
paddingLeft: 12,
|
|
4551
|
-
paddingRight: 12,
|
|
4552
|
-
paddingY: 10,
|
|
4553
|
-
textMarginLeft: 12,
|
|
4554
|
-
minTextWidth: 70,
|
|
4555
|
-
iconSize: 22,
|
|
4556
|
-
radius: 5,
|
|
4557
|
-
inputSize: 14,
|
|
4558
|
-
outputSize: 10
|
|
4559
|
-
}
|
|
4560
|
-
};
|
|
4561
|
-
class TaskStepExtension {
|
|
4562
|
-
static create(configuration) {
|
|
4563
|
-
return new TaskStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$1);
|
|
4564
|
-
}
|
|
4565
|
-
constructor(configuration) {
|
|
4566
|
-
this.configuration = configuration;
|
|
4567
|
-
this.componentType = 'task';
|
|
4568
|
-
this.createComponentView = createTaskStepComponentViewFactory(false, this.configuration.view);
|
|
4569
|
-
}
|
|
4570
|
-
}
|
|
4571
|
-
|
|
4572
4664
|
class DefaultSequenceComponentExtension {
|
|
4573
4665
|
constructor() {
|
|
4574
4666
|
this.create = DefaultSequenceComponent.create;
|
|
@@ -4581,39 +4673,15 @@
|
|
|
4581
4673
|
}
|
|
4582
4674
|
}
|
|
4583
4675
|
|
|
4584
|
-
class
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
class: 'sqd-line-grid-path',
|
|
4588
|
-
fill: 'none'
|
|
4589
|
-
});
|
|
4590
|
-
return new LineGrid(size, path);
|
|
4591
|
-
}
|
|
4592
|
-
constructor(size, element) {
|
|
4593
|
-
this.size = size;
|
|
4594
|
-
this.element = element;
|
|
4595
|
-
}
|
|
4596
|
-
setScale(_, scaledSize) {
|
|
4597
|
-
Dom.attrs(this.element, {
|
|
4598
|
-
d: `M ${scaledSize.x} 0 L 0 0 0 ${scaledSize.y}`
|
|
4599
|
-
});
|
|
4676
|
+
class DefaultClickBehaviorWrapper {
|
|
4677
|
+
constructor() {
|
|
4678
|
+
this.wrap = (behavior) => behavior;
|
|
4600
4679
|
}
|
|
4601
4680
|
}
|
|
4602
4681
|
|
|
4603
|
-
|
|
4604
|
-
gridSizeX: 48,
|
|
4605
|
-
gridSizeY: 48
|
|
4606
|
-
};
|
|
4607
|
-
class LineGridExtension {
|
|
4608
|
-
static create(configuration) {
|
|
4609
|
-
return new LineGridExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration);
|
|
4610
|
-
}
|
|
4611
|
-
constructor(configuration) {
|
|
4612
|
-
this.configuration = configuration;
|
|
4613
|
-
}
|
|
4682
|
+
class DefaultClickBehaviorWrapperExtension {
|
|
4614
4683
|
create() {
|
|
4615
|
-
|
|
4616
|
-
return LineGrid.create(size);
|
|
4684
|
+
return new DefaultClickBehaviorWrapper();
|
|
4617
4685
|
}
|
|
4618
4686
|
}
|
|
4619
4687
|
|
|
@@ -4633,6 +4701,9 @@
|
|
|
4633
4701
|
if (ext.stepComponentViewWrapper) {
|
|
4634
4702
|
services.stepComponentViewWrapper = ext.stepComponentViewWrapper;
|
|
4635
4703
|
}
|
|
4704
|
+
if (ext.clickBehaviorWrapperExtension) {
|
|
4705
|
+
services.clickBehaviorWrapperExtension = ext.clickBehaviorWrapperExtension;
|
|
4706
|
+
}
|
|
4636
4707
|
if (ext.badges) {
|
|
4637
4708
|
services.badges = (services.badges || []).concat(ext.badges);
|
|
4638
4709
|
}
|
|
@@ -4684,6 +4755,9 @@
|
|
|
4684
4755
|
if (!services.stepComponentViewWrapper) {
|
|
4685
4756
|
services.stepComponentViewWrapper = new DefaultStepComponentViewWrapperExtension();
|
|
4686
4757
|
}
|
|
4758
|
+
if (!services.clickBehaviorWrapperExtension) {
|
|
4759
|
+
services.clickBehaviorWrapperExtension = new DefaultClickBehaviorWrapperExtension();
|
|
4760
|
+
}
|
|
4687
4761
|
if (!services.badges) {
|
|
4688
4762
|
services.badges = [];
|
|
4689
4763
|
}
|
|
@@ -4980,35 +5054,6 @@
|
|
|
4980
5054
|
}
|
|
4981
5055
|
}
|
|
4982
5056
|
|
|
4983
|
-
class LineGridDesignerExtension {
|
|
4984
|
-
static create(configuration) {
|
|
4985
|
-
const grid = LineGridExtension.create(configuration);
|
|
4986
|
-
return new LineGridDesignerExtension(grid);
|
|
4987
|
-
}
|
|
4988
|
-
constructor(grid) {
|
|
4989
|
-
this.grid = grid;
|
|
4990
|
-
}
|
|
4991
|
-
}
|
|
4992
|
-
|
|
4993
|
-
class StepsDesignerExtension {
|
|
4994
|
-
static create(configuration) {
|
|
4995
|
-
const steps = [];
|
|
4996
|
-
if (configuration.container) {
|
|
4997
|
-
steps.push(ContainerStepExtension.create(configuration.container));
|
|
4998
|
-
}
|
|
4999
|
-
if (configuration.switch) {
|
|
5000
|
-
steps.push(SwitchStepExtension.create(configuration.switch));
|
|
5001
|
-
}
|
|
5002
|
-
if (configuration.task) {
|
|
5003
|
-
steps.push(TaskStepExtension.create(configuration.task));
|
|
5004
|
-
}
|
|
5005
|
-
return new StepsDesignerExtension(steps);
|
|
5006
|
-
}
|
|
5007
|
-
constructor(steps) {
|
|
5008
|
-
this.steps = steps;
|
|
5009
|
-
}
|
|
5010
|
-
}
|
|
5011
|
-
|
|
5012
5057
|
exports.Badges = Badges;
|
|
5013
5058
|
exports.CenteredViewportCalculator = CenteredViewportCalculator;
|
|
5014
5059
|
exports.ClassicWheelControllerExtension = ClassicWheelControllerExtension;
|
|
@@ -5021,6 +5066,7 @@
|
|
|
5021
5066
|
exports.DefaultSequenceComponent = DefaultSequenceComponent;
|
|
5022
5067
|
exports.DefaultSequenceComponentView = DefaultSequenceComponentView;
|
|
5023
5068
|
exports.DefaultViewportController = DefaultViewportController;
|
|
5069
|
+
exports.DefaultViewportControllerDesignerExtension = DefaultViewportControllerDesignerExtension;
|
|
5024
5070
|
exports.DefaultViewportControllerExtension = DefaultViewportControllerExtension;
|
|
5025
5071
|
exports.DefinitionWalker = DefinitionWalker;
|
|
5026
5072
|
exports.Designer = Designer;
|
|
@@ -5040,12 +5086,15 @@
|
|
|
5040
5086
|
exports.PathBarApi = PathBarApi;
|
|
5041
5087
|
exports.RectPlaceholder = RectPlaceholder;
|
|
5042
5088
|
exports.RectPlaceholderView = RectPlaceholderView;
|
|
5089
|
+
exports.SelectStepBehaviorEndToken = SelectStepBehaviorEndToken;
|
|
5043
5090
|
exports.ServicesResolver = ServicesResolver;
|
|
5044
5091
|
exports.SimpleEvent = SimpleEvent;
|
|
5092
|
+
exports.StartStopRootComponentDesignerExtension = StartStopRootComponentDesignerExtension;
|
|
5045
5093
|
exports.StartStopRootComponentExtension = StartStopRootComponentExtension;
|
|
5046
5094
|
exports.StepComponent = StepComponent;
|
|
5047
5095
|
exports.StepExtensionResolver = StepExtensionResolver;
|
|
5048
5096
|
exports.StepsDesignerExtension = StepsDesignerExtension;
|
|
5097
|
+
exports.TYPE = TYPE;
|
|
5049
5098
|
exports.ToolboxApi = ToolboxApi;
|
|
5050
5099
|
exports.Uid = Uid;
|
|
5051
5100
|
exports.ValidationErrorBadgeExtension = ValidationErrorBadgeExtension;
|