0.4.3 • Published 6 years ago
react-numeral-input v0.4.3
react-numeral-input
It is a very tiny component which is a replacement of HTML input element for post-editing format of number values.
ex. 1000000 -> 1,000,000
Live Demo
Dependency
- React.js
- Numeral.js
install
npm install react-numeral-input
Usage
// replace original input from
<input value={this.state.numeralVal} className="" placeholder="" onChange={this.onChange} />
// like this
<NumeralInput value={this.state.numeralVal} className="" placeholder="" onChange={this.onChange} />
Example
let NumeralInput = require('react-numeral-input');
module.exports = React.createClass({
getInitialState() {
return {
numeralVal: 1000000
}
},
onChange(val){
this.setState( {numeralVal:val});
},
render() {
return (
<NumeralInput
value={this.state.numeralVal}
className="form-control"
placeholder=""
onChange={this.onChange} />
)
}
});
Options
You can set any original input props. such as minlength, maxlength. For example:
<NumeralInput value={this.state.numeralVal} className="" placeholder="" onChange={this.onChange} minLength={2} maxLength={10}/>
fmt(:string)
Default: "0,0"
It is passed to configure numeral format, You can find more information from Numeral.js.
onChange(:function)
Callback when value is changed, you will receieve unformated number (1000000 instead of 1,000,000).
0.4.3
6 years ago
0.4.2
7 years ago
0.4.1
7 years ago
0.4.0
8 years ago
0.3.3
8 years ago
0.3.2
8 years ago
0.3.1
8 years ago
0.3.0
8 years ago
0.2.2
8 years ago
0.2.1
8 years ago
0.2.0
9 years ago
0.1.4
9 years ago
0.1.3
9 years ago
0.1.2
9 years ago
0.1.1
9 years ago
0.1.0
9 years ago
0.0.9
9 years ago
0.0.8
9 years ago
0.0.7
9 years ago
0.0.6
9 years ago
0.0.5
9 years ago
0.0.4
9 years ago
0.0.3
9 years ago
0.0.2
9 years ago
0.0.1
9 years ago