import Box from '../../box';
import Button from '../../button';
import React from 'react';
import ReactDOM from 'react-dom';
import Select from '../../select';
import Table from '../../table';
const Option = Select.Option;
const dataSource = length => {
    const result = [];
    for (let i = 0; i < length; i++) {
        result.push({
            title: {
                name: `Quotation for 1PCS Nano ${3 + i}.0 controller compatible`,
            },
            id: 100306660940 + i,
            time: 2000 + i,
        });
    }
    return result;
};
const render = () => {
    return (React.createElement(Select, { popupContainer: node => node.parentNode, popupProps: { autoFit: true }, defaultValue: "jack", "aria-label": "name is", showSearch: true, hasClear: true },
        React.createElement(Option, { value: "jack" }, "Jack"),
        React.createElement(Option, { value: "frank" }, "Frank"),
        React.createElement(Option, { value: "hugo" }, "Hugo")));
};
class App extends React.Component {
    constructor() {
        super(...arguments);
        this.state = {
            sticky: false,
            lock: false,
            dataSource: dataSource(50),
        };
    }
    onSwitch(tag) {
        const props = {};
        switch (tag) {
            case 'sticky':
                props.sticky = true;
                break;
            case 'lock':
                props.lock = true;
                break;
            case 'dataSource':
                props.dataSource =
                    this.state.dataSource.length > 0 ? [] : dataSource(50);
                break;
            default:
                break;
        }
        this.setState(props);
    }
    render() {
        return (React.createElement("div", null,
            React.createElement(Box, { direction: "row", spacing: 20 },
                React.createElement(Button, { onClick: this.onSwitch.bind(this, 'sticky') }, "enable sticky"),
                React.createElement(Button, { onClick: this.onSwitch.bind(this, 'lock') }, "enable lock"),
                React.createElement(Button, { onClick: this.onSwitch.bind(this, 'dataSource') }, "toggle dataSource")),
            React.createElement("br", null),
            React.createElement(Table, { dataSource: this.state.dataSource, fixedHeader: true, stickyHeader: this.state.sticky },
                React.createElement(Table.Column, { title: "Id", dataIndex: "id", width: 200, lock: this.state.lock }),
                React.createElement(Table.Column, { title: "Title", dataIndex: "title.name", width: 200 }),
                React.createElement(Table.Column, { title: "Time", dataIndex: "time", width: 200 }),
                React.createElement(Table.Column, { title: "test", cell: render, width: 200 }))));
    }
}
ReactDOM.render(React.createElement(App, null), document.getElementById('table-demo-12'));
