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

react-files

Package Overview
Dependencies
Maintainers
0
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-files - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

2

dist/index.js

@@ -1,1 +0,1 @@

!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["React"],t);else{var r="object"==typeof exports?t(require("react")):t(e.React);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,(e=>(()=>{var t={703:(e,t,r)=>{"use strict";var n=r(414);function a(){}function o(){}o.resetWarningCache=a,e.exports=function(){function e(e,t,r,a,o,i){if(i!==n){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:a};return r.PropTypes=r,r}},697:(e,t,r)=>{e.exports=r(703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},639:t=>{"use strict";t.exports=e}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{"use strict";n.r(a),n.d(a,{default:()=>d});var e=n(639),t=n.n(e),r=n(697),o=n.n(r);const i=function(e){var t=e.name.split(".");return t.length>1?t[t.length-1]:"none"};function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o,i,l=[],c=!0,s=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(e){s=!0,a=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw a}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var s=/^(application|audio|example|image|message|model|multipart|text|video|\*)\/[a-z0-9\.\+\*-]+$/,u=/\.[a-zA-Z0-9]*$/;const f=function(e,t){return!e||e.some((function(e){if(t.type&&e.match(s)){var r=l(t.type.split("/"),2),n=r[0],a=r[1],o=l(e.split("/"),2),i=o[0],c=o[1];if(i&&c){if("*"===i&&"*"===c)return!0;if(i===n&&"*"===c)return!0;if(i===n&&c===a)return!0}}else if(t.extension&&e.match(u)){var f=e.substr(1);return t.extension.toLowerCase()===f.toLowerCase()}return!1}))};function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},p.apply(this,arguments)}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var y=function(r){var n,a,o=r.accepts,l=r.children,c=r.className,s=r.clickable,u=r.dragActiveClassName,y=(r.dragActiveStyle,r.inputProps),d=r.multiple,v=r.maxFiles,g=r.maxFileSize,b=r.minFileSize,h=r.name,O=r.onChange,x=r.onDragEnter,j=r.onDragLeave,S=r.onError,w=r.style,A=(0,e.useRef)(1),T=(0,e.useRef)(),C=(0,e.useRef)(),E=(n=(0,e.useState)(!1),a=2,function(e){if(Array.isArray(e))return e}(n)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o,i,l=[],c=!0,s=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(e){s=!0,a=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw a}}return l}}(n,a)||function(e,t){if(e){if("string"==typeof e)return m(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(e,t):void 0}}(n,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),P=E[0],k=E[1],D=function(e,t){S(e,t)},N=(0,e.useCallback)((function(e){e.preventDefault(),e.stopPropagation()}),[]),R=function(e){var t=T.current;u&&(t.className=t.className.replace(" ".concat(u),"")),"function"==typeof l&&k(!1),j&&j(e)},_=function(e){e.preventDefault(),R(e);var t,r=e.dataTransfer?e.dataTransfer.files:e.target.files;!1===d&&r.length>1&&(r=[r[0]]);for(var n=[],a=0;a<r.length;a+=1){var l=r[a];if(l.id="files-".concat(A.current),A.current+=1,l.extension=i(l),l.sizeReadable=(t=l.size)>=1e9?Math.ceil(t/1e9)+"GB":t>=1e6?Math.ceil(t/1e6)+"MB":t>=1e3?Math.ceil(t/1e3)+"KB":Math.ceil(t)+"B",l.type&&"image"===l.type.split("/")[0]?l.preview={type:"image",url:window.URL.createObjectURL(l)}:l.preview={type:"file"},n.length>=v){D({code:4,message:"maximum file count reached"},l);break}if(l.size>g){D({code:2,message:"".concat(l.name," is too large")},l);break}if(l.size<b){D({code:3,message:"".concat(l.name," is too small")},l);break}if(!f(o,l)){D({code:1,message:"".concat(l.name," is not a valid file type")},l);break}n.push(l)}O(n)};return t().createElement(t().Fragment,null,t().createElement("input",p({},y,{ref:C,type:"file",accept:o?o.join():"",multiple:d,name:h,style:{display:"none"},onChange:_})),t().createElement("div",{ref:T,className:c,onClick:!0===s?function(){C.current.value=null,C.current.click()}:null,onDrop:_,onDragOver:N,onDragEnter:function(e){var t=T.current;u&&!t.className.includes(u)&&(t.className="".concat(t.className," ").concat(u)),"function"==typeof l&&k(!0),x&&x(e)},onDragLeave:R,style:w},"function"==typeof l?l(P):l))};y.propTypes={accepts:o().array,children:o().oneOfType([o().func,o().arrayOf(o().node),o().node]),className:o().string,clickable:o().bool,dragActiveClassName:o().string,inputProps:o().object,multiple:o().bool,maxFiles:o().number,maxFileSize:o().number,minFileSize:o().number,name:o().string,onChange:o().func,onDragEnter:o().func,onDragLeave:o().func,onError:o().func,style:o().object},y.defaultProps={accepts:null,className:void 0,clickable:!0,dragActiveClassName:void 0,inputProps:{},multiple:!0,maxFiles:1/0,maxFileSize:1/0,minFileSize:0,name:"file",onChange:function(e){return console.log(e)},onDragEnter:void 0,onDragLeave:void 0,onError:function(e){return console.log("error code ".concat(e.code,": ").concat(e.message))}};const d=y})(),a})()));
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["React"],t);else{var r="object"==typeof exports?t(require("react")):t(e.React);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,(e=>(()=>{var t={694:(e,t,r)=>{"use strict";var n=r(925);function o(){}function a(){}a.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,a,i){if(i!==n){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:o};return r.PropTypes=r,r}},556:(e,t,r)=>{e.exports=r(694)()},925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},156:t=>{"use strict";t.exports=e}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var a=r[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{"use strict";n.r(o),n.d(o,{default:()=>d});var e=n(156),t=n.n(e),r=n(556),a=n.n(r);const i=function(e){var t=e.name.split(".");return t.length>1?t[t.length-1]:"none"};function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,l=[],c=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var u=/^(application|audio|example|image|message|model|multipart|text|video|\*)\/[a-z0-9\.\+\*-]+$/,s=/\.[a-zA-Z0-9]*$/;const f=function(e,t){return!e||e.some((function(e){if(t.type&&e.match(u)){var r=l(t.type.split("/"),2),n=r[0],o=r[1],a=l(e.split("/"),2),i=a[0],c=a[1];if(i&&c){if("*"===i&&"*"===c)return!0;if(i===n&&"*"===c)return!0;if(i===n&&c===o)return!0}}else if(t.extension&&e.match(s)){var f=e.substr(1);return t.extension.toLowerCase()===f.toLowerCase()}return!1}))};function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},p.apply(null,arguments)}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var y=function(r){var n,o,a=r.accepts,l=void 0===a?null:a,c=r.children,u=r.className,s=r.clickable,y=void 0===s||s,d=r.dragActiveClassName,v=r.inputProps,g=void 0===v?{}:v,b=r.multiple,h=void 0===b||b,O=r.maxFiles,x=void 0===O?1/0:O,j=r.maxFileSize,S=void 0===j?1/0:j,T=r.minFileSize,w=void 0===T?0:T,A=r.name,C=void 0===A?"file":A,E=r.onChange,P=void 0===E?function(e){return console.log(e)}:E,k=r.onDragEnter,R=r.onDragLeave,_=r.onError,D=void 0===_?function(e){return console.log("error code ".concat(e.code,": ").concat(e.message))}:_,N=r.style,z=(0,e.useRef)(1),I=(0,e.useRef)(),M=(0,e.useRef)(),L=(n=(0,e.useState)(!1),o=2,function(e){if(Array.isArray(e))return e}(n)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,l=[],c=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return l}}(n,o)||function(e,t){if(e){if("string"==typeof e)return m(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(e,t):void 0}}(n,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),F=L[0],U=L[1],B=function(e,t){D(e,t)},$=(0,e.useCallback)((function(e){e.preventDefault(),e.stopPropagation()}),[]),q=function(e){var t=I.current;d&&(t.className=t.className.replace(" ".concat(d),"")),"function"==typeof c&&U(!1),R&&R(e)},W=function(e){e.preventDefault(),q(e);var t,r=e.dataTransfer?e.dataTransfer.files:e.target.files;!1===h&&r.length>1&&(r=[r[0]]);for(var n=[],o=0;o<r.length;o+=1){var a=r[o];if(a.id="files-".concat(z.current),z.current+=1,a.extension=i(a),a.sizeReadable=(t=a.size)>=1e9?Math.ceil(t/1e9)+"GB":t>=1e6?Math.ceil(t/1e6)+"MB":t>=1e3?Math.ceil(t/1e3)+"KB":Math.ceil(t)+"B",a.type&&"image"===a.type.split("/")[0]?a.preview={type:"image",url:window.URL.createObjectURL(a)}:a.preview={type:"file"},n.length>=x){B({code:4,message:"maximum file count reached"},a);break}if(a.size>S){B({code:2,message:"".concat(a.name," is too large")},a);break}if(a.size<w){B({code:3,message:"".concat(a.name," is too small")},a);break}if(!f(l,a)){B({code:1,message:"".concat(a.name," is not a valid file type")},a);break}n.push(a)}P(n)};return t().createElement(t().Fragment,null,t().createElement("input",p({},g,{ref:M,type:"file",accept:l?l.join():"",multiple:h,name:C,style:{display:"none"},onChange:W})),t().createElement("div",{ref:I,className:u,onClick:!0===y?function(){M.current.value=null,M.current.click()}:null,onDrop:W,onDragOver:$,onDragEnter:function(e){var t=I.current;d&&!t.className.includes(d)&&(t.className="".concat(t.className," ").concat(d)),"function"==typeof c&&U(!0),k&&k(e)},onDragLeave:q,style:N},"function"==typeof c?c(F):c))};y.propTypes={accepts:a().array,children:a().oneOfType([a().func,a().arrayOf(a().node),a().node]),className:a().string,clickable:a().bool,dragActiveClassName:a().string,inputProps:a().object,multiple:a().bool,maxFiles:a().number,maxFileSize:a().number,minFileSize:a().number,name:a().string,onChange:a().func,onDragEnter:a().func,onDragLeave:a().func,onError:a().func,style:a().object};const d=y})(),o})()));
The MIT License (MIT)
Copyright (c) 2016 Jared Reich
Copyright (c) 2023 Mother Co

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "react-files",
"version": "3.0.0",
"version": "3.0.1",
"main": "dist/index.js",

@@ -48,7 +48,7 @@ "description": "A file input (dropzone) management component for React",

"devDependencies": {
"@babel/core": "^7.20.12",
"@babel/core": "^7.24.7",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"axios": "^1.3.2",
"axios": "^1.7.2",
"babel-eslint": "^10.1.0",

@@ -58,3 +58,3 @@ "babel-loader": "^9.1.2",

"eslint-config-mother": "^2.0.15",
"express": "^4.18.2",
"express": "^4.19.2",
"form-data": "^4.0.0",

@@ -66,8 +66,8 @@ "husky": "^4.2.5",

"react-dom": "^18.2.0",
"webpack": "^5.75.0",
"webpack": "^5.92.1",
"webpack-bundle-analyzer": "^4.7.0",
"webpack-cli": "^5.0.1",
"webpack-dev-middleware": "^6.0.1",
"webpack-hot-middleware": "^2.25.3"
"webpack-dev-middleware": "^6.1.3",
"webpack-hot-middleware": "^2.26.1"
}
}
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