Skip to content

Commit 7240008

Browse files
author
Marco Cesarato
committed
feat: add initial value prop
1 parent 3c23c0d commit 7240008

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

PROPS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
| `fontFamily` | Custom fontFamily of the text input of the Spinner | String | System Default | |
3535
| `fontSize` | Custom fontSize of the text input of the Spinner | Number | `14` | |
3636
| `height` | Custom height of the Spinner | Number | `50` | |
37+
| `initialValue` | Initial value of the Spinner | String<br>Number | `0` | |
3738
| `inputStyle` | Input Style (Text number at middle) | Object | | Could overwrite other props |
3839
| `maxLength` | Limits the maximum number of characters that can be entered. | Number | | |
3940
| `max` | Max number permitted | String<br>Number | `0` | |

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ Check the "[Props List](PROPS.md)" file to have the complete list of component p
105105
| `append` | Custom element before right button | Component | | |
106106
| `autofocus` | If `true`, focuses the input on `componentDidMount`. | | `false` | |
107107
| `disabled` | Disable the Spinner or not | Boolean | `false` | |
108-
| `editable` | Set if input number field is editable or not | Boolean | `true` | |
108+
| `editable` | Set if input number field is editable or not | Boolean | `true` | |
109+
| `initialValue` | Initial value of the Spinner | String<br>Number | `0` | |
109110
| `maxLength` | Limits the maximum number of characters that can be entered. | Number | | |
110111
| `max` | Max number permitted | String<br>Number | `0` |
111112
| `min` | Min value permitted | String<br>Number | `99` |

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class InputSpinner extends Component {
2929
this.state = {
3030
min: this.parseNum(this.props.min),
3131
max: this.parseNum(this.props.max),
32-
value: this.parseNum(this.props.value),
32+
value: this.parseNum(!isNaN(this.props.initialValue) ? this.props.initialValue : this.props.value),
3333
step: spinnerStep,
3434
focused: false,
3535
buttonPress: null,
@@ -828,6 +828,7 @@ InputSpinner.defaultProps = {
828828
min: 0,
829829
max: 999,
830830
value: 0,
831+
initialValue: null,
831832
step: 1,
832833
precision: 2,
833834
rounded: true,

0 commit comments

Comments
 (0)