|
|
@ -22,6 +22,7 @@ import Checkbox from './Checkbox'; |
|
|
|
import Divider from './Divider'; |
|
|
|
import Divider from './Divider'; |
|
|
|
import FlexBox from './FlexBox'; |
|
|
|
import FlexBox from './FlexBox'; |
|
|
|
import IconButton from './IconButton'; |
|
|
|
import IconButton from './IconButton'; |
|
|
|
|
|
|
|
import Spinner from './Spinner'; |
|
|
|
import { BodyText } from './Text'; |
|
|
|
import { BodyText } from './Text'; |
|
|
|
|
|
|
|
|
|
|
|
const List = forwardRef( |
|
|
|
const List = forwardRef( |
|
|
@ -43,6 +44,7 @@ const List = forwardRef( |
|
|
|
listItemProps: { sx: listItemSx, ...restListItemProps } = {}, |
|
|
|
listItemProps: { sx: listItemSx, ...restListItemProps } = {}, |
|
|
|
listItems, |
|
|
|
listItems, |
|
|
|
listProps: { sx: listSx, ...restListProps } = {}, |
|
|
|
listProps: { sx: listSx, ...restListProps } = {}, |
|
|
|
|
|
|
|
loading, |
|
|
|
onAdd, |
|
|
|
onAdd, |
|
|
|
onDelete, |
|
|
|
onDelete, |
|
|
|
onEdit, |
|
|
|
onEdit, |
|
|
@ -186,13 +188,15 @@ const List = forwardRef( |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const listItemElements = useMemo(() => { |
|
|
|
const listItemElements = useMemo(() => { |
|
|
|
let result = listEmptyElement; |
|
|
|
if (loading) return <Spinner mt={0} />; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!listItems) return listEmptyElement; |
|
|
|
|
|
|
|
|
|
|
|
if (listItems) { |
|
|
|
|
|
|
|
const entries = Object.entries(listItems); |
|
|
|
const entries = Object.entries(listItems); |
|
|
|
|
|
|
|
|
|
|
|
if (entries.length > 0) { |
|
|
|
if (entries.length <= 0) return listEmptyElement; |
|
|
|
result = entries.map(([key, value]) => { |
|
|
|
|
|
|
|
|
|
|
|
return entries.map(([key, value]) => { |
|
|
|
const listItem = renderListItem(key, value); |
|
|
|
const listItem = renderListItem(key, value); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
@ -221,13 +225,10 @@ const List = forwardRef( |
|
|
|
</MUIListItem> |
|
|
|
</MUIListItem> |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
}, [ |
|
|
|
}, [ |
|
|
|
listEmptyElement, |
|
|
|
loading, |
|
|
|
listItems, |
|
|
|
listItems, |
|
|
|
|
|
|
|
listEmptyElement, |
|
|
|
renderListItem, |
|
|
|
renderListItem, |
|
|
|
restListItemProps, |
|
|
|
restListItemProps, |
|
|
|
listItemKeyPrefix, |
|
|
|
listItemKeyPrefix, |
|
|
|