Skip to content

Commit

Permalink
fix(form): PasssWord statusRender support value
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Nov 15, 2023
1 parent ee6beb6 commit 5abe403
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/form/src/components/Text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const passwordProgressMap = {

export type PasssWordStrengthProps = {
getStatus?: (value?: string) => PasswordStatus;
statusRender?: (status: PasswordStatus) => React.ReactNode;
statusRender?: (status: PasswordStatus, value?: string) => React.ReactNode;
getPercent?: (value?: string) => number;
popoverProps?: PopoverProps;
strengthText?: React.ReactNode;
Expand All @@ -63,7 +63,7 @@ const PasssWordStrength: React.FC<
return (
<Form.Item shouldUpdate noStyle>
{(form) => {
const value = form.getFieldValue(props.name || []);
const value = form.getFieldValue(props.name || []) as string;
const status = props.getStatus?.(value);
const getPasswordProgressDom = () => {
return value && value.length && status ? (
Expand Down Expand Up @@ -93,7 +93,7 @@ const PasssWordStrength: React.FC<
padding: '4px 0',
}}
>
{props?.statusRender?.(status)}
{props?.statusRender?.(status, value)}
{getPasswordProgressDom()}
<div
style={{
Expand Down Expand Up @@ -128,7 +128,7 @@ const Password: React.FC<
}: ProFormFieldItemProps<PasswordProps & PasssWordStrengthProps, InputRef>) => {
const [open, setOpen] = useState<boolean>(false);

if (fieldProps?.getStatus && fieldProps?.statusRender) {
if (fieldProps?.getStatus && fieldProps?.statusRender && rest.name) {
return (
<PasssWordStrength
name={rest.name}
Expand Down

0 comments on commit 5abe403

Please sign in to comment.