| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <v-tooltip | 
					
						
							|  |  |  |     ref="copyToolTip" | 
					
						
							|  |  |  |     v-model="show" | 
					
						
							|  |  |  |     color="success lighten-1" | 
					
						
							|  |  |  |     top | 
					
						
							|  |  |  |     :open-on-hover="false" | 
					
						
							|  |  |  |     :open-on-click="true" | 
					
						
							|  |  |  |     close-delay="500" | 
					
						
							|  |  |  |     transition="slide-y-transition" | 
					
						
							|  |  |  |   > | 
					
						
							|  |  |  |     <template #activator="{ on }"> | 
					
						
							|  |  |  |       <v-btn | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |         :icon="icon" | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |         :color="color" | 
					
						
							|  |  |  |         retain-focus-on-click | 
					
						
							| 
									
										
										
										
											2021-11-04 18:15:23 -08:00
										 |  |  |         :class="btnClass" | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |         @click=" | 
					
						
							|  |  |  |           on.click; | 
					
						
							|  |  |  |           textToClipboard(); | 
					
						
							|  |  |  |         " | 
					
						
							|  |  |  |         @blur="on.blur" | 
					
						
							|  |  |  |       > | 
					
						
							|  |  |  |         <v-icon>{{ $globals.icons.contentCopy }}</v-icon> | 
					
						
							| 
									
										
										
										
											2022-08-15 23:55:51 +02:00
										 |  |  |         {{ icon ? "" : $t("general.copy") }} | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |       </v-btn> | 
					
						
							|  |  |  |     </template> | 
					
						
							|  |  |  |     <span> | 
					
						
							|  |  |  |       <v-icon left dark> | 
					
						
							|  |  |  |         {{ $globals.icons.clipboardCheck }} | 
					
						
							|  |  |  |       </v-icon> | 
					
						
							| 
									
										
										
										
											2022-08-15 23:55:51 +02:00
										 |  |  |       <slot> {{ $t("general.copied_message") }} </slot> | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |     </span> | 
					
						
							|  |  |  |   </v-tooltip> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | <script lang="ts"> | 
					
						
							|  |  |  | import { defineComponent, ref } from "@nuxtjs/composition-api"; | 
					
						
							|  |  |  | import { VTooltip } from "~/types/vuetify"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default defineComponent({ | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |   props: { | 
					
						
							|  |  |  |     copyText: { | 
					
						
							| 
									
										
										
										
											2021-08-07 16:49:55 -08:00
										 |  |  |       type: String, | 
					
						
							| 
									
										
										
										
											2022-08-15 23:55:51 +02:00
										 |  |  |       required: true, | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |     }, | 
					
						
							|  |  |  |     color: { | 
					
						
							| 
									
										
										
										
											2021-08-07 16:49:55 -08:00
										 |  |  |       type: String, | 
					
						
							| 
									
										
										
										
											2021-11-22 20:10:48 -09:00
										 |  |  |       default: "", | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |     icon: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: true, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-11-04 18:15:23 -08:00
										 |  |  |     btnClass: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       default: "", | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |   setup(props) { | 
					
						
							|  |  |  |     const show = ref(false); | 
					
						
							|  |  |  |     const copyToolTip = ref<VTooltip | null>(null); | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     function toggleBlur() { | 
					
						
							|  |  |  |       copyToolTip.value?.deactivate(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function textToClipboard() { | 
					
						
							|  |  |  |       show.value = true; | 
					
						
							|  |  |  |       const copyText = props.copyText; | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |       navigator.clipboard.writeText(copyText).then( | 
					
						
							| 
									
										
										
										
											2021-11-06 11:28:47 -08:00
										 |  |  |         () => console.log(`Copied\n${copyText}`), | 
					
						
							|  |  |  |         () => console.log(`Copied Failed\n${copyText}`) | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |       ); | 
					
						
							|  |  |  |       setTimeout(() => { | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |         toggleBlur(); | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |       }, 500); | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       show, | 
					
						
							|  |  |  |       copyToolTip, | 
					
						
							|  |  |  |       textToClipboard, | 
					
						
							| 
									
										
										
										
											2022-08-15 23:55:51 +02:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-15 23:55:51 +02:00
										 |  |  | <style lang="scss" scoped></style> |