import { CSSProperties } from 'react'; import { ArrayFieldItemTemplateProps, FormContextType, getTemplate, getUiOptions, RJSFSchema, StrictRJSFSchema, } from '@rjsf/utils'; /** The `ArrayFieldItemTemplate` component is the template used to render an items of an array. * * @param props - The `ArrayFieldItemTemplateProps` props for the component */ export default function ArrayFieldItemTemplate< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any, >(props: ArrayFieldItemTemplateProps) { const { children, className, buttonsProps, displayLabel, hasDescription, hasToolbar, registry, uiSchema } = props; const uiOptions = getUiOptions(uiSchema); const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>( 'ArrayFieldItemButtonsTemplate', registry, uiOptions, ); const btnStyle: CSSProperties = { flex: 1, paddingLeft: 6, paddingRight: 6, fontWeight: 'bold', }; const margin = hasDescription ? 31 : 9; const containerStyle = { display: 'flex', alignItems: displayLabel ? 'center' : 'baseline' }; const toolbarStyle = { display: 'flex', justifyContent: 'flex-end', marginTop: displayLabel ? `${margin}px` : 0 }; return (
{children}
{hasToolbar && (
)}
); }