rc-pagination
Advanced tools
Comparing version 1.8.8 to 1.8.9
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ pàgina', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ strana', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ Seite', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ page', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ página', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ leheküljel', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ sivu', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ page', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ ページ', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ 쪽', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ pagina', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ páginas', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/странице', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ strana', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ sida', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '/ trang', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '条/页', |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports["default"] = { | ||
exports['default'] = { | ||
// Options.jsx | ||
@@ -9,0 +9,0 @@ items_per_page: '條/頁', |
@@ -7,2 +7,18 @@ 'use strict'; | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
var _react = require('react'); | ||
@@ -20,19 +36,11 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
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; } | ||
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) : _defaults(subClass, superClass); } | ||
var Options = function (_React$Component) { | ||
_inherits(Options, _React$Component); | ||
(0, _inherits3['default'])(Options, _React$Component); | ||
function Options(props) { | ||
_classCallCheck(this, Options); | ||
(0, _classCallCheck3['default'])(this, Options); | ||
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); | ||
var _this = (0, _possibleConstructorReturn3['default'])(this, (Options.__proto__ || Object.getPrototypeOf(Options)).call(this, props)); | ||
@@ -50,116 +58,122 @@ _this.state = { | ||
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; | ||
(0, _createClass3['default'])(Options, [{ | ||
key: '_buildOptionText', | ||
value: function _buildOptionText(value) { | ||
return value + ' ' + this.props.locale.items_per_page; | ||
} | ||
var val = Number(this.state._current); | ||
if (isNaN(val)) { | ||
val = this.state.current; | ||
}, { | ||
key: '_changeSize', | ||
value: function _changeSize(value) { | ||
this.props.changeSize(Number(value)); | ||
} | ||
if (e.keyCode === _KeyCode2["default"].ENTER) { | ||
var c = this.props.quickGo(val); | ||
}, { | ||
key: '_handleChange', | ||
value: function _handleChange(evt) { | ||
var _val = evt.target.value; | ||
this.setState({ | ||
_current: c, | ||
current: c | ||
_current: _val | ||
}); | ||
} | ||
}; | ||
}, { | ||
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 === _KeyCode2['default'].ENTER) { | ||
var c = this.props.quickGo(val); | ||
this.setState({ | ||
_current: c, | ||
current: c | ||
}); | ||
} | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
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 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 || quickGo)) { | ||
return null; | ||
} | ||
if (!(changeSize || quickGo)) { | ||
return null; | ||
} | ||
if (changeSize && Select) { | ||
var Option = Select.Option; | ||
var pageSize = props.pageSize || props.pageSizeOptions[0]; | ||
var options = props.pageSizeOptions.map(function (opt, i) { | ||
return _react2['default'].createElement( | ||
Option, | ||
{ key: i, value: opt }, | ||
buildOptionText(opt) | ||
); | ||
}); | ||
if (changeSize && Select) { | ||
var Option = Select.Option; | ||
var pageSize = props.pageSize || props.pageSizeOptions[0]; | ||
var options = props.pageSizeOptions.map(function (opt, i) { | ||
return _react2["default"].createElement( | ||
Option, | ||
{ key: i, value: opt }, | ||
buildOptionText(opt) | ||
changeSelect = _react2['default'].createElement( | ||
Select, | ||
{ | ||
prefixCls: props.selectPrefixCls, | ||
showSearch: false, | ||
className: prefixCls + '-size-changer', | ||
optionLabelProp: 'children', | ||
dropdownMatchSelectWidth: false, | ||
value: pageSize.toString(), | ||
onChange: this._changeSize, | ||
getPopupContainer: function getPopupContainer(triggerNode) { | ||
return triggerNode.parentNode; | ||
} | ||
}, | ||
options | ||
); | ||
}); | ||
} | ||
changeSelect = _react2["default"].createElement( | ||
Select, | ||
{ | ||
prefixCls: props.selectPrefixCls, | ||
showSearch: false, | ||
className: prefixCls + '-size-changer', | ||
optionLabelProp: 'children', | ||
dropdownMatchSelectWidth: false, | ||
value: pageSize.toString(), | ||
onChange: this._changeSize, | ||
getPopupContainer: function getPopupContainer(triggerNode) { | ||
return triggerNode.parentNode; | ||
} | ||
}, | ||
options | ||
); | ||
} | ||
if (quickGo) { | ||
goInput = _react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-quick-jumper' }, | ||
locale.jump_to, | ||
_react2['default'].createElement('input', { | ||
type: 'text', | ||
value: state._current, | ||
onChange: this._handleChange, | ||
onKeyUp: this._go | ||
}), | ||
locale.page | ||
); | ||
} | ||
if (quickGo) { | ||
goInput = _react2["default"].createElement( | ||
return _react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-quick-jumper' }, | ||
locale.jump_to, | ||
_react2["default"].createElement('input', { | ||
type: 'text', | ||
value: state._current, | ||
onChange: this._handleChange, | ||
onKeyUp: this._go | ||
}), | ||
locale.page | ||
{ className: '' + prefixCls }, | ||
changeSelect, | ||
goInput | ||
); | ||
} | ||
return _react2["default"].createElement( | ||
'div', | ||
{ className: '' + prefixCls }, | ||
changeSelect, | ||
goInput | ||
); | ||
}; | ||
}]); | ||
return Options; | ||
}(_react2["default"].Component); | ||
}(_react2['default'].Component); | ||
Options.propTypes = { | ||
changeSize: _propTypes2["default"].func, | ||
quickGo: _propTypes2["default"].func, | ||
selectComponentClass: _propTypes2["default"].func, | ||
current: _propTypes2["default"].number, | ||
pageSizeOptions: _propTypes2["default"].arrayOf(_propTypes2["default"].string), | ||
pageSize: _propTypes2["default"].number, | ||
buildOptionText: _propTypes2["default"].func, | ||
locale: _propTypes2["default"].object | ||
changeSize: _propTypes2['default'].func, | ||
quickGo: _propTypes2['default'].func, | ||
selectComponentClass: _propTypes2['default'].func, | ||
current: _propTypes2['default'].number, | ||
pageSizeOptions: _propTypes2['default'].arrayOf(_propTypes2['default'].string), | ||
pageSize: _propTypes2['default'].number, | ||
buildOptionText: _propTypes2['default'].func, | ||
locale: _propTypes2['default'].object | ||
}; | ||
@@ -169,3 +183,3 @@ Options.defaultProps = { | ||
}; | ||
exports["default"] = Options; | ||
exports['default'] = Options; | ||
module.exports = exports['default']; |
@@ -15,3 +15,3 @@ 'use strict'; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
@@ -30,6 +30,6 @@ var Pager = function Pager(props) { | ||
return _react2["default"].createElement( | ||
return _react2['default'].createElement( | ||
'li', | ||
{ title: props.showTitle ? props.page : null, className: cls, onClick: props.onClick }, | ||
_react2["default"].createElement( | ||
_react2['default'].createElement( | ||
'a', | ||
@@ -43,13 +43,13 @@ null, | ||
Pager.propTypes = { | ||
page: _propTypes2["default"].number, | ||
active: _propTypes2["default"].bool, | ||
last: _propTypes2["default"].bool, | ||
locale: _propTypes2["default"].object, | ||
className: _propTypes2["default"].string, | ||
showTitle: _propTypes2["default"].bool, | ||
rootPrefixCls: _propTypes2["default"].string, | ||
onClick: _propTypes2["default"].func | ||
page: _propTypes2['default'].number, | ||
active: _propTypes2['default'].bool, | ||
last: _propTypes2['default'].bool, | ||
locale: _propTypes2['default'].object, | ||
className: _propTypes2['default'].string, | ||
showTitle: _propTypes2['default'].bool, | ||
rootPrefixCls: _propTypes2['default'].string, | ||
onClick: _propTypes2['default'].func | ||
}; | ||
exports["default"] = Pager; | ||
exports['default'] = Pager; | ||
module.exports = exports['default']; |
@@ -7,2 +7,18 @@ 'use strict'; | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
var _react = require('react'); | ||
@@ -32,21 +48,13 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
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; } | ||
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) : _defaults(subClass, superClass); } | ||
function noop() {} | ||
var Pagination = function (_React$Component) { | ||
_inherits(Pagination, _React$Component); | ||
(0, _inherits3['default'])(Pagination, _React$Component); | ||
function Pagination(props) { | ||
_classCallCheck(this, Pagination); | ||
(0, _classCallCheck3['default'])(this, Pagination); | ||
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); | ||
var _this = (0, _possibleConstructorReturn3['default'])(this, (Pagination.__proto__ || Object.getPrototypeOf(Pagination)).call(this, props)); | ||
@@ -81,163 +89,342 @@ var hasOnChange = props.onChange !== noop; | ||
Pagination.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
if ('current' in nextProps) { | ||
this.setState({ | ||
current: nextProps.current, | ||
_current: nextProps.current | ||
}); | ||
} | ||
(0, _createClass3['default'])(Pagination, [{ | ||
key: 'componentWillReceiveProps', | ||
value: 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; | ||
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); | ||
} | ||
newState.pageSize = nextProps.pageSize; | ||
this.setState(newState); | ||
} | ||
}; | ||
// private methods | ||
// private methods | ||
Pagination.prototype._calcPage = function _calcPage(p) { | ||
var pageSize = p; | ||
if (typeof pageSize === 'undefined') { | ||
pageSize = this.state.pageSize; | ||
}, { | ||
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; | ||
} | ||
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 === _KeyCode2["default"].ARROW_UP || evt.keyCode === _KeyCode2["default"].ARROW_DOWN) { | ||
evt.preventDefault(); | ||
}, { | ||
key: '_isValid', | ||
value: function _isValid(page) { | ||
return typeof page === 'number' && page >= 1 && page !== this.state.current; | ||
} | ||
}; | ||
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: '_handleKeyDown', | ||
value: function _handleKeyDown(evt) { | ||
if (evt.keyCode === _KeyCode2['default'].ARROW_UP || evt.keyCode === _KeyCode2['default'].ARROW_DOWN) { | ||
evt.preventDefault(); | ||
} | ||
} | ||
}, { | ||
key: '_handleKeyUp', | ||
value: function _handleKeyUp(evt) { | ||
var _val = evt.target.value; | ||
var val = void 0; | ||
this.setState({ | ||
_current: val | ||
}); | ||
if (_val === '') { | ||
val = _val; | ||
} else if (isNaN(Number(_val))) { | ||
val = this.state._current; | ||
} else { | ||
val = Number(_val); | ||
} | ||
if (evt.keyCode === _KeyCode2["default"].ENTER) { | ||
this._handleChange(val); | ||
} else if (evt.keyCode === _KeyCode2["default"].ARROW_UP) { | ||
this._handleChange(val - 1); | ||
} else if (evt.keyCode === _KeyCode2["default"].ARROW_DOWN) { | ||
this._handleChange(val + 1); | ||
} | ||
}; | ||
this.setState({ | ||
_current: val | ||
}); | ||
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 | ||
}); | ||
if (evt.keyCode === _KeyCode2['default'].ENTER) { | ||
this._handleChange(val); | ||
} else if (evt.keyCode === _KeyCode2['default'].ARROW_UP) { | ||
this._handleChange(val - 1); | ||
} else if (evt.keyCode === _KeyCode2['default'].ARROW_DOWN) { | ||
this._handleChange(val + 1); | ||
} | ||
if (!('current' in this.props)) { | ||
this.setState({ | ||
current: current, | ||
_current: current | ||
}); | ||
} | ||
}, { | ||
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 | ||
}); | ||
} | ||
} | ||
this.props.onShowSizeChange(current, size); | ||
} | ||
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(); | ||
} | ||
Pagination.prototype._handleChange = function _handleChange(p) { | ||
var page = p; | ||
if (this._isValid(page)) { | ||
if (page > this._calcPage()) { | ||
page = this._calcPage(); | ||
if (!('current' in this.props)) { | ||
this.setState({ | ||
current: page, | ||
_current: page | ||
}); | ||
} | ||
var pageSize = this.state.pageSize; | ||
this.props.onChange(page, pageSize); | ||
return page; | ||
} | ||
if (!('current' in this.props)) { | ||
this.setState({ | ||
current: page, | ||
_current: page | ||
}); | ||
return this.state.current; | ||
} | ||
}, { | ||
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 - (this.props.showLessItems ? 3 : 5))); | ||
} | ||
}, { | ||
key: '_jumpNext', | ||
value: function _jumpNext() { | ||
this._handleChange(Math.min(this._calcPage(), this.state.current + (this.props.showLessItems ? 3 : 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 pageSize = this.state.pageSize; | ||
this.props.onChange(page, pageSize); | ||
var prefixCls = props.prefixCls; | ||
var allPages = this._calcPage(); | ||
var pagerList = []; | ||
var jumpPrev = null; | ||
var jumpNext = null; | ||
var firstPager = null; | ||
var lastPager = null; | ||
return page; | ||
} | ||
var pageBufferSize = props.showLessItems ? 1 : 2; | ||
var _state = this.state, | ||
current = _state.current, | ||
pageSize = _state.pageSize; | ||
return this.state.current; | ||
}; | ||
Pagination.prototype._prev = function _prev() { | ||
if (this._hasPrev()) { | ||
this._handleChange(this.state.current - 1); | ||
} | ||
}; | ||
if (props.simple) { | ||
return _react2['default'].createElement( | ||
'ul', | ||
{ className: prefixCls + ' ' + prefixCls + '-simple ' + props.className }, | ||
_react2['default'].createElement( | ||
'li', | ||
{ | ||
title: props.showTitle ? locale.prev_page : null, | ||
onClick: this._prev, | ||
className: (this._hasPrev() ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-prev', | ||
'aria-disabled': !this._hasPrev() | ||
}, | ||
_react2['default'].createElement('a', null) | ||
), | ||
_react2['default'].createElement( | ||
'li', | ||
{ | ||
title: props.showTitle ? this.state.current + '/' + allPages : null, | ||
className: prefixCls + '-simple-pager' | ||
}, | ||
_react2['default'].createElement('input', { | ||
type: 'text', | ||
value: this.state._current, | ||
onKeyDown: this._handleKeyDown, | ||
onKeyUp: this._handleKeyUp, | ||
onChange: this._handleKeyUp | ||
}), | ||
_react2['default'].createElement( | ||
'span', | ||
{ className: prefixCls + '-slash' }, | ||
'\uFF0F' | ||
), | ||
allPages | ||
), | ||
_react2['default'].createElement( | ||
'li', | ||
{ | ||
title: props.showTitle ? locale.next_page : null, | ||
onClick: this._next, | ||
className: (this._hasNext() ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-next', | ||
'aria-disabled': !this._hasNext() | ||
}, | ||
_react2['default'].createElement('a', null) | ||
) | ||
); | ||
} | ||
Pagination.prototype._next = function _next() { | ||
if (this._hasNext()) { | ||
this._handleChange(this.state.current + 1); | ||
} | ||
}; | ||
if (allPages <= 5 + pageBufferSize * 2) { | ||
for (var i = 1; i <= allPages; i++) { | ||
var active = this.state.current === i; | ||
pagerList.push(_react2['default'].createElement(_Pager2['default'], { | ||
locale: locale, | ||
rootPrefixCls: prefixCls, | ||
onClick: this._handleChange.bind(this, i), | ||
key: i, | ||
page: i, | ||
active: active, | ||
showTitle: props.showTitle | ||
})); | ||
} | ||
} else { | ||
var prevItemTitle = props.showLessItems ? locale.prev_3 : locale.prev_5; | ||
var nextItemTitle = props.showLessItems ? locale.next_3 : locale.next_5; | ||
jumpPrev = _react2['default'].createElement( | ||
'li', | ||
{ | ||
title: props.showTitle ? prevItemTitle : null, | ||
key: 'prev', | ||
onClick: this._jumpPrev, | ||
className: prefixCls + '-jump-prev' | ||
}, | ||
_react2['default'].createElement('a', null) | ||
); | ||
jumpNext = _react2['default'].createElement( | ||
'li', | ||
{ | ||
title: props.showTitle ? nextItemTitle : null, | ||
key: 'next', | ||
onClick: this._jumpNext, | ||
className: prefixCls + '-jump-next' | ||
}, | ||
_react2['default'].createElement('a', null) | ||
); | ||
lastPager = _react2['default'].createElement(_Pager2['default'], { | ||
locale: props.locale, | ||
last: true, | ||
rootPrefixCls: prefixCls, | ||
onClick: this._handleChange.bind(this, allPages), | ||
key: allPages, | ||
page: allPages, | ||
active: false, | ||
showTitle: props.showTitle | ||
}); | ||
firstPager = _react2['default'].createElement(_Pager2['default'], { | ||
locale: props.locale, | ||
rootPrefixCls: prefixCls, | ||
onClick: this._handleChange.bind(this, 1), | ||
key: 1, | ||
page: 1, | ||
active: false, | ||
showTitle: props.showTitle | ||
}); | ||
Pagination.prototype._jumpPrev = function _jumpPrev() { | ||
this._handleChange(Math.max(1, this.state.current - (this.props.showLessItems ? 3 : 5))); | ||
}; | ||
var left = Math.max(1, current - pageBufferSize); | ||
var right = Math.min(current + pageBufferSize, allPages); | ||
Pagination.prototype._jumpNext = function _jumpNext() { | ||
this._handleChange(Math.min(this._calcPage(), this.state.current + (this.props.showLessItems ? 3 : 5))); | ||
}; | ||
if (current - 1 <= pageBufferSize) { | ||
right = 1 + pageBufferSize * 2; | ||
} | ||
Pagination.prototype._hasPrev = function _hasPrev() { | ||
return this.state.current > 1; | ||
}; | ||
if (allPages - current <= pageBufferSize) { | ||
left = allPages - pageBufferSize * 2; | ||
} | ||
Pagination.prototype._hasNext = function _hasNext() { | ||
return this.state.current < this._calcPage(); | ||
}; | ||
for (var _i = left; _i <= right; _i++) { | ||
var _active = current === _i; | ||
pagerList.push(_react2['default'].createElement(_Pager2['default'], { | ||
locale: props.locale, | ||
rootPrefixCls: prefixCls, | ||
onClick: this._handleChange.bind(this, _i), | ||
key: _i, | ||
page: _i, | ||
active: _active, | ||
showTitle: props.showTitle | ||
})); | ||
} | ||
Pagination.prototype.render = function render() { | ||
var props = this.props; | ||
var locale = props.locale; | ||
if (current - 1 >= pageBufferSize * 2 && current !== 1 + 2) { | ||
pagerList[0] = _react2['default'].cloneElement(pagerList[0], { | ||
className: prefixCls + '-item-after-jump-prev' | ||
}); | ||
pagerList.unshift(jumpPrev); | ||
} | ||
if (allPages - current >= pageBufferSize * 2 && current !== allPages - 2) { | ||
pagerList[pagerList.length - 1] = _react2['default'].cloneElement(pagerList[pagerList.length - 1], { | ||
className: prefixCls + '-item-before-jump-next' | ||
}); | ||
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 pageBufferSize = props.showLessItems ? 1 : 2; | ||
var _state = this.state, | ||
current = _state.current, | ||
pageSize = _state.pageSize; | ||
var totalText = null; | ||
if (props.simple) { | ||
return _react2["default"].createElement( | ||
if (props.showTotal) { | ||
totalText = _react2['default'].createElement( | ||
'span', | ||
{ className: prefixCls + '-total-text' }, | ||
props.showTotal(props.total, [(current - 1) * pageSize + 1, current * pageSize > props.total ? props.total : current * pageSize]) | ||
); | ||
} | ||
var prevDisabled = !this._hasPrev(); | ||
var nextDisabled = !this._hasNext(); | ||
return _react2['default'].createElement( | ||
'ul', | ||
{ className: prefixCls + ' ' + prefixCls + '-simple ' + props.className }, | ||
_react2["default"].createElement( | ||
{ | ||
className: prefixCls + ' ' + props.className, | ||
style: props.style, | ||
unselectable: 'unselectable' | ||
}, | ||
totalText, | ||
_react2['default'].createElement( | ||
'li', | ||
@@ -247,215 +434,52 @@ { | ||
onClick: this._prev, | ||
className: (this._hasPrev() ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-prev', | ||
'aria-disabled': !this._hasPrev() | ||
className: (!prevDisabled ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-prev', | ||
'aria-disabled': prevDisabled | ||
}, | ||
_react2["default"].createElement('a', null) | ||
_react2['default'].createElement('a', null) | ||
), | ||
_react2["default"].createElement( | ||
pagerList, | ||
_react2['default'].createElement( | ||
'li', | ||
{ | ||
title: props.showTitle ? this.state.current + '/' + allPages : null, | ||
className: prefixCls + '-simple-pager' | ||
}, | ||
_react2["default"].createElement('input', { | ||
type: 'text', | ||
value: this.state._current, | ||
onKeyDown: this._handleKeyDown, | ||
onKeyUp: this._handleKeyUp, | ||
onChange: this._handleKeyUp | ||
}), | ||
_react2["default"].createElement( | ||
'span', | ||
{ className: prefixCls + '-slash' }, | ||
'\uFF0F' | ||
), | ||
allPages | ||
), | ||
_react2["default"].createElement( | ||
'li', | ||
{ | ||
title: props.showTitle ? locale.next_page : null, | ||
onClick: this._next, | ||
className: (this._hasNext() ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-next', | ||
'aria-disabled': !this._hasNext() | ||
className: (!nextDisabled ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-next', | ||
'aria-disabled': nextDisabled | ||
}, | ||
_react2["default"].createElement('a', null) | ||
) | ||
); | ||
} | ||
if (allPages <= 5 + pageBufferSize * 2) { | ||
for (var i = 1; i <= allPages; i++) { | ||
var active = this.state.current === i; | ||
pagerList.push(_react2["default"].createElement(_Pager2["default"], { | ||
locale: locale, | ||
rootPrefixCls: prefixCls, | ||
onClick: this._handleChange.bind(this, i), | ||
key: i, | ||
page: i, | ||
active: active, | ||
showTitle: props.showTitle | ||
})); | ||
} | ||
} else { | ||
var prevItemTitle = props.showLessItems ? locale.prev_3 : locale.prev_5; | ||
var nextItemTitle = props.showLessItems ? locale.next_3 : locale.next_5; | ||
jumpPrev = _react2["default"].createElement( | ||
'li', | ||
{ | ||
title: props.showTitle ? prevItemTitle : null, | ||
key: 'prev', | ||
onClick: this._jumpPrev, | ||
className: prefixCls + '-jump-prev' | ||
}, | ||
_react2["default"].createElement('a', null) | ||
); | ||
jumpNext = _react2["default"].createElement( | ||
'li', | ||
{ | ||
title: props.showTitle ? nextItemTitle : null, | ||
key: 'next', | ||
onClick: this._jumpNext, | ||
className: prefixCls + '-jump-next' | ||
}, | ||
_react2["default"].createElement('a', null) | ||
); | ||
lastPager = _react2["default"].createElement(_Pager2["default"], { | ||
locale: props.locale, | ||
last: true, | ||
rootPrefixCls: prefixCls, | ||
onClick: this._handleChange.bind(this, allPages), | ||
key: allPages, | ||
page: allPages, | ||
active: false, | ||
showTitle: props.showTitle | ||
}); | ||
firstPager = _react2["default"].createElement(_Pager2["default"], { | ||
locale: props.locale, | ||
rootPrefixCls: prefixCls, | ||
onClick: this._handleChange.bind(this, 1), | ||
key: 1, | ||
page: 1, | ||
active: false, | ||
showTitle: props.showTitle | ||
}); | ||
var left = Math.max(1, current - pageBufferSize); | ||
var right = Math.min(current + pageBufferSize, allPages); | ||
if (current - 1 <= pageBufferSize) { | ||
right = 1 + pageBufferSize * 2; | ||
} | ||
if (allPages - current <= pageBufferSize) { | ||
left = allPages - pageBufferSize * 2; | ||
} | ||
for (var _i = left; _i <= right; _i++) { | ||
var _active = current === _i; | ||
pagerList.push(_react2["default"].createElement(_Pager2["default"], { | ||
_react2['default'].createElement('a', null) | ||
), | ||
_react2['default'].createElement(_Options2['default'], { | ||
locale: props.locale, | ||
rootPrefixCls: prefixCls, | ||
onClick: this._handleChange.bind(this, _i), | ||
key: _i, | ||
page: _i, | ||
active: _active, | ||
showTitle: props.showTitle | ||
})); | ||
} | ||
if (current - 1 >= pageBufferSize * 2 && current !== 1 + 2) { | ||
pagerList[0] = _react2["default"].cloneElement(pagerList[0], { | ||
className: prefixCls + '-item-after-jump-prev' | ||
}); | ||
pagerList.unshift(jumpPrev); | ||
} | ||
if (allPages - current >= pageBufferSize * 2 && current !== allPages - 2) { | ||
pagerList[pagerList.length - 1] = _react2["default"].cloneElement(pagerList[pagerList.length - 1], { | ||
className: prefixCls + '-item-before-jump-next' | ||
}); | ||
pagerList.push(jumpNext); | ||
} | ||
if (left !== 1) { | ||
pagerList.unshift(firstPager); | ||
} | ||
if (right !== allPages) { | ||
pagerList.push(lastPager); | ||
} | ||
} | ||
var totalText = null; | ||
if (props.showTotal) { | ||
totalText = _react2["default"].createElement( | ||
'span', | ||
{ className: prefixCls + '-total-text' }, | ||
props.showTotal(props.total, [(current - 1) * pageSize + 1, current * pageSize > props.total ? props.total : current * pageSize]) | ||
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 | ||
}) | ||
); | ||
} | ||
var prevDisabled = !this._hasPrev(); | ||
var nextDisabled = !this._hasNext(); | ||
return _react2["default"].createElement( | ||
'ul', | ||
{ | ||
className: prefixCls + ' ' + props.className, | ||
style: props.style, | ||
unselectable: 'unselectable' | ||
}, | ||
totalText, | ||
_react2["default"].createElement( | ||
'li', | ||
{ | ||
title: props.showTitle ? locale.prev_page : null, | ||
onClick: this._prev, | ||
className: (!prevDisabled ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-prev', | ||
'aria-disabled': prevDisabled | ||
}, | ||
_react2["default"].createElement('a', null) | ||
), | ||
pagerList, | ||
_react2["default"].createElement( | ||
'li', | ||
{ | ||
title: props.showTitle ? locale.next_page : null, | ||
onClick: this._next, | ||
className: (!nextDisabled ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-next', | ||
'aria-disabled': nextDisabled | ||
}, | ||
_react2["default"].createElement('a', null) | ||
), | ||
_react2["default"].createElement(_Options2["default"], { | ||
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; | ||
}(_react2["default"].Component); | ||
}(_react2['default'].Component); | ||
Pagination.propTypes = { | ||
current: _propTypes2["default"].number, | ||
defaultCurrent: _propTypes2["default"].number, | ||
total: _propTypes2["default"].number, | ||
pageSize: _propTypes2["default"].number, | ||
defaultPageSize: _propTypes2["default"].number, | ||
onChange: _propTypes2["default"].func, | ||
showSizeChanger: _propTypes2["default"].bool, | ||
showLessItems: _propTypes2["default"].bool, | ||
onShowSizeChange: _propTypes2["default"].func, | ||
selectComponentClass: _propTypes2["default"].func, | ||
showQuickJumper: _propTypes2["default"].bool, | ||
showTitle: _propTypes2["default"].bool, | ||
pageSizeOptions: _propTypes2["default"].arrayOf(_propTypes2["default"].string), | ||
showTotal: _propTypes2["default"].func, | ||
locale: _propTypes2["default"].object, | ||
style: _propTypes2["default"].object | ||
current: _propTypes2['default'].number, | ||
defaultCurrent: _propTypes2['default'].number, | ||
total: _propTypes2['default'].number, | ||
pageSize: _propTypes2['default'].number, | ||
defaultPageSize: _propTypes2['default'].number, | ||
onChange: _propTypes2['default'].func, | ||
showSizeChanger: _propTypes2['default'].bool, | ||
showLessItems: _propTypes2['default'].bool, | ||
onShowSizeChange: _propTypes2['default'].func, | ||
selectComponentClass: _propTypes2['default'].func, | ||
showQuickJumper: _propTypes2['default'].bool, | ||
showTitle: _propTypes2['default'].bool, | ||
pageSizeOptions: _propTypes2['default'].arrayOf(_propTypes2['default'].string), | ||
showTotal: _propTypes2['default'].func, | ||
locale: _propTypes2['default'].object, | ||
style: _propTypes2['default'].object | ||
}; | ||
@@ -477,7 +501,7 @@ | ||
onShowSizeChange: noop, | ||
locale: _zh_CN2["default"], | ||
locale: _zh_CN2['default'], | ||
style: {} | ||
}; | ||
exports["default"] = Pagination; | ||
exports['default'] = Pagination; | ||
module.exports = exports['default']; |
{ | ||
"name": "rc-pagination", | ||
"version": "1.8.8", | ||
"version": "1.8.9", | ||
"description": "pagination ui component for react", | ||
@@ -23,5 +23,7 @@ "keywords": [ | ||
"lib", | ||
"es", | ||
"assets/*.css" | ||
], | ||
"main": "lib/index", | ||
"module": "es/index", | ||
"config": { | ||
@@ -32,5 +34,6 @@ "port": 3000 | ||
"build": "rc-tools run build", | ||
"compile": "rc-tools run compile --babel-runtime", | ||
"gh-pages": "rc-tools run gh-pages", | ||
"start": "rc-tools run server", | ||
"pub": "rc-tools run pub", | ||
"pub": "rc-tools run pub --babel-runtime", | ||
"lint": "rc-tools run lint", | ||
@@ -48,3 +51,3 @@ "lint:fix": "rc-tools run lint --fix", | ||
"rc-select": "5.x", | ||
"rc-tools": "5.x", | ||
"rc-tools": "6.x", | ||
"react": "^15.2.1", | ||
@@ -51,0 +54,0 @@ "react-addons-test-utils": "^15.3.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65989
51
1963