|
|
@ -15,6 +15,7 @@ import { GREY, TEXT, UNSELECTED } from '../../lib/consts/DEFAULT_THEME'; |
|
|
|
import INPUT_TYPES from '../../lib/consts/INPUT_TYPES'; |
|
|
|
import INPUT_TYPES from '../../lib/consts/INPUT_TYPES'; |
|
|
|
|
|
|
|
|
|
|
|
type OutlinedInputOptionalProps = { |
|
|
|
type OutlinedInputOptionalProps = { |
|
|
|
|
|
|
|
disableAutofill?: boolean; |
|
|
|
onPasswordVisibilityAppend?: ( |
|
|
|
onPasswordVisibilityAppend?: ( |
|
|
|
inputType: string, |
|
|
|
inputType: string, |
|
|
|
...restArgs: Parameters<Exclude<MUIIconButtonProps['onClick'], undefined>> |
|
|
|
...restArgs: Parameters<Exclude<MUIIconButtonProps['onClick'], undefined>> |
|
|
@ -25,13 +26,15 @@ type OutlinedInputProps = MUIOutlinedInputProps & OutlinedInputOptionalProps; |
|
|
|
|
|
|
|
|
|
|
|
const OUTLINED_INPUT_DEFAULT_PROPS: Pick< |
|
|
|
const OUTLINED_INPUT_DEFAULT_PROPS: Pick< |
|
|
|
OutlinedInputOptionalProps, |
|
|
|
OutlinedInputOptionalProps, |
|
|
|
'onPasswordVisibilityAppend' |
|
|
|
'disableAutofill' | 'onPasswordVisibilityAppend' |
|
|
|
> = { |
|
|
|
> = { |
|
|
|
|
|
|
|
disableAutofill: false, |
|
|
|
onPasswordVisibilityAppend: undefined, |
|
|
|
onPasswordVisibilityAppend: undefined, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const OutlinedInput: FC<OutlinedInputProps> = (outlinedInputProps) => { |
|
|
|
const OutlinedInput: FC<OutlinedInputProps> = (outlinedInputProps) => { |
|
|
|
const { |
|
|
|
const { |
|
|
|
|
|
|
|
disableAutofill = false, |
|
|
|
endAdornment, |
|
|
|
endAdornment, |
|
|
|
label, |
|
|
|
label, |
|
|
|
onPasswordVisibilityAppend, |
|
|
|
onPasswordVisibilityAppend, |
|
|
@ -68,6 +71,7 @@ const OutlinedInput: FC<OutlinedInputProps> = (outlinedInputProps) => { |
|
|
|
</> |
|
|
|
</> |
|
|
|
); |
|
|
|
); |
|
|
|
}, [initialType, onPasswordVisibilityAppend, type]); |
|
|
|
}, [initialType, onPasswordVisibilityAppend, type]); |
|
|
|
|
|
|
|
|
|
|
|
const combinedSx = useMemo( |
|
|
|
const combinedSx = useMemo( |
|
|
|
() => ({ |
|
|
|
() => ({ |
|
|
|
color: GREY, |
|
|
|
color: GREY, |
|
|
@ -102,6 +106,7 @@ const OutlinedInput: FC<OutlinedInputProps> = (outlinedInputProps) => { |
|
|
|
}), |
|
|
|
}), |
|
|
|
[label, sx], |
|
|
|
[label, sx], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const combinedEndAdornment = useMemo(() => { |
|
|
|
const combinedEndAdornment = useMemo(() => { |
|
|
|
let result; |
|
|
|
let result; |
|
|
|
|
|
|
|
|
|
|
@ -125,18 +130,33 @@ const OutlinedInput: FC<OutlinedInputProps> = (outlinedInputProps) => { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
}, [passwordVisibilityButton, endAdornment]); |
|
|
|
}, [passwordVisibilityButton, endAdornment]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const autofillLock = useMemo< |
|
|
|
|
|
|
|
Pick<MUIOutlinedInputProps, 'onFocus' | 'readOnly'> | undefined |
|
|
|
|
|
|
|
>( |
|
|
|
|
|
|
|
() => |
|
|
|
|
|
|
|
disableAutofill |
|
|
|
|
|
|
|
? { |
|
|
|
|
|
|
|
onFocus: (...args) => { |
|
|
|
|
|
|
|
const [event] = args; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
event.target.readOnly = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outlinedInputRestProps?.onFocus?.call(null, ...args); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
readOnly: true, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
: undefined, |
|
|
|
|
|
|
|
[disableAutofill, outlinedInputRestProps?.onFocus], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<MUIOutlinedInput |
|
|
|
<MUIOutlinedInput |
|
|
|
{...{ |
|
|
|
endAdornment={combinedEndAdornment} |
|
|
|
endAdornment: combinedEndAdornment, |
|
|
|
label={label} |
|
|
|
label, |
|
|
|
inputProps={{ type, ...inputRestProps }} |
|
|
|
inputProps: { |
|
|
|
{...outlinedInputRestProps} |
|
|
|
type, |
|
|
|
{...autofillLock} |
|
|
|
...inputRestProps, |
|
|
|
sx={combinedSx} |
|
|
|
}, |
|
|
|
|
|
|
|
...outlinedInputRestProps, |
|
|
|
|
|
|
|
sx: combinedSx, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
/> |
|
|
|
/> |
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|