import Dialog from './dialog.jsx'
import { VueExtension } from '../../utils/extensions/vue.js'

export default VueExtension.InvokeComponent(unmount=>({
    data(){
        return {
            options:{
                show: false,
                overlay: true,
                zIndex: 1030,
                lockScroll: false,
                duration: 0.36,
                closeOnClickOveraly: true,
                title: '',
                content: '',
                type: 'confirm',
                buttons: [],
                primary: '',
                onButtonClick:null
            }
        }
    },
    methods:{
        open(options){
            this.options = {...this.options, ...options, show: true}
        },
        onButtonClick(data){
            this.options.onButtonClick(data)
            unmount()
        }
    },
    render(){
        return <Dialog  {...{props:this.options} } vOn:close={unmount} vOn:button-click={this.onButtonClick}/>
    }
}))