@@ -5,24 +5,24 @@ import type { Ref } from 'vue'
5
5
import type { UseModalOptionsPrivate } from ' ../Modal'
6
6
import { useInternalVfm , useVfm } from ' ~/useApi'
7
7
8
- const { modalsContainers, dynamicModals } = useVfm ()
9
- const { resolvedClosed, resolvedOpened } = useInternalVfm ()
8
+ const vfm = useVfm ()
9
+ const _vfm = useInternalVfm ()
10
10
11
11
const uid = Symbol (' ModalsContainer' )
12
- const shouldMount = computed (() => uid === modalsContainers .value [0 ])
12
+ const shouldMount = computed (() => uid === vfm . modalsContainers .value ?. [0 ])
13
13
14
14
const openedDynamicModals: Ref <UseModalOptionsPrivate []> = shallowRef ([])
15
15
16
16
function syncOpenDynamicModals() {
17
- openedDynamicModals .value = dynamicModals .filter (modal => modal .modelValue )
17
+ openedDynamicModals .value = vfm . dynamicModals .filter (modal => modal .modelValue )
18
18
}
19
19
20
20
function withSyncOpenDynamicModals(callbackFn ? : () => void ) {
21
21
callbackFn ?.()
22
22
syncOpenDynamicModals ()
23
23
}
24
24
25
- watch (() => dynamicModals .map (modal => modal .modelValue ), (value , oldValue ) => {
25
+ watch (() => vfm . dynamicModals ? .map (modal => modal .modelValue ), (value , oldValue ) => {
26
26
if (! oldValue || value .length !== oldValue .length ) {
27
27
syncOpenDynamicModals ()
28
28
return
@@ -44,9 +44,9 @@ watch(() => dynamicModals.map(modal => modal.modelValue), (value, oldValue) => {
44
44
immediate: true ,
45
45
})
46
46
47
- modalsContainers .value .push (uid )
47
+ vfm . modalsContainers .value .push (uid )
48
48
onBeforeUnmount (() => {
49
- modalsContainers .value = modalsContainers .value .filter (i => i !== uid )
49
+ vfm . modalsContainers .value = vfm . modalsContainers .value .filter (i => i !== uid )
50
50
})
51
51
</script >
52
52
@@ -58,8 +58,8 @@ onBeforeUnmount(() => {
58
58
:key =" modal.id"
59
59
v-bind =" modal.attrs"
60
60
v-model =" modal.modelValue"
61
- @closed =" withSyncOpenDynamicModals(() => resolvedClosed(index))"
62
- @opened =" () => resolvedOpened(index)"
61
+ @closed =" withSyncOpenDynamicModals(() => _vfm. resolvedClosed?. (index))"
62
+ @opened =" () => _vfm. resolvedOpened?. (index)"
63
63
>
64
64
<template v-for =" (slot , key ) in modal .slots " #[key ] :key =" key " >
65
65
<div v-if =" isString(slot)" v-html =" slot" />
0 commit comments