From 850e84c0e0ce11bdc90be1ae652dec6723012243 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Tue, 3 Sep 2024 12:08:40 +0200 Subject: [PATCH] feat(RadioGroup): handle `value-key` prop --- src/runtime/components/RadioGroup.vue | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/runtime/components/RadioGroup.vue b/src/runtime/components/RadioGroup.vue index 039575a6..8877fd50 100644 --- a/src/runtime/components/RadioGroup.vue +++ b/src/runtime/components/RadioGroup.vue @@ -24,6 +24,11 @@ export interface RadioGroupProps extends Pick>(), { + valueKey: 'value' as any, orientation: 'vertical' }) const emits = defineEmits() @@ -84,14 +90,20 @@ function normalizeItem(item: any) { } } + const value = item[props.valueKey] + return { ...item, - id: `${id}:${item.value}` + value, + id: `${id}:${value}` } } const normalizedItems = computed(() => { - if (!props.items) return [] + if (!props.items) { + return [] + } + return props.items.map(normalizeItem) })