import { jsx as _jsx } from "react/jsx-runtime";
import { Fragment, useContext } from "react";
import { TableContext } from "./tableContext";
import { Row } from "./row";
export const TBody = (props)=>{
    const { dataSource, columns, expandedRowKeys, canExpand, toggleExpandRow } = useContext(TableContext);
    return /*#__PURE__*/ _jsx("tbody", {
        className: "orderly-ui-table-body",
        children: dataSource?.map((record, index)=>{
            const key = typeof props.generatedRowKey === "function" ? props.generatedRowKey(record, index) : `${index}`; /// `record.ts_${record.price}_${record.size}_${index}`;
            const row = /*#__PURE__*/ _jsx(Row, {
                rowKey: key,
                index: index,
                columns: columns,
                record: record,
                canExpand: canExpand,
                justified: props.justified,
                bordered: props.bordered,
                onRow: props.onRow,
                onToggleExpand: toggleExpandRow,
                expanded: !!expandedRowKeys?.includes(key),
                expandRowRender: props.expandRowRender
            }, key);
            if (typeof props.renderRowContainer === "function") {
                return /*#__PURE__*/ _jsx(Fragment, {
                    children: props.renderRowContainer(record, index, row)
                }, key);
            }
            return row;
        })
    });
};

//# sourceMappingURL=tbody.js.map