fix(ui): Input and FieldInput should support number modifer natively

This commit is contained in:
Neko Ayaka
2026-01-11 22:35:18 +08:00
parent e5a86e78ae
commit 00666852fc
2 changed files with 32 additions and 12 deletions
@@ -13,7 +13,7 @@ const props = withDefaults(defineProps<{
singleLine: true,
})
const modelValue = defineModel<string>({ required: false })
const modelValue = defineModel<string | number>({ required: false })
</script>
<template>
@@ -33,7 +33,14 @@ const modelValue = defineModel<string>({ required: false })
</div>
</div>
<Input
v-if="singleLine"
v-if="singleLine && props.type === 'number'"
v-model.number="modelValue"
:type="props.type"
:placeholder="props.placeholder"
:class="props.inputClass"
/>
<Input
v-else-if="singleLine"
v-model="modelValue"
:type="props.type"
:placeholder="props.placeholder"
+23 -10
View File
@@ -18,7 +18,7 @@ const props = withDefaults(defineProps<{
theme: 'default',
})
const modelValue = defineModel<string>({ required: false })
const modelValue = defineModel<string | number>({ required: false })
const variantClasses: Record<InputVariant, Record<InputTheme, {
default: string[]
@@ -59,13 +59,26 @@ const variantClasses: Record<InputVariant, Record<InputTheme, {
</script>
<template>
<input
v-model="modelValue"
:type="props.type || 'text'"
:class="[
'transition-all duration-200 ease-in-out',
'cursor-disabled:not-allowed',
...variantClasses[props.variant][props.theme].default,
]"
>
<template v-if="props.type === 'number'">
<input
v-model.number="modelValue"
:type="props.type || 'text'"
:class="[
'transition-all duration-200 ease-in-out',
'cursor-disabled:not-allowed',
...variantClasses[props.variant][props.theme].default,
]"
>
</template>
<template v-else>
<input
v-model="modelValue"
:type="props.type || 'text'"
:class="[
'transition-all duration-200 ease-in-out',
'cursor-disabled:not-allowed',
...variantClasses[props.variant][props.theme].default,
]"
>
</template>
</template>