// noinspection JSCheckFunctionSignatures
Vue.component('tt-button', {
//language=Vue
template: `
{{text}}
`,
props: {
sm: {type: Boolean, default: false},
icon: {type: String, required: false},
text: {type: String, required: false},
href: {type: String, required: false},
additionalClass: {type: String, required: false},
confirmText: {type: String, required: false},
loading: {type: Boolean, default: false},
},
computed: {
buttonClasses() {
const classes = {
'btn-sm': this.sm,
'btn-loading': this.loading
}
if (this.additionalClass) {
this.additionalClass.split(' ').forEach(className => {
classes[className] = true
})
}
return classes
}
},
methods: {
handleClick(event) {
if (this.loading) return event.preventDefault();
if (typeof this.confirmText === 'string' && !confirm(this.confirmText)) return event.preventDefault();
this.$emit('click', event)
}
}
})