Skip to content

Commit

Permalink
feat(input): add min max values on model
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaubree committed Jan 16, 2024
1 parent b58f966 commit 5514d5b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/input/UInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,20 @@ function autoFocus() {
input.value?.focus()
}
function onInput(event: Event) {
modelValue.value = (event.target as HTMLInputElement).value
if (props.type === 'number') {
if (attrs.min && event < attrs.min) {
modelValue.value = Number(attrs.min)
return
}
if (attrs.max && event > attrs.max) {
modelValue.value = Number(attrs.max)
return
}
modelValue.value = (event.target as HTMLInputElement).value
}
else {
modelValue.value = (event.target as HTMLInputElement).value
}
}
onMounted(() => {
Expand Down

0 comments on commit 5514d5b

Please # to comment.