@shipstatic/drop 0.2.18 → 0.2.20
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/dist/index.cjs +4 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +5 -28
- package/dist/index.js.map +1 -1
- package/dist/testing.d.cts +1 -2
- package/dist/testing.d.ts +1 -2
- package/dist/{useDrop-DbGbhh56.d.cts → useDrop-ddRfHehl.d.cts} +6 -4
- package/dist/{useDrop-DbGbhh56.d.ts → useDrop-ddRfHehl.d.ts} +6 -4
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { P as ProcessedFile } from './useDrop-
|
|
2
|
-
export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-
|
|
1
|
+
import { P as ProcessedFile } from './useDrop-ddRfHehl.cjs';
|
|
2
|
+
export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-ddRfHehl.cjs';
|
|
3
3
|
import { formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
4
|
-
import '@shipstatic/types';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Unified file processing utilities
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { P as ProcessedFile } from './useDrop-
|
|
2
|
-
export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-
|
|
1
|
+
import { P as ProcessedFile } from './useDrop-ddRfHehl.js';
|
|
2
|
+
export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-ddRfHehl.js';
|
|
3
3
|
import { formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
4
|
-
import '@shipstatic/types';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Unified file processing utilities
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useRef, useMemo, useCallback } from 'react';
|
|
2
|
-
import { formatFileSize as formatFileSize$1,
|
|
2
|
+
import { formatFileSize as formatFileSize$1, filterJunk, validateFiles } from '@shipstatic/ship';
|
|
3
3
|
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -11700,7 +11700,7 @@ var require_mime_db = __commonJS({
|
|
|
11700
11700
|
}
|
|
11701
11701
|
});
|
|
11702
11702
|
|
|
11703
|
-
// node_modules/.pnpm/@shipstatic+types@0.
|
|
11703
|
+
// node_modules/.pnpm/@shipstatic+types@0.6.0/node_modules/@shipstatic/types/dist/index.js
|
|
11704
11704
|
var ErrorType;
|
|
11705
11705
|
(function(ErrorType2) {
|
|
11706
11706
|
ErrorType2["Validation"] = "validation_failed";
|
|
@@ -11926,7 +11926,7 @@ function useDrop(options) {
|
|
|
11926
11926
|
[state.value]
|
|
11927
11927
|
);
|
|
11928
11928
|
const hasError = useMemo(() => state.value === "error", [state.value]);
|
|
11929
|
-
const validFiles = useMemo(() =>
|
|
11929
|
+
const validFiles = useMemo(() => state.files.filter((f) => f.status === "ready"), [state.files]);
|
|
11930
11930
|
const getFilesForUpload = useCallback(() => {
|
|
11931
11931
|
return validFiles.map((f) => f.file);
|
|
11932
11932
|
}, [validFiles]);
|
|
@@ -11986,34 +11986,11 @@ function useDrop(options) {
|
|
|
11986
11986
|
}));
|
|
11987
11987
|
const processedFiles = cleanFiles.map((file) => createProcessedFile(file));
|
|
11988
11988
|
const finalFiles = stripPrefix ? stripCommonPrefix(processedFiles) : processedFiles;
|
|
11989
|
-
const filesForValidation = finalFiles
|
|
11990
|
-
const browserUnknown = !f.file.type || f.file.type === "application/octet-stream";
|
|
11991
|
-
const mimeDbUnknown = !f.type || f.type === "application/octet-stream";
|
|
11992
|
-
const isUnknownType = browserUnknown && mimeDbUnknown;
|
|
11993
|
-
if (isUnknownType) {
|
|
11994
|
-
const textFile = new File([f.file], f.file.name, {
|
|
11995
|
-
type: "text/plain",
|
|
11996
|
-
lastModified: f.file.lastModified
|
|
11997
|
-
});
|
|
11998
|
-
if (f.file.webkitRelativePath) {
|
|
11999
|
-
Object.defineProperty(textFile, "webkitRelativePath", {
|
|
12000
|
-
value: f.file.webkitRelativePath,
|
|
12001
|
-
writable: false,
|
|
12002
|
-
configurable: true
|
|
12003
|
-
});
|
|
12004
|
-
}
|
|
12005
|
-
return { ...f, file: textFile, type: "text/plain" };
|
|
12006
|
-
}
|
|
12007
|
-
return f;
|
|
12008
|
-
});
|
|
11989
|
+
const filesForValidation = finalFiles;
|
|
12009
11990
|
const validatableFiles = filesForValidation.map((f) => ({
|
|
12010
11991
|
name: f.path,
|
|
12011
11992
|
// Use full path to match server-side validation
|
|
12012
|
-
|
|
12013
|
-
// Use corrected MIME type from mime-db, not browser's File.type
|
|
12014
|
-
size: f.file.size,
|
|
12015
|
-
status: f.status,
|
|
12016
|
-
statusMessage: f.statusMessage
|
|
11993
|
+
size: f.file.size
|
|
12017
11994
|
}));
|
|
12018
11995
|
const config = await ship.getConfig();
|
|
12019
11996
|
const validation = validateFiles(validatableFiles, config);
|