import type { ReactNode } from 'react'; import type { ChartDatapoint } from '../../core/types/chart-data.js'; import type { SankeyLink as D3SankeyLink, SankeyNode as D3SankeyNode } from '../vendor/d3-sankey/index.js'; /** A node in the resolved domain graph model (accessor join output). * @internal **/ export interface SankeyGraphNode extends Record { id: string; /** Resolved from `nodeLabelAccessor`, falling back to the node id. */ label: string; /** Resolved from `columnAccessor`; undefined when topology-inferred. */ column?: number; } /** A directed edge in the resolved domain graph model. */ export interface SankeyGraphLink extends Record { source: string; target: string; value: number; } /** The resolved domain graph model exposed via the data context. */ export interface SankeyGraphModel { nodes: SankeyGraphNode[]; links: SankeyGraphLink[]; } /** * A node after the d3-sankey layout pass: carries the domain fields plus the * computed geometry (`x0`/`x1`/`y0`/`y1`, `depth`, `value`, link references). */ export type SankeyLayoutNode = D3SankeyNode>; /** * A link after the d3-sankey layout pass: `source`/`target` are resolved to * node objects and `width`/`y0`/`y1` describe the ribbon geometry. * @internal */ export type SankeyLayoutLink = D3SankeyLink>; /** The computed layout model exposed via the layout context. */ export interface SankeyLayoutModel { nodes: SankeyLayoutNode[]; links: SankeyLayoutLink[]; } /** * A neighbor node entry in a Sankey node tooltip, describing one upstream or * downstream connection. * @internal */ export type SankeyNeighborEntry = { /** * The neighbor node's display label. */ label: string; /** * The neighbor node's id — used to resolve its color via useNodeColors. */ nodeId: string; /** * The link value, formatted with formatter and unit. */ formattedValue: string; /** * `link.value / totalNodeFlow * 100`, formatted as `"X.X%"`. `totalNodeFlow` * is the sum of all incoming link values (for a source entry) or all * outgoing link values (for a target entry) of the hovered node. */ formattedPercentage: string; /** * The neighbor node's total inflow (sum of all its incoming link values). */ totalInflow: number; /** * The neighbor node's total outflow (sum of all its outgoing link values). */ totalOutflow: number; /** * The original consumer-provided datapoint record for the neighbor node. */ data: ChartDatapoint | undefined; }; /** * Data provided to the custom tooltip render function for a hovered node. * @internal */ export type SankeyNodeTooltipPayload = { type: 'SankeyNode'; /** * The hovered node's unique identifier — used to resolve its color via useNodeColors. */ nodeId: string; /** * The hovered node's display label. */ label: string; /** * The hovered node's resolved color. */ color: string; /** * The hovered node's total inflow (sum of all incoming link values). */ totalInflow: number; /** * The hovered node's total outflow (sum of all outgoing link values). */ totalOutflow: number; /** * The hovered node's total volume (max of inflow and outflow), formatted with the chart's * formatter and unit. Handles source-boundary nodes (no inflow) and sink-boundary nodes * (no outflow) correctly by taking the non-zero side. */ formattedValue: string; /** * The hovered node's total inflow (sum of all incoming link values), formatted with the * chart's formatter and unit. */ formattedInflow: string; /** * The hovered node's total outflow (sum of all outgoing link values), formatted with the * chart's formatter and unit. */ formattedOutflow: string; /** * Direct upstream neighbors (nodes flowing INTO this node, one level to the left). */ sources: SankeyNeighborEntry[]; /** * Direct downstream neighbors (nodes this node flows TO, one level to the right). */ targets: SankeyNeighborEntry[]; /** * The original consumer-provided datapoint record for this node, containing any * extra fields beyond `id`, `label`, and `column`. */ data: ChartDatapoint | undefined; }; /** * Data provided to the custom tooltip render function for a hovered link. * @internal */ export type SankeyLinkTooltipPayload = { type: 'SankeyLink'; /** The id of the link's source node. */ sourceId: string; /** The label of the link's source node. */ sourceLabel: string; /** The id of the link's target node. */ targetId: string; /** The label of the link's target node. */ targetLabel: string; /** The raw link value. */ value: number; /** The link value, formatted with `formatter` and `unit`. */ formattedValue: string; /** * The consumer-provided datapoint for this link, carrying every field of the * corresponding row of the `data` prop. D3-internal geometry fields are excluded. */ data: ChartDatapoint; }; /** * Discriminated union of all Sankey tooltip payloads passed to the custom * tooltip render function. * @internal */ export type SankeyTooltipPayload = SankeyNodeTooltipPayload | SankeyLinkTooltipPayload; /** * Props for the `SankeyChart.Tooltip` slot. * @internal */ export type SankeyChartTooltipProps = { /** When true, suppresses the tooltip entirely. */ hidden?: boolean; /** Custom render function receiving the hovered shape's typed payload. */ children?: (payload: SankeyTooltipPayload) => ReactNode; }; /** @internal */ export type SankeyCustomTooltipConfig = { hidden?: boolean; template?: SankeyChartTooltipProps['children']; }; //# sourceMappingURL=sankey-internal.d.ts.map