mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
feat(RadioGroup): add selected to label slot props (#1587)
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
@change="onUpdate(option.value)"
|
||||
>
|
||||
<template #label>
|
||||
<slot name="label" v-bind="{ option }" />
|
||||
<slot name="label" v-bind="{ option, selected: option.selected }" />
|
||||
</template>
|
||||
</URadio>
|
||||
</fieldset>
|
||||
@@ -117,6 +117,10 @@ export default defineComponent({
|
||||
return get(option, props.optionAttribute, get(option, props.valueAttribute))
|
||||
}
|
||||
|
||||
const guessOptionSelected = (option: any) => {
|
||||
return props.modelValue === guessOptionValue(option)
|
||||
}
|
||||
|
||||
const normalizeOption = (option: any) => {
|
||||
if (['string', 'number', 'boolean'].includes(typeof option)) {
|
||||
return {
|
||||
@@ -128,7 +132,8 @@ export default defineComponent({
|
||||
return {
|
||||
...option,
|
||||
value: guessOptionValue(option),
|
||||
label: guessOptionText(option)
|
||||
label: guessOptionText(option),
|
||||
selected: guessOptionSelected(option)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user