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