Skip to content

Commit

Permalink
fix(form): Password support strengthText
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Nov 15, 2023
1 parent 61fe19a commit fcade9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/form/src/components/LoginForm/demos/login-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export default () => {
fieldProps={{
size: 'large',
prefix: <LockOutlined className={'prefixIcon'} />,
strengthText:
'Password should contain numbers, letters and special characters, at least 8 characters long.',
getStatus: (value) => {
if (value && value.length > 12) {
return 'ok';
Expand Down
5 changes: 4 additions & 1 deletion packages/form/src/components/Text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down Expand Up @@ -98,7 +99,7 @@ const PasssWordStrength: React.FC<
marginTop: 10,
}}
>
<span>请至少输入 6 个字符。请不要使用容易被猜到的密码。</span>
<span>{props.strengthText}</span>
</div>
</div>
}
Expand Down Expand Up @@ -134,6 +135,7 @@ const Password: React.FC<
statusRender={fieldProps?.statusRender}
getPercent={fieldProps?.getPercent}
popoverProps={fieldProps?.popoverProps}
strengthText={fieldProps?.strengthText}
open={open}
onOpenChange={setOpen}
>
Expand All @@ -145,6 +147,7 @@ const Password: React.FC<
'statusRender',
'getPercent',
'popoverProps',
'strengthText',
]),
onBlur: (e: any) => {
fieldProps?.onBlur?.(e);
Expand Down

0 comments on commit fcade9f

Please sign in to comment.