|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
|
import { EditModeInj, inject, useVModel } from '#imports' |
|
|
|
|
import { VNodeRef } from '@vue/runtime-core' |
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
|
modelValue?: number | string | null |
|
|
|
@ -12,15 +13,21 @@ const emits = defineEmits(['update:modelValue'])
|
|
|
|
|
const editEnabled = inject(EditModeInj) |
|
|
|
|
|
|
|
|
|
const vModel = useVModel(props, 'modelValue', emits) |
|
|
|
|
|
|
|
|
|
const focus: VNodeRef = (el) => { |
|
|
|
|
;(el as HTMLInputElement)?.focus() |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
|
<input |
|
|
|
|
:ref="focus" |
|
|
|
|
v-if="editEnabled" |
|
|
|
|
v-model="vModel" |
|
|
|
|
class="w-full !border-none text-base" |
|
|
|
|
:class="{ '!px-2': editEnabled }" |
|
|
|
|
type="number" |
|
|
|
|
@blur="editEnabled = false" |
|
|
|
|
@keydown.down.stop |
|
|
|
|
@keydown.left.stop |
|
|
|
|
@keydown.right.stop |
|
|
|
|