UNPKG

4.05 kBTypeScriptView Raw
1import type React from 'react';
2import type { CommonProps } from '../util';
3import type { default as Menu, MenuProps } from '../menu';
4import type { ButtonProps } from '../button';
5import type { PopupProps } from '../overlay';
6/**
7 * @api SplitButton
8 */
9export interface SplitButtonProps extends Omit<ButtonProps, 'onSelect'>, CommonProps {
10 /**
11 * 主按钮的文案
12 * @en Text in button
13 */
14 label?: React.ReactNode;
15 /**
16 * 按钮的类型
17 * @en Typeo of button
18 * @defaultValue 'normal'
19 */
20 type?: 'normal' | 'primary' | 'secondary';
21 /**
22 * 按钮组的尺寸
23 * @en Size of button
24 * @defaultValue 'medium'
25 */
26 size?: 'small' | 'medium' | 'large';
27 /**
28 * 设置标签类型
29 * @en The html tag to be rendered
30 */
31 component?: 'button' | 'a';
32 /**
33 * 是否为幽灵按钮
34 * @en Setting ghost button
35 */
36 ghost?: 'light' | 'dark' | false | true;
37 /**
38 * 是否禁用
39 * @en Is disabled
40 */
41 disabled?: boolean;
42 /**
43 * 默认激活的菜单项(用法同 Menu 非受控)
44 * @en The keys of default selected items, as Menu
45 */
46 defaultSelectedKeys?: string[];
47 /**
48 * 激活的菜单项(用法同 Menu 受控)
49 * @en The keys of selected items
50 */
51 selectedKeys?: string[];
52 /**
53 * 菜单的选择模式
54 * @en The select mode of menu
55 */
56 selectMode?: 'single' | 'multiple';
57 /**
58 * 选择菜单项时的回调,参考 Menu
59 * @en Callback when select the menu,see Menu
60 */
61 onSelect?: MenuProps['onSelect'];
62 /**
63 * 点击菜单项时的回调,参考 Menu
64 * @en Callback when click the menu,see Menu
65 */
66 onItemClick?: MenuProps['onItemClick'];
67 /**
68 * 触发按钮的属性(支持 Button 的所有属性透传)
69 * @en The props of trigger element
70 */
71 triggerProps?: ButtonProps;
72 /**
73 * 弹层菜单的宽度是否与按钮组一致
74 * @en Whether the popup width is the same as the button
75 * @defaultValue true
76 */
77 autoWidth?: boolean;
78 /**
79 * 弹层是否显示
80 * @en Visible state of the popup
81 */
82 visible?: boolean;
83 /**
84 * 弹层默认是否显示
85 * @en Default visible state of the popup
86 */
87 defaultVisible?: boolean;
88 /**
89 * 弹层显示状态变化时的回调函数
90 * @en Callback when visible state change
91 * @param visible - 弹层显示状态
92 * @param type - 触发弹层显示或隐藏的来源 menuSelect 表示由 menu 触发;fromTrigger 表示由 trigger 的点击触发;docClick 表示由 document 的点击触发
93 */
94 onVisibleChange?: (visible: boolean, type: 'menuSelect' | 'fromTrigger' | 'docClick') => void;
95 /**
96 * 弹层的触发方式
97 * @en Trigger type of popup
98 * @defaultValue 'click'
99 */
100 popupTriggerType?: 'click' | 'hover';
101 /**
102 * 弹层对齐方式,详情见 Overlay align
103 * @en Align of popup, @see Overlay doc for detail
104 */
105 popupAlign?: string;
106 /**
107 * 弹层自定义样式
108 * @en Custom style of popup
109 */
110 popupStyle?: React.CSSProperties;
111 /**
112 * 弹层自定义样式类
113 * @en Custom className of popup
114 */
115 popupClassName?: string;
116 /**
117 * 透传给弹层的属性
118 * @en The props of popup
119 */
120 popupProps?: PopupProps;
121 /**
122 * 弹层容器,如果是函数需要返回 ref,如果是字符串则是该 DOM 的 id,也可以直接传入 DOM 节点
123 * @en The container of popup
124 */
125 popupContainer?: PopupProps['container'];
126 /**
127 * 是否跟随滚动
128 * @en follow Trigger or not
129 */
130 followTrigger?: boolean;
131 /**
132 * 透传给 Menu 的属性
133 * @en The props of menu
134 */
135 menuProps?: MenuProps & {
136 ref?: (ins: React.ComponentRef<typeof Menu>) => void;
137 };
138 /**
139 * 透传给 左侧按钮 的属性
140 * @en The props of left button
141 */
142 leftButtonProps?: ButtonProps;
143}