Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a053aa6

Browse files
chore: code review from Alex
1 parent 97ebfef commit a053aa6

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

‎packages/vue-final-modal/src/components/VueFinalModal/VueFinalModal.vue‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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)
165165
const modalExposed = computed<ModalExposed>(() => ({
166166
modalId,
167167
hideOverlay,

‎packages/vue-final-modal/src/components/VueFinalModal/VueFinalModalProps.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import type { Options } from 'focus-trap'
22
import type { PropType, RendererElement, TransitionProps } from 'vue'
33
import 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

911
export const vueFinalModalProps = {
1012
/**

‎packages/vue-final-modal/src/plugin.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /