import { CSSProperties, FocusEvent } from 'react'; import Grid from '@material-ui/core/Grid'; import TextField from '@material-ui/core/TextField'; import { ADDITIONAL_PROPERTY_FLAG, FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString, WrapIfAdditionalTemplateProps, } from '@rjsf/utils'; /** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are * part of an `additionalProperties` part of a schema. * * @param props - The `WrapIfAdditionalProps` for this component */ export default function WrapIfAdditionalTemplate< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any >(props: WrapIfAdditionalTemplateProps) { const { children, classNames, style, disabled, id, label, onDropPropertyClick, onKeyChange, readonly, required, schema, uiSchema, registry, } = props; 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 btnStyle: CSSProperties = { flex: 1, paddingLeft: 6, paddingRight: 6, fontWeight: 'bold', }; if (!additional) { return (
{children}
); } const handleBlur = ({ target }: FocusEvent) => onKeyChange(target.value); return ( {children} ); }