|
|
@ -8,11 +8,14 @@ interface Props { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const { modelValue: value } = defineProps<Props>() |
|
|
|
const { modelValue: value } = defineProps<Props>() |
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['update:modelValue']) |
|
|
|
const emit = defineEmits(['update:modelValue']) |
|
|
|
|
|
|
|
|
|
|
|
const column = inject(ColumnInj) |
|
|
|
const column = inject(ColumnInj) |
|
|
|
|
|
|
|
|
|
|
|
const editEnabled = inject<boolean>('editEnabled') |
|
|
|
const editEnabled = inject<boolean>('editEnabled') |
|
|
|
|
|
|
|
|
|
|
|
const localState = computed({ |
|
|
|
const vModel = computed({ |
|
|
|
get: () => value, |
|
|
|
get: () => value, |
|
|
|
set: (val) => { |
|
|
|
set: (val) => { |
|
|
|
if (!(column && column.meta && column.meta.validate) || isValidURL(val)) { |
|
|
|
if (!(column && column.meta && column.meta.validate) || isValidURL(val)) { |
|
|
@ -24,19 +27,16 @@ const localState = computed({ |
|
|
|
const isValid = computed(() => value && isValidURL(value)) |
|
|
|
const isValid = computed(() => value && isValidURL(value)) |
|
|
|
|
|
|
|
|
|
|
|
const root = ref<HTMLInputElement>() |
|
|
|
const root = ref<HTMLInputElement>() |
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
onMounted(() => { |
|
|
|
root.value?.focus() |
|
|
|
root.value?.focus() |
|
|
|
}) |
|
|
|
}) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<span v-if="editEnabled"> |
|
|
|
<input v-if="editEnabled" ref="root" v-model="vModel" class="outline-none" /> |
|
|
|
<input ref="root" v-model="localState" /> |
|
|
|
<nuxt-link v-else-if="isValid" class="py-2 underline hover:opacity-75" :to="value" target="_blank">{{ value }}</nuxt-link> |
|
|
|
</span> |
|
|
|
|
|
|
|
<span v-else> |
|
|
|
|
|
|
|
<a v-if="isValid" class="caption py-2 text-primary underline hover:opacity-75" :href="value" target="_blank">{{ value }}</a> |
|
|
|
|
|
|
|
<span v-else>{{ value }}</span> |
|
|
|
<span v-else>{{ value }}</span> |
|
|
|
</span> |
|
|
|
|
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<style scoped></style> |
|
|
|
<style scoped></style> |
|
|
|