import './demo2.css';
import 'whatwg-fetch';
import CascaderSelect from '..';
import React from 'react';
import ReactDOM from 'react-dom';
interface PageStates {
  data: Array<any>;
}
class Demo extends React.Component<{}, PageStates> {
  constructor(props) {
    super(props);

    this.state = {
      data: [],
    };

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

  componentDidMount() {
    fetch('https://os.alipayobjects.com/rmsportal/ODDwqcDFTLAguOvWEolX.json')
      .then(response => response.json())
      .then(data => {
        this.setState({ data });
      })
      .catch(e => console.log(e));
  }

  handleChange(value, data, extra) {
    console.log(value, data, extra);
  }

  render() {
    return (
      <div>
        <CascaderSelect
          size='large'
          multiple
          dataSource={this.state.data}
          onChange={this.handleChange}
        />
        <br/>
        <br/>
        <CascaderSelect
          size='medium'
          multiple
          dataSource={this.state.data}
          onChange={this.handleChange}
        />
        <br/>
        <br/>
        <CascaderSelect
          size='small'
          multiple
          dataSource={this.state.data}
          onChange={this.handleChange}
        />
        <br/>
        <br/>
        <CascaderSelect
          size='xs'
          multiple
          dataSource={this.state.data}
          onChange={this.handleChange}
        />
        <br/>
        <br/>
        <div style={{ backgroundColor: '#f3f3f3', padding: '10px' }}>
          <CascaderSelect
            multiple
            theme='grey'
            dataSource={this.state.data}
            onChange={this.handleChange}
          />
        </div>
      </div>

    );
  }
}
ReactDOM.render(<Demo />, document.getElementById('cascader-select-demo-2'));
