File tree Expand file tree Collapse file tree 3 files changed +18
-11
lines changed
packages/vue-final-modal/src Expand file tree Collapse file tree 3 files changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -159,9 +159,9 @@ async function openLastOverlay() {
159159 })
160160}
161161
162- const modalId = toRef (props , ' modalId' )
163- const hideOverlay = toRef (props , ' hideOverlay' )
164- const overlayBehavior = toRef (props , ' overlayBehavior' )
162+ const modalId = toRef (() => props . modalId )
163+ const hideOverlay = toRef (() => props . hideOverlay )
164+ const overlayBehavior = toRef (() => props . overlayBehavior )
165165const modalExposed = computed <ModalExposed >(() => ({
166166 modalId ,
167167 hideOverlay ,
Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ import type { Options } from 'focus-trap'
22import type { PropType , RendererElement , TransitionProps } from 'vue'
33import type { ModalId , StyleValue } from '~/Modal'
44
5- // Hack from: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-1331857805
6- type AnyString = string & { }
7- type VfmTransition = 'vfm-fade' | 'vfm-slide-down' | 'vfm-slide-up' | 'vfm-slide-right' | 'vfm-slide-left' | AnyString
5+ /**
6+ * @see [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729)
7+ */
8+ type LiteralUnion < T extends U , U = string > = T | ( U & Record < never , never > )
9+ type VfmTransition = LiteralUnion < 'vfm-fade' | 'vfm-slide-down' | 'vfm-slide-up' | 'vfm-slide-right' | 'vfm-slide-left' >
810
911export const vueFinalModalProps = {
1012 /**
Original file line number Diff line number Diff line change @@ -59,9 +59,14 @@ export function createVfm() {
5959 } ,
6060 closeAll ( ) {
6161 return Promise . allSettled ( openedModals
62- . map ( modal => getModalExposed ( modal ) )
63- . filter ( ( modal ) : modal is ComputedRef < ModalExposed > => ! ! modal )
64- . map ( modal => modal . value . toggle ( false ) ) )
62+ . reduce < Promise < string > [ ] > ( ( acc , cur ) => {
63+ const modalExposed = getModalExposed ( cur )
64+ const promise = modalExposed ?. value . toggle ( false )
65+ if ( promise )
66+ acc . push ( promise )
67+ return acc
68+ } , [ ] ) ,
69+ )
6570 } ,
6671 } )
6772
@@ -70,6 +75,6 @@ export function createVfm() {
7075 return vfm
7176}
7277
73- export function getModalExposed ( componentInternalInstance : undefined | null | ComponentInternalInstance ) : null | ComputedRef < ModalExposed > {
74- return componentInternalInstance ?. exposed ?. modalExposed || null
78+ export function getModalExposed ( componentInternalInstance : undefined | null | ComponentInternalInstance ) : undefined | null | ComputedRef < ModalExposed > {
79+ return componentInternalInstance ?. exposed ?. modalExposed
7580}
You can’t perform that action at this time.
0 commit comments