1 | 'use strict';
|
2 |
|
3 | exports.__esModule = true;
|
4 |
|
5 | var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
6 |
|
7 | var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
8 |
|
9 | var _extends2 = require('babel-runtime/helpers/extends');
|
10 |
|
11 | var _extends3 = _interopRequireDefault(_extends2);
|
12 |
|
13 | var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
14 |
|
15 | var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
16 |
|
17 | var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
18 |
|
19 | var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
20 |
|
21 | var _inherits2 = require('babel-runtime/helpers/inherits');
|
22 |
|
23 | var _inherits3 = _interopRequireDefault(_inherits2);
|
24 |
|
25 | var _class, _temp;
|
26 |
|
27 | var _react = require('react');
|
28 |
|
29 | var _react2 = _interopRequireDefault(_react);
|
30 |
|
31 | var _propTypes = require('prop-types');
|
32 |
|
33 | var _propTypes2 = _interopRequireDefault(_propTypes);
|
34 |
|
35 | var _reactLifecyclesCompat = require('react-lifecycles-compat');
|
36 |
|
37 | var _classnames = require('classnames');
|
38 |
|
39 | var _classnames2 = _interopRequireDefault(_classnames);
|
40 |
|
41 | var _configProvider = require('../config-provider');
|
42 |
|
43 | var _configProvider2 = _interopRequireDefault(_configProvider);
|
44 |
|
45 | var _icon = require('../icon');
|
46 |
|
47 | var _icon2 = _interopRequireDefault(_icon);
|
48 |
|
49 | var _button = require('../button');
|
50 |
|
51 | var _button2 = _interopRequireDefault(_button);
|
52 |
|
53 | var _input = require('../input');
|
54 |
|
55 | var _input2 = _interopRequireDefault(_input);
|
56 |
|
57 | var _select = require('../select');
|
58 |
|
59 | var _select2 = _interopRequireDefault(_select);
|
60 |
|
61 | var _util = require('../util');
|
62 |
|
63 | var _zhCn = require('../locale/zh-cn.js');
|
64 |
|
65 | var _zhCn2 = _interopRequireDefault(_zhCn);
|
66 |
|
67 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
68 |
|
69 | var Option = _select2.default.Option;
|
70 |
|
71 | var noop = function noop() {};
|
72 |
|
73 | function correctCurrent(currentPage, total, currentPageSize) {
|
74 | var totalPage = getTotalPage(total, currentPageSize);
|
75 | return currentPage > totalPage ? totalPage : currentPage;
|
76 | }
|
77 |
|
78 | function getTotalPage(total, currentPageSize) {
|
79 | var totalPage = Math.ceil(total / currentPageSize);
|
80 | return totalPage <= 0 ? 1 : totalPage;
|
81 | }
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | var Pagination = (_temp = _class = function (_Component) {
|
87 | (0, _inherits3.default)(Pagination, _Component);
|
88 |
|
89 | function Pagination(props, context) {
|
90 | (0, _classCallCheck3.default)(this, Pagination);
|
91 |
|
92 | var _this = (0, _possibleConstructorReturn3.default)(this, _Component.call(this, props, context));
|
93 |
|
94 | _this.handleJump = function (e) {
|
95 | var total = _this.props.total;
|
96 | var _this$state = _this.state,
|
97 | current = _this$state.current,
|
98 | currentPageSize = _this$state.currentPageSize,
|
99 | inputValue = _this$state.inputValue;
|
100 |
|
101 | var totalPage = getTotalPage(total, currentPageSize);
|
102 | var value = parseInt(inputValue, 10);
|
103 |
|
104 | if (isNaN(value)) {
|
105 | value = '';
|
106 | } else if (value < 1) {
|
107 | value = 1;
|
108 | } else if (value > totalPage) {
|
109 | value = totalPage;
|
110 | }
|
111 |
|
112 | if (value && value !== current) {
|
113 | _this.onPageItemClick(value, e);
|
114 | }
|
115 |
|
116 | _this.setState({
|
117 | inputValue: ''
|
118 | });
|
119 | };
|
120 |
|
121 | _this.state = {
|
122 | current: props.defaultCurrent || 1,
|
123 | currentPageSize: 0,
|
124 | inputValue: ''
|
125 | };
|
126 | return _this;
|
127 | }
|
128 |
|
129 | Pagination.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
|
130 | var current = props.current,
|
131 | total = props.total,
|
132 | pageSize = props.pageSize;
|
133 |
|
134 | var st = {};
|
135 | var newCurrent = correctCurrent(current || state.current, total, pageSize);
|
136 | if (state.current !== newCurrent) {
|
137 | st.current = newCurrent;
|
138 | }
|
139 | if (state.currentPageSize !== pageSize) {
|
140 | st.currentPageSize = pageSize;
|
141 | }
|
142 |
|
143 | return st;
|
144 | };
|
145 |
|
146 | Pagination.prototype.onPageItemClick = function onPageItemClick(page, e) {
|
147 | if (!('current' in this.props)) {
|
148 | this.setState({
|
149 | current: page
|
150 | });
|
151 | }
|
152 | this.props.onChange(page, e);
|
153 | };
|
154 |
|
155 | Pagination.prototype.onInputChange = function onInputChange(value) {
|
156 | this.setState({
|
157 | inputValue: value
|
158 | });
|
159 | };
|
160 |
|
161 | Pagination.prototype.onSelectSize = function onSelectSize(pageSize) {
|
162 | var newState = {
|
163 | currentPageSize: pageSize
|
164 | };
|
165 |
|
166 | var totalPage = getTotalPage(this.props.total, pageSize);
|
167 | if (this.state.current > totalPage) {
|
168 | newState.current = totalPage;
|
169 | }
|
170 |
|
171 | this.setState(newState);
|
172 | this.props.onPageSizeChange(pageSize);
|
173 | };
|
174 |
|
175 | Pagination.prototype.renderPageTotal = function renderPageTotal() {
|
176 | var _props = this.props,
|
177 | prefix = _props.prefix,
|
178 | total = _props.total,
|
179 | totalRender = _props.totalRender;
|
180 | var _state = this.state,
|
181 | currentPageSize = _state.currentPageSize,
|
182 | current = _state.current;
|
183 |
|
184 | var range = [(current - 1) * currentPageSize + 1, current * currentPageSize];
|
185 |
|
186 | return _react2.default.createElement(
|
187 | 'div',
|
188 | { className: prefix + 'pagination-total' },
|
189 | totalRender(total, range)
|
190 | );
|
191 | };
|
192 |
|
193 | Pagination.prototype.renderPageItem = function renderPageItem(index) {
|
194 | var _cx;
|
195 |
|
196 | var _props2 = this.props,
|
197 | prefix = _props2.prefix,
|
198 | size = _props2.size,
|
199 | link = _props2.link,
|
200 | pageNumberRender = _props2.pageNumberRender,
|
201 | total = _props2.total,
|
202 | pageSize = _props2.pageSize,
|
203 | locale = _props2.locale;
|
204 | var current = this.state.current;
|
205 |
|
206 |
|
207 | var totalPage = getTotalPage(total, pageSize);
|
208 | var isCurrent = parseInt(index, 10) === current;
|
209 | var props = {
|
210 | size: size,
|
211 | className: (0, _classnames2.default)((_cx = {}, _cx[prefix + 'pagination-item'] = true, _cx[prefix + 'current'] = isCurrent, _cx)),
|
212 | onClick: isCurrent ? noop : this.onPageItemClick.bind(this, index)
|
213 | };
|
214 | if (link) {
|
215 | props.component = 'a';
|
216 | props.href = link.replace('{page}', index);
|
217 | }
|
218 |
|
219 | return _react2.default.createElement(
|
220 | _button2.default,
|
221 | (0, _extends3.default)({
|
222 | 'aria-label': _util.str.template(locale.total, {
|
223 | current: index,
|
224 | total: totalPage
|
225 | })
|
226 | }, props, {
|
227 | key: index
|
228 | }),
|
229 | pageNumberRender(index)
|
230 | );
|
231 | };
|
232 |
|
233 | Pagination.prototype.renderPageFirst = function renderPageFirst(current) {
|
234 | var _cx2;
|
235 |
|
236 | var _props3 = this.props,
|
237 | prefix = _props3.prefix,
|
238 | size = _props3.size,
|
239 | shape = _props3.shape,
|
240 | locale = _props3.locale;
|
241 |
|
242 |
|
243 | var isFirst = current <= 1;
|
244 | var props = {
|
245 | disabled: isFirst,
|
246 | size: size,
|
247 | className: (0, _classnames2.default)((_cx2 = {}, _cx2[prefix + 'pagination-item'] = true, _cx2[prefix + 'prev'] = true, _cx2)),
|
248 | onClick: this.onPageItemClick.bind(this, current - 1)
|
249 | };
|
250 |
|
251 | var icon = _react2.default.createElement(_icon2.default, { type: 'arrow-left', className: prefix + 'pagination-icon-prev' });
|
252 |
|
253 | return _react2.default.createElement(
|
254 | _button2.default,
|
255 | (0, _extends3.default)({}, props, { 'aria-label': _util.str.template(locale.labelPrev, { current: current }) }),
|
256 | icon,
|
257 | shape === 'arrow-only' || shape === 'arrow-prev-only' || shape === 'no-border' ? '' : locale.prev
|
258 | );
|
259 | };
|
260 |
|
261 | Pagination.prototype.renderPageLast = function renderPageLast(current, totalPage) {
|
262 | var _cx3;
|
263 |
|
264 | var _props4 = this.props,
|
265 | prefix = _props4.prefix,
|
266 | size = _props4.size,
|
267 | shape = _props4.shape,
|
268 | locale = _props4.locale;
|
269 |
|
270 |
|
271 | var isLast = current >= totalPage;
|
272 | var props = {
|
273 | disabled: isLast,
|
274 | size: size,
|
275 | className: (0, _classnames2.default)((_cx3 = {}, _cx3[prefix + 'pagination-item'] = true, _cx3[prefix + 'next'] = true, _cx3)),
|
276 | onClick: this.onPageItemClick.bind(this, current + 1)
|
277 | };
|
278 |
|
279 | var icon = _react2.default.createElement(_icon2.default, { type: 'arrow-right', className: prefix + 'pagination-icon-next' });
|
280 |
|
281 | return _react2.default.createElement(
|
282 | _button2.default,
|
283 | (0, _extends3.default)({}, props, { 'aria-label': _util.str.template(locale.labelNext, { current: current }) }),
|
284 | shape === 'arrow-only' || shape === 'no-border' ? '' : locale.next,
|
285 | icon
|
286 | );
|
287 | };
|
288 |
|
289 | Pagination.prototype.renderPageEllipsis = function renderPageEllipsis(idx) {
|
290 | var prefix = this.props.prefix;
|
291 |
|
292 |
|
293 | return _react2.default.createElement(_icon2.default, {
|
294 | className: prefix + 'pagination-ellipsis ' + prefix + 'pagination-icon-ellipsis',
|
295 | type: 'ellipsis',
|
296 | key: 'ellipsis-' + idx
|
297 | });
|
298 | };
|
299 |
|
300 | Pagination.prototype.renderPageJump = function renderPageJump() {
|
301 | var _this2 = this;
|
302 |
|
303 | var _props5 = this.props,
|
304 | prefix = _props5.prefix,
|
305 | size = _props5.size,
|
306 | locale = _props5.locale;
|
307 | var inputValue = this.state.inputValue;
|
308 |
|
309 |
|
310 |
|
311 | return [_react2.default.createElement(
|
312 | 'span',
|
313 | { className: prefix + 'pagination-jump-text' },
|
314 | locale.goTo
|
315 | ), _react2.default.createElement(_input2.default, {
|
316 | className: prefix + 'pagination-jump-input',
|
317 | type: 'text',
|
318 | 'aria-label': locale.inputAriaLabel,
|
319 | size: size,
|
320 | value: inputValue,
|
321 | onChange: this.onInputChange.bind(this),
|
322 | onKeyDown: function onKeyDown(e) {
|
323 | if (e.keyCode === _util.KEYCODE.ENTER) {
|
324 | _this2.handleJump(e);
|
325 | }
|
326 | }
|
327 | }), _react2.default.createElement(
|
328 | 'span',
|
329 | { className: prefix + 'pagination-jump-text' },
|
330 | locale.page
|
331 | ), _react2.default.createElement(
|
332 | _button2.default,
|
333 | { className: prefix + 'pagination-jump-go', size: size, onClick: this.handleJump },
|
334 | locale.go
|
335 | )];
|
336 |
|
337 | };
|
338 |
|
339 | Pagination.prototype.renderPageDisplay = function renderPageDisplay(current, totalPage) {
|
340 | var _props6 = this.props,
|
341 | prefix = _props6.prefix,
|
342 | pageNumberRender = _props6.pageNumberRender;
|
343 |
|
344 |
|
345 | return _react2.default.createElement(
|
346 | 'span',
|
347 | { className: prefix + 'pagination-display' },
|
348 | _react2.default.createElement(
|
349 | 'em',
|
350 | null,
|
351 | pageNumberRender(current)
|
352 | ),
|
353 | '/',
|
354 | pageNumberRender(totalPage)
|
355 | );
|
356 | };
|
357 |
|
358 | Pagination.prototype.renderPageList = function renderPageList(current, totalPage) {
|
359 | var _props7 = this.props,
|
360 | prefix = _props7.prefix,
|
361 | pageShowCount = _props7.pageShowCount;
|
362 |
|
363 | var pages = [];
|
364 |
|
365 | if (totalPage <= pageShowCount) {
|
366 | for (var i = 1; i <= totalPage; i++) {
|
367 | pages.push(this.renderPageItem(i));
|
368 | }
|
369 | } else {
|
370 |
|
371 | var othersCount = pageShowCount - 3;
|
372 | var halfCount = parseInt(othersCount / 2, 10);
|
373 | var start = void 0,
|
374 | end = void 0;
|
375 |
|
376 | pages.push(this.renderPageItem(1));
|
377 |
|
378 | start = current - halfCount;
|
379 | end = current + halfCount;
|
380 | if (start <= 1) {
|
381 | start = 2;
|
382 | end = start + othersCount;
|
383 | }
|
384 | if (start > 2) {
|
385 | pages.push(this.renderPageEllipsis(1));
|
386 | }
|
387 | if (end >= totalPage - 1) {
|
388 | end = totalPage - 1;
|
389 | start = totalPage - 1 - othersCount;
|
390 | }
|
391 | for (var j = start; j <= end; j++) {
|
392 | pages.push(this.renderPageItem(j));
|
393 | }
|
394 | if (end < totalPage - 1) {
|
395 | pages.push(this.renderPageEllipsis(2));
|
396 | }
|
397 |
|
398 | pages.push(this.renderPageItem(totalPage));
|
399 | }
|
400 |
|
401 | return _react2.default.createElement(
|
402 | 'div',
|
403 | { className: prefix + 'pagination-list' },
|
404 | pages
|
405 | );
|
406 | };
|
407 |
|
408 | Pagination.prototype.renderPageSizeSelector = function renderPageSizeSelector() {
|
409 | var _props8 = this.props,
|
410 | prefix = _props8.prefix,
|
411 | pageSizeSelector = _props8.pageSizeSelector,
|
412 | locale = _props8.locale;
|
413 |
|
414 | var pageSizeSpan = _react2.default.createElement(
|
415 | 'span',
|
416 | { className: prefix + 'pagination-size-selector-title' },
|
417 | locale.pageSize
|
418 | );
|
419 |
|
420 | switch (pageSizeSelector) {
|
421 | case 'filter':
|
422 | return _react2.default.createElement(
|
423 | 'div',
|
424 | { className: prefix + 'pagination-size-selector' },
|
425 | pageSizeSpan,
|
426 | this.renderPageSizeFilter()
|
427 | );
|
428 | case 'dropdown':
|
429 | return _react2.default.createElement(
|
430 | 'div',
|
431 | { className: prefix + 'pagination-size-selector' },
|
432 | pageSizeSpan,
|
433 | this.renderPageSizeDropdown()
|
434 | );
|
435 | default:
|
436 | return null;
|
437 | }
|
438 | };
|
439 |
|
440 | Pagination.prototype.renderPageSizeFilter = function renderPageSizeFilter() {
|
441 | var _this3 = this;
|
442 |
|
443 | var _props9 = this.props,
|
444 | prefix = _props9.prefix,
|
445 | size = _props9.size,
|
446 | pageSizeList = _props9.pageSizeList;
|
447 | var currentPageSize = this.state.currentPageSize;
|
448 |
|
449 |
|
450 | return _react2.default.createElement(
|
451 | 'div',
|
452 | { className: prefix + 'pagination-size-selector-filter' },
|
453 | pageSizeList.map(function (item, index) {
|
454 | var _cx4;
|
455 |
|
456 | var label = void 0;
|
457 | var pageSize = void 0;
|
458 | if (item.value) {
|
459 |
|
460 | label = item.label;
|
461 | pageSize = item.value;
|
462 | } else {
|
463 |
|
464 | label = pageSize = item;
|
465 | }
|
466 | var classes = (0, _classnames2.default)((_cx4 = {}, _cx4[prefix + 'pagination-size-selector-btn'] = true, _cx4[prefix + 'current'] = pageSize === currentPageSize, _cx4));
|
467 |
|
468 | return _react2.default.createElement(
|
469 | _button2.default,
|
470 | {
|
471 | key: index,
|
472 | text: true,
|
473 | size: size,
|
474 | className: classes,
|
475 | onClick: pageSize !== currentPageSize ? _this3.onSelectSize.bind(_this3, pageSize) : null
|
476 | },
|
477 | label
|
478 | );
|
479 | })
|
480 | );
|
481 | };
|
482 |
|
483 | Pagination.prototype.renderPageSizeDropdown = function renderPageSizeDropdown() {
|
484 | var _props10 = this.props,
|
485 | prefix = _props10.prefix,
|
486 | size = _props10.size,
|
487 | pageSizeList = _props10.pageSizeList,
|
488 | locale = _props10.locale,
|
489 | popupProps = _props10.popupProps,
|
490 | selectProps = _props10.selectProps;
|
491 | var currentPageSize = this.state.currentPageSize;
|
492 |
|
493 |
|
494 | return _react2.default.createElement(
|
495 | _select2.default,
|
496 | (0, _extends3.default)({
|
497 | className: prefix + 'pagination-size-selector-dropdown',
|
498 | popupClassName: prefix + 'pagination-size-selector-popup',
|
499 | popupProps: popupProps,
|
500 | 'aria-label': locale.selectAriaLabel,
|
501 | autoWidth: false,
|
502 | size: size,
|
503 | value: currentPageSize,
|
504 | onChange: this.onSelectSize.bind(this)
|
505 | }, selectProps),
|
506 | pageSizeList.map(function (item, index) {
|
507 | var label = void 0;
|
508 | var pageSize = void 0;
|
509 | if (item.value) {
|
510 |
|
511 | label = item.label;
|
512 | pageSize = item.value;
|
513 | } else {
|
514 |
|
515 | label = pageSize = item;
|
516 | }
|
517 | return _react2.default.createElement(
|
518 | Option,
|
519 | { key: index, value: pageSize },
|
520 | label
|
521 | );
|
522 | })
|
523 | );
|
524 | };
|
525 |
|
526 | Pagination.prototype.render = function render() {
|
527 | var _cx5,
|
528 | _this4 = this;
|
529 |
|
530 |
|
531 | var _props11 = this.props,
|
532 | prefix = _props11.prefix,
|
533 | pure = _props11.pure,
|
534 | rtl = _props11.rtl,
|
535 | device = _props11.device,
|
536 | paginationType = _props11.type,
|
537 | size = _props11.size,
|
538 | shape = _props11.shape,
|
539 | className = _props11.className,
|
540 | total = _props11.total,
|
541 | totalRender = _props11.totalRender,
|
542 | pageSize = _props11.pageSize,
|
543 | pageSizeSelector = _props11.pageSizeSelector,
|
544 | pageSizeList = _props11.pageSizeList,
|
545 | pageSizePosition = _props11.pageSizePosition,
|
546 | useFloatLayout = _props11.useFloatLayout,
|
547 | onPageSizeChange = _props11.onPageSizeChange,
|
548 | hideOnlyOnePage = _props11.hideOnlyOnePage,
|
549 | showJump = _props11.showJump,
|
550 | locale = _props11.locale,
|
551 | current = _props11.current,
|
552 | defaultCurrent = _props11.defaultCurrent,
|
553 | pageShowCount = _props11.pageShowCount,
|
554 | pageNumberRender = _props11.pageNumberRender,
|
555 | link = _props11.link,
|
556 | onChange = _props11.onChange,
|
557 | popupProps = _props11.popupProps,
|
558 | selectProps = _props11.selectProps,
|
559 | others = (0, _objectWithoutProperties3.default)(_props11, ['prefix', 'pure', 'rtl', 'device', 'type', 'size', 'shape', 'className', 'total', 'totalRender', 'pageSize', 'pageSizeSelector', 'pageSizeList', 'pageSizePosition', 'useFloatLayout', 'onPageSizeChange', 'hideOnlyOnePage', 'showJump', 'locale', 'current', 'defaultCurrent', 'pageShowCount', 'pageNumberRender', 'link', 'onChange', 'popupProps', 'selectProps']);
|
560 |
|
561 |
|
562 | var _state2 = this.state,
|
563 | currentPage = _state2.current,
|
564 | currentPageSize = _state2.currentPageSize;
|
565 |
|
566 | var totalPage = getTotalPage(total, currentPageSize);
|
567 | var pageFirst = this.renderPageFirst(currentPage);
|
568 | var pageLast = this.renderPageLast(currentPage, totalPage);
|
569 | var sizeSelector = this.renderPageSizeSelector();
|
570 | var isStart = pageSizePosition === 'start';
|
571 |
|
572 | var type = paginationType;
|
573 |
|
574 | if (device === 'phone' && type === 'normal') {
|
575 | type = 'simple';
|
576 | }
|
577 |
|
578 | var classes = (0, _classnames2.default)((_cx5 = {}, _cx5[prefix + 'pagination'] = true, _cx5['' + prefix + size] = size, _cx5['' + prefix + type] = type, _cx5['' + prefix + shape] = shape, _cx5[prefix + 'start'] = !!pageSizeSelector && isStart && useFloatLayout, _cx5[prefix + 'end'] = !!pageSizeSelector && !isStart && useFloatLayout, _cx5[prefix + 'hide'] = totalPage <= 1 && hideOnlyOnePage, _cx5[className] = !!className, _cx5));
|
579 |
|
580 | if (rtl) {
|
581 | others.dir = 'rtl';
|
582 | }
|
583 |
|
584 | var buildComponent = function buildComponent() {
|
585 | for (var _len = arguments.length, coms = Array(_len), _key = 0; _key < _len; _key++) {
|
586 | coms[_key] = arguments[_key];
|
587 | }
|
588 |
|
589 | return _react2.default.createElement(
|
590 | 'div',
|
591 | (0, _extends3.default)({ className: classes }, _util.obj.pickOthers(Object.keys(Pagination.propTypes), others)),
|
592 | isStart && sizeSelector,
|
593 | totalRender ? _this4.renderPageTotal() : null,
|
594 | _react2.default.createElement(
|
595 | 'div',
|
596 | { className: prefix + 'pagination-pages' },
|
597 | coms.map(function (com, index) {
|
598 | return com && _react2.default.cloneElement(com, { key: index });
|
599 | })
|
600 | ),
|
601 | !isStart && sizeSelector
|
602 | );
|
603 | };
|
604 |
|
605 | switch (type) {
|
606 | case 'mini':
|
607 | return buildComponent(pageFirst, pageLast);
|
608 | case 'simple':
|
609 | {
|
610 | var pageDisplay = this.renderPageDisplay(currentPage, totalPage);
|
611 | return buildComponent(pageFirst, pageDisplay, pageLast);
|
612 | }
|
613 | case 'normal':
|
614 | {
|
615 | var pageList = this.renderPageList(currentPage, totalPage);
|
616 | var _pageDisplay = showJump && total > pageSize * pageShowCount ? this.renderPageDisplay(currentPage, totalPage) : null;
|
617 | var pageJump = showJump && total > pageSize * pageShowCount ? this.renderPageJump(currentPage, totalPage) : null;
|
618 | return buildComponent.apply(undefined, [pageFirst, pageList, pageLast, _pageDisplay].concat(pageJump));
|
619 | }
|
620 | default:
|
621 | return null;
|
622 | }
|
623 | };
|
624 |
|
625 | return Pagination;
|
626 | }(_react.Component), _class.propTypes = (0, _extends3.default)({}, _configProvider2.default.propTypes, {
|
627 | prefix: _propTypes2.default.string,
|
628 | pure: _propTypes2.default.bool,
|
629 | rtl: _propTypes2.default.bool,
|
630 | device: _propTypes2.default.oneOf(['desktop', 'tablet', 'phone']),
|
631 | className: _propTypes2.default.string,
|
632 | |
633 |
|
634 |
|
635 | locale: _propTypes2.default.object,
|
636 | |
637 |
|
638 |
|
639 | type: _propTypes2.default.oneOf(['normal', 'simple', 'mini']),
|
640 | |
641 |
|
642 |
|
643 | shape: _propTypes2.default.oneOf(['normal', 'arrow-only', 'arrow-prev-only', 'no-border']),
|
644 | |
645 |
|
646 |
|
647 | size: _propTypes2.default.oneOf(['small', 'medium', 'large']),
|
648 | |
649 |
|
650 |
|
651 | current: _propTypes2.default.number,
|
652 | |
653 |
|
654 |
|
655 | defaultCurrent: _propTypes2.default.number,
|
656 | |
657 |
|
658 |
|
659 |
|
660 |
|
661 | onChange: _propTypes2.default.func,
|
662 | |
663 |
|
664 |
|
665 | total: _propTypes2.default.number,
|
666 | |
667 |
|
668 |
|
669 |
|
670 |
|
671 | totalRender: _propTypes2.default.func,
|
672 | |
673 |
|
674 |
|
675 | pageShowCount: _propTypes2.default.number,
|
676 | |
677 |
|
678 |
|
679 | pageSize: _propTypes2.default.number,
|
680 | |
681 |
|
682 |
|
683 | pageSizeSelector: _propTypes2.default.oneOf([false, 'filter', 'dropdown']),
|
684 | |
685 |
|
686 |
|
687 | pageSizeList: _propTypes2.default.oneOfType([_propTypes2.default.arrayOf(_propTypes2.default.number), _propTypes2.default.arrayOf(_propTypes2.default.shape({
|
688 | label: _propTypes2.default.string,
|
689 | value: _propTypes2.default.number
|
690 | }))]),
|
691 | |
692 |
|
693 |
|
694 |
|
695 |
|
696 | pageNumberRender: _propTypes2.default.func,
|
697 | |
698 |
|
699 |
|
700 | pageSizePosition: _propTypes2.default.oneOf(['start', 'end']),
|
701 | |
702 |
|
703 |
|
704 | useFloatLayout: _propTypes2.default.bool,
|
705 | |
706 |
|
707 |
|
708 |
|
709 | onPageSizeChange: _propTypes2.default.func,
|
710 | |
711 |
|
712 |
|
713 | hideOnlyOnePage: _propTypes2.default.bool,
|
714 | |
715 |
|
716 |
|
717 | showJump: _propTypes2.default.bool,
|
718 | |
719 |
|
720 |
|
721 | link: _propTypes2.default.string,
|
722 | |
723 |
|
724 |
|
725 | popupProps: _propTypes2.default.object,
|
726 | selectProps: _propTypes2.default.object
|
727 | }), _class.defaultProps = {
|
728 | prefix: 'next-',
|
729 | pure: false,
|
730 | rtl: false,
|
731 | locale: _zhCn2.default.Pagination,
|
732 | type: 'normal',
|
733 | shape: 'normal',
|
734 | size: 'medium',
|
735 | defaultCurrent: 1,
|
736 | onChange: noop,
|
737 | pageSize: 10,
|
738 | pageSizeSelector: false,
|
739 | pageSizeList: [5, 10, 20],
|
740 | pageSizePosition: 'start',
|
741 | onPageSizeChange: noop,
|
742 | useFloatLayout: false,
|
743 | total: 100,
|
744 | pageShowCount: 5,
|
745 | hideOnlyOnePage: false,
|
746 | showJump: true,
|
747 | pageNumberRender: function pageNumberRender(index) {
|
748 | return index;
|
749 | }
|
750 | }, _temp);
|
751 | Pagination.displayName = 'Pagination';
|
752 | exports.default = _configProvider2.default.config((0, _reactLifecyclesCompat.polyfill)(Pagination));
|
753 | module.exports = exports['default']; |
\ | No newline at end of file |