1 | import * as React from 'react';
|
2 | import type { MenuRef as RcMenuRef } from 'rc-menu';
|
3 | import { ItemGroup } from 'rc-menu';
|
4 | import type { ItemType, MenuItemType } from './hooks/useItems';
|
5 | import type { MenuProps } from './menu';
|
6 | import type { MenuTheme } from './MenuContext';
|
7 | import MenuDivider from './MenuDivider';
|
8 | import Item, { type MenuItemProps } from './MenuItem';
|
9 | import SubMenu, { type SubMenuProps } from './SubMenu';
|
10 | export type { MenuItemGroupProps } from 'rc-menu';
|
11 | export type { MenuDividerProps } from './MenuDivider';
|
12 | export type { MenuItemProps, MenuProps, MenuTheme, SubMenuProps };
|
13 | export type MenuRef = {
|
14 | menu: RcMenuRef | null;
|
15 | focus: (options?: FocusOptions) => void;
|
16 | };
|
17 | type ComponentProps = MenuProps & React.RefAttributes<MenuRef>;
|
18 | type GenericItemType<T = unknown> = T extends infer U extends MenuItemType ? unknown extends U ? ItemType : ItemType<U> : ItemType;
|
19 | type GenericComponentProps<T = unknown> = Omit<ComponentProps, 'items'> & {
|
20 | items?: GenericItemType<T>[];
|
21 | };
|
22 | type CompoundedComponent = React.ForwardRefExoticComponent<GenericComponentProps> & {
|
23 | Item: typeof Item;
|
24 | SubMenu: typeof SubMenu;
|
25 | Divider: typeof MenuDivider;
|
26 | ItemGroup: typeof ItemGroup;
|
27 | };
|
28 | interface GenericComponent extends Omit<CompoundedComponent, ''> {
|
29 | <T extends MenuItemType>(props: GenericComponentProps<T>): ReturnType<CompoundedComponent>;
|
30 | }
|
31 | declare const Menu: GenericComponent;
|
32 | export default Menu;
|