Skip to content

Commit

Permalink
feat: add initial value prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Cesarato committed Sep 25, 2020
1 parent 3c23c0d commit 7240008
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions PROPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
| `fontFamily` | Custom fontFamily of the text input of the Spinner | String | System Default | |
| `fontSize` | Custom fontSize of the text input of the Spinner | Number | `14` | |
| `height` | Custom height of the Spinner | Number | `50` | |
| `initialValue` | Initial value of the Spinner | String<br>Number | `0` | |
| `inputStyle` | Input Style (Text number at middle) | Object | | Could overwrite other props |
| `maxLength` | Limits the maximum number of characters that can be entered. | Number | | |
| `max` | Max number permitted | String<br>Number | `0` | |
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ Check the "[Props List](PROPS.md)" file to have the complete list of component p
| `append` | Custom element before right button | Component | | |
| `autofocus` | If `true`, focuses the input on `componentDidMount`. | | `false` | |
| `disabled` | Disable the Spinner or not | Boolean | `false` | |
| `editable` | Set if input number field is editable or not | Boolean | `true` | |
| `editable` | Set if input number field is editable or not | Boolean | `true` | |
| `initialValue` | Initial value of the Spinner | String<br>Number | `0` | |
| `maxLength` | Limits the maximum number of characters that can be entered. | Number | | |
| `max` | Max number permitted | String<br>Number | `0` |
| `min` | Min value permitted | String<br>Number | `99` |
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InputSpinner extends Component {
this.state = {
min: this.parseNum(this.props.min),
max: this.parseNum(this.props.max),
value: this.parseNum(this.props.value),
value: this.parseNum(!isNaN(this.props.initialValue) ? this.props.initialValue : this.props.value),
step: spinnerStep,
focused: false,
buttonPress: null,
Expand Down Expand Up @@ -828,6 +828,7 @@ InputSpinner.defaultProps = {
min: 0,
max: 999,
value: 0,
initialValue: null,
step: 1,
precision: 2,
rounded: true,
Expand Down

0 comments on commit 7240008

Please sign in to comment.