11import { isString , tryOnUnmounted } from '@vueuse/core'
22import { computed , inject , markRaw , reactive , useAttrs } from 'vue'
3+ import VueFinalModal from './components/VueFinalModal/VueFinalModal.vue'
34import type CoreModal from './components/CoreModal/CoreModal.vue'
45import { internalVfmSymbol , vfmSymbol } from './injectionSymbols'
56import type { ComponentProps , InternalVfm , ModalSlot , UseModalOptions , UseModalOptionsPrivate , UseModalReturnType , Vfm } from './Modal'
@@ -26,7 +27,7 @@ function withMarkRaw<
2627 const { component, slots : innerSlots , ...rest } = options
2728
2829 const slots = typeof innerSlots === 'undefined'
29- ? undefined
30+ ? { }
3031 : Object . fromEntries < ModalSlot > ( Object . entries ( innerSlots ) . map ( ( [ name , maybeComponent ] ) => {
3132 if ( isString ( maybeComponent ) )
3233 return [ name , maybeComponent ] as const
@@ -43,7 +44,7 @@ function withMarkRaw<
4344
4445 return {
4546 ...rest ,
46- component : markRaw ( component ) ,
47+ component : markRaw ( component || VueFinalModal ) ,
4748 slots,
4849 }
4950}
@@ -58,6 +59,7 @@ function defineModal<
5859 const options = reactive ( {
5960 id : Symbol ( 'useModal' ) ,
6061 modelValue : ! ! _options ?. defaultModelValue ,
62+ attrs : { } ,
6163 ...withMarkRaw ( _options ) ,
6264 } ) as UseModalOptionsPrivate < ModalProps , DefaultSlotProps >
6365
@@ -84,10 +86,14 @@ function defineModal<
8486 } )
8587 }
8688
87- function patchOptions ( _options : UseModalOptions < ModalProps , DefaultSlotProps > ) {
88- Object . assign ( options ?. attrs || { } , _options ?. attrs || { } )
89- Object . assign ( options ?. component || { } , _options ?. component || { } )
90- Object . assign ( options ?. slots || { } , _options ?. slots || { } )
89+ function patchOptions ( _options : Partial < UseModalOptions < ModalProps , DefaultSlotProps > > ) {
90+ const _patchOptions = withMarkRaw ( _options )
91+ if ( _patchOptions ?. attrs )
92+ Object . assign ( options . attrs || { } , _patchOptions . attrs )
93+ if ( _patchOptions ?. component )
94+ Object . assign ( options . component || { } , _patchOptions . component )
95+ if ( _patchOptions ?. slots )
96+ Object . assign ( options . slots || { } , _patchOptions . slots )
9197 }
9298
9399 function destroy ( ) : void {
0 commit comments