Skip to content

Commit 643d20e

Browse files
committed
Prepare for 2.1.0 release
1 parent 51b9c85 commit 643d20e

File tree

9 files changed

+28
-12
lines changed

9 files changed

+28
-12
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2.1.0
2+
--------------------------------------------------------------------------------
3+
* Added `snap` prop to make the value snap to the closest step when using buttons or up/down keys to change it.
4+
* Pass a reference to the input element to the onChange callbacks
5+
* Fixed an issue preventing the input from being editable when it's entire value is selected
6+
* Fixed an issue that might cause the component to loose its value if re-rendered without value prop
7+
8+
19
2.0.9
210
--------------------------------------------------------------------------------
311
* Field now accepts `"-."`, `"+.`", `"."`, `"-"`, and `"+"` at beginning of input value.

__tests__/misc.test.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ describe ('NumericInput/misc', function() {
5656
TestUtils.Simulate.focus(input)
5757
input.value = 1
5858
TestUtils.Simulate.change(input)
59-
expect(log.toString()).toEqual('1,1')
59+
expect(log.length).toEqual(3)
60+
expect(log[0]).toEqual(1)
61+
expect(log[1]).toEqual('1')
62+
expect(log[2]).toEqual(input)
6063
done()
6164
})
6265

@@ -116,10 +119,10 @@ describe ('NumericInput/misc', function() {
116119
TestUtils.Simulate.focus(input)
117120
input.value = 2
118121
TestUtils.Simulate.change(input)
119-
expect(log).toEqual([2,'2'])
122+
expect(log).toEqual([2, '2', input])
120123
input.value = ""
121124
TestUtils.Simulate.change(input)
122-
expect(log).toEqual([2,'2',null,""])
125+
expect(log).toEqual([2, '2', input, null, "", input])
123126
done()
124127
})
125128

dist/react-numeric-input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ return /******/ (function(modules) { // webpackBootstrap
237237
// many reasons for changing the value and this is the common place
238238
// that can capture them all
239239
if (prevState.value !== this.state.value && (!isNaN(this.state.value) || this.state.value === null)) {
240-
this._invokeEventCallback("onChange", this.state.value, this.refs.input.value);
240+
this._invokeEventCallback("onChange", this.state.value, this.refs.input.value, this.refs.input);
241241
}
242242

243243
// focus the input is needed (for example up/down buttons set

dist/react-numeric-input.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/Demo.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export default class Demo extends React.Component
2121
required : { value: true, on: false },
2222
noValidate: { value: true, on: false },
2323
pattern : { value: "[0-9].[0-9][0-9]", on: false },
24-
title : { value: "The title attr", on: false }//,
24+
title : { value: "The title attr", on: false },
25+
snap : { value: true, on: false },
26+
inputmode : { value: "numeric", on: false }
2527
// library
2628
}
2729
}
@@ -186,7 +188,8 @@ export default class Demo extends React.Component
186188
{ name: "title" , type: "text" },
187189
{ name: "required" , type: "bool" },
188190
{ name: "noValidate", type: "bool" },
189-
{ name: "inputmode" , type: "text" }
191+
{ name: "inputmode" , type: "text" },
192+
{ name: "snap" , type: "bool" }
190193
])}
191194
{/*
192195
parse function parseFloat

examples/examples.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ return /******/ (function(modules) { // webpackBootstrap
158158
required: { value: true, on: false },
159159
noValidate: { value: true, on: false },
160160
pattern: { value: "[0-9].[0-9][0-9]", on: false },
161-
title: { value: "The title attr", on: false } //,
161+
title: { value: "The title attr", on: false },
162+
snap: { value: true, on: false },
163+
inputmode: { value: "numeric", on: false }
162164
// library
163165
}
164166
};
@@ -358,7 +360,7 @@ return /******/ (function(modules) { // webpackBootstrap
358360
React.createElement(
359361
"tbody",
360362
null,
361-
this.renderPropEditors([{ name: "name", type: "text" }, { name: "className", type: "text" }, { name: "value", type: "text" }, { name: "min", type: "number" }, { name: "max", type: "number" }, { name: "step", type: "number", min: 0.001, step: 0.1, precision: 3 }, { name: "precision", type: "number", min: 0, max: 20 }, { name: "size", type: "number", min: 0, max: 60 }, { name: "maxLength", type: "number", min: 0, max: 20 }, { name: "disabled", type: "bool" }, { name: "readOnly", type: "bool" }, { name: "mobile", type: "bool" }, { name: "pattern", type: "text" }, { name: "title", type: "text" }, { name: "required", type: "bool" }, { name: "noValidate", type: "bool" }, { name: "inputmode", type: "text" }])
363+
this.renderPropEditors([{ name: "name", type: "text" }, { name: "className", type: "text" }, { name: "value", type: "text" }, { name: "min", type: "number" }, { name: "max", type: "number" }, { name: "step", type: "number", min: 0.001, step: 0.1, precision: 3 }, { name: "precision", type: "number", min: 0, max: 20 }, { name: "size", type: "number", min: 0, max: 60 }, { name: "maxLength", type: "number", min: 0, max: 20 }, { name: "disabled", type: "bool" }, { name: "readOnly", type: "bool" }, { name: "mobile", type: "bool" }, { name: "pattern", type: "text" }, { name: "title", type: "text" }, { name: "required", type: "bool" }, { name: "noValidate", type: "bool" }, { name: "inputmode", type: "text" }, { name: "snap", type: "bool" }])
362364
)
363365
)
364366
)

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ module.exports =
142142
key: 'componentDidUpdate',
143143
value: function componentDidUpdate(prevProps, prevState) {
144144
if (prevState.value !== this.state.value && (!isNaN(this.state.value) || this.state.value === null)) {
145-
this._invokeEventCallback("onChange", this.state.value, this.refs.input.value);
145+
this._invokeEventCallback("onChange", this.state.value, this.refs.input.value, this.refs.input);
146146
}
147147

148148
if (this.state.inputFocus) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-numeric-input",
3-
"version": "2.0.9",
3+
"version": "2.1.0",
44
"description": "Number input component that can replace the native number input which is not yet very well supported and where it is, it does not have the same appearance across the browsers. Additionally this component offers more flexible options and can be used for any values (differently formatted representations of the internal numeric value).",
55
"main": "index.js",
66
"scripts": {

src/NumericInput.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class NumericInput extends Component
363363
// many reasons for changing the value and this is the common place
364364
// that can capture them all
365365
if (prevState.value !== this.state.value && (!isNaN(this.state.value) || this.state.value === null)) {
366-
this._invokeEventCallback("onChange", this.state.value, this.refs.input.value)
366+
this._invokeEventCallback("onChange", this.state.value, this.refs.input.value, this.refs.input)
367367
}
368368

369369
// focus the input is needed (for example up/down buttons set

0 commit comments

Comments
 (0)