'use client';
import React from 'react';
import { useTableColumns } from '../TableColumns/index.js';
import { TableCellProvider } from './TableCellProvider/index.js';
const baseClass = 'table';
export const Table = ({ columns: columnsFromProps, customCellContext, data })=>{
    const { columns: columnsFromContext } = useTableColumns();
    const columns = columnsFromProps || columnsFromContext;
    const activeColumns = columns?.filter((col)=>col?.active);
    if (!activeColumns || activeColumns.length === 0) {
        return /*#__PURE__*/ React.createElement("div", null, "No columns selected");
    }
    return /*#__PURE__*/ React.createElement("div", {
        className: baseClass
    }, /*#__PURE__*/ React.createElement("table", {
        cellPadding: "0",
        cellSpacing: "0"
    }, /*#__PURE__*/ React.createElement("thead", null, /*#__PURE__*/ React.createElement("tr", null, activeColumns.map((col, i)=>/*#__PURE__*/ React.createElement("th", {
            id: `heading-${col.accessor}`,
            key: i
        }, col.components.Heading)))), /*#__PURE__*/ React.createElement("tbody", null, data && data.map((row, rowIndex)=>/*#__PURE__*/ React.createElement("tr", {
            className: `row-${rowIndex + 1}`,
            key: rowIndex
        }, activeColumns.map((col, colIndex)=>{
            return /*#__PURE__*/ React.createElement("td", {
                className: `cell-${col.accessor}`,
                key: colIndex
            }, /*#__PURE__*/ React.createElement(TableCellProvider, {
                cellData: row[col.accessor],
                cellProps: col?.cellProps,
                columnIndex: colIndex,
                customCellContext: customCellContext,
                rowData: row
            }, col.components.Cell));
        }))))));
};
export default Table;

//# sourceMappingURL=index.js.map