File size: 837 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import FormControl from '@mui/material/FormControl';
import FormHelperText from '@mui/material/FormHelperText';
import type { ReactNode } from 'react';
import React, { createElement } from 'react';
export default function wrapField(
{
component,
disabled,
error,
errorMessage,
fullWidth,
helperText,
margin,
readOnly,
required,
showInlineError,
variant,
}: any,
...children: ReactNode[]
) {
const formHelperText = showInlineError && error ? errorMessage : helperText;
const props = {
component,
disabled: !!disabled,
error: !!error,
fullWidth: !!fullWidth,
margin,
readOnly,
required,
variant,
};
return createElement(
FormControl,
props,
...children,
!!formHelperText && <FormHelperText>{formHelperText}</FormHelperText>
);
}
|