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() {
159
159
})
160
160
}
161
161
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 )
165
165
const modalExposed = computed <ModalExposed >(() => ({
166
166
modalId ,
167
167
hideOverlay ,
Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ import type { Options } from 'focus-trap'
2
2
import type { PropType , RendererElement , TransitionProps } from 'vue'
3
3
import type { ModalId , StyleValue } from '~/Modal'
4
4
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' >
8
10
9
11
export const vueFinalModalProps = {
10
12
/**
Original file line number Diff line number Diff line change @@ -59,9 +59,14 @@ export function createVfm() {
59
59
} ,
60
60
closeAll ( ) {
61
61
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
+ )
65
70
} ,
66
71
} )
67
72
@@ -70,6 +75,6 @@ export function createVfm() {
70
75
return vfm
71
76
}
72
77
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
75
80
}
You can’t perform that action at this time.
0 commit comments