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