var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import React from 'react';
import ReactDOM from 'react-dom';
import Upload from '..';
import { Button } from '../..';
const requestOpts = {
    action: 'https://www.easy-mock.com/mock/5b713974309d0d7d107a74a3/alifd/upload',
    data: { osstoken: 1234 },
    headers: { 'X-Requested-With': 12345 },
};
function beforeUpload(file, options) {
    console.log('beforeUpload callback : ', file, options);
    return requestOpts;
}
function asyncBeforeUpload(file, options) {
    return __awaiter(this, void 0, void 0, function* () {
        console.log('beforeUpload callback : ', file, options);
        return yield new Promise(resolve => {
            setTimeout(() => {
                resolve(requestOpts);
            }, 1e3);
        });
    });
}
function onChange(file) {
    console.log('onChange callback : ', file);
}
ReactDOM.render([
    React.createElement(Upload, { listType: "text", action: "https://www.easy-mock.com/mock/5b713974309d0d7d107a74a3/alifd/upload", accept: "image/png, image/jpg, image/jpeg, image/gif, image/bmp", beforeUpload: beforeUpload, onChange: onChange, key: "1" },
        React.createElement(Button, { type: "primary", style: { margin: '0 0 10px' } }, "Upload File")),
    React.createElement(Upload, { listType: "text", action: "https://www.easy-mock.com/mock/5b713974309d0d7d107a74a3/alifd/upload", accept: "image/png, image/jpg, image/jpeg, image/gif, image/bmp", beforeUpload: asyncBeforeUpload, onChange: onChange, key: "2" },
        React.createElement(Button, { type: "secondary", style: { margin: '0 0 10px' } }, "Async Call before Upload File")),
    React.createElement(Upload, { listType: "text", action: "https://www.easy-mock.com/mock/5b713974309d0d7d107a74a3/alifd/upload", accept: "image/png, image/jpg, image/jpeg, image/gif, image/bmp", beforeUpload: () => false, onChange: onChange, key: "3" },
        React.createElement(Button, { type: "normal", style: { margin: '0 0 10px' } }, "Prevent Upload")),
    React.createElement(Upload, { listType: "text", action: "https://www.easy-mock.com/mock/5b713974309d0d7d107a74a3/alifd/upload", accept: "image/png, image/jpg, image/jpeg, image/gif, image/bmp", beforeUpload: () => new Promise((resovle, reject) => setTimeout(() => reject(new Error('error')))), onChange: onChange, key: "4" },
        React.createElement(Button, { type: "primary", style: { margin: '0 0 10px' } }, "Async Prevent Upload")),
], document.getElementById('upload-demo-13'));
