UNPKG

@talend/react-components

Version:
70 lines (69 loc) 1.89 kB
import PropTypes from 'prop-types'; import { Component } from 'react'; import { withTranslation } from 'react-i18next'; import Icon from '../../Icon'; import I18N_DOMAIN_COMPONENTS from '../../constants'; import getDefaultT from '../../translate'; import { getTheme } from '../../theme'; import theme from './CellBoolean.module.scss'; import { jsx as _jsx } from "react/jsx-runtime"; const css = getTheme(theme); export const DISPLAY_MODE = { TEXT: 'TEXT', ICON: 'ICON' }; /** * Cell renderer that displays a boolean */ class CellBoolean extends Component { shouldComponentUpdate(nextProps) { return this.props.cellData !== nextProps.cellData; } render() { const { cellData, t, columnData } = this.props; if (columnData.displayMode === DISPLAY_MODE.ICON) { if (cellData) { return /*#__PURE__*/_jsx("div", { className: css('cell-boolean-container'), children: /*#__PURE__*/_jsx(Icon, { name: "talend-check-circle", title: t('CAD_LIST_MANDATORY_REQUIRED', { defaultValue: 'Required' }) }) }); } return null; } if (cellData === true) { return t('BOOLEAN_VALUE_TRUE', { defaultValue: 'Yes' }); } else if (cellData === false) { return t('BOOLEAN_VALUE_FALSE', { defaultValue: 'No' }); } return null; } } CellBoolean.displayName = 'VirtualizedList(CellBoolean)'; CellBoolean.propTypes = { cellData: PropTypes.bool, t: PropTypes.func, columnData: PropTypes.shape({ displayMode: PropTypes.oneOf(Object.values(DISPLAY_MODE)) }).isRequired }; CellBoolean.defaultProps = { t: getDefaultT(), columnData: { displayMode: DISPLAY_MODE.TEXT } }; export default withTranslation(I18N_DOMAIN_COMPONENTS)(CellBoolean); //# sourceMappingURL=CellBoolean.component.js.map