1 | import { RenderFunction, SetupContext, ComponentPublicInstance, Ref } from 'vue'
|
2 | import { VXEComponent, VxeComponentBase, VxeEvent, SizeType, ValueOf, SlotVNodeType } from './component'
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export const VxeModal: VXEComponent<VxeModalProps, VxeModalEventProps, VxeModalSlots>
|
11 |
|
12 |
|
13 |
|
14 | export const Modal: typeof VxeModal
|
15 |
|
16 | export type VxeModalInstance = ComponentPublicInstance<VxeModalProps, VxeModalConstructor>
|
17 |
|
18 | export interface VxeModalConstructor extends VxeComponentBase, VxeModalMethods {
|
19 | props: VxeModalProps
|
20 | context: SetupContext<VxeModalEmits>
|
21 | reactData: ModalReactData
|
22 | getRefMaps(): ModalPrivateRef
|
23 | renderVN: RenderFunction
|
24 | }
|
25 |
|
26 | export interface ModalPrivateRef {
|
27 | refElem: Ref<HTMLDivElement>
|
28 | }
|
29 | export interface VxeModalPrivateRef extends ModalPrivateRef { }
|
30 |
|
31 | export interface ModalReactData {
|
32 | inited: boolean
|
33 | visible: boolean
|
34 | contentVisible: boolean
|
35 | modalTop: number
|
36 | modalZindex: number
|
37 | zoomLocat: {
|
38 | left: number
|
39 | top: number
|
40 | width: number
|
41 | height: number
|
42 | } | null
|
43 | firstOpen: boolean
|
44 | }
|
45 |
|
46 | export interface ModalMethods {
|
47 | dispatchEvent(type: ValueOf<VxeModalEmits>, params: any, evnt?: Event): void
|
48 | |
49 |
|
50 |
|
51 | open(): Promise<any>
|
52 | |
53 |
|
54 |
|
55 | close(): Promise<any>
|
56 | |
57 |
|
58 |
|
59 | getBox(): HTMLElement
|
60 | |
61 |
|
62 |
|
63 | getPosition(): {
|
64 | top?: number
|
65 | left?: number
|
66 | } | null
|
67 | |
68 |
|
69 |
|
70 | setPosition(top?: number, left?: number): Promise<any>
|
71 | |
72 |
|
73 |
|
74 | isMaximized(): boolean
|
75 | |
76 |
|
77 |
|
78 | zoom(): Promise<boolean>
|
79 | |
80 |
|
81 |
|
82 | maximize(): Promise<any>
|
83 | |
84 |
|
85 |
|
86 | revert(): Promise<any>
|
87 | }
|
88 | export interface VxeModalMethods extends ModalMethods { }
|
89 |
|
90 | export interface ModalPrivateMethods { }
|
91 | export interface VxeModalPrivateMethods extends ModalPrivateMethods { }
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | export type ModalType = 'alert' | 'confirm' | 'message' | 'modal'
|
97 |
|
98 |
|
99 |
|
100 | export type ModalStatus = 'info' | 'success' | 'warning' | 'question' | 'error' | 'loading'
|
101 |
|
102 | export type ModalPosition = {
|
103 | top?: number
|
104 | left?: number
|
105 | }
|
106 |
|
107 |
|
108 |
|
109 |
|
110 | export type ModalEventTypes = 'model' | 'mask' | 'close' | 'confirm' | 'cancel' | 'exit' | 'exist'
|
111 |
|
112 | export namespace VxeModalPropTypes {
|
113 | export type Size = SizeType
|
114 | export type ModelValue = boolean
|
115 | export type ID = string | null
|
116 | export type Type = ModalType
|
117 | export type Loading = boolean
|
118 | export type Status = ModalStatus
|
119 | export type IconStatus = string
|
120 | export type ClassName = string
|
121 | export type Top = number | string
|
122 | export type Position = 'center' | ModalPosition
|
123 | export type Title = string | number
|
124 | export type Duration = number | string
|
125 | export type Content = number | string | null
|
126 | |
127 |
|
128 |
|
129 |
|
130 | export type Message = Content
|
131 | export type ShowCancelButton = boolean | null
|
132 | export type CancelButtonText = string
|
133 | export type ShowConfirmButton = boolean | null
|
134 | export type ConfirmButtonText = string
|
135 | export type LockView = boolean
|
136 | export type LockScroll = boolean
|
137 | export type Mask = boolean
|
138 | export type MaskClosable = boolean
|
139 | export type EscClosable = boolean
|
140 | export type Resize = boolean
|
141 | export type ShowHeader = boolean
|
142 | export type ShowFooter = boolean
|
143 | export type ShowZoom = boolean
|
144 | export type ShowClose = boolean
|
145 | export type DblclickZoom = boolean
|
146 | export type Width = number | string
|
147 | export type Height = number | string
|
148 | export type MinWidth = number | string
|
149 | export type MinHeight = number | string
|
150 | export type ZIndex = number
|
151 | export type MarginSize = number | string
|
152 | export type Fullscreen = boolean
|
153 | export type Draggable = boolean
|
154 | export type Remember = boolean
|
155 | export type DestroyOnClose = boolean
|
156 | export type ShowTitleOverflow = boolean
|
157 | export type Transfer = boolean
|
158 | export type Storage = boolean
|
159 | export type StorageKey = string
|
160 | export type Animat = boolean
|
161 | export type BeforeHideMethod = (params: ModalVisibleParams) => Promise<any>
|
162 | export type Slots = ModalSlots
|
163 | }
|
164 |
|
165 | export type VxeModalProps = {
|
166 | size?: VxeModalPropTypes.Size
|
167 | modelValue?: VxeModalPropTypes.ModelValue
|
168 | id?: VxeModalPropTypes.ID
|
169 | type?: VxeModalPropTypes.Type
|
170 | loading?: VxeModalPropTypes.Loading
|
171 | status?: VxeModalPropTypes.Status
|
172 | iconStatus?: VxeModalPropTypes.IconStatus
|
173 | className?: VxeModalPropTypes.ClassName
|
174 | top?: VxeModalPropTypes.Top
|
175 | position?: VxeModalPropTypes.Position
|
176 | title?: VxeModalPropTypes.Title
|
177 | duration?: VxeModalPropTypes.Duration
|
178 | content?: VxeModalPropTypes.Content
|
179 | showCancelButton?: VxeModalPropTypes.ShowCancelButton
|
180 | cancelButtonText?: VxeModalPropTypes.CancelButtonText
|
181 | showConfirmButton?: VxeModalPropTypes.ShowConfirmButton
|
182 | confirmButtonText?: VxeModalPropTypes.ConfirmButtonText
|
183 | lockView?: VxeModalPropTypes.LockView
|
184 | lockScroll?: VxeModalPropTypes.LockScroll
|
185 | mask?: VxeModalPropTypes.Mask
|
186 | maskClosable?: VxeModalPropTypes.MaskClosable
|
187 | escClosable?: VxeModalPropTypes.EscClosable
|
188 | resize?: VxeModalPropTypes.Resize
|
189 | showHeader?: VxeModalPropTypes.ShowHeader
|
190 | showFooter?: VxeModalPropTypes.ShowFooter
|
191 | showZoom?: VxeModalPropTypes.ShowZoom
|
192 | showClose?: VxeModalPropTypes.ShowClose
|
193 | dblclickZoom?: VxeModalPropTypes.DblclickZoom
|
194 | draggable?: VxeModalPropTypes.Draggable
|
195 | width?: VxeModalPropTypes.Width
|
196 | height?: VxeModalPropTypes.Height
|
197 | minWidth?: VxeModalPropTypes.MinWidth
|
198 | minHeight?: VxeModalPropTypes.MinHeight
|
199 | zIndex?: VxeModalPropTypes.ZIndex
|
200 | marginSize?: VxeModalPropTypes.MarginSize
|
201 | fullscreen?: VxeModalPropTypes.Fullscreen
|
202 | remember?: VxeModalPropTypes.Remember
|
203 | destroyOnClose?: VxeModalPropTypes.DestroyOnClose
|
204 | showTitleOverflow?: VxeModalPropTypes.ShowTitleOverflow
|
205 | transfer?: VxeModalPropTypes.Transfer
|
206 | storage?: VxeModalPropTypes.Storage
|
207 | storageKey?: VxeModalPropTypes.StorageKey
|
208 | animat?: VxeModalPropTypes.Animat
|
209 | beforeHideMethod?: VxeModalPropTypes.BeforeHideMethod
|
210 | slots?: VxeModalPropTypes.Slots
|
211 | |
212 |
|
213 |
|
214 | message?: VxeModalPropTypes.Content
|
215 | }
|
216 |
|
217 | export type ModalSlots = {
|
218 | |
219 |
|
220 |
|
221 | default?(params: ModalDefaultSlotParams): SlotVNodeType[] | SlotVNodeType
|
222 | |
223 |
|
224 |
|
225 | header?(params: ModalHeaderSlotParams): SlotVNodeType[] | SlotVNodeType
|
226 | |
227 |
|
228 |
|
229 | title?(params: ModalTitleSlotParams): SlotVNodeType[] | SlotVNodeType
|
230 | |
231 |
|
232 |
|
233 | corner?(params: ModalTitleSlotParams): SlotVNodeType[] | SlotVNodeType
|
234 | |
235 |
|
236 |
|
237 | footer?(params: ModalFooterSlotParams): SlotVNodeType[] | SlotVNodeType
|
238 | }
|
239 |
|
240 | export type VxeModalEmits = [
|
241 | 'update:modelValue',
|
242 | 'show',
|
243 | 'hide',
|
244 | 'before-hide',
|
245 | 'close',
|
246 | 'confirm',
|
247 | 'cancel',
|
248 | 'zoom',
|
249 | 'resize',
|
250 | 'move'
|
251 | ]
|
252 |
|
253 |
|
254 |
|
255 |
|
256 | export interface ModalController {
|
257 | |
258 |
|
259 |
|
260 |
|
261 | open(options: VxeModalDefines.ModalOptions): Promise<ModalEventTypes>
|
262 | |
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 | alert(content: VxeModalPropTypes.Content, title?: VxeModalPropTypes.Title, options?: VxeModalDefines.ModalOptions): Promise<ModalEventTypes>
|
269 | |
270 |
|
271 |
|
272 |
|
273 | alert(options: VxeModalDefines.ModalOptions): Promise<ModalEventTypes>
|
274 | |
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 | confirm(content: VxeModalPropTypes.Content, title?: VxeModalPropTypes.Title, options?: VxeModalDefines.ModalOptions): Promise<ModalEventTypes>
|
281 | |
282 |
|
283 |
|
284 |
|
285 | confirm(options: VxeModalDefines.ModalOptions): Promise<ModalEventTypes>
|
286 | |
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 | message(content: VxeModalPropTypes.Content, options?: VxeModalDefines.ModalOptions): Promise<ModalEventTypes>
|
293 | |
294 |
|
295 |
|
296 |
|
297 | message(options: VxeModalDefines.ModalOptions): Promise<ModalEventTypes>
|
298 | |
299 |
|
300 |
|
301 |
|
302 | get(id: string): VxeModalConstructor & VxeModalMethods
|
303 | |
304 |
|
305 |
|
306 |
|
307 | close(id?: VxeModalPropTypes.ID): Promise<any>
|
308 | }
|
309 |
|
310 | export interface ModalDefaultSlotParams {
|
311 | $modal: VxeModalConstructor & VxeModalMethods
|
312 | }
|
313 |
|
314 | export interface ModalHeaderSlotParams extends ModalDefaultSlotParams { }
|
315 | export interface ModalTitleSlotParams extends ModalDefaultSlotParams { }
|
316 | export interface ModalFooterSlotParams extends ModalDefaultSlotParams { }
|
317 |
|
318 | interface ModalVisibleParams {
|
319 | type: ModalEventTypes
|
320 | }
|
321 |
|
322 | export namespace VxeModalDefines {
|
323 | export interface ModalOptions extends VxeModalProps, VxeModalEventProps {
|
324 | key?: string | number
|
325 | }
|
326 |
|
327 | interface ModalEventParams extends VxeEvent {
|
328 | $modal: VxeModalConstructor & VxeModalMethods
|
329 | }
|
330 |
|
331 | interface ModalBaseParams extends ModalVisibleParams { }
|
332 |
|
333 | export interface ShowParams extends ModalBaseParams { }
|
334 | export interface ShowEventParams extends ModalEventParams, ShowParams { }
|
335 |
|
336 | export interface HideParams extends ModalBaseParams { }
|
337 | export interface HideEventParams extends ModalEventParams, HideParams { }
|
338 |
|
339 | export interface BeforeHideParams extends ModalBaseParams { }
|
340 | export interface BeforeHideEventParams extends ModalEventParams, BeforeHideParams { }
|
341 |
|
342 | export interface ConfirmParams extends ModalBaseParams { }
|
343 | export interface ConfirmEventParams extends ModalEventParams, ConfirmParams { }
|
344 |
|
345 | export interface CancelParams extends ModalBaseParams { }
|
346 | export interface CancelEventParams extends ModalEventParams, CancelParams { }
|
347 |
|
348 | export interface CloseParams extends ModalBaseParams { }
|
349 | export interface CloseEventParams extends ModalEventParams, CloseParams { }
|
350 |
|
351 | export interface ZoomParams extends ModalBaseParams { }
|
352 | export interface ZoomEventParams extends ModalEventParams, ZoomParams { }
|
353 |
|
354 | export interface ResizeParams extends ModalBaseParams { }
|
355 | export interface ResizeEventParams extends ModalEventParams, ResizeParams { }
|
356 |
|
357 | export interface MoveParams extends ModalBaseParams { }
|
358 | export interface MoveEventParams extends ModalEventParams, MoveParams { }
|
359 | }
|
360 |
|
361 | export type VxeModalEventProps = {
|
362 | onShow?: VxeModalEvents.Show
|
363 | onHide?: VxeModalEvents.Hide
|
364 | onBeforeHide?: VxeModalEvents.BeforeHide
|
365 | onConfirm?: VxeModalEvents.Confirm
|
366 | onCancel?: VxeModalEvents.Cancel
|
367 | onClose?: VxeModalEvents.Close
|
368 | onZoom?: VxeModalEvents.Zoom
|
369 | onResize?: VxeModalEvents.Resize
|
370 | onMove?: VxeModalEvents.Move
|
371 | }
|
372 |
|
373 | export interface VxeModalListeners {
|
374 | show?: VxeModalEvents.Show
|
375 | hide?: VxeModalEvents.Hide
|
376 | beforeHide?: VxeModalEvents.BeforeHide
|
377 | confirm?: VxeModalEvents.Confirm
|
378 | cancel?: VxeModalEvents.Cancel
|
379 | close?: VxeModalEvents.Close
|
380 | zoom?: VxeModalEvents.Zoom
|
381 | resize?: VxeModalEvents.Resize
|
382 | move?: VxeModalEvents.Move
|
383 | }
|
384 |
|
385 | export namespace VxeModalEvents {
|
386 | export type Show = (params: VxeModalDefines.ShowEventParams) => void
|
387 | export type Hide = (params: VxeModalDefines.HideEventParams) => void
|
388 | export type BeforeHide = (params: VxeModalDefines.BeforeHideEventParams) => void
|
389 | export type Confirm = (params: VxeModalDefines.ConfirmEventParams) => void
|
390 | export type Cancel = (params: VxeModalDefines.CancelEventParams) => void
|
391 | export type Close = (params: VxeModalDefines.CloseEventParams) => void
|
392 | export type Zoom = (params: VxeModalDefines.ZoomEventParams) => void
|
393 | export type Resize = (params: VxeModalDefines.ResizeEventParams) => void
|
394 | export type Move = (params: VxeModalDefines.MoveEventParams) => void
|
395 | }
|
396 |
|
397 | export interface VxeModalSlots {
|
398 | |
399 |
|
400 |
|
401 | default: (params: ModalDefaultSlotParams) => any
|
402 | |
403 |
|
404 |
|
405 | header: (params: ModalHeaderSlotParams) => any
|
406 | |
407 |
|
408 |
|
409 | title: (params: ModalTitleSlotParams) => any
|
410 | |
411 |
|
412 |
|
413 | corner: (params: ModalTitleSlotParams) => any
|
414 | |
415 |
|
416 |
|
417 | footer: (params: ModalFooterSlotParams) => any
|
418 | }
|