| 
1 |  | -import { ArrayFieldTemplateItemType, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';  | 
 | 1 | +import {  | 
 | 2 | +  ArrayFieldItemTemplateType,  | 
 | 3 | +  FormContextType,  | 
 | 4 | +  getTemplate,  | 
 | 5 | +  getUiOptions,  | 
 | 6 | +  RJSFSchema,  | 
 | 7 | +  StrictRJSFSchema,  | 
 | 8 | +} from '@rjsf/utils';  | 
2 | 9 | import { Box, Flex, Group } from '@mantine/core';  | 
3 | 10 | 
 
  | 
4 | 11 | /** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.  | 
5 | 12 |  *  | 
6 |  | - * @param props - The `ArrayFieldTemplateItemType` props for the component  | 
 | 13 | + * @param props - The `ArrayFieldItemTemplateType` props for the component  | 
7 | 14 |  */  | 
8 | 15 | export default function ArrayFieldItemTemplate<  | 
9 | 16 |   T = any,  | 
10 | 17 |   S extends StrictRJSFSchema = RJSFSchema,  | 
11 | 18 |   F extends FormContextType = any  | 
12 |  | ->(props: ArrayFieldTemplateItemType<T, S, F>) {  | 
13 |  | -  const {  | 
14 |  | -    disabled,  | 
15 |  | -    className,  | 
16 |  | -    hasCopy,  | 
17 |  | -    hasMoveDown,  | 
18 |  | -    hasMoveUp,  | 
19 |  | -    hasRemove,  | 
20 |  | -    hasToolbar,  | 
21 |  | -    index,  | 
22 |  | -    onCopyIndexClick,  | 
23 |  | -    onDropIndexClick,  | 
24 |  | -    onReorderClick,  | 
25 |  | -    readonly,  | 
26 |  | -    uiSchema,  | 
 | 19 | +>(props: ArrayFieldItemTemplateType<T, S, F>) {  | 
 | 20 | +  const { buttonsProps, className, hasToolbar, index, uiSchema, registry, children } = props;  | 
 | 21 | +  const uiOptions = getUiOptions<T, S, F>(uiSchema);  | 
 | 22 | +  const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(  | 
 | 23 | +    'ArrayFieldItemButtonsTemplate',  | 
27 | 24 |     registry,  | 
28 |  | -    children,  | 
29 |  | -  } = props;  | 
30 |  | -  const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates;  | 
 | 25 | +    uiOptions  | 
 | 26 | +  );  | 
31 | 27 | 
 
  | 
32 | 28 |   return (  | 
33 | 29 |     <Box key={`array-item-${index}`} className={className || 'array-item'} mb='xs'>  | 
34 | 30 |       <Flex gap='xs' align='end' justify='center'>  | 
35 | 31 |         <Box w='100%'>{children}</Box>  | 
36 | 32 |         {hasToolbar && (  | 
37 |  | -          <Group wrap='nowrap' gap={2}>  | 
38 |  | -            {(hasMoveUp || hasMoveDown) && (  | 
 | 33 | +          <Group wrap='nowrap' gap={2} mb={7}>  | 
 | 34 | +            <ArrayFieldItemButtonsTemplate {...buttonsProps} />  | 
 | 35 | +          </Group>  | 
 | 36 | +        )}  | 
 | 37 | +      </Flex>  | 
 | 38 | +    </Box>  | 
 | 39 | +  );  | 
 | 40 | +}  | 
 | 41 | + | 
 | 42 | +/*  | 
 | 43 | +{(hasMoveUp || hasMoveDown) && (  | 
39 | 44 |               <MoveUpButton  | 
40 | 45 |                 iconType='sm'  | 
41 | 46 |                 className='array-item-move-up'  | 
@@ -75,9 +80,4 @@ export default function ArrayFieldItemTemplate<  | 
75 | 80 |                 registry={registry}  | 
76 | 81 |               />  | 
77 | 82 |             )}  | 
78 |  | -          </Group>  | 
79 |  | -        )}  | 
80 |  | -      </Flex>  | 
81 |  | -    </Box>  | 
82 |  | -  );  | 
83 |  | -}  | 
 | 83 | + */  | 
0 commit comments