import { h } from "@stencil/core";
import { ColumnRenderer } from '../column/column.renderer';
export const Td = ({ classList, column, columnIndex, offset, renderer, row, rowIndex }) => {
    const attrs = ColumnRenderer.columnAttributes(column, columnIndex, row);
    const refFn = r => column.initCell(r, offset);
    // TODO: abstract this out better
    if (column.cellTemplate) {
        return h("td", Object.assign({}, attrs, { class: classList, ref: r => renderer.cellTemplate(r, offset, column, row, rowIndex, column.cellTemplate) }));
    }
    else if (column.cellFormatter) {
        return h("td", Object.assign({}, attrs, { class: classList, innerHTML: column.cellFormatter(row, column, rowIndex), ref: refFn }));
    }
    else {
        return h("td", Object.assign({}, attrs, { class: classList, ref: refFn }), column.cellRenderer(row, column, rowIndex));
    }
};
