Skip to content

Commit

Permalink
Update to version 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jsillitoe committed Jun 21, 2017
1 parent d0505ae commit 8de4092
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ An es6 react component for currency. Supports custom decimal and thousand separ
[![Build Status](https://travis-ci.org/jsillitoe/react-currency-input.svg?branch=master)](https://travis-ci.org/jsillitoe/react-currency-input)


## Changes

V1.3.0:
-------
* Depecrated "onChange" option in favor of "onChangeEvent". This fixes the argument order to better match React's default input handling
* Updated dependencies to React 15
* Added parseFloat polyfill
* Persist events to deal with an issue of event pooling
* Other bug fixes.

## Installation
```
npm install react-currency-input --save
Expand All @@ -24,13 +34,13 @@ const MyApp = React.createClass({
return ({amount: "0.00"});
},

handleChange(newValue){
this.setState({amount: newValue});
handleChange(event, maskedvalue, floatvalue){
this.setState({amount: maskedvalue});
},
render() {
return (
<div>
<CurrencyInput value={this.state.amount} onChange={this.handleChange}/>
<CurrencyInput value={this.state.amount} onChangeEvent={this.handleChange}/>
</div>
);
}
Expand Down Expand Up @@ -121,7 +131,8 @@ All other attributes are applied to the input element. For example, you can int
| Option | Default Value | Description |
| ------------- | ----------- | ----------- |
| value | 0 | The initial currency value |
| onChange | n/a | Callback function to handle value changes |
| onChange | n/a | Callback function to handle value changes. Deprecated, use onChangeEvent. |
| onChangeEvent | n/a | Callback function to handle value changes |
| precision | 2 | Number of digits after the decimal separator |
| decimalSeparator | '.' | The decimal separator |
| thousandSeparator | ',' | The thousand separator |
Expand Down
7 changes: 5 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
</head>
<body>

<div id="example0" style="margin: 10px">2</div>
<div id="example0" style="margin: 10px">0</div>


<div id="example1" style="margin: 10px">2</div>
<div id="example1" style="margin: 10px">1</div>


<div id="example2" style="margin: 10px">2</div>
Expand All @@ -28,6 +28,9 @@
<div id="example5" style="margin: 10px">5</div>


<div id="example6" style="margin: 10px">6</div>


<script src="bundle.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ ReactDOM.render(<CurrencyInput prefix="$" precision="0"/>, document.getElementBy

ReactDOM.render(<CurrencyInput prefix="$" suffix=" kr"/>, document.getElementById('example5'));

ReactDOM.render(<CurrencyInput value="1" allowNegative={true}/>, document.getElementById('example6'));

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-currency-input",
"version": "1.2.8",
"version": "1.3.0",
"description": "React component for inputing currency amounts",
"main": "lib/index.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class CurrencyInput extends Component {

this.setState({ maskedValue, value }, () => {
this.props.onChange(maskedValue, value, event);
this.props.onChangeEvent(event, maskedValue, value);
});
}

Expand Down Expand Up @@ -244,6 +245,7 @@ CurrencyInput.propTypes = {

CurrencyInput.defaultProps = {
onChange: function(maskValue, value, event) {/*no-op*/},
onChangeEvent: function(event, maskValue, value) {/*no-op*/},
value: '0',
decimalSeparator: '.',
thousandSeparator: ',',
Expand Down

0 comments on commit 8de4092

Please sign in to comment.