11import React , { useCallback , useRef , useEffect } from 'react' ;
2- import { _cs } from '@togglecorp/fujs' ;
2+ import {
3+ _cs ,
4+ isNotDefined ,
5+ } from '@togglecorp/fujs' ;
36
47import RawButton from '../RawButton' ;
58
@@ -15,6 +18,7 @@ export interface GenericOptionParams<P extends ContentBaseProps, OK extends Opti
1518 optionContainerClassName ?: string ;
1619 contentRenderer : ( props : Pick < P , Exclude < keyof P , 'containerClassName' | 'title' > > ) => React . ReactNode ;
1720 contentRendererParam : ( key : OK , opt : O ) => P ;
21+ actionsSelector ?: ( props : O ) => React . ReactNode ;
1822 option : O ;
1923 optionKey : OK ;
2024 onClick : ( optionKey : OK , option : O ) => void ;
@@ -25,6 +29,7 @@ function GenericOption<P extends ContentBaseProps, OK extends OptionKey, O>({
2529 optionContainerClassName,
2630 contentRenderer,
2731 contentRendererParam,
32+ actionsSelector,
2833 option,
2934 onClick,
3035 onFocus,
@@ -81,23 +86,41 @@ function GenericOption<P extends ContentBaseProps, OK extends OptionKey, O>({
8186 [ ] ,
8287 ) ;
8388
89+ if ( isNotDefined ( actionsSelector ) ) {
90+ return (
91+ < RawButton
92+ elementRef = { divRef }
93+ className = { _cs ( styles . optionRenderer , containerClassName , optionContainerClassName ) }
94+ onClick = { handleClick }
95+ onMouseMove = { handleMouseMove }
96+ onMouseLeave = { handleMouseLeave }
97+ title = { title }
98+ name = { optionKey }
99+ focused = { isFocused }
100+ >
101+ { contentRenderer ( props ) }
102+ </ RawButton >
103+ ) ;
104+ }
105+
84106 return (
85- < RawButton
86- elementRef = { divRef }
87- className = { _cs (
88- styles . optionRenderer ,
89- optionContainerClassName ,
90- containerClassName ,
91- ) }
92- onClick = { handleClick }
93- onMouseMove = { handleMouseMove }
94- onMouseLeave = { handleMouseLeave }
95- title = { title }
96- name = { optionKey }
97- focused = { isFocused }
107+ < div
108+ className = { styles . optionContainer }
98109 >
99- { contentRenderer ( props ) }
100- </ RawButton >
110+ < RawButton
111+ elementRef = { divRef }
112+ className = { _cs ( styles . optionRenderer , containerClassName , optionContainerClassName ) }
113+ onClick = { handleClick }
114+ onMouseMove = { handleMouseMove }
115+ onMouseLeave = { handleMouseLeave }
116+ title = { title }
117+ name = { optionKey }
118+ focused = { isFocused }
119+ >
120+ { contentRenderer ( props ) }
121+ </ RawButton >
122+ { actionsSelector ( option ) }
123+ </ div >
101124 ) ;
102125}
103126export default GenericOption ;
0 commit comments