File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
src/design-system/password-box Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -10,19 +10,22 @@ interface PasswordBoxButtonProps {
1010 onClick : ( event : Readonly < React . MouseEvent < HTMLButtonElement > > ) => void ;
1111 disabled : boolean ;
1212 isPasswordVisible : boolean ;
13+ testId ?: string ;
1314}
1415
1516export const PasswordInputButton = ( {
1617 onClick,
1718 disabled,
1819 isPasswordVisible,
20+ testId,
1921} : Readonly < PasswordBoxButtonProps > ) : JSX . Element => {
2022 return (
2123 < button
2224 type = "button"
2325 className = { cx . inputButton }
2426 onClick = { onClick }
2527 disabled = { disabled }
28+ data-testid = { testId }
2629 >
2730 { isPasswordVisible ? (
2831 < CloseEye
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export interface PasswordInputProps extends Form.FormControlProps {
2121 defaultIsPasswordVisible ?: boolean ;
2222 containerClassName ?: string ;
2323 containerStyle ?: React . CSSProperties ;
24+ testId ?: string ;
2425}
2526
2627export const PasswordInput = ( {
@@ -35,6 +36,7 @@ export const PasswordInput = ({
3536 onChange,
3637 defaultIsPasswordVisible = false ,
3738 containerStyle,
39+ testId,
3840} : Readonly < PasswordInputProps > ) : JSX . Element => {
3941 const [ isPasswordVisible , setIsPasswordVisible ] = useState (
4042 defaultIsPasswordVisible ,
@@ -62,6 +64,7 @@ export const PasswordInput = ({
6264 value = { value }
6365 onChange = { onChange }
6466 id = { id }
67+ data-testid = { testId }
6568 />
6669 </ Form . Control >
6770 < Form . Label
@@ -70,6 +73,7 @@ export const PasswordInput = ({
7073 { label }
7174 </ Form . Label >
7275 < PasswordInputButton
76+ testId = { testId && `${ testId } -toggle` }
7377 onClick = { ( event ) : void => {
7478 event . preventDefault ( ) ;
7579 setIsPasswordVisible ( ! isPasswordVisible ) ;
You can’t perform that action at this time.
0 commit comments