import type { FormContextType, RJSFSchema, StrictRJSFSchema, WrapIfAdditionalTemplateProps } from '@rjsf/utils'; import { ADDITIONAL_PROPERTY_FLAG, buttonId, TranslatableString } from '@rjsf/utils'; import Col from 'react-bootstrap/Col'; import Form from 'react-bootstrap/Form'; import Row from 'react-bootstrap/Row'; export default function WrapIfAdditionalTemplate< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any, >({ classNames, style, children, disabled, id, label, displayLabel, onRemoveProperty, onKeyRenameBlur, rawDescription, readonly, required, schema, uiSchema, registry, }: WrapIfAdditionalTemplateProps) { const { templates, translateString } = registry; // Button templates are not overridden in the uiSchema const { RemoveButton } = templates.ButtonTemplates; const keyLabel = translateString(TranslatableString.KeyLabel, [label]); const additional = ADDITIONAL_PROPERTY_FLAG in schema; const descPadding = rawDescription ? 1 : 0; const descMargin = rawDescription ? -24 : 0; if (!additional) { return (
{children}
); } const keyId = `${id}-key`; const margin = displayLabel ? 12 + descMargin : 0; const padding = displayLabel ? 4 + descPadding : 1; return ( {displayLabel && {keyLabel}} {children} ); }