![JAR search and dependency download from the Maven repository](/logo.png)
components.widgets.Table.cells.TextCell.TextCell.jsx Maven / Gradle / Ivy
/**
* Created by emamoshin on 27.09.2017.
*/
import React from 'react'
import PropTypes from 'prop-types'
import get from 'lodash/get'
import classNames from 'classnames'
import isUndefined from 'lodash/isUndefined'
import withTooltip from '../../withTooltip'
import { Text } from '../../../../snippets/Typography/Text/Text'
import { Icon } from '../../../../snippets/Icon/Icon'
import { iconPositions } from './cellTypes'
import SubText from './SubText'
/** Описание */
function TextCell({
fieldKey,
icon,
iconPosition,
id,
model,
preLine,
subTextFieldKey,
subTextFormat,
visible,
forwardedRef,
...rest
}) {
const mainText = model && get(model, fieldKey || id)
if ((!Number.isFinite(mainText) && !mainText) || !visible) { return null }
return (
{icon && }
{subTextFieldKey ? (
) : null}
)
}
TextCell.propTypes = {
/**
* Модель данных
*/
model: PropTypes.object,
/**
* Ключ значения из модели
*/
fieldKey: PropTypes.string,
/**
* Класс
*/
className: PropTypes.string,
/**
* Формат
*/
format: PropTypes.string,
/**
* Ключ значения сабтекста из модели
*/
subTextFieldKey: PropTypes.string,
/**
* Формат сабтекста
*/
subTextFormat: PropTypes.string,
/**
* Флаг видимости
*/
visible: PropTypes.bool,
/**
* Иконка
*/
icon: PropTypes.string,
/**
* Местоположение текста
*/
iconPosition: PropTypes.oneOf(Object.values(iconPositions)),
preLine: PropTypes.bool,
id: PropTypes.string,
}
TextCell.defaultProps = {
visible: true,
iconPosition: iconPositions.LEFT,
}
export { TextCell }
export default withTooltip(TextCell)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy