1 |
|
2 |
|
3 | import * as React from 'react';
|
4 | import CommonProps from '../util';
|
5 | import { ButtonProps } from '../button';
|
6 | import { OverlayProps } from '../overlay';
|
7 |
|
8 | export type CloseMode = 'close' | 'mask' | 'esc';
|
9 | interface HTMLAttributesWeak extends React.HTMLAttributes<HTMLElement> {
|
10 | title?: any;
|
11 | }
|
12 |
|
13 | export interface DialogProps extends HTMLAttributesWeak, CommonProps {
|
14 | |
15 |
|
16 |
|
17 | visible?: boolean;
|
18 |
|
19 | |
20 |
|
21 |
|
22 | title?: React.ReactNode;
|
23 |
|
24 | |
25 |
|
26 |
|
27 | children?: React.ReactNode;
|
28 |
|
29 | |
30 |
|
31 |
|
32 | footer?: boolean | React.ReactNode;
|
33 |
|
34 | |
35 |
|
36 |
|
37 | footerAlign?: 'left' | 'center' | 'right';
|
38 |
|
39 | |
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | footerActions?: Array<string>;
|
47 |
|
48 | |
49 |
|
50 |
|
51 | cache?: boolean;
|
52 |
|
53 | |
54 |
|
55 |
|
56 | onOk?: (event: React.MouseEvent) => void;
|
57 |
|
58 | |
59 |
|
60 |
|
61 | onCancel?: (event: React.MouseEvent) => void;
|
62 |
|
63 | |
64 |
|
65 |
|
66 | okProps?: ButtonProps;
|
67 |
|
68 | |
69 |
|
70 |
|
71 | cancelProps?: ButtonProps;
|
72 |
|
73 | |
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | closeable?: 'close' | 'mask' | 'esc' | boolean | 'close,mask' | 'close,esc' | 'mask,esc';
|
83 | |
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 | closeMode?: CloseMode[] | 'close' | 'mask' | 'esc';
|
91 |
|
92 | |
93 |
|
94 |
|
95 | onClose?: (trigger: string, event: React.MouseEvent) => void;
|
96 |
|
97 | |
98 |
|
99 |
|
100 | afterClose?: () => void;
|
101 |
|
102 | |
103 |
|
104 |
|
105 | hasMask?: boolean;
|
106 |
|
107 | |
108 |
|
109 |
|
110 | animation?: any | boolean;
|
111 |
|
112 | |
113 |
|
114 |
|
115 | autoFocus?: boolean;
|
116 |
|
117 | |
118 |
|
119 |
|
120 |
|
121 | align?: string | boolean;
|
122 | |
123 |
|
124 |
|
125 |
|
126 | isFullScreen?: boolean;
|
127 |
|
128 | |
129 |
|
130 |
|
131 |
|
132 | shouldUpdatePosition?: boolean;
|
133 |
|
134 | |
135 |
|
136 |
|
137 |
|
138 | minMargin?: number;
|
139 | |
140 |
|
141 |
|
142 | overlayProps?: OverlayProps;
|
143 |
|
144 | |
145 |
|
146 |
|
147 | locale?: {
|
148 | ok: string;
|
149 | cancel: string;
|
150 | };
|
151 |
|
152 | |
153 |
|
154 |
|
155 | height?: string | number;
|
156 | popupContainer?: string | HTMLElement | ((target: HTMLElement) => HTMLElement);
|
157 | /**
|
158 | * 开启 v2 版本弹窗
|
159 | */
|
160 | v2?: boolean;
|
161 | /**
|
162 | * [v2] 定制关闭按钮 icon
|
163 | */
|
164 | closeIcon?: React.ReactNode;
|
165 | /**
|
166 | * [v2] 弹窗宽度 v2 生效
|
167 | */
|
168 | width?: string | number;
|
169 | /**
|
170 | * [v2] 弹窗上边距。默认 100,设置 centered=true 后默认 40
|
171 | */
|
172 | top?: number;
|
173 | /**
|
174 | * [v2] 弹窗下边距, 默认 40
|
175 | */
|
176 | bottom?: number;
|
177 | /**
|
178 | * [v2] 对话框高度超过浏览器视口高度时,对话框是否展示滚动条。关闭此功后对话框会随高度撑开页面
|
179 | */
|
180 | overflowScroll?: boolean;
|
181 | /**
|
182 | * [v2] 弹窗居中对齐
|
183 | */
|
184 | centered?: boolean;
|
185 | /**
|
186 | * [v2] 自定义渲染弹窗
|
187 | */
|
188 | dialogRender?: (modal: React.ReactNode) => React.ReactNode;
|
189 | }
|
190 |
|
191 | export interface QuickShowConfig extends DialogProps {
|
192 | prefix?: string;
|
193 | type?: 'alert' | 'confirm';
|
194 | messageProps?: object;
|
195 | content?: React.ReactNode;
|
196 | onOk?: () => void;
|
197 | onCancel?: () => void;
|
198 | okProps?: object;
|
199 | needWrapper?: boolean;
|
200 | }
|
201 |
|
202 | export interface QuickShowRet {
|
203 | hide: () => void;
|
204 | }
|
205 |
|
206 | export default class Dialog extends React.Component<DialogProps, any> {
|
207 | static show(config: QuickShowConfig): QuickShowRet;
|
208 | static alert(config: QuickShowConfig): QuickShowRet;
|
209 | static confirm(config: QuickShowConfig): QuickShowRet;
|
210 | static success(config: QuickShowConfig): QuickShowRet;
|
211 | static error(config: QuickShowConfig): QuickShowRet;
|
212 | static warning(config: QuickShowConfig): QuickShowRet;
|
213 | static notice(config: QuickShowConfig): QuickShowRet;
|
214 | static help(config: QuickShowConfig): QuickShowRet;
|
215 | }
|