main
vue 26 lines 772 Bytes
Raw
1 <template>
2 <span class="inline-flex items-center gap-2">
3 {{ value?.toString().trim() || "" }}
4
5 <n-tooltip v-if="value?.toString().trim()" class="px-2! py-1!">
6 <template #trigger>
7 <n-button v-if="isSupported" text @click="copy(value.toString())">
8 <template #icon>
9 <Icon name="carbon:copy" :size="12" />
10 </template>
11 </n-button>
12 </template>
13 <span class="text-xs">{{ copied ? "Copied" : "Copy" }}</span>
14 </n-tooltip>
15 </span>
16 </template>
17
18 <script setup lang="ts">
19 import { useClipboard } from "@vueuse/core"
20 import { NButton, NTooltip } from "naive-ui"
21 import Icon from "@/components/common/Icon.vue"
22
23 const { value } = defineProps<{ value: string | number | null }>()
24
25 const { copy, copied, isSupported } = useClipboard()
26 </script>