fix(striker-ui): allow boolean header in List

This commit is contained in:
Tsu-ba-me 2023-02-17 19:44:11 -05:00
parent 92a38374cb
commit a7ea47de30

View File

@ -140,36 +140,36 @@ const List = forwardRef(
isEdit, isEdit,
onAllCheckboxChange, onAllCheckboxChange,
]); ]);
const headerElement = useMemo( const headerElement = useMemo(() => {
() => const headerType = typeof header;
isInsertHeader && header ? (
<FlexBox row spacing={headerSpacing} sx={{ height: '2.4em' }}> return isInsertHeader && header ? (
{checkAllElement} <FlexBox row spacing={headerSpacing} sx={{ height: '2.4em' }}>
{typeof header === 'string' ? ( {checkAllElement}
<> {['boolean', 'string'].includes(headerType) ? (
<BodyText>{header}</BodyText> <>
<Divider sx={{ flexGrow: 1 }} /> {headerType === 'string' && <BodyText>{header}</BodyText>}
</> <Divider sx={{ flexGrow: 1 }} />
) : ( </>
header ) : (
)} header
{deleteItemButton} )}
{editItemButton} {deleteItemButton}
{addItemButton} {editItemButton}
</FlexBox> {addItemButton}
) : ( </FlexBox>
header ) : (
), header
[ );
addItemButton, }, [
checkAllElement, addItemButton,
deleteItemButton, checkAllElement,
editItemButton, deleteItemButton,
header, editItemButton,
headerSpacing, header,
isInsertHeader, headerSpacing,
], isInsertHeader,
); ]);
const listEmptyElement = useMemo( const listEmptyElement = useMemo(
() => () =>
typeof listEmpty === 'string' ? ( typeof listEmpty === 'string' ? (