2023-03-28 23:31:11 +02:00
|
|
|
<script setup lang="ts">
|
2023-08-22 01:00:20 +02:00
|
|
|
import { useCopy } from '@/composable/copy';
|
2023-03-28 23:31:11 +02:00
|
|
|
|
2023-04-19 20:30:45 +02:00
|
|
|
const props = withDefaults(defineProps<{ value?: string }>(), { value: '' });
|
|
|
|
const { value } = toRefs(props);
|
2023-03-28 23:31:11 +02:00
|
|
|
|
|
|
|
const initialText = 'Copy to clipboard';
|
|
|
|
|
2023-08-22 01:00:20 +02:00
|
|
|
const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
|
|
|
|
const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : initialText);
|
2023-03-28 23:31:11 +02:00
|
|
|
</script>
|
|
|
|
|
2023-05-28 23:13:24 +02:00
|
|
|
<template>
|
2023-10-14 18:24:54 +02:00
|
|
|
<c-tooltip :tooltip="tooltipText">
|
|
|
|
<span cursor-pointer font-mono @click="copy()">{{ value }}</span>
|
|
|
|
</c-tooltip>
|
2023-05-28 23:13:24 +02:00
|
|
|
</template>
|