import { ChangeEvent, FocusEvent } from 'react'; import { Input } from 'antd'; import { ariaDescribedByIds, FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema, WidgetProps, } from '@rjsf/utils'; const INPUT_STYLE = { width: '100%', }; /** The `TextareaWidget` is a widget for rendering input fields as textarea. * * @param props - The `WidgetProps` for this component */ export default function TextareaWidget< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any, >({ disabled, registry, id, htmlName, onBlur, onChange, onFocus, options, placeholder, readonly, value, }: WidgetProps) { const { formContext } = registry; const { readonlyAsDisabled = true } = formContext as GenericObjectType; const handleChange = ({ target }: ChangeEvent) => onChange(target.value === '' ? options.emptyValue : target.value); const handleBlur = ({ target }: FocusEvent) => onBlur(id, target && target.value); const handleFocus = ({ target }: FocusEvent) => onFocus(id, target && target.value); // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided, // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors const extraProps = { type: 'textarea', }; return ( ); }