| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <v-tooltip | 
					
						
							|  |  |  |     ref="copyToolTip" | 
					
						
							|  |  |  |     v-model="show" | 
					
						
							|  |  |  |     top | 
					
						
							|  |  |  |     :open-on-hover="false" | 
					
						
							|  |  |  |     :open-on-click="true" | 
					
						
							|  |  |  |     close-delay="500" | 
					
						
							|  |  |  |     transition="slide-y-transition" | 
					
						
							|  |  |  |   > | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <template #activator="{ props }"> | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |       <v-btn | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         variant="flat" | 
					
						
							| 
									
										
										
										
											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" | 
					
						
							| 
									
										
										
										
											2024-11-12 04:30:08 +01:00
										 |  |  |         :disabled="copyText !== '' ? false : true" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         v-bind="props" | 
					
						
							|  |  |  |         @click="textToClipboard()" | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |       > | 
					
						
							|  |  |  |         <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> | 
					
						
							| 
									
										
										
										
											2025-07-07 09:32:34 +02:00
										 |  |  |     <span v-if="!isSupported || copiedSuccess !== null"> | 
					
						
							|  |  |  |       <v-icon start> | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |         {{ $globals.icons.clipboardCheck }} | 
					
						
							|  |  |  |       </v-icon> | 
					
						
							| 
									
										
										
										
											2023-12-29 16:48:28 +01:00
										 |  |  |       <slot v-if="!isSupported"> {{ $t("general.your-browser-does-not-support-clipboard") }} </slot> | 
					
						
							| 
									
										
										
										
											2025-07-07 09:32:34 +02:00
										 |  |  |       <slot v-else> {{ copiedSuccess ? $t("general.copied_message") : $t("general.clipboard-copy-failure") }} </slot> | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |     </span> | 
					
						
							|  |  |  |   </v-tooltip> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | import { useClipboard } from "@vueuse/core"; | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | export default defineNuxtComponent({ | 
					
						
							| 
									
										
										
										
											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) { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     const { copy, copied, isSupported } = useClipboard(); | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     const show = ref(false); | 
					
						
							|  |  |  |     const copyToolTip = ref<VTooltip | null>(null); | 
					
						
							| 
									
										
										
										
											2025-07-07 09:32:34 +02:00
										 |  |  |     const copiedSuccess = ref<boolean | null>(null); | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-29 16:48:28 +01:00
										 |  |  |     async function textToClipboard() { | 
					
						
							|  |  |  |       if (isSupported.value) { | 
					
						
							|  |  |  |         await copy(props.copyText); | 
					
						
							|  |  |  |         if (copied.value) { | 
					
						
							| 
									
										
										
										
											2025-07-07 09:32:34 +02:00
										 |  |  |           copiedSuccess.value = true; | 
					
						
							|  |  |  |           console.info(`Copied\n${props.copyText}`); | 
					
						
							| 
									
										
										
										
											2023-12-29 16:48:28 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							| 
									
										
										
										
											2025-07-07 09:32:34 +02:00
										 |  |  |           copiedSuccess.value = false; | 
					
						
							|  |  |  |           console.error("Copy failed: ", copied.value); | 
					
						
							| 
									
										
										
										
											2023-12-29 16:48:28 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       else { | 
					
						
							|  |  |  |         console.warn("Clipboard is currently not supported by your browser. Ensure you're on a secure (https) site."); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |       show.value = true; | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |       setTimeout(() => { | 
					
						
							| 
									
										
										
										
											2025-07-07 09:32:34 +02:00
										 |  |  |         show.value = false; | 
					
						
							|  |  |  |       }, 3000); | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       show, | 
					
						
							|  |  |  |       copyToolTip, | 
					
						
							|  |  |  |       textToClipboard, | 
					
						
							| 
									
										
										
										
											2023-12-29 16:48:28 +01:00
										 |  |  |       copied, | 
					
						
							|  |  |  |       isSupported, | 
					
						
							| 
									
										
										
										
											2025-07-07 09:32:34 +02:00
										 |  |  |       copiedSuccess, | 
					
						
							| 
									
										
										
										
											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> |