Merge branch 'v3' into pr/1945

This commit is contained in:
Benjamin Canac
2025-07-17 10:56:15 +02:00
11 changed files with 104 additions and 68 deletions

View File

@@ -121,7 +121,7 @@ provide(formFieldInjectionKey, computed(() => ({
{{ error }}
</slot>
</div>
<div v-else-if="help || !!slots.help" :class="ui.help({ class: props.ui?.help })">
<div v-else-if="help || !!slots.help" :id="`${ariaId}-help`" :class="ui.help({ class: props.ui?.help })">
<slot name="help" :help="help">
{{ help }}
</slot>

View File

@@ -128,15 +128,16 @@ export interface InputMenuProps<T extends ArrayOrNested<InputMenuItem> = ArrayOr
}
export type InputMenuEmits<A extends ArrayOrNested<InputMenuItem>, VK extends GetItemKeys<A> | undefined, M extends boolean> = Pick<ComboboxRootEmits, 'update:open'> & {
change: [payload: Event]
blur: [payload: FocusEvent]
focus: [payload: FocusEvent]
create: [item: string]
'change': [payload: Event]
'blur': [payload: FocusEvent]
'focus': [payload: FocusEvent]
'create': [item: string]
/** Event handler when highlighted element changes. */
highlight: [payload: {
'highlight': [payload: {
ref: HTMLElement
value: GetModelValue<A, VK, M>
} | undefined]
'remove-tag': [item: GetModelValue<A, VK, M>]
} & GetModelValueEmits<A, VK, M>
type SlotProps<T extends InputMenuItem> = (props: { item: T, index: number }) => any
@@ -366,6 +367,7 @@ function onRemoveTag(event: any) {
const modelValue = props.modelValue as GetModelValue<T, VK, true>
const filteredValue = modelValue.filter(value => !isEqual(value, event))
emits('update:modelValue', filteredValue as GetModelValue<T, VK, M>)
emits('remove-tag', event)
onUpdate(filteredValue)
}
}

View File

@@ -70,7 +70,9 @@ export type RadioGroupEmits = RadioGroupRootEmits & {
change: [payload: Event]
}
type SlotProps<T extends RadioGroupItem> = (props: { item: T & { id: string }, modelValue?: RadioGroupValue }) => any
type NormalizeItem<T extends RadioGroupItem> = Exclude<T & { id: string }, RadioGroupValue>
type SlotProps<T extends RadioGroupItem> = (props: { item: NormalizeItem<T>, modelValue?: RadioGroupValue }) => any
export interface RadioGroupSlots<T extends RadioGroupItem = RadioGroupItem> {
legend(props?: {}): any
@@ -114,21 +116,21 @@ const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.radioGroup |
indicator: props.indicator
}))
function normalizeItem(item: any) {
function normalizeItem(item: T): NormalizeItem<T> {
if (item === null) {
return {
id: `${id}:null`,
value: undefined,
label: undefined
}
} as NormalizeItem<T>
}
if (typeof item === 'string' || typeof item === 'number') {
if (typeof item === 'string' || typeof item === 'number' || typeof item === 'bigint') {
return {
id: `${id}:${item}`,
value: String(item),
label: String(item)
}
} as NormalizeItem<T>
}
const value = get(item, props.valueKey as string)
@@ -136,7 +138,7 @@ function normalizeItem(item: any) {
const description = get(item, props.descriptionKey as string)
return {
...item,
...(item as NormalizeItem<T>),
value,
label,
description,

View File

@@ -89,10 +89,15 @@ export function useFormField<T>(props?: Props<T>, opts?: { bind?: boolean, defer
.filter(type => formField?.value?.[type])
.map(type => `${formField?.value.ariaId}-${type}`) || []
return {
'aria-describedby': descriptiveAttrs.join(' '),
const attrs: Record<string, any> = {
'aria-invalid': !!formField?.value.error
}
if (descriptiveAttrs.length > 0) {
attrs['aria-describedby'] = descriptiveAttrs.join(' ')
}
return attrs
})
}
}