{"version":3,"file":"Popover-ComwYVsn.js","sources":["../../../app/javascript/components/shared/Popover.vue"],"sourcesContent":["<template>\n <div\n v-on-click-outside=\"hide\"\n class=\"relative\">\n <fade-transition>\n <div\n v-if=\"showOverlay && showing\"\n class=\"popover-overlay fixed pin bg-ink opacity-50\"\n @click=\"hide\"></div>\n </fade-transition>\n <div\n v-if=\"$slots.target\"\n class=\"popover-target\"\n @click.prevent=\"clickTarget\">\n <slot name=\"target\"></slot>\n </div>\n <transition\n name=\"popover\"\n @after-enter=\"onAfterEnter\"\n @after-leave=\"onAfterLeave\">\n <div\n v-show=\"showing\"\n class=\"menu absolute\"\n :style=\"menuPositionStyle\"\n :class=\"[\n menuBorderClasses,\n menuBgClass,\n `${primaryOrigin}-${secondaryOrigin}`\n ]\">\n <slot name=\"body\"></slot>\n <transition name=\"secondary\">\n <div\n v-if=\"$slots.secondary\"\n class=\"secondary-menu absolute w-full shadow-2\"\n :class=\"menuBgClass\"\n :style=\"secondaryMenuStyle\">\n <slot name=\"secondary\"></slot>\n </div>\n </transition>\n </div>\n </transition>\n </div>\n</template>\n\n<script>\nimport { vOnClickOutside } from \"@vueuse/components\";\nimport FadeTransition from \"@/app/javascript/components/transitions/FadeTransition.vue\";\n\nexport default {\n name: \"Popover\",\n directives: {\n onClickOutside: vOnClickOutside\n },\n components: {\n FadeTransition\n },\n props: {\n origin: {\n type: String,\n default: \"top left\"\n },\n minWidth: {\n type: String,\n default: \"200px\"\n },\n alwaysShow: {\n type: Boolean,\n default: false\n },\n showOverlay: {\n type: Boolean,\n default: false\n },\n disabled: {\n type: Boolean,\n default: false\n },\n bordered: {\n type: Boolean,\n default: false\n },\n menuZIndex: {\n type: Number,\n default: 2\n },\n menuBgClass: {\n type: String,\n default: \"bg-paper-1\"\n }\n },\n emits: [\"opened\", \"closed\"],\n data() {\n return {\n showing: false\n };\n },\n computed: {\n primaryOrigin() {\n return this.origin.split(/\\s+/)[0];\n },\n secondaryOrigin() {\n return this.origin.split(/\\s+/)[1];\n },\n menuBorderClasses() {\n if (this.bordered) {\n return \"border border-paper\";\n }\n return null;\n },\n menuPositionStyle() {\n const adjustments = {};\n if (this.secondaryOrigin === \"center\") {\n adjustments.left = \"50%\";\n adjustments.transform = \"translateX(-50%)\";\n } else {\n adjustments[this.secondaryOrigin] = \"0\";\n }\n\n return {\n [this.primaryOrigin]: \"100%\",\n [`margin-${this.primaryOrigin}`]: \"0.25rem\",\n transformOrigin: this.origin,\n minWidth: this.minWidth,\n zIndex: this.menuZIndex,\n ...adjustments\n };\n },\n secondaryMenuStyle() {\n const secondaryMenuOrigin =\n this.primaryOrigin === \"top\" ? \"top\" : \"bottom\";\n\n return {\n [secondaryMenuOrigin]: \"100%\",\n [`margin-${secondaryMenuOrigin}`]: \"0.25rem\",\n transformOrigin: this.origin,\n minWidth: this.minWidth\n };\n }\n },\n mounted() {\n this.showing = this.alwaysShow;\n },\n methods: {\n clickTarget() {\n if (!this.disabled) {\n this.showing = !this.showing;\n }\n },\n hide() {\n if (!this.alwaysShow) {\n this.showing = false;\n }\n },\n onAfterEnter() {\n this.$emit(\"opened\");\n },\n onAfterLeave() {\n this.$emit(\"closed\");\n }\n }\n};\n</script>\n\n<style lang=\"scss\" scoped>\n.popover-enter-from,\n.popover-leave-to,\n.secondary-enter-from,\n.secondary-leave-to {\n opacity: 0;\n transform: scale(0.9);\n\n // Special case for centred popover\n &.top-center,\n &.bottom-center {\n transform: translate(-50%) scale(0.9) !important;\n }\n}\n\n.popover-enter-active,\n.popover-leave-active,\n.secondary-enter-active,\n.secondary-leave-active {\n transition: all 0.2s ease-out;\n}\n\n.popover-enter-to,\n.popover-leave,\n.secondary-enter-to,\n.secondary-leave {\n opacity: 1;\n transform: scale(1);\n\n // Special case for centred popover\n &.top-center,\n &.bottom-center {\n transform: translate(-50%) scale(1) !important;\n }\n}\n\n.popover-overlay {\n z-index: 1;\n}\n\n.popover-target {\n position: relative;\n z-index: 2;\n}\n\n.arrow {\n height: 16px;\n width: 16px;\n}\n</style>\n"],"names":["_sfc_main","vOnClickOutside","FadeTransition","adjustments","secondaryMenuOrigin","_hoisted_1","_withDirectives","_openBlock","_createElementBlock","_createVNode","_component_fade_transition","_withCtx","$props","$data","$options","args","_createCommentVNode","_ctx","_cache","_withModifiers","_renderSlot","_Transition","_createElementVNode","_normalizeClass","_normalizeStyle"],"mappings":"yPAgDA,MAAKA,EAAU,CACb,KAAM,UACN,WAAY,CACV,eAAgBC,CACjB,EACD,WAAY,CACV,eAAAC,CACD,EACD,MAAO,CACL,OAAQ,CACN,KAAM,OACN,QAAS,UACV,EACD,SAAU,CACR,KAAM,OACN,QAAS,OACV,EACD,WAAY,CACV,KAAM,QACN,QAAS,EACV,EACD,YAAa,CACX,KAAM,QACN,QAAS,EACV,EACD,SAAU,CACR,KAAM,QACN,QAAS,EACV,EACD,SAAU,CACR,KAAM,QACN,QAAS,EACV,EACD,WAAY,CACV,KAAM,OACN,QAAS,CACV,EACD,YAAa,CACX,KAAM,OACN,QAAS,YACX,CACD,EACD,MAAO,CAAC,SAAU,QAAQ,EAC1B,MAAO,CACL,MAAO,CACL,QAAS,EACV,CACF,EACD,SAAU,CACR,eAAgB,CACd,OAAO,KAAK,OAAO,MAAM,KAAK,EAAE,CAAC,CAClC,EACD,iBAAkB,CAChB,OAAO,KAAK,OAAO,MAAM,KAAK,EAAE,CAAC,CAClC,EACD,mBAAoB,CAClB,OAAI,KAAK,SACA,sBAEF,IACR,EACD,mBAAoB,CAClB,MAAMC,EAAc,CAAE,EACtB,OAAI,KAAK,kBAAoB,UAC3BA,EAAY,KAAO,MACnBA,EAAY,UAAY,oBAExBA,EAAY,KAAK,eAAe,EAAI,IAG/B,CACL,CAAC,KAAK,aAAa,EAAG,OACtB,CAAC,UAAU,KAAK,aAAa,EAAE,EAAG,UAClC,gBAAiB,KAAK,OACtB,SAAU,KAAK,SACf,OAAQ,KAAK,WACb,GAAGA,CACJ,CACF,EACD,oBAAqB,CACnB,MAAMC,EACJ,KAAK,gBAAkB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