import { memo } from 'react'; import cx from 'classnames'; import { ISelectItem } from './Select'; import Icon from '../icon'; import { InlineLoading } from '../loading/InlineLoading'; export interface IOptionProps< Key extends string | number = string | number, Item extends ISelectItem = ISelectItem > { value: Item; active: boolean; selected: boolean; index: number; onSelect(item: Item): void; onMouseEnter(index: number): void; onMouseLeave(index: number): void; multiple: boolean; children?: React.ReactNode; loading: boolean; } function SelectOption< Key extends string | number = string | number, Item extends ISelectItem = ISelectItem >({ value, active, selected, onSelect, index, onMouseEnter, onMouseLeave, multiple, children, loading, }: IOptionProps) { return (
{ e.preventDefault(); onSelect(value); }} onMouseEnter={() => !value.type && onMouseEnter(index)} onMouseLeave={() => !value.type && onMouseLeave(index)} title={typeof value.text === 'string' ? value.text : ''} >

{children}

{multiple && selected && ( )} {loading && ( )}
); } export default memo(SelectOption);