import type { ArrayFieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils'; import { getTemplate, getUiOptions, isFixedItems, buttonId } from '@rjsf/utils'; import { Fieldset } from 'primereact/fieldset'; import AddButton from '../AddButton'; /** The `ArrayFieldTemplate` component is the template used to render all items in an array. * * @param props - The `ArrayFieldTemplateProps` props for the component */ export default function ArrayFieldTemplate< T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any, >(props: ArrayFieldTemplateProps) { const { uiSchema, fieldPathId, canAdd, className, disabled, items, optionalDataControl, onAddClick, readonly, schema, title, registry, required, // Destructure the following props out so that they aren't put into the DOM formData, rawErrors, ...rest } = props; const uiOptions = getUiOptions(uiSchema); const ArrayFieldDescriptionTemplate = getTemplate<'ArrayFieldDescriptionTemplate', T, S, F>( 'ArrayFieldDescriptionTemplate', registry, uiOptions, ); const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>( 'ArrayFieldTitleTemplate', registry, uiOptions, ); const showOptionalDataControlInTitle = !readonly && !disabled; return ( <>
(schema) ? '' : ' sortable-form-fields'}`} >
{!showOptionalDataControlInTitle ? optionalDataControl : undefined} {items}
{canAdd && (
)}
); }