UNPKG

@talend/react-components

Version:
53 lines (52 loc) 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _propTypes = _interopRequireDefault(require("prop-types")); var _react = require("react"); var _classnames = _interopRequireDefault(require("classnames")); var _Action = _interopRequireDefault(require("../../Actions/Action")); var _CellWithIconModule = _interopRequireDefault(require("./CellWithIcon.module.scss")); var _jsxRuntime = require("react/jsx-runtime"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /** * Cell renderer that displays text + icon */class CellWithIcon extends _react.Component { shouldComponentUpdate(nextProps) { return this.props.cellData !== nextProps.cellData || this.props.columnData !== nextProps.columnData || this.props.rowData !== nextProps.rowData; } render() { const { columnData, rowData, cellData } = this.props; const action = columnData.getIcon(rowData); return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", { className: (0, _classnames.default)('cell-icon-container', _CellWithIconModule.default['cell-icon-container']), children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", { children: cellData }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { className: (0, _classnames.default)('icon-container', _CellWithIconModule.default['icon-container']), children: action && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Action.default, { ...action, hideLabel: true, link: true }) })] }); } } CellWithIcon.displayName = 'VirtualizedList(CellWithIcon)'; CellWithIcon.propTypes = { // The cell value : props.rowData[props.dataKey] cellData: _propTypes.default.string, // Can be any object rowData: _propTypes.default.object, columnData: _propTypes.default.shape({ getIcon: _propTypes.default.func.isRequired }).isRequired }; var _default = exports.default = CellWithIcon; //# sourceMappingURL=CellWithIcon.component.js.map