-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Expand file tree
/
Copy pathitem.tsx
More file actions
46 lines (41 loc) · 1.06 KB
/
item.tsx
File metadata and controls
46 lines (41 loc) · 1.06 KB
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
39
40
41
42
43
44
45
46
/**
* WordPress dependencies
*/
import { forwardRef, useContext } from '@wordpress/element';
/**
* Internal dependencies
*/
import type { WordPressComponentProps } from '../context';
import type { MenuItemProps } from './types';
import * as Styled from './styles';
import { MenuContext } from './context';
export const MenuItem = forwardRef<
HTMLDivElement,
WordPressComponentProps< MenuItemProps, 'div', false >
>( function MenuItem(
{ prefix, suffix, children, hideOnClick = true, ...props },
ref
) {
const menuContext = useContext( MenuContext );
return (
<Styled.MenuItem
ref={ ref }
{ ...props }
accessibleWhenDisabled
hideOnClick={ hideOnClick }
store={ menuContext?.store }
>
<Styled.ItemPrefixWrapper>{ prefix }</Styled.ItemPrefixWrapper>
<Styled.MenuItemContentWrapper>
<Styled.MenuItemChildrenWrapper>
{ children }
</Styled.MenuItemChildrenWrapper>
{ suffix && (
<Styled.ItemSuffixWrapper>
{ suffix }
</Styled.ItemSuffixWrapper>
) }
</Styled.MenuItemContentWrapper>
</Styled.MenuItem>
);
} );