|
3 | 3 | Ref,
|
4 | 4 | SetupContext,
|
5 | 5 | EmitsOptions,
|
6 |
| - ComponentPublicInstance |
| 6 | + ComponentPublicInstance, |
| 7 | + DefineComponent, |
| 8 | + Component |
7 | 9 | } from 'vue'
|
8 | 10 |
|
9 | 11 | export interface VfmOptions {
|
@@ -31,19 +33,72 @@ interface VueFinalModalInfo {
|
31 | 33 | focusTrap: boolean
|
32 | 34 | }
|
33 | 35 |
|
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 { |
35 | 81 | vfmContainer: HTMLDivElement,
|
36 | 82 | vfmContent: HTMLDivElement
|
37 | 83 | }
|
38 | 84 |
|
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 |
45 | 98 | 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 |
47 | 102 | }
|
48 | 103 |
|
49 | 104 | declare module '@vue/runtime-core' {
|
|
0 commit comments