11import { useMountMergeState } from '@ant-design/pro-utils' ;
2- import { Form , Popover , PopoverProps , Progress , type InputProps } from 'antd' ;
2+ import { Form , Popover , PopoverProps , type InputProps } from 'antd' ;
33import type { InputRef , PasswordProps } from 'antd/lib/input' ;
44import omit from 'omit.js' ;
55import React , { useState } from 'react' ;
@@ -34,16 +34,8 @@ const ProFormText: React.FC<ProFormFieldItemProps<InputProps, InputRef>> = ({
3434
3535export type PasswordStatus = 'ok' | 'pass' | 'poor' | undefined ;
3636
37- const passwordProgressMap = {
38- ok : 'success' ,
39- pass : 'normal' ,
40- poor : 'exception' ,
41- } as const ;
42-
4337export type PasssWordStrengthProps = {
44- getStatus ?: ( value ?: string ) => PasswordStatus ;
45- statusRender ?: ( status : PasswordStatus , value ?: string ) => React . ReactNode ;
46- getPercent ?: ( status : PasswordStatus , value ?: string ) => number ;
38+ statusRender ?: ( value ?: string ) => React . ReactNode ;
4739 popoverProps ?: PopoverProps ;
4840 strengthText ?: React . ReactNode ;
4941} ;
@@ -64,20 +56,6 @@ const PasssWordStrength: React.FC<
6456 < Form . Item shouldUpdate noStyle >
6557 { ( form ) => {
6658 const value = form . getFieldValue ( props . name || [ ] ) as string ;
67- const status = props . getStatus ?.( value ) ;
68- const getPasswordProgressDom = ( ) => {
69- return value && value . length && status ? (
70- < Progress
71- status = { passwordProgressMap [ status ] }
72- steps = { 3 }
73- style = { {
74- width : '100%' ,
75- } }
76- percent = { props . getPercent ?.( status , value ) || 0 }
77- showInfo = { false }
78- />
79- ) : null ;
80- } ;
8159 return (
8260 < Popover
8361 getPopupContainer = { ( node ) => {
@@ -93,8 +71,6 @@ const PasssWordStrength: React.FC<
9371 padding : '4px 0' ,
9472 } }
9573 >
96- { props ?. statusRender ?.( status , value ) }
97- { getPasswordProgressDom ( ) }
9874 { props . strengthText ? (
9975 < div
10076 style = { {
@@ -130,13 +106,11 @@ const Password: React.FC<
130106} : ProFormFieldItemProps < PasswordProps & PasssWordStrengthProps , InputRef > ) => {
131107 const [ open , setOpen ] = useState < boolean > ( false ) ;
132108
133- if ( fieldProps ?. getStatus && fieldProps ?. statusRender && rest . name ) {
109+ if ( fieldProps ?. statusRender && rest . name ) {
134110 return (
135111 < PasssWordStrength
136112 name = { rest . name }
137- getStatus = { fieldProps ?. getStatus }
138113 statusRender = { fieldProps ?. statusRender }
139- getPercent = { fieldProps ?. getPercent }
140114 popoverProps = { fieldProps ?. popoverProps }
141115 strengthText = { fieldProps ?. strengthText }
142116 open = { open }
@@ -146,9 +120,7 @@ const Password: React.FC<
146120 valueType = "password"
147121 fieldProps = { {
148122 ...omit ( fieldProps , [
149- 'getStatus' ,
150123 'statusRender' ,
151- 'getPercent' ,
152124 'popoverProps' ,
153125 'strengthText' ,
154126 ] ) ,
0 commit comments