File tree Expand file tree Collapse file tree 1 file changed +21
-12
lines changed Expand file tree Collapse file tree 1 file changed +21
-12
lines changed Original file line number Diff line number Diff line change 3
3
Button ,
4
4
ButtonGroup ,
5
5
ClickAwayListener ,
6
+ Divider ,
6
7
MenuItem ,
7
8
MenuList ,
8
9
Paper ,
@@ -13,6 +14,8 @@ interface Option {
13
14
icon : React . ReactNode ;
14
15
label : string ;
15
16
onClick : ( event : React . MouseEvent < HTMLLIElement , MouseEvent > , index : number ) => void ;
17
+ isDivider ?: boolean ;
18
+ show ?: boolean ;
16
19
}
17
20
18
21
interface ActionButtonProps {
@@ -68,18 +71,24 @@ export default function ActionButton({
68
71
< Paper >
69
72
< ClickAwayListener onClickAway = { handleClose } >
70
73
< MenuList id = "split-button-menu" autoFocusItem >
71
- { options . map ( ( option , index ) => (
72
- < MenuItem
73
- key = { index }
74
- onClick = { ( event ) => {
75
- handleMenuItemClick ( ) ;
76
- option . onClick ( event , index ) ;
77
- } }
78
- >
79
- < div style = { { marginRight : '1rem' } } > { option . icon } </ div >
80
- { option . label }
81
- </ MenuItem >
82
- ) ) }
74
+ { options
75
+ . filter ( ( option ) => option . show !== false )
76
+ . map ( ( option , index ) =>
77
+ option . isDivider ? (
78
+ < Divider />
79
+ ) : (
80
+ < MenuItem
81
+ key = { index }
82
+ onClick = { ( event ) => {
83
+ handleMenuItemClick ( ) ;
84
+ option . onClick ( event , index ) ;
85
+ } }
86
+ >
87
+ < div style = { { marginRight : '1rem' } } > { option . icon } </ div >
88
+ { option . label }
89
+ </ MenuItem >
90
+ )
91
+ ) }
83
92
</ MenuList >
84
93
</ ClickAwayListener >
85
94
</ Paper >
You can’t perform that action at this time.
0 commit comments