From 1ca0015e07dcc5df1563e1d72be6575ae4ced009 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Tue, 19 Mar 2024 18:03:59 -0500 Subject: [PATCH] Support passing `NormalizedPickerItem[]` to Picker (#1858) --- .../components/src/spectrum/picker/Picker.tsx | 66 +++++++++++-------- .../src/spectrum/picker/PickerUtils.ts | 44 ++++++++++--- 2 files changed, 74 insertions(+), 36 deletions(-) diff --git a/packages/components/src/spectrum/picker/Picker.tsx b/packages/components/src/spectrum/picker/Picker.tsx index 30702010a..b81601873 100644 --- a/packages/components/src/spectrum/picker/Picker.tsx +++ b/packages/components/src/spectrum/picker/Picker.tsx @@ -17,7 +17,10 @@ import { PickerItemContent } from './PickerItemContent'; import { Item, Section } from '../shared'; export type PickerProps = { - children: PickerItemOrSection | PickerItemOrSection[]; + children: + | PickerItemOrSection + | PickerItemOrSection[] + | NormalizedPickerItem[]; /** Can be set to true or a TooltipOptions to enable item tooltips */ tooltip?: boolean | TooltipOptions; /** The currently selected key in the collection (controlled). */ @@ -99,31 +102,38 @@ export function Picker({ ); const renderItem = useCallback( - ({ key, item }: NormalizedPickerItem) => ( - // The `textValue` prop gets used to provide the content of `