import Grid from '@mui/material/Grid'; import { FormContextType, ObjectFieldTemplateProps, RJSFSchema, StrictRJSFSchema, canExpand, descriptionId, getTemplate, getUiOptions, titleId, buttonId, } from '@rjsf/utils'; /** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the * title and description if available. If the object is expandable, then an `AddButton` is also rendered after all * the properties. * * @param props - The `ObjectFieldTemplateProps` for this component */ export default function ObjectFieldTemplate< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any, >(props: ObjectFieldTemplateProps) { const { description, title, properties, required, disabled, readonly, uiSchema, fieldPathId, schema, formData, optionalDataControl, onAddProperty, registry, } = props; const uiOptions = getUiOptions(uiSchema); const TitleFieldTemplate = getTemplate<'TitleFieldTemplate', T, S, F>('TitleFieldTemplate', registry, uiOptions); const DescriptionFieldTemplate = getTemplate<'DescriptionFieldTemplate', T, S, F>( 'DescriptionFieldTemplate', registry, uiOptions, ); const showOptionalDataControlInTitle = !readonly && !disabled; // Button templates are not overridden in the uiSchema const { ButtonTemplates: { AddButton }, } = registry.templates; return ( <> {title && ( )} {description && ( )} {!showOptionalDataControlInTitle ? optionalDataControl : undefined} {properties.map((element, index) => // Remove the if the inner element is hidden as the // itself would otherwise still take up space. element.hidden ? ( element.content ) : ( {element.content} ), )} {canExpand(schema, uiSchema, formData) && ( )} ); }