@uploadthing/dropzone
Advanced tools
Comparing version 0.1.4-canary.aa58d1b to 0.2.0
@@ -1,6 +0,28 @@ | ||
import attrAccepts from 'attr-accept'; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const accepts = // @ts-expect-error - ESM interop | ||
typeof attrAccepts === "function" ? attrAccepts : attrAccepts.default; | ||
/** | ||
* This is a forked version of the react-dropzone package, that's been minified | ||
* to suit UploadThing's needs and be easily portable to other frameworks than React. | ||
* See original source here: https://github.com/react-dropzone/react-dropzone | ||
* The original package is licensed under the MIT license. | ||
*/ /** | ||
* Copyright (c) (MIT License) 2015 Andrey Okonetchnikov | ||
* https://github.com/react-dropzone/attr-accept/blob/master/src/index.js | ||
*/ function accepts(file, acceptedFiles) { | ||
if (file && acceptedFiles) { | ||
const acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(","); | ||
const fileName = file.name ?? ""; | ||
const mimeType = (file.type ?? "").toLowerCase(); | ||
const baseMimeType = mimeType.replace(/\/.*$/, ""); | ||
return acceptedFilesArray.some((type)=>{ | ||
const validType = type.trim().toLowerCase(); | ||
if (validType.startsWith(".")) { | ||
return fileName.toLowerCase().endsWith(validType); | ||
} else if (validType.endsWith("/*")) { | ||
// This is something like a image/* mime type | ||
return baseMimeType === validType.replace(/\/.*$/, ""); | ||
} | ||
return mimeType === validType; | ||
}); | ||
} | ||
return true; | ||
} | ||
// Firefox versions prior to 53 return a bogus MIME type for every file drag, so dragovers with | ||
@@ -7,0 +29,0 @@ // that MIME type will always be accepted |
{ | ||
"name": "@uploadthing/dropzone", | ||
"version": "0.1.4-canary.aa58d1b", | ||
"version": "0.2.0", | ||
"type": "module", | ||
@@ -48,13 +48,12 @@ "license": "MIT", | ||
"dependencies": { | ||
"attr-accept": "^2.2.2", | ||
"file-selector": "^0.6.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "18.2.55", | ||
"@types/react": "18.2.60", | ||
"@uploadthing/eslint-config": "0.2.0", | ||
"@uploadthing/tsconfig": "0.1.0", | ||
"bunchee": "^4.4.8", | ||
"eslint": "^8.56.0", | ||
"eslint": "^8.57.0", | ||
"react": "18.2.0", | ||
"solid-js": "^1.7.11", | ||
"solid-js": "^1.8.15", | ||
"typescript": "^5.3.3" | ||
@@ -61,0 +60,0 @@ }, |
Sorry, the diff of this file is not supported yet
60902
3
1465
- Removedattr-accept@^2.2.2
- Removedattr-accept@2.2.5(transitive)