import React, { memo } from "react"; import { NodeProps as ReactFlowNodeV9Props } from "react-flow-renderer"; import { NodeProps as ReactFlowNodeV12Props, Position } from "@xyflow/react"; import Tooltip from "../../../components/Tooltip/Tooltip"; import { ReacFlowVersionSupportProps, useReactFlowVersion } from "../versionsupport"; import { NodeContent, NodeContentProps } from "./NodeContent"; interface NodeDefaultExtendedProps extends ReacFlowVersionSupportProps { /** * Contains all properties for our implementation of the React-Flow node. * For details pls see the `NodeContent` element documentation. */ data: NodeContentProps; } type NodeDefaultV9Props = NodeDefaultExtendedProps & ReactFlowNodeV9Props; type NodeDefaultV12Props = NodeDefaultExtendedProps & Omit; export type NodeDefaultProps = NodeDefaultV9Props | NodeDefaultV12Props; /** * The `NodeDefault` element manages the display of React-Flow nodes. * This element cannot be used directly, it must be connected via a `nodeTypes` definition and all properties need to be routed through the `elements` property items inside the `ReactFlow` container. * @see https://reactflow.dev/docs/api/nodes/ */ export const NodeDefault = memo((node: NodeDefaultProps) => { const { flowVersion, data, targetPosition = Position.Left, sourcePosition = Position.Right, isConnectable = true, selected, } = node; const evaluateFlowVersion = useReactFlowVersion(); const flowVersionCheck = flowVersion || evaluateFlowVersion; const nodeEl = ( ); if (!selected && data?.minimalShape !== "none" && !!data?.getMinimalTooltipData) { const tooltipData = data?.getMinimalTooltipData(node); if (!!tooltipData.label || !!tooltipData.content) { return ( {tooltipData.label &&
{tooltipData.label}
} {tooltipData.content &&
{tooltipData.content}
} } > {nodeEl}
); } } return nodeEl; }); export default NodeDefault;