File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ export default function App() {
4848| onCompleted | ` function ` | ` () => {} ` | false | Function called when the code is completed |
4949| placeholder | ` string ` | ` · ` | false | String rendered in each item when no value has been typed |
5050| value | ` string ` | ` () => {} ` | false | Control internal input value |
51+ | type | ` text ` or ` password ` | ` text ` | false | Display the item value or a password mask |
52+ | passwordMask | ` string ` | ` • ` | false | Password mask |
5153
5254### CSS Properties
5355
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ type Props = {
1717 placeholder ?: string ;
1818 value ?: string ;
1919 dataCy ?: string ;
20+ type ?: 'text' | 'password' ;
21+ passwordMask ?: string ;
2022} ;
2123
2224const ReactInputVerificationCode = ( {
@@ -26,7 +28,9 @@ const ReactInputVerificationCode = ({
2628 onCompleted = ( ) => { } ,
2729 placeholder = '·' ,
2830 value : pValue ,
29- dataCy = 'verification-code'
31+ dataCy = 'verification-code' ,
32+ type = 'text' ,
33+ passwordMask = '•'
3034} : Props ) => {
3135 const emptyValue = new Array ( length ) . fill ( placeholder ) ;
3236
@@ -167,6 +171,11 @@ const ReactInputVerificationCode = ({
167171 if ( pValue !== value . join ( '' ) ) setValue ( pValue . split ( '' ) ) ;
168172 } , [ pValue ] ) ;
169173
174+ const renderItemText = ( itemValue : string ) => {
175+ if ( itemValue === placeholder ) return placeholder ;
176+ return type === 'password' ? passwordMask : itemValue ;
177+ } ;
178+
170179 return (
171180 < React . Fragment >
172181 < Global
@@ -214,7 +223,7 @@ const ReactInputVerificationCode = ({
214223 onFocus = { onItemFocus ( i ) }
215224 data-cy = { `${ dataCy } -${ i } -item` }
216225 >
217- { value [ i ] || placeholder }
226+ { renderItemText ( value [ i ] ) }
218227 </ Item >
219228 ) ) }
220229 </ Container >
You can’t perform that action at this time.
0 commit comments