From 2e09f1f61e562ec09c4a779bbd141f31c1da7b45 Mon Sep 17 00:00:00 2001 From: MrSnoozles Date: Sat, 19 Oct 2024 13:02:57 +0000 Subject: [PATCH] Add importable $closeModal helper --- src/index.ts | 2 +- src/plugins/modals.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 66e3a6d2..3b70384c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,7 +40,7 @@ export { ELEMENT_REF, createNativeView } from './runtimeHelpers'; export * from '@vue/runtime-core'; export { vShow } from './directives/vShow'; -export { $showModal } from './plugins/modals'; +export { $showModal, $closeModal } from './plugins/modals'; export { $navigateTo, $navigateBack } from './plugins/navigation'; // creates a special root container that calls resetRoot whenever it's children change diff --git a/src/plugins/modals.ts b/src/plugins/modals.ts index 9a82d862..8938649f 100644 --- a/src/plugins/modals.ts +++ b/src/plugins/modals.ts @@ -61,6 +61,8 @@ function resolveModalTarget( return false; } +const modalStack = []; + export async function $showModal( component: Component

, options: ShowModalOptions = {}, @@ -127,6 +129,9 @@ export async function $showModal( }); }; const closeModal = (...args: any[]) => { + // remove view from modalStack + modalStack.splice(modalStack.indexOf(view), 1); + view.nativeView?.closeModal(...args); }; @@ -144,5 +149,12 @@ export async function $showModal( view.mount(root); openModal(); + modalStack.push(view); }); } + +export function $closeModal(...args) { + const view = modalStack.at(-1); + + view?.context.config.globalProperties.$closeModal(...args); +} \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy