<commit_before>import React, { memo, ReactNode } from 'react'
// @ts-ignore
import { useTheme, useValueFormatter } from '@nivo/core'
import { Chip } from './Chip'

interface BasicTooltipProps {
    id: ReactNode
    value?: number | string
    color?: string
    enableChip?: boolean
    renderContent?: () => JSX.Element
}

export const BasicTooltip = memo<BasicTooltipProps>(
    ({ 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 = (
                <div style={theme.tooltip.basic}>
                    {enableChip && <Chip color={color} style={theme.tooltip.chip} />}
                    {value !== undefined ? (
                        <span>
                            {id}: <strong>{isNaN(value) ? String(value) : value}</strong>
                        </span>
                    ) : (
                        id
                    )}
                </div>
            )
        }

        return <div style={theme.tooltip.container}>{content}</div>
    }
)

/*
BasicTooltip.displayName = 'BasicTooltip'
BasicTooltip.propTypes = {
    id: PropTypes.node.isRequired,
    value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
    enableChip: PropTypes.bool.isRequired,
    color: PropTypes.string,
    format: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
    renderContent: PropTypes.func,
}
BasicTooltip.defaultProps = {
    enableChip: false,
}
*/<commit_msg>feat(tooltip): adapt BasicTooltip for new typings<commit_after>import React, { memo, ReactNode } from 'react'
// @ts-ignore
import { useTheme, DataFormatter, useValueFormatter } from '@nivo/core'
import { Chip } from './Chip'

interface BasicTooltipProps {
    id: ReactNode
    value?: number | string | Date
    format?: DataFormatter
    color?: string
    enableChip?: boolean
    renderContent?: () => JSX.Element
}

export const BasicTooltip = memo<BasicTooltipProps>(
    ({ 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 = (
                <div style={theme.tooltip.basic}>
                    {enableChip && <Chip color={color!} style={theme.tooltip.chip} />}
                    {value !== undefined ? (
                        <span>
                            {id}: <strong>{`${value}`}</strong>
                        </span>
                    ) : (
                        id
                    )}
                </div>
            )
        }

        return <div style={theme.tooltip.container}>{content}</div>
    }
)

/*
BasicTooltip.displayName = 'BasicTooltip'
BasicTooltip.propTypes = {
    id: PropTypes.node.isRequired,
    value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
    enableChip: PropTypes.bool.isRequired,
    color: PropTypes.string,
    format: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
    renderContent: PropTypes.func,
}
BasicTooltip.defaultProps = {
    enableChip: false,
}
*/
{'fraction_non_alphanumeric': 0.1230479267635972, 'fraction_numerical': 0.0, 'mean_word_length': 1.9839357429718876, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2748892', 'n_tokens_mistral': 991, 'n_tokens_neox': 979, 'n_words': 221}