Commit 6d5f9aa699c5da8af6bf5841baddc4a8bd603917
1 parent
21f7a854
feat(modal): add closeModal for useModal
Showing
2 changed files
with
5 additions
and
0 deletions
src/components/Modal/src/hooks/useModal.ts
@@ -90,6 +90,10 @@ export function useModal(): UseModalReturnType { | @@ -90,6 +90,10 @@ export function useModal(): UseModalReturnType { | ||
90 | dataTransferRef[unref(uidRef)] = toRaw(data); | 90 | dataTransferRef[unref(uidRef)] = toRaw(data); |
91 | } | 91 | } |
92 | }, | 92 | }, |
93 | + | ||
94 | + closeModal: () => { | ||
95 | + getInstance()?.setModalProps({ visible: false }); | ||
96 | + }, | ||
93 | }; | 97 | }; |
94 | return [register, methods]; | 98 | return [register, methods]; |
95 | } | 99 | } |
src/components/Modal/src/types.ts
@@ -13,6 +13,7 @@ export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void; | @@ -13,6 +13,7 @@ export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void; | ||
13 | 13 | ||
14 | export interface ReturnMethods extends ModalMethods { | 14 | export interface ReturnMethods extends ModalMethods { |
15 | openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void; | 15 | openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void; |
16 | + closeModal: () => void; | ||
16 | getVisible?: ComputedRef<boolean>; | 17 | getVisible?: ComputedRef<boolean>; |
17 | } | 18 | } |
18 | 19 |