/**
 * DevExtreme (esm/renovation/ui/pager/page_size/small.js)
 * Version: 23.1.6 (build 23316-0110)
 * Build date: Sun Nov 12 2023
 *
 * Copyright (c) 2012 - 2023 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 = ["inputAttr", "pageSize", "pageSizeChange", "pageSizes", "parentRef"];
import {
    createComponentVNode
} from "inferno";
import {
    InfernoEffect,
    InfernoComponent
} from "@devextreme/runtime/inferno";
import messageLocalization from "../../../../localization/message";
import {
    SelectBox
} from "../../editors/drop_down_editors/select_box";
import {
    calculateValuesFittedWidth
} from "../utils/calculate_values_fitted_width";
import {
    getElementMinWidth
} from "../utils/get_element_width";
import {
    InternalPagerProps
} from "../common/pager_props";
export var viewFunction = _ref => {
    var {
        props: {
            inputAttr: inputAttr,
            pageSize: pageSize,
            pageSizeChange: pageSizeChange,
            pageSizes: pageSizes
        },
        width: width
    } = _ref;
    return createComponentVNode(2, SelectBox, {
        displayExpr: "text",
        valueExpr: "value",
        dataSource: pageSizes,
        value: pageSize,
        valueChange: pageSizeChange,
        width: width,
        inputAttr: inputAttr
    })
};
export var PageSizeSmallProps = {
    inputAttr: Object.freeze({
        "aria-label": messageLocalization.format("dxPager-ariaPageSize")
    })
};
var PageSizeSmallPropsType = {
    get pageSize() {
        return InternalPagerProps.pageSize
    },
    get inputAttr() {
        return PageSizeSmallProps.inputAttr
    }
};
export class PageSizeSmall extends InfernoComponent {
    constructor(props) {
        super(props);
        this.state = {
            minWidth: 10
        };
        this.updateWidth = this.updateWidth.bind(this)
    }
    createEffects() {
        return [new InfernoEffect(this.updateWidth, [this.props, this.state.minWidth, this.props.pageSize, this.props.pageSizeChange, this.props.pageSizes, this.props.inputAttr])]
    }
    updateEffects() {
        var _this$_effects$;
        null === (_this$_effects$ = this._effects[0]) || void 0 === _this$_effects$ ? void 0 : _this$_effects$.update([this.props, this.state.minWidth, this.props.pageSize, this.props.pageSizeChange, this.props.pageSizes, this.props.inputAttr])
    }
    updateWidth() {
        this.setState(__state_argument => ({
            minWidth: getElementMinWidth(this.props.parentRef.current) || __state_argument.minWidth
        }))
    }
    get width() {
        return calculateValuesFittedWidth(this.state.minWidth, this.props.pageSizes.map(p => p.value))
    }
    get restAttributes() {
        var _this$props = this.props,
            restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
        return restProps
    }
    render() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props),
            width: this.width,
            restAttributes: this.restAttributes
        })
    }
}
PageSizeSmall.defaultProps = PageSizeSmallPropsType;
