@@ -21,17 +21,17 @@ export function CheckBoxListItems<T>({
2121 getItemId,
2222 sx,
2323 secondaryAction,
24- enableSecondaryActionOnHover,
2524 addSelectAllCheckbox,
2625 selectAllCheckBoxLabel,
2726 getItemLabel,
2827 isDisabled,
2928 isDndDragAndDropActive,
3029 isDragDisable,
3130 divider,
32- isCheckboxClickableOnly,
31+ onItemClick,
32+ isItemClickable,
3333 ...props
34- } : CheckBoxListItemsProps < T > ) {
34+ } : Readonly < CheckBoxListItemsProps < T > > ) {
3535 const handleOnchange = useCallback (
3636 ( newValues : T [ ] ) => {
3737 if ( onSelectionChange ) {
@@ -77,16 +77,8 @@ export function CheckBoxListItems<T>({
7777 if ( ! secondaryAction ) {
7878 return null ;
7979 }
80-
81- if ( ! enableSecondaryActionOnHover ) {
82- return secondaryAction ( item ) ;
83- }
84-
85- if ( hover === getItemId ( item ) ) {
86- return secondaryAction ( item ) ;
87- }
88-
89- return null ;
80+ const isItemHovered = hover === getItemId ( item ) ;
81+ return secondaryAction ( item , isItemHovered ) ;
9082 } ;
9183
9284 const selectAllLabel = useMemo (
@@ -126,6 +118,8 @@ export function CheckBoxListItems<T>({
126118 const label = getItemLabel ? getItemLabel ( item ) : getItemId ( item ) ;
127119 const disabled = isDisabled ? isDisabled ( item ) : false ;
128120 const addDivider = divider && index < items . length - 1 ;
121+ // sx can be dependent on item or not
122+ const calculatedItemSx = typeof sx ?. items === 'function' ? sx ?. items ( item ) : sx ?. items ;
129123
130124 if ( isDndDragAndDropActive ) {
131125 return (
@@ -142,14 +136,15 @@ export function CheckBoxListItems<T>({
142136 checked = { isChecked ( item ) }
143137 label = { label }
144138 onClick = { ( ) => toggleSelection ( getItemId ( item ) ) }
145- sx = { sx }
139+ sx = { calculatedItemSx }
146140 disabled = { disabled }
147141 getItemId = { getItemId }
148142 secondaryAction = { handleSecondaryAction }
149143 isDragDisable = { isDragDisable }
150144 provided = { provided }
151145 divider = { addDivider }
152- isCheckboxClickableOnly = { isCheckboxClickableOnly }
146+ onItemClick = { onItemClick }
147+ isItemClickable = { isItemClickable }
153148 />
154149 ) }
155150 </ Draggable >
@@ -164,10 +159,11 @@ export function CheckBoxListItems<T>({
164159 onClick = { ( ) => toggleSelection ( getItemId ( item ) ) }
165160 disabled = { disabled }
166161 getItemId = { getItemId }
167- sx = { sx }
162+ sx = { calculatedItemSx }
168163 secondaryAction = { handleSecondaryAction }
169164 divider = { addDivider }
170- isCheckboxClickableOnly = { isCheckboxClickableOnly }
165+ onItemClick = { onItemClick }
166+ isItemClickable = { isItemClickable }
171167 />
172168 ) ;
173169 } ) }
0 commit comments