@atlaskit/dynamic-table
Version:
A dynamic table displays rows of data with built-in pagination, sorting, and re-ordering functionality.
47 lines (46 loc) • 1.87 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["cells", "key"],
_excluded2 = ["content", "testId", "key"];
import React from 'react';
import { TableBodyCell } from '../styled/table-cell';
import { TableBodyRow } from '../styled/table-row';
var Row = function Row(_ref) {
var row = _ref.row,
head = _ref.head,
testId = _ref.testId,
isFixedSize = _ref.isFixedSize,
isHighlighted = _ref.isHighlighted;
// `key` is pulled out so it isn't spread into JSX (React 19 warns about that). The parent
// already applies it to this row, and each cell gets an explicit `key` below.
var cells = row.cells,
rowKey = row.key,
restRowProps = _objectWithoutProperties(row, _excluded);
return /*#__PURE__*/React.createElement(TableBodyRow, _extends({}, restRowProps, {
isHighlighted: isHighlighted
}, isHighlighted ? {
'data-ts--dynamic-table--table-row--highlighted': true
} : null, {
testId: row.testId || testId && "".concat(testId, "--row-").concat(rowKey)
}), cells.map(function (cell, cellIndex) {
var content = cell.content,
cellTestId = cell.testId,
_cellKey = cell.key,
restCellProps = _objectWithoutProperties(cell, _excluded2);
var _ref2 = (head || {
cells: []
}).cells[cellIndex] || {},
shouldTruncate = _ref2.shouldTruncate,
width = _ref2.width;
return /*#__PURE__*/React.createElement(TableBodyCell, _extends({
"data-testid": cellTestId || testId && "".concat(testId, "--cell-").concat(cellIndex)
}, restCellProps, {
isFixedSize: isFixedSize,
key: cellIndex,
shouldTruncate: shouldTruncate,
width: width
}), content);
}));
};
// eslint-disable-next-line @repo/internal/react/require-jsdoc
export default Row;