Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Box } from '@chakra-ui/react';
import React from 'react';

import { AccordionItem, AccordionItemContent, AccordionItemTrigger, AccordionRoot } from 'toolkit/chakra/accordion';

import ContractMethodArrayButton from './ContractMethodArrayButton';
import ArrayButton from 'ui/shared/forms/ArrayButton';

export interface Props {
label: string;
Expand Down Expand Up @@ -33,8 +32,8 @@ const ContractMethodFieldAccordion = ({ label, level, children, onAddClick, onRe
<Box textStyle="sm" fontWeight={ 700 } mr="auto" color={ isInvalid ? 'text.error' : undefined }>
{ label }
</Box>
{ onRemoveClick && index !== undefined && <ContractMethodArrayButton index={ index } onClick={ onRemoveClick } type="remove"/> }
{ onAddClick && index !== undefined && <ContractMethodArrayButton index={ index } onClick={ onAddClick } type="add" ml={ 1 }/> }
{ onRemoveClick && index !== undefined && <ArrayButton index={ index } onClick={ onRemoveClick } type="remove"/> }
{ onAddClick && index !== undefined && <ArrayButton index={ index } onClick={ onAddClick } type="add" ml={ 1 }/> }
</AccordionItemTrigger>
<AccordionItemContent display="flex" flexDir="column" rowGap={ 1 } pl="18px" pr="6px">
{ children }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { useFormContext } from 'react-hook-form';

import type { ContractAbiItemInput } from '../types';

import ContractMethodArrayButton from './ContractMethodArrayButton';
import ArrayButton from 'ui/shared/forms/ArrayButton';

import type { Props as AccordionProps } from './ContractMethodFieldAccordion';
import ContractMethodFieldAccordion from './ContractMethodFieldAccordion';
import ContractMethodFieldInput from './ContractMethodFieldInput';
Expand Down Expand Up @@ -151,9 +152,9 @@ const ContractMethodFieldInputArray = ({
isOptional={ registeredIndices.length === 1 }
/>
{ !hasFixedSize && registeredIndices.length > 1 &&
<ContractMethodArrayButton index={ registeredIndex } onClick={ handleRemoveButtonClick } type="remove" my="6px"/> }
<ArrayButton index={ registeredIndex } onClick={ handleRemoveButtonClick } type="remove" my="6px"/> }
{ !hasFixedSize && index === registeredIndices.length - 1 &&
<ContractMethodArrayButton index={ registeredIndex } onClick={ handleAddButtonClick } type="add" my="6px"/> }
<ArrayButton index={ registeredIndex } onClick={ handleAddButtonClick } type="add" my="6px"/> }
</Flex>
);
}) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props extends Omit<IconButtonProps, 'type'> {
type: 'add' | 'remove';
}

const ContractMethodArrayButton = ({ type, index, onClick, ...props }: Props) => {
const ArrayButton = ({ type, index, onClick, ...props }: Props) => {

const handleClick = React.useCallback((event: React.MouseEvent<HTMLButtonElement>) => {
event.stopPropagation();
Expand All @@ -30,4 +30,4 @@ const ContractMethodArrayButton = ({ type, index, onClick, ...props }: Props) =>
);
};

export default React.memo(ContractMethodArrayButton);
export default React.memo(ArrayButton);
Loading