@@ -5,24 +5,24 @@ import type { Ref } from 'vue'
55import type { UseModalOptionsPrivate } from ' ../Modal'
66import { useInternalVfm , useVfm } from ' ~/useApi'
77
8- const { modalsContainers, dynamicModals } = useVfm ()
9- const { resolvedClosed, resolvedOpened } = useInternalVfm ()
8+ const vfm = useVfm ()
9+ const _vfm = useInternalVfm ()
1010
1111const uid = Symbol (' ModalsContainer' )
12- const shouldMount = computed (() => uid === modalsContainers .value [0 ])
12+ const shouldMount = computed (() => uid === vfm . modalsContainers .value ?. [0 ])
1313
1414const openedDynamicModals: Ref <UseModalOptionsPrivate []> = shallowRef ([])
1515
1616function syncOpenDynamicModals() {
17- openedDynamicModals .value = dynamicModals .filter (modal => modal .modelValue )
17+ openedDynamicModals .value = vfm . dynamicModals .filter (modal => modal .modelValue )
1818}
1919
2020function withSyncOpenDynamicModals(callbackFn ? : () => void ) {
2121 callbackFn ?.()
2222 syncOpenDynamicModals ()
2323}
2424
25- watch (() => dynamicModals .map (modal => modal .modelValue ), (value , oldValue ) => {
25+ watch (() => vfm . dynamicModals ? .map (modal => modal .modelValue ), (value , oldValue ) => {
2626 if (! oldValue || value .length !== oldValue .length ) {
2727 syncOpenDynamicModals ()
2828 return
@@ -44,9 +44,9 @@ watch(() => dynamicModals.map(modal => modal.modelValue), (value, oldValue) => {
4444 immediate: true ,
4545})
4646
47- modalsContainers .value .push (uid )
47+ vfm . modalsContainers .value .push (uid )
4848onBeforeUnmount (() => {
49- modalsContainers .value = modalsContainers .value .filter (i => i !== uid )
49+ vfm . modalsContainers .value = vfm . modalsContainers .value .filter (i => i !== uid )
5050})
5151 </script >
5252
@@ -58,8 +58,8 @@ onBeforeUnmount(() => {
5858 :key =" modal.id"
5959 v-bind =" modal.attrs"
6060 v-model =" modal.modelValue"
61- @closed =" withSyncOpenDynamicModals(() => resolvedClosed(index))"
62- @opened =" () => resolvedOpened(index)"
61+ @closed =" withSyncOpenDynamicModals(() => _vfm. resolvedClosed?. (index))"
62+ @opened =" () => _vfm. resolvedOpened?. (index)"
6363 >
6464 <template v-for =" (slot , key ) in modal .slots " #[key ] :key =" key " >
6565 <div v-if =" isString(slot)" v-html =" slot" />
0 commit comments