import { ChangeEvent, FocusEvent } from 'react'; import { Input } from 'antd'; import { ariaDescribedByIds, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps, GenericObjectType, } from '@rjsf/utils'; /** The `PasswordWidget` component uses the `BaseInputTemplate` changing the type to `password`. * * @param props - The `WidgetProps` for this component */ export default function PasswordWidget< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any, >(props: WidgetProps) { const { disabled, registry, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props; const { formContext } = registry; const { readonlyAsDisabled = true } = formContext as GenericObjectType; const emptyValue = options.emptyValue || ''; const handleChange = ({ target }: ChangeEvent) => onChange(target.value === '' ? emptyValue : target.value); const handleBlur = ({ target }: FocusEvent) => onBlur(id, target.value); const handleFocus = ({ target }: FocusEvent) => onFocus(id, target.value); return ( ); }