orcasvn-react-diagrams 0.1.16 → 0.1.17
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 +136 -138
- 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/IPortProps.d.ts +3 -0
- package/dist/cjs/types/models/implementations/Port.d.ts +6 -2
- package/dist/cjs/types/models/implementations/index.d.ts +0 -2
- package/dist/esm/index.js +137 -137
- package/dist/esm/index.js.map +1 -1
- 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/IPortProps.d.ts +3 -0
- package/dist/esm/types/models/implementations/Port.d.ts +6 -2
- package/dist/esm/types/models/implementations/index.d.ts +0 -2
- package/dist/index.d.ts +10 -11
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -560,8 +560,100 @@ var Element$1 = /** @class */ (function () {
|
|
|
560
560
|
return Element;
|
|
561
561
|
}());
|
|
562
562
|
|
|
563
|
+
/******************************************************************************
|
|
564
|
+
Copyright (c) Microsoft Corporation.
|
|
565
|
+
|
|
566
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
567
|
+
purpose with or without fee is hereby granted.
|
|
568
|
+
|
|
569
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
570
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
571
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
572
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
573
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
574
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
575
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
576
|
+
***************************************************************************** */
|
|
577
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
var __assign = function() {
|
|
581
|
+
__assign = Object.assign || function __assign(t) {
|
|
582
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
583
|
+
s = arguments[i];
|
|
584
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
585
|
+
}
|
|
586
|
+
return t;
|
|
587
|
+
};
|
|
588
|
+
return __assign.apply(this, arguments);
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
function __spreadArray(to, from, pack) {
|
|
592
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
593
|
+
if (ar || !(i in from)) {
|
|
594
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
595
|
+
ar[i] = from[i];
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
602
|
+
var e = new Error(message);
|
|
603
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
var ShapeWrapper = React$1.forwardRef(function (shapeProps, ref) {
|
|
607
|
+
//if direction is provided, rotation is based on direction
|
|
608
|
+
var rotation = shapeProps.rotation || 0;
|
|
609
|
+
if (shapeProps.direction) {
|
|
610
|
+
switch (shapeProps.direction) {
|
|
611
|
+
case 'left':
|
|
612
|
+
rotation = -90;
|
|
613
|
+
break;
|
|
614
|
+
case 'right':
|
|
615
|
+
rotation = 90;
|
|
616
|
+
break;
|
|
617
|
+
case 'down':
|
|
618
|
+
rotation = 180;
|
|
619
|
+
break;
|
|
620
|
+
default:
|
|
621
|
+
rotation = 0;
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
var position = { x: shapeProps.x, y: shapeProps.y };
|
|
626
|
+
var transformOrigin = "center";
|
|
627
|
+
if (typeof shapeProps.positioningAnchor === 'object') {
|
|
628
|
+
position.x = position.x - shapeProps.positioningAnchor.x / 100 * shapeProps.width;
|
|
629
|
+
position.y = position.y - shapeProps.positioningAnchor.y / 100 * shapeProps.height;
|
|
630
|
+
transformOrigin = "".concat(shapeProps.positioningAnchor.x, "% ").concat(shapeProps.positioningAnchor.y, "%");
|
|
631
|
+
}
|
|
632
|
+
else if (shapeProps.positioningAnchor === exports.PositioningAnchor.Center) {
|
|
633
|
+
position.x = position.x - shapeProps.width / 2;
|
|
634
|
+
position.y = position.y - shapeProps.height / 2;
|
|
635
|
+
}
|
|
636
|
+
var objectOfAllEventAttributes = React$1.useMemo(function () {
|
|
637
|
+
var arrayOfAllEventAttributes = Object.entries(shapeProps).filter(function (_a) {
|
|
638
|
+
var k = _a[0]; _a[1];
|
|
639
|
+
return k.startsWith('on');
|
|
640
|
+
});
|
|
641
|
+
return Object.fromEntries(arrayOfAllEventAttributes);
|
|
642
|
+
}, [shapeProps]);
|
|
643
|
+
var viewboxWidth = shapeProps.width > shapeProps.height ? 100 : shapeProps.width / shapeProps.height * 100;
|
|
644
|
+
var viewBoxHeight = shapeProps.height > shapeProps.width ? 100 : shapeProps.height / shapeProps.width * 100;
|
|
645
|
+
var viewBox = shapeProps.viewBox || "0 0 ".concat(viewboxWidth, " ").concat(viewBoxHeight);
|
|
646
|
+
return (React$1.createElement("g", { transform: "rotate(".concat(rotation, ")"), style: { transformOrigin: transformOrigin, transformBox: "content-box" } },
|
|
647
|
+
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)));
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
var CustomShape = React$1.forwardRef(function (props, ref) {
|
|
651
|
+
return (React$1.createElement(ShapeWrapper, __assign({}, props, { ref: ref }), props.children));
|
|
652
|
+
});
|
|
653
|
+
|
|
563
654
|
var Port$1 = /** @class */ (function () {
|
|
564
|
-
function Port(x, y, label,
|
|
655
|
+
function Port(x, y, label, shapeRenderer, width, height) {
|
|
656
|
+
var _this = this;
|
|
565
657
|
this._id = generateUniqueId();
|
|
566
658
|
this.position = { x: x, y: y };
|
|
567
659
|
if (!height) {
|
|
@@ -571,7 +663,14 @@ var Port$1 = /** @class */ (function () {
|
|
|
571
663
|
this.size = { width: width, height: height };
|
|
572
664
|
}
|
|
573
665
|
this.label = label;
|
|
574
|
-
|
|
666
|
+
if (shapeRenderer && shapeRenderer.shape) {
|
|
667
|
+
this.renderShape = shapeRenderer.shape;
|
|
668
|
+
}
|
|
669
|
+
else if (shapeRenderer && shapeRenderer.customShapeWithJSX) {
|
|
670
|
+
this.renderShape = React$1.forwardRef(function (props, ref) {
|
|
671
|
+
return (React$1.createElement(CustomShape, { ref: ref, x: props.x, y: props.y, width: props.width, height: props.height, rotation: props.rotation, positioningAnchor: shapeRenderer.positioningAnchor, 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); } }, shapeRenderer.customShapeWithJSX));
|
|
672
|
+
});
|
|
673
|
+
}
|
|
575
674
|
}
|
|
576
675
|
Object.defineProperty(Port.prototype, "id", {
|
|
577
676
|
get: function () {
|
|
@@ -701,130 +800,6 @@ var EditorContext = /** @class */ (function () {
|
|
|
701
800
|
return EditorContext;
|
|
702
801
|
}());
|
|
703
802
|
|
|
704
|
-
/******************************************************************************
|
|
705
|
-
Copyright (c) Microsoft Corporation.
|
|
706
|
-
|
|
707
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
708
|
-
purpose with or without fee is hereby granted.
|
|
709
|
-
|
|
710
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
711
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
712
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
713
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
714
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
715
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
716
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
717
|
-
***************************************************************************** */
|
|
718
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
719
|
-
|
|
720
|
-
var extendStatics = function(d, b) {
|
|
721
|
-
extendStatics = Object.setPrototypeOf ||
|
|
722
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
723
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
724
|
-
return extendStatics(d, b);
|
|
725
|
-
};
|
|
726
|
-
|
|
727
|
-
function __extends(d, b) {
|
|
728
|
-
if (typeof b !== "function" && b !== null)
|
|
729
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
730
|
-
extendStatics(d, b);
|
|
731
|
-
function __() { this.constructor = d; }
|
|
732
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
var __assign = function() {
|
|
736
|
-
__assign = Object.assign || function __assign(t) {
|
|
737
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
738
|
-
s = arguments[i];
|
|
739
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
740
|
-
}
|
|
741
|
-
return t;
|
|
742
|
-
};
|
|
743
|
-
return __assign.apply(this, arguments);
|
|
744
|
-
};
|
|
745
|
-
|
|
746
|
-
function __spreadArray(to, from, pack) {
|
|
747
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
748
|
-
if (ar || !(i in from)) {
|
|
749
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
750
|
-
ar[i] = from[i];
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
757
|
-
var e = new Error(message);
|
|
758
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
759
|
-
};
|
|
760
|
-
|
|
761
|
-
var ShapeWrapper = React$1.forwardRef(function (shapeProps, ref) {
|
|
762
|
-
//if direction is provided, rotation is based on direction
|
|
763
|
-
var rotation = shapeProps.rotation || 0;
|
|
764
|
-
if (shapeProps.direction) {
|
|
765
|
-
switch (shapeProps.direction) {
|
|
766
|
-
case 'left':
|
|
767
|
-
rotation = -90;
|
|
768
|
-
break;
|
|
769
|
-
case 'right':
|
|
770
|
-
rotation = 90;
|
|
771
|
-
break;
|
|
772
|
-
case 'down':
|
|
773
|
-
rotation = 180;
|
|
774
|
-
break;
|
|
775
|
-
default:
|
|
776
|
-
rotation = 0;
|
|
777
|
-
break;
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
var position = { x: shapeProps.x, y: shapeProps.y };
|
|
781
|
-
var transformOrigin = "center";
|
|
782
|
-
if (typeof shapeProps.positioningAnchor === 'object') {
|
|
783
|
-
position.x = position.x - shapeProps.positioningAnchor.x / 100 * shapeProps.width;
|
|
784
|
-
position.y = position.y - shapeProps.positioningAnchor.y / 100 * shapeProps.height;
|
|
785
|
-
transformOrigin = "".concat(shapeProps.positioningAnchor.x, "% ").concat(shapeProps.positioningAnchor.y, "%");
|
|
786
|
-
}
|
|
787
|
-
else if (shapeProps.positioningAnchor === exports.PositioningAnchor.Center) {
|
|
788
|
-
position.x = position.x - shapeProps.width / 2;
|
|
789
|
-
position.y = position.y - shapeProps.height / 2;
|
|
790
|
-
}
|
|
791
|
-
var objectOfAllEventAttributes = React$1.useMemo(function () {
|
|
792
|
-
var arrayOfAllEventAttributes = Object.entries(shapeProps).filter(function (_a) {
|
|
793
|
-
var k = _a[0]; _a[1];
|
|
794
|
-
return k.startsWith('on');
|
|
795
|
-
});
|
|
796
|
-
return Object.fromEntries(arrayOfAllEventAttributes);
|
|
797
|
-
}, [shapeProps]);
|
|
798
|
-
var viewboxWidth = shapeProps.width > shapeProps.height ? 100 : shapeProps.width / shapeProps.height * 100;
|
|
799
|
-
var viewBoxHeight = shapeProps.height > shapeProps.width ? 100 : shapeProps.height / shapeProps.width * 100;
|
|
800
|
-
var viewBox = shapeProps.viewBox || "0 0 ".concat(viewboxWidth, " ").concat(viewBoxHeight);
|
|
801
|
-
return (React$1.createElement("g", { transform: "rotate(".concat(rotation, ")"), style: { transformOrigin: transformOrigin, transformBox: "content-box" } },
|
|
802
|
-
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)));
|
|
803
|
-
});
|
|
804
|
-
|
|
805
|
-
var CustomShape = React$1.forwardRef(function (props, ref) {
|
|
806
|
-
return (React$1.createElement(ShapeWrapper, __assign({}, props, { ref: ref }), props.children));
|
|
807
|
-
});
|
|
808
|
-
|
|
809
|
-
var CustomPortFromJSXElement = /** @class */ (function (_super) {
|
|
810
|
-
__extends(CustomPortFromJSXElement, _super);
|
|
811
|
-
function CustomPortFromJSXElement(x, y, renderCustomShape, label, shapePositioningAnchor, width, height) {
|
|
812
|
-
var _this = _super.call(this, x, y, label, React$1.forwardRef(function (props, ref) {
|
|
813
|
-
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));
|
|
814
|
-
}), width, height) || this;
|
|
815
|
-
return _this;
|
|
816
|
-
}
|
|
817
|
-
return CustomPortFromJSXElement;
|
|
818
|
-
}(Port$1));
|
|
819
|
-
|
|
820
|
-
var CustomPortFromShape = /** @class */ (function (_super) {
|
|
821
|
-
__extends(CustomPortFromShape, _super);
|
|
822
|
-
function CustomPortFromShape(x, y, shape, label, width, height) {
|
|
823
|
-
return _super.call(this, x, y, label, shape, width, height) || this;
|
|
824
|
-
}
|
|
825
|
-
return CustomPortFromShape;
|
|
826
|
-
}(Port$1));
|
|
827
|
-
|
|
828
803
|
var Circle = React$1.forwardRef(function (props, ref) {
|
|
829
804
|
var s = { height: 100, width: 100 };
|
|
830
805
|
if (props.r) {
|
|
@@ -1482,7 +1457,7 @@ var Text = React$1.forwardRef(function (_a, ref) {
|
|
|
1482
1457
|
var Text$1 = React$1.memo(Text);
|
|
1483
1458
|
|
|
1484
1459
|
var Port1 = React$1.forwardRef(function (props, ref) {
|
|
1485
|
-
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;
|
|
1460
|
+
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, onMouseEnter = props.onMouseEnter, onMouseLeave = props.onMouseLeave, onMouseMove = props.onMouseMove, calculateRotationAngle = props.calculateRotationAngle, renderShape = props.renderShape;
|
|
1486
1461
|
var textRef = React$1.useRef(null);
|
|
1487
1462
|
var rotationAngle = React$1.useMemo(function () {
|
|
1488
1463
|
if (!calculateRotationAngle)
|
|
@@ -1500,7 +1475,7 @@ var Port1 = React$1.forwardRef(function (props, ref) {
|
|
|
1500
1475
|
return (React$1.createElement(RenderShape, __assign({ ref: ref }, props, { rotation: rotationAngle })));
|
|
1501
1476
|
}
|
|
1502
1477
|
else {
|
|
1503
|
-
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" });
|
|
1478
|
+
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); }, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onMouseMove: onMouseMove, 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" });
|
|
1504
1479
|
}
|
|
1505
1480
|
}, [props]);
|
|
1506
1481
|
return (React$1.createElement(React$1.Fragment, null,
|
|
@@ -8979,11 +8954,12 @@ var Element = function (props) {
|
|
|
8979
8954
|
var _a, _b, _c;
|
|
8980
8955
|
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, defaultPortSize = props.defaultPortSize, onClick = props.onClick, onContextMenu = props.onContextMenu, 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;
|
|
8981
8956
|
var _d = React$1.useState(), selectedPort = _d[0], setSelectedPort = _d[1];
|
|
8982
|
-
var _e = React$1.useState(
|
|
8957
|
+
var _e = React$1.useState(), hoveredPort = _e[0], setHoveredPort = _e[1];
|
|
8958
|
+
var _f = React$1.useState((_b = (_a = props.ports) === null || _a === void 0 ? void 0 : _a.map(function (p) {
|
|
8983
8959
|
return __assign(__assign({}, p), { id: p.id, ref: React$1.createRef() });
|
|
8984
|
-
})) !== null && _b !== void 0 ? _b : []), ports =
|
|
8985
|
-
var
|
|
8986
|
-
var
|
|
8960
|
+
})) !== null && _b !== void 0 ? _b : []), ports = _f[0], setPorts = _f[1];
|
|
8961
|
+
var _g = React$1.useState(false), someElementLinkStarted = _g[0], setSomeElementLinkStarted = _g[1];
|
|
8962
|
+
var _h = React$1.useState(), potentialPortPosition = _h[0], setPotentialPortPosition = _h[1];
|
|
8987
8963
|
var _paperEventEmitterContext = React$1.useContext(paperEventEmitterContext);
|
|
8988
8964
|
var elementRef = React$1.useRef(null);
|
|
8989
8965
|
var elementLinkStarted = React$1.useRef();
|
|
@@ -9049,6 +9025,7 @@ var Element = function (props) {
|
|
|
9049
9025
|
elementLinkStarted.current = undefined;
|
|
9050
9026
|
setSomeElementLinkStarted(false);
|
|
9051
9027
|
setPotentialPortPosition(undefined);
|
|
9028
|
+
setHoveredPort(undefined);
|
|
9052
9029
|
});
|
|
9053
9030
|
return function () {
|
|
9054
9031
|
elementStartedListener.off();
|
|
@@ -9187,7 +9164,6 @@ var Element = function (props) {
|
|
|
9187
9164
|
};
|
|
9188
9165
|
//Normalize port position
|
|
9189
9166
|
var normalizePortPosition = function (tempNewPosition) {
|
|
9190
|
-
console.info('normalizePortPosition', tempNewPosition);
|
|
9191
9167
|
var newPosition;
|
|
9192
9168
|
if (portMoveableAreas && portMoveableAreas.length > 0) { //If moveable areas is defined
|
|
9193
9169
|
newPosition = normalizePortPositionOnMoveableAreas(portMoveableAreas, tempNewPosition);
|
|
@@ -9271,6 +9247,11 @@ var Element = function (props) {
|
|
|
9271
9247
|
function handleElementMouseMove(ev) {
|
|
9272
9248
|
//ev.stopPropagation(); //Can't use stopPropagation here, because do not create tempLink
|
|
9273
9249
|
if (someElementLinkStarted && elementRef.current) {
|
|
9250
|
+
//If an element link is being created, calculate the potential port position when the mouse moves over the element.
|
|
9251
|
+
if (hoveredPort) {
|
|
9252
|
+
setPotentialPortPosition(undefined);
|
|
9253
|
+
return;
|
|
9254
|
+
}
|
|
9274
9255
|
/* The above code is calculating the relative position of the mouse within a specific
|
|
9275
9256
|
element on the page. It first gets the bounding rectangle of the element using
|
|
9276
9257
|
`getBoundingClientRect()` and the bounding box of the element using `getBBox()`. Then,
|
|
@@ -9314,7 +9295,7 @@ var Element = function (props) {
|
|
|
9314
9295
|
};
|
|
9315
9296
|
//Get rotate angle of port by port direction is defined.
|
|
9316
9297
|
var rotatePort = React$1.useCallback(function (x, y) {
|
|
9317
|
-
console.info('calculating port rotation', x, y)
|
|
9298
|
+
// console.info('calculating port rotation', x, y)
|
|
9318
9299
|
if (!portSlideRailSVGClassName)
|
|
9319
9300
|
return 0;
|
|
9320
9301
|
var slideRailSVG = getSlideRailSVG(portSlideRailSVGClassName);
|
|
@@ -9379,6 +9360,14 @@ var Element = function (props) {
|
|
|
9379
9360
|
movingOffsetThreshold: PORT_MOVING_OFFSET_THRESHOLD,
|
|
9380
9361
|
onMove: handlePortMove
|
|
9381
9362
|
});
|
|
9363
|
+
useSelectionFrame({
|
|
9364
|
+
container: container,
|
|
9365
|
+
targetSVGElement: (hoveredPort === null || hoveredPort === void 0 ? void 0 : hoveredPort.ref.current) || undefined,
|
|
9366
|
+
resizability: {
|
|
9367
|
+
enabled: false,
|
|
9368
|
+
keepRatio: false
|
|
9369
|
+
},
|
|
9370
|
+
});
|
|
9382
9371
|
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, onContextMenu: function (e) { return onContextMenu ? onContextMenu(id, e, elementRef.current) : true; } },
|
|
9383
9372
|
renderedShape,
|
|
9384
9373
|
potentialPortPosition && (portPlaceholderShape
|
|
@@ -9388,7 +9377,18 @@ var Element = function (props) {
|
|
|
9388
9377
|
var _a, _b, _c, _d, _e, _f;
|
|
9389
9378
|
return React$1.createElement(Port, { key: p.id, ref: p.ref, id: p.id, x: p.position.x, y: p.position.y, width: (_c = (_b = (_a = p.size) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : defaultPortSize) !== null && _c !== void 0 ? _c : PORT_DEFAULT_SIZE, height: (_f = (_e = (_d = p.size) === null || _d === void 0 ? void 0 : _d.height) !== null && _e !== void 0 ? _e : defaultPortSize) !== null && _f !== void 0 ? _f : PORT_DEFAULT_SIZE, container: container,
|
|
9390
9379
|
// rotation={rotatePort(p)}
|
|
9391
|
-
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,
|
|
9380
|
+
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, onMouseMove: function () {
|
|
9381
|
+
if (someElementLinkStarted)
|
|
9382
|
+
setHoveredPort(p);
|
|
9383
|
+
},
|
|
9384
|
+
// onMouseEnter={() => {
|
|
9385
|
+
// if (someElementLinkStarted) setHoveredPort(p)
|
|
9386
|
+
// }}
|
|
9387
|
+
onMouseLeave: function () {
|
|
9388
|
+
console.log('onMouseLeave');
|
|
9389
|
+
if (someElementLinkStarted)
|
|
9390
|
+
setHoveredPort(undefined);
|
|
9391
|
+
}, renderShape: p.renderShape });
|
|
9392
9392
|
}),
|
|
9393
9393
|
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) {
|
|
9394
9394
|
var _a, _b;
|
|
@@ -9909,7 +9909,7 @@ var Paper = function (props) {
|
|
|
9909
9909
|
if (!newElementLink)
|
|
9910
9910
|
return null;
|
|
9911
9911
|
//Automatic bending, if is not defined points
|
|
9912
|
-
if (!newElementLink.points) {
|
|
9912
|
+
if (!newElementLink.points || newElementLink.points.length === 0) {
|
|
9913
9913
|
newElementLink = automationAddPointsToLink(newElementLink, MAX_LINK_KNOT_COUNT);
|
|
9914
9914
|
}
|
|
9915
9915
|
var isValid = true;
|
|
@@ -10231,8 +10231,6 @@ function Editor(_a) {
|
|
|
10231
10231
|
|
|
10232
10232
|
exports.CircleRC = Circle;
|
|
10233
10233
|
exports.CrescentRC = Crescent;
|
|
10234
|
-
exports.CustomPortFromJSXElement = CustomPortFromJSXElement;
|
|
10235
|
-
exports.CustomPortFromShape = CustomPortFromShape;
|
|
10236
10234
|
exports.CustomShapeRC = CustomShape;
|
|
10237
10235
|
exports.EditorContext = EditorContext;
|
|
10238
10236
|
exports.Element = Element$1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import IText from "../models/IText";
|
|
2
|
-
import {
|
|
3
|
-
export declare class CustomPort1 extends
|
|
2
|
+
import { Port } from '../models';
|
|
3
|
+
export declare class CustomPort1 extends Port {
|
|
4
4
|
constructor(x: number, y: number, label?: IText, width?: number, height?: number);
|
|
5
5
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class PortIn extends
|
|
1
|
+
import { Port } from "../models";
|
|
2
|
+
export default class PortIn extends Port {
|
|
3
3
|
constructor(x: number, y: number, width?: number, height?: number);
|
|
4
4
|
}
|
|
@@ -17,6 +17,9 @@ export interface IPortProps {
|
|
|
17
17
|
onMouseDown?: (portId: string, e: React.MouseEvent<SVGElement>) => void;
|
|
18
18
|
moveableAreas?: IPosition[][];
|
|
19
19
|
label?: IText;
|
|
20
|
+
onMouseEnter?: (ev: React.MouseEvent) => void;
|
|
21
|
+
onMouseLeave?: (ev: React.MouseEvent) => void;
|
|
22
|
+
onMouseMove?: (ev: React.MouseEvent) => void;
|
|
20
23
|
onPortLabelMoved?: (offsetX: number, offsetY: number) => void;
|
|
21
24
|
onPortLabelResized?: (width: number, height: number) => void;
|
|
22
25
|
onPortLabelContentChanged?: (ev: React.ChangeEvent, newValue: string) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import IPort from "../IPort";
|
|
3
3
|
import { IPortProps } from "../IPortProps";
|
|
4
4
|
import IText from "../IText";
|
|
@@ -10,6 +10,10 @@ export default class Port implements IPort {
|
|
|
10
10
|
size?: ISize;
|
|
11
11
|
label?: IText;
|
|
12
12
|
renderShape?: React.ForwardRefExoticComponent<IPortProps & React.RefAttributes<SVGSVGElement>>;
|
|
13
|
-
constructor(x: number, y: number, label?: IText,
|
|
13
|
+
constructor(x: number, y: number, label?: IText, shapeRenderer?: {
|
|
14
|
+
shape?: React.ForwardRefExoticComponent<IPortProps & React.RefAttributes<SVGSVGElement>>;
|
|
15
|
+
customShapeWithJSX?: JSX.Element;
|
|
16
|
+
positioningAnchor?: IPosition;
|
|
17
|
+
}, width?: number, height?: number);
|
|
14
18
|
get id(): string;
|
|
15
19
|
}
|