Skip to content

Commit

Permalink
fix(form): PassWord getPercent support status
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Nov 15, 2023
1 parent 5abe403 commit 7c1bf34
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default () => {
}
return 'poor';
},
getPercent: (value) => {
getPercent: (status, value) => {
if (value && value.length > 12) {
return 100;
}
Expand Down
20 changes: 11 additions & 9 deletions packages/form/src/components/Text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const passwordProgressMap = {
export type PasssWordStrengthProps = {
getStatus?: (value?: string) => PasswordStatus;
statusRender?: (status: PasswordStatus, value?: string) => React.ReactNode;
getPercent?: (value?: string) => number;
getPercent?: (status: PasswordStatus, value?: string) => number;
popoverProps?: PopoverProps;
strengthText?: React.ReactNode;
};
Expand Down Expand Up @@ -73,7 +73,7 @@ const PasssWordStrength: React.FC<
style={{
width: '100%',
}}
percent={props.getPercent?.(value) || 0}
percent={props.getPercent?.(status, value) || 0}
showInfo={false}
/>
) : null;
Expand All @@ -95,13 +95,15 @@ const PasssWordStrength: React.FC<
>
{props?.statusRender?.(status, value)}
{getPasswordProgressDom()}
<div
style={{
marginTop: 10,
}}
>
<span>{props.strengthText}</span>
</div>
{props.strengthText ? (
<div
style={{
marginTop: 10,
}}
>
<span>{props.strengthText}</span>
</div>
) : null}
</div>
}
overlayStyle={{
Expand Down

0 comments on commit 7c1bf34

Please sign in to comment.