import { FocusEvent } from 'react'; import { ADDITIONAL_PROPERTY_FLAG, FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString, WrapIfAdditionalTemplateProps, } from '@rjsf/utils'; import Row from 'react-bootstrap/Row'; import Col from 'react-bootstrap/Col'; import Form from 'react-bootstrap/Form'; export default function WrapIfAdditionalTemplate< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any >({ classNames, style, children, disabled, id, label, onDropPropertyClick, onKeyChange, 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; if (!additional) { return (
{children}
); } const handleBlur = ({ target }: FocusEvent) => onKeyChange(target.value); const keyId = `${id}-key`; return ( {keyLabel} {children} ); }