import React from 'react' import { type TooltipContentProps } from './ChartTooltipTypes' import styles from './_charts-tooltip.module.scss' import { c } from '../../../translations/LibraryTranslationService' const TooltipBodyContent: React.FC = ({ data, config, hasColumnHeader, rowTotalData, type = 'default', }) => { const cellStyles = `${styles.cellWrap} ${hasColumnHeader ? styles.cellWrapTable : ''}` return ( {hasColumnHeader ? ( {config.map((column) => ( // column.name is the unique key for the table column headers ))} ) : null} {data.map((row, rowIndex) => ( {config.map((column, columnIndex) => ( ))} ))} {/* TODO: Move the 'total' row logic to a separate component. */} {/* Not all variants of the table have a 'total' row */} {rowTotalData ? ( {config.slice(1).map((column, columnIndex) => ( ))} ) : null}
{column.label}
{(type === 'swatchLine' || (type === 'table' && row?.swatchLineColor)) && columnIndex === 0 ? (
) : ( <> )}
{row[column.name]}
{c('total')} {rowTotalData[column.name]}
) } export default TooltipBodyContent