UNPKG

@atlaskit/dynamic-table

Version:

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

52 lines (51 loc) 2.61 kB
import _extends from "@babel/runtime/helpers/extends"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; import _inherits from "@babel/runtime/helpers/inherits"; function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } import React from 'react'; import withSortedPageRows from '../hoc/with-sorted-page-rows'; import TableRow from './table-row'; // eslint-disable-next-line @repo/internal/react/no-class-components var BodyComponent = /*#__PURE__*/function (_React$Component) { function BodyComponent() { _classCallCheck(this, BodyComponent); return _callSuper(this, BodyComponent, arguments); } _inherits(BodyComponent, _React$Component); return _createClass(BodyComponent, [{ key: "render", value: function render() { var _this$props = this.props, pageRows = _this$props.pageRows, head = _this$props.head, isFixedSize = _this$props.isFixedSize, highlightedRowIndex = _this$props.highlightedRowIndex, testId = _this$props.testId, forwardedRef = _this$props.forwardedRef; return /*#__PURE__*/React.createElement("tbody", { "data-testid": testId && "".concat(testId, "--body"), ref: forwardedRef }, pageRows.map(function (row, rowIndex) { return /*#__PURE__*/React.createElement(TableRow, { head: head, isFixedSize: isFixedSize, key: row.key || rowIndex, row: row, isHighlighted: row.isHighlighted || !!highlightedRowIndex && (typeof highlightedRowIndex === 'number' ? highlightedRowIndex === rowIndex : highlightedRowIndex.indexOf(rowIndex) > -1), testId: testId }); })); } }]); }(React.Component); var Body = withSortedPageRows( /*#__PURE__*/React.forwardRef(function (props, ref) { return /*#__PURE__*/React.createElement(BodyComponent, _extends({}, props, { forwardedRef: ref })); })); // eslint-disable-next-line @repo/internal/react/require-jsdoc export default Body;