diff --git a/src/runtime/components/InputMenu.vue b/src/runtime/components/InputMenu.vue index cb280f67..89bb42f7 100644 --- a/src/runtime/components/InputMenu.vue +++ b/src/runtime/components/InputMenu.vue @@ -80,6 +80,11 @@ export interface InputMenuProps extends Pick, 'modelValu * @defaultValue ['label'] */ filter?: boolean | string[] + /** + * When `items` is an array of objects, select the field to use as the value instead of the object itself. + * @defaultValue undefined + */ + valueKey?: keyof T items?: T[] | T[][] /** Highlight the ring color like a focus state. */ highlight?: boolean @@ -313,7 +318,7 @@ function onUpdateOpen(value: boolean) { - + diff --git a/src/runtime/components/Select.vue b/src/runtime/components/Select.vue index b61d70db..ada2661c 100644 --- a/src/runtime/components/Select.vue +++ b/src/runtime/components/Select.vue @@ -58,6 +58,11 @@ export interface SelectProps extends Omit, UseCompone * @defaultValue true */ portal?: boolean + /** + * When `items` is an array of objects, select the field to use as the value. + * @defaultValue 'value' + */ + valueKey?: string items?: T[] | T[][] /** Highlight the ring color like a focus state. */ highlight?: boolean @@ -92,6 +97,7 @@ import { useAppConfig, useComponentIcons, useFormField, useButtonGroup } from '# import { UIcon, UChip, UAvatar } from '#components' const props = withDefaults(defineProps>(), { + valueKey: 'value' as any, portal: true }) const emits = defineEmits() @@ -175,7 +181,7 @@ function onUpdateOpen(value: boolean) { {{ item.label }} - + diff --git a/src/runtime/components/SelectMenu.vue b/src/runtime/components/SelectMenu.vue index 999fe285..a731b36b 100644 --- a/src/runtime/components/SelectMenu.vue +++ b/src/runtime/components/SelectMenu.vue @@ -67,6 +67,11 @@ export interface SelectMenuProps extends Pick, 'modelVal * @defaultValue ['label'] */ filter?: boolean | string[] + /** + * When `items` is an array of objects, select the field to use as the value instead of the object itself. + * @defaultValue undefined + */ + valueKey?: keyof T items?: T[] | T[][] /** Highlight the ring color like a focus state. */ highlight?: boolean @@ -246,7 +251,7 @@ function onUpdateOpen(value: boolean) { - +