/**
 * DevExtreme (renovation/ui/grids/data_grid_next/data_grid_next_full.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/
 */
"use strict";
exports.DataGridNextProps = exports.DataGridNext = void 0;
exports.defaultOptions = defaultOptions;
exports.viewFunction = void 0;
var _inferno = require("inferno");
var _inferno2 = require("@devextreme/runtime/inferno");
var _data_grid_next = require("./data_grid_next");
var _paging = require("./paging/paging");
var _pager = require("./pager/pager");
var _selection = require("./selection/selection");
var _master_detail = require("./master_detail/master_detail");
var _utils = require("../../../../core/options/utils");
var _excluded = ["accessKey", "activeStateEnabled", "cacheEnabled", "children", "className", "columns", "dataSource", "dataState", "dataStateChange", "defaultDataState", "disabled", "focusStateEnabled", "height", "hint", "hoverStateEnabled", "keyExpr", "masterDetail", "noDataTemplate", "onClick", "onDataErrorOccurred", "onKeyDown", "pager", "paging", "remoteOperations", "rtlEnabled", "selection", "tabIndex", "visible", "width"];

function _objectWithoutProperties(source, excluded) {
    if (null == source) {
        return {}
    }
    var target = _objectWithoutPropertiesLoose(source, excluded);
    var key, i;
    if (Object.getOwnPropertySymbols) {
        var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
        for (i = 0; i < sourceSymbolKeys.length; i++) {
            key = sourceSymbolKeys[i];
            if (excluded.indexOf(key) >= 0) {
                continue
            }
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) {
                continue
            }
            target[key] = source[key]
        }
    }
    return target
}

function _objectWithoutPropertiesLoose(source, excluded) {
    if (null == source) {
        return {}
    }
    var target = {};
    var sourceKeys = Object.keys(source);
    var key, i;
    for (i = 0; i < sourceKeys.length; i++) {
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) {
            continue
        }
        target[key] = source[key]
    }
    return target
}

function _defineProperties(target, props) {
    for (var i = 0; i < props.length; i++) {
        var descriptor = props[i];
        descriptor.enumerable = descriptor.enumerable || false;
        descriptor.configurable = true;
        if ("value" in descriptor) {
            descriptor.writable = true
        }
        Object.defineProperty(target, descriptor.key, descriptor)
    }
}

function _createClass(Constructor, protoProps, staticProps) {
    if (protoProps) {
        _defineProperties(Constructor.prototype, protoProps)
    }
    if (staticProps) {
        _defineProperties(Constructor, staticProps)
    }
    Object.defineProperty(Constructor, "prototype", {
        writable: false
    });
    return Constructor
}

function _assertThisInitialized(self) {
    if (void 0 === self) {
        throw new ReferenceError("this hasn't been initialised - super() hasn't been called")
    }
    return self
}

function _inheritsLoose(subClass, superClass) {
    subClass.prototype = Object.create(superClass.prototype);
    subClass.prototype.constructor = subClass;
    _setPrototypeOf(subClass, superClass)
}

function _setPrototypeOf(o, p) {
    _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
        o.__proto__ = p;
        return o
    };
    return _setPrototypeOf(o, p)
}

function _extends() {
    _extends = Object.assign ? Object.assign.bind() : function(target) {
        for (var i = 1; i < arguments.length; i++) {
            var source = arguments[i];
            for (var key in source) {
                if (Object.prototype.hasOwnProperty.call(source, key)) {
                    target[key] = source[key]
                }
            }
        }
        return target
    };
    return _extends.apply(this, arguments)
}
var viewFunction = function(viewModel) {
    var _viewModel$props$pagi, _viewModel$props$pagi2, _viewModel$props$pagi3, _viewModel$props$page, _viewModel$props$page2, _viewModel$props$page3, _viewModel$props$page4, _viewModel$props$page5, _viewModel$props$page6, _viewModel$props$page7, _viewModel$props$sele, _viewModel$props$sele2, _viewModel$props$sele3, _viewModel$props$mast, _viewModel$props$mast2;
    return (0, _inferno.normalizeProps)((0, _inferno.createComponentVNode)(2, _data_grid_next.DataGridNext, _extends({
        dataSource: viewModel.props.dataSource,
        cacheEnabled: viewModel.props.cacheEnabled,
        remoteOperations: viewModel.props.remoteOperations,
        dataState: viewModel.props.dataState,
        keyExpr: viewModel.props.keyExpr,
        columns: viewModel.props.columns,
        noDataTemplate: viewModel.props.noDataTemplate,
        onDataErrorOccurred: viewModel.props.onDataErrorOccurred,
        activeStateEnabled: viewModel.props.activeStateEnabled,
        className: viewModel.props.className,
        disabled: viewModel.props.disabled,
        focusStateEnabled: viewModel.props.focusStateEnabled,
        height: viewModel.props.height,
        hint: viewModel.props.hint,
        hoverStateEnabled: viewModel.props.hoverStateEnabled,
        rtlEnabled: viewModel.props.rtlEnabled,
        tabIndex: viewModel.props.tabIndex,
        visible: viewModel.props.visible,
        width: viewModel.props.width
    }, viewModel.restAttributes, {
        children: [(0, _inferno.createComponentVNode)(2, _paging.DataGridNextPaging, {
            enabled: null === (_viewModel$props$pagi = viewModel.props.paging) || void 0 === _viewModel$props$pagi ? void 0 : _viewModel$props$pagi.enabled,
            pageIndex: null === (_viewModel$props$pagi2 = viewModel.props.paging) || void 0 === _viewModel$props$pagi2 ? void 0 : _viewModel$props$pagi2.pageIndex,
            pageSize: null === (_viewModel$props$pagi3 = viewModel.props.paging) || void 0 === _viewModel$props$pagi3 ? void 0 : _viewModel$props$pagi3.pageSize
        }), (0, _inferno.createComponentVNode)(2, _pager.DataGridNextPager, {
            visible: null === (_viewModel$props$page = viewModel.props.pager) || void 0 === _viewModel$props$page ? void 0 : _viewModel$props$page.visible,
            showInfo: null === (_viewModel$props$page2 = viewModel.props.pager) || void 0 === _viewModel$props$page2 ? void 0 : _viewModel$props$page2.showInfo,
            showNavigationButtons: null === (_viewModel$props$page3 = viewModel.props.pager) || void 0 === _viewModel$props$page3 ? void 0 : _viewModel$props$page3.showNavigationButtons,
            showPageSizeSelector: null === (_viewModel$props$page4 = viewModel.props.pager) || void 0 === _viewModel$props$page4 ? void 0 : _viewModel$props$page4.showPageSizeSelector,
            allowedPageSizes: null === (_viewModel$props$page5 = viewModel.props.pager) || void 0 === _viewModel$props$page5 ? void 0 : _viewModel$props$page5.allowedPageSizes,
            displayMode: null === (_viewModel$props$page6 = viewModel.props.pager) || void 0 === _viewModel$props$page6 ? void 0 : _viewModel$props$page6.displayMode,
            infoText: null === (_viewModel$props$page7 = viewModel.props.pager) || void 0 === _viewModel$props$page7 ? void 0 : _viewModel$props$page7.infoText
        }), (0, _inferno.createComponentVNode)(2, _selection.DataGridNextSelection, {
            mode: viewModel.selectionMode,
            selectedRowKeys: null === (_viewModel$props$sele = viewModel.props.selection) || void 0 === _viewModel$props$sele ? void 0 : _viewModel$props$sele.selectedRowKeys,
            allowSelectAll: null === (_viewModel$props$sele2 = viewModel.props.selection) || void 0 === _viewModel$props$sele2 ? void 0 : _viewModel$props$sele2.allowSelectAll,
            selectAllMode: null === (_viewModel$props$sele3 = viewModel.props.selection) || void 0 === _viewModel$props$sele3 ? void 0 : _viewModel$props$sele3.selectAllMode
        }), (0, _inferno.createComponentVNode)(2, _master_detail.DataGridNextMasterDetail, {
            enabled: viewModel.masterDetailEnabled,
            expandedRowKeys: null === (_viewModel$props$mast = viewModel.props.masterDetail) || void 0 === _viewModel$props$mast ? void 0 : _viewModel$props$mast.expandedRowKeys,
            template: null === (_viewModel$props$mast2 = viewModel.props.masterDetail) || void 0 === _viewModel$props$mast2 ? void 0 : _viewModel$props$mast2.template
        })]
    }), null, viewModel.dataGrid))
};
exports.viewFunction = viewFunction;
var DataGridNextProps = _data_grid_next.DataGridNextProps;
exports.DataGridNextProps = DataGridNextProps;
var getTemplate = function(TemplateProp) {
    return TemplateProp && (TemplateProp.defaultProps ? function(props) {
        return (0, _inferno.normalizeProps)((0, _inferno.createComponentVNode)(2, TemplateProp, _extends({}, props)))
    } : TemplateProp)
};
var DataGridNext = function(_InfernoWrapperCompon) {
    _inheritsLoose(DataGridNext, _InfernoWrapperCompon);

    function DataGridNext(props) {
        var _this;
        _this = _InfernoWrapperCompon.call(this, props) || this;
        _this.dataGrid = (0, _inferno.createRef)();
        _this.state = {
            dataState: void 0 !== _this.props.dataState ? _this.props.dataState : _this.props.defaultDataState
        };
        _this.refresh = _this.refresh.bind(_assertThisInitialized(_this));
        return _this
    }
    var _proto = DataGridNext.prototype;
    _proto.createEffects = function() {
        return [(0, _inferno2.createReRenderEffect)()]
    };
    _proto.refresh = function() {
        return this.dataGrid.current.refresh()
    };
    _proto.render = function() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props, {
                dataState: void 0 !== this.props.dataState ? this.props.dataState : this.state.dataState,
                noDataTemplate: getTemplate(props.noDataTemplate)
            }),
            dataGrid: this.dataGrid,
            masterDetailEnabled: this.masterDetailEnabled,
            selectionMode: this.selectionMode,
            restAttributes: this.restAttributes
        })
    };
    _createClass(DataGridNext, [{
        key: "masterDetailEnabled",
        get: function() {
            var _this$props$masterDet, _this$props$masterDet2;
            return null !== (_this$props$masterDet = null === (_this$props$masterDet2 = this.props.masterDetail) || void 0 === _this$props$masterDet2 ? void 0 : _this$props$masterDet2.enabled) && void 0 !== _this$props$masterDet ? _this$props$masterDet : false
        }
    }, {
        key: "selectionMode",
        get: function() {
            var _this$props$selection, _this$props$selection2;
            return null !== (_this$props$selection = null === (_this$props$selection2 = this.props.selection) || void 0 === _this$props$selection2 ? void 0 : _this$props$selection2.mode) && void 0 !== _this$props$selection ? _this$props$selection : "none"
        }
    }, {
        key: "restAttributes",
        get: function() {
            var _this$props$dataState = _extends({}, this.props, {
                    dataState: void 0 !== this.props.dataState ? this.props.dataState : this.state.dataState
                }),
                restProps = (_this$props$dataState.accessKey, _this$props$dataState.activeStateEnabled, _this$props$dataState.cacheEnabled, _this$props$dataState.children, _this$props$dataState.className, _this$props$dataState.columns, _this$props$dataState.dataSource, _this$props$dataState.dataState, _this$props$dataState.dataStateChange, _this$props$dataState.defaultDataState, _this$props$dataState.disabled, _this$props$dataState.focusStateEnabled, _this$props$dataState.height, _this$props$dataState.hint, _this$props$dataState.hoverStateEnabled, _this$props$dataState.keyExpr, _this$props$dataState.masterDetail, _this$props$dataState.noDataTemplate, _this$props$dataState.onClick, _this$props$dataState.onDataErrorOccurred, _this$props$dataState.onKeyDown, _this$props$dataState.pager, _this$props$dataState.paging, _this$props$dataState.remoteOperations, _this$props$dataState.rtlEnabled, _this$props$dataState.selection, _this$props$dataState.tabIndex, _this$props$dataState.visible, _this$props$dataState.width, _objectWithoutProperties(_this$props$dataState, _excluded));
            return restProps
        }
    }]);
    return DataGridNext
}(_inferno2.InfernoWrapperComponent);
exports.DataGridNext = DataGridNext;

function __processTwoWayProps(defaultProps) {
    var twoWayProps = ["dataState"];
    return Object.keys(defaultProps).reduce((function(props, propName) {
        var propValue = defaultProps[propName];
        var defaultPropName = twoWayProps.some((function(p) {
            return p === propName
        })) ? "default" + propName.charAt(0).toUpperCase() + propName.slice(1) : propName;
        props[defaultPropName] = propValue;
        return props
    }), {})
}
DataGridNext.defaultProps = DataGridNextProps;
var __defaultOptionRules = [];

function defaultOptions(rule) {
    __defaultOptionRules.push(rule);
    DataGridNext.defaultProps = Object.create(Object.prototype, _extends(Object.getOwnPropertyDescriptors(DataGridNext.defaultProps), Object.getOwnPropertyDescriptors(__processTwoWayProps((0, _utils.convertRulesToOptions)(__defaultOptionRules)))))
}
