orcasvn-react-diagrams 0.1.48 → 0.1.50
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 +150 -134
- 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 +150 -134
- 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
|
@@ -714,7 +714,9 @@ var Port$1 = /** @class */ (function () {
|
|
|
714
714
|
}
|
|
715
715
|
else if (shapeRenderer && shapeRenderer.customShapeWithJSX) {
|
|
716
716
|
this.renderShape = React.forwardRef(function (props, ref) {
|
|
717
|
-
return (React.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); } },
|
|
717
|
+
return (React.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); } },
|
|
718
|
+
shapeRenderer.customShapeWithJSX,
|
|
719
|
+
props.children));
|
|
718
720
|
});
|
|
719
721
|
}
|
|
720
722
|
}
|
|
@@ -1065,7 +1067,8 @@ var Circle = React.forwardRef(function (props, ref) {
|
|
|
1065
1067
|
s.width = props.width;
|
|
1066
1068
|
}
|
|
1067
1069
|
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 })
|
|
1070
|
+
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 }),
|
|
1071
|
+
props.children));
|
|
1069
1072
|
});
|
|
1070
1073
|
|
|
1071
1074
|
var Crescent = React.forwardRef(function (props, ref) {
|
|
@@ -1084,7 +1087,8 @@ var Crescent = React.forwardRef(function (props, ref) {
|
|
|
1084
1087
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
1085
1088
|
return (React.createElement(ShapeWrapper, __assign({ ref: ref, viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height }),
|
|
1086
1089
|
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 })
|
|
1090
|
+
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 }),
|
|
1091
|
+
props.children));
|
|
1088
1092
|
});
|
|
1089
1093
|
|
|
1090
1094
|
var Rectangle = React.forwardRef(function (props, ref) {
|
|
@@ -1104,7 +1108,8 @@ var Rectangle = React.forwardRef(function (props, ref) {
|
|
|
1104
1108
|
}
|
|
1105
1109
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
1106
1110
|
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 })
|
|
1111
|
+
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 }),
|
|
1112
|
+
props.children));
|
|
1108
1113
|
});
|
|
1109
1114
|
|
|
1110
1115
|
var RectangularFrame = React.forwardRef(function (props, ref) {
|
|
@@ -1130,7 +1135,8 @@ var RectangularFrame = React.forwardRef(function (props, ref) {
|
|
|
1130
1135
|
return (React.createElement(ShapeWrapper, __assign({}, props, { ref: ref, height: props.height, width: props.width }),
|
|
1131
1136
|
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
1137
|
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" })
|
|
1138
|
+
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" }),
|
|
1139
|
+
props.children));
|
|
1134
1140
|
});
|
|
1135
1141
|
|
|
1136
1142
|
var createRoot;
|
|
@@ -1207,8 +1213,67 @@ var PORT_PLACEHOLDER_DEFAULT_STROKE = 'green';
|
|
|
1207
1213
|
var PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH = 20;
|
|
1208
1214
|
var PORT_DEFAULT_SIZE = 20;
|
|
1209
1215
|
|
|
1216
|
+
var Logger = /** @class */ (function () {
|
|
1217
|
+
function Logger() {
|
|
1218
|
+
this.level = 'info';
|
|
1219
|
+
this.customLogger = null;
|
|
1220
|
+
}
|
|
1221
|
+
Logger.prototype.setLevel = function (level) {
|
|
1222
|
+
this.level = level;
|
|
1223
|
+
};
|
|
1224
|
+
Logger.prototype.setCustomLogger = function (logger) {
|
|
1225
|
+
this.customLogger = logger;
|
|
1226
|
+
};
|
|
1227
|
+
Logger.prototype.log = function (level, message) {
|
|
1228
|
+
var _a;
|
|
1229
|
+
var optionalParams = [];
|
|
1230
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1231
|
+
optionalParams[_i - 2] = arguments[_i];
|
|
1232
|
+
}
|
|
1233
|
+
var levels = ['error', 'warn', 'info', 'debug'];
|
|
1234
|
+
if (this.level && levels.indexOf(level) <= levels.indexOf(this.level)) {
|
|
1235
|
+
if (this.customLogger) {
|
|
1236
|
+
this.customLogger.apply(this, __spreadArray([level, message], optionalParams, false));
|
|
1237
|
+
}
|
|
1238
|
+
else {
|
|
1239
|
+
console[level] ? (_a = console)[level].apply(_a, __spreadArray([message], optionalParams, false)) : console.log.apply(console, __spreadArray([message], optionalParams, false));
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
Logger.prototype.error = function (msg) {
|
|
1244
|
+
var optionalParams = [];
|
|
1245
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1246
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
1247
|
+
}
|
|
1248
|
+
this.log.apply(this, __spreadArray(['error', msg], optionalParams, false));
|
|
1249
|
+
};
|
|
1250
|
+
Logger.prototype.warn = function (msg) {
|
|
1251
|
+
var optionalParams = [];
|
|
1252
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1253
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
1254
|
+
}
|
|
1255
|
+
this.log.apply(this, __spreadArray(['warn', msg], optionalParams, false));
|
|
1256
|
+
};
|
|
1257
|
+
Logger.prototype.info = function (msg) {
|
|
1258
|
+
var optionalParams = [];
|
|
1259
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1260
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
1261
|
+
}
|
|
1262
|
+
this.log.apply(this, __spreadArray(['info', msg], optionalParams, false));
|
|
1263
|
+
};
|
|
1264
|
+
Logger.prototype.debug = function (msg) {
|
|
1265
|
+
var optionalParams = [];
|
|
1266
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1267
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
1268
|
+
}
|
|
1269
|
+
this.log.apply(this, __spreadArray(['debug', msg], optionalParams, false));
|
|
1270
|
+
};
|
|
1271
|
+
return Logger;
|
|
1272
|
+
}());
|
|
1273
|
+
var logger = new Logger();
|
|
1274
|
+
|
|
1210
1275
|
var SelectionFrame = function (props) {
|
|
1211
|
-
var propTargetSVGElement = props.targetSVGElement, propWidth = props.width, propHeight = props.height, propFramePadding = props.framePadding,
|
|
1276
|
+
var propTargetSVGElement = props.targetSVGElement, propWidth = props.width, propHeight = props.height, propFramePadding = props.framePadding, objectX = props.objectX, objectY = props.objectY,
|
|
1212
1277
|
// movingOffsetThreshold: propMovingOffsetThreshold,
|
|
1213
1278
|
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
1279
|
var bbox = propTargetSVGElement === null || propTargetSVGElement === void 0 ? void 0 : propTargetSVGElement.getBBox();
|
|
@@ -1218,19 +1283,19 @@ var SelectionFrame = function (props) {
|
|
|
1218
1283
|
if (propWidth) {
|
|
1219
1284
|
setWidth(propWidth);
|
|
1220
1285
|
}
|
|
1221
|
-
}, [
|
|
1222
|
-
var _c = React.useState(
|
|
1223
|
-
var _d = React.useState(
|
|
1286
|
+
}, [objectX, propWidth]);
|
|
1287
|
+
var _c = React.useState(objectX !== null && objectX !== void 0 ? objectX : 0), curX = _c[0], setCurX = _c[1];
|
|
1288
|
+
var _d = React.useState(objectY !== null && objectY !== void 0 ? objectY : 0), curY = _d[0], setCurY = _d[1];
|
|
1224
1289
|
React.useEffect(function () {
|
|
1225
|
-
if (
|
|
1226
|
-
|
|
1290
|
+
if (objectX) {
|
|
1291
|
+
setCurX(objectX);
|
|
1227
1292
|
}
|
|
1228
|
-
}, [
|
|
1293
|
+
}, [objectX]);
|
|
1229
1294
|
React.useEffect(function () {
|
|
1230
|
-
if (
|
|
1231
|
-
|
|
1295
|
+
if (objectY) {
|
|
1296
|
+
setCurY(objectY);
|
|
1232
1297
|
}
|
|
1233
|
-
}, [
|
|
1298
|
+
}, [objectY]);
|
|
1234
1299
|
var framePadding = propFramePadding || 0;
|
|
1235
1300
|
var r = 5;
|
|
1236
1301
|
var _e = React.useState(false), draggingRect = _e[0], setDraggingRect = _e[1];
|
|
@@ -1274,8 +1339,8 @@ var SelectionFrame = function (props) {
|
|
|
1274
1339
|
var newX = mousePosition.x + xFromMouse;
|
|
1275
1340
|
var newY = mousePosition.y + yFromMouse;
|
|
1276
1341
|
if (propOnMove) {
|
|
1277
|
-
|
|
1278
|
-
|
|
1342
|
+
setCurX(newX);
|
|
1343
|
+
setCurY(newY);
|
|
1279
1344
|
propOnMove(newX, newY);
|
|
1280
1345
|
setLastMoveTime(Date.now());
|
|
1281
1346
|
setStartX(mouseEvent.clientX);
|
|
@@ -1305,6 +1370,14 @@ var SelectionFrame = function (props) {
|
|
|
1305
1370
|
}
|
|
1306
1371
|
};
|
|
1307
1372
|
React.useEffect(function () {
|
|
1373
|
+
logger.debug('SelectionFrame: circleHandleMouseDown triggered', {
|
|
1374
|
+
draggingCircle: draggingCircle,
|
|
1375
|
+
startX: startX,
|
|
1376
|
+
startY: startY,
|
|
1377
|
+
width: width,
|
|
1378
|
+
height: height,
|
|
1379
|
+
propMovingRate: propMovingRate
|
|
1380
|
+
});
|
|
1308
1381
|
var circleHandleMouseMove = function (event) {
|
|
1309
1382
|
var mouseEvent = event;
|
|
1310
1383
|
if (draggingCircle) {
|
|
@@ -1345,9 +1418,13 @@ var SelectionFrame = function (props) {
|
|
|
1345
1418
|
var container = propContainer;
|
|
1346
1419
|
container.addEventListener('mousemove', circleHandleMouseMove);
|
|
1347
1420
|
container.addEventListener('mouseup', circleHandleMouseUp);
|
|
1421
|
+
//logging the start of the circle handle mouse move
|
|
1422
|
+
logger.debug('SelectionFrame: circleHandleMouseMove started', container);
|
|
1348
1423
|
return function () {
|
|
1349
1424
|
container.removeEventListener('mousemove', circleHandleMouseMove);
|
|
1350
1425
|
container.removeEventListener('mouseup', circleHandleMouseUp);
|
|
1426
|
+
//logging the end of the circle handle mouse move
|
|
1427
|
+
logger.debug('SelectionFrame: circleHandleMouseMove ended', container);
|
|
1351
1428
|
};
|
|
1352
1429
|
}, [draggingCircle, width, height, curX, curY, lastMoveTime, propContainer, propMovingRate, propOnResize, propResizability, startX, startY]);
|
|
1353
1430
|
var rectangleSize = Math.max(width, height);
|
|
@@ -1366,6 +1443,13 @@ var SelectionFrame = function (props) {
|
|
|
1366
1443
|
|
|
1367
1444
|
var useSelectionFrame = function (props) {
|
|
1368
1445
|
React.useEffect(function () {
|
|
1446
|
+
//log selection frame rendering
|
|
1447
|
+
if (props.targetSVGElement) {
|
|
1448
|
+
console.debug('Rendering SelectionFrame for targetSVGElement:', props.targetSVGElement);
|
|
1449
|
+
}
|
|
1450
|
+
else {
|
|
1451
|
+
console.warn('No targetSVGElement provided for SelectionFrame.');
|
|
1452
|
+
}
|
|
1369
1453
|
if (props.targetSVGElement && props.container) {
|
|
1370
1454
|
//render SelectionFrame component to the parent element of the targetSVGElement
|
|
1371
1455
|
if (props.container) {
|
|
@@ -1699,8 +1783,8 @@ var Text = React.forwardRef(function (_a, ref) {
|
|
|
1699
1783
|
onContentChanged === null || onContentChanged === void 0 ? void 0 : onContentChanged(ev, ev.target.value);
|
|
1700
1784
|
};
|
|
1701
1785
|
useSelectionFrame({
|
|
1702
|
-
|
|
1703
|
-
|
|
1786
|
+
objectX: absolutePosition === null || absolutePosition === void 0 ? void 0 : absolutePosition.x,
|
|
1787
|
+
objectY: absolutePosition === null || absolutePosition === void 0 ? void 0 : absolutePosition.y,
|
|
1704
1788
|
container: container,
|
|
1705
1789
|
targetSVGElement: (isSelected && svgRef.current) ? svgRef.current : undefined,
|
|
1706
1790
|
resizability: {
|
|
@@ -7402,65 +7486,6 @@ function calculateAngleWithOx(pStart, pEnd) {
|
|
|
7402
7486
|
return angleInDegrees;
|
|
7403
7487
|
}
|
|
7404
7488
|
|
|
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
7489
|
/**
|
|
7465
7490
|
* Check if position 1 is within the radius r of position 2
|
|
7466
7491
|
* @returns boolean
|
|
@@ -7883,7 +7908,7 @@ var correctPortPositionInElement = function (elementRelativePosition, elementWid
|
|
|
7883
7908
|
var Port1 = React.forwardRef(function (props, ref) {
|
|
7884
7909
|
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
7910
|
// onManuallyTriggerRenderHandler,
|
|
7886
|
-
renderShape = props.renderShape;
|
|
7911
|
+
renderShape = props.renderShape, children = props.children;
|
|
7887
7912
|
var textRef = React.useRef(null);
|
|
7888
7913
|
var rotationAngle = React.useMemo(function () {
|
|
7889
7914
|
if (!calculateRotationAngle)
|
|
@@ -7905,10 +7930,10 @@ var Port1 = React.forwardRef(function (props, ref) {
|
|
|
7905
7930
|
var renderedShape = React.useMemo(function () {
|
|
7906
7931
|
if (renderShape) {
|
|
7907
7932
|
var RenderShape = renderShape;
|
|
7908
|
-
return (React.createElement(RenderShape, __assign({ ref: ref }, props, { rotation: rotationAngle })));
|
|
7933
|
+
return (React.createElement(RenderShape, __assign({ ref: ref }, props, { rotation: rotationAngle }), children));
|
|
7909
7934
|
}
|
|
7910
7935
|
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" });
|
|
7936
|
+
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
7937
|
}
|
|
7913
7938
|
}, [props]);
|
|
7914
7939
|
return (React.createElement(React.Fragment, null,
|
|
@@ -8404,13 +8429,12 @@ var ElementWrapper = React.forwardRef(function (_a, ref) {
|
|
|
8404
8429
|
});
|
|
8405
8430
|
|
|
8406
8431
|
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];
|
|
8432
|
+
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;
|
|
8433
|
+
var _a = React.useState(), selectedPort = _a[0], setSelectedPort = _a[1];
|
|
8434
|
+
var _b = React.useState(), hoveredPort = _b[0], setHoveredPort = _b[1];
|
|
8435
|
+
var _c = React.useState([]), ports = _c[0], setPorts = _c[1];
|
|
8436
|
+
var _d = React.useState(false), someElementLinkStarted = _d[0], setSomeElementLinkStarted = _d[1];
|
|
8437
|
+
var _e = React.useState(), potentialPortPosition = _e[0], setPotentialPortPosition = _e[1];
|
|
8414
8438
|
var _paperEventEmitterContext = React.useContext(paperEventEmitterContext);
|
|
8415
8439
|
var elementRef = React.useRef(null);
|
|
8416
8440
|
React.useImperativeHandle(forwardedRef, function () { return elementRef.current; });
|
|
@@ -8555,6 +8579,7 @@ var Element = React.forwardRef(function (props, forwardedRef) {
|
|
|
8555
8579
|
}, []);
|
|
8556
8580
|
var handleSelectedPort = React.useCallback(function (portId, e) {
|
|
8557
8581
|
e.stopPropagation();
|
|
8582
|
+
logger.debug('Port selected', portId, e);
|
|
8558
8583
|
var port = portsRef.current.find(function (p) { return p.id === portId; });
|
|
8559
8584
|
if (!port)
|
|
8560
8585
|
return;
|
|
@@ -8603,6 +8628,8 @@ var Element = React.forwardRef(function (props, forwardedRef) {
|
|
|
8603
8628
|
//Handle when mouse down on port
|
|
8604
8629
|
var handlePortMouseDown = React.useCallback(function (portId, e) {
|
|
8605
8630
|
e.stopPropagation();
|
|
8631
|
+
//log debugger
|
|
8632
|
+
logger.debug('Port mouse down', portId, e);
|
|
8606
8633
|
var port = portsRef.current.find(function (p) { return p.id === portId; });
|
|
8607
8634
|
if (!port)
|
|
8608
8635
|
return;
|
|
@@ -8788,51 +8815,40 @@ var Element = React.forwardRef(function (props, forwardedRef) {
|
|
|
8788
8815
|
setPorts(function (prev) { return __spreadArray([], prev, true); });
|
|
8789
8816
|
}
|
|
8790
8817
|
}, []);
|
|
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));
|
|
8818
|
+
//log element render
|
|
8819
|
+
logger.debug('Rendering Element', id, x, y, width, height, cssClass, portPlaceholderShape, children, container, parentAbsolutePosition, textsPlaceHolderFlexStyle, textsPlaceHolderFlexboxPosition, textsPlaceHolderClassName, texts, portSlideRailSVGClassName, portMoveableAreas, portDirection, defaultPortSize);
|
|
8820
|
+
return (React.createElement(React.Fragment, null,
|
|
8821
|
+
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; } },
|
|
8822
|
+
renderedShape,
|
|
8823
|
+
potentialPortPosition && (portPlaceholderShape
|
|
8824
|
+
? React.createElement("svg", { x: potentialPortPosition.x, y: potentialPortPosition.y }, portPlaceholderShape)
|
|
8825
|
+
: 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 :
|
|
8826
|
+
ports.map(function (p, index) {
|
|
8827
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8828
|
+
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,
|
|
8829
|
+
// rotation={rotatePort(p)}
|
|
8830
|
+
calculateRotationAngle: rotatePort, label: p.label, onPortLabelMoved: handlePortLabelMoved, onPortLabelResized: handlePortLabelResized, onPortLabelContentChanged: handlePortLabelContentChanged, onSelected: handleSelectedPort, onMouseDown: handlePortMouseDown, onMouseUp: handlePortMouseUp, onMouseMove: handlePortMouseMove,
|
|
8831
|
+
// onMouseEnter={() => {
|
|
8832
|
+
// if (someElementLinkStarted) setHoveredPort(p)
|
|
8833
|
+
// }}
|
|
8834
|
+
onMouseLeave: handlePortMouseLeave,
|
|
8835
|
+
// onManuallyTriggerRenderHandler={p.manuallyTriggerRenderHandler?.bind(p)}
|
|
8836
|
+
renderShape: p.renderShape },
|
|
8837
|
+
selectedPort && selectedPort.id === p.id && (hoveredPort === null || hoveredPort === void 0 ? void 0 : hoveredPort.id) !== p.id &&
|
|
8838
|
+
(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: {
|
|
8839
|
+
enabled: false,
|
|
8840
|
+
keepRatio: false
|
|
8841
|
+
}, objectX: elementAbsPosition.x + selectedPort.position.x, objectY: elementAbsPosition.y + selectedPort.position.y, onMove: handlePortMove })),
|
|
8842
|
+
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: {
|
|
8843
|
+
enabled: false,
|
|
8844
|
+
keepRatio: false
|
|
8845
|
+
} })));
|
|
8846
|
+
}), texts === null || texts === void 0 ? void 0 :
|
|
8847
|
+
texts.map(function (t, index) {
|
|
8848
|
+
var _a, _b;
|
|
8849
|
+
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); } });
|
|
8850
|
+
}),
|
|
8851
|
+
children)));
|
|
8836
8852
|
});
|
|
8837
8853
|
var Element$1 = React.memo(Element);
|
|
8838
8854
|
|
|
@@ -9794,7 +9810,7 @@ var Paper = function (props) {
|
|
|
9794
9810
|
React.createElement(SelectionFrame, { container: paperContainerRef.current, targetSVGElement: selectedElementSVG || undefined, resizability: (selectedElement === null || selectedElement === void 0 ? void 0 : selectedElement.resizability) || {
|
|
9795
9811
|
enabled: true,
|
|
9796
9812
|
keepRatio: true
|
|
9797
|
-
},
|
|
9813
|
+
}, 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
9814
|
//movingOffsetThreshold: ELEMENT_MOVING_OFFSET_THRESHOLD,
|
|
9799
9815
|
onMouseDown: function (ev) {
|
|
9800
9816
|
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
|
}
|