mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-20 15:01:46 +01:00
Merge branch 'v3' into pr/1945
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user