import React from 'react'
import PropTypes from 'prop-types'

import styles from './styles.scss'
import BEMModule from 'utils/bem'
const bem = new BEMModule(styles)

const ColumnTextValue = ({align, children, className, tag: Tag, value}) => {
    const rootClassNames = bem.classNames(
        'c-column-text-value',
        {[align]: true},
        className
    )

    return (
        <Tag className={rootClassNames}>
            {value}
            {children}
        </Tag>
    )
}

ColumnTextValue.propTypes = {
    align: PropTypes.oneOf(['left', 'center', 'right']),
    children: PropTypes.node,
    className: PropTypes.string,
    tag: PropTypes.string,
    value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
}

ColumnTextValue.defaultProps = {
    align: 'center',
    tag: 'td',
}

export default React.memo(ColumnTextValue)
