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components/_autocompletes.styl'\n\n// Extensions\nimport VSelect from '../VSelect/VSelect'\nimport VAutocomplete from '../VAutocomplete/VAutocomplete'\n\n// Utils\nimport { keyCodes } from '../../util/helpers'\n\n/* @vue/component */\nexport default {\n name: 'v-combobox',\n\n extends: VAutocomplete,\n\n props: {\n delimiters: {\n type: Array,\n default: () => ([])\n },\n returnObject: {\n type: Boolean,\n default: true\n }\n },\n\n data: () => ({\n editingIndex: -1\n }),\n\n computed: {\n counterValue () {\n return this.multiple\n ? this.selectedItems.length\n : (this.internalSearch || '').toString().length\n },\n hasSlot () {\n return VSelect.options.computed.hasSlot.call(this) || this.multiple\n },\n isAnyValueAllowed () {\n return true\n },\n menuCanShow () {\n if (!this.isFocused) return false\n\n return this.hasDisplayedItems ||\n (!!this.$slots['no-data'] && !this.hideNoData)\n }\n },\n\n methods: {\n onFilteredItemsChanged () {\n // nop\n },\n onInternalSearchChanged (val) {\n if (\n val &&\n this.multiple &&\n this.delimiters.length\n ) {\n const delimiter = this.delimiters.find(d => val.endsWith(d))\n if (delimiter != null) {\n this.internalSearch = val.slice(0, val.length - delimiter.length)\n this.updateTags()\n }\n }\n\n this.updateMenuDimensions()\n },\n genChipSelection (item, index) {\n const chip = VSelect.options.methods.genChipSelection.call(this, item, index)\n\n // Allow user to update an existing value\n if (this.multiple) {\n chip.componentOptions.listeners.dblclick = () => {\n this.editingIndex = index\n this.internalSearch = this.getText(item)\n this.selectedIndex = -1\n }\n }\n\n return chip\n },\n onChipInput (item) {\n VSelect.options.methods.onChipInput.call(this, item)\n\n this.editingIndex = -1\n },\n // Requires a manual definition\n // to overwrite removal in v-autocomplete\n onEnterDown (e) {\n e.preventDefault()\n\n VSelect.options.methods.onEnterDown.call(this)\n\n // If has menu index, let v-select-list handle\n if (this.getMenuIndex() > -1) return\n\n this.updateSelf()\n },\n onKeyDown (e) {\n const keyCode = e.keyCode\n\n VSelect.options.methods.onKeyDown.call(this, e)\n\n // If user is at selection index of 0\n // create a new tag\n if (this.multiple &&\n keyCode === keyCodes.left &&\n this.$refs.input.selectionStart === 0\n ) {\n this.updateSelf()\n }\n\n // The ordering is important here\n // allows new value to be updated\n // and then moves the index to the\n // proper location\n this.changeSelectedIndex(keyCode)\n },\n onTabDown (e) {\n // When adding tags, if searching and\n // there is not a filtered options,\n // add the value to the tags list\n if (this.multiple &&\n this.internalSearch &&\n this.getMenuIndex() === -1\n ) {\n e.preventDefault()\n e.stopPropagation()\n\n return this.updateTags()\n }\n\n VAutocomplete.options.methods.onTabDown.call(this, e)\n },\n selectItem (item) {\n // Currently only supports items:<string[]>\n if (this.editingIndex > -1) {\n this.updateEditing()\n } else {\n VSelect.options.methods.selectItem.call(this, item)\n }\n },\n setSelectedItems () {\n if (this.internalValue == null ||\n this.internalValue === ''\n ) {\n this.selectedItems = []\n } else {\n this.selectedItems = this.multiple ? this.internalValue : [this.internalValue]\n }\n },\n setValue (value = this.internalSearch) {\n VSelect.options.methods.setValue.call(this, value)\n },\n updateEditing () {\n const value = this.internalValue.slice()\n value[this.editingIndex] = this.internalSearch\n\n this.setValue(value)\n\n this.editingIndex = -1\n },\n updateCombobox () {\n const isUsingSlot = Boolean(this.$scopedSlots.selection) || this.hasChips\n\n // If search is not dirty and is\n // using slot, do nothing\n if (isUsingSlot && !this.searchIsDirty) return\n\n // The internal search is not matching\n // the internal value, update the input\n if (this.internalSearch !== this.getText(this.internalValue)) this.setValue()\n\n // Reset search if using slot\n // to avoid a double input\n if (isUsingSlot) this.internalSearch = undefined\n },\n updateSelf () {\n this.multiple ? this.updateTags() : this.updateCombobox()\n },\n updateTags () {\n const menuIndex = this.getMenuIndex()\n\n // If the user is not searching\n // and no menu item is selected\n // do nothing\n if (menuIndex < 0 &&\n !this.searchIsDirty\n ) return\n\n if (this.editingIndex > -1) {\n return this.updateEditing()\n }\n\n const index = this.selectedItems.indexOf(this.internalSearch)\n // If it already exists, do nothing\n // this might need to change to bring\n // the duplicated item to the last entered\n if (index > -1) {\n const internalValue = this.internalValue.slice()\n internalValue.splice(index, 1)\n\n this.setValue(internalValue)\n }\n\n // If menu index is greater than 1\n // the selection is handled elsewhere\n // TODO: find out where\n if (menuIndex > -1) return (this.internalSearch = null)\n\n this.selectItem(this.internalSearch)\n this.internalSearch = null\n }\n }\n}\n"],"sourceRoot":""}
|