"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

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

var _vue = _interopRequireWildcard(require("vue"));

var _vueTypes = _interopRequireDefault(require("../_util/vue-types"));

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

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

var _LocaleReceiver = _interopRequireDefault(require("../locale-provider/LocaleReceiver"));

var _propsUtil = require("../_util/props-util");

var _vcPagination = _interopRequireDefault(require("../vc-pagination"));

var _en_US = _interopRequireDefault(require("../vc-pagination/locale/en_US"));

var _LeftOutlined = _interopRequireDefault(require("@ant-design/icons-vue/LeftOutlined"));

var _RightOutlined = _interopRequireDefault(require("@ant-design/icons-vue/RightOutlined"));

var _DoubleLeftOutlined = _interopRequireDefault(require("@ant-design/icons-vue/DoubleLeftOutlined"));

var _DoubleRightOutlined = _interopRequireDefault(require("@ant-design/icons-vue/DoubleRightOutlined"));

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

var _classNames = _interopRequireDefault(require("../_util/classNames"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _objectWithoutProperties(source, excluded) { if (source == null) 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 (source == null) 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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var PaginationProps = function PaginationProps() {
  return {
    total: _vueTypes.default.number,
    defaultCurrent: _vueTypes.default.number,
    disabled: _vueTypes.default.bool,
    current: _vueTypes.default.number,
    defaultPageSize: _vueTypes.default.number,
    pageSize: _vueTypes.default.number,
    hideOnSinglePage: _vueTypes.default.bool,
    showSizeChanger: _vueTypes.default.bool,
    pageSizeOptions: _vueTypes.default.arrayOf(_vueTypes.default.oneOfType([_vueTypes.default.number, _vueTypes.default.string])),
    buildOptionText: _vueTypes.default.func,
    showSizeChange: _vueTypes.default.func,
    showQuickJumper: _vueTypes.default.oneOfType([_vueTypes.default.bool, _vueTypes.default.object]),
    showTotal: _vueTypes.default.any,
    size: _vueTypes.default.string,
    simple: _vueTypes.default.bool,
    locale: _vueTypes.default.object,
    prefixCls: _vueTypes.default.string,
    selectPrefixCls: _vueTypes.default.string,
    itemRender: _vueTypes.default.func,
    role: _vueTypes.default.string,
    showLessItems: _vueTypes.default.bool
  };
};

exports.PaginationProps = PaginationProps;

var PaginationConfig = function PaginationConfig() {
  return _objectSpread(_objectSpread({}, PaginationProps()), {}, {
    position: _vueTypes.default.oneOf(['top', 'bottom', 'both'])
  });
};

exports.PaginationConfig = PaginationConfig;
var _default = {
  name: 'APagination',
  inheritAttrs: false,
  props: _objectSpread({}, PaginationProps()),
  setup: function setup() {
    return {
      configProvider: (0, _vue.inject)('configProvider', _configProvider.ConfigConsumerProps)
    };
  },
  methods: {
    getIconsProps: function getIconsProps(prefixCls) {
      var prevIcon = _vue.createVNode("a", {
        "class": "".concat(prefixCls, "-item-link")
      }, [_vue.createVNode(_LeftOutlined.default, null, null)]);

      var nextIcon = _vue.createVNode("a", {
        "class": "".concat(prefixCls, "-item-link")
      }, [_vue.createVNode(_RightOutlined.default, null, null)]);

      var jumpPrevIcon = _vue.createVNode("a", {
        "class": "".concat(prefixCls, "-item-link")
      }, [_vue.createVNode("div", {
        "class": "".concat(prefixCls, "-item-container")
      }, [_vue.createVNode(_DoubleLeftOutlined.default, {
        "class": "".concat(prefixCls, "-item-link-icon")
      }, null), _vue.createVNode("span", {
        "class": "".concat(prefixCls, "-item-ellipsis")
      }, [_vue.createTextVNode("\u2022\u2022\u2022")])])]);

      var jumpNextIcon = _vue.createVNode("a", {
        "class": "".concat(prefixCls, "-item-link")
      }, [_vue.createVNode("div", {
        "class": "".concat(prefixCls, "-item-container")
      }, [_vue.createVNode(_DoubleRightOutlined.default, {
        "class": "".concat(prefixCls, "-item-link-icon")
      }, null), _vue.createVNode("span", {
        "class": "".concat(prefixCls, "-item-ellipsis")
      }, [_vue.createTextVNode("\u2022\u2022\u2022")])])]);

      return {
        prevIcon: prevIcon,
        nextIcon: nextIcon,
        jumpPrevIcon: jumpPrevIcon,
        jumpNextIcon: jumpNextIcon
      };
    },
    renderPagination: function renderPagination(contextLocale) {
      var _getOptionProps = (0, _propsUtil.getOptionProps)(this),
          customizePrefixCls = _getOptionProps.prefixCls,
          customizeSelectPrefixCls = _getOptionProps.selectPrefixCls,
          buildOptionText = _getOptionProps.buildOptionText,
          size = _getOptionProps.size,
          customLocale = _getOptionProps.locale,
          restProps = _objectWithoutProperties(_getOptionProps, ["prefixCls", "selectPrefixCls", "buildOptionText", "size", "locale"]);

      var getPrefixCls = this.configProvider.getPrefixCls;
      var prefixCls = getPrefixCls('pagination', customizePrefixCls);
      var selectPrefixCls = getPrefixCls('select', customizeSelectPrefixCls);
      var isSmall = size === 'small';

      var paginationProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
        prefixCls: prefixCls,
        selectPrefixCls: selectPrefixCls
      }, restProps), this.getIconsProps(prefixCls)), {}, {
        selectComponentClass: isSmall ? _MiniSelect.default : _select.default,
        locale: _objectSpread(_objectSpread({}, contextLocale), customLocale),
        buildOptionText: buildOptionText || this.$slots.buildOptionText
      }, this.$attrs), {}, {
        class: (0, _classNames.default)({
          mini: isSmall
        }, this.$attrs.class),
        itemRender: this.itemRender || this.$slots.itemRender
      });

      return _vue.createVNode(_vcPagination.default, paginationProps, null);
    }
  },
  render: function render() {
    return _vue.createVNode(_LocaleReceiver.default, {
      "componentName": "Pagination",
      "defaultLocale": _en_US.default,
      "children": this.renderPagination
    }, null);
  }
};
exports.default = _default;