UNPKG

3.06 kBTypeScriptView Raw
1/// <reference types="react" />
2
3import * as React from 'react';
4import CommonProps from '../util';
5import { OverlayProps } from '../overlay';
6interface HTMLAttributesWeak extends React.HTMLAttributes<HTMLElement> {
7 title?: any;
8}
9
10export interface MessageProps extends HTMLAttributesWeak, CommonProps {
11 /**
12 * 反馈类型
13 */
14 type?: 'success' | 'warning' | 'error' | 'notice' | 'help' | 'loading';
15
16 /**
17 * 反馈外观
18 */
19 shape?: 'inline' | 'addon' | 'toast';
20
21 /**
22 * 反馈大小
23 */
24 size?: 'medium' | 'large';
25
26 /**
27 * 标题
28 */
29 title?: React.ReactNode;
30
31 /**
32 * 内容,非函数式调用下使用
33 */
34 children?: React.ReactNode;
35
36 /**
37 * 默认是否显示
38 */
39 defaultVisible?: boolean;
40
41 /**
42 * 当前是否显示
43 */
44 visible?: boolean;
45
46 /**
47 * 显示的图标类型,会覆盖内部设置的IconType,传false不显示图标
48 */
49 iconType?: string | false;
50
51 /**
52 * 显示关闭按钮
53 */
54 closeable?: boolean;
55
56 /**
57 * 关闭按钮的回调
58 */
59 onClose?: () => void;
60
61 /**
62 * 关闭之后调用的函数
63 */
64 afterClose?: () => void;
65
66 /**
67 * 是否开启展开收起动画
68 */
69 animation?: boolean;
70}
71
72export interface MessageQuickProps extends Omit<HTMLAttributesWeak, 'content'>, CommonProps {
73 /**
74 * 反馈类型
75 */
76 type?: 'success' | 'warning' | 'error' | 'notice' | 'help' | 'loading';
77
78 /**
79 * 反馈大小
80 */
81 size?: 'medium' | 'large';
82 /**
83 * 标题
84 */
85 title?: React.ReactNode;
86
87 /**
88 * 内容,函数式调用下使用
89 */
90 content?: React.ReactNode;
91 /**
92 * 弹层相对于参照元素的定位, 详见开发指南的[定位部分](#定位)
93 */
94 align?: string | boolean;
95
96 /**
97 * 弹层相对于参照元素定位的微调
98 */
99 offset?: Array<any>;
100 /**
101 * 是否显示遮罩
102 */
103 hasMask?: boolean;
104
105 /**
106 * 显示持续时间,0表示一直存在,以毫秒为单位
107 */
108 duration?: number;
109 timeoutId?: string;
110
111 /**
112 * 显示关闭按钮
113 */
114 closeable?: boolean;
115
116 /**
117 * 关闭按钮的回调
118 */
119 onClose?: () => void;
120
121 /**
122 * 关闭之后调用的函数
123 */
124 afterClose?: () => void;
125
126 /**
127 * 是否开启展开收起动画
128 */
129 animation?: boolean;
130 /**
131 * 透传到弹层组件的属性对象
132 */
133 overlayProps?: OverlayProps;
134}
135
136type OpenProps = string | React.ReactElement | MessageQuickProps;
137
138export default class Message extends React.Component<MessageProps, any> {
139 static show(props: OpenProps): void;
140 static hide(): void;
141 static success(props: OpenProps): void;
142 static warning(props: OpenProps): void;
143 static error(props: OpenProps): void;
144 static help(props: OpenProps): void;
145 static loading(props: OpenProps): void;
146 static notice(props: OpenProps): void;
147 static config(props: OpenProps): void;
148}