Skip to content

Commit 8de4092

Browse files
committed
Update to version 1.3.0
1 parent d0505ae commit 8de4092

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ An es6 react component for currency. Supports custom decimal and thousand separ
55
[![Build Status](https://travis-ci.org/jsillitoe/react-currency-input.svg?branch=master)](https://travis-ci.org/jsillitoe/react-currency-input)
66

77

8+
## Changes
9+
10+
V1.3.0:
11+
-------
12+
* Depecrated "onChange" option in favor of "onChangeEvent". This fixes the argument order to better match React's default input handling
13+
* Updated dependencies to React 15
14+
* Added parseFloat polyfill
15+
* Persist events to deal with an issue of event pooling
16+
* Other bug fixes.
17+
818
## Installation
919
```
1020
npm install react-currency-input --save
@@ -24,13 +34,13 @@ const MyApp = React.createClass({
2434
return ({amount: "0.00"});
2535
},
2636

27-
handleChange(newValue){
28-
this.setState({amount: newValue});
37+
handleChange(event, maskedvalue, floatvalue){
38+
this.setState({amount: maskedvalue});
2939
},
3040
render() {
3141
return (
3242
<div>
33-
<CurrencyInput value={this.state.amount} onChange={this.handleChange}/>
43+
<CurrencyInput value={this.state.amount} onChangeEvent={this.handleChange}/>
3444
</div>
3545
);
3646
}
@@ -121,7 +131,8 @@ All other attributes are applied to the input element. For example, you can int
121131
| Option | Default Value | Description |
122132
| ------------- | ----------- | ----------- |
123133
| value | 0 | The initial currency value |
124-
| onChange | n/a | Callback function to handle value changes |
134+
| onChange | n/a | Callback function to handle value changes. Deprecated, use onChangeEvent. |
135+
| onChangeEvent | n/a | Callback function to handle value changes |
125136
| precision | 2 | Number of digits after the decimal separator |
126137
| decimalSeparator | '.' | The decimal separator |
127138
| thousandSeparator | ',' | The thousand separator |

examples/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
</head>
1111
<body>
1212

13-
<div id="example0" style="margin: 10px">2</div>
13+
<div id="example0" style="margin: 10px">0</div>
1414

1515

16-
<div id="example1" style="margin: 10px">2</div>
16+
<div id="example1" style="margin: 10px">1</div>
1717

1818

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

3030

31+
<div id="example6" style="margin: 10px">6</div>
32+
33+
3134
<script src="bundle.js"></script>
3235
</body>
3336
</html>

examples/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ ReactDOM.render(<CurrencyInput prefix="$" precision="0"/>, document.getElementBy
2020

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

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-currency-input",
3-
"version": "1.2.8",
3+
"version": "1.3.0",
44
"description": "React component for inputing currency amounts",
55
"main": "lib/index.js",
66
"scripts": {

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ class CurrencyInput extends Component {
175175

176176
this.setState({ maskedValue, value }, () => {
177177
this.props.onChange(maskedValue, value, event);
178+
this.props.onChangeEvent(event, maskedValue, value);
178179
});
179180
}
180181

@@ -244,6 +245,7 @@ CurrencyInput.propTypes = {
244245

245246
CurrencyInput.defaultProps = {
246247
onChange: function(maskValue, value, event) {/*no-op*/},
248+
onChangeEvent: function(event, maskValue, value) {/*no-op*/},
247249
value: '0',
248250
decimalSeparator: '.',
249251
thousandSeparator: ',',

0 commit comments

Comments
 (0)