@@ -65,6 +65,12 @@ interface PrimaryActionsProps< Item > {
65
65
actions : Action < Item > [ ] ;
66
66
registry : ReturnType < typeof useRegistry > ;
67
67
}
68
+ interface ActionsListProps < Item > {
69
+ item : Item ;
70
+ actions : Action < Item > [ ] ;
71
+ registry : ReturnType < typeof useRegistry > ;
72
+ ActionTrigger : ( props : ActionTriggerProps < Item > ) => ReactElement ;
73
+ }
68
74
69
75
function ButtonTrigger < Item > ( {
70
76
action,
@@ -160,28 +166,12 @@ export function ActionsMenuGroup< Item >( {
160
166
const registry = useRegistry ( ) ;
161
167
return (
162
168
< Menu . Group >
163
- { actions . map ( ( action ) => {
164
- if ( 'RenderModal' in action ) {
165
- return (
166
- < ActionWithModal
167
- key = { action . id }
168
- action = { action }
169
- items = { [ item ] }
170
- ActionTrigger = { MenuItemTrigger }
171
- />
172
- ) ;
173
- }
174
- return (
175
- < MenuItemTrigger
176
- key = { action . id }
177
- action = { action }
178
- onClick = { ( ) => {
179
- action . callback ( [ item ] , { registry } ) ;
180
- } }
181
- items = { [ item ] }
182
- />
183
- ) ;
184
- } ) }
169
+ < ActionsList
170
+ actions = { actions }
171
+ item = { item }
172
+ registry = { registry }
173
+ ActionTrigger = { MenuItemTrigger }
174
+ />
185
175
</ Menu . Group >
186
176
) ;
187
177
}
@@ -286,20 +276,35 @@ function PrimaryActions< Item >( {
286
276
if ( ! Array . isArray ( actions ) || actions . length === 0 ) {
287
277
return null ;
288
278
}
279
+ return (
280
+ < ActionsList
281
+ actions = { actions }
282
+ item = { item }
283
+ registry = { registry }
284
+ ActionTrigger = { ButtonTrigger }
285
+ />
286
+ ) ;
287
+ }
289
288
289
+ function ActionsList < Item > ( {
290
+ item,
291
+ actions,
292
+ registry,
293
+ ActionTrigger,
294
+ } : ActionsListProps < Item > ) {
290
295
return actions . map ( ( action ) => {
291
296
if ( 'RenderModal' in action ) {
292
297
return (
293
298
< ActionWithModal
294
299
key = { action . id }
295
300
action = { action }
296
301
items = { [ item ] }
297
- ActionTrigger = { ButtonTrigger }
302
+ ActionTrigger = { ActionTrigger }
298
303
/>
299
304
) ;
300
305
}
301
306
return (
302
- < ButtonTrigger
307
+ < ActionTrigger
303
308
key = { action . id }
304
309
action = { action }
305
310
onClick = { ( ) => {
0 commit comments