UNPKG

@confi/conflux-react-ui-test-package

Version:

Modern and minimalist React UI library.

41 lines (36 loc) 1.24 kB
import React from 'react'; import { useTableContext } from './table-context'; var TableCell = function TableCell(_ref) { var columns = _ref.columns, row = _ref.row, rowIndex = _ref.rowIndex, emptyText = _ref.emptyText, onCellClick = _ref.onCellClick; var _useTableContext = useTableContext(), removeRow = _useTableContext.removeRow; var actions = { remove: function remove() { removeRow && removeRow(rowIndex); } }; /* eslint-disable react/jsx-no-useless-fragment */ return /*#__PURE__*/React.createElement(React.Fragment, null, columns.map(function (column, index) { var data = { row: rowIndex, column: index, rowValue: row }; var rowLabel = row[column.value]; var cellValue = !rowLabel ? emptyText : typeof rowLabel === 'function' ? rowLabel(actions, data) : rowLabel; return /*#__PURE__*/React.createElement("td", { key: "row-td-".concat(index, "-").concat(column.value), onClick: function onClick() { return onCellClick(cellValue, rowIndex, index); } }, /*#__PURE__*/React.createElement("div", { className: "cell" }, cellValue)); })); /* eslint-enable */ }; export default React.memo(TableCell);