import Vue from 'vue'
import UITips from './Tips.vue'
import UIAlert from './Alert.vue'
import UIConfirm from './Confirm.vue'

export const Tips = Vue.extend(UITips)
export const Alert = Vue.extend(UIAlert)
export const Confirm = Vue.extend(UIConfirm)

export function $tips(data={}) {
    let instance = new Tips({
        data
    }).$mount()

    document.body.appendChild(instance.$el)

    Vue.nextTick(() => {
        instance.show = true
    })
}

export function $alert(data={}) {
    let instance = new Alert({
        data
    }).$mount()

    document.body.appendChild(instance.$el)

    Vue.nextTick(() => {
        instance.show = true
    })
}

export function $confirm(data={}) {
    let instance = new Confirm({
        data
    }).$mount()

    document.body.appendChild(instance.$el)

    Vue.nextTick(() => {
        instance.show = true
    })
}