Skip to content

Commit

Permalink
fix: post merge fix
Browse files Browse the repository at this point in the history
Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
  • Loading branch information
LE SAULNIER Kevin committed Sep 17, 2024
1 parent 7743357 commit 1b450e3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
20 changes: 7 additions & 13 deletions demo/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,19 +648,13 @@ function AppContent({ language, onLanguageClick }) {
}}
onItemClick={(item) => console.log('clicked', item)}
isItemClickable={(item) => item.id.indexOf('i') >= 0}
sx={(item) =>
item.id.indexOf('i') >= 0
? {
label: {
color: 'blue',
},
}
: {
label: {
color: 'red',
},
}
}
sx={{
items: (item) => ({
label: {
color: item.id.indexOf('i') >= 0 ? 'blue' : 'red',
},
}),
}}
/>
<div
style={{
Expand Down
6 changes: 3 additions & 3 deletions src/components/checkBoxList/CheckBoxListItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export function CheckBoxListItems<T>({
const disabled = isDisabled ? isDisabled(item) : false;
const addDivider = divider && index < items.length - 1;
// sx can be dependent on item or not
const calculatedSx = typeof sx === 'function' ? sx(item) : sx;
const calculatedItemSx = typeof sx?.items === 'function' ? sx?.items(item) : sx?.items;

if (isDndDragAndDropActive) {
return (
Expand All @@ -136,7 +136,7 @@ export function CheckBoxListItems<T>({
checked={isChecked(item)}
label={label}
onClick={() => toggleSelection(getItemId(item))}
sx={calculatedSx}
sx={calculatedItemSx}
disabled={disabled}
getItemId={getItemId}
secondaryAction={handleSecondaryAction}
Expand All @@ -159,7 +159,7 @@ export function CheckBoxListItems<T>({
onClick={() => toggleSelection(getItemId(item))}
disabled={disabled}
getItemId={getItemId}
sx={calculatedSx}
sx={calculatedItemSx}
secondaryAction={handleSecondaryAction}
divider={addDivider}
onItemClick={onItemClick}
Expand Down
21 changes: 12 additions & 9 deletions src/components/checkBoxList/checkBoxList.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@
import React from 'react';
import { DraggableProvided, DragStart, DropResult } from 'react-beautiful-dnd';
import { SxProps } from '@mui/system';
import { Theme } from '@mui/material';

export type CheckBoxListItemSx = {
checkBoxIcon?: SxProps;
label?: SxProps;
checkboxListItem?: SxProps;
checkboxButton?: SxProps;
checkbox?: SxProps;
checkBoxIcon?: SxProps<Theme>;
label?: SxProps<Theme>;
checkboxListItem?: SxProps<Theme>;
checkboxButton?: SxProps<Theme>;
checkbox?: SxProps<Theme>;
};

export type CheckBoxListItemsSx = {
dragAndDropContainer?: SxProps;
checkboxList?: SxProps;
export type CheckBoxListSx = {
dragAndDropContainer?: SxProps<Theme>;
checkboxList?: SxProps<Theme>;
};

export type CheckBoxListItemSxMethod<T> = (item: T) => CheckBoxListItemSx;

type CheckBoxListItemSxProps<T> = (CheckBoxListItemSx | CheckBoxListItemSxMethod<T>) & CheckBoxListItemsSx;
type CheckBoxListItemSxProps<T> = CheckBoxListSx & {
items: CheckBoxListItemSx | CheckBoxListItemSxMethod<T>;
};

export interface CheckBoxListItemProps<T> {
item: T;
Expand Down

0 comments on commit 1b450e3

Please sign in to comment.