rc-input-number
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -14,2 +14,6 @@ 'use strict'; | ||
function preventDefault(e) { | ||
e.preventDefault(); | ||
} | ||
var InputNumber = React.createClass({ | ||
@@ -27,5 +31,7 @@ displayName: 'InputNumber', | ||
return { | ||
value: value | ||
value: value, | ||
focused: props.autoFocus | ||
}; | ||
}, | ||
getDefaultProps: function getDefaultProps() { | ||
@@ -40,2 +46,3 @@ return { | ||
}, | ||
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
@@ -48,9 +55,13 @@ if ('value' in nextProps) { | ||
}, | ||
setValue: function setValue(v) { | ||
setValue: function setValue(v, callback) { | ||
this.setState({ | ||
value: v | ||
}); | ||
}, callback); | ||
this.props.onChange(v); | ||
}, | ||
step: function step(type, e) { | ||
step: function step(type, e, callback) { | ||
var _this = this; | ||
if (e) { | ||
@@ -77,4 +88,7 @@ e.preventDefault(); | ||
} | ||
this.setValue(val); | ||
this.setValue(val, function () { | ||
React.findDOMNode(_this.refs.input).focus(); | ||
}); | ||
}, | ||
onChange: function onChange(event) { | ||
@@ -116,2 +130,15 @@ var props = this.props; | ||
}, | ||
handleFocus: function handleFocus() { | ||
this.setState({ | ||
focused: true | ||
}); | ||
}, | ||
handleBlur: function handleBlur() { | ||
this.setState({ | ||
focused: false | ||
}); | ||
}, | ||
render: function render() { | ||
@@ -122,3 +149,3 @@ var _rcUtil$classSet; | ||
var prefixCls = props.prefixCls; | ||
var classes = rcUtil.classSet((_rcUtil$classSet = {}, _defineProperty(_rcUtil$classSet, prefixCls, true), _defineProperty(_rcUtil$classSet, prefixCls + '-disabled', props.disabled), _rcUtil$classSet)); | ||
var classes = rcUtil.classSet((_rcUtil$classSet = {}, _defineProperty(_rcUtil$classSet, prefixCls, true), _defineProperty(_rcUtil$classSet, prefixCls + '-disabled', props.disabled), _defineProperty(_rcUtil$classSet, prefixCls + '-focused', this.state.focused), _rcUtil$classSet)); | ||
var upDisabledClass = ''; | ||
@@ -148,15 +175,17 @@ var downDisabledClass = ''; | ||
'div', | ||
{ unselectable: true, | ||
{ unselectable: 'unselectable', | ||
ref: 'up', | ||
onClick: upDisabledClass ? noop : this.up, | ||
onMouseDown: preventDefault, | ||
className: prefixCls + '-handler ' + prefixCls + '-handler-up ' + upDisabledClass }, | ||
React.createElement('div', { className: prefixCls + '-handler-up-inner' }) | ||
React.createElement('div', { unselectable: 'unselectable', className: prefixCls + '-handler-up-inner' }) | ||
), | ||
React.createElement( | ||
'div', | ||
{ unselectable: true, | ||
{ unselectable: 'unselectable', | ||
ref: 'down', | ||
onMouseDown: preventDefault, | ||
onClick: downDisabledClass ? noop : this.down, | ||
className: prefixCls + '-handler ' + prefixCls + '-handler-down ' + downDisabledClass }, | ||
React.createElement('div', { className: prefixCls + '-handler-down-inner' }) | ||
React.createElement('div', { unselectable: 'unselectable', className: prefixCls + '-handler-down-inner' }) | ||
) | ||
@@ -169,2 +198,4 @@ ), | ||
autoComplete: 'off', | ||
onFocus: this.handleFocus, | ||
onBlur: this.handleBlur, | ||
onKeyDown: this.handleKeyDown, | ||
@@ -171,0 +202,0 @@ autoFocus: props.autoFocus, |
{ | ||
"name": "rc-input-number", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "input-number ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -136,2 +136,8 @@ # rc-input-number | ||
<tr> | ||
<td>style</td> | ||
<td>Object</td> | ||
<td></td> | ||
<td>root style. such as {width:100}</td> | ||
</tr> | ||
<tr> | ||
<td>onChange</td> | ||
@@ -138,0 +144,0 @@ <td>Function</td> |
Sorry, the diff of this file is not supported yet
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
13477
280
163