import { FocusEvent } from 'react'; import { ADDITIONAL_PROPERTY_FLAG, buttonId, FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString, WrapIfAdditionalTemplateProps, } from '@snups/rjsf-utils'; import { InputText } from 'primereact/inputtext'; /** 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, >({ classNames, style, children, disabled, id, label, onDropPropertyClick, onKeyChange, readonly, required, schema, registry, }: WrapIfAdditionalTemplateProps) { const { templates, translateString } = registry; 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); return (
{children}
(id, 'remove')} className='rjsf-object-property-remove' disabled={disabled || readonly} onClick={onDropPropertyClick(label)} registry={registry} />
); }