import Button from '../../button';
import React from 'react';
import ReactDOM from 'react-dom';
import Table from '..';
const dataSource = () => {
    const result = [];
    for (let i = 0; i < 5; i++) {
        result.push({
            title: `Quotation for 1PCS Nano ${3 + i}.0 controller compatible`,
            id: 100306660940 + i,
            time: 2000 + i,
        });
    }
    return result;
}, render = (value, index, record) => {
    return React.createElement("a", null,
        "Remove(",
        record.id,
        ")");
};
class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            dataSource: dataSource(),
        };
    }
    onSort(dataIndex, order) {
        const dataSource = this.state.dataSource.sort(function (a, b) {
            const result = a[dataIndex] - b[dataIndex];
            return order === 'asc' ? (result > 0 ? 1 : -1) : result > 0 ? -1 : 1;
        });
        this.setState({
            dataSource,
        });
    }
    toggleIndent() {
        this.setState({
            expandedRowIndent: [2, 1],
        });
    }
    toggleCol() {
        this.setState({
            hasExpandedRowCtrl: false,
        });
    }
    render() {
        return (React.createElement("div", null,
            React.createElement("p", null,
                React.createElement(Button, { onClick: this.toggleIndent.bind(this) },
                    ' ',
                    "Update indent",
                    ' ')),
            React.createElement(Table, { dataSource: this.state.dataSource, isZebra: this.state.isZebra, hasBorder: false, onSort: this.onSort.bind(this), expandedRowRender: record => record.title, onRowClick: () => console.log('rowClick'), expandedRowIndent: this.state.expandedRowIndent },
                React.createElement(Table.Column, { title: "Id", dataIndex: "id", sortable: true }),
                React.createElement(Table.Column, { title: "Title", dataIndex: "title" }),
                React.createElement(Table.Column, { title: "Time", dataIndex: "time" }),
                React.createElement(Table.Column, { cell: render, width: 200 }))));
    }
}
ReactDOM.render(React.createElement(App, null), document.getElementById('table-demo-7'));
