orcasvn-react-diagrams 0.1.11 → 0.1.13
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 +95 -19
- package/dist/cjs/types/components/elements/elementWrapper.d.ts +1 -0
- package/dist/cjs/types/components/paper.d.ts +1 -0
- package/dist/cjs/types/contexts/paperEventEmitterContext.d.ts +5 -1
- package/dist/cjs/types/mocks/port1.d.ts +1 -1
- package/dist/cjs/types/mocks/portIn.d.ts +1 -1
- package/dist/cjs/types/models/IElement.d.ts +1 -0
- package/dist/cjs/types/models/IElementProps.d.ts +2 -0
- package/dist/cjs/types/models/IPort.d.ts +1 -1
- package/dist/cjs/types/models/callbackTypes.d.ts +2 -0
- package/dist/cjs/types/models/implementations/CustomPortFromJSXElement.d.ts +1 -1
- package/dist/cjs/types/models/implementations/CustomPortFromShape.d.ts +1 -1
- package/dist/cjs/types/models/implementations/EditorContext.d.ts +2 -0
- package/dist/cjs/types/models/implementations/Element.d.ts +1 -0
- package/dist/cjs/types/models/implementations/Port.d.ts +2 -2
- package/dist/cjs/types/models/implementations/rectangularFrameElement.d.ts +1 -0
- package/dist/cjs/types/utils/constants.d.ts +3 -0
- package/dist/esm/index.js +95 -19
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/elements/elementWrapper.d.ts +1 -0
- package/dist/esm/types/components/paper.d.ts +1 -0
- package/dist/esm/types/contexts/paperEventEmitterContext.d.ts +5 -1
- package/dist/esm/types/mocks/port1.d.ts +1 -1
- package/dist/esm/types/mocks/portIn.d.ts +1 -1
- package/dist/esm/types/models/IElement.d.ts +1 -0
- package/dist/esm/types/models/IElementProps.d.ts +2 -0
- package/dist/esm/types/models/IPort.d.ts +1 -1
- package/dist/esm/types/models/callbackTypes.d.ts +2 -0
- package/dist/esm/types/models/implementations/CustomPortFromJSXElement.d.ts +1 -1
- package/dist/esm/types/models/implementations/CustomPortFromShape.d.ts +1 -1
- package/dist/esm/types/models/implementations/EditorContext.d.ts +2 -0
- package/dist/esm/types/models/implementations/Element.d.ts +1 -0
- package/dist/esm/types/models/implementations/Port.d.ts +2 -2
- package/dist/esm/types/models/implementations/rectangularFrameElement.d.ts +1 -0
- package/dist/esm/types/utils/constants.d.ts +3 -0
- package/dist/index.d.ts +14 -7
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -561,10 +561,15 @@ var Element$1 = /** @class */ (function () {
|
|
|
561
561
|
}());
|
|
562
562
|
|
|
563
563
|
var Port$1 = /** @class */ (function () {
|
|
564
|
-
function Port(x, y,
|
|
564
|
+
function Port(x, y, label, renderShape, width, height) {
|
|
565
565
|
this._id = generateUniqueId();
|
|
566
566
|
this.position = { x: x, y: y };
|
|
567
|
-
|
|
567
|
+
if (!height) {
|
|
568
|
+
height = width;
|
|
569
|
+
}
|
|
570
|
+
if (width && height) {
|
|
571
|
+
this.size = { width: width, height: height };
|
|
572
|
+
}
|
|
568
573
|
this.label = label;
|
|
569
574
|
this.renderShape = renderShape;
|
|
570
575
|
}
|
|
@@ -803,10 +808,10 @@ var CustomShape = React$1.forwardRef(function (props, ref) {
|
|
|
803
808
|
|
|
804
809
|
var CustomPortFromJSXElement = /** @class */ (function (_super) {
|
|
805
810
|
__extends(CustomPortFromJSXElement, _super);
|
|
806
|
-
function CustomPortFromJSXElement(x, y,
|
|
807
|
-
var _this = _super.call(this, x, y,
|
|
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) {
|
|
808
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));
|
|
809
|
-
})) || this;
|
|
814
|
+
}), width, height) || this;
|
|
810
815
|
return _this;
|
|
811
816
|
}
|
|
812
817
|
return CustomPortFromJSXElement;
|
|
@@ -814,8 +819,8 @@ var CustomPortFromJSXElement = /** @class */ (function (_super) {
|
|
|
814
819
|
|
|
815
820
|
var CustomPortFromShape = /** @class */ (function (_super) {
|
|
816
821
|
__extends(CustomPortFromShape, _super);
|
|
817
|
-
function CustomPortFromShape(x, y,
|
|
818
|
-
return _super.call(this, x, y,
|
|
822
|
+
function CustomPortFromShape(x, y, shape, label, width, height) {
|
|
823
|
+
return _super.call(this, x, y, label, shape, width, height) || this;
|
|
819
824
|
}
|
|
820
825
|
return CustomPortFromShape;
|
|
821
826
|
}(Port$1));
|
|
@@ -935,10 +940,12 @@ var EVENT_NAME = {
|
|
|
935
940
|
ELEMENT_DRAGGED: 'element_dragged',
|
|
936
941
|
ELEMENT_RESIZED: 'element_resized',
|
|
937
942
|
ELEMENT_DELETED: 'element_deleted',
|
|
943
|
+
ELEMENT_SELECTED: 'element_selected',
|
|
938
944
|
//PORT
|
|
939
945
|
PORT_MOUSE_DOWN: 'port_mouse_down',
|
|
940
946
|
PORT_MOUSE_UP: 'port_mouse_up',
|
|
941
947
|
PORT_MOVED: 'port_moved',
|
|
948
|
+
PORT_SELECTED: 'port_selected',
|
|
942
949
|
//COMMAND
|
|
943
950
|
COMMAND_DELETE_SELECTED_PORT: 'command_delete_selected_port',
|
|
944
951
|
COMMAND_DELETE_SELECTED_LINK: 'command_delete_selected_link',
|
|
@@ -969,7 +976,8 @@ var TEXT_MOVING_OFFSET_THRESHOLD = 10;
|
|
|
969
976
|
var PORT_PLACEHOLDER_DEFAULT_SIZE = 8;
|
|
970
977
|
var PORT_PLACEHOLDER_DEFAULT_STROKE = 'green';
|
|
971
978
|
var PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH = 20;
|
|
972
|
-
var PORT_MOVING_OFFSET_THRESHOLD = 15;
|
|
979
|
+
var PORT_MOVING_OFFSET_THRESHOLD = 15;
|
|
980
|
+
var PORT_DEFAULT_SIZE = 20;
|
|
973
981
|
|
|
974
982
|
var SelectionFrame = function (props) {
|
|
975
983
|
var _a;
|
|
@@ -1272,6 +1280,30 @@ var onElementLinkEnded = function (callback) {
|
|
|
1272
1280
|
off: off
|
|
1273
1281
|
};
|
|
1274
1282
|
};
|
|
1283
|
+
var emitElementSelected = function (element) {
|
|
1284
|
+
eventEmitter.emit(EVENT_NAME.ELEMENT_SELECTED, element);
|
|
1285
|
+
};
|
|
1286
|
+
var onElementSelected = function (callback) {
|
|
1287
|
+
eventEmitter.on(EVENT_NAME.ELEMENT_SELECTED, callback);
|
|
1288
|
+
var off = function () {
|
|
1289
|
+
eventEmitter.off(EVENT_NAME.ELEMENT_SELECTED, callback);
|
|
1290
|
+
};
|
|
1291
|
+
return {
|
|
1292
|
+
off: off
|
|
1293
|
+
};
|
|
1294
|
+
};
|
|
1295
|
+
var emitPortSelected = function (port, elementId) {
|
|
1296
|
+
eventEmitter.emit(EVENT_NAME.PORT_SELECTED, port, elementId);
|
|
1297
|
+
};
|
|
1298
|
+
var onPortSelected = function (callback) {
|
|
1299
|
+
eventEmitter.on(EVENT_NAME.PORT_SELECTED, callback);
|
|
1300
|
+
var off = function () {
|
|
1301
|
+
eventEmitter.off(EVENT_NAME.PORT_SELECTED, callback);
|
|
1302
|
+
};
|
|
1303
|
+
return {
|
|
1304
|
+
off: off
|
|
1305
|
+
};
|
|
1306
|
+
};
|
|
1275
1307
|
var paperEventEmitterContext = React$1.createContext({
|
|
1276
1308
|
emitter: eventEmitter,
|
|
1277
1309
|
emitPaperClicked: emitPaperClicked,
|
|
@@ -1282,10 +1314,14 @@ var paperEventEmitterContext = React$1.createContext({
|
|
|
1282
1314
|
onPortMouseDown: onPortMouseDown,
|
|
1283
1315
|
emitPortMoved: emitPortMoved,
|
|
1284
1316
|
onPortMoved: onPortMoved,
|
|
1317
|
+
emitPortSelected: emitPortSelected,
|
|
1318
|
+
onPortSelected: onPortSelected,
|
|
1285
1319
|
emitElementMoved: emitElementMoved,
|
|
1286
1320
|
onElementMoved: onElementMoved,
|
|
1287
1321
|
emitElementResized: emitElementResized,
|
|
1288
1322
|
onElementResized: onElementResized,
|
|
1323
|
+
emitElementSelected: emitElementSelected,
|
|
1324
|
+
onElementSelected: onElementSelected,
|
|
1289
1325
|
emitCommandDeleteSelectedPort: emitCommandDeleteSelectedPort,
|
|
1290
1326
|
onCommandDeleteSelectedPort: onCommandDeleteSelectedPort,
|
|
1291
1327
|
emitCommandDeleteSelectedElement: emitCommandDeleteSelectedElement,
|
|
@@ -7611,11 +7647,21 @@ var Ruler = function (_a) {
|
|
|
7611
7647
|
};
|
|
7612
7648
|
|
|
7613
7649
|
var ElementWrapper = React$1.forwardRef(function (_a, ref) {
|
|
7614
|
-
var x = _a.x, y = _a.y, children = _a.children; _a.portPlaceholders; _a.ports; var onClick = _a.onClick, onMouseMove = _a.onMouseMove, onMouseLeave = _a.onMouseLeave, onMouseUp = _a.onMouseUp;
|
|
7650
|
+
var x = _a.x, y = _a.y, children = _a.children; _a.portPlaceholders; _a.ports; var onClick = _a.onClick, onContextMenu = _a.onContextMenu, onMouseMove = _a.onMouseMove, onMouseLeave = _a.onMouseLeave, onMouseUp = _a.onMouseUp;
|
|
7615
7651
|
var handleMouseDown = function (ev) {
|
|
7616
7652
|
ev.stopPropagation();
|
|
7617
7653
|
};
|
|
7618
|
-
|
|
7654
|
+
var handleClick = function (ev) {
|
|
7655
|
+
if (ev.type === 'click') {
|
|
7656
|
+
if (onClick)
|
|
7657
|
+
onClick(ev);
|
|
7658
|
+
}
|
|
7659
|
+
else if (ev.type === 'contextmenu') {
|
|
7660
|
+
if (onContextMenu)
|
|
7661
|
+
onContextMenu(ev);
|
|
7662
|
+
}
|
|
7663
|
+
};
|
|
7664
|
+
return (React$1.createElement("svg", { x: x, y: y, onClick: handleClick, onContextMenu: handleClick, onMouseDown: handleMouseDown, ref: ref, style: { overflow: "visible" }, onMouseMove: onMouseMove, onMouseLeave: onMouseLeave, onMouseUp: onMouseUp }, children));
|
|
7619
7665
|
});
|
|
7620
7666
|
|
|
7621
7667
|
// Calculate the position of the 4 vertices of a rectangle relative to its parent svg
|
|
@@ -8885,7 +8931,7 @@ var Flexbox$1 = /*@__PURE__*/getDefaultExportFromCjs(bundleExports);
|
|
|
8885
8931
|
|
|
8886
8932
|
var Element = function (props) {
|
|
8887
8933
|
var _a, _b;
|
|
8888
|
-
var id = props.id, x = props.x, y = props.y, width = props.width, height = props.height, portPlaceholderShape = props.portPlaceholderShape, children = props.children, container = props.container, textsPlaceHolderFlexStyle = props.textsPlaceHolderFlexStyle, textsPlaceHolderFlexboxPosition = props.textsPlaceHolderFlexboxPosition, textsPlaceHolderClassName = props.textsPlaceHolderClassName, texts = props.texts, portSlideRailSVGClassName = props.portSlideRailSVGClassName, portMoveableAreas = props.portMoveableAreas, portDirection = props.portDirection, onClick = props.onClick, renderShape = props.renderShape; props.onMoved; var onPortMoved = props.onPortMoved; props.onResized; var onPortMouseDown = props.onPortMouseDown, onPortMouseUp = props.onPortMouseUp; props.onMouseMove; props.onMouseLeave; props.onMouseUp; var onMouseUpAtLinkedPortPlaceholder = props.onMouseUpAtLinkedPortPlaceholder, onTextUpdated = props.onTextUpdated;
|
|
8934
|
+
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;
|
|
8889
8935
|
var _c = React$1.useState(), selectedPort = _c[0], setSelectedPort = _c[1];
|
|
8890
8936
|
var _d = React$1.useState((_b = (_a = props.ports) === null || _a === void 0 ? void 0 : _a.map(function (p) {
|
|
8891
8937
|
return __assign(__assign({}, p), { id: p.id, ref: React$1.createRef() });
|
|
@@ -8952,9 +8998,30 @@ var Element = function (props) {
|
|
|
8952
8998
|
elementEndedListener.off();
|
|
8953
8999
|
};
|
|
8954
9000
|
}, []);
|
|
9001
|
+
//Listen another port is selected
|
|
9002
|
+
React$1.useEffect(function () {
|
|
9003
|
+
var portSelectedListener = _paperEventEmitterContext.onPortSelected(function (port, elementId) {
|
|
9004
|
+
if (elementId !== id) {
|
|
9005
|
+
setSelectedPort(undefined);
|
|
9006
|
+
}
|
|
9007
|
+
});
|
|
9008
|
+
return function () {
|
|
9009
|
+
portSelectedListener.off();
|
|
9010
|
+
};
|
|
9011
|
+
}, []);
|
|
9012
|
+
//Listen another element is selected
|
|
9013
|
+
React$1.useEffect(function () {
|
|
9014
|
+
var portSelectedListener = _paperEventEmitterContext.onElementSelected(function (element) {
|
|
9015
|
+
setSelectedPort(undefined);
|
|
9016
|
+
});
|
|
9017
|
+
return function () {
|
|
9018
|
+
portSelectedListener.off();
|
|
9019
|
+
};
|
|
9020
|
+
}, []);
|
|
8955
9021
|
var handleSelectedPort = function (port, e) {
|
|
8956
9022
|
e.stopPropagation();
|
|
8957
9023
|
setSelectedPort(port);
|
|
9024
|
+
_paperEventEmitterContext.emitPortSelected(port, id);
|
|
8958
9025
|
};
|
|
8959
9026
|
//From one point find another point on the line segment so that the distance between the two points is the shortest.
|
|
8960
9027
|
var findNearestPointOnSegment = function (position, linePoints) {
|
|
@@ -9246,13 +9313,14 @@ var Element = function (props) {
|
|
|
9246
9313
|
movingOffsetThreshold: PORT_MOVING_OFFSET_THRESHOLD,
|
|
9247
9314
|
onMove: handlePortMove
|
|
9248
9315
|
});
|
|
9249
|
-
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 },
|
|
9316
|
+
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; } },
|
|
9250
9317
|
renderedShape,
|
|
9251
9318
|
potentialPortPosition && (portPlaceholderShape
|
|
9252
9319
|
? React$1.createElement("svg", { x: potentialPortPosition.x, y: potentialPortPosition.y }, portPlaceholderShape)
|
|
9253
9320
|
: React$1.createElement("rect", { x: potentialPortPosition.x - PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH / 2, y: potentialPortPosition.y - PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH / 2, width: PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH, height: PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH, rx: PORT_PLACEHOLDER_DEFAULT_SIZE, ry: PORT_PLACEHOLDER_DEFAULT_SIZE, stroke: PORT_PLACEHOLDER_DEFAULT_STROKE, fill: "none", strokeWidth: 3 })), ports === null || ports === void 0 ? void 0 :
|
|
9254
9321
|
ports.map(function (p, index) {
|
|
9255
|
-
|
|
9322
|
+
var _a, _b, _c, _d, _e, _f;
|
|
9323
|
+
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,
|
|
9256
9324
|
// rotation={rotatePort(p)}
|
|
9257
9325
|
calculateRotationAngle: rotatePort, label: p.label, onPortLabelMoved: function (x, y) { return handlePortLabelMoved(x, y, p, index); }, onPortLabelResized: function (w, h) { return handlePortLabelResized(w, h, p, index); }, onPortLabelContentChanged: function (ev, newValue) { return handlePortLabelContentChanged(newValue, p, index); }, onSelected: function (portId, event) { return handleSelectedPort(p, event); }, onMouseDown: handlePortMouseDown, onMouseUp: handlePortMouseUp, renderShape: p.renderShape });
|
|
9258
9326
|
}),
|
|
@@ -9975,16 +10043,24 @@ var Paper = function (props) {
|
|
|
9975
10043
|
});
|
|
9976
10044
|
});
|
|
9977
10045
|
};
|
|
10046
|
+
var handleElementClicked = function (id, e, ref, element) {
|
|
10047
|
+
e.stopPropagation();
|
|
10048
|
+
setSelectedElementSVG(ref);
|
|
10049
|
+
setSelectedElement(elements.find(function (e) { return e.id === id; }));
|
|
10050
|
+
setMouseDownedOnPaper(false);
|
|
10051
|
+
paperEventEmitter.emitElementSelected(element);
|
|
10052
|
+
};
|
|
9978
10053
|
var renderElementInTree = function (element) {
|
|
9979
10054
|
var _a, _b;
|
|
9980
10055
|
//use the defined react element or the default Element component
|
|
9981
10056
|
var ReactElement = element.reactElement || Element;
|
|
9982
10057
|
return (React$1.createElement("g", { key: element.id }, React$1.createElement(ReactElement, { key: "element-".concat(element.id), id: element.id, height: element.size.height, width: element.size.width, x: (_a = element.relativePosition) === null || _a === void 0 ? void 0 : _a.x, y: (_b = element.relativePosition) === null || _b === void 0 ? void 0 : _b.y, onClick: function (id, e, ref) {
|
|
9983
|
-
e
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
10058
|
+
handleElementClicked(id, e, ref, element);
|
|
10059
|
+
}, onContextMenu: function (id, e, ref) {
|
|
10060
|
+
var _a;
|
|
10061
|
+
handleElementClicked(id, e, ref, element);
|
|
10062
|
+
(_a = props.onElementContextMenu) === null || _a === void 0 ? void 0 : _a.call(props, element, e);
|
|
10063
|
+
}, container: paperContainerRef.current, renderShape: element.renderShape, cssClass: element.cssClass, texts: element.texts, ports: element.ports, portMoveableAreas: element.portMoveableAreas, portSlideRailSVGClassName: element.portSlideRailSVGClassName, portDirection: element.portDirection, defaultPortSize: element.defaultPortSize, onPortMoved: handlePortMoved, onPortMouseDown: handlePortMouseDown, onPortMouseUp: handlePortMouseUp,
|
|
9988
10064
|
// portPlaceholderShape={(<Circle x={0} y={0} width={10} height={10} fill='red' positioningAnchor={PositioningAnchor.Center} />)}
|
|
9989
10065
|
onMouseUpAtLinkedPortPlaceholder: function (elementLink, position) { return handleMouseUpAtLinkedPortPlaceholder(elementLink, position, element); }, onTextUpdated: function (textId, newContent) { return handleElementTextChange(element, textId, newContent); }, textsPlaceHolderClassName: element.textsPlaceHolderClassName, textsPlaceHolderFlexStyle: element.textsPlaceHolderFlexStyle, textsPlaceHolderFlexboxPosition: element.textsPlaceHolderFlexboxPosition }, element.childrenElements && element.childrenElements.map(renderElementInTree))));
|
|
9990
10066
|
};
|
|
@@ -10018,7 +10094,7 @@ var Paper = function (props) {
|
|
|
10018
10094
|
function Editor(_a) {
|
|
10019
10095
|
var editorContext = _a.editorContext;
|
|
10020
10096
|
return (React$1.createElement(React$1.Fragment, null,
|
|
10021
|
-
React$1.createElement(Paper, { size: { width: 3000, height: 3000 }, elements: editorContext.elements, links: editorContext.links, texts: editorContext.texts, onPaperClicked: editorContext.onPaperClicked, onPortMoved: editorContext.onPortMoved, onElementMoved: editorContext.onElementMoved, onElementResized: editorContext.onElementResized, onLinkValidation: editorContext.validateLink, onCreatingLink: editorContext.onCreatingLink, onCreatingPortByLinking: editorContext.onCreatingPortByLinking })));
|
|
10097
|
+
React$1.createElement(Paper, { size: { width: 3000, height: 3000 }, elements: editorContext.elements, links: editorContext.links, texts: editorContext.texts, onPaperClicked: editorContext.onPaperClicked, onPortMoved: editorContext.onPortMoved, onElementContextMenu: editorContext.onElementContextMenu, onElementMoved: editorContext.onElementMoved, onElementResized: editorContext.onElementResized, onLinkValidation: editorContext.validateLink, onCreatingLink: editorContext.onCreatingLink, onCreatingPortByLinking: editorContext.onCreatingPortByLinking })));
|
|
10022
10098
|
}
|
|
10023
10099
|
|
|
10024
10100
|
exports.CircleRC = Circle;
|
|
@@ -15,6 +15,7 @@ interface PaperProps {
|
|
|
15
15
|
texts: IPaperText[];
|
|
16
16
|
onPaperClicked?: () => void;
|
|
17
17
|
onPortMoved?: (position: IPosition, port: IPort, element: IElement) => void;
|
|
18
|
+
onElementContextMenu?: (element: IElement, mouseEvent: React.MouseEvent<SVGElement>) => void;
|
|
18
19
|
onElementMoved?: (position: IPosition, element: IElement, index: number) => void;
|
|
19
20
|
onElementResized?: (size: ISize, element: IElement, index: number) => void;
|
|
20
21
|
onLinkValidation?: (sourcePort: IPort, sourceElement: IElement, targetPort: IPort, targetElement: IElement) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import EventEmitter from "eventemitter3";
|
|
3
|
-
import { onCommandDeleteSelectedHandler, OnElementLinkEnded, OnElementLinkStarted, onElementMovedHandler, onElementResizedHandler, onPortMouseDownHandler, onPortMouseUpHandler, onPortMovedHandler } from "../models/callbackTypes";
|
|
3
|
+
import { onCommandDeleteSelectedHandler, OnElementLinkEnded, OnElementLinkStarted, onElementMovedHandler, onElementResizedHandler, OnElementSelected, onPortMouseDownHandler, onPortMouseUpHandler, onPortMovedHandler, OnPortSelected } from "../models/callbackTypes";
|
|
4
4
|
interface IEventListenerReturn {
|
|
5
5
|
off: () => void;
|
|
6
6
|
}
|
|
@@ -14,10 +14,14 @@ interface IPaperEventContext {
|
|
|
14
14
|
onPortMouseDown: (callback: onPortMouseDownHandler) => IEventListenerReturn;
|
|
15
15
|
emitPortMoved: onPortMovedHandler;
|
|
16
16
|
onPortMoved: (callback: onPortMovedHandler) => IEventListenerReturn;
|
|
17
|
+
emitPortSelected: OnPortSelected;
|
|
18
|
+
onPortSelected: (callback: OnPortSelected) => IEventListenerReturn;
|
|
17
19
|
emitElementMoved: onElementMovedHandler;
|
|
18
20
|
onElementMoved: (elementId: string, callback: onElementMovedHandler) => IEventListenerReturn;
|
|
19
21
|
emitElementResized: onElementResizedHandler;
|
|
20
22
|
onElementResized: (elementId: string, callback: onElementResizedHandler) => IEventListenerReturn;
|
|
23
|
+
emitElementSelected: OnElementSelected;
|
|
24
|
+
onElementSelected: (callback: OnElementSelected) => IEventListenerReturn;
|
|
21
25
|
emitCommandDeleteSelectedPort: onCommandDeleteSelectedHandler;
|
|
22
26
|
onCommandDeleteSelectedPort: (callback: onCommandDeleteSelectedHandler) => IEventListenerReturn;
|
|
23
27
|
emitCommandDeleteSelectedElement: onCommandDeleteSelectedHandler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import IText from "../models/IText";
|
|
2
2
|
import { CustomPortFromShape } from '../models/implementations/CustomPortFromShape';
|
|
3
3
|
export declare class CustomPort1 extends CustomPortFromShape {
|
|
4
|
-
constructor(x: number, y: number,
|
|
4
|
+
constructor(x: number, y: number, label?: IText, width?: number, height?: number);
|
|
5
5
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CustomPortFromJSXElement } from "../models/implementations/CustomPortFromJSXElement";
|
|
2
2
|
export default class PortIn extends CustomPortFromJSXElement {
|
|
3
|
-
constructor(x: number, y: number, width
|
|
3
|
+
constructor(x: number, y: number, width?: number, height?: number);
|
|
4
4
|
}
|
|
@@ -23,6 +23,7 @@ export default interface IElement {
|
|
|
23
23
|
portMoveableAreas?: IPosition[][];
|
|
24
24
|
portSlideRailSVGClassName?: string;
|
|
25
25
|
portDirection?: SubObjectDirection;
|
|
26
|
+
defaultPortSize?: number;
|
|
26
27
|
parentElement?: IElement;
|
|
27
28
|
onParentChanged?: (callback: (oldParent?: IElement, newParent?: IElement) => void) => (() => void);
|
|
28
29
|
addPort: (newPort: IPort) => void;
|
|
@@ -20,7 +20,9 @@ interface IElementProps {
|
|
|
20
20
|
portMoveableAreas?: IPosition[][];
|
|
21
21
|
portSlideRailSVGClassName?: string;
|
|
22
22
|
portDirection?: SubObjectDirection;
|
|
23
|
+
defaultPortSize?: number;
|
|
23
24
|
onClick?: (elementId: string, e: React.MouseEvent<SVGElement>, ref: SVGSVGElement | null) => void;
|
|
25
|
+
onContextMenu?: (elementId: string, e: React.MouseEvent<SVGElement>, ref: SVGSVGElement | null) => void;
|
|
24
26
|
container: Element;
|
|
25
27
|
onResized?: onElementResizedHandler;
|
|
26
28
|
onMoved?: onElementMovedHandler;
|
|
@@ -9,6 +9,8 @@ export type onPortMouseDownHandler = (ev: React.MouseEvent<SVGElement>, port: IP
|
|
|
9
9
|
export type onPortMouseUpHandler = (ev: React.MouseEvent<SVGElement>, port: IPort, elementId: string) => void;
|
|
10
10
|
export type onElementMovedHandler = (element: IElement, oldPosition: IPosition, newPosition: IPosition) => void;
|
|
11
11
|
export type onElementResizedHandler = (element: IElement, oldSize: ISize, newSize: ISize) => void;
|
|
12
|
+
export type OnElementSelected = (element: IElement) => void;
|
|
12
13
|
export type onCommandDeleteSelectedHandler = () => void;
|
|
13
14
|
export type OnElementLinkStarted = (elementLink: IElementLink) => void;
|
|
14
15
|
export type OnElementLinkEnded = (elementLink?: IElementLink) => void;
|
|
16
|
+
export type OnPortSelected = (port: IPort, elementId: string) => void;
|
|
@@ -3,5 +3,5 @@ import Port from "./Port";
|
|
|
3
3
|
import IText from "../IText";
|
|
4
4
|
import IPosition from "../position";
|
|
5
5
|
export declare class CustomPortFromJSXElement extends Port {
|
|
6
|
-
constructor(x: number, y: number,
|
|
6
|
+
constructor(x: number, y: number, renderCustomShape: JSX.Element, label?: IText, shapePositioningAnchor?: IPosition, width?: number, height?: number);
|
|
7
7
|
}
|
|
@@ -3,5 +3,5 @@ import Port from "./Port";
|
|
|
3
3
|
import IText from "../IText";
|
|
4
4
|
import { IPortProps } from "../IPortProps";
|
|
5
5
|
export declare class CustomPortFromShape extends Port {
|
|
6
|
-
constructor(x: number, y: number,
|
|
6
|
+
constructor(x: number, y: number, shape: React.ForwardRefExoticComponent<IPortProps & React.RefAttributes<SVGSVGElement>>, label?: IText, width?: number, height?: number);
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import IElement from "../IElement";
|
|
2
3
|
import IElementLink from "../IElementLink";
|
|
3
4
|
import { IPaperText } from "../IText";
|
|
@@ -10,6 +11,7 @@ export declare class EditorContext {
|
|
|
10
11
|
private _texts;
|
|
11
12
|
onPaperClicked?: () => void;
|
|
12
13
|
onPortMoved?: (position: IPosition, port: IPort, element: IElement) => void;
|
|
14
|
+
onElementContextMenu?: (element: IElement, mouseEvent: React.MouseEvent<SVGElement>) => void;
|
|
13
15
|
onElementMoved?: (position: IPosition, element: IElement, index: number) => void;
|
|
14
16
|
onElementResized?: (size: ISize, element: IElement, index: number) => void;
|
|
15
17
|
validateLink?: (sourcePort: IPort, sourceElement: IElement, targetPort: IPort, targetElement: IElement) => boolean;
|
|
@@ -26,6 +26,7 @@ export default class Element implements IElement {
|
|
|
26
26
|
portMoveableAreas?: IPosition[][];
|
|
27
27
|
portSlideRailSVGClassName?: string;
|
|
28
28
|
portDirection?: SubObjectDirection;
|
|
29
|
+
defaultPortSize?: number;
|
|
29
30
|
onResized?: ((width: number, height: number) => void) | undefined;
|
|
30
31
|
onMoved?: ((x: number, y: number) => void) | undefined;
|
|
31
32
|
textsPlaceHolderClassName?: string;
|
|
@@ -7,9 +7,9 @@ import ISize from "../size";
|
|
|
7
7
|
export default class Port implements IPort {
|
|
8
8
|
private readonly _id;
|
|
9
9
|
position: IPosition;
|
|
10
|
-
size
|
|
10
|
+
size?: ISize;
|
|
11
11
|
label?: IText;
|
|
12
12
|
renderShape?: React.ForwardRefExoticComponent<IPortProps & React.RefAttributes<SVGSVGElement>>;
|
|
13
|
-
constructor(x: number, y: number,
|
|
13
|
+
constructor(x: number, y: number, label?: IText, renderShape?: React.ForwardRefExoticComponent<IPortProps & React.RefAttributes<SVGSVGElement>>, width?: number, height?: number);
|
|
14
14
|
get id(): string;
|
|
15
15
|
}
|
|
@@ -6,5 +6,6 @@ import IFlexboxType from '../IFlexboxType';
|
|
|
6
6
|
import IPosition from '../position';
|
|
7
7
|
export default class RectangularFrameElement extends Element {
|
|
8
8
|
resizability: IResizability;
|
|
9
|
+
defaultPortSize?: number | undefined;
|
|
9
10
|
constructor(x: number, y: number, width: number, height: number, cssClass?: string, texts?: IText[], ports?: IPort[], textsPlaceHolderClassName?: string, textsPlaceHolderFlexStyle?: IFlexboxType, textsPlaceHolderFlexboxPosition?: IPosition);
|
|
10
11
|
}
|
|
@@ -6,9 +6,11 @@ export declare const EVENT_NAME: {
|
|
|
6
6
|
ELEMENT_DRAGGED: string;
|
|
7
7
|
ELEMENT_RESIZED: string;
|
|
8
8
|
ELEMENT_DELETED: string;
|
|
9
|
+
ELEMENT_SELECTED: string;
|
|
9
10
|
PORT_MOUSE_DOWN: string;
|
|
10
11
|
PORT_MOUSE_UP: string;
|
|
11
12
|
PORT_MOVED: string;
|
|
13
|
+
PORT_SELECTED: string;
|
|
12
14
|
COMMAND_DELETE_SELECTED_PORT: string;
|
|
13
15
|
COMMAND_DELETE_SELECTED_LINK: string;
|
|
14
16
|
COMMAND_DELETE_SELECTED_ELEMENT: string;
|
|
@@ -45,3 +47,4 @@ export declare const PORT_PLACEHOLDER_DEFAULT_SIZE = 8;
|
|
|
45
47
|
export declare const PORT_PLACEHOLDER_DEFAULT_STROKE = "green";
|
|
46
48
|
export declare const PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH = 20;
|
|
47
49
|
export declare const PORT_MOVING_OFFSET_THRESHOLD = 15;
|
|
50
|
+
export declare const PORT_DEFAULT_SIZE = 20;
|