rc-upload
Advanced tools
Comparing version 3.3.4 to 4.0.0-alpha.0
import React, { Component } from 'react'; | ||
import { UploadProps, RcFile } from './interface'; | ||
import type { UploadProps, RcFile } from './interface'; | ||
interface ParsedFileInfo { | ||
origin: RcFile; | ||
action: string; | ||
data: object; | ||
parsedFile: File | Blob | null; | ||
} | ||
declare class AjaxUploader extends Component<UploadProps> { | ||
@@ -17,4 +23,7 @@ state: { | ||
uploadFiles: (files: FileList) => void; | ||
upload(file: RcFile, fileList: Array<RcFile>): void; | ||
post(file: RcFile): void; | ||
/** | ||
* Process file before upload. When all the file is ready, we start upload. | ||
*/ | ||
processFile: (file: RcFile, fileList: RcFile[]) => Promise<ParsedFileInfo>; | ||
post({ data, origin, action, parsedFile }: ParsedFileInfo): void; | ||
reset(): void; | ||
@@ -21,0 +30,0 @@ abort(file?: any): void; |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; | ||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray"; | ||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
@@ -9,4 +12,2 @@ import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import _createSuper from "@babel/runtime/helpers/esm/createSuper"; | ||
/* eslint react/no-is-mounted:0,react/sort-comp:0,react/prop-types:0 */ | ||
import React, { Component } from 'react'; | ||
@@ -100,12 +101,118 @@ import classNames from 'classnames'; | ||
_this.uploadFiles = function (files) { | ||
var postFiles = Array.prototype.slice.call(files); | ||
postFiles.map(function (file) { | ||
var originFiles = _toConsumableArray(files); | ||
var postFiles = originFiles.map(function (file) { | ||
// eslint-disable-next-line no-param-reassign | ||
file.uid = getUid(); | ||
return file; | ||
}).forEach(function (file) { | ||
_this.upload(file, postFiles); | ||
return _this.processFile(file, originFiles); | ||
}); // Batch upload files | ||
Promise.all(postFiles).then(function (fileList) { | ||
var onBatchStart = _this.props.onBatchStart; | ||
var enabledFiles = fileList.filter(function (file) { | ||
return file; | ||
}); | ||
onBatchStart === null || onBatchStart === void 0 ? void 0 : onBatchStart(enabledFiles.map(function (file) { | ||
return file.origin; | ||
})); | ||
enabledFiles.forEach(function (file) { | ||
_this.post(file); | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Process file before upload. When all the file is ready, we start upload. | ||
*/ | ||
_this.processFile = /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file, fileList) { | ||
var _this$props2, beforeUpload, action, data, transformedFile, mergedAction, mergedData, parsedFile; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_this$props2 = _this.props, beforeUpload = _this$props2.beforeUpload, action = _this$props2.action, data = _this$props2.data; | ||
transformedFile = file; | ||
if (!beforeUpload) { | ||
_context.next = 8; | ||
break; | ||
} | ||
_context.next = 5; | ||
return beforeUpload(file, fileList); | ||
case 5: | ||
transformedFile = _context.sent; | ||
if (!(transformedFile === false)) { | ||
_context.next = 8; | ||
break; | ||
} | ||
return _context.abrupt("return", null); | ||
case 8: | ||
if (!(typeof action === 'function')) { | ||
_context.next = 14; | ||
break; | ||
} | ||
_context.next = 11; | ||
return action(file); | ||
case 11: | ||
mergedAction = _context.sent; | ||
_context.next = 15; | ||
break; | ||
case 14: | ||
mergedAction = action; | ||
case 15: | ||
if (!(typeof data === 'function')) { | ||
_context.next = 21; | ||
break; | ||
} | ||
_context.next = 18; | ||
return data(file); | ||
case 18: | ||
mergedData = _context.sent; | ||
_context.next = 22; | ||
break; | ||
case 21: | ||
mergedData = data; | ||
case 22: | ||
parsedFile = _typeof(transformedFile) === 'object' && transformedFile ? transformedFile : file; // Used for `request.ts` get form data name | ||
if (!parsedFile.name) { | ||
parsedFile.name = file.name; | ||
} | ||
return _context.abrupt("return", { | ||
origin: file, | ||
data: mergedData, | ||
parsedFile: parsedFile, | ||
action: mergedAction | ||
}); | ||
case 25: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
return function (_x, _x2) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
_this.saveFileInput = function (node) { | ||
@@ -130,44 +237,11 @@ _this.fileInput = node; | ||
}, { | ||
key: "upload", | ||
value: function upload(file, fileList) { | ||
key: "post", | ||
value: function post(_ref2) { | ||
var _this2 = this; | ||
var props = this.props; | ||
var data = _ref2.data, | ||
origin = _ref2.origin, | ||
action = _ref2.action, | ||
parsedFile = _ref2.parsedFile; | ||
if (!props.beforeUpload) { | ||
// always async in case use react state to keep fileList | ||
Promise.resolve().then(function () { | ||
_this2.post(file); | ||
}); | ||
return; | ||
} | ||
var before = props.beforeUpload(file, fileList); | ||
if (before && typeof before !== 'boolean' && before.then) { | ||
before.then(function (processedFile) { | ||
var processedFileType = Object.prototype.toString.call(processedFile); | ||
if (processedFileType === '[object File]' || processedFileType === '[object Blob]') { | ||
_this2.post(processedFile); | ||
return; | ||
} | ||
_this2.post(file); | ||
}).catch(function (e) { | ||
// eslint-disable-next-line no-console | ||
console.log(e); | ||
}); | ||
} else if (before !== false) { | ||
Promise.resolve().then(function () { | ||
_this2.post(file); | ||
}); | ||
} | ||
} | ||
}, { | ||
key: "post", | ||
value: function post(file) { | ||
var _this3 = this; | ||
if (!this._isMounted) { | ||
@@ -179,58 +253,27 @@ return; | ||
var onStart = props.onStart, | ||
onProgress = props.onProgress, | ||
_props$transformFile = props.transformFile, | ||
transformFile = _props$transformFile === void 0 ? function (originFile) { | ||
return originFile; | ||
} : _props$transformFile; | ||
new Promise(function (resolve) { | ||
var actionRet = props.action; | ||
if (typeof actionRet === 'function') { | ||
actionRet = actionRet(file); | ||
onProgress = props.onProgress; | ||
var uid = origin.uid; | ||
var request = props.customRequest || defaultRequest; | ||
var requestOption = { | ||
action: action, | ||
filename: props.name, | ||
data: data, | ||
file: parsedFile, | ||
headers: props.headers, | ||
withCredentials: props.withCredentials, | ||
method: props.method || 'post', | ||
onProgress: onProgress ? function (e) { | ||
onProgress(e, origin); | ||
} : null, | ||
onSuccess: function onSuccess(ret, xhr) { | ||
delete _this2.reqs[uid]; | ||
props.onSuccess(ret, origin, xhr); | ||
}, | ||
onError: function onError(err, ret) { | ||
delete _this2.reqs[uid]; | ||
props.onError(err, ret, origin); | ||
} | ||
return resolve(actionRet); | ||
}).then(function (action) { | ||
var uid = file.uid; | ||
var request = props.customRequest || defaultRequest; | ||
var transform = Promise.resolve(transformFile(file)).then(function (transformedFile) { | ||
var data = props.data; | ||
if (typeof data === 'function') { | ||
data = data(transformedFile); | ||
} | ||
return Promise.all([transformedFile, data]); | ||
}).catch(function (e) { | ||
console.error(e); // eslint-disable-line no-console | ||
}); | ||
transform.then(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
transformedFile = _ref2[0], | ||
data = _ref2[1]; | ||
var requestOption = { | ||
action: action, | ||
filename: props.name, | ||
data: data, | ||
file: transformedFile, | ||
headers: props.headers, | ||
withCredentials: props.withCredentials, | ||
method: props.method || 'post', | ||
onProgress: onProgress ? function (e) { | ||
onProgress(e, file); | ||
} : null, | ||
onSuccess: function onSuccess(ret, xhr) { | ||
delete _this3.reqs[uid]; | ||
props.onSuccess(ret, file, xhr); | ||
}, | ||
onError: function onError(err, ret) { | ||
delete _this3.reqs[uid]; | ||
props.onError(err, ret, file); | ||
} | ||
}; | ||
onStart(file); | ||
_this3.reqs[uid] = request(requestOption); | ||
}); | ||
}); | ||
}; | ||
onStart(origin); | ||
this.reqs[uid] = request(requestOption); | ||
} | ||
@@ -272,17 +315,17 @@ }, { | ||
var _this$props2 = this.props, | ||
Tag = _this$props2.component, | ||
prefixCls = _this$props2.prefixCls, | ||
className = _this$props2.className, | ||
disabled = _this$props2.disabled, | ||
id = _this$props2.id, | ||
style = _this$props2.style, | ||
multiple = _this$props2.multiple, | ||
accept = _this$props2.accept, | ||
children = _this$props2.children, | ||
directory = _this$props2.directory, | ||
openFileDialogOnClick = _this$props2.openFileDialogOnClick, | ||
onMouseEnter = _this$props2.onMouseEnter, | ||
onMouseLeave = _this$props2.onMouseLeave, | ||
otherProps = _objectWithoutProperties(_this$props2, ["component", "prefixCls", "className", "disabled", "id", "style", "multiple", "accept", "children", "directory", "openFileDialogOnClick", "onMouseEnter", "onMouseLeave"]); | ||
var _this$props3 = this.props, | ||
Tag = _this$props3.component, | ||
prefixCls = _this$props3.prefixCls, | ||
className = _this$props3.className, | ||
disabled = _this$props3.disabled, | ||
id = _this$props3.id, | ||
style = _this$props3.style, | ||
multiple = _this$props3.multiple, | ||
accept = _this$props3.accept, | ||
children = _this$props3.children, | ||
directory = _this$props3.directory, | ||
openFileDialogOnClick = _this$props3.openFileDialogOnClick, | ||
onMouseEnter = _this$props3.onMouseEnter, | ||
onMouseLeave = _this$props3.onMouseLeave, | ||
otherProps = _objectWithoutProperties(_this$props3, ["component", "prefixCls", "className", "disabled", "id", "style", "multiple", "accept", "children", "directory", "openFileDialogOnClick", "onMouseEnter", "onMouseLeave"]); | ||
@@ -289,0 +332,0 @@ var cls = classNames((_classNames = {}, _defineProperty(_classNames, prefixCls, true), _defineProperty(_classNames, "".concat(prefixCls, "-disabled"), disabled), _defineProperty(_classNames, className, className), _classNames)); // because input don't have directory/webkitdirectory type declaration |
@@ -1,3 +0,3 @@ | ||
import { RcFile } from './interface'; | ||
declare const _default: (file: RcFile, acceptedFiles: string | Array<string>) => boolean; | ||
import type { RcFile } from './interface'; | ||
declare const _default: (file: RcFile, acceptedFiles: string | string[]) => boolean; | ||
export default _default; |
@@ -1,2 +0,2 @@ | ||
import * as React from 'react'; | ||
import type * as React from 'react'; | ||
export declare type Action = string | ((file: RcFile) => string | PromiseLike<string>); | ||
@@ -16,2 +16,3 @@ export interface UploadProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onError' | 'onProgress'> { | ||
multiple?: boolean; | ||
onBatchStart?: (fileList: RcFile[]) => void; | ||
onStart?: (file: RcFile) => void; | ||
@@ -25,3 +26,2 @@ onError?: (error: Error, ret: object, file: RcFile) => void; | ||
openFileDialogOnClick?: boolean; | ||
transformFile?: (file: RcFile) => string | Blob | RcFile | PromiseLike<string | Blob | RcFile>; | ||
prefixCls?: string; | ||
@@ -37,5 +37,3 @@ id?: string; | ||
export declare type UploadRequestMethod = 'POST' | 'PUT' | 'PATCH' | 'post' | 'put' | 'patch'; | ||
export interface UploadRequestHeader { | ||
[key: string]: string; | ||
} | ||
export declare type UploadRequestHeader = Record<string, string>; | ||
export interface UploadRequestError extends Error { | ||
@@ -52,3 +50,3 @@ status?: number; | ||
filename?: string; | ||
file: RcFile; | ||
file: RcFile | Blob; | ||
withCredentials?: boolean; | ||
@@ -55,0 +53,0 @@ action: string; |
@@ -1,4 +0,4 @@ | ||
import { UploadRequestOption } from './interface'; | ||
import type { UploadRequestOption } from './interface'; | ||
export default function upload(option: UploadRequestOption): { | ||
abort(): void; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { RcFile } from './interface'; | ||
import type { RcFile } from './interface'; | ||
interface InternalDataTransferItem extends DataTransferItem { | ||
@@ -13,3 +13,3 @@ isFile: boolean; | ||
} | ||
declare const traverseFileTree: (files: Array<InternalDataTransferItem>, callback: any, isAccepted: any) => void; | ||
declare const traverseFileTree: (files: InternalDataTransferItem[], callback: any, isAccepted: any) => void; | ||
export default traverseFileTree; |
import { Component } from 'react'; | ||
import AjaxUpload from './AjaxUploader'; | ||
import { UploadProps, RcFile } from './interface'; | ||
import type { UploadProps, RcFile } from './interface'; | ||
declare function empty(): void; | ||
@@ -5,0 +5,0 @@ declare class Upload extends Component<UploadProps> { |
import React, { Component } from 'react'; | ||
import { UploadProps, RcFile } from './interface'; | ||
import type { UploadProps, RcFile } from './interface'; | ||
interface ParsedFileInfo { | ||
origin: RcFile; | ||
action: string; | ||
data: object; | ||
parsedFile: File | Blob | null; | ||
} | ||
declare class AjaxUploader extends Component<UploadProps> { | ||
@@ -17,4 +23,7 @@ state: { | ||
uploadFiles: (files: FileList) => void; | ||
upload(file: RcFile, fileList: Array<RcFile>): void; | ||
post(file: RcFile): void; | ||
/** | ||
* Process file before upload. When all the file is ready, we start upload. | ||
*/ | ||
processFile: (file: RcFile, fileList: RcFile[]) => Promise<ParsedFileInfo>; | ||
post({ data, origin, action, parsedFile }: ParsedFileInfo): void; | ||
reset(): void; | ||
@@ -21,0 +30,0 @@ abort(file?: any): void; |
@@ -18,4 +18,10 @@ "use strict"; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
@@ -43,3 +49,2 @@ | ||
/* eslint react/no-is-mounted:0,react/sort-comp:0,react/prop-types:0 */ | ||
var AjaxUploader = /*#__PURE__*/function (_Component) { | ||
@@ -124,12 +129,117 @@ (0, _inherits2.default)(AjaxUploader, _Component); | ||
_this.uploadFiles = function (files) { | ||
var postFiles = Array.prototype.slice.call(files); | ||
postFiles.map(function (file) { | ||
var originFiles = (0, _toConsumableArray2.default)(files); | ||
var postFiles = originFiles.map(function (file) { | ||
// eslint-disable-next-line no-param-reassign | ||
file.uid = (0, _uid.default)(); | ||
return file; | ||
}).forEach(function (file) { | ||
_this.upload(file, postFiles); | ||
return _this.processFile(file, originFiles); | ||
}); // Batch upload files | ||
Promise.all(postFiles).then(function (fileList) { | ||
var onBatchStart = _this.props.onBatchStart; | ||
var enabledFiles = fileList.filter(function (file) { | ||
return file; | ||
}); | ||
onBatchStart === null || onBatchStart === void 0 ? void 0 : onBatchStart(enabledFiles.map(function (file) { | ||
return file.origin; | ||
})); | ||
enabledFiles.forEach(function (file) { | ||
_this.post(file); | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Process file before upload. When all the file is ready, we start upload. | ||
*/ | ||
_this.processFile = /*#__PURE__*/function () { | ||
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(file, fileList) { | ||
var _this$props2, beforeUpload, action, data, transformedFile, mergedAction, mergedData, parsedFile; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_this$props2 = _this.props, beforeUpload = _this$props2.beforeUpload, action = _this$props2.action, data = _this$props2.data; | ||
transformedFile = file; | ||
if (!beforeUpload) { | ||
_context.next = 8; | ||
break; | ||
} | ||
_context.next = 5; | ||
return beforeUpload(file, fileList); | ||
case 5: | ||
transformedFile = _context.sent; | ||
if (!(transformedFile === false)) { | ||
_context.next = 8; | ||
break; | ||
} | ||
return _context.abrupt("return", null); | ||
case 8: | ||
if (!(typeof action === 'function')) { | ||
_context.next = 14; | ||
break; | ||
} | ||
_context.next = 11; | ||
return action(file); | ||
case 11: | ||
mergedAction = _context.sent; | ||
_context.next = 15; | ||
break; | ||
case 14: | ||
mergedAction = action; | ||
case 15: | ||
if (!(typeof data === 'function')) { | ||
_context.next = 21; | ||
break; | ||
} | ||
_context.next = 18; | ||
return data(file); | ||
case 18: | ||
mergedData = _context.sent; | ||
_context.next = 22; | ||
break; | ||
case 21: | ||
mergedData = data; | ||
case 22: | ||
parsedFile = (0, _typeof2.default)(transformedFile) === 'object' && transformedFile ? transformedFile : file; // Used for `request.ts` get form data name | ||
if (!parsedFile.name) { | ||
parsedFile.name = file.name; | ||
} | ||
return _context.abrupt("return", { | ||
origin: file, | ||
data: mergedData, | ||
parsedFile: parsedFile, | ||
action: mergedAction | ||
}); | ||
case 25: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
return function (_x, _x2) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
_this.saveFileInput = function (node) { | ||
@@ -154,44 +264,11 @@ _this.fileInput = node; | ||
}, { | ||
key: "upload", | ||
value: function upload(file, fileList) { | ||
key: "post", | ||
value: function post(_ref2) { | ||
var _this2 = this; | ||
var props = this.props; | ||
var data = _ref2.data, | ||
origin = _ref2.origin, | ||
action = _ref2.action, | ||
parsedFile = _ref2.parsedFile; | ||
if (!props.beforeUpload) { | ||
// always async in case use react state to keep fileList | ||
Promise.resolve().then(function () { | ||
_this2.post(file); | ||
}); | ||
return; | ||
} | ||
var before = props.beforeUpload(file, fileList); | ||
if (before && typeof before !== 'boolean' && before.then) { | ||
before.then(function (processedFile) { | ||
var processedFileType = Object.prototype.toString.call(processedFile); | ||
if (processedFileType === '[object File]' || processedFileType === '[object Blob]') { | ||
_this2.post(processedFile); | ||
return; | ||
} | ||
_this2.post(file); | ||
}).catch(function (e) { | ||
// eslint-disable-next-line no-console | ||
console.log(e); | ||
}); | ||
} else if (before !== false) { | ||
Promise.resolve().then(function () { | ||
_this2.post(file); | ||
}); | ||
} | ||
} | ||
}, { | ||
key: "post", | ||
value: function post(file) { | ||
var _this3 = this; | ||
if (!this._isMounted) { | ||
@@ -203,58 +280,27 @@ return; | ||
var onStart = props.onStart, | ||
onProgress = props.onProgress, | ||
_props$transformFile = props.transformFile, | ||
transformFile = _props$transformFile === void 0 ? function (originFile) { | ||
return originFile; | ||
} : _props$transformFile; | ||
new Promise(function (resolve) { | ||
var actionRet = props.action; | ||
if (typeof actionRet === 'function') { | ||
actionRet = actionRet(file); | ||
onProgress = props.onProgress; | ||
var uid = origin.uid; | ||
var request = props.customRequest || _request.default; | ||
var requestOption = { | ||
action: action, | ||
filename: props.name, | ||
data: data, | ||
file: parsedFile, | ||
headers: props.headers, | ||
withCredentials: props.withCredentials, | ||
method: props.method || 'post', | ||
onProgress: onProgress ? function (e) { | ||
onProgress(e, origin); | ||
} : null, | ||
onSuccess: function onSuccess(ret, xhr) { | ||
delete _this2.reqs[uid]; | ||
props.onSuccess(ret, origin, xhr); | ||
}, | ||
onError: function onError(err, ret) { | ||
delete _this2.reqs[uid]; | ||
props.onError(err, ret, origin); | ||
} | ||
return resolve(actionRet); | ||
}).then(function (action) { | ||
var uid = file.uid; | ||
var request = props.customRequest || _request.default; | ||
var transform = Promise.resolve(transformFile(file)).then(function (transformedFile) { | ||
var data = props.data; | ||
if (typeof data === 'function') { | ||
data = data(transformedFile); | ||
} | ||
return Promise.all([transformedFile, data]); | ||
}).catch(function (e) { | ||
console.error(e); // eslint-disable-line no-console | ||
}); | ||
transform.then(function (_ref) { | ||
var _ref2 = (0, _slicedToArray2.default)(_ref, 2), | ||
transformedFile = _ref2[0], | ||
data = _ref2[1]; | ||
var requestOption = { | ||
action: action, | ||
filename: props.name, | ||
data: data, | ||
file: transformedFile, | ||
headers: props.headers, | ||
withCredentials: props.withCredentials, | ||
method: props.method || 'post', | ||
onProgress: onProgress ? function (e) { | ||
onProgress(e, file); | ||
} : null, | ||
onSuccess: function onSuccess(ret, xhr) { | ||
delete _this3.reqs[uid]; | ||
props.onSuccess(ret, file, xhr); | ||
}, | ||
onError: function onError(err, ret) { | ||
delete _this3.reqs[uid]; | ||
props.onError(err, ret, file); | ||
} | ||
}; | ||
onStart(file); | ||
_this3.reqs[uid] = request(requestOption); | ||
}); | ||
}); | ||
}; | ||
onStart(origin); | ||
this.reqs[uid] = request(requestOption); | ||
} | ||
@@ -296,17 +342,17 @@ }, { | ||
var _this$props2 = this.props, | ||
Tag = _this$props2.component, | ||
prefixCls = _this$props2.prefixCls, | ||
className = _this$props2.className, | ||
disabled = _this$props2.disabled, | ||
id = _this$props2.id, | ||
style = _this$props2.style, | ||
multiple = _this$props2.multiple, | ||
accept = _this$props2.accept, | ||
children = _this$props2.children, | ||
directory = _this$props2.directory, | ||
openFileDialogOnClick = _this$props2.openFileDialogOnClick, | ||
onMouseEnter = _this$props2.onMouseEnter, | ||
onMouseLeave = _this$props2.onMouseLeave, | ||
otherProps = (0, _objectWithoutProperties2.default)(_this$props2, ["component", "prefixCls", "className", "disabled", "id", "style", "multiple", "accept", "children", "directory", "openFileDialogOnClick", "onMouseEnter", "onMouseLeave"]); | ||
var _this$props3 = this.props, | ||
Tag = _this$props3.component, | ||
prefixCls = _this$props3.prefixCls, | ||
className = _this$props3.className, | ||
disabled = _this$props3.disabled, | ||
id = _this$props3.id, | ||
style = _this$props3.style, | ||
multiple = _this$props3.multiple, | ||
accept = _this$props3.accept, | ||
children = _this$props3.children, | ||
directory = _this$props3.directory, | ||
openFileDialogOnClick = _this$props3.openFileDialogOnClick, | ||
onMouseEnter = _this$props3.onMouseEnter, | ||
onMouseLeave = _this$props3.onMouseLeave, | ||
otherProps = (0, _objectWithoutProperties2.default)(_this$props3, ["component", "prefixCls", "className", "disabled", "id", "style", "multiple", "accept", "children", "directory", "openFileDialogOnClick", "onMouseEnter", "onMouseLeave"]); | ||
var cls = (0, _classnames.default)((_classNames = {}, (0, _defineProperty2.default)(_classNames, prefixCls, true), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-disabled"), disabled), (0, _defineProperty2.default)(_classNames, className, className), _classNames)); // because input don't have directory/webkitdirectory type declaration | ||
@@ -313,0 +359,0 @@ |
@@ -1,3 +0,3 @@ | ||
import { RcFile } from './interface'; | ||
declare const _default: (file: RcFile, acceptedFiles: string | Array<string>) => boolean; | ||
import type { RcFile } from './interface'; | ||
declare const _default: (file: RcFile, acceptedFiles: string | string[]) => boolean; | ||
export default _default; |
@@ -1,2 +0,2 @@ | ||
import * as React from 'react'; | ||
import type * as React from 'react'; | ||
export declare type Action = string | ((file: RcFile) => string | PromiseLike<string>); | ||
@@ -16,2 +16,3 @@ export interface UploadProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onError' | 'onProgress'> { | ||
multiple?: boolean; | ||
onBatchStart?: (fileList: RcFile[]) => void; | ||
onStart?: (file: RcFile) => void; | ||
@@ -25,3 +26,2 @@ onError?: (error: Error, ret: object, file: RcFile) => void; | ||
openFileDialogOnClick?: boolean; | ||
transformFile?: (file: RcFile) => string | Blob | RcFile | PromiseLike<string | Blob | RcFile>; | ||
prefixCls?: string; | ||
@@ -37,5 +37,3 @@ id?: string; | ||
export declare type UploadRequestMethod = 'POST' | 'PUT' | 'PATCH' | 'post' | 'put' | 'patch'; | ||
export interface UploadRequestHeader { | ||
[key: string]: string; | ||
} | ||
export declare type UploadRequestHeader = Record<string, string>; | ||
export interface UploadRequestError extends Error { | ||
@@ -52,3 +50,3 @@ status?: number; | ||
filename?: string; | ||
file: RcFile; | ||
file: RcFile | Blob; | ||
withCredentials?: boolean; | ||
@@ -55,0 +53,0 @@ action: string; |
@@ -1,4 +0,4 @@ | ||
import { UploadRequestOption } from './interface'; | ||
import type { UploadRequestOption } from './interface'; | ||
export default function upload(option: UploadRequestOption): { | ||
abort(): void; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { RcFile } from './interface'; | ||
import type { RcFile } from './interface'; | ||
interface InternalDataTransferItem extends DataTransferItem { | ||
@@ -13,3 +13,3 @@ isFile: boolean; | ||
} | ||
declare const traverseFileTree: (files: Array<InternalDataTransferItem>, callback: any, isAccepted: any) => void; | ||
declare const traverseFileTree: (files: InternalDataTransferItem[], callback: any, isAccepted: any) => void; | ||
export default traverseFileTree; |
import { Component } from 'react'; | ||
import AjaxUpload from './AjaxUploader'; | ||
import { UploadProps, RcFile } from './interface'; | ||
import type { UploadProps, RcFile } from './interface'; | ||
declare function empty(): void; | ||
@@ -5,0 +5,0 @@ declare class Upload extends Component<UploadProps> { |
{ | ||
"name": "rc-upload", | ||
"version": "3.3.4", | ||
"version": "4.0.0-alpha.0", | ||
"description": "upload ui component for react", | ||
@@ -40,3 +40,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/jest": "^26.0.0", | ||
"@types/enzyme": "^3.10.8", | ||
"@types/jest": "^26.0.20", | ||
"@types/react": "^16.9.2", | ||
@@ -62,2 +63,3 @@ "@types/react-dom": "^16.9.0", | ||
"react-dom": "^16.0.0", | ||
"regenerator-runtime": "^0.13.7", | ||
"sinon": "^9.0.2", | ||
@@ -64,0 +66,0 @@ "typescript": "^4.0.2", |
@@ -79,3 +79,2 @@ # rc-upload | ||
|openFileDialogOnClick | boolean | true | useful for drag only upload as it does not trigger on enter key or click event | | ||
|transformFile | function(file): Promise<blob> | | transform file before request | | ||
@@ -82,0 +81,0 @@ #### onError arguments |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56910
1386
26
1
118