"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _components = require("../components");

var _context = require("../config-provider/context");

var _icon = _interopRequireDefault(require("../icon"));

var _select = _interopRequireDefault(require("../select"));

var _MiniSelect = _interopRequireDefault(require("./MiniSelect"));

var LeftLine = _icon.default.LeftLine,
    RightLine = _icon.default.RightLine,
    DoubleLeftLine = _icon.default.DoubleLeftLine,
    DoubleRightLine = _icon.default.DoubleRightLine,
    EllipsisLine = _icon.default.EllipsisLine;

var getIconsProps = function getIconsProps(prefixCls) {
  var ellipsis = /*#__PURE__*/_react.default.createElement("span", {
    className: "".concat(prefixCls, "-item-ellipsis")
  }, /*#__PURE__*/_react.default.createElement(EllipsisLine, null));

  var prevIcon = /*#__PURE__*/_react.default.createElement("button", {
    className: "".concat(prefixCls, "-item-link"),
    type: "button",
    tabIndex: -1
  }, /*#__PURE__*/_react.default.createElement(LeftLine, {
    className: "".concat(prefixCls, "-item-link-icon")
  }));

  var nextIcon = /*#__PURE__*/_react.default.createElement("button", {
    className: "".concat(prefixCls, "-item-link"),
    type: "button",
    tabIndex: -1
  }, /*#__PURE__*/_react.default.createElement(RightLine, {
    className: "".concat(prefixCls, "-item-link-icon")
  }));

  var jumpPrevIcon = /*#__PURE__*/_react.default.createElement("a", {
    className: "".concat(prefixCls, "-item-link")
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefixCls, "-item-container")
  }, /*#__PURE__*/_react.default.createElement(DoubleLeftLine, {
    className: "".concat(prefixCls, "-item-link-icon")
  }), ellipsis));

  var jumpNextIcon = /*#__PURE__*/_react.default.createElement("a", {
    className: "".concat(prefixCls, "-item-link")
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefixCls, "-item-container")
  }, /*#__PURE__*/_react.default.createElement(DoubleRightLine, {
    className: "".concat(prefixCls, "-item-link-icon")
  }), ellipsis));

  return {
    prevIcon: prevIcon,
    nextIcon: nextIcon,
    jumpPrevIcon: jumpPrevIcon,
    jumpNextIcon: jumpNextIcon
  };
};

var Pagination = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
  var className = props.className,
      size = props.size,
      simple = props.simple;

  var _React$useContext = _react.default.useContext(_context.ConfigContext),
      getPrefixClassName = _React$useContext.getPrefixClassName;

  var paginationCls = getPrefixClassName('pagination');
  var selectPrefixCls = getPrefixClassName('select'); // const isMini = size === 'mini' || size === 'small';

  var isMini = size === 'mini' || size === 'small' || simple; // 如果要求simple时要展示mini效果，则用这一行

  var endCls = (0, _classnames.default)(className, (0, _defineProperty2.default)({}, "".concat(paginationCls, "-mini"), isMini));
  var comProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, props), {}, {
    className: endCls
  });
  return /*#__PURE__*/_react.default.createElement(_components.RcPagination, Object.assign({
    ref: ref,
    prefixCls: paginationCls,
    selectPrefixCls: selectPrefixCls
  }, comProps, getIconsProps(paginationCls), {
    selectComponentClass: isMini ? _MiniSelect.default : _select.default
  }));
});

Pagination.displayName = 'Pagination';
Pagination.defaultProps = {
  size: 'default',
  defaultPageSize: 10,
  disabled: false,
  showQuickJumper: false,
  total: 0,
  simple: false,
  hideOnSinglePage: false
};
var _default = Pagination;
exports.default = _default;