@@ -19,6 +19,8 @@ export type PasswordInputProps = Omit<
1919 "state" | "stateRelatedMessage" | "iconId" | "classes"
2020> & {
2121 classes ?: Partial < Record < "root" | "input" | "label" | "checkbox" , string > > ;
22+ /** Default "Your password must contain:", if empty string the hint wont be displayed */
23+ messagesHint ?: ReactNode ;
2224 messages ?: {
2325 severity : PasswordInputProps . Severity ;
2426 message : ReactNode ;
@@ -41,6 +43,8 @@ export namespace PasswordInputProps {
4143 * */
4244export const PasswordInput = memo (
4345 forwardRef < HTMLDivElement , PasswordInputProps > ( ( props , ref ) => {
46+ const { t } = useTranslation ( ) ;
47+
4448 const {
4549 className,
4650 label,
@@ -51,13 +55,12 @@ export const PasswordInput = memo(
5155 style,
5256 messages = [ ] ,
5357 nativeInputProps,
58+ messagesHint = t ( "your password must contain" ) ,
5459 ...rest
5560 } = props ;
5661
5762 assert < Equals < keyof typeof rest , never > > ( ) ;
5863
59- const { t } = useTranslation ( ) ;
60-
6164 const inputId = ( function useClosure ( ) {
6265 const id = useId ( ) ;
6366
@@ -113,9 +116,11 @@ export const PasswordInput = memo(
113116 id = { messagesGroupId }
114117 aria-live = "assertive"
115118 >
116- < p className = { fr . cx ( "fr-message" ) } id = { messageGroupId } >
117- { t ( "your password must contain" ) }
118- </ p >
119+ { messagesHint !== "" && (
120+ < p className = { fr . cx ( "fr-message" ) } id = { messageGroupId } >
121+ { messagesHint }
122+ </ p >
123+ ) }
119124 { messages . map ( ( { severity, message } , index ) => (
120125 < p
121126 key = { index }
0 commit comments