'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
var Checkbox = require('../../Field/checkbox/Checkbox.js');
var styles = require('../styles.js');
var utils = require('../utils.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

function TableBody({ filteredRows, onRowClick, selectedRows, disabledRows, columns, rowIdentifier, 'data-testid': dataTestId, 'data-trackid': dataTrackId, }) {
    return (React__default['default'].createElement("tbody", { "data-testid": dataTestId, "data-trackid": dataTrackId }, filteredRows.map((row, rowIndex) => {
        const rowId = utils.getRowIdByIdentifier(row, rowIdentifier || '');
        const isChecked = !!(rowIdentifier &&
            selectedRows &&
            selectedRows.includes(rowId));
        const isDisabled = !!(rowIdentifier &&
            disabledRows &&
            disabledRows.includes(rowId));
        return (React__default['default'].createElement("tr", { key: `row_${rowIndex}`, "data-selected": isChecked, "data-disabled": isDisabled, role: "row" },
            typeof onRowClick === 'function' && (React__default['default'].createElement(styles.CheckboxCell, { as: "td", role: "cell" },
                React__default['default'].createElement(Checkbox.Checkbox, { onChange: (e) => onRowClick(e.target.value), value: rowId, name: "select-row", checked: isChecked, disabled: isDisabled }))),
            columns.map((column, cellIndex) => !column.hideCell && (React__default['default'].createElement(styles.Td, { key: `cell_${cellIndex}`, textAlign: column.textAlign, role: "cell" }, column.renderCell(row))))));
    })));
}

exports['default'] = TableBody;
