UNPKG

@atlaskit/dynamic-table

Version:

A dynamic table displays rows of data with built-in pagination, sorting, and re-ordering functionality.

50 lines (49 loc) • 1.44 kB
import _extends from "@babel/runtime/helpers/extends"; import React from 'react'; import { TableBodyCell } from '../styled/table-cell'; import { TableBodyRow } from '../styled/table-row'; const Row = ({ row, head, testId, isFixedSize, 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. const { cells, key: rowKey, ...restRowProps } = row; return /*#__PURE__*/React.createElement(TableBodyRow, _extends({}, restRowProps, { isHighlighted: isHighlighted }, isHighlighted ? { 'data-ts--dynamic-table--table-row--highlighted': true } : null, { testId: row.testId || testId && `${testId}--row-${rowKey}` }), cells.map((cell, cellIndex) => { const { content, testId: cellTestId, key: _cellKey, ...restCellProps } = cell; const { shouldTruncate, width } = (head || { cells: [] }).cells[cellIndex] || {}; return /*#__PURE__*/React.createElement(TableBodyCell, _extends({ "data-testid": cellTestId || testId && `${testId}--cell-${cellIndex}` }, restCellProps, { isFixedSize: isFixedSize, key: cellIndex, shouldTruncate: shouldTruncate, width: width }), content); })); }; // eslint-disable-next-line @repo/internal/react/require-jsdoc export default Row;