Pagination.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. var _vue = require("vue");
  8. var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
  9. var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
  10. var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
  11. var _vueTypes = _interopRequireDefault(require("../_util/vue-types"));
  12. var _BaseMixin = _interopRequireDefault(require("../_util/BaseMixin"));
  13. var _propsUtil = require("../_util/props-util");
  14. var _Pager = _interopRequireDefault(require("./Pager"));
  15. var _Options = _interopRequireDefault(require("./Options"));
  16. var _zh_CN = _interopRequireDefault(require("./locale/zh_CN"));
  17. var _KeyCode = _interopRequireDefault(require("./KeyCode"));
  18. var _classNames9 = _interopRequireDefault(require("../_util/classNames"));
  19. var _antInputDirective = _interopRequireDefault(require("../_util/antInputDirective"));
  20. var _vnode = require("../_util/vnode");
  21. var _firstNotUndefined = _interopRequireDefault(require("../_util/firstNotUndefined"));
  22. var _excluded = ["class"];
  23. // 是否是正整数
  24. function isInteger(value) {
  25. return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
  26. }
  27. function defaultItemRender(_ref) {
  28. var originalElement = _ref.originalElement;
  29. return originalElement;
  30. }
  31. function calculatePage(p, state, props) {
  32. var pageSize = typeof p === 'undefined' ? state.statePageSize : p;
  33. return Math.floor((props.total - 1) / pageSize) + 1;
  34. }
  35. var _default = (0, _vue.defineComponent)({
  36. compatConfig: {
  37. MODE: 3
  38. },
  39. name: 'Pagination',
  40. mixins: [_BaseMixin.default],
  41. inheritAttrs: false,
  42. props: {
  43. disabled: {
  44. type: Boolean,
  45. default: undefined
  46. },
  47. prefixCls: _vueTypes.default.string.def('rc-pagination'),
  48. selectPrefixCls: _vueTypes.default.string.def('rc-select'),
  49. current: Number,
  50. defaultCurrent: _vueTypes.default.number.def(1),
  51. total: _vueTypes.default.number.def(0),
  52. pageSize: Number,
  53. defaultPageSize: _vueTypes.default.number.def(10),
  54. hideOnSinglePage: {
  55. type: Boolean,
  56. default: false
  57. },
  58. showSizeChanger: {
  59. type: Boolean,
  60. default: undefined
  61. },
  62. showLessItems: {
  63. type: Boolean,
  64. default: false
  65. },
  66. // showSizeChange: PropTypes.func.def(noop),
  67. selectComponentClass: _vueTypes.default.any,
  68. showPrevNextJumpers: {
  69. type: Boolean,
  70. default: true
  71. },
  72. showQuickJumper: _vueTypes.default.oneOfType([_vueTypes.default.looseBool, _vueTypes.default.object]).def(false),
  73. showTitle: {
  74. type: Boolean,
  75. default: true
  76. },
  77. pageSizeOptions: _vueTypes.default.arrayOf(_vueTypes.default.oneOfType([_vueTypes.default.number, _vueTypes.default.string])),
  78. buildOptionText: Function,
  79. showTotal: Function,
  80. simple: {
  81. type: Boolean,
  82. default: undefined
  83. },
  84. locale: _vueTypes.default.object.def(_zh_CN.default),
  85. itemRender: _vueTypes.default.func.def(defaultItemRender),
  86. prevIcon: _vueTypes.default.any,
  87. nextIcon: _vueTypes.default.any,
  88. jumpPrevIcon: _vueTypes.default.any,
  89. jumpNextIcon: _vueTypes.default.any,
  90. totalBoundaryShowSizeChanger: _vueTypes.default.number.def(50)
  91. },
  92. data: function data() {
  93. var props = this.$props;
  94. var current = (0, _firstNotUndefined.default)([this.current, this.defaultCurrent]);
  95. var pageSize = (0, _firstNotUndefined.default)([this.pageSize, this.defaultPageSize]);
  96. current = Math.min(current, calculatePage(pageSize, undefined, props));
  97. return {
  98. stateCurrent: current,
  99. stateCurrentInputValue: current,
  100. statePageSize: pageSize
  101. };
  102. },
  103. watch: {
  104. current: function current(val) {
  105. this.setState({
  106. stateCurrent: val,
  107. stateCurrentInputValue: val
  108. });
  109. },
  110. pageSize: function pageSize(val) {
  111. var newState = {};
  112. var current = this.stateCurrent;
  113. var newCurrent = calculatePage(val, this.$data, this.$props);
  114. current = current > newCurrent ? newCurrent : current;
  115. if (!(0, _propsUtil.hasProp)(this, 'current')) {
  116. newState.stateCurrent = current;
  117. newState.stateCurrentInputValue = current;
  118. }
  119. newState.statePageSize = val;
  120. this.setState(newState);
  121. },
  122. stateCurrent: function stateCurrent(_val, oldValue) {
  123. var _this = this;
  124. // When current page change, fix focused style of prev item
  125. // A hacky solution of https://github.com/ant-design/ant-design/issues/8948
  126. this.$nextTick(function () {
  127. if (_this.$refs.paginationNode) {
  128. var lastCurrentNode = _this.$refs.paginationNode.querySelector(".".concat(_this.prefixCls, "-item-").concat(oldValue));
  129. if (lastCurrentNode && document.activeElement === lastCurrentNode) {
  130. lastCurrentNode.blur();
  131. }
  132. }
  133. });
  134. },
  135. total: function total() {
  136. var newState = {};
  137. var newCurrent = calculatePage(this.pageSize, this.$data, this.$props);
  138. if ((0, _propsUtil.hasProp)(this, 'current')) {
  139. var current = Math.min(this.current, newCurrent);
  140. newState.stateCurrent = current;
  141. newState.stateCurrentInputValue = current;
  142. } else {
  143. var _current = this.stateCurrent;
  144. if (_current === 0 && newCurrent > 0) {
  145. _current = 1;
  146. } else {
  147. _current = Math.min(this.stateCurrent, newCurrent);
  148. }
  149. newState.stateCurrent = _current;
  150. }
  151. this.setState(newState);
  152. }
  153. },
  154. methods: {
  155. getJumpPrevPage: function getJumpPrevPage() {
  156. return Math.max(1, this.stateCurrent - (this.showLessItems ? 3 : 5));
  157. },
  158. getJumpNextPage: function getJumpNextPage() {
  159. return Math.min(calculatePage(undefined, this.$data, this.$props), this.stateCurrent + (this.showLessItems ? 3 : 5));
  160. },
  161. getItemIcon: function getItemIcon(icon, label) {
  162. var prefixCls = this.$props.prefixCls;
  163. var iconNode = (0, _propsUtil.getComponent)(this, icon, this.$props) || (0, _vue.createVNode)("button", {
  164. "type": "button",
  165. "aria-label": label,
  166. "class": "".concat(prefixCls, "-item-link")
  167. }, null);
  168. return iconNode;
  169. },
  170. getValidValue: function getValidValue(e) {
  171. var inputValue = e.target.value;
  172. var allPages = calculatePage(undefined, this.$data, this.$props);
  173. var stateCurrentInputValue = this.$data.stateCurrentInputValue;
  174. var value;
  175. if (inputValue === '') {
  176. value = inputValue;
  177. } else if (isNaN(Number(inputValue))) {
  178. value = stateCurrentInputValue;
  179. } else if (inputValue >= allPages) {
  180. value = allPages;
  181. } else {
  182. value = Number(inputValue);
  183. }
  184. return value;
  185. },
  186. isValid: function isValid(page) {
  187. return isInteger(page) && page !== this.stateCurrent;
  188. },
  189. shouldDisplayQuickJumper: function shouldDisplayQuickJumper() {
  190. var _this$$props = this.$props,
  191. showQuickJumper = _this$$props.showQuickJumper,
  192. pageSize = _this$$props.pageSize,
  193. total = _this$$props.total;
  194. if (total <= pageSize) {
  195. return false;
  196. }
  197. return showQuickJumper;
  198. },
  199. // calculatePage (p) {
  200. // let pageSize = p
  201. // if (typeof pageSize === 'undefined') {
  202. // pageSize = this.statePageSize
  203. // }
  204. // return Math.floor((this.total - 1) / pageSize) + 1
  205. // },
  206. handleKeyDown: function handleKeyDown(event) {
  207. if (event.keyCode === _KeyCode.default.ARROW_UP || event.keyCode === _KeyCode.default.ARROW_DOWN) {
  208. event.preventDefault();
  209. }
  210. },
  211. handleKeyUp: function handleKeyUp(e) {
  212. if (e.isComposing || e.target.composing) return;
  213. var value = this.getValidValue(e);
  214. var stateCurrentInputValue = this.stateCurrentInputValue;
  215. if (value !== stateCurrentInputValue) {
  216. this.setState({
  217. stateCurrentInputValue: value
  218. });
  219. }
  220. if (e.keyCode === _KeyCode.default.ENTER) {
  221. this.handleChange(value);
  222. } else if (e.keyCode === _KeyCode.default.ARROW_UP) {
  223. this.handleChange(value - 1);
  224. } else if (e.keyCode === _KeyCode.default.ARROW_DOWN) {
  225. this.handleChange(value + 1);
  226. }
  227. },
  228. changePageSize: function changePageSize(size) {
  229. var current = this.stateCurrent;
  230. var preCurrent = current;
  231. var newCurrent = calculatePage(size, this.$data, this.$props);
  232. current = current > newCurrent ? newCurrent : current;
  233. // fix the issue:
  234. // Once 'total' is 0, 'current' in 'onShowSizeChange' is 0, which is not correct.
  235. if (newCurrent === 0) {
  236. current = this.stateCurrent;
  237. }
  238. if (typeof size === 'number') {
  239. if (!(0, _propsUtil.hasProp)(this, 'pageSize')) {
  240. this.setState({
  241. statePageSize: size
  242. });
  243. }
  244. if (!(0, _propsUtil.hasProp)(this, 'current')) {
  245. this.setState({
  246. stateCurrent: current,
  247. stateCurrentInputValue: current
  248. });
  249. }
  250. }
  251. this.__emit('update:pageSize', size);
  252. if (current !== preCurrent) {
  253. this.__emit('update:current', current);
  254. }
  255. this.__emit('showSizeChange', current, size);
  256. this.__emit('change', current, size);
  257. },
  258. handleChange: function handleChange(p) {
  259. var disabled = this.$props.disabled;
  260. var page = p;
  261. if (this.isValid(page) && !disabled) {
  262. var currentPage = calculatePage(undefined, this.$data, this.$props);
  263. if (page > currentPage) {
  264. page = currentPage;
  265. } else if (page < 1) {
  266. page = 1;
  267. }
  268. if (!(0, _propsUtil.hasProp)(this, 'current')) {
  269. this.setState({
  270. stateCurrent: page,
  271. stateCurrentInputValue: page
  272. });
  273. }
  274. // this.__emit('input', page)
  275. this.__emit('update:current', page);
  276. this.__emit('change', page, this.statePageSize);
  277. return page;
  278. }
  279. return this.stateCurrent;
  280. },
  281. prev: function prev() {
  282. if (this.hasPrev()) {
  283. this.handleChange(this.stateCurrent - 1);
  284. }
  285. },
  286. next: function next() {
  287. if (this.hasNext()) {
  288. this.handleChange(this.stateCurrent + 1);
  289. }
  290. },
  291. jumpPrev: function jumpPrev() {
  292. this.handleChange(this.getJumpPrevPage());
  293. },
  294. jumpNext: function jumpNext() {
  295. this.handleChange(this.getJumpNextPage());
  296. },
  297. hasPrev: function hasPrev() {
  298. return this.stateCurrent > 1;
  299. },
  300. hasNext: function hasNext() {
  301. return this.stateCurrent < calculatePage(undefined, this.$data, this.$props);
  302. },
  303. getShowSizeChanger: function getShowSizeChanger() {
  304. var _this$$props2 = this.$props,
  305. showSizeChanger = _this$$props2.showSizeChanger,
  306. total = _this$$props2.total,
  307. totalBoundaryShowSizeChanger = _this$$props2.totalBoundaryShowSizeChanger;
  308. if (typeof showSizeChanger !== 'undefined') {
  309. return showSizeChanger;
  310. }
  311. return total > totalBoundaryShowSizeChanger;
  312. },
  313. runIfEnter: function runIfEnter(event, callback) {
  314. if (event.key === 'Enter' || event.charCode === 13) {
  315. for (var _len = arguments.length, restParams = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  316. restParams[_key - 2] = arguments[_key];
  317. }
  318. callback.apply(void 0, restParams);
  319. }
  320. },
  321. runIfEnterPrev: function runIfEnterPrev(event) {
  322. this.runIfEnter(event, this.prev);
  323. },
  324. runIfEnterNext: function runIfEnterNext(event) {
  325. this.runIfEnter(event, this.next);
  326. },
  327. runIfEnterJumpPrev: function runIfEnterJumpPrev(event) {
  328. this.runIfEnter(event, this.jumpPrev);
  329. },
  330. runIfEnterJumpNext: function runIfEnterJumpNext(event) {
  331. this.runIfEnter(event, this.jumpNext);
  332. },
  333. handleGoTO: function handleGoTO(event) {
  334. if (event.keyCode === _KeyCode.default.ENTER || event.type === 'click') {
  335. this.handleChange(this.stateCurrentInputValue);
  336. }
  337. },
  338. renderPrev: function renderPrev(prevPage) {
  339. var itemRender = this.$props.itemRender;
  340. var prevButton = itemRender({
  341. page: prevPage,
  342. type: 'prev',
  343. originalElement: this.getItemIcon('prevIcon', 'prev page')
  344. });
  345. var disabled = !this.hasPrev();
  346. return (0, _propsUtil.isValidElement)(prevButton) ? (0, _vnode.cloneElement)(prevButton, disabled ? {
  347. disabled: disabled
  348. } : {}) : prevButton;
  349. },
  350. renderNext: function renderNext(nextPage) {
  351. var itemRender = this.$props.itemRender;
  352. var nextButton = itemRender({
  353. page: nextPage,
  354. type: 'next',
  355. originalElement: this.getItemIcon('nextIcon', 'next page')
  356. });
  357. var disabled = !this.hasNext();
  358. return (0, _propsUtil.isValidElement)(nextButton) ? (0, _vnode.cloneElement)(nextButton, disabled ? {
  359. disabled: disabled
  360. } : {}) : nextButton;
  361. }
  362. },
  363. render: function render() {
  364. var _classNames6;
  365. var _this$$props3 = this.$props,
  366. prefixCls = _this$$props3.prefixCls,
  367. disabled = _this$$props3.disabled,
  368. hideOnSinglePage = _this$$props3.hideOnSinglePage,
  369. total = _this$$props3.total,
  370. locale = _this$$props3.locale,
  371. showQuickJumper = _this$$props3.showQuickJumper,
  372. showLessItems = _this$$props3.showLessItems,
  373. showTitle = _this$$props3.showTitle,
  374. showTotal = _this$$props3.showTotal,
  375. simple = _this$$props3.simple,
  376. itemRender = _this$$props3.itemRender,
  377. showPrevNextJumpers = _this$$props3.showPrevNextJumpers,
  378. jumpPrevIcon = _this$$props3.jumpPrevIcon,
  379. jumpNextIcon = _this$$props3.jumpNextIcon,
  380. selectComponentClass = _this$$props3.selectComponentClass,
  381. selectPrefixCls = _this$$props3.selectPrefixCls,
  382. pageSizeOptions = _this$$props3.pageSizeOptions;
  383. var stateCurrent = this.stateCurrent,
  384. statePageSize = this.statePageSize;
  385. var _splitAttrs$extraAttr = (0, _propsUtil.splitAttrs)(this.$attrs).extraAttrs,
  386. className = _splitAttrs$extraAttr.class,
  387. restAttrs = (0, _objectWithoutProperties2.default)(_splitAttrs$extraAttr, _excluded);
  388. // When hideOnSinglePage is true and there is only 1 page, hide the pager
  389. if (hideOnSinglePage === true && this.total <= statePageSize) {
  390. return null;
  391. }
  392. var allPages = calculatePage(undefined, this.$data, this.$props);
  393. var pagerList = [];
  394. var jumpPrev = null;
  395. var jumpNext = null;
  396. var firstPager = null;
  397. var lastPager = null;
  398. var gotoButton = null;
  399. var goButton = showQuickJumper && showQuickJumper.goButton;
  400. var pageBufferSize = showLessItems ? 1 : 2;
  401. var prevPage = stateCurrent - 1 > 0 ? stateCurrent - 1 : 0;
  402. var nextPage = stateCurrent + 1 < allPages ? stateCurrent + 1 : allPages;
  403. var hasPrev = this.hasPrev();
  404. var hasNext = this.hasNext();
  405. if (simple) {
  406. if (goButton) {
  407. if (typeof goButton === 'boolean') {
  408. gotoButton = (0, _vue.createVNode)("button", {
  409. "type": "button",
  410. "onClick": this.handleGoTO,
  411. "onKeyup": this.handleGoTO
  412. }, [locale.jump_to_confirm]);
  413. } else {
  414. gotoButton = (0, _vue.createVNode)("span", {
  415. "onClick": this.handleGoTO,
  416. "onKeyup": this.handleGoTO
  417. }, [goButton]);
  418. }
  419. var _gotoButton = function () {
  420. return gotoButton;
  421. }();
  422. gotoButton = (0, _vue.createVNode)("li", {
  423. "title": showTitle ? "".concat(locale.jump_to).concat(stateCurrent, "/").concat(allPages) : null,
  424. "class": "".concat(prefixCls, "-simple-pager")
  425. }, [gotoButton]);
  426. }
  427. return (0, _vue.createVNode)("ul", (0, _objectSpread2.default)({
  428. "class": (0, _classNames9.default)("".concat(prefixCls, " ").concat(prefixCls, "-simple"), (0, _defineProperty2.default)({}, "".concat(prefixCls, "-disabled"), disabled), className)
  429. }, restAttrs), [(0, _vue.createVNode)("li", {
  430. "title": showTitle ? locale.prev_page : null,
  431. "onClick": this.prev,
  432. "tabindex": hasPrev ? 0 : null,
  433. "onKeypress": this.runIfEnterPrev,
  434. "class": (0, _classNames9.default)("".concat(prefixCls, "-prev"), (0, _defineProperty2.default)({}, "".concat(prefixCls, "-disabled"), !hasPrev)),
  435. "aria-disabled": !hasPrev
  436. }, [this.renderPrev(prevPage)]), (0, _vue.createVNode)("li", {
  437. "title": showTitle ? "".concat(stateCurrent, "/").concat(allPages) : null,
  438. "class": "".concat(prefixCls, "-simple-pager")
  439. }, [(0, _vue.withDirectives)((0, _vue.createVNode)("input", {
  440. "type": "text",
  441. "value": this.stateCurrentInputValue,
  442. "disabled": disabled,
  443. "onKeydown": this.handleKeyDown,
  444. "onKeyup": this.handleKeyUp,
  445. "onInput": this.handleKeyUp,
  446. "onChange": this.handleKeyUp,
  447. "size": "3"
  448. }, null), [[_antInputDirective.default]]), (0, _vue.createVNode)("span", {
  449. "class": "".concat(prefixCls, "-slash")
  450. }, [(0, _vue.createTextVNode)("\uFF0F")]), allPages]), (0, _vue.createVNode)("li", {
  451. "title": showTitle ? locale.next_page : null,
  452. "onClick": this.next,
  453. "tabindex": hasNext ? 0 : null,
  454. "onKeypress": this.runIfEnterNext,
  455. "class": (0, _classNames9.default)("".concat(prefixCls, "-next"), (0, _defineProperty2.default)({}, "".concat(prefixCls, "-disabled"), !hasNext)),
  456. "aria-disabled": !hasNext
  457. }, [this.renderNext(nextPage)]), gotoButton]);
  458. }
  459. if (allPages <= 3 + pageBufferSize * 2) {
  460. var pagerProps = {
  461. locale: locale,
  462. rootPrefixCls: prefixCls,
  463. showTitle: showTitle,
  464. itemRender: itemRender,
  465. onClick: this.handleChange,
  466. onKeypress: this.runIfEnter
  467. };
  468. if (!allPages) {
  469. pagerList.push((0, _vue.createVNode)(_Pager.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, pagerProps), {}, {
  470. "key": "noPager",
  471. "page": 1,
  472. "class": "".concat(prefixCls, "-item-disabled")
  473. }), null));
  474. }
  475. for (var i = 1; i <= allPages; i += 1) {
  476. var active = stateCurrent === i;
  477. pagerList.push((0, _vue.createVNode)(_Pager.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, pagerProps), {}, {
  478. "key": i,
  479. "page": i,
  480. "active": active
  481. }), null));
  482. }
  483. } else {
  484. var prevItemTitle = showLessItems ? locale.prev_3 : locale.prev_5;
  485. var nextItemTitle = showLessItems ? locale.next_3 : locale.next_5;
  486. if (showPrevNextJumpers) {
  487. jumpPrev = (0, _vue.createVNode)("li", {
  488. "title": this.showTitle ? prevItemTitle : null,
  489. "key": "prev",
  490. "onClick": this.jumpPrev,
  491. "tabindex": "0",
  492. "onKeypress": this.runIfEnterJumpPrev,
  493. "class": (0, _classNames9.default)("".concat(prefixCls, "-jump-prev"), (0, _defineProperty2.default)({}, "".concat(prefixCls, "-jump-prev-custom-icon"), !!jumpPrevIcon))
  494. }, [itemRender({
  495. page: this.getJumpPrevPage(),
  496. type: 'jump-prev',
  497. originalElement: this.getItemIcon('jumpPrevIcon', 'prev page')
  498. })]);
  499. jumpNext = (0, _vue.createVNode)("li", {
  500. "title": this.showTitle ? nextItemTitle : null,
  501. "key": "next",
  502. "tabindex": "0",
  503. "onClick": this.jumpNext,
  504. "onKeypress": this.runIfEnterJumpNext,
  505. "class": (0, _classNames9.default)("".concat(prefixCls, "-jump-next"), (0, _defineProperty2.default)({}, "".concat(prefixCls, "-jump-next-custom-icon"), !!jumpNextIcon))
  506. }, [itemRender({
  507. page: this.getJumpNextPage(),
  508. type: 'jump-next',
  509. originalElement: this.getItemIcon('jumpNextIcon', 'next page')
  510. })]);
  511. }
  512. lastPager = (0, _vue.createVNode)(_Pager.default, {
  513. "locale": locale,
  514. "last": true,
  515. "rootPrefixCls": prefixCls,
  516. "onClick": this.handleChange,
  517. "onKeypress": this.runIfEnter,
  518. "key": allPages,
  519. "page": allPages,
  520. "active": false,
  521. "showTitle": showTitle,
  522. "itemRender": itemRender
  523. }, null);
  524. firstPager = (0, _vue.createVNode)(_Pager.default, {
  525. "locale": locale,
  526. "rootPrefixCls": prefixCls,
  527. "onClick": this.handleChange,
  528. "onKeypress": this.runIfEnter,
  529. "key": 1,
  530. "page": 1,
  531. "active": false,
  532. "showTitle": showTitle,
  533. "itemRender": itemRender
  534. }, null);
  535. var left = Math.max(1, stateCurrent - pageBufferSize);
  536. var right = Math.min(stateCurrent + pageBufferSize, allPages);
  537. if (stateCurrent - 1 <= pageBufferSize) {
  538. right = 1 + pageBufferSize * 2;
  539. }
  540. if (allPages - stateCurrent <= pageBufferSize) {
  541. left = allPages - pageBufferSize * 2;
  542. }
  543. for (var _i = left; _i <= right; _i += 1) {
  544. var _active = stateCurrent === _i;
  545. pagerList.push((0, _vue.createVNode)(_Pager.default, {
  546. "locale": locale,
  547. "rootPrefixCls": prefixCls,
  548. "onClick": this.handleChange,
  549. "onKeypress": this.runIfEnter,
  550. "key": _i,
  551. "page": _i,
  552. "active": _active,
  553. "showTitle": showTitle,
  554. "itemRender": itemRender
  555. }, null));
  556. }
  557. if (stateCurrent - 1 >= pageBufferSize * 2 && stateCurrent !== 1 + 2) {
  558. pagerList[0] = (0, _vue.createVNode)(_Pager.default, {
  559. "locale": locale,
  560. "rootPrefixCls": prefixCls,
  561. "onClick": this.handleChange,
  562. "onKeypress": this.runIfEnter,
  563. "key": left,
  564. "page": left,
  565. "class": "".concat(prefixCls, "-item-after-jump-prev"),
  566. "active": false,
  567. "showTitle": this.showTitle,
  568. "itemRender": itemRender
  569. }, null);
  570. pagerList.unshift(jumpPrev);
  571. }
  572. if (allPages - stateCurrent >= pageBufferSize * 2 && stateCurrent !== allPages - 2) {
  573. pagerList[pagerList.length - 1] = (0, _vue.createVNode)(_Pager.default, {
  574. "locale": locale,
  575. "rootPrefixCls": prefixCls,
  576. "onClick": this.handleChange,
  577. "onKeypress": this.runIfEnter,
  578. "key": right,
  579. "page": right,
  580. "class": "".concat(prefixCls, "-item-before-jump-next"),
  581. "active": false,
  582. "showTitle": this.showTitle,
  583. "itemRender": itemRender
  584. }, null);
  585. pagerList.push(jumpNext);
  586. }
  587. if (left !== 1) {
  588. pagerList.unshift(firstPager);
  589. }
  590. if (right !== allPages) {
  591. pagerList.push(lastPager);
  592. }
  593. }
  594. var totalText = null;
  595. if (showTotal) {
  596. totalText = (0, _vue.createVNode)("li", {
  597. "class": "".concat(prefixCls, "-total-text")
  598. }, [showTotal(total, [total === 0 ? 0 : (stateCurrent - 1) * statePageSize + 1, stateCurrent * statePageSize > total ? total : stateCurrent * statePageSize])]);
  599. }
  600. var prevDisabled = !hasPrev || !allPages;
  601. var nextDisabled = !hasNext || !allPages;
  602. var buildOptionText = this.buildOptionText || this.$slots.buildOptionText;
  603. return (0, _vue.createVNode)("ul", (0, _objectSpread2.default)((0, _objectSpread2.default)({
  604. "unselectable": "on",
  605. "ref": "paginationNode"
  606. }, restAttrs), {}, {
  607. "class": (0, _classNames9.default)((_classNames6 = {}, (0, _defineProperty2.default)(_classNames6, "".concat(prefixCls), true), (0, _defineProperty2.default)(_classNames6, "".concat(prefixCls, "-disabled"), disabled), _classNames6), className)
  608. }), [totalText, (0, _vue.createVNode)("li", {
  609. "title": showTitle ? locale.prev_page : null,
  610. "onClick": this.prev,
  611. "tabindex": prevDisabled ? null : 0,
  612. "onKeypress": this.runIfEnterPrev,
  613. "class": (0, _classNames9.default)("".concat(prefixCls, "-prev"), (0, _defineProperty2.default)({}, "".concat(prefixCls, "-disabled"), prevDisabled)),
  614. "aria-disabled": prevDisabled
  615. }, [this.renderPrev(prevPage)]), pagerList, (0, _vue.createVNode)("li", {
  616. "title": showTitle ? locale.next_page : null,
  617. "onClick": this.next,
  618. "tabindex": nextDisabled ? null : 0,
  619. "onKeypress": this.runIfEnterNext,
  620. "class": (0, _classNames9.default)("".concat(prefixCls, "-next"), (0, _defineProperty2.default)({}, "".concat(prefixCls, "-disabled"), nextDisabled)),
  621. "aria-disabled": nextDisabled
  622. }, [this.renderNext(nextPage)]), (0, _vue.createVNode)(_Options.default, {
  623. "disabled": disabled,
  624. "locale": locale,
  625. "rootPrefixCls": prefixCls,
  626. "selectComponentClass": selectComponentClass,
  627. "selectPrefixCls": selectPrefixCls,
  628. "changeSize": this.getShowSizeChanger() ? this.changePageSize : null,
  629. "current": stateCurrent,
  630. "pageSize": statePageSize,
  631. "pageSizeOptions": pageSizeOptions,
  632. "buildOptionText": buildOptionText || null,
  633. "quickGo": this.shouldDisplayQuickJumper() ? this.handleChange : null,
  634. "goButton": goButton
  635. }, null)]);
  636. }
  637. });
  638. exports.default = _default;