rc-pagination
Advanced tools
Comparing version 1.1.9 to 1.1.10
@@ -12,3 +12,6 @@ 'use strict'; | ||
DELETE: 46, | ||
ENTER: 13 | ||
ENTER: 13, | ||
ARROW_UP: 38, | ||
ARROW_DOWN: 40 | ||
}; |
@@ -113,4 +113,2 @@ 'use strict'; | ||
this.setState({ value: val }); | ||
if (evt.keyCode === ENTER_KEY) { | ||
@@ -117,0 +115,0 @@ this.props.quickGo(val); |
@@ -14,2 +14,3 @@ 'use strict'; | ||
var Options = require('./Options'); | ||
var KEYCODE = require('./KeyCode'); | ||
@@ -30,6 +31,7 @@ function noop() {} | ||
current: props.current, | ||
_current: props.current, | ||
pageSize: props.pageSize | ||
}; | ||
['render', '_handleChange', '_simpleChange', '_changePageSize', '_isValid', '_prev', '_next', '_hasPrev', '_hasNext', '_jumpPrev', '_jumpNext', '_canJumpPrev', '_canJumpNext'].map(function (method) { | ||
['render', '_handleChange', '_handleKeyUp', '_handleKeyDown', '_changePageSize', '_isValid', '_prev', '_next', '_hasPrev', '_hasNext', '_jumpPrev', '_jumpNext', '_canJumpPrev', '_canJumpNext'].map(function (method) { | ||
return _this[method] = _this[method].bind(_this); | ||
@@ -77,3 +79,3 @@ }); | ||
{ className: prefixCls + '-simple-pager' }, | ||
React.createElement('input', { type: 'text', value: this.state.current, onChange: this._simpleChange }), | ||
React.createElement('input', { type: 'text', value: this.state._current, onKeyDown: this._handleKeyDown, onKeyUp: this._handleKeyUp, onChange: this._handleKeyUp }), | ||
React.createElement( | ||
@@ -180,2 +182,35 @@ 'span', | ||
}, { | ||
key: '_handleKeyDown', | ||
value: function _handleKeyDown(evt) { | ||
if (evt.keyCode === KEYCODE.ARROW_UP || evt.keyCode === KEYCODE.ARROW_DOWN) { | ||
evt.preventDefault(); | ||
} | ||
} | ||
}, { | ||
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 | ||
}); | ||
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); | ||
} | ||
} | ||
}, { | ||
key: '_changePageSize', | ||
@@ -190,11 +225,9 @@ value: function _changePageSize(size) { | ||
}, { | ||
key: '_simpleChange', | ||
value: function _simpleChange(evt) { | ||
this._handleChange(Number(evt.target.value)); | ||
} | ||
}, { | ||
key: '_handleChange', | ||
value: function _handleChange(page) { | ||
if (this._isValid(page)) { | ||
this.setState({ current: page }); | ||
this.setState({ | ||
current: page, | ||
_current: page | ||
}); | ||
this.props.onChange(page); | ||
@@ -201,0 +234,0 @@ } |
{ | ||
"name": "rc-pagination", | ||
"version": "1.1.9", | ||
"version": "1.1.10", | ||
"description": "pagination ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
27324
621