25 lines
		
	
	
		
			781 B
		
	
	
	
		
			Vue
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			781 B
		
	
	
	
		
			Vue
		
	
	
	
	
	
| <script setup lang="ts">
 | |
| import { useVModel } from '@vueuse/core';
 | |
| import { IconCopy } from '@tabler/icons-vue';
 | |
| import { useCopy } from '@/composable/copy';
 | |
| 
 | |
| const props = defineProps<{ value: string }>();
 | |
| const emit = defineEmits(['update:value']);
 | |
| 
 | |
| const value = useVModel(props, 'value', emit);
 | |
| const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
 | |
| const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : 'Copy to clipboard');
 | |
| </script>
 | |
| 
 | |
| <template>
 | |
|   <c-input-text v-model:value="value">
 | |
|     <template #suffix>
 | |
|       <c-tooltip :tooltip="tooltipText">
 | |
|         <c-button circle variant="text" size="small" @click="copy()">
 | |
|           <IconCopy size="15" />
 | |
|         </c-button>
 | |
|       </c-tooltip>
 | |
|     </template>
 | |
|   </c-input-text>
 | |
| </template>
 |