import { __assign, __extends } from "tslib";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { NumberInput } from '../../../number-input';
import BasePageJumper from './BasePageJumper';
var INPUT_WIDTH = 56;
var MiniPageJumper = (function (_super) {
    __extends(MiniPageJumper, _super);
    function MiniPageJumper(props) {
        var _this = _super.call(this, props) || this;
        _this.reset = false;
        _this.state.prevCurrent = props.current;
        return _this;
    }
    MiniPageJumper.prototype.render = function () {
        var value = this.state.value;
        var totalPages = this.props.totalPages;
        return (_jsxs("div", __assign({ className: "zent-pagination-mini-page-jumper", "data-zv": 'v10.0.11' }, { children: [_jsx(NumberInput, { integer: true, value: value, onChange: this.onChange, onPressEnter: this.onConfirm, width: INPUT_WIDTH }, void 0), _jsx("span", __assign({ className: "zent-pagination-mini-page-jumper__sep", "data-zv": 'v10.0.11' }, { children: "/" }), void 0), _jsx("span", __assign({ className: "zent-pagination-mini-page-jumper__total", "data-zv": 'v10.0.11' }, { children: totalPages }), void 0)] }), void 0));
    };
    MiniPageJumper.getDerivedStateFromProps = function (props, state) {
        return {
            value: props.current !== state.prevCurrent ? props.current : state.value,
            prevCurrent: props.current,
        };
    };
    MiniPageJumper.prototype.handleJump = function (pageNumber) {
        var _a = this.props, onJump = _a.onJump, totalPages = _a.totalPages;
        onJump(pageNumber);
        if (pageNumber > totalPages) {
            this.setState({
                value: totalPages,
            });
        }
        if (pageNumber < 1) {
            this.setState({
                value: 1,
            });
        }
    };
    return MiniPageJumper;
}(BasePageJumper));
export { MiniPageJumper };
export default MiniPageJumper;
