/**
 * DevExtreme (esm/renovation/ui/grids/data_grid_next/widgets/data_row.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 = ["columns", "row", "rowIndex"];
import {
    createComponentVNode
} from "inferno";
import {
    InfernoEffect,
    InfernoComponent
} from "@devextreme/runtime/inferno";
import {
    PluginsContext
} from "../../../../utils/plugin/context";
import {
    DataCell
} from "./data_cell";
import {
    RowBase,
    RowClassesGetter
} from "./row_base";
import CLASSES from "../classes";
export var viewFunction = viewModel => {
    var {
        rowTemplate: RowTemplate
    } = viewModel;
    var {
        columns: columns,
        row: row,
        rowIndex: rowIndex
    } = viewModel.props;
    return RowTemplate ? createComponentVNode(2, RowTemplate, {
        row: row,
        rowIndex: rowIndex
    }) : createComponentVNode(2, RowBase, {
        row: row,
        children: columns.map((column, index) => createComponentVNode(2, DataCell, {
            columnIndex: index,
            countColumn: columns.length,
            column: column,
            cellTemplate: column.cellTemplate,
            cellContainerTemplate: column.cellContainerTemplate,
            row: row
        }, index))
    })
};
export var DataRowProps = {
    row: Object.freeze({
        data: {},
        rowType: "data"
    }),
    rowIndex: 0,
    columns: Object.freeze([])
};
export class DataRow extends InfernoComponent {
    constructor(props) {
        super(props);
        this.state = {};
        this.extendDataRowClasses = this.extendDataRowClasses.bind(this)
    }
    get plugins() {
        if ("PluginsContext" in this.context) {
            return this.context.PluginsContext
        }
        return PluginsContext
    }
    createEffects() {
        return [new InfernoEffect(this.extendDataRowClasses, [this.plugins])]
    }
    updateEffects() {
        var _this$_effects$;
        null === (_this$_effects$ = this._effects[0]) || void 0 === _this$_effects$ ? void 0 : _this$_effects$.update([this.plugins])
    }
    extendDataRowClasses() {
        return this.plugins.extend(RowClassesGetter, 1, base => row => {
            if ("data" === row.rowType) {
                return _extends({}, base(row), {
                    [CLASSES.dataRow]: true
                })
            }
            return base(row)
        })
    }
    get rowTemplate() {
        return this.props.row.template
    }
    get restAttributes() {
        var _this$props = this.props,
            restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
        return restProps
    }
    render() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props),
            plugins: this.plugins,
            rowTemplate: this.rowTemplate,
            restAttributes: this.restAttributes
        })
    }
}
DataRow.defaultProps = DataRowProps;
