import { jsx } from 'react/jsx-runtime';
import { TableRow } from './TableRow.js';
import { getRowId } from './Table.utils.js';
import { useTableExpansion } from './hooks/useTableExpansion.js';
import { useTableSelection } from './hooks/useTableSelection.js';

function TableBodyComponent({ data, columns, rowKey, expandedRowRender, expandedRows = [], onExpandedRowsChange, selectable, selectionType, selectedRows = [], onSelectionChange, freezeFirstColumn, freezeLastColumn, theme, }) {
    const { handleExpandChange } = useTableExpansion({
        expandedRows,
        onExpandedRowsChange,
    });
    const { handleSelectionChange } = useTableSelection({
        data,
        rowKey,
        selectionType,
        selectedRows,
        onSelectionChange,
    });
    return (jsx("tbody", { children: data.map((row, index) => {
            const rowId = getRowId(row, index, rowKey);
            return (jsx(TableRow, { row: row, rowId: rowId, columns: columns, expandedRowRender: expandedRowRender, isExpanded: expandedRows.includes(rowId), onExpandChange: (expanded) => handleExpandChange(rowId, expanded), selectable: selectable, selectionType: selectionType, isSelected: selectedRows.includes(rowId), onSelectionChange: (selected) => handleSelectionChange(rowId, selected), freezeFirstColumn: freezeFirstColumn, freezeLastColumn: freezeLastColumn, theme: theme }, rowId));
        }) }));
}
const TableBody = TableBodyComponent;

export { TableBody };
