rc-input-number
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,6 +0,9 @@ | ||
/** @jsx React.DOM */ | ||
'use strict'; | ||
var React = require('react'); | ||
var rcUtil = require('rc-util'); | ||
var InputNumber = React.createClass({ | ||
getInitialState: function () { | ||
displayName: 'InputNumber', | ||
getInitialState: function getInitialState() { | ||
return { | ||
@@ -10,12 +13,9 @@ value: 0 | ||
}, | ||
componentDidMount: function () { | ||
componentDidMount: function componentDidMount() { | ||
if (this.props.value) { | ||
this.setState({value: this.props.value || 0}); | ||
this.setState({ value: this.props.value || 0 }); | ||
} | ||
}, | ||
componentWillUnmount: function () { | ||
}, | ||
step: function (type, e) { | ||
componentWillUnmount: function componentWillUnmount() {}, | ||
step: function step(type, e) { | ||
e.preventDefault(); | ||
@@ -25,3 +25,4 @@ if (this.props.disabled) { | ||
} | ||
var stepNum = this.props.step || 1, val; | ||
var stepNum = this.props.step || 1, | ||
val; | ||
if (type === 'down') { | ||
@@ -37,19 +38,19 @@ val = Number(this.state.value) - Number(stepNum); | ||
this.props.value = val; | ||
this.setState({value: val}); | ||
this.setState({ value: val }); | ||
}, | ||
onChange: function (event) { | ||
onChange: function onChange(event) { | ||
var val = event.target.value; | ||
if (!isNaN(parseFloat(val)) && isFinite(val)) { | ||
this.setState({value: event.target.value}); | ||
this.setState({ value: event.target.value }); | ||
} | ||
}, | ||
handleKeyDown: function (e) { | ||
handleKeyDown: function handleKeyDown(e) { | ||
if (e.keyCode === 38) { | ||
this.step('up',e); | ||
this.step('up', e); | ||
} | ||
if (e.keyCode === 40) { | ||
this.step('down',e); | ||
this.step('down', e); | ||
} | ||
}, | ||
render: function () { | ||
render: function render() { | ||
var classes = rcUtil.classSet({ | ||
@@ -59,26 +60,26 @@ 'rc-input-num': true, | ||
}); | ||
return ( | ||
<div className={classes}> | ||
<a href="#" | ||
ref="down" | ||
onClick={this.step.bind(this, 'down')} | ||
className="rc-input-num-handler rc-input-num-handler-down"></a> | ||
<input className="rc-input-num-input" type="text" autocomplete="off" ref="input" onKeyDown={this.handleKeyDown} | ||
autofocus={this.props.autofocus} | ||
required={this.props.required} | ||
readonly={this.props.readonly} | ||
disabled={this.props.disabled} | ||
max={this.props.max} | ||
min={this.props.min} | ||
name={this.props.name} | ||
onChange={this.onChange} | ||
value={this.state.value} /> | ||
<a href="#" | ||
ref="up" | ||
onClick={this.step.bind(this, 'up')} | ||
className="rc-input-num-handler rc-input-num-handler-up"></a> | ||
</div> | ||
return React.createElement( | ||
'div', | ||
{ className: classes }, | ||
React.createElement('a', { href: '#', | ||
ref: 'down', | ||
onClick: this.step.bind(this, 'down'), | ||
className: 'rc-input-num-handler rc-input-num-handler-down' }), | ||
React.createElement('input', { className: 'rc-input-num-input', type: 'text', autocomplete: 'off', ref: 'input', onKeyDown: this.handleKeyDown, | ||
autofocus: this.props.autofocus, | ||
required: this.props.required, | ||
readonly: this.props.readonly, | ||
disabled: this.props.disabled, | ||
max: this.props.max, | ||
min: this.props.min, | ||
name: this.props.name, | ||
onChange: this.onChange, | ||
value: this.state.value }), | ||
React.createElement('a', { href: '#', | ||
ref: 'up', | ||
onClick: this.step.bind(this, 'up'), | ||
className: 'rc-input-num-handler rc-input-num-handler-up' }) | ||
); | ||
} | ||
}); | ||
module.exports = InputNumber; | ||
module.exports = InputNumber; |
{ | ||
"name": "rc-input-number", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "input-number ui component for react", | ||
@@ -11,2 +11,3 @@ "keywords": [ | ||
], | ||
"main": "lib/index", | ||
"homepage": "https://github.com/react-component/input-number", | ||
@@ -22,7 +23,2 @@ "author": "tsjxyz@gmail.com", | ||
"licenses": "MIT", | ||
"spm": { | ||
"dependencies": { | ||
"react": "*" | ||
} | ||
}, | ||
"config": { | ||
@@ -33,18 +29,19 @@ "port": 8000 | ||
"build": "rc-tools run build", | ||
"precommit": "rc-tools run precommit", | ||
"less": "rc-tools run less", | ||
"gh-pages": "rc-tools run gh-pages", | ||
"history": "rc-tools run history", | ||
"start": "node-dev --harmony node_modules/.bin/rc-server", | ||
"publish": "spm publish && rc-tools run tag", | ||
"start": "node --harmony node_modules/.bin/rc-server", | ||
"publish": "rc-tools run tag", | ||
"lint": "rc-tools run lint", | ||
"test": "", | ||
"saucelabs": "rc-tools run saucelabs", | ||
"browser-test": "rc-tools run browser-test", | ||
"browser-test-cover": "rc-tools run browser-test-cover" | ||
"saucelabs": "node --harmony node_modules/.bin/rc-tools run saucelabs", | ||
"browser-test": "node --harmony node_modules/.bin/rc-tools run browser-test", | ||
"browser-test-cover": "node --harmony node_modules/.bin/rc-tools run browser-test-cover" | ||
}, | ||
"devDependencies": { | ||
"expect.js": "~0.3.1", | ||
"precommit-hook": "^1.0.7", | ||
"rc-server": "~2.1.2", | ||
"rc-tools": "2.x", | ||
"rc-server": "3.x", | ||
"rc-tools": "3.x", | ||
"react": "~0.13.0", | ||
@@ -57,5 +54,4 @@ "node-dev": "2.x" | ||
"precommit": [ | ||
"lint", | ||
"less" | ||
"precommit" | ||
] | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
0
10035
6
174
2