File size: 778 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { Annotation } from '@nivo/annotations'
import { ComputedNode, InputLink, InputNode, NetworkSvgProps } from './types'
import { useNodeAnnotations } from './hooks'

interface NetworkNodeAnnotationsProps<Node extends InputNode, Link extends InputLink> {
    nodes: ComputedNode<Node>[]
    annotations: NonNullable<NetworkSvgProps<Node, Link>['annotations']>
}

export const NetworkNodeAnnotations = <Node extends InputNode, Link extends InputLink>({
    nodes,
    annotations,
}: NetworkNodeAnnotationsProps<Node, Link>) => {
    const boundAnnotations = useNodeAnnotations<Node>(nodes, annotations)

    return (
        <>
            {boundAnnotations.map((annotation, i) => (
                <Annotation key={i} {...annotation} />
            ))}
        </>
    )
}