orcasvn-react-diagrams 0.1.29 → 0.1.30
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
CHANGED
|
@@ -7505,12 +7505,12 @@ var checkPointContainsPolygon = function (position, polygonPoints) {
|
|
|
7505
7505
|
*/
|
|
7506
7506
|
var makePolygonOfElement = function (ele) {
|
|
7507
7507
|
var polygon = new Flatten$1.Polygon();
|
|
7508
|
-
var
|
|
7508
|
+
var vertexes = getFourVertexesOfBBoxFromElement(ele);
|
|
7509
7509
|
polygon.addFace([
|
|
7510
|
-
Flatten$1.point(
|
|
7511
|
-
Flatten$1.point(
|
|
7512
|
-
Flatten$1.point(
|
|
7513
|
-
Flatten$1.point(
|
|
7510
|
+
Flatten$1.point(vertexes[0].x, vertexes[0].y),
|
|
7511
|
+
Flatten$1.point(vertexes[1].x, vertexes[1].y),
|
|
7512
|
+
Flatten$1.point(vertexes[2].x, vertexes[2].y),
|
|
7513
|
+
Flatten$1.point(vertexes[3].x, vertexes[3].y),
|
|
7514
7514
|
]);
|
|
7515
7515
|
return polygon;
|
|
7516
7516
|
};
|
|
@@ -7552,46 +7552,30 @@ var getFirstIntersection = function (startPosition, endPosition, elements) {
|
|
|
7552
7552
|
//Find a point next to an element from a point on the element
|
|
7553
7553
|
var generateSubstitutePosition = function (intersectedPosition, targetPosition, ele) {
|
|
7554
7554
|
var translationOffset = 20;
|
|
7555
|
-
var
|
|
7556
|
-
var vertex1Position = {
|
|
7557
|
-
x: ele.position.x + strokeWidthOffset,
|
|
7558
|
-
y: ele.position.y + strokeWidthOffset,
|
|
7559
|
-
};
|
|
7560
|
-
var vertex2Position = {
|
|
7561
|
-
x: ele.position.x + ele.size.width - strokeWidthOffset,
|
|
7562
|
-
y: ele.position.y + strokeWidthOffset,
|
|
7563
|
-
};
|
|
7564
|
-
var vertex3Position = {
|
|
7565
|
-
x: ele.position.x + ele.size.width - strokeWidthOffset,
|
|
7566
|
-
y: ele.position.y + ele.size.height - strokeWidthOffset,
|
|
7567
|
-
};
|
|
7568
|
-
var vertex4Position = {
|
|
7569
|
-
x: ele.position.x + strokeWidthOffset,
|
|
7570
|
-
y: ele.position.y + ele.size.height - strokeWidthOffset,
|
|
7571
|
-
};
|
|
7555
|
+
var _a = getFourVertexesOfBBoxFromElement(ele), vertex1Position = _a[0], vertex2Position = _a[1], vertex3Position = _a[2], vertex4Position = _a[3];
|
|
7572
7556
|
var replacementPosition = null;
|
|
7573
|
-
if (checkSamePosition(vertex1Position, intersectedPosition,
|
|
7557
|
+
if (checkSamePosition(vertex1Position, intersectedPosition, 0)) {
|
|
7574
7558
|
//Cut at vertex 1 of bbox, move out a distance x,y
|
|
7575
7559
|
replacementPosition = {
|
|
7576
7560
|
x: vertex1Position.x - translationOffset,
|
|
7577
7561
|
y: vertex1Position.y - translationOffset,
|
|
7578
7562
|
};
|
|
7579
7563
|
}
|
|
7580
|
-
else if (checkSamePosition(vertex2Position, intersectedPosition,
|
|
7564
|
+
else if (checkSamePosition(vertex2Position, intersectedPosition, 0)) {
|
|
7581
7565
|
//Cut at vertex 2 of bbox, move out a distance x,y
|
|
7582
7566
|
replacementPosition = {
|
|
7583
7567
|
x: vertex2Position.x + translationOffset,
|
|
7584
7568
|
y: vertex2Position.y - translationOffset,
|
|
7585
7569
|
};
|
|
7586
7570
|
}
|
|
7587
|
-
else if (checkSamePosition(vertex3Position, intersectedPosition,
|
|
7571
|
+
else if (checkSamePosition(vertex3Position, intersectedPosition, 0)) {
|
|
7588
7572
|
//Cut at vertex 3 of bbox, move out a distance x,y
|
|
7589
7573
|
replacementPosition = {
|
|
7590
7574
|
x: vertex3Position.x + translationOffset,
|
|
7591
7575
|
y: vertex3Position.y + translationOffset,
|
|
7592
7576
|
};
|
|
7593
7577
|
}
|
|
7594
|
-
else if (checkSamePosition(vertex4Position, intersectedPosition,
|
|
7578
|
+
else if (checkSamePosition(vertex4Position, intersectedPosition, 0)) {
|
|
7595
7579
|
//Cut at vertex 4 of bbox, move out a distance x,y
|
|
7596
7580
|
replacementPosition = {
|
|
7597
7581
|
x: vertex4Position.x - translationOffset,
|
|
@@ -7699,6 +7683,25 @@ var getRelativePosition = function (clientPosition, relativeElement) {
|
|
|
7699
7683
|
x: clientPosition.x - relativeRect.left,
|
|
7700
7684
|
y: clientPosition.y - relativeRect.top,
|
|
7701
7685
|
};
|
|
7686
|
+
};
|
|
7687
|
+
var getFourVertexesOfBBoxFromElement = function (element) {
|
|
7688
|
+
var vertex1Position = {
|
|
7689
|
+
x: element.position.x,
|
|
7690
|
+
y: element.position.y
|
|
7691
|
+
};
|
|
7692
|
+
var vertex2Position = {
|
|
7693
|
+
x: element.position.x + element.size.width,
|
|
7694
|
+
y: element.position.y
|
|
7695
|
+
};
|
|
7696
|
+
var vertex3Position = {
|
|
7697
|
+
x: element.position.x + element.size.width,
|
|
7698
|
+
y: element.position.y + element.size.height
|
|
7699
|
+
};
|
|
7700
|
+
var vertex4Position = {
|
|
7701
|
+
x: element.position.x,
|
|
7702
|
+
y: element.position.y + element.size.height
|
|
7703
|
+
};
|
|
7704
|
+
return [vertex1Position, vertex2Position, vertex3Position, vertex4Position];
|
|
7702
7705
|
};
|
|
7703
7706
|
|
|
7704
7707
|
var makerStart = React.createElement("circle", { cx: 10, cy: 10, r: 10, fill: "blue" });
|
|
@@ -8058,7 +8061,7 @@ var Element = function (props) {
|
|
|
8058
8061
|
}, [ports]);
|
|
8059
8062
|
React.useEffect(function () {
|
|
8060
8063
|
var _a;
|
|
8061
|
-
console.info('Rendering Element ' + ((_a = texts === null || texts === void 0 ? void 0 : texts[0]) === null || _a === void 0 ? void 0 : _a.content) || id);
|
|
8064
|
+
console.info('Rendering Element ' + ((_a = texts === null || texts === void 0 ? void 0 : texts[0]) === null || _a === void 0 ? void 0 : _a.content) || id, props.ports);
|
|
8062
8065
|
});
|
|
8063
8066
|
//Listen a new port is created, after add new port to ports state
|
|
8064
8067
|
React.useEffect(function () {
|
|
@@ -8839,7 +8842,7 @@ var Paper = function (props) {
|
|
|
8839
8842
|
parentChangedCancelers.forEach(function (canceller) { return canceller === null || canceller === void 0 ? void 0 : canceller(); });
|
|
8840
8843
|
addedPortCancelers.forEach(function (canceller) { return canceller(); });
|
|
8841
8844
|
};
|
|
8842
|
-
}, []);
|
|
8845
|
+
}, [elements]);
|
|
8843
8846
|
//Update elements tree when length of elements change
|
|
8844
8847
|
React.useEffect(function () {
|
|
8845
8848
|
updateElementsTree();
|
|
@@ -8912,6 +8915,9 @@ var Paper = function (props) {
|
|
|
8912
8915
|
//Automatically add points on the link so that the link does not cross elements, default maximum 10 points
|
|
8913
8916
|
var automationAddPointsToLink = React.useCallback(function (eleLink, limitPoint) {
|
|
8914
8917
|
if (limitPoint === void 0) { limitPoint = 10; }
|
|
8918
|
+
if (!eleLink.targetElement) {
|
|
8919
|
+
throw new Error("Target element is not found in element link");
|
|
8920
|
+
}
|
|
8915
8921
|
var sourceElement = eleLink.sourceElement, sourcePort = eleLink.sourcePort, targetElement = eleLink.targetElement, targetPort = eleLink.targetPort;
|
|
8916
8922
|
var sourcePosition = {
|
|
8917
8923
|
x: sourceElement.position.x + sourcePort.position.x,
|
|
@@ -8921,6 +8927,20 @@ var Paper = function (props) {
|
|
|
8921
8927
|
x: targetElement.position.x + targetPort.position.x,
|
|
8922
8928
|
y: targetElement.position.y + targetPort.position.y
|
|
8923
8929
|
};
|
|
8930
|
+
var fourVertexesOfSourceEleBBox = getFourVertexesOfBBoxFromElement(sourceElement);
|
|
8931
|
+
var fourVertexesOfTargetEleBBox = getFourVertexesOfBBoxFromElement(targetElement);
|
|
8932
|
+
var projectedSourcePositionOnBBox = findNearestProjectedPoint(sourcePosition, [
|
|
8933
|
+
[fourVertexesOfSourceEleBBox[0], fourVertexesOfSourceEleBBox[1]],
|
|
8934
|
+
[fourVertexesOfSourceEleBBox[1], fourVertexesOfSourceEleBBox[2]],
|
|
8935
|
+
[fourVertexesOfSourceEleBBox[2], fourVertexesOfSourceEleBBox[3]],
|
|
8936
|
+
[fourVertexesOfSourceEleBBox[3], fourVertexesOfSourceEleBBox[0]],
|
|
8937
|
+
]);
|
|
8938
|
+
var projectedTargetPositionOnBBox = findNearestProjectedPoint(targetPosition, [
|
|
8939
|
+
[fourVertexesOfTargetEleBBox[0], fourVertexesOfTargetEleBBox[1]],
|
|
8940
|
+
[fourVertexesOfTargetEleBBox[1], fourVertexesOfTargetEleBBox[2]],
|
|
8941
|
+
[fourVertexesOfTargetEleBBox[2], fourVertexesOfTargetEleBBox[3]],
|
|
8942
|
+
[fourVertexesOfTargetEleBBox[3], fourVertexesOfTargetEleBBox[0]],
|
|
8943
|
+
]);
|
|
8924
8944
|
var numberOfPoints = 0;
|
|
8925
8945
|
//create points between the start and end points, to create a line segment that passes through the points without intersecting the elements
|
|
8926
8946
|
function generatePositions(sourcePosition, targetPosition, elements) {
|
|
@@ -8940,7 +8960,7 @@ var Paper = function (props) {
|
|
|
8940
8960
|
return __spreadArray(__spreadArray(__spreadArray([], prependedPoints, true), [replacementPosition], false), appendedPoints, true);
|
|
8941
8961
|
}
|
|
8942
8962
|
var elements = elementsRef.current;
|
|
8943
|
-
var points = generatePositions(
|
|
8963
|
+
var points = generatePositions(projectedSourcePositionOnBBox, projectedTargetPositionOnBBox, elements);
|
|
8944
8964
|
return __assign(__assign({}, eleLink), { points: points });
|
|
8945
8965
|
}, []);
|
|
8946
8966
|
var handlePaperMouseMove = function (ev) {
|
|
@@ -45,3 +45,4 @@ export declare const getFirstIntersection: (startPosition: IPosition, endPositio
|
|
|
45
45
|
} | undefined;
|
|
46
46
|
export declare const generateSubstitutePosition: (intersectedPosition: IPosition, targetPosition: IPosition, ele: IElement) => IPosition;
|
|
47
47
|
export declare const getRelativePosition: (clientPosition: IPosition, relativeElement: Element) => IPosition;
|
|
48
|
+
export declare const getFourVertexesOfBBoxFromElement: (element: IElement) => IPosition[];
|
package/dist/esm/index.js
CHANGED
|
@@ -7501,12 +7501,12 @@ var checkPointContainsPolygon = function (position, polygonPoints) {
|
|
|
7501
7501
|
*/
|
|
7502
7502
|
var makePolygonOfElement = function (ele) {
|
|
7503
7503
|
var polygon = new Flatten$1.Polygon();
|
|
7504
|
-
var
|
|
7504
|
+
var vertexes = getFourVertexesOfBBoxFromElement(ele);
|
|
7505
7505
|
polygon.addFace([
|
|
7506
|
-
Flatten$1.point(
|
|
7507
|
-
Flatten$1.point(
|
|
7508
|
-
Flatten$1.point(
|
|
7509
|
-
Flatten$1.point(
|
|
7506
|
+
Flatten$1.point(vertexes[0].x, vertexes[0].y),
|
|
7507
|
+
Flatten$1.point(vertexes[1].x, vertexes[1].y),
|
|
7508
|
+
Flatten$1.point(vertexes[2].x, vertexes[2].y),
|
|
7509
|
+
Flatten$1.point(vertexes[3].x, vertexes[3].y),
|
|
7510
7510
|
]);
|
|
7511
7511
|
return polygon;
|
|
7512
7512
|
};
|
|
@@ -7548,46 +7548,30 @@ var getFirstIntersection = function (startPosition, endPosition, elements) {
|
|
|
7548
7548
|
//Find a point next to an element from a point on the element
|
|
7549
7549
|
var generateSubstitutePosition = function (intersectedPosition, targetPosition, ele) {
|
|
7550
7550
|
var translationOffset = 20;
|
|
7551
|
-
var
|
|
7552
|
-
var vertex1Position = {
|
|
7553
|
-
x: ele.position.x + strokeWidthOffset,
|
|
7554
|
-
y: ele.position.y + strokeWidthOffset,
|
|
7555
|
-
};
|
|
7556
|
-
var vertex2Position = {
|
|
7557
|
-
x: ele.position.x + ele.size.width - strokeWidthOffset,
|
|
7558
|
-
y: ele.position.y + strokeWidthOffset,
|
|
7559
|
-
};
|
|
7560
|
-
var vertex3Position = {
|
|
7561
|
-
x: ele.position.x + ele.size.width - strokeWidthOffset,
|
|
7562
|
-
y: ele.position.y + ele.size.height - strokeWidthOffset,
|
|
7563
|
-
};
|
|
7564
|
-
var vertex4Position = {
|
|
7565
|
-
x: ele.position.x + strokeWidthOffset,
|
|
7566
|
-
y: ele.position.y + ele.size.height - strokeWidthOffset,
|
|
7567
|
-
};
|
|
7551
|
+
var _a = getFourVertexesOfBBoxFromElement(ele), vertex1Position = _a[0], vertex2Position = _a[1], vertex3Position = _a[2], vertex4Position = _a[3];
|
|
7568
7552
|
var replacementPosition = null;
|
|
7569
|
-
if (checkSamePosition(vertex1Position, intersectedPosition,
|
|
7553
|
+
if (checkSamePosition(vertex1Position, intersectedPosition, 0)) {
|
|
7570
7554
|
//Cut at vertex 1 of bbox, move out a distance x,y
|
|
7571
7555
|
replacementPosition = {
|
|
7572
7556
|
x: vertex1Position.x - translationOffset,
|
|
7573
7557
|
y: vertex1Position.y - translationOffset,
|
|
7574
7558
|
};
|
|
7575
7559
|
}
|
|
7576
|
-
else if (checkSamePosition(vertex2Position, intersectedPosition,
|
|
7560
|
+
else if (checkSamePosition(vertex2Position, intersectedPosition, 0)) {
|
|
7577
7561
|
//Cut at vertex 2 of bbox, move out a distance x,y
|
|
7578
7562
|
replacementPosition = {
|
|
7579
7563
|
x: vertex2Position.x + translationOffset,
|
|
7580
7564
|
y: vertex2Position.y - translationOffset,
|
|
7581
7565
|
};
|
|
7582
7566
|
}
|
|
7583
|
-
else if (checkSamePosition(vertex3Position, intersectedPosition,
|
|
7567
|
+
else if (checkSamePosition(vertex3Position, intersectedPosition, 0)) {
|
|
7584
7568
|
//Cut at vertex 3 of bbox, move out a distance x,y
|
|
7585
7569
|
replacementPosition = {
|
|
7586
7570
|
x: vertex3Position.x + translationOffset,
|
|
7587
7571
|
y: vertex3Position.y + translationOffset,
|
|
7588
7572
|
};
|
|
7589
7573
|
}
|
|
7590
|
-
else if (checkSamePosition(vertex4Position, intersectedPosition,
|
|
7574
|
+
else if (checkSamePosition(vertex4Position, intersectedPosition, 0)) {
|
|
7591
7575
|
//Cut at vertex 4 of bbox, move out a distance x,y
|
|
7592
7576
|
replacementPosition = {
|
|
7593
7577
|
x: vertex4Position.x - translationOffset,
|
|
@@ -7695,6 +7679,25 @@ var getRelativePosition = function (clientPosition, relativeElement) {
|
|
|
7695
7679
|
x: clientPosition.x - relativeRect.left,
|
|
7696
7680
|
y: clientPosition.y - relativeRect.top,
|
|
7697
7681
|
};
|
|
7682
|
+
};
|
|
7683
|
+
var getFourVertexesOfBBoxFromElement = function (element) {
|
|
7684
|
+
var vertex1Position = {
|
|
7685
|
+
x: element.position.x,
|
|
7686
|
+
y: element.position.y
|
|
7687
|
+
};
|
|
7688
|
+
var vertex2Position = {
|
|
7689
|
+
x: element.position.x + element.size.width,
|
|
7690
|
+
y: element.position.y
|
|
7691
|
+
};
|
|
7692
|
+
var vertex3Position = {
|
|
7693
|
+
x: element.position.x + element.size.width,
|
|
7694
|
+
y: element.position.y + element.size.height
|
|
7695
|
+
};
|
|
7696
|
+
var vertex4Position = {
|
|
7697
|
+
x: element.position.x,
|
|
7698
|
+
y: element.position.y + element.size.height
|
|
7699
|
+
};
|
|
7700
|
+
return [vertex1Position, vertex2Position, vertex3Position, vertex4Position];
|
|
7698
7701
|
};
|
|
7699
7702
|
|
|
7700
7703
|
var makerStart = React.createElement("circle", { cx: 10, cy: 10, r: 10, fill: "blue" });
|
|
@@ -8054,7 +8057,7 @@ var Element = function (props) {
|
|
|
8054
8057
|
}, [ports]);
|
|
8055
8058
|
useEffect(function () {
|
|
8056
8059
|
var _a;
|
|
8057
|
-
console.info('Rendering Element ' + ((_a = texts === null || texts === void 0 ? void 0 : texts[0]) === null || _a === void 0 ? void 0 : _a.content) || id);
|
|
8060
|
+
console.info('Rendering Element ' + ((_a = texts === null || texts === void 0 ? void 0 : texts[0]) === null || _a === void 0 ? void 0 : _a.content) || id, props.ports);
|
|
8058
8061
|
});
|
|
8059
8062
|
//Listen a new port is created, after add new port to ports state
|
|
8060
8063
|
useEffect(function () {
|
|
@@ -8835,7 +8838,7 @@ var Paper = function (props) {
|
|
|
8835
8838
|
parentChangedCancelers.forEach(function (canceller) { return canceller === null || canceller === void 0 ? void 0 : canceller(); });
|
|
8836
8839
|
addedPortCancelers.forEach(function (canceller) { return canceller(); });
|
|
8837
8840
|
};
|
|
8838
|
-
}, []);
|
|
8841
|
+
}, [elements]);
|
|
8839
8842
|
//Update elements tree when length of elements change
|
|
8840
8843
|
useEffect(function () {
|
|
8841
8844
|
updateElementsTree();
|
|
@@ -8908,6 +8911,9 @@ var Paper = function (props) {
|
|
|
8908
8911
|
//Automatically add points on the link so that the link does not cross elements, default maximum 10 points
|
|
8909
8912
|
var automationAddPointsToLink = useCallback(function (eleLink, limitPoint) {
|
|
8910
8913
|
if (limitPoint === void 0) { limitPoint = 10; }
|
|
8914
|
+
if (!eleLink.targetElement) {
|
|
8915
|
+
throw new Error("Target element is not found in element link");
|
|
8916
|
+
}
|
|
8911
8917
|
var sourceElement = eleLink.sourceElement, sourcePort = eleLink.sourcePort, targetElement = eleLink.targetElement, targetPort = eleLink.targetPort;
|
|
8912
8918
|
var sourcePosition = {
|
|
8913
8919
|
x: sourceElement.position.x + sourcePort.position.x,
|
|
@@ -8917,6 +8923,20 @@ var Paper = function (props) {
|
|
|
8917
8923
|
x: targetElement.position.x + targetPort.position.x,
|
|
8918
8924
|
y: targetElement.position.y + targetPort.position.y
|
|
8919
8925
|
};
|
|
8926
|
+
var fourVertexesOfSourceEleBBox = getFourVertexesOfBBoxFromElement(sourceElement);
|
|
8927
|
+
var fourVertexesOfTargetEleBBox = getFourVertexesOfBBoxFromElement(targetElement);
|
|
8928
|
+
var projectedSourcePositionOnBBox = findNearestProjectedPoint(sourcePosition, [
|
|
8929
|
+
[fourVertexesOfSourceEleBBox[0], fourVertexesOfSourceEleBBox[1]],
|
|
8930
|
+
[fourVertexesOfSourceEleBBox[1], fourVertexesOfSourceEleBBox[2]],
|
|
8931
|
+
[fourVertexesOfSourceEleBBox[2], fourVertexesOfSourceEleBBox[3]],
|
|
8932
|
+
[fourVertexesOfSourceEleBBox[3], fourVertexesOfSourceEleBBox[0]],
|
|
8933
|
+
]);
|
|
8934
|
+
var projectedTargetPositionOnBBox = findNearestProjectedPoint(targetPosition, [
|
|
8935
|
+
[fourVertexesOfTargetEleBBox[0], fourVertexesOfTargetEleBBox[1]],
|
|
8936
|
+
[fourVertexesOfTargetEleBBox[1], fourVertexesOfTargetEleBBox[2]],
|
|
8937
|
+
[fourVertexesOfTargetEleBBox[2], fourVertexesOfTargetEleBBox[3]],
|
|
8938
|
+
[fourVertexesOfTargetEleBBox[3], fourVertexesOfTargetEleBBox[0]],
|
|
8939
|
+
]);
|
|
8920
8940
|
var numberOfPoints = 0;
|
|
8921
8941
|
//create points between the start and end points, to create a line segment that passes through the points without intersecting the elements
|
|
8922
8942
|
function generatePositions(sourcePosition, targetPosition, elements) {
|
|
@@ -8936,7 +8956,7 @@ var Paper = function (props) {
|
|
|
8936
8956
|
return __spreadArray(__spreadArray(__spreadArray([], prependedPoints, true), [replacementPosition], false), appendedPoints, true);
|
|
8937
8957
|
}
|
|
8938
8958
|
var elements = elementsRef.current;
|
|
8939
|
-
var points = generatePositions(
|
|
8959
|
+
var points = generatePositions(projectedSourcePositionOnBBox, projectedTargetPositionOnBBox, elements);
|
|
8940
8960
|
return __assign(__assign({}, eleLink), { points: points });
|
|
8941
8961
|
}, []);
|
|
8942
8962
|
var handlePaperMouseMove = function (ev) {
|