-
Notifications
You must be signed in to change notification settings - Fork 4k
/
item.tsx
31 lines (28 loc) · 887 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
/**
* 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 } { ...props }>
{ children ?? props.value }
<Styled.SelectedItemCheck>
<Icon icon={ check } />
</Styled.SelectedItemCheck>
</Styled.SelectItem>
);
}
CustomSelectItem.displayName = 'CustomSelectControlV2.Item';
export default CustomSelectItem;