UNPKG

8.92 kBTypeScriptView Raw
1import { RenderFunction, SetupContext, ComponentPublicInstance, Ref } from 'vue'
2import { VXEComponent, VxeComponentBase, VxeEvent, SizeType, ValueOf, SlotVNodeType } from './component'
3
4/* eslint-disable no-use-before-define */
5
6export declare const VxeDrawer: VXEComponent<VxeDrawerProps, VxeDrawerEventProps>
7
8export type VxeDrawerInstance = ComponentPublicInstance<VxeDrawerProps, VxeDrawerConstructor>
9
10export interface VxeDrawerConstructor extends VxeComponentBase, VxeDrawerMethods {
11 props: VxeDrawerProps
12 context: SetupContext<VxeDrawerEmits>
13 reactData: DrawerReactData
14 getRefMaps(): DrawerPrivateRef
15 getComputeMaps(): DrawerPrivateComputed
16 renderVN: RenderFunction
17}
18
19export interface DrawerPrivateRef {
20 refElem: Ref<HTMLDivElement | undefined>
21}
22export interface VxeDrawerPrivateRef extends DrawerPrivateRef { }
23
24/**
25 * 窗口类型
26 */
27export type DrawerPosition = 'top' | 'bottom' | 'left' | 'right'
28
29/**
30 * 窗口事件类型
31 */
32export type DrawerEventTypes = 'model' | 'mask' | 'close' | 'confirm' | 'cancel' | 'exit' | 'exist'
33
34export namespace VxeDrawerPropTypes {
35 export type Size = SizeType
36 export type ModelValue = boolean
37 export type ID = string | null
38 export type Loading = boolean
39 export type ClassName = string
40 export type Position = DrawerPosition
41 export type Title = string | number
42 export type Content = number | string | null
43 export type ShowCancelButton = boolean | null
44 export type CancelButtonText = string
45 export type ShowConfirmButton = boolean | null
46 export type ConfirmButtonText = string
47 export type LockView = boolean
48 export type LockScroll = boolean
49 export type Mask = boolean
50 export type MaskClosable = boolean
51 export type EscClosable = boolean
52 export type ShowHeader = boolean
53 export type ShowFooter = boolean
54 export type ShowClose = boolean
55 export type Width = number | string
56 export type Height = number | string
57 export type ZIndex = number
58 export type DestroyOnClose = boolean
59 export type ShowTitleOverflow = boolean
60 export type Transfer = boolean
61 export type BeforeHideMethod = (params: VxeDrawerDefines.DrawerVisibleParams) => Promise<any>
62 export type Slots = VxeDrawerSlots
63}
64
65export type VxeDrawerProps = {
66 size?: VxeDrawerPropTypes.Size
67 modelValue?: VxeDrawerPropTypes.ModelValue
68 id?: VxeDrawerPropTypes.ID
69 loading?: VxeDrawerPropTypes.Loading
70 className?: VxeDrawerPropTypes.ClassName
71 position?: VxeDrawerPropTypes.Position
72 title?: VxeDrawerPropTypes.Title
73 content?: VxeDrawerPropTypes.Content
74 showCancelButton?: VxeDrawerPropTypes.ShowCancelButton
75 cancelButtonText?: VxeDrawerPropTypes.CancelButtonText
76 showConfirmButton?: VxeDrawerPropTypes.ShowConfirmButton
77 confirmButtonText?: VxeDrawerPropTypes.ConfirmButtonText
78 lockView?: VxeDrawerPropTypes.LockView
79 lockScroll?: VxeDrawerPropTypes.LockScroll
80 mask?: VxeDrawerPropTypes.Mask
81 maskClosable?: VxeDrawerPropTypes.MaskClosable
82 escClosable?: VxeDrawerPropTypes.EscClosable
83 showHeader?: VxeDrawerPropTypes.ShowHeader
84 showFooter?: VxeDrawerPropTypes.ShowFooter
85 showClose?: VxeDrawerPropTypes.ShowClose
86 width?: VxeDrawerPropTypes.Width
87 height?: VxeDrawerPropTypes.Height
88 zIndex?: VxeDrawerPropTypes.ZIndex
89 destroyOnClose?: VxeDrawerPropTypes.DestroyOnClose
90 showTitleOverflow?: VxeDrawerPropTypes.ShowTitleOverflow
91 transfer?: VxeDrawerPropTypes.Transfer
92 beforeHideMethod?: VxeDrawerPropTypes.BeforeHideMethod
93 slots?: VxeDrawerPropTypes.Slots
94}
95
96export interface DrawerPrivateComputed {
97}
98export interface VxeDrawerPrivateComputed extends DrawerPrivateComputed { }
99
100export interface DrawerReactData {
101 inited: boolean
102 visible: boolean
103 contentVisible: boolean
104 drawerZIndex: number
105 firstOpen: boolean
106}
107
108export interface DrawerMethods {
109 dispatchEvent(type: ValueOf<VxeDrawerEmits>, params: any, evnt?: Event): void
110 /**
111 * 手动打开窗口
112 */
113 open(): Promise<any>
114 /**
115 * 手动关闭窗口
116 */
117 close(): Promise<any>
118 /**
119 * 获取当前窗口元素
120 */
121 getBox(): HTMLElement
122}
123export interface VxeDrawerMethods extends DrawerMethods { }
124
125export interface DrawerPrivateMethods { }
126export interface VxeDrawerPrivateMethods extends DrawerPrivateMethods { }
127
128export type VxeDrawerEmits = [
129 'update:modelValue',
130 'show',
131 'hide',
132 'before-hide',
133 'close',
134 'confirm',
135 'cancel'
136]
137
138/**
139 * 全局窗口控制器
140 */
141export interface DrawerController {
142 /**
143 * 创建窗口
144 * @param options 参数
145 */
146 open(options: VxeDrawerDefines.DrawerOptions): Promise<DrawerEventTypes>
147 /**
148 * 获取动态的活动窗口
149 * @param id 窗口唯一标识
150 */
151 get(id: string): VxeDrawerConstructor & VxeDrawerMethods
152 /**
153 * 关闭动态的活动窗口,如果为空则关闭所有
154 * @param id 窗口唯一标识
155 */
156 close(id?: VxeDrawerPropTypes.ID): Promise<any>
157}
158
159export namespace VxeDrawerDefines {
160 export interface DrawerEventParams extends VxeEvent {
161 $drawer: VxeDrawerConstructor
162 }
163
164 export interface DrawerOptions extends VxeDrawerProps, VxeDrawerEventProps {
165 key?: string | number
166 }
167
168 export interface DrawerVisibleParams {
169 type: DrawerEventTypes
170 }
171
172 interface DrawerBaseParams extends DrawerVisibleParams { }
173
174 export interface ShowParams extends DrawerBaseParams { }
175 export interface ShowEventParams extends DrawerEventParams, ShowParams { }
176
177 export interface HideParams extends DrawerBaseParams { }
178 export interface HideEventParams extends DrawerEventParams, HideParams { }
179
180 export interface BeforeHideParams extends DrawerBaseParams { }
181 export interface BeforeHideEventParams extends DrawerEventParams, BeforeHideParams { }
182
183 export interface ConfirmParams extends DrawerBaseParams { }
184 export interface ConfirmEventParams extends DrawerEventParams, ConfirmParams { }
185
186 export interface CancelParams extends DrawerBaseParams { }
187 export interface CancelEventParams extends DrawerEventParams, CancelParams { }
188
189 export interface CloseParams extends DrawerBaseParams { }
190 export interface CloseEventParams extends DrawerEventParams, CloseParams { }
191
192 export interface ZoomParams extends DrawerBaseParams { }
193 export interface ZoomEventParams extends DrawerEventParams, ZoomParams { }
194
195 export interface ResizeParams extends DrawerBaseParams { }
196 export interface ResizeEventParams extends DrawerEventParams, ResizeParams { }
197
198 export interface MoveParams extends DrawerBaseParams { }
199 export interface MoveEventParams extends DrawerEventParams, MoveParams { }
200}
201
202export type VxeDrawerEventProps = {
203 onShow?: VxeDrawerEvents.Show
204 onHide?: VxeDrawerEvents.Hide
205 onBeforeHide?: VxeDrawerEvents.BeforeHide
206 onConfirm?: VxeDrawerEvents.Confirm
207 onCancel?: VxeDrawerEvents.Cancel
208 onClose?: VxeDrawerEvents.Close
209}
210
211export interface VxeDrawerListeners {
212 show?: VxeDrawerEvents.Show
213 hide?: VxeDrawerEvents.Hide
214 beforeHide?: VxeDrawerEvents.BeforeHide
215 confirm?: VxeDrawerEvents.Confirm
216 cancel?: VxeDrawerEvents.Cancel
217 close?: VxeDrawerEvents.Close
218}
219
220export namespace VxeDrawerEvents {
221 export type Show = (params: VxeDrawerDefines.ShowEventParams) => void
222 export type Hide = (params: VxeDrawerDefines.HideEventParams) => void
223 export type BeforeHide = (params: VxeDrawerDefines.BeforeHideEventParams) => void
224 export type Confirm = (params: VxeDrawerDefines.ConfirmEventParams) => void
225 export type Cancel = (params: VxeDrawerDefines.CancelEventParams) => void
226 export type Close = (params: VxeDrawerDefines.CloseEventParams) => void
227}
228
229export namespace VxeDrawerSlotTypes {
230 export interface DefaultSlotParams {
231 $drawer: VxeDrawerConstructor & VxeDrawerMethods
232 }
233 export interface HeaderSlotParams extends DefaultSlotParams { }
234 export interface TitleSlotParams extends DefaultSlotParams { }
235 export interface FooterSlotParams extends DefaultSlotParams { }
236}
237
238export interface VxeDrawerSlots {
239 /**
240 * 自定义窗口内容模板
241 */
242 default?(params: VxeDrawerSlotTypes.DefaultSlotParams): SlotVNodeType[] | SlotVNodeType
243 /**
244 * 自定义窗口头部的模板
245 */
246 header?(params: VxeDrawerSlotTypes.HeaderSlotParams): SlotVNodeType[] | SlotVNodeType
247 /**
248 * 自定义窗口标题的模板(如果使用了 header 插槽,则该插槽无效)
249 */
250 title?(params: VxeDrawerSlotTypes.TitleSlotParams): SlotVNodeType[] | SlotVNodeType
251 /**
252 * 自定义窗口右上角的模板
253 */
254 corner?(params: VxeDrawerSlotTypes.TitleSlotParams): SlotVNodeType[] | SlotVNodeType
255 /**
256 * 自定义窗口底部的模板
257 */
258 footer?(params: VxeDrawerSlotTypes.FooterSlotParams): SlotVNodeType[] | SlotVNodeType
259}
260
261export const Drawer: typeof VxeDrawer
262export default VxeDrawer