chore(FormGroup): simplify bindings between input and form group p… (#704)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Romain Hamel
2023-09-21 23:22:55 +02:00
committed by GitHub
parent a94782d94b
commit 46879dc1b7
14 changed files with 81 additions and 65 deletions

View File

@@ -1,7 +1,7 @@
<template>
<div :class="ui.wrapper">
<input
:id="id"
:id="inputId"
ref="input"
:name="name"
:value="modelValue"
@@ -119,7 +119,7 @@ export default defineComponent({
},
size: {
type: String as PropType<keyof typeof config.size>,
default: () => config.default.size,
default: null,
validator (value: string) {
return Object.keys(config.size).includes(value)
}
@@ -154,10 +154,7 @@ export default defineComponent({
setup (props, { emit, slots }) {
const { ui, attrs } = useUI('input', props.ui, config, { mergeWrapper: true })
const { emitFormBlur, emitFormInput, formGroup } = useFormGroup(props)
const color = computed(() => formGroup?.error?.value ? 'red' : props.color)
const size = computed(() => formGroup?.size?.value ?? props.size)
const id = formGroup?.labelFor
const { emitFormBlur, emitFormInput, size, color, inputId, name } = useFormGroup(props, config)
const input = ref<HTMLInputElement | null>(null)
@@ -261,7 +258,8 @@ export default defineComponent({
ui,
attrs,
// eslint-disable-next-line vue/no-dupe-keys
id,
name,
inputId,
input,
isLeading,
isTrailing,