import type { TextProps } from '@nivo/text'; import type { SankeyNodeDatum } from '@nivo/sankey'; import { animated } from '@react-spring/web'; import { FlowTypeIcon } from './FlowTypeIcon'; import type { VisitorFlowLink, VisitorFlowNode } from './types'; const LABEL_WIDTH = 168; const LABEL_HEIGHT = 18; type FlowSankeyLabelProps = TextProps & { node: SankeyNodeDatum; }; /** * Renders a Sankey outside-label with a category icon for faster scanning. * * @param props - Nivo label component properties. * @param props.node - Sankey node carrying flow metadata. * @param props.children - Truncated label text from Nivo. * @param props.textAnchor - Horizontal alignment relative to the node. * @param props.transform - Animated SVG transform from Nivo. * @return Icon + text label group. */ export const FlowSankeyLabel = ({ node, children, textAnchor, transform }: FlowSankeyLabelProps ) => { const isEnd = 'end' === textAnchor; return ( {/* * HTML inside SVG foreignObject; xmlns omitted because React's * div typings reject it and HTML documents treat this as HTML. */}
{children}
); };