CommonInputCopyToClipboard.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { useCopyToClipboard } from '#shared/composables/useCopyToClipboard.ts'
  4. import CommonButton from '../CommonButton/CommonButton.vue'
  5. interface Props {
  6. label: string
  7. labelPlaceholder?: string[]
  8. value: string
  9. copyButtonText?: string
  10. help?: string
  11. }
  12. withDefaults(defineProps<Props>(), {
  13. copyButtonText: __('Copy Text'),
  14. })
  15. const { copyToClipboard } = useCopyToClipboard()
  16. </script>
  17. <template>
  18. <FormKit
  19. type="text"
  20. :model-value="value"
  21. :label="label"
  22. :label-placeholder="labelPlaceholder"
  23. :help="help"
  24. readonly
  25. >
  26. <template #link="context">
  27. <div class="mb-0.5 ms-2 flex h-full items-center">
  28. <CommonButton
  29. prefix-icon="files"
  30. size="medium"
  31. :aria-describedby="context.id"
  32. @click="copyToClipboard(value)"
  33. >{{ $t(copyButtonText) }}</CommonButton
  34. >
  35. </div>
  36. </template>
  37. </FormKit>
  38. </template>