/**
 * DevExtreme (esm/renovation/ui/grids/data_grid_next/scrolling/virtual_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 _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
var _excluded = ["cellClasses", "height", "rowKey"];
import {
    createVNode
} from "inferno";
import {
    BaseInfernoComponent
} from "@devextreme/runtime/inferno";
import {
    normalizeStyles
} from "@devextreme/runtime/inferno";
import CLASSES from "../classes";
import {
    combineClasses
} from "../../../../utils/combine_classes";
var rowClasses = combineClasses({
    [CLASSES.row]: true,
    [CLASSES.columnLines]: true,
    [CLASSES.virtualRow]: true
});
export var viewFunction = _ref => {
    var {
        props: {
            rowKey: rowKey
        },
        virtualCells: virtualCells
    } = _ref;
    return createVNode(1, "tr", rowClasses, virtualCells.map(_ref2 => {
        var {
            cellClass: cellClass,
            height: height,
            key: key
        } = _ref2;
        return createVNode(1, "td", cellClass, null, 1, {
            style: normalizeStyles({
                height: height
            })
        }, key)
    }), 0, {
        role: "presentation"
    }, rowKey)
};
export var VirtualRowProps = {
    height: 0,
    cellClasses: Object.freeze([]),
    rowKey: 0
};
export class VirtualRow extends BaseInfernoComponent {
    constructor(props) {
        super(props);
        this.state = {};
        this.__getterCache = {}
    }
    get virtualCells() {
        if (void 0 !== this.__getterCache.virtualCells) {
            return this.__getterCache.virtualCells
        }
        return this.__getterCache.virtualCells = (() => {
            var {
                cellClasses: cellClasses,
                height: height
            } = this.props;
            var cells = [];
            cellClasses.forEach((c_class, index) => {
                cells.push({
                    height: height,
                    key: index,
                    cellClass: c_class
                })
            });
            return cells
        })()
    }
    get restAttributes() {
        var _this$props = this.props,
            restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
        return restProps
    }
    componentWillUpdate(nextProps, nextState, context) {
        if (this.props.cellClasses !== nextProps.cellClasses || this.props.height !== nextProps.height) {
            this.__getterCache.virtualCells = void 0
        }
    }
    render() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props),
            virtualCells: this.virtualCells,
            restAttributes: this.restAttributes
        })
    }
}
VirtualRow.defaultProps = VirtualRowProps;
