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/lib/cjs/index.cjs
CHANGED
|
@@ -200,27 +200,17 @@ function race(timeout, a, b, c, d) {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
class ControlBarApi {
|
|
203
|
-
static create(state, historyController, stateModifier
|
|
204
|
-
const api = new ControlBarApi(state, historyController, stateModifier
|
|
203
|
+
static create(state, historyController, stateModifier) {
|
|
204
|
+
const api = new ControlBarApi(state, historyController, stateModifier);
|
|
205
205
|
race(0, state.onIsReadonlyChanged, state.onSelectedStepIdChanged, state.onIsDragDisabledChanged, api.isUndoRedoSupported() ? state.onDefinitionChanged : undefined).subscribe(api.onStateChanged.forward);
|
|
206
206
|
return api;
|
|
207
207
|
}
|
|
208
|
-
constructor(state, historyController, stateModifier
|
|
208
|
+
constructor(state, historyController, stateModifier) {
|
|
209
209
|
this.state = state;
|
|
210
210
|
this.historyController = historyController;
|
|
211
211
|
this.stateModifier = stateModifier;
|
|
212
|
-
this.viewportApi = viewportApi;
|
|
213
212
|
this.onStateChanged = new SimpleEvent();
|
|
214
213
|
}
|
|
215
|
-
resetViewport() {
|
|
216
|
-
this.viewportApi.resetViewport();
|
|
217
|
-
}
|
|
218
|
-
zoomIn() {
|
|
219
|
-
this.viewportApi.zoom(true);
|
|
220
|
-
}
|
|
221
|
-
zoomOut() {
|
|
222
|
-
this.viewportApi.zoom(false);
|
|
223
|
-
}
|
|
224
214
|
isDragDisabled() {
|
|
225
215
|
return this.state.isDragDisabled;
|
|
226
216
|
}
|
|
@@ -691,21 +681,20 @@ function animate(interval, handler) {
|
|
|
691
681
|
}
|
|
692
682
|
|
|
693
683
|
class ViewportAnimator {
|
|
694
|
-
constructor(
|
|
695
|
-
this.
|
|
684
|
+
constructor(state) {
|
|
685
|
+
this.state = state;
|
|
696
686
|
}
|
|
697
687
|
execute(target) {
|
|
698
688
|
if (this.animation && this.animation.isAlive) {
|
|
699
689
|
this.animation.stop();
|
|
700
690
|
}
|
|
701
|
-
const
|
|
702
|
-
const
|
|
703
|
-
const startScale = viewport.scale;
|
|
691
|
+
const startPosition = this.state.viewport.position;
|
|
692
|
+
const startScale = this.state.viewport.scale;
|
|
704
693
|
const deltaPosition = startPosition.subtract(target.position);
|
|
705
694
|
const deltaScale = startScale - target.scale;
|
|
706
695
|
this.animation = animate(150, progress => {
|
|
707
696
|
const newScale = startScale - deltaScale * progress;
|
|
708
|
-
this.
|
|
697
|
+
this.state.setViewport({
|
|
709
698
|
position: startPosition.subtract(deltaPosition.multiplyByScalar(progress)),
|
|
710
699
|
scale: newScale
|
|
711
700
|
});
|
|
@@ -738,23 +727,23 @@ class ZoomByWheelCalculator {
|
|
|
738
727
|
}
|
|
739
728
|
|
|
740
729
|
class ViewportApi {
|
|
741
|
-
constructor(workspaceController, viewportController
|
|
730
|
+
constructor(state, workspaceController, viewportController) {
|
|
731
|
+
this.state = state;
|
|
742
732
|
this.workspaceController = workspaceController;
|
|
743
733
|
this.viewportController = viewportController;
|
|
744
|
-
this.
|
|
745
|
-
this.animator = new ViewportAnimator(this.api);
|
|
734
|
+
this.animator = new ViewportAnimator(this.state);
|
|
746
735
|
}
|
|
747
736
|
limitScale(scale) {
|
|
748
737
|
return this.viewportController.limitScale(scale);
|
|
749
738
|
}
|
|
750
739
|
resetViewport() {
|
|
751
740
|
const defaultViewport = this.viewportController.getDefault();
|
|
752
|
-
this.
|
|
741
|
+
this.state.setViewport(defaultViewport);
|
|
753
742
|
}
|
|
754
743
|
zoom(direction) {
|
|
755
744
|
const viewport = this.viewportController.getZoomed(direction);
|
|
756
745
|
if (viewport) {
|
|
757
|
-
this.
|
|
746
|
+
this.state.setViewport(viewport);
|
|
758
747
|
}
|
|
759
748
|
}
|
|
760
749
|
moveViewportToStep(stepId) {
|
|
@@ -767,11 +756,10 @@ class ViewportApi {
|
|
|
767
756
|
this.animator.execute(viewport);
|
|
768
757
|
}
|
|
769
758
|
handleWheelEvent(e) {
|
|
770
|
-
const
|
|
771
|
-
const
|
|
772
|
-
const newViewport = ZoomByWheelCalculator.calculate(this.viewportController, viewport, canvasPosition, e);
|
|
759
|
+
const canvasPosition = this.workspaceController.getCanvasPosition();
|
|
760
|
+
const newViewport = ZoomByWheelCalculator.calculate(this.viewportController, this.state.viewport, canvasPosition, e);
|
|
773
761
|
if (newViewport) {
|
|
774
|
-
this.
|
|
762
|
+
this.state.setViewport(newViewport);
|
|
775
763
|
}
|
|
776
764
|
}
|
|
777
765
|
}
|
|
@@ -781,6 +769,12 @@ class WorkspaceApi {
|
|
|
781
769
|
this.state = state;
|
|
782
770
|
this.workspaceController = workspaceController;
|
|
783
771
|
}
|
|
772
|
+
getViewport() {
|
|
773
|
+
return this.state.viewport;
|
|
774
|
+
}
|
|
775
|
+
setViewport(viewport) {
|
|
776
|
+
this.state.setViewport(viewport);
|
|
777
|
+
}
|
|
784
778
|
getCanvasPosition() {
|
|
785
779
|
return this.workspaceController.getCanvasPosition();
|
|
786
780
|
}
|
|
@@ -790,12 +784,6 @@ class WorkspaceApi {
|
|
|
790
784
|
getRootComponentSize() {
|
|
791
785
|
return this.workspaceController.getRootComponentSize();
|
|
792
786
|
}
|
|
793
|
-
getViewport() {
|
|
794
|
-
return this.state.viewport;
|
|
795
|
-
}
|
|
796
|
-
setViewport(viewport) {
|
|
797
|
-
this.state.setViewport(viewport);
|
|
798
|
-
}
|
|
799
787
|
updateRootComponent() {
|
|
800
788
|
this.workspaceController.updateRootComponent();
|
|
801
789
|
}
|
|
@@ -811,9 +799,8 @@ class DesignerApi {
|
|
|
811
799
|
static create(context) {
|
|
812
800
|
const workspace = new WorkspaceApi(context.state, context.workspaceController);
|
|
813
801
|
const viewportController = context.services.viewportController.create(workspace);
|
|
814
|
-
const viewport = new ViewportApi(context.workspaceController, viewportController, workspace);
|
|
815
802
|
const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
|
|
816
|
-
return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.stateModifier
|
|
803
|
+
return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.stateModifier), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, new ViewportApi(context.state, context.workspaceController, viewportController), new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
|
|
817
804
|
}
|
|
818
805
|
constructor(shadowRoot, controlBar, toolbox, editor, workspace, viewport, pathBar, definitionWalker, i18n) {
|
|
819
806
|
this.shadowRoot = shadowRoot;
|
|
@@ -828,36 +815,15 @@ class DesignerApi {
|
|
|
828
815
|
}
|
|
829
816
|
}
|
|
830
817
|
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
}
|
|
836
|
-
validateStep(step, parentSequence) {
|
|
837
|
-
var _a;
|
|
838
|
-
if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.step) {
|
|
839
|
-
return this.configuration.step(step, parentSequence, this.state.definition);
|
|
840
|
-
}
|
|
841
|
-
return true;
|
|
842
|
-
}
|
|
843
|
-
validateRoot() {
|
|
844
|
-
var _a;
|
|
845
|
-
if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.root) {
|
|
846
|
-
return this.configuration.root(this.state.definition);
|
|
847
|
-
}
|
|
848
|
-
return true;
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
class IconProvider {
|
|
853
|
-
constructor(configuration) {
|
|
854
|
-
this.configuration = configuration;
|
|
818
|
+
const TYPE = 'selectStep';
|
|
819
|
+
class SelectStepBehaviorEndToken {
|
|
820
|
+
static is(token) {
|
|
821
|
+
return Boolean(token) && token.type === TYPE;
|
|
855
822
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
return null;
|
|
823
|
+
constructor(stepId, time) {
|
|
824
|
+
this.stepId = stepId;
|
|
825
|
+
this.time = time;
|
|
826
|
+
this.type = TYPE;
|
|
861
827
|
}
|
|
862
828
|
}
|
|
863
829
|
|
|
@@ -922,349 +888,104 @@ function createG(parentElement) {
|
|
|
922
888
|
return g;
|
|
923
889
|
}
|
|
924
890
|
|
|
925
|
-
|
|
926
|
-
(
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
(
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
const badges = Badges.createForStep(stepContext, view, componentContext);
|
|
942
|
-
return new StepComponent(view, stepContext.step, stepContext.parentSequence, view.hasOutput, badges);
|
|
891
|
+
class ValidationErrorBadgeView {
|
|
892
|
+
static create(parent, cfg) {
|
|
893
|
+
const g = Dom.svg('g');
|
|
894
|
+
const halfOfSize = cfg.size / 2;
|
|
895
|
+
const circle = Dom.svg('path', {
|
|
896
|
+
class: 'sqd-validation-error',
|
|
897
|
+
d: `M 0 ${-halfOfSize} l ${halfOfSize} ${cfg.size} l ${-cfg.size} 0 Z`
|
|
898
|
+
});
|
|
899
|
+
Dom.translate(circle, halfOfSize, halfOfSize);
|
|
900
|
+
g.appendChild(circle);
|
|
901
|
+
const icon = Icons.appendPath(g, 'sqd-validation-error-icon-path', Icons.alert, cfg.iconSize);
|
|
902
|
+
const offsetX = (cfg.size - cfg.iconSize) / 2;
|
|
903
|
+
const offsetY = offsetX * 1.5;
|
|
904
|
+
Dom.translate(icon, offsetX, offsetY);
|
|
905
|
+
parent.appendChild(g);
|
|
906
|
+
return new ValidationErrorBadgeView(parent, g, cfg.size, cfg.size);
|
|
943
907
|
}
|
|
944
|
-
constructor(
|
|
945
|
-
this.
|
|
946
|
-
this.
|
|
947
|
-
this.
|
|
948
|
-
this.
|
|
949
|
-
this.badges = badges;
|
|
908
|
+
constructor(parent, g, width, height) {
|
|
909
|
+
this.parent = parent;
|
|
910
|
+
this.g = g;
|
|
911
|
+
this.width = width;
|
|
912
|
+
this.height = height;
|
|
950
913
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
return this;
|
|
954
|
-
}
|
|
955
|
-
if (this.view.sequenceComponents) {
|
|
956
|
-
for (const component of this.view.sequenceComponents) {
|
|
957
|
-
const result = component.findById(stepId);
|
|
958
|
-
if (result) {
|
|
959
|
-
return result;
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
return null;
|
|
914
|
+
destroy() {
|
|
915
|
+
this.parent.removeChild(this.g);
|
|
964
916
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
class ValidatorFactory {
|
|
920
|
+
static createForStep(stepContext, view, componentContext) {
|
|
921
|
+
return () => {
|
|
922
|
+
if (!componentContext.validator.validateStep(stepContext.step, stepContext.parentSequence)) {
|
|
923
|
+
return false;
|
|
972
924
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
component: this
|
|
925
|
+
if (view.haveCollapsedChildren) {
|
|
926
|
+
let allChildrenValid = true;
|
|
927
|
+
componentContext.definitionWalker.forEachChildren(stepContext.step, (step, _, parentSequence) => {
|
|
928
|
+
if (!componentContext.validator.validateStep(step, parentSequence)) {
|
|
929
|
+
allChildrenValid = false;
|
|
930
|
+
return false;
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
if (!allChildrenValid) {
|
|
934
|
+
return false;
|
|
984
935
|
}
|
|
985
|
-
: viewResult;
|
|
986
|
-
}
|
|
987
|
-
return null;
|
|
988
|
-
}
|
|
989
|
-
resolvePlaceholders(skipComponent, result) {
|
|
990
|
-
if (skipComponent !== this) {
|
|
991
|
-
if (this.view.sequenceComponents) {
|
|
992
|
-
this.view.sequenceComponents.forEach(component => component.resolvePlaceholders(skipComponent, result));
|
|
993
936
|
}
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
}
|
|
997
|
-
result.components.push(this);
|
|
998
|
-
}
|
|
937
|
+
return true;
|
|
938
|
+
};
|
|
999
939
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
940
|
+
static createForRoot(componentContext) {
|
|
941
|
+
return () => {
|
|
942
|
+
return componentContext.validator.validateRoot();
|
|
943
|
+
};
|
|
1002
944
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
class ValidationErrorBadge {
|
|
948
|
+
static createForStep(parentElement, view, stepContext, componentContext, configuration) {
|
|
949
|
+
const validator = ValidatorFactory.createForStep(stepContext, view, componentContext);
|
|
950
|
+
return new ValidationErrorBadge(parentElement, validator, configuration);
|
|
1005
951
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
952
|
+
static createForRoot(parentElement, componentContext, configuration) {
|
|
953
|
+
const validator = ValidatorFactory.createForRoot(componentContext);
|
|
954
|
+
return new ValidationErrorBadge(parentElement, validator, configuration);
|
|
1008
955
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
956
|
+
constructor(parentElement, validator, configuration) {
|
|
957
|
+
this.parentElement = parentElement;
|
|
958
|
+
this.validator = validator;
|
|
959
|
+
this.configuration = configuration;
|
|
960
|
+
this.view = null;
|
|
961
|
+
}
|
|
962
|
+
update(result) {
|
|
963
|
+
const isValid = this.validator();
|
|
964
|
+
if (isValid) {
|
|
965
|
+
if (this.view) {
|
|
966
|
+
this.view.destroy();
|
|
967
|
+
this.view = null;
|
|
968
|
+
}
|
|
1012
969
|
}
|
|
1013
|
-
this.
|
|
970
|
+
else if (!this.view) {
|
|
971
|
+
this.view = ValidationErrorBadgeView.create(this.parentElement, this.configuration);
|
|
972
|
+
}
|
|
973
|
+
return isValid && result;
|
|
1014
974
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
class StepComponentViewContextFactory {
|
|
1018
|
-
static create(stepContext, componentContext) {
|
|
1019
|
-
const preferenceKeyPrefix = stepContext.step.id + ':';
|
|
1020
|
-
return {
|
|
1021
|
-
i18n: componentContext.i18n,
|
|
1022
|
-
getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
|
|
1023
|
-
getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
|
|
1024
|
-
createSequenceComponent: (parentElement, sequence) => {
|
|
1025
|
-
const sequenceContext = {
|
|
1026
|
-
sequence,
|
|
1027
|
-
depth: stepContext.depth + 1,
|
|
1028
|
-
isInputConnected: true,
|
|
1029
|
-
isOutputConnected: stepContext.isOutputConnected,
|
|
1030
|
-
isPreview: stepContext.isPreview
|
|
1031
|
-
};
|
|
1032
|
-
return componentContext.services.sequenceComponent.create(parentElement, sequenceContext, componentContext);
|
|
1033
|
-
},
|
|
1034
|
-
createRegionComponentView(parentElement, componentClassName, contentFactory) {
|
|
1035
|
-
return componentContext.services.regionComponentView.create(parentElement, componentClassName, stepContext, this, contentFactory);
|
|
1036
|
-
},
|
|
1037
|
-
createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
|
|
1038
|
-
getPreference: (key) => componentContext.preferenceStorage.getItem(preferenceKeyPrefix + key),
|
|
1039
|
-
setPreference: (key, value) => componentContext.preferenceStorage.setItem(preferenceKeyPrefix + key, value)
|
|
1040
|
-
};
|
|
975
|
+
resolveClick() {
|
|
976
|
+
return null;
|
|
1041
977
|
}
|
|
1042
978
|
}
|
|
1043
979
|
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
980
|
+
const defaultConfiguration$7 = {
|
|
981
|
+
view: {
|
|
982
|
+
size: 22,
|
|
983
|
+
iconSize: 12
|
|
1047
984
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
const wrappedView = componentContext.services.stepComponentViewWrapper.wrap(view, stepContext);
|
|
1053
|
-
return StepComponent.create(wrappedView, stepContext, componentContext);
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
class ComponentContext {
|
|
1058
|
-
static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
|
|
1059
|
-
const validator = new DefinitionValidator(configuration.validator, state);
|
|
1060
|
-
const iconProvider = new IconProvider(configuration.steps);
|
|
1061
|
-
const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
|
|
1062
|
-
return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
|
|
1063
|
-
}
|
|
1064
|
-
constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
|
|
1065
|
-
this.shadowRoot = shadowRoot;
|
|
1066
|
-
this.validator = validator;
|
|
1067
|
-
this.iconProvider = iconProvider;
|
|
1068
|
-
this.placeholderController = placeholderController;
|
|
1069
|
-
this.stepComponentFactory = stepComponentFactory;
|
|
1070
|
-
this.definitionWalker = definitionWalker;
|
|
1071
|
-
this.services = services;
|
|
1072
|
-
this.preferenceStorage = preferenceStorage;
|
|
1073
|
-
this.i18n = i18n;
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
class CustomActionController {
|
|
1078
|
-
constructor(configuration, state, stateModifier) {
|
|
1079
|
-
this.configuration = configuration;
|
|
1080
|
-
this.state = state;
|
|
1081
|
-
this.stateModifier = stateModifier;
|
|
1082
|
-
}
|
|
1083
|
-
trigger(action, step, sequence) {
|
|
1084
|
-
const handler = this.configuration.customActionHandler;
|
|
1085
|
-
if (!handler) {
|
|
1086
|
-
console.warn(`Custom action handler is not defined (action type: ${action.type})`);
|
|
1087
|
-
return;
|
|
1088
|
-
}
|
|
1089
|
-
const context = this.createCustomActionHandlerContext();
|
|
1090
|
-
handler(action, step, sequence, context);
|
|
1091
|
-
}
|
|
1092
|
-
createCustomActionHandlerContext() {
|
|
1093
|
-
return {
|
|
1094
|
-
notifyStepNameChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepNameChanged, stepId, false),
|
|
1095
|
-
notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepPropertyChanged, stepId, false),
|
|
1096
|
-
notifyStepInserted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepInserted, stepId, true),
|
|
1097
|
-
notifyStepMoved: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepMoved, stepId, true),
|
|
1098
|
-
notifyStepDeleted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepDeleted, stepId, true)
|
|
1099
|
-
};
|
|
1100
|
-
}
|
|
1101
|
-
notifyStepChanged(changeType, stepId, updateDependencies) {
|
|
1102
|
-
if (!stepId) {
|
|
1103
|
-
throw new Error('Step id is empty');
|
|
1104
|
-
}
|
|
1105
|
-
this.state.notifyDefinitionChanged(changeType, stepId);
|
|
1106
|
-
if (updateDependencies) {
|
|
1107
|
-
this.stateModifier.updateDependencies();
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
class EditorView {
|
|
1113
|
-
static create(parent) {
|
|
1114
|
-
return new EditorView(parent);
|
|
1115
|
-
}
|
|
1116
|
-
constructor(parent) {
|
|
1117
|
-
this.parent = parent;
|
|
1118
|
-
this.currentContainer = null;
|
|
1119
|
-
}
|
|
1120
|
-
setContent(content, className) {
|
|
1121
|
-
const container = Dom.element('div', {
|
|
1122
|
-
class: className
|
|
1123
|
-
});
|
|
1124
|
-
container.appendChild(content);
|
|
1125
|
-
if (this.currentContainer) {
|
|
1126
|
-
this.parent.removeChild(this.currentContainer);
|
|
1127
|
-
}
|
|
1128
|
-
this.parent.appendChild(container);
|
|
1129
|
-
this.currentContainer = container;
|
|
1130
|
-
}
|
|
1131
|
-
destroy() {
|
|
1132
|
-
if (this.currentContainer) {
|
|
1133
|
-
this.parent.removeChild(this.currentContainer);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
class Editor {
|
|
1139
|
-
static create(parent, api, stepEditorClassName, stepEditorProvider, rootEditorClassName, rootEditorProvider, customSelectedStepIdProvider) {
|
|
1140
|
-
const view = EditorView.create(parent);
|
|
1141
|
-
function render(step) {
|
|
1142
|
-
const definition = api.getDefinition();
|
|
1143
|
-
let content;
|
|
1144
|
-
let className;
|
|
1145
|
-
if (step) {
|
|
1146
|
-
const stepContext = api.createStepEditorContext(step.id);
|
|
1147
|
-
content = stepEditorProvider(step, stepContext, definition, api.isReadonly());
|
|
1148
|
-
className = stepEditorClassName;
|
|
1149
|
-
}
|
|
1150
|
-
else {
|
|
1151
|
-
const rootContext = api.createRootEditorContext();
|
|
1152
|
-
content = rootEditorProvider(definition, rootContext, api.isReadonly());
|
|
1153
|
-
className = rootEditorClassName;
|
|
1154
|
-
}
|
|
1155
|
-
view.setContent(content, className);
|
|
1156
|
-
}
|
|
1157
|
-
const renderer = api.runRenderer(step => render(step), customSelectedStepIdProvider);
|
|
1158
|
-
return new Editor(view, renderer);
|
|
1159
|
-
}
|
|
1160
|
-
constructor(view, renderer) {
|
|
1161
|
-
this.view = view;
|
|
1162
|
-
this.renderer = renderer;
|
|
1163
|
-
}
|
|
1164
|
-
destroy() {
|
|
1165
|
-
this.view.destroy();
|
|
1166
|
-
this.renderer.destroy();
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
class ValidationErrorBadgeView {
|
|
1171
|
-
static create(parent, cfg) {
|
|
1172
|
-
const g = Dom.svg('g');
|
|
1173
|
-
const halfOfSize = cfg.size / 2;
|
|
1174
|
-
const circle = Dom.svg('path', {
|
|
1175
|
-
class: 'sqd-validation-error',
|
|
1176
|
-
d: `M 0 ${-halfOfSize} l ${halfOfSize} ${cfg.size} l ${-cfg.size} 0 Z`
|
|
1177
|
-
});
|
|
1178
|
-
Dom.translate(circle, halfOfSize, halfOfSize);
|
|
1179
|
-
g.appendChild(circle);
|
|
1180
|
-
const icon = Icons.appendPath(g, 'sqd-validation-error-icon-path', Icons.alert, cfg.iconSize);
|
|
1181
|
-
const offsetX = (cfg.size - cfg.iconSize) / 2;
|
|
1182
|
-
const offsetY = offsetX * 1.5;
|
|
1183
|
-
Dom.translate(icon, offsetX, offsetY);
|
|
1184
|
-
parent.appendChild(g);
|
|
1185
|
-
return new ValidationErrorBadgeView(parent, g, cfg.size, cfg.size);
|
|
1186
|
-
}
|
|
1187
|
-
constructor(parent, g, width, height) {
|
|
1188
|
-
this.parent = parent;
|
|
1189
|
-
this.g = g;
|
|
1190
|
-
this.width = width;
|
|
1191
|
-
this.height = height;
|
|
1192
|
-
}
|
|
1193
|
-
destroy() {
|
|
1194
|
-
this.parent.removeChild(this.g);
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
class ValidatorFactory {
|
|
1199
|
-
static createForStep(stepContext, view, componentContext) {
|
|
1200
|
-
return () => {
|
|
1201
|
-
if (!componentContext.validator.validateStep(stepContext.step, stepContext.parentSequence)) {
|
|
1202
|
-
return false;
|
|
1203
|
-
}
|
|
1204
|
-
if (view.haveCollapsedChildren) {
|
|
1205
|
-
let allChildrenValid = true;
|
|
1206
|
-
componentContext.definitionWalker.forEachChildren(stepContext.step, (step, _, parentSequence) => {
|
|
1207
|
-
if (!componentContext.validator.validateStep(step, parentSequence)) {
|
|
1208
|
-
allChildrenValid = false;
|
|
1209
|
-
return false;
|
|
1210
|
-
}
|
|
1211
|
-
});
|
|
1212
|
-
if (!allChildrenValid) {
|
|
1213
|
-
return false;
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
return true;
|
|
1217
|
-
};
|
|
1218
|
-
}
|
|
1219
|
-
static createForRoot(componentContext) {
|
|
1220
|
-
return () => {
|
|
1221
|
-
return componentContext.validator.validateRoot();
|
|
1222
|
-
};
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
class ValidationErrorBadge {
|
|
1227
|
-
static createForStep(parentElement, view, stepContext, componentContext, configuration) {
|
|
1228
|
-
const validator = ValidatorFactory.createForStep(stepContext, view, componentContext);
|
|
1229
|
-
return new ValidationErrorBadge(parentElement, validator, configuration);
|
|
1230
|
-
}
|
|
1231
|
-
static createForRoot(parentElement, componentContext, configuration) {
|
|
1232
|
-
const validator = ValidatorFactory.createForRoot(componentContext);
|
|
1233
|
-
return new ValidationErrorBadge(parentElement, validator, configuration);
|
|
1234
|
-
}
|
|
1235
|
-
constructor(parentElement, validator, configuration) {
|
|
1236
|
-
this.parentElement = parentElement;
|
|
1237
|
-
this.validator = validator;
|
|
1238
|
-
this.configuration = configuration;
|
|
1239
|
-
this.view = null;
|
|
1240
|
-
}
|
|
1241
|
-
update(result) {
|
|
1242
|
-
const isValid = this.validator();
|
|
1243
|
-
if (isValid) {
|
|
1244
|
-
if (this.view) {
|
|
1245
|
-
this.view.destroy();
|
|
1246
|
-
this.view = null;
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
else if (!this.view) {
|
|
1250
|
-
this.view = ValidationErrorBadgeView.create(this.parentElement, this.configuration);
|
|
1251
|
-
}
|
|
1252
|
-
return isValid && result;
|
|
1253
|
-
}
|
|
1254
|
-
resolveClick() {
|
|
1255
|
-
return null;
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
const defaultConfiguration$7 = {
|
|
1260
|
-
view: {
|
|
1261
|
-
size: 22,
|
|
1262
|
-
iconSize: 12
|
|
1263
|
-
}
|
|
1264
|
-
};
|
|
1265
|
-
class ValidationErrorBadgeExtension {
|
|
1266
|
-
static create(configuration) {
|
|
1267
|
-
return new ValidationErrorBadgeExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$7);
|
|
985
|
+
};
|
|
986
|
+
class ValidationErrorBadgeExtension {
|
|
987
|
+
static create(configuration) {
|
|
988
|
+
return new ValidationErrorBadgeExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$7);
|
|
1268
989
|
}
|
|
1269
990
|
constructor(configuration) {
|
|
1270
991
|
this.configuration = configuration;
|
|
@@ -1334,54 +1055,58 @@ class InputView {
|
|
|
1334
1055
|
}
|
|
1335
1056
|
}
|
|
1336
1057
|
|
|
1058
|
+
const EPS = 0.5; // Epsilon, a tiny offset to avoid rendering issues
|
|
1337
1059
|
class JoinView {
|
|
1338
1060
|
static createStraightJoin(parent, start, height) {
|
|
1061
|
+
const dy = Math.sign(height);
|
|
1339
1062
|
const join = Dom.svg('line', {
|
|
1340
1063
|
class: 'sqd-join',
|
|
1341
1064
|
x1: start.x,
|
|
1342
|
-
y1: start.y,
|
|
1065
|
+
y1: start.y - EPS * dy,
|
|
1343
1066
|
x2: start.x,
|
|
1344
|
-
y2: start.y + height
|
|
1067
|
+
y2: start.y + height + EPS * dy
|
|
1345
1068
|
});
|
|
1346
1069
|
parent.insertBefore(join, parent.firstChild);
|
|
1347
1070
|
}
|
|
1348
1071
|
static createJoins(parent, start, targets) {
|
|
1349
1072
|
const firstTarget = targets[0];
|
|
1350
1073
|
const h = Math.abs(firstTarget.y - start.y) / 2; // half height
|
|
1351
|
-
const
|
|
1074
|
+
const dy = Math.sign(firstTarget.y - start.y); // direction y
|
|
1352
1075
|
switch (targets.length) {
|
|
1353
1076
|
case 1:
|
|
1354
1077
|
if (start.x === targets[0].x) {
|
|
1355
|
-
JoinView.createStraightJoin(parent, start, firstTarget.y *
|
|
1078
|
+
JoinView.createStraightJoin(parent, start, firstTarget.y * dy);
|
|
1356
1079
|
}
|
|
1357
1080
|
else {
|
|
1358
|
-
appendCurvedJoins(parent, start, targets, h,
|
|
1081
|
+
appendCurvedJoins(parent, start, targets, h, dy);
|
|
1359
1082
|
}
|
|
1360
1083
|
break;
|
|
1361
1084
|
case 2:
|
|
1362
|
-
appendCurvedJoins(parent, start, targets, h,
|
|
1085
|
+
appendCurvedJoins(parent, start, targets, h, dy);
|
|
1363
1086
|
break;
|
|
1364
1087
|
default:
|
|
1365
1088
|
{
|
|
1366
1089
|
const f = targets[0]; // first
|
|
1367
1090
|
const l = targets[targets.length - 1]; // last
|
|
1368
|
-
|
|
1369
|
-
|
|
1091
|
+
const eps = EPS * dy;
|
|
1092
|
+
appendJoin(parent, `M ${f.x} ${f.y + eps} l 0 ${-eps} q ${h * 0.3} ${h * -dy * 0.8} ${h} ${h * -dy} ` +
|
|
1093
|
+
`l ${l.x - f.x - h * 2} 0 q ${h * 0.8} ${-h * -dy * 0.3} ${h} ${-h * -dy} l 0 ${eps}`);
|
|
1370
1094
|
for (let i = 1; i < targets.length - 1; i++) {
|
|
1371
|
-
JoinView.createStraightJoin(parent, targets[i], h * -
|
|
1095
|
+
JoinView.createStraightJoin(parent, targets[i], h * -dy);
|
|
1372
1096
|
}
|
|
1373
|
-
JoinView.createStraightJoin(parent, start, h *
|
|
1097
|
+
JoinView.createStraightJoin(parent, start, h * dy);
|
|
1374
1098
|
}
|
|
1375
1099
|
break;
|
|
1376
1100
|
}
|
|
1377
1101
|
}
|
|
1378
1102
|
}
|
|
1379
|
-
function appendCurvedJoins(parent, start, targets, h,
|
|
1103
|
+
function appendCurvedJoins(parent, start, targets, h, dy) {
|
|
1104
|
+
const eps = EPS * dy;
|
|
1380
1105
|
for (const target of targets) {
|
|
1381
|
-
const l = Math.abs(target.x - start.x) - h * 2; // line
|
|
1382
|
-
const
|
|
1383
|
-
appendJoin(parent, `M ${start.x} ${start.y} q ${
|
|
1384
|
-
`l ${
|
|
1106
|
+
const l = Math.abs(target.x - start.x) - h * 2; // straight line length
|
|
1107
|
+
const dx = Math.sign(target.x - start.x); // direction x
|
|
1108
|
+
appendJoin(parent, `M ${start.x} ${start.y - eps} l 0 ${eps} q ${dx * h * 0.3} ${dy * h * 0.8} ${dx * h} ${dy * h} ` +
|
|
1109
|
+
`l ${dx * l} 0 q ${dx * h * 0.7} ${dy * h * 0.2} ${dx * h} ${dy * h} l 0 ${eps}`);
|
|
1385
1110
|
}
|
|
1386
1111
|
}
|
|
1387
1112
|
function appendJoin(parent, d) {
|
|
@@ -1564,6 +1289,20 @@ class DefaultSequenceComponent {
|
|
|
1564
1289
|
}
|
|
1565
1290
|
}
|
|
1566
1291
|
|
|
1292
|
+
exports.ClickCommandType = void 0;
|
|
1293
|
+
(function (ClickCommandType) {
|
|
1294
|
+
ClickCommandType[ClickCommandType["selectStep"] = 1] = "selectStep";
|
|
1295
|
+
ClickCommandType[ClickCommandType["rerenderStep"] = 2] = "rerenderStep";
|
|
1296
|
+
ClickCommandType[ClickCommandType["openFolder"] = 3] = "openFolder";
|
|
1297
|
+
ClickCommandType[ClickCommandType["triggerCustomAction"] = 4] = "triggerCustomAction";
|
|
1298
|
+
})(exports.ClickCommandType || (exports.ClickCommandType = {}));
|
|
1299
|
+
exports.PlaceholderDirection = void 0;
|
|
1300
|
+
(function (PlaceholderDirection) {
|
|
1301
|
+
PlaceholderDirection[PlaceholderDirection["none"] = 0] = "none";
|
|
1302
|
+
PlaceholderDirection[PlaceholderDirection["in"] = 1] = "in";
|
|
1303
|
+
PlaceholderDirection[PlaceholderDirection["out"] = 2] = "out";
|
|
1304
|
+
})(exports.PlaceholderDirection || (exports.PlaceholderDirection = {}));
|
|
1305
|
+
|
|
1567
1306
|
class StartStopRootComponentView {
|
|
1568
1307
|
static create(parent, sequence, parentPlaceIndicator, context, cfg) {
|
|
1569
1308
|
const g = Dom.svg('g', {
|
|
@@ -2042,28 +1781,106 @@ class DefaultViewportControllerExtension {
|
|
|
2042
1781
|
}
|
|
2043
1782
|
}
|
|
2044
1783
|
|
|
2045
|
-
class
|
|
2046
|
-
static create(
|
|
2047
|
-
const
|
|
2048
|
-
|
|
2049
|
-
const extension = services.steps[i];
|
|
2050
|
-
dict[extension.componentType] = extension;
|
|
2051
|
-
}
|
|
2052
|
-
return new StepExtensionResolver(dict);
|
|
1784
|
+
class StepComponent {
|
|
1785
|
+
static create(view, stepContext, componentContext) {
|
|
1786
|
+
const badges = Badges.createForStep(stepContext, view, componentContext);
|
|
1787
|
+
return new StepComponent(view, stepContext.step, stepContext.parentSequence, view.hasOutput, badges);
|
|
2053
1788
|
}
|
|
2054
|
-
constructor(
|
|
2055
|
-
this.
|
|
1789
|
+
constructor(view, step, parentSequence, hasOutput, badges) {
|
|
1790
|
+
this.view = view;
|
|
1791
|
+
this.step = step;
|
|
1792
|
+
this.parentSequence = parentSequence;
|
|
1793
|
+
this.hasOutput = hasOutput;
|
|
1794
|
+
this.badges = badges;
|
|
2056
1795
|
}
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
throw new Error(`Not supported component type: ${componentType}`);
|
|
1796
|
+
findById(stepId) {
|
|
1797
|
+
if (this.step.id === stepId) {
|
|
1798
|
+
return this;
|
|
2061
1799
|
}
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
1800
|
+
if (this.view.sequenceComponents) {
|
|
1801
|
+
for (const component of this.view.sequenceComponents) {
|
|
1802
|
+
const result = component.findById(stepId);
|
|
1803
|
+
if (result) {
|
|
1804
|
+
return result;
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
return null;
|
|
1809
|
+
}
|
|
1810
|
+
resolveClick(click) {
|
|
1811
|
+
if (this.view.sequenceComponents) {
|
|
1812
|
+
for (const component of this.view.sequenceComponents) {
|
|
1813
|
+
const result = component.resolveClick(click);
|
|
1814
|
+
if (result) {
|
|
1815
|
+
return result;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
const badgeResult = this.badges.resolveClick(click);
|
|
1820
|
+
if (badgeResult) {
|
|
1821
|
+
return badgeResult;
|
|
1822
|
+
}
|
|
1823
|
+
const viewResult = this.view.resolveClick(click);
|
|
1824
|
+
if (viewResult) {
|
|
1825
|
+
return viewResult === true
|
|
1826
|
+
? {
|
|
1827
|
+
type: exports.ClickCommandType.selectStep,
|
|
1828
|
+
component: this
|
|
1829
|
+
}
|
|
1830
|
+
: viewResult;
|
|
1831
|
+
}
|
|
1832
|
+
return null;
|
|
1833
|
+
}
|
|
1834
|
+
resolvePlaceholders(skipComponent, result) {
|
|
1835
|
+
if (skipComponent !== this) {
|
|
1836
|
+
if (this.view.sequenceComponents) {
|
|
1837
|
+
this.view.sequenceComponents.forEach(component => component.resolvePlaceholders(skipComponent, result));
|
|
1838
|
+
}
|
|
1839
|
+
if (this.view.placeholders) {
|
|
1840
|
+
this.view.placeholders.forEach(ph => result.placeholders.push(ph));
|
|
1841
|
+
}
|
|
1842
|
+
result.components.push(this);
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
setIsDragging(isDragging) {
|
|
1846
|
+
this.view.setIsDragging(isDragging);
|
|
1847
|
+
}
|
|
1848
|
+
setIsSelected(isSelected) {
|
|
1849
|
+
this.view.setIsSelected(isSelected);
|
|
1850
|
+
}
|
|
1851
|
+
setIsDisabled(isDisabled) {
|
|
1852
|
+
this.view.setIsDisabled(isDisabled);
|
|
1853
|
+
}
|
|
1854
|
+
updateBadges(result) {
|
|
1855
|
+
if (this.view.sequenceComponents) {
|
|
1856
|
+
this.view.sequenceComponents.forEach(component => component.updateBadges(result));
|
|
1857
|
+
}
|
|
1858
|
+
this.badges.update(result);
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
class StepExtensionResolver {
|
|
1863
|
+
static create(services) {
|
|
1864
|
+
const dict = {};
|
|
1865
|
+
for (let i = services.steps.length - 1; i >= 0; i--) {
|
|
1866
|
+
const extension = services.steps[i];
|
|
1867
|
+
dict[extension.componentType] = extension;
|
|
1868
|
+
}
|
|
1869
|
+
return new StepExtensionResolver(dict);
|
|
1870
|
+
}
|
|
1871
|
+
constructor(dict) {
|
|
1872
|
+
this.dict = dict;
|
|
1873
|
+
}
|
|
1874
|
+
resolve(componentType) {
|
|
1875
|
+
const extension = this.dict[componentType];
|
|
1876
|
+
if (!extension) {
|
|
1877
|
+
throw new Error(`Not supported component type: ${componentType}`);
|
|
1878
|
+
}
|
|
1879
|
+
return extension;
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
class RectPlaceholderView {
|
|
2067
1884
|
static create(parent, width, height, radius, iconSize, direction) {
|
|
2068
1885
|
const g = Dom.svg('g', {
|
|
2069
1886
|
visibility: 'hidden',
|
|
@@ -2122,63 +1939,414 @@ class RectPlaceholder {
|
|
|
2122
1939
|
resolveClick() {
|
|
2123
1940
|
return null;
|
|
2124
1941
|
}
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
|
-
class DefaultRegionView {
|
|
2128
|
-
static create(parent, widths, height) {
|
|
2129
|
-
const totalWidth = widths.reduce((result, width) => result + width, 0);
|
|
2130
|
-
const lines = [
|
|
2131
|
-
drawLine(parent, 0, 0, totalWidth, 0),
|
|
2132
|
-
drawLine(parent, 0, 0, 0, height),
|
|
2133
|
-
drawLine(parent, 0, height, totalWidth, height),
|
|
2134
|
-
drawLine(parent, totalWidth, 0, totalWidth, height)
|
|
2135
|
-
];
|
|
2136
|
-
let offsetX = widths[0];
|
|
2137
|
-
for (let i = 1; i < widths.length; i++) {
|
|
2138
|
-
lines.push(drawLine(parent, offsetX, 0, offsetX, height));
|
|
2139
|
-
offsetX += widths[i];
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
class DefaultRegionView {
|
|
1945
|
+
static create(parent, widths, height) {
|
|
1946
|
+
const totalWidth = widths.reduce((result, width) => result + width, 0);
|
|
1947
|
+
const lines = [
|
|
1948
|
+
drawLine(parent, 0, 0, totalWidth, 0),
|
|
1949
|
+
drawLine(parent, 0, 0, 0, height),
|
|
1950
|
+
drawLine(parent, 0, height, totalWidth, height),
|
|
1951
|
+
drawLine(parent, totalWidth, 0, totalWidth, height)
|
|
1952
|
+
];
|
|
1953
|
+
let offsetX = widths[0];
|
|
1954
|
+
for (let i = 1; i < widths.length; i++) {
|
|
1955
|
+
lines.push(drawLine(parent, offsetX, 0, offsetX, height));
|
|
1956
|
+
offsetX += widths[i];
|
|
1957
|
+
}
|
|
1958
|
+
return new DefaultRegionView(lines, totalWidth, height);
|
|
1959
|
+
}
|
|
1960
|
+
constructor(lines, width, height) {
|
|
1961
|
+
this.lines = lines;
|
|
1962
|
+
this.width = width;
|
|
1963
|
+
this.height = height;
|
|
1964
|
+
}
|
|
1965
|
+
getClientPosition() {
|
|
1966
|
+
return getAbsolutePosition(this.lines[0]);
|
|
1967
|
+
}
|
|
1968
|
+
resolveClick(click) {
|
|
1969
|
+
const regionPosition = this.getClientPosition();
|
|
1970
|
+
const d = click.position.subtract(regionPosition);
|
|
1971
|
+
if (d.x >= 0 && d.y >= 0 && d.x < this.width * click.scale && d.y < this.height * click.scale) {
|
|
1972
|
+
return true;
|
|
1973
|
+
}
|
|
1974
|
+
return null;
|
|
1975
|
+
}
|
|
1976
|
+
setIsSelected(isSelected) {
|
|
1977
|
+
this.lines.forEach(region => {
|
|
1978
|
+
Dom.toggleClass(region, isSelected, 'sqd-selected');
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
function drawLine(parent, x1, y1, x2, y2) {
|
|
1983
|
+
const line = Dom.svg('line', {
|
|
1984
|
+
class: 'sqd-region',
|
|
1985
|
+
x1,
|
|
1986
|
+
y1,
|
|
1987
|
+
x2,
|
|
1988
|
+
y2
|
|
1989
|
+
});
|
|
1990
|
+
parent.insertBefore(line, parent.firstChild);
|
|
1991
|
+
return line;
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
class DefaultRegionComponentViewExtension {
|
|
1995
|
+
create(parentElement, componentClassName, stepContext, _, contentFactory) {
|
|
1996
|
+
const g = ComponentDom.stepG(componentClassName, stepContext.step.type, stepContext.step.id);
|
|
1997
|
+
parentElement.appendChild(g);
|
|
1998
|
+
return contentFactory(g, DefaultRegionView.create);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
class DefaultViewportControllerDesignerExtension {
|
|
2003
|
+
static create(configuration) {
|
|
2004
|
+
return new DefaultViewportControllerDesignerExtension(DefaultViewportControllerExtension.create(configuration));
|
|
2005
|
+
}
|
|
2006
|
+
constructor(viewportController) {
|
|
2007
|
+
this.viewportController = viewportController;
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
class LineGrid {
|
|
2012
|
+
static create(size) {
|
|
2013
|
+
const path = Dom.svg('path', {
|
|
2014
|
+
class: 'sqd-line-grid-path',
|
|
2015
|
+
fill: 'none'
|
|
2016
|
+
});
|
|
2017
|
+
return new LineGrid(size, path);
|
|
2018
|
+
}
|
|
2019
|
+
constructor(size, element) {
|
|
2020
|
+
this.size = size;
|
|
2021
|
+
this.element = element;
|
|
2022
|
+
}
|
|
2023
|
+
setScale(_, scaledSize) {
|
|
2024
|
+
Dom.attrs(this.element, {
|
|
2025
|
+
d: `M ${scaledSize.x} 0 L 0 0 0 ${scaledSize.y}`
|
|
2026
|
+
});
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
const defaultConfiguration$4 = {
|
|
2031
|
+
gridSizeX: 48,
|
|
2032
|
+
gridSizeY: 48
|
|
2033
|
+
};
|
|
2034
|
+
class LineGridExtension {
|
|
2035
|
+
static create(configuration) {
|
|
2036
|
+
return new LineGridExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$4);
|
|
2037
|
+
}
|
|
2038
|
+
constructor(configuration) {
|
|
2039
|
+
this.configuration = configuration;
|
|
2040
|
+
}
|
|
2041
|
+
create() {
|
|
2042
|
+
const size = new Vector(this.configuration.gridSizeX, this.configuration.gridSizeY);
|
|
2043
|
+
return LineGrid.create(size);
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
class LineGridDesignerExtension {
|
|
2048
|
+
static create(configuration) {
|
|
2049
|
+
const grid = LineGridExtension.create(configuration);
|
|
2050
|
+
return new LineGridDesignerExtension(grid);
|
|
2051
|
+
}
|
|
2052
|
+
constructor(grid) {
|
|
2053
|
+
this.grid = grid;
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
class StartStopRootComponentDesignerExtension {
|
|
2058
|
+
static create(configuration) {
|
|
2059
|
+
return new StartStopRootComponentDesignerExtension(StartStopRootComponentExtension.create(configuration));
|
|
2060
|
+
}
|
|
2061
|
+
constructor(rootComponent) {
|
|
2062
|
+
this.rootComponent = rootComponent;
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
const defaultConfiguration$3 = {
|
|
2067
|
+
view: {
|
|
2068
|
+
paddingTop: 20,
|
|
2069
|
+
paddingX: 20,
|
|
2070
|
+
inputSize: 18,
|
|
2071
|
+
inputIconSize: 14,
|
|
2072
|
+
label: {
|
|
2073
|
+
height: 22,
|
|
2074
|
+
paddingX: 10,
|
|
2075
|
+
minWidth: 50,
|
|
2076
|
+
radius: 10
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
};
|
|
2080
|
+
class ContainerStepExtension {
|
|
2081
|
+
static create(configuration) {
|
|
2082
|
+
return new ContainerStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$3);
|
|
2083
|
+
}
|
|
2084
|
+
constructor(configuration) {
|
|
2085
|
+
this.configuration = configuration;
|
|
2086
|
+
this.componentType = 'container';
|
|
2087
|
+
this.createComponentView = createContainerStepComponentViewFactory(this.configuration.view);
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
const defaultConfiguration$2 = {
|
|
2092
|
+
view: {
|
|
2093
|
+
minContainerWidth: 40,
|
|
2094
|
+
paddingX: 20,
|
|
2095
|
+
paddingTop: 20,
|
|
2096
|
+
connectionHeight: 16,
|
|
2097
|
+
inputSize: 18,
|
|
2098
|
+
inputIconSize: 14,
|
|
2099
|
+
branchNameLabel: {
|
|
2100
|
+
height: 22,
|
|
2101
|
+
paddingX: 10,
|
|
2102
|
+
minWidth: 50,
|
|
2103
|
+
radius: 10
|
|
2104
|
+
},
|
|
2105
|
+
nameLabel: {
|
|
2106
|
+
height: 22,
|
|
2107
|
+
paddingX: 10,
|
|
2108
|
+
minWidth: 50,
|
|
2109
|
+
radius: 10
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
};
|
|
2113
|
+
class SwitchStepExtension {
|
|
2114
|
+
static create(configuration) {
|
|
2115
|
+
return new SwitchStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$2);
|
|
2116
|
+
}
|
|
2117
|
+
constructor(configuration) {
|
|
2118
|
+
this.configuration = configuration;
|
|
2119
|
+
this.componentType = 'switch';
|
|
2120
|
+
this.createComponentView = createSwitchStepComponentViewFactory(this.configuration.view);
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
const defaultConfiguration$1 = {
|
|
2125
|
+
view: {
|
|
2126
|
+
paddingLeft: 12,
|
|
2127
|
+
paddingRight: 12,
|
|
2128
|
+
paddingY: 10,
|
|
2129
|
+
textMarginLeft: 12,
|
|
2130
|
+
minTextWidth: 70,
|
|
2131
|
+
iconSize: 22,
|
|
2132
|
+
radius: 5,
|
|
2133
|
+
inputSize: 14,
|
|
2134
|
+
outputSize: 10
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2137
|
+
class TaskStepExtension {
|
|
2138
|
+
static create(configuration) {
|
|
2139
|
+
return new TaskStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$1);
|
|
2140
|
+
}
|
|
2141
|
+
constructor(configuration) {
|
|
2142
|
+
this.configuration = configuration;
|
|
2143
|
+
this.componentType = 'task';
|
|
2144
|
+
this.createComponentView = createTaskStepComponentViewFactory(false, this.configuration.view);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
class StepsDesignerExtension {
|
|
2149
|
+
static create(configuration) {
|
|
2150
|
+
const steps = [];
|
|
2151
|
+
if (configuration.container) {
|
|
2152
|
+
steps.push(ContainerStepExtension.create(configuration.container));
|
|
2153
|
+
}
|
|
2154
|
+
if (configuration.switch) {
|
|
2155
|
+
steps.push(SwitchStepExtension.create(configuration.switch));
|
|
2156
|
+
}
|
|
2157
|
+
if (configuration.task) {
|
|
2158
|
+
steps.push(TaskStepExtension.create(configuration.task));
|
|
2159
|
+
}
|
|
2160
|
+
return new StepsDesignerExtension(steps);
|
|
2161
|
+
}
|
|
2162
|
+
constructor(steps) {
|
|
2163
|
+
this.steps = steps;
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
class DefinitionValidator {
|
|
2168
|
+
constructor(configuration, state) {
|
|
2169
|
+
this.configuration = configuration;
|
|
2170
|
+
this.state = state;
|
|
2171
|
+
}
|
|
2172
|
+
validateStep(step, parentSequence) {
|
|
2173
|
+
var _a;
|
|
2174
|
+
if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.step) {
|
|
2175
|
+
return this.configuration.step(step, parentSequence, this.state.definition);
|
|
2176
|
+
}
|
|
2177
|
+
return true;
|
|
2178
|
+
}
|
|
2179
|
+
validateRoot() {
|
|
2180
|
+
var _a;
|
|
2181
|
+
if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.root) {
|
|
2182
|
+
return this.configuration.root(this.state.definition);
|
|
2183
|
+
}
|
|
2184
|
+
return true;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
class IconProvider {
|
|
2189
|
+
constructor(configuration) {
|
|
2190
|
+
this.configuration = configuration;
|
|
2191
|
+
}
|
|
2192
|
+
getIconUrl(step) {
|
|
2193
|
+
if (this.configuration.iconUrlProvider) {
|
|
2194
|
+
return this.configuration.iconUrlProvider(step.componentType, step.type);
|
|
2195
|
+
}
|
|
2196
|
+
return null;
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
class StepComponentViewContextFactory {
|
|
2201
|
+
static create(stepContext, componentContext) {
|
|
2202
|
+
const preferenceKeyPrefix = stepContext.step.id + ':';
|
|
2203
|
+
return {
|
|
2204
|
+
i18n: componentContext.i18n,
|
|
2205
|
+
getStepIconUrl: () => componentContext.iconProvider.getIconUrl(stepContext.step),
|
|
2206
|
+
getStepName: () => componentContext.i18n(`step.${stepContext.step.type}.name`, stepContext.step.name),
|
|
2207
|
+
createSequenceComponent: (parentElement, sequence) => {
|
|
2208
|
+
const sequenceContext = {
|
|
2209
|
+
sequence,
|
|
2210
|
+
depth: stepContext.depth + 1,
|
|
2211
|
+
isInputConnected: true,
|
|
2212
|
+
isOutputConnected: stepContext.isOutputConnected,
|
|
2213
|
+
isPreview: stepContext.isPreview
|
|
2214
|
+
};
|
|
2215
|
+
return componentContext.services.sequenceComponent.create(parentElement, sequenceContext, componentContext);
|
|
2216
|
+
},
|
|
2217
|
+
createRegionComponentView(parentElement, componentClassName, contentFactory) {
|
|
2218
|
+
return componentContext.services.regionComponentView.create(parentElement, componentClassName, stepContext, this, contentFactory);
|
|
2219
|
+
},
|
|
2220
|
+
createPlaceholderForArea: componentContext.services.placeholder.createForArea.bind(componentContext.services.placeholder),
|
|
2221
|
+
getPreference: (key) => componentContext.preferenceStorage.getItem(preferenceKeyPrefix + key),
|
|
2222
|
+
setPreference: (key, value) => componentContext.preferenceStorage.setItem(preferenceKeyPrefix + key, value)
|
|
2223
|
+
};
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
class StepComponentFactory {
|
|
2228
|
+
constructor(stepExtensionResolver) {
|
|
2229
|
+
this.stepExtensionResolver = stepExtensionResolver;
|
|
2230
|
+
}
|
|
2231
|
+
create(parentElement, stepContext, componentContext) {
|
|
2232
|
+
const viewContext = StepComponentViewContextFactory.create(stepContext, componentContext);
|
|
2233
|
+
const extension = this.stepExtensionResolver.resolve(stepContext.step.componentType);
|
|
2234
|
+
const view = extension.createComponentView(parentElement, stepContext, viewContext);
|
|
2235
|
+
const wrappedView = componentContext.services.stepComponentViewWrapper.wrap(view, stepContext);
|
|
2236
|
+
return StepComponent.create(wrappedView, stepContext, componentContext);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
class ComponentContext {
|
|
2241
|
+
static create(configuration, state, stepExtensionResolver, definitionWalker, preferenceStorage, placeholderController, i18n, services) {
|
|
2242
|
+
const validator = new DefinitionValidator(configuration.validator, state);
|
|
2243
|
+
const iconProvider = new IconProvider(configuration.steps);
|
|
2244
|
+
const stepComponentFactory = new StepComponentFactory(stepExtensionResolver);
|
|
2245
|
+
return new ComponentContext(configuration.shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n);
|
|
2246
|
+
}
|
|
2247
|
+
constructor(shadowRoot, validator, iconProvider, placeholderController, stepComponentFactory, definitionWalker, services, preferenceStorage, i18n) {
|
|
2248
|
+
this.shadowRoot = shadowRoot;
|
|
2249
|
+
this.validator = validator;
|
|
2250
|
+
this.iconProvider = iconProvider;
|
|
2251
|
+
this.placeholderController = placeholderController;
|
|
2252
|
+
this.stepComponentFactory = stepComponentFactory;
|
|
2253
|
+
this.definitionWalker = definitionWalker;
|
|
2254
|
+
this.services = services;
|
|
2255
|
+
this.preferenceStorage = preferenceStorage;
|
|
2256
|
+
this.i18n = i18n;
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
class CustomActionController {
|
|
2261
|
+
constructor(configuration, state, stateModifier) {
|
|
2262
|
+
this.configuration = configuration;
|
|
2263
|
+
this.state = state;
|
|
2264
|
+
this.stateModifier = stateModifier;
|
|
2265
|
+
}
|
|
2266
|
+
trigger(action, step, sequence) {
|
|
2267
|
+
const handler = this.configuration.customActionHandler;
|
|
2268
|
+
if (!handler) {
|
|
2269
|
+
console.warn(`Custom action handler is not defined (action type: ${action.type})`);
|
|
2270
|
+
return;
|
|
2271
|
+
}
|
|
2272
|
+
const context = this.createCustomActionHandlerContext();
|
|
2273
|
+
handler(action, step, sequence, context);
|
|
2274
|
+
}
|
|
2275
|
+
createCustomActionHandlerContext() {
|
|
2276
|
+
return {
|
|
2277
|
+
notifyStepNameChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepNameChanged, stepId, false),
|
|
2278
|
+
notifyStepPropertiesChanged: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepPropertyChanged, stepId, false),
|
|
2279
|
+
notifyStepInserted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepInserted, stepId, true),
|
|
2280
|
+
notifyStepMoved: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepMoved, stepId, true),
|
|
2281
|
+
notifyStepDeleted: (stepId) => this.notifyStepChanged(exports.DefinitionChangeType.stepDeleted, stepId, true)
|
|
2282
|
+
};
|
|
2283
|
+
}
|
|
2284
|
+
notifyStepChanged(changeType, stepId, updateDependencies) {
|
|
2285
|
+
if (!stepId) {
|
|
2286
|
+
throw new Error('Step id is empty');
|
|
2287
|
+
}
|
|
2288
|
+
this.state.notifyDefinitionChanged(changeType, stepId);
|
|
2289
|
+
if (updateDependencies) {
|
|
2290
|
+
this.stateModifier.updateDependencies();
|
|
2140
2291
|
}
|
|
2141
|
-
return new DefaultRegionView(lines, totalWidth, height);
|
|
2142
2292
|
}
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
class EditorView {
|
|
2296
|
+
static create(parent) {
|
|
2297
|
+
return new EditorView(parent);
|
|
2147
2298
|
}
|
|
2148
|
-
|
|
2149
|
-
|
|
2299
|
+
constructor(parent) {
|
|
2300
|
+
this.parent = parent;
|
|
2301
|
+
this.currentContainer = null;
|
|
2150
2302
|
}
|
|
2151
|
-
|
|
2152
|
-
const
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2303
|
+
setContent(content, className) {
|
|
2304
|
+
const container = Dom.element('div', {
|
|
2305
|
+
class: className
|
|
2306
|
+
});
|
|
2307
|
+
container.appendChild(content);
|
|
2308
|
+
if (this.currentContainer) {
|
|
2309
|
+
this.parent.removeChild(this.currentContainer);
|
|
2156
2310
|
}
|
|
2157
|
-
|
|
2311
|
+
this.parent.appendChild(container);
|
|
2312
|
+
this.currentContainer = container;
|
|
2158
2313
|
}
|
|
2159
|
-
|
|
2160
|
-
this.
|
|
2161
|
-
|
|
2162
|
-
}
|
|
2314
|
+
destroy() {
|
|
2315
|
+
if (this.currentContainer) {
|
|
2316
|
+
this.parent.removeChild(this.currentContainer);
|
|
2317
|
+
}
|
|
2163
2318
|
}
|
|
2164
|
-
}
|
|
2165
|
-
function drawLine(parent, x1, y1, x2, y2) {
|
|
2166
|
-
const line = Dom.svg('line', {
|
|
2167
|
-
class: 'sqd-region',
|
|
2168
|
-
x1,
|
|
2169
|
-
y1,
|
|
2170
|
-
x2,
|
|
2171
|
-
y2
|
|
2172
|
-
});
|
|
2173
|
-
parent.insertBefore(line, parent.firstChild);
|
|
2174
|
-
return line;
|
|
2175
2319
|
}
|
|
2176
2320
|
|
|
2177
|
-
class
|
|
2178
|
-
create(
|
|
2179
|
-
const
|
|
2180
|
-
|
|
2181
|
-
|
|
2321
|
+
class Editor {
|
|
2322
|
+
static create(parent, api, stepEditorClassName, stepEditorProvider, rootEditorClassName, rootEditorProvider, customSelectedStepIdProvider) {
|
|
2323
|
+
const view = EditorView.create(parent);
|
|
2324
|
+
function render(step) {
|
|
2325
|
+
const definition = api.getDefinition();
|
|
2326
|
+
let content;
|
|
2327
|
+
let className;
|
|
2328
|
+
if (step) {
|
|
2329
|
+
const stepContext = api.createStepEditorContext(step.id);
|
|
2330
|
+
content = stepEditorProvider(step, stepContext, definition, api.isReadonly());
|
|
2331
|
+
className = stepEditorClassName;
|
|
2332
|
+
}
|
|
2333
|
+
else {
|
|
2334
|
+
const rootContext = api.createRootEditorContext();
|
|
2335
|
+
content = rootEditorProvider(definition, rootContext, api.isReadonly());
|
|
2336
|
+
className = rootEditorClassName;
|
|
2337
|
+
}
|
|
2338
|
+
view.setContent(content, className);
|
|
2339
|
+
}
|
|
2340
|
+
const renderer = api.runRenderer(step => render(step), customSelectedStepIdProvider);
|
|
2341
|
+
return new Editor(view, renderer);
|
|
2342
|
+
}
|
|
2343
|
+
constructor(view, renderer) {
|
|
2344
|
+
this.view = view;
|
|
2345
|
+
this.renderer = renderer;
|
|
2346
|
+
}
|
|
2347
|
+
destroy() {
|
|
2348
|
+
this.view.destroy();
|
|
2349
|
+
this.renderer.destroy();
|
|
2182
2350
|
}
|
|
2183
2351
|
}
|
|
2184
2352
|
|
|
@@ -2227,6 +2395,8 @@ class BehaviorController {
|
|
|
2227
2395
|
constructor(dom, shadowRoot) {
|
|
2228
2396
|
this.dom = dom;
|
|
2229
2397
|
this.shadowRoot = shadowRoot;
|
|
2398
|
+
this.previousEndToken = null;
|
|
2399
|
+
this.state = null;
|
|
2230
2400
|
this.onMouseMove = (e) => {
|
|
2231
2401
|
e.preventDefault();
|
|
2232
2402
|
e.stopPropagation();
|
|
@@ -2298,7 +2468,7 @@ class BehaviorController {
|
|
|
2298
2468
|
const delta = this.state.startPosition.subtract(position);
|
|
2299
2469
|
const newBehavior = this.state.behavior.onMove(delta);
|
|
2300
2470
|
if (newBehavior) {
|
|
2301
|
-
this.state.behavior.onEnd(true, null);
|
|
2471
|
+
this.state.behavior.onEnd(true, null, null);
|
|
2302
2472
|
this.state.behavior = newBehavior;
|
|
2303
2473
|
this.state.startPosition = position;
|
|
2304
2474
|
this.state.behavior.onStart(this.state.startPosition);
|
|
@@ -2312,8 +2482,9 @@ class BehaviorController {
|
|
|
2312
2482
|
this.unbind(this.shadowRoot);
|
|
2313
2483
|
}
|
|
2314
2484
|
this.unbind(window);
|
|
2315
|
-
this.state.behavior.onEnd(interrupt, element);
|
|
2316
|
-
this.state =
|
|
2485
|
+
const endToken = this.state.behavior.onEnd(interrupt, element, this.previousEndToken);
|
|
2486
|
+
this.state = null;
|
|
2487
|
+
this.previousEndToken = endToken || null;
|
|
2317
2488
|
}
|
|
2318
2489
|
}
|
|
2319
2490
|
|
|
@@ -2989,9 +3160,11 @@ class SelectStepBehavior {
|
|
|
2989
3160
|
}
|
|
2990
3161
|
}
|
|
2991
3162
|
onEnd(interrupt) {
|
|
2992
|
-
if (
|
|
2993
|
-
|
|
3163
|
+
if (interrupt) {
|
|
3164
|
+
return;
|
|
2994
3165
|
}
|
|
3166
|
+
this.stateModifier.trySelectStep(this.pressedStepComponent.step, this.pressedStepComponent.parentSequence);
|
|
3167
|
+
return new SelectStepBehaviorEndToken(this.pressedStepComponent.step.id, Date.now());
|
|
2995
3168
|
}
|
|
2996
3169
|
}
|
|
2997
3170
|
|
|
@@ -3304,10 +3477,7 @@ class PinchToZoomController {
|
|
|
3304
3477
|
const zoomRealPoint = zoomPoint
|
|
3305
3478
|
.divideByScalar(this.state.lastViewport.scale)
|
|
3306
3479
|
.subtract(this.state.lastViewport.position.divideByScalar(this.state.lastViewport.scale));
|
|
3307
|
-
const position = zoomRealPoint
|
|
3308
|
-
.multiplyByScalar(-scale)
|
|
3309
|
-
.add(zoomPoint)
|
|
3310
|
-
.add(deltaCenterPoint.divideByScalar(this.state.lastViewport.scale));
|
|
3480
|
+
const position = zoomRealPoint.multiplyByScalar(-scale).add(zoomPoint).add(deltaCenterPoint);
|
|
3311
3481
|
const newViewport = {
|
|
3312
3482
|
position,
|
|
3313
3483
|
scale
|
|
@@ -3360,13 +3530,14 @@ class Workspace {
|
|
|
3360
3530
|
var _a;
|
|
3361
3531
|
const view = WorkspaceView.create(parent, designerContext.componentContext);
|
|
3362
3532
|
const clickBehaviorResolver = new ClickBehaviorResolver(designerContext);
|
|
3533
|
+
const clickBehaviorWrapper = designerContext.services.clickBehaviorWrapperExtension.create(designerContext.customActionController);
|
|
3363
3534
|
const wheelController = designerContext.services.wheelController.create(api.viewport, api.workspace);
|
|
3364
3535
|
const pinchToZoomController = PinchToZoomController.create(api.workspace, api.viewport, api.shadowRoot);
|
|
3365
3536
|
const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
|
|
3366
3537
|
? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
|
|
3367
3538
|
: undefined);
|
|
3368
3539
|
const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
|
|
3369
|
-
const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, api.viewport, designerContext.services);
|
|
3540
|
+
const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, api.viewport, designerContext.services);
|
|
3370
3541
|
setTimeout(() => {
|
|
3371
3542
|
workspace.updateRootComponent();
|
|
3372
3543
|
api.viewport.resetViewport();
|
|
@@ -3382,7 +3553,7 @@ class Workspace {
|
|
|
3382
3553
|
view.bindContextMenu(workspace.onContextMenu);
|
|
3383
3554
|
return workspace;
|
|
3384
3555
|
}
|
|
3385
|
-
constructor(view, definitionWalker, state, behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, viewportApi, services) {
|
|
3556
|
+
constructor(view, definitionWalker, state, behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, viewportApi, services) {
|
|
3386
3557
|
this.view = view;
|
|
3387
3558
|
this.definitionWalker = definitionWalker;
|
|
3388
3559
|
this.state = state;
|
|
@@ -3391,6 +3562,7 @@ class Workspace {
|
|
|
3391
3562
|
this.pinchToZoomController = pinchToZoomController;
|
|
3392
3563
|
this.contextMenuController = contextMenuController;
|
|
3393
3564
|
this.clickBehaviorResolver = clickBehaviorResolver;
|
|
3565
|
+
this.clickBehaviorWrapper = clickBehaviorWrapper;
|
|
3394
3566
|
this.viewportApi = viewportApi;
|
|
3395
3567
|
this.services = services;
|
|
3396
3568
|
this.onRendered = new SimpleEvent();
|
|
@@ -3404,7 +3576,8 @@ class Workspace {
|
|
|
3404
3576
|
const forceMove = isMiddleButton || altKey;
|
|
3405
3577
|
const commandOrNull = this.resolveClick(target, position);
|
|
3406
3578
|
const behavior = this.clickBehaviorResolver.resolve(commandOrNull, target, forceMove);
|
|
3407
|
-
this.
|
|
3579
|
+
const wrappedBehavior = this.clickBehaviorWrapper.wrap(behavior, commandOrNull);
|
|
3580
|
+
this.behaviorController.start(position, wrappedBehavior);
|
|
3408
3581
|
}
|
|
3409
3582
|
};
|
|
3410
3583
|
this.onPinchToZoom = (distance, centerPoint) => {
|
|
@@ -3722,7 +3895,7 @@ class ControlBar {
|
|
|
3722
3895
|
static create(parent, api) {
|
|
3723
3896
|
const isUndoRedoSupported = api.controlBar.isUndoRedoSupported();
|
|
3724
3897
|
const view = ControlBarView.create(parent, isUndoRedoSupported, api.i18n);
|
|
3725
|
-
const bar = new ControlBar(view, api.controlBar, isUndoRedoSupported);
|
|
3898
|
+
const bar = new ControlBar(view, api.controlBar, api.viewport, isUndoRedoSupported);
|
|
3726
3899
|
view.bindResetButtonClick(() => bar.onResetButtonClicked());
|
|
3727
3900
|
view.bindZoomInButtonClick(() => bar.onZoomInButtonClicked());
|
|
3728
3901
|
view.bindZoomOutButtonClick(() => bar.onZoomOutButtonClicked());
|
|
@@ -3736,9 +3909,10 @@ class ControlBar {
|
|
|
3736
3909
|
bar.refreshButtons();
|
|
3737
3910
|
return bar;
|
|
3738
3911
|
}
|
|
3739
|
-
constructor(view, controlBarApi, isUndoRedoSupported) {
|
|
3912
|
+
constructor(view, controlBarApi, viewportApi, isUndoRedoSupported) {
|
|
3740
3913
|
this.view = view;
|
|
3741
3914
|
this.controlBarApi = controlBarApi;
|
|
3915
|
+
this.viewportApi = viewportApi;
|
|
3742
3916
|
this.isUndoRedoSupported = isUndoRedoSupported;
|
|
3743
3917
|
}
|
|
3744
3918
|
updateLayout() {
|
|
@@ -3748,13 +3922,13 @@ class ControlBar {
|
|
|
3748
3922
|
//
|
|
3749
3923
|
}
|
|
3750
3924
|
onResetButtonClicked() {
|
|
3751
|
-
this.
|
|
3925
|
+
this.viewportApi.resetViewport();
|
|
3752
3926
|
}
|
|
3753
3927
|
onZoomInButtonClicked() {
|
|
3754
|
-
this.
|
|
3928
|
+
this.viewportApi.zoom(true);
|
|
3755
3929
|
}
|
|
3756
3930
|
onZoomOutButtonClicked() {
|
|
3757
|
-
this.
|
|
3931
|
+
this.viewportApi.zoom(false);
|
|
3758
3932
|
}
|
|
3759
3933
|
onMoveButtonClicked() {
|
|
3760
3934
|
this.controlBarApi.toggleIsDragDisabled();
|
|
@@ -4272,31 +4446,6 @@ class ToolboxExtension {
|
|
|
4272
4446
|
}
|
|
4273
4447
|
}
|
|
4274
4448
|
|
|
4275
|
-
const defaultConfiguration$4 = {
|
|
4276
|
-
view: {
|
|
4277
|
-
paddingTop: 20,
|
|
4278
|
-
paddingX: 20,
|
|
4279
|
-
inputSize: 18,
|
|
4280
|
-
inputIconSize: 14,
|
|
4281
|
-
label: {
|
|
4282
|
-
height: 22,
|
|
4283
|
-
paddingX: 10,
|
|
4284
|
-
minWidth: 50,
|
|
4285
|
-
radius: 10
|
|
4286
|
-
}
|
|
4287
|
-
}
|
|
4288
|
-
};
|
|
4289
|
-
class ContainerStepExtension {
|
|
4290
|
-
static create(configuration) {
|
|
4291
|
-
return new ContainerStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$4);
|
|
4292
|
-
}
|
|
4293
|
-
constructor(configuration) {
|
|
4294
|
-
this.configuration = configuration;
|
|
4295
|
-
this.componentType = 'container';
|
|
4296
|
-
this.createComponentView = createContainerStepComponentViewFactory(this.configuration.view);
|
|
4297
|
-
}
|
|
4298
|
-
}
|
|
4299
|
-
|
|
4300
4449
|
class DefaultPlaceholderControllerExtension {
|
|
4301
4450
|
create() {
|
|
4302
4451
|
return {
|
|
@@ -4305,7 +4454,7 @@ class DefaultPlaceholderControllerExtension {
|
|
|
4305
4454
|
}
|
|
4306
4455
|
}
|
|
4307
4456
|
|
|
4308
|
-
const defaultConfiguration
|
|
4457
|
+
const defaultConfiguration = {
|
|
4309
4458
|
gapWidth: 88,
|
|
4310
4459
|
gapHeight: 24,
|
|
4311
4460
|
radius: 6,
|
|
@@ -4313,7 +4462,7 @@ const defaultConfiguration$3 = {
|
|
|
4313
4462
|
};
|
|
4314
4463
|
class RectPlaceholderExtension {
|
|
4315
4464
|
static create(configuration) {
|
|
4316
|
-
return new RectPlaceholderExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration
|
|
4465
|
+
return new RectPlaceholderExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration);
|
|
4317
4466
|
}
|
|
4318
4467
|
constructor(configuration) {
|
|
4319
4468
|
this.configuration = configuration;
|
|
@@ -4327,63 +4476,6 @@ class RectPlaceholderExtension {
|
|
|
4327
4476
|
}
|
|
4328
4477
|
}
|
|
4329
4478
|
|
|
4330
|
-
const defaultConfiguration$2 = {
|
|
4331
|
-
view: {
|
|
4332
|
-
minContainerWidth: 40,
|
|
4333
|
-
paddingX: 20,
|
|
4334
|
-
paddingTop: 20,
|
|
4335
|
-
connectionHeight: 16,
|
|
4336
|
-
inputSize: 18,
|
|
4337
|
-
inputIconSize: 14,
|
|
4338
|
-
branchNameLabel: {
|
|
4339
|
-
height: 22,
|
|
4340
|
-
paddingX: 10,
|
|
4341
|
-
minWidth: 50,
|
|
4342
|
-
radius: 10
|
|
4343
|
-
},
|
|
4344
|
-
nameLabel: {
|
|
4345
|
-
height: 22,
|
|
4346
|
-
paddingX: 10,
|
|
4347
|
-
minWidth: 50,
|
|
4348
|
-
radius: 10
|
|
4349
|
-
}
|
|
4350
|
-
}
|
|
4351
|
-
};
|
|
4352
|
-
class SwitchStepExtension {
|
|
4353
|
-
static create(configuration) {
|
|
4354
|
-
return new SwitchStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$2);
|
|
4355
|
-
}
|
|
4356
|
-
constructor(configuration) {
|
|
4357
|
-
this.configuration = configuration;
|
|
4358
|
-
this.componentType = 'switch';
|
|
4359
|
-
this.createComponentView = createSwitchStepComponentViewFactory(this.configuration.view);
|
|
4360
|
-
}
|
|
4361
|
-
}
|
|
4362
|
-
|
|
4363
|
-
const defaultConfiguration$1 = {
|
|
4364
|
-
view: {
|
|
4365
|
-
paddingLeft: 12,
|
|
4366
|
-
paddingRight: 12,
|
|
4367
|
-
paddingY: 10,
|
|
4368
|
-
textMarginLeft: 12,
|
|
4369
|
-
minTextWidth: 70,
|
|
4370
|
-
iconSize: 22,
|
|
4371
|
-
radius: 5,
|
|
4372
|
-
inputSize: 14,
|
|
4373
|
-
outputSize: 10
|
|
4374
|
-
}
|
|
4375
|
-
};
|
|
4376
|
-
class TaskStepExtension {
|
|
4377
|
-
static create(configuration) {
|
|
4378
|
-
return new TaskStepExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$1);
|
|
4379
|
-
}
|
|
4380
|
-
constructor(configuration) {
|
|
4381
|
-
this.configuration = configuration;
|
|
4382
|
-
this.componentType = 'task';
|
|
4383
|
-
this.createComponentView = createTaskStepComponentViewFactory(false, this.configuration.view);
|
|
4384
|
-
}
|
|
4385
|
-
}
|
|
4386
|
-
|
|
4387
4479
|
class DefaultSequenceComponentExtension {
|
|
4388
4480
|
constructor() {
|
|
4389
4481
|
this.create = DefaultSequenceComponent.create;
|
|
@@ -4396,39 +4488,15 @@ class DefaultStepComponentViewWrapperExtension {
|
|
|
4396
4488
|
}
|
|
4397
4489
|
}
|
|
4398
4490
|
|
|
4399
|
-
class
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
class: 'sqd-line-grid-path',
|
|
4403
|
-
fill: 'none'
|
|
4404
|
-
});
|
|
4405
|
-
return new LineGrid(size, path);
|
|
4406
|
-
}
|
|
4407
|
-
constructor(size, element) {
|
|
4408
|
-
this.size = size;
|
|
4409
|
-
this.element = element;
|
|
4410
|
-
}
|
|
4411
|
-
setScale(_, scaledSize) {
|
|
4412
|
-
Dom.attrs(this.element, {
|
|
4413
|
-
d: `M ${scaledSize.x} 0 L 0 0 0 ${scaledSize.y}`
|
|
4414
|
-
});
|
|
4491
|
+
class DefaultClickBehaviorWrapper {
|
|
4492
|
+
constructor() {
|
|
4493
|
+
this.wrap = (behavior) => behavior;
|
|
4415
4494
|
}
|
|
4416
4495
|
}
|
|
4417
4496
|
|
|
4418
|
-
|
|
4419
|
-
gridSizeX: 48,
|
|
4420
|
-
gridSizeY: 48
|
|
4421
|
-
};
|
|
4422
|
-
class LineGridExtension {
|
|
4423
|
-
static create(configuration) {
|
|
4424
|
-
return new LineGridExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration);
|
|
4425
|
-
}
|
|
4426
|
-
constructor(configuration) {
|
|
4427
|
-
this.configuration = configuration;
|
|
4428
|
-
}
|
|
4497
|
+
class DefaultClickBehaviorWrapperExtension {
|
|
4429
4498
|
create() {
|
|
4430
|
-
|
|
4431
|
-
return LineGrid.create(size);
|
|
4499
|
+
return new DefaultClickBehaviorWrapper();
|
|
4432
4500
|
}
|
|
4433
4501
|
}
|
|
4434
4502
|
|
|
@@ -4448,6 +4516,9 @@ function merge(services, extensions) {
|
|
|
4448
4516
|
if (ext.stepComponentViewWrapper) {
|
|
4449
4517
|
services.stepComponentViewWrapper = ext.stepComponentViewWrapper;
|
|
4450
4518
|
}
|
|
4519
|
+
if (ext.clickBehaviorWrapperExtension) {
|
|
4520
|
+
services.clickBehaviorWrapperExtension = ext.clickBehaviorWrapperExtension;
|
|
4521
|
+
}
|
|
4451
4522
|
if (ext.badges) {
|
|
4452
4523
|
services.badges = (services.badges || []).concat(ext.badges);
|
|
4453
4524
|
}
|
|
@@ -4499,6 +4570,9 @@ function setDefaults(services, configuration) {
|
|
|
4499
4570
|
if (!services.stepComponentViewWrapper) {
|
|
4500
4571
|
services.stepComponentViewWrapper = new DefaultStepComponentViewWrapperExtension();
|
|
4501
4572
|
}
|
|
4573
|
+
if (!services.clickBehaviorWrapperExtension) {
|
|
4574
|
+
services.clickBehaviorWrapperExtension = new DefaultClickBehaviorWrapperExtension();
|
|
4575
|
+
}
|
|
4502
4576
|
if (!services.badges) {
|
|
4503
4577
|
services.badges = [];
|
|
4504
4578
|
}
|
|
@@ -4795,35 +4869,6 @@ class Designer {
|
|
|
4795
4869
|
}
|
|
4796
4870
|
}
|
|
4797
4871
|
|
|
4798
|
-
class LineGridDesignerExtension {
|
|
4799
|
-
static create(configuration) {
|
|
4800
|
-
const grid = LineGridExtension.create(configuration);
|
|
4801
|
-
return new LineGridDesignerExtension(grid);
|
|
4802
|
-
}
|
|
4803
|
-
constructor(grid) {
|
|
4804
|
-
this.grid = grid;
|
|
4805
|
-
}
|
|
4806
|
-
}
|
|
4807
|
-
|
|
4808
|
-
class StepsDesignerExtension {
|
|
4809
|
-
static create(configuration) {
|
|
4810
|
-
const steps = [];
|
|
4811
|
-
if (configuration.container) {
|
|
4812
|
-
steps.push(ContainerStepExtension.create(configuration.container));
|
|
4813
|
-
}
|
|
4814
|
-
if (configuration.switch) {
|
|
4815
|
-
steps.push(SwitchStepExtension.create(configuration.switch));
|
|
4816
|
-
}
|
|
4817
|
-
if (configuration.task) {
|
|
4818
|
-
steps.push(TaskStepExtension.create(configuration.task));
|
|
4819
|
-
}
|
|
4820
|
-
return new StepsDesignerExtension(steps);
|
|
4821
|
-
}
|
|
4822
|
-
constructor(steps) {
|
|
4823
|
-
this.steps = steps;
|
|
4824
|
-
}
|
|
4825
|
-
}
|
|
4826
|
-
|
|
4827
4872
|
exports.Badges = Badges;
|
|
4828
4873
|
exports.CenteredViewportCalculator = CenteredViewportCalculator;
|
|
4829
4874
|
exports.ClassicWheelControllerExtension = ClassicWheelControllerExtension;
|
|
@@ -4836,6 +4881,7 @@ exports.DefaultRegionView = DefaultRegionView;
|
|
|
4836
4881
|
exports.DefaultSequenceComponent = DefaultSequenceComponent;
|
|
4837
4882
|
exports.DefaultSequenceComponentView = DefaultSequenceComponentView;
|
|
4838
4883
|
exports.DefaultViewportController = DefaultViewportController;
|
|
4884
|
+
exports.DefaultViewportControllerDesignerExtension = DefaultViewportControllerDesignerExtension;
|
|
4839
4885
|
exports.DefaultViewportControllerExtension = DefaultViewportControllerExtension;
|
|
4840
4886
|
exports.Designer = Designer;
|
|
4841
4887
|
exports.DesignerApi = DesignerApi;
|
|
@@ -4854,12 +4900,15 @@ exports.OutputView = OutputView;
|
|
|
4854
4900
|
exports.PathBarApi = PathBarApi;
|
|
4855
4901
|
exports.RectPlaceholder = RectPlaceholder;
|
|
4856
4902
|
exports.RectPlaceholderView = RectPlaceholderView;
|
|
4903
|
+
exports.SelectStepBehaviorEndToken = SelectStepBehaviorEndToken;
|
|
4857
4904
|
exports.ServicesResolver = ServicesResolver;
|
|
4858
4905
|
exports.SimpleEvent = SimpleEvent;
|
|
4906
|
+
exports.StartStopRootComponentDesignerExtension = StartStopRootComponentDesignerExtension;
|
|
4859
4907
|
exports.StartStopRootComponentExtension = StartStopRootComponentExtension;
|
|
4860
4908
|
exports.StepComponent = StepComponent;
|
|
4861
4909
|
exports.StepExtensionResolver = StepExtensionResolver;
|
|
4862
4910
|
exports.StepsDesignerExtension = StepsDesignerExtension;
|
|
4911
|
+
exports.TYPE = TYPE;
|
|
4863
4912
|
exports.ToolboxApi = ToolboxApi;
|
|
4864
4913
|
exports.Uid = Uid;
|
|
4865
4914
|
exports.ValidationErrorBadgeExtension = ValidationErrorBadgeExtension;
|