orcasvn-react-diagrams 0.1.14 → 0.1.15
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 +34 -11
- package/dist/esm/index.js +34 -11
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -8976,24 +8976,34 @@ var bundleExports = bundle.exports;
|
|
|
8976
8976
|
var Flexbox$1 = /*@__PURE__*/getDefaultExportFromCjs(bundleExports);
|
|
8977
8977
|
|
|
8978
8978
|
var Element = function (props) {
|
|
8979
|
-
var _a, _b;
|
|
8979
|
+
var _a, _b, _c;
|
|
8980
8980
|
var id = props.id, x = props.x, y = props.y, width = props.width, height = props.height, portPlaceholderShape = props.portPlaceholderShape, children = props.children, container = props.container, textsPlaceHolderFlexStyle = props.textsPlaceHolderFlexStyle, textsPlaceHolderFlexboxPosition = props.textsPlaceHolderFlexboxPosition, textsPlaceHolderClassName = props.textsPlaceHolderClassName, texts = props.texts, portSlideRailSVGClassName = props.portSlideRailSVGClassName, portMoveableAreas = props.portMoveableAreas, portDirection = props.portDirection, defaultPortSize = props.defaultPortSize, onClick = props.onClick, onContextMenu = props.onContextMenu, renderShape = props.renderShape; props.onMoved; var onPortMoved = props.onPortMoved; props.onResized; var onPortMouseDown = props.onPortMouseDown, onPortMouseUp = props.onPortMouseUp; props.onMouseMove; props.onMouseLeave; props.onMouseUp; var onMouseUpAtLinkedPortPlaceholder = props.onMouseUpAtLinkedPortPlaceholder, onTextUpdated = props.onTextUpdated;
|
|
8981
|
-
var
|
|
8982
|
-
var
|
|
8981
|
+
var _d = React$1.useState(), selectedPort = _d[0], setSelectedPort = _d[1];
|
|
8982
|
+
var _e = React$1.useState((_b = (_a = props.ports) === null || _a === void 0 ? void 0 : _a.map(function (p) {
|
|
8983
8983
|
return __assign(__assign({}, p), { id: p.id, ref: React$1.createRef() });
|
|
8984
|
-
})) !== null && _b !== void 0 ? _b : []), ports =
|
|
8985
|
-
var
|
|
8986
|
-
var
|
|
8984
|
+
})) !== null && _b !== void 0 ? _b : []), ports = _e[0], setPorts = _e[1];
|
|
8985
|
+
var _f = React$1.useState(false), someElementLinkStarted = _f[0], setSomeElementLinkStarted = _f[1];
|
|
8986
|
+
var _g = React$1.useState(), potentialPortPosition = _g[0], setPotentialPortPosition = _g[1];
|
|
8987
8987
|
var _paperEventEmitterContext = React$1.useContext(paperEventEmitterContext);
|
|
8988
8988
|
var elementRef = React$1.useRef(null);
|
|
8989
8989
|
var elementLinkStarted = React$1.useRef();
|
|
8990
8990
|
//Listen a new port is created, after add new port to ports state
|
|
8991
8991
|
React$1.useEffect(function () {
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
return
|
|
8995
|
-
|
|
8996
|
-
|
|
8992
|
+
setPorts(function (prev) {
|
|
8993
|
+
var _a, _b;
|
|
8994
|
+
return (_b = (_a = props.ports) === null || _a === void 0 ? void 0 : _a.map(function (p, index) {
|
|
8995
|
+
var _a, _b;
|
|
8996
|
+
var position = p.position;
|
|
8997
|
+
//Handle the case when the port is created.
|
|
8998
|
+
if (!((_a = prev[index]) === null || _a === void 0 ? void 0 : _a.ref)) {
|
|
8999
|
+
position = normalizePortPosition(position);
|
|
9000
|
+
onPortMoved === null || onPortMoved === void 0 ? void 0 : onPortMoved(p, id, p.position, position);
|
|
9001
|
+
_paperEventEmitterContext.emitPortMoved(p, id, p.position, position);
|
|
9002
|
+
}
|
|
9003
|
+
return __assign(__assign({}, p), { position: position, id: p.id, ref: ((_b = prev[index]) === null || _b === void 0 ? void 0 : _b.ref) || React$1.createRef() });
|
|
9004
|
+
})) !== null && _b !== void 0 ? _b : [];
|
|
9005
|
+
});
|
|
9006
|
+
}, [(_c = props.ports) === null || _c === void 0 ? void 0 : _c.length]);
|
|
8997
9007
|
//Listen trigger of Delete key, handle delete port is selected
|
|
8998
9008
|
React$1.useEffect(function () {
|
|
8999
9009
|
var listener = _paperEventEmitterContext.onCommandDeleteSelectedPort(function () {
|
|
@@ -9018,6 +9028,7 @@ var Element = function (props) {
|
|
|
9018
9028
|
//Check port moved
|
|
9019
9029
|
if (port.position.x !== newPosition.x || port.position.y !== newPosition.y) {
|
|
9020
9030
|
onPortMoved === null || onPortMoved === void 0 ? void 0 : onPortMoved(port, id, port.position, newPosition);
|
|
9031
|
+
_paperEventEmitterContext.emitPortMoved(port, id, port.position, newPosition);
|
|
9021
9032
|
}
|
|
9022
9033
|
return __assign(__assign({}, port), { position: newPosition });
|
|
9023
9034
|
});
|
|
@@ -9835,6 +9846,18 @@ var Paper = function (props) {
|
|
|
9835
9846
|
}
|
|
9836
9847
|
return link;
|
|
9837
9848
|
}); });
|
|
9849
|
+
//Update port position in element, not re-render
|
|
9850
|
+
setElements(function (prevElements) {
|
|
9851
|
+
var _a;
|
|
9852
|
+
var updatedElementIndex = prevElements.findIndex(function (e) { return e.id === elementId; });
|
|
9853
|
+
prevElements[updatedElementIndex].ports = (_a = prevElements[updatedElementIndex].ports) === null || _a === void 0 ? void 0 : _a.map(function (p) {
|
|
9854
|
+
if (p.id === port.id) {
|
|
9855
|
+
p.position = newPosition;
|
|
9856
|
+
}
|
|
9857
|
+
return p;
|
|
9858
|
+
});
|
|
9859
|
+
return prevElements;
|
|
9860
|
+
});
|
|
9838
9861
|
};
|
|
9839
9862
|
//Handle creating a new element link
|
|
9840
9863
|
var handlePortMouseDown = function (ev, port, elementId) {
|
package/dist/esm/index.js
CHANGED
|
@@ -8972,24 +8972,34 @@ var bundleExports = bundle.exports;
|
|
|
8972
8972
|
var Flexbox$1 = /*@__PURE__*/getDefaultExportFromCjs(bundleExports);
|
|
8973
8973
|
|
|
8974
8974
|
var Element = function (props) {
|
|
8975
|
-
var _a, _b;
|
|
8975
|
+
var _a, _b, _c;
|
|
8976
8976
|
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;
|
|
8977
|
-
var
|
|
8978
|
-
var
|
|
8977
|
+
var _d = useState(), selectedPort = _d[0], setSelectedPort = _d[1];
|
|
8978
|
+
var _e = useState((_b = (_a = props.ports) === null || _a === void 0 ? void 0 : _a.map(function (p) {
|
|
8979
8979
|
return __assign(__assign({}, p), { id: p.id, ref: React$1.createRef() });
|
|
8980
|
-
})) !== null && _b !== void 0 ? _b : []), ports =
|
|
8981
|
-
var
|
|
8982
|
-
var
|
|
8980
|
+
})) !== null && _b !== void 0 ? _b : []), ports = _e[0], setPorts = _e[1];
|
|
8981
|
+
var _f = useState(false), someElementLinkStarted = _f[0], setSomeElementLinkStarted = _f[1];
|
|
8982
|
+
var _g = useState(), potentialPortPosition = _g[0], setPotentialPortPosition = _g[1];
|
|
8983
8983
|
var _paperEventEmitterContext = useContext(paperEventEmitterContext);
|
|
8984
8984
|
var elementRef = useRef(null);
|
|
8985
8985
|
var elementLinkStarted = useRef();
|
|
8986
8986
|
//Listen a new port is created, after add new port to ports state
|
|
8987
8987
|
useEffect(function () {
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
return
|
|
8991
|
-
|
|
8992
|
-
|
|
8988
|
+
setPorts(function (prev) {
|
|
8989
|
+
var _a, _b;
|
|
8990
|
+
return (_b = (_a = props.ports) === null || _a === void 0 ? void 0 : _a.map(function (p, index) {
|
|
8991
|
+
var _a, _b;
|
|
8992
|
+
var position = p.position;
|
|
8993
|
+
//Handle the case when the port is created.
|
|
8994
|
+
if (!((_a = prev[index]) === null || _a === void 0 ? void 0 : _a.ref)) {
|
|
8995
|
+
position = normalizePortPosition(position);
|
|
8996
|
+
onPortMoved === null || onPortMoved === void 0 ? void 0 : onPortMoved(p, id, p.position, position);
|
|
8997
|
+
_paperEventEmitterContext.emitPortMoved(p, id, p.position, position);
|
|
8998
|
+
}
|
|
8999
|
+
return __assign(__assign({}, p), { position: position, id: p.id, ref: ((_b = prev[index]) === null || _b === void 0 ? void 0 : _b.ref) || React$1.createRef() });
|
|
9000
|
+
})) !== null && _b !== void 0 ? _b : [];
|
|
9001
|
+
});
|
|
9002
|
+
}, [(_c = props.ports) === null || _c === void 0 ? void 0 : _c.length]);
|
|
8993
9003
|
//Listen trigger of Delete key, handle delete port is selected
|
|
8994
9004
|
useEffect(function () {
|
|
8995
9005
|
var listener = _paperEventEmitterContext.onCommandDeleteSelectedPort(function () {
|
|
@@ -9014,6 +9024,7 @@ var Element = function (props) {
|
|
|
9014
9024
|
//Check port moved
|
|
9015
9025
|
if (port.position.x !== newPosition.x || port.position.y !== newPosition.y) {
|
|
9016
9026
|
onPortMoved === null || onPortMoved === void 0 ? void 0 : onPortMoved(port, id, port.position, newPosition);
|
|
9027
|
+
_paperEventEmitterContext.emitPortMoved(port, id, port.position, newPosition);
|
|
9017
9028
|
}
|
|
9018
9029
|
return __assign(__assign({}, port), { position: newPosition });
|
|
9019
9030
|
});
|
|
@@ -9831,6 +9842,18 @@ var Paper = function (props) {
|
|
|
9831
9842
|
}
|
|
9832
9843
|
return link;
|
|
9833
9844
|
}); });
|
|
9845
|
+
//Update port position in element, not re-render
|
|
9846
|
+
setElements(function (prevElements) {
|
|
9847
|
+
var _a;
|
|
9848
|
+
var updatedElementIndex = prevElements.findIndex(function (e) { return e.id === elementId; });
|
|
9849
|
+
prevElements[updatedElementIndex].ports = (_a = prevElements[updatedElementIndex].ports) === null || _a === void 0 ? void 0 : _a.map(function (p) {
|
|
9850
|
+
if (p.id === port.id) {
|
|
9851
|
+
p.position = newPosition;
|
|
9852
|
+
}
|
|
9853
|
+
return p;
|
|
9854
|
+
});
|
|
9855
|
+
return prevElements;
|
|
9856
|
+
});
|
|
9834
9857
|
};
|
|
9835
9858
|
//Handle creating a new element link
|
|
9836
9859
|
var handlePortMouseDown = function (ev, port, elementId) {
|