import { memo, ReactNode } from 'react' import { ValueFormat, useValueFormatter } from '@nivo/core' import { useTheme } from '@nivo/theming' import { Chip } from './Chip' export interface BasicTooltipProps { id: ReactNode value?: number | string | Date format?: ValueFormat color?: string enableChip?: boolean /** * @deprecated This should be replaced by custom tooltip components. */ renderContent?: () => JSX.Element } export const BasicTooltip = memo( ({ id, value: _value, format, enableChip = false, color, renderContent }) => { const theme = useTheme() const formatValue = useValueFormatter(format) let content: JSX.Element if (typeof renderContent === 'function') { content = renderContent() } else { let value = _value if (formatValue !== undefined && value !== undefined) { value = formatValue(value) } content = (
{enableChip && } {value !== undefined ? ( {id}: {`${value}`} ) : ( id )}
) } return (
{content}
) } )