vben
2020-11-27 81baf1d5c4606aab83c0e65397ce4b090c2e4e08
提交 | 用户 | age
b6d5e5 1 import type { ButtonProps } from 'ant-design-vue/lib/button/buttonTypes';
2f6253 2 import type { CSSProperties, VNodeChild } from 'vue';
3 /**
4  * @description: 弹窗对外暴露的方法
5  */
6 export interface ModalMethods {
7   setModalProps: (props: Partial<ModalProps>) => void;
8 }
9
10 export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void;
81baf1 11
2f6253 12 export interface ReturnMethods extends ModalMethods {
ea24df 13   openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void;
2f6253 14 }
81baf1 15
2f6253 16 export type UseModalReturnType = [RegisterFn, ReturnMethods];
17
18 export interface ReturnInnerMethods extends ModalMethods {
19   closeModal: () => void;
20   changeLoading: (loading: boolean) => void;
21   changeOkLoading: (loading: boolean) => void;
22 }
81baf1 23
2f6253 24 export type UseModalInnerReturnType = [RegisterFn, ReturnInnerMethods];
25
26 export interface ModalProps {
27   // 启用wrapper后 底部可以适当增加高度
28   wrapperFooterOffset?: number;
29   draggable?: boolean;
30
31   // 是否可以进行全屏
32   canFullscreen?: boolean;
33   visible?: boolean;
34   // 温馨提醒信息
35   helpMessage: string | string[];
36
37   // 是否使用modalWrapper
38   useWrapper: boolean;
39
40   loading: boolean;
41
42   wrapperProps: Omit<ModalWrapperProps, 'loading'>;
43
44   showOkBtn: boolean;
45   showCancelBtn: boolean;
46   closeFunc: () => Promise<any>;
47
48   /**
49    * Specify a function that will be called when modal is closed completely.
50    * @type Function
51    */
52   afterClose?: () => any;
53
54   /**
55    * Body style for modal body element. Such as height, padding etc.
56    * @default {}
57    * @type object
58    */
59   bodyStyle?: CSSProperties;
60
61   /**
62    * Text of the Cancel button
63    * @default 'cancel'
64    * @type string
65    */
66   cancelText?: string;
67
68   /**
69    * Centered Modal
70    * @default false
71    * @type boolean
72    */
73   centered?: boolean;
74
75   /**
76    * Whether a close (x) button is visible on top right of the modal dialog or not
77    * @default true
78    * @type boolean
79    */
80   closable?: boolean;
81   /**
82    * Whether a close (x) button is visible on top right of the modal dialog or not
83    */
84   closeIcon?: VNodeChild | JSX.Element;
85
86   /**
87    * Whether to apply loading visual effect for OK button or not
88    * @default false
89    * @type boolean
90    */
91   confirmLoading?: boolean;
92
93   /**
94    * Whether to unmount child components on onClose
95    * @default false
96    * @type boolean
97    */
98   destroyOnClose?: boolean;
99
100   /**
101    * Footer content, set as :footer="null" when you don't need default buttons
102    * @default OK and Cancel buttons
103    * @type any (string | slot)
104    */
105   footer?: VNodeChild | JSX.Element;
106
107   /**
108    * Return the mount node for Modal
109    * @default () => document.body
110    * @type Function
111    */
112   getContainer?: (instance: any) => HTMLElement;
113
114   /**
115    * Whether show mask or not.
116    * @default true
117    * @type boolean
118    */
119   mask?: boolean;
120
121   /**
122    * Whether to close the modal dialog when the mask (area outside the modal) is clicked
123    * @default true
124    * @type boolean
125    */
126   maskClosable?: boolean;
127
128   /**
129    * Style for modal's mask element.
130    * @default {}
131    * @type object
132    */
133   maskStyle?: CSSProperties;
134
135   /**
136    * Text of the OK button
137    * @default 'OK'
138    * @type string
139    */
140   okText?: string;
141
142   /**
143    * Button type of the OK button
144    * @default 'primary'
145    * @type string
146    */
147   okType?: 'primary' | 'danger' | 'dashed' | 'ghost' | 'default';
148
149   /**
150    * The ok button props, follow jsx rules
151    * @type object
152    */
153   okButtonProps?: ButtonProps;
154
155   /**
156    * The cancel button props, follow jsx rules
157    * @type object
158    */
159   cancelButtonProps?: ButtonProps;
160
161   /**
162    * The modal dialog's title
163    * @type any (string | slot)
164    */
165   title?: VNodeChild | JSX.Element;
166
167   /**
168    * Width of the modal dialog
169    * @default 520
170    * @type string | number
171    */
172   width?: string | number;
173
174   /**
175    * The class name of the container of the modal dialog
176    * @type string
177    */
178   wrapClassName?: string;
179
180   /**
181    * The z-index of the Modal
182    * @default 1000
183    * @type number
184    */
185   zIndex?: number;
186 }
187
188 export interface ModalWrapperProps {
189   footerOffset?: number;
190   loading: boolean;
191   modalHeaderHeight: number;
192   modalFooterHeight: number;
193   minHeight: number;
194   visible: boolean;
195   fullScreen: boolean;
196 }