import { Selector } from 'react-redux' ; import { ChartType } from '../../..' ; import { GlobalChartState } from '../../../../state/chart_state' ; import { createCustomCachedSelector } from '../../../../state/create_selector' ; import { getSettingsSpecSelector } from '../../../../state/selectors/get_settings_specs' ; import { isPickedCells } from '../../layout/types/viewmodel_types' ; import { getSpecOrNull } from './heatmap_spec' ; import { getPickedShapes } from './picked_shapes' ; internal export function createOnElementOutCaller ( ) { let prevPickedShapes = null ; let selector = null ; return ( state ) => { if ( selector === null && state . chartType === ChartType . Heatmap ) { selector = createCustomCachedSelector ( [ getSpecOrNull , getPickedShapes , getSettingsSpecSelector ] , ( spec , pickedShapes , settings ) : void => { if ( ! spec ) { return ; } if ( ! settings . onElementOut ) { return ; } const nextPickedShapes = isPickedCells ( pickedShapes ) ? pickedShapes . length : 0 ; if ( prevPickedShapes !== null && prevPickedShapes > 0 && nextPickedShapes === 0 ) { settings . onElementOut ( ) ; } prevPickedShapes = nextPickedShapes ; } ) ; } if ( selector ) { selector ( state ) ; } } ; }