import { Form } from 'antd'; import { FieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema, getTemplate, getUiOptions, GenericObjectType, } from '@rjsf/utils'; const VERTICAL_LABEL_COL = { span: 24 }; const VERTICAL_WRAPPER_COL = { span: 24 }; /** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field * content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component. * * @param props - The `FieldTemplateProps` for this component */ export default function FieldTemplate< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any, >(props: FieldTemplateProps) { const { children, description, displayLabel, errors, help, rawHelp, hidden, id, label, rawErrors, rawDescription, registry, required, schema, uiSchema, } = props; const { formContext } = registry; const { colon, labelCol = VERTICAL_LABEL_COL, wrapperCol = VERTICAL_WRAPPER_COL, wrapperStyle, descriptionLocation = 'below', } = formContext as GenericObjectType; const uiOptions = getUiOptions(uiSchema); const WrapIfAdditionalTemplate = getTemplate<'WrapIfAdditionalTemplate', T, S, F>( 'WrapIfAdditionalTemplate', registry, uiOptions, ); if (hidden) { return
{children}
; } // check to see if there is rawDescription(string) before using description(ReactNode) // to prevent showing a blank description area const descriptionNode = rawDescription ? description : undefined; const descriptionProps: GenericObjectType = {}; switch (descriptionLocation) { case 'tooltip': descriptionProps.tooltip = descriptionNode; break; case 'below': default: descriptionProps.extra = descriptionNode; break; } const isCheckbox = uiOptions.widget === 'checkbox'; return ( {children} ); }