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,CACH,KAAK,cADF,EAEH,KAAK,QAAL,CAAc,KAAK,aAAnB,CAFG,CAAL,EAGG;AACD,aAAK,SAAL;AACD;AACF,KA9LM;;AA+LP,IAAA,OAAO,CAAE,IAAF,EAAW;AAChB,aAAO,KAAK,cAAL,CAAoB,OAApB,CAA4B,KAAK,QAAL,CAAc,IAAd,CAA5B,IAAmD,CAAC,CAA3D;AACD;;AAjMM;AA7KmB,CAAf,CAAf","sourcesContent":["// Styles\nimport './VAutocomplete.sass'\n\n// Extensions\nimport VSelect, { defaultMenuProps as VSelectMenuProps } from '../VSelect/VSelect'\nimport VTextField from '../VTextField/VTextField'\n\n// Utilities\nimport { keyCodes } from '../../util/helpers'\n\n// Types\nimport { PropType } from 'vue'\n\nconst defaultMenuProps = {\n ...VSelectMenuProps,\n offsetY: true,\n offsetOverflow: true,\n transition: false,\n}\n\n/* @vue/component */\nexport default VSelect.extend({\n name: 'v-autocomplete',\n\n props: {\n allowOverflow: {\n type: Boolean,\n default: true,\n },\n autoSelectFirst: {\n type: Boolean,\n default: false,\n },\n filter: {\n type: Function,\n default: (item: any, queryText: string, itemText: string) => {\n return itemText.toLocaleLowerCase().indexOf(queryText.toLocaleLowerCase()) > -1\n },\n },\n hideNoData: Boolean,\n menuProps: {\n type: VSelect.options.props.menuProps.type,\n default: () => defaultMenuProps,\n },\n noFilter: Boolean,\n searchInput: {\n type: String as PropType<string | undefined>,\n default: undefined,\n },\n },\n\n data () {\n return {\n lazySearch: this.searchInput,\n }\n },\n\n computed: {\n classes (): object {\n return {\n ...VSelect.options.computed.classes.call(this),\n 'v-autocomplete': true,\n 'v-autocomplete--is-selecting-index': this.selectedIndex > -1,\n }\n },\n computedItems (): object[] {\n return this.filteredItems\n },\n selectedValues (): object[] {\n return this.selectedItems.map(item => this.getValue(item))\n },\n hasDisplayedItems (): boolean {\n return this.hideSelected\n ? this.filteredItems.some(item => !this.hasItem(item))\n : this.filteredItems.length > 0\n },\n currentRange (): number {\n if (this.selectedItem == null) return 0\n\n return String(this.getText(this.selectedItem)).length\n },\n filteredItems (): object[] {\n if (!this.isSearching || this.noFilter || this.internalSearch == null) return this.allItems\n\n return this.allItems.filter(item => this.filter(item, String(this.internalSearch), String(this.getText(item))))\n },\n internalSearch: {\n get (): string | undefined {\n return this.lazySearch\n },\n set (val: any) {\n this.lazySearch = val\n\n this.$emit('update:search-input', val)\n },\n },\n isAnyValueAllowed (): boolean {\n return false\n },\n isDirty (): boolean {\n return this.searchIsDirty || this.selectedItems.length > 0\n },\n isSearching (): boolean {\n return (\n this.multiple &&\n this.searchIsDirty\n ) || (\n this.searchIsDirty &&\n this.internalSearch !== this.getText(this.selectedItem)\n )\n },\n menuCanShow (): boolean {\n if (!this.isFocused) return false\n\n return this.hasDisplayedItems || !this.hideNoData\n },\n $_menuProps (): object {\n const props = VSelect.options.computed.$_menuProps.call(this);\n (props as any).contentClass = `v-autocomplete__content ${(props as any).contentClass || ''}`.trim()\n return {\n ...defaultMenuProps,\n ...props,\n }\n },\n searchIsDirty (): boolean {\n return this.internalSearch != null &&\n this.internalSearch !== ''\n },\n selectedItem (): any {\n if (this.multiple) return null\n\n return this.selectedItems.find(i => {\n return this.valueComparator(this.getValue(i), this.getValue(this.internalValue))\n })\n },\n listData () {\n const data = VSelect.options.computed.listData.call(this) as any\n\n data.props = {\n ...data.props,\n items: this.virtualizedItems,\n noFilter: (\n this.noFilter ||\n !this.isSearching ||\n !this.filteredItems.length\n ),\n searchInput: this.internalSearch,\n }\n\n return data\n },\n },\n\n watch: {\n filteredItems: 'onFilteredItemsChanged',\n internalValue: 'setSearch',\n isFocused (val) {\n if (val) {\n this.$refs.input &&\n this.$refs.input.select()\n } else {\n this.updateSelf()\n }\n },\n isMenuActive (val) {\n if (val || !this.hasSlot) return\n\n this.lazySearch = undefined\n },\n items (val, oldVal) {\n // If we are focused, the menu\n // is not active, hide no data is enabled,\n // and items change\n // User is probably async loading\n // items, try to activate the menu\n if (\n !(oldVal && oldVal.length) &&\n this.hideNoData &&\n this.isFocused &&\n !this.isMenuActive &&\n val.length\n ) this.activateMenu()\n },\n searchInput (val: string) {\n this.lazySearch = val\n },\n internalSearch: 'onInternalSearchChanged',\n itemText: 'updateSelf',\n },\n\n created () {\n this.setSearch()\n },\n\n methods: {\n onFilteredItemsChanged (val: never[], oldVal: never[]) {\n // TODO: How is the watcher triggered\n // for duplicate items? no idea\n if (val === oldVal) return\n\n this.setMenuIndex(-1)\n\n this.$nextTick(() => {\n if (\n !this.internalSearch ||\n (val.length !== 1 &&\n !this.autoSelectFirst)\n ) return\n\n this.$refs.menu.getTiles()\n this.setMenuIndex(0)\n })\n },\n onInternalSearchChanged () {\n this.updateMenuDimensions()\n },\n updateMenuDimensions () {\n // Type from menuable is not making it through\n this.isMenuActive && this.$refs.menu && this.$refs.menu.updateDimensions()\n },\n changeSelectedIndex (keyCode: number) {\n // Do not allow changing of selectedIndex\n // when search is dirty\n if (this.searchIsDirty) return\n\n if (![\n keyCodes.backspace,\n keyCodes.left,\n keyCodes.right,\n keyCodes.delete,\n ].includes(keyCode)) return\n\n const index = this.selectedItems.length - 1\n\n if (keyCode === keyCodes.left) {\n if (this.selectedIndex === -1) {\n this.selectedIndex = index\n } else {\n this.selectedIndex--\n }\n } else if (keyCode === keyCodes.right) {\n if (this.selectedIndex >= index) {\n this.selectedIndex = -1\n } else {\n this.selectedIndex++\n }\n } else if (this.selectedIndex === -1) {\n this.selectedIndex = index\n return\n }\n\n const currentItem = this.selectedItems[this.selectedIndex]\n\n if ([\n keyCodes.backspace,\n keyCodes.delete,\n ].includes(keyCode) &&\n !this.getDisabled(currentItem)\n ) {\n const newIndex = this.selectedIndex === index\n ? this.selectedIndex - 1\n : this.selectedItems[this.selectedIndex + 1]\n ? this.selectedIndex\n : -1\n\n if (newIndex === -1) {\n this.setValue(this.multiple ? [] : undefined)\n } else {\n this.selectItem(currentItem)\n }\n\n this.selectedIndex = newIndex\n }\n },\n clearableCallback () {\n this.internalSearch = undefined\n\n VSelect.options.methods.clearableCallback.call(this)\n },\n genInput () {\n const input = VTextField.options.methods.genInput.call(this)\n\n input.data = input.data || {}\n input.data.attrs = input.data.attrs || {}\n input.data.domProps = input.data.domProps || {}\n input.data.domProps.value = this.internalSearch\n\n return input\n },\n genInputSlot () {\n const slot = VSelect.options.methods.genInputSlot.call(this)\n\n slot.data!.attrs!.role = 'combobox'\n\n return slot\n },\n genSelections () {\n return this.hasSlot || this.multiple\n ? VSelect.options.methods.genSelections.call(this)\n : []\n },\n onClick () {\n if (this.isDisabled) return\n\n this.selectedIndex > -1\n ? (this.selectedIndex = -1)\n : this.onFocus()\n\n this.activateMenu()\n },\n onInput (e: Event) {\n if (\n this.selectedIndex > -1 ||\n !e.target\n ) return\n\n const target = e.target as HTMLInputElement\n const value = target.value\n\n // If typing and menu is not currently active\n if (target.value) this.activateMenu()\n\n this.internalSearch = value\n this.badInput = target.validity && target.validity.badInput\n },\n onKeyDown (e: KeyboardEvent) {\n const keyCode = e.keyCode\n\n VSelect.options.methods.onKeyDown.call(this, e)\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 onSpaceDown (e: KeyboardEvent) { /* noop */ },\n onTabDown (e: KeyboardEvent) {\n VSelect.options.methods.onTabDown.call(this, e)\n this.updateSelf()\n },\n onUpDown () {\n // For autocomplete / combobox, cycling\n // interfers with native up/down behavior\n // instead activate the menu\n this.activateMenu()\n },\n setSelectedItems () {\n VSelect.options.methods.setSelectedItems.call(this)\n\n // #4273 Don't replace if searching\n // #4403 Don't replace if focused\n if (!this.isFocused) this.setSearch()\n },\n setSearch () {\n // Wait for nextTick so selectedItem\n // has had time to update\n this.$nextTick(() => {\n if (\n !this.multiple ||\n !this.internalSearch ||\n !this.isMenuActive\n ) {\n this.internalSearch = (\n !this.selectedItems.length ||\n this.multiple ||\n this.hasSlot\n )\n ? null\n : this.getText(this.selectedItem)\n }\n })\n },\n updateSelf () {\n if (!this.searchIsDirty &&\n !this.internalValue\n ) return\n\n if (!this.valueComparator(\n this.internalSearch,\n this.getValue(this.internalValue)\n )) {\n this.setSearch()\n }\n },\n hasItem (item: any) {\n return this.selectedValues.indexOf(this.getValue(item)) > -1\n },\n },\n})\n"],"sourceRoot":"","file":"VAutocomplete.js"} |