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

@@ -28,7 +28,7 @@
class="inline-flex w-full"
>
<slot :open="open" :disabled="disabled" :loading="loading">
<button :id="id" :class="selectClass" :disabled="disabled || loading" type="button" v-bind="attrs">
<button :id="inputId" :class="selectClass" :disabled="disabled || loading" type="button" v-bind="attrs">
<span v-if="(isLeading && leadingIconName) || $slots.leading" :class="leadingWrapperIconClass">
<slot name="leading" :disabled="disabled" :loading="loading">
<UIcon :name="leadingIconName" :class="leadingIconClass" />
@@ -254,7 +254,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)
}
@@ -314,10 +314,7 @@ export default defineComponent({
const popper = computed<PopperOptions>(() => defu({}, props.popper, uiMenu.value.popper as PopperOptions))
const [trigger, container] = usePopper(popper.value)
const { emitFormBlur, emitFormChange, 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, emitFormChange, inputId, color, size, name } = useFormGroup(props, config)
const query = ref('')
const searchInput = ref<ComponentPublicInstance<HTMLElement>>()
@@ -446,7 +443,8 @@ export default defineComponent({
uiMenu,
attrs,
// eslint-disable-next-line vue/no-dupe-keys
id,
name,
inputId,
trigger,
container,
isLeading,