setFocusedOptionIndex(null)}
>
{fetching ? (
) : (
<>
{showCreatable && (
setFocusedOptionIndex(0)}
>
{creatableText}
)}
{!filteredOptions?.length && !showCreatable && emptyText ? (
{emptyText}
) :
filteredOptions.map((option: Option, index: number) => {
const label = getOptionLabel(option);
const hovered = focusedOption && getOptionValue(option) === getOptionValue(focusedOption);
const selected = selectedOptions.find((selectedOption: Option) => {
return getOptionValue(selectedOption) === getOptionValue(option);
});
return (
{renderOption({
className: 'ChipsSelect__option',
option,
hovered,
children: label,
selected: !!selected,
getRootRef: (e) => chipsSelectOptions[index] = e,
onMouseDown: (e: React.MouseEvent) => {
onChangeStart(e, option);
if (!e.defaultPrevented) {
closeAfterSelect && setOpened(false);
addOption(option);
clearInput();
}
},
onMouseEnter: () => setFocusedOptionIndex(index),
})}
);
})
}
>
)}