mirror of https://github.com/nocodb/nocodb
43 lines
922 B
43 lines
922 B
2 years ago
|
<script lang="ts" setup>
|
||
2 years ago
|
import type { VNodeRef } from '@vue/runtime-core'
|
||
2 years ago
|
import { inject, useVModel } from '#imports'
|
||
|
import { EditModeInj } from '~/context'
|
||
2 years ago
|
|
||
|
interface Props {
|
||
2 years ago
|
modelValue: number | null | string | undefined
|
||
2 years ago
|
}
|
||
|
|
||
|
interface Emits {
|
||
|
(event: 'update:modelValue', model: number): void
|
||
|
}
|
||
|
|
||
|
const props = defineProps<Props>()
|
||
|
|
||
|
const emits = defineEmits<Emits>()
|
||
|
|
||
2 years ago
|
const editEnabled = inject(EditModeInj)
|
||
2 years ago
|
|
||
|
const vModel = useVModel(props, 'modelValue', emits)
|
||
|
|
||
2 years ago
|
const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
|
||
2 years ago
|
</script>
|
||
|
|
||
|
<template>
|
||
|
<input
|
||
|
v-if="editEnabled"
|
||
2 years ago
|
:ref="focus"
|
||
2 years ago
|
v-model="vModel"
|
||
2 years ago
|
class="outline-none p-0 border-none w-full h-full prose-sm"
|
||
2 years ago
|
type="number"
|
||
|
step="0.1"
|
||
2 years ago
|
@blur="editEnabled = false"
|
||
2 years ago
|
/>
|
||
|
<span v-else class="prose-sm">{{ vModel }}</span>
|
||
|
</template>
|
||
|
|
||
|
<style scoped lang="scss">
|
||
|
input[type='number']:focus {
|
||
|
@apply ring-transparent;
|
||
|
}
|
||
|
</style>
|