import { processPointerMove } from '../../utils/hover-state' ; import { getOffset } from '../../utils/common' ; import { SeriesList , SeriesRef , TransformedPoint , TargetList , NotifyPointerMoveFn , TooltipParameters , TooltipReference , Rect , } from '../../types' ; internal export const getParameters = ( series , target ) : TooltipParameters => { const currentSeries = series . find ( ( { name } ) => target . series === name ) ! ; const item = currentSeries . points . find ( point => point . index === target . point ) as TransformedPoint ; return { element : currentSeries . getPointTransformer . getTargetElement ( item ) , text : `${ item . value }` , } ; } ; internal export const createReference = ( rect , rootRef ) : TooltipReference => ( { clientWidth : 0 , clientHeight : 0 , getBoundingClientRect ( ) { const offset = getOffset ( rootRef . current ! ) ; const htmlRect = rootRef . current ! . ownerDocument ! . documentElement . getBoundingClientRect ( ) ; const left = rect [ 0 ] + offset [ 0 ] + htmlRect . left ; const right = rect [ 2 ] + offset [ 0 ] + htmlRect . left ; const top = rect [ 1 ] + offset [ 1 ] + htmlRect . top ; const bottom = rect [ 3 ] + offset [ 1 ] + htmlRect . top ; return { left , top , right , bottom , width : right - left , height : bottom - top , } ; } , } ) ; internal export const processHandleTooltip = ( targets , currentTarget , onTargetItemChange ? ) => { const filterTargets = targets . filter ( target => target . point !== undefined ) ; return processPointerMove ( filterTargets , currentTarget , onTargetItemChange ) ; } ;