From fcade9f3bce22cb032ad5c00a71fc22035e224d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9F=E8=B4=A4?= Date: Wed, 15 Nov 2023 11:04:14 +0800 Subject: [PATCH] fix(form): Password support strengthText --- packages/form/src/components/LoginForm/demos/login-form.tsx | 2 ++ packages/form/src/components/Text/index.tsx | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/form/src/components/LoginForm/demos/login-form.tsx b/packages/form/src/components/LoginForm/demos/login-form.tsx index f416592bb948..530bf7b5d040 100644 --- a/packages/form/src/components/LoginForm/demos/login-form.tsx +++ b/packages/form/src/components/LoginForm/demos/login-form.tsx @@ -77,6 +77,8 @@ export default () => { fieldProps={{ size: 'large', prefix: , + strengthText: + 'Password should contain numbers, letters and special characters, at least 8 characters long.', getStatus: (value) => { if (value && value.length > 12) { return 'ok'; diff --git a/packages/form/src/components/Text/index.tsx b/packages/form/src/components/Text/index.tsx index 97ad60a096f6..89878107c501 100644 --- a/packages/form/src/components/Text/index.tsx +++ b/packages/form/src/components/Text/index.tsx @@ -45,6 +45,7 @@ export type PasssWordStrengthProps = { statusRender?: (status: PasswordStatus) => React.ReactNode; getPercent?: (value?: string) => number; popoverProps?: PopoverProps; + strengthText?: React.ReactNode; }; const PasssWordStrength: React.FC< @@ -98,7 +99,7 @@ const PasssWordStrength: React.FC< marginTop: 10, }} > - 请至少输入 6 个字符。请不要使用容易被猜到的密码。 + {props.strengthText} } @@ -134,6 +135,7 @@ const Password: React.FC< statusRender={fieldProps?.statusRender} getPercent={fieldProps?.getPercent} popoverProps={fieldProps?.popoverProps} + strengthText={fieldProps?.strengthText} open={open} onOpenChange={setOpen} > @@ -145,6 +147,7 @@ const Password: React.FC< 'statusRender', 'getPercent', 'popoverProps', + 'strengthText', ]), onBlur: (e: any) => { fieldProps?.onBlur?.(e);