UNPKG

2.14 kBTypeScriptView Raw
1/// <reference types="react" />
2
3import * as React from 'react';
4import { Item, Group, Divider, MenuProps } from '../menu';
5import CommonProps from '../util';
6import { ButtonProps } from '../button';
7import { PopupProps } from '../overlay';
8
9export interface MenuButtonProps extends Omit<ButtonProps, 'onSelect'>, CommonProps {
10 /**
11 * 按钮上的文本内容
12 */
13 label?: React.ReactNode;
14
15 /**
16 * 弹层是否与按钮宽度相同
17 */
18 autoWidth?: boolean;
19
20 /**
21 * 弹层触发方式
22 */
23 popupTriggerType?: 'click' | 'hover';
24
25 /**
26 * 弹层容器
27 */
28 popupContainer?: string | HTMLElement | ((target: HTMLElement) => HTMLElement);
29
30 /**
31 * 弹层展开状态
32 */
33 visible?: boolean;
34
35 /**
36 * 弹层默认是否展开
37 */
38 defaultVisible?: boolean;
39
40 /**
41 * 弹层在显示和隐藏触发的事件
42 */
43 onVisibleChange?: (visible: boolean, type: string) => void;
44
45 /**
46 * 弹层自定义样式
47 */
48 popupStyle?: React.CSSProperties;
49
50 /**
51 * 弹层自定义样式类
52 */
53 popupClassName?: string;
54
55 /**
56 * 弹层属性透传
57 */
58 popupProps?: PopupProps;
59
60 /**
61 * 菜单是否跟随滚动
62 */
63 followTrigger?: boolean;
64
65 /**
66 * 默认激活的菜单项(用法同 Menu 非受控)
67 */
68 defaultSelectedKeys?: Array<any>;
69
70 /**
71 * 激活的菜单项(用法同 Menu 受控)
72 */
73 selectedKeys?: string | Array<any>;
74
75 /**
76 * 菜单的选择模式,同 Menu
77 */
78 selectMode?: 'single' | 'multiple';
79
80 /**
81 * 点击菜单项后的回调,同 Menu
82 */
83 onItemClick?: (key: string, item: any, event: React.MouseEvent<HTMLElement>) => void;
84
85 /**
86 * 选择菜单后的回调,同 Menu
87 */
88 onSelect?: (selectedKeys: Array<any>, item: any, extra: any) => void;
89
90 /**
91 * 菜单属性透传
92 */
93 menuProps?: MenuProps;
94}
95
96export default class MenuButton extends React.Component<MenuButtonProps, any> {
97 static Item: typeof Item;
98 static Group: typeof Group;
99 static Divider: typeof Divider;
100}