import Vue , { VueConstructor } from 'vue' ; export type Toggleable < T extends string = 'value' > = VueConstructor < Vue & { isActive : boolean ; } & Record < T , any > > ; export function factory < T extends string = 'value' > ( prop ? , event ? ) ; export function factory ( prop = 'value' , event = 'input' ) { return Vue . extend ( { name : 'toggleable' , props : { [ prop ] : { required : false } , } , data ( ) { return { isActive : ! ! this [ prop ] , } ; } , watch : { [ prop ] ( val ) { this . isActive = ! ! val ; } , isActive ( val ) { ! ! val !== this [ prop ] && this . $emit ( event , val ) ; } , } , } ) ; } const Toggleable = factory ( ) ; export default Toggleable ;