import { h } from "@stencil/core";
import { TableClasses } from '../table.utils';
import { ColumnRenderer } from '../column/column.renderer';
export const EditCell = ({ classList, column, columnIndex, offset, row, rowIndex, renderer }) => {
    const attrs = ColumnRenderer.columnAttributes(column, columnIndex, row);
    const refFn = r => column.initCell(r, offset);
    const allClasses = `${classList} ${TableClasses.editCell}`;
    // TODO: abstract this out better
    if (column.editTemplate) {
        return h("td", Object.assign({}, attrs, { class: allClasses, ref: r => renderer.cellTemplate(r, offset, column, row, rowIndex, column.editTemplate) }));
    }
    else if (column.editFormatter) {
        return h("td", Object.assign({}, attrs, { class: allClasses, innerHTML: column.editFormatter(row, column, rowIndex), ref: refFn }));
    }
    else {
        return h("td", Object.assign({}, attrs, { class: allClasses, ref: refFn }), column.editRenderer(row, column));
    }
};
