orcasvn-react-diagrams 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1411 -187
- package/dist/cjs/types/components/shapes/halfCircle.d.ts +1 -1
- package/dist/cjs/types/components/shapes/polygon.d.ts +1 -1
- package/dist/cjs/types/components/shapes/rectangle.d.ts +1 -1
- package/dist/cjs/types/components/shapes/rectangularFrame.d.ts +1 -1
- package/dist/cjs/types/mocks/customPortWithBuiltinShape.d.ts +2 -0
- package/dist/cjs/types/mocks/port1.d.ts +2 -2
- package/dist/cjs/types/mocks/portIn.d.ts +2 -2
- package/dist/cjs/types/models/implementations/CustomPortFromJSXElement.d.ts +7 -0
- package/dist/cjs/types/models/implementations/CustomPortFromShape.d.ts +7 -0
- package/dist/cjs/types/models/implementations/index.d.ts +1 -1
- package/dist/esm/index.js +1330 -106
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/shapes/halfCircle.d.ts +1 -1
- package/dist/esm/types/components/shapes/polygon.d.ts +1 -1
- package/dist/esm/types/components/shapes/rectangle.d.ts +1 -1
- package/dist/esm/types/components/shapes/rectangularFrame.d.ts +1 -1
- package/dist/esm/types/mocks/customPortWithBuiltinShape.d.ts +2 -0
- package/dist/esm/types/mocks/port1.d.ts +2 -2
- package/dist/esm/types/mocks/portIn.d.ts +2 -2
- package/dist/esm/types/models/implementations/CustomPortFromJSXElement.d.ts +7 -0
- package/dist/esm/types/models/implementations/CustomPortFromShape.d.ts +7 -0
- package/dist/esm/types/models/implementations/index.d.ts +1 -1
- package/dist/index.d.ts +6 -6
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var React = require('react');
|
|
5
|
+
var React$1 = require('react');
|
|
6
6
|
var require$$0 = require('react-dom');
|
|
7
|
-
var Flexbox = require('react-svg-flexbox');
|
|
8
7
|
|
|
9
8
|
exports.PositioningAnchor = void 0;
|
|
10
9
|
(function (PositioningAnchor) {
|
|
@@ -37,6 +36,8 @@ exports.TextAlign = void 0;
|
|
|
37
36
|
TextAlign[TextAlign["center"] = 2] = "center";
|
|
38
37
|
})(exports.TextAlign || (exports.TextAlign = {}));
|
|
39
38
|
|
|
39
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
40
|
+
|
|
40
41
|
function getDefaultExportFromCjs (x) {
|
|
41
42
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
42
43
|
}
|
|
@@ -752,7 +753,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
752
753
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
753
754
|
};
|
|
754
755
|
|
|
755
|
-
var ShapeWrapper = React.forwardRef(function (shapeProps, ref) {
|
|
756
|
+
var ShapeWrapper = React$1.forwardRef(function (shapeProps, ref) {
|
|
756
757
|
//if direction is provided, rotation is based on direction
|
|
757
758
|
var rotation = shapeProps.rotation || 0;
|
|
758
759
|
if (shapeProps.direction) {
|
|
@@ -782,7 +783,7 @@ var ShapeWrapper = React.forwardRef(function (shapeProps, ref) {
|
|
|
782
783
|
position.x = position.x - shapeProps.width / 2;
|
|
783
784
|
position.y = position.y - shapeProps.height / 2;
|
|
784
785
|
}
|
|
785
|
-
var objectOfAllEventAttributes = React.useMemo(function () {
|
|
786
|
+
var objectOfAllEventAttributes = React$1.useMemo(function () {
|
|
786
787
|
var arrayOfAllEventAttributes = Object.entries(shapeProps).filter(function (_a) {
|
|
787
788
|
var k = _a[0]; _a[1];
|
|
788
789
|
return k.startsWith('on');
|
|
@@ -792,26 +793,26 @@ var ShapeWrapper = React.forwardRef(function (shapeProps, ref) {
|
|
|
792
793
|
var viewboxWidth = shapeProps.width > shapeProps.height ? 100 : shapeProps.width / shapeProps.height * 100;
|
|
793
794
|
var viewBoxHeight = shapeProps.height > shapeProps.width ? 100 : shapeProps.height / shapeProps.width * 100;
|
|
794
795
|
var viewBox = shapeProps.viewBox || "0 0 ".concat(viewboxWidth, " ").concat(viewBoxHeight);
|
|
795
|
-
return (React.createElement("g", { transform: "rotate(".concat(rotation, ")"), style: { transformOrigin: transformOrigin, transformBox: "content-box" } },
|
|
796
|
-
React.createElement("svg", __assign({ ref: ref, style: { overflow: "visible" }, x: position.x, y: position.y, width: shapeProps.width, height: shapeProps.height, className: shapeProps.cssClass, viewBox: viewBox }, objectOfAllEventAttributes), shapeProps.children)));
|
|
796
|
+
return (React$1.createElement("g", { transform: "rotate(".concat(rotation, ")"), style: { transformOrigin: transformOrigin, transformBox: "content-box" } },
|
|
797
|
+
React$1.createElement("svg", __assign({ ref: ref, style: { overflow: "visible" }, x: position.x, y: position.y, width: shapeProps.width, height: shapeProps.height, className: shapeProps.cssClass, viewBox: viewBox }, objectOfAllEventAttributes), shapeProps.children)));
|
|
797
798
|
});
|
|
798
799
|
|
|
799
|
-
var CustomShape = React.forwardRef(function (props, ref) {
|
|
800
|
-
return (React.createElement(ShapeWrapper, __assign({}, props, { ref: ref }), props.children));
|
|
800
|
+
var CustomShape = React$1.forwardRef(function (props, ref) {
|
|
801
|
+
return (React$1.createElement(ShapeWrapper, __assign({}, props, { ref: ref }), props.children));
|
|
801
802
|
});
|
|
802
803
|
|
|
803
|
-
var
|
|
804
|
-
__extends(
|
|
805
|
-
function
|
|
806
|
-
var _this = _super.call(this, x, y, width, height, label, React.forwardRef(function (props, ref) {
|
|
807
|
-
return (React.createElement(CustomShape, { ref: ref, x: props.x, y: props.y, width: props.width, height: props.height, rotation: props.rotation, positioningAnchor: shapePositioningAnchor, onClick: function (e) { var _a; return (_a = props.onSelected) === null || _a === void 0 ? void 0 : _a.call(props, _this.id, e); }, onMouseDown: function (e) { var _a; return (_a = props.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(props, _this.id, e); }, onMouseUp: function (e) { var _a; return (_a = props.onMouseUp) === null || _a === void 0 ? void 0 : _a.call(props, _this.id, e); } },
|
|
804
|
+
var CustomPortFromJSXElement = /** @class */ (function (_super) {
|
|
805
|
+
__extends(CustomPortFromJSXElement, _super);
|
|
806
|
+
function CustomPortFromJSXElement(x, y, width, height, renderCustomShape, label, shapePositioningAnchor) {
|
|
807
|
+
var _this = _super.call(this, x, y, width, height, label, React$1.forwardRef(function (props, ref) {
|
|
808
|
+
return (React$1.createElement(CustomShape, { ref: ref, x: props.x, y: props.y, width: props.width, height: props.height, rotation: props.rotation, positioningAnchor: shapePositioningAnchor, onClick: function (e) { var _a; return (_a = props.onSelected) === null || _a === void 0 ? void 0 : _a.call(props, _this.id, e); }, onMouseDown: function (e) { var _a; return (_a = props.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(props, _this.id, e); }, onMouseUp: function (e) { var _a; return (_a = props.onMouseUp) === null || _a === void 0 ? void 0 : _a.call(props, _this.id, e); } }, renderCustomShape));
|
|
808
809
|
})) || this;
|
|
809
810
|
return _this;
|
|
810
811
|
}
|
|
811
|
-
return
|
|
812
|
+
return CustomPortFromJSXElement;
|
|
812
813
|
}(Port$1));
|
|
813
814
|
|
|
814
|
-
var Circle = React.forwardRef(function (props, ref) {
|
|
815
|
+
var Circle = React$1.forwardRef(function (props, ref) {
|
|
815
816
|
var s = { height: 100, width: 100 };
|
|
816
817
|
if (props.r) {
|
|
817
818
|
s.height = props.r * 2;
|
|
@@ -824,11 +825,11 @@ var Circle = React.forwardRef(function (props, ref) {
|
|
|
824
825
|
s.height = props.height;
|
|
825
826
|
s.width = props.width;
|
|
826
827
|
}
|
|
827
|
-
return (React.createElement(ShapeWrapper, __assign({ viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height, ref: ref }),
|
|
828
|
-
React.createElement("circle", { className: "".concat(props.portMoveableAreaCssClass), vectorEffect: "non-scaling-stroke", cx: 50, cy: 50, r: 50, fill: props.fill || 'transparent', stroke: props.stroke || "none", strokeWidth: props.strokeWidth })));
|
|
828
|
+
return (React$1.createElement(ShapeWrapper, __assign({ viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height, ref: ref }),
|
|
829
|
+
React$1.createElement("circle", { className: "".concat(props.portMoveableAreaCssClass), vectorEffect: "non-scaling-stroke", cx: 50, cy: 50, r: 50, fill: props.fill || 'transparent', stroke: props.stroke || "none", strokeWidth: props.strokeWidth })));
|
|
829
830
|
});
|
|
830
831
|
|
|
831
|
-
var Crescent = function (props) {
|
|
832
|
+
var Crescent = React$1.forwardRef(function (props, ref) {
|
|
832
833
|
var s = { height: 100, width: 100 };
|
|
833
834
|
if (props.r) {
|
|
834
835
|
s.height = props.r * 2;
|
|
@@ -842,11 +843,12 @@ var Crescent = function (props) {
|
|
|
842
843
|
s.width = props.width;
|
|
843
844
|
}
|
|
844
845
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
845
|
-
return (React.createElement(ShapeWrapper, __assign({ viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height }),
|
|
846
|
-
React.createElement("
|
|
847
|
-
};
|
|
846
|
+
return (React$1.createElement(ShapeWrapper, __assign({ ref: ref, viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height }),
|
|
847
|
+
React$1.createElement("rect", { width: 100, height: 100, stroke: "transparent", fill: 'transparent' }),
|
|
848
|
+
React$1.createElement("path", { className: "".concat(props.portMoveableAreaCssClass), vectorEffect: "non-scaling-stroke", d: "M 0 75 A 50 50 0 1 1 100 75 Z", fill: props.fill || 'none', stroke: props.stroke || 'none', strokeWidth: sw })));
|
|
849
|
+
});
|
|
848
850
|
|
|
849
|
-
var Rectangle = function (props) {
|
|
851
|
+
var Rectangle = React$1.forwardRef(function (props, ref) {
|
|
850
852
|
var scaledWidth = props.width;
|
|
851
853
|
var scaledHeight = props.height;
|
|
852
854
|
if (props.width > 100 || props.height > 100) {
|
|
@@ -862,11 +864,11 @@ var Rectangle = function (props) {
|
|
|
862
864
|
}
|
|
863
865
|
}
|
|
864
866
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
865
|
-
return (React.createElement(ShapeWrapper, __assign({}, props, { height: props.height, width: props.width }),
|
|
866
|
-
React.createElement("rect", { className: "rect-border ".concat(props.portMoveableAreaCssClass), vectorEffect: "non-scaling-stroke", width: scaledWidth, height: scaledHeight, fill: props.fill || "transparent", stroke: props.stroke || "none", strokeWidth: sw })));
|
|
867
|
-
};
|
|
867
|
+
return (React$1.createElement(ShapeWrapper, __assign({}, props, { ref: ref, height: props.height, width: props.width }),
|
|
868
|
+
React$1.createElement("rect", { className: "rect-border ".concat(props.portMoveableAreaCssClass), vectorEffect: "non-scaling-stroke", width: scaledWidth, height: scaledHeight, fill: props.fill || "transparent", stroke: props.stroke || "none", strokeWidth: sw })));
|
|
869
|
+
});
|
|
868
870
|
|
|
869
|
-
var RectangularFrame = function (props) {
|
|
871
|
+
var RectangularFrame = React$1.forwardRef(function (props, ref) {
|
|
870
872
|
var scaledWidth = props.width;
|
|
871
873
|
var scaledHeight = props.height;
|
|
872
874
|
if (props.width > 100 || props.height > 100) {
|
|
@@ -886,11 +888,11 @@ var RectangularFrame = function (props) {
|
|
|
886
888
|
var fw = props.frameColor ? (props.frameWidth || 1) : 0;
|
|
887
889
|
var scaledFw = scaledWidth / props.width * fw;
|
|
888
890
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
889
|
-
return (React.createElement(ShapeWrapper, __assign({}, props, { height: props.height, width: props.width }),
|
|
890
|
-
React.createElement("rect", { vectorEffect: "non-scaling-stroke", className: "rectangular-frame-outer-border ".concat(props.portMoveableAreaCssClass), x: vbX, y: vbY, width: scaledWidth, height: scaledHeight, fill: "none", stroke: props.stroke || "none", strokeWidth: sw }),
|
|
891
|
-
React.createElement("rect", { vectorEffect: "non-scaling-stroke", className: 'rectangular-frame-hallway', x: vbX + scaledFw / 2, y: vbY + scaledFw / 2, width: scaledWidth - scaledFw, height: scaledHeight - scaledFw, stroke: props.frameColor || "none", strokeWidth: fw, fill: props.fill || "transparent" }),
|
|
892
|
-
React.createElement("rect", { vectorEffect: "non-scaling-stroke", className: 'rectangular-frame-inner-border', x: vbX + scaledFw, y: vbY + scaledFw, width: scaledWidth - scaledFw * 2, height: scaledHeight - scaledFw * 2, stroke: props.stroke || "none", strokeWidth: sw, fill: props.fill || "transparent" })));
|
|
893
|
-
};
|
|
891
|
+
return (React$1.createElement(ShapeWrapper, __assign({}, props, { ref: ref, height: props.height, width: props.width }),
|
|
892
|
+
React$1.createElement("rect", { vectorEffect: "non-scaling-stroke", className: "rectangular-frame-outer-border ".concat(props.portMoveableAreaCssClass), x: vbX, y: vbY, width: scaledWidth, height: scaledHeight, fill: "none", stroke: props.stroke || "none", strokeWidth: sw }),
|
|
893
|
+
React$1.createElement("rect", { vectorEffect: "non-scaling-stroke", className: 'rectangular-frame-hallway', x: vbX + scaledFw / 2, y: vbY + scaledFw / 2, width: scaledWidth - scaledFw, height: scaledHeight - scaledFw, stroke: props.frameColor || "none", strokeWidth: fw, fill: props.fill || "transparent" }),
|
|
894
|
+
React$1.createElement("rect", { vectorEffect: "non-scaling-stroke", className: 'rectangular-frame-inner-border', x: vbX + scaledFw, y: vbY + scaledFw, width: scaledWidth - scaledFw * 2, height: scaledHeight - scaledFw * 2, stroke: props.stroke || "none", strokeWidth: sw, fill: props.fill || "transparent" })));
|
|
895
|
+
});
|
|
894
896
|
|
|
895
897
|
var createRoot;
|
|
896
898
|
|
|
@@ -964,17 +966,17 @@ var PORT_MOVING_OFFSET_THRESHOLD = 15;
|
|
|
964
966
|
var SelectionFrame = function (props) {
|
|
965
967
|
var _a;
|
|
966
968
|
var bbox = (_a = props.targetSVGElement) === null || _a === void 0 ? void 0 : _a.getBBox();
|
|
967
|
-
var _b = React.useState(props.width || (bbox === null || bbox === void 0 ? void 0 : bbox.width) || MIN_ELEMENT_SIZE), width = _b[0], setWidth = _b[1];
|
|
968
|
-
var _c = React.useState(props.height || (bbox === null || bbox === void 0 ? void 0 : bbox.height) || MIN_ELEMENT_SIZE), height = _c[0], setHeight = _c[1];
|
|
969
|
+
var _b = React$1.useState(props.width || (bbox === null || bbox === void 0 ? void 0 : bbox.width) || MIN_ELEMENT_SIZE), width = _b[0], setWidth = _b[1];
|
|
970
|
+
var _c = React$1.useState(props.height || (bbox === null || bbox === void 0 ? void 0 : bbox.height) || MIN_ELEMENT_SIZE), height = _c[0], setHeight = _c[1];
|
|
969
971
|
var x = 0;
|
|
970
972
|
var y = 0;
|
|
971
973
|
var framePadding = props.framePadding || 0;
|
|
972
974
|
var r = 5;
|
|
973
|
-
var _d = React.useState(false), draggingRect = _d[0], setDraggingRect = _d[1];
|
|
974
|
-
var _e = React.useState(false), draggingCircle = _e[0], setDraggingCircle = _e[1];
|
|
975
|
-
var _f = React.useState(0), startX = _f[0], setStartX = _f[1];
|
|
976
|
-
var _g = React.useState(0), startY = _g[0], setStartY = _g[1];
|
|
977
|
-
var _h = React.useState(0), lastMoveTime = _h[0], setLastMoveTime = _h[1];
|
|
975
|
+
var _d = React$1.useState(false), draggingRect = _d[0], setDraggingRect = _d[1];
|
|
976
|
+
var _e = React$1.useState(false), draggingCircle = _e[0], setDraggingCircle = _e[1];
|
|
977
|
+
var _f = React$1.useState(0), startX = _f[0], setStartX = _f[1];
|
|
978
|
+
var _g = React$1.useState(0), startY = _g[0], setStartY = _g[1];
|
|
979
|
+
var _h = React$1.useState(0), lastMoveTime = _h[0], setLastMoveTime = _h[1];
|
|
978
980
|
var addRectHandleMouseDown = function (event) {
|
|
979
981
|
event.stopPropagation();
|
|
980
982
|
if (!draggingCircle) {
|
|
@@ -984,7 +986,7 @@ var SelectionFrame = function (props) {
|
|
|
984
986
|
setStartY(event.clientY);
|
|
985
987
|
}
|
|
986
988
|
};
|
|
987
|
-
var rectHandleMouseMove = React.useCallback(function (event) {
|
|
989
|
+
var rectHandleMouseMove = React$1.useCallback(function (event) {
|
|
988
990
|
var mouseEvent = event;
|
|
989
991
|
if (draggingRect) {
|
|
990
992
|
var offsetX = mouseEvent.clientX - startX;
|
|
@@ -1007,7 +1009,7 @@ var SelectionFrame = function (props) {
|
|
|
1007
1009
|
}
|
|
1008
1010
|
}
|
|
1009
1011
|
}, [draggingRect, props.onMove, props.movingRate, startX, startY, lastMoveTime]);
|
|
1010
|
-
React.useEffect(function () {
|
|
1012
|
+
React$1.useEffect(function () {
|
|
1011
1013
|
var addRectHandleMouseUp = function () {
|
|
1012
1014
|
//mouse up
|
|
1013
1015
|
setDraggingRect(false);
|
|
@@ -1032,7 +1034,7 @@ var SelectionFrame = function (props) {
|
|
|
1032
1034
|
setDraggingCircle(true);
|
|
1033
1035
|
}
|
|
1034
1036
|
};
|
|
1035
|
-
React.useEffect(function () {
|
|
1037
|
+
React$1.useEffect(function () {
|
|
1036
1038
|
var circleHandleMouseMove = function (event) {
|
|
1037
1039
|
var mouseEvent = event;
|
|
1038
1040
|
if (draggingCircle) {
|
|
@@ -1088,15 +1090,15 @@ var SelectionFrame = function (props) {
|
|
|
1088
1090
|
leftX -= rectangleSize / 2;
|
|
1089
1091
|
topY -= rectangleSize / 2;
|
|
1090
1092
|
}
|
|
1091
|
-
return (React.createElement(React.Fragment, null,
|
|
1092
|
-
props.dragDropHandlerElement && React.createElement(props.dragDropHandlerElement, { dragging: draggingRect, onMouseDown: addRectHandleMouseDown }),
|
|
1093
|
-
React.createElement("rect", { vectorEffect: "non-scaling-stroke", x: leftX, y: topY, width: width, height: height, fill: 'none', stroke: 'blue', strokeWidth: props.strokeWidth || 5, cursor: draggingRect ? 'grabbing' : 'grab', onMouseDown: addRectHandleMouseDown }),
|
|
1093
|
+
return (React$1.createElement(React$1.Fragment, null,
|
|
1094
|
+
props.dragDropHandlerElement && React$1.createElement(props.dragDropHandlerElement, { dragging: draggingRect, onMouseDown: addRectHandleMouseDown }),
|
|
1095
|
+
React$1.createElement("rect", { vectorEffect: "non-scaling-stroke", x: leftX, y: topY, width: width, height: height, fill: 'none', stroke: 'blue', strokeWidth: props.strokeWidth || 5, cursor: draggingRect ? 'grabbing' : 'grab', onMouseDown: addRectHandleMouseDown }),
|
|
1094
1096
|
props.resizability.enabled ?
|
|
1095
|
-
(React.createElement("circle", { cursor: 'se-resize', cx: leftX + width, cy: topY + height, r: r, fill: 'blue', stroke: 'blue', onMouseDown: circleHandleMouseDown })) : null));
|
|
1097
|
+
(React$1.createElement("circle", { cursor: 'se-resize', cx: leftX + width, cy: topY + height, r: r, fill: 'blue', stroke: 'blue', onMouseDown: circleHandleMouseDown })) : null));
|
|
1096
1098
|
};
|
|
1097
1099
|
|
|
1098
1100
|
var useSelectionFrame = function (props) {
|
|
1099
|
-
React.useEffect(function () {
|
|
1101
|
+
React$1.useEffect(function () {
|
|
1100
1102
|
if (props.targetSVGElement && props.container) {
|
|
1101
1103
|
//render SelectionFrame component to the parent element of the targetSVGElement
|
|
1102
1104
|
if (props.container) {
|
|
@@ -1105,7 +1107,7 @@ var useSelectionFrame = function (props) {
|
|
|
1105
1107
|
svg_1.style.outline = 'none';
|
|
1106
1108
|
props.targetSVGElement.appendChild(svg_1);
|
|
1107
1109
|
var root_1 = createRoot(svg_1);
|
|
1108
|
-
root_1.render(React.createElement(SelectionFrame, __assign({}, props, { container: props.container })));
|
|
1110
|
+
root_1.render(React$1.createElement(SelectionFrame, __assign({}, props, { container: props.container })));
|
|
1109
1111
|
return function () {
|
|
1110
1112
|
root_1.unmount();
|
|
1111
1113
|
if (props.targetSVGElement) {
|
|
@@ -1262,7 +1264,7 @@ var onElementLinkEnded = function (callback) {
|
|
|
1262
1264
|
off: off
|
|
1263
1265
|
};
|
|
1264
1266
|
};
|
|
1265
|
-
var paperEventEmitterContext = React.createContext({
|
|
1267
|
+
var paperEventEmitterContext = React$1.createContext({
|
|
1266
1268
|
emitter: eventEmitter,
|
|
1267
1269
|
emitPaperClicked: emitPaperClicked,
|
|
1268
1270
|
onPaperClicked: onPaperClicked,
|
|
@@ -1290,13 +1292,13 @@ var paperEventEmitterContext = React.createContext({
|
|
|
1290
1292
|
onElementLinkEnded: onElementLinkEnded,
|
|
1291
1293
|
});
|
|
1292
1294
|
|
|
1293
|
-
var Text = React.forwardRef(function (_a, ref) {
|
|
1295
|
+
var Text = React$1.forwardRef(function (_a, ref) {
|
|
1294
1296
|
var id = _a.id, content = _a.content, x = _a.x, y = _a.y, width = _a.width, height = _a.height, _b = _a.align, align = _b === void 0 ? exports.TextAlign.left : _b, fontSizeProp = _a.fontSize, border = _a.border, container = _a.container, onSelected = _a.onSelected, onMoved = _a.onMoved, onResized = _a.onResized, onContentChanged = _a.onContentChanged;
|
|
1295
|
-
var _c = React.useState(false), isSelected = _c[0], setIsSelected = _c[1];
|
|
1296
|
-
var _d = React.useState(false), isEditing = _d[0], setIsEditing = _d[1];
|
|
1297
|
-
var svgRef = React.useRef();
|
|
1298
|
-
var onPaperClicked = React.useContext(paperEventEmitterContext).onPaperClicked;
|
|
1299
|
-
React.useEffect(function () {
|
|
1297
|
+
var _c = React$1.useState(false), isSelected = _c[0], setIsSelected = _c[1];
|
|
1298
|
+
var _d = React$1.useState(false), isEditing = _d[0], setIsEditing = _d[1];
|
|
1299
|
+
var svgRef = React$1.useRef();
|
|
1300
|
+
var onPaperClicked = React$1.useContext(paperEventEmitterContext).onPaperClicked;
|
|
1301
|
+
React$1.useEffect(function () {
|
|
1300
1302
|
var paperClickListener = onPaperClicked(function (ev) {
|
|
1301
1303
|
var _a;
|
|
1302
1304
|
var textareaELe = (_a = svgRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('textarea');
|
|
@@ -1343,7 +1345,7 @@ var Text = React.forwardRef(function (_a, ref) {
|
|
|
1343
1345
|
strokeWidth: 3,
|
|
1344
1346
|
movingOffsetThreshold: TEXT_MOVING_OFFSET_THRESHOLD,
|
|
1345
1347
|
});
|
|
1346
|
-
var textAlign = React.useMemo(function () {
|
|
1348
|
+
var textAlign = React$1.useMemo(function () {
|
|
1347
1349
|
switch (align) {
|
|
1348
1350
|
case exports.TextAlign.left:
|
|
1349
1351
|
return 'left';
|
|
@@ -1357,7 +1359,7 @@ var Text = React.forwardRef(function (_a, ref) {
|
|
|
1357
1359
|
}, [align]);
|
|
1358
1360
|
var fontSize = fontSizeProp || TEXT_FONT_SIZE;
|
|
1359
1361
|
var borderStyle = border || 'none';
|
|
1360
|
-
return (React.createElement("svg", { style: { overflow: "visible" }, x: x, y: y, ref: function (node) {
|
|
1362
|
+
return (React$1.createElement("svg", { style: { overflow: "visible" }, x: x, y: y, ref: function (node) {
|
|
1361
1363
|
svgRef.current = node;
|
|
1362
1364
|
if (typeof ref === 'function') {
|
|
1363
1365
|
ref(node);
|
|
@@ -1366,13 +1368,13 @@ var Text = React.forwardRef(function (_a, ref) {
|
|
|
1366
1368
|
ref.current = node;
|
|
1367
1369
|
}
|
|
1368
1370
|
}, onClick: handleClick },
|
|
1369
|
-
React.createElement("foreignObject", { width: width, height: height, style: {
|
|
1371
|
+
React$1.createElement("foreignObject", { width: width, height: height, style: {
|
|
1370
1372
|
overflow: 'visible',
|
|
1371
1373
|
userSelect: 'none',
|
|
1372
1374
|
WebkitUserSelect: 'none',
|
|
1373
1375
|
msUserSelect: 'none'
|
|
1374
1376
|
} },
|
|
1375
|
-
React.createElement("div", { style: {
|
|
1377
|
+
React$1.createElement("div", { style: {
|
|
1376
1378
|
width: '100%',
|
|
1377
1379
|
height: '100%',
|
|
1378
1380
|
borderWidth: '1px',
|
|
@@ -1381,7 +1383,7 @@ var Text = React.forwardRef(function (_a, ref) {
|
|
|
1381
1383
|
// whiteSpace: 'pre-wrap',
|
|
1382
1384
|
boxSizing: 'border-box',
|
|
1383
1385
|
} },
|
|
1384
|
-
React.createElement("textarea", { style: {
|
|
1386
|
+
React$1.createElement("textarea", { style: {
|
|
1385
1387
|
fontFamily: 'initial',
|
|
1386
1388
|
display: 'inline-block',
|
|
1387
1389
|
width: '100%',
|
|
@@ -1399,12 +1401,12 @@ var Text = React.forwardRef(function (_a, ref) {
|
|
|
1399
1401
|
}
|
|
1400
1402
|
}, value: content, onChange: handleChangeText })))));
|
|
1401
1403
|
});
|
|
1402
|
-
var Text$1 = React.memo(Text);
|
|
1404
|
+
var Text$1 = React$1.memo(Text);
|
|
1403
1405
|
|
|
1404
|
-
var Port1 = React.forwardRef(function (props, ref) {
|
|
1406
|
+
var Port1 = React$1.forwardRef(function (props, ref) {
|
|
1405
1407
|
var id = props.id, x = props.x, y = props.y, width = props.width, height = props.height, container = props.container, label = props.label, onPortLabelMoved = props.onPortLabelMoved, onPortLabelResized = props.onPortLabelResized, onPortLabelContentChanged = props.onPortLabelContentChanged, onSelected = props.onSelected, onMouseDown = props.onMouseDown, onMouseUp = props.onMouseUp, calculateRotationAngle = props.calculateRotationAngle, renderShape = props.renderShape;
|
|
1406
|
-
var textRef = React.useRef(null);
|
|
1407
|
-
var rotationAngle = React.useMemo(function () {
|
|
1408
|
+
var textRef = React$1.useRef(null);
|
|
1409
|
+
var rotationAngle = React$1.useMemo(function () {
|
|
1408
1410
|
if (!calculateRotationAngle)
|
|
1409
1411
|
return 0;
|
|
1410
1412
|
return calculateRotationAngle(x, y);
|
|
@@ -1412,22 +1414,22 @@ var Port1 = React.forwardRef(function (props, ref) {
|
|
|
1412
1414
|
var renderLabel = function (label) {
|
|
1413
1415
|
var content = label.content, size = label.size;
|
|
1414
1416
|
var position = label.position || PORT_LABEL_POSITION;
|
|
1415
|
-
return React.createElement(Text$1, { id: label.id, ref: textRef, x: x + position.x, y: y + position.y, width: size.width, height: size.height, content: content, fontSize: label.fontSize, border: label.border, container: container, onMoved: onPortLabelMoved, onResized: onPortLabelResized, onContentChanged: onPortLabelContentChanged });
|
|
1417
|
+
return React$1.createElement(Text$1, { id: label.id, ref: textRef, x: x + position.x, y: y + position.y, width: size.width, height: size.height, content: content, fontSize: label.fontSize, border: label.border, container: container, onMoved: onPortLabelMoved, onResized: onPortLabelResized, onContentChanged: onPortLabelContentChanged });
|
|
1416
1418
|
};
|
|
1417
|
-
var renderedShape = React.useMemo(function () {
|
|
1419
|
+
var renderedShape = React$1.useMemo(function () {
|
|
1418
1420
|
if (renderShape) {
|
|
1419
1421
|
var RenderShape = renderShape;
|
|
1420
|
-
return (React.createElement(RenderShape, __assign({ ref: ref }, props, { rotation: rotationAngle })));
|
|
1422
|
+
return (React$1.createElement(RenderShape, __assign({ ref: ref }, props, { rotation: rotationAngle })));
|
|
1421
1423
|
}
|
|
1422
1424
|
else {
|
|
1423
|
-
return React.createElement(Circle, { onMouseDown: function (e) { return onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(id, e); }, onMouseUp: function (e) { return onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(id, e); }, onClick: function (e) { return onSelected === null || onSelected === void 0 ? void 0 : onSelected(id, e); }, ref: ref, x: x, y: y, positioningAnchor: exports.PositioningAnchor.Center, height: height, width: width, stroke: "black", fill: "black" });
|
|
1425
|
+
return React$1.createElement(Circle, { onMouseDown: function (e) { return onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(id, e); }, onMouseUp: function (e) { return onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(id, e); }, onClick: function (e) { return onSelected === null || onSelected === void 0 ? void 0 : onSelected(id, e); }, ref: ref, x: x, y: y, positioningAnchor: exports.PositioningAnchor.Center, height: height, width: width, stroke: "black", fill: "black" });
|
|
1424
1426
|
}
|
|
1425
1427
|
}, [props]);
|
|
1426
|
-
return (React.createElement(React.Fragment, null,
|
|
1428
|
+
return (React$1.createElement(React$1.Fragment, null,
|
|
1427
1429
|
renderedShape,
|
|
1428
1430
|
label && renderLabel(label)));
|
|
1429
1431
|
});
|
|
1430
|
-
var Port = React.memo(Port1);
|
|
1432
|
+
var Port = React$1.memo(Port1);
|
|
1431
1433
|
|
|
1432
1434
|
// Render the svg <path> element
|
|
1433
1435
|
function getCurvePathData(points, smoothing, closed) {
|
|
@@ -1588,14 +1590,14 @@ function calculateAngleWithOx(pStart, pEnd) {
|
|
|
1588
1590
|
//Defined remove icon for element link, shown when element link is selected.
|
|
1589
1591
|
function CloseIcon(_a) {
|
|
1590
1592
|
var onClick = _a.onClick;
|
|
1591
|
-
return (React.createElement("svg", { width: 20, height: 20, viewBox: "0 0 24.00 24.00", xmlns: "http://www.w3.org/2000/svg", fill: "#ff0000", transform: "rotate(0)", onMouseDown: function (ev) { ev.stopPropagation(); }, onClick: onClick, cursor: 'pointer' },
|
|
1592
|
-
React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0", transform: "translate(3.84,3.84), scale(0.68)" },
|
|
1593
|
-
React.createElement("rect", { x: "0", y: "0", width: "24.00", height: "24.00", rx: "12", fill: "#ffffff", strokeWidth: "0" })),
|
|
1594
|
-
React.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round", stroke: "#CCCCCC", "stroke-width": "0.048" }),
|
|
1595
|
-
React.createElement("g", { id: "SVGRepo_iconCarrier" },
|
|
1596
|
-
React.createElement("g", null,
|
|
1597
|
-
React.createElement("path", { fill: "none", d: "M0 0h24v24H0z" }),
|
|
1598
|
-
React.createElement("path", { d: "M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm0-11.414L9.172 7.757 7.757 9.172 10.586 12l-2.829 2.828 1.415 1.415L12 13.414l2.828 2.829 1.415-1.415L13.414 12l2.829-2.828-1.415-1.415L12 10.586z" })))));
|
|
1593
|
+
return (React$1.createElement("svg", { width: 20, height: 20, viewBox: "0 0 24.00 24.00", xmlns: "http://www.w3.org/2000/svg", fill: "#ff0000", transform: "rotate(0)", onMouseDown: function (ev) { ev.stopPropagation(); }, onClick: onClick, cursor: 'pointer' },
|
|
1594
|
+
React$1.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0", transform: "translate(3.84,3.84), scale(0.68)" },
|
|
1595
|
+
React$1.createElement("rect", { x: "0", y: "0", width: "24.00", height: "24.00", rx: "12", fill: "#ffffff", strokeWidth: "0" })),
|
|
1596
|
+
React$1.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round", stroke: "#CCCCCC", "stroke-width": "0.048" }),
|
|
1597
|
+
React$1.createElement("g", { id: "SVGRepo_iconCarrier" },
|
|
1598
|
+
React$1.createElement("g", null,
|
|
1599
|
+
React$1.createElement("path", { fill: "none", d: "M0 0h24v24H0z" }),
|
|
1600
|
+
React$1.createElement("path", { d: "M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm0-11.414L9.172 7.757 7.757 9.172 10.586 12l-2.829 2.828 1.415 1.415L12 13.414l2.828 2.829 1.415-1.415L13.414 12l2.829-2.828-1.415-1.415L12 10.586z" })))));
|
|
1599
1601
|
}
|
|
1600
1602
|
|
|
1601
1603
|
/**
|
|
@@ -7350,25 +7352,25 @@ var getRelativePosition = function (clientPosition, relativeElement) {
|
|
|
7350
7352
|
};
|
|
7351
7353
|
};
|
|
7352
7354
|
|
|
7353
|
-
var makerStart = React.createElement("circle", { cx: 10, cy: 10, r: 10, fill: "blue" });
|
|
7354
|
-
var makerEnd = React.createElement("path", { d: "M0 0 L 20 10 L0 20 Z", fill: "blue" }); //<path d="M0 0 L 10 5 L0 10 Z"></path>
|
|
7355
|
+
var makerStart = React$1.createElement("circle", { cx: 10, cy: 10, r: 10, fill: "blue" });
|
|
7356
|
+
var makerEnd = React$1.createElement("path", { d: "M0 0 L 20 10 L0 20 Z", fill: "blue" }); //<path d="M0 0 L 10 5 L0 10 Z"></path>
|
|
7355
7357
|
var IElementLink = function (_a) {
|
|
7356
7358
|
var _b, _c;
|
|
7357
7359
|
var id = _a.id, path = _a.path, stroke = _a.stroke, _d = _a.strokeWidth, strokeWidth = _d === void 0 ? 4 : _d, pointsProp = _a.points, sourcePosition = _a.sourcePosition, targetPosition = _a.targetPosition, onPathChanged = _a.onPathChanged, onClickDelete = _a.onClickDelete, onSelected = _a.onSelected, onDeselected = _a.onDeselected, container = _a.container, _e = _a.markerStart, markerStart = _e === void 0 ? makerStart : _e, _f = _a.markerEnd, markerEnd = _f === void 0 ? makerEnd : _f, _g = _a.markerDistanceFromPort, markerDistanceFromPort = _g === void 0 ? LINK_MARKER_DISTANCE_FROM_PORT : _g, _h = _a.markerSize, markerSize = _h === void 0 ? LINK_MARKER_SIZE : _h, label = _a.label, sourceLabel = _a.sourceLabel, targetLabel = _a.targetLabel, onLabelMoved = _a.onLabelMoved, onLabelResized = _a.onLabelResized, onLabelContentChanged = _a.onLabelContentChanged;
|
|
7358
|
-
var _j = React.useState(path), pathStr = _j[0], setPathStr = _j[1];
|
|
7359
|
-
var _k = React.useState(pointsProp !== null && pointsProp !== void 0 ? pointsProp : []), points = _k[0], setPoints = _k[1];
|
|
7360
|
-
var _l = React.useState(false), isDragging = _l[0], setIsDragging = _l[1];
|
|
7361
|
-
var _m = React.useState(), draggingPointIndex = _m[0], setDraggingPointIndex = _m[1];
|
|
7362
|
-
var _o = React.useState({
|
|
7360
|
+
var _j = React$1.useState(path), pathStr = _j[0], setPathStr = _j[1];
|
|
7361
|
+
var _k = React$1.useState(pointsProp !== null && pointsProp !== void 0 ? pointsProp : []), points = _k[0], setPoints = _k[1];
|
|
7362
|
+
var _l = React$1.useState(false), isDragging = _l[0], setIsDragging = _l[1];
|
|
7363
|
+
var _m = React$1.useState(), draggingPointIndex = _m[0], setDraggingPointIndex = _m[1];
|
|
7364
|
+
var _o = React$1.useState({
|
|
7363
7365
|
current: null,
|
|
7364
7366
|
}), selectedLabelRef = _o[0], setSelectedLabelRef = _o[1];
|
|
7365
|
-
var _p = React.useState(false), isSelectedLink = _p[0], setIsSelectedLink = _p[1];
|
|
7366
|
-
var onPaperClicked = React.useContext(paperEventEmitterContext).onPaperClicked;
|
|
7367
|
-
var pathRef = React.useRef(null);
|
|
7368
|
-
var labelRef = React.useRef(null);
|
|
7369
|
-
var sourceLabelRef = React.useRef(null);
|
|
7370
|
-
var targetLabelRef = React.useRef(null);
|
|
7371
|
-
React.useEffect(function () {
|
|
7367
|
+
var _p = React$1.useState(false), isSelectedLink = _p[0], setIsSelectedLink = _p[1];
|
|
7368
|
+
var onPaperClicked = React$1.useContext(paperEventEmitterContext).onPaperClicked;
|
|
7369
|
+
var pathRef = React$1.useRef(null);
|
|
7370
|
+
var labelRef = React$1.useRef(null);
|
|
7371
|
+
var sourceLabelRef = React$1.useRef(null);
|
|
7372
|
+
var targetLabelRef = React$1.useRef(null);
|
|
7373
|
+
React$1.useEffect(function () {
|
|
7372
7374
|
var paperClickListener = onPaperClicked(function () {
|
|
7373
7375
|
setSelectedLabelRef({
|
|
7374
7376
|
current: null,
|
|
@@ -7380,17 +7382,17 @@ var IElementLink = function (_a) {
|
|
|
7380
7382
|
paperClickListener.off();
|
|
7381
7383
|
};
|
|
7382
7384
|
}, []);
|
|
7383
|
-
React.useLayoutEffect(function () {
|
|
7385
|
+
React$1.useLayoutEffect(function () {
|
|
7384
7386
|
var pointsList = __spreadArray(__spreadArray([sourcePosition], points, true), [targetPosition], false);
|
|
7385
7387
|
var _pathStr = createSmoothPathString(pointsList, undefined);
|
|
7386
7388
|
setPathStr(_pathStr);
|
|
7387
7389
|
}, [sourcePosition, points, targetPosition]);
|
|
7388
|
-
React.useEffect(function () {
|
|
7390
|
+
React$1.useEffect(function () {
|
|
7389
7391
|
if (!pathStr)
|
|
7390
7392
|
return;
|
|
7391
7393
|
onPathChanged === null || onPathChanged === void 0 ? void 0 : onPathChanged(pathStr, id);
|
|
7392
7394
|
}, [pathStr, id]);
|
|
7393
|
-
React.useLayoutEffect(function () {
|
|
7395
|
+
React$1.useLayoutEffect(function () {
|
|
7394
7396
|
//handle when creating and moving point
|
|
7395
7397
|
var handleMouseMove = function (ev) {
|
|
7396
7398
|
var mouseEvent = ev;
|
|
@@ -7546,7 +7548,7 @@ var IElementLink = function (_a) {
|
|
|
7546
7548
|
x: relativePosition.x + relativePositionTo.x,
|
|
7547
7549
|
y: relativePosition.y + relativePositionTo.y,
|
|
7548
7550
|
};
|
|
7549
|
-
return (React.createElement(Text$1, { id: label.id, x: position.x, y: position.y, width: size.width, height: size.height, content: content, fontSize: label.fontSize, border: label.border, ref: curLabelRef, container: container, onSelected: function () { return setSelectedLabelRef(curLabelRef); }, onMoved: handleLabelMoved, onResized: handleLabelResized, onContentChanged: handleLabelContentChanged }));
|
|
7551
|
+
return (React$1.createElement(Text$1, { id: label.id, x: position.x, y: position.y, width: size.width, height: size.height, content: content, fontSize: label.fontSize, border: label.border, ref: curLabelRef, container: container, onSelected: function () { return setSelectedLabelRef(curLabelRef); }, onMoved: handleLabelMoved, onResized: handleLabelResized, onContentChanged: handleLabelContentChanged }));
|
|
7550
7552
|
};
|
|
7551
7553
|
var angleMarkerStart = '0';
|
|
7552
7554
|
var angleMarkerEnd = '0';
|
|
@@ -7564,28 +7566,28 @@ var IElementLink = function (_a) {
|
|
|
7564
7566
|
}
|
|
7565
7567
|
centerPathPosition = (_c = pathRef.current) === null || _c === void 0 ? void 0 : _c.getPointAtLength(pathRef.current.getTotalLength() / 2);
|
|
7566
7568
|
}
|
|
7567
|
-
return (React.createElement("g", null,
|
|
7568
|
-
React.createElement("path", { ref: pathRef, d: pathStr, className: isSelectedLink ? CSS_CLASS_LINK_SELECTED : '', fill: "none", stroke: stroke || LINK_DEFAULT_COLOR, strokeWidth: strokeWidth }),
|
|
7569
|
-
React.createElement("path", { d: pathStr, fill: "none", stroke: 'transparent', strokeWidth: LINK_CLICKABLE_STROKE_WIDTH, onClick: handleClickPath, onMouseDown: handleMouseDownOnPath }),
|
|
7570
|
-
isSelectedLink && centerPathPosition && React.createElement("svg", { x: centerPathPosition.x - 10, y: centerPathPosition.y - 10 },
|
|
7571
|
-
React.createElement(CloseIcon, { onClick: onClickDelete })),
|
|
7569
|
+
return (React$1.createElement("g", null,
|
|
7570
|
+
React$1.createElement("path", { ref: pathRef, d: pathStr, className: isSelectedLink ? CSS_CLASS_LINK_SELECTED : '', fill: "none", stroke: stroke || LINK_DEFAULT_COLOR, strokeWidth: strokeWidth }),
|
|
7571
|
+
React$1.createElement("path", { d: pathStr, fill: "none", stroke: 'transparent', strokeWidth: LINK_CLICKABLE_STROKE_WIDTH, onClick: handleClickPath, onMouseDown: handleMouseDownOnPath }),
|
|
7572
|
+
isSelectedLink && centerPathPosition && React$1.createElement("svg", { x: centerPathPosition.x - 10, y: centerPathPosition.y - 10 },
|
|
7573
|
+
React$1.createElement(CloseIcon, { onClick: onClickDelete })),
|
|
7572
7574
|
label && renderLabel(label, 'middle', centerPathPosition),
|
|
7573
7575
|
sourceLabel && renderLabel(sourceLabel, 'source', sourcePosition),
|
|
7574
7576
|
targetLabel && renderLabel(targetLabel, 'target', targetPosition),
|
|
7575
|
-
markerStartPosition && React.createElement("g", { transform: "rotate(".concat(angleMarkerStart, ")"), style: { transformOrigin: 'center', transformBox: 'content-box' } },
|
|
7576
|
-
React.createElement("svg", { x: markerStartPosition.x - markerSize / 2, y: markerStartPosition.y - markerSize / 2, width: markerSize, height: markerSize }, markerStart)),
|
|
7577
|
-
markerEndPosition && React.createElement("g", { transform: "rotate(".concat(angleMarkerEnd, ")"), style: { transformOrigin: 'center', transformBox: 'content-box' } },
|
|
7578
|
-
React.createElement("svg", { x: markerEndPosition.x - markerSize / 2, y: markerEndPosition.y - markerSize / 2, width: markerSize, height: markerSize }, markerEnd))));
|
|
7577
|
+
markerStartPosition && React$1.createElement("g", { transform: "rotate(".concat(angleMarkerStart, ")"), style: { transformOrigin: 'center', transformBox: 'content-box' } },
|
|
7578
|
+
React$1.createElement("svg", { x: markerStartPosition.x - markerSize / 2, y: markerStartPosition.y - markerSize / 2, width: markerSize, height: markerSize }, markerStart)),
|
|
7579
|
+
markerEndPosition && React$1.createElement("g", { transform: "rotate(".concat(angleMarkerEnd, ")"), style: { transformOrigin: 'center', transformBox: 'content-box' } },
|
|
7580
|
+
React$1.createElement("svg", { x: markerEndPosition.x - markerSize / 2, y: markerEndPosition.y - markerSize / 2, width: markerSize, height: markerSize }, markerEnd))));
|
|
7579
7581
|
};
|
|
7580
|
-
var ElementLink = React.memo(IElementLink);
|
|
7582
|
+
var ElementLink = React$1.memo(IElementLink);
|
|
7581
7583
|
|
|
7582
7584
|
var Ruler = function (_a) {
|
|
7583
7585
|
var squareSize = _a.squareSize, border = _a.border;
|
|
7584
7586
|
var numColumns = Math.ceil(3000 / squareSize);
|
|
7585
7587
|
var numRows = Math.ceil(3000 / squareSize);
|
|
7586
7588
|
var tableWidth = numColumns * squareSize;
|
|
7587
|
-
return (React.createElement("table", { style: { position: 'absolute', zIndex: -1, top: 0, left: 0, borderCollapse: 'collapse', width: tableWidth } },
|
|
7588
|
-
React.createElement("tbody", null, Array.from({ length: numRows }).map(function (_, rowIndex) { return (React.createElement("tr", { key: rowIndex, style: { margin: 0, padding: 0 } }, Array.from({ length: numColumns }).map(function (_, colIndex) { return (React.createElement("td", { key: colIndex, style: {
|
|
7589
|
+
return (React$1.createElement("table", { style: { position: 'absolute', zIndex: -1, top: 0, left: 0, borderCollapse: 'collapse', width: tableWidth } },
|
|
7590
|
+
React$1.createElement("tbody", null, Array.from({ length: numRows }).map(function (_, rowIndex) { return (React$1.createElement("tr", { key: rowIndex, style: { margin: 0, padding: 0 } }, Array.from({ length: numColumns }).map(function (_, colIndex) { return (React$1.createElement("td", { key: colIndex, style: {
|
|
7589
7591
|
width: squareSize,
|
|
7590
7592
|
height: squareSize,
|
|
7591
7593
|
border: border,
|
|
@@ -7596,16 +7598,16 @@ var Ruler = function (_a) {
|
|
|
7596
7598
|
position: 'relative',
|
|
7597
7599
|
fontSize: 12,
|
|
7598
7600
|
} },
|
|
7599
|
-
rowIndex === 0 ? React.createElement("span", { style: { marginLeft: "-12px" } }, colIndex * squareSize) : "",
|
|
7600
|
-
colIndex === 0 ? React.createElement("span", { style: { top: "-9px", position: "absolute" } }, rowIndex * squareSize) : "")); }))); }))));
|
|
7601
|
+
rowIndex === 0 ? React$1.createElement("span", { style: { marginLeft: "-12px" } }, colIndex * squareSize) : "",
|
|
7602
|
+
colIndex === 0 ? React$1.createElement("span", { style: { top: "-9px", position: "absolute" } }, rowIndex * squareSize) : "")); }))); }))));
|
|
7601
7603
|
};
|
|
7602
7604
|
|
|
7603
|
-
var ElementWrapper = React.forwardRef(function (_a, ref) {
|
|
7605
|
+
var ElementWrapper = React$1.forwardRef(function (_a, ref) {
|
|
7604
7606
|
var x = _a.x, y = _a.y, children = _a.children; _a.portPlaceholders; _a.ports; var onClick = _a.onClick, onMouseMove = _a.onMouseMove, onMouseLeave = _a.onMouseLeave, onMouseUp = _a.onMouseUp;
|
|
7605
7607
|
var handleMouseDown = function (ev) {
|
|
7606
7608
|
ev.stopPropagation();
|
|
7607
7609
|
};
|
|
7608
|
-
return (React.createElement("svg", { x: x, y: y, onClick: onClick, onMouseDown: handleMouseDown, ref: ref, style: { overflow: "visible" }, onMouseMove: onMouseMove, onMouseLeave: onMouseLeave, onMouseUp: onMouseUp }, children));
|
|
7610
|
+
return (React$1.createElement("svg", { x: x, y: y, onClick: onClick, onMouseDown: handleMouseDown, ref: ref, style: { overflow: "visible" }, onMouseMove: onMouseMove, onMouseLeave: onMouseLeave, onMouseUp: onMouseUp }, children));
|
|
7609
7611
|
});
|
|
7610
7612
|
|
|
7611
7613
|
// Calculate the position of the 4 vertices of a rectangle relative to its parent svg
|
|
@@ -7651,27 +7653,1249 @@ var checkPositionOnLine = function (position, line) {
|
|
|
7651
7653
|
return _line.contains(point);
|
|
7652
7654
|
};
|
|
7653
7655
|
|
|
7656
|
+
var bundle = {exports: {}};
|
|
7657
|
+
|
|
7658
|
+
var cssLayout = {exports: {}};
|
|
7659
|
+
|
|
7660
|
+
(function (module, exports) {
|
|
7661
|
+
// UMD (Universal Module Definition)
|
|
7662
|
+
// See https://github.com/umdjs/umd for reference
|
|
7663
|
+
//
|
|
7664
|
+
// This file uses the following specific UMD implementation:
|
|
7665
|
+
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
|
7666
|
+
(function(root, factory) {
|
|
7667
|
+
{
|
|
7668
|
+
// Node. Does not work with strict CommonJS, but
|
|
7669
|
+
// only CommonJS-like environments that support module.exports,
|
|
7670
|
+
// like Node.
|
|
7671
|
+
module.exports = factory();
|
|
7672
|
+
}
|
|
7673
|
+
}(commonjsGlobal, function() {
|
|
7674
|
+
/**
|
|
7675
|
+
* Copyright (c) 2014, Facebook, Inc.
|
|
7676
|
+
* All rights reserved.
|
|
7677
|
+
*
|
|
7678
|
+
* This source code is licensed under the BSD-style license found in the
|
|
7679
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7680
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
7681
|
+
*/
|
|
7682
|
+
|
|
7683
|
+
var computeLayout = (function() {
|
|
7684
|
+
|
|
7685
|
+
var CSS_UNDEFINED;
|
|
7686
|
+
|
|
7687
|
+
var CSS_DIRECTION_INHERIT = 'inherit';
|
|
7688
|
+
var CSS_DIRECTION_LTR = 'ltr';
|
|
7689
|
+
var CSS_DIRECTION_RTL = 'rtl';
|
|
7690
|
+
|
|
7691
|
+
var CSS_FLEX_DIRECTION_ROW = 'row';
|
|
7692
|
+
var CSS_FLEX_DIRECTION_ROW_REVERSE = 'row-reverse';
|
|
7693
|
+
var CSS_FLEX_DIRECTION_COLUMN = 'column';
|
|
7694
|
+
var CSS_FLEX_DIRECTION_COLUMN_REVERSE = 'column-reverse';
|
|
7695
|
+
|
|
7696
|
+
var CSS_JUSTIFY_FLEX_START = 'flex-start';
|
|
7697
|
+
var CSS_JUSTIFY_CENTER = 'center';
|
|
7698
|
+
var CSS_JUSTIFY_FLEX_END = 'flex-end';
|
|
7699
|
+
var CSS_JUSTIFY_SPACE_BETWEEN = 'space-between';
|
|
7700
|
+
var CSS_JUSTIFY_SPACE_AROUND = 'space-around';
|
|
7701
|
+
|
|
7702
|
+
var CSS_ALIGN_FLEX_START = 'flex-start';
|
|
7703
|
+
var CSS_ALIGN_CENTER = 'center';
|
|
7704
|
+
var CSS_ALIGN_FLEX_END = 'flex-end';
|
|
7705
|
+
var CSS_ALIGN_STRETCH = 'stretch';
|
|
7706
|
+
|
|
7707
|
+
var CSS_POSITION_RELATIVE = 'relative';
|
|
7708
|
+
var CSS_POSITION_ABSOLUTE = 'absolute';
|
|
7709
|
+
|
|
7710
|
+
var leading = {
|
|
7711
|
+
'row': 'left',
|
|
7712
|
+
'row-reverse': 'right',
|
|
7713
|
+
'column': 'top',
|
|
7714
|
+
'column-reverse': 'bottom'
|
|
7715
|
+
};
|
|
7716
|
+
var trailing = {
|
|
7717
|
+
'row': 'right',
|
|
7718
|
+
'row-reverse': 'left',
|
|
7719
|
+
'column': 'bottom',
|
|
7720
|
+
'column-reverse': 'top'
|
|
7721
|
+
};
|
|
7722
|
+
var pos = {
|
|
7723
|
+
'row': 'left',
|
|
7724
|
+
'row-reverse': 'right',
|
|
7725
|
+
'column': 'top',
|
|
7726
|
+
'column-reverse': 'bottom'
|
|
7727
|
+
};
|
|
7728
|
+
var dim = {
|
|
7729
|
+
'row': 'width',
|
|
7730
|
+
'row-reverse': 'width',
|
|
7731
|
+
'column': 'height',
|
|
7732
|
+
'column-reverse': 'height'
|
|
7733
|
+
};
|
|
7734
|
+
|
|
7735
|
+
// When transpiled to Java / C the node type has layout, children and style
|
|
7736
|
+
// properties. For the JavaScript version this function adds these properties
|
|
7737
|
+
// if they don't already exist.
|
|
7738
|
+
function fillNodes(node) {
|
|
7739
|
+
if (!node.layout || node.isDirty) {
|
|
7740
|
+
node.layout = {
|
|
7741
|
+
width: undefined,
|
|
7742
|
+
height: undefined,
|
|
7743
|
+
top: 0,
|
|
7744
|
+
left: 0,
|
|
7745
|
+
right: 0,
|
|
7746
|
+
bottom: 0
|
|
7747
|
+
};
|
|
7748
|
+
}
|
|
7749
|
+
|
|
7750
|
+
if (!node.style) {
|
|
7751
|
+
node.style = {};
|
|
7752
|
+
}
|
|
7753
|
+
|
|
7754
|
+
if (!node.children) {
|
|
7755
|
+
node.children = [];
|
|
7756
|
+
}
|
|
7757
|
+
node.children.forEach(fillNodes);
|
|
7758
|
+
return node;
|
|
7759
|
+
}
|
|
7760
|
+
|
|
7761
|
+
function isUndefined(value) {
|
|
7762
|
+
return value === undefined;
|
|
7763
|
+
}
|
|
7764
|
+
|
|
7765
|
+
function isRowDirection(flexDirection) {
|
|
7766
|
+
return flexDirection === CSS_FLEX_DIRECTION_ROW ||
|
|
7767
|
+
flexDirection === CSS_FLEX_DIRECTION_ROW_REVERSE;
|
|
7768
|
+
}
|
|
7769
|
+
|
|
7770
|
+
function isColumnDirection(flexDirection) {
|
|
7771
|
+
return flexDirection === CSS_FLEX_DIRECTION_COLUMN ||
|
|
7772
|
+
flexDirection === CSS_FLEX_DIRECTION_COLUMN_REVERSE;
|
|
7773
|
+
}
|
|
7774
|
+
|
|
7775
|
+
function getLeadingMargin(node, axis) {
|
|
7776
|
+
if (node.style.marginStart !== undefined && isRowDirection(axis)) {
|
|
7777
|
+
return node.style.marginStart;
|
|
7778
|
+
}
|
|
7779
|
+
|
|
7780
|
+
var value = null;
|
|
7781
|
+
switch (axis) {
|
|
7782
|
+
case 'row': value = node.style.marginLeft; break;
|
|
7783
|
+
case 'row-reverse': value = node.style.marginRight; break;
|
|
7784
|
+
case 'column': value = node.style.marginTop; break;
|
|
7785
|
+
case 'column-reverse': value = node.style.marginBottom; break;
|
|
7786
|
+
}
|
|
7787
|
+
|
|
7788
|
+
if (value !== undefined) {
|
|
7789
|
+
return value;
|
|
7790
|
+
}
|
|
7791
|
+
|
|
7792
|
+
if (node.style.margin !== undefined) {
|
|
7793
|
+
return node.style.margin;
|
|
7794
|
+
}
|
|
7795
|
+
|
|
7796
|
+
return 0;
|
|
7797
|
+
}
|
|
7798
|
+
|
|
7799
|
+
function getTrailingMargin(node, axis) {
|
|
7800
|
+
if (node.style.marginEnd !== undefined && isRowDirection(axis)) {
|
|
7801
|
+
return node.style.marginEnd;
|
|
7802
|
+
}
|
|
7803
|
+
|
|
7804
|
+
var value = null;
|
|
7805
|
+
switch (axis) {
|
|
7806
|
+
case 'row': value = node.style.marginRight; break;
|
|
7807
|
+
case 'row-reverse': value = node.style.marginLeft; break;
|
|
7808
|
+
case 'column': value = node.style.marginBottom; break;
|
|
7809
|
+
case 'column-reverse': value = node.style.marginTop; break;
|
|
7810
|
+
}
|
|
7811
|
+
|
|
7812
|
+
if (value != null) {
|
|
7813
|
+
return value;
|
|
7814
|
+
}
|
|
7815
|
+
|
|
7816
|
+
if (node.style.margin !== undefined) {
|
|
7817
|
+
return node.style.margin;
|
|
7818
|
+
}
|
|
7819
|
+
|
|
7820
|
+
return 0;
|
|
7821
|
+
}
|
|
7822
|
+
|
|
7823
|
+
function getLeadingPadding(node, axis) {
|
|
7824
|
+
if (node.style.paddingStart !== undefined && node.style.paddingStart >= 0
|
|
7825
|
+
&& isRowDirection(axis)) {
|
|
7826
|
+
return node.style.paddingStart;
|
|
7827
|
+
}
|
|
7828
|
+
|
|
7829
|
+
var value = null;
|
|
7830
|
+
switch (axis) {
|
|
7831
|
+
case 'row': value = node.style.paddingLeft; break;
|
|
7832
|
+
case 'row-reverse': value = node.style.paddingRight; break;
|
|
7833
|
+
case 'column': value = node.style.paddingTop; break;
|
|
7834
|
+
case 'column-reverse': value = node.style.paddingBottom; break;
|
|
7835
|
+
}
|
|
7836
|
+
|
|
7837
|
+
if (value != null && value >= 0) {
|
|
7838
|
+
return value;
|
|
7839
|
+
}
|
|
7840
|
+
|
|
7841
|
+
if (node.style.padding !== undefined && node.style.padding >= 0) {
|
|
7842
|
+
return node.style.padding;
|
|
7843
|
+
}
|
|
7844
|
+
|
|
7845
|
+
return 0;
|
|
7846
|
+
}
|
|
7847
|
+
|
|
7848
|
+
function getTrailingPadding(node, axis) {
|
|
7849
|
+
if (node.style.paddingEnd !== undefined && node.style.paddingEnd >= 0
|
|
7850
|
+
&& isRowDirection(axis)) {
|
|
7851
|
+
return node.style.paddingEnd;
|
|
7852
|
+
}
|
|
7853
|
+
|
|
7854
|
+
var value = null;
|
|
7855
|
+
switch (axis) {
|
|
7856
|
+
case 'row': value = node.style.paddingRight; break;
|
|
7857
|
+
case 'row-reverse': value = node.style.paddingLeft; break;
|
|
7858
|
+
case 'column': value = node.style.paddingBottom; break;
|
|
7859
|
+
case 'column-reverse': value = node.style.paddingTop; break;
|
|
7860
|
+
}
|
|
7861
|
+
|
|
7862
|
+
if (value != null && value >= 0) {
|
|
7863
|
+
return value;
|
|
7864
|
+
}
|
|
7865
|
+
|
|
7866
|
+
if (node.style.padding !== undefined && node.style.padding >= 0) {
|
|
7867
|
+
return node.style.padding;
|
|
7868
|
+
}
|
|
7869
|
+
|
|
7870
|
+
return 0;
|
|
7871
|
+
}
|
|
7872
|
+
|
|
7873
|
+
function getLeadingBorder(node, axis) {
|
|
7874
|
+
if (node.style.borderStartWidth !== undefined && node.style.borderStartWidth >= 0
|
|
7875
|
+
&& isRowDirection(axis)) {
|
|
7876
|
+
return node.style.borderStartWidth;
|
|
7877
|
+
}
|
|
7878
|
+
|
|
7879
|
+
var value = null;
|
|
7880
|
+
switch (axis) {
|
|
7881
|
+
case 'row': value = node.style.borderLeftWidth; break;
|
|
7882
|
+
case 'row-reverse': value = node.style.borderRightWidth; break;
|
|
7883
|
+
case 'column': value = node.style.borderTopWidth; break;
|
|
7884
|
+
case 'column-reverse': value = node.style.borderBottomWidth; break;
|
|
7885
|
+
}
|
|
7886
|
+
|
|
7887
|
+
if (value != null && value >= 0) {
|
|
7888
|
+
return value;
|
|
7889
|
+
}
|
|
7890
|
+
|
|
7891
|
+
if (node.style.borderWidth !== undefined && node.style.borderWidth >= 0) {
|
|
7892
|
+
return node.style.borderWidth;
|
|
7893
|
+
}
|
|
7894
|
+
|
|
7895
|
+
return 0;
|
|
7896
|
+
}
|
|
7897
|
+
|
|
7898
|
+
function getTrailingBorder(node, axis) {
|
|
7899
|
+
if (node.style.borderEndWidth !== undefined && node.style.borderEndWidth >= 0
|
|
7900
|
+
&& isRowDirection(axis)) {
|
|
7901
|
+
return node.style.borderEndWidth;
|
|
7902
|
+
}
|
|
7903
|
+
|
|
7904
|
+
var value = null;
|
|
7905
|
+
switch (axis) {
|
|
7906
|
+
case 'row': value = node.style.borderRightWidth; break;
|
|
7907
|
+
case 'row-reverse': value = node.style.borderLeftWidth; break;
|
|
7908
|
+
case 'column': value = node.style.borderBottomWidth; break;
|
|
7909
|
+
case 'column-reverse': value = node.style.borderTopWidth; break;
|
|
7910
|
+
}
|
|
7911
|
+
|
|
7912
|
+
if (value != null && value >= 0) {
|
|
7913
|
+
return value;
|
|
7914
|
+
}
|
|
7915
|
+
|
|
7916
|
+
if (node.style.borderWidth !== undefined && node.style.borderWidth >= 0) {
|
|
7917
|
+
return node.style.borderWidth;
|
|
7918
|
+
}
|
|
7919
|
+
|
|
7920
|
+
return 0;
|
|
7921
|
+
}
|
|
7922
|
+
|
|
7923
|
+
function getLeadingPaddingAndBorder(node, axis) {
|
|
7924
|
+
return getLeadingPadding(node, axis) + getLeadingBorder(node, axis);
|
|
7925
|
+
}
|
|
7926
|
+
|
|
7927
|
+
function getTrailingPaddingAndBorder(node, axis) {
|
|
7928
|
+
return getTrailingPadding(node, axis) + getTrailingBorder(node, axis);
|
|
7929
|
+
}
|
|
7930
|
+
|
|
7931
|
+
function getBorderAxis(node, axis) {
|
|
7932
|
+
return getLeadingBorder(node, axis) + getTrailingBorder(node, axis);
|
|
7933
|
+
}
|
|
7934
|
+
|
|
7935
|
+
function getMarginAxis(node, axis) {
|
|
7936
|
+
return getLeadingMargin(node, axis) + getTrailingMargin(node, axis);
|
|
7937
|
+
}
|
|
7938
|
+
|
|
7939
|
+
function getPaddingAndBorderAxis(node, axis) {
|
|
7940
|
+
return getLeadingPaddingAndBorder(node, axis) +
|
|
7941
|
+
getTrailingPaddingAndBorder(node, axis);
|
|
7942
|
+
}
|
|
7943
|
+
|
|
7944
|
+
function getJustifyContent(node) {
|
|
7945
|
+
if (node.style.justifyContent) {
|
|
7946
|
+
return node.style.justifyContent;
|
|
7947
|
+
}
|
|
7948
|
+
return 'flex-start';
|
|
7949
|
+
}
|
|
7950
|
+
|
|
7951
|
+
function getAlignContent(node) {
|
|
7952
|
+
if (node.style.alignContent) {
|
|
7953
|
+
return node.style.alignContent;
|
|
7954
|
+
}
|
|
7955
|
+
return 'flex-start';
|
|
7956
|
+
}
|
|
7957
|
+
|
|
7958
|
+
function getAlignItem(node, child) {
|
|
7959
|
+
if (child.style.alignSelf) {
|
|
7960
|
+
return child.style.alignSelf;
|
|
7961
|
+
}
|
|
7962
|
+
if (node.style.alignItems) {
|
|
7963
|
+
return node.style.alignItems;
|
|
7964
|
+
}
|
|
7965
|
+
return 'stretch';
|
|
7966
|
+
}
|
|
7967
|
+
|
|
7968
|
+
function resolveAxis(axis, direction) {
|
|
7969
|
+
if (direction === CSS_DIRECTION_RTL) {
|
|
7970
|
+
if (axis === CSS_FLEX_DIRECTION_ROW) {
|
|
7971
|
+
return CSS_FLEX_DIRECTION_ROW_REVERSE;
|
|
7972
|
+
} else if (axis === CSS_FLEX_DIRECTION_ROW_REVERSE) {
|
|
7973
|
+
return CSS_FLEX_DIRECTION_ROW;
|
|
7974
|
+
}
|
|
7975
|
+
}
|
|
7976
|
+
|
|
7977
|
+
return axis;
|
|
7978
|
+
}
|
|
7979
|
+
|
|
7980
|
+
function resolveDirection(node, parentDirection) {
|
|
7981
|
+
var direction;
|
|
7982
|
+
if (node.style.direction) {
|
|
7983
|
+
direction = node.style.direction;
|
|
7984
|
+
} else {
|
|
7985
|
+
direction = CSS_DIRECTION_INHERIT;
|
|
7986
|
+
}
|
|
7987
|
+
|
|
7988
|
+
if (direction === CSS_DIRECTION_INHERIT) {
|
|
7989
|
+
direction = (parentDirection === undefined ? CSS_DIRECTION_LTR : parentDirection);
|
|
7990
|
+
}
|
|
7991
|
+
|
|
7992
|
+
return direction;
|
|
7993
|
+
}
|
|
7994
|
+
|
|
7995
|
+
function getFlexDirection(node) {
|
|
7996
|
+
if (node.style.flexDirection) {
|
|
7997
|
+
return node.style.flexDirection;
|
|
7998
|
+
}
|
|
7999
|
+
return CSS_FLEX_DIRECTION_COLUMN;
|
|
8000
|
+
}
|
|
8001
|
+
|
|
8002
|
+
function getCrossFlexDirection(flexDirection, direction) {
|
|
8003
|
+
if (isColumnDirection(flexDirection)) {
|
|
8004
|
+
return resolveAxis(CSS_FLEX_DIRECTION_ROW, direction);
|
|
8005
|
+
} else {
|
|
8006
|
+
return CSS_FLEX_DIRECTION_COLUMN;
|
|
8007
|
+
}
|
|
8008
|
+
}
|
|
8009
|
+
|
|
8010
|
+
function getPositionType(node) {
|
|
8011
|
+
if (node.style.position) {
|
|
8012
|
+
return node.style.position;
|
|
8013
|
+
}
|
|
8014
|
+
return 'relative';
|
|
8015
|
+
}
|
|
8016
|
+
|
|
8017
|
+
function isFlex(node) {
|
|
8018
|
+
return (
|
|
8019
|
+
getPositionType(node) === CSS_POSITION_RELATIVE &&
|
|
8020
|
+
node.style.flex > 0
|
|
8021
|
+
);
|
|
8022
|
+
}
|
|
8023
|
+
|
|
8024
|
+
function isFlexWrap(node) {
|
|
8025
|
+
return node.style.flexWrap === 'wrap';
|
|
8026
|
+
}
|
|
8027
|
+
|
|
8028
|
+
function getDimWithMargin(node, axis) {
|
|
8029
|
+
return node.layout[dim[axis]] + getMarginAxis(node, axis);
|
|
8030
|
+
}
|
|
8031
|
+
|
|
8032
|
+
function isDimDefined(node, axis) {
|
|
8033
|
+
return node.style[dim[axis]] !== undefined && node.style[dim[axis]] >= 0;
|
|
8034
|
+
}
|
|
8035
|
+
|
|
8036
|
+
function isPosDefined(node, pos) {
|
|
8037
|
+
return node.style[pos] !== undefined;
|
|
8038
|
+
}
|
|
8039
|
+
|
|
8040
|
+
function isMeasureDefined(node) {
|
|
8041
|
+
return node.style.measure !== undefined;
|
|
8042
|
+
}
|
|
8043
|
+
|
|
8044
|
+
function getPosition(node, pos) {
|
|
8045
|
+
if (node.style[pos] !== undefined) {
|
|
8046
|
+
return node.style[pos];
|
|
8047
|
+
}
|
|
8048
|
+
return 0;
|
|
8049
|
+
}
|
|
8050
|
+
|
|
8051
|
+
function boundAxis(node, axis, value) {
|
|
8052
|
+
var min = {
|
|
8053
|
+
'row': node.style.minWidth,
|
|
8054
|
+
'row-reverse': node.style.minWidth,
|
|
8055
|
+
'column': node.style.minHeight,
|
|
8056
|
+
'column-reverse': node.style.minHeight
|
|
8057
|
+
}[axis];
|
|
8058
|
+
|
|
8059
|
+
var max = {
|
|
8060
|
+
'row': node.style.maxWidth,
|
|
8061
|
+
'row-reverse': node.style.maxWidth,
|
|
8062
|
+
'column': node.style.maxHeight,
|
|
8063
|
+
'column-reverse': node.style.maxHeight
|
|
8064
|
+
}[axis];
|
|
8065
|
+
|
|
8066
|
+
var boundValue = value;
|
|
8067
|
+
if (max !== undefined && max >= 0 && boundValue > max) {
|
|
8068
|
+
boundValue = max;
|
|
8069
|
+
}
|
|
8070
|
+
if (min !== undefined && min >= 0 && boundValue < min) {
|
|
8071
|
+
boundValue = min;
|
|
8072
|
+
}
|
|
8073
|
+
return boundValue;
|
|
8074
|
+
}
|
|
8075
|
+
|
|
8076
|
+
function fmaxf(a, b) {
|
|
8077
|
+
if (a > b) {
|
|
8078
|
+
return a;
|
|
8079
|
+
}
|
|
8080
|
+
return b;
|
|
8081
|
+
}
|
|
8082
|
+
|
|
8083
|
+
// When the user specifically sets a value for width or height
|
|
8084
|
+
function setDimensionFromStyle(node, axis) {
|
|
8085
|
+
// The parent already computed us a width or height. We just skip it
|
|
8086
|
+
if (node.layout[dim[axis]] !== undefined) {
|
|
8087
|
+
return;
|
|
8088
|
+
}
|
|
8089
|
+
// We only run if there's a width or height defined
|
|
8090
|
+
if (!isDimDefined(node, axis)) {
|
|
8091
|
+
return;
|
|
8092
|
+
}
|
|
8093
|
+
|
|
8094
|
+
// The dimensions can never be smaller than the padding and border
|
|
8095
|
+
node.layout[dim[axis]] = fmaxf(
|
|
8096
|
+
boundAxis(node, axis, node.style[dim[axis]]),
|
|
8097
|
+
getPaddingAndBorderAxis(node, axis)
|
|
8098
|
+
);
|
|
8099
|
+
}
|
|
8100
|
+
|
|
8101
|
+
function setTrailingPosition(node, child, axis) {
|
|
8102
|
+
child.layout[trailing[axis]] = node.layout[dim[axis]] -
|
|
8103
|
+
child.layout[dim[axis]] - child.layout[pos[axis]];
|
|
8104
|
+
}
|
|
8105
|
+
|
|
8106
|
+
// If both left and right are defined, then use left. Otherwise return
|
|
8107
|
+
// +left or -right depending on which is defined.
|
|
8108
|
+
function getRelativePosition(node, axis) {
|
|
8109
|
+
if (node.style[leading[axis]] !== undefined) {
|
|
8110
|
+
return getPosition(node, leading[axis]);
|
|
8111
|
+
}
|
|
8112
|
+
return -getPosition(node, trailing[axis]);
|
|
8113
|
+
}
|
|
8114
|
+
|
|
8115
|
+
function layoutNodeImpl(node, parentMaxWidth, /*css_direction_t*/parentDirection) {
|
|
8116
|
+
var/*css_direction_t*/ direction = resolveDirection(node, parentDirection);
|
|
8117
|
+
var/*(c)!css_flex_direction_t*//*(java)!int*/ mainAxis = resolveAxis(getFlexDirection(node), direction);
|
|
8118
|
+
var/*(c)!css_flex_direction_t*//*(java)!int*/ crossAxis = getCrossFlexDirection(mainAxis, direction);
|
|
8119
|
+
var/*(c)!css_flex_direction_t*//*(java)!int*/ resolvedRowAxis = resolveAxis(CSS_FLEX_DIRECTION_ROW, direction);
|
|
8120
|
+
|
|
8121
|
+
// Handle width and height style attributes
|
|
8122
|
+
setDimensionFromStyle(node, mainAxis);
|
|
8123
|
+
setDimensionFromStyle(node, crossAxis);
|
|
8124
|
+
|
|
8125
|
+
// Set the resolved resolution in the node's layout
|
|
8126
|
+
node.layout.direction = direction;
|
|
8127
|
+
|
|
8128
|
+
// The position is set by the parent, but we need to complete it with a
|
|
8129
|
+
// delta composed of the margin and left/top/right/bottom
|
|
8130
|
+
node.layout[leading[mainAxis]] += getLeadingMargin(node, mainAxis) +
|
|
8131
|
+
getRelativePosition(node, mainAxis);
|
|
8132
|
+
node.layout[trailing[mainAxis]] += getTrailingMargin(node, mainAxis) +
|
|
8133
|
+
getRelativePosition(node, mainAxis);
|
|
8134
|
+
node.layout[leading[crossAxis]] += getLeadingMargin(node, crossAxis) +
|
|
8135
|
+
getRelativePosition(node, crossAxis);
|
|
8136
|
+
node.layout[trailing[crossAxis]] += getTrailingMargin(node, crossAxis) +
|
|
8137
|
+
getRelativePosition(node, crossAxis);
|
|
8138
|
+
|
|
8139
|
+
// Inline immutable values from the target node to avoid excessive method
|
|
8140
|
+
// invocations during the layout calculation.
|
|
8141
|
+
var/*int*/ childCount = node.children.length;
|
|
8142
|
+
var/*float*/ paddingAndBorderAxisResolvedRow = getPaddingAndBorderAxis(node, resolvedRowAxis);
|
|
8143
|
+
|
|
8144
|
+
if (isMeasureDefined(node)) {
|
|
8145
|
+
var/*bool*/ isResolvedRowDimDefined = !isUndefined(node.layout[dim[resolvedRowAxis]]);
|
|
8146
|
+
|
|
8147
|
+
var/*float*/ width = CSS_UNDEFINED;
|
|
8148
|
+
if (isDimDefined(node, resolvedRowAxis)) {
|
|
8149
|
+
width = node.style.width;
|
|
8150
|
+
} else if (isResolvedRowDimDefined) {
|
|
8151
|
+
width = node.layout[dim[resolvedRowAxis]];
|
|
8152
|
+
} else {
|
|
8153
|
+
width = parentMaxWidth -
|
|
8154
|
+
getMarginAxis(node, resolvedRowAxis);
|
|
8155
|
+
}
|
|
8156
|
+
width -= paddingAndBorderAxisResolvedRow;
|
|
8157
|
+
|
|
8158
|
+
// We only need to give a dimension for the text if we haven't got any
|
|
8159
|
+
// for it computed yet. It can either be from the style attribute or because
|
|
8160
|
+
// the element is flexible.
|
|
8161
|
+
var/*bool*/ isRowUndefined = !isDimDefined(node, resolvedRowAxis) && !isResolvedRowDimDefined;
|
|
8162
|
+
var/*bool*/ isColumnUndefined = !isDimDefined(node, CSS_FLEX_DIRECTION_COLUMN) &&
|
|
8163
|
+
isUndefined(node.layout[dim[CSS_FLEX_DIRECTION_COLUMN]]);
|
|
8164
|
+
|
|
8165
|
+
// Let's not measure the text if we already know both dimensions
|
|
8166
|
+
if (isRowUndefined || isColumnUndefined) {
|
|
8167
|
+
var/*css_dim_t*/ measureDim = node.style.measure(
|
|
8168
|
+
/*(c)!node->context,*/
|
|
8169
|
+
/*(java)!layoutContext.measureOutput,*/
|
|
8170
|
+
width
|
|
8171
|
+
);
|
|
8172
|
+
if (isRowUndefined) {
|
|
8173
|
+
node.layout.width = measureDim.width +
|
|
8174
|
+
paddingAndBorderAxisResolvedRow;
|
|
8175
|
+
}
|
|
8176
|
+
if (isColumnUndefined) {
|
|
8177
|
+
node.layout.height = measureDim.height +
|
|
8178
|
+
getPaddingAndBorderAxis(node, CSS_FLEX_DIRECTION_COLUMN);
|
|
8179
|
+
}
|
|
8180
|
+
}
|
|
8181
|
+
if (childCount === 0) {
|
|
8182
|
+
return;
|
|
8183
|
+
}
|
|
8184
|
+
}
|
|
8185
|
+
|
|
8186
|
+
var/*bool*/ isNodeFlexWrap = isFlexWrap(node);
|
|
8187
|
+
|
|
8188
|
+
var/*css_justify_t*/ justifyContent = getJustifyContent(node);
|
|
8189
|
+
|
|
8190
|
+
var/*float*/ leadingPaddingAndBorderMain = getLeadingPaddingAndBorder(node, mainAxis);
|
|
8191
|
+
var/*float*/ leadingPaddingAndBorderCross = getLeadingPaddingAndBorder(node, crossAxis);
|
|
8192
|
+
var/*float*/ paddingAndBorderAxisMain = getPaddingAndBorderAxis(node, mainAxis);
|
|
8193
|
+
var/*float*/ paddingAndBorderAxisCross = getPaddingAndBorderAxis(node, crossAxis);
|
|
8194
|
+
|
|
8195
|
+
var/*bool*/ isMainDimDefined = !isUndefined(node.layout[dim[mainAxis]]);
|
|
8196
|
+
var/*bool*/ isCrossDimDefined = !isUndefined(node.layout[dim[crossAxis]]);
|
|
8197
|
+
var/*bool*/ isMainRowDirection = isRowDirection(mainAxis);
|
|
8198
|
+
|
|
8199
|
+
var/*int*/ i;
|
|
8200
|
+
var/*int*/ ii;
|
|
8201
|
+
var/*css_node_t**/ child;
|
|
8202
|
+
var/*(c)!css_flex_direction_t*//*(java)!int*/ axis;
|
|
8203
|
+
|
|
8204
|
+
var/*css_node_t**/ firstAbsoluteChild = null;
|
|
8205
|
+
var/*css_node_t**/ currentAbsoluteChild = null;
|
|
8206
|
+
|
|
8207
|
+
var/*float*/ definedMainDim = CSS_UNDEFINED;
|
|
8208
|
+
if (isMainDimDefined) {
|
|
8209
|
+
definedMainDim = node.layout[dim[mainAxis]] - paddingAndBorderAxisMain;
|
|
8210
|
+
}
|
|
8211
|
+
|
|
8212
|
+
// We want to execute the next two loops one per line with flex-wrap
|
|
8213
|
+
var/*int*/ startLine = 0;
|
|
8214
|
+
var/*int*/ endLine = 0;
|
|
8215
|
+
// var/*int*/ nextOffset = 0;
|
|
8216
|
+
var/*int*/ alreadyComputedNextLayout = 0;
|
|
8217
|
+
// We aggregate the total dimensions of the container in those two variables
|
|
8218
|
+
var/*float*/ linesCrossDim = 0;
|
|
8219
|
+
var/*float*/ linesMainDim = 0;
|
|
8220
|
+
var/*int*/ linesCount = 0;
|
|
8221
|
+
while (endLine < childCount) {
|
|
8222
|
+
// <Loop A> Layout non flexible children and count children by type
|
|
8223
|
+
|
|
8224
|
+
// mainContentDim is accumulation of the dimensions and margin of all the
|
|
8225
|
+
// non flexible children. This will be used in order to either set the
|
|
8226
|
+
// dimensions of the node if none already exist, or to compute the
|
|
8227
|
+
// remaining space left for the flexible children.
|
|
8228
|
+
var/*float*/ mainContentDim = 0;
|
|
8229
|
+
|
|
8230
|
+
// There are three kind of children, non flexible, flexible and absolute.
|
|
8231
|
+
// We need to know how many there are in order to distribute the space.
|
|
8232
|
+
var/*int*/ flexibleChildrenCount = 0;
|
|
8233
|
+
var/*float*/ totalFlexible = 0;
|
|
8234
|
+
var/*int*/ nonFlexibleChildrenCount = 0;
|
|
8235
|
+
|
|
8236
|
+
// Use the line loop to position children in the main axis for as long
|
|
8237
|
+
// as they are using a simple stacking behaviour. Children that are
|
|
8238
|
+
// immediately stacked in the initial loop will not be touched again
|
|
8239
|
+
// in <Loop C>.
|
|
8240
|
+
var/*bool*/ isSimpleStackMain =
|
|
8241
|
+
(isMainDimDefined && justifyContent === CSS_JUSTIFY_FLEX_START) ||
|
|
8242
|
+
(!isMainDimDefined && justifyContent !== CSS_JUSTIFY_CENTER);
|
|
8243
|
+
var/*int*/ firstComplexMain = (isSimpleStackMain ? childCount : startLine);
|
|
8244
|
+
|
|
8245
|
+
// Use the initial line loop to position children in the cross axis for
|
|
8246
|
+
// as long as they are relatively positioned with alignment STRETCH or
|
|
8247
|
+
// FLEX_START. Children that are immediately stacked in the initial loop
|
|
8248
|
+
// will not be touched again in <Loop D>.
|
|
8249
|
+
var/*bool*/ isSimpleStackCross = true;
|
|
8250
|
+
var/*int*/ firstComplexCross = childCount;
|
|
8251
|
+
|
|
8252
|
+
var/*css_node_t**/ firstFlexChild = null;
|
|
8253
|
+
var/*css_node_t**/ currentFlexChild = null;
|
|
8254
|
+
|
|
8255
|
+
var/*float*/ mainDim = leadingPaddingAndBorderMain;
|
|
8256
|
+
var/*float*/ crossDim = 0;
|
|
8257
|
+
|
|
8258
|
+
var/*float*/ maxWidth;
|
|
8259
|
+
for (i = startLine; i < childCount; ++i) {
|
|
8260
|
+
child = node.children[i];
|
|
8261
|
+
child.lineIndex = linesCount;
|
|
8262
|
+
|
|
8263
|
+
child.nextAbsoluteChild = null;
|
|
8264
|
+
child.nextFlexChild = null;
|
|
8265
|
+
|
|
8266
|
+
var/*css_align_t*/ alignItem = getAlignItem(node, child);
|
|
8267
|
+
|
|
8268
|
+
// Pre-fill cross axis dimensions when the child is using stretch before
|
|
8269
|
+
// we call the recursive layout pass
|
|
8270
|
+
if (alignItem === CSS_ALIGN_STRETCH &&
|
|
8271
|
+
getPositionType(child) === CSS_POSITION_RELATIVE &&
|
|
8272
|
+
isCrossDimDefined &&
|
|
8273
|
+
!isDimDefined(child, crossAxis)) {
|
|
8274
|
+
child.layout[dim[crossAxis]] = fmaxf(
|
|
8275
|
+
boundAxis(child, crossAxis, node.layout[dim[crossAxis]] -
|
|
8276
|
+
paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)),
|
|
8277
|
+
// You never want to go smaller than padding
|
|
8278
|
+
getPaddingAndBorderAxis(child, crossAxis)
|
|
8279
|
+
);
|
|
8280
|
+
} else if (getPositionType(child) === CSS_POSITION_ABSOLUTE) {
|
|
8281
|
+
// Store a private linked list of absolutely positioned children
|
|
8282
|
+
// so that we can efficiently traverse them later.
|
|
8283
|
+
if (firstAbsoluteChild === null) {
|
|
8284
|
+
firstAbsoluteChild = child;
|
|
8285
|
+
}
|
|
8286
|
+
if (currentAbsoluteChild !== null) {
|
|
8287
|
+
currentAbsoluteChild.nextAbsoluteChild = child;
|
|
8288
|
+
}
|
|
8289
|
+
currentAbsoluteChild = child;
|
|
8290
|
+
|
|
8291
|
+
// Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both
|
|
8292
|
+
// left and right or top and bottom).
|
|
8293
|
+
for (ii = 0; ii < 2; ii++) {
|
|
8294
|
+
axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;
|
|
8295
|
+
if (!isUndefined(node.layout[dim[axis]]) &&
|
|
8296
|
+
!isDimDefined(child, axis) &&
|
|
8297
|
+
isPosDefined(child, leading[axis]) &&
|
|
8298
|
+
isPosDefined(child, trailing[axis])) {
|
|
8299
|
+
child.layout[dim[axis]] = fmaxf(
|
|
8300
|
+
boundAxis(child, axis, node.layout[dim[axis]] -
|
|
8301
|
+
getPaddingAndBorderAxis(node, axis) -
|
|
8302
|
+
getMarginAxis(child, axis) -
|
|
8303
|
+
getPosition(child, leading[axis]) -
|
|
8304
|
+
getPosition(child, trailing[axis])),
|
|
8305
|
+
// You never want to go smaller than padding
|
|
8306
|
+
getPaddingAndBorderAxis(child, axis)
|
|
8307
|
+
);
|
|
8308
|
+
}
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
|
|
8312
|
+
var/*float*/ nextContentDim = 0;
|
|
8313
|
+
|
|
8314
|
+
// It only makes sense to consider a child flexible if we have a computed
|
|
8315
|
+
// dimension for the node.
|
|
8316
|
+
if (isMainDimDefined && isFlex(child)) {
|
|
8317
|
+
flexibleChildrenCount++;
|
|
8318
|
+
totalFlexible += child.style.flex;
|
|
8319
|
+
|
|
8320
|
+
// Store a private linked list of flexible children so that we can
|
|
8321
|
+
// efficiently traverse them later.
|
|
8322
|
+
if (firstFlexChild === null) {
|
|
8323
|
+
firstFlexChild = child;
|
|
8324
|
+
}
|
|
8325
|
+
if (currentFlexChild !== null) {
|
|
8326
|
+
currentFlexChild.nextFlexChild = child;
|
|
8327
|
+
}
|
|
8328
|
+
currentFlexChild = child;
|
|
8329
|
+
|
|
8330
|
+
// Even if we don't know its exact size yet, we already know the padding,
|
|
8331
|
+
// border and margin. We'll use this partial information, which represents
|
|
8332
|
+
// the smallest possible size for the child, to compute the remaining
|
|
8333
|
+
// available space.
|
|
8334
|
+
nextContentDim = getPaddingAndBorderAxis(child, mainAxis) +
|
|
8335
|
+
getMarginAxis(child, mainAxis);
|
|
8336
|
+
|
|
8337
|
+
} else {
|
|
8338
|
+
maxWidth = CSS_UNDEFINED;
|
|
8339
|
+
if (!isMainRowDirection) {
|
|
8340
|
+
if (isDimDefined(node, resolvedRowAxis)) {
|
|
8341
|
+
maxWidth = node.layout[dim[resolvedRowAxis]] -
|
|
8342
|
+
paddingAndBorderAxisResolvedRow;
|
|
8343
|
+
} else {
|
|
8344
|
+
maxWidth = parentMaxWidth -
|
|
8345
|
+
getMarginAxis(node, resolvedRowAxis) -
|
|
8346
|
+
paddingAndBorderAxisResolvedRow;
|
|
8347
|
+
}
|
|
8348
|
+
}
|
|
8349
|
+
|
|
8350
|
+
// This is the main recursive call. We layout non flexible children.
|
|
8351
|
+
if (alreadyComputedNextLayout === 0) {
|
|
8352
|
+
layoutNode(/*(java)!layoutContext, */child, maxWidth, direction);
|
|
8353
|
+
}
|
|
8354
|
+
|
|
8355
|
+
// Absolute positioned elements do not take part of the layout, so we
|
|
8356
|
+
// don't use them to compute mainContentDim
|
|
8357
|
+
if (getPositionType(child) === CSS_POSITION_RELATIVE) {
|
|
8358
|
+
nonFlexibleChildrenCount++;
|
|
8359
|
+
// At this point we know the final size and margin of the element.
|
|
8360
|
+
nextContentDim = getDimWithMargin(child, mainAxis);
|
|
8361
|
+
}
|
|
8362
|
+
}
|
|
8363
|
+
|
|
8364
|
+
// The element we are about to add would make us go to the next line
|
|
8365
|
+
if (isNodeFlexWrap &&
|
|
8366
|
+
isMainDimDefined &&
|
|
8367
|
+
mainContentDim + nextContentDim > definedMainDim &&
|
|
8368
|
+
// If there's only one element, then it's bigger than the content
|
|
8369
|
+
// and needs its own line
|
|
8370
|
+
i !== startLine) {
|
|
8371
|
+
nonFlexibleChildrenCount--;
|
|
8372
|
+
alreadyComputedNextLayout = 1;
|
|
8373
|
+
break;
|
|
8374
|
+
}
|
|
8375
|
+
|
|
8376
|
+
// Disable simple stacking in the main axis for the current line as
|
|
8377
|
+
// we found a non-trivial child. The remaining children will be laid out
|
|
8378
|
+
// in <Loop C>.
|
|
8379
|
+
if (isSimpleStackMain &&
|
|
8380
|
+
(getPositionType(child) !== CSS_POSITION_RELATIVE || isFlex(child))) {
|
|
8381
|
+
isSimpleStackMain = false;
|
|
8382
|
+
firstComplexMain = i;
|
|
8383
|
+
}
|
|
8384
|
+
|
|
8385
|
+
// Disable simple stacking in the cross axis for the current line as
|
|
8386
|
+
// we found a non-trivial child. The remaining children will be laid out
|
|
8387
|
+
// in <Loop D>.
|
|
8388
|
+
if (isSimpleStackCross &&
|
|
8389
|
+
(getPositionType(child) !== CSS_POSITION_RELATIVE ||
|
|
8390
|
+
(alignItem !== CSS_ALIGN_STRETCH && alignItem !== CSS_ALIGN_FLEX_START) ||
|
|
8391
|
+
isUndefined(child.layout[dim[crossAxis]]))) {
|
|
8392
|
+
isSimpleStackCross = false;
|
|
8393
|
+
firstComplexCross = i;
|
|
8394
|
+
}
|
|
8395
|
+
|
|
8396
|
+
if (isSimpleStackMain) {
|
|
8397
|
+
child.layout[pos[mainAxis]] += mainDim;
|
|
8398
|
+
if (isMainDimDefined) {
|
|
8399
|
+
setTrailingPosition(node, child, mainAxis);
|
|
8400
|
+
}
|
|
8401
|
+
|
|
8402
|
+
mainDim += getDimWithMargin(child, mainAxis);
|
|
8403
|
+
crossDim = fmaxf(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis)));
|
|
8404
|
+
}
|
|
8405
|
+
|
|
8406
|
+
if (isSimpleStackCross) {
|
|
8407
|
+
child.layout[pos[crossAxis]] += linesCrossDim + leadingPaddingAndBorderCross;
|
|
8408
|
+
if (isCrossDimDefined) {
|
|
8409
|
+
setTrailingPosition(node, child, crossAxis);
|
|
8410
|
+
}
|
|
8411
|
+
}
|
|
8412
|
+
|
|
8413
|
+
alreadyComputedNextLayout = 0;
|
|
8414
|
+
mainContentDim += nextContentDim;
|
|
8415
|
+
endLine = i + 1;
|
|
8416
|
+
}
|
|
8417
|
+
|
|
8418
|
+
// <Loop B> Layout flexible children and allocate empty space
|
|
8419
|
+
|
|
8420
|
+
// In order to position the elements in the main axis, we have two
|
|
8421
|
+
// controls. The space between the beginning and the first element
|
|
8422
|
+
// and the space between each two elements.
|
|
8423
|
+
var/*float*/ leadingMainDim = 0;
|
|
8424
|
+
var/*float*/ betweenMainDim = 0;
|
|
8425
|
+
|
|
8426
|
+
// The remaining available space that needs to be allocated
|
|
8427
|
+
var/*float*/ remainingMainDim = 0;
|
|
8428
|
+
if (isMainDimDefined) {
|
|
8429
|
+
remainingMainDim = definedMainDim - mainContentDim;
|
|
8430
|
+
} else {
|
|
8431
|
+
remainingMainDim = fmaxf(mainContentDim, 0) - mainContentDim;
|
|
8432
|
+
}
|
|
8433
|
+
|
|
8434
|
+
// If there are flexible children in the mix, they are going to fill the
|
|
8435
|
+
// remaining space
|
|
8436
|
+
if (flexibleChildrenCount !== 0) {
|
|
8437
|
+
var/*float*/ flexibleMainDim = remainingMainDim / totalFlexible;
|
|
8438
|
+
var/*float*/ baseMainDim;
|
|
8439
|
+
var/*float*/ boundMainDim;
|
|
8440
|
+
|
|
8441
|
+
// If the flex share of remaining space doesn't meet min/max bounds,
|
|
8442
|
+
// remove this child from flex calculations.
|
|
8443
|
+
currentFlexChild = firstFlexChild;
|
|
8444
|
+
while (currentFlexChild !== null) {
|
|
8445
|
+
baseMainDim = flexibleMainDim * currentFlexChild.style.flex +
|
|
8446
|
+
getPaddingAndBorderAxis(currentFlexChild, mainAxis);
|
|
8447
|
+
boundMainDim = boundAxis(currentFlexChild, mainAxis, baseMainDim);
|
|
8448
|
+
|
|
8449
|
+
if (baseMainDim !== boundMainDim) {
|
|
8450
|
+
remainingMainDim -= boundMainDim;
|
|
8451
|
+
totalFlexible -= currentFlexChild.style.flex;
|
|
8452
|
+
}
|
|
8453
|
+
|
|
8454
|
+
currentFlexChild = currentFlexChild.nextFlexChild;
|
|
8455
|
+
}
|
|
8456
|
+
flexibleMainDim = remainingMainDim / totalFlexible;
|
|
8457
|
+
|
|
8458
|
+
// The non flexible children can overflow the container, in this case
|
|
8459
|
+
// we should just assume that there is no space available.
|
|
8460
|
+
if (flexibleMainDim < 0) {
|
|
8461
|
+
flexibleMainDim = 0;
|
|
8462
|
+
}
|
|
8463
|
+
|
|
8464
|
+
currentFlexChild = firstFlexChild;
|
|
8465
|
+
while (currentFlexChild !== null) {
|
|
8466
|
+
// At this point we know the final size of the element in the main
|
|
8467
|
+
// dimension
|
|
8468
|
+
currentFlexChild.layout[dim[mainAxis]] = boundAxis(currentFlexChild, mainAxis,
|
|
8469
|
+
flexibleMainDim * currentFlexChild.style.flex +
|
|
8470
|
+
getPaddingAndBorderAxis(currentFlexChild, mainAxis)
|
|
8471
|
+
);
|
|
8472
|
+
|
|
8473
|
+
maxWidth = CSS_UNDEFINED;
|
|
8474
|
+
if (isDimDefined(node, resolvedRowAxis)) {
|
|
8475
|
+
maxWidth = node.layout[dim[resolvedRowAxis]] -
|
|
8476
|
+
paddingAndBorderAxisResolvedRow;
|
|
8477
|
+
} else if (!isMainRowDirection) {
|
|
8478
|
+
maxWidth = parentMaxWidth -
|
|
8479
|
+
getMarginAxis(node, resolvedRowAxis) -
|
|
8480
|
+
paddingAndBorderAxisResolvedRow;
|
|
8481
|
+
}
|
|
8482
|
+
|
|
8483
|
+
// And we recursively call the layout algorithm for this child
|
|
8484
|
+
layoutNode(/*(java)!layoutContext, */currentFlexChild, maxWidth, direction);
|
|
8485
|
+
|
|
8486
|
+
child = currentFlexChild;
|
|
8487
|
+
currentFlexChild = currentFlexChild.nextFlexChild;
|
|
8488
|
+
child.nextFlexChild = null;
|
|
8489
|
+
}
|
|
8490
|
+
|
|
8491
|
+
// We use justifyContent to figure out how to allocate the remaining
|
|
8492
|
+
// space available
|
|
8493
|
+
} else if (justifyContent !== CSS_JUSTIFY_FLEX_START) {
|
|
8494
|
+
if (justifyContent === CSS_JUSTIFY_CENTER) {
|
|
8495
|
+
leadingMainDim = remainingMainDim / 2;
|
|
8496
|
+
} else if (justifyContent === CSS_JUSTIFY_FLEX_END) {
|
|
8497
|
+
leadingMainDim = remainingMainDim;
|
|
8498
|
+
} else if (justifyContent === CSS_JUSTIFY_SPACE_BETWEEN) {
|
|
8499
|
+
remainingMainDim = fmaxf(remainingMainDim, 0);
|
|
8500
|
+
if (flexibleChildrenCount + nonFlexibleChildrenCount - 1 !== 0) {
|
|
8501
|
+
betweenMainDim = remainingMainDim /
|
|
8502
|
+
(flexibleChildrenCount + nonFlexibleChildrenCount - 1);
|
|
8503
|
+
} else {
|
|
8504
|
+
betweenMainDim = 0;
|
|
8505
|
+
}
|
|
8506
|
+
} else if (justifyContent === CSS_JUSTIFY_SPACE_AROUND) {
|
|
8507
|
+
// Space on the edges is half of the space between elements
|
|
8508
|
+
betweenMainDim = remainingMainDim /
|
|
8509
|
+
(flexibleChildrenCount + nonFlexibleChildrenCount);
|
|
8510
|
+
leadingMainDim = betweenMainDim / 2;
|
|
8511
|
+
}
|
|
8512
|
+
}
|
|
8513
|
+
|
|
8514
|
+
// <Loop C> Position elements in the main axis and compute dimensions
|
|
8515
|
+
|
|
8516
|
+
// At this point, all the children have their dimensions set. We need to
|
|
8517
|
+
// find their position. In order to do that, we accumulate data in
|
|
8518
|
+
// variables that are also useful to compute the total dimensions of the
|
|
8519
|
+
// container!
|
|
8520
|
+
mainDim += leadingMainDim;
|
|
8521
|
+
|
|
8522
|
+
for (i = firstComplexMain; i < endLine; ++i) {
|
|
8523
|
+
child = node.children[i];
|
|
8524
|
+
|
|
8525
|
+
if (getPositionType(child) === CSS_POSITION_ABSOLUTE &&
|
|
8526
|
+
isPosDefined(child, leading[mainAxis])) {
|
|
8527
|
+
// In case the child is position absolute and has left/top being
|
|
8528
|
+
// defined, we override the position to whatever the user said
|
|
8529
|
+
// (and margin/border).
|
|
8530
|
+
child.layout[pos[mainAxis]] = getPosition(child, leading[mainAxis]) +
|
|
8531
|
+
getLeadingBorder(node, mainAxis) +
|
|
8532
|
+
getLeadingMargin(child, mainAxis);
|
|
8533
|
+
} else {
|
|
8534
|
+
// If the child is position absolute (without top/left) or relative,
|
|
8535
|
+
// we put it at the current accumulated offset.
|
|
8536
|
+
child.layout[pos[mainAxis]] += mainDim;
|
|
8537
|
+
|
|
8538
|
+
// Define the trailing position accordingly.
|
|
8539
|
+
if (isMainDimDefined) {
|
|
8540
|
+
setTrailingPosition(node, child, mainAxis);
|
|
8541
|
+
}
|
|
8542
|
+
|
|
8543
|
+
// Now that we placed the element, we need to update the variables
|
|
8544
|
+
// We only need to do that for relative elements. Absolute elements
|
|
8545
|
+
// do not take part in that phase.
|
|
8546
|
+
if (getPositionType(child) === CSS_POSITION_RELATIVE) {
|
|
8547
|
+
// The main dimension is the sum of all the elements dimension plus
|
|
8548
|
+
// the spacing.
|
|
8549
|
+
mainDim += betweenMainDim + getDimWithMargin(child, mainAxis);
|
|
8550
|
+
// The cross dimension is the max of the elements dimension since there
|
|
8551
|
+
// can only be one element in that cross dimension.
|
|
8552
|
+
crossDim = fmaxf(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis)));
|
|
8553
|
+
}
|
|
8554
|
+
}
|
|
8555
|
+
}
|
|
8556
|
+
|
|
8557
|
+
var/*float*/ containerCrossAxis = node.layout[dim[crossAxis]];
|
|
8558
|
+
if (!isCrossDimDefined) {
|
|
8559
|
+
containerCrossAxis = fmaxf(
|
|
8560
|
+
// For the cross dim, we add both sides at the end because the value
|
|
8561
|
+
// is aggregate via a max function. Intermediate negative values
|
|
8562
|
+
// can mess this computation otherwise
|
|
8563
|
+
boundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross),
|
|
8564
|
+
paddingAndBorderAxisCross
|
|
8565
|
+
);
|
|
8566
|
+
}
|
|
8567
|
+
|
|
8568
|
+
// <Loop D> Position elements in the cross axis
|
|
8569
|
+
for (i = firstComplexCross; i < endLine; ++i) {
|
|
8570
|
+
child = node.children[i];
|
|
8571
|
+
|
|
8572
|
+
if (getPositionType(child) === CSS_POSITION_ABSOLUTE &&
|
|
8573
|
+
isPosDefined(child, leading[crossAxis])) {
|
|
8574
|
+
// In case the child is absolutely positionned and has a
|
|
8575
|
+
// top/left/bottom/right being set, we override all the previously
|
|
8576
|
+
// computed positions to set it correctly.
|
|
8577
|
+
child.layout[pos[crossAxis]] = getPosition(child, leading[crossAxis]) +
|
|
8578
|
+
getLeadingBorder(node, crossAxis) +
|
|
8579
|
+
getLeadingMargin(child, crossAxis);
|
|
8580
|
+
|
|
8581
|
+
} else {
|
|
8582
|
+
var/*float*/ leadingCrossDim = leadingPaddingAndBorderCross;
|
|
8583
|
+
|
|
8584
|
+
// For a relative children, we're either using alignItems (parent) or
|
|
8585
|
+
// alignSelf (child) in order to determine the position in the cross axis
|
|
8586
|
+
if (getPositionType(child) === CSS_POSITION_RELATIVE) {
|
|
8587
|
+
/*eslint-disable */
|
|
8588
|
+
// This variable is intentionally re-defined as the code is transpiled to a block scope language
|
|
8589
|
+
var/*css_align_t*/ alignItem = getAlignItem(node, child);
|
|
8590
|
+
/*eslint-enable */
|
|
8591
|
+
if (alignItem === CSS_ALIGN_STRETCH) {
|
|
8592
|
+
// You can only stretch if the dimension has not already been set
|
|
8593
|
+
// previously.
|
|
8594
|
+
if (isUndefined(child.layout[dim[crossAxis]])) {
|
|
8595
|
+
child.layout[dim[crossAxis]] = fmaxf(
|
|
8596
|
+
boundAxis(child, crossAxis, containerCrossAxis -
|
|
8597
|
+
paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)),
|
|
8598
|
+
// You never want to go smaller than padding
|
|
8599
|
+
getPaddingAndBorderAxis(child, crossAxis)
|
|
8600
|
+
);
|
|
8601
|
+
}
|
|
8602
|
+
} else if (alignItem !== CSS_ALIGN_FLEX_START) {
|
|
8603
|
+
// The remaining space between the parent dimensions+padding and child
|
|
8604
|
+
// dimensions+margin.
|
|
8605
|
+
var/*float*/ remainingCrossDim = containerCrossAxis -
|
|
8606
|
+
paddingAndBorderAxisCross - getDimWithMargin(child, crossAxis);
|
|
8607
|
+
|
|
8608
|
+
if (alignItem === CSS_ALIGN_CENTER) {
|
|
8609
|
+
leadingCrossDim += remainingCrossDim / 2;
|
|
8610
|
+
} else { // CSS_ALIGN_FLEX_END
|
|
8611
|
+
leadingCrossDim += remainingCrossDim;
|
|
8612
|
+
}
|
|
8613
|
+
}
|
|
8614
|
+
}
|
|
8615
|
+
|
|
8616
|
+
// And we apply the position
|
|
8617
|
+
child.layout[pos[crossAxis]] += linesCrossDim + leadingCrossDim;
|
|
8618
|
+
|
|
8619
|
+
// Define the trailing position accordingly.
|
|
8620
|
+
if (isCrossDimDefined) {
|
|
8621
|
+
setTrailingPosition(node, child, crossAxis);
|
|
8622
|
+
}
|
|
8623
|
+
}
|
|
8624
|
+
}
|
|
8625
|
+
|
|
8626
|
+
linesCrossDim += crossDim;
|
|
8627
|
+
linesMainDim = fmaxf(linesMainDim, mainDim);
|
|
8628
|
+
linesCount += 1;
|
|
8629
|
+
startLine = endLine;
|
|
8630
|
+
}
|
|
8631
|
+
|
|
8632
|
+
// <Loop E>
|
|
8633
|
+
//
|
|
8634
|
+
// Note(prenaux): More than one line, we need to layout the crossAxis
|
|
8635
|
+
// according to alignContent.
|
|
8636
|
+
//
|
|
8637
|
+
// Note that we could probably remove <Loop D> and handle the one line case
|
|
8638
|
+
// here too, but for the moment this is safer since it won't interfere with
|
|
8639
|
+
// previously working code.
|
|
8640
|
+
//
|
|
8641
|
+
// See specs:
|
|
8642
|
+
// http://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#layout-algorithm
|
|
8643
|
+
// section 9.4
|
|
8644
|
+
//
|
|
8645
|
+
if (linesCount > 1 && isCrossDimDefined) {
|
|
8646
|
+
var/*float*/ nodeCrossAxisInnerSize = node.layout[dim[crossAxis]] -
|
|
8647
|
+
paddingAndBorderAxisCross;
|
|
8648
|
+
var/*float*/ remainingAlignContentDim = nodeCrossAxisInnerSize - linesCrossDim;
|
|
8649
|
+
|
|
8650
|
+
var/*float*/ crossDimLead = 0;
|
|
8651
|
+
var/*float*/ currentLead = leadingPaddingAndBorderCross;
|
|
8652
|
+
|
|
8653
|
+
var/*css_align_t*/ alignContent = getAlignContent(node);
|
|
8654
|
+
if (alignContent === CSS_ALIGN_FLEX_END) {
|
|
8655
|
+
currentLead += remainingAlignContentDim;
|
|
8656
|
+
} else if (alignContent === CSS_ALIGN_CENTER) {
|
|
8657
|
+
currentLead += remainingAlignContentDim / 2;
|
|
8658
|
+
} else if (alignContent === CSS_ALIGN_STRETCH) {
|
|
8659
|
+
if (nodeCrossAxisInnerSize > linesCrossDim) {
|
|
8660
|
+
crossDimLead = (remainingAlignContentDim / linesCount);
|
|
8661
|
+
}
|
|
8662
|
+
}
|
|
8663
|
+
|
|
8664
|
+
var/*int*/ endIndex = 0;
|
|
8665
|
+
for (i = 0; i < linesCount; ++i) {
|
|
8666
|
+
var/*int*/ startIndex = endIndex;
|
|
8667
|
+
|
|
8668
|
+
// compute the line's height and find the endIndex
|
|
8669
|
+
var/*float*/ lineHeight = 0;
|
|
8670
|
+
for (ii = startIndex; ii < childCount; ++ii) {
|
|
8671
|
+
child = node.children[ii];
|
|
8672
|
+
if (getPositionType(child) !== CSS_POSITION_RELATIVE) {
|
|
8673
|
+
continue;
|
|
8674
|
+
}
|
|
8675
|
+
if (child.lineIndex !== i) {
|
|
8676
|
+
break;
|
|
8677
|
+
}
|
|
8678
|
+
if (!isUndefined(child.layout[dim[crossAxis]])) {
|
|
8679
|
+
lineHeight = fmaxf(
|
|
8680
|
+
lineHeight,
|
|
8681
|
+
child.layout[dim[crossAxis]] + getMarginAxis(child, crossAxis)
|
|
8682
|
+
);
|
|
8683
|
+
}
|
|
8684
|
+
}
|
|
8685
|
+
endIndex = ii;
|
|
8686
|
+
lineHeight += crossDimLead;
|
|
8687
|
+
|
|
8688
|
+
for (ii = startIndex; ii < endIndex; ++ii) {
|
|
8689
|
+
child = node.children[ii];
|
|
8690
|
+
if (getPositionType(child) !== CSS_POSITION_RELATIVE) {
|
|
8691
|
+
continue;
|
|
8692
|
+
}
|
|
8693
|
+
|
|
8694
|
+
var/*css_align_t*/ alignContentAlignItem = getAlignItem(node, child);
|
|
8695
|
+
if (alignContentAlignItem === CSS_ALIGN_FLEX_START) {
|
|
8696
|
+
child.layout[pos[crossAxis]] = currentLead + getLeadingMargin(child, crossAxis);
|
|
8697
|
+
} else if (alignContentAlignItem === CSS_ALIGN_FLEX_END) {
|
|
8698
|
+
child.layout[pos[crossAxis]] = currentLead + lineHeight - getTrailingMargin(child, crossAxis) - child.layout[dim[crossAxis]];
|
|
8699
|
+
} else if (alignContentAlignItem === CSS_ALIGN_CENTER) {
|
|
8700
|
+
var/*float*/ childHeight = child.layout[dim[crossAxis]];
|
|
8701
|
+
child.layout[pos[crossAxis]] = currentLead + (lineHeight - childHeight) / 2;
|
|
8702
|
+
} else if (alignContentAlignItem === CSS_ALIGN_STRETCH) {
|
|
8703
|
+
child.layout[pos[crossAxis]] = currentLead + getLeadingMargin(child, crossAxis);
|
|
8704
|
+
// TODO(prenaux): Correctly set the height of items with undefined
|
|
8705
|
+
// (auto) crossAxis dimension.
|
|
8706
|
+
}
|
|
8707
|
+
}
|
|
8708
|
+
|
|
8709
|
+
currentLead += lineHeight;
|
|
8710
|
+
}
|
|
8711
|
+
}
|
|
8712
|
+
|
|
8713
|
+
var/*bool*/ needsMainTrailingPos = false;
|
|
8714
|
+
var/*bool*/ needsCrossTrailingPos = false;
|
|
8715
|
+
|
|
8716
|
+
// If the user didn't specify a width or height, and it has not been set
|
|
8717
|
+
// by the container, then we set it via the children.
|
|
8718
|
+
if (!isMainDimDefined) {
|
|
8719
|
+
node.layout[dim[mainAxis]] = fmaxf(
|
|
8720
|
+
// We're missing the last padding at this point to get the final
|
|
8721
|
+
// dimension
|
|
8722
|
+
boundAxis(node, mainAxis, linesMainDim + getTrailingPaddingAndBorder(node, mainAxis)),
|
|
8723
|
+
// We can never assign a width smaller than the padding and borders
|
|
8724
|
+
paddingAndBorderAxisMain
|
|
8725
|
+
);
|
|
8726
|
+
|
|
8727
|
+
if (mainAxis === CSS_FLEX_DIRECTION_ROW_REVERSE ||
|
|
8728
|
+
mainAxis === CSS_FLEX_DIRECTION_COLUMN_REVERSE) {
|
|
8729
|
+
needsMainTrailingPos = true;
|
|
8730
|
+
}
|
|
8731
|
+
}
|
|
8732
|
+
|
|
8733
|
+
if (!isCrossDimDefined) {
|
|
8734
|
+
node.layout[dim[crossAxis]] = fmaxf(
|
|
8735
|
+
// For the cross dim, we add both sides at the end because the value
|
|
8736
|
+
// is aggregate via a max function. Intermediate negative values
|
|
8737
|
+
// can mess this computation otherwise
|
|
8738
|
+
boundAxis(node, crossAxis, linesCrossDim + paddingAndBorderAxisCross),
|
|
8739
|
+
paddingAndBorderAxisCross
|
|
8740
|
+
);
|
|
8741
|
+
|
|
8742
|
+
if (crossAxis === CSS_FLEX_DIRECTION_ROW_REVERSE ||
|
|
8743
|
+
crossAxis === CSS_FLEX_DIRECTION_COLUMN_REVERSE) {
|
|
8744
|
+
needsCrossTrailingPos = true;
|
|
8745
|
+
}
|
|
8746
|
+
}
|
|
8747
|
+
|
|
8748
|
+
// <Loop F> Set trailing position if necessary
|
|
8749
|
+
if (needsMainTrailingPos || needsCrossTrailingPos) {
|
|
8750
|
+
for (i = 0; i < childCount; ++i) {
|
|
8751
|
+
child = node.children[i];
|
|
8752
|
+
|
|
8753
|
+
if (needsMainTrailingPos) {
|
|
8754
|
+
setTrailingPosition(node, child, mainAxis);
|
|
8755
|
+
}
|
|
8756
|
+
|
|
8757
|
+
if (needsCrossTrailingPos) {
|
|
8758
|
+
setTrailingPosition(node, child, crossAxis);
|
|
8759
|
+
}
|
|
8760
|
+
}
|
|
8761
|
+
}
|
|
8762
|
+
|
|
8763
|
+
// <Loop G> Calculate dimensions for absolutely positioned elements
|
|
8764
|
+
currentAbsoluteChild = firstAbsoluteChild;
|
|
8765
|
+
while (currentAbsoluteChild !== null) {
|
|
8766
|
+
// Pre-fill dimensions when using absolute position and both offsets for
|
|
8767
|
+
// the axis are defined (either both left and right or top and bottom).
|
|
8768
|
+
for (ii = 0; ii < 2; ii++) {
|
|
8769
|
+
axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;
|
|
8770
|
+
|
|
8771
|
+
if (!isUndefined(node.layout[dim[axis]]) &&
|
|
8772
|
+
!isDimDefined(currentAbsoluteChild, axis) &&
|
|
8773
|
+
isPosDefined(currentAbsoluteChild, leading[axis]) &&
|
|
8774
|
+
isPosDefined(currentAbsoluteChild, trailing[axis])) {
|
|
8775
|
+
currentAbsoluteChild.layout[dim[axis]] = fmaxf(
|
|
8776
|
+
boundAxis(currentAbsoluteChild, axis, node.layout[dim[axis]] -
|
|
8777
|
+
getBorderAxis(node, axis) -
|
|
8778
|
+
getMarginAxis(currentAbsoluteChild, axis) -
|
|
8779
|
+
getPosition(currentAbsoluteChild, leading[axis]) -
|
|
8780
|
+
getPosition(currentAbsoluteChild, trailing[axis])
|
|
8781
|
+
),
|
|
8782
|
+
// You never want to go smaller than padding
|
|
8783
|
+
getPaddingAndBorderAxis(currentAbsoluteChild, axis)
|
|
8784
|
+
);
|
|
8785
|
+
}
|
|
8786
|
+
|
|
8787
|
+
if (isPosDefined(currentAbsoluteChild, trailing[axis]) &&
|
|
8788
|
+
!isPosDefined(currentAbsoluteChild, leading[axis])) {
|
|
8789
|
+
currentAbsoluteChild.layout[leading[axis]] =
|
|
8790
|
+
node.layout[dim[axis]] -
|
|
8791
|
+
currentAbsoluteChild.layout[dim[axis]] -
|
|
8792
|
+
getPosition(currentAbsoluteChild, trailing[axis]);
|
|
8793
|
+
}
|
|
8794
|
+
}
|
|
8795
|
+
|
|
8796
|
+
child = currentAbsoluteChild;
|
|
8797
|
+
currentAbsoluteChild = currentAbsoluteChild.nextAbsoluteChild;
|
|
8798
|
+
child.nextAbsoluteChild = null;
|
|
8799
|
+
}
|
|
8800
|
+
}
|
|
8801
|
+
|
|
8802
|
+
function layoutNode(node, parentMaxWidth, parentDirection) {
|
|
8803
|
+
node.shouldUpdate = true;
|
|
8804
|
+
|
|
8805
|
+
var direction = node.style.direction || CSS_DIRECTION_LTR;
|
|
8806
|
+
var skipLayout =
|
|
8807
|
+
!node.isDirty &&
|
|
8808
|
+
node.lastLayout &&
|
|
8809
|
+
node.lastLayout.requestedHeight === node.layout.height &&
|
|
8810
|
+
node.lastLayout.requestedWidth === node.layout.width &&
|
|
8811
|
+
node.lastLayout.parentMaxWidth === parentMaxWidth &&
|
|
8812
|
+
node.lastLayout.direction === direction;
|
|
8813
|
+
|
|
8814
|
+
if (skipLayout) {
|
|
8815
|
+
node.layout.width = node.lastLayout.width;
|
|
8816
|
+
node.layout.height = node.lastLayout.height;
|
|
8817
|
+
node.layout.top = node.lastLayout.top;
|
|
8818
|
+
node.layout.left = node.lastLayout.left;
|
|
8819
|
+
} else {
|
|
8820
|
+
if (!node.lastLayout) {
|
|
8821
|
+
node.lastLayout = {};
|
|
8822
|
+
}
|
|
8823
|
+
|
|
8824
|
+
node.lastLayout.requestedWidth = node.layout.width;
|
|
8825
|
+
node.lastLayout.requestedHeight = node.layout.height;
|
|
8826
|
+
node.lastLayout.parentMaxWidth = parentMaxWidth;
|
|
8827
|
+
node.lastLayout.direction = direction;
|
|
8828
|
+
|
|
8829
|
+
// Reset child layouts
|
|
8830
|
+
node.children.forEach(function(child) {
|
|
8831
|
+
child.layout.width = undefined;
|
|
8832
|
+
child.layout.height = undefined;
|
|
8833
|
+
child.layout.top = 0;
|
|
8834
|
+
child.layout.left = 0;
|
|
8835
|
+
});
|
|
8836
|
+
|
|
8837
|
+
layoutNodeImpl(node, parentMaxWidth, parentDirection);
|
|
8838
|
+
|
|
8839
|
+
node.lastLayout.width = node.layout.width;
|
|
8840
|
+
node.lastLayout.height = node.layout.height;
|
|
8841
|
+
node.lastLayout.top = node.layout.top;
|
|
8842
|
+
node.lastLayout.left = node.layout.left;
|
|
8843
|
+
}
|
|
8844
|
+
}
|
|
8845
|
+
|
|
8846
|
+
return {
|
|
8847
|
+
layoutNodeImpl: layoutNodeImpl,
|
|
8848
|
+
computeLayout: layoutNode,
|
|
8849
|
+
fillNodes: fillNodes
|
|
8850
|
+
};
|
|
8851
|
+
})();
|
|
8852
|
+
|
|
8853
|
+
// This module export is only used for the purposes of unit testing this file. When
|
|
8854
|
+
// the library is packaged this file is included within css-layout.js which forms
|
|
8855
|
+
// the public API.
|
|
8856
|
+
{
|
|
8857
|
+
module.exports = computeLayout;
|
|
8858
|
+
}
|
|
8859
|
+
|
|
8860
|
+
|
|
8861
|
+
return function(node) {
|
|
8862
|
+
/*eslint-disable */
|
|
8863
|
+
// disabling ESLint because this code relies on the above include
|
|
8864
|
+
computeLayout.fillNodes(node);
|
|
8865
|
+
computeLayout.computeLayout(node);
|
|
8866
|
+
/*eslint-enable */
|
|
8867
|
+
};
|
|
8868
|
+
}));
|
|
8869
|
+
} (cssLayout));
|
|
8870
|
+
|
|
8871
|
+
var cssLayoutExports = cssLayout.exports;
|
|
8872
|
+
|
|
8873
|
+
function _interopDefault$1(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=_interopDefault$1(React$1),reactDom=require$$0,computeLayout=_interopDefault$1(cssLayoutExports);function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){_defineProperty(e,t,r[t]);});}return e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n);}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),e}function _typeof2(e){return (_typeof2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _typeof(e){return (_typeof="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(e){return _typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof2(e)})(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){return !t||"object"!==_typeof(t)&&"function"!=typeof t?_assertThisInitialized(e):t}function _getPrototypeOf(e){return (_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _setPrototypeOf(e,t){return (_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t);}var Flexbox=function(e){function t(){var e;return _classCallCheck(this,t),(e=_possibleConstructorReturn(this,_getPrototypeOf(t).call(this))).childRefs=[],e.shouldUpdateAgain=!1,e.state={layout:{children:[]}},e}return _inherits(t,React.Component),_createClass(t,[{key:"componentDidMount",value:function(){this.forceUpdate();}},{key:"componentDidUpdate",value:function(){if(this.shouldUpdateAgain=!this.shouldUpdateAgain,this.shouldUpdateAgain){var e=this.props,t=e.children,r=e.onLayout,n=e.style,o=this.getChildrenMeasured(this.childRefs),i=this.getFlattenedChildren(t),u=this.getChildrenAsMergedStyles(i,o),c=this.getComputedLayout(u,n);r(c),this.setState({layout:c});}}},{key:"getFlattenedChildren",value:function(e){return e.filter(function(e){return e}).filter(function(e){return "string"!=typeof e}).map(function(e){return Array.isArray(e)?e:[e]}).reduce(function(e,t){return e.concat(t)},[])}},{key:"getChildrenAsMergedStyles",value:function(e,t){return t.map(function(t,r){var n=e[r]||{},o=n&&n.props?n.props.style:{};return {style:_objectSpread({},o,{height:t.height||o.height,width:t.width||o.width})}})}},{key:"getChildrenMeasured",value:function(e){return e&&e.length?e.map(function(e){return e.getBBox?e.getBBox():reactDom.findDOMNode(e).getBBox()}):[]}},{key:"getComputedLayout",value:function(e,t){var r={children:Array.from(e||[]),style:_objectSpread({},t)};return computeLayout(r),r}},{key:"getLayoutChildren",value:function(e){return e&&e.children&&e.children.length?e.children:[]}},{key:"getLayoutAttributesForChild",value:function(e,t){if(t&&t.layout){var r=t.layout,n=r.left,o=r.top;switch(e.type){case"circle":var i=e.props.r||0;return {cx:n+i,cy:o+i};case"ellipse":return {cx:n+(e.props.rx||0),cy:o+(e.props.ry||0)};case"g":case"path":case"polygon":case"polyline":return {transform:"translate(".concat(n," ").concat(o,")")};default:return {x:n,y:o}}}return {}}},{key:"render",value:function(){var e=this,t=this.props,r=t.children,n=t.className,o=t.x,i=t.y,u=this.state.layout;this.childRefs=[];var c=this.getFlattenedChildren(r),a=this.getLayoutChildren(u);return React.createElement("g",{className:n,transform:"translate(".concat(o," ").concat(i,")")},c.map(function(t,r){return React.cloneElement(t,_objectSpread({},t.props,e.getLayoutAttributesForChild(t,a[r]),{key:"child-".concat(r),ref:function(t){return t?e.childRefs.push(t):null}}))}))}}]),t}();Flexbox.defaultProps={children:[],className:null,onLayout:function(){},style:{},x:0,y:0},bundle.exports=Flexbox;
|
|
8874
|
+
|
|
8875
|
+
var bundleExports = bundle.exports;
|
|
8876
|
+
var Flexbox$1 = /*@__PURE__*/getDefaultExportFromCjs(bundleExports);
|
|
8877
|
+
|
|
7654
8878
|
var Element = function (props) {
|
|
7655
|
-
var _a, _b
|
|
8879
|
+
var _a, _b;
|
|
7656
8880
|
var id = props.id, x = props.x, y = props.y, width = props.width, height = props.height, portPlaceholderShape = props.portPlaceholderShape, children = props.children, container = props.container, textsPlaceHolderFlexStyle = props.textsPlaceHolderFlexStyle, textsPlaceHolderFlexboxPosition = props.textsPlaceHolderFlexboxPosition, textsPlaceHolderClassName = props.textsPlaceHolderClassName, texts = props.texts, portSlideRailSVGClassName = props.portSlideRailSVGClassName, portMoveableAreas = props.portMoveableAreas, portDirection = props.portDirection, onClick = props.onClick, renderShape = props.renderShape; props.onMoved; var onPortMoved = props.onPortMoved; props.onResized; var onPortMouseDown = props.onPortMouseDown, onPortMouseUp = props.onPortMouseUp; props.onMouseMove; props.onMouseLeave; props.onMouseUp; var onMouseUpAtLinkedPortPlaceholder = props.onMouseUpAtLinkedPortPlaceholder, onTextUpdated = props.onTextUpdated;
|
|
7657
|
-
var
|
|
7658
|
-
var
|
|
7659
|
-
return __assign(__assign({}, p), { id: p.id, ref: React.createRef() });
|
|
7660
|
-
})) !== null && _b !== void 0 ? _b : []), ports =
|
|
7661
|
-
var
|
|
7662
|
-
var
|
|
7663
|
-
var _paperEventEmitterContext = React.useContext(paperEventEmitterContext);
|
|
7664
|
-
var elementRef = React.useRef(null);
|
|
7665
|
-
var elementLinkStarted = React.useRef();
|
|
8881
|
+
var _c = React$1.useState(), selectedPort = _c[0], setSelectedPort = _c[1];
|
|
8882
|
+
var _d = React$1.useState((_b = (_a = props.ports) === null || _a === void 0 ? void 0 : _a.map(function (p) {
|
|
8883
|
+
return __assign(__assign({}, p), { id: p.id, ref: React$1.createRef() });
|
|
8884
|
+
})) !== null && _b !== void 0 ? _b : []), ports = _d[0], setPorts = _d[1];
|
|
8885
|
+
var _e = React$1.useState(false), someElementLinkStarted = _e[0], setSomeElementLinkStarted = _e[1];
|
|
8886
|
+
var _f = React$1.useState(), potentialPortPosition = _f[0], setPotentialPortPosition = _f[1];
|
|
8887
|
+
var _paperEventEmitterContext = React$1.useContext(paperEventEmitterContext);
|
|
8888
|
+
var elementRef = React$1.useRef(null);
|
|
8889
|
+
var elementLinkStarted = React$1.useRef();
|
|
7666
8890
|
//Listen a new port is created, after add new port to ports state
|
|
7667
|
-
React.useEffect(function () {
|
|
8891
|
+
React$1.useEffect(function () {
|
|
7668
8892
|
var _a, _b;
|
|
7669
8893
|
setPorts((_b = (_a = props.ports) === null || _a === void 0 ? void 0 : _a.map(function (p) {
|
|
7670
|
-
return __assign(__assign({}, p), { id: p.id, ref: React.createRef() });
|
|
8894
|
+
return __assign(__assign({}, p), { id: p.id, ref: React$1.createRef() });
|
|
7671
8895
|
})) !== null && _b !== void 0 ? _b : []);
|
|
7672
8896
|
}, [props.ports]);
|
|
7673
8897
|
//Listen trigger of Delete key, handle delete port is selected
|
|
7674
|
-
React.useEffect(function () {
|
|
8898
|
+
React$1.useEffect(function () {
|
|
7675
8899
|
var listener = _paperEventEmitterContext.onCommandDeleteSelectedPort(function () {
|
|
7676
8900
|
if (selectedPort) {
|
|
7677
8901
|
setPorts(function (prev) { return prev.filter(function (p) { return p.id !== selectedPort.id; }); });
|
|
@@ -7682,7 +8906,7 @@ var Element = function (props) {
|
|
|
7682
8906
|
listener.off();
|
|
7683
8907
|
};
|
|
7684
8908
|
}, [selectedPort]);
|
|
7685
|
-
React.useEffect(function () {
|
|
8909
|
+
React$1.useEffect(function () {
|
|
7686
8910
|
//Listener onMouseDown event on #paper-container
|
|
7687
8911
|
var eventListener = _paperEventEmitterContext.onPaperClicked(function (ev) {
|
|
7688
8912
|
setSelectedPort(undefined);
|
|
@@ -7705,7 +8929,7 @@ var Element = function (props) {
|
|
|
7705
8929
|
};
|
|
7706
8930
|
}, [ports, onPortMoved]);
|
|
7707
8931
|
//Listen creating element link started, ended.
|
|
7708
|
-
React.useEffect(function () {
|
|
8932
|
+
React$1.useEffect(function () {
|
|
7709
8933
|
var elementStartedListener = _paperEventEmitterContext.onElementLinkStarted(function (tempLink) {
|
|
7710
8934
|
elementLinkStarted.current = tempLink;
|
|
7711
8935
|
setSomeElementLinkStarted(true);
|
|
@@ -7781,7 +9005,7 @@ var Element = function (props) {
|
|
|
7781
9005
|
}
|
|
7782
9006
|
return coordinates;
|
|
7783
9007
|
};
|
|
7784
|
-
var getSlideRailSVG = React.useCallback(function (portSlideRailSVGClassName) {
|
|
9008
|
+
var getSlideRailSVG = React$1.useCallback(function (portSlideRailSVGClassName) {
|
|
7785
9009
|
var _a;
|
|
7786
9010
|
var slideRailSVG = (_a = elementRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(".".concat(portSlideRailSVGClassName));
|
|
7787
9011
|
return slideRailSVG;
|
|
@@ -7948,7 +9172,7 @@ var Element = function (props) {
|
|
|
7948
9172
|
}
|
|
7949
9173
|
};
|
|
7950
9174
|
//Get rotate angle of port by port direction is defined.
|
|
7951
|
-
var rotatePort = React.useCallback(function (x, y) {
|
|
9175
|
+
var rotatePort = React$1.useCallback(function (x, y) {
|
|
7952
9176
|
console.info('calculating port rotation', x, y);
|
|
7953
9177
|
if (!portSlideRailSVGClassName)
|
|
7954
9178
|
return 0;
|
|
@@ -7988,7 +9212,7 @@ var Element = function (props) {
|
|
|
7988
9212
|
}
|
|
7989
9213
|
return rotationAngle;
|
|
7990
9214
|
}, [portSlideRailSVGClassName, portDirection, getSlideRailSVG]);
|
|
7991
|
-
var renderedShape = React.useMemo(function () {
|
|
9215
|
+
var renderedShape = React$1.useMemo(function () {
|
|
7992
9216
|
if (renderShape)
|
|
7993
9217
|
return renderShape(props);
|
|
7994
9218
|
return null;
|
|
@@ -7996,7 +9220,7 @@ var Element = function (props) {
|
|
|
7996
9220
|
//Re-render port again after rendered to automation rotate port
|
|
7997
9221
|
//Because elementRef.current equals null in first render so automation rotate port is incorrect.
|
|
7998
9222
|
//TODO: check if this is still needed -> Still needed
|
|
7999
|
-
React.useLayoutEffect(function () {
|
|
9223
|
+
React$1.useLayoutEffect(function () {
|
|
8000
9224
|
if (elementRef.current) {
|
|
8001
9225
|
setPorts(function (prev) { return __spreadArray([], prev, true); });
|
|
8002
9226
|
}
|
|
@@ -8004,7 +9228,7 @@ var Element = function (props) {
|
|
|
8004
9228
|
//use selection frame
|
|
8005
9229
|
useSelectionFrame({
|
|
8006
9230
|
container: container,
|
|
8007
|
-
targetSVGElement: (
|
|
9231
|
+
targetSVGElement: (selectedPort === null || selectedPort === void 0 ? void 0 : selectedPort.ref.current) || undefined,
|
|
8008
9232
|
resizability: {
|
|
8009
9233
|
enabled: false,
|
|
8010
9234
|
keepRatio: false
|
|
@@ -8014,19 +9238,19 @@ var Element = function (props) {
|
|
|
8014
9238
|
movingOffsetThreshold: PORT_MOVING_OFFSET_THRESHOLD,
|
|
8015
9239
|
onMove: handlePortMove
|
|
8016
9240
|
});
|
|
8017
|
-
return (React.createElement(ElementWrapper, { ref: elementRef, x: x, y: y, onClick: function (e) { return onClick ? onClick(id, e, elementRef.current) : true; }, onMouseMove: handleElementMouseMove, onMouseLeave: handleElementMouseLeave, onMouseUp: handleElementMouseUp },
|
|
9241
|
+
return (React$1.createElement(ElementWrapper, { ref: elementRef, x: x, y: y, onClick: function (e) { return onClick ? onClick(id, e, elementRef.current) : true; }, onMouseMove: handleElementMouseMove, onMouseLeave: handleElementMouseLeave, onMouseUp: handleElementMouseUp },
|
|
8018
9242
|
renderedShape,
|
|
8019
9243
|
potentialPortPosition && (portPlaceholderShape
|
|
8020
|
-
? React.createElement("svg", { x: potentialPortPosition.x, y: potentialPortPosition.y }, portPlaceholderShape)
|
|
8021
|
-
: React.createElement("rect", { x: potentialPortPosition.x - PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH / 2, y: potentialPortPosition.y - PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH / 2, width: PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH, height: PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH, rx: PORT_PLACEHOLDER_DEFAULT_SIZE, ry: PORT_PLACEHOLDER_DEFAULT_SIZE, stroke: PORT_PLACEHOLDER_DEFAULT_STROKE, fill: "none", strokeWidth: 3 })), ports === null || ports === void 0 ? void 0 :
|
|
9244
|
+
? React$1.createElement("svg", { x: potentialPortPosition.x, y: potentialPortPosition.y }, portPlaceholderShape)
|
|
9245
|
+
: React$1.createElement("rect", { x: potentialPortPosition.x - PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH / 2, y: potentialPortPosition.y - PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH / 2, width: PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH, height: PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH, rx: PORT_PLACEHOLDER_DEFAULT_SIZE, ry: PORT_PLACEHOLDER_DEFAULT_SIZE, stroke: PORT_PLACEHOLDER_DEFAULT_STROKE, fill: "none", strokeWidth: 3 })), ports === null || ports === void 0 ? void 0 :
|
|
8022
9246
|
ports.map(function (p, index) {
|
|
8023
|
-
return React.createElement(Port, { key: p.id, ref: p.ref, id: p.id, x: p.position.x, y: p.position.y, width: p.size.width, height: p.size.height, container: container,
|
|
9247
|
+
return React$1.createElement(Port, { key: p.id, ref: p.ref, id: p.id, x: p.position.x, y: p.position.y, width: p.size.width, height: p.size.height, container: container,
|
|
8024
9248
|
// rotation={rotatePort(p)}
|
|
8025
9249
|
calculateRotationAngle: rotatePort, label: p.label, onPortLabelMoved: function (x, y) { return handlePortLabelMoved(x, y, p, index); }, onPortLabelResized: function (w, h) { return handlePortLabelResized(w, h, p, index); }, onPortLabelContentChanged: function (ev, newValue) { return handlePortLabelContentChanged(newValue, p, index); }, onSelected: function (portId, event) { return handleSelectedPort(p, event); }, onMouseDown: handlePortMouseDown, onMouseUp: handlePortMouseUp, renderShape: p.renderShape });
|
|
8026
9250
|
}),
|
|
8027
|
-
React.createElement(Flexbox, { className: textsPlaceHolderClassName, style: textsPlaceHolderFlexStyle, x: textsPlaceHolderFlexboxPosition === null || textsPlaceHolderFlexboxPosition === void 0 ? void 0 : textsPlaceHolderFlexboxPosition.x, y: textsPlaceHolderFlexboxPosition === null || textsPlaceHolderFlexboxPosition === void 0 ? void 0 : textsPlaceHolderFlexboxPosition.y }, texts === null || texts === void 0 ? void 0 : texts.map(function (t, index) {
|
|
9251
|
+
React$1.createElement(Flexbox$1, { className: textsPlaceHolderClassName, style: textsPlaceHolderFlexStyle, x: textsPlaceHolderFlexboxPosition === null || textsPlaceHolderFlexboxPosition === void 0 ? void 0 : textsPlaceHolderFlexboxPosition.x, y: textsPlaceHolderFlexboxPosition === null || textsPlaceHolderFlexboxPosition === void 0 ? void 0 : textsPlaceHolderFlexboxPosition.y }, texts === null || texts === void 0 ? void 0 : texts.map(function (t, index) {
|
|
8028
9252
|
var _a, _b;
|
|
8029
|
-
return React.createElement(Text$1, { id: t.id, key: index, content: t.content, x: (_a = t.position) === null || _a === void 0 ? void 0 : _a.x, y: (_b = t.position) === null || _b === void 0 ? void 0 : _b.y, width: t.size.width, height: t.size.height, align: t.align, fontSize: t.fontSize, border: t.border, container: container, style: t.style, onContentChanged: function (ev, newContent) { return onTextUpdated === null || onTextUpdated === void 0 ? void 0 : onTextUpdated(t.id, newContent); } });
|
|
9253
|
+
return React$1.createElement(Text$1, { id: t.id, key: index, content: t.content, x: (_a = t.position) === null || _a === void 0 ? void 0 : _a.x, y: (_b = t.position) === null || _b === void 0 ? void 0 : _b.y, width: t.size.width, height: t.size.height, align: t.align, fontSize: t.fontSize, border: t.border, container: container, style: t.style, onContentChanged: function (ev, newContent) { return onTextUpdated === null || onTextUpdated === void 0 ? void 0 : onTextUpdated(t.id, newContent); } });
|
|
8030
9254
|
})),
|
|
8031
9255
|
children));
|
|
8032
9256
|
};
|
|
@@ -8047,9 +9271,9 @@ var createRect = function (x, y, width, height, strokeWidth, transformOrigin, tr
|
|
|
8047
9271
|
};
|
|
8048
9272
|
function BBoxDebugger(_a) {
|
|
8049
9273
|
var elementSVG = _a.elementSVG;
|
|
8050
|
-
var _b = React.useState(false), isTurnOn = _b[0], setIsTurnOn = _b[1];
|
|
8051
|
-
var displayedBBoxDebug = React.useRef([]);
|
|
8052
|
-
React.useEffect(function () {
|
|
9274
|
+
var _b = React$1.useState(false), isTurnOn = _b[0], setIsTurnOn = _b[1];
|
|
9275
|
+
var displayedBBoxDebug = React$1.useRef([]);
|
|
9276
|
+
React$1.useEffect(function () {
|
|
8053
9277
|
var keyPress = function (ev) {
|
|
8054
9278
|
if (ev.ctrlKey && ev.key === 'b') {
|
|
8055
9279
|
setIsTurnOn(function (prev) { return !prev; });
|
|
@@ -8129,7 +9353,7 @@ function BBoxDebugger(_a) {
|
|
|
8129
9353
|
}, 1000);
|
|
8130
9354
|
return intervalId;
|
|
8131
9355
|
};
|
|
8132
|
-
React.useEffect(function () {
|
|
9356
|
+
React$1.useEffect(function () {
|
|
8133
9357
|
if (!isTurnOn || !elementSVG)
|
|
8134
9358
|
return;
|
|
8135
9359
|
var listChildrenGroupByLevel = getListChildrenAndGroupSameLevel(elementSVG);
|
|
@@ -8141,12 +9365,12 @@ function BBoxDebugger(_a) {
|
|
|
8141
9365
|
clearBBoxDebugger(displayedBBoxDebug.current);
|
|
8142
9366
|
};
|
|
8143
9367
|
}, [isTurnOn, elementSVG]);
|
|
8144
|
-
return (React.createElement("div", { style: {
|
|
9368
|
+
return (React$1.createElement("div", { style: {
|
|
8145
9369
|
position: 'fixed',
|
|
8146
9370
|
top: 20,
|
|
8147
9371
|
right: 20
|
|
8148
9372
|
} },
|
|
8149
|
-
React.createElement("div", { style: {
|
|
9373
|
+
React$1.createElement("div", { style: {
|
|
8150
9374
|
backgroundColor: 'white',
|
|
8151
9375
|
boxShadow: '0px 1px 4px 1px',
|
|
8152
9376
|
borderRadius: 4,
|
|
@@ -8170,9 +9394,9 @@ var createDebuggerPoint = function (cx, cy) {
|
|
|
8170
9394
|
};
|
|
8171
9395
|
var LinkDebugger = function (_a) {
|
|
8172
9396
|
var links = _a.links, svgContainer = _a.svgContainer;
|
|
8173
|
-
var _b = React.useState(false), isTurnOn = _b[0], setIsTurnOn = _b[1];
|
|
8174
|
-
var displayedDebuggerPoint = React.useRef([]);
|
|
8175
|
-
React.useEffect(function () {
|
|
9397
|
+
var _b = React$1.useState(false), isTurnOn = _b[0], setIsTurnOn = _b[1];
|
|
9398
|
+
var displayedDebuggerPoint = React$1.useRef([]);
|
|
9399
|
+
React$1.useEffect(function () {
|
|
8176
9400
|
var keyPress = function (ev) {
|
|
8177
9401
|
if (ev.ctrlKey && ev.key === 'l') {
|
|
8178
9402
|
setIsTurnOn(function (prev) { return !prev; });
|
|
@@ -8189,7 +9413,7 @@ var LinkDebugger = function (_a) {
|
|
|
8189
9413
|
ele === null || ele === void 0 ? void 0 : ele.remove();
|
|
8190
9414
|
}
|
|
8191
9415
|
};
|
|
8192
|
-
React.useEffect(function () {
|
|
9416
|
+
React$1.useEffect(function () {
|
|
8193
9417
|
if (isTurnOn) {
|
|
8194
9418
|
links.forEach(function (link) {
|
|
8195
9419
|
var _a;
|
|
@@ -8204,13 +9428,13 @@ var LinkDebugger = function (_a) {
|
|
|
8204
9428
|
clearDebuggerPoint();
|
|
8205
9429
|
};
|
|
8206
9430
|
}, [isTurnOn, links]);
|
|
8207
|
-
return (React.createElement("div", null));
|
|
9431
|
+
return (React$1.createElement("div", null));
|
|
8208
9432
|
};
|
|
8209
9433
|
|
|
8210
9434
|
function useKeyboardCommands(_a) {
|
|
8211
9435
|
var element = _a.element;
|
|
8212
|
-
var _b = React.useContext(paperEventEmitterContext), emitCommandDeleteSelectedElement = _b.emitCommandDeleteSelectedElement, emitCommandDeleteSelectedLink = _b.emitCommandDeleteSelectedLink, emitCommandDeleteSelectedPort = _b.emitCommandDeleteSelectedPort, emitCommandDeleteSelectedText = _b.emitCommandDeleteSelectedText;
|
|
8213
|
-
React.useEffect(function () {
|
|
9436
|
+
var _b = React$1.useContext(paperEventEmitterContext), emitCommandDeleteSelectedElement = _b.emitCommandDeleteSelectedElement, emitCommandDeleteSelectedLink = _b.emitCommandDeleteSelectedLink, emitCommandDeleteSelectedPort = _b.emitCommandDeleteSelectedPort, emitCommandDeleteSelectedText = _b.emitCommandDeleteSelectedText;
|
|
9437
|
+
React$1.useEffect(function () {
|
|
8214
9438
|
var callback = function (ev) {
|
|
8215
9439
|
var keyboardEv = ev;
|
|
8216
9440
|
if (keyboardEv.key === "Delete") {
|
|
@@ -8260,18 +9484,18 @@ function convertElementsToTree(elements) {
|
|
|
8260
9484
|
}
|
|
8261
9485
|
var Paper = function (props) {
|
|
8262
9486
|
var _a;
|
|
8263
|
-
var _b = React.useState(props.elements), elements = _b[0], setElements = _b[1];
|
|
8264
|
-
var _c = React.useState([]), elementsInTree = _c[0], setElementsInTree = _c[1];
|
|
8265
|
-
var _d = React.useState(), selectedElement = _d[0], setSelectedElement = _d[1];
|
|
8266
|
-
var _e = React.useState((_a = props.links) !== null && _a !== void 0 ? _a : []), links = _e[0], setLinks = _e[1];
|
|
8267
|
-
var _f = React.useState(), selectedLink = _f[0], setSelectedLink = _f[1];
|
|
8268
|
-
var _g = React.useState(), tempLink = _g[0], setTempLink = _g[1];
|
|
8269
|
-
var _h = React.useState(props.texts), texts = _h[0], setTexts = _h[1];
|
|
8270
|
-
var _j = React.useState(), selectedText = _j[0], setSelectedText = _j[1];
|
|
8271
|
-
var _k = React.useState(null), selectedElementSVG = _k[0], setSelectedElementSVG = _k[1];
|
|
8272
|
-
var _l = React.useState(false), mouseDownedOnPaper = _l[0], setMouseDownedOnPaper = _l[1];
|
|
8273
|
-
var paperEventEmitter = React.useContext(paperEventEmitterContext);
|
|
8274
|
-
var paperContainerRef = React.useRef(null);
|
|
9487
|
+
var _b = React$1.useState(props.elements), elements = _b[0], setElements = _b[1];
|
|
9488
|
+
var _c = React$1.useState([]), elementsInTree = _c[0], setElementsInTree = _c[1];
|
|
9489
|
+
var _d = React$1.useState(), selectedElement = _d[0], setSelectedElement = _d[1];
|
|
9490
|
+
var _e = React$1.useState((_a = props.links) !== null && _a !== void 0 ? _a : []), links = _e[0], setLinks = _e[1];
|
|
9491
|
+
var _f = React$1.useState(), selectedLink = _f[0], setSelectedLink = _f[1];
|
|
9492
|
+
var _g = React$1.useState(), tempLink = _g[0], setTempLink = _g[1];
|
|
9493
|
+
var _h = React$1.useState(props.texts), texts = _h[0], setTexts = _h[1];
|
|
9494
|
+
var _j = React$1.useState(), selectedText = _j[0], setSelectedText = _j[1];
|
|
9495
|
+
var _k = React$1.useState(null), selectedElementSVG = _k[0], setSelectedElementSVG = _k[1];
|
|
9496
|
+
var _l = React$1.useState(false), mouseDownedOnPaper = _l[0], setMouseDownedOnPaper = _l[1];
|
|
9497
|
+
var paperEventEmitter = React$1.useContext(paperEventEmitterContext);
|
|
9498
|
+
var paperContainerRef = React$1.useRef(null);
|
|
8275
9499
|
useKeyboardCommands({
|
|
8276
9500
|
element: paperContainerRef.current
|
|
8277
9501
|
});
|
|
@@ -8279,7 +9503,7 @@ var Paper = function (props) {
|
|
|
8279
9503
|
var parsedElementsInTree = convertElementsToTree(elements);
|
|
8280
9504
|
setElementsInTree(parsedElementsInTree);
|
|
8281
9505
|
};
|
|
8282
|
-
React.useEffect(function () {
|
|
9506
|
+
React$1.useEffect(function () {
|
|
8283
9507
|
//Listen parent of elements changed, then update elements tree
|
|
8284
9508
|
var parentChangedCancelers = elements.map(function (element) {
|
|
8285
9509
|
var _a;
|
|
@@ -8306,7 +9530,7 @@ var Paper = function (props) {
|
|
|
8306
9530
|
};
|
|
8307
9531
|
}, elements);
|
|
8308
9532
|
//Update elements tree when length of elements change
|
|
8309
|
-
React.useEffect(function () {
|
|
9533
|
+
React$1.useEffect(function () {
|
|
8310
9534
|
updateElementsTree();
|
|
8311
9535
|
}, [elements.length]);
|
|
8312
9536
|
//Get all child elements of the deleted element
|
|
@@ -8320,7 +9544,7 @@ var Paper = function (props) {
|
|
|
8320
9544
|
return __spreadArray(__spreadArray([], childElms, true), childOfChildElements, true);
|
|
8321
9545
|
};
|
|
8322
9546
|
//Listen command delete selected for element
|
|
8323
|
-
React.useEffect(function () {
|
|
9547
|
+
React$1.useEffect(function () {
|
|
8324
9548
|
var listener = paperEventEmitter.onCommandDeleteSelectedElement(function () {
|
|
8325
9549
|
if (selectedElement) {
|
|
8326
9550
|
var deletedChildElements = getDeletedChildElements(selectedElement);
|
|
@@ -8335,7 +9559,7 @@ var Paper = function (props) {
|
|
|
8335
9559
|
};
|
|
8336
9560
|
}, [selectedElement]);
|
|
8337
9561
|
//Listen command delete selected for link
|
|
8338
|
-
React.useEffect(function () {
|
|
9562
|
+
React$1.useEffect(function () {
|
|
8339
9563
|
var listener = paperEventEmitter.onCommandDeleteSelectedLink(function () {
|
|
8340
9564
|
if (selectedLink) {
|
|
8341
9565
|
setLinks(function (prev) { return prev.filter(function (l) { return l.id !== selectedLink.id; }); });
|
|
@@ -8347,7 +9571,7 @@ var Paper = function (props) {
|
|
|
8347
9571
|
};
|
|
8348
9572
|
}, [selectedLink]);
|
|
8349
9573
|
//Listen command delete selected for Text
|
|
8350
|
-
React.useEffect(function () {
|
|
9574
|
+
React$1.useEffect(function () {
|
|
8351
9575
|
var listener = paperEventEmitter.onCommandDeleteSelectedText(function () {
|
|
8352
9576
|
if (selectedText) {
|
|
8353
9577
|
setTexts(function (prev) { return prev.filter(function (t) { return t.id !== selectedText.id; }); });
|
|
@@ -8433,7 +9657,7 @@ var Paper = function (props) {
|
|
|
8433
9657
|
}
|
|
8434
9658
|
setMouseDownedOnPaper(false);
|
|
8435
9659
|
};
|
|
8436
|
-
var handlePathChange = React.useCallback(function (path, id) {
|
|
9660
|
+
var handlePathChange = React$1.useCallback(function (path, id) {
|
|
8437
9661
|
//Update path of element link, that changed
|
|
8438
9662
|
setLinks(function (prevLinks) {
|
|
8439
9663
|
var updatedLinkIndex = prevLinks.findIndex(function (l) { return l.id === id; });
|
|
@@ -8520,7 +9744,7 @@ var Paper = function (props) {
|
|
|
8520
9744
|
setTempLink(undefined);
|
|
8521
9745
|
}
|
|
8522
9746
|
};
|
|
8523
|
-
var handleLinkLabelMoved = React.useCallback(function (offsetX, offsetY, index, labelType) {
|
|
9747
|
+
var handleLinkLabelMoved = React$1.useCallback(function (offsetX, offsetY, index, labelType) {
|
|
8524
9748
|
setLinks(function (prevLinks) {
|
|
8525
9749
|
var newLinks = __spreadArray([], prevLinks, true);
|
|
8526
9750
|
var currentLink = newLinks[index];
|
|
@@ -8556,7 +9780,7 @@ var Paper = function (props) {
|
|
|
8556
9780
|
return newLinks;
|
|
8557
9781
|
});
|
|
8558
9782
|
}, []);
|
|
8559
|
-
var handleLinkLabelResized = React.useCallback(function (width, height, index, labelType) {
|
|
9783
|
+
var handleLinkLabelResized = React$1.useCallback(function (width, height, index, labelType) {
|
|
8560
9784
|
setLinks(function (prevLinks) {
|
|
8561
9785
|
var newLinks = __spreadArray([], prevLinks, true);
|
|
8562
9786
|
var currentLink = newLinks[index];
|
|
@@ -8589,7 +9813,7 @@ var Paper = function (props) {
|
|
|
8589
9813
|
return newLinks;
|
|
8590
9814
|
});
|
|
8591
9815
|
}, []);
|
|
8592
|
-
var handleLinkLabelContentChanged = React.useCallback(function (newValue, index, labelType) {
|
|
9816
|
+
var handleLinkLabelContentChanged = React$1.useCallback(function (newValue, index, labelType) {
|
|
8593
9817
|
setLinks(function (prevLinks) {
|
|
8594
9818
|
var newLinks = __spreadArray([], prevLinks, true);
|
|
8595
9819
|
var currentLink = newLinks[index];
|
|
@@ -8673,7 +9897,7 @@ var Paper = function (props) {
|
|
|
8673
9897
|
Cache to avoid re-initializing the function when the component re-renders to
|
|
8674
9898
|
avoid causing the components using it to re-render unnecessarily
|
|
8675
9899
|
*/
|
|
8676
|
-
var onLabelMoved = React.useCallback(function (index) {
|
|
9900
|
+
var onLabelMoved = React$1.useCallback(function (index) {
|
|
8677
9901
|
return function (offsetX, offsetY, labelType) {
|
|
8678
9902
|
handleLinkLabelMoved(offsetX, offsetY, index, labelType);
|
|
8679
9903
|
};
|
|
@@ -8682,7 +9906,7 @@ var Paper = function (props) {
|
|
|
8682
9906
|
Cache to avoid re-initializing the function when the component re-renders to
|
|
8683
9907
|
avoid causing the components using it to re-render unnecessarily
|
|
8684
9908
|
*/
|
|
8685
|
-
var onLabelResized = React.useCallback(function (index) {
|
|
9909
|
+
var onLabelResized = React$1.useCallback(function (index) {
|
|
8686
9910
|
return function (width, height, labelType) {
|
|
8687
9911
|
handleLinkLabelResized(width, height, index, labelType);
|
|
8688
9912
|
};
|
|
@@ -8691,12 +9915,12 @@ var Paper = function (props) {
|
|
|
8691
9915
|
Cache to avoid re-initializing the function when the component re-renders to
|
|
8692
9916
|
avoid causing the components using it to re-render unnecessarily
|
|
8693
9917
|
*/
|
|
8694
|
-
var onLabelContentChanged = React.useCallback(function (index) {
|
|
9918
|
+
var onLabelContentChanged = React$1.useCallback(function (index) {
|
|
8695
9919
|
return function (newValue, labelType) {
|
|
8696
9920
|
handleLinkLabelContentChanged(newValue, index, labelType);
|
|
8697
9921
|
};
|
|
8698
9922
|
}, [handleLinkLabelContentChanged]);
|
|
8699
|
-
var handleClickLinkDelete = React.useCallback(function (link, index) {
|
|
9923
|
+
var handleClickLinkDelete = React$1.useCallback(function (link, index) {
|
|
8700
9924
|
return function () {
|
|
8701
9925
|
setLinks(function (prevLinks) {
|
|
8702
9926
|
var newLinks = __spreadArray([], prevLinks, true);
|
|
@@ -8747,7 +9971,7 @@ var Paper = function (props) {
|
|
|
8747
9971
|
var _a, _b;
|
|
8748
9972
|
//use the defined react element or the default Element component
|
|
8749
9973
|
var ReactElement = element.reactElement || Element;
|
|
8750
|
-
return (React.createElement("g", { key: element.id }, React.createElement(ReactElement, { key: "element-".concat(element.id), id: element.id, height: element.size.height, width: element.size.width, x: (_a = element.relativePosition) === null || _a === void 0 ? void 0 : _a.x, y: (_b = element.relativePosition) === null || _b === void 0 ? void 0 : _b.y, onClick: function (id, e, ref) {
|
|
9974
|
+
return (React$1.createElement("g", { key: element.id }, React$1.createElement(ReactElement, { key: "element-".concat(element.id), id: element.id, height: element.size.height, width: element.size.width, x: (_a = element.relativePosition) === null || _a === void 0 ? void 0 : _a.x, y: (_b = element.relativePosition) === null || _b === void 0 ? void 0 : _b.y, onClick: function (id, e, ref) {
|
|
8751
9975
|
e.stopPropagation();
|
|
8752
9976
|
setSelectedElementSVG(ref);
|
|
8753
9977
|
setSelectedElement(element);
|
|
@@ -8756,15 +9980,15 @@ var Paper = function (props) {
|
|
|
8756
9980
|
// portPlaceholderShape={(<Circle x={0} y={0} width={10} height={10} fill='red' positioningAnchor={PositioningAnchor.Center} />)}
|
|
8757
9981
|
onMouseUpAtLinkedPortPlaceholder: function (elementLink, position) { return handleMouseUpAtLinkedPortPlaceholder(elementLink, position, element); }, onTextUpdated: function (textId, newContent) { return handleElementTextChange(element, textId, newContent); }, textsPlaceHolderClassName: element.textsPlaceHolderClassName, textsPlaceHolderFlexStyle: element.textsPlaceHolderFlexStyle, textsPlaceHolderFlexboxPosition: element.textsPlaceHolderFlexboxPosition }, element.childrenElements && element.childrenElements.map(renderElementInTree))));
|
|
8758
9982
|
};
|
|
8759
|
-
return (React.createElement("div", { style: { position: "relative" } },
|
|
8760
|
-
React.createElement(Ruler, { squareSize: 100, border: '1px dashed grey' }),
|
|
8761
|
-
React.createElement("svg", { tabIndex: 0, width: size.width, height: size.height, ref: paperContainerRef, id: "paper-container", onMouseMove: handlePaperMouseMove, onMouseDown: handleMouseDownOnPaper, onMouseUp: handleMouseUpOnPaper },
|
|
9983
|
+
return (React$1.createElement("div", { style: { position: "relative" } },
|
|
9984
|
+
React$1.createElement(Ruler, { squareSize: 100, border: '1px dashed grey' }),
|
|
9985
|
+
React$1.createElement("svg", { tabIndex: 0, width: size.width, height: size.height, ref: paperContainerRef, id: "paper-container", onMouseMove: handlePaperMouseMove, onMouseDown: handleMouseDownOnPaper, onMouseUp: handleMouseUpOnPaper },
|
|
8762
9986
|
paperContainerRef.current ? elementsInTree.map(function (element, index) {
|
|
8763
9987
|
return renderElementInTree(element);
|
|
8764
9988
|
}) : "",
|
|
8765
9989
|
links && links.map(function (link, index) {
|
|
8766
9990
|
var _a, _b, _c, _d;
|
|
8767
|
-
return (React.createElement(ElementLink, { key: link.id, id: link.id, path: link.path, sourcePosition: {
|
|
9991
|
+
return (React$1.createElement(ElementLink, { key: link.id, id: link.id, path: link.path, sourcePosition: {
|
|
8768
9992
|
x: link.sourceElement.position.x + link.sourcePort.position.x,
|
|
8769
9993
|
y: link.sourceElement.position.y + link.sourcePort.position.y
|
|
8770
9994
|
}, targetPosition: {
|
|
@@ -8772,26 +9996,26 @@ var Paper = function (props) {
|
|
|
8772
9996
|
y: ((_c = link.targetElement) === null || _c === void 0 ? void 0 : _c.position.y) + ((_d = link.targetPort) === null || _d === void 0 ? void 0 : _d.position.y)
|
|
8773
9997
|
}, points: link.points, onPathChanged: handlePathChange, onClickDelete: handleClickLinkDelete(link, index), onSelected: function () { return handleSelectLink(link); }, onDeselected: function () { return handleDeselectLink(); }, container: paperContainerRef.current, markerStart: link.markerStart, markerEnd: link.markerEnd, markerDistanceFromPort: link.markerDistanceFromPort, markerSize: link.markerSize, label: link.label, sourceLabel: link.sourceLabel, targetLabel: link.targetLabel, onLabelMoved: onLabelMoved(index), onLabelResized: onLabelResized(index), onLabelContentChanged: onLabelContentChanged(index) }));
|
|
8774
9998
|
}),
|
|
8775
|
-
(tempLink === null || tempLink === void 0 ? void 0 : tempLink.tempTargetPosition) && React.createElement(ElementLink, { id: tempLink.id, points: tempLink.points, sourcePosition: {
|
|
9999
|
+
(tempLink === null || tempLink === void 0 ? void 0 : tempLink.tempTargetPosition) && React$1.createElement(ElementLink, { id: tempLink.id, points: tempLink.points, sourcePosition: {
|
|
8776
10000
|
x: tempLink.sourceElement.position.x + tempLink.sourcePort.position.x,
|
|
8777
10001
|
y: tempLink.sourceElement.position.y + tempLink.sourcePort.position.y
|
|
8778
10002
|
}, targetPosition: tempLink.tempTargetPosition, container: paperContainerRef.current, markerStart: tempLink.markerStart, markerEnd: tempLink.markerEnd, markerDistanceFromPort: tempLink.markerDistanceFromPort, markerSize: tempLink.markerSize }),
|
|
8779
|
-
texts.map(function (text, index) { return (React.createElement(Text$1, { key: text.id, id: text.id, x: text.position.x, y: text.position.y, width: text.size.width, height: text.size.height, fontSize: text.fontSize, border: text.border, container: paperContainerRef.current, content: text.content, align: text.align, onSelected: function () {
|
|
10003
|
+
texts.map(function (text, index) { return (React$1.createElement(Text$1, { key: text.id, id: text.id, x: text.position.x, y: text.position.y, width: text.size.width, height: text.size.height, fontSize: text.fontSize, border: text.border, container: paperContainerRef.current, content: text.content, align: text.align, onSelected: function () {
|
|
8780
10004
|
setSelectedText(text);
|
|
8781
10005
|
} })); })),
|
|
8782
|
-
React.createElement(BBoxDebugger, { elementSVG: selectedElementSVG }),
|
|
8783
|
-
React.createElement(LinkDebugger, { links: links, svgContainer: paperContainerRef.current })));
|
|
10006
|
+
React$1.createElement(BBoxDebugger, { elementSVG: selectedElementSVG }),
|
|
10007
|
+
React$1.createElement(LinkDebugger, { links: links, svgContainer: paperContainerRef.current })));
|
|
8784
10008
|
};
|
|
8785
10009
|
|
|
8786
10010
|
function Editor(_a) {
|
|
8787
10011
|
var editorContext = _a.editorContext;
|
|
8788
|
-
return (React.createElement(React.Fragment, null,
|
|
8789
|
-
React.createElement(Paper, { size: { width: 3000, height: 3000 }, elements: editorContext.elements, links: editorContext.links, texts: editorContext.texts, onPaperClicked: editorContext.onPaperClicked, onPortMoved: editorContext.onPortMoved, onElementMoved: editorContext.onElementMoved, onElementResized: editorContext.onElementResized, onLinkValidation: editorContext.validateLink, onCreatingLink: editorContext.onCreatingLink, onCreatingPortByLinking: editorContext.onCreatingPortByLinking })));
|
|
10012
|
+
return (React$1.createElement(React$1.Fragment, null,
|
|
10013
|
+
React$1.createElement(Paper, { size: { width: 3000, height: 3000 }, elements: editorContext.elements, links: editorContext.links, texts: editorContext.texts, onPaperClicked: editorContext.onPaperClicked, onPortMoved: editorContext.onPortMoved, onElementMoved: editorContext.onElementMoved, onElementResized: editorContext.onElementResized, onLinkValidation: editorContext.validateLink, onCreatingLink: editorContext.onCreatingLink, onCreatingPortByLinking: editorContext.onCreatingPortByLinking })));
|
|
8790
10014
|
}
|
|
8791
10015
|
|
|
8792
10016
|
exports.CircleRC = Circle;
|
|
8793
10017
|
exports.CrescentRC = Crescent;
|
|
8794
|
-
exports.
|
|
10018
|
+
exports.CustomPortFromJSXElement = CustomPortFromJSXElement;
|
|
8795
10019
|
exports.CustomShapeRC = CustomShape;
|
|
8796
10020
|
exports.EditorContext = EditorContext;
|
|
8797
10021
|
exports.Element = Element$1;
|