react-cosmos-diagram 0.1.1 → 0.3.0
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/README.md +146 -0
- package/dist/esm/components/Edges/Anchor.d.ts +2 -2
- package/dist/esm/components/Edges/Anchor.d.ts.map +1 -1
- package/dist/esm/components/Edges/EdgeWrapper/index.d.ts.map +1 -1
- package/dist/esm/components/Edges/EdgeWrapper/type.d.ts +4 -2
- package/dist/esm/components/Edges/EdgeWrapper/type.d.ts.map +1 -1
- package/dist/esm/components/Port/utils.d.ts +9 -1
- package/dist/esm/components/Port/utils.d.ts.map +1 -1
- package/dist/esm/components/ReactDiagramProvider/type.d.ts +1 -0
- package/dist/esm/components/ReactDiagramProvider/type.d.ts.map +1 -1
- package/dist/esm/components/StoreUpdater/index.d.ts +2 -2
- package/dist/esm/components/StoreUpdater/index.d.ts.map +1 -1
- package/dist/esm/container/ConnectionLineRenderer/ConnectionPath.d.ts +17 -0
- package/dist/esm/container/ConnectionLineRenderer/ConnectionPath.d.ts.map +1 -0
- package/dist/esm/container/ConnectionLineRenderer/index.d.ts +11 -0
- package/dist/esm/container/ConnectionLineRenderer/index.d.ts.map +1 -0
- package/dist/esm/container/ConnectionLineRenderer/type.d.ts +15 -0
- package/dist/esm/container/ConnectionLineRenderer/type.d.ts.map +1 -0
- package/dist/esm/container/EdgeRenderer/index.d.ts +3 -4
- package/dist/esm/container/EdgeRenderer/index.d.ts.map +1 -1
- package/dist/esm/container/EdgeRenderer/type.d.ts +3 -3
- package/dist/esm/container/EdgeRenderer/type.d.ts.map +1 -1
- package/dist/esm/container/ReactDiagram/DiagramView.d.ts +1 -1
- package/dist/esm/container/ReactDiagram/DiagramView.d.ts.map +1 -1
- package/dist/esm/container/ReactDiagram/index.d.ts +4 -0
- package/dist/esm/container/ReactDiagram/index.d.ts.map +1 -1
- package/dist/esm/index.d.ts +4 -6
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +158 -136
- package/dist/esm/store/initialState.d.ts.map +1 -1
- package/dist/esm/types/core.d.ts +6 -2
- package/dist/esm/types/core.d.ts.map +1 -1
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/utils/graph.d.ts +1 -1
- package/dist/esm/utils/graph.d.ts.map +1 -1
- package/dist/style.css +45 -7
- package/dist/umd/components/Edges/Anchor.d.ts +2 -2
- package/dist/umd/components/Edges/Anchor.d.ts.map +1 -1
- package/dist/umd/components/Edges/EdgeWrapper/index.d.ts.map +1 -1
- package/dist/umd/components/Edges/EdgeWrapper/type.d.ts +4 -2
- package/dist/umd/components/Edges/EdgeWrapper/type.d.ts.map +1 -1
- package/dist/umd/components/Port/utils.d.ts +9 -1
- package/dist/umd/components/Port/utils.d.ts.map +1 -1
- package/dist/umd/components/ReactDiagramProvider/type.d.ts +1 -0
- package/dist/umd/components/ReactDiagramProvider/type.d.ts.map +1 -1
- package/dist/umd/components/StoreUpdater/index.d.ts +2 -2
- package/dist/umd/components/StoreUpdater/index.d.ts.map +1 -1
- package/dist/umd/container/ConnectionLineRenderer/ConnectionPath.d.ts +17 -0
- package/dist/umd/container/ConnectionLineRenderer/ConnectionPath.d.ts.map +1 -0
- package/dist/umd/container/ConnectionLineRenderer/index.d.ts +11 -0
- package/dist/umd/container/ConnectionLineRenderer/index.d.ts.map +1 -0
- package/dist/umd/container/ConnectionLineRenderer/type.d.ts +15 -0
- package/dist/umd/container/ConnectionLineRenderer/type.d.ts.map +1 -0
- package/dist/umd/container/EdgeRenderer/index.d.ts +3 -4
- package/dist/umd/container/EdgeRenderer/index.d.ts.map +1 -1
- package/dist/umd/container/EdgeRenderer/type.d.ts +3 -3
- package/dist/umd/container/EdgeRenderer/type.d.ts.map +1 -1
- package/dist/umd/container/ReactDiagram/DiagramView.d.ts +1 -1
- package/dist/umd/container/ReactDiagram/DiagramView.d.ts.map +1 -1
- package/dist/umd/container/ReactDiagram/index.d.ts +4 -0
- package/dist/umd/container/ReactDiagram/index.d.ts.map +1 -1
- package/dist/umd/index.d.ts +4 -6
- package/dist/umd/index.d.ts.map +1 -1
- package/dist/umd/index.js +2 -2
- package/dist/umd/store/initialState.d.ts.map +1 -1
- package/dist/umd/types/core.d.ts +6 -2
- package/dist/umd/types/core.d.ts.map +1 -1
- package/dist/umd/types/index.d.ts +1 -0
- package/dist/umd/types/index.d.ts.map +1 -1
- package/dist/umd/utils/graph.d.ts +1 -1
- package/dist/umd/utils/graph.d.ts.map +1 -1
- package/package.json +2 -3
- package/dist/esm/components/ConnectionEdge/ConnectionPath.d.ts +0 -13
- package/dist/esm/components/ConnectionEdge/ConnectionPath.d.ts.map +0 -1
- package/dist/esm/components/ConnectionEdge/index.d.ts +0 -8
- package/dist/esm/components/ConnectionEdge/index.d.ts.map +0 -1
- package/dist/umd/components/ConnectionEdge/ConnectionPath.d.ts +0 -13
- package/dist/umd/components/ConnectionEdge/ConnectionPath.d.ts.map +0 -1
- package/dist/umd/components/ConnectionEdge/index.d.ts +0 -8
- package/dist/umd/components/ConnectionEdge/index.d.ts.map +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -381,7 +381,7 @@ const getMarkerId = (marker, rfId) => {
|
|
|
381
381
|
.map((key) => `${key}=${marker[key]}`)
|
|
382
382
|
.join('&')}`;
|
|
383
383
|
};
|
|
384
|
-
const getEdgeId = ({ source, target }) => `
|
|
384
|
+
const getEdgeId = ({ source, target }) => `react-diagram__edge-${source}-${target}`;
|
|
385
385
|
const isExistsConnection = (edge, edges) => edges.some((el) => el.source === edge.source && el.target === edge.target);
|
|
386
386
|
const addEdge = (edgeParams, edges) => {
|
|
387
387
|
if (!isEdge(edgeParams)) {
|
|
@@ -401,8 +401,8 @@ const addEdge = (edgeParams, edges) => {
|
|
|
401
401
|
};
|
|
402
402
|
return edges.concat(edge);
|
|
403
403
|
};
|
|
404
|
-
const updateEdge = (
|
|
405
|
-
const { id: oldEdgeId, ...rest } =
|
|
404
|
+
const updateEdge = (originEdge, newConnection, edges, options = { shouldReplaceId: true }) => {
|
|
405
|
+
const { id: oldEdgeId, ...rest } = originEdge;
|
|
406
406
|
if (!newConnection.source || !newConnection.target)
|
|
407
407
|
devWarn('020');
|
|
408
408
|
const foundEdge = edges.find((e) => e.id === oldEdgeId);
|
|
@@ -1220,9 +1220,22 @@ const getClosestPort = (pos, connectionRadius, ports) => {
|
|
|
1220
1220
|
});
|
|
1221
1221
|
return closestPort;
|
|
1222
1222
|
};
|
|
1223
|
+
const pointToRendererPoint = ({ x, y }, [tx, ty, tScale]) => {
|
|
1224
|
+
const position = {
|
|
1225
|
+
x: (x - tx) / tScale,
|
|
1226
|
+
y: (y - ty) / tScale,
|
|
1227
|
+
};
|
|
1228
|
+
return position;
|
|
1229
|
+
};
|
|
1230
|
+
const rendererPointToPoint = ({ x, y }, [tx, ty, tScale]) => {
|
|
1231
|
+
return {
|
|
1232
|
+
x: x * tScale + tx,
|
|
1233
|
+
y: y * tScale + ty,
|
|
1234
|
+
};
|
|
1235
|
+
};
|
|
1223
1236
|
const handlePointerDown = ({ isAnchor = false, event, nodeId, portType, getState, setState, onConnect, onEdgeUpdateEnd, }) => {
|
|
1224
1237
|
const doc = getHostForElement(event.target);
|
|
1225
|
-
const { domNode, autoPanOnConnect, getNodes, cancelConnection, onConnectStart, onConnectEnd, panBy, } = getState();
|
|
1238
|
+
const { domNode, autoPanOnConnect, connectionRadius, getNodes, cancelConnection, onConnectStart, onConnectEnd, panBy, } = getState();
|
|
1226
1239
|
const containerBounds = domNode?.getBoundingClientRect();
|
|
1227
1240
|
const { x, y } = getEventPosition(event);
|
|
1228
1241
|
const clickedPort = doc?.elementFromPoint(x, y);
|
|
@@ -1256,8 +1269,9 @@ const handlePointerDown = ({ isAnchor = false, event, nodeId, portType, getState
|
|
|
1256
1269
|
});
|
|
1257
1270
|
onConnectStart?.(event, { nodeId, portType });
|
|
1258
1271
|
const onPointerMove = (event) => {
|
|
1272
|
+
const { transform } = getState();
|
|
1259
1273
|
connectionPosition = getEventPosition(event, containerBounds);
|
|
1260
|
-
closestPort = getClosestPort(connectionPosition,
|
|
1274
|
+
closestPort = getClosestPort(pointToRendererPoint(connectionPosition, transform), connectionRadius, allPort);
|
|
1261
1275
|
if (!autoPanStarted) {
|
|
1262
1276
|
autoPan();
|
|
1263
1277
|
autoPanStarted = true;
|
|
@@ -1265,20 +1279,11 @@ const handlePointerDown = ({ isAnchor = false, event, nodeId, portType, getState
|
|
|
1265
1279
|
const result = getConnection(event, closestPort, nodeId, portType, doc);
|
|
1266
1280
|
isValid = result.isValid;
|
|
1267
1281
|
connection = result.connection;
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
y,
|
|
1274
|
-
},
|
|
1275
|
-
});
|
|
1276
|
-
}
|
|
1277
|
-
else {
|
|
1278
|
-
setState({
|
|
1279
|
-
connectionPosition,
|
|
1280
|
-
});
|
|
1281
|
-
}
|
|
1282
|
+
setState({
|
|
1283
|
+
connectionPosition: closestPort && isValid
|
|
1284
|
+
? rendererPointToPoint(closestPort, transform)
|
|
1285
|
+
: connectionPosition,
|
|
1286
|
+
});
|
|
1282
1287
|
};
|
|
1283
1288
|
const onPointerUp = (event) => {
|
|
1284
1289
|
if (isValid && connection)
|
|
@@ -1317,12 +1322,15 @@ const portPositionY = (y, shift, position) => {
|
|
|
1317
1322
|
return y + shift;
|
|
1318
1323
|
return y;
|
|
1319
1324
|
};
|
|
1320
|
-
const EdgeUpdaterClassName = 'react-
|
|
1321
|
-
function Anchor({ position, centerX, centerY, radius = 10, onMouseDown,
|
|
1325
|
+
const EdgeUpdaterClassName = 'react-diagram__edge-updater';
|
|
1326
|
+
function Anchor({ position, centerX, centerY, radius = 10, onMouseDown,
|
|
1327
|
+
// onMouseEnter,
|
|
1328
|
+
// onMouseOut,
|
|
1329
|
+
type, }) {
|
|
1322
1330
|
return (jsx("circle", { className: cc([
|
|
1323
1331
|
EdgeUpdaterClassName,
|
|
1324
1332
|
`${EdgeUpdaterClassName}-${type}`,
|
|
1325
|
-
]), cx: portPositionX(centerX, radius, position), cy: portPositionY(centerY, radius, position), r: radius, stroke: "transparent", fill: "transparent", onMouseDown: onMouseDown
|
|
1333
|
+
]), cx: portPositionX(centerX, radius, position), cy: portPositionY(centerY, radius, position), r: radius, stroke: "transparent", fill: "transparent", onMouseDown: onMouseDown }));
|
|
1326
1334
|
}
|
|
1327
1335
|
|
|
1328
1336
|
function getMouseHandler$1(id, getState, handler) {
|
|
@@ -1344,11 +1352,34 @@ const wrapEdge = (EdgeComponent) => {
|
|
|
1344
1352
|
markerEnd, markerStart,
|
|
1345
1353
|
// labelProps
|
|
1346
1354
|
label, labelStyle, labelShowBg, labelBgStyle, labelBgPadding, labelBgBorderRadius,
|
|
1355
|
+
// AnchorProps
|
|
1356
|
+
edgeUpdaterRadius,
|
|
1347
1357
|
// position
|
|
1348
1358
|
sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, selected, elementsSelectable, hidden, isFocusable, onClick, onDoubleClick, onContextMenu, onMouseEnter, onMouseMove, onMouseLeave, onEdgeUpdate, onEdgeUpdateStart, onEdgeUpdateEnd, } = props;
|
|
1359
|
+
const position = {
|
|
1360
|
+
sourceX,
|
|
1361
|
+
sourceY,
|
|
1362
|
+
targetX,
|
|
1363
|
+
targetY,
|
|
1364
|
+
sourcePosition,
|
|
1365
|
+
targetPosition,
|
|
1366
|
+
};
|
|
1367
|
+
const sourceAndTargetIds = {
|
|
1368
|
+
source,
|
|
1369
|
+
sourcePort,
|
|
1370
|
+
target,
|
|
1371
|
+
targetPort,
|
|
1372
|
+
};
|
|
1373
|
+
const isConnecting = className === 'react-diagram__connection';
|
|
1374
|
+
if (isConnecting) {
|
|
1375
|
+
document
|
|
1376
|
+
.querySelector('path')
|
|
1377
|
+
?.classList.add('react-diagram__connection-path');
|
|
1378
|
+
return (jsx(EdgeComponent, { ...sourceAndTargetIds, ...position, id: id, data: data, style: style, selected: selected }));
|
|
1379
|
+
}
|
|
1380
|
+
const store = useStoreApi();
|
|
1349
1381
|
const edgeRef = useRef(null);
|
|
1350
1382
|
const [updating, setUpdating] = useState(false);
|
|
1351
|
-
const store = useStoreApi();
|
|
1352
1383
|
const markerStartUrl = useMemo(() => `url(#${getMarkerId(markerStart, rfId)})`, [markerStart, rfId]);
|
|
1353
1384
|
const markerEndUrl = useMemo(() => `url(#${getMarkerId(markerEnd, rfId)})`, [markerEnd, rfId]);
|
|
1354
1385
|
if (hidden) {
|
|
@@ -1399,12 +1430,6 @@ const wrapEdge = (EdgeComponent) => {
|
|
|
1399
1430
|
{ selected, inactive },
|
|
1400
1431
|
]);
|
|
1401
1432
|
const marker = { markerStart: markerStartUrl, markerEnd: markerEndUrl };
|
|
1402
|
-
const sourceAndTargetIds = {
|
|
1403
|
-
source,
|
|
1404
|
-
sourcePort,
|
|
1405
|
-
target,
|
|
1406
|
-
targetPort,
|
|
1407
|
-
};
|
|
1408
1433
|
const labelProps = {
|
|
1409
1434
|
label,
|
|
1410
1435
|
labelStyle,
|
|
@@ -1413,14 +1438,6 @@ const wrapEdge = (EdgeComponent) => {
|
|
|
1413
1438
|
labelBgPadding,
|
|
1414
1439
|
labelBgBorderRadius,
|
|
1415
1440
|
};
|
|
1416
|
-
const position = {
|
|
1417
|
-
sourceX,
|
|
1418
|
-
sourceY,
|
|
1419
|
-
targetX,
|
|
1420
|
-
targetY,
|
|
1421
|
-
sourcePosition,
|
|
1422
|
-
targetPosition,
|
|
1423
|
-
};
|
|
1424
1441
|
const events = {
|
|
1425
1442
|
onClick: onEdgeClick,
|
|
1426
1443
|
onDoubleClick: onEdgeDoubleClick,
|
|
@@ -1429,11 +1446,17 @@ const wrapEdge = (EdgeComponent) => {
|
|
|
1429
1446
|
onMouseMove: onEdgeMouseMove,
|
|
1430
1447
|
onMouseLeave: onEdgeMouseLeave,
|
|
1431
1448
|
};
|
|
1432
|
-
return (
|
|
1449
|
+
return (jsx("g", { ...events, ref: edgeRef, className: wrapperClassName, tabIndex: isFocusable ? 0 : undefined, role: isFocusable ? 'button' : undefined, "aria-label": ariaLabel === null
|
|
1433
1450
|
? undefined
|
|
1434
1451
|
: ariaLabel
|
|
1435
1452
|
? ariaLabel
|
|
1436
|
-
: `Edge from ${source} to ${target}`, "aria-describedby": isFocusable ? `${ARIA_EDGE_DESC_KEY}-${rfId}` : undefined, children:
|
|
1453
|
+
: `Edge from ${source} to ${target}`, "aria-describedby": isFocusable ? `${ARIA_EDGE_DESC_KEY}-${rfId}` : undefined, children: !updating && (jsxs(Fragment, { children: [jsx(EdgeComponent, { ...sourceAndTargetIds, ...marker, ...labelProps, ...position, id: id, data: data, style: style, selected: selected }), jsx(Anchor, { position: sourcePosition, centerX: sourceX, centerY: sourceY, radius: edgeUpdaterRadius, onMouseDown: handleEdgeUpdater('target'),
|
|
1454
|
+
// onMouseEnter={console.log}
|
|
1455
|
+
// onMouseOut={console.log}
|
|
1456
|
+
type: "source" }), jsx(Anchor, { position: targetPosition, centerX: targetX, centerY: targetY, radius: edgeUpdaterRadius, onMouseDown: handleEdgeUpdater('source'),
|
|
1457
|
+
// onMouseEnter={console.log}
|
|
1458
|
+
// onMouseOut={console.log}
|
|
1459
|
+
type: "target" })] })) }));
|
|
1437
1460
|
};
|
|
1438
1461
|
EdgeWrapper.displayName = 'EdgeWrapper';
|
|
1439
1462
|
return memo(EdgeWrapper);
|
|
@@ -1533,77 +1556,77 @@ const selector$2 = (s) => ({
|
|
|
1533
1556
|
nodeInternals: s.nodeInternals,
|
|
1534
1557
|
onError: s.onError,
|
|
1535
1558
|
});
|
|
1536
|
-
function EdgeRenderer({ rfId, edgeTypes,
|
|
1559
|
+
function EdgeRenderer({ rfId, edgeTypes, noPanClassName, edgeUpdaterRadius, onEdgeClick, onEdgeDoubleClick, onEdgeContextMenu, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, onEdgeUpdate, onEdgeUpdateStart, onEdgeUpdateEnd, }) {
|
|
1537
1560
|
const { edges, width, height, nodeInternals } = useStore(selector$2, shallow);
|
|
1538
|
-
return (jsxs(
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1561
|
+
return (jsxs("svg", { width: width || '100vw', height: height || '100vh', className: "react-diagram__edges react-diagram__container", children: [jsx(MarkerComponent$1, { defaultColor: "#000000", rfId: rfId }), jsx("g", { children: edges.map((edge) => {
|
|
1562
|
+
const { data, type,
|
|
1563
|
+
// elProps
|
|
1564
|
+
id, className, style, ariaLabel,
|
|
1565
|
+
// sourceAndTargetIds
|
|
1566
|
+
source, sourcePort, target, targetPort,
|
|
1567
|
+
// marker
|
|
1568
|
+
markerEnd, markerStart,
|
|
1569
|
+
// labelProps
|
|
1570
|
+
label, labelStyle, labelShowBg, labelBgStyle, labelBgPadding, labelBgBorderRadius, } = edge;
|
|
1571
|
+
const [sourceNodeRect, sourcePortBounds, sourceIsValid] = getNodeData(nodeInternals.get(source));
|
|
1572
|
+
const [targetNodeRect, targetPortBounds, targetIsValid] = getNodeData(nodeInternals.get(target));
|
|
1573
|
+
if (!sourceIsValid || !targetIsValid) {
|
|
1574
|
+
return null;
|
|
1575
|
+
}
|
|
1576
|
+
const edgeType = type || 'straight';
|
|
1577
|
+
const EdgeComponent = edgeTypes[edgeType] || edgeTypes.default;
|
|
1578
|
+
const targetNodePorts = targetPortBounds.target;
|
|
1579
|
+
const sourcePortInfo = getPort(sourcePortBounds.source, sourcePort);
|
|
1580
|
+
const targetPortInfo = getPort(targetNodePorts, targetPort);
|
|
1581
|
+
const sourcePosition = sourcePortInfo?.position || Position.Bottom;
|
|
1582
|
+
const targetPosition = targetPortInfo?.position || Position.Top;
|
|
1583
|
+
const isFocusable = !!edge.focusable;
|
|
1584
|
+
if (!sourcePortInfo || !targetPortInfo) {
|
|
1585
|
+
return null;
|
|
1586
|
+
}
|
|
1587
|
+
const elProps = {
|
|
1588
|
+
id,
|
|
1589
|
+
className: cc([className, noPanClassName]),
|
|
1590
|
+
style,
|
|
1591
|
+
ariaLabel,
|
|
1592
|
+
};
|
|
1593
|
+
const sourceAndTargetIds = {
|
|
1594
|
+
source,
|
|
1595
|
+
sourcePort,
|
|
1596
|
+
target,
|
|
1597
|
+
targetPort,
|
|
1598
|
+
};
|
|
1599
|
+
const marker = {
|
|
1600
|
+
markerEnd,
|
|
1601
|
+
markerStart,
|
|
1602
|
+
};
|
|
1603
|
+
const labelProps = {
|
|
1604
|
+
label,
|
|
1605
|
+
labelStyle,
|
|
1606
|
+
labelShowBg,
|
|
1607
|
+
labelBgStyle,
|
|
1608
|
+
labelBgPadding,
|
|
1609
|
+
labelBgBorderRadius,
|
|
1610
|
+
};
|
|
1611
|
+
const edgePositions = getEdgePositions(sourceNodeRect, sourcePortInfo, sourcePosition, targetNodeRect, targetPortInfo, targetPosition);
|
|
1612
|
+
const position = {
|
|
1613
|
+
...edgePositions,
|
|
1614
|
+
sourcePosition,
|
|
1615
|
+
targetPosition,
|
|
1616
|
+
};
|
|
1617
|
+
const events = {
|
|
1618
|
+
onClick: onEdgeClick,
|
|
1619
|
+
onDoubleClick: onEdgeDoubleClick,
|
|
1620
|
+
onContextMenu: onEdgeContextMenu,
|
|
1621
|
+
onMouseEnter: onEdgeMouseEnter,
|
|
1622
|
+
onMouseMove: onEdgeMouseMove,
|
|
1623
|
+
onMouseLeave: onEdgeMouseLeave,
|
|
1624
|
+
onEdgeUpdate,
|
|
1625
|
+
onEdgeUpdateStart,
|
|
1626
|
+
onEdgeUpdateEnd,
|
|
1627
|
+
};
|
|
1628
|
+
return (jsx(EdgeComponent, { ...elProps, ...sourceAndTargetIds, ...marker, ...labelProps, ...position, ...events, rfId: rfId, type: edgeType, data: data, isFocusable: isFocusable, edgeUpdaterRadius: edgeUpdaterRadius }, id));
|
|
1629
|
+
}) })] }));
|
|
1607
1630
|
}
|
|
1608
1631
|
EdgeRenderer.displayName = 'EdgeRenderer';
|
|
1609
1632
|
var EdgeRenderer$1 = memo(EdgeRenderer);
|
|
@@ -1614,7 +1637,7 @@ const oppositePosition = {
|
|
|
1614
1637
|
[Position.Top]: Position.Bottom,
|
|
1615
1638
|
[Position.Bottom]: Position.Top,
|
|
1616
1639
|
};
|
|
1617
|
-
function ConnectionPath({
|
|
1640
|
+
function ConnectionPath({ nodeId, portType, edge, Component, EdgeWrapper, }) {
|
|
1618
1641
|
const { fromNode, toX, toY } = useStore(useCallback((s) => ({
|
|
1619
1642
|
fromNode: s.nodeInternals.get(nodeId),
|
|
1620
1643
|
toX: (s.connectionPosition.x - s.transform[0]) / s.transform[2],
|
|
@@ -1639,36 +1662,31 @@ function ConnectionPath({ style, nodeId, portType }) {
|
|
|
1639
1662
|
if (!fromPosition || !toPosition) {
|
|
1640
1663
|
return null;
|
|
1641
1664
|
}
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
sourceX: fromX,
|
|
1647
|
-
sourceY: fromY,
|
|
1648
|
-
sourcePosition: fromPosition,
|
|
1649
|
-
targetX: toX,
|
|
1650
|
-
targetY: toY,
|
|
1651
|
-
targetPosition: toPosition,
|
|
1652
|
-
};
|
|
1653
|
-
[dAttr] = getStepPath({
|
|
1654
|
-
...pathParams,
|
|
1655
|
-
borderRadius: 0,
|
|
1656
|
-
});
|
|
1657
|
-
return (jsx("path", { d: dAttr, fill: "none", className: "react-diagram__connection-path", style: style }));
|
|
1665
|
+
if (Component) {
|
|
1666
|
+
return (jsx(Component, { fromNode: fromNode, fromPort: fromPort, fromX: fromX, fromY: fromY, toX: toX, toY: toY, fromPosition: fromPosition, toPosition: toPosition }));
|
|
1667
|
+
}
|
|
1668
|
+
return (jsx(EdgeWrapper, { id: edge.id, className: "react-diagram__connection", type: edge.type || 'default', source: edge.source, target: edge.target, isFocusable: false, sourceX: fromX, sourceY: fromY, targetX: toX, targetY: toY, sourcePosition: fromPosition, targetPosition: toPosition }));
|
|
1658
1669
|
}
|
|
1659
1670
|
ConnectionPath.displayName = 'ConnectionPath';
|
|
1660
1671
|
|
|
1661
1672
|
const selector$1 = (s) => ({
|
|
1673
|
+
edges: s.edges,
|
|
1662
1674
|
nodeId: s.connectionNodeId,
|
|
1663
1675
|
portType: s.connectionPortType,
|
|
1664
1676
|
});
|
|
1665
|
-
function
|
|
1666
|
-
const { nodeId, portType } = useStore(selector$1, shallow);
|
|
1677
|
+
function ConnectionLineRenderer({ containerStyle, edgeTypes, component, }) {
|
|
1678
|
+
const { nodeId, portType, edges } = useStore(selector$1, shallow);
|
|
1667
1679
|
const isValid = !!(nodeId && portType);
|
|
1668
1680
|
if (!isValid) {
|
|
1669
1681
|
return null;
|
|
1670
1682
|
}
|
|
1671
|
-
|
|
1683
|
+
const selectedEdge = edges.find((edge) => edge[portType] === nodeId);
|
|
1684
|
+
if (!selectedEdge)
|
|
1685
|
+
return null;
|
|
1686
|
+
const EdgeWrapper = selectedEdge?.type
|
|
1687
|
+
? edgeTypes[selectedEdge.type]
|
|
1688
|
+
: edgeTypes.default;
|
|
1689
|
+
return (jsx("svg", { style: containerStyle, className: "react-diagram__container react-diagram__connection-line", children: jsx("g", { className: "react-diagram__connection", children: jsx(ConnectionPath, { nodeId: nodeId, portType: portType, edge: selectedEdge, Component: component, EdgeWrapper: EdgeWrapper }) }) }));
|
|
1672
1690
|
}
|
|
1673
1691
|
|
|
1674
1692
|
function DiagramView({ rfId,
|
|
@@ -1677,8 +1695,10 @@ noPanClassName, panning, defaultViewport, multiSelectionKeyCode, onMove, onMoveS
|
|
|
1677
1695
|
// NodeRenderer props
|
|
1678
1696
|
onlyRenderVisibleElements, disableKeyboardA11y, noDragClassName, nodeOrigin, nodeTypes, onNodeClick, onNodeDoubleClick, onNodeContextMenu, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave,
|
|
1679
1697
|
// EdgeRenderer props
|
|
1680
|
-
edgeTypes, onEdgeClick, onEdgeDoubleClick, onEdgeContextMenu, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, onEdgeUpdate, onEdgeUpdateStart, onEdgeUpdateEnd,
|
|
1681
|
-
|
|
1698
|
+
edgeTypes, edgeUpdaterRadius, onEdgeClick, onEdgeDoubleClick, onEdgeContextMenu, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, onEdgeUpdate, onEdgeUpdateStart, onEdgeUpdateEnd,
|
|
1699
|
+
// ConnectionLineWrapper
|
|
1700
|
+
ConnectionLineContainerStyle, ConnectionLineComponent, }) {
|
|
1701
|
+
return (jsxs(DiagramRenderer$1, { multiSelectionKeyCode: multiSelectionKeyCode, noPanClassName: noPanClassName, panning: panning, defaultViewport: defaultViewport, onMove: onMove, onMoveStart: onMoveStart, onMoveEnd: onMoveEnd, children: [jsx(NodeRenderer$1, { rfId: rfId, nodeTypes: nodeTypes, onlyRenderVisibleElements: onlyRenderVisibleElements, disableKeyboardA11y: disableKeyboardA11y, nodeOrigin: nodeOrigin, noDragClassName: noDragClassName, noPanClassName: noPanClassName, onNodeClick: onNodeClick, onNodeDoubleClick: onNodeDoubleClick, onNodeContextMenu: onNodeContextMenu, onNodeMouseEnter: onNodeMouseEnter, onNodeMouseMove: onNodeMouseMove, onNodeMouseLeave: onNodeMouseLeave }), jsx(EdgeRenderer$1, { rfId: rfId, edgeTypes: edgeTypes, noPanClassName: noPanClassName, edgeUpdaterRadius: edgeUpdaterRadius, onEdgeClick: onEdgeClick, onEdgeDoubleClick: onEdgeDoubleClick, onEdgeContextMenu: onEdgeContextMenu, onEdgeMouseEnter: onEdgeMouseEnter, onEdgeMouseMove: onEdgeMouseMove, onEdgeMouseLeave: onEdgeMouseLeave, onEdgeUpdate: onEdgeUpdate, onEdgeUpdateStart: onEdgeUpdateStart, onEdgeUpdateEnd: onEdgeUpdateEnd }), jsx(ConnectionLineRenderer, { edgeTypes: edgeTypes, containerStyle: ConnectionLineContainerStyle, component: ConnectionLineComponent })] }));
|
|
1682
1702
|
}
|
|
1683
1703
|
DiagramView.displayName = 'DiagramView';
|
|
1684
1704
|
var DiagramView$1 = memo(DiagramView);
|
|
@@ -1709,7 +1729,7 @@ function useDirectStoreUpdater(key, value, setState) {
|
|
|
1709
1729
|
}
|
|
1710
1730
|
}, [value]);
|
|
1711
1731
|
}
|
|
1712
|
-
const StoreUpdater = ({ nodes, onNodesChange, onNodeDrag, onNodeDragStart, onNodeDragEnd, edges, onEdgesChange, gridStep, elevateNodesOnSelect, nodesDraggable, autoPanOnNodeDrag, autoPanOnConnect, onConnect, onConnectStart, onConnectEnd, onError, nodeExtent, translateExtent, minZoom, maxZoom, }) => {
|
|
1732
|
+
const StoreUpdater = ({ nodes, onNodesChange, onNodeDrag, onNodeDragStart, onNodeDragEnd, edges, onEdgesChange, gridStep, elevateNodesOnSelect, nodesDraggable, autoPanOnNodeDrag, autoPanOnConnect, connectionRadius, onConnect, onConnectStart, onConnectEnd, onError, nodeExtent, translateExtent, minZoom, maxZoom, }) => {
|
|
1713
1733
|
const { setNodes, setEdges, setNodeExtent, setTranslateExtent, setMinZoom, setMaxZoom, } = useStore(selector, shallow);
|
|
1714
1734
|
const store = useStoreApi();
|
|
1715
1735
|
useDirectStoreUpdater('gridStep', gridStep, store.setState);
|
|
@@ -1723,6 +1743,7 @@ const StoreUpdater = ({ nodes, onNodesChange, onNodeDrag, onNodeDragStart, onNod
|
|
|
1723
1743
|
useDirectStoreUpdater('nodesDraggable', nodesDraggable, store.setState);
|
|
1724
1744
|
useDirectStoreUpdater('autoPanOnNodeDrag', autoPanOnNodeDrag, store.setState);
|
|
1725
1745
|
useDirectStoreUpdater('autoPanOnConnect', autoPanOnConnect, store.setState);
|
|
1746
|
+
useDirectStoreUpdater('connectionRadius', connectionRadius, store.setState);
|
|
1726
1747
|
useDirectStoreUpdater('onNodesChange', onNodesChange, store.setState);
|
|
1727
1748
|
useDirectStoreUpdater('onNodeDrag', onNodeDrag, store.setState);
|
|
1728
1749
|
useDirectStoreUpdater('onNodeDragStart', onNodeDragStart, store.setState);
|
|
@@ -2361,6 +2382,7 @@ const initialState = {
|
|
|
2361
2382
|
autoPanOnConnect: true,
|
|
2362
2383
|
nodeExtent: infiniteExtent,
|
|
2363
2384
|
translateExtent: infiniteExtent,
|
|
2385
|
+
connectionRadius: 20,
|
|
2364
2386
|
onError: devWarn,
|
|
2365
2387
|
};
|
|
2366
2388
|
|
|
@@ -2558,13 +2580,13 @@ const defaultEdgeTypes = {
|
|
|
2558
2580
|
};
|
|
2559
2581
|
const ReactDiagram = forwardRef(({ id,
|
|
2560
2582
|
// DiagramView props
|
|
2561
|
-
panning = true, minZoom, maxZoom, translateExtent, nodeExtent, defaultViewport = initViewport, multiSelectionKeyCode, onlyRenderVisibleElements = false, disableKeyboardA11y = false, noDragClassName = 'nodrag', noPanClassName = 'nopan', nodeOrigin = initNodeOrigin, nodeTypes = defaultNodeTypes, onNodeClick, onNodeDoubleClick, onNodeContextMenu, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, edgeTypes = defaultEdgeTypes, onEdgeClick, onEdgeDoubleClick, onEdgeContextMenu, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, onEdgeUpdate, onEdgeUpdateStart, onEdgeUpdateEnd, onMove, onMoveStart, onMoveEnd,
|
|
2583
|
+
panning = true, minZoom, maxZoom, translateExtent, nodeExtent, defaultViewport = initViewport, multiSelectionKeyCode, onlyRenderVisibleElements = false, disableKeyboardA11y = false, noDragClassName = 'nodrag', noPanClassName = 'nopan', nodeOrigin = initNodeOrigin, nodeTypes = defaultNodeTypes, onNodeClick, onNodeDoubleClick, onNodeContextMenu, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, edgeTypes = defaultEdgeTypes, edgeUpdaterRadius, onEdgeClick, onEdgeDoubleClick, onEdgeContextMenu, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, onEdgeUpdate, onEdgeUpdateStart, onEdgeUpdateEnd, onMove, onMoveStart, onMoveEnd, ConnectionLineContainerStyle, ConnectionLineComponent,
|
|
2562
2584
|
// StoreUpdater props
|
|
2563
|
-
nodes, edges, nodesDraggable, elevateNodesOnSelect, autoPanOnNodeDrag, autoPanOnConnect, onNodesChange, onNodeDrag, onNodeDragStart, onNodeDragEnd, onEdgesChange, onConnect, onConnectStart, onConnectEnd, onError, }, ref) => {
|
|
2585
|
+
nodes, edges, nodesDraggable, elevateNodesOnSelect, autoPanOnNodeDrag, autoPanOnConnect, connectionRadius, onNodesChange, onNodeDrag, onNodeDragStart, onNodeDragEnd, onEdgesChange, onConnect, onConnectStart, onConnectEnd, onError, }, ref) => {
|
|
2564
2586
|
const rfId = id || '1';
|
|
2565
2587
|
const nodeTypesWrapped = useNodeOrEdgeTypes(nodeTypes, createNodeTypes);
|
|
2566
2588
|
const edgeTypesWrapped = useNodeOrEdgeTypes(edgeTypes, createEdgeTypes);
|
|
2567
|
-
return (jsx("div", { ref: ref, className: "react-diagram", children: jsxs(Wrapper, { children: [jsx(DiagramView$1, { rfId: rfId, panning: panning, defaultViewport: defaultViewport, multiSelectionKeyCode: multiSelectionKeyCode, onlyRenderVisibleElements: onlyRenderVisibleElements, disableKeyboardA11y: disableKeyboardA11y, noDragClassName: noDragClassName, noPanClassName: noPanClassName, nodeOrigin: nodeOrigin, nodeTypes: nodeTypesWrapped, edgeTypes: edgeTypesWrapped, onNodeClick: onNodeClick, onNodeDoubleClick: onNodeDoubleClick, onNodeContextMenu: onNodeContextMenu, onNodeMouseEnter: onNodeMouseEnter, onNodeMouseMove: onNodeMouseMove, onNodeMouseLeave: onNodeMouseLeave, onEdgeClick: onEdgeClick, onEdgeDoubleClick: onEdgeDoubleClick, onEdgeContextMenu: onEdgeContextMenu, onEdgeMouseEnter: onEdgeMouseEnter, onEdgeMouseMove: onEdgeMouseMove, onEdgeMouseLeave: onEdgeMouseLeave, onEdgeUpdate: onEdgeUpdate, onEdgeUpdateStart: onEdgeUpdateStart, onEdgeUpdateEnd: onEdgeUpdateEnd, onMove: onMove, onMoveStart: onMoveStart, onMoveEnd: onMoveEnd }), jsx(StoreUpdater, { rfId: rfId, nodes: nodes, edges: edges, nodesDraggable: nodesDraggable, elevateNodesOnSelect: elevateNodesOnSelect, autoPanOnNodeDrag: autoPanOnNodeDrag, autoPanOnConnect: autoPanOnConnect, nodeExtent: nodeExtent, translateExtent: translateExtent, minZoom: minZoom, maxZoom: maxZoom, onNodesChange: onNodesChange, onNodeDrag: onNodeDrag, onNodeDragStart: onNodeDragStart, onNodeDragEnd: onNodeDragEnd, onEdgesChange: onEdgesChange, onConnect: onConnect, onConnectStart: onConnectStart, onConnectEnd: onConnectEnd, onError: onError })] }) }));
|
|
2589
|
+
return (jsx("div", { ref: ref, className: "react-diagram", children: jsxs(Wrapper, { children: [jsx(DiagramView$1, { rfId: rfId, panning: panning, defaultViewport: defaultViewport, multiSelectionKeyCode: multiSelectionKeyCode, onlyRenderVisibleElements: onlyRenderVisibleElements, disableKeyboardA11y: disableKeyboardA11y, noDragClassName: noDragClassName, noPanClassName: noPanClassName, nodeOrigin: nodeOrigin, nodeTypes: nodeTypesWrapped, edgeTypes: edgeTypesWrapped, edgeUpdaterRadius: edgeUpdaterRadius, ConnectionLineContainerStyle: ConnectionLineContainerStyle, ConnectionLineComponent: ConnectionLineComponent, onNodeClick: onNodeClick, onNodeDoubleClick: onNodeDoubleClick, onNodeContextMenu: onNodeContextMenu, onNodeMouseEnter: onNodeMouseEnter, onNodeMouseMove: onNodeMouseMove, onNodeMouseLeave: onNodeMouseLeave, onEdgeClick: onEdgeClick, onEdgeDoubleClick: onEdgeDoubleClick, onEdgeContextMenu: onEdgeContextMenu, onEdgeMouseEnter: onEdgeMouseEnter, onEdgeMouseMove: onEdgeMouseMove, onEdgeMouseLeave: onEdgeMouseLeave, onEdgeUpdate: onEdgeUpdate, onEdgeUpdateStart: onEdgeUpdateStart, onEdgeUpdateEnd: onEdgeUpdateEnd, onMove: onMove, onMoveStart: onMoveStart, onMoveEnd: onMoveEnd }), jsx(StoreUpdater, { rfId: rfId, nodes: nodes, edges: edges, nodesDraggable: nodesDraggable, elevateNodesOnSelect: elevateNodesOnSelect, autoPanOnNodeDrag: autoPanOnNodeDrag, autoPanOnConnect: autoPanOnConnect, connectionRadius: connectionRadius, nodeExtent: nodeExtent, translateExtent: translateExtent, minZoom: minZoom, maxZoom: maxZoom, onNodesChange: onNodesChange, onNodeDrag: onNodeDrag, onNodeDragStart: onNodeDragStart, onNodeDragEnd: onNodeDragEnd, onEdgesChange: onEdgesChange, onConnect: onConnect, onConnectStart: onConnectStart, onConnectEnd: onConnectEnd, onError: onError })] }) }));
|
|
2568
2590
|
});
|
|
2569
2591
|
ReactDiagram.displayName = 'ReactDiagram';
|
|
2570
2592
|
|
|
@@ -2578,4 +2600,4 @@ function createUseItemsState(applyChanges) {
|
|
|
2578
2600
|
const useNodesState = createUseItemsState(applyNodeChanges);
|
|
2579
2601
|
const useEdgesState = createUseItemsState(applyEdgeChanges);
|
|
2580
2602
|
|
|
2581
|
-
export { BaseEdge, MarkerType, Port$1 as Port, Position,
|
|
2603
|
+
export { BaseEdge, BezierEdge, MarkerType, Port$1 as Port, Position, ReactDiagramProvider, StepEdge, addEdge, boxToRect, clamp, ReactDiagram as default, getBezierPath, getStepPath, internalsSymbol, isEdge, isNode, rectToBox, updateEdge, useEdgesState, useNodesState };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialState.d.ts","sourceRoot":"","sources":["../react-diagram/packages/src/store/initialState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,eAAO,MAAM,cAAc,EAAE,gBAG5B,CAAC;AAEF,QAAA,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"initialState.d.ts","sourceRoot":"","sources":["../react-diagram/packages/src/store/initialState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,eAAO,MAAM,cAAc,EAAE,gBAG5B,CAAC;AAEF,QAAA,MAAM,YAAY,EAAE,iBAmCnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/dist/esm/types/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { HTMLAttributes, MouseEvent as ReactMouseEvent } from 'react';
|
|
2
|
-
import { CoordinateExtent, GridStep, Viewport, Node, Edge, OnNodesChange, OnEdgesChange, OnConnect, OnConnectStart, OnConnectEnd, OnMove, OnError } from '.';
|
|
1
|
+
import type { CSSProperties, HTMLAttributes, MouseEvent as ReactMouseEvent } from 'react';
|
|
2
|
+
import { CoordinateExtent, GridStep, Viewport, Node, Edge, OnNodesChange, OnEdgesChange, OnConnect, OnConnectStart, OnConnectEnd, OnMove, OnError, ConnectionLineComponent } from '.';
|
|
3
3
|
import { NodeDragHandler } from '../hooks/useDrag/type';
|
|
4
4
|
import { KeyCode } from '../hooks/useGlobalKeyHandler';
|
|
5
5
|
import { NodeOrigin } from '../components/Node/utils';
|
|
@@ -19,6 +19,10 @@ export type ReactDiagramProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
19
19
|
nodeTypes?: NodeTypes;
|
|
20
20
|
edges?: Edge[];
|
|
21
21
|
edgeTypes?: EdgeTypes;
|
|
22
|
+
edgeUpdaterRadius?: number;
|
|
23
|
+
ConnectionLineContainerStyle?: CSSProperties;
|
|
24
|
+
ConnectionLineComponent?: ConnectionLineComponent;
|
|
25
|
+
connectionRadius?: number;
|
|
22
26
|
onNodesChange?: OnNodesChange;
|
|
23
27
|
onNodeClick?: NodeMouseHandler;
|
|
24
28
|
onNodeDoubleClick?: NodeMouseHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../react-diagram/packages/src/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../react-diagram/packages/src/types/core.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../react-diagram/packages/src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AAEvB,cAAc,kCAAkC,CAAC;AAGjD,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../react-diagram/packages/src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AAEvB,cAAc,kCAAkC,CAAC;AAGjD,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0CAA0C,CAAC"}
|
|
@@ -11,7 +11,7 @@ export declare const getNodePositionWithOrigin: (node: Node | undefined, nodeOri
|
|
|
11
11
|
export declare const getNodesInside: (nodeInternals: NodeInternals, rect: Rect, [tx, ty, tScale]?: Transform, partially?: boolean, excludeNonSelectableNodes?: boolean, nodeOrigin?: NodeOrigin) => Node[];
|
|
12
12
|
export declare const getMarkerId: (marker: EdgeMarker | undefined, rfId?: string) => string;
|
|
13
13
|
export declare const addEdge: (edgeParams: Edge | Connection, edges: Edge[]) => Edge[];
|
|
14
|
-
export declare const updateEdge: (
|
|
14
|
+
export declare const updateEdge: (originEdge: Edge, newConnection: Connection, edges: Edge[], options?: {
|
|
15
15
|
shouldReplaceId: boolean;
|
|
16
16
|
}) => Edge[];
|
|
17
17
|
export declare const getRectOfNodes: (nodes: Node[], nodeOrigin?: NodeOrigin) => Rect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../react-diagram/packages/src/utils/graph.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,eAAO,MAAM,MAAM,YAAa,IAAI,GAAG,UAAU,GAAG,IAAI,6CACc,CAAC;AAEvE,eAAO,MAAM,MAAM,YAAa,IAAI,GAAG,UAAU,GAAG,IAAI,yBACX,CAAC;AAE9C,eAAO,MAAM,yBAAyB,SAC7B,IAAI,GAAG,SAAS,8BAEtB,UAAU,GAAG;IAAE,gBAAgB,EAAE,UAAU,CAAA;CA6B7C,CAAC;AAEF,eAAO,MAAM,cAAc,uCAElB,IAAI,sHAMV,IAAI,EA2CN,CAAC;AAEF,eAAO,MAAM,WAAW,WACb,UAAU,GAAG,SAAS,SACvB,MAAM,KACb,MAeF,CAAC;AAQF,eAAO,MAAM,OAAO,eACL,IAAI,GAAG,UAAU,SACtB,IAAI,EAAE,KACb,IAAI,EAqBN,CAAC;AAEF,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../react-diagram/packages/src/utils/graph.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,eAAO,MAAM,MAAM,YAAa,IAAI,GAAG,UAAU,GAAG,IAAI,6CACc,CAAC;AAEvE,eAAO,MAAM,MAAM,YAAa,IAAI,GAAG,UAAU,GAAG,IAAI,yBACX,CAAC;AAE9C,eAAO,MAAM,yBAAyB,SAC7B,IAAI,GAAG,SAAS,8BAEtB,UAAU,GAAG;IAAE,gBAAgB,EAAE,UAAU,CAAA;CA6B7C,CAAC;AAEF,eAAO,MAAM,cAAc,uCAElB,IAAI,sHAMV,IAAI,EA2CN,CAAC;AAEF,eAAO,MAAM,WAAW,WACb,UAAU,GAAG,SAAS,SACvB,MAAM,KACb,MAeF,CAAC;AAQF,eAAO,MAAM,OAAO,eACL,IAAI,GAAG,UAAU,SACtB,IAAI,EAAE,KACb,IAAI,EAqBN,CAAC;AAEF,eAAO,MAAM,UAAU,eACR,IAAI,iBACD,UAAU,SAClB,IAAI,EAAE;;MAEb,IAAI,EAiBN,CAAC;AAEF,eAAO,MAAM,cAAc,UACjB,IAAI,EAAE,8BAEb,IAyBF,CAAC"}
|
package/dist/style.css
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
text-align: center;
|
|
22
22
|
|
|
23
|
-
border:
|
|
23
|
+
border: 2px solid #000000;
|
|
24
24
|
background-color: #ffffff;
|
|
25
25
|
box-sizing: border-box;
|
|
26
26
|
}
|
|
@@ -41,6 +41,38 @@
|
|
|
41
41
|
cursor: grab;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
.react-diagram__node-default.selected {
|
|
45
|
+
border-radius: 3px;
|
|
46
|
+
|
|
47
|
+
border: 2px dotted transparent;
|
|
48
|
+
background-image: linear-gradient(to right, #ffffff, #ffffff),
|
|
49
|
+
conic-gradient(
|
|
50
|
+
from var(--angle),
|
|
51
|
+
#d53e33 0deg 90deg,
|
|
52
|
+
#fbb300 90deg 180deg,
|
|
53
|
+
#377af5 180deg 270deg,
|
|
54
|
+
#399953 270deg 360deg
|
|
55
|
+
);
|
|
56
|
+
background-origin: border-box;
|
|
57
|
+
background-clip: padding-box, border-box;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@property --angle {
|
|
61
|
+
syntax: '<angle>';
|
|
62
|
+
initial-value: 0deg;
|
|
63
|
+
inherits: false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@keyframes rotate {
|
|
67
|
+
to {
|
|
68
|
+
--angle: 360deg;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.react-diagram__node.selected {
|
|
73
|
+
animation: rotate 4s linear infinite;
|
|
74
|
+
}
|
|
75
|
+
|
|
44
76
|
.react-diagram__port {
|
|
45
77
|
width: 6px;
|
|
46
78
|
height: 6px;
|
|
@@ -93,11 +125,6 @@
|
|
|
93
125
|
fill: none;
|
|
94
126
|
}
|
|
95
127
|
|
|
96
|
-
.react-diagram__edgeupdater {
|
|
97
|
-
cursor: move;
|
|
98
|
-
pointer-events: all;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
128
|
.react-diagram__edge-text-bg {
|
|
102
129
|
fill: white;
|
|
103
130
|
}
|
|
@@ -117,6 +144,16 @@
|
|
|
117
144
|
font-size: 10px;
|
|
118
145
|
}
|
|
119
146
|
|
|
147
|
+
.react-diagram__edge-updater {
|
|
148
|
+
cursor: move;
|
|
149
|
+
pointer-events: all;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.react-diagram__edge-updater:hover {
|
|
153
|
+
transition: 0.2s;
|
|
154
|
+
fill: #000000;
|
|
155
|
+
}
|
|
156
|
+
|
|
120
157
|
.react-diagram__viewport {
|
|
121
158
|
transform-origin: 0 0;
|
|
122
159
|
z-index: 2;
|
|
@@ -128,7 +165,8 @@
|
|
|
128
165
|
cursor: grab;
|
|
129
166
|
}
|
|
130
167
|
|
|
131
|
-
.react-diagram .react-diagram__edges
|
|
168
|
+
.react-diagram .react-diagram__edges,
|
|
169
|
+
.react-diagram .react-diagram__connection-line {
|
|
132
170
|
pointer-events: none;
|
|
133
171
|
overflow: visible;
|
|
134
172
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MouseEvent as ReactMouseEvent, SVGAttributes } from 'react';
|
|
2
2
|
import { Position } from '../../types';
|
|
3
|
-
type EventNames = 'onMouseDown'
|
|
3
|
+
type EventNames = 'onMouseDown';
|
|
4
4
|
type AnchorEvents = {
|
|
5
5
|
[H in EventNames]?: (event: ReactMouseEvent<SVGGElement, MouseEvent>) => void;
|
|
6
6
|
};
|
|
@@ -11,6 +11,6 @@ interface AnchorProps extends SVGAttributes<SVGGElement>, AnchorEvents {
|
|
|
11
11
|
radius?: number;
|
|
12
12
|
type: string;
|
|
13
13
|
}
|
|
14
|
-
declare function Anchor({ position, centerX, centerY, radius, onMouseDown,
|
|
14
|
+
declare function Anchor({ position, centerX, centerY, radius, onMouseDown, type, }: AnchorProps): import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
export default Anchor;
|
|
16
16
|
//# sourceMappingURL=Anchor.d.ts.map
|