UNPKG

2.4 kBTypeScriptView Raw
1/// <reference types="react" />
2
3import * as React from 'react';
4import CommonProps from '../util';
5
6export interface GroupProps extends React.HTMLAttributes<HTMLElement>, CommonProps {
7 /**
8 * 统一设置 Button 组件的按钮大小
9 */
10 size?: string;
11}
12
13export class Group extends React.Component<GroupProps, any> {}
14interface HTMLAttributesWeak extends React.ButtonHTMLAttributes<HTMLElement> {
15 type?: any;
16 onClick?: any;
17}
18
19export interface ButtonProps extends HTMLAttributesWeak, CommonProps {
20 /**
21 * 按钮的类型
22 */
23 type?: 'primary' | 'secondary' | 'normal';
24
25 /**
26 * 按钮的尺寸
27 */
28 size?: 'small' | 'medium' | 'large';
29 /**
30 * 按钮中 Icon 的尺寸,用于替代 Icon 的默认大小
31 */
32 icons?: { loading?: React.ReactNode };
33 /**
34 * 按钮中 Icon 的尺寸,用于替代 Icon 的默认大小
35 */
36 iconSize?:
37 | number
38 | 'xxs'
39 | 'xs'
40 | 'small'
41 | 'medium'
42 | 'large'
43 | 'xl'
44 | 'xxl'
45 | 'xxxl'
46 | 'inherit';
47
48 /**
49 * 当 component = 'button' 时,设置 button 标签的 type 值
50 */
51 htmlType?: 'submit' | 'reset' | 'button';
52
53 /**
54 * 设置标签类型
55 * TODO: 这里的 ReactNode 是错的,但是为了向前兼容而保留,下个大版本应该去掉
56 */
57 component?: 'button' | 'a' | React.ReactNode | React.ComponentType;
58
59 /**
60 * 设置按钮的载入状态
61 */
62 loading?: boolean;
63
64 /**
65 * 是否为幽灵按钮
66 */
67 ghost?: true | false | 'light' | 'dark';
68
69 /**
70 * 是否为文本按钮
71 */
72 text?: boolean;
73
74 /**
75 * 是否为警告按钮
76 */
77 warning?: boolean;
78
79 /**
80 * 是否禁用
81 */
82 disabled?: boolean;
83
84 /**
85 * 点击按钮的回调
86 */
87 onClick?: React.MouseEventHandler;
88
89 /**
90 * 在Button组件使用component属性值为a时有效,代表链接页面的URL
91 */
92 href?: string;
93
94 /**
95 * 在Button组件使用component属性值为a时有效,代表何处打开链接文档
96 */
97 target?: string;
98
99 /**
100 * 在Button组件使用component属性值为 React Router Link 时有效,代表链接页面的路径
101 */
102 to?: string;
103}
104
105export default class Button extends React.Component<ButtonProps, any> {
106 static Group: typeof Group;
107}