UNPKG

2.65 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
9interface HTMLAttributesWeak extends ButtonProps {
10 onSelect?: any;
11}
12
13export interface SplitButtonProps extends HTMLAttributesWeak, CommonProps {
14 /**
15 * 按钮的类型
16 */
17 type?: 'normal' | 'primary' | 'secondary';
18
19 /**
20 * 按钮组的尺寸
21 */
22 size?: 'small' | 'medium' | 'large';
23
24 /**
25 * 主按钮的文案
26 */
27 label?: React.ReactNode;
28
29 /**
30 * 设置标签类型
31 */
32 component?: 'button' | 'a';
33
34 /**
35 * 是否为幽灵按钮
36 */
37 ghost?: 'light' | 'dark' | false | true;
38
39 /**
40 * 默认激活的菜单项(用法同 Menu 非受控)
41 */
42 defaultSelectedKeys?: string[];
43
44 /**
45 * 激活的菜单项(用法同 Menu 受控)
46 */
47 selectedKeys?: string[];
48
49 /**
50 * 菜单的选择模式
51 */
52 selectMode?: 'single' | 'multiple';
53
54 /**
55 * 触发按钮的属性(支持 Button 的所有属性透传)
56 */
57 triggerProps?: ButtonProps;
58
59 /**
60 * 弹层菜单的宽度是否与按钮组一致
61 */
62 autoWidth?: boolean;
63
64 /**
65 * 弹层是否显示
66 */
67 visible?: boolean;
68
69 /**
70 * 弹层默认是否显示
71 */
72 defaultVisible?: boolean;
73
74 /**
75 * 弹层显示状态变化时的回调函数
76 */
77 onVisibleChange?: (visible: boolean, reason: string) => void;
78
79 /**
80 * 弹层的触发方式
81 */
82 popupTriggerType?: 'click' | 'hover';
83
84 /**
85 * 弹层对齐方式, 详情见Overlay align
86 */
87 popupAlign?: string;
88
89 /**
90 * 弹层自定义样式
91 */
92 popupStyle?: React.CSSProperties;
93
94 /**
95 * 弹层自定义样式类
96 */
97 popupClassName?: string;
98
99 /**
100 * 透传给弹层的属性
101 */
102 popupProps?: PopupProps;
103
104 /**
105 * 点击菜单项后的回调,同 Menu
106 */
107 onItemClick?: (key: string, item: any, event: React.MouseEvent<HTMLElement>) => void;
108
109 /**
110 * 选择菜单后的回调,同 Menu
111 */
112 onSelect?: (selectedKeys: Array<any>, item: any, extra: any) => void;
113
114 /**
115 * 透传给 Menu 的属性
116 */
117 menuProps?: MenuProps;
118
119 /**
120 * 透传给 左侧按钮 的属性
121 */
122 leftButtonProps?: ButtonProps;
123}
124
125export default class SplitButton extends React.Component<SplitButtonProps, any> {
126 static Item: typeof Item;
127 static Group: typeof Group;
128 static Divider: typeof Divider;
129}