2022-04-16 01:15:23 +02:00
|
|
|
<template>
|
2023-05-14 21:26:18 +02:00
|
|
|
<c-input-text v-model:value="value">
|
2022-04-16 01:15:23 +02:00
|
|
|
<template #suffix>
|
|
|
|
<n-tooltip trigger="hover">
|
|
|
|
<template #trigger>
|
2023-05-14 21:26:18 +02:00
|
|
|
<c-button circle variant="text" size="small" @click="onCopyClicked">
|
|
|
|
<icon-mdi-content-copy />
|
2023-04-19 21:38:59 +02:00
|
|
|
</c-button>
|
2022-04-16 01:15:23 +02:00
|
|
|
</template>
|
|
|
|
{{ tooltipText }}
|
|
|
|
</n-tooltip>
|
2022-04-22 23:31:40 +02:00
|
|
|
</template>
|
2023-05-14 21:26:18 +02:00
|
|
|
</c-input-text>
|
2022-04-16 01:15:23 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2022-04-22 23:31:40 +02:00
|
|
|
import { useVModel, useClipboard } from '@vueuse/core';
|
2022-04-16 01:15:23 +02:00
|
|
|
import { ref } from 'vue';
|
|
|
|
|
2022-04-22 23:31:40 +02:00
|
|
|
const props = defineProps<{ value: string }>();
|
|
|
|
const emit = defineEmits(['update:value']);
|
2022-04-16 01:15:23 +02:00
|
|
|
|
2022-04-22 23:31:40 +02:00
|
|
|
const value = useVModel(props, 'value', emit);
|
|
|
|
const tooltipText = ref('Copy to clipboard');
|
2022-04-16 01:15:23 +02:00
|
|
|
|
2022-04-22 23:31:40 +02:00
|
|
|
const { copy } = useClipboard({ source: value });
|
2022-04-16 01:15:23 +02:00
|
|
|
|
|
|
|
function onCopyClicked() {
|
2022-04-22 23:31:40 +02:00
|
|
|
copy();
|
|
|
|
tooltipText.value = 'Copied !';
|
2022-04-16 01:15:23 +02:00
|
|
|
|
2022-04-22 23:31:40 +02:00
|
|
|
setTimeout(() => {
|
|
|
|
tooltipText.value = 'Copy to clipboard';
|
|
|
|
}, 2000);
|
2022-04-16 01:15:23 +02:00
|
|
|
}
|
|
|
|
</script>
|