@@ -24,7 +24,7 @@ type Props = {
2424 isInputNum ?: boolean ,
2525 value ?: string ,
2626 className ?: string ,
27- isSecure ?: boolean
27+ isInputSecure ?: boolean ,
2828} ;
2929
3030type State = {
@@ -70,12 +70,18 @@ class SingleOtpInput extends PureComponent<*> {
7070
7171 getClasses = ( ...classes ) =>
7272 classes . filter ( c => ! isStyleObject ( c ) && c !== false ) . join ( ' ' ) ;
73-
73+
7474 getType = ( ) => {
75- if ( this . props . isSecure ) return 'password'
76- if ( this . props . isInputNum ) return 'tel'
77- return 'text'
78- }
75+ if ( this . props . isInputSecure ) {
76+ return 'password' ;
77+ }
78+
79+ if ( this . props . isInputNum ) {
80+ return 'tel' ;
81+ }
82+
83+ return 'text' ;
84+ } ;
7985
8086 render ( ) {
8187 const {
@@ -94,7 +100,7 @@ class SingleOtpInput extends PureComponent<*> {
94100 index,
95101 value,
96102 className,
97- isSecure ,
103+ isInputSecure ,
98104 ...rest
99105 } = this . props ;
100106
@@ -104,7 +110,9 @@ class SingleOtpInput extends PureComponent<*> {
104110 style = { { display : 'flex' , alignItems : 'center' } }
105111 >
106112 < input
107- aria-label = { `${ ( index === 0 ) ? 'Please enter verification code. ' : '' } ${ isInputNum ? 'Digit' : 'Character' } ${ index + 1 } ` }
113+ aria-label = { `${
114+ index === 0 ? 'Please enter verification code. ' : ''
115+ } ${ isInputNum ? 'Digit' : 'Character' } ${ index + 1 } `}
108116 autoComplete = "off"
109117 style = { Object . assign (
110118 { width : '1em' , textAlign : 'center' } ,
@@ -142,7 +150,7 @@ class OtpInput extends Component<Props, State> {
142150 isDisabled : false ,
143151 shouldAutoFocus : false ,
144152 value : '' ,
145- isSecure : false
153+ isInputSecure : false ,
146154 } ;
147155
148156 state = {
@@ -161,7 +169,9 @@ class OtpInput extends Component<Props, State> {
161169 }
162170
163171 if ( placeholder . length > 0 ) {
164- console . error ( 'Length of the placeholder should be equal to the number of inputs.' ) ;
172+ console . error (
173+ 'Length of the placeholder should be equal to the number of inputs.'
174+ ) ;
165175 }
166176 }
167177 } ;
@@ -306,12 +316,14 @@ class OtpInput extends Component<Props, State> {
306316 errorStyle,
307317 shouldAutoFocus,
308318 isInputNum,
309- isSecure ,
310- className
319+ isInputSecure ,
320+ className,
311321 } = this . props ;
312- const otp = this . getOtpValue ( ) ;
322+
313323 const inputs = [ ] ;
324+ const otp = this . getOtpValue ( ) ;
314325 const placeholder = this . getPlaceholderValue ( ) ;
326+
315327 for ( let i = 0 ; i < numInputs ; i ++ ) {
316328 inputs . push (
317329 < SingleOtpInput
@@ -339,7 +351,7 @@ class OtpInput extends Component<Props, State> {
339351 errorStyle = { errorStyle }
340352 shouldAutoFocus = { shouldAutoFocus }
341353 isInputNum = { isInputNum }
342- isSecure = { isSecure }
354+ isInputSecure = { isInputSecure }
343355 className = { className }
344356 />
345357 ) ;
0 commit comments