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,UAAI,CAAC,KAAK,aAAN,IACF,CAAC,KAAK,aADR,EAEE;;AAEF,UAAI,CAAC,KAAK,eAAL,CACH,KAAK,cADF,EAEH,KAAK,QAAL,CAAc,KAAK,aAAnB,CAFG,CAAL,EAGG;AACD,aAAK,SAAL;AACD;AACF,KA9LM;AA+LP,IAAA,OA/LO,mBA+LE,IA/LF,EA+LW;AAChB,aAAO,KAAK,cAAL,CAAoB,OAApB,CAA4B,KAAK,QAAL,CAAc,IAAd,CAA5B,IAAmD,CAAC,CAA3D;AACD;AAjMM;AA7KmB,CAAf,C","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"} |