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AAE,KAAF,EAAS;AACd,yBAAa,qBADC;AAEd,mBAAO;AACL,yBAAU,CAAC,KAAK,YAAN,IAAsB,KAAK,SAA5B,GAAyC,OAAzC,GAAmD;AADvD;AAFO,SAAT,EAKJ,QALI,CAAP;AAMD;AA1TY,C","sourcesContent":["import '../../stylus/components/_dialogs.styl'\n\n// Mixins\nimport Dependent from '../../mixins/dependent'\nimport Detachable from '../../mixins/detachable'\nimport Overlayable from '../../mixins/overlayable'\nimport Returnable from '../../mixins/returnable'\nimport Stackable from '../../mixins/stackable'\nimport Toggleable from '../../mixins/toggleable'\n\n// Directives\nimport ClickOutside from '../../directives/click-outside'\n\n// Helpers\nimport { convertToUnit, keyCodes, getSlotType } from '../../util/helpers'\nimport ThemeProvider from '../../util/ThemeProvider'\nimport { consoleError } from '../../util/console'\n\n/* @vue/component */\nexport default {\n name: 'v-dialog',\n\n directives: {\n ClickOutside\n },\n\n mixins: [\n Dependent,\n Detachable,\n Overlayable,\n Returnable,\n Stackable,\n Toggleable\n ],\n\n props: {\n disabled: Boolean,\n persistent: Boolean,\n fullscreen: Boolean,\n fullWidth: Boolean,\n noClickAnimation: Boolean,\n light: Boolean,\n dark: Boolean,\n maxWidth: {\n type: [String, Number],\n default: 'none'\n },\n origin: {\n type: String,\n default: 'center center'\n },\n width: {\n type: [String, Number],\n default: 'auto'\n },\n scrollable: Boolean,\n transition: {\n type: [String, Boolean],\n default: 'dialog-transition'\n }\n },\n\n data () {\n return {\n animate: false,\n animateTimeout: null,\n stackClass: 'v-dialog__content--active',\n stackMinZIndex: 200\n }\n },\n\n computed: {\n classes () {\n return {\n [(`v-dialog ${this.contentClass}`).trim()]: true,\n 'v-dialog--active': this.isActive,\n 'v-dialog--persistent': this.persistent,\n 'v-dialog--fullscreen': this.fullscreen,\n 'v-dialog--scrollable': this.scrollable,\n 'v-dialog--animated': this.animate\n }\n },\n contentClasses () {\n return {\n 'v-dialog__content': true,\n 'v-dialog__content--active': this.isActive\n }\n },\n hasActivator () {\n return Boolean(\n !!this.$slots.activator ||\n !!this.$scopedSlots.activator\n )\n }\n },\n\n watch: {\n isActive (val) {\n if (val) {\n this.show()\n this.hideScroll()\n } else {\n this.removeOverlay()\n this.unbind()\n }\n },\n fullscreen (val) {\n if (!this.isActive) return\n\n if (val) {\n this.hideScroll()\n this.removeOverlay(false)\n } else {\n this.showScroll()\n this.genOverlay()\n }\n }\n },\n\n beforeMount () {\n this.$nextTick(() => {\n this.isBooted = this.isActive\n this.isActive && this.show()\n })\n },\n\n mounted () {\n if (getSlotType(this, 'activator', true) === 'v-slot') {\n consoleError(`v-dialog's activator slot must be bound, try '<template #activator=\"data\"><v-btn v-on=\"data.on>'`, this)\n }\n },\n\n beforeDestroy () {\n if (typeof window !== 'undefined') this.unbind()\n },\n\n methods: {\n animateClick () {\n this.animate = false\n // Needed for when clicking very fast\n // outside of the dialog\n this.$nextTick(() => {\n this.animate = true\n clearTimeout(this.animateTimeout)\n this.animateTimeout = setTimeout(() => (this.animate = false), 150)\n })\n },\n closeConditional (e) {\n // If the dialog content contains\n // the click event, or if the\n // dialog is not active\n if (!this.isActive || this.$refs.content.contains(e.target)) return false\n\n // If we made it here, the click is outside\n // and is active. If persistent, and the\n // click is on the overlay, animate\n if (this.persistent) {\n if (!this.noClickAnimation &&\n this.overlay === e.target\n ) this.animateClick()\n\n return false\n }\n\n // close dialog if !persistent, clicked outside and we're the topmost dialog.\n // Since this should only be called in a capture event (bottom up), we shouldn't need to stop propagation\n return this.activeZIndex >= this.getMaxZIndex()\n },\n hideScroll () {\n if (this.fullscreen) {\n document.documentElement.classList.add('overflow-y-hidden')\n } else {\n Overlayable.options.methods.hideScroll.call(this)\n }\n },\n show () {\n !this.fullscreen && !this.hideOverlay && this.genOverlay()\n this.$refs.content.focus()\n this.bind()\n },\n bind () {\n window.addEventListener('focusin', this.onFocusin)\n },\n unbind () {\n window.removeEventListener('focusin', this.onFocusin)\n },\n onKeydown (e) {\n if (e.keyCode === keyCodes.esc && !this.getOpenDependents().length) {\n if (!this.persistent) {\n this.isActive = false\n const activator = this.getActivator()\n this.$nextTick(() => activator && activator.focus())\n } else if (!this.noClickAnimation) {\n this.animateClick()\n }\n }\n this.$emit('keydown', e)\n },\n onFocusin (e) {\n const { target } = event\n\n if (\n // It isn't the document or the dialog body\n ![document, this.$refs.content].includes(target) &&\n // It isn't inside the dialog body\n !this.$refs.content.contains(target) &&\n // We're the topmost dialog\n this.activeZIndex >= this.getMaxZIndex() &&\n // It isn't inside a dependent element (like a menu)\n !this.getOpenDependentElements().some(el => el.contains(target))\n // So we must have focused something outside the dialog and its children\n ) {\n // Find and focus the first available element inside the dialog\n const focusable = this.$refs.content.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])')\n focusable.length && focusable[0].focus()\n }\n },\n getActivator (e) {\n if (this.$refs.activator) {\n return this.$refs.activator.children.length > 0\n ? this.$refs.activator.children[0]\n : this.$refs.activator\n }\n\n if (e) {\n this.activatedBy = e.currentTarget || e.target\n }\n\n if (this.activatedBy) return this.activatedBy\n\n if (this.activatorNode) {\n const activator = Array.isArray(this.activatorNode) ? this.activatorNode[0] : this.activatorNode\n const el = activator && activator.elm\n if (el) return el\n }\n\n consoleError('No activator found')\n },\n genActivator () {\n if (!this.hasActivator) return null\n\n const listeners = this.disabled ? {} : {\n click: e => {\n e.stopPropagation()\n this.getActivator(e)\n if (!this.disabled) this.isActive = !this.isActive\n }\n }\n\n if (getSlotType(this, 'activator') === 'scoped') {\n const activator = this.$scopedSlots.activator({ on: listeners })\n this.activatorNode = activator\n return activator\n }\n\n return this.$createElement('div', {\n staticClass: 'v-dialog__activator',\n class: {\n 'v-dialog__activator--disabled': this.disabled\n },\n ref: 'activator',\n on: listeners\n }, this.$slots.activator)\n }\n },\n\n render (h) {\n const children = []\n const data = {\n 'class': this.classes,\n ref: 'dialog',\n directives: [\n {\n name: 'click-outside',\n value: () => { this.isActive = false },\n args: {\n closeConditional: this.closeConditional,\n include: this.getOpenDependentElements\n }\n },\n { name: 'show', value: this.isActive }\n ],\n on: {\n click: e => { e.stopPropagation() }\n }\n }\n\n if (!this.fullscreen) {\n data.style = {\n maxWidth: this.maxWidth === 'none' ? undefined : convertToUnit(this.maxWidth),\n width: this.width === 'auto' ? undefined : convertToUnit(this.width)\n }\n }\n\n children.push(this.genActivator())\n\n let dialog = h('div', data, this.showLazyContent(this.$slots.default))\n if (this.transition) {\n dialog = h('transition', {\n props: {\n name: this.transition,\n origin: this.origin\n }\n }, [dialog])\n }\n\n children.push(h('div', {\n 'class': this.contentClasses,\n attrs: {\n tabIndex: '-1',\n ...this.getScopeIdAttrs()\n },\n on: {\n keydown: this.onKeydown\n },\n style: { zIndex: this.activeZIndex },\n ref: 'content'\n }, [\n this.$createElement(ThemeProvider, {\n props: {\n root: true,\n light: this.light,\n dark: this.dark\n }\n }, [dialog])\n ]))\n\n return h('div', {\n staticClass: 'v-dialog__container',\n style: {\n display: (!this.hasActivator || this.fullWidth) ? 'block' : 'inline-block'\n }\n }, children)\n }\n}\n"],"sourceRoot":""}
|