import PropTypes from 'prop-types';

import {CommonList} from './common/CommonList';

export class PureList extends CommonList {
    static propTypes = {
        ...CommonList.propTypes,
        rows: PropTypes.array.isRequired
    };

    constructor(props) {
        super(props);

        this.renderItem = this.renderItem.bind(this);
    }

    hasItems() {
        return this.props.rows.length > 0;
    }

    isEmptyList() {
        return this.props.rows.length === 0;
    }

    isEmptyListMessageVisible() {
        return !this.hasItems();
    }

    renderItems() {
        return this.props.rows.map(this.renderItem);
    }
}
