|
|
@ -1,15 +1,24 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
import { computed } from '#imports' |
|
|
|
import { computed } from '#imports' |
|
|
|
|
|
|
|
|
|
|
|
import { isEmail } from '~/utils/validation' |
|
|
|
import { isEmail } from '~/utils/validation' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { modelValue: value } = defineProps<Props>() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['update:modelValue']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const editEnabled = inject<boolean>('editEnabled') |
|
|
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
interface Props { |
|
|
|
modelValue: string |
|
|
|
modelValue: string |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const { modelValue } = defineProps<Props>() |
|
|
|
const root = ref<HTMLInputElement>() |
|
|
|
|
|
|
|
const localState = computed({ |
|
|
|
|
|
|
|
get: () => value, |
|
|
|
|
|
|
|
set: (val) => emit('update:modelValue', val), |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const validEmail = computed(() => isEmail(modelValue)) |
|
|
|
const validEmail = computed(() => isEmail(value)) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
|
<script lang="ts"> |
|
|
@ -19,6 +28,14 @@ export default { |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<a v-if="validEmail" :href="`mailto:${modelValue}`" target="_blank">{{ modelValue }}</a> |
|
|
|
<input v-if="editEnabled" ref="root" v-model="localState" /> |
|
|
|
<span v-else>{{ modelValue }}</span> |
|
|
|
<a |
|
|
|
|
|
|
|
v-else-if="validEmail" |
|
|
|
|
|
|
|
class="caption py-2 text-primary underline hover:opacity-75" |
|
|
|
|
|
|
|
:href="`mailto:${value}`" |
|
|
|
|
|
|
|
target="_blank" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{{ value }} |
|
|
|
|
|
|
|
</a> |
|
|
|
|
|
|
|
<span v-else>{{ value }}</span> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|