Compare commits

...

2 Commits

Author SHA1 Message Date
57a30a1cc3 [FEAT] generize the form model 2024-09-03 23:34:21 +02:00
188925380b [FEAT] review some namings 2024-09-03 21:20:32 +02:00
12 changed files with 339 additions and 160 deletions

View File

@ -1,12 +1,7 @@
import { ReactElement, ReactNode } from 'react'; import { ReactNode } from 'react';
import { Button, Flex, IconButton, Text, Tooltip } from '@chakra-ui/react'; import { Flex, Text } from '@chakra-ui/react';
import { import { MdErrorOutline, MdHelpOutline, MdRefresh } from 'react-icons/md';
MdErrorOutline,
MdHelpOutline,
MdLabelImportant,
MdRefresh,
} from 'react-icons/md';
export type FormGroupProps = { export type FormGroupProps = {
error?: ReactNode; error?: ReactNode;

View File

@ -0,0 +1,37 @@
import { RefObject } from 'react';
import { Input } from '@chakra-ui/react';
import { FormGroup } from '@/components/form/FormGroup';
import { UseFormidableReturn } from '@/components/form/Formidable';
export type FormInputProps = {
form: UseFormidableReturn;
variableName: string;
ref?: RefObject<any>;
label?: string;
placeholder?: string;
isRequired?: boolean;
};
export const FormInput = ({
form,
variableName,
ref,
placeholder,
...rest
}: FormInputProps) => {
return (
<FormGroup
isModify={form.isModify[variableName]}
onRestore={() => form.restoreValue({ [variableName]: true })}
{...rest}
>
<Input
ref={ref}
value={form.values[variableName]}
onChange={(e) => form.setValues({ [variableName]: e.target.value })}
/>
</FormGroup>
);
};

View File

@ -0,0 +1,62 @@
import { RefObject } from 'react';
import {
Input,
NumberDecrementStepper,
NumberIncrementStepper,
NumberInput,
NumberInputField,
NumberInputProps,
NumberInputStepper,
} from '@chakra-ui/react';
import { FormGroup } from '@/components/form/FormGroup';
import { UseFormidableReturn } from '@/components/form/Formidable';
export type FormNumberProps = Pick<
NumberInputProps,
'step' | 'defaultValue' | 'min' | 'max'
> & {
form: UseFormidableReturn;
variableName: string;
ref?: RefObject<any>;
label?: string;
placeholder?: string;
isRequired?: boolean;
};
export const FormNumber = ({
form,
variableName,
ref,
placeholder,
step,
min,
max,
defaultValue,
...rest
}: FormNumberProps) => {
return (
<FormGroup
isModify={form.isModify[variableName]}
onRestore={() => form.restoreValue({ [variableName]: true })}
{...rest}
>
<NumberInput
ref={ref}
value={form.values[variableName]}
onChange={(_, value) => form.setValues({ [variableName]: value })}
step={step}
defaultValue={defaultValue}
min={min}
max={max}
>
<NumberInputField />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
</FormGroup>
);
};

View File

@ -0,0 +1,42 @@
import { RefObject } from 'react';
import { FormGroup } from '@/components/form/FormGroup';
import { UseFormidableReturn } from '@/components/form/Formidable';
import { SelectSingle } from '@/components/select/SelectSingle';
export type FormSelectProps = {
form: UseFormidableReturn;
variableName: string;
ref?: RefObject<any>;
label?: string;
placeholder?: string;
isRequired?: boolean;
options?: object[];
keyInputValue?: string;
};
export const FormSelect = ({
form,
variableName,
ref,
placeholder,
options,
keyInputValue = 'name',
...rest
}: FormSelectProps) => {
return (
<FormGroup
isModify={form.isModify[variableName]}
onRestore={() => form.restoreValue({ [variableName]: true })}
{...rest}
>
<SelectSingle
ref={ref}
value={form.values[variableName]}
options={options}
onChange={(value) => form.setValues({ [variableName]: value })}
keyValue={keyInputValue}
/>
</FormGroup>
);
};

View File

@ -0,0 +1,42 @@
import { RefObject } from 'react';
import { FormGroup } from '@/components/form/FormGroup';
import { UseFormidableReturn } from '@/components/form/Formidable';
import { SelectMultiple } from '@/components/select/SelectMultiple';
export type FormSelectMultipleProps = {
form: UseFormidableReturn;
variableName: string;
ref?: RefObject<any>;
label?: string;
placeholder?: string;
isRequired?: boolean;
options?: object[];
keyInputValue?: string;
};
export const FormSelectMultiple = ({
form,
variableName,
ref,
placeholder,
options,
keyInputValue = 'name',
...rest
}: FormSelectMultipleProps) => {
return (
<FormGroup
isModify={form.isModify[variableName]}
onRestore={() => form.restoreValue({ [variableName]: true })}
{...rest}
>
<SelectMultiple
//ref={ref}
values={form.values[variableName]}
options={options}
onChange={(value) => form.setValues({ [variableName]: value })}
keyValue={keyInputValue}
/>
</FormGroup>
);
};

View File

@ -0,0 +1,37 @@
import { RefObject } from 'react';
import { Textarea } from '@chakra-ui/react';
import { FormGroup } from '@/components/form/FormGroup';
import { UseFormidableReturn } from '@/components/form/Formidable';
export type FormTextareaProps = {
form: UseFormidableReturn;
variableName: string;
ref?: RefObject<any>;
label?: string;
placeholder?: string;
isRequired?: boolean;
};
export const FormTextarea = ({
form,
variableName,
ref,
placeholder,
...rest
}: FormTextareaProps) => {
return (
<FormGroup
isModify={form.isModify[variableName]}
onRestore={() => form.restoreValue({ [variableName]: true })}
{...rest}
>
<Textarea
ref={ref}
value={form.values[variableName]}
onChange={(e) => form.setValues({ [variableName]: e.target.value })}
/>
</FormGroup>
);
};

View File

@ -62,9 +62,7 @@ export const useFormidable = <TYPE extends object = object>({
}) => { }) => {
const [values, setValues] = useState<TYPE>({ ...initialValues } as TYPE); const [values, setValues] = useState<TYPE>({ ...initialValues } as TYPE);
const [initialData, setInitialData] = useState<TYPE>(initialValues); const [initialData, setInitialData] = useState<TYPE>(initialValues);
const [valueChange, setValueChange] = useState<{ [key: string]: boolean }>( const [isModify, setIsModify] = useState<{ [key: string]: boolean }>({});
{}
);
const [isFormModified, setIsFormModified] = useState<boolean>(false); const [isFormModified, setIsFormModified] = useState<boolean>(false);
useEffect(() => { useEffect(() => {
setInitialData((previous) => { setInitialData((previous) => {
@ -77,7 +75,7 @@ export const useFormidable = <TYPE extends object = object>({
//console.log(`FORMIDABLE: ==> update new values`); //console.log(`FORMIDABLE: ==> update new values`);
setValues({ ...initialValues }); setValues({ ...initialValues });
const ret = getDifferences(initialValues, initialValues); const ret = getDifferences(initialValues, initialValues);
setValueChange(ret); setIsModify(ret);
setIsFormModified(hasAnyTrue(ret)); setIsFormModified(hasAnyTrue(ret));
return initialValues; return initialValues;
}); });
@ -85,7 +83,7 @@ export const useFormidable = <TYPE extends object = object>({
initialValues, initialValues,
setInitialData, setInitialData,
setValues, setValues,
setValueChange, setIsModify,
setIsFormModified, setIsFormModified,
]); ]);
const setValuesExternal = useCallback( const setValuesExternal = useCallback(
@ -94,7 +92,7 @@ export const useFormidable = <TYPE extends object = object>({
setValues((previous) => { setValues((previous) => {
const newValues = { ...previous, ...data }; const newValues = { ...previous, ...data };
const ret = getDifferences(initialData, newValues); const ret = getDifferences(initialData, newValues);
setValueChange(ret); setIsModify(ret);
setIsFormModified(hasAnyTrue(ret)); setIsFormModified(hasAnyTrue(ret));
return newValues; return newValues;
}); });
@ -124,21 +122,21 @@ export const useFormidable = <TYPE extends object = object>({
//console.log(`initialData data ${JSON.stringify(initialData, null, 2)}`); //console.log(`initialData data ${JSON.stringify(initialData, null, 2)}`);
//console.log(`New data ${JSON.stringify(newValue, null, 2)}`); //console.log(`New data ${JSON.stringify(newValue, null, 2)}`);
const ret = getDifferences(initialData, newValue); const ret = getDifferences(initialData, newValue);
setValueChange(ret); setIsModify(ret);
setIsFormModified(hasAnyTrue(ret)); setIsFormModified(hasAnyTrue(ret));
return newValue; return newValue;
}); });
}, },
[setValues, initialData, setIsFormModified, setValueChange] [setValues, initialData, setIsFormModified, setIsModify]
); );
const getDeltaData = useCallback( const getDeltaData = useCallback(
({ omit = [], only }: { omit?: string[]; only?: string[] }) => { ({ omit = [], only }: { omit?: string[]; only?: string[] }) => {
const out = {}; const out = {};
Object.keys(valueChange).forEach((key) => { Object.keys(isModify).forEach((key) => {
if (omit.includes(key) || (only && !only.includes(key))) { if (omit.includes(key) || (only && !only.includes(key))) {
return; return;
} }
if (!valueChange[key]) { if (!isModify[key]) {
return; return;
} }
const tmpValue = values[key]; const tmpValue = values[key];
@ -150,14 +148,16 @@ export const useFormidable = <TYPE extends object = object>({
}); });
return out; return out;
}, },
[valueChange, values] [isModify, values]
); );
return { return {
values, values,
valueChange, isModify,
isFormModified, isFormModified,
setValues: setValuesExternal, setValues: setValuesExternal,
getDeltaData, getDeltaData,
restoreValue, restoreValue,
}; };
}; };
export type UseFormidableReturn = ReturnType<typeof useFormidable>;

View File

@ -9,7 +9,6 @@ import {
AlertDialogOverlay, AlertDialogOverlay,
Button, Button,
UseDisclosureReturn, UseDisclosureReturn,
useDisclosure,
} from '@chakra-ui/react'; } from '@chakra-ui/react';
export type ConfirmPopUpProps = { export type ConfirmPopUpProps = {

View File

@ -30,10 +30,15 @@ import { useNavigate, useParams } from 'react-router-dom';
import { Track, TrackResource } from '@/back-api'; import { Track, TrackResource } from '@/back-api';
import { FormGroup } from '@/components/form/FormGroup'; import { FormGroup } from '@/components/form/FormGroup';
import { FormInput } from '@/components/form/FormInput';
import { FormNumber } from '@/components/form/FormNumber';
import { FormSelect } from '@/components/form/FormSelect';
import { FormSelectMultiple } from '@/components/form/FormSelectMultiple';
import { FormTextarea } from '@/components/form/FormTextarea';
import { useFormidable } from '@/components/form/Formidable'; import { useFormidable } from '@/components/form/Formidable';
import { SelectMultiple } from '@/components/form/SelectMultiple';
import { SelectSingle } from '@/components/form/SelectSingle';
import { ConfirmPopUp } from '@/components/popup/ConfirmPopUp'; import { ConfirmPopUp } from '@/components/popup/ConfirmPopUp';
import { SelectMultiple } from '@/components/select/SelectMultiple';
import { SelectSingle } from '@/components/select/SelectSingle';
import { useOrderedAlbums } from '@/service/Album'; import { useOrderedAlbums } from '@/service/Album';
import { useOrderedArtists } from '@/service/Artist'; import { useOrderedArtists } from '@/service/Artist';
import { useOrderedGenders } from '@/service/Gender'; import { useOrderedGenders } from '@/service/Gender';
@ -142,87 +147,45 @@ export const TrackEditPopUp = ({}: TrackEditPopUpProps) => {
)} )}
{!admin && ( {!admin && (
<> <>
<FormGroup <FormInput
form={form}
variableName="name"
isRequired isRequired
isModify={form.valueChange.name}
onRestore={() => form.restoreValue({ name: true })}
label="Title" label="Title"
>
<Input
ref={initialRef} ref={initialRef}
value={form.values.name}
onChange={(e) => form.setValues({ name: e.target.value })}
/> />
</FormGroup> <FormTextarea
form={form}
<FormGroup variableName="description"
isModify={form.valueChange.description}
onRestore={() => form.restoreValue({ description: true })}
label="Description" label="Description"
>
<Textarea
value={form.values.description}
onChange={(e) =>
form.setValues({ description: e.target.value })
}
/> />
</FormGroup> <FormSelect
<FormGroup form={form}
isModify={form.valueChange.genderId} variableName="genderId"
onRestore={() => form.restoreValue({ genderId: true })}
label="Gender"
>
<SelectSingle
value={form.values.genderId}
options={dataGenders} options={dataGenders}
onChange={(value) => form.setValues({ genderId: value })} label="Gender"
keyValue="name"
/> />
</FormGroup> <FormSelectMultiple
<FormGroup form={form}
isModify={form.valueChange.artists} variableName="artists"
onRestore={() => form.restoreValue({ artists: true })}
label="Artist(s)"
>
<SelectMultiple
values={form.values.artists}
options={dataArtist} options={dataArtist}
onChange={(value) => form.setValues({ artists: value })} label="Artist(s)"
keyValue="name"
/> />
</FormGroup> <FormSelect
<FormGroup form={form}
isModify={form.valueChange.albumId} variableName="albumId"
onRestore={() => form.restoreValue({ albumId: true })}
label="Album"
>
<SelectSingle
value={form.values.albumId}
options={dataAlbums} options={dataAlbums}
onChange={(value) => form.setValues({ albumId: value })} label="Album"
keyValue="name"
/> />
</FormGroup> <FormNumber
<FormGroup form={form}
isModify={form.valueChange.track} variableName="track"
onRestore={() => form.restoreValue({ track: true })}
label="Track n°" label="Track n°"
>
<NumberInput
value={form.values.track}
onChange={(_, value) => form.setValues({ track: value })}
step={1} step={1}
defaultValue={0} defaultValue={0}
min={0} min={0}
max={1000} max={1000}
> />
<NumberInputField />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
</FormGroup>
</> </>
)} )}
</ModalBody> </ModalBody>

View File

@ -4,21 +4,21 @@ import { Box, Button, Flex, Text } from '@chakra-ui/react';
import { isNullOrUndefined } from '@/utils/validator'; import { isNullOrUndefined } from '@/utils/validator';
export type SelectMultipleValueDisplayType = { export type SelectListModel = {
id: any; id: any;
name: any; name: any;
isSelected: boolean; isSelected?: boolean;
}; };
const optionToOptionDisplay = ( const optionToOptionDisplay = (
data: SelectMultipleValueDisplayType[] | undefined, data: SelectListModel[] | undefined,
selectedOptions: SelectMultipleValueDisplayType[], selectedOptions: SelectListModel[],
search?: string search?: string
): SelectMultipleValueDisplayType[] => { ): SelectListModel[] => {
if (isNullOrUndefined(data)) { if (isNullOrUndefined(data)) {
return []; return [];
} }
const out: SelectMultipleValueDisplayType[] = []; const out: SelectListModel[] = [];
data.forEach((element) => { data.forEach((element) => {
if (search) { if (search) {
if (!element.name.toLowerCase().includes(search.toLowerCase())) { if (!element.name.toLowerCase().includes(search.toLowerCase())) {
@ -34,18 +34,18 @@ const optionToOptionDisplay = (
return out; return out;
}; };
export type FormSelectListProps = { export type SelectListProps = {
options?: SelectMultipleValueDisplayType[]; options?: SelectListModel[];
selected: SelectMultipleValueDisplayType[]; selected: SelectListModel[];
onSelectValue: (data: SelectMultipleValueDisplayType) => void; onSelectValue: (data: SelectListModel) => void;
search?: string; search?: string;
}; };
export const FormSelectList = ({ export const SelectList = ({
options, options,
selected, selected,
onSelectValue, onSelectValue,
search, search,
}: FormSelectListProps) => { }: SelectListProps) => {
const displayedValue = optionToOptionDisplay(options, selected, search); const displayedValue = optionToOptionDisplay(options, selected, search);
const scrollToRef = useRef<HTMLButtonElement | null>(null); const scrollToRef = useRef<HTMLButtonElement | null>(null);
useEffect(() => { useEffect(() => {

View File

@ -1,10 +1,9 @@
import { useMemo, useState } from 'react'; import { RefObject, useMemo, useRef, useState } from 'react';
import { import {
Button,
Flex, Flex,
Input, Input,
InputGroup,
InputRightElement,
Spinner, Spinner,
Tag, Tag,
TagCloseButton, TagCloseButton,
@ -12,12 +11,9 @@ import {
Wrap, Wrap,
WrapItem, WrapItem,
} from '@chakra-ui/react'; } from '@chakra-ui/react';
import { MdSearch } from 'react-icons/md'; import { MdKeyboardArrowDown, MdKeyboardArrowUp } from 'react-icons/md';
import { import { SelectList, SelectListModel } from '@/components/select/SelectList';
FormSelectList,
SelectMultipleValueDisplayType,
} from '@/components/form/FormSelectList';
import { isNullOrUndefined } from '@/utils/validator'; import { isNullOrUndefined } from '@/utils/validator';
export type SelectMultipleProps = { export type SelectMultipleProps = {
@ -26,12 +22,14 @@ export type SelectMultipleProps = {
onChange?: (value: (number | string)[] | undefined) => void; onChange?: (value: (number | string)[] | undefined) => void;
keyKey?: string; keyKey?: string;
keyValue?: string; keyValue?: string;
ref?: RefObject<any>;
}; };
export const SelectMultiple = ({ export const SelectMultiple = ({
options, options,
onChange, onChange,
values, values,
ref,
keyKey = 'id', keyKey = 'id',
keyValue = keyKey, keyValue = keyKey,
}: SelectMultipleProps) => { }: SelectMultipleProps) => {
@ -41,14 +39,14 @@ export const SelectMultiple = ({
return { return {
id: element[keyKey], id: element[keyKey],
name: element[keyValue], name: element[keyValue],
isSelected: false, } as SelectListModel;
} as SelectMultipleValueDisplayType;
}); });
}, [options, keyKey, keyValue]); }, [options, keyKey, keyValue]);
const [currentSearch, setCurrentSearch] = useState<string | undefined>( const [currentSearch, setCurrentSearch] = useState<string | undefined>(
undefined undefined
); );
const refFocus = ref ?? useRef<HTMLInputElement | null>(null);
const selectedOptions = useMemo(() => { const selectedOptions = useMemo(() => {
if (isNullOrUndefined(values) || !transformedOption) { if (isNullOrUndefined(values) || !transformedOption) {
return []; return [];
@ -58,7 +56,7 @@ export const SelectMultiple = ({
}); });
}, [values, transformedOption]); }, [values, transformedOption]);
const selectValue = (data: SelectMultipleValueDisplayType) => { const selectValue = (data: SelectListModel) => {
const newValues = values?.includes(data.id) const newValues = values?.includes(data.id)
? values.filter((elem) => data.id !== elem) ? values.filter((elem) => data.id !== elem)
: [...(values ?? []), data.id]; : [...(values ?? []), data.id];
@ -74,13 +72,19 @@ export const SelectMultiple = ({
if (!options) { if (!options) {
return <Spinner />; return <Spinner />;
} }
function onChangeInput(value: string): void { const onChangeInput = (value: string): void => {
if (value === '') { if (value === '') {
setCurrentSearch(undefined); setCurrentSearch(undefined);
} else { } else {
setCurrentSearch(value); setCurrentSearch(value);
} }
};
const onOpenClose = () => {
if (!showList) {
refFocus?.current?.focus();
return;
} }
};
return ( return (
<Flex direction="column" width="full" gap="0px"> <Flex direction="column" width="full" gap="0px">
@ -102,19 +106,33 @@ export const SelectMultiple = ({
))} ))}
</Wrap> </Wrap>
)} )}
<InputGroup minWidth="50%" marginLeft="auto">
<InputRightElement pointerEvents="none"> <Flex>
<MdSearch color="gray.300" />
</InputRightElement>
<Input <Input
ref={refFocus}
width="full"
onChange={(e) => onChangeInput(e.target.value)} onChange={(e) => onChangeInput(e.target.value)}
//onSubmit={onSubmit} //onSubmit={onSubmit}
onFocus={() => setShowList(true)} onFocus={() => setShowList(true)}
onBlur={() => setTimeout(() => setShowList(false), 200)} onBlur={() => setTimeout(() => setShowList(false), 200)}
value={showList ? (currentSearch ?? '') : ''}
borderRadius="5px 0 0 5px"
/> />
</InputGroup> <Button
onClick={onOpenClose}
variant="outline"
borderRadius="0 5px 5px 0"
borderWidth="1px 1px 1px 0"
>
{showList ? (
<MdKeyboardArrowUp color="gray.300" />
) : (
<MdKeyboardArrowDown color="gray.300" />
)}
</Button>
</Flex>
{showList && ( {showList && (
<FormSelectList <SelectList
options={transformedOption} options={transformedOption}
selected={selectedOptions} selected={selectedOptions}
search={currentSearch} search={currentSearch}

View File

@ -1,29 +1,13 @@
import { useMemo, useRef, useState } from 'react'; import { RefObject, useMemo, useRef, useState } from 'react';
import { import { Button, Flex, Input, Spinner } from '@chakra-ui/react';
Badge,
Box,
Button,
Flex,
Input,
InputGroup,
InputRightElement,
Spinner,
Tag,
TagCloseButton,
TagLabel,
} from '@chakra-ui/react';
import { import {
MdClose, MdClose,
MdKeyboardArrowDown, MdKeyboardArrowDown,
MdKeyboardArrowUp, MdKeyboardArrowUp,
MdSearch,
} from 'react-icons/md'; } from 'react-icons/md';
import { import { SelectList, SelectListModel } from '@/components/select/SelectList';
FormSelectList,
SelectMultipleValueDisplayType,
} from '@/components/form/FormSelectList';
import { isNullOrUndefined } from '@/utils/validator'; import { isNullOrUndefined } from '@/utils/validator';
export type SelectSingleProps = { export type SelectSingleProps = {
@ -32,12 +16,14 @@ export type SelectSingleProps = {
onChange?: (value: number | string | undefined) => void; onChange?: (value: number | string | undefined) => void;
keyKey?: string; keyKey?: string;
keyValue?: string; keyValue?: string;
ref?: RefObject<any>;
}; };
export const SelectSingle = ({ export const SelectSingle = ({
options, options,
onChange, onChange,
value, value,
ref,
keyKey = 'id', keyKey = 'id',
keyValue = keyKey, keyValue = keyKey,
}: SelectSingleProps) => { }: SelectSingleProps) => {
@ -47,14 +33,13 @@ export const SelectSingle = ({
return { return {
id: element[keyKey], id: element[keyKey],
name: element[keyValue], name: element[keyValue],
isSelected: false, } as SelectListModel;
} as SelectMultipleValueDisplayType;
}); });
}, [options, keyKey, keyValue]); }, [options, keyKey, keyValue]);
const [currentSearch, setCurrentSearch] = useState<string | undefined>( const [currentSearch, setCurrentSearch] = useState<string | undefined>(
undefined undefined
); );
const ref = useRef<HTMLInputElement | null>(null); const refFocus = ref ?? useRef<HTMLInputElement | null>(null);
const selectedOptions = useMemo(() => { const selectedOptions = useMemo(() => {
if (isNullOrUndefined(value)) { if (isNullOrUndefined(value)) {
return undefined; return undefined;
@ -62,7 +47,7 @@ export const SelectSingle = ({
return transformedOption?.find((data) => data.id === value); return transformedOption?.find((data) => data.id === value);
}, [value, transformedOption]); }, [value, transformedOption]);
const selectValue = (data?: SelectMultipleValueDisplayType) => { const selectValue = (data?: SelectListModel) => {
const tmpData = data?.id == selectedOptions?.id ? undefined : data; const tmpData = data?.id == selectedOptions?.id ? undefined : data;
setShowList(false); setShowList(false);
if (onChange) { if (onChange) {
@ -80,21 +65,21 @@ export const SelectSingle = ({
} }
} }
const onRemoveItem = () => { const onRemoveItem = () => {
if (showList || !selectedOptions) { if (selectedOptions) {
ref?.current?.focus();
return;
}
console.log('Remove item ...');
if (onChange) { if (onChange) {
onChange(undefined); onChange(undefined);
} }
}
if (!showList || selectedOptions) {
refFocus?.current?.focus();
}
}; };
return ( return (
<Flex direction="column" width="full" gap="0px"> <Flex direction="column" width="full" gap="0px">
<Flex> <Flex>
<Input <Input
ref={ref} ref={refFocus}
width="full" width="full"
onChange={(e) => onChangeInput(e.target.value)} onChange={(e) => onChangeInput(e.target.value)}
//onSubmit={onSubmit} //onSubmit={onSubmit}
@ -113,7 +98,6 @@ export const SelectSingle = ({
variant="outline" variant="outline"
borderRadius="0 5px 5px 0" borderRadius="0 5px 5px 0"
borderWidth="1px 1px 1px 0" borderWidth="1px 1px 1px 0"
isDisabled={showList}
> >
{selectedOptions ? ( {selectedOptions ? (
<MdClose color="gray.300" /> <MdClose color="gray.300" />
@ -125,7 +109,7 @@ export const SelectSingle = ({
</Button> </Button>
</Flex> </Flex>
{showList && ( {showList && (
<FormSelectList <SelectList
options={transformedOption} options={transformedOption}
selected={selectedOptions ? [selectedOptions] : []} selected={selectedOptions ? [selectedOptions] : []}
search={currentSearch} search={currentSearch}