import {autobind} from "core-decorators"; import {computed, observable} from "mobx"; import * as React from "react"; import {findDOMNode} from "react-dom"; import Button from "focus-components/button"; import {LineProps} from "./line"; import * as styles from "./style/list.css"; export type ListStyle = Partial; export interface ListBaseProps> { classNames?: ListStyle; LineComponent: ReactComponent

; lineProps?: P; isManualFetch?: boolean; offset?: number; perPage?: number; } @autobind export abstract class ListBase>> extends React.Component { @observable maxElements = this.props.perPage; private page = 1; protected abstract get data(): T[]; @computed protected get displayedData() { if (this.maxElements) { return this.data.slice(0, this.maxElements); } else { return this.data; } } @computed protected get hasMoreData() { if (this.maxElements) { return this.data.length > this.maxElements; } else { return false; } } componentDidMount() { const {isManualFetch, perPage} = this.props; if (!isManualFetch && perPage) { this.attachScrollListener(); } } componentDidUpdate() { this.componentDidMount(); } componentWillUnmount() { const {isManualFetch, perPage} = this.props; if (!isManualFetch && perPage) { this.detachScrollListener(); } } protected renderManualFetch() { const {isManualFetch, classNames} = this.props; if (isManualFetch && this.hasMoreData) { return (