orcasvn-react-diagrams 0.1.48 → 0.1.49
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 +144 -133
- package/dist/cjs/types/models/IElementSelectorProps.d.ts +2 -2
- package/dist/cjs/types/models/IPortProps.d.ts +1 -0
- package/dist/esm/index.js +144 -133
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/models/IElementSelectorProps.d.ts +2 -2
- package/dist/esm/types/models/IPortProps.d.ts +1 -0
- package/dist/index.d.ts +3 -2
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1065,7 +1065,8 @@ var Circle = React.forwardRef(function (props, ref) {
|
|
|
1065
1065
|
s.width = props.width;
|
|
1066
1066
|
}
|
|
1067
1067
|
return (React.createElement(ShapeWrapper, __assign({ viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height, ref: ref }),
|
|
1068
|
-
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 })
|
|
1068
|
+
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 }),
|
|
1069
|
+
props.children));
|
|
1069
1070
|
});
|
|
1070
1071
|
|
|
1071
1072
|
var Crescent = React.forwardRef(function (props, ref) {
|
|
@@ -1084,7 +1085,8 @@ var Crescent = React.forwardRef(function (props, ref) {
|
|
|
1084
1085
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
1085
1086
|
return (React.createElement(ShapeWrapper, __assign({ ref: ref, viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height }),
|
|
1086
1087
|
React.createElement("rect", { width: 100, height: 100, stroke: "transparent", fill: 'transparent' }),
|
|
1087
|
-
React.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 })
|
|
1088
|
+
React.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 }),
|
|
1089
|
+
props.children));
|
|
1088
1090
|
});
|
|
1089
1091
|
|
|
1090
1092
|
var Rectangle = React.forwardRef(function (props, ref) {
|
|
@@ -1104,7 +1106,8 @@ var Rectangle = React.forwardRef(function (props, ref) {
|
|
|
1104
1106
|
}
|
|
1105
1107
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
1106
1108
|
return (React.createElement(ShapeWrapper, __assign({}, props, { ref: ref, height: props.height, width: props.width }),
|
|
1107
|
-
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 })
|
|
1109
|
+
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 }),
|
|
1110
|
+
props.children));
|
|
1108
1111
|
});
|
|
1109
1112
|
|
|
1110
1113
|
var RectangularFrame = React.forwardRef(function (props, ref) {
|
|
@@ -1130,7 +1133,8 @@ var RectangularFrame = React.forwardRef(function (props, ref) {
|
|
|
1130
1133
|
return (React.createElement(ShapeWrapper, __assign({}, props, { ref: ref, height: props.height, width: props.width }),
|
|
1131
1134
|
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 }),
|
|
1132
1135
|
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" }),
|
|
1133
|
-
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" })
|
|
1136
|
+
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" }),
|
|
1137
|
+
props.children));
|
|
1134
1138
|
});
|
|
1135
1139
|
|
|
1136
1140
|
var createRoot;
|
|
@@ -1207,8 +1211,67 @@ var PORT_PLACEHOLDER_DEFAULT_STROKE = 'green';
|
|
|
1207
1211
|
var PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH = 20;
|
|
1208
1212
|
var PORT_DEFAULT_SIZE = 20;
|
|
1209
1213
|
|
|
1214
|
+
var Logger = /** @class */ (function () {
|
|
1215
|
+
function Logger() {
|
|
1216
|
+
this.level = 'info';
|
|
1217
|
+
this.customLogger = null;
|
|
1218
|
+
}
|
|
1219
|
+
Logger.prototype.setLevel = function (level) {
|
|
1220
|
+
this.level = level;
|
|
1221
|
+
};
|
|
1222
|
+
Logger.prototype.setCustomLogger = function (logger) {
|
|
1223
|
+
this.customLogger = logger;
|
|
1224
|
+
};
|
|
1225
|
+
Logger.prototype.log = function (level, message) {
|
|
1226
|
+
var _a;
|
|
1227
|
+
var optionalParams = [];
|
|
1228
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1229
|
+
optionalParams[_i - 2] = arguments[_i];
|
|
1230
|
+
}
|
|
1231
|
+
var levels = ['error', 'warn', 'info', 'debug'];
|
|
1232
|
+
if (this.level && levels.indexOf(level) <= levels.indexOf(this.level)) {
|
|
1233
|
+
if (this.customLogger) {
|
|
1234
|
+
this.customLogger.apply(this, __spreadArray([level, message], optionalParams, false));
|
|
1235
|
+
}
|
|
1236
|
+
else {
|
|
1237
|
+
console[level] ? (_a = console)[level].apply(_a, __spreadArray([message], optionalParams, false)) : console.log.apply(console, __spreadArray([message], optionalParams, false));
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
};
|
|
1241
|
+
Logger.prototype.error = function (msg) {
|
|
1242
|
+
var optionalParams = [];
|
|
1243
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1244
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
1245
|
+
}
|
|
1246
|
+
this.log.apply(this, __spreadArray(['error', msg], optionalParams, false));
|
|
1247
|
+
};
|
|
1248
|
+
Logger.prototype.warn = function (msg) {
|
|
1249
|
+
var optionalParams = [];
|
|
1250
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1251
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
1252
|
+
}
|
|
1253
|
+
this.log.apply(this, __spreadArray(['warn', msg], optionalParams, false));
|
|
1254
|
+
};
|
|
1255
|
+
Logger.prototype.info = function (msg) {
|
|
1256
|
+
var optionalParams = [];
|
|
1257
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1258
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
1259
|
+
}
|
|
1260
|
+
this.log.apply(this, __spreadArray(['info', msg], optionalParams, false));
|
|
1261
|
+
};
|
|
1262
|
+
Logger.prototype.debug = function (msg) {
|
|
1263
|
+
var optionalParams = [];
|
|
1264
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1265
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
1266
|
+
}
|
|
1267
|
+
this.log.apply(this, __spreadArray(['debug', msg], optionalParams, false));
|
|
1268
|
+
};
|
|
1269
|
+
return Logger;
|
|
1270
|
+
}());
|
|
1271
|
+
var logger = new Logger();
|
|
1272
|
+
|
|
1210
1273
|
var SelectionFrame = function (props) {
|
|
1211
|
-
var propTargetSVGElement = props.targetSVGElement, propWidth = props.width, propHeight = props.height, propFramePadding = props.framePadding,
|
|
1274
|
+
var propTargetSVGElement = props.targetSVGElement, propWidth = props.width, propHeight = props.height, propFramePadding = props.framePadding, objectX = props.objectX, objectY = props.objectY,
|
|
1212
1275
|
// movingOffsetThreshold: propMovingOffsetThreshold,
|
|
1213
1276
|
propMovingRate = props.movingRate, propOnMouseDown = props.onMouseDown, propOnMouseUp = props.onMouseUp, propOnMove = props.onMove, propContainer = props.container, propResizability = props.resizability, propOnResize = props.onResize, PropDragDropHandlerElement = props.dragDropHandlerElement, propStrokeWidth = props.strokeWidth, propAnchor = props.anchor;
|
|
1214
1277
|
var bbox = propTargetSVGElement === null || propTargetSVGElement === void 0 ? void 0 : propTargetSVGElement.getBBox();
|
|
@@ -1218,19 +1281,19 @@ var SelectionFrame = function (props) {
|
|
|
1218
1281
|
if (propWidth) {
|
|
1219
1282
|
setWidth(propWidth);
|
|
1220
1283
|
}
|
|
1221
|
-
}, [
|
|
1222
|
-
var _c = React.useState(
|
|
1223
|
-
var _d = React.useState(
|
|
1284
|
+
}, [objectX, propWidth]);
|
|
1285
|
+
var _c = React.useState(objectX !== null && objectX !== void 0 ? objectX : 0), curX = _c[0], setCurX = _c[1];
|
|
1286
|
+
var _d = React.useState(objectY !== null && objectY !== void 0 ? objectY : 0), curY = _d[0], setCurY = _d[1];
|
|
1224
1287
|
React.useEffect(function () {
|
|
1225
|
-
if (
|
|
1226
|
-
|
|
1288
|
+
if (objectX) {
|
|
1289
|
+
setCurX(objectX);
|
|
1227
1290
|
}
|
|
1228
|
-
}, [
|
|
1291
|
+
}, [objectX]);
|
|
1229
1292
|
React.useEffect(function () {
|
|
1230
|
-
if (
|
|
1231
|
-
|
|
1293
|
+
if (objectY) {
|
|
1294
|
+
setCurY(objectY);
|
|
1232
1295
|
}
|
|
1233
|
-
}, [
|
|
1296
|
+
}, [objectY]);
|
|
1234
1297
|
var framePadding = propFramePadding || 0;
|
|
1235
1298
|
var r = 5;
|
|
1236
1299
|
var _e = React.useState(false), draggingRect = _e[0], setDraggingRect = _e[1];
|
|
@@ -1274,8 +1337,8 @@ var SelectionFrame = function (props) {
|
|
|
1274
1337
|
var newX = mousePosition.x + xFromMouse;
|
|
1275
1338
|
var newY = mousePosition.y + yFromMouse;
|
|
1276
1339
|
if (propOnMove) {
|
|
1277
|
-
|
|
1278
|
-
|
|
1340
|
+
setCurX(newX);
|
|
1341
|
+
setCurY(newY);
|
|
1279
1342
|
propOnMove(newX, newY);
|
|
1280
1343
|
setLastMoveTime(Date.now());
|
|
1281
1344
|
setStartX(mouseEvent.clientX);
|
|
@@ -1305,6 +1368,14 @@ var SelectionFrame = function (props) {
|
|
|
1305
1368
|
}
|
|
1306
1369
|
};
|
|
1307
1370
|
React.useEffect(function () {
|
|
1371
|
+
logger.debug('SelectionFrame: circleHandleMouseDown triggered', {
|
|
1372
|
+
draggingCircle: draggingCircle,
|
|
1373
|
+
startX: startX,
|
|
1374
|
+
startY: startY,
|
|
1375
|
+
width: width,
|
|
1376
|
+
height: height,
|
|
1377
|
+
propMovingRate: propMovingRate
|
|
1378
|
+
});
|
|
1308
1379
|
var circleHandleMouseMove = function (event) {
|
|
1309
1380
|
var mouseEvent = event;
|
|
1310
1381
|
if (draggingCircle) {
|
|
@@ -1345,9 +1416,13 @@ var SelectionFrame = function (props) {
|
|
|
1345
1416
|
var container = propContainer;
|
|
1346
1417
|
container.addEventListener('mousemove', circleHandleMouseMove);
|
|
1347
1418
|
container.addEventListener('mouseup', circleHandleMouseUp);
|
|
1419
|
+
//logging the start of the circle handle mouse move
|
|
1420
|
+
logger.debug('SelectionFrame: circleHandleMouseMove started', container);
|
|
1348
1421
|
return function () {
|
|
1349
1422
|
container.removeEventListener('mousemove', circleHandleMouseMove);
|
|
1350
1423
|
container.removeEventListener('mouseup', circleHandleMouseUp);
|
|
1424
|
+
//logging the end of the circle handle mouse move
|
|
1425
|
+
logger.debug('SelectionFrame: circleHandleMouseMove ended', container);
|
|
1351
1426
|
};
|
|
1352
1427
|
}, [draggingCircle, width, height, curX, curY, lastMoveTime, propContainer, propMovingRate, propOnResize, propResizability, startX, startY]);
|
|
1353
1428
|
var rectangleSize = Math.max(width, height);
|
|
@@ -1366,6 +1441,13 @@ var SelectionFrame = function (props) {
|
|
|
1366
1441
|
|
|
1367
1442
|
var useSelectionFrame = function (props) {
|
|
1368
1443
|
React.useEffect(function () {
|
|
1444
|
+
//log selection frame rendering
|
|
1445
|
+
if (props.targetSVGElement) {
|
|
1446
|
+
console.debug('Rendering SelectionFrame for targetSVGElement:', props.targetSVGElement);
|
|
1447
|
+
}
|
|
1448
|
+
else {
|
|
1449
|
+
console.warn('No targetSVGElement provided for SelectionFrame.');
|
|
1450
|
+
}
|
|
1369
1451
|
if (props.targetSVGElement && props.container) {
|
|
1370
1452
|
//render SelectionFrame component to the parent element of the targetSVGElement
|
|
1371
1453
|
if (props.container) {
|
|
@@ -1699,8 +1781,8 @@ var Text = React.forwardRef(function (_a, ref) {
|
|
|
1699
1781
|
onContentChanged === null || onContentChanged === void 0 ? void 0 : onContentChanged(ev, ev.target.value);
|
|
1700
1782
|
};
|
|
1701
1783
|
useSelectionFrame({
|
|
1702
|
-
|
|
1703
|
-
|
|
1784
|
+
objectX: absolutePosition === null || absolutePosition === void 0 ? void 0 : absolutePosition.x,
|
|
1785
|
+
objectY: absolutePosition === null || absolutePosition === void 0 ? void 0 : absolutePosition.y,
|
|
1704
1786
|
container: container,
|
|
1705
1787
|
targetSVGElement: (isSelected && svgRef.current) ? svgRef.current : undefined,
|
|
1706
1788
|
resizability: {
|
|
@@ -7402,65 +7484,6 @@ function calculateAngleWithOx(pStart, pEnd) {
|
|
|
7402
7484
|
return angleInDegrees;
|
|
7403
7485
|
}
|
|
7404
7486
|
|
|
7405
|
-
var Logger = /** @class */ (function () {
|
|
7406
|
-
function Logger() {
|
|
7407
|
-
this.level = 'info';
|
|
7408
|
-
this.customLogger = null;
|
|
7409
|
-
}
|
|
7410
|
-
Logger.prototype.setLevel = function (level) {
|
|
7411
|
-
this.level = level;
|
|
7412
|
-
};
|
|
7413
|
-
Logger.prototype.setCustomLogger = function (logger) {
|
|
7414
|
-
this.customLogger = logger;
|
|
7415
|
-
};
|
|
7416
|
-
Logger.prototype.log = function (level, message) {
|
|
7417
|
-
var _a;
|
|
7418
|
-
var optionalParams = [];
|
|
7419
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
7420
|
-
optionalParams[_i - 2] = arguments[_i];
|
|
7421
|
-
}
|
|
7422
|
-
var levels = ['error', 'warn', 'info', 'debug'];
|
|
7423
|
-
if (this.level && levels.indexOf(level) <= levels.indexOf(this.level)) {
|
|
7424
|
-
if (this.customLogger) {
|
|
7425
|
-
this.customLogger.apply(this, __spreadArray([level, message], optionalParams, false));
|
|
7426
|
-
}
|
|
7427
|
-
else {
|
|
7428
|
-
console[level] ? (_a = console)[level].apply(_a, __spreadArray([message], optionalParams, false)) : console.log.apply(console, __spreadArray([message], optionalParams, false));
|
|
7429
|
-
}
|
|
7430
|
-
}
|
|
7431
|
-
};
|
|
7432
|
-
Logger.prototype.error = function (msg) {
|
|
7433
|
-
var optionalParams = [];
|
|
7434
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7435
|
-
optionalParams[_i - 1] = arguments[_i];
|
|
7436
|
-
}
|
|
7437
|
-
this.log.apply(this, __spreadArray(['error', msg], optionalParams, false));
|
|
7438
|
-
};
|
|
7439
|
-
Logger.prototype.warn = function (msg) {
|
|
7440
|
-
var optionalParams = [];
|
|
7441
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7442
|
-
optionalParams[_i - 1] = arguments[_i];
|
|
7443
|
-
}
|
|
7444
|
-
this.log.apply(this, __spreadArray(['warn', msg], optionalParams, false));
|
|
7445
|
-
};
|
|
7446
|
-
Logger.prototype.info = function (msg) {
|
|
7447
|
-
var optionalParams = [];
|
|
7448
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7449
|
-
optionalParams[_i - 1] = arguments[_i];
|
|
7450
|
-
}
|
|
7451
|
-
this.log.apply(this, __spreadArray(['info', msg], optionalParams, false));
|
|
7452
|
-
};
|
|
7453
|
-
Logger.prototype.debug = function (msg) {
|
|
7454
|
-
var optionalParams = [];
|
|
7455
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7456
|
-
optionalParams[_i - 1] = arguments[_i];
|
|
7457
|
-
}
|
|
7458
|
-
this.log.apply(this, __spreadArray(['debug', msg], optionalParams, false));
|
|
7459
|
-
};
|
|
7460
|
-
return Logger;
|
|
7461
|
-
}());
|
|
7462
|
-
var logger = new Logger();
|
|
7463
|
-
|
|
7464
7487
|
/**
|
|
7465
7488
|
* Check if position 1 is within the radius r of position 2
|
|
7466
7489
|
* @returns boolean
|
|
@@ -7883,7 +7906,7 @@ var correctPortPositionInElement = function (elementRelativePosition, elementWid
|
|
|
7883
7906
|
var Port1 = React.forwardRef(function (props, ref) {
|
|
7884
7907
|
var id = props.id, x = props.x, y = props.y, width = props.width, height = props.height, container = props.container, label = props.label, parentAbsolutePosition = props.parentAbsolutePosition, 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,
|
|
7885
7908
|
// onManuallyTriggerRenderHandler,
|
|
7886
|
-
renderShape = props.renderShape;
|
|
7909
|
+
renderShape = props.renderShape, children = props.children;
|
|
7887
7910
|
var textRef = React.useRef(null);
|
|
7888
7911
|
var rotationAngle = React.useMemo(function () {
|
|
7889
7912
|
if (!calculateRotationAngle)
|
|
@@ -7905,10 +7928,10 @@ var Port1 = React.forwardRef(function (props, ref) {
|
|
|
7905
7928
|
var renderedShape = React.useMemo(function () {
|
|
7906
7929
|
if (renderShape) {
|
|
7907
7930
|
var RenderShape = renderShape;
|
|
7908
|
-
return (React.createElement(RenderShape, __assign({ ref: ref }, props, { rotation: rotationAngle })));
|
|
7931
|
+
return (React.createElement(RenderShape, __assign({ ref: ref }, props, { rotation: rotationAngle }), children));
|
|
7909
7932
|
}
|
|
7910
7933
|
else {
|
|
7911
|
-
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); }, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onMouseMove: function (e) { return onMouseMove === null || onMouseMove === void 0 ? void 0 : onMouseMove(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" });
|
|
7934
|
+
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); }, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onMouseMove: function (e) { return onMouseMove === null || onMouseMove === void 0 ? void 0 : onMouseMove(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" }, children);
|
|
7912
7935
|
}
|
|
7913
7936
|
}, [props]);
|
|
7914
7937
|
return (React.createElement(React.Fragment, null,
|
|
@@ -8404,13 +8427,12 @@ var ElementWrapper = React.forwardRef(function (_a, ref) {
|
|
|
8404
8427
|
});
|
|
8405
8428
|
|
|
8406
8429
|
var Element = React.forwardRef(function (props, forwardedRef) {
|
|
8407
|
-
var
|
|
8408
|
-
var
|
|
8409
|
-
var
|
|
8410
|
-
var
|
|
8411
|
-
var
|
|
8412
|
-
var
|
|
8413
|
-
var _g = React.useState(), potentialPortPosition = _g[0], setPotentialPortPosition = _g[1];
|
|
8430
|
+
var id = props.id, x = props.x, y = props.y, width = props.width, height = props.height, cssClass = props.cssClass, portPlaceholderShape = props.portPlaceholderShape, children = props.children, container = props.container, parentAbsolutePosition = props.parentAbsolutePosition, 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, onMouseMove = props.onMouseMove, onMouseLeave = props.onMouseLeave, onMouseUp = props.onMouseUp, onMouseDown = props.onMouseDown, onMouseUpAtLinkedPortPlaceholder = props.onMouseUpAtLinkedPortPlaceholder, onTextUpdated = props.onTextUpdated;
|
|
8431
|
+
var _a = React.useState(), selectedPort = _a[0], setSelectedPort = _a[1];
|
|
8432
|
+
var _b = React.useState(), hoveredPort = _b[0], setHoveredPort = _b[1];
|
|
8433
|
+
var _c = React.useState([]), ports = _c[0], setPorts = _c[1];
|
|
8434
|
+
var _d = React.useState(false), someElementLinkStarted = _d[0], setSomeElementLinkStarted = _d[1];
|
|
8435
|
+
var _e = React.useState(), potentialPortPosition = _e[0], setPotentialPortPosition = _e[1];
|
|
8414
8436
|
var _paperEventEmitterContext = React.useContext(paperEventEmitterContext);
|
|
8415
8437
|
var elementRef = React.useRef(null);
|
|
8416
8438
|
React.useImperativeHandle(forwardedRef, function () { return elementRef.current; });
|
|
@@ -8788,51 +8810,40 @@ var Element = React.forwardRef(function (props, forwardedRef) {
|
|
|
8788
8810
|
setPorts(function (prev) { return __spreadArray([], prev, true); });
|
|
8789
8811
|
}
|
|
8790
8812
|
}, []);
|
|
8791
|
-
//
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
// if (someElementLinkStarted) setHoveredPort(p)
|
|
8826
|
-
// }}
|
|
8827
|
-
onMouseLeave: handlePortMouseLeave,
|
|
8828
|
-
// onManuallyTriggerRenderHandler={p.manuallyTriggerRenderHandler?.bind(p)}
|
|
8829
|
-
renderShape: p.renderShape });
|
|
8830
|
-
}), texts === null || texts === void 0 ? void 0 :
|
|
8831
|
-
texts.map(function (t, index) {
|
|
8832
|
-
var _a, _b;
|
|
8833
|
-
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) || 0, y: ((_b = t.position) === null || _b === void 0 ? void 0 : _b.y) || 0, width: t.size.width, height: t.size.height, editable: t.editable, align: t.align, fontSize: t.fontSize, border: t.border, container: container, style: t.style, parentAbsolutePosition: elementAbsPosition, onContentChanged: function (ev, newContent) { return onTextUpdated === null || onTextUpdated === void 0 ? void 0 : onTextUpdated(id, t.id, newContent); } });
|
|
8834
|
-
}),
|
|
8835
|
-
children));
|
|
8813
|
+
//log element render
|
|
8814
|
+
logger.debug('Rendering Element', id, x, y, width, height, cssClass, portPlaceholderShape, children, container, parentAbsolutePosition, textsPlaceHolderFlexStyle, textsPlaceHolderFlexboxPosition, textsPlaceHolderClassName, texts, portSlideRailSVGClassName, portMoveableAreas, portDirection, defaultPortSize);
|
|
8815
|
+
return (React.createElement(React.Fragment, null,
|
|
8816
|
+
React.createElement(ElementWrapper, { ref: elementRef, x: x, y: y, cssClass: cssClass, onClick: function (e) { return onClick ? onClick(id, e, elementRef.current) : true; }, onMouseMove: handleElementMouseMove, onMouseLeave: handleElementMouseLeave, onMouseDown: handleElementMouseDown, onMouseUp: handleElementMouseUp, onContextMenu: function (e) { return onContextMenu ? onContextMenu(id, e, elementRef.current) : true; } },
|
|
8817
|
+
renderedShape,
|
|
8818
|
+
potentialPortPosition && (portPlaceholderShape
|
|
8819
|
+
? React.createElement("svg", { x: potentialPortPosition.x, y: potentialPortPosition.y }, portPlaceholderShape)
|
|
8820
|
+
: 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 :
|
|
8821
|
+
ports.map(function (p, index) {
|
|
8822
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8823
|
+
return React.createElement(Port, { key: p.id, ref: p.ref, id: p.id, x: p.position.x, y: p.position.y, parentAbsolutePosition: elementAbsPosition, 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,
|
|
8824
|
+
// rotation={rotatePort(p)}
|
|
8825
|
+
calculateRotationAngle: rotatePort, label: p.label, onPortLabelMoved: handlePortLabelMoved, onPortLabelResized: handlePortLabelResized, onPortLabelContentChanged: handlePortLabelContentChanged, onSelected: handleSelectedPort, onMouseDown: handlePortMouseDown, onMouseUp: handlePortMouseUp, onMouseMove: handlePortMouseMove,
|
|
8826
|
+
// onMouseEnter={() => {
|
|
8827
|
+
// if (someElementLinkStarted) setHoveredPort(p)
|
|
8828
|
+
// }}
|
|
8829
|
+
onMouseLeave: handlePortMouseLeave,
|
|
8830
|
+
// onManuallyTriggerRenderHandler={p.manuallyTriggerRenderHandler?.bind(p)}
|
|
8831
|
+
renderShape: p.renderShape },
|
|
8832
|
+
selectedPort && selectedPort.id === p.id && (hoveredPort === null || hoveredPort === void 0 ? void 0 : hoveredPort.id) !== p.id &&
|
|
8833
|
+
(React.createElement(SelectionFrame, { container: container, targetSVGElement: ((_g = selectedPort === null || selectedPort === void 0 ? void 0 : selectedPort.ref) === null || _g === void 0 ? void 0 : _g.current) || undefined, resizability: {
|
|
8834
|
+
enabled: false,
|
|
8835
|
+
keepRatio: false
|
|
8836
|
+
}, objectX: elementAbsPosition.x + selectedPort.position.x, objectY: elementAbsPosition.y + selectedPort.position.y, onMove: handlePortMove })),
|
|
8837
|
+
hoveredPort && hoveredPort.id === p.id && (React.createElement(SelectionFrame, { container: container, targetSVGElement: ((_h = hoveredPort === null || hoveredPort === void 0 ? void 0 : hoveredPort.ref) === null || _h === void 0 ? void 0 : _h.current) || undefined, resizability: {
|
|
8838
|
+
enabled: false,
|
|
8839
|
+
keepRatio: false
|
|
8840
|
+
} })));
|
|
8841
|
+
}), texts === null || texts === void 0 ? void 0 :
|
|
8842
|
+
texts.map(function (t, index) {
|
|
8843
|
+
var _a, _b;
|
|
8844
|
+
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) || 0, y: ((_b = t.position) === null || _b === void 0 ? void 0 : _b.y) || 0, width: t.size.width, height: t.size.height, editable: t.editable, align: t.align, fontSize: t.fontSize, border: t.border, container: container, style: t.style, parentAbsolutePosition: elementAbsPosition, onContentChanged: function (ev, newContent) { return onTextUpdated === null || onTextUpdated === void 0 ? void 0 : onTextUpdated(id, t.id, newContent); } });
|
|
8845
|
+
}),
|
|
8846
|
+
children)));
|
|
8836
8847
|
});
|
|
8837
8848
|
var Element$1 = React.memo(Element);
|
|
8838
8849
|
|
|
@@ -9794,7 +9805,7 @@ var Paper = function (props) {
|
|
|
9794
9805
|
React.createElement(SelectionFrame, { container: paperContainerRef.current, targetSVGElement: selectedElementSVG || undefined, resizability: (selectedElement === null || selectedElement === void 0 ? void 0 : selectedElement.resizability) || {
|
|
9795
9806
|
enabled: true,
|
|
9796
9807
|
keepRatio: true
|
|
9797
|
-
},
|
|
9808
|
+
}, objectX: selectedElementAbsPosition === null || selectedElementAbsPosition === void 0 ? void 0 : selectedElementAbsPosition.x, objectY: selectedElementAbsPosition === null || selectedElementAbsPosition === void 0 ? void 0 : selectedElementAbsPosition.y, width: selectedElement === null || selectedElement === void 0 ? void 0 : selectedElement.size.width, height: selectedElement === null || selectedElement === void 0 ? void 0 : selectedElement.size.height,
|
|
9798
9809
|
//movingOffsetThreshold: ELEMENT_MOVING_OFFSET_THRESHOLD,
|
|
9799
9810
|
onMouseDown: function (ev) {
|
|
9800
9811
|
var _a;
|
|
@@ -3,8 +3,8 @@ import IResizability from "./IResizability";
|
|
|
3
3
|
import { IDragDropHandlerElementProps } from "../components/elements/dragDropHandlerElement";
|
|
4
4
|
import { PositioningAnchor } from "./enums/PositioningAnchor";
|
|
5
5
|
interface ISelectionFrameProps {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
objectX?: number;
|
|
7
|
+
objectY?: number;
|
|
8
8
|
width?: number;
|
|
9
9
|
height?: number;
|
|
10
10
|
targetSVGElement?: SVGSVGElement;
|
|
@@ -26,4 +26,5 @@ export interface IPortProps {
|
|
|
26
26
|
onPortLabelContentChanged?: (ev: React.ChangeEvent, newValue: string, portId: string) => void;
|
|
27
27
|
renderShape?: React.ForwardRefExoticComponent<IPortProps & React.RefAttributes<SVGSVGElement>>;
|
|
28
28
|
calculateRotationAngle?: (x: number, y: number) => number;
|
|
29
|
+
children?: React.ReactNode;
|
|
29
30
|
}
|