
META-INF.resources.js.components.ModelBuilder.Edges.DefaultObjectRelationshipEdge.tsx Maven / Gradle / Ivy
The newest version!
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
import React, {useMemo} from 'react';
import {
EdgeProps,
Node,
getEdgeCenter,
getSmoothStepPath,
useStoreState,
} from 'react-flow-renderer';
import {ObjectRelationshipEdgeData} from '../types';
import {getEdgeParams} from '../utils';
import ObjectRelationshipEdge from './ObjectRelationshipEdge';
export default function DefaultObjectRelationshipEdge({
data,
id: edgeId,
source,
target,
}: EdgeProps) {
const {nodes} = useStoreState((state) => state);
const sourceNode = useMemo(
() => nodes.find((node) => node.id === source),
[source, nodes]
) as Node;
const targetNode = useMemo(
() => nodes.find((node) => node.id === target),
[target, nodes]
) as Node;
const {sourcePos, sourceX, sourceY, targetPos, targetX, targetY} =
getEdgeParams(sourceNode, targetNode);
const edgePath = getSmoothStepPath({
sourcePosition: sourcePos,
sourceX,
sourceY,
targetPosition: targetPos,
targetX,
targetY,
});
const reverseEdgePath = getSmoothStepPath({
sourcePosition: targetPos,
sourceX: targetX,
sourceY: targetY,
targetPosition: sourcePos,
targetX: sourceX,
targetY: sourceY,
});
const [edgeCenterX, edgeCenterY] = getEdgeCenter({
sourceX,
sourceY,
targetX,
targetY,
});
return (
);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy