import Vue , { VNode , CreateElement } from 'vue' ; export const createCommonRender = ( tagName , eventNames = [ ] ) => function ( createElement ) : VNode { const vueElement = this as Vue ; const allListeners = eventNames . reduce ( ( listeners , eventName ) => { return { ... listeners , [ eventName ] : ( event ) => { let emittedValue = event . detail ; if ( event . detail ?. value ) { emittedValue = event . detail . value ; } vueElement . $emit ( eventName , emittedValue ) ; } , } ; } , vueElement . $listeners ) ; return createElement ( tagName , { ref : 'wc' , domProps : vueElement . $props , on : allListeners , } , [ vueElement . $slots . default ] ) ; } ; export const createCommonMethod = ( methodName ) => function ( ... args ) { this . $refs . wc [ methodName ] ( ... args ) ; } as unknown ;