@itools-front/ifrontui
Version:
Vue Material Component Framework
63 lines (52 loc) • 1.29 kB
JavaScript
// Mixins
import { inject as RegistrableInject } from '../registrable';
export function factory(namespace, child, parent) {
return RegistrableInject(namespace, child, parent).extend({
name: 'groupable',
props: {
activeClass: {
type: String,
default() {
if (!this[namespace]) return undefined;
return this[namespace].activeClass;
}
},
disabled: Boolean
},
data() {
return {
isActive: false
};
},
computed: {
groupClasses() {
if (!this.activeClass) return {};
return {
[this.activeClass]: this.isActive
};
}
},
created() {
this[namespace] && this[namespace].register(this);
},
beforeDestroy() {
this[namespace] && this[namespace].unregister(this);
},
methods: {
toggle(e) {
if (this.disabled && e) {
// Prevent keyboard actions
// from children elements
// within disabled tabs
e.preventDefault();
return;
}
this.$emit('change');
}
}
});
}
/* eslint-disable-next-line @typescript-eslint/no-redeclare */
const Groupable = factory('itemGroup');
export default Groupable;
//# sourceMappingURL=index.js.map