@@ -12,7 +12,8 @@ var __assign = (this && this.__assign) || function () {
12
12
import React from 'react' ;
13
13
import { InputAdornment } from '@mui/material' ;
14
14
import { Security as SecurityIcon } from '@mui/icons-material' ;
15
- import { string as YupString , ref } from 'yup' ;
15
+ import { string as YupString } from 'yup' ;
16
+ import { wrap } from '../../helpers' ;
16
17
import TextField from './TextField' ;
17
18
var NewPasswordField = function ( _a ) {
18
19
var
@@ -24,12 +25,18 @@ var NewPasswordField = function (_a) {
24
25
_c = _a . repeatPasswordFieldProps ,
25
26
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
26
27
repeatPasswordFieldProps = _c === void 0 ? { } : _c ;
28
+ var _d = React . useState ( ) , password = _d [ 0 ] , setPassword = _d [ 1 ] ;
27
29
var endAdornment = ( React . createElement ( InputAdornment , { position : 'end' } ,
28
30
React . createElement ( SecurityIcon , null ) ) ) ;
31
+ passwordFieldProps . onKeyUp = wrap ( {
32
+ after : function ( event ) {
33
+ setPassword ( event . target . value ) ;
34
+ }
35
+ } , passwordFieldProps . onKeyUp ) ;
29
36
passwordFieldProps [ 'InputProps' ] = __assign ( { endAdornment : endAdornment } , ( 'InputProps' in passwordFieldProps && passwordFieldProps . InputProps ) ) ;
30
37
repeatPasswordFieldProps [ 'InputProps' ] = __assign ( { endAdornment : endAdornment } , ( 'InputProps' in repeatPasswordFieldProps && repeatPasswordFieldProps . InputProps ) ) ;
31
38
return React . createElement ( React . Fragment , null ,
32
39
React . createElement ( TextField , __assign ( { type : 'password' , name : 'password' , required : true } , passwordFieldProps ) ) ,
33
- React . createElement ( TextField , __assign ( { type : 'password' , name : 'repeatPassword' , required : true , validate : YupString ( ) . oneOf ( [ ref ( ' password' ) , undefined ] , 'Passwords don\'t match' ) } , repeatPasswordFieldProps ) ) ) ;
40
+ React . createElement ( TextField , __assign ( { type : 'password' , name : 'repeatPassword' , required : true , validate : YupString ( ) . oneOf ( [ password ] , 'Passwords don\'t match' ) } , repeatPasswordFieldProps ) ) ) ;
34
41
} ;
35
42
export default NewPasswordField ;
0 commit comments