chore(Input/InputNumber/PinInput/Textarea): clean functions order

This commit is contained in:
Benjamin Canac
2025-04-01 12:05:57 +02:00
parent ce767c8429
commit 4d8179ba08
4 changed files with 44 additions and 50 deletions

View File

@@ -104,12 +104,6 @@ const ui = computed(() => input({
const inputRef = ref<HTMLInputElement | null>(null)
function autoFocus() {
if (props.autofocus) {
inputRef.value?.focus()
}
}
// Custom function to handle the v-model properties
function updateInput(value: string | null) {
if (modelModifiers.trim) {
@@ -155,15 +149,21 @@ function onBlur(event: FocusEvent) {
emits('blur', event)
}
defineExpose({
inputRef
})
function autoFocus() {
if (props.autofocus) {
inputRef.value?.focus()
}
}
onMounted(() => {
setTimeout(() => {
autoFocus()
}, props.autofocusDelay)
})
defineExpose({
inputRef
})
</script>
<template>

View File

@@ -115,18 +115,6 @@ const decrementIcon = computed(() => props.decrementIcon || (props.orientation =
const inputRef = ref<InstanceType<typeof NumberFieldInput> | null>(null)
function autoFocus() {
if (props.autofocus) {
inputRef.value?.$el?.focus()
}
}
onMounted(() => {
setTimeout(() => {
autoFocus()
}, props.autofocusDelay)
})
function onUpdate(value: number) {
// @ts-expect-error - 'target' does not exist in type 'EventInit'
const event = new Event('change', { target: { value } })
@@ -141,6 +129,18 @@ function onBlur(event: FocusEvent) {
emits('blur', event)
}
function autoFocus() {
if (props.autofocus) {
inputRef.value?.$el?.focus()
}
}
onMounted(() => {
setTimeout(() => {
autoFocus()
}, props.autofocusDelay)
})
defineExpose({
inputRef
})

View File

@@ -78,12 +78,6 @@ const ui = computed(() => pinInput({
const inputsRef = ref<ComponentPublicInstance[]>([])
function autoFocus() {
if (props.autofocus) {
inputsRef.value[0]?.$el?.focus()
}
}
const completed = ref(false)
function onComplete(value: string[]) {
// @ts-expect-error - 'target' does not exist in type 'EventInit'
@@ -99,15 +93,21 @@ function onBlur(event: FocusEvent) {
}
}
defineExpose({
inputsRef
})
function autoFocus() {
if (props.autofocus) {
inputsRef.value[0]?.$el?.focus()
}
}
onMounted(() => {
setTimeout(() => {
autoFocus()
}, props.autofocusDelay)
})
defineExpose({
inputsRef
})
</script>
<template>

View File

@@ -87,12 +87,6 @@ const ui = computed(() => textarea({
const textareaRef = ref<HTMLTextAreaElement | null>(null)
function autoFocus() {
if (props.autofocus) {
textareaRef.value?.focus()
}
}
// Custom function to handle the v-model properties
function updateInput(value: string | null) {
if (modelModifiers.trim) {
@@ -140,18 +134,14 @@ function onBlur(event: FocusEvent) {
emits('blur', event)
}
onMounted(() => {
setTimeout(() => {
autoFocus()
}, props.autofocusDelay)
})
function autoFocus() {
if (props.autofocus) {
textareaRef.value?.focus()
}
}
function autoResize() {
if (props.autoresize) {
if (!textareaRef.value) {
return
}
if (props.autoresize && textareaRef.value) {
textareaRef.value.rows = props.rows
const overflow = textareaRef.value.style.overflow
textareaRef.value.style.overflow = 'hidden'
@@ -176,15 +166,19 @@ watch(modelValue, () => {
nextTick(autoResize)
})
defineExpose({
textareaRef
})
onMounted(() => {
setTimeout(() => {
autoFocus()
}, props.autofocusDelay)
setTimeout(() => {
autoResize()
}, 100)
})
defineExpose({
textareaRef
})
</script>
<template>