1- import { defineComponent , h , ref , VNode , onMounted } from 'vue' ;
1+ /* eslint-disable no-prototype-builtins */
2+ import type { VNode , ComponentOptions } from 'vue' ;
3+ import { defineComponent , h , ref , onMounted } from 'vue' ;
24
35// TODO(FW-2969): types
46
@@ -10,6 +12,20 @@ const EMPTY_PROP = Symbol();
1012const DEFAULT_EMPTY_PROP = { default : EMPTY_PROP } ;
1113
1214export const defineOverlayContainer = < Props extends object > ( name : string , defineCustomElement : ( ) => void , componentProps : string [ ] = [ ] , hasDelegateHost ?: boolean , controller ?: any ) => {
15+ const options : ComponentOptions = {
16+ name,
17+ props : {
18+ 'isOpen' : DEFAULT_EMPTY_PROP
19+ }
20+ }
21+
22+ componentProps . forEach ( componentProp => {
23+ options . props [ componentProp ] = DEFAULT_EMPTY_PROP ;
24+ } ) ;
25+
26+ if ( controller !== undefined ) {
27+ options . emits = [ 'willPresent' , 'didPresent' , 'willDismiss' , 'didDismiss' ] ;
28+ }
1329
1430 const createControllerComponent = ( ) => {
1531 return defineComponent < Props & OverlayProps > ( ( props , { slots, emit } ) => {
@@ -77,7 +93,7 @@ export const defineOverlayContainer = <Props extends object>(name: string, defin
7793 return ;
7894 }
7995
80- let restOfProps : any = { } ;
96+ const restOfProps : Record < string , any > = { } ;
8197
8298 /**
8399 * We can use Object.entries here
@@ -130,7 +146,7 @@ export const defineOverlayContainer = <Props extends object>(name: string, defin
130146 }
131147 ) ;
132148 }
133- } ) ;
149+ } , options ) ;
134150 } ;
135151 const createInlineComponent = ( ) => {
136152 return defineComponent ( ( props , { slots } ) => {
@@ -147,7 +163,7 @@ export const defineOverlayContainer = <Props extends object>(name: string, defin
147163 } ) ;
148164
149165 return ( ) => {
150- let restOfProps : any = { } ;
166+ const restOfProps : Record < string , any > = { } ;
151167
152168 /**
153169 * We can use Object.entries here
@@ -187,24 +203,10 @@ export const defineOverlayContainer = <Props extends object>(name: string, defin
187203 ( isOpen . value || restOfProps . keepContentsMounted || restOfProps . keepContentsMounted === '' ) ? renderChildren ( ) : undefined
188204 )
189205 }
190- } ) ;
206+ } , options ) ;
191207 }
192208
193209 const Container = ( controller !== undefined ) ? createControllerComponent ( ) : createInlineComponent ( ) ;
194210
195- Container . name = name ;
196-
197- Container . props = {
198- 'isOpen' : DEFAULT_EMPTY_PROP
199- } ;
200-
201- componentProps . forEach ( componentProp => {
202- Container . props [ componentProp ] = DEFAULT_EMPTY_PROP ;
203- } ) ;
204-
205- if ( controller !== undefined ) {
206- Container . emits = [ 'willPresent' , 'didPresent' , 'willDismiss' , 'didDismiss' ] ;
207- }
208-
209211 return Container ;
210212}
0 commit comments