Skip to content

Commit 2cfe3a0

Browse files
committed
feat(type): support dynamic modal
1 parent b8756e3 commit 2cfe3a0

File tree

1 file changed

+64
-9
lines changed

1 file changed

+64
-9
lines changed

types/index.d.ts

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import {
33
Ref,
44
SetupContext,
55
EmitsOptions,
6-
ComponentPublicInstance
6+
ComponentPublicInstance,
7+
DefineComponent,
8+
Component
79
} from 'vue'
810

911
export interface VfmOptions {
@@ -31,19 +33,72 @@ interface VueFinalModalInfo {
3133
focusTrap: boolean
3234
}
3335

34-
export type VueFinalModalComponent = ComponentPublicInstance & {
36+
export interface DynamicModalOptions {
37+
/**
38+
* modal component
39+
*/
40+
component?: string | Component
41+
/**
42+
* bind props and attrs to modal
43+
*/
44+
bind?: {[key: string]: any}
45+
/**
46+
* register events to modal
47+
*/
48+
on?: {[key: string]: Function | Function[]}
49+
/**
50+
* modal component slot
51+
*
52+
* @example
53+
* ```js
54+
* {
55+
* slot: {
56+
* default: {
57+
* component: 'RegistedComponentName'
58+
* bind: {
59+
* yourPropsKey: propsValue
60+
* }
61+
* }
62+
* }
63+
* }
64+
* ```
65+
*/
66+
slots?: {
67+
[key: string]: {
68+
component: string | Component
69+
bind: {[key: string]: any}
70+
}
71+
}
72+
}
73+
74+
interface DynamicModalData extends DynamicModalOptions {
75+
value: boolean
76+
id: symbol
77+
params: any
78+
}
79+
80+
export interface VueFinalModalComponent extends ComponentPublicInstance {
3581
vfmContainer: HTMLDivElement,
3682
vfmContent: HTMLDivElement
3783
}
3884

39-
export type VueFinalModalProperty = {
40-
openedModals: VueFinalModalInfo[]
41-
modals: VueFinalModalInfo[]
42-
get(name: string): VueFinalModalInfo | undefined
43-
show(name: string): void
44-
hide(name: string): void
85+
86+
export interface VueFinalModalProperty {
87+
readonly dynamicModals: DynamicModalData[]
88+
readonly openedModals: VueFinalModalInfo[]
89+
readonly modals: VueFinalModalInfo[]
90+
91+
get(...names: string[]): VueFinalModalInfo[]
92+
93+
show(name: string, params?: any): void
94+
show(modal: DynamicModalOptions, params?: any): void
95+
96+
97+
hide(...names: string[]): void
4598
hideAll(): void
46-
toggle(name: string, show: boolean): void
99+
100+
toggle(name: string | string[], params?: any): void
101+
toggle(name: string | string[], show?: boolean, params?: any): void
47102
}
48103

49104
declare module '@vue/runtime-core' {

0 commit comments

Comments
 (0)