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MAMA;AACL,qBAAK,eAAL,CAAqB,CAArB;AACD;AACF,SAhBM;AAiBP,uBAjBO,2BAiBU,CAjBV,EAiBW;AAChB;AACA,iBAAK,QAAL;AAEA,gBAAI,EAAE,OAAF,KAAc,kBAAS,IAAvB,IAA+B,KAAK,SAAL,GAAiB,KAAK,KAAL,CAAW,MAAX,GAAoB,CAAxE,EAA2E;AACzE,qBAAK,SAAL;AACA;AACA;AACD,aAJD,MAIO,IAAI,EAAE,OAAF,KAAc,kBAAS,EAAvB,IAA6B,KAAK,SAAL,GAAiB,CAAC,CAAnD,EAAsD;AAC3D,qBAAK,SAAL;AACD,aAFM,MAEA,IAAI,EAAE,OAAF,KAAc,kBAAS,KAAvB,IAAgC,KAAK,SAAL,KAAmB,CAAC,CAAxD,EAA2D;AAChE,qBAAK,KAAL,CAAW,KAAK,SAAhB,EAA2B,KAA3B;AACD,aAFM,MAEA;AAAE;AAAQ;AACjB;AACA,cAAE,cAAF;AACD,SAhCM;AAiCP,gBAjCO,sBAiCC;AACN,iBAAK,KAAL,GAAa,KAAK,KAAL,CAAW,OAAX,CAAmB,gBAAnB,CAAoC,eAApC,CAAb;AACD;AAnCM;AA1BI,C;;;;;;;;;AAJf","sourcesContent":["/**\n * Menu keyable\n *\n * @mixin\n *\n * Primarily used to support VSelect\n * Handles opening and closing of VMenu from keystrokes\n * Will conditionally highlight VListTiles for VSelect\n */\n\n// Utils\nimport { keyCodes } from '../../../util/helpers'\n\n/* @vue/component */\nexport default {\n props: {\n disableKeys: Boolean\n },\n\n data: () => ({\n listIndex: -1,\n tiles: []\n }),\n\n watch: {\n isActive (val) {\n if (!val) this.listIndex = -1\n },\n listIndex (next, prev) {\n if (next in this.tiles) {\n const tile = this.tiles[next]\n tile.classList.add('v-list__tile--highlighted')\n this.$refs.content.scrollTop = tile.offsetTop - tile.clientHeight\n }\n\n prev in this.tiles &&\n this.tiles[prev].classList.remove('v-list__tile--highlighted')\n }\n },\n\n methods: {\n onKeyDown (e) {\n if (e.keyCode === keyCodes.esc) {\n // Wait for dependent elements to close first\n setTimeout(() => { this.isActive = false })\n const activator = this.getActivator()\n this.$nextTick(() => activator && activator.focus())\n } else if (e.keyCode === keyCodes.tab) {\n setTimeout(() => {\n if (!this.$refs.content.contains(document.activeElement)) {\n this.isActive = false\n }\n })\n } else {\n this.changeListIndex(e)\n }\n },\n changeListIndex (e) {\n // For infinite scroll and autocomplete, re-evaluate children\n this.getTiles()\n\n if (e.keyCode === keyCodes.down && this.listIndex < this.tiles.length - 1) {\n this.listIndex++\n // Allow user to set listIndex to -1 so\n // that the list can be un-highlighted\n } else if (e.keyCode === keyCodes.up && this.listIndex > -1) {\n this.listIndex--\n } else if (e.keyCode === keyCodes.enter && this.listIndex !== -1) {\n this.tiles[this.listIndex].click()\n } else { return }\n // One of the conditions was met, prevent default action (#2988)\n e.preventDefault()\n },\n getTiles () {\n this.tiles = this.$refs.content.querySelectorAll('.v-list__tile')\n }\n }\n}\n"],"sourceRoot":""}
|