Debian Codegraph @

node/@patternfly/react-core/src/components/Menu/DrilldownMenu.tsx

raw
1 import { createRef } from 'react';
2 import { Menu } from './Menu';
3 import { MenuContent } from './MenuContent';
4 import { MenuList } from './MenuList';
5 import { MenuContext } from './MenuContext';
6
7 export interface DrilldownMenuProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ref' | 'onSelect'> {
8 /** Items within drilldown sub-menu */
9 children?: React.ReactNode;
10 /** ID of the drilldown sub-menu */
11 id?: string;
12 /** Flag indicating whether the menu is drilled in */
13 isMenuDrilledIn?: boolean;
14 /** Optional callback to get the height of the sub menu */
15 getHeight?: (height: string) => void;
16 }
17
18 export const DrilldownMenu: React.FunctionComponent<DrilldownMenuProps> = ({
19 children,
20 id,
21 isMenuDrilledIn = false,
22 getHeight,
23 ...props
24 }: DrilldownMenuProps) => (
25 /* eslint-disable @typescript-eslint/no-unused-vars */
26 <MenuContext.Consumer>
27 {({ menuId, parentMenu, flyoutRef, setFlyoutRef, disableHover, ...context }) => (
28 <Menu
29 id={id}
30 parentMenu={menuId}
31 isMenuDrilledIn={isMenuDrilledIn}
32 isRootMenu={false}
33 ref={createRef()}
34 {...context}
35 {...props}
36 >
37 <MenuContent getHeight={getHeight}>
38 <MenuList>{children}</MenuList>
39 </MenuContent>
40 </Menu>
41 )}
42 </MenuContext.Consumer>
43 /* eslint-enable @typescript-eslint/no-unused-vars */
44 );
45
46 DrilldownMenu.displayName = 'DrilldownMenu';