37 lines
No EOL
627 B
JavaScript
37 lines
No EOL
627 B
JavaScript
import Vue from 'vue';
|
|
export function factory(prop = 'value', event = 'input') {
|
|
return Vue.extend({
|
|
name: 'toggleable',
|
|
model: {
|
|
prop,
|
|
event
|
|
},
|
|
props: {
|
|
[prop]: {
|
|
required: false
|
|
}
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
isActive: !!this[prop]
|
|
};
|
|
},
|
|
|
|
watch: {
|
|
[prop](val) {
|
|
this.isActive = !!val;
|
|
},
|
|
|
|
isActive(val) {
|
|
!!val !== this[prop] && this.$emit(event, val);
|
|
}
|
|
|
|
}
|
|
});
|
|
}
|
|
/* eslint-disable-next-line no-redeclare */
|
|
|
|
const Toggleable = factory();
|
|
export default Toggleable;
|
|
//# sourceMappingURL=index.js.map
|