UNPKG

@talend/react-components

Version:
41 lines 1.27 kB
import PropTypes from 'prop-types'; import { defaultColumnConfiguration } from '../Content.component'; import { jsx as _jsx } from "react/jsx-runtime"; const { cellRenderer: DefaultCellRenderer } = defaultColumnConfiguration; function CellMappedData(props) { const { cellData, columnData } = props; const { valuesMap, separator = ', ', ...restColumnData } = columnData; let cellContent; const getMappedValue = value => { const mappedValue = valuesMap[value] || value; return mappedValue !== undefined ? mappedValue : null; }; if (Array.isArray(cellData)) { cellContent = cellData.map(getMappedValue).filter(value => value !== undefined && value !== null && value !== '').sort((a, b) => a.toString().localeCompare(b.toString())).join(separator); } else { cellContent = getMappedValue(cellData); } return /*#__PURE__*/_jsx(DefaultCellRenderer, { ...props, cellData: cellContent, columnData: restColumnData }); } CellMappedData.propTypes = { cellData: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), columnData: PropTypes.shape({ valuesMap: PropTypes.object, separator: PropTypes.string }) }; export default CellMappedData; //# sourceMappingURL=CellMappedData.component.js.map