1 | import type * as React from 'react';
|
2 | interface ItemSharedProps {
|
3 | ref?: React.Ref<HTMLLIElement | null>;
|
4 | style?: React.CSSProperties;
|
5 | className?: string;
|
6 | }
|
7 | export interface SubMenuType extends ItemSharedProps {
|
8 | type?: 'submenu';
|
9 | label?: React.ReactNode;
|
10 | children: ItemType[];
|
11 | disabled?: boolean;
|
12 | key: string;
|
13 | rootClassName?: string;
|
14 | itemIcon?: RenderIconType;
|
15 | expandIcon?: RenderIconType;
|
16 | onMouseEnter?: MenuHoverEventHandler;
|
17 | onMouseLeave?: MenuHoverEventHandler;
|
18 | popupClassName?: string;
|
19 | popupOffset?: number[];
|
20 | popupStyle?: React.CSSProperties;
|
21 | onClick?: MenuClickEventHandler;
|
22 | onTitleClick?: (info: MenuTitleInfo) => void;
|
23 | onTitleMouseEnter?: MenuHoverEventHandler;
|
24 | onTitleMouseLeave?: MenuHoverEventHandler;
|
25 | }
|
26 | export interface MenuItemType extends ItemSharedProps {
|
27 | type?: 'item';
|
28 | label?: React.ReactNode;
|
29 | disabled?: boolean;
|
30 | itemIcon?: RenderIconType;
|
31 | extra?: React.ReactNode;
|
32 | key: React.Key;
|
33 | onMouseEnter?: MenuHoverEventHandler;
|
34 | onMouseLeave?: MenuHoverEventHandler;
|
35 | onClick?: MenuClickEventHandler;
|
36 | }
|
37 | export interface MenuItemGroupType extends ItemSharedProps {
|
38 | type: 'group';
|
39 | label?: React.ReactNode;
|
40 | children?: ItemType[];
|
41 | }
|
42 | export interface MenuDividerType extends Omit<ItemSharedProps, 'ref'> {
|
43 | type: 'divider';
|
44 | }
|
45 | export type ItemType = SubMenuType | MenuItemType | MenuItemGroupType | MenuDividerType | null;
|
46 | export type MenuMode = 'horizontal' | 'vertical' | 'inline';
|
47 | export type BuiltinPlacements = Record<string, any>;
|
48 | export type TriggerSubMenuAction = 'click' | 'hover';
|
49 | export interface RenderIconInfo {
|
50 | isSelected?: boolean;
|
51 | isOpen?: boolean;
|
52 | isSubMenu?: boolean;
|
53 | disabled?: boolean;
|
54 | }
|
55 | export type RenderIconType = React.ReactNode | ((props: RenderIconInfo) => React.ReactNode);
|
56 | export interface MenuInfo {
|
57 | key: string;
|
58 | keyPath: string[];
|
59 | /** @deprecated This will not support in future. You should avoid to use this */
|
60 | item: React.ReactInstance;
|
61 | domEvent: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>;
|
62 | }
|
63 | export interface MenuTitleInfo {
|
64 | key: string;
|
65 | domEvent: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>;
|
66 | }
|
67 | export type MenuHoverEventHandler = (info: {
|
68 | key: string;
|
69 | domEvent: React.MouseEvent<HTMLElement>;
|
70 | }) => void;
|
71 | export interface SelectInfo extends MenuInfo {
|
72 | selectedKeys: string[];
|
73 | }
|
74 | export type SelectEventHandler = (info: SelectInfo) => void;
|
75 | export type MenuClickEventHandler = (info: MenuInfo) => void;
|
76 | export type MenuRef = {
|
77 | |
78 |
|
79 |
|
80 |
|
81 | focus: (options?: FocusOptions) => void;
|
82 | list: HTMLUListElement;
|
83 | };
|
84 | export type ComponentType = 'submenu' | 'item' | 'group' | 'divider';
|
85 | export type Components = Partial<Record<ComponentType, React.ComponentType<any>>>;
|
86 | export {};
|