import React__default from 'react';
import { Checkbox } from '../../Field/checkbox/Checkbox.js';
import { CheckboxCell, Td } from '../styles.js';
import { getRowIdByIdentifier } from '../utils.js';

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

export { TableBody as default };
