mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-30 03:38:54 +01:00
chore(Input/InputNumber/PinInput/Textarea): clean functions order
This commit is contained in:
@@ -104,12 +104,6 @@ const ui = computed(() => input({
|
|||||||
|
|
||||||
const inputRef = ref<HTMLInputElement | null>(null)
|
const inputRef = ref<HTMLInputElement | null>(null)
|
||||||
|
|
||||||
function autoFocus() {
|
|
||||||
if (props.autofocus) {
|
|
||||||
inputRef.value?.focus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom function to handle the v-model properties
|
// Custom function to handle the v-model properties
|
||||||
function updateInput(value: string | null) {
|
function updateInput(value: string | null) {
|
||||||
if (modelModifiers.trim) {
|
if (modelModifiers.trim) {
|
||||||
@@ -155,15 +149,21 @@ function onBlur(event: FocusEvent) {
|
|||||||
emits('blur', event)
|
emits('blur', event)
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
function autoFocus() {
|
||||||
inputRef
|
if (props.autofocus) {
|
||||||
})
|
inputRef.value?.focus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
autoFocus()
|
autoFocus()
|
||||||
}, props.autofocusDelay)
|
}, props.autofocusDelay)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
inputRef
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -115,18 +115,6 @@ const decrementIcon = computed(() => props.decrementIcon || (props.orientation =
|
|||||||
|
|
||||||
const inputRef = ref<InstanceType<typeof NumberFieldInput> | null>(null)
|
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) {
|
function onUpdate(value: number) {
|
||||||
// @ts-expect-error - 'target' does not exist in type 'EventInit'
|
// @ts-expect-error - 'target' does not exist in type 'EventInit'
|
||||||
const event = new Event('change', { target: { value } })
|
const event = new Event('change', { target: { value } })
|
||||||
@@ -141,6 +129,18 @@ function onBlur(event: FocusEvent) {
|
|||||||
emits('blur', event)
|
emits('blur', event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function autoFocus() {
|
||||||
|
if (props.autofocus) {
|
||||||
|
inputRef.value?.$el?.focus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
autoFocus()
|
||||||
|
}, props.autofocusDelay)
|
||||||
|
})
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
inputRef
|
inputRef
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -78,12 +78,6 @@ const ui = computed(() => pinInput({
|
|||||||
|
|
||||||
const inputsRef = ref<ComponentPublicInstance[]>([])
|
const inputsRef = ref<ComponentPublicInstance[]>([])
|
||||||
|
|
||||||
function autoFocus() {
|
|
||||||
if (props.autofocus) {
|
|
||||||
inputsRef.value[0]?.$el?.focus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const completed = ref(false)
|
const completed = ref(false)
|
||||||
function onComplete(value: string[]) {
|
function onComplete(value: string[]) {
|
||||||
// @ts-expect-error - 'target' does not exist in type 'EventInit'
|
// @ts-expect-error - 'target' does not exist in type 'EventInit'
|
||||||
@@ -99,15 +93,21 @@ function onBlur(event: FocusEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
function autoFocus() {
|
||||||
inputsRef
|
if (props.autofocus) {
|
||||||
})
|
inputsRef.value[0]?.$el?.focus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
autoFocus()
|
autoFocus()
|
||||||
}, props.autofocusDelay)
|
}, props.autofocusDelay)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
inputsRef
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -87,12 +87,6 @@ const ui = computed(() => textarea({
|
|||||||
|
|
||||||
const textareaRef = ref<HTMLTextAreaElement | null>(null)
|
const textareaRef = ref<HTMLTextAreaElement | null>(null)
|
||||||
|
|
||||||
function autoFocus() {
|
|
||||||
if (props.autofocus) {
|
|
||||||
textareaRef.value?.focus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom function to handle the v-model properties
|
// Custom function to handle the v-model properties
|
||||||
function updateInput(value: string | null) {
|
function updateInput(value: string | null) {
|
||||||
if (modelModifiers.trim) {
|
if (modelModifiers.trim) {
|
||||||
@@ -140,18 +134,14 @@ function onBlur(event: FocusEvent) {
|
|||||||
emits('blur', event)
|
emits('blur', event)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
function autoFocus() {
|
||||||
setTimeout(() => {
|
if (props.autofocus) {
|
||||||
autoFocus()
|
textareaRef.value?.focus()
|
||||||
}, props.autofocusDelay)
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
function autoResize() {
|
function autoResize() {
|
||||||
if (props.autoresize) {
|
if (props.autoresize && textareaRef.value) {
|
||||||
if (!textareaRef.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
textareaRef.value.rows = props.rows
|
textareaRef.value.rows = props.rows
|
||||||
const overflow = textareaRef.value.style.overflow
|
const overflow = textareaRef.value.style.overflow
|
||||||
textareaRef.value.style.overflow = 'hidden'
|
textareaRef.value.style.overflow = 'hidden'
|
||||||
@@ -176,15 +166,19 @@ watch(modelValue, () => {
|
|||||||
nextTick(autoResize)
|
nextTick(autoResize)
|
||||||
})
|
})
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
textareaRef
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
autoFocus()
|
||||||
|
}, props.autofocusDelay)
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
autoResize()
|
autoResize()
|
||||||
}, 100)
|
}, 100)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
textareaRef
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
Reference in New Issue
Block a user