import type { ChangeEvent } from 'react'; import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils'; import { ariaDescribedByIds, getInputProps } from '@rjsf/utils'; import { Password } from 'primereact/password'; /** The `PasswordWidget` renders a `Password` component * * @param props - The `WidgetProps` for this component */ export default function PasswordWidget< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any, >(props: WidgetProps) { const { id, placeholder, value, required, readonly, disabled, onChange, onChangeOverride, onBlur, onFocus, autofocus, options, schema, type, rawErrors = [], } = props; const inputProps = getInputProps(schema, type, options); const primeProps = (options.prime || {}) as object; const handleChange = ({ target: { value: newValue } }: ChangeEvent) => onChange(newValue === '' ? options.emptyValue : newValue); const handleBlur = () => onBlur && onBlur(id, value); const handleFocus = () => onFocus && onFocus(id, value); return ( 0} onChange={onChangeOverride || handleChange} onBlur={handleBlur} onFocus={handleFocus} aria-describedby={ariaDescribedByIds(id, !!schema.examples)} pt={{ root: { style: { display: 'flex', flexDirection: 'column' } } }} /> ); }