This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/vuetify/lib/components/VOverflowBtn/VOverflowBtn.js
2019-08-11 20:48:02 +02:00

93 lines
No EOL
2.6 KiB
JavaScript

// Styles
import "../../../src/components/VOverflowBtn/VOverflowBtn.sass"; // Extensions
import VSelect from '../VSelect/VSelect';
import VAutocomplete from '../VAutocomplete';
import VTextField from '../VTextField/VTextField'; // Components
import VBtn from '../VBtn'; // Utilities
import { consoleWarn } from '../../util/console';
/* @vue/component */
export default VAutocomplete.extend({
name: 'v-overflow-btn',
props: {
editable: Boolean,
segmented: Boolean
},
computed: {
classes() {
return { ...VAutocomplete.options.computed.classes.call(this),
'v-overflow-btn': true,
'v-overflow-btn--segmented': this.segmented,
'v-overflow-btn--editable': this.editable
};
},
isAnyValueAllowed() {
return this.editable || VAutocomplete.options.computed.isAnyValueAllowed.call(this);
},
isSingle() {
return true;
},
computedItems() {
return this.segmented ? this.allItems : this.filteredItems;
}
},
methods: {
genSelections() {
return this.editable ? VAutocomplete.options.methods.genSelections.call(this) : VSelect.options.methods.genSelections.call(this); // Override v-autocomplete's override
},
genCommaSelection(item, index, last) {
return this.segmented ? this.genSegmentedBtn(item) : VSelect.options.methods.genCommaSelection.call(this, item, index, last);
},
genInput() {
const input = VTextField.options.methods.genInput.call(this);
input.data = input.data || {};
input.data.domProps.value = this.editable ? this.internalSearch : '';
input.data.attrs.readonly = !this.isAnyValueAllowed;
return input;
},
genLabel() {
if (this.editable && this.isFocused) return null;
const label = VTextField.options.methods.genLabel.call(this);
if (!label) return label;
label.data = label.data || {}; // Reset previously set styles from parent
label.data.style = {};
return label;
},
genSegmentedBtn(item) {
const itemValue = this.getValue(item);
const itemObj = this.computedItems.find(i => this.getValue(i) === itemValue) || item;
if (!itemObj.text || !itemObj.callback) {
consoleWarn('When using \'segmented\' prop without a selection slot, items must contain both a text and callback property', this);
return null;
}
return this.$createElement(VBtn, {
props: {
text: true
},
on: {
click(e) {
e.stopPropagation();
itemObj.callback(e);
}
}
}, [itemObj.text]);
}
}
});
//# sourceMappingURL=VOverflowBtn.js.map