-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
item.tsx
35 lines (32 loc) · 947 Bytes
/
item.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
/**
* WordPress dependencies
*/
import { useContext } from '@wordpress/element';
import { Icon, check } from '@wordpress/icons';
/**
* Internal dependencies
*/
import type { CustomSelectItemProps } from './types';
import type { WordPressComponentProps } from '../context';
import * as Styled from './styles';
import { CustomSelectContext } from './custom-select';
export function CustomSelectItem( {
children,
...props
}: WordPressComponentProps< CustomSelectItemProps, 'div', false > ) {
const customSelectContext = useContext( CustomSelectContext );
return (
<Styled.SelectItem
store={ customSelectContext?.store }
size={ customSelectContext?.size ?? 'default' }
{ ...props }
>
{ children ?? props.value }
<Styled.SelectedItemCheck>
<Icon icon={ check } />
</Styled.SelectedItemCheck>
</Styled.SelectItem>
);
}
CustomSelectItem.displayName = 'CustomSelectControlV2.Item';
export default CustomSelectItem;