/**
 * DevExtreme (esm/renovation/ui/grids/data_grid_next/widgets/data_cell.js)
 * Version: 22.1.3 (build 22180-0310)
 * Build date: Wed Jun 29 2022
 *
 * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import _extends from "@babel/runtime/helpers/esm/extends";
var _excluded = ["cellContainerTemplate", "cellTemplate", "column", "columnIndex", "countColumn", "row"];
import {
    createVNode,
    createComponentVNode,
    normalizeProps
} from "inferno";
import {
    BaseInfernoComponent
} from "@devextreme/runtime/inferno";
import {
    combineClasses
} from "../../../../utils/combine_classes";
import CLASSES from "../classes";
export var viewFunction = viewModel => {
    var {
        cellText: cellText,
        classes: classes
    } = viewModel;
    var {
        cellContainerTemplate: CellContainerTemplate,
        cellTemplate: CellTemplate,
        row: row
    } = viewModel.props;
    var cellContentTemplate = viewModel.props.cellTemplate ? CellTemplate({
        data: row.data
    }) : cellText;
    return !viewModel.props.cellContainerTemplate ? createVNode(1, "td", classes, cellContentTemplate, 0, {
        "aria-selected": "false",
        role: "gridcell"
    }) : CellContainerTemplate({
        data: row.data
    })
};
export var DataCellProps = {
    row: Object.freeze({
        data: {},
        rowType: "data"
    }),
    columnIndex: 0,
    countColumn: 0,
    column: Object.freeze({})
};
var getTemplate = TemplateProp => TemplateProp && (TemplateProp.defaultProps ? props => normalizeProps(createComponentVNode(2, TemplateProp, _extends({}, props))) : TemplateProp);
export class DataCell extends BaseInfernoComponent {
    constructor(props) {
        super(props);
        this.state = {}
    }
    get cellText() {
        var {
            dataField: dataField
        } = this.props.column;
        var value = dataField && this.props.row.data[dataField];
        return void 0 !== value ? String(value) : ""
    }
    get classes() {
        var {
            columnIndex: columnIndex,
            countColumn: countColumn
        } = this.props;
        var classesMap = {
            [CLASSES.firstChild]: 0 === columnIndex,
            [CLASSES.lastChild]: columnIndex === countColumn - 1
        };
        return combineClasses(classesMap)
    }
    get restAttributes() {
        var _this$props = this.props,
            restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
        return restProps
    }
    render() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props, {
                cellTemplate: getTemplate(props.cellTemplate),
                cellContainerTemplate: getTemplate(props.cellContainerTemplate)
            }),
            cellText: this.cellText,
            classes: this.classes,
            restAttributes: this.restAttributes
        })
    }
}
DataCell.defaultProps = DataCellProps;
