Pagination.js 23 KB

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