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AACT,qBAAK,IAAL,CAAU,EAAV;AAEA,oBAAI,GAAG,OAAH,KAAe,MAAnB,EAA2B;AACzB,yBAAK,IAAL,CAAU,QAAV;AACA,yBAAK,IAAL,CAAU,MAAV;AAEA,2BAAO,IAAP;AACD;AAED,qBAAK,GAAG,aAAR;AACD;AACD,mBAAO,IAAP;AACD,SA3JM;AA4JP,kBA5JO,wBA4JG;AACR,gBAAI,KAAK,QAAL,CAAc,UAAd,CAAyB,SAA7B,EAAwC;AACtC,yBAAS,eAAT,CAA0B,SAA1B,CAAoC,GAApC,CAAwC,mBAAxC;AACD,aAFD,MAEO;AACL,sDAAwB,MAAxB,EAAgC,OAAhC,EAAyC,KAAK,cAA9C,EAAqF,EAAE,SAAS,KAAX,EAArF;AACA,uBAAO,gBAAP,CAAwB,SAAxB,EAAmC,KAAK,cAAxC;AACD;AACF,SAnKM;AAoKP,kBApKO,wBAoKG;AACR,qBAAS,eAAT,CAA0B,SAA1B,CAAoC,MAApC,CAA2C,mBAA3C;AACA,mBAAO,mBAAP,CAA2B,OAA3B,EAAoC,KAAK,cAAzC;AACA,mBAAO,mBAAP,CAA2B,SAA3B,EAAsC,KAAK,cAA3C;AACD;AAxKM;AA3BgE,CAA5D,C;AApBf","sourcesContent":["// Styles\nimport '../stylus/components/_overlay.styl'\n\n// Utilities\nimport { keyCodes, addPassiveEventListener } from '../util/helpers'\n\n// Types\nimport Vue from 'vue'\n\ninterface Toggleable extends Vue {\n isActive?: boolean\n}\n\ninterface Stackable extends Vue {\n activeZIndex: number\n}\n\ninterface options {\n absolute?: boolean\n $refs: {\n dialog?: HTMLElement\n content?: HTMLElement\n }\n}\n\n/* @vue/component */\nexport default Vue.extend<Vue & Toggleable & Stackable & options>().extend({\n name: 'overlayable',\n\n props: {\n hideOverlay: Boolean\n },\n\n data () {\n return {\n overlay: null as HTMLElement | null,\n overlayOffset: 0,\n overlayTimeout: undefined as number | undefined,\n overlayTransitionDuration: 500 + 150 // transition + delay\n }\n },\n\n watch: {\n hideOverlay (value) {\n if (value) this.removeOverlay()\n else this.genOverlay()\n }\n },\n\n beforeDestroy () {\n this.removeOverlay()\n },\n\n methods: {\n genOverlay () {\n // If fn is called and timeout is active\n // or overlay already exists\n // cancel removal of overlay and re-add active\n if ((!this.isActive || this.hideOverlay) ||\n (this.isActive && this.overlayTimeout) ||\n this.overlay\n ) {\n clearTimeout(this.overlayTimeout)\n\n return this.overlay &&\n this.overlay.classList.add('v-overlay--active')\n }\n\n this.overlay = document.createElement('div')\n this.overlay.className = 'v-overlay'\n\n if (this.absolute) this.overlay.className += ' v-overlay--absolute'\n\n this.hideScroll()\n\n const parent = this.absolute\n ? this.$el.parentNode\n : document.querySelector('[data-app]')\n\n parent && parent.insertBefore(this.overlay, parent.firstChild)\n\n // eslint-disable-next-line no-unused-expressions\n this.overlay.clientHeight // Force repaint\n requestAnimationFrame(() => {\n // https://github.com/vuetifyjs/vuetify/issues/4678\n if (!this.overlay) return\n\n this.overlay.className += ' v-overlay--active'\n\n if (this.activeZIndex !== undefined) {\n this.overlay.style.zIndex = String(this.activeZIndex - 1)\n }\n })\n\n return true\n },\n /** removeOverlay(false) will not restore the scollbar afterwards */\n removeOverlay (showScroll = true) {\n if (!this.overlay) {\n return showScroll && this.showScroll()\n }\n\n this.overlay.classList.remove('v-overlay--active')\n\n this.overlayTimeout = window.setTimeout(() => {\n // IE11 Fix\n try {\n if (this.overlay && this.overlay.parentNode) {\n this.overlay.parentNode.removeChild(this.overlay)\n }\n this.overlay = null\n showScroll && this.showScroll()\n } catch (e) { console.log(e) }\n\n clearTimeout(this.overlayTimeout)\n this.overlayTimeout = undefined\n }, this.overlayTransitionDuration)\n },\n scrollListener (e: WheelEvent & KeyboardEvent) {\n if (e.type === 'keydown') {\n if (\n ['INPUT', 'TEXTAREA', 'SELECT'].includes((e.target as Element).tagName) ||\n // https://github.com/vuetifyjs/vuetify/issues/4715\n (e.target as HTMLElement).isContentEditable\n ) return\n\n const up = [keyCodes.up, keyCodes.pageup]\n const down = [keyCodes.down, keyCodes.pagedown]\n\n if (up.includes(e.keyCode)) {\n (e as any).deltaY = -1\n } else if (down.includes(e.keyCode)) {\n (e as any).deltaY = 1\n } else {\n return\n }\n }\n\n if (e.target === this.overlay ||\n (e.type !== 'keydown' && e.target === document.body) ||\n this.checkPath(e)) e.preventDefault()\n },\n hasScrollbar (el?: Element) {\n if (!el || el.nodeType !== Node.ELEMENT_NODE) return false\n\n const style = window.getComputedStyle(el)\n return ['auto', 'scroll'].includes(style.overflowY!) && el.scrollHeight > el.clientHeight\n },\n shouldScroll (el: Element, delta: number) {\n if (el.scrollTop === 0 && delta < 0) return true\n return el.scrollTop + el.clientHeight === el.scrollHeight && delta > 0\n },\n isInside (el: Element, parent: Element): boolean {\n if (el === parent) {\n return true\n } else if (el === null || el === document.body) {\n return false\n } else {\n return this.isInside(el.parentNode as Element, parent)\n }\n },\n checkPath (e: WheelEvent) {\n const path = e.path || this.composedPath(e)\n const delta = e.deltaY\n\n if (e.type === 'keydown' && path[0] === document.body) {\n const dialog = this.$refs.dialog\n const selected = window.getSelection().anchorNode as Element\n if (dialog && this.hasScrollbar(dialog) && this.isInside(selected, dialog)) {\n return this.shouldScroll(dialog, delta)\n }\n return true\n }\n\n for (let index = 0; index < path.length; index++) {\n const el = path[index]\n\n if (el === document) return true\n if (el === document.documentElement) return true\n if (el === this.$refs.content) return true\n\n if (this.hasScrollbar(el as Element)) return this.shouldScroll(el as Element, delta)\n }\n\n return true\n },\n /**\n * Polyfill for Event.prototype.composedPath\n */\n composedPath (e: WheelEvent): EventTarget[] {\n if (e.composedPath) return e.composedPath()\n\n const path = []\n let el = e.target as Element\n\n while (el) {\n path.push(el)\n\n if (el.tagName === 'HTML') {\n path.push(document)\n path.push(window)\n\n return path\n }\n\n el = el.parentElement!\n }\n return path\n },\n hideScroll () {\n if (this.$vuetify.breakpoint.smAndDown) {\n document.documentElement!.classList.add('overflow-y-hidden')\n } else {\n addPassiveEventListener(window, 'wheel', this.scrollListener as EventHandlerNonNull, { passive: false })\n window.addEventListener('keydown', this.scrollListener as EventHandlerNonNull)\n }\n },\n showScroll () {\n document.documentElement!.classList.remove('overflow-y-hidden')\n window.removeEventListener('wheel', this.scrollListener as EventHandlerNonNull)\n window.removeEventListener('keydown', this.scrollListener as EventHandlerNonNull)\n }\n }\n})\n"],"sourceRoot":""}
|