@@ -21,17 +21,17 @@ export function CheckBoxListItems<T>({
21
21
getItemId,
22
22
sx,
23
23
secondaryAction,
24
- enableSecondaryActionOnHover,
25
24
addSelectAllCheckbox,
26
25
selectAllCheckBoxLabel,
27
26
getItemLabel,
28
27
isDisabled,
29
28
isDndDragAndDropActive,
30
29
isDragDisable,
31
30
divider,
32
- isCheckboxClickableOnly,
31
+ onItemClick,
32
+ isItemClickable,
33
33
...props
34
- } : CheckBoxListItemsProps < T > ) {
34
+ } : Readonly < CheckBoxListItemsProps < T > > ) {
35
35
const handleOnchange = useCallback (
36
36
( newValues : T [ ] ) => {
37
37
if ( onSelectionChange ) {
@@ -77,16 +77,8 @@ export function CheckBoxListItems<T>({
77
77
if ( ! secondaryAction ) {
78
78
return null ;
79
79
}
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 ) ;
90
82
} ;
91
83
92
84
const selectAllLabel = useMemo (
@@ -126,6 +118,8 @@ export function CheckBoxListItems<T>({
126
118
const label = getItemLabel ? getItemLabel ( item ) : getItemId ( item ) ;
127
119
const disabled = isDisabled ? isDisabled ( item ) : false ;
128
120
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 ;
129
123
130
124
if ( isDndDragAndDropActive ) {
131
125
return (
@@ -142,14 +136,15 @@ export function CheckBoxListItems<T>({
142
136
checked = { isChecked ( item ) }
143
137
label = { label }
144
138
onClick = { ( ) => toggleSelection ( getItemId ( item ) ) }
145
- sx = { sx }
139
+ sx = { calculatedItemSx }
146
140
disabled = { disabled }
147
141
getItemId = { getItemId }
148
142
secondaryAction = { handleSecondaryAction }
149
143
isDragDisable = { isDragDisable }
150
144
provided = { provided }
151
145
divider = { addDivider }
152
- isCheckboxClickableOnly = { isCheckboxClickableOnly }
146
+ onItemClick = { onItemClick }
147
+ isItemClickable = { isItemClickable }
153
148
/>
154
149
) }
155
150
</ Draggable >
@@ -164,10 +159,11 @@ export function CheckBoxListItems<T>({
164
159
onClick = { ( ) => toggleSelection ( getItemId ( item ) ) }
165
160
disabled = { disabled }
166
161
getItemId = { getItemId }
167
- sx = { sx }
162
+ sx = { calculatedItemSx }
168
163
secondaryAction = { handleSecondaryAction }
169
164
divider = { addDivider }
170
- isCheckboxClickableOnly = { isCheckboxClickableOnly }
165
+ onItemClick = { onItemClick }
166
+ isItemClickable = { isItemClickable }
171
167
/>
172
168
) ;
173
169
} ) }
0 commit comments