-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathlistbox-button-option.tsx
38 lines (35 loc) · 1.07 KB
/
listbox-button-option.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React, { ComponentProps, FC, MouseEvent, RefObject } from 'react'
import classNames from 'classnames'
import { EbayIcon } from '../ebay-icon'
type EbayListboxButtonOptionProps = ComponentProps<'input'> & {
selected?: boolean;
index?: number;
onClick?: (event: MouseEvent<HTMLDivElement>, value: any, index: number) => void;
innerRef?: RefObject<HTMLDivElement>;
};
const ListboxOption: FC<EbayListboxButtonOptionProps> = ({
value,
children,
selected,
onClick,
index,
innerRef,
className,
...rest
}) => {
const wrapperClassName = classNames(`listbox-button__option`, className,
{ 'listbox-button__option--active': selected })
return (
<div
{...rest}
className={wrapperClassName}
role="option"
aria-selected={selected}
ref={innerRef}
onClick={(e) => {onClick(e, value, index)}}
>
<span className="listbox-button__value">{children}</span>
<EbayIcon name="tick16" />
</div>)
}
export default ListboxOption