UNPKG

3.52 kBTypeScriptView Raw
1import * as React from 'react';
2import type { ButtonProps, LegacyButtonType } from '../button/button';
3import type { DirectionType } from '../config-provider';
4type MousePosition = {
5 x: number;
6 y: number;
7} | null;
8export interface ModalProps {
9 /** 对话框是否可见 */
10 open?: boolean;
11 /** 确定按钮 loading */
12 confirmLoading?: boolean;
13 /** 标题 */
14 title?: React.ReactNode;
15 /** 是否显示右上角的关闭按钮 */
16 closable?: boolean;
17 /** 点击确定回调 */
18 onOk?: (e: React.MouseEvent<HTMLElement>) => void;
19 /** 点击模态框右上角叉、取消按钮、Props.maskClosable 值为 true 时的遮罩层或键盘按下 Esc 时的回调 */
20 onCancel?: (e: React.MouseEvent<HTMLElement>) => void;
21 afterClose?: () => void;
22 /** 垂直居中 */
23 centered?: boolean;
24 /** 宽度 */
25 width?: string | number;
26 /** 底部内容 */
27 footer?: React.ReactNode;
28 /** 确认按钮文字 */
29 okText?: React.ReactNode;
30 /** 确认按钮类型 */
31 okType?: LegacyButtonType;
32 /** 取消按钮文字 */
33 cancelText?: React.ReactNode;
34 /** 点击蒙层是否允许关闭 */
35 maskClosable?: boolean;
36 /** 强制渲染 Modal */
37 forceRender?: boolean;
38 okButtonProps?: ButtonProps;
39 cancelButtonProps?: ButtonProps;
40 destroyOnClose?: boolean;
41 style?: React.CSSProperties;
42 wrapClassName?: string;
43 maskTransitionName?: string;
44 transitionName?: string;
45 className?: string;
46 getContainer?: string | HTMLElement | getContainerFunc | false;
47 zIndex?: number;
48 bodyStyle?: React.CSSProperties;
49 maskStyle?: React.CSSProperties;
50 mask?: boolean;
51 keyboard?: boolean;
52 wrapProps?: any;
53 prefixCls?: string;
54 closeIcon?: React.ReactNode;
55 modalRender?: (node: React.ReactNode) => React.ReactNode;
56 focusTriggerAfterClose?: boolean;
57 children?: React.ReactNode;
58 mousePosition?: MousePosition;
59 /** @deprecated Please use `open` instead. */
60 visible?: boolean;
61}
62type getContainerFunc = () => HTMLElement;
63export interface ModalFuncProps {
64 prefixCls?: string;
65 className?: string;
66 open?: boolean;
67 /** @deprecated Please use `open` instead. */
68 visible?: boolean;
69 title?: React.ReactNode;
70 closable?: boolean;
71 content?: React.ReactNode;
72 onOk?: (...args: any[]) => any;
73 onCancel?: (...args: any[]) => any;
74 afterClose?: () => void;
75 okButtonProps?: ButtonProps;
76 cancelButtonProps?: ButtonProps;
77 centered?: boolean;
78 width?: string | number;
79 okText?: React.ReactNode;
80 okType?: LegacyButtonType;
81 cancelText?: React.ReactNode;
82 icon?: React.ReactNode;
83 mask?: boolean;
84 maskClosable?: boolean;
85 zIndex?: number;
86 okCancel?: boolean;
87 style?: React.CSSProperties;
88 wrapClassName?: string;
89 maskStyle?: React.CSSProperties;
90 type?: 'info' | 'success' | 'error' | 'warn' | 'warning' | 'confirm';
91 keyboard?: boolean;
92 getContainer?: string | HTMLElement | getContainerFunc | false;
93 autoFocusButton?: null | 'ok' | 'cancel';
94 transitionName?: string;
95 maskTransitionName?: string;
96 direction?: DirectionType;
97 bodyStyle?: React.CSSProperties;
98 closeIcon?: React.ReactNode;
99 modalRender?: (node: React.ReactNode) => React.ReactNode;
100 focusTriggerAfterClose?: boolean;
101}
102export interface ModalLocale {
103 okText: string;
104 cancelText: string;
105 justOkText: string;
106}
107declare const Modal: React.FC<ModalProps>;
108export default Modal;