58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
import ImmutablePureComponent from 'react-immutable-pure-component'
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
import Block from './block'
|
|
import ScrollableList from './scrollable_list'
|
|
import ListItem from './list_item'
|
|
|
|
export default class List extends ImmutablePureComponent {
|
|
|
|
static propTypes = {
|
|
items: PropTypes.oneOfType([
|
|
PropTypes.array,
|
|
ImmutablePropTypes.map,
|
|
ImmutablePropTypes.list,
|
|
]),
|
|
scrollKey: PropTypes.string,
|
|
emptyMessage: PropTypes.any,
|
|
size: PropTypes.oneOf([
|
|
'small',
|
|
'large'
|
|
]),
|
|
onLoadMore: PropTypes.func,
|
|
hasMore: PropTypes.bool,
|
|
}
|
|
|
|
render() {
|
|
const {
|
|
items,
|
|
scrollKey,
|
|
emptyMessage,
|
|
hasMore,
|
|
size,
|
|
onLoadMore
|
|
} = this.props
|
|
|
|
return (
|
|
<Block>
|
|
<ScrollableList
|
|
onLoadMore={onLoadMore}
|
|
hasMore={hasMore}
|
|
scrollKey={scrollKey}
|
|
emptyMessage={emptyMessage}
|
|
>
|
|
{
|
|
items.map((item, i) => (
|
|
<ListItem
|
|
size={size}
|
|
key={`list-item-${i}`}
|
|
isLast={items.size - 1 === i}
|
|
{...item}
|
|
/>
|
|
))
|
|
}
|
|
</ScrollableList>
|
|
</Block>
|
|
)
|
|
}
|
|
|
|
} |