rsuite 4.10.4 → 4.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ <a name="4.10.5"></a>
2
+ ## [4.10.5](https://github.com/rsuite/rsuite/compare/v4.10.4...v4.10.5) (2021-11-26)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * **Uploader:** uploader fileMap is not updated when status is error ([#2158](https://github.com/rsuite/rsuite/issues/2158)) ([7d80b55](https://github.com/rsuite/rsuite/commit/7d80b55))
8
+
9
+
10
+
1
11
  <a name="4.10.4"></a>
2
12
  ## [4.10.4](https://github.com/rsuite/rsuite/compare/4.10.3...4.10.4) (2021-10-22)
3
13
 
package/dist/rsuite.js CHANGED
@@ -10228,7 +10228,7 @@ eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime/he
10228
10228
  /***/ (function(module, exports, __webpack_require__) {
10229
10229
 
10230
10230
  "use strict";
10231
- eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\");\n\nvar _interopRequireWildcard = __webpack_require__(/*! @babel/runtime/helpers/interopRequireWildcard */ \"./node_modules/@babel/runtime/helpers/interopRequireWildcard.js\");\n\nexports.__esModule = true;\nexports.default = void 0;\n\nvar _objectWithoutPropertiesLoose2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/objectWithoutPropertiesLoose */ \"./node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js\"));\n\nvar _extends2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/extends */ \"./node_modules/@babel/runtime/helpers/extends.js\"));\n\nvar _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/assertThisInitialized */ \"./node_modules/@babel/runtime/helpers/assertThisInitialized.js\"));\n\nvar _inheritsLoose2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inheritsLoose */ \"./node_modules/@babel/runtime/helpers/inheritsLoose.js\"));\n\nvar _find2 = _interopRequireDefault(__webpack_require__(/*! lodash/find */ \"./node_modules/lodash/find.js\"));\n\nvar React = _interopRequireWildcard(__webpack_require__(/*! react */ \"react\"));\n\nvar _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ \"./node_modules/prop-types/index.js\"));\n\nvar _classnames = _interopRequireDefault(__webpack_require__(/*! classnames */ \"./node_modules/classnames/index.js\"));\n\nvar _IntlContext = _interopRequireDefault(__webpack_require__(/*! ../IntlProvider/IntlContext */ \"./src/IntlProvider/IntlContext.ts\"));\n\nvar _withLocale = _interopRequireDefault(__webpack_require__(/*! ../IntlProvider/withLocale */ \"./src/IntlProvider/withLocale.tsx\"));\n\nvar _UploadFileItem = _interopRequireDefault(__webpack_require__(/*! ./UploadFileItem */ \"./src/Uploader/UploadFileItem.tsx\"));\n\nvar _UploadTrigger = _interopRequireDefault(__webpack_require__(/*! ./UploadTrigger */ \"./src/Uploader/UploadTrigger.tsx\"));\n\nvar _utils = __webpack_require__(/*! ../utils */ \"./src/utils/index.ts\");\n\nvar _utils2 = __webpack_require__(/*! ./utils */ \"./src/Uploader/utils.ts\");\n\nvar _jsxFileName = \"/home/runner/work/rsuite/rsuite/src/Uploader/Uploader.tsx\";\n\nvar Uploader =\n/*#__PURE__*/\nfunction (_React$Component) {\n (0, _inheritsLoose2.default)(Uploader, _React$Component);\n\n function Uploader(props) {\n var _this;\n\n _this = _React$Component.call(this, props) || this;\n _this.inputRef = void 0;\n\n _this.handleRemoveFile = function (fileKey) {\n var _this$props$onRemove, _this$props, _this$props$onChange, _this$props2;\n\n var fileList = _this.getFileList();\n\n var file = (0, _find2.default)(fileList, function (f) {\n return f.fileKey === fileKey;\n });\n var nextFileList = fileList.filter(function (f) {\n return f.fileKey !== fileKey;\n });\n\n if (_this.xhrs[file.fileKey] && _this.xhrs[file.fileKey].readyState !== 4) {\n _this.xhrs[file.fileKey].abort();\n }\n\n _this.setState({\n fileList: nextFileList\n });\n\n (_this$props$onRemove = (_this$props = _this.props).onRemove) === null || _this$props$onRemove === void 0 ? void 0 : _this$props$onRemove.call(_this$props, file);\n (_this$props$onChange = (_this$props2 = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props2, nextFileList);\n\n _this.cleanInputValue();\n };\n\n _this.handleUploadTriggerChange = function (event) {\n var _this$props3 = _this.props,\n autoUpload = _this$props3.autoUpload,\n shouldQueueUpdate = _this$props3.shouldQueueUpdate,\n onChange = _this$props3.onChange;\n\n var fileList = _this.getFileList();\n\n var files = (0, _utils2.getFiles)(event);\n var newFileList = [];\n Array.from(files).forEach(function (file) {\n newFileList.push({\n blobFile: file,\n name: file.name,\n status: 'inited',\n fileKey: (0, _utils2.guid)()\n });\n });\n var nextFileList = [].concat(fileList, newFileList);\n var checkState = shouldQueueUpdate === null || shouldQueueUpdate === void 0 ? void 0 : shouldQueueUpdate(nextFileList, newFileList);\n\n var upload = function upload() {\n onChange === null || onChange === void 0 ? void 0 : onChange(nextFileList);\n\n _this.setState({\n fileList: nextFileList\n }, function () {\n autoUpload && _this.handleAjaxUpload();\n });\n };\n\n if (checkState instanceof Promise) {\n checkState.then(function (res) {\n if (res) {\n upload();\n }\n });\n return;\n } else if (checkState === false) {\n _this.cleanInputValue();\n\n return;\n }\n\n upload();\n };\n\n _this.handleAjaxUploadSuccess = function (file, response, event, xhr) {\n var nextFile = (0, _extends2.default)({}, file, {\n status: 'finished',\n progress: 100\n });\n\n _this.updateFileList(nextFile, function () {\n var _this$props$onSuccess, _this$props4;\n\n (_this$props$onSuccess = (_this$props4 = _this.props).onSuccess) === null || _this$props$onSuccess === void 0 ? void 0 : _this$props$onSuccess.call(_this$props4, response, nextFile, event, xhr);\n });\n };\n\n _this.handleAjaxUploadError = function (file, status, event, xhr) {\n var nextFile = (0, _extends2.default)({}, file, {\n status: 'error'\n });\n\n _this.updateFileList(nextFile, function () {\n var _this$props$onError, _this$props5;\n\n (_this$props$onError = (_this$props5 = _this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props5, status, nextFile, event, xhr);\n });\n };\n\n _this.handleAjaxUploadProgress = function (file, percent, event, xhr) {\n var nextFile = (0, _extends2.default)({}, file, {\n status: 'uploading',\n progress: percent\n });\n\n _this.updateFileList(nextFile, function () {\n var _this$props$onProgres, _this$props6;\n\n (_this$props$onProgres = (_this$props6 = _this.props).onProgress) === null || _this$props$onProgres === void 0 ? void 0 : _this$props$onProgres.call(_this$props6, percent, nextFile, event, xhr);\n });\n };\n\n _this.handleUploadFile = function (file) {\n var _this$props7 = _this.props,\n name = _this$props7.name,\n action = _this$props7.action,\n headers = _this$props7.headers,\n withCredentials = _this$props7.withCredentials,\n timeout = _this$props7.timeout,\n data = _this$props7.data,\n onUpload = _this$props7.onUpload;\n var xhr = (0, _utils.ajaxUpload)({\n name: name,\n timeout: timeout,\n headers: headers,\n data: data,\n withCredentials: withCredentials,\n file: file.blobFile,\n url: action,\n onError: _this.handleAjaxUploadError.bind((0, _assertThisInitialized2.default)(_this), file),\n onSuccess: _this.handleAjaxUploadSuccess.bind((0, _assertThisInitialized2.default)(_this), file),\n onProgress: _this.handleAjaxUploadProgress.bind((0, _assertThisInitialized2.default)(_this), file)\n });\n\n _this.updateFileList((0, _extends2.default)({}, file, {\n status: 'uploading'\n }));\n\n _this.xhrs[file.fileKey] = xhr;\n onUpload === null || onUpload === void 0 ? void 0 : onUpload(file);\n };\n\n _this.handleReupload = function (file) {\n var _this$props8 = _this.props,\n onReupload = _this$props8.onReupload,\n autoUpload = _this$props8.autoUpload;\n autoUpload && _this.handleUploadFile(file);\n onReupload === null || onReupload === void 0 ? void 0 : onReupload(file);\n };\n\n _this.createFile = function (file) {\n var fileKey = file.fileKey;\n return (0, _extends2.default)({}, file, {\n fileKey: fileKey || (0, _utils2.guid)(),\n progress: 0\n });\n };\n\n _this.addPrefix = function (name) {\n return (0, _utils.prefix)(_this.props.classPrefix)(name);\n };\n\n _this.progressTimer = void 0;\n _this.xhrs = {};\n _this.uploadTrigger = null;\n var _props$defaultFileLis = props.defaultFileList,\n defaultFileList = _props$defaultFileLis === void 0 ? [] : _props$defaultFileLis;\n\n var _fileList = defaultFileList.map(_this.createFile);\n\n _this.state = {\n fileList: _fileList,\n fileMap: {}\n };\n _this.inputRef = React.createRef();\n return _this;\n } // public API\n\n\n var _proto = Uploader.prototype;\n\n _proto.start = function start(file) {\n if (file) {\n this.handleUploadFile(file);\n return;\n }\n\n this.handleAjaxUpload();\n };\n\n _proto.getFileList = function getFileList() {\n var fileList = this.props.fileList;\n var fileMap = this.state.fileMap;\n\n if (typeof fileList !== 'undefined') {\n return fileList.map(function (file) {\n return (0, _extends2.default)({}, file, {}, fileMap[file.fileKey]);\n });\n }\n\n return this.state.fileList;\n };\n\n _proto.cleanInputValue = function cleanInputValue() {\n if (this.inputRef.current) {\n this.inputRef.current.getInputInstance().value = '';\n }\n };\n\n _proto.handleAjaxUpload = function handleAjaxUpload() {\n var _this2 = this;\n\n var shouldUpload = this.props.shouldUpload;\n var fileList = this.getFileList();\n fileList.forEach(function (file) {\n var checkState = shouldUpload === null || shouldUpload === void 0 ? void 0 : shouldUpload(file);\n\n if (checkState instanceof Promise) {\n checkState.then(function (res) {\n if (res) {\n _this2.handleUploadFile(file);\n }\n });\n return;\n } else if (checkState === false) {\n return;\n }\n\n if (file.status === 'inited') {\n _this2.handleUploadFile(file);\n }\n });\n this.cleanInputValue();\n };\n\n _proto.updateFileList = function updateFileList(nextFile, callback) {\n var fileList = this.getFileList();\n var nextFileList = fileList.map(function (file) {\n return file.fileKey === nextFile.fileKey ? nextFile : file;\n });\n var nextState = {\n fileList: nextFileList\n };\n\n if (nextFile.progress) {\n var fileMap = this.state.fileMap;\n fileMap[nextFile.fileKey] = {\n progress: nextFile.progress,\n status: nextFile.status\n };\n nextState.fileMap = fileMap;\n }\n\n this.setState(nextState, callback);\n };\n\n _proto.renderFileItems = function renderFileItems() {\n var _this3 = this;\n\n var _this$props9 = this.props,\n disabledFileItem = _this$props9.disabledFileItem,\n listType = _this$props9.listType,\n onPreview = _this$props9.onPreview,\n maxPreviewFileSize = _this$props9.maxPreviewFileSize,\n renderFileInfo = _this$props9.renderFileInfo,\n removable = _this$props9.removable;\n var fileList = this.getFileList();\n return React.createElement(\"div\", {\n key: \"items\",\n className: this.addPrefix('file-items'),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 327\n },\n __self: this\n }, fileList.map(function (file, index) {\n return React.createElement(_UploadFileItem.default, {\n key: file.fileKey || index,\n file: file,\n maxPreviewFileSize: maxPreviewFileSize,\n listType: listType,\n disabled: disabledFileItem,\n onPreview: onPreview,\n onReupload: _this3.handleReupload,\n onCancel: _this3.handleRemoveFile,\n renderFileInfo: renderFileInfo,\n removable: removable,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 329\n },\n __self: this\n });\n }));\n };\n\n _proto.renderUploadTrigger = function renderUploadTrigger() {\n var _this$props10 = this.props,\n name = _this$props10.name,\n multiple = _this$props10.multiple,\n disabled = _this$props10.disabled,\n accept = _this$props10.accept,\n children = _this$props10.children,\n toggleComponentClass = _this$props10.toggleComponentClass,\n draggable = _this$props10.draggable,\n rest = (0, _objectWithoutPropertiesLoose2.default)(_this$props10, [\"name\", \"multiple\", \"disabled\", \"accept\", \"children\", \"toggleComponentClass\", \"draggable\"]);\n var unhandled = (0, _utils.getUnhandledProps)(Uploader, rest);\n return React.createElement(_UploadTrigger.default, (0, _extends2.default)({}, unhandled, {\n name: name,\n key: \"trigger\",\n multiple: multiple,\n draggable: draggable,\n disabled: disabled,\n accept: accept,\n ref: this.inputRef,\n onChange: this.handleUploadTriggerChange,\n componentClass: toggleComponentClass,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 360\n },\n __self: this\n }), children);\n };\n\n _proto.render = function render() {\n var _classNames;\n\n var _this$props11 = this.props,\n classPrefix = _this$props11.classPrefix,\n className = _this$props11.className,\n listType = _this$props11.listType,\n fileListVisible = _this$props11.fileListVisible,\n locale = _this$props11.locale,\n style = _this$props11.style,\n draggable = _this$props11.draggable;\n var classes = (0, _classnames.default)(className, classPrefix, this.addPrefix(listType), (_classNames = {}, _classNames[this.addPrefix('draggable')] = draggable, _classNames));\n var renderList = [this.renderUploadTrigger()];\n\n if (fileListVisible) {\n renderList.push(this.renderFileItems());\n }\n\n if (listType === 'picture') {\n renderList.reverse();\n }\n\n return React.createElement(_IntlContext.default.Provider, {\n value: locale,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 401\n },\n __self: this\n }, React.createElement(\"div\", {\n className: classes,\n style: style,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 402\n },\n __self: this\n }, renderList));\n };\n\n return Uploader;\n}(React.Component);\n\nUploader.propTypes = {\n action: _propTypes.default.string,\n accept: _propTypes.default.string,\n autoUpload: _propTypes.default.bool,\n children: _propTypes.default.node,\n className: _propTypes.default.string,\n classPrefix: _propTypes.default.string,\n defaultFileList: _propTypes.default.array,\n fileList: _propTypes.default.array,\n data: _propTypes.default.object,\n multiple: _propTypes.default.bool,\n disabled: _propTypes.default.bool,\n disabledFileItem: _propTypes.default.bool,\n name: _propTypes.default.string,\n timeout: _propTypes.default.number,\n withCredentials: _propTypes.default.bool,\n headers: _propTypes.default.object,\n locale: _propTypes.default.object,\n listType: _propTypes.default.oneOf(['text', 'picture-text', 'picture']),\n shouldQueueUpdate: _propTypes.default.func,\n shouldUpload: _propTypes.default.func,\n onChange: _propTypes.default.func,\n onUpload: _propTypes.default.func,\n onReupload: _propTypes.default.func,\n onPreview: _propTypes.default.func,\n onError: _propTypes.default.func,\n onSuccess: _propTypes.default.func,\n onProgress: _propTypes.default.func,\n onRemove: _propTypes.default.func,\n maxPreviewFileSize: _propTypes.default.number,\n style: _propTypes.default.object,\n toggleComponentClass: _propTypes.default.elementType,\n renderFileInfo: _propTypes.default.func,\n removable: _propTypes.default.bool,\n fileListVisible: _propTypes.default.bool,\n draggable: _propTypes.default.bool\n};\nUploader.defaultProps = {\n autoUpload: true,\n timeout: 0,\n name: 'file',\n multiple: false,\n disabled: false,\n withCredentials: false,\n data: {},\n listType: 'text',\n removable: true,\n fileListVisible: true\n};\n\nvar _default = (0, _utils.compose)((0, _withLocale.default)(['Uploader']), (0, _utils.defaultProps)({\n classPrefix: 'uploader'\n}))(Uploader);\n\nexports.default = _default;\nmodule.exports = exports.default;\n\n//# sourceURL=webpack://rsuite/./src/Uploader/Uploader.tsx?");
10231
+ eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\");\n\nvar _interopRequireWildcard = __webpack_require__(/*! @babel/runtime/helpers/interopRequireWildcard */ \"./node_modules/@babel/runtime/helpers/interopRequireWildcard.js\");\n\nexports.__esModule = true;\nexports.default = void 0;\n\nvar _objectWithoutPropertiesLoose2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/objectWithoutPropertiesLoose */ \"./node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js\"));\n\nvar _extends2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/extends */ \"./node_modules/@babel/runtime/helpers/extends.js\"));\n\nvar _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/assertThisInitialized */ \"./node_modules/@babel/runtime/helpers/assertThisInitialized.js\"));\n\nvar _inheritsLoose2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inheritsLoose */ \"./node_modules/@babel/runtime/helpers/inheritsLoose.js\"));\n\nvar _find2 = _interopRequireDefault(__webpack_require__(/*! lodash/find */ \"./node_modules/lodash/find.js\"));\n\nvar React = _interopRequireWildcard(__webpack_require__(/*! react */ \"react\"));\n\nvar _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ \"./node_modules/prop-types/index.js\"));\n\nvar _classnames = _interopRequireDefault(__webpack_require__(/*! classnames */ \"./node_modules/classnames/index.js\"));\n\nvar _IntlContext = _interopRequireDefault(__webpack_require__(/*! ../IntlProvider/IntlContext */ \"./src/IntlProvider/IntlContext.ts\"));\n\nvar _withLocale = _interopRequireDefault(__webpack_require__(/*! ../IntlProvider/withLocale */ \"./src/IntlProvider/withLocale.tsx\"));\n\nvar _UploadFileItem = _interopRequireDefault(__webpack_require__(/*! ./UploadFileItem */ \"./src/Uploader/UploadFileItem.tsx\"));\n\nvar _UploadTrigger = _interopRequireDefault(__webpack_require__(/*! ./UploadTrigger */ \"./src/Uploader/UploadTrigger.tsx\"));\n\nvar _utils = __webpack_require__(/*! ../utils */ \"./src/utils/index.ts\");\n\nvar _utils2 = __webpack_require__(/*! ./utils */ \"./src/Uploader/utils.ts\");\n\nvar _jsxFileName = \"/home/runner/work/rsuite/rsuite/src/Uploader/Uploader.tsx\";\n\nvar Uploader =\n/*#__PURE__*/\nfunction (_React$Component) {\n (0, _inheritsLoose2.default)(Uploader, _React$Component);\n\n function Uploader(props) {\n var _this;\n\n _this = _React$Component.call(this, props) || this;\n _this.inputRef = void 0;\n\n _this.handleRemoveFile = function (fileKey) {\n var _this$props$onRemove, _this$props, _this$props$onChange, _this$props2;\n\n var fileList = _this.getFileList();\n\n var file = (0, _find2.default)(fileList, function (f) {\n return f.fileKey === fileKey;\n });\n var nextFileList = fileList.filter(function (f) {\n return f.fileKey !== fileKey;\n });\n\n if (_this.xhrs[file.fileKey] && _this.xhrs[file.fileKey].readyState !== 4) {\n _this.xhrs[file.fileKey].abort();\n }\n\n _this.setState({\n fileList: nextFileList\n });\n\n (_this$props$onRemove = (_this$props = _this.props).onRemove) === null || _this$props$onRemove === void 0 ? void 0 : _this$props$onRemove.call(_this$props, file);\n (_this$props$onChange = (_this$props2 = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props2, nextFileList);\n\n _this.cleanInputValue();\n };\n\n _this.handleUploadTriggerChange = function (event) {\n var _this$props3 = _this.props,\n autoUpload = _this$props3.autoUpload,\n shouldQueueUpdate = _this$props3.shouldQueueUpdate,\n onChange = _this$props3.onChange;\n\n var fileList = _this.getFileList();\n\n var files = (0, _utils2.getFiles)(event);\n var newFileList = [];\n Array.from(files).forEach(function (file) {\n newFileList.push({\n blobFile: file,\n name: file.name,\n status: 'inited',\n fileKey: (0, _utils2.guid)()\n });\n });\n var nextFileList = [].concat(fileList, newFileList);\n var checkState = shouldQueueUpdate === null || shouldQueueUpdate === void 0 ? void 0 : shouldQueueUpdate(nextFileList, newFileList);\n\n var upload = function upload() {\n onChange === null || onChange === void 0 ? void 0 : onChange(nextFileList);\n\n _this.setState({\n fileList: nextFileList\n }, function () {\n autoUpload && _this.handleAjaxUpload();\n });\n };\n\n if (checkState instanceof Promise) {\n checkState.then(function (res) {\n if (res) {\n upload();\n }\n });\n return;\n } else if (checkState === false) {\n _this.cleanInputValue();\n\n return;\n }\n\n upload();\n };\n\n _this.handleAjaxUploadSuccess = function (file, response, event, xhr) {\n var nextFile = (0, _extends2.default)({}, file, {\n status: 'finished',\n progress: 100\n });\n\n _this.updateFileList(nextFile, function () {\n var _this$props$onSuccess, _this$props4;\n\n (_this$props$onSuccess = (_this$props4 = _this.props).onSuccess) === null || _this$props$onSuccess === void 0 ? void 0 : _this$props$onSuccess.call(_this$props4, response, nextFile, event, xhr);\n });\n };\n\n _this.handleAjaxUploadError = function (file, status, event, xhr) {\n var nextFile = (0, _extends2.default)({}, file, {\n status: 'error'\n });\n\n _this.updateFileList(nextFile, function () {\n var _this$props$onError, _this$props5;\n\n (_this$props$onError = (_this$props5 = _this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props5, status, nextFile, event, xhr);\n });\n };\n\n _this.handleAjaxUploadProgress = function (file, percent, event, xhr) {\n var nextFile = (0, _extends2.default)({}, file, {\n status: 'uploading',\n progress: percent\n });\n\n _this.updateFileList(nextFile, function () {\n var _this$props$onProgres, _this$props6;\n\n (_this$props$onProgres = (_this$props6 = _this.props).onProgress) === null || _this$props$onProgres === void 0 ? void 0 : _this$props$onProgres.call(_this$props6, percent, nextFile, event, xhr);\n });\n };\n\n _this.handleUploadFile = function (file) {\n var _this$props7 = _this.props,\n name = _this$props7.name,\n action = _this$props7.action,\n headers = _this$props7.headers,\n withCredentials = _this$props7.withCredentials,\n timeout = _this$props7.timeout,\n data = _this$props7.data,\n onUpload = _this$props7.onUpload;\n var xhr = (0, _utils.ajaxUpload)({\n name: name,\n timeout: timeout,\n headers: headers,\n data: data,\n withCredentials: withCredentials,\n file: file.blobFile,\n url: action,\n onError: _this.handleAjaxUploadError.bind((0, _assertThisInitialized2.default)(_this), file),\n onSuccess: _this.handleAjaxUploadSuccess.bind((0, _assertThisInitialized2.default)(_this), file),\n onProgress: _this.handleAjaxUploadProgress.bind((0, _assertThisInitialized2.default)(_this), file)\n });\n\n _this.updateFileList((0, _extends2.default)({}, file, {\n status: 'uploading'\n }));\n\n _this.xhrs[file.fileKey] = xhr;\n onUpload === null || onUpload === void 0 ? void 0 : onUpload(file);\n };\n\n _this.handleReupload = function (file) {\n var _this$props8 = _this.props,\n onReupload = _this$props8.onReupload,\n autoUpload = _this$props8.autoUpload;\n autoUpload && _this.handleUploadFile(file);\n onReupload === null || onReupload === void 0 ? void 0 : onReupload(file);\n };\n\n _this.createFile = function (file) {\n var fileKey = file.fileKey;\n return (0, _extends2.default)({}, file, {\n fileKey: fileKey || (0, _utils2.guid)(),\n progress: 0\n });\n };\n\n _this.addPrefix = function (name) {\n return (0, _utils.prefix)(_this.props.classPrefix)(name);\n };\n\n _this.progressTimer = void 0;\n _this.xhrs = {};\n _this.uploadTrigger = null;\n var _props$defaultFileLis = props.defaultFileList,\n defaultFileList = _props$defaultFileLis === void 0 ? [] : _props$defaultFileLis;\n\n var _fileList = defaultFileList.map(_this.createFile);\n\n _this.state = {\n fileList: _fileList,\n fileMap: {}\n };\n _this.inputRef = React.createRef();\n return _this;\n } // public API\n\n\n var _proto = Uploader.prototype;\n\n _proto.start = function start(file) {\n if (file) {\n this.handleUploadFile(file);\n return;\n }\n\n this.handleAjaxUpload();\n };\n\n _proto.getFileList = function getFileList() {\n var fileList = this.props.fileList;\n var fileMap = this.state.fileMap;\n\n if (typeof fileList !== 'undefined') {\n return fileList.map(function (file) {\n return (0, _extends2.default)({}, file, {}, fileMap[file.fileKey]);\n });\n }\n\n return this.state.fileList;\n };\n\n _proto.cleanInputValue = function cleanInputValue() {\n if (this.inputRef.current) {\n this.inputRef.current.getInputInstance().value = '';\n }\n };\n\n _proto.handleAjaxUpload = function handleAjaxUpload() {\n var _this2 = this;\n\n var shouldUpload = this.props.shouldUpload;\n var fileList = this.getFileList();\n fileList.forEach(function (file) {\n var checkState = shouldUpload === null || shouldUpload === void 0 ? void 0 : shouldUpload(file);\n\n if (checkState instanceof Promise) {\n checkState.then(function (res) {\n if (res) {\n _this2.handleUploadFile(file);\n }\n });\n return;\n } else if (checkState === false) {\n return;\n }\n\n if (file.status === 'inited') {\n _this2.handleUploadFile(file);\n }\n });\n this.cleanInputValue();\n };\n\n _proto.updateFileList = function updateFileList(nextFile, callback) {\n var fileList = this.getFileList();\n var nextFileList = fileList.map(function (file) {\n return file.fileKey === nextFile.fileKey ? nextFile : file;\n });\n var nextState = {\n fileList: nextFileList\n };\n\n if (nextFile.progress || nextFile.status === 'error') {\n var fileMap = this.state.fileMap;\n fileMap[nextFile.fileKey] = {\n progress: nextFile.progress,\n status: nextFile.status\n };\n nextState.fileMap = fileMap;\n }\n\n this.setState(nextState, callback);\n };\n\n _proto.renderFileItems = function renderFileItems() {\n var _this3 = this;\n\n var _this$props9 = this.props,\n disabledFileItem = _this$props9.disabledFileItem,\n listType = _this$props9.listType,\n onPreview = _this$props9.onPreview,\n maxPreviewFileSize = _this$props9.maxPreviewFileSize,\n renderFileInfo = _this$props9.renderFileInfo,\n removable = _this$props9.removable;\n var fileList = this.getFileList();\n return React.createElement(\"div\", {\n key: \"items\",\n className: this.addPrefix('file-items'),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 327\n },\n __self: this\n }, fileList.map(function (file, index) {\n return React.createElement(_UploadFileItem.default, {\n key: file.fileKey || index,\n file: file,\n maxPreviewFileSize: maxPreviewFileSize,\n listType: listType,\n disabled: disabledFileItem,\n onPreview: onPreview,\n onReupload: _this3.handleReupload,\n onCancel: _this3.handleRemoveFile,\n renderFileInfo: renderFileInfo,\n removable: removable,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 329\n },\n __self: this\n });\n }));\n };\n\n _proto.renderUploadTrigger = function renderUploadTrigger() {\n var _this$props10 = this.props,\n name = _this$props10.name,\n multiple = _this$props10.multiple,\n disabled = _this$props10.disabled,\n accept = _this$props10.accept,\n children = _this$props10.children,\n toggleComponentClass = _this$props10.toggleComponentClass,\n draggable = _this$props10.draggable,\n rest = (0, _objectWithoutPropertiesLoose2.default)(_this$props10, [\"name\", \"multiple\", \"disabled\", \"accept\", \"children\", \"toggleComponentClass\", \"draggable\"]);\n var unhandled = (0, _utils.getUnhandledProps)(Uploader, rest);\n return React.createElement(_UploadTrigger.default, (0, _extends2.default)({}, unhandled, {\n name: name,\n key: \"trigger\",\n multiple: multiple,\n draggable: draggable,\n disabled: disabled,\n accept: accept,\n ref: this.inputRef,\n onChange: this.handleUploadTriggerChange,\n componentClass: toggleComponentClass,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 360\n },\n __self: this\n }), children);\n };\n\n _proto.render = function render() {\n var _classNames;\n\n var _this$props11 = this.props,\n classPrefix = _this$props11.classPrefix,\n className = _this$props11.className,\n listType = _this$props11.listType,\n fileListVisible = _this$props11.fileListVisible,\n locale = _this$props11.locale,\n style = _this$props11.style,\n draggable = _this$props11.draggable;\n var classes = (0, _classnames.default)(className, classPrefix, this.addPrefix(listType), (_classNames = {}, _classNames[this.addPrefix('draggable')] = draggable, _classNames));\n var renderList = [this.renderUploadTrigger()];\n\n if (fileListVisible) {\n renderList.push(this.renderFileItems());\n }\n\n if (listType === 'picture') {\n renderList.reverse();\n }\n\n return React.createElement(_IntlContext.default.Provider, {\n value: locale,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 401\n },\n __self: this\n }, React.createElement(\"div\", {\n className: classes,\n style: style,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 402\n },\n __self: this\n }, renderList));\n };\n\n return Uploader;\n}(React.Component);\n\nUploader.propTypes = {\n action: _propTypes.default.string,\n accept: _propTypes.default.string,\n autoUpload: _propTypes.default.bool,\n children: _propTypes.default.node,\n className: _propTypes.default.string,\n classPrefix: _propTypes.default.string,\n defaultFileList: _propTypes.default.array,\n fileList: _propTypes.default.array,\n data: _propTypes.default.object,\n multiple: _propTypes.default.bool,\n disabled: _propTypes.default.bool,\n disabledFileItem: _propTypes.default.bool,\n name: _propTypes.default.string,\n timeout: _propTypes.default.number,\n withCredentials: _propTypes.default.bool,\n headers: _propTypes.default.object,\n locale: _propTypes.default.object,\n listType: _propTypes.default.oneOf(['text', 'picture-text', 'picture']),\n shouldQueueUpdate: _propTypes.default.func,\n shouldUpload: _propTypes.default.func,\n onChange: _propTypes.default.func,\n onUpload: _propTypes.default.func,\n onReupload: _propTypes.default.func,\n onPreview: _propTypes.default.func,\n onError: _propTypes.default.func,\n onSuccess: _propTypes.default.func,\n onProgress: _propTypes.default.func,\n onRemove: _propTypes.default.func,\n maxPreviewFileSize: _propTypes.default.number,\n style: _propTypes.default.object,\n toggleComponentClass: _propTypes.default.elementType,\n renderFileInfo: _propTypes.default.func,\n removable: _propTypes.default.bool,\n fileListVisible: _propTypes.default.bool,\n draggable: _propTypes.default.bool\n};\nUploader.defaultProps = {\n autoUpload: true,\n timeout: 0,\n name: 'file',\n multiple: false,\n disabled: false,\n withCredentials: false,\n data: {},\n listType: 'text',\n removable: true,\n fileListVisible: true\n};\n\nvar _default = (0, _utils.compose)((0, _withLocale.default)(['Uploader']), (0, _utils.defaultProps)({\n classPrefix: 'uploader'\n}))(Uploader);\n\nexports.default = _default;\nmodule.exports = exports.default;\n\n//# sourceURL=webpack://rsuite/./src/Uploader/Uploader.tsx?");
10232
10232
 
10233
10233
  /***/ }),
10234
10234