@@ -67,59 +67,57 @@ function collectOptionValues(children: unknown): PicklistValue[] {
6767function findSelectedItemLabel (
6868 children : unknown ,
6969 selectedValue : PicklistValue
70- ) : React . ReactNode | null {
71- return (
72- React . Children . map ( children , ( child ) => {
73- if ( ! React . isValidElement ( child ) ) {
74- return null ;
75- }
70+ ) : React . ReactNode {
71+ return React . Children . map ( children , ( child ) => {
72+ if ( ! React . isValidElement ( child ) ) {
73+ return null ;
74+ }
7675
77- const props = child . props ;
78- const isPropsObject = typeof props === 'object' && props !== null ;
76+ const props = child . props ;
77+ const isPropsObject = typeof props === 'object' && props !== null ;
7978
80- if ( ! isPropsObject ) {
81- return null ;
82- }
79+ if ( ! isPropsObject ) {
80+ return null ;
81+ }
8382
84- // Recursively check children for nested PicklistItems
85- if ( child . type !== PicklistItem ) {
86- return ! ( 'children' in props )
87- ? null
88- : findSelectedItemLabel ( props . children , selectedValue ) ;
89- }
83+ // Recursively check children for nested PicklistItems
84+ if ( child . type !== PicklistItem ) {
85+ return ! ( 'children' in props )
86+ ? null
87+ : findSelectedItemLabel ( props . children , selectedValue ) ;
88+ }
9089
91- // Check if this is specifically a PicklistItem component
92- if ( ! ( 'value' in props ) || props . value !== selectedValue ) {
93- return null ;
94- }
90+ // Check if this is specifically a PicklistItem component
91+ if ( ! ( 'value' in props ) || props . value !== selectedValue ) {
92+ return null ;
93+ }
9594
96- // Skip disabled items
97- if ( 'disabled' in props && props . disabled === true ) {
98- return null ;
99- }
95+ // Skip disabled items
96+ if ( 'disabled' in props && props . disabled === true ) {
97+ return null ;
98+ }
10099
101- // Safely access label and children properties with proper type checking
102- const label = 'label' in props ? props . label : undefined ;
103- const itemChildren = 'children' in props ? props . children : undefined ;
104-
105- // Simple type check for React.ReactNode values
106- const labelValue =
107- typeof label === 'string' ||
108- typeof label === 'number' ||
109- React . isValidElement ( label )
110- ? label
111- : undefined ;
112- const childrenValue =
113- typeof itemChildren === 'string' ||
114- typeof itemChildren === 'number' ||
115- React . isValidElement ( itemChildren ) ||
116- Array . isArray ( itemChildren )
117- ? itemChildren
118- : undefined ;
119-
120- return labelValue || childrenValue ;
121- } ) . find ( ( result ) => result !== null ) ?? null
122- ) ;
100+ // Safely access label and children properties with proper type checking
101+ const label = 'label' in props ? props . label : undefined ;
102+ const itemChildren = 'children' in props ? props . children : undefined ;
103+
104+ // Simple type check for React.ReactNode values
105+ const labelValue =
106+ typeof label === 'string' ||
107+ typeof label === 'number' ||
108+ React . isValidElement ( label )
109+ ? label
110+ : undefined ;
111+ const childrenValue =
112+ typeof itemChildren === 'string' ||
113+ typeof itemChildren === 'number' ||
114+ React . isValidElement ( itemChildren ) ||
115+ Array . isArray ( itemChildren )
116+ ? itemChildren
117+ : undefined ;
118+
119+ return labelValue || childrenValue ;
120+ } ) ;
123121}
124122
125123/**
0 commit comments