@@ -23,8 +23,27 @@ export interface MenuListProps<
23
23
headerIcon ?: HI | undefined ;
24
24
headerAction ?: string | React . ReactElement | undefined ;
25
25
items ?: MenuItem < V , I > [ ] | undefined ;
26
- headerProps ?: FlexAllProps < 'div' > | undefined ;
27
- listProps ?: FlexAllProps < 'div' > | undefined ;
26
+ headerProps ?:
27
+ | FlexAllProps <
28
+ React . ComponentType <
29
+ React . DetailedHTMLProps < React . HTMLAttributes < HTMLDivElement > , HTMLDivElement >
30
+ >
31
+ >
32
+ | undefined ;
33
+ headerGroupProps ?:
34
+ | FlexAllProps <
35
+ React . ComponentType <
36
+ React . DetailedHTMLProps < React . HTMLAttributes < HTMLDivElement > , HTMLDivElement >
37
+ >
38
+ >
39
+ | undefined ;
40
+ listProps ?:
41
+ | FlexAllProps <
42
+ React . ComponentType <
43
+ React . DetailedHTMLProps < React . HTMLAttributes < HTMLDivElement > , HTMLDivElement >
44
+ >
45
+ >
46
+ | undefined ;
28
47
onItemSelect ?: MenuListItemProps < V , I > [ 'onSelect' ] | undefined ;
29
48
onItemMouseEnter ?:
30
49
| ( ( value : MenuListItemProps < V , I > [ 'value' ] , event : React . MouseEvent < HTMLDivElement > ) => void )
@@ -72,16 +91,12 @@ const HeaderRoot = styled((props: React.PropsWithChildren<FlexComponentProps>) =
72
91
...rc ?. MenuList ?. header ?. root ,
73
92
} ) ) ;
74
93
75
- const HeaderTitleContainer = styled ( ( props : React . PropsWithChildren < FlexComponentProps < 'div' > > ) => {
76
- return < Flex grow alignItems = "center" { ...props } /> ;
77
- } ) ( ( { theme : { rc } , onClick } ) => ( {
94
+ const HeaderGroup = styled ( Flex ) ( ( { theme : { rc } , onClick } ) => ( {
78
95
cursor : onClick ? 'pointer' : undefined ,
79
- ...rc ?. MenuList ?. header ?. root ,
96
+ ...rc ?. MenuList ?. header ?. group ?. root ,
80
97
} ) ) ;
81
98
82
- const HeaderTitle = styled ( ( props : React . PropsWithChildren < FlexComponentProps > ) => {
83
- return < Flex { ...props } /> ;
84
- } ) ( ( { theme : { rc } } ) => ( {
99
+ const HeaderTitle = styled ( Flex ) ( ( { theme : { rc } } ) => ( {
85
100
fontWeight : 500 ,
86
101
...rc ?. MenuList ?. header ?. title ?. root ,
87
102
} ) ) ;
@@ -97,6 +112,7 @@ export default function MenuList<
97
112
onClose,
98
113
items,
99
114
headerProps,
115
+ headerGroupProps,
100
116
listProps,
101
117
onItemSelect,
102
118
onItemMouseEnter,
@@ -139,9 +155,16 @@ export default function MenuList<
139
155
140
156
const hasHeader = ! ! ( header || headerIconProps || onBack || headerAction || onClose ) ;
141
157
158
+ const hasHeaderIcon = ! ! backIconProps || ! ! headerIconProps ;
159
+
160
+ const headerGroupFlex =
161
+ typeof theme ?. header ?. group ?. flex === 'function'
162
+ ? theme . header . group . flex ( { hasIcon : hasHeaderIcon } )
163
+ : theme ?. header ?. group ?. flex ;
164
+
142
165
const headerTitleFlex =
143
166
typeof theme ?. header ?. title ?. flex === 'function'
144
- ? theme . header . title . flex ( { hasIcon : ! ! backIconProps || ! ! headerIconProps } )
167
+ ? theme . header . title . flex ( { hasIcon : hasHeaderIcon } )
145
168
: theme ?. header ?. title ?. flex ;
146
169
147
170
const listContainerFlex =
@@ -198,7 +221,13 @@ export default function MenuList<
198
221
< Root onKeyDown = { keyDownHandler } { ...rest } >
199
222
{ hasHeader && (
200
223
< HeaderRoot py = "xs" pl = "s" pr { ...theme ?. header ?. flex } { ...headerProps } >
201
- < HeaderTitleContainer grow alignItems = "center" onClick = { onBack ? backHandler : undefined } >
224
+ < HeaderGroup
225
+ grow
226
+ alignItems = "center"
227
+ onClick = { onBack ? backHandler : undefined }
228
+ { ...headerGroupFlex }
229
+ { ...headerGroupProps }
230
+ >
202
231
{ ! ! backIconProps && < SvgSpriteIcon size = "1.5em" { ...backIconProps } /> }
203
232
{ ! ! headerIconProps && < SvgSpriteIcon { ...headerIconProps } /> }
204
233
@@ -210,7 +239,7 @@ export default function MenuList<
210
239
>
211
240
{ header }
212
241
</ HeaderTitle >
213
- </ HeaderTitleContainer >
242
+ </ HeaderGroup >
214
243
215
244
{ headerActionElement }
216
245
0 commit comments