@@ -16,37 +16,43 @@ interface StylingProps {
16
16
labelStyle ?: React . CSSProperties ;
17
17
}
18
18
19
- interface OptionProps extends StylingProps {
20
- index : number ;
21
- option : DetailedOption ;
22
- isSelected : boolean ;
23
- onChange : ( option : DetailedOption ) => void ;
19
+ interface OptionLabelProps extends DetailedOption {
20
+ index : string | number ;
24
21
}
25
22
26
- export function OptionLabel (
27
- props : DetailedOption & { index : string | number }
28
- ) : JSX . Element {
23
+ export const OptionLabel : React . FC < OptionLabelProps > = ( {
24
+ index,
25
+ label,
26
+ title,
27
+ value,
28
+ } ) => {
29
29
const ctx = window . dash_component_api . useDashContext ( ) ;
30
30
const ExternalWrapper = window . dash_component_api . ExternalWrapper ;
31
31
32
- if ( typeof props . label === 'object' ) {
33
- const labels =
34
- props . label instanceof Array ? props . label : [ props . label ] ;
32
+ if ( typeof label === 'object' ) {
33
+ const labels = label instanceof Array ? label : [ label ] ;
35
34
return (
36
35
< >
37
36
{ labels . map ( ( label , i ) => (
38
37
< ExternalWrapper
39
38
key = { i }
40
39
component = { label }
41
- componentPath = { [ ...ctx . componentPath , props . index , i ] }
40
+ componentPath = { [ ...ctx . componentPath , index , i ] }
42
41
/>
43
42
) ) }
44
43
</ >
45
44
) ;
46
45
}
47
46
48
- const displayLabel = `${ props . label ?? props . value } ` ;
49
- return < span title = { props . title } > { displayLabel } </ span > ;
47
+ const displayLabel = `${ label ?? value } ` ;
48
+ return < span title = { title } > { displayLabel } </ span > ;
49
+ } ;
50
+
51
+ interface OptionProps extends StylingProps {
52
+ index : number ;
53
+ option : DetailedOption ;
54
+ isSelected : boolean ;
55
+ onChange : ( option : DetailedOption ) => void ;
50
56
}
51
57
52
58
export const Option : React . FC < OptionProps > = ( {
0 commit comments