import { ChangeEvent } from 'react'; import { ariaDescribedByIds, FormContextType, getInputProps, RJSFSchema, StrictRJSFSchema, WidgetProps, } from '@snups/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 _onChange = ({ target: { value } }: ChangeEvent) => onChange(value === '' ? options.emptyValue : value); const _onBlur = () => onBlur && onBlur(id, value); const _onFocus = () => onFocus && onFocus(id, value); return ( 0} onChange={onChangeOverride || _onChange} onBlur={_onBlur} onFocus={_onFocus} aria-describedby={ariaDescribedByIds(id, !!schema.examples)} pt={{ root: { style: { display: 'flex', flexDirection: 'column' } } }} /> ); }