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