import type { ArrayFieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils'; import { getTemplate, getUiOptions, isFixedItems, buttonId } from '@rjsf/utils'; import { cleanClassNames } from '../util'; /** 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, // classNames, This is not part of the type, so it is likely never passed in disabled, items, optionalDataControl, onAddClick, // options, This is not part of the type, so it is likely never passed in readonly, required, schema, title, registry, } = 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; // Button templates are not overridden in the uiSchema const { ButtonTemplates: { AddButton }, } = registry.templates; return (
(schema) ? '' : 'sortable-form-fields'])}>
{!showOptionalDataControlInTitle ? optionalDataControl : undefined} {items}
{canAdd && (
)}
); }