UNPKG

@atlaskit/dynamic-table

Version:

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

54 lines (52 loc) • 2.25 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _react = _interopRequireDefault(require("react")); var _tableCell = require("../styled/table-cell"); var _tableRow = require("../styled/table-row"); var _excluded = ["cells", "key"], _excluded2 = ["content", "testId", "key"]; 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 = (0, _objectWithoutProperties2.default)(row, _excluded); return /*#__PURE__*/_react.default.createElement(_tableRow.TableBodyRow, (0, _extends2.default)({}, 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 = (0, _objectWithoutProperties2.default)(cell, _excluded2); var _ref2 = (head || { cells: [] }).cells[cellIndex] || {}, shouldTruncate = _ref2.shouldTruncate, width = _ref2.width; return /*#__PURE__*/_react.default.createElement(_tableCell.TableBodyCell, (0, _extends2.default)({ "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 var _default = exports.default = Row;