import type { ChangeEvent } from 'react'; import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils'; import { InputTextarea } from 'primereact/inputtextarea'; /** The `TextareaWidget` is a widget for rendering input fields as textarea using PrimeReact. * * @param props - The `WidgetProps` for this component */ export default function TextareaWidget< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any, >(props: WidgetProps) { const { id, htmlName, value, required, disabled, readonly, autofocus, onChange, onBlur, onFocus, options } = props; const primeProps = (options.prime || {}) as object; let rows = 5; // noinspection SuspiciousTypeOfGuard if (typeof options.rows === 'string' || typeof options.rows === 'number') { rows = Number(options.rows); } const handleChange = (event: ChangeEvent) => { onChange(event.target.value === '' ? options.emptyValue : event.target.value); }; return ( onBlur(id, event.target.value))} onFocus={onFocus && ((event) => onFocus(id, event.target.value))} /> ); }