Socket
Socket
Sign inDemoInstall

rc-pagination

Package Overview
Dependencies
Maintainers
3
Versions
202
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-pagination - npm Package Compare versions

Comparing version 1.5.5 to 1.6.0

5

HISTORY.md

@@ -0,1 +1,6 @@

1.5.6 / 2016-11-15
==================
* Add `range` as showTotal's second argument.
1.5.5 / 2016-09-01

@@ -2,0 +7,0 @@ ==================

2

lib/index.js

@@ -1,4 +0,4 @@

// export this package's api
'use strict';
// export this package's api
module.exports = require('./Pagination');
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports['default'] = {
exports["default"] = {
// Options.jsx

@@ -8,0 +8,0 @@ items_per_page: '/ page',

'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports['default'] = {
exports["default"] = {
// Options.jsx
items_per_page: '/page',
items_per_page: '/странице',
jump_to: 'Перейти',

@@ -10,0 +10,0 @@ page: '',

'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports['default'] = {
exports["default"] = {
// Options.jsx

@@ -8,0 +8,0 @@ items_per_page: '条/页',

'use strict';
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }

@@ -14,13 +14,11 @@ var React = require('react');

var Options = (function (_React$Component) {
var Options = function (_React$Component) {
_inherits(Options, _React$Component);
function Options(props) {
var _this = this;
_classCallCheck(this, Options);
_get(Object.getPrototypeOf(Options.prototype), 'constructor', this).call(this, props);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
this.state = {
_this.state = {
current: props.current,

@@ -33,108 +31,110 @@ _current: props.current

});
return _this;
}
_createClass(Options, [{
key: '_buildOptionText',
value: function _buildOptionText(value) {
return value + ' ' + this.props.locale.items_per_page;
Options.prototype._buildOptionText = function _buildOptionText(value) {
return value + ' ' + this.props.locale.items_per_page;
};
Options.prototype._changeSize = function _changeSize(value) {
this.props.changeSize(Number(value));
};
Options.prototype._handleChange = function _handleChange(evt) {
var _val = evt.target.value;
this.setState({
_current: _val
});
};
Options.prototype._go = function _go(e) {
var _val = e.target.value;
if (_val === '') {
return;
}
}, {
key: '_changeSize',
value: function _changeSize(value) {
this.props.changeSize(Number(value));
var val = Number(this.state._current);
if (isNaN(val)) {
val = this.state.current;
}
}, {
key: '_handleChange',
value: function _handleChange(evt) {
var _val = evt.target.value;
if (e.keyCode === KEYCODE.ENTER) {
var c = this.props.quickGo(val);
this.setState({
_current: _val
_current: c,
current: c
});
}
}, {
key: '_go',
value: function _go(e) {
var _val = e.target.value;
if (_val === '') {
return;
}
var val = Number(this.state._current);
if (isNaN(val)) {
val = this.state.current;
}
if (e.keyCode === KEYCODE.ENTER) {
var c = this.props.quickGo(val);
this.setState({
_current: c,
current: c
});
}
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
};
var props = this.props;
var state = this.state;
var locale = props.locale;
var prefixCls = props.rootPrefixCls + '-options';
var changeSize = props.changeSize;
var quickGo = props.quickGo;
var buildOptionText = props.buildOptionText || this._buildOptionText;
var Select = props.selectComponentClass;
var changeSelect = null;
var goInput = null;
Options.prototype.render = function render() {
var _this2 = this;
if (!(changeSize || quickGo)) {
return null;
}
var props = this.props;
var state = this.state;
var locale = props.locale;
var prefixCls = props.rootPrefixCls + '-options';
var changeSize = props.changeSize;
var quickGo = props.quickGo;
var buildOptionText = props.buildOptionText || this._buildOptionText;
var Select = props.selectComponentClass;
var changeSelect = null;
var goInput = null;
if (changeSize && Select) {
(function () {
var Option = Select.Option;
var pageSize = props.pageSize || props.pageSizeOptions[0];
var options = props.pageSizeOptions.map(function (opt, i) {
return React.createElement(
Option,
{ key: i, value: opt },
buildOptionText(opt)
);
});
if (!(changeSize || quickGo)) {
return null;
}
changeSelect = React.createElement(
Select,
{
prefixCls: props.selectPrefixCls, showSearch: false,
className: prefixCls + '-size-changer',
optionLabelProp: 'children',
dropdownMatchSelectWidth: false,
value: pageSize + '', onChange: _this2._changeSize },
options
if (changeSize && Select) {
(function () {
var Option = Select.Option;
var pageSize = props.pageSize || props.pageSizeOptions[0];
var options = props.pageSizeOptions.map(function (opt, i) {
return React.createElement(
Option,
{ key: i, value: opt },
buildOptionText(opt)
);
})();
}
});
if (quickGo) {
goInput = React.createElement(
'div',
{ className: prefixCls + '-quick-jumper' },
locale.jump_to,
React.createElement('input', { type: 'text', value: state._current, onChange: this._handleChange.bind(this), onKeyUp: this._go.bind(this) }),
locale.page
changeSelect = React.createElement(
Select,
{
prefixCls: props.selectPrefixCls,
showSearch: false,
className: prefixCls + '-size-changer',
optionLabelProp: 'children',
dropdownMatchSelectWidth: false,
value: pageSize.toString(),
onChange: _this2._changeSize
},
options
);
}
})();
}
return React.createElement(
if (quickGo) {
goInput = React.createElement(
'div',
{ className: '' + prefixCls },
changeSelect,
goInput
{ className: prefixCls + '-quick-jumper' },
locale.jump_to,
React.createElement('input', {
type: 'text',
value: state._current,
onChange: this._handleChange,
onKeyUp: this._go
}),
locale.page
);
}
}]);
return React.createElement(
'div',
{ className: '' + prefixCls },
changeSelect,
goInput
);
};
return Options;
})(React.Component);
}(React.Component);

@@ -141,0 +141,0 @@ Options.propTypes = {

'use strict';
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
var React = require('react');
var Pager = (function (_React$Component) {
var Pager = function (_React$Component) {
_inherits(Pager, _React$Component);

@@ -19,30 +19,27 @@

_get(Object.getPrototypeOf(Pager.prototype), 'constructor', this).apply(this, arguments);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
_createClass(Pager, [{
key: 'render',
value: function render() {
var props = this.props;
var prefixCls = props.rootPrefixCls + '-item';
var cls = prefixCls + ' ' + prefixCls + '-' + props.page;
Pager.prototype.render = function render() {
var props = this.props;
var prefixCls = props.rootPrefixCls + '-item';
var cls = prefixCls + ' ' + prefixCls + '-' + props.page;
if (props.active) {
cls = cls + ' ' + prefixCls + '-active';
}
return React.createElement(
'li',
{ title: props.page, className: cls, onClick: props.onClick },
React.createElement(
'a',
null,
props.page
)
);
if (props.active) {
cls = cls + ' ' + prefixCls + '-active';
}
}]);
return React.createElement(
'li',
{ title: props.page, className: cls, onClick: props.onClick },
React.createElement(
'a',
null,
props.page
)
);
};
return Pager;
})(React.Component);
}(React.Component);

@@ -49,0 +46,0 @@ Pager.propTypes = {

'use strict';
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }

@@ -19,14 +19,12 @@ var React = require('react');

var Pagination = (function (_React$Component) {
var Pagination = function (_React$Component) {
_inherits(Pagination, _React$Component);
function Pagination(props) {
var _this = this;
_classCallCheck(this, Pagination);
_get(Object.getPrototypeOf(Pagination.prototype), 'constructor', this).call(this, props);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
var hasOnChange = props.onChange !== noop;
var hasCurrent = ('current' in props);
var hasCurrent = 'current' in props;
if (hasCurrent && !hasOnChange) {

@@ -46,3 +44,3 @@ console.warn('Warning: You provided a `current` prop to a Pagination component without an `onChange` handler. This will render a read-only component.'); // eslint-disable-line

this.state = {
_this.state = {
current: current,

@@ -56,297 +54,343 @@ _current: current,

});
return _this;
}
_createClass(Pagination, [{
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if ('current' in nextProps) {
this.setState({
current: nextProps.current,
_current: nextProps.current
});
}
Pagination.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if ('current' in nextProps) {
this.setState({
current: nextProps.current,
_current: nextProps.current
});
}
if ('pageSize' in nextProps) {
var newState = {};
var current = this.state.current;
var newCurrent = this._calcPage(nextProps.pageSize);
current = current > newCurrent ? newCurrent : current;
if (!('current' in nextProps)) {
newState.current = current;
newState._current = current;
}
newState.pageSize = nextProps.pageSize;
this.setState(newState);
if ('pageSize' in nextProps) {
var newState = {};
var current = this.state.current;
var newCurrent = this._calcPage(nextProps.pageSize);
current = current > newCurrent ? newCurrent : current;
if (!('current' in nextProps)) {
newState.current = current;
newState._current = current;
}
newState.pageSize = nextProps.pageSize;
this.setState(newState);
}
};
// private methods
// private methods
}, {
key: '_calcPage',
value: function _calcPage(p) {
var pageSize = p;
if (typeof pageSize === 'undefined') {
pageSize = this.state.pageSize;
}
return Math.floor((this.props.total - 1) / pageSize) + 1;
Pagination.prototype._calcPage = function _calcPage(p) {
var pageSize = p;
if (typeof pageSize === 'undefined') {
pageSize = this.state.pageSize;
}
}, {
key: '_isValid',
value: function _isValid(page) {
return typeof page === 'number' && page >= 1 && page !== this.state.current;
return Math.floor((this.props.total - 1) / pageSize) + 1;
};
Pagination.prototype._isValid = function _isValid(page) {
return typeof page === 'number' && page >= 1 && page !== this.state.current;
};
Pagination.prototype._handleKeyDown = function _handleKeyDown(evt) {
if (evt.keyCode === KEYCODE.ARROW_UP || evt.keyCode === KEYCODE.ARROW_DOWN) {
evt.preventDefault();
}
}, {
key: '_handleKeyDown',
value: function _handleKeyDown(evt) {
if (evt.keyCode === KEYCODE.ARROW_UP || evt.keyCode === KEYCODE.ARROW_DOWN) {
evt.preventDefault();
}
};
Pagination.prototype._handleKeyUp = function _handleKeyUp(evt) {
var _val = evt.target.value;
var val = void 0;
if (_val === '') {
val = _val;
} else if (isNaN(Number(_val))) {
val = this.state._current;
} else {
val = Number(_val);
}
}, {
key: '_handleKeyUp',
value: function _handleKeyUp(evt) {
var _val = evt.target.value;
var val = undefined;
if (_val === '') {
val = _val;
} else if (isNaN(Number(_val))) {
val = this.state._current;
} else {
val = Number(_val);
}
this.setState({
_current: val
});
this.setState({
_current: val
});
if (evt.keyCode === KEYCODE.ENTER) {
this._handleChange(val);
} else if (evt.keyCode === KEYCODE.ARROW_UP) {
this._handleChange(val - 1);
} else if (evt.keyCode === KEYCODE.ARROW_DOWN) {
this._handleChange(val + 1);
}
};
if (evt.keyCode === KEYCODE.ENTER) {
this._handleChange(val);
} else if (evt.keyCode === KEYCODE.ARROW_UP) {
this._handleChange(val - 1);
} else if (evt.keyCode === KEYCODE.ARROW_DOWN) {
this._handleChange(val + 1);
Pagination.prototype._changePageSize = function _changePageSize(size) {
var current = this.state.current;
var newCurrent = this._calcPage(size);
current = current > newCurrent ? newCurrent : current;
if (typeof size === 'number') {
if (!('pageSize' in this.props)) {
this.setState({
pageSize: size
});
}
}
}, {
key: '_changePageSize',
value: function _changePageSize(size) {
var current = this.state.current;
var newCurrent = this._calcPage(size);
current = current > newCurrent ? newCurrent : current;
if (typeof size === 'number') {
if (!('pageSize' in this.props)) {
this.setState({
pageSize: size
});
}
if (!('current' in this.props)) {
this.setState({
current: current,
_current: current
});
}
if (!('current' in this.props)) {
this.setState({
current: current,
_current: current
});
}
this.props.onShowSizeChange(current, size);
}
}, {
key: '_handleChange',
value: function _handleChange(p) {
var page = p;
if (this._isValid(page)) {
if (page > this._calcPage()) {
page = this._calcPage();
}
this.props.onShowSizeChange(current, size);
};
if (!('current' in this.props)) {
this.setState({
current: page,
_current: page
});
}
Pagination.prototype._handleChange = function _handleChange(p) {
var page = p;
if (this._isValid(page)) {
if (page > this._calcPage()) {
page = this._calcPage();
}
this.props.onChange(page);
return page;
if (!('current' in this.props)) {
this.setState({
current: page,
_current: page
});
}
return this.state.current;
this.props.onChange(page);
return page;
}
}, {
key: '_prev',
value: function _prev() {
if (this._hasPrev()) {
this._handleChange(this.state.current - 1);
}
}
}, {
key: '_next',
value: function _next() {
if (this._hasNext()) {
this._handleChange(this.state.current + 1);
}
}
}, {
key: '_jumpPrev',
value: function _jumpPrev() {
this._handleChange(Math.max(1, this.state.current - 5));
}
}, {
key: '_jumpNext',
value: function _jumpNext() {
this._handleChange(Math.min(this._calcPage(), this.state.current + 5));
}
}, {
key: '_hasPrev',
value: function _hasPrev() {
return this.state.current > 1;
}
}, {
key: '_hasNext',
value: function _hasNext() {
return this.state.current < this._calcPage();
}
}, {
key: 'render',
value: function render() {
var props = this.props;
var locale = props.locale;
var prefixCls = props.prefixCls;
var allPages = this._calcPage();
var pagerList = [];
var jumpPrev = null;
var jumpNext = null;
var firstPager = null;
var lastPager = null;
return this.state.current;
};
if (props.simple) {
return React.createElement(
'ul',
{ className: prefixCls + ' ' + prefixCls + '-simple ' + props.className },
React.createElement(
'li',
{ title: locale.prev_page, onClick: this._prev, className: (this._hasPrev() ? '' : prefixCls + '-disabled ') + (prefixCls + '-prev') },
React.createElement('a', null)
),
React.createElement(
'div',
{ title: this.state.current + '/' + allPages, className: prefixCls + '-simple-pager' },
React.createElement('input', { type: 'text', value: this.state._current, onKeyDown: this._handleKeyDown, onKeyUp: this._handleKeyUp, onChange: this._handleKeyUp }),
React.createElement(
'span',
{ className: prefixCls + '-slash' },
'/'
),
allPages
),
React.createElement(
'li',
{ title: locale.next_page, onClick: this._next, className: (this._hasNext() ? '' : prefixCls + '-disabled ') + (prefixCls + '-next') },
React.createElement('a', null)
)
);
}
Pagination.prototype._prev = function _prev() {
if (this._hasPrev()) {
this._handleChange(this.state.current - 1);
}
};
if (allPages <= 9) {
for (var i = 1; i <= allPages; i++) {
var active = this.state.current === i;
pagerList.push(React.createElement(Pager, { locale: locale, rootPrefixCls: prefixCls, onClick: this._handleChange.bind(this, i), key: i, page: i, active: active }));
}
} else {
jumpPrev = React.createElement(
'li',
{ title: locale.prev_5, key: 'prev', onClick: this._jumpPrev, className: prefixCls + '-jump-prev' },
React.createElement('a', null)
);
jumpNext = React.createElement(
'li',
{ title: locale.next_5, key: 'next', onClick: this._jumpNext, className: prefixCls + '-jump-next' },
React.createElement('a', null)
);
lastPager = React.createElement(Pager, {
locale: props.locale,
last: true, rootPrefixCls: prefixCls, onClick: this._handleChange.bind(this, allPages), key: allPages, page: allPages, active: false });
firstPager = React.createElement(Pager, {
locale: props.locale,
rootPrefixCls: prefixCls, onClick: this._handleChange.bind(this, 1), key: 1, page: 1, active: false });
Pagination.prototype._next = function _next() {
if (this._hasNext()) {
this._handleChange(this.state.current + 1);
}
};
var current = this.state.current;
Pagination.prototype._jumpPrev = function _jumpPrev() {
this._handleChange(Math.max(1, this.state.current - 5));
};
var left = Math.max(1, current - 2);
var right = Math.min(current + 2, allPages);
Pagination.prototype._jumpNext = function _jumpNext() {
this._handleChange(Math.min(this._calcPage(), this.state.current + 5));
};
if (current - 1 <= 2) {
right = 1 + 4;
}
Pagination.prototype._hasPrev = function _hasPrev() {
return this.state.current > 1;
};
if (allPages - current <= 2) {
left = allPages - 4;
}
Pagination.prototype._hasNext = function _hasNext() {
return this.state.current < this._calcPage();
};
for (var i = left; i <= right; i++) {
var active = current === i;
pagerList.push(React.createElement(Pager, {
locale: props.locale,
rootPrefixCls: prefixCls, onClick: this._handleChange.bind(this, i), key: i, page: i, active: active }));
}
Pagination.prototype.render = function render() {
var props = this.props;
var locale = props.locale;
if (current - 1 >= 4) {
pagerList.unshift(jumpPrev);
}
if (allPages - current >= 4) {
pagerList.push(jumpNext);
}
var prefixCls = props.prefixCls;
var allPages = this._calcPage();
var pagerList = [];
var jumpPrev = null;
var jumpNext = null;
var firstPager = null;
var lastPager = null;
if (left !== 1) {
pagerList.unshift(firstPager);
}
if (right !== allPages) {
pagerList.push(lastPager);
}
}
var _state = this.state,
current = _state.current,
pageSize = _state.pageSize;
var totalText = null;
if (props.showTotal) {
totalText = React.createElement(
'span',
{ className: prefixCls + '-total-text' },
props.showTotal(props.total)
);
}
if (props.simple) {
return React.createElement(
'ul',
{ className: prefixCls + ' ' + props.className,
unselectable: 'unselectable' },
totalText,
{ className: prefixCls + ' ' + prefixCls + '-simple ' + props.className },
React.createElement(
'li',
{ title: locale.prev_page, onClick: this._prev, className: (this._hasPrev() ? '' : prefixCls + '-disabled ') + (prefixCls + '-prev') },
{
title: locale.prev_page,
onClick: this._prev,
className: (this._hasPrev() ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-prev'
},
React.createElement('a', null)
),
pagerList,
React.createElement(
'div',
{ title: this.state.current + '/' + allPages, className: prefixCls + '-simple-pager' },
React.createElement('input', {
type: 'text',
value: this.state._current,
onKeyDown: this._handleKeyDown,
onKeyUp: this._handleKeyUp,
onChange: this._handleKeyUp
}),
React.createElement(
'span',
{ className: prefixCls + '-slash' },
'\uFF0F'
),
allPages
),
React.createElement(
'li',
{ title: locale.next_page, onClick: this._next, className: (this._hasNext() ? '' : prefixCls + '-disabled ') + (prefixCls + '-next') },
{
title: locale.next_page,
onClick: this._next,
className: (this._hasNext() ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-next'
},
React.createElement('a', null)
),
React.createElement(Options, {
)
);
}
if (allPages <= 9) {
for (var i = 1; i <= allPages; i++) {
var active = this.state.current === i;
pagerList.push(React.createElement(Pager, {
locale: locale,
rootPrefixCls: prefixCls,
onClick: this._handleChange.bind(this, i),
key: i,
page: i,
active: active
}));
}
} else {
jumpPrev = React.createElement(
'li',
{
title: locale.prev_5,
key: 'prev',
onClick: this._jumpPrev,
className: prefixCls + '-jump-prev'
},
React.createElement('a', null)
);
jumpNext = React.createElement(
'li',
{
title: locale.next_5,
key: 'next',
onClick: this._jumpNext,
className: prefixCls + '-jump-next'
},
React.createElement('a', null)
);
lastPager = React.createElement(Pager, {
locale: props.locale,
last: true,
rootPrefixCls: prefixCls,
onClick: this._handleChange.bind(this, allPages),
key: allPages,
page: allPages,
active: false
});
firstPager = React.createElement(Pager, {
locale: props.locale,
rootPrefixCls: prefixCls,
onClick: this._handleChange.bind(this, 1),
key: 1,
page: 1,
active: false
});
var left = Math.max(1, current - 2);
var right = Math.min(current + 2, allPages);
if (current - 1 <= 2) {
right = 1 + 4;
}
if (allPages - current <= 2) {
left = allPages - 4;
}
for (var _i = left; _i <= right; _i++) {
var _active = current === _i;
pagerList.push(React.createElement(Pager, {
locale: props.locale,
rootPrefixCls: prefixCls,
selectComponentClass: props.selectComponentClass,
selectPrefixCls: props.selectPrefixCls,
changeSize: this.props.showSizeChanger ? this._changePageSize.bind(this) : null,
current: this.state.current,
pageSize: this.state.pageSize,
pageSizeOptions: this.props.pageSizeOptions,
quickGo: this.props.showQuickJumper ? this._handleChange.bind(this) : null })
onClick: this._handleChange.bind(this, _i),
key: _i,
page: _i,
active: _active
}));
}
if (current - 1 >= 4) {
pagerList.unshift(jumpPrev);
}
if (allPages - current >= 4) {
pagerList.push(jumpNext);
}
if (left !== 1) {
pagerList.unshift(firstPager);
}
if (right !== allPages) {
pagerList.push(lastPager);
}
}
var totalText = null;
if (props.showTotal) {
totalText = React.createElement(
'span',
{ className: prefixCls + '-total-text' },
props.showTotal(props.total, [(current - 1) * pageSize, current * pageSize > props.total ? props.total : current * pageSize])
);
}
}]);
return React.createElement(
'ul',
{
className: prefixCls + ' ' + props.className,
style: props.style,
unselectable: 'unselectable'
},
totalText,
React.createElement(
'li',
{
title: locale.prev_page,
onClick: this._prev,
className: (this._hasPrev() ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-prev'
},
React.createElement('a', null)
),
pagerList,
React.createElement(
'li',
{
title: locale.next_page,
onClick: this._next,
className: (this._hasNext() ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-next'
},
React.createElement('a', null)
),
React.createElement(Options, {
locale: props.locale,
rootPrefixCls: prefixCls,
selectComponentClass: props.selectComponentClass,
selectPrefixCls: props.selectPrefixCls,
changeSize: this.props.showSizeChanger ? this._changePageSize.bind(this) : null,
current: this.state.current,
pageSize: this.state.pageSize,
pageSizeOptions: this.props.pageSizeOptions,
quickGo: this.props.showQuickJumper ? this._handleChange.bind(this) : null
})
);
};
return Pagination;
})(React.Component);
}(React.Component);

@@ -366,3 +410,4 @@ Pagination.propTypes = {

showTotal: React.PropTypes.func,
locale: React.PropTypes.object
locale: React.PropTypes.object,
style: React.PropTypes.object
};

@@ -382,5 +427,6 @@

onShowSizeChange: noop,
locale: LOCALE
locale: LOCALE,
style: {}
};
module.exports = Pagination;
{
"name": "rc-pagination",
"version": "1.5.5",
"version": "1.6.0",
"description": "pagination ui component for react",

@@ -32,9 +32,11 @@ "keywords": [

"gh-pages": "rc-tools run gh-pages",
"start": "rc-server",
"start": "rc-tools run server",
"pub": "rc-tools run pub",
"lint": "rc-tools run lint",
"lint:fix": "rc-tools run lint --fix",
"karma": "rc-tools run karma",
"saucelabs": "rc-tools run saucelabs",
"browser-test": "rc-tools run browser-test",
"browser-test-cover": "rc-tools run browser-test-cover"
"test": "rc-tools run test",
"chrome-test": "rc-tools run chrome-test",
"coverage": "rc-tools run coverage"
},

@@ -45,8 +47,6 @@ "devDependencies": {

"rc-select": "5.x",
"rc-server": "3.x",
"rc-tools": "4.x",
"rc-util": "3.x",
"react": "~0.14.3",
"react-addons-test-utils": "~0.14.3",
"react-dom": "~0.14.3"
"rc-tools": "5.x",
"react": "^15.2.1",
"react-addons-test-utils": "^15.3.1",
"react-dom": "^15.2.1"
},

@@ -53,0 +53,0 @@ "pre-commit": [

@@ -79,6 +79,7 @@ # rc-pagination

| showQuickJump | show quick goto jumper | Bool | false |
| showTotal | show total records text | Function | undefined |
| showTotal | show total records text | Function(total, range) | undefined |
| className | when set "mini", show mini version | String | rc-pagination |
| simple | when set, show simple pager | Object | null |
| locale | to set l10n config | Object | [zh_CN](https://github.com/react-component/pagination/blob/master/src/locale/zh_CN.js) |
| style | the style of pagination | Object | {} |

@@ -85,0 +86,0 @@ ## Test Case

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc