You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1965 lines
73 KiB
1965 lines
73 KiB
"use strict";
|
|
(self["webpackChunk"] = self["webpackChunk"] || []).push([[15428],{
|
|
|
|
/***/ 47046:
|
|
/*!*********************************************************************!*\
|
|
!*** ./node_modules/@ant-design/icons-svg/es/asn/DeleteOutlined.js ***!
|
|
\*********************************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__) {
|
|
|
|
// This icon file is generated automatically.
|
|
var DeleteOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z" } }] }, "name": "delete", "theme": "outlined" };
|
|
/* harmony default export */ __webpack_exports__["Z"] = (DeleteOutlined);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 49495:
|
|
/*!***********************************************************************!*\
|
|
!*** ./node_modules/@ant-design/icons-svg/es/asn/DownloadOutlined.js ***!
|
|
\***********************************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__) {
|
|
|
|
// This icon file is generated automatically.
|
|
var DownloadOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z" } }] }, "name": "download", "theme": "outlined" };
|
|
/* harmony default export */ __webpack_exports__["Z"] = (DownloadOutlined);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 7426:
|
|
/*!***********************************************************!*\
|
|
!*** ./node_modules/antd/es/upload/index.js + 20 modules ***!
|
|
\***********************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
"Z": function() { return /* binding */ es_upload; }
|
|
});
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
|
|
var esm_extends = __webpack_require__(87462);
|
|
// EXTERNAL MODULE: ./node_modules/react/index.js
|
|
var react = __webpack_require__(67294);
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
var defineProperty = __webpack_require__(4942);
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js
|
|
var regeneratorRuntime = __webpack_require__(74165);
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
var esm_typeof = __webpack_require__(71002);
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
|
|
var toConsumableArray = __webpack_require__(74902);
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
|
|
var slicedToArray = __webpack_require__(97685);
|
|
// EXTERNAL MODULE: ./node_modules/classnames/index.js
|
|
var classnames = __webpack_require__(94184);
|
|
var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
|
|
var classCallCheck = __webpack_require__(15671);
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
|
|
var createClass = __webpack_require__(43144);
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
|
|
var inherits = __webpack_require__(60136);
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createSuper.js + 1 modules
|
|
var createSuper = __webpack_require__(51630);
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
|
|
var objectWithoutProperties = __webpack_require__(45987);
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
|
|
var asyncToGenerator = __webpack_require__(15861);
|
|
// EXTERNAL MODULE: ./node_modules/rc-util/es/pickAttrs.js
|
|
var pickAttrs = __webpack_require__(64217);
|
|
;// CONCATENATED MODULE: ./node_modules/rc-upload/es/request.js
|
|
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();
|
|
}
|
|
};
|
|
}
|
|
;// CONCATENATED MODULE: ./node_modules/rc-upload/es/uid.js
|
|
var now = +new Date();
|
|
var index = 0;
|
|
function uid() {
|
|
// eslint-disable-next-line no-plusplus
|
|
return "rc-upload-".concat(now, "-").concat(++index);
|
|
}
|
|
// EXTERNAL MODULE: ./node_modules/rc-util/es/warning.js
|
|
var warning = __webpack_require__(80334);
|
|
;// CONCATENATED MODULE: ./node_modules/rc-upload/es/attr-accept.js
|
|
|
|
/* harmony default export */ var attr_accept = (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)) {
|
|
(0,warning/* default */.ZP)(false, "Upload takes an invalidate 'accept' type '".concat(validType, "'.Skip for check."));
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
});
|
|
}
|
|
|
|
return true;
|
|
});
|
|
;// CONCATENATED MODULE: ./node_modules/rc-upload/es/traverseFileTree.js
|
|
function loopFiles(item, callback) {
|
|
var dirReader = item.createReader();
|
|
var fileList = [];
|
|
|
|
function sequence() {
|
|
dirReader.readEntries(function (entries) {
|
|
var entryList = Array.prototype.slice.apply(entries);
|
|
fileList = fileList.concat(entryList); // Check if all the file has been viewed
|
|
|
|
var isFinished = !entryList.length;
|
|
|
|
if (isFinished) {
|
|
callback(fileList);
|
|
} else {
|
|
sequence();
|
|
}
|
|
});
|
|
}
|
|
|
|
sequence();
|
|
}
|
|
|
|
var traverseFileTree = function traverseFileTree(files, callback, isAccepted) {
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
var _traverseFileTree = function _traverseFileTree(item, path) {
|
|
// eslint-disable-next-line no-param-reassign
|
|
item.path = path || '';
|
|
|
|
if (item.isFile) {
|
|
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
|
|
}
|
|
});
|
|
}
|
|
|
|
callback([file]);
|
|
}
|
|
});
|
|
} else if (item.isDirectory) {
|
|
loopFiles(item, function (entries) {
|
|
entries.forEach(function (entryItem) {
|
|
_traverseFileTree(entryItem, "".concat(path).concat(item.name, "/"));
|
|
});
|
|
});
|
|
}
|
|
};
|
|
|
|
files.forEach(function (file) {
|
|
_traverseFileTree(file.webkitGetAsEntry());
|
|
});
|
|
};
|
|
|
|
/* harmony default export */ var es_traverseFileTree = (traverseFileTree);
|
|
;// CONCATENATED MODULE: ./node_modules/rc-upload/es/AjaxUploader.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _excluded = ["component", "prefixCls", "className", "disabled", "id", "style", "multiple", "accept", "capture", "children", "directory", "openFileDialogOnClick", "onMouseEnter", "onMouseLeave"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var AjaxUploader = /*#__PURE__*/function (_Component) {
|
|
(0,inherits/* default */.Z)(AjaxUploader, _Component);
|
|
|
|
var _super = (0,createSuper/* default */.Z)(AjaxUploader);
|
|
|
|
function AjaxUploader() {
|
|
var _this;
|
|
|
|
(0,classCallCheck/* default */.Z)(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));
|
|
_this.state = {
|
|
uid: uid()
|
|
};
|
|
_this.reqs = {};
|
|
_this.fileInput = void 0;
|
|
_this._isMounted = void 0;
|
|
|
|
_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,toConsumableArray/* default */.Z)(files).filter(function (file) {
|
|
return !directory || attr_accept(file, accept);
|
|
});
|
|
|
|
_this.uploadFiles(acceptedFiles);
|
|
|
|
_this.reset();
|
|
};
|
|
|
|
_this.onClick = function (e) {
|
|
var el = _this.fileInput;
|
|
|
|
if (!el) {
|
|
return;
|
|
}
|
|
|
|
var _this$props2 = _this.props,
|
|
children = _this$props2.children,
|
|
onClick = _this$props2.onClick;
|
|
|
|
if (children && children.type === 'button') {
|
|
var parent = el.parentNode;
|
|
parent.focus();
|
|
parent.querySelector('button').blur();
|
|
}
|
|
|
|
el.click();
|
|
|
|
if (onClick) {
|
|
onClick(e);
|
|
}
|
|
};
|
|
|
|
_this.onKeyDown = function (e) {
|
|
if (e.key === 'Enter') {
|
|
_this.onClick(e);
|
|
}
|
|
};
|
|
|
|
_this.onFileDrop = function (e) {
|
|
var multiple = _this.props.multiple;
|
|
e.preventDefault();
|
|
|
|
if (e.type === 'dragover') {
|
|
return;
|
|
}
|
|
|
|
if (_this.props.directory) {
|
|
es_traverseFileTree(Array.prototype.slice.call(e.dataTransfer.items), _this.uploadFiles, function (_file) {
|
|
return attr_accept(_file, _this.props.accept);
|
|
});
|
|
} else {
|
|
var files = (0,toConsumableArray/* default */.Z)(e.dataTransfer.files).filter(function (file) {
|
|
return attr_accept(file, _this.props.accept);
|
|
});
|
|
|
|
if (multiple === false) {
|
|
files = files.slice(0, 1);
|
|
}
|
|
|
|
_this.uploadFiles(files);
|
|
}
|
|
};
|
|
|
|
_this.uploadFiles = function (files) {
|
|
var originFiles = (0,toConsumableArray/* default */.Z)(files);
|
|
|
|
var postFiles = originFiles.map(function (file) {
|
|
// eslint-disable-next-line no-param-reassign
|
|
file.uid = uid();
|
|
return _this.processFile(file, originFiles);
|
|
}); // Batch upload files
|
|
|
|
Promise.all(postFiles).then(function (fileList) {
|
|
var onBatchStart = _this.props.onBatchStart;
|
|
onBatchStart === null || onBatchStart === void 0 ? void 0 : onBatchStart(fileList.map(function (_ref) {
|
|
var origin = _ref.origin,
|
|
parsedFile = _ref.parsedFile;
|
|
return {
|
|
file: origin,
|
|
parsedFile: parsedFile
|
|
};
|
|
}));
|
|
fileList.filter(function (file) {
|
|
return file.parsedFile !== null;
|
|
}).forEach(function (file) {
|
|
_this.post(file);
|
|
});
|
|
});
|
|
};
|
|
|
|
_this.processFile = /*#__PURE__*/function () {
|
|
var _ref2 = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/(0,regeneratorRuntime/* default */.Z)().mark(function _callee(file, fileList) {
|
|
var beforeUpload, transformedFile, action, mergedAction, data, mergedData, parsedData, parsedFile, mergedParsedFile;
|
|
return (0,regeneratorRuntime/* default */.Z)().wrap(function _callee$(_context) {
|
|
while (1) {
|
|
switch (_context.prev = _context.next) {
|
|
case 0:
|
|
beforeUpload = _this.props.beforeUpload;
|
|
transformedFile = file;
|
|
|
|
if (!beforeUpload) {
|
|
_context.next = 14;
|
|
break;
|
|
}
|
|
|
|
_context.prev = 3;
|
|
_context.next = 6;
|
|
return beforeUpload(file, fileList);
|
|
|
|
case 6:
|
|
transformedFile = _context.sent;
|
|
_context.next = 12;
|
|
break;
|
|
|
|
case 9:
|
|
_context.prev = 9;
|
|
_context.t0 = _context["catch"](3);
|
|
// Rejection will also trade as false
|
|
transformedFile = false;
|
|
|
|
case 12:
|
|
if (!(transformedFile === false)) {
|
|
_context.next = 14;
|
|
break;
|
|
}
|
|
|
|
return _context.abrupt("return", {
|
|
origin: file,
|
|
parsedFile: null,
|
|
action: null,
|
|
data: null
|
|
});
|
|
|
|
case 14:
|
|
// Get latest action
|
|
action = _this.props.action;
|
|
|
|
if (!(typeof action === 'function')) {
|
|
_context.next = 21;
|
|
break;
|
|
}
|
|
|
|
_context.next = 18;
|
|
return action(file);
|
|
|
|
case 18:
|
|
mergedAction = _context.sent;
|
|
_context.next = 22;
|
|
break;
|
|
|
|
case 21:
|
|
mergedAction = action;
|
|
|
|
case 22:
|
|
// Get latest data
|
|
data = _this.props.data;
|
|
|
|
if (!(typeof data === 'function')) {
|
|
_context.next = 29;
|
|
break;
|
|
}
|
|
|
|
_context.next = 26;
|
|
return data(file);
|
|
|
|
case 26:
|
|
mergedData = _context.sent;
|
|
_context.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,esm_typeof/* default */.Z)(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 _context.abrupt("return", {
|
|
origin: file,
|
|
data: mergedData,
|
|
parsedFile: mergedParsedFile,
|
|
action: mergedAction
|
|
});
|
|
|
|
case 35:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}
|
|
}, _callee, null, [[3, 9]]);
|
|
}));
|
|
|
|
return function (_x, _x2) {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
}();
|
|
|
|
_this.saveFileInput = function (node) {
|
|
_this.fileInput = node;
|
|
};
|
|
|
|
return _this;
|
|
}
|
|
|
|
(0,createClass/* default */.Z)(AjaxUploader, [{
|
|
key: "componentDidMount",
|
|
value: function componentDidMount() {
|
|
this._isMounted = true;
|
|
}
|
|
}, {
|
|
key: "componentWillUnmount",
|
|
value: function componentWillUnmount() {
|
|
this._isMounted = false;
|
|
this.abort();
|
|
}
|
|
}, {
|
|
key: "post",
|
|
value: function post(_ref3) {
|
|
var _this2 = this;
|
|
|
|
var data = _ref3.data,
|
|
origin = _ref3.origin,
|
|
action = _ref3.action,
|
|
parsedFile = _ref3.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 || upload;
|
|
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 ? void 0 : onProgress(e, parsedFile);
|
|
},
|
|
onSuccess: function onSuccess(ret, xhr) {
|
|
var onSuccess = _this2.props.onSuccess;
|
|
onSuccess === null || onSuccess === void 0 ? 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 ? void 0 : onError(err, ret, parsedFile);
|
|
delete _this2.reqs[uid];
|
|
}
|
|
};
|
|
onStart(origin);
|
|
this.reqs[uid] = request(requestOption);
|
|
}
|
|
}, {
|
|
key: "reset",
|
|
value: function reset() {
|
|
this.setState({
|
|
uid: uid()
|
|
});
|
|
}
|
|
}, {
|
|
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 _classNames;
|
|
|
|
var _this$props4 = this.props,
|
|
Tag = _this$props4.component,
|
|
prefixCls = _this$props4.prefixCls,
|
|
className = _this$props4.className,
|
|
disabled = _this$props4.disabled,
|
|
id = _this$props4.id,
|
|
style = _this$props4.style,
|
|
multiple = _this$props4.multiple,
|
|
accept = _this$props4.accept,
|
|
capture = _this$props4.capture,
|
|
children = _this$props4.children,
|
|
directory = _this$props4.directory,
|
|
openFileDialogOnClick = _this$props4.openFileDialogOnClick,
|
|
onMouseEnter = _this$props4.onMouseEnter,
|
|
onMouseLeave = _this$props4.onMouseLeave,
|
|
otherProps = (0,objectWithoutProperties/* default */.Z)(_this$props4, _excluded);
|
|
|
|
var cls = classnames_default()((_classNames = {}, (0,defineProperty/* default */.Z)(_classNames, prefixCls, true), (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-disabled"), disabled), (0,defineProperty/* default */.Z)(_classNames, className, className), _classNames)); // because input don't have directory/webkitdirectory type declaration
|
|
|
|
var dirProps = directory ? {
|
|
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.onFileDrop,
|
|
tabIndex: '0'
|
|
};
|
|
return /*#__PURE__*/react.createElement(Tag, (0,esm_extends/* default */.Z)({}, events, {
|
|
className: cls,
|
|
role: "button",
|
|
style: style
|
|
}), /*#__PURE__*/react.createElement("input", (0,esm_extends/* default */.Z)({}, (0,pickAttrs/* default */.Z)(otherProps, {
|
|
aria: true,
|
|
data: true
|
|
}), {
|
|
id: id,
|
|
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: {
|
|
display: 'none'
|
|
},
|
|
accept: accept
|
|
}, dirProps, {
|
|
multiple: multiple,
|
|
onChange: this.onChange
|
|
}, capture != null ? {
|
|
capture: capture
|
|
} : {})), children);
|
|
}
|
|
}]);
|
|
|
|
return AjaxUploader;
|
|
}(react.Component);
|
|
|
|
/* harmony default export */ var es_AjaxUploader = (AjaxUploader);
|
|
;// CONCATENATED MODULE: ./node_modules/rc-upload/es/Upload.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* eslint react/prop-types:0 */
|
|
|
|
|
|
|
|
function empty() {}
|
|
|
|
var Upload = /*#__PURE__*/function (_Component) {
|
|
(0,inherits/* default */.Z)(Upload, _Component);
|
|
|
|
var _super = (0,createSuper/* default */.Z)(Upload);
|
|
|
|
function Upload() {
|
|
var _this;
|
|
|
|
(0,classCallCheck/* default */.Z)(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));
|
|
_this.uploader = void 0;
|
|
|
|
_this.saveUploader = function (node) {
|
|
_this.uploader = node;
|
|
};
|
|
|
|
return _this;
|
|
}
|
|
|
|
(0,createClass/* default */.Z)(Upload, [{
|
|
key: "abort",
|
|
value: function abort(file) {
|
|
this.uploader.abort(file);
|
|
}
|
|
}, {
|
|
key: "render",
|
|
value: function render() {
|
|
return /*#__PURE__*/react.createElement(es_AjaxUploader, (0,esm_extends/* default */.Z)({}, this.props, {
|
|
ref: this.saveUploader
|
|
}));
|
|
}
|
|
}]);
|
|
|
|
return Upload;
|
|
}(react.Component);
|
|
|
|
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
|
|
};
|
|
/* harmony default export */ var es_Upload = (Upload);
|
|
;// CONCATENATED MODULE: ./node_modules/rc-upload/es/index.js
|
|
|
|
/* harmony default export */ var es = (es_Upload);
|
|
// EXTERNAL MODULE: ./node_modules/rc-util/es/hooks/useMergedState.js
|
|
var useMergedState = __webpack_require__(21770);
|
|
// EXTERNAL MODULE: ./node_modules/react-dom/index.js
|
|
var react_dom = __webpack_require__(73935);
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/config-provider/context.js
|
|
var context = __webpack_require__(53124);
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/config-provider/DisabledContext.js
|
|
var DisabledContext = __webpack_require__(98866);
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/locale-provider/LocaleReceiver.js + 1 modules
|
|
var LocaleReceiver = __webpack_require__(23715);
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/locale/default.js + 1 modules
|
|
var locale_default = __webpack_require__(80779);
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js
|
|
var objectSpread2 = __webpack_require__(1413);
|
|
;// CONCATENATED MODULE: ./node_modules/@ant-design/icons-svg/es/asn/FileTwoTone.js
|
|
// This icon file is generated automatically.
|
|
var FileTwoTone = { "icon": function render(primaryColor, secondaryColor) { return { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M534 352V136H232v752h560V394H576a42 42 0 01-42-42z", "fill": secondaryColor } }, { "tag": "path", "attrs": { "d": "M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM602 137.8L790.2 326H602V137.8zM792 888H232V136h302v216a42 42 0 0042 42h216v494z", "fill": primaryColor } }] }; }, "name": "file", "theme": "twotone" };
|
|
/* harmony default export */ var asn_FileTwoTone = (FileTwoTone);
|
|
|
|
// EXTERNAL MODULE: ./node_modules/antd/node_modules/@ant-design/icons/es/components/AntdIcon.js + 3 modules
|
|
var AntdIcon = __webpack_require__(93771);
|
|
;// CONCATENATED MODULE: ./node_modules/antd/node_modules/@ant-design/icons/es/icons/FileTwoTone.js
|
|
|
|
// GENERATE BY ./scripts/generate.ts
|
|
// DON NOT EDIT IT MANUALLY
|
|
|
|
|
|
|
|
var FileTwoTone_FileTwoTone = function FileTwoTone(props, ref) {
|
|
return /*#__PURE__*/react.createElement(AntdIcon/* default */.Z, (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, props), {}, {
|
|
ref: ref,
|
|
icon: asn_FileTwoTone
|
|
}));
|
|
};
|
|
FileTwoTone_FileTwoTone.displayName = 'FileTwoTone';
|
|
/* harmony default export */ var icons_FileTwoTone = (/*#__PURE__*/react.forwardRef(FileTwoTone_FileTwoTone));
|
|
// EXTERNAL MODULE: ./node_modules/antd/node_modules/@ant-design/icons/es/icons/LoadingOutlined.js
|
|
var LoadingOutlined = __webpack_require__(19267);
|
|
;// CONCATENATED MODULE: ./node_modules/@ant-design/icons-svg/es/asn/PaperClipOutlined.js
|
|
// This icon file is generated automatically.
|
|
var PaperClipOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M779.3 196.6c-94.2-94.2-247.6-94.2-341.7 0l-261 260.8c-1.7 1.7-2.6 4-2.6 6.4s.9 4.7 2.6 6.4l36.9 36.9a9 9 0 0012.7 0l261-260.8c32.4-32.4 75.5-50.2 121.3-50.2s88.9 17.8 121.2 50.2c32.4 32.4 50.2 75.5 50.2 121.2 0 45.8-17.8 88.8-50.2 121.2l-266 265.9-43.1 43.1c-40.3 40.3-105.8 40.3-146.1 0-19.5-19.5-30.2-45.4-30.2-73s10.7-53.5 30.2-73l263.9-263.8c6.7-6.6 15.5-10.3 24.9-10.3h.1c9.4 0 18.1 3.7 24.7 10.3 6.7 6.7 10.3 15.5 10.3 24.9 0 9.3-3.7 18.1-10.3 24.7L372.4 653c-1.7 1.7-2.6 4-2.6 6.4s.9 4.7 2.6 6.4l36.9 36.9a9 9 0 0012.7 0l215.6-215.6c19.9-19.9 30.8-46.3 30.8-74.4s-11-54.6-30.8-74.4c-41.1-41.1-107.9-41-149 0L463 364 224.8 602.1A172.22 172.22 0 00174 724.8c0 46.3 18.1 89.8 50.8 122.5 33.9 33.8 78.3 50.7 122.7 50.7 44.4 0 88.8-16.9 122.6-50.7l309.2-309C824.8 492.7 850 432 850 367.5c.1-64.6-25.1-125.3-70.7-170.9z" } }] }, "name": "paper-clip", "theme": "outlined" };
|
|
/* harmony default export */ var asn_PaperClipOutlined = (PaperClipOutlined);
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/antd/node_modules/@ant-design/icons/es/icons/PaperClipOutlined.js
|
|
|
|
// GENERATE BY ./scripts/generate.ts
|
|
// DON NOT EDIT IT MANUALLY
|
|
|
|
|
|
|
|
var PaperClipOutlined_PaperClipOutlined = function PaperClipOutlined(props, ref) {
|
|
return /*#__PURE__*/react.createElement(AntdIcon/* default */.Z, (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, props), {}, {
|
|
ref: ref,
|
|
icon: asn_PaperClipOutlined
|
|
}));
|
|
};
|
|
PaperClipOutlined_PaperClipOutlined.displayName = 'PaperClipOutlined';
|
|
/* harmony default export */ var icons_PaperClipOutlined = (/*#__PURE__*/react.forwardRef(PaperClipOutlined_PaperClipOutlined));
|
|
;// CONCATENATED MODULE: ./node_modules/@ant-design/icons-svg/es/asn/PictureTwoTone.js
|
|
// This icon file is generated automatically.
|
|
var PictureTwoTone = { "icon": function render(primaryColor, secondaryColor) { return { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zm-40 632H136v-39.9l138.5-164.3 150.1 178L658.1 489 888 761.6V792zm0-129.8L664.2 396.8c-3.2-3.8-9-3.8-12.2 0L424.6 666.4l-144-170.7c-3.2-3.8-9-3.8-12.2 0L136 652.7V232h752v430.2z", "fill": primaryColor } }, { "tag": "path", "attrs": { "d": "M424.6 765.8l-150.1-178L136 752.1V792h752v-30.4L658.1 489z", "fill": secondaryColor } }, { "tag": "path", "attrs": { "d": "M136 652.7l132.4-157c3.2-3.8 9-3.8 12.2 0l144 170.7L652 396.8c3.2-3.8 9-3.8 12.2 0L888 662.2V232H136v420.7zM304 280a88 88 0 110 176 88 88 0 010-176z", "fill": secondaryColor } }, { "tag": "path", "attrs": { "d": "M276 368a28 28 0 1056 0 28 28 0 10-56 0z", "fill": secondaryColor } }, { "tag": "path", "attrs": { "d": "M304 456a88 88 0 100-176 88 88 0 000 176zm0-116c15.5 0 28 12.5 28 28s-12.5 28-28 28-28-12.5-28-28 12.5-28 28-28z", "fill": primaryColor } }] }; }, "name": "picture", "theme": "twotone" };
|
|
/* harmony default export */ var asn_PictureTwoTone = (PictureTwoTone);
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/antd/node_modules/@ant-design/icons/es/icons/PictureTwoTone.js
|
|
|
|
// GENERATE BY ./scripts/generate.ts
|
|
// DON NOT EDIT IT MANUALLY
|
|
|
|
|
|
|
|
var PictureTwoTone_PictureTwoTone = function PictureTwoTone(props, ref) {
|
|
return /*#__PURE__*/react.createElement(AntdIcon/* default */.Z, (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, props), {}, {
|
|
ref: ref,
|
|
icon: asn_PictureTwoTone
|
|
}));
|
|
};
|
|
PictureTwoTone_PictureTwoTone.displayName = 'PictureTwoTone';
|
|
/* harmony default export */ var icons_PictureTwoTone = (/*#__PURE__*/react.forwardRef(PictureTwoTone_PictureTwoTone));
|
|
// EXTERNAL MODULE: ./node_modules/rc-motion/es/index.js + 11 modules
|
|
var rc_motion_es = __webpack_require__(62874);
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/button/index.js
|
|
var es_button = __webpack_require__(71577);
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/_util/hooks/useForceUpdate.js
|
|
var useForceUpdate = __webpack_require__(57838);
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/_util/motion.js
|
|
var motion = __webpack_require__(33603);
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/_util/reactNode.js
|
|
var reactNode = __webpack_require__(96159);
|
|
;// CONCATENATED MODULE: ./node_modules/antd/es/upload/utils.js
|
|
|
|
|
|
function file2Obj(file) {
|
|
return (0,esm_extends/* default */.Z)((0,esm_extends/* default */.Z)({}, file), {
|
|
lastModified: file.lastModified,
|
|
lastModifiedDate: file.lastModifiedDate,
|
|
name: file.name,
|
|
size: file.size,
|
|
type: file.type,
|
|
uid: file.uid,
|
|
percent: 0,
|
|
originFileObj: file
|
|
});
|
|
}
|
|
/** Upload fileList. Replace file if exist or just push into it. */
|
|
function updateFileList(file, fileList) {
|
|
var nextFileList = (0,toConsumableArray/* default */.Z)(fileList);
|
|
var fileIndex = nextFileList.findIndex(function (_ref) {
|
|
var uid = _ref.uid;
|
|
return uid === file.uid;
|
|
});
|
|
if (fileIndex === -1) {
|
|
nextFileList.push(file);
|
|
} else {
|
|
nextFileList[fileIndex] = file;
|
|
}
|
|
return nextFileList;
|
|
}
|
|
function getFileItem(file, fileList) {
|
|
var matchKey = file.uid !== undefined ? 'uid' : 'name';
|
|
return fileList.filter(function (item) {
|
|
return item[matchKey] === file[matchKey];
|
|
})[0];
|
|
}
|
|
function removeFileItem(file, fileList) {
|
|
var matchKey = file.uid !== undefined ? 'uid' : 'name';
|
|
var removed = fileList.filter(function (item) {
|
|
return item[matchKey] !== file[matchKey];
|
|
});
|
|
if (removed.length === fileList.length) {
|
|
return null;
|
|
}
|
|
return removed;
|
|
}
|
|
// ==================== Default Image Preview ====================
|
|
var extname = function extname() {
|
|
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
var temp = url.split('/');
|
|
var filename = temp[temp.length - 1];
|
|
var filenameWithoutSuffix = filename.split(/#|\?/)[0];
|
|
return (/\.[^./\\]*$/.exec(filenameWithoutSuffix) || [''])[0];
|
|
};
|
|
var isImageFileType = function isImageFileType(type) {
|
|
return type.indexOf('image/') === 0;
|
|
};
|
|
var isImageUrl = function isImageUrl(file) {
|
|
if (file.type && !file.thumbUrl) {
|
|
return isImageFileType(file.type);
|
|
}
|
|
var url = file.thumbUrl || file.url || '';
|
|
var extension = extname(url);
|
|
if (/^data:image\//.test(url) || /(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg|ico|heic|heif)$/i.test(extension)) {
|
|
return true;
|
|
}
|
|
if (/^data:/.test(url)) {
|
|
// other file types of base64
|
|
return false;
|
|
}
|
|
if (extension) {
|
|
// other file types which have extension
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
var MEASURE_SIZE = 200;
|
|
function previewImage(file) {
|
|
return new Promise(function (resolve) {
|
|
if (!file.type || !isImageFileType(file.type)) {
|
|
resolve('');
|
|
return;
|
|
}
|
|
var canvas = document.createElement('canvas');
|
|
canvas.width = MEASURE_SIZE;
|
|
canvas.height = MEASURE_SIZE;
|
|
canvas.style.cssText = "position: fixed; left: 0; top: 0; width: ".concat(MEASURE_SIZE, "px; height: ").concat(MEASURE_SIZE, "px; z-index: 9999; display: none;");
|
|
document.body.appendChild(canvas);
|
|
var ctx = canvas.getContext('2d');
|
|
var img = new Image();
|
|
img.onload = function () {
|
|
var width = img.width,
|
|
height = img.height;
|
|
var drawWidth = MEASURE_SIZE;
|
|
var drawHeight = MEASURE_SIZE;
|
|
var offsetX = 0;
|
|
var offsetY = 0;
|
|
if (width > height) {
|
|
drawHeight = height * (MEASURE_SIZE / width);
|
|
offsetY = -(drawHeight - drawWidth) / 2;
|
|
} else {
|
|
drawWidth = width * (MEASURE_SIZE / height);
|
|
offsetX = -(drawWidth - drawHeight) / 2;
|
|
}
|
|
ctx.drawImage(img, offsetX, offsetY, drawWidth, drawHeight);
|
|
var dataURL = canvas.toDataURL();
|
|
document.body.removeChild(canvas);
|
|
resolve(dataURL);
|
|
};
|
|
img.crossOrigin = 'anonymous';
|
|
if (file.type.startsWith('image/svg+xml')) {
|
|
var reader = new FileReader();
|
|
reader.addEventListener('load', function () {
|
|
if (reader.result) img.src = reader.result;
|
|
});
|
|
reader.readAsDataURL(file);
|
|
} else {
|
|
img.src = window.URL.createObjectURL(file);
|
|
}
|
|
});
|
|
}
|
|
// EXTERNAL MODULE: ./node_modules/@ant-design/icons-svg/es/asn/DeleteOutlined.js
|
|
var asn_DeleteOutlined = __webpack_require__(47046);
|
|
;// CONCATENATED MODULE: ./node_modules/antd/node_modules/@ant-design/icons/es/icons/DeleteOutlined.js
|
|
|
|
// GENERATE BY ./scripts/generate.ts
|
|
// DON NOT EDIT IT MANUALLY
|
|
|
|
|
|
|
|
var DeleteOutlined = function DeleteOutlined(props, ref) {
|
|
return /*#__PURE__*/react.createElement(AntdIcon/* default */.Z, (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, props), {}, {
|
|
ref: ref,
|
|
icon: asn_DeleteOutlined/* default */.Z
|
|
}));
|
|
};
|
|
DeleteOutlined.displayName = 'DeleteOutlined';
|
|
/* harmony default export */ var icons_DeleteOutlined = (/*#__PURE__*/react.forwardRef(DeleteOutlined));
|
|
// EXTERNAL MODULE: ./node_modules/@ant-design/icons-svg/es/asn/DownloadOutlined.js
|
|
var asn_DownloadOutlined = __webpack_require__(49495);
|
|
;// CONCATENATED MODULE: ./node_modules/antd/node_modules/@ant-design/icons/es/icons/DownloadOutlined.js
|
|
|
|
// GENERATE BY ./scripts/generate.ts
|
|
// DON NOT EDIT IT MANUALLY
|
|
|
|
|
|
|
|
var DownloadOutlined = function DownloadOutlined(props, ref) {
|
|
return /*#__PURE__*/react.createElement(AntdIcon/* default */.Z, (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, props), {}, {
|
|
ref: ref,
|
|
icon: asn_DownloadOutlined/* default */.Z
|
|
}));
|
|
};
|
|
DownloadOutlined.displayName = 'DownloadOutlined';
|
|
/* harmony default export */ var icons_DownloadOutlined = (/*#__PURE__*/react.forwardRef(DownloadOutlined));
|
|
// EXTERNAL MODULE: ./node_modules/antd/node_modules/@ant-design/icons/es/icons/EyeOutlined.js + 1 modules
|
|
var EyeOutlined = __webpack_require__(7124);
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/progress/index.js + 10 modules
|
|
var progress = __webpack_require__(97910);
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/tooltip/index.js + 3 modules
|
|
var tooltip = __webpack_require__(84908);
|
|
;// CONCATENATED MODULE: ./node_modules/antd/es/upload/UploadList/ListItem.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ListItem = /*#__PURE__*/react.forwardRef(function (_ref, ref) {
|
|
var _classNames3;
|
|
var prefixCls = _ref.prefixCls,
|
|
className = _ref.className,
|
|
style = _ref.style,
|
|
locale = _ref.locale,
|
|
listType = _ref.listType,
|
|
file = _ref.file,
|
|
items = _ref.items,
|
|
progressProps = _ref.progress,
|
|
iconRender = _ref.iconRender,
|
|
actionIconRender = _ref.actionIconRender,
|
|
itemRender = _ref.itemRender,
|
|
isImgUrl = _ref.isImgUrl,
|
|
showPreviewIcon = _ref.showPreviewIcon,
|
|
showRemoveIcon = _ref.showRemoveIcon,
|
|
showDownloadIcon = _ref.showDownloadIcon,
|
|
customPreviewIcon = _ref.previewIcon,
|
|
customRemoveIcon = _ref.removeIcon,
|
|
customDownloadIcon = _ref.downloadIcon,
|
|
onPreview = _ref.onPreview,
|
|
onDownload = _ref.onDownload,
|
|
onClose = _ref.onClose;
|
|
var _a, _b;
|
|
// Status: which will ignore `removed` status
|
|
var status = file.status;
|
|
var _React$useState = react.useState(status),
|
|
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
|
|
mergedStatus = _React$useState2[0],
|
|
setMergedStatus = _React$useState2[1];
|
|
react.useEffect(function () {
|
|
if (status !== 'removed') {
|
|
setMergedStatus(status);
|
|
}
|
|
}, [status]);
|
|
// Delay to show the progress bar
|
|
var _React$useState3 = react.useState(false),
|
|
_React$useState4 = (0,slicedToArray/* default */.Z)(_React$useState3, 2),
|
|
showProgress = _React$useState4[0],
|
|
setShowProgress = _React$useState4[1];
|
|
var progressRafRef = react.useRef(null);
|
|
react.useEffect(function () {
|
|
progressRafRef.current = setTimeout(function () {
|
|
setShowProgress(true);
|
|
}, 300);
|
|
return function () {
|
|
if (progressRafRef.current) {
|
|
clearTimeout(progressRafRef.current);
|
|
}
|
|
};
|
|
}, []);
|
|
// This is used for legacy span make scrollHeight the wrong value.
|
|
// We will force these to be `display: block` with non `picture-card`
|
|
var spanClassName = "".concat(prefixCls, "-span");
|
|
var iconNode = iconRender(file);
|
|
var icon = /*#__PURE__*/react.createElement("div", {
|
|
className: "".concat(prefixCls, "-text-icon")
|
|
}, iconNode);
|
|
if (listType === 'picture' || listType === 'picture-card') {
|
|
if (mergedStatus === 'uploading' || !file.thumbUrl && !file.url) {
|
|
var _classNames;
|
|
var uploadingClassName = classnames_default()((_classNames = {}, (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-list-item-thumbnail"), true), (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-list-item-file"), mergedStatus !== 'uploading'), _classNames));
|
|
icon = /*#__PURE__*/react.createElement("div", {
|
|
className: uploadingClassName
|
|
}, iconNode);
|
|
} else {
|
|
var _classNames2;
|
|
var thumbnail = (isImgUrl === null || isImgUrl === void 0 ? void 0 : isImgUrl(file)) ? /*#__PURE__*/react.createElement("img", {
|
|
src: file.thumbUrl || file.url,
|
|
alt: file.name,
|
|
className: "".concat(prefixCls, "-list-item-image"),
|
|
crossOrigin: file.crossOrigin
|
|
}) : iconNode;
|
|
var aClassName = classnames_default()((_classNames2 = {}, (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-list-item-thumbnail"), true), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-list-item-file"), isImgUrl && !isImgUrl(file)), _classNames2));
|
|
icon = /*#__PURE__*/react.createElement("a", {
|
|
className: aClassName,
|
|
onClick: function onClick(e) {
|
|
return onPreview(file, e);
|
|
},
|
|
href: file.url || file.thumbUrl,
|
|
target: "_blank",
|
|
rel: "noopener noreferrer"
|
|
}, thumbnail);
|
|
}
|
|
}
|
|
var infoUploadingClass = classnames_default()((_classNames3 = {}, (0,defineProperty/* default */.Z)(_classNames3, "".concat(prefixCls, "-list-item"), true), (0,defineProperty/* default */.Z)(_classNames3, "".concat(prefixCls, "-list-item-").concat(mergedStatus), true), (0,defineProperty/* default */.Z)(_classNames3, "".concat(prefixCls, "-list-item-list-type-").concat(listType), true), _classNames3));
|
|
var linkProps = typeof file.linkProps === 'string' ? JSON.parse(file.linkProps) : file.linkProps;
|
|
var removeIcon = showRemoveIcon ? actionIconRender((typeof customRemoveIcon === 'function' ? customRemoveIcon(file) : customRemoveIcon) || /*#__PURE__*/react.createElement(icons_DeleteOutlined, null), function () {
|
|
return onClose(file);
|
|
}, prefixCls, locale.removeFile) : null;
|
|
var downloadIcon = showDownloadIcon && mergedStatus === 'done' ? actionIconRender((typeof customDownloadIcon === 'function' ? customDownloadIcon(file) : customDownloadIcon) || /*#__PURE__*/react.createElement(icons_DownloadOutlined, null), function () {
|
|
return onDownload(file);
|
|
}, prefixCls, locale.downloadFile) : null;
|
|
var downloadOrDelete = listType !== 'picture-card' && /*#__PURE__*/react.createElement("span", {
|
|
key: "download-delete",
|
|
className: classnames_default()("".concat(prefixCls, "-list-item-card-actions"), {
|
|
picture: listType === 'picture'
|
|
})
|
|
}, downloadIcon, removeIcon);
|
|
var listItemNameClass = classnames_default()("".concat(prefixCls, "-list-item-name"));
|
|
var preview = file.url ? [/*#__PURE__*/react.createElement("a", (0,esm_extends/* default */.Z)({
|
|
key: "view",
|
|
target: "_blank",
|
|
rel: "noopener noreferrer",
|
|
className: listItemNameClass,
|
|
title: file.name
|
|
}, linkProps, {
|
|
href: file.url,
|
|
onClick: function onClick(e) {
|
|
return onPreview(file, e);
|
|
}
|
|
}), file.name), downloadOrDelete] : [/*#__PURE__*/react.createElement("span", {
|
|
key: "view",
|
|
className: listItemNameClass,
|
|
onClick: function onClick(e) {
|
|
return onPreview(file, e);
|
|
},
|
|
title: file.name
|
|
}, file.name), downloadOrDelete];
|
|
var previewStyle = {
|
|
pointerEvents: 'none',
|
|
opacity: 0.5
|
|
};
|
|
var previewIcon = showPreviewIcon ? /*#__PURE__*/react.createElement("a", {
|
|
href: file.url || file.thumbUrl,
|
|
target: "_blank",
|
|
rel: "noopener noreferrer",
|
|
style: file.url || file.thumbUrl ? undefined : previewStyle,
|
|
onClick: function onClick(e) {
|
|
return onPreview(file, e);
|
|
},
|
|
title: locale.previewFile
|
|
}, typeof customPreviewIcon === 'function' ? customPreviewIcon(file) : customPreviewIcon || /*#__PURE__*/react.createElement(EyeOutlined/* default */.Z, null)) : null;
|
|
var actions = listType === 'picture-card' && mergedStatus !== 'uploading' && /*#__PURE__*/react.createElement("span", {
|
|
className: "".concat(prefixCls, "-list-item-actions")
|
|
}, previewIcon, mergedStatus === 'done' && downloadIcon, removeIcon);
|
|
var message;
|
|
if (file.response && typeof file.response === 'string') {
|
|
message = file.response;
|
|
} else {
|
|
message = ((_a = file.error) === null || _a === void 0 ? void 0 : _a.statusText) || ((_b = file.error) === null || _b === void 0 ? void 0 : _b.message) || locale.uploadError;
|
|
}
|
|
var iconAndPreview = /*#__PURE__*/react.createElement("span", {
|
|
className: spanClassName
|
|
}, icon, preview);
|
|
var _React$useContext = react.useContext(context/* ConfigContext */.E_),
|
|
getPrefixCls = _React$useContext.getPrefixCls;
|
|
var rootPrefixCls = getPrefixCls();
|
|
var dom = /*#__PURE__*/react.createElement("div", {
|
|
className: infoUploadingClass
|
|
}, /*#__PURE__*/react.createElement("div", {
|
|
className: "".concat(prefixCls, "-list-item-info")
|
|
}, iconAndPreview), actions, showProgress && /*#__PURE__*/react.createElement(rc_motion_es["default"], {
|
|
motionName: "".concat(rootPrefixCls, "-fade"),
|
|
visible: mergedStatus === 'uploading',
|
|
motionDeadline: 2000
|
|
}, function (_ref2) {
|
|
var motionClassName = _ref2.className;
|
|
// show loading icon if upload progress listener is disabled
|
|
var loadingProgress = 'percent' in file ? /*#__PURE__*/react.createElement(progress/* default */.Z, (0,esm_extends/* default */.Z)({}, progressProps, {
|
|
type: "line",
|
|
percent: file.percent
|
|
})) : null;
|
|
return /*#__PURE__*/react.createElement("div", {
|
|
className: classnames_default()("".concat(prefixCls, "-list-item-progress"), motionClassName)
|
|
}, loadingProgress);
|
|
}));
|
|
var listContainerNameClass = classnames_default()("".concat(prefixCls, "-list-").concat(listType, "-container"), className);
|
|
var item = mergedStatus === 'error' ? /*#__PURE__*/react.createElement(tooltip/* default */.Z, {
|
|
title: message,
|
|
getPopupContainer: function getPopupContainer(node) {
|
|
return node.parentNode;
|
|
}
|
|
}, dom) : dom;
|
|
return /*#__PURE__*/react.createElement("div", {
|
|
className: listContainerNameClass,
|
|
style: style,
|
|
ref: ref
|
|
}, itemRender ? itemRender(item, file, items, {
|
|
download: onDownload.bind(null, file),
|
|
preview: onPreview.bind(null, file),
|
|
remove: onClose.bind(null, file)
|
|
}) : item);
|
|
});
|
|
/* harmony default export */ var UploadList_ListItem = (ListItem);
|
|
;// CONCATENATED MODULE: ./node_modules/antd/es/upload/UploadList/index.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var listItemMotion = (0,esm_extends/* default */.Z)({}, motion/* default */.ZP);
|
|
delete listItemMotion.onAppearEnd;
|
|
delete listItemMotion.onEnterEnd;
|
|
delete listItemMotion.onLeaveEnd;
|
|
var InternalUploadList = function InternalUploadList(props, ref) {
|
|
var _classNames;
|
|
var _props$listType = props.listType,
|
|
listType = _props$listType === void 0 ? 'text' : _props$listType,
|
|
_props$previewFile = props.previewFile,
|
|
previewFile = _props$previewFile === void 0 ? previewImage : _props$previewFile,
|
|
onPreview = props.onPreview,
|
|
onDownload = props.onDownload,
|
|
onRemove = props.onRemove,
|
|
locale = props.locale,
|
|
iconRender = props.iconRender,
|
|
_props$isImageUrl = props.isImageUrl,
|
|
isImgUrl = _props$isImageUrl === void 0 ? isImageUrl : _props$isImageUrl,
|
|
customizePrefixCls = props.prefixCls,
|
|
_props$items = props.items,
|
|
items = _props$items === void 0 ? [] : _props$items,
|
|
_props$showPreviewIco = props.showPreviewIcon,
|
|
showPreviewIcon = _props$showPreviewIco === void 0 ? true : _props$showPreviewIco,
|
|
_props$showRemoveIcon = props.showRemoveIcon,
|
|
showRemoveIcon = _props$showRemoveIcon === void 0 ? true : _props$showRemoveIcon,
|
|
_props$showDownloadIc = props.showDownloadIcon,
|
|
showDownloadIcon = _props$showDownloadIc === void 0 ? false : _props$showDownloadIc,
|
|
removeIcon = props.removeIcon,
|
|
previewIcon = props.previewIcon,
|
|
downloadIcon = props.downloadIcon,
|
|
_props$progress = props.progress,
|
|
progress = _props$progress === void 0 ? {
|
|
strokeWidth: 2,
|
|
showInfo: false
|
|
} : _props$progress,
|
|
appendAction = props.appendAction,
|
|
_props$appendActionVi = props.appendActionVisible,
|
|
appendActionVisible = _props$appendActionVi === void 0 ? true : _props$appendActionVi,
|
|
itemRender = props.itemRender;
|
|
var forceUpdate = (0,useForceUpdate/* default */.Z)();
|
|
var _React$useState = react.useState(false),
|
|
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
|
|
motionAppear = _React$useState2[0],
|
|
setMotionAppear = _React$useState2[1];
|
|
// ============================= Effect =============================
|
|
react.useEffect(function () {
|
|
if (listType !== 'picture' && listType !== 'picture-card') {
|
|
return;
|
|
}
|
|
(items || []).forEach(function (file) {
|
|
if (typeof document === 'undefined' || typeof window === 'undefined' || !window.FileReader || !window.File || !(file.originFileObj instanceof File || file.originFileObj instanceof Blob) || file.thumbUrl !== undefined) {
|
|
return;
|
|
}
|
|
file.thumbUrl = '';
|
|
if (previewFile) {
|
|
previewFile(file.originFileObj).then(function (previewDataUrl) {
|
|
// Need append '' to avoid dead loop
|
|
file.thumbUrl = previewDataUrl || '';
|
|
forceUpdate();
|
|
});
|
|
}
|
|
});
|
|
}, [listType, items, previewFile]);
|
|
react.useEffect(function () {
|
|
setMotionAppear(true);
|
|
}, []);
|
|
// ============================= Events =============================
|
|
var onInternalPreview = function onInternalPreview(file, e) {
|
|
if (!onPreview) {
|
|
return;
|
|
}
|
|
e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
return onPreview(file);
|
|
};
|
|
var onInternalDownload = function onInternalDownload(file) {
|
|
if (typeof onDownload === 'function') {
|
|
onDownload(file);
|
|
} else if (file.url) {
|
|
window.open(file.url);
|
|
}
|
|
};
|
|
var onInternalClose = function onInternalClose(file) {
|
|
onRemove === null || onRemove === void 0 ? void 0 : onRemove(file);
|
|
};
|
|
var internalIconRender = function internalIconRender(file) {
|
|
if (iconRender) {
|
|
return iconRender(file, listType);
|
|
}
|
|
var isLoading = file.status === 'uploading';
|
|
var fileIcon = isImgUrl && isImgUrl(file) ? /*#__PURE__*/react.createElement(icons_PictureTwoTone, null) : /*#__PURE__*/react.createElement(icons_FileTwoTone, null);
|
|
var icon = isLoading ? /*#__PURE__*/react.createElement(LoadingOutlined/* default */.Z, null) : /*#__PURE__*/react.createElement(icons_PaperClipOutlined, null);
|
|
if (listType === 'picture') {
|
|
icon = isLoading ? /*#__PURE__*/react.createElement(LoadingOutlined/* default */.Z, null) : fileIcon;
|
|
} else if (listType === 'picture-card') {
|
|
icon = isLoading ? locale.uploading : fileIcon;
|
|
}
|
|
return icon;
|
|
};
|
|
var actionIconRender = function actionIconRender(customIcon, callback, prefixCls, title) {
|
|
var btnProps = {
|
|
type: 'text',
|
|
size: 'small',
|
|
title: title,
|
|
onClick: function onClick(e) {
|
|
callback();
|
|
if ((0,reactNode/* isValidElement */.l$)(customIcon) && customIcon.props.onClick) {
|
|
customIcon.props.onClick(e);
|
|
}
|
|
},
|
|
className: "".concat(prefixCls, "-list-item-card-actions-btn")
|
|
};
|
|
if ((0,reactNode/* isValidElement */.l$)(customIcon)) {
|
|
var btnIcon = (0,reactNode/* cloneElement */.Tm)(customIcon, (0,esm_extends/* default */.Z)((0,esm_extends/* default */.Z)({}, customIcon.props), {
|
|
onClick: function onClick() {}
|
|
}));
|
|
return /*#__PURE__*/react.createElement(es_button/* default */.Z, (0,esm_extends/* default */.Z)({}, btnProps, {
|
|
icon: btnIcon
|
|
}));
|
|
}
|
|
return /*#__PURE__*/react.createElement(es_button/* default */.Z, (0,esm_extends/* default */.Z)({}, btnProps), /*#__PURE__*/react.createElement("span", null, customIcon));
|
|
};
|
|
// ============================== Ref ===============================
|
|
// Test needs
|
|
react.useImperativeHandle(ref, function () {
|
|
return {
|
|
handlePreview: onInternalPreview,
|
|
handleDownload: onInternalDownload
|
|
};
|
|
});
|
|
var _React$useContext = react.useContext(context/* ConfigContext */.E_),
|
|
getPrefixCls = _React$useContext.getPrefixCls,
|
|
direction = _React$useContext.direction;
|
|
// ============================= Render =============================
|
|
var prefixCls = getPrefixCls('upload', customizePrefixCls);
|
|
var listClassNames = classnames_default()((_classNames = {}, (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-list"), true), (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-list-").concat(listType), true), (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-list-rtl"), direction === 'rtl'), _classNames));
|
|
// >>> Motion config
|
|
var motionKeyList = (0,toConsumableArray/* default */.Z)(items.map(function (file) {
|
|
return {
|
|
key: file.uid,
|
|
file: file
|
|
};
|
|
}));
|
|
var animationDirection = listType === 'picture-card' ? 'animate-inline' : 'animate';
|
|
// const transitionName = list.length === 0 ? '' : `${prefixCls}-${animationDirection}`;
|
|
var motionConfig = {
|
|
motionDeadline: 2000,
|
|
motionName: "".concat(prefixCls, "-").concat(animationDirection),
|
|
keys: motionKeyList,
|
|
motionAppear: motionAppear
|
|
};
|
|
if (listType !== 'picture-card') {
|
|
motionConfig = (0,esm_extends/* default */.Z)((0,esm_extends/* default */.Z)({}, listItemMotion), motionConfig);
|
|
}
|
|
return /*#__PURE__*/react.createElement("div", {
|
|
className: listClassNames
|
|
}, /*#__PURE__*/react.createElement(rc_motion_es.CSSMotionList, (0,esm_extends/* default */.Z)({}, motionConfig, {
|
|
component: false
|
|
}), function (_ref) {
|
|
var key = _ref.key,
|
|
file = _ref.file,
|
|
motionClassName = _ref.className,
|
|
motionStyle = _ref.style;
|
|
return /*#__PURE__*/react.createElement(UploadList_ListItem, {
|
|
key: key,
|
|
locale: locale,
|
|
prefixCls: prefixCls,
|
|
className: motionClassName,
|
|
style: motionStyle,
|
|
file: file,
|
|
items: items,
|
|
progress: progress,
|
|
listType: listType,
|
|
isImgUrl: isImgUrl,
|
|
showPreviewIcon: showPreviewIcon,
|
|
showRemoveIcon: showRemoveIcon,
|
|
showDownloadIcon: showDownloadIcon,
|
|
removeIcon: removeIcon,
|
|
previewIcon: previewIcon,
|
|
downloadIcon: downloadIcon,
|
|
iconRender: internalIconRender,
|
|
actionIconRender: actionIconRender,
|
|
itemRender: itemRender,
|
|
onPreview: onInternalPreview,
|
|
onDownload: onInternalDownload,
|
|
onClose: onInternalClose
|
|
});
|
|
}), appendAction && /*#__PURE__*/react.createElement(rc_motion_es["default"], (0,esm_extends/* default */.Z)({}, motionConfig, {
|
|
visible: appendActionVisible,
|
|
forceRender: true
|
|
}), function (_ref2) {
|
|
var motionClassName = _ref2.className,
|
|
motionStyle = _ref2.style;
|
|
return (0,reactNode/* cloneElement */.Tm)(appendAction, function (oriProps) {
|
|
return {
|
|
className: classnames_default()(oriProps.className, motionClassName),
|
|
style: (0,esm_extends/* default */.Z)((0,esm_extends/* default */.Z)((0,esm_extends/* default */.Z)({}, motionStyle), {
|
|
// prevent the element has hover css pseudo-class that may cause animation to end prematurely.
|
|
pointerEvents: motionClassName ? 'none' : undefined
|
|
}), oriProps.style)
|
|
};
|
|
});
|
|
}));
|
|
};
|
|
var UploadList = /*#__PURE__*/react.forwardRef(InternalUploadList);
|
|
if (false) {}
|
|
/* harmony default export */ var upload_UploadList = (UploadList);
|
|
;// CONCATENATED MODULE: ./node_modules/antd/es/upload/Upload.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) {
|
|
return value instanceof P ? value : new P(function (resolve) {
|
|
resolve(value);
|
|
});
|
|
}
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
}
|
|
function rejected(value) {
|
|
try {
|
|
step(generator["throw"](value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
}
|
|
function step(result) {
|
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
}
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var LIST_IGNORE = "__LIST_IGNORE_".concat(Date.now(), "__");
|
|
var InternalUpload = function InternalUpload(props, ref) {
|
|
var _classNames2;
|
|
var fileList = props.fileList,
|
|
defaultFileList = props.defaultFileList,
|
|
onRemove = props.onRemove,
|
|
_props$showUploadList = props.showUploadList,
|
|
showUploadList = _props$showUploadList === void 0 ? true : _props$showUploadList,
|
|
_props$listType = props.listType,
|
|
listType = _props$listType === void 0 ? 'text' : _props$listType,
|
|
onPreview = props.onPreview,
|
|
onDownload = props.onDownload,
|
|
onChange = props.onChange,
|
|
onDrop = props.onDrop,
|
|
previewFile = props.previewFile,
|
|
customDisabled = props.disabled,
|
|
propLocale = props.locale,
|
|
iconRender = props.iconRender,
|
|
isImageUrl = props.isImageUrl,
|
|
progress = props.progress,
|
|
customizePrefixCls = props.prefixCls,
|
|
className = props.className,
|
|
_props$type = props.type,
|
|
type = _props$type === void 0 ? 'select' : _props$type,
|
|
children = props.children,
|
|
style = props.style,
|
|
itemRender = props.itemRender,
|
|
maxCount = props.maxCount,
|
|
_props$data = props.data,
|
|
data = _props$data === void 0 ? {} : _props$data,
|
|
_props$multiple = props.multiple,
|
|
multiple = _props$multiple === void 0 ? false : _props$multiple,
|
|
_props$action = props.action,
|
|
action = _props$action === void 0 ? '' : _props$action,
|
|
_props$accept = props.accept,
|
|
accept = _props$accept === void 0 ? '' : _props$accept,
|
|
_props$supportServerR = props.supportServerRender,
|
|
supportServerRender = _props$supportServerR === void 0 ? true : _props$supportServerR;
|
|
// ===================== Disabled =====================
|
|
var disabled = react.useContext(DisabledContext/* default */.Z);
|
|
var mergedDisabled = customDisabled !== null && customDisabled !== void 0 ? customDisabled : disabled;
|
|
var _useMergedState = (0,useMergedState/* default */.Z)(defaultFileList || [], {
|
|
value: fileList,
|
|
postState: function postState(list) {
|
|
return list !== null && list !== void 0 ? list : [];
|
|
}
|
|
}),
|
|
_useMergedState2 = (0,slicedToArray/* default */.Z)(_useMergedState, 2),
|
|
mergedFileList = _useMergedState2[0],
|
|
setMergedFileList = _useMergedState2[1];
|
|
var _React$useState = react.useState('drop'),
|
|
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
|
|
dragState = _React$useState2[0],
|
|
setDragState = _React$useState2[1];
|
|
var upload = react.useRef(null);
|
|
false ? 0 : void 0;
|
|
false ? 0 : void 0;
|
|
// Control mode will auto fill file uid if not provided
|
|
react.useMemo(function () {
|
|
var timestamp = Date.now();
|
|
(fileList || []).forEach(function (file, index) {
|
|
if (!file.uid && !Object.isFrozen(file)) {
|
|
file.uid = "__AUTO__".concat(timestamp, "_").concat(index, "__");
|
|
}
|
|
});
|
|
}, [fileList]);
|
|
var onInternalChange = function onInternalChange(file, changedFileList, event) {
|
|
var cloneList = (0,toConsumableArray/* default */.Z)(changedFileList);
|
|
// Cut to match count
|
|
if (maxCount === 1) {
|
|
cloneList = cloneList.slice(-1);
|
|
} else if (maxCount) {
|
|
cloneList = cloneList.slice(0, maxCount);
|
|
}
|
|
// Prevent React18 auto batch since input[upload] trigger process at same time
|
|
// which makes fileList closure problem
|
|
(0,react_dom.flushSync)(function () {
|
|
setMergedFileList(cloneList);
|
|
});
|
|
var changeInfo = {
|
|
file: file,
|
|
fileList: cloneList
|
|
};
|
|
if (event) {
|
|
changeInfo.event = event;
|
|
}
|
|
onChange === null || onChange === void 0 ? void 0 : onChange(changeInfo);
|
|
};
|
|
var mergedBeforeUpload = function mergedBeforeUpload(file, fileListArgs) {
|
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0,regeneratorRuntime/* default */.Z)().mark(function _callee() {
|
|
var beforeUpload, transformFile, parsedFile, result;
|
|
return (0,regeneratorRuntime/* default */.Z)().wrap(function _callee$(_context) {
|
|
while (1) switch (_context.prev = _context.next) {
|
|
case 0:
|
|
beforeUpload = props.beforeUpload, transformFile = props.transformFile;
|
|
parsedFile = file;
|
|
if (!beforeUpload) {
|
|
_context.next = 13;
|
|
break;
|
|
}
|
|
_context.next = 5;
|
|
return beforeUpload(file, fileListArgs);
|
|
case 5:
|
|
result = _context.sent;
|
|
if (!(result === false)) {
|
|
_context.next = 8;
|
|
break;
|
|
}
|
|
return _context.abrupt("return", false);
|
|
case 8:
|
|
// Hack for LIST_IGNORE, we add additional info to remove from the list
|
|
delete file[LIST_IGNORE];
|
|
if (!(result === LIST_IGNORE)) {
|
|
_context.next = 12;
|
|
break;
|
|
}
|
|
Object.defineProperty(file, LIST_IGNORE, {
|
|
value: true,
|
|
configurable: true
|
|
});
|
|
return _context.abrupt("return", false);
|
|
case 12:
|
|
if ((0,esm_typeof/* default */.Z)(result) === 'object' && result) {
|
|
parsedFile = result;
|
|
}
|
|
case 13:
|
|
if (!transformFile) {
|
|
_context.next = 17;
|
|
break;
|
|
}
|
|
_context.next = 16;
|
|
return transformFile(parsedFile);
|
|
case 16:
|
|
parsedFile = _context.sent;
|
|
case 17:
|
|
return _context.abrupt("return", parsedFile);
|
|
case 18:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}, _callee);
|
|
}));
|
|
};
|
|
var onBatchStart = function onBatchStart(batchFileInfoList) {
|
|
// Skip file which marked as `LIST_IGNORE`, these file will not add to file list
|
|
var filteredFileInfoList = batchFileInfoList.filter(function (info) {
|
|
return !info.file[LIST_IGNORE];
|
|
});
|
|
// Nothing to do since no file need upload
|
|
if (!filteredFileInfoList.length) {
|
|
return;
|
|
}
|
|
var objectFileList = filteredFileInfoList.map(function (info) {
|
|
return file2Obj(info.file);
|
|
});
|
|
// Concat new files with prev files
|
|
var newFileList = (0,toConsumableArray/* default */.Z)(mergedFileList);
|
|
objectFileList.forEach(function (fileObj) {
|
|
// Replace file if exist
|
|
newFileList = updateFileList(fileObj, newFileList);
|
|
});
|
|
objectFileList.forEach(function (fileObj, index) {
|
|
// Repeat trigger `onChange` event for compatible
|
|
var triggerFileObj = fileObj;
|
|
if (!filteredFileInfoList[index].parsedFile) {
|
|
// `beforeUpload` return false
|
|
var originFileObj = fileObj.originFileObj;
|
|
var clone;
|
|
try {
|
|
clone = new File([originFileObj], originFileObj.name, {
|
|
type: originFileObj.type
|
|
});
|
|
} catch (e) {
|
|
clone = new Blob([originFileObj], {
|
|
type: originFileObj.type
|
|
});
|
|
clone.name = originFileObj.name;
|
|
clone.lastModifiedDate = new Date();
|
|
clone.lastModified = new Date().getTime();
|
|
}
|
|
clone.uid = fileObj.uid;
|
|
triggerFileObj = clone;
|
|
} else {
|
|
// Inject `uploading` status
|
|
fileObj.status = 'uploading';
|
|
}
|
|
onInternalChange(triggerFileObj, newFileList);
|
|
});
|
|
};
|
|
var onSuccess = function onSuccess(response, file, xhr) {
|
|
try {
|
|
if (typeof response === 'string') {
|
|
response = JSON.parse(response);
|
|
}
|
|
} catch (e) {
|
|
/* do nothing */
|
|
}
|
|
// removed
|
|
if (!getFileItem(file, mergedFileList)) {
|
|
return;
|
|
}
|
|
var targetItem = file2Obj(file);
|
|
targetItem.status = 'done';
|
|
targetItem.percent = 100;
|
|
targetItem.response = response;
|
|
targetItem.xhr = xhr;
|
|
var nextFileList = updateFileList(targetItem, mergedFileList);
|
|
onInternalChange(targetItem, nextFileList);
|
|
};
|
|
var onProgress = function onProgress(e, file) {
|
|
// removed
|
|
if (!getFileItem(file, mergedFileList)) {
|
|
return;
|
|
}
|
|
var targetItem = file2Obj(file);
|
|
targetItem.status = 'uploading';
|
|
targetItem.percent = e.percent;
|
|
var nextFileList = updateFileList(targetItem, mergedFileList);
|
|
onInternalChange(targetItem, nextFileList, e);
|
|
};
|
|
var onError = function onError(error, response, file) {
|
|
// removed
|
|
if (!getFileItem(file, mergedFileList)) {
|
|
return;
|
|
}
|
|
var targetItem = file2Obj(file);
|
|
targetItem.error = error;
|
|
targetItem.response = response;
|
|
targetItem.status = 'error';
|
|
var nextFileList = updateFileList(targetItem, mergedFileList);
|
|
onInternalChange(targetItem, nextFileList);
|
|
};
|
|
var handleRemove = function handleRemove(file) {
|
|
var currentFile;
|
|
Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(function (ret) {
|
|
var _a;
|
|
// Prevent removing file
|
|
if (ret === false) {
|
|
return;
|
|
}
|
|
var removedFileList = removeFileItem(file, mergedFileList);
|
|
if (removedFileList) {
|
|
currentFile = (0,esm_extends/* default */.Z)((0,esm_extends/* default */.Z)({}, file), {
|
|
status: 'removed'
|
|
});
|
|
mergedFileList === null || mergedFileList === void 0 ? void 0 : mergedFileList.forEach(function (item) {
|
|
var matchKey = currentFile.uid !== undefined ? 'uid' : 'name';
|
|
if (item[matchKey] === currentFile[matchKey] && !Object.isFrozen(item)) {
|
|
item.status = 'removed';
|
|
}
|
|
});
|
|
(_a = upload.current) === null || _a === void 0 ? void 0 : _a.abort(currentFile);
|
|
onInternalChange(currentFile, removedFileList);
|
|
}
|
|
});
|
|
};
|
|
var onFileDrop = function onFileDrop(e) {
|
|
setDragState(e.type);
|
|
if (e.type === 'drop') {
|
|
onDrop === null || onDrop === void 0 ? void 0 : onDrop(e);
|
|
}
|
|
};
|
|
// Test needs
|
|
react.useImperativeHandle(ref, function () {
|
|
return {
|
|
onBatchStart: onBatchStart,
|
|
onSuccess: onSuccess,
|
|
onProgress: onProgress,
|
|
onError: onError,
|
|
fileList: mergedFileList,
|
|
upload: upload.current
|
|
};
|
|
});
|
|
var _React$useContext = react.useContext(context/* ConfigContext */.E_),
|
|
getPrefixCls = _React$useContext.getPrefixCls,
|
|
direction = _React$useContext.direction;
|
|
var prefixCls = getPrefixCls('upload', customizePrefixCls);
|
|
var rcUploadProps = (0,esm_extends/* default */.Z)((0,esm_extends/* default */.Z)({
|
|
onBatchStart: onBatchStart,
|
|
onError: onError,
|
|
onProgress: onProgress,
|
|
onSuccess: onSuccess
|
|
}, props), {
|
|
data: data,
|
|
multiple: multiple,
|
|
action: action,
|
|
accept: accept,
|
|
supportServerRender: supportServerRender,
|
|
prefixCls: prefixCls,
|
|
disabled: mergedDisabled,
|
|
beforeUpload: mergedBeforeUpload,
|
|
onChange: undefined
|
|
});
|
|
delete rcUploadProps.className;
|
|
delete rcUploadProps.style;
|
|
// Remove id to avoid open by label when trigger is hidden
|
|
// !children: https://github.com/ant-design/ant-design/issues/14298
|
|
// disabled: https://github.com/ant-design/ant-design/issues/16478
|
|
// https://github.com/ant-design/ant-design/issues/24197
|
|
if (!children || mergedDisabled) {
|
|
delete rcUploadProps.id;
|
|
}
|
|
var renderUploadList = function renderUploadList(button, buttonVisible) {
|
|
return showUploadList ? /*#__PURE__*/react.createElement(LocaleReceiver/* default */.Z, {
|
|
componentName: "Upload",
|
|
defaultLocale: locale_default/* default.Upload */.Z.Upload
|
|
}, function (contextLocale) {
|
|
var _ref = typeof showUploadList === 'boolean' ? {} : showUploadList,
|
|
showRemoveIcon = _ref.showRemoveIcon,
|
|
showPreviewIcon = _ref.showPreviewIcon,
|
|
showDownloadIcon = _ref.showDownloadIcon,
|
|
removeIcon = _ref.removeIcon,
|
|
previewIcon = _ref.previewIcon,
|
|
downloadIcon = _ref.downloadIcon;
|
|
return /*#__PURE__*/react.createElement(upload_UploadList, {
|
|
prefixCls: prefixCls,
|
|
listType: listType,
|
|
items: mergedFileList,
|
|
previewFile: previewFile,
|
|
onPreview: onPreview,
|
|
onDownload: onDownload,
|
|
onRemove: handleRemove,
|
|
showRemoveIcon: !mergedDisabled && showRemoveIcon,
|
|
showPreviewIcon: showPreviewIcon,
|
|
showDownloadIcon: showDownloadIcon,
|
|
removeIcon: removeIcon,
|
|
previewIcon: previewIcon,
|
|
downloadIcon: downloadIcon,
|
|
iconRender: iconRender,
|
|
locale: (0,esm_extends/* default */.Z)((0,esm_extends/* default */.Z)({}, contextLocale), propLocale),
|
|
isImageUrl: isImageUrl,
|
|
progress: progress,
|
|
appendAction: button,
|
|
appendActionVisible: buttonVisible,
|
|
itemRender: itemRender
|
|
});
|
|
}) : button;
|
|
};
|
|
if (type === 'drag') {
|
|
var _classNames;
|
|
var dragCls = classnames_default()(prefixCls, (_classNames = {}, (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-drag"), true), (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-drag-uploading"), mergedFileList.some(function (file) {
|
|
return file.status === 'uploading';
|
|
})), (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-drag-hover"), dragState === 'dragover'), (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-disabled"), mergedDisabled), (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-rtl"), direction === 'rtl'), _classNames), className);
|
|
return /*#__PURE__*/react.createElement("span", null, /*#__PURE__*/react.createElement("div", {
|
|
className: dragCls,
|
|
onDrop: onFileDrop,
|
|
onDragOver: onFileDrop,
|
|
onDragLeave: onFileDrop,
|
|
style: style
|
|
}, /*#__PURE__*/react.createElement(es, (0,esm_extends/* default */.Z)({}, rcUploadProps, {
|
|
ref: upload,
|
|
className: "".concat(prefixCls, "-btn")
|
|
}), /*#__PURE__*/react.createElement("div", {
|
|
className: "".concat(prefixCls, "-drag-container")
|
|
}, children))), renderUploadList());
|
|
}
|
|
var uploadButtonCls = classnames_default()(prefixCls, (_classNames2 = {}, (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-select"), true), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-select-").concat(listType), true), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-disabled"), mergedDisabled), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-rtl"), direction === 'rtl'), _classNames2));
|
|
var renderUploadButton = function renderUploadButton(uploadButtonStyle) {
|
|
return /*#__PURE__*/react.createElement("div", {
|
|
className: uploadButtonCls,
|
|
style: uploadButtonStyle
|
|
}, /*#__PURE__*/react.createElement(es, (0,esm_extends/* default */.Z)({}, rcUploadProps, {
|
|
ref: upload
|
|
})));
|
|
};
|
|
var uploadButton = renderUploadButton(children ? undefined : {
|
|
display: 'none'
|
|
});
|
|
if (listType === 'picture-card') {
|
|
return /*#__PURE__*/react.createElement("span", {
|
|
className: classnames_default()("".concat(prefixCls, "-picture-card-wrapper"), className)
|
|
}, renderUploadList(uploadButton, !!children));
|
|
}
|
|
return /*#__PURE__*/react.createElement("span", {
|
|
className: className
|
|
}, uploadButton, renderUploadList());
|
|
};
|
|
var Upload_Upload = /*#__PURE__*/react.forwardRef(InternalUpload);
|
|
if (false) {}
|
|
/* harmony default export */ var upload_Upload = (Upload_Upload);
|
|
;// CONCATENATED MODULE: ./node_modules/antd/es/upload/Dragger.js
|
|
|
|
var __rest = undefined && undefined.__rest || function (s, e) {
|
|
var t = {};
|
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
}
|
|
return t;
|
|
};
|
|
|
|
|
|
var Dragger = /*#__PURE__*/react.forwardRef(function (_a, ref) {
|
|
var style = _a.style,
|
|
height = _a.height,
|
|
restProps = __rest(_a, ["style", "height"]);
|
|
return /*#__PURE__*/react.createElement(upload_Upload, (0,esm_extends/* default */.Z)({
|
|
ref: ref
|
|
}, restProps, {
|
|
type: "drag",
|
|
style: (0,esm_extends/* default */.Z)((0,esm_extends/* default */.Z)({}, style), {
|
|
height: height
|
|
})
|
|
}));
|
|
});
|
|
if (false) {}
|
|
/* harmony default export */ var upload_Dragger = (Dragger);
|
|
;// CONCATENATED MODULE: ./node_modules/antd/es/upload/index.js
|
|
|
|
|
|
var es_upload_Upload = upload_Upload;
|
|
es_upload_Upload.Dragger = upload_Dragger;
|
|
es_upload_Upload.LIST_IGNORE = LIST_IGNORE;
|
|
/* harmony default export */ var es_upload = (es_upload_Upload);
|
|
|
|
/***/ }),
|
|
|
|
/***/ 13759:
|
|
/*!****************************************************************!*\
|
|
!*** ./node_modules/antd/es/upload/style/index.js + 1 modules ***!
|
|
\****************************************************************/
|
|
/***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/style/default.less
|
|
var style_default = __webpack_require__(43146);
|
|
;// CONCATENATED MODULE: ./node_modules/antd/es/upload/style/index.less
|
|
// extracted by mini-css-extract-plugin
|
|
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/button/style/index.js + 1 modules
|
|
var style = __webpack_require__(29913);
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/progress/style/index.js + 1 modules
|
|
var progress_style = __webpack_require__(57273);
|
|
// EXTERNAL MODULE: ./node_modules/antd/es/tooltip/style/index.js + 1 modules
|
|
var tooltip_style = __webpack_require__(38390);
|
|
;// CONCATENATED MODULE: ./node_modules/antd/es/upload/style/index.js
|
|
|
|
|
|
// style dependencies
|
|
// deps-lint-skip: form
|
|
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
}]); |