sequential-workflow-designer 0.24.8 → 0.25.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 +4 -4
- package/dist/index.umd.js +285 -150
- package/lib/cjs/index.cjs +285 -150
- package/lib/esm/index.js +285 -150
- package/lib/index.d.ts +47 -28
- package/package.json +1 -1
package/lib/esm/index.js
CHANGED
|
@@ -669,16 +669,92 @@ class ToolboxDataProvider {
|
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
671
|
|
|
672
|
+
function animate(interval, handler) {
|
|
673
|
+
const iv = setInterval(tick, 15);
|
|
674
|
+
const startTime = Date.now();
|
|
675
|
+
const anim = {
|
|
676
|
+
isAlive: true,
|
|
677
|
+
stop: () => {
|
|
678
|
+
anim.isAlive = false;
|
|
679
|
+
clearInterval(iv);
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
function tick() {
|
|
683
|
+
const progress = Math.min((Date.now() - startTime) / interval, 1);
|
|
684
|
+
handler(progress);
|
|
685
|
+
if (progress === 1) {
|
|
686
|
+
anim.stop();
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
return anim;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
class ViewportAnimator {
|
|
693
|
+
constructor(api) {
|
|
694
|
+
this.api = api;
|
|
695
|
+
}
|
|
696
|
+
execute(target) {
|
|
697
|
+
if (this.animation && this.animation.isAlive) {
|
|
698
|
+
this.animation.stop();
|
|
699
|
+
}
|
|
700
|
+
const viewport = this.api.getViewport();
|
|
701
|
+
const startPosition = viewport.position;
|
|
702
|
+
const startScale = viewport.scale;
|
|
703
|
+
const deltaPosition = startPosition.subtract(target.position);
|
|
704
|
+
const deltaScale = startScale - target.scale;
|
|
705
|
+
this.animation = animate(150, progress => {
|
|
706
|
+
const newScale = startScale - deltaScale * progress;
|
|
707
|
+
this.api.setViewport({
|
|
708
|
+
position: startPosition.subtract(deltaPosition.multiplyByScalar(progress)),
|
|
709
|
+
scale: newScale
|
|
710
|
+
});
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
class ZoomByWheelCalculator {
|
|
716
|
+
static calculate(controller, current, canvasPosition, e) {
|
|
717
|
+
if (e.deltaY === 0) {
|
|
718
|
+
return null;
|
|
719
|
+
}
|
|
720
|
+
const nextScale = controller.getNextScale(current.scale, e.deltaY < 0);
|
|
721
|
+
let scale;
|
|
722
|
+
const absDeltaY = Math.abs(e.deltaY);
|
|
723
|
+
if (absDeltaY < controller.smoothDeltaYLimit) {
|
|
724
|
+
const fraction = absDeltaY / controller.smoothDeltaYLimit;
|
|
725
|
+
const step = nextScale.next - nextScale.current;
|
|
726
|
+
scale = current.scale + step * fraction;
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
scale = nextScale.next;
|
|
730
|
+
}
|
|
731
|
+
const mousePoint = new Vector(e.pageX, e.pageY).subtract(canvasPosition);
|
|
732
|
+
// The real point is point on canvas with no scale.
|
|
733
|
+
const mouseRealPoint = mousePoint.divideByScalar(current.scale).subtract(current.position.divideByScalar(current.scale));
|
|
734
|
+
const position = mouseRealPoint.multiplyByScalar(-scale).add(mousePoint);
|
|
735
|
+
return { position, scale };
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
672
739
|
class ViewportApi {
|
|
673
|
-
constructor(workspaceController, viewportController) {
|
|
740
|
+
constructor(workspaceController, viewportController, api) {
|
|
674
741
|
this.workspaceController = workspaceController;
|
|
675
742
|
this.viewportController = viewportController;
|
|
743
|
+
this.api = api;
|
|
744
|
+
this.animator = new ViewportAnimator(this.api);
|
|
745
|
+
}
|
|
746
|
+
limitScale(scale) {
|
|
747
|
+
return this.viewportController.limitScale(scale);
|
|
676
748
|
}
|
|
677
749
|
resetViewport() {
|
|
678
|
-
this.viewportController.
|
|
750
|
+
const defaultViewport = this.viewportController.getDefault();
|
|
751
|
+
this.api.setViewport(defaultViewport);
|
|
679
752
|
}
|
|
680
753
|
zoom(direction) {
|
|
681
|
-
this.viewportController.
|
|
754
|
+
const viewport = this.viewportController.getZoomed(direction);
|
|
755
|
+
if (viewport) {
|
|
756
|
+
this.api.setViewport(viewport);
|
|
757
|
+
}
|
|
682
758
|
}
|
|
683
759
|
moveViewportToStep(stepId) {
|
|
684
760
|
const component = this.workspaceController.getComponentByStepId(stepId);
|
|
@@ -686,7 +762,16 @@ class ViewportApi {
|
|
|
686
762
|
const clientPosition = component.view.getClientPosition();
|
|
687
763
|
const componentPosition = clientPosition.subtract(canvasPosition);
|
|
688
764
|
const componentSize = new Vector(component.view.width, component.view.height);
|
|
689
|
-
this.viewportController.
|
|
765
|
+
const viewport = this.viewportController.getFocusedOnComponent(componentPosition, componentSize);
|
|
766
|
+
this.animator.execute(viewport);
|
|
767
|
+
}
|
|
768
|
+
handleWheelEvent(e) {
|
|
769
|
+
const viewport = this.api.getViewport();
|
|
770
|
+
const canvasPosition = this.api.getCanvasPosition();
|
|
771
|
+
const newViewport = ZoomByWheelCalculator.calculate(this.viewportController, viewport, canvasPosition, e);
|
|
772
|
+
if (newViewport) {
|
|
773
|
+
this.api.setViewport(newViewport);
|
|
774
|
+
}
|
|
690
775
|
}
|
|
691
776
|
}
|
|
692
777
|
|
|
@@ -725,7 +810,7 @@ class DesignerApi {
|
|
|
725
810
|
static create(context) {
|
|
726
811
|
const workspace = new WorkspaceApi(context.state, context.workspaceController);
|
|
727
812
|
const viewportController = context.services.viewportController.create(workspace);
|
|
728
|
-
const viewport = new ViewportApi(context.workspaceController, viewportController);
|
|
813
|
+
const viewport = new ViewportApi(context.workspaceController, viewportController, workspace);
|
|
729
814
|
const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
|
|
730
815
|
return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.stateModifier, viewport), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, viewport, new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
|
|
731
816
|
}
|
|
@@ -1170,7 +1255,7 @@ class ValidationErrorBadge {
|
|
|
1170
1255
|
}
|
|
1171
1256
|
}
|
|
1172
1257
|
|
|
1173
|
-
const defaultConfiguration$
|
|
1258
|
+
const defaultConfiguration$7 = {
|
|
1174
1259
|
view: {
|
|
1175
1260
|
size: 22,
|
|
1176
1261
|
iconSize: 12
|
|
@@ -1178,7 +1263,7 @@ const defaultConfiguration$6 = {
|
|
|
1178
1263
|
};
|
|
1179
1264
|
class ValidationErrorBadgeExtension {
|
|
1180
1265
|
static create(configuration) {
|
|
1181
|
-
return new ValidationErrorBadgeExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$
|
|
1266
|
+
return new ValidationErrorBadgeExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$7);
|
|
1182
1267
|
}
|
|
1183
1268
|
constructor(configuration) {
|
|
1184
1269
|
this.configuration = configuration;
|
|
@@ -1574,7 +1659,7 @@ class StartStopRootComponent {
|
|
|
1574
1659
|
}
|
|
1575
1660
|
}
|
|
1576
1661
|
|
|
1577
|
-
const defaultConfiguration$
|
|
1662
|
+
const defaultConfiguration$6 = {
|
|
1578
1663
|
view: {
|
|
1579
1664
|
size: 30,
|
|
1580
1665
|
defaultIconSize: 22,
|
|
@@ -1586,7 +1671,7 @@ const defaultConfiguration$5 = {
|
|
|
1586
1671
|
};
|
|
1587
1672
|
class StartStopRootComponentExtension {
|
|
1588
1673
|
static create(configuration) {
|
|
1589
|
-
return new StartStopRootComponentExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$
|
|
1674
|
+
return new StartStopRootComponentExtension(configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$6);
|
|
1590
1675
|
}
|
|
1591
1676
|
constructor(configuration) {
|
|
1592
1677
|
this.configuration = configuration;
|
|
@@ -1820,15 +1905,15 @@ const createTaskStepComponentViewFactory = (isInterrupted, cfg) => (parentElemen
|
|
|
1820
1905
|
};
|
|
1821
1906
|
|
|
1822
1907
|
class CenteredViewportCalculator {
|
|
1823
|
-
static center(
|
|
1908
|
+
static center(padding, canvasSize, rootComponentSize) {
|
|
1824
1909
|
if (canvasSize.x === 0 || canvasSize.y === 0) {
|
|
1825
1910
|
return {
|
|
1826
1911
|
position: new Vector(0, 0),
|
|
1827
1912
|
scale: 1
|
|
1828
1913
|
};
|
|
1829
1914
|
}
|
|
1830
|
-
const canvasSafeWidth = Math.max(canvasSize.x -
|
|
1831
|
-
const canvasSafeHeight = Math.max(canvasSize.y -
|
|
1915
|
+
const canvasSafeWidth = Math.max(canvasSize.x - padding * 2, 0);
|
|
1916
|
+
const canvasSafeHeight = Math.max(canvasSize.y - padding * 2, 0);
|
|
1832
1917
|
const scale = Math.min(Math.min(canvasSafeWidth / rootComponentSize.x, canvasSafeHeight / rootComponentSize.y), 1);
|
|
1833
1918
|
const width = rootComponentSize.x * scale;
|
|
1834
1919
|
const height = rootComponentSize.y * scale;
|
|
@@ -1839,7 +1924,7 @@ class CenteredViewportCalculator {
|
|
|
1839
1924
|
scale
|
|
1840
1925
|
};
|
|
1841
1926
|
}
|
|
1842
|
-
static
|
|
1927
|
+
static getFocusedOnComponent(canvasSize, viewport, componentPosition, componentSize) {
|
|
1843
1928
|
const realPosition = viewport.position.divideByScalar(viewport.scale).subtract(componentPosition.divideByScalar(viewport.scale));
|
|
1844
1929
|
const componentOffset = componentSize.divideByScalar(2);
|
|
1845
1930
|
const position = realPosition.add(canvasSize.divideByScalar(2)).subtract(componentOffset);
|
|
@@ -1847,6 +1932,24 @@ class CenteredViewportCalculator {
|
|
|
1847
1932
|
}
|
|
1848
1933
|
}
|
|
1849
1934
|
|
|
1935
|
+
class ClassicWheelController {
|
|
1936
|
+
static create(api) {
|
|
1937
|
+
return new ClassicWheelController(api);
|
|
1938
|
+
}
|
|
1939
|
+
constructor(api) {
|
|
1940
|
+
this.api = api;
|
|
1941
|
+
}
|
|
1942
|
+
onWheel(e) {
|
|
1943
|
+
this.api.handleWheelEvent(e);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
class ClassicWheelControllerExtension {
|
|
1948
|
+
constructor() {
|
|
1949
|
+
this.create = ClassicWheelController.create;
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1850
1953
|
class NextQuantifiedNumber {
|
|
1851
1954
|
constructor(values) {
|
|
1852
1955
|
this.values = values;
|
|
@@ -1873,142 +1976,68 @@ class NextQuantifiedNumber {
|
|
|
1873
1976
|
next: this.values[index]
|
|
1874
1977
|
};
|
|
1875
1978
|
}
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
const
|
|
1879
|
-
|
|
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 };
|
|
1979
|
+
limit(scale) {
|
|
1980
|
+
const min = this.values[0];
|
|
1981
|
+
const max = this.values[this.values.length - 1];
|
|
1982
|
+
return Math.min(Math.max(scale, min), max);
|
|
1909
1983
|
}
|
|
1910
1984
|
}
|
|
1911
1985
|
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
this.api = api;
|
|
1918
|
-
}
|
|
1919
|
-
onWheel(e) {
|
|
1920
|
-
const viewport = this.api.getViewport();
|
|
1921
|
-
const canvasPosition = this.api.getCanvasPosition();
|
|
1922
|
-
const newViewport = QuantifiedScaleViewportCalculator.zoomByWheel(viewport, e, canvasPosition);
|
|
1923
|
-
if (newViewport) {
|
|
1924
|
-
this.api.setViewport(newViewport);
|
|
1925
|
-
}
|
|
1926
|
-
}
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1929
|
-
class ClassicWheelControllerExtension {
|
|
1930
|
-
constructor() {
|
|
1931
|
-
this.create = ClassicWheelController.create;
|
|
1932
|
-
}
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
|
-
function animate(interval, handler) {
|
|
1936
|
-
const iv = setInterval(tick, 15);
|
|
1937
|
-
const startTime = Date.now();
|
|
1938
|
-
const anim = {
|
|
1939
|
-
isAlive: true,
|
|
1940
|
-
stop: () => {
|
|
1941
|
-
anim.isAlive = false;
|
|
1942
|
-
clearInterval(iv);
|
|
1943
|
-
}
|
|
1944
|
-
};
|
|
1945
|
-
function tick() {
|
|
1946
|
-
const progress = Math.min((Date.now() - startTime) / interval, 1);
|
|
1947
|
-
handler(progress);
|
|
1948
|
-
if (progress === 1) {
|
|
1949
|
-
anim.stop();
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
return anim;
|
|
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();
|
|
1962
|
-
}
|
|
1963
|
-
const viewport = this.api.getViewport();
|
|
1964
|
-
const startPosition = viewport.position;
|
|
1965
|
-
const startScale = viewport.scale;
|
|
1966
|
-
const deltaPosition = startPosition.subtract(target.position);
|
|
1967
|
-
const deltaScale = startScale - target.scale;
|
|
1968
|
-
this.animation = animate(150, progress => {
|
|
1969
|
-
const newScale = startScale - deltaScale * progress;
|
|
1970
|
-
this.api.setViewport({
|
|
1971
|
-
position: startPosition.subtract(deltaPosition.multiplyByScalar(progress)),
|
|
1972
|
-
scale: newScale
|
|
1973
|
-
});
|
|
1974
|
-
});
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
|
|
1978
|
-
const CENTER_MARGIN = 10;
|
|
1986
|
+
const defaultConfiguration$5 = {
|
|
1987
|
+
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],
|
|
1988
|
+
smoothDeltaYLimit: 16,
|
|
1989
|
+
padding: 10
|
|
1990
|
+
};
|
|
1979
1991
|
class DefaultViewportController {
|
|
1980
|
-
static create(api) {
|
|
1981
|
-
|
|
1992
|
+
static create(api, configuration) {
|
|
1993
|
+
const config = configuration !== null && configuration !== void 0 ? configuration : defaultConfiguration$5;
|
|
1994
|
+
const nqn = new NextQuantifiedNumber(config.scales);
|
|
1995
|
+
return new DefaultViewportController(config.smoothDeltaYLimit, nqn, api, config.padding);
|
|
1982
1996
|
}
|
|
1983
|
-
constructor(api) {
|
|
1997
|
+
constructor(smoothDeltaYLimit, nqn, api, padding) {
|
|
1998
|
+
this.smoothDeltaYLimit = smoothDeltaYLimit;
|
|
1999
|
+
this.nqn = nqn;
|
|
1984
2000
|
this.api = api;
|
|
1985
|
-
this.
|
|
2001
|
+
this.padding = padding;
|
|
1986
2002
|
}
|
|
1987
|
-
|
|
2003
|
+
getDefault() {
|
|
1988
2004
|
const rootComponentSize = this.api.getRootComponentSize();
|
|
1989
2005
|
const canvasSize = this.api.getCanvasSize();
|
|
1990
|
-
|
|
1991
|
-
this.api.setViewport(target);
|
|
2006
|
+
return CenteredViewportCalculator.center(this.padding, canvasSize, rootComponentSize);
|
|
1992
2007
|
}
|
|
1993
|
-
|
|
1994
|
-
const
|
|
1995
|
-
const
|
|
1996
|
-
|
|
2008
|
+
getZoomed(direction) {
|
|
2009
|
+
const current = this.api.getViewport();
|
|
2010
|
+
const nextScale = this.nqn.next(current.scale, direction);
|
|
2011
|
+
if (nextScale) {
|
|
2012
|
+
return {
|
|
2013
|
+
position: current.position,
|
|
2014
|
+
scale: nextScale.next
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
return null;
|
|
1997
2018
|
}
|
|
1998
|
-
|
|
2019
|
+
getFocusedOnComponent(componentPosition, componentSize) {
|
|
1999
2020
|
const viewport = this.api.getViewport();
|
|
2000
2021
|
const canvasSize = this.api.getCanvasSize();
|
|
2001
|
-
|
|
2002
|
-
this.animateTo(target);
|
|
2022
|
+
return CenteredViewportCalculator.getFocusedOnComponent(canvasSize, viewport, componentPosition, componentSize);
|
|
2003
2023
|
}
|
|
2004
|
-
|
|
2005
|
-
this.
|
|
2024
|
+
getNextScale(scale, direction) {
|
|
2025
|
+
return this.nqn.next(scale, direction);
|
|
2026
|
+
}
|
|
2027
|
+
limitScale(scale) {
|
|
2028
|
+
return this.nqn.limit(scale);
|
|
2006
2029
|
}
|
|
2007
2030
|
}
|
|
2008
2031
|
|
|
2009
2032
|
class DefaultViewportControllerExtension {
|
|
2010
|
-
|
|
2011
|
-
|
|
2033
|
+
static create(configuration) {
|
|
2034
|
+
return new DefaultViewportControllerExtension(configuration);
|
|
2035
|
+
}
|
|
2036
|
+
constructor(configuration) {
|
|
2037
|
+
this.configuration = configuration;
|
|
2038
|
+
}
|
|
2039
|
+
create(api) {
|
|
2040
|
+
return DefaultViewportController.create(api, this.configuration);
|
|
2012
2041
|
}
|
|
2013
2042
|
}
|
|
2014
2043
|
|
|
@@ -2168,10 +2197,26 @@ function readTouchPosition(e) {
|
|
|
2168
2197
|
return new Vector(touch.pageX, touch.pageY);
|
|
2169
2198
|
}
|
|
2170
2199
|
throw new Error('Unknown touch position');
|
|
2200
|
+
}
|
|
2201
|
+
function calculateFingerDistance(e) {
|
|
2202
|
+
if (e.touches.length === 2) {
|
|
2203
|
+
const t0 = e.touches[0];
|
|
2204
|
+
const t1 = e.touches[1];
|
|
2205
|
+
return Math.hypot(t0.clientX - t1.clientX, t0.clientY - t1.clientY);
|
|
2206
|
+
}
|
|
2207
|
+
throw new Error('Cannot calculate finger distance');
|
|
2208
|
+
}
|
|
2209
|
+
function readFingerCenterPoint(e) {
|
|
2210
|
+
if (e.touches.length === 2) {
|
|
2211
|
+
const t0 = e.touches[0];
|
|
2212
|
+
const t1 = e.touches[1];
|
|
2213
|
+
return new Vector((t0.pageX + t1.pageX) / 2, (t0.pageY + t1.pageY) / 2);
|
|
2214
|
+
}
|
|
2215
|
+
throw new Error('Cannot calculate finger center point');
|
|
2171
2216
|
}
|
|
2172
2217
|
|
|
2173
|
-
const notInitializedError = 'State is not initialized';
|
|
2174
|
-
const nonPassiveOptions = {
|
|
2218
|
+
const notInitializedError$1 = 'State is not initialized';
|
|
2219
|
+
const nonPassiveOptions$1 = {
|
|
2175
2220
|
passive: false
|
|
2176
2221
|
};
|
|
2177
2222
|
class BehaviorController {
|
|
@@ -2201,7 +2246,7 @@ class BehaviorController {
|
|
|
2201
2246
|
e.preventDefault();
|
|
2202
2247
|
e.stopPropagation();
|
|
2203
2248
|
if (!this.state) {
|
|
2204
|
-
throw new Error(notInitializedError);
|
|
2249
|
+
throw new Error(notInitializedError$1);
|
|
2205
2250
|
}
|
|
2206
2251
|
const position = (_a = this.state.lastPosition) !== null && _a !== void 0 ? _a : this.state.startPosition;
|
|
2207
2252
|
const element = this.dom.elementFromPoint(position.x, position.y);
|
|
@@ -2232,21 +2277,21 @@ class BehaviorController {
|
|
|
2232
2277
|
}
|
|
2233
2278
|
bind(target) {
|
|
2234
2279
|
target.addEventListener('mousemove', this.onMouseMove, false);
|
|
2235
|
-
target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
|
|
2280
|
+
target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions$1);
|
|
2236
2281
|
target.addEventListener('mouseup', this.onMouseUp, false);
|
|
2237
|
-
target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
|
|
2238
|
-
target.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
|
|
2282
|
+
target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions$1);
|
|
2283
|
+
target.addEventListener('touchstart', this.onTouchStart, nonPassiveOptions$1);
|
|
2239
2284
|
}
|
|
2240
2285
|
unbind(target) {
|
|
2241
2286
|
target.removeEventListener('mousemove', this.onMouseMove, false);
|
|
2242
|
-
target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
|
|
2287
|
+
target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions$1);
|
|
2243
2288
|
target.removeEventListener('mouseup', this.onMouseUp, false);
|
|
2244
|
-
target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
|
|
2245
|
-
target.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions);
|
|
2289
|
+
target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions$1);
|
|
2290
|
+
target.removeEventListener('touchstart', this.onTouchStart, nonPassiveOptions$1);
|
|
2246
2291
|
}
|
|
2247
2292
|
move(position) {
|
|
2248
2293
|
if (!this.state) {
|
|
2249
|
-
throw new Error(notInitializedError);
|
|
2294
|
+
throw new Error(notInitializedError$1);
|
|
2250
2295
|
}
|
|
2251
2296
|
this.state.lastPosition = position;
|
|
2252
2297
|
const delta = this.state.startPosition.subtract(position);
|
|
@@ -2260,7 +2305,7 @@ class BehaviorController {
|
|
|
2260
2305
|
}
|
|
2261
2306
|
stop(interrupt, element) {
|
|
2262
2307
|
if (!this.state) {
|
|
2263
|
-
throw new Error(notInitializedError);
|
|
2308
|
+
throw new Error(notInitializedError$1);
|
|
2264
2309
|
}
|
|
2265
2310
|
if (this.shadowRoot) {
|
|
2266
2311
|
this.unbind(this.shadowRoot);
|
|
@@ -2835,20 +2880,26 @@ class WorkspaceView {
|
|
|
2835
2880
|
getCanvasSize() {
|
|
2836
2881
|
return new Vector(this.canvas.clientWidth, this.canvas.clientHeight);
|
|
2837
2882
|
}
|
|
2838
|
-
|
|
2883
|
+
bindMouseDown(handler) {
|
|
2839
2884
|
this.canvas.addEventListener('mousedown', e => {
|
|
2840
2885
|
e.preventDefault();
|
|
2841
2886
|
handler(readMousePosition(e), e.target, e.button, e.altKey);
|
|
2842
2887
|
}, false);
|
|
2888
|
+
}
|
|
2889
|
+
bindTouchStart(clickHandler, pinchToZoomHandler) {
|
|
2843
2890
|
this.canvas.addEventListener('touchstart', e => {
|
|
2844
2891
|
var _a;
|
|
2845
2892
|
e.preventDefault();
|
|
2893
|
+
if (e.touches.length === 2) {
|
|
2894
|
+
pinchToZoomHandler(calculateFingerDistance(e), readFingerCenterPoint(e));
|
|
2895
|
+
return;
|
|
2896
|
+
}
|
|
2846
2897
|
const clientPosition = readTouchClientPosition(e);
|
|
2847
2898
|
const dom = (_a = this.shadowRoot) !== null && _a !== void 0 ? _a : document;
|
|
2848
2899
|
const element = dom.elementFromPoint(clientPosition.x, clientPosition.y);
|
|
2849
2900
|
if (element) {
|
|
2850
2901
|
const position = readTouchPosition(e);
|
|
2851
|
-
|
|
2902
|
+
clickHandler(position, element, 0, false);
|
|
2852
2903
|
}
|
|
2853
2904
|
}, listenerOptions$1);
|
|
2854
2905
|
}
|
|
@@ -3225,17 +3276,96 @@ class ContextMenuItemsBuilder {
|
|
|
3225
3276
|
}
|
|
3226
3277
|
}
|
|
3227
3278
|
|
|
3279
|
+
const nonPassiveOptions = {
|
|
3280
|
+
passive: false
|
|
3281
|
+
};
|
|
3282
|
+
const notInitializedError = 'State is not initialized';
|
|
3283
|
+
class PinchToZoomController {
|
|
3284
|
+
static create(workspaceApi, viewportApi, shadowRoot) {
|
|
3285
|
+
return new PinchToZoomController(workspaceApi, viewportApi, shadowRoot);
|
|
3286
|
+
}
|
|
3287
|
+
constructor(workspaceApi, viewportApi, shadowRoot) {
|
|
3288
|
+
this.workspaceApi = workspaceApi;
|
|
3289
|
+
this.viewportApi = viewportApi;
|
|
3290
|
+
this.shadowRoot = shadowRoot;
|
|
3291
|
+
this.state = null;
|
|
3292
|
+
this.onTouchMove = (e) => {
|
|
3293
|
+
e.preventDefault();
|
|
3294
|
+
if (!this.state) {
|
|
3295
|
+
throw new Error(notInitializedError);
|
|
3296
|
+
}
|
|
3297
|
+
const touchEvent = e;
|
|
3298
|
+
const distance = calculateFingerDistance(touchEvent);
|
|
3299
|
+
const centerPoint = readFingerCenterPoint(touchEvent);
|
|
3300
|
+
const deltaCenterPoint = centerPoint.subtract(this.state.lastCenterPoint);
|
|
3301
|
+
const scale = this.viewportApi.limitScale(this.state.startScale * (distance / this.state.startDistance));
|
|
3302
|
+
const zoomPoint = centerPoint.subtract(this.state.canvasPosition);
|
|
3303
|
+
const zoomRealPoint = zoomPoint
|
|
3304
|
+
.divideByScalar(this.state.lastViewport.scale)
|
|
3305
|
+
.subtract(this.state.lastViewport.position.divideByScalar(this.state.lastViewport.scale));
|
|
3306
|
+
const position = zoomRealPoint
|
|
3307
|
+
.multiplyByScalar(-scale)
|
|
3308
|
+
.add(zoomPoint)
|
|
3309
|
+
.add(deltaCenterPoint.divideByScalar(this.state.lastViewport.scale));
|
|
3310
|
+
const newViewport = {
|
|
3311
|
+
position,
|
|
3312
|
+
scale
|
|
3313
|
+
};
|
|
3314
|
+
this.workspaceApi.setViewport(newViewport);
|
|
3315
|
+
this.state.lastCenterPoint = centerPoint;
|
|
3316
|
+
this.state.lastViewport = newViewport;
|
|
3317
|
+
};
|
|
3318
|
+
this.onTouchEnd = (e) => {
|
|
3319
|
+
e.preventDefault();
|
|
3320
|
+
if (!this.state) {
|
|
3321
|
+
throw new Error(notInitializedError);
|
|
3322
|
+
}
|
|
3323
|
+
if (this.shadowRoot) {
|
|
3324
|
+
this.unbind(this.shadowRoot);
|
|
3325
|
+
}
|
|
3326
|
+
this.unbind(window);
|
|
3327
|
+
this.state = null;
|
|
3328
|
+
};
|
|
3329
|
+
}
|
|
3330
|
+
start(startDistance, centerPoint) {
|
|
3331
|
+
if (this.state) {
|
|
3332
|
+
throw new Error(`State is already initialized`);
|
|
3333
|
+
}
|
|
3334
|
+
if (this.shadowRoot) {
|
|
3335
|
+
this.bind(this.shadowRoot);
|
|
3336
|
+
}
|
|
3337
|
+
this.bind(window);
|
|
3338
|
+
const viewport = this.workspaceApi.getViewport();
|
|
3339
|
+
this.state = {
|
|
3340
|
+
canvasPosition: this.workspaceApi.getCanvasPosition(),
|
|
3341
|
+
startScale: viewport.scale,
|
|
3342
|
+
startDistance,
|
|
3343
|
+
lastViewport: viewport,
|
|
3344
|
+
lastCenterPoint: centerPoint
|
|
3345
|
+
};
|
|
3346
|
+
}
|
|
3347
|
+
bind(target) {
|
|
3348
|
+
target.addEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
|
|
3349
|
+
target.addEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
|
|
3350
|
+
}
|
|
3351
|
+
unbind(target) {
|
|
3352
|
+
target.removeEventListener('touchmove', this.onTouchMove, nonPassiveOptions);
|
|
3353
|
+
target.removeEventListener('touchend', this.onTouchEnd, nonPassiveOptions);
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
|
|
3228
3357
|
class Workspace {
|
|
3229
3358
|
static create(parent, designerContext, api) {
|
|
3230
3359
|
var _a;
|
|
3231
3360
|
const view = WorkspaceView.create(parent, designerContext.componentContext);
|
|
3232
3361
|
const clickBehaviorResolver = new ClickBehaviorResolver(designerContext);
|
|
3233
|
-
const wheelController = designerContext.services.wheelController.create(api.workspace);
|
|
3362
|
+
const wheelController = designerContext.services.wheelController.create(api.viewport, api.workspace);
|
|
3363
|
+
const pinchToZoomController = PinchToZoomController.create(api.workspace, api.viewport, api.shadowRoot);
|
|
3234
3364
|
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
3365
|
? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
|
|
3236
3366
|
: undefined);
|
|
3237
3367
|
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);
|
|
3368
|
+
const workspace = new Workspace(view, designerContext.definitionWalker, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, api.viewport, designerContext.services);
|
|
3239
3369
|
setTimeout(() => {
|
|
3240
3370
|
workspace.updateRootComponent();
|
|
3241
3371
|
api.viewport.resetViewport();
|
|
@@ -3245,17 +3375,19 @@ class Workspace {
|
|
|
3245
3375
|
race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged, designerContext.state.onFolderPathChanged).subscribe(r => {
|
|
3246
3376
|
workspace.onStateChanged(r[0], r[1], r[2]);
|
|
3247
3377
|
});
|
|
3248
|
-
view.
|
|
3378
|
+
view.bindMouseDown(workspace.onClick);
|
|
3379
|
+
view.bindTouchStart(workspace.onClick, workspace.onPinchToZoom);
|
|
3249
3380
|
view.bindWheel(workspace.onWheel);
|
|
3250
3381
|
view.bindContextMenu(workspace.onContextMenu);
|
|
3251
3382
|
return workspace;
|
|
3252
3383
|
}
|
|
3253
|
-
constructor(view, definitionWalker, state, behaviorController, wheelController, contextMenuController, clickBehaviorResolver, viewportApi, services) {
|
|
3384
|
+
constructor(view, definitionWalker, state, behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, viewportApi, services) {
|
|
3254
3385
|
this.view = view;
|
|
3255
3386
|
this.definitionWalker = definitionWalker;
|
|
3256
3387
|
this.state = state;
|
|
3257
3388
|
this.behaviorController = behaviorController;
|
|
3258
3389
|
this.wheelController = wheelController;
|
|
3390
|
+
this.pinchToZoomController = pinchToZoomController;
|
|
3259
3391
|
this.contextMenuController = contextMenuController;
|
|
3260
3392
|
this.clickBehaviorResolver = clickBehaviorResolver;
|
|
3261
3393
|
this.viewportApi = viewportApi;
|
|
@@ -3274,6 +3406,9 @@ class Workspace {
|
|
|
3274
3406
|
this.behaviorController.start(position, behavior);
|
|
3275
3407
|
}
|
|
3276
3408
|
};
|
|
3409
|
+
this.onPinchToZoom = (distance, centerPoint) => {
|
|
3410
|
+
this.pinchToZoomController.start(distance, centerPoint);
|
|
3411
|
+
};
|
|
3277
3412
|
this.onWheel = (e) => {
|
|
3278
3413
|
e.preventDefault();
|
|
3279
3414
|
e.stopPropagation();
|
|
@@ -4397,7 +4532,7 @@ function setDefaults(services, configuration) {
|
|
|
4397
4532
|
services.regionComponentView = new DefaultRegionComponentViewExtension();
|
|
4398
4533
|
}
|
|
4399
4534
|
if (!services.viewportController) {
|
|
4400
|
-
services.viewportController =
|
|
4535
|
+
services.viewportController = DefaultViewportControllerExtension.create();
|
|
4401
4536
|
}
|
|
4402
4537
|
if (!services.grid) {
|
|
4403
4538
|
services.grid = LineGridExtension.create();
|
|
@@ -4688,4 +4823,4 @@ class StepsDesignerExtension {
|
|
|
4688
4823
|
}
|
|
4689
4824
|
}
|
|
4690
4825
|
|
|
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,
|
|
4826
|
+
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, RectPlaceholder, RectPlaceholderView, ServicesResolver, SimpleEvent, StartStopRootComponentExtension, StepComponent, StepExtensionResolver, StepsDesignerExtension, ToolboxApi, Uid, ValidationErrorBadgeExtension, Vector, ViewportApi, WorkspaceApi, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, getAbsolutePosition, race };
|