import React, { createContext, forwardRef, useCallback, } from 'react';
import { VirtualGridRepeaterBase } from './VirtualGridRepeaterBase';
import { VirtualTableRow } from './VirtualTableRow';
import { TableForceRenderIndexes } from './TableForceRenderIndexes';
import { useVirtualGridStateContext } from './VirtualGridStateContext';
import { VirtualTableRowMutated } from './VirtualTableRowMutated';
const OuterElementPropsContext = createContext({});
export function VirtualTableRepeater({ children }) {
    const gridState = useVirtualGridStateContext();
    const renderItem = useCallback((index, { style, itemKey, index2d } = {}) => {
        return (React.createElement(VirtualTableRowMutated, { index: index, style: style, itemKey: itemKey, rowIndex: index2d?.rowIndex }, children));
    }, [children]);
    return (React.createElement(VirtualGridRepeaterBase, { innerElementType: TableForceRenderIndexes, outerElementType: OuterElement, gridState: gridState, renderItem: renderItem }, VirtualTableRow));
}
// wrap with forwardRef to avoid warning in console about ref being passed to a function component without `forwardRef`.
// react-window passes the ref - https://github.com/bvaughn/react-window/blob/6ff5694ac810617515acf74401ba68fe2951133b/src/createGridComponent.js#L464
export const OuterElement = forwardRef(({ children, ...rest }, _ref) => {
    return (React.createElement(OuterElementPropsContext.Provider, { value: rest }, children));
});
//# sourceMappingURL=VirtualTableRepeater.js.map