import type { FieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils'; import { getTemplate, getUiOptions } from '@rjsf/utils'; import Form from 'react-bootstrap/Form'; export default function FieldTemplate< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any, >({ id, children, displayLabel, rawErrors = [], errors, help, description, rawDescription, classNames, style, disabled, label, hidden, onKeyRename, onKeyRenameBlur, onRemoveProperty, readonly, required, schema, uiSchema, registry, }: FieldTemplateProps) { const uiOptions = getUiOptions(uiSchema); const WrapIfAdditionalTemplate = getTemplate<'WrapIfAdditionalTemplate', T, S, F>( 'WrapIfAdditionalTemplate', registry, uiOptions, ); if (hidden) { return
{children}
; } const isCheckbox = uiOptions.widget === 'checkbox'; return ( {displayLabel && !isCheckbox && ( 0 ? 'text-danger' : ''}> {label} {required ? '*' : null} )} {children} {displayLabel && rawDescription && !isCheckbox && ( 0 ? 'text-danger' : 'text-muted'}>{description} )} {errors} {help} ); }