Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-images-uploading

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-images-uploading - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

56

dist/index.js

@@ -146,3 +146,3 @@ 'use strict';

var ImageUploading = function (_a) {
var multiple = _a.multiple, onChange = _a.onChange, maxNumber = _a.maxNumber, children = _a.children, defaultValue = _a.defaultValue, acceptType = _a.acceptType, maxFileSize = _a.maxFileSize, resolutionWidth = _a.resolutionWidth, resolutionHeight = _a.resolutionHeight, resolutionType = _a.resolutionType;
var multiple = _a.multiple, onChange = _a.onChange, maxNumber = _a.maxNumber, children = _a.children, defaultValue = _a.defaultValue, acceptType = _a.acceptType, maxFileSize = _a.maxFileSize, resolutionWidth = _a.resolutionWidth, resolutionHeight = _a.resolutionHeight, resolutionType = _a.resolutionType, onError = _a.onError;
var inputRef = useRef(null);

@@ -214,15 +214,17 @@ var _b = useState(function () {

var validate = function (fileList) { return __awaiter(void 0, void 0, void 0, function () {
var i, _a, file, dataURL, fileType, type, checkRes;
var newErrors, i, _a, file, dataURL, fileType, type, checkRes;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
setErrors(__assign({}, defaultErrors));
if (maxNumber && fileList.length + imageList.length > maxNumber) {
setErrors(__assign(__assign({}, errors), { maxNumber: true }));
return [2 /*return*/, false];
}
newErrors = __assign({}, defaultErrors);
if (!(maxNumber &&
!keyUpdate &&
fileList.length + imageList.length > maxNumber)) return [3 /*break*/, 1];
newErrors.maxNumber = true;
return [3 /*break*/, 5];
case 1:
i = 0;
_b.label = 1;
case 1:
if (!(i < fileList.length)) return [3 /*break*/, 4];
_b.label = 2;
case 2:
if (!(i < fileList.length)) return [3 /*break*/, 5];
_a = fileList[i], file = _a.file, dataURL = _a.dataURL;

@@ -232,9 +234,9 @@ if (file) {

if (!fileType.includes("image")) {
setErrors(__assign(__assign({}, errors), { acceptType: true }));
return [2 /*return*/, false];
newErrors.acceptType = true;
return [3 /*break*/, 5];
}
if (maxFileSize) {
if (file.size > maxFileSize) {
setErrors(__assign(__assign({}, errors), { maxFileSize: true }));
return [2 /*return*/, false];
newErrors.maxFileSize = true;
return [3 /*break*/, 5];
}

@@ -245,20 +247,26 @@ }

if (acceptType.indexOf(type) < 0) {
setErrors(__assign(__assign({}, errors), { acceptType: true }));
return [2 /*return*/, false];
newErrors.acceptType = true;
return [3 /*break*/, 5];
}
}
}
if (!(dataURL && resolutionType)) return [3 /*break*/, 3];
if (!(dataURL && resolutionType)) return [3 /*break*/, 4];
return [4 /*yield*/, checkResolution(dataURL, resolutionType, resolutionWidth, resolutionHeight)];
case 2:
case 3:
checkRes = _b.sent();
if (!checkRes) {
setErrors(__assign(__assign({}, errors), { resolution: true }));
newErrors.resolution = true;
return [3 /*break*/, 5];
}
_b.label = 4;
case 4:
i++;
return [3 /*break*/, 2];
case 5:
setErrors(newErrors);
if (Object.values(newErrors).find(Boolean)) {
onError && onError(newErrors, fileList);
return [2 /*return*/, false];
}
_b.label = 3;
case 3:
i++;
return [3 /*break*/, 1];
case 4: return [2 /*return*/, true];
return [2 /*return*/, true];
}

@@ -265,0 +273,0 @@ });

@@ -21,2 +21,3 @@ /// <reference types="react" />

resolutionType?: ResolutionType;
onError?: (errors: ErrorsType, files?: ImageListType) => void;
}

@@ -23,0 +24,0 @@ export interface ExportInterface {

{
"name": "react-images-uploading",
"version": "2.2.1",
"version": "2.2.2",
"description": "A simple images uploader without UI. Building by yourself",

@@ -5,0 +5,0 @@ "author": "imvutoan",

@@ -45,2 +45,5 @@ # react-images-uploading

};
onError = (errors, files) => {
console.log(errors, files);
};

@@ -55,2 +58,3 @@ render() {

acceptType={["jpg", "gif", "png"]}
onError={this.onError}
>

@@ -107,2 +111,3 @@ {({ imageList, onImageUpload, onImageRemoveAll }) => (

| onChange | function | | | Called every update |
| onError | function | (errors, files) => void | | Called if have error on validate each update |
| defaultValue | array | \[\{dataURL: \.\.\. \}, \.\.\.\] | | Init data |

@@ -109,0 +114,0 @@ | acceptType | array | \['jpg', 'gif', 'png'\] | \[\] | Supported image extension |

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc