import type { ArrayFieldItemTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils'; import { getUiOptions, getTemplate } from '@rjsf/utils'; import { Button, Grid, Segment } from 'semantic-ui-react'; import { getSemanticProps, MaybeWrap } from '../util'; const gridStyle = (vertical: boolean) => ({ display: 'grid', gridTemplateColumns: `1fr ${vertical ? 65 : 150}px`, }); /** 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, buttonsProps, displayLabel, hasDescription, hasToolbar, uiSchema, registry, parentUiSchema } = props; const uiOptions = getUiOptions(uiSchema); const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>( 'ArrayFieldItemButtonsTemplate', registry, uiOptions, ); const semanticProps = getSemanticProps({ uiSchema: parentUiSchema, formContext: registry.formContext, defaultSchemaProps: { horizontalButtons: true, wrapItem: false }, }); const { horizontalButtons = true, wrapItem = false } = semanticProps; const margin = hasDescription ? 5 : 24; return (
{children} {hasToolbar && ( )}
); }