mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-19 06:21:46 +01:00
chore(FormGroup): simplify bindings between input and form group p… (#704)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user