File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ type Props = {
19
19
hasErrored ?: boolean ,
20
20
errorStyle ?: Object ,
21
21
shouldAutoFocus ?: boolean ,
22
+ isInputNum ?: boolean ,
22
23
} ;
23
24
24
25
type State = {
@@ -76,9 +77,12 @@ class SingleOtpInput extends PureComponent<*> {
76
77
focusStyle,
77
78
disabledStyle,
78
79
shouldAutoFocus,
80
+ isInputNum,
79
81
...rest
80
82
} = this . props ;
81
83
84
+ const numValueLimits = isInputNum ? { min : 0 , max : 9 } : { } ;
85
+
82
86
return (
83
87
< div style = { { display : 'flex' , alignItems : 'center' } } >
84
88
< input
@@ -94,7 +98,8 @@ class SingleOtpInput extends PureComponent<*> {
94
98
isDisabled && disabledStyle ,
95
99
hasErrored && errorStyle
96
100
) }
97
- type = "tel"
101
+ type = { isInputNum ? 'number' : 'tel' }
102
+ { ...numValueLimits }
98
103
maxLength = "1"
99
104
ref = { input => {
100
105
this . input = input ;
@@ -227,6 +232,7 @@ class OtpInput extends Component<Props, State> {
227
232
hasErrored,
228
233
errorStyle,
229
234
shouldAutoFocus,
235
+ isInputNum,
230
236
} = this . props ;
231
237
const inputs = [ ] ;
232
238
@@ -255,6 +261,7 @@ class OtpInput extends Component<Props, State> {
255
261
hasErrored = { hasErrored }
256
262
errorStyle = { errorStyle }
257
263
shouldAutoFocus = { shouldAutoFocus }
264
+ isInputNum = { isInputNum }
258
265
/>
259
266
) ;
260
267
}
You can’t perform that action at this time.
0 commit comments