first commit
This commit is contained in:
21
frontend/node_modules/rc-upload/LICENSE
generated
vendored
Normal file
21
frontend/node_modules/rc-upload/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016-present react-component
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
126
frontend/node_modules/rc-upload/README.md
generated
vendored
Normal file
126
frontend/node_modules/rc-upload/README.md
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
# rc-upload
|
||||
|
||||
React Upload
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![npm download][download-image]][download-url]
|
||||
[![build status][github-actions-image]][github-actions-url]
|
||||
[![Codecov][codecov-image]][codecov-url]
|
||||
[![bundle size][bundlephobia-image]][bundlephobia-url]
|
||||
[![dumi][dumi-image]][dumi-url]
|
||||
|
||||
[npm-image]: http://img.shields.io/npm/v/rc-upload.svg?style=flat-square
|
||||
[npm-url]: http://npmjs.org/package/rc-upload
|
||||
[travis-image]: https://img.shields.io/travis/react-component/upload/master?style=flat-square
|
||||
[travis-url]: https://travis-ci.com/react-component/upload
|
||||
[github-actions-image]: https://github.com/react-component/upload/workflows/CI/badge.svg
|
||||
[github-actions-url]: https://github.com/react-component/upload/actions
|
||||
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/upload/master.svg?style=flat-square
|
||||
[codecov-url]: https://app.codecov.io/gh/react-component/upload
|
||||
[david-url]: https://david-dm.org/react-component/upload
|
||||
[david-image]: https://david-dm.org/react-component/upload/status.svg?style=flat-square
|
||||
[david-dev-url]: https://david-dm.org/react-component/upload?type=dev
|
||||
[david-dev-image]: https://david-dm.org/react-component/upload/dev-status.svg?style=flat-square
|
||||
[download-image]: https://img.shields.io/npm/dm/rc-upload.svg?style=flat-square
|
||||
[download-url]: https://npmjs.org/package/rc-upload
|
||||
[bundlephobia-url]: https://bundlephobia.com/package/rc-upload
|
||||
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-upload
|
||||
[dumi-url]: https://github.com/umijs/dumi
|
||||
[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
|
||||
|
||||
## Development
|
||||
|
||||
```
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
http://localhost:8000/
|
||||
|
||||
online example: https://upload.react-component.vercel.app/
|
||||
|
||||
## Feature
|
||||
|
||||
* support IE11+, Chrome, Firefox, Safari
|
||||
|
||||
## install
|
||||
|
||||
[](https://npmjs.org/package/rc-upload)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var Upload = require('rc-upload');
|
||||
var React = require('react');
|
||||
React.render(<Upload />, container);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### props
|
||||
|
||||
|name|type|default| description|
|
||||
|-----|---|--------|----|
|
||||
|name | string | file| file param post to server |
|
||||
|style | object | {}| root component inline style |
|
||||
|className | string | - | root component className |
|
||||
|disabled | boolean | false | whether disabled |
|
||||
|component | "div"|"span" | "span"| wrap component name |
|
||||
|action| string | function(file): string | Promise<string> | | form action url |
|
||||
|method | string | post | request method |
|
||||
|directory| boolean | false | support upload whole directory |
|
||||
|data| object/function(file) | | other data object to post or a function which returns a data object(a promise object which resolve a data object) |
|
||||
|headers| object | {} | http headers to post, available in modern browsers |
|
||||
|accept | string | | input accept attribute |
|
||||
|capture | string | | input capture attribute |
|
||||
|multiple | boolean | false | only support ie10+|
|
||||
|onStart | function| | start upload file |
|
||||
|onError| function| | error callback |
|
||||
|onSuccess | function | | success callback |
|
||||
|onProgress | function || progress callback, only for modern browsers|
|
||||
|beforeUpload| function |null| before upload check, return false or a rejected Promise will stop upload, only for modern browsers|
|
||||
|customRequest | function | null | provide an override for the default xhr behavior for additional customization|
|
||||
|withCredentials | boolean | false | ajax upload with cookie send |
|
||||
|openFileDialogOnClick | boolean | true | useful for drag only upload as it does not trigger on enter key or click event |
|
||||
|pastable | boolean | false | support paste upload |
|
||||
|
||||
#### onError arguments
|
||||
|
||||
1. `err`: request error message
|
||||
2. `response`: request response, not support on iframeUpload
|
||||
3. `file`: upload file
|
||||
|
||||
### onSuccess arguments
|
||||
|
||||
1. `result`: response body
|
||||
2. `file`: upload file
|
||||
3. `xhr`: xhr header, only for modern browsers which support AJAX upload. since
|
||||
2.4.0
|
||||
|
||||
|
||||
### customRequest
|
||||
|
||||
Allows for advanced customization by overriding default behavior in AjaxUploader. Provide your own XMLHttpRequest calls to interface with custom backend processes or interact with AWS S3 service through the aws-sdk-js package.
|
||||
|
||||
customRequest callback is passed an object with:
|
||||
|
||||
* `onProgress: (event: { percent: number }): void`
|
||||
* `onError: (event: Error, body?: Object): void`
|
||||
* `onSuccess: (body: Object): void`
|
||||
* `data: Object`
|
||||
* `filename: String`
|
||||
* `file: File`
|
||||
* `withCredentials: Boolean`
|
||||
* `action: String`
|
||||
* `headers: Object`
|
||||
|
||||
|
||||
### methods
|
||||
|
||||
abort(file?: File) => void: abort the uploading file
|
||||
|
||||
## License
|
||||
|
||||
rc-upload is released under the MIT license.
|
||||
37
frontend/node_modules/rc-upload/es/AjaxUploader.d.ts
generated
vendored
Normal file
37
frontend/node_modules/rc-upload/es/AjaxUploader.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import React, { Component } from 'react';
|
||||
import type { RcFile, UploadProps } from './interface';
|
||||
interface ParsedFileInfo {
|
||||
origin: RcFile;
|
||||
action: string;
|
||||
data: Record<string, unknown>;
|
||||
parsedFile: RcFile;
|
||||
}
|
||||
declare class AjaxUploader extends Component<UploadProps> {
|
||||
state: {
|
||||
uid: string;
|
||||
};
|
||||
reqs: Record<string, any>;
|
||||
private fileInput;
|
||||
private _isMounted;
|
||||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
||||
onClick: (event: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => void;
|
||||
onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
||||
onDataTransferFiles: (dataTransfer: DataTransfer, existFileCallback?: () => void) => Promise<void>;
|
||||
onFilePaste: (e: ClipboardEvent) => Promise<void>;
|
||||
onFileDragOver: (e: React.DragEvent<HTMLDivElement>) => void;
|
||||
onFileDrop: (e: React.DragEvent<HTMLDivElement>) => Promise<void>;
|
||||
componentDidMount(): void;
|
||||
componentWillUnmount(): void;
|
||||
componentDidUpdate(prevProps: UploadProps): void;
|
||||
uploadFiles: (files: File[]) => void;
|
||||
/**
|
||||
* Process file before upload. When all the file is ready, we start upload.
|
||||
*/
|
||||
processFile: (file: RcFile, fileList: RcFile[]) => Promise<ParsedFileInfo>;
|
||||
post({ data, origin, action, parsedFile }: ParsedFileInfo): void;
|
||||
reset(): void;
|
||||
abort(file?: any): void;
|
||||
saveFileInput: (node: HTMLInputElement) => void;
|
||||
render(): React.JSX.Element;
|
||||
}
|
||||
export default AjaxUploader;
|
||||
481
frontend/node_modules/rc-upload/es/AjaxUploader.js
generated
vendored
Normal file
481
frontend/node_modules/rc-upload/es/AjaxUploader.js
generated
vendored
Normal file
@@ -0,0 +1,481 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
||||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
||||
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
||||
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
||||
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
var _excluded = ["component", "prefixCls", "className", "classNames", "disabled", "id", "name", "style", "styles", "multiple", "accept", "capture", "children", "directory", "folder", "openFileDialogOnClick", "onMouseEnter", "onMouseLeave", "hasControlInside"];
|
||||
/* eslint react/no-is-mounted:0,react/sort-comp:0,react/prop-types:0 */
|
||||
import clsx from 'classnames';
|
||||
import pickAttrs from "rc-util/es/pickAttrs";
|
||||
import React, { Component } from 'react';
|
||||
import attrAccept from "./attr-accept";
|
||||
import defaultRequest from "./request";
|
||||
import traverseFileTree from "./traverseFileTree";
|
||||
import getUid from "./uid";
|
||||
var AjaxUploader = /*#__PURE__*/function (_Component) {
|
||||
_inherits(AjaxUploader, _Component);
|
||||
var _super = _createSuper(AjaxUploader);
|
||||
function AjaxUploader() {
|
||||
var _this;
|
||||
_classCallCheck(this, AjaxUploader);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
_this = _super.call.apply(_super, [this].concat(args));
|
||||
_defineProperty(_assertThisInitialized(_this), "state", {
|
||||
uid: getUid()
|
||||
});
|
||||
_defineProperty(_assertThisInitialized(_this), "reqs", {});
|
||||
_defineProperty(_assertThisInitialized(_this), "fileInput", void 0);
|
||||
_defineProperty(_assertThisInitialized(_this), "_isMounted", void 0);
|
||||
_defineProperty(_assertThisInitialized(_this), "onChange", function (e) {
|
||||
var _this$props = _this.props,
|
||||
accept = _this$props.accept,
|
||||
directory = _this$props.directory;
|
||||
var files = e.target.files;
|
||||
var acceptedFiles = _toConsumableArray(files).filter(function (file) {
|
||||
return !directory || attrAccept(file, accept);
|
||||
});
|
||||
_this.uploadFiles(acceptedFiles);
|
||||
_this.reset();
|
||||
});
|
||||
_defineProperty(_assertThisInitialized(_this), "onClick", function (event) {
|
||||
var el = _this.fileInput;
|
||||
if (!el) {
|
||||
return;
|
||||
}
|
||||
var target = event.target;
|
||||
var onClick = _this.props.onClick;
|
||||
if (target && target.tagName === 'BUTTON') {
|
||||
var parent = el.parentNode;
|
||||
parent.focus();
|
||||
target.blur();
|
||||
}
|
||||
el.click();
|
||||
if (onClick) {
|
||||
onClick(event);
|
||||
}
|
||||
});
|
||||
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (e) {
|
||||
if (e.key === 'Enter') {
|
||||
_this.onClick(e);
|
||||
}
|
||||
});
|
||||
_defineProperty(_assertThisInitialized(_this), "onDataTransferFiles", /*#__PURE__*/function () {
|
||||
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dataTransfer, existFileCallback) {
|
||||
var _this$props2, multiple, accept, directory, items, files, acceptFiles;
|
||||
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
||||
while (1) switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
_this$props2 = _this.props, multiple = _this$props2.multiple, accept = _this$props2.accept, directory = _this$props2.directory;
|
||||
items = _toConsumableArray(dataTransfer.items || []);
|
||||
files = _toConsumableArray(dataTransfer.files || []);
|
||||
if (files.length > 0 || items.some(function (item) {
|
||||
return item.kind === 'file';
|
||||
})) {
|
||||
existFileCallback === null || existFileCallback === void 0 || existFileCallback();
|
||||
}
|
||||
if (!directory) {
|
||||
_context.next = 11;
|
||||
break;
|
||||
}
|
||||
_context.next = 7;
|
||||
return traverseFileTree(Array.prototype.slice.call(items), function (_file) {
|
||||
return attrAccept(_file, _this.props.accept);
|
||||
});
|
||||
case 7:
|
||||
files = _context.sent;
|
||||
_this.uploadFiles(files);
|
||||
_context.next = 14;
|
||||
break;
|
||||
case 11:
|
||||
acceptFiles = _toConsumableArray(files).filter(function (file) {
|
||||
return attrAccept(file, accept);
|
||||
});
|
||||
if (multiple === false) {
|
||||
acceptFiles = files.slice(0, 1);
|
||||
}
|
||||
_this.uploadFiles(acceptFiles);
|
||||
case 14:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
return function (_x, _x2) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}());
|
||||
_defineProperty(_assertThisInitialized(_this), "onFilePaste", /*#__PURE__*/function () {
|
||||
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(e) {
|
||||
var pastable, clipboardData;
|
||||
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
||||
while (1) switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
pastable = _this.props.pastable;
|
||||
if (pastable) {
|
||||
_context2.next = 3;
|
||||
break;
|
||||
}
|
||||
return _context2.abrupt("return");
|
||||
case 3:
|
||||
if (!(e.type === 'paste')) {
|
||||
_context2.next = 6;
|
||||
break;
|
||||
}
|
||||
clipboardData = e.clipboardData;
|
||||
return _context2.abrupt("return", _this.onDataTransferFiles(clipboardData, function () {
|
||||
e.preventDefault();
|
||||
}));
|
||||
case 6:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
}
|
||||
}, _callee2);
|
||||
}));
|
||||
return function (_x3) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
}());
|
||||
_defineProperty(_assertThisInitialized(_this), "onFileDragOver", function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
_defineProperty(_assertThisInitialized(_this), "onFileDrop", /*#__PURE__*/function () {
|
||||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(e) {
|
||||
var dataTransfer;
|
||||
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
||||
while (1) switch (_context3.prev = _context3.next) {
|
||||
case 0:
|
||||
e.preventDefault();
|
||||
if (!(e.type === 'drop')) {
|
||||
_context3.next = 4;
|
||||
break;
|
||||
}
|
||||
dataTransfer = e.dataTransfer;
|
||||
return _context3.abrupt("return", _this.onDataTransferFiles(dataTransfer));
|
||||
case 4:
|
||||
case "end":
|
||||
return _context3.stop();
|
||||
}
|
||||
}, _callee3);
|
||||
}));
|
||||
return function (_x4) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
}());
|
||||
_defineProperty(_assertThisInitialized(_this), "uploadFiles", function (files) {
|
||||
var originFiles = _toConsumableArray(files);
|
||||
var postFiles = originFiles.map(function (file) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
file.uid = getUid();
|
||||
return _this.processFile(file, originFiles);
|
||||
});
|
||||
|
||||
// Batch upload files
|
||||
Promise.all(postFiles).then(function (fileList) {
|
||||
var onBatchStart = _this.props.onBatchStart;
|
||||
onBatchStart === null || onBatchStart === void 0 || onBatchStart(fileList.map(function (_ref4) {
|
||||
var origin = _ref4.origin,
|
||||
parsedFile = _ref4.parsedFile;
|
||||
return {
|
||||
file: origin,
|
||||
parsedFile: parsedFile
|
||||
};
|
||||
}));
|
||||
fileList.filter(function (file) {
|
||||
return file.parsedFile !== null;
|
||||
}).forEach(function (file) {
|
||||
_this.post(file);
|
||||
});
|
||||
});
|
||||
});
|
||||
/**
|
||||
* Process file before upload. When all the file is ready, we start upload.
|
||||
*/
|
||||
_defineProperty(_assertThisInitialized(_this), "processFile", /*#__PURE__*/function () {
|
||||
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(file, fileList) {
|
||||
var beforeUpload, transformedFile, action, mergedAction, data, mergedData, parsedData, parsedFile, mergedParsedFile;
|
||||
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
||||
while (1) switch (_context4.prev = _context4.next) {
|
||||
case 0:
|
||||
beforeUpload = _this.props.beforeUpload;
|
||||
transformedFile = file;
|
||||
if (!beforeUpload) {
|
||||
_context4.next = 14;
|
||||
break;
|
||||
}
|
||||
_context4.prev = 3;
|
||||
_context4.next = 6;
|
||||
return beforeUpload(file, fileList);
|
||||
case 6:
|
||||
transformedFile = _context4.sent;
|
||||
_context4.next = 12;
|
||||
break;
|
||||
case 9:
|
||||
_context4.prev = 9;
|
||||
_context4.t0 = _context4["catch"](3);
|
||||
// Rejection will also trade as false
|
||||
transformedFile = false;
|
||||
case 12:
|
||||
if (!(transformedFile === false)) {
|
||||
_context4.next = 14;
|
||||
break;
|
||||
}
|
||||
return _context4.abrupt("return", {
|
||||
origin: file,
|
||||
parsedFile: null,
|
||||
action: null,
|
||||
data: null
|
||||
});
|
||||
case 14:
|
||||
// Get latest action
|
||||
action = _this.props.action;
|
||||
if (!(typeof action === 'function')) {
|
||||
_context4.next = 21;
|
||||
break;
|
||||
}
|
||||
_context4.next = 18;
|
||||
return action(file);
|
||||
case 18:
|
||||
mergedAction = _context4.sent;
|
||||
_context4.next = 22;
|
||||
break;
|
||||
case 21:
|
||||
mergedAction = action;
|
||||
case 22:
|
||||
// Get latest data
|
||||
data = _this.props.data;
|
||||
if (!(typeof data === 'function')) {
|
||||
_context4.next = 29;
|
||||
break;
|
||||
}
|
||||
_context4.next = 26;
|
||||
return data(file);
|
||||
case 26:
|
||||
mergedData = _context4.sent;
|
||||
_context4.next = 30;
|
||||
break;
|
||||
case 29:
|
||||
mergedData = data;
|
||||
case 30:
|
||||
parsedData =
|
||||
// string type is from legacy `transformFile`.
|
||||
// Not sure if this will work since no related test case works with it
|
||||
(_typeof(transformedFile) === 'object' || typeof transformedFile === 'string') && transformedFile ? transformedFile : file;
|
||||
if (parsedData instanceof File) {
|
||||
parsedFile = parsedData;
|
||||
} else {
|
||||
parsedFile = new File([parsedData], file.name, {
|
||||
type: file.type
|
||||
});
|
||||
}
|
||||
mergedParsedFile = parsedFile;
|
||||
mergedParsedFile.uid = file.uid;
|
||||
return _context4.abrupt("return", {
|
||||
origin: file,
|
||||
data: mergedData,
|
||||
parsedFile: mergedParsedFile,
|
||||
action: mergedAction
|
||||
});
|
||||
case 35:
|
||||
case "end":
|
||||
return _context4.stop();
|
||||
}
|
||||
}, _callee4, null, [[3, 9]]);
|
||||
}));
|
||||
return function (_x5, _x6) {
|
||||
return _ref5.apply(this, arguments);
|
||||
};
|
||||
}());
|
||||
_defineProperty(_assertThisInitialized(_this), "saveFileInput", function (node) {
|
||||
_this.fileInput = node;
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
_createClass(AjaxUploader, [{
|
||||
key: "componentDidMount",
|
||||
value: function componentDidMount() {
|
||||
this._isMounted = true;
|
||||
var pastable = this.props.pastable;
|
||||
if (pastable) {
|
||||
document.addEventListener('paste', this.onFilePaste);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "componentWillUnmount",
|
||||
value: function componentWillUnmount() {
|
||||
this._isMounted = false;
|
||||
this.abort();
|
||||
document.removeEventListener('paste', this.onFilePaste);
|
||||
}
|
||||
}, {
|
||||
key: "componentDidUpdate",
|
||||
value: function componentDidUpdate(prevProps) {
|
||||
var pastable = this.props.pastable;
|
||||
if (pastable && !prevProps.pastable) {
|
||||
document.addEventListener('paste', this.onFilePaste);
|
||||
} else if (!pastable && prevProps.pastable) {
|
||||
document.removeEventListener('paste', this.onFilePaste);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "post",
|
||||
value: function post(_ref6) {
|
||||
var _this2 = this;
|
||||
var data = _ref6.data,
|
||||
origin = _ref6.origin,
|
||||
action = _ref6.action,
|
||||
parsedFile = _ref6.parsedFile;
|
||||
if (!this._isMounted) {
|
||||
return;
|
||||
}
|
||||
var _this$props3 = this.props,
|
||||
onStart = _this$props3.onStart,
|
||||
customRequest = _this$props3.customRequest,
|
||||
name = _this$props3.name,
|
||||
headers = _this$props3.headers,
|
||||
withCredentials = _this$props3.withCredentials,
|
||||
method = _this$props3.method;
|
||||
var uid = origin.uid;
|
||||
var request = customRequest || defaultRequest;
|
||||
var requestOption = {
|
||||
action: action,
|
||||
filename: name,
|
||||
data: data,
|
||||
file: parsedFile,
|
||||
headers: headers,
|
||||
withCredentials: withCredentials,
|
||||
method: method || 'post',
|
||||
onProgress: function onProgress(e) {
|
||||
var onProgress = _this2.props.onProgress;
|
||||
onProgress === null || onProgress === void 0 || onProgress(e, parsedFile);
|
||||
},
|
||||
onSuccess: function onSuccess(ret, xhr) {
|
||||
var onSuccess = _this2.props.onSuccess;
|
||||
onSuccess === null || onSuccess === void 0 || onSuccess(ret, parsedFile, xhr);
|
||||
delete _this2.reqs[uid];
|
||||
},
|
||||
onError: function onError(err, ret) {
|
||||
var onError = _this2.props.onError;
|
||||
onError === null || onError === void 0 || onError(err, ret, parsedFile);
|
||||
delete _this2.reqs[uid];
|
||||
}
|
||||
};
|
||||
onStart(origin);
|
||||
this.reqs[uid] = request(requestOption, {
|
||||
defaultRequest: defaultRequest
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "reset",
|
||||
value: function reset() {
|
||||
this.setState({
|
||||
uid: getUid()
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "abort",
|
||||
value: function abort(file) {
|
||||
var reqs = this.reqs;
|
||||
if (file) {
|
||||
var uid = file.uid ? file.uid : file;
|
||||
if (reqs[uid] && reqs[uid].abort) {
|
||||
reqs[uid].abort();
|
||||
}
|
||||
delete reqs[uid];
|
||||
} else {
|
||||
Object.keys(reqs).forEach(function (uid) {
|
||||
if (reqs[uid] && reqs[uid].abort) {
|
||||
reqs[uid].abort();
|
||||
}
|
||||
delete reqs[uid];
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props4 = this.props,
|
||||
Tag = _this$props4.component,
|
||||
prefixCls = _this$props4.prefixCls,
|
||||
className = _this$props4.className,
|
||||
_this$props4$classNam = _this$props4.classNames,
|
||||
classNames = _this$props4$classNam === void 0 ? {} : _this$props4$classNam,
|
||||
disabled = _this$props4.disabled,
|
||||
id = _this$props4.id,
|
||||
name = _this$props4.name,
|
||||
style = _this$props4.style,
|
||||
_this$props4$styles = _this$props4.styles,
|
||||
styles = _this$props4$styles === void 0 ? {} : _this$props4$styles,
|
||||
multiple = _this$props4.multiple,
|
||||
accept = _this$props4.accept,
|
||||
capture = _this$props4.capture,
|
||||
children = _this$props4.children,
|
||||
directory = _this$props4.directory,
|
||||
folder = _this$props4.folder,
|
||||
openFileDialogOnClick = _this$props4.openFileDialogOnClick,
|
||||
onMouseEnter = _this$props4.onMouseEnter,
|
||||
onMouseLeave = _this$props4.onMouseLeave,
|
||||
hasControlInside = _this$props4.hasControlInside,
|
||||
otherProps = _objectWithoutProperties(_this$props4, _excluded);
|
||||
var cls = clsx(_defineProperty(_defineProperty(_defineProperty({}, prefixCls, true), "".concat(prefixCls, "-disabled"), disabled), className, className));
|
||||
// because input don't have directory/webkitdirectory type declaration
|
||||
var dirProps = directory || folder ? {
|
||||
directory: 'directory',
|
||||
webkitdirectory: 'webkitdirectory'
|
||||
} : {};
|
||||
var events = disabled ? {} : {
|
||||
onClick: openFileDialogOnClick ? this.onClick : function () {},
|
||||
onKeyDown: openFileDialogOnClick ? this.onKeyDown : function () {},
|
||||
onMouseEnter: onMouseEnter,
|
||||
onMouseLeave: onMouseLeave,
|
||||
onDrop: this.onFileDrop,
|
||||
onDragOver: this.onFileDragOver,
|
||||
tabIndex: hasControlInside ? undefined : '0'
|
||||
};
|
||||
return /*#__PURE__*/React.createElement(Tag, _extends({}, events, {
|
||||
className: cls,
|
||||
role: hasControlInside ? undefined : 'button',
|
||||
style: style
|
||||
}), /*#__PURE__*/React.createElement("input", _extends({}, pickAttrs(otherProps, {
|
||||
aria: true,
|
||||
data: true
|
||||
}), {
|
||||
id: id
|
||||
/**
|
||||
* https://github.com/ant-design/ant-design/issues/50643,
|
||||
* https://github.com/react-component/upload/pull/575#issuecomment-2320646552
|
||||
*/,
|
||||
name: name,
|
||||
disabled: disabled,
|
||||
type: "file",
|
||||
ref: this.saveFileInput,
|
||||
onClick: function onClick(e) {
|
||||
return e.stopPropagation();
|
||||
} // https://github.com/ant-design/ant-design/issues/19948
|
||||
,
|
||||
key: this.state.uid,
|
||||
style: _objectSpread({
|
||||
display: 'none'
|
||||
}, styles.input),
|
||||
className: classNames.input,
|
||||
accept: accept
|
||||
}, dirProps, {
|
||||
multiple: multiple,
|
||||
onChange: this.onChange
|
||||
}, capture != null ? {
|
||||
capture: capture
|
||||
} : {})), children);
|
||||
}
|
||||
}]);
|
||||
return AjaxUploader;
|
||||
}(Component);
|
||||
export default AjaxUploader;
|
||||
28
frontend/node_modules/rc-upload/es/Upload.d.ts
generated
vendored
Normal file
28
frontend/node_modules/rc-upload/es/Upload.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import React, { Component } from 'react';
|
||||
import AjaxUpload from './AjaxUploader';
|
||||
import type { UploadProps, RcFile } from './interface';
|
||||
declare function empty(): void;
|
||||
declare class Upload extends Component<UploadProps> {
|
||||
static defaultProps: {
|
||||
component: string;
|
||||
prefixCls: string;
|
||||
data: {};
|
||||
headers: {};
|
||||
name: string;
|
||||
multipart: boolean;
|
||||
onStart: typeof empty;
|
||||
onError: typeof empty;
|
||||
onSuccess: typeof empty;
|
||||
multiple: boolean;
|
||||
beforeUpload: any;
|
||||
customRequest: any;
|
||||
withCredentials: boolean;
|
||||
openFileDialogOnClick: boolean;
|
||||
hasControlInside: boolean;
|
||||
};
|
||||
private uploader;
|
||||
abort(file: RcFile): void;
|
||||
saveUploader: (node: AjaxUpload) => void;
|
||||
render(): React.JSX.Element;
|
||||
}
|
||||
export default Upload;
|
||||
60
frontend/node_modules/rc-upload/es/Upload.js
generated
vendored
Normal file
60
frontend/node_modules/rc-upload/es/Upload.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
||||
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
||||
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
||||
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
/* eslint react/prop-types:0 */
|
||||
import React, { Component } from 'react';
|
||||
import AjaxUpload from "./AjaxUploader";
|
||||
function empty() {}
|
||||
var Upload = /*#__PURE__*/function (_Component) {
|
||||
_inherits(Upload, _Component);
|
||||
var _super = _createSuper(Upload);
|
||||
function Upload() {
|
||||
var _this;
|
||||
_classCallCheck(this, Upload);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
_this = _super.call.apply(_super, [this].concat(args));
|
||||
_defineProperty(_assertThisInitialized(_this), "uploader", void 0);
|
||||
_defineProperty(_assertThisInitialized(_this), "saveUploader", function (node) {
|
||||
_this.uploader = node;
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
_createClass(Upload, [{
|
||||
key: "abort",
|
||||
value: function abort(file) {
|
||||
this.uploader.abort(file);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
return /*#__PURE__*/React.createElement(AjaxUpload, _extends({}, this.props, {
|
||||
ref: this.saveUploader
|
||||
}));
|
||||
}
|
||||
}]);
|
||||
return Upload;
|
||||
}(Component);
|
||||
_defineProperty(Upload, "defaultProps", {
|
||||
component: 'span',
|
||||
prefixCls: 'rc-upload',
|
||||
data: {},
|
||||
headers: {},
|
||||
name: 'file',
|
||||
multipart: false,
|
||||
onStart: empty,
|
||||
onError: empty,
|
||||
onSuccess: empty,
|
||||
multiple: false,
|
||||
beforeUpload: null,
|
||||
customRequest: null,
|
||||
withCredentials: false,
|
||||
openFileDialogOnClick: true,
|
||||
hasControlInside: false
|
||||
});
|
||||
export default Upload;
|
||||
3
frontend/node_modules/rc-upload/es/attr-accept.d.ts
generated
vendored
Normal file
3
frontend/node_modules/rc-upload/es/attr-accept.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { RcFile } from './interface';
|
||||
declare const _default: (file: RcFile, acceptedFiles: string | string[]) => boolean;
|
||||
export default _default;
|
||||
47
frontend/node_modules/rc-upload/es/attr-accept.js
generated
vendored
Normal file
47
frontend/node_modules/rc-upload/es/attr-accept.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import warning from "rc-util/es/warning";
|
||||
export default (function (file, acceptedFiles) {
|
||||
if (file && acceptedFiles) {
|
||||
var acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(',');
|
||||
var fileName = file.name || '';
|
||||
var mimeType = file.type || '';
|
||||
var baseMimeType = mimeType.replace(/\/.*$/, '');
|
||||
return acceptedFilesArray.some(function (type) {
|
||||
var validType = type.trim();
|
||||
// This is something like */*,* allow all files
|
||||
if (/^\*(\/\*)?$/.test(type)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// like .jpg, .png
|
||||
if (validType.charAt(0) === '.') {
|
||||
var lowerFileName = fileName.toLowerCase();
|
||||
var lowerType = validType.toLowerCase();
|
||||
var affixList = [lowerType];
|
||||
if (lowerType === '.jpg' || lowerType === '.jpeg') {
|
||||
affixList = ['.jpg', '.jpeg'];
|
||||
}
|
||||
return affixList.some(function (affix) {
|
||||
return lowerFileName.endsWith(affix);
|
||||
});
|
||||
}
|
||||
|
||||
// This is something like a image/* mime type
|
||||
if (/\/\*$/.test(validType)) {
|
||||
return baseMimeType === validType.replace(/\/.*$/, '');
|
||||
}
|
||||
|
||||
// Full match
|
||||
if (mimeType === validType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Invalidate type should skip
|
||||
if (/^\w+$/.test(validType)) {
|
||||
warning(false, "Upload takes an invalidate 'accept' type '".concat(validType, "'.Skip for check."));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return true;
|
||||
});
|
||||
4
frontend/node_modules/rc-upload/es/index.d.ts
generated
vendored
Normal file
4
frontend/node_modules/rc-upload/es/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { UploadProps } from './interface';
|
||||
import Upload from './Upload';
|
||||
export type { UploadProps };
|
||||
export default Upload;
|
||||
2
frontend/node_modules/rc-upload/es/index.js
generated
vendored
Normal file
2
frontend/node_modules/rc-upload/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import Upload from "./Upload";
|
||||
export default Upload;
|
||||
77
frontend/node_modules/rc-upload/es/interface.d.ts
generated
vendored
Normal file
77
frontend/node_modules/rc-upload/es/interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
import type * as React from 'react';
|
||||
export type BeforeUploadFileType = File | Blob | boolean | string;
|
||||
export type Action = string | ((file: RcFile) => string | PromiseLike<string>);
|
||||
export interface UploadProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onError' | 'onProgress'> {
|
||||
name?: string;
|
||||
style?: React.CSSProperties;
|
||||
className?: string;
|
||||
disabled?: boolean;
|
||||
component?: React.ComponentType<any> | string;
|
||||
action?: Action;
|
||||
method?: UploadRequestMethod;
|
||||
/** @deprecated Please use `folder` instead */
|
||||
directory?: boolean;
|
||||
folder?: boolean;
|
||||
data?: Record<string, unknown> | ((file: RcFile | string | Blob) => Record<string, unknown>);
|
||||
headers?: UploadRequestHeader;
|
||||
accept?: string;
|
||||
multiple?: boolean;
|
||||
onBatchStart?: (fileList: {
|
||||
file: RcFile;
|
||||
parsedFile: Exclude<BeforeUploadFileType, boolean>;
|
||||
}[]) => void;
|
||||
onStart?: (file: RcFile) => void;
|
||||
onError?: (error: Error, ret: Record<string, unknown>, file: RcFile) => void;
|
||||
onSuccess?: (response: Record<string, unknown>, file: RcFile, xhr: XMLHttpRequest) => void;
|
||||
onProgress?: (event: UploadProgressEvent, file: RcFile) => void;
|
||||
beforeUpload?: (file: RcFile, FileList: RcFile[]) => BeforeUploadFileType | Promise<void | BeforeUploadFileType> | void;
|
||||
customRequest?: CustomUploadRequestOption;
|
||||
withCredentials?: boolean;
|
||||
openFileDialogOnClick?: boolean;
|
||||
prefixCls?: string;
|
||||
id?: string;
|
||||
onMouseEnter?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
||||
onMouseLeave?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
||||
onClick?: (e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => void;
|
||||
classNames?: {
|
||||
input?: string;
|
||||
};
|
||||
styles?: {
|
||||
input?: React.CSSProperties;
|
||||
};
|
||||
hasControlInside?: boolean;
|
||||
pastable?: boolean;
|
||||
}
|
||||
export interface UploadProgressEvent extends Partial<ProgressEvent> {
|
||||
percent?: number;
|
||||
}
|
||||
export type UploadRequestMethod = 'POST' | 'PUT' | 'PATCH' | 'post' | 'put' | 'patch';
|
||||
export type UploadRequestHeader = Record<string, string>;
|
||||
export type UploadRequestFile = Exclude<BeforeUploadFileType, File | boolean> | RcFile;
|
||||
export interface UploadRequestError extends Error {
|
||||
status?: number;
|
||||
method?: UploadRequestMethod;
|
||||
url?: string;
|
||||
}
|
||||
export interface UploadRequestOption<T = any> {
|
||||
onProgress?: (event: UploadProgressEvent, file?: UploadRequestFile) => void;
|
||||
onError?: (event: UploadRequestError | ProgressEvent, body?: T) => void;
|
||||
onSuccess?: (body: T, fileOrXhr?: UploadRequestFile | XMLHttpRequest) => void;
|
||||
data?: Record<string, unknown>;
|
||||
filename?: string;
|
||||
file: UploadRequestFile;
|
||||
withCredentials?: boolean;
|
||||
action: string;
|
||||
headers?: UploadRequestHeader;
|
||||
method: UploadRequestMethod;
|
||||
}
|
||||
export type CustomUploadRequestOption = (option: UploadRequestOption, info: {
|
||||
defaultRequest: (option: UploadRequestOption) => {
|
||||
abort: () => void;
|
||||
} | void;
|
||||
}) => void | {
|
||||
abort: () => void;
|
||||
};
|
||||
export interface RcFile extends File {
|
||||
uid: string;
|
||||
}
|
||||
1
frontend/node_modules/rc-upload/es/interface.js
generated
vendored
Normal file
1
frontend/node_modules/rc-upload/es/interface.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
4
frontend/node_modules/rc-upload/es/request.d.ts
generated
vendored
Normal file
4
frontend/node_modules/rc-upload/es/request.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { UploadRequestOption } from './interface';
|
||||
export default function upload(option: UploadRequestOption): {
|
||||
abort(): void;
|
||||
};
|
||||
91
frontend/node_modules/rc-upload/es/request.js
generated
vendored
Normal file
91
frontend/node_modules/rc-upload/es/request.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
function getError(option, xhr) {
|
||||
var msg = "cannot ".concat(option.method, " ").concat(option.action, " ").concat(xhr.status, "'");
|
||||
var err = new Error(msg);
|
||||
err.status = xhr.status;
|
||||
err.method = option.method;
|
||||
err.url = option.action;
|
||||
return err;
|
||||
}
|
||||
function getBody(xhr) {
|
||||
var text = xhr.responseText || xhr.response;
|
||||
if (!text) {
|
||||
return text;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(text);
|
||||
} catch (e) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
export default function upload(option) {
|
||||
// eslint-disable-next-line no-undef
|
||||
var xhr = new XMLHttpRequest();
|
||||
if (option.onProgress && xhr.upload) {
|
||||
xhr.upload.onprogress = function progress(e) {
|
||||
if (e.total > 0) {
|
||||
e.percent = e.loaded / e.total * 100;
|
||||
}
|
||||
option.onProgress(e);
|
||||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
var formData = new FormData();
|
||||
if (option.data) {
|
||||
Object.keys(option.data).forEach(function (key) {
|
||||
var value = option.data[key];
|
||||
// support key-value array data
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach(function (item) {
|
||||
// { list: [ 11, 22 ] }
|
||||
// formData.append('list[]', 11);
|
||||
formData.append("".concat(key, "[]"), item);
|
||||
});
|
||||
return;
|
||||
}
|
||||
formData.append(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
if (option.file instanceof Blob) {
|
||||
formData.append(option.filename, option.file, option.file.name);
|
||||
} else {
|
||||
formData.append(option.filename, option.file);
|
||||
}
|
||||
xhr.onerror = function error(e) {
|
||||
option.onError(e);
|
||||
};
|
||||
xhr.onload = function onload() {
|
||||
// allow success when 2xx status
|
||||
// see https://github.com/react-component/upload/issues/34
|
||||
if (xhr.status < 200 || xhr.status >= 300) {
|
||||
return option.onError(getError(option, xhr), getBody(xhr));
|
||||
}
|
||||
return option.onSuccess(getBody(xhr), xhr);
|
||||
};
|
||||
xhr.open(option.method, option.action, true);
|
||||
|
||||
// Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179
|
||||
if (option.withCredentials && 'withCredentials' in xhr) {
|
||||
xhr.withCredentials = true;
|
||||
}
|
||||
var headers = option.headers || {};
|
||||
|
||||
// when set headers['X-Requested-With'] = null , can close default XHR header
|
||||
// see https://github.com/react-component/upload/issues/33
|
||||
if (headers['X-Requested-With'] !== null) {
|
||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
}
|
||||
Object.keys(headers).forEach(function (h) {
|
||||
if (headers[h] !== null) {
|
||||
xhr.setRequestHeader(h, headers[h]);
|
||||
}
|
||||
});
|
||||
xhr.send(formData);
|
||||
return {
|
||||
abort: function abort() {
|
||||
xhr.abort();
|
||||
}
|
||||
};
|
||||
}
|
||||
14
frontend/node_modules/rc-upload/es/traverseFileTree.d.ts
generated
vendored
Normal file
14
frontend/node_modules/rc-upload/es/traverseFileTree.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { RcFile } from './interface';
|
||||
interface InternalDataTransferItem extends DataTransferItem {
|
||||
isFile: boolean;
|
||||
file: (cd: (file: RcFile & {
|
||||
webkitRelativePath?: string;
|
||||
}) => void) => void;
|
||||
createReader: () => any;
|
||||
fullPath: string;
|
||||
isDirectory: boolean;
|
||||
name: string;
|
||||
path: string;
|
||||
}
|
||||
declare const traverseFileTree: (files: InternalDataTransferItem[], isAccepted: any) => Promise<any[]>;
|
||||
export default traverseFileTree;
|
||||
175
frontend/node_modules/rc-upload/es/traverseFileTree.js
generated
vendored
Normal file
175
frontend/node_modules/rc-upload/es/traverseFileTree.js
generated
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
||||
// https://github.com/ant-design/ant-design/issues/50080
|
||||
var traverseFileTree = /*#__PURE__*/function () {
|
||||
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(files, isAccepted) {
|
||||
var flattenFileList, progressFileList, readDirectory, _readDirectory, readFile, _readFile, _traverseFileTree, wipIndex;
|
||||
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
||||
while (1) switch (_context4.prev = _context4.next) {
|
||||
case 0:
|
||||
_readFile = function _readFile3() {
|
||||
_readFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(item) {
|
||||
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
||||
while (1) switch (_context3.prev = _context3.next) {
|
||||
case 0:
|
||||
return _context3.abrupt("return", new Promise(function (reslove) {
|
||||
item.file(function (file) {
|
||||
if (isAccepted(file)) {
|
||||
// https://github.com/ant-design/ant-design/issues/16426
|
||||
if (item.fullPath && !file.webkitRelativePath) {
|
||||
Object.defineProperties(file, {
|
||||
webkitRelativePath: {
|
||||
writable: true
|
||||
}
|
||||
});
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
file.webkitRelativePath = item.fullPath.replace(/^\//, '');
|
||||
Object.defineProperties(file, {
|
||||
webkitRelativePath: {
|
||||
writable: false
|
||||
}
|
||||
});
|
||||
}
|
||||
reslove(file);
|
||||
} else {
|
||||
reslove(null);
|
||||
}
|
||||
});
|
||||
}));
|
||||
case 1:
|
||||
case "end":
|
||||
return _context3.stop();
|
||||
}
|
||||
}, _callee3);
|
||||
}));
|
||||
return _readFile.apply(this, arguments);
|
||||
};
|
||||
readFile = function _readFile2(_x4) {
|
||||
return _readFile.apply(this, arguments);
|
||||
};
|
||||
_readDirectory = function _readDirectory3() {
|
||||
_readDirectory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(directory) {
|
||||
var dirReader, entries, results, n, i;
|
||||
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
||||
while (1) switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
dirReader = directory.createReader();
|
||||
entries = [];
|
||||
case 2:
|
||||
if (!true) {
|
||||
_context2.next = 12;
|
||||
break;
|
||||
}
|
||||
_context2.next = 5;
|
||||
return new Promise(function (resolve) {
|
||||
dirReader.readEntries(resolve, function () {
|
||||
return resolve([]);
|
||||
});
|
||||
});
|
||||
case 5:
|
||||
results = _context2.sent;
|
||||
n = results.length;
|
||||
if (n) {
|
||||
_context2.next = 9;
|
||||
break;
|
||||
}
|
||||
return _context2.abrupt("break", 12);
|
||||
case 9:
|
||||
for (i = 0; i < n; i++) {
|
||||
entries.push(results[i]);
|
||||
}
|
||||
_context2.next = 2;
|
||||
break;
|
||||
case 12:
|
||||
return _context2.abrupt("return", entries);
|
||||
case 13:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
}
|
||||
}, _callee2);
|
||||
}));
|
||||
return _readDirectory.apply(this, arguments);
|
||||
};
|
||||
readDirectory = function _readDirectory2(_x3) {
|
||||
return _readDirectory.apply(this, arguments);
|
||||
};
|
||||
flattenFileList = [];
|
||||
progressFileList = [];
|
||||
files.forEach(function (file) {
|
||||
return progressFileList.push(file.webkitGetAsEntry());
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
_traverseFileTree = /*#__PURE__*/function () {
|
||||
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(item, path) {
|
||||
var _file, entries;
|
||||
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
||||
while (1) switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
if (item) {
|
||||
_context.next = 2;
|
||||
break;
|
||||
}
|
||||
return _context.abrupt("return");
|
||||
case 2:
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
item.path = path || '';
|
||||
if (!item.isFile) {
|
||||
_context.next = 10;
|
||||
break;
|
||||
}
|
||||
_context.next = 6;
|
||||
return readFile(item);
|
||||
case 6:
|
||||
_file = _context.sent;
|
||||
if (_file) {
|
||||
flattenFileList.push(_file);
|
||||
}
|
||||
_context.next = 15;
|
||||
break;
|
||||
case 10:
|
||||
if (!item.isDirectory) {
|
||||
_context.next = 15;
|
||||
break;
|
||||
}
|
||||
_context.next = 13;
|
||||
return readDirectory(item);
|
||||
case 13:
|
||||
entries = _context.sent;
|
||||
progressFileList.push.apply(progressFileList, _toConsumableArray(entries));
|
||||
case 15:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
return function _traverseFileTree(_x5, _x6) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
wipIndex = 0;
|
||||
case 9:
|
||||
if (!(wipIndex < progressFileList.length)) {
|
||||
_context4.next = 15;
|
||||
break;
|
||||
}
|
||||
_context4.next = 12;
|
||||
return _traverseFileTree(progressFileList[wipIndex]);
|
||||
case 12:
|
||||
wipIndex++;
|
||||
_context4.next = 9;
|
||||
break;
|
||||
case 15:
|
||||
return _context4.abrupt("return", flattenFileList);
|
||||
case 16:
|
||||
case "end":
|
||||
return _context4.stop();
|
||||
}
|
||||
}, _callee4);
|
||||
}));
|
||||
return function traverseFileTree(_x, _x2) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
export default traverseFileTree;
|
||||
1
frontend/node_modules/rc-upload/es/uid.d.ts
generated
vendored
Normal file
1
frontend/node_modules/rc-upload/es/uid.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default function uid(): string;
|
||||
6
frontend/node_modules/rc-upload/es/uid.js
generated
vendored
Normal file
6
frontend/node_modules/rc-upload/es/uid.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
var now = +new Date();
|
||||
var index = 0;
|
||||
export default function uid() {
|
||||
// eslint-disable-next-line no-plusplus
|
||||
return "rc-upload-".concat(now, "-").concat(++index);
|
||||
}
|
||||
37
frontend/node_modules/rc-upload/lib/AjaxUploader.d.ts
generated
vendored
Normal file
37
frontend/node_modules/rc-upload/lib/AjaxUploader.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import React, { Component } from 'react';
|
||||
import type { RcFile, UploadProps } from './interface';
|
||||
interface ParsedFileInfo {
|
||||
origin: RcFile;
|
||||
action: string;
|
||||
data: Record<string, unknown>;
|
||||
parsedFile: RcFile;
|
||||
}
|
||||
declare class AjaxUploader extends Component<UploadProps> {
|
||||
state: {
|
||||
uid: string;
|
||||
};
|
||||
reqs: Record<string, any>;
|
||||
private fileInput;
|
||||
private _isMounted;
|
||||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
||||
onClick: (event: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => void;
|
||||
onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
||||
onDataTransferFiles: (dataTransfer: DataTransfer, existFileCallback?: () => void) => Promise<void>;
|
||||
onFilePaste: (e: ClipboardEvent) => Promise<void>;
|
||||
onFileDragOver: (e: React.DragEvent<HTMLDivElement>) => void;
|
||||
onFileDrop: (e: React.DragEvent<HTMLDivElement>) => Promise<void>;
|
||||
componentDidMount(): void;
|
||||
componentWillUnmount(): void;
|
||||
componentDidUpdate(prevProps: UploadProps): void;
|
||||
uploadFiles: (files: File[]) => void;
|
||||
/**
|
||||
* Process file before upload. When all the file is ready, we start upload.
|
||||
*/
|
||||
processFile: (file: RcFile, fileList: RcFile[]) => Promise<ParsedFileInfo>;
|
||||
post({ data, origin, action, parsedFile }: ParsedFileInfo): void;
|
||||
reset(): void;
|
||||
abort(file?: any): void;
|
||||
saveFileInput: (node: HTMLInputElement) => void;
|
||||
render(): React.JSX.Element;
|
||||
}
|
||||
export default AjaxUploader;
|
||||
489
frontend/node_modules/rc-upload/lib/AjaxUploader.js
generated
vendored
Normal file
489
frontend/node_modules/rc-upload/lib/AjaxUploader.js
generated
vendored
Normal file
@@ -0,0 +1,489 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
||||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
||||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
||||
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
||||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
||||
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
||||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
||||
var _classnames = _interopRequireDefault(require("classnames"));
|
||||
var _pickAttrs = _interopRequireDefault(require("rc-util/lib/pickAttrs"));
|
||||
var _react = _interopRequireWildcard(require("react"));
|
||||
var _attrAccept = _interopRequireDefault(require("./attr-accept"));
|
||||
var _request = _interopRequireDefault(require("./request"));
|
||||
var _traverseFileTree = _interopRequireDefault(require("./traverseFileTree"));
|
||||
var _uid = _interopRequireDefault(require("./uid"));
|
||||
var _excluded = ["component", "prefixCls", "className", "classNames", "disabled", "id", "name", "style", "styles", "multiple", "accept", "capture", "children", "directory", "folder", "openFileDialogOnClick", "onMouseEnter", "onMouseLeave", "hasControlInside"];
|
||||
/* eslint react/no-is-mounted:0,react/sort-comp:0,react/prop-types:0 */
|
||||
var AjaxUploader = /*#__PURE__*/function (_Component) {
|
||||
(0, _inherits2.default)(AjaxUploader, _Component);
|
||||
var _super = (0, _createSuper2.default)(AjaxUploader);
|
||||
function AjaxUploader() {
|
||||
var _this;
|
||||
(0, _classCallCheck2.default)(this, AjaxUploader);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
_this = _super.call.apply(_super, [this].concat(args));
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
||||
uid: (0, _uid.default)()
|
||||
});
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "reqs", {});
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fileInput", void 0);
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_isMounted", void 0);
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onChange", function (e) {
|
||||
var _this$props = _this.props,
|
||||
accept = _this$props.accept,
|
||||
directory = _this$props.directory;
|
||||
var files = e.target.files;
|
||||
var acceptedFiles = (0, _toConsumableArray2.default)(files).filter(function (file) {
|
||||
return !directory || (0, _attrAccept.default)(file, accept);
|
||||
});
|
||||
_this.uploadFiles(acceptedFiles);
|
||||
_this.reset();
|
||||
});
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClick", function (event) {
|
||||
var el = _this.fileInput;
|
||||
if (!el) {
|
||||
return;
|
||||
}
|
||||
var target = event.target;
|
||||
var onClick = _this.props.onClick;
|
||||
if (target && target.tagName === 'BUTTON') {
|
||||
var parent = el.parentNode;
|
||||
parent.focus();
|
||||
target.blur();
|
||||
}
|
||||
el.click();
|
||||
if (onClick) {
|
||||
onClick(event);
|
||||
}
|
||||
});
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onKeyDown", function (e) {
|
||||
if (e.key === 'Enter') {
|
||||
_this.onClick(e);
|
||||
}
|
||||
});
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDataTransferFiles", /*#__PURE__*/function () {
|
||||
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(dataTransfer, existFileCallback) {
|
||||
var _this$props2, multiple, accept, directory, items, files, acceptFiles;
|
||||
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
||||
while (1) switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
_this$props2 = _this.props, multiple = _this$props2.multiple, accept = _this$props2.accept, directory = _this$props2.directory;
|
||||
items = (0, _toConsumableArray2.default)(dataTransfer.items || []);
|
||||
files = (0, _toConsumableArray2.default)(dataTransfer.files || []);
|
||||
if (files.length > 0 || items.some(function (item) {
|
||||
return item.kind === 'file';
|
||||
})) {
|
||||
existFileCallback === null || existFileCallback === void 0 || existFileCallback();
|
||||
}
|
||||
if (!directory) {
|
||||
_context.next = 11;
|
||||
break;
|
||||
}
|
||||
_context.next = 7;
|
||||
return (0, _traverseFileTree.default)(Array.prototype.slice.call(items), function (_file) {
|
||||
return (0, _attrAccept.default)(_file, _this.props.accept);
|
||||
});
|
||||
case 7:
|
||||
files = _context.sent;
|
||||
_this.uploadFiles(files);
|
||||
_context.next = 14;
|
||||
break;
|
||||
case 11:
|
||||
acceptFiles = (0, _toConsumableArray2.default)(files).filter(function (file) {
|
||||
return (0, _attrAccept.default)(file, accept);
|
||||
});
|
||||
if (multiple === false) {
|
||||
acceptFiles = files.slice(0, 1);
|
||||
}
|
||||
_this.uploadFiles(acceptFiles);
|
||||
case 14:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
return function (_x, _x2) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}());
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onFilePaste", /*#__PURE__*/function () {
|
||||
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(e) {
|
||||
var pastable, clipboardData;
|
||||
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
||||
while (1) switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
pastable = _this.props.pastable;
|
||||
if (pastable) {
|
||||
_context2.next = 3;
|
||||
break;
|
||||
}
|
||||
return _context2.abrupt("return");
|
||||
case 3:
|
||||
if (!(e.type === 'paste')) {
|
||||
_context2.next = 6;
|
||||
break;
|
||||
}
|
||||
clipboardData = e.clipboardData;
|
||||
return _context2.abrupt("return", _this.onDataTransferFiles(clipboardData, function () {
|
||||
e.preventDefault();
|
||||
}));
|
||||
case 6:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
}
|
||||
}, _callee2);
|
||||
}));
|
||||
return function (_x3) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
}());
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onFileDragOver", function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onFileDrop", /*#__PURE__*/function () {
|
||||
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3(e) {
|
||||
var dataTransfer;
|
||||
return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
|
||||
while (1) switch (_context3.prev = _context3.next) {
|
||||
case 0:
|
||||
e.preventDefault();
|
||||
if (!(e.type === 'drop')) {
|
||||
_context3.next = 4;
|
||||
break;
|
||||
}
|
||||
dataTransfer = e.dataTransfer;
|
||||
return _context3.abrupt("return", _this.onDataTransferFiles(dataTransfer));
|
||||
case 4:
|
||||
case "end":
|
||||
return _context3.stop();
|
||||
}
|
||||
}, _callee3);
|
||||
}));
|
||||
return function (_x4) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
}());
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "uploadFiles", function (files) {
|
||||
var originFiles = (0, _toConsumableArray2.default)(files);
|
||||
var postFiles = originFiles.map(function (file) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
file.uid = (0, _uid.default)();
|
||||
return _this.processFile(file, originFiles);
|
||||
});
|
||||
|
||||
// Batch upload files
|
||||
Promise.all(postFiles).then(function (fileList) {
|
||||
var onBatchStart = _this.props.onBatchStart;
|
||||
onBatchStart === null || onBatchStart === void 0 || onBatchStart(fileList.map(function (_ref4) {
|
||||
var origin = _ref4.origin,
|
||||
parsedFile = _ref4.parsedFile;
|
||||
return {
|
||||
file: origin,
|
||||
parsedFile: parsedFile
|
||||
};
|
||||
}));
|
||||
fileList.filter(function (file) {
|
||||
return file.parsedFile !== null;
|
||||
}).forEach(function (file) {
|
||||
_this.post(file);
|
||||
});
|
||||
});
|
||||
});
|
||||
/**
|
||||
* Process file before upload. When all the file is ready, we start upload.
|
||||
*/
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "processFile", /*#__PURE__*/function () {
|
||||
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee4(file, fileList) {
|
||||
var beforeUpload, transformedFile, action, mergedAction, data, mergedData, parsedData, parsedFile, mergedParsedFile;
|
||||
return (0, _regeneratorRuntime2.default)().wrap(function _callee4$(_context4) {
|
||||
while (1) switch (_context4.prev = _context4.next) {
|
||||
case 0:
|
||||
beforeUpload = _this.props.beforeUpload;
|
||||
transformedFile = file;
|
||||
if (!beforeUpload) {
|
||||
_context4.next = 14;
|
||||
break;
|
||||
}
|
||||
_context4.prev = 3;
|
||||
_context4.next = 6;
|
||||
return beforeUpload(file, fileList);
|
||||
case 6:
|
||||
transformedFile = _context4.sent;
|
||||
_context4.next = 12;
|
||||
break;
|
||||
case 9:
|
||||
_context4.prev = 9;
|
||||
_context4.t0 = _context4["catch"](3);
|
||||
// Rejection will also trade as false
|
||||
transformedFile = false;
|
||||
case 12:
|
||||
if (!(transformedFile === false)) {
|
||||
_context4.next = 14;
|
||||
break;
|
||||
}
|
||||
return _context4.abrupt("return", {
|
||||
origin: file,
|
||||
parsedFile: null,
|
||||
action: null,
|
||||
data: null
|
||||
});
|
||||
case 14:
|
||||
// Get latest action
|
||||
action = _this.props.action;
|
||||
if (!(typeof action === 'function')) {
|
||||
_context4.next = 21;
|
||||
break;
|
||||
}
|
||||
_context4.next = 18;
|
||||
return action(file);
|
||||
case 18:
|
||||
mergedAction = _context4.sent;
|
||||
_context4.next = 22;
|
||||
break;
|
||||
case 21:
|
||||
mergedAction = action;
|
||||
case 22:
|
||||
// Get latest data
|
||||
data = _this.props.data;
|
||||
if (!(typeof data === 'function')) {
|
||||
_context4.next = 29;
|
||||
break;
|
||||
}
|
||||
_context4.next = 26;
|
||||
return data(file);
|
||||
case 26:
|
||||
mergedData = _context4.sent;
|
||||
_context4.next = 30;
|
||||
break;
|
||||
case 29:
|
||||
mergedData = data;
|
||||
case 30:
|
||||
parsedData =
|
||||
// string type is from legacy `transformFile`.
|
||||
// Not sure if this will work since no related test case works with it
|
||||
((0, _typeof2.default)(transformedFile) === 'object' || typeof transformedFile === 'string') && transformedFile ? transformedFile : file;
|
||||
if (parsedData instanceof File) {
|
||||
parsedFile = parsedData;
|
||||
} else {
|
||||
parsedFile = new File([parsedData], file.name, {
|
||||
type: file.type
|
||||
});
|
||||
}
|
||||
mergedParsedFile = parsedFile;
|
||||
mergedParsedFile.uid = file.uid;
|
||||
return _context4.abrupt("return", {
|
||||
origin: file,
|
||||
data: mergedData,
|
||||
parsedFile: mergedParsedFile,
|
||||
action: mergedAction
|
||||
});
|
||||
case 35:
|
||||
case "end":
|
||||
return _context4.stop();
|
||||
}
|
||||
}, _callee4, null, [[3, 9]]);
|
||||
}));
|
||||
return function (_x5, _x6) {
|
||||
return _ref5.apply(this, arguments);
|
||||
};
|
||||
}());
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "saveFileInput", function (node) {
|
||||
_this.fileInput = node;
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
(0, _createClass2.default)(AjaxUploader, [{
|
||||
key: "componentDidMount",
|
||||
value: function componentDidMount() {
|
||||
this._isMounted = true;
|
||||
var pastable = this.props.pastable;
|
||||
if (pastable) {
|
||||
document.addEventListener('paste', this.onFilePaste);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "componentWillUnmount",
|
||||
value: function componentWillUnmount() {
|
||||
this._isMounted = false;
|
||||
this.abort();
|
||||
document.removeEventListener('paste', this.onFilePaste);
|
||||
}
|
||||
}, {
|
||||
key: "componentDidUpdate",
|
||||
value: function componentDidUpdate(prevProps) {
|
||||
var pastable = this.props.pastable;
|
||||
if (pastable && !prevProps.pastable) {
|
||||
document.addEventListener('paste', this.onFilePaste);
|
||||
} else if (!pastable && prevProps.pastable) {
|
||||
document.removeEventListener('paste', this.onFilePaste);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "post",
|
||||
value: function post(_ref6) {
|
||||
var _this2 = this;
|
||||
var data = _ref6.data,
|
||||
origin = _ref6.origin,
|
||||
action = _ref6.action,
|
||||
parsedFile = _ref6.parsedFile;
|
||||
if (!this._isMounted) {
|
||||
return;
|
||||
}
|
||||
var _this$props3 = this.props,
|
||||
onStart = _this$props3.onStart,
|
||||
customRequest = _this$props3.customRequest,
|
||||
name = _this$props3.name,
|
||||
headers = _this$props3.headers,
|
||||
withCredentials = _this$props3.withCredentials,
|
||||
method = _this$props3.method;
|
||||
var uid = origin.uid;
|
||||
var request = customRequest || _request.default;
|
||||
var requestOption = {
|
||||
action: action,
|
||||
filename: name,
|
||||
data: data,
|
||||
file: parsedFile,
|
||||
headers: headers,
|
||||
withCredentials: withCredentials,
|
||||
method: method || 'post',
|
||||
onProgress: function onProgress(e) {
|
||||
var onProgress = _this2.props.onProgress;
|
||||
onProgress === null || onProgress === void 0 || onProgress(e, parsedFile);
|
||||
},
|
||||
onSuccess: function onSuccess(ret, xhr) {
|
||||
var onSuccess = _this2.props.onSuccess;
|
||||
onSuccess === null || onSuccess === void 0 || onSuccess(ret, parsedFile, xhr);
|
||||
delete _this2.reqs[uid];
|
||||
},
|
||||
onError: function onError(err, ret) {
|
||||
var onError = _this2.props.onError;
|
||||
onError === null || onError === void 0 || onError(err, ret, parsedFile);
|
||||
delete _this2.reqs[uid];
|
||||
}
|
||||
};
|
||||
onStart(origin);
|
||||
this.reqs[uid] = request(requestOption, {
|
||||
defaultRequest: _request.default
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "reset",
|
||||
value: function reset() {
|
||||
this.setState({
|
||||
uid: (0, _uid.default)()
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "abort",
|
||||
value: function abort(file) {
|
||||
var reqs = this.reqs;
|
||||
if (file) {
|
||||
var uid = file.uid ? file.uid : file;
|
||||
if (reqs[uid] && reqs[uid].abort) {
|
||||
reqs[uid].abort();
|
||||
}
|
||||
delete reqs[uid];
|
||||
} else {
|
||||
Object.keys(reqs).forEach(function (uid) {
|
||||
if (reqs[uid] && reqs[uid].abort) {
|
||||
reqs[uid].abort();
|
||||
}
|
||||
delete reqs[uid];
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props4 = this.props,
|
||||
Tag = _this$props4.component,
|
||||
prefixCls = _this$props4.prefixCls,
|
||||
className = _this$props4.className,
|
||||
_this$props4$classNam = _this$props4.classNames,
|
||||
classNames = _this$props4$classNam === void 0 ? {} : _this$props4$classNam,
|
||||
disabled = _this$props4.disabled,
|
||||
id = _this$props4.id,
|
||||
name = _this$props4.name,
|
||||
style = _this$props4.style,
|
||||
_this$props4$styles = _this$props4.styles,
|
||||
styles = _this$props4$styles === void 0 ? {} : _this$props4$styles,
|
||||
multiple = _this$props4.multiple,
|
||||
accept = _this$props4.accept,
|
||||
capture = _this$props4.capture,
|
||||
children = _this$props4.children,
|
||||
directory = _this$props4.directory,
|
||||
folder = _this$props4.folder,
|
||||
openFileDialogOnClick = _this$props4.openFileDialogOnClick,
|
||||
onMouseEnter = _this$props4.onMouseEnter,
|
||||
onMouseLeave = _this$props4.onMouseLeave,
|
||||
hasControlInside = _this$props4.hasControlInside,
|
||||
otherProps = (0, _objectWithoutProperties2.default)(_this$props4, _excluded);
|
||||
var cls = (0, _classnames.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, prefixCls, true), "".concat(prefixCls, "-disabled"), disabled), className, className));
|
||||
// because input don't have directory/webkitdirectory type declaration
|
||||
var dirProps = directory || folder ? {
|
||||
directory: 'directory',
|
||||
webkitdirectory: 'webkitdirectory'
|
||||
} : {};
|
||||
var events = disabled ? {} : {
|
||||
onClick: openFileDialogOnClick ? this.onClick : function () {},
|
||||
onKeyDown: openFileDialogOnClick ? this.onKeyDown : function () {},
|
||||
onMouseEnter: onMouseEnter,
|
||||
onMouseLeave: onMouseLeave,
|
||||
onDrop: this.onFileDrop,
|
||||
onDragOver: this.onFileDragOver,
|
||||
tabIndex: hasControlInside ? undefined : '0'
|
||||
};
|
||||
return /*#__PURE__*/_react.default.createElement(Tag, (0, _extends2.default)({}, events, {
|
||||
className: cls,
|
||||
role: hasControlInside ? undefined : 'button',
|
||||
style: style
|
||||
}), /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({}, (0, _pickAttrs.default)(otherProps, {
|
||||
aria: true,
|
||||
data: true
|
||||
}), {
|
||||
id: id
|
||||
/**
|
||||
* https://github.com/ant-design/ant-design/issues/50643,
|
||||
* https://github.com/react-component/upload/pull/575#issuecomment-2320646552
|
||||
*/,
|
||||
name: name,
|
||||
disabled: disabled,
|
||||
type: "file",
|
||||
ref: this.saveFileInput,
|
||||
onClick: function onClick(e) {
|
||||
return e.stopPropagation();
|
||||
} // https://github.com/ant-design/ant-design/issues/19948
|
||||
,
|
||||
key: this.state.uid,
|
||||
style: (0, _objectSpread2.default)({
|
||||
display: 'none'
|
||||
}, styles.input),
|
||||
className: classNames.input,
|
||||
accept: accept
|
||||
}, dirProps, {
|
||||
multiple: multiple,
|
||||
onChange: this.onChange
|
||||
}, capture != null ? {
|
||||
capture: capture
|
||||
} : {})), children);
|
||||
}
|
||||
}]);
|
||||
return AjaxUploader;
|
||||
}(_react.Component);
|
||||
var _default = exports.default = AjaxUploader;
|
||||
28
frontend/node_modules/rc-upload/lib/Upload.d.ts
generated
vendored
Normal file
28
frontend/node_modules/rc-upload/lib/Upload.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import React, { Component } from 'react';
|
||||
import AjaxUpload from './AjaxUploader';
|
||||
import type { UploadProps, RcFile } from './interface';
|
||||
declare function empty(): void;
|
||||
declare class Upload extends Component<UploadProps> {
|
||||
static defaultProps: {
|
||||
component: string;
|
||||
prefixCls: string;
|
||||
data: {};
|
||||
headers: {};
|
||||
name: string;
|
||||
multipart: boolean;
|
||||
onStart: typeof empty;
|
||||
onError: typeof empty;
|
||||
onSuccess: typeof empty;
|
||||
multiple: boolean;
|
||||
beforeUpload: any;
|
||||
customRequest: any;
|
||||
withCredentials: boolean;
|
||||
openFileDialogOnClick: boolean;
|
||||
hasControlInside: boolean;
|
||||
};
|
||||
private uploader;
|
||||
abort(file: RcFile): void;
|
||||
saveUploader: (node: AjaxUpload) => void;
|
||||
render(): React.JSX.Element;
|
||||
}
|
||||
export default Upload;
|
||||
69
frontend/node_modules/rc-upload/lib/Upload.js
generated
vendored
Normal file
69
frontend/node_modules/rc-upload/lib/Upload.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
||||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
||||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
||||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
||||
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
||||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
||||
var _react = _interopRequireWildcard(require("react"));
|
||||
var _AjaxUploader = _interopRequireDefault(require("./AjaxUploader"));
|
||||
/* eslint react/prop-types:0 */
|
||||
|
||||
function empty() {}
|
||||
var Upload = /*#__PURE__*/function (_Component) {
|
||||
(0, _inherits2.default)(Upload, _Component);
|
||||
var _super = (0, _createSuper2.default)(Upload);
|
||||
function Upload() {
|
||||
var _this;
|
||||
(0, _classCallCheck2.default)(this, Upload);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
_this = _super.call.apply(_super, [this].concat(args));
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "uploader", void 0);
|
||||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "saveUploader", function (node) {
|
||||
_this.uploader = node;
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
(0, _createClass2.default)(Upload, [{
|
||||
key: "abort",
|
||||
value: function abort(file) {
|
||||
this.uploader.abort(file);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
return /*#__PURE__*/_react.default.createElement(_AjaxUploader.default, (0, _extends2.default)({}, this.props, {
|
||||
ref: this.saveUploader
|
||||
}));
|
||||
}
|
||||
}]);
|
||||
return Upload;
|
||||
}(_react.Component);
|
||||
(0, _defineProperty2.default)(Upload, "defaultProps", {
|
||||
component: 'span',
|
||||
prefixCls: 'rc-upload',
|
||||
data: {},
|
||||
headers: {},
|
||||
name: 'file',
|
||||
multipart: false,
|
||||
onStart: empty,
|
||||
onError: empty,
|
||||
onSuccess: empty,
|
||||
multiple: false,
|
||||
beforeUpload: null,
|
||||
customRequest: null,
|
||||
withCredentials: false,
|
||||
openFileDialogOnClick: true,
|
||||
hasControlInside: false
|
||||
});
|
||||
var _default = exports.default = Upload;
|
||||
3
frontend/node_modules/rc-upload/lib/attr-accept.d.ts
generated
vendored
Normal file
3
frontend/node_modules/rc-upload/lib/attr-accept.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { RcFile } from './interface';
|
||||
declare const _default: (file: RcFile, acceptedFiles: string | string[]) => boolean;
|
||||
export default _default;
|
||||
54
frontend/node_modules/rc-upload/lib/attr-accept.js
generated
vendored
Normal file
54
frontend/node_modules/rc-upload/lib/attr-accept.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _warning = _interopRequireDefault(require("rc-util/lib/warning"));
|
||||
var _default = exports.default = function _default(file, acceptedFiles) {
|
||||
if (file && acceptedFiles) {
|
||||
var acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(',');
|
||||
var fileName = file.name || '';
|
||||
var mimeType = file.type || '';
|
||||
var baseMimeType = mimeType.replace(/\/.*$/, '');
|
||||
return acceptedFilesArray.some(function (type) {
|
||||
var validType = type.trim();
|
||||
// This is something like */*,* allow all files
|
||||
if (/^\*(\/\*)?$/.test(type)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// like .jpg, .png
|
||||
if (validType.charAt(0) === '.') {
|
||||
var lowerFileName = fileName.toLowerCase();
|
||||
var lowerType = validType.toLowerCase();
|
||||
var affixList = [lowerType];
|
||||
if (lowerType === '.jpg' || lowerType === '.jpeg') {
|
||||
affixList = ['.jpg', '.jpeg'];
|
||||
}
|
||||
return affixList.some(function (affix) {
|
||||
return lowerFileName.endsWith(affix);
|
||||
});
|
||||
}
|
||||
|
||||
// This is something like a image/* mime type
|
||||
if (/\/\*$/.test(validType)) {
|
||||
return baseMimeType === validType.replace(/\/.*$/, '');
|
||||
}
|
||||
|
||||
// Full match
|
||||
if (mimeType === validType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Invalidate type should skip
|
||||
if (/^\w+$/.test(validType)) {
|
||||
(0, _warning.default)(false, "Upload takes an invalidate 'accept' type '".concat(validType, "'.Skip for check."));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return true;
|
||||
};
|
||||
4
frontend/node_modules/rc-upload/lib/index.d.ts
generated
vendored
Normal file
4
frontend/node_modules/rc-upload/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { UploadProps } from './interface';
|
||||
import Upload from './Upload';
|
||||
export type { UploadProps };
|
||||
export default Upload;
|
||||
9
frontend/node_modules/rc-upload/lib/index.js
generated
vendored
Normal file
9
frontend/node_modules/rc-upload/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _Upload = _interopRequireDefault(require("./Upload"));
|
||||
var _default = exports.default = _Upload.default;
|
||||
77
frontend/node_modules/rc-upload/lib/interface.d.ts
generated
vendored
Normal file
77
frontend/node_modules/rc-upload/lib/interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
import type * as React from 'react';
|
||||
export type BeforeUploadFileType = File | Blob | boolean | string;
|
||||
export type Action = string | ((file: RcFile) => string | PromiseLike<string>);
|
||||
export interface UploadProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onError' | 'onProgress'> {
|
||||
name?: string;
|
||||
style?: React.CSSProperties;
|
||||
className?: string;
|
||||
disabled?: boolean;
|
||||
component?: React.ComponentType<any> | string;
|
||||
action?: Action;
|
||||
method?: UploadRequestMethod;
|
||||
/** @deprecated Please use `folder` instead */
|
||||
directory?: boolean;
|
||||
folder?: boolean;
|
||||
data?: Record<string, unknown> | ((file: RcFile | string | Blob) => Record<string, unknown>);
|
||||
headers?: UploadRequestHeader;
|
||||
accept?: string;
|
||||
multiple?: boolean;
|
||||
onBatchStart?: (fileList: {
|
||||
file: RcFile;
|
||||
parsedFile: Exclude<BeforeUploadFileType, boolean>;
|
||||
}[]) => void;
|
||||
onStart?: (file: RcFile) => void;
|
||||
onError?: (error: Error, ret: Record<string, unknown>, file: RcFile) => void;
|
||||
onSuccess?: (response: Record<string, unknown>, file: RcFile, xhr: XMLHttpRequest) => void;
|
||||
onProgress?: (event: UploadProgressEvent, file: RcFile) => void;
|
||||
beforeUpload?: (file: RcFile, FileList: RcFile[]) => BeforeUploadFileType | Promise<void | BeforeUploadFileType> | void;
|
||||
customRequest?: CustomUploadRequestOption;
|
||||
withCredentials?: boolean;
|
||||
openFileDialogOnClick?: boolean;
|
||||
prefixCls?: string;
|
||||
id?: string;
|
||||
onMouseEnter?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
||||
onMouseLeave?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
||||
onClick?: (e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => void;
|
||||
classNames?: {
|
||||
input?: string;
|
||||
};
|
||||
styles?: {
|
||||
input?: React.CSSProperties;
|
||||
};
|
||||
hasControlInside?: boolean;
|
||||
pastable?: boolean;
|
||||
}
|
||||
export interface UploadProgressEvent extends Partial<ProgressEvent> {
|
||||
percent?: number;
|
||||
}
|
||||
export type UploadRequestMethod = 'POST' | 'PUT' | 'PATCH' | 'post' | 'put' | 'patch';
|
||||
export type UploadRequestHeader = Record<string, string>;
|
||||
export type UploadRequestFile = Exclude<BeforeUploadFileType, File | boolean> | RcFile;
|
||||
export interface UploadRequestError extends Error {
|
||||
status?: number;
|
||||
method?: UploadRequestMethod;
|
||||
url?: string;
|
||||
}
|
||||
export interface UploadRequestOption<T = any> {
|
||||
onProgress?: (event: UploadProgressEvent, file?: UploadRequestFile) => void;
|
||||
onError?: (event: UploadRequestError | ProgressEvent, body?: T) => void;
|
||||
onSuccess?: (body: T, fileOrXhr?: UploadRequestFile | XMLHttpRequest) => void;
|
||||
data?: Record<string, unknown>;
|
||||
filename?: string;
|
||||
file: UploadRequestFile;
|
||||
withCredentials?: boolean;
|
||||
action: string;
|
||||
headers?: UploadRequestHeader;
|
||||
method: UploadRequestMethod;
|
||||
}
|
||||
export type CustomUploadRequestOption = (option: UploadRequestOption, info: {
|
||||
defaultRequest: (option: UploadRequestOption) => {
|
||||
abort: () => void;
|
||||
} | void;
|
||||
}) => void | {
|
||||
abort: () => void;
|
||||
};
|
||||
export interface RcFile extends File {
|
||||
uid: string;
|
||||
}
|
||||
5
frontend/node_modules/rc-upload/lib/interface.js
generated
vendored
Normal file
5
frontend/node_modules/rc-upload/lib/interface.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
4
frontend/node_modules/rc-upload/lib/request.d.ts
generated
vendored
Normal file
4
frontend/node_modules/rc-upload/lib/request.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { UploadRequestOption } from './interface';
|
||||
export default function upload(option: UploadRequestOption): {
|
||||
abort(): void;
|
||||
};
|
||||
97
frontend/node_modules/rc-upload/lib/request.js
generated
vendored
Normal file
97
frontend/node_modules/rc-upload/lib/request.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = upload;
|
||||
function getError(option, xhr) {
|
||||
var msg = "cannot ".concat(option.method, " ").concat(option.action, " ").concat(xhr.status, "'");
|
||||
var err = new Error(msg);
|
||||
err.status = xhr.status;
|
||||
err.method = option.method;
|
||||
err.url = option.action;
|
||||
return err;
|
||||
}
|
||||
function getBody(xhr) {
|
||||
var text = xhr.responseText || xhr.response;
|
||||
if (!text) {
|
||||
return text;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(text);
|
||||
} catch (e) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
function upload(option) {
|
||||
// eslint-disable-next-line no-undef
|
||||
var xhr = new XMLHttpRequest();
|
||||
if (option.onProgress && xhr.upload) {
|
||||
xhr.upload.onprogress = function progress(e) {
|
||||
if (e.total > 0) {
|
||||
e.percent = e.loaded / e.total * 100;
|
||||
}
|
||||
option.onProgress(e);
|
||||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
var formData = new FormData();
|
||||
if (option.data) {
|
||||
Object.keys(option.data).forEach(function (key) {
|
||||
var value = option.data[key];
|
||||
// support key-value array data
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach(function (item) {
|
||||
// { list: [ 11, 22 ] }
|
||||
// formData.append('list[]', 11);
|
||||
formData.append("".concat(key, "[]"), item);
|
||||
});
|
||||
return;
|
||||
}
|
||||
formData.append(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
if (option.file instanceof Blob) {
|
||||
formData.append(option.filename, option.file, option.file.name);
|
||||
} else {
|
||||
formData.append(option.filename, option.file);
|
||||
}
|
||||
xhr.onerror = function error(e) {
|
||||
option.onError(e);
|
||||
};
|
||||
xhr.onload = function onload() {
|
||||
// allow success when 2xx status
|
||||
// see https://github.com/react-component/upload/issues/34
|
||||
if (xhr.status < 200 || xhr.status >= 300) {
|
||||
return option.onError(getError(option, xhr), getBody(xhr));
|
||||
}
|
||||
return option.onSuccess(getBody(xhr), xhr);
|
||||
};
|
||||
xhr.open(option.method, option.action, true);
|
||||
|
||||
// Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179
|
||||
if (option.withCredentials && 'withCredentials' in xhr) {
|
||||
xhr.withCredentials = true;
|
||||
}
|
||||
var headers = option.headers || {};
|
||||
|
||||
// when set headers['X-Requested-With'] = null , can close default XHR header
|
||||
// see https://github.com/react-component/upload/issues/33
|
||||
if (headers['X-Requested-With'] !== null) {
|
||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
}
|
||||
Object.keys(headers).forEach(function (h) {
|
||||
if (headers[h] !== null) {
|
||||
xhr.setRequestHeader(h, headers[h]);
|
||||
}
|
||||
});
|
||||
xhr.send(formData);
|
||||
return {
|
||||
abort: function abort() {
|
||||
xhr.abort();
|
||||
}
|
||||
};
|
||||
}
|
||||
14
frontend/node_modules/rc-upload/lib/traverseFileTree.d.ts
generated
vendored
Normal file
14
frontend/node_modules/rc-upload/lib/traverseFileTree.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { RcFile } from './interface';
|
||||
interface InternalDataTransferItem extends DataTransferItem {
|
||||
isFile: boolean;
|
||||
file: (cd: (file: RcFile & {
|
||||
webkitRelativePath?: string;
|
||||
}) => void) => void;
|
||||
createReader: () => any;
|
||||
fullPath: string;
|
||||
isDirectory: boolean;
|
||||
name: string;
|
||||
path: string;
|
||||
}
|
||||
declare const traverseFileTree: (files: InternalDataTransferItem[], isAccepted: any) => Promise<any[]>;
|
||||
export default traverseFileTree;
|
||||
182
frontend/node_modules/rc-upload/lib/traverseFileTree.js
generated
vendored
Normal file
182
frontend/node_modules/rc-upload/lib/traverseFileTree.js
generated
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
||||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
// https://github.com/ant-design/ant-design/issues/50080
|
||||
var traverseFileTree = /*#__PURE__*/function () {
|
||||
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee4(files, isAccepted) {
|
||||
var flattenFileList, progressFileList, readDirectory, _readDirectory, readFile, _readFile, _traverseFileTree, wipIndex;
|
||||
return (0, _regeneratorRuntime2.default)().wrap(function _callee4$(_context4) {
|
||||
while (1) switch (_context4.prev = _context4.next) {
|
||||
case 0:
|
||||
_readFile = function _readFile3() {
|
||||
_readFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3(item) {
|
||||
return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
|
||||
while (1) switch (_context3.prev = _context3.next) {
|
||||
case 0:
|
||||
return _context3.abrupt("return", new Promise(function (reslove) {
|
||||
item.file(function (file) {
|
||||
if (isAccepted(file)) {
|
||||
// https://github.com/ant-design/ant-design/issues/16426
|
||||
if (item.fullPath && !file.webkitRelativePath) {
|
||||
Object.defineProperties(file, {
|
||||
webkitRelativePath: {
|
||||
writable: true
|
||||
}
|
||||
});
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
file.webkitRelativePath = item.fullPath.replace(/^\//, '');
|
||||
Object.defineProperties(file, {
|
||||
webkitRelativePath: {
|
||||
writable: false
|
||||
}
|
||||
});
|
||||
}
|
||||
reslove(file);
|
||||
} else {
|
||||
reslove(null);
|
||||
}
|
||||
});
|
||||
}));
|
||||
case 1:
|
||||
case "end":
|
||||
return _context3.stop();
|
||||
}
|
||||
}, _callee3);
|
||||
}));
|
||||
return _readFile.apply(this, arguments);
|
||||
};
|
||||
readFile = function _readFile2(_x4) {
|
||||
return _readFile.apply(this, arguments);
|
||||
};
|
||||
_readDirectory = function _readDirectory3() {
|
||||
_readDirectory = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(directory) {
|
||||
var dirReader, entries, results, n, i;
|
||||
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
||||
while (1) switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
dirReader = directory.createReader();
|
||||
entries = [];
|
||||
case 2:
|
||||
if (!true) {
|
||||
_context2.next = 12;
|
||||
break;
|
||||
}
|
||||
_context2.next = 5;
|
||||
return new Promise(function (resolve) {
|
||||
dirReader.readEntries(resolve, function () {
|
||||
return resolve([]);
|
||||
});
|
||||
});
|
||||
case 5:
|
||||
results = _context2.sent;
|
||||
n = results.length;
|
||||
if (n) {
|
||||
_context2.next = 9;
|
||||
break;
|
||||
}
|
||||
return _context2.abrupt("break", 12);
|
||||
case 9:
|
||||
for (i = 0; i < n; i++) {
|
||||
entries.push(results[i]);
|
||||
}
|
||||
_context2.next = 2;
|
||||
break;
|
||||
case 12:
|
||||
return _context2.abrupt("return", entries);
|
||||
case 13:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
}
|
||||
}, _callee2);
|
||||
}));
|
||||
return _readDirectory.apply(this, arguments);
|
||||
};
|
||||
readDirectory = function _readDirectory2(_x3) {
|
||||
return _readDirectory.apply(this, arguments);
|
||||
};
|
||||
flattenFileList = [];
|
||||
progressFileList = [];
|
||||
files.forEach(function (file) {
|
||||
return progressFileList.push(file.webkitGetAsEntry());
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
_traverseFileTree = /*#__PURE__*/function () {
|
||||
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(item, path) {
|
||||
var _file, entries;
|
||||
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
||||
while (1) switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
if (item) {
|
||||
_context.next = 2;
|
||||
break;
|
||||
}
|
||||
return _context.abrupt("return");
|
||||
case 2:
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
item.path = path || '';
|
||||
if (!item.isFile) {
|
||||
_context.next = 10;
|
||||
break;
|
||||
}
|
||||
_context.next = 6;
|
||||
return readFile(item);
|
||||
case 6:
|
||||
_file = _context.sent;
|
||||
if (_file) {
|
||||
flattenFileList.push(_file);
|
||||
}
|
||||
_context.next = 15;
|
||||
break;
|
||||
case 10:
|
||||
if (!item.isDirectory) {
|
||||
_context.next = 15;
|
||||
break;
|
||||
}
|
||||
_context.next = 13;
|
||||
return readDirectory(item);
|
||||
case 13:
|
||||
entries = _context.sent;
|
||||
progressFileList.push.apply(progressFileList, (0, _toConsumableArray2.default)(entries));
|
||||
case 15:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
return function _traverseFileTree(_x5, _x6) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
wipIndex = 0;
|
||||
case 9:
|
||||
if (!(wipIndex < progressFileList.length)) {
|
||||
_context4.next = 15;
|
||||
break;
|
||||
}
|
||||
_context4.next = 12;
|
||||
return _traverseFileTree(progressFileList[wipIndex]);
|
||||
case 12:
|
||||
wipIndex++;
|
||||
_context4.next = 9;
|
||||
break;
|
||||
case 15:
|
||||
return _context4.abrupt("return", flattenFileList);
|
||||
case 16:
|
||||
case "end":
|
||||
return _context4.stop();
|
||||
}
|
||||
}, _callee4);
|
||||
}));
|
||||
return function traverseFileTree(_x, _x2) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
var _default = exports.default = traverseFileTree;
|
||||
1
frontend/node_modules/rc-upload/lib/uid.d.ts
generated
vendored
Normal file
1
frontend/node_modules/rc-upload/lib/uid.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default function uid(): string;
|
||||
12
frontend/node_modules/rc-upload/lib/uid.js
generated
vendored
Normal file
12
frontend/node_modules/rc-upload/lib/uid.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = uid;
|
||||
var now = +new Date();
|
||||
var index = 0;
|
||||
function uid() {
|
||||
// eslint-disable-next-line no-plusplus
|
||||
return "rc-upload-".concat(now, "-").concat(++index);
|
||||
}
|
||||
75
frontend/node_modules/rc-upload/package.json
generated
vendored
Normal file
75
frontend/node_modules/rc-upload/package.json
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"name": "rc-upload",
|
||||
"version": "4.11.0",
|
||||
"description": "upload ui component for react",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-component",
|
||||
"react-upload",
|
||||
"upload"
|
||||
],
|
||||
"homepage": "http://github.com/react-component/upload",
|
||||
"bugs": {
|
||||
"url": "http://github.com/react-component/upload/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:react-component/upload.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "./lib/index",
|
||||
"module": "./es/index",
|
||||
"files": [
|
||||
"lib",
|
||||
"es"
|
||||
],
|
||||
"scripts": {
|
||||
"compile": "father build",
|
||||
"coverage": "rc-test --coverage",
|
||||
"docs:build": "dumi build",
|
||||
"docs:deploy": "npm run docs:build && gh-pages -d dist",
|
||||
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
|
||||
"now-build": "npm run docs:build",
|
||||
"prepublishOnly": "npm run compile && np --yolo --no-publish",
|
||||
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
|
||||
"postpublish": "npm run docs:deploy",
|
||||
"start": "dumi dev",
|
||||
"test": "rc-test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"classnames": "^2.2.5",
|
||||
"rc-util": "^5.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rc-component/father-plugin": "^1.0.0",
|
||||
"@testing-library/jest-dom": "^6.1.5",
|
||||
"@testing-library/react": "^16.2.0",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/react": "^18.0.0",
|
||||
"@types/react-dom": "^18.0.0",
|
||||
"@umijs/fabric": "^4.0.1",
|
||||
"axios": "^1.9.0",
|
||||
"co-busboy": "^2.0.2",
|
||||
"coveralls": "^3.0.3",
|
||||
"cross-env": "^7.0.0",
|
||||
"dumi": "^2.1.0",
|
||||
"eslint": "^8.0.0",
|
||||
"father": "^4.0.0",
|
||||
"fs-extra": "^11.2.0",
|
||||
"gh-pages": "^6.1.1",
|
||||
"np": "^10.0.7",
|
||||
"raf": "^3.4.0",
|
||||
"rc-test": "^7.0.13",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0",
|
||||
"regenerator-runtime": "^0.14.1",
|
||||
"sinon": "^9.0.2",
|
||||
"typescript": "^5.3.3",
|
||||
"vinyl-fs": "^4.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=16.9.0",
|
||||
"react-dom": ">=16.9.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user