import * as React from 'react';
import { ViewController } from '../lib/ctr';
export default class Pageing extends ViewController {
    get page() {
        return this.props.page;
    }
    render() {
        if (!this.page)
            return null;
        var { dataPageCount, indexPage } = this.page;
        if (dataPageCount <= 1)
            return null;
        var offset = 5;
        return (React.createElement("div", { className: "text-right" },
            React.createElement("ul", { className: "pagination" },
                React.createElement("li", { className: `footable-page-arrow ${indexPage ? '' : 'disabled'}` },
                    React.createElement("a", { "data-page": "first", href: "#first", onClick: e => indexPage && this.page.reload({}, 0) }, "\u00AB")),
                React.createElement("li", { className: `footable-page-arrow ${indexPage ? '' : 'disabled'}` },
                    React.createElement("a", { "data-page": "prev", href: "#prev", onClick: e => indexPage && this.page.reload({}, indexPage - 1) }, "\u2039")),
                Array.from({ length: 10 }).map((e, i) => {
                    var j = indexPage + i - offset;
                    if (j < 0 || j >= dataPageCount)
                        return null;
                    return (React.createElement("li", { className: `footable-page ${indexPage == j ? 'active' : ''}` },
                        React.createElement("a", { "data-page": "0", href: "#", onClick: e => indexPage != j && this.page.reload({}, j) }, j + 1)));
                }).filter(e => e),
                React.createElement("li", { className: `footable-page-arrow ${indexPage + 1 < dataPageCount ? '' : 'disabled'}` },
                    React.createElement("a", { "data-page": "next", href: "#next", onClick: e => indexPage + 1 < dataPageCount && this.page.reload({}, indexPage + 1) }, "\u203A")),
                React.createElement("li", { className: `footable-page-arrow ${indexPage + 1 < dataPageCount ? '' : 'disabled'}` },
                    React.createElement("a", { "data-page": "last", href: "#last", onClick: e => indexPage + 1 < dataPageCount && this.page.reload({}, dataPageCount - 1) }, "\u00BB")))));
    }
}
