| 1 |
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps, getTemplate } from '@rjsf/utils'; |
| 2 |
|
| 3 |
/** The `TextareaWidget` is a widget for rendering input fields as textarea. |
| 4 |
* |
| 5 |
* @param props - The `WidgetProps` for this component |
| 6 |
*/ |
| 7 |
export default function TextareaWidget< |
| 8 |
T = any, |
| 9 |
S extends StrictRJSFSchema = RJSFSchema, |
| 10 |
F extends FormContextType = any |
| 11 |
>(props: WidgetProps<T, S, F>) { |
| 12 |
const { options, registry } = props; |
| 13 |
const BaseInputTemplate = getTemplate<'BaseInputTemplate', T, S, F>('BaseInputTemplate', registry, options); |
| 14 |
|
| 15 |
let rows: string | number = 5; |
| 16 |
if (typeof options.rows === 'string' || typeof options.rows === 'number') { |
| 17 |
rows = options.rows; |
| 18 |
} |
| 19 |
|
| 20 |
return <BaseInputTemplate {...props} multiline rows={rows} />; |
| 21 |
} |