@shipstatic/drop 0.1.13 → 0.1.15

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.d.cts CHANGED
@@ -7,6 +7,14 @@ import { Ship, formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
7
7
  * and defines drop-specific types
8
8
  */
9
9
 
10
+ /**
11
+ * Extended File interface with webkitRelativePath
12
+ * This property is set by browsers for folder uploads and drag-drop
13
+ * https://developer.mozilla.org/en-US/docs/Web/API/File/webkitRelativePath
14
+ */
15
+ interface FileWithPath extends File {
16
+ readonly webkitRelativePath: string;
17
+ }
10
18
  declare const FILE_STATUSES: {
11
19
  readonly PROCESSING: "processing";
12
20
  readonly UPLOADING: "uploading";
@@ -176,7 +184,7 @@ declare const formatFileSize: typeof formatFileSize$1;
176
184
  declare function createProcessedFile(file: File, options?: {
177
185
  /** Custom path (defaults to webkitRelativePath or file.name) */
178
186
  path?: string;
179
- }): Promise<ProcessedFile>;
187
+ }): ProcessedFile;
180
188
  /**
181
189
  * Strip common directory prefix from file paths
182
190
  * Only strips if ALL files share the same prefix
@@ -219,4 +227,4 @@ declare function isZipFile(file: File): boolean;
219
227
  */
220
228
  declare function getMimeType(path: string): string;
221
229
 
222
- export { type ClientError, type DropOptions, type DropReturn, type DropState, type DropStateValue, type DropStatus, FILE_STATUSES, type FileStatus, type ProcessedFile, type ZipExtractionResult, createProcessedFile, extractZipToFiles, formatFileSize, getMimeType, isZipFile, normalizePath, stripCommonPrefix, traverseFileTree, useDrop };
230
+ export { type ClientError, type DropOptions, type DropReturn, type DropState, type DropStateValue, type DropStatus, FILE_STATUSES, type FileStatus, type FileWithPath, type ProcessedFile, type ZipExtractionResult, createProcessedFile, extractZipToFiles, formatFileSize, getMimeType, isZipFile, normalizePath, stripCommonPrefix, traverseFileTree, useDrop };
package/dist/index.d.ts CHANGED
@@ -7,6 +7,14 @@ import { Ship, formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
7
7
  * and defines drop-specific types
8
8
  */
9
9
 
10
+ /**
11
+ * Extended File interface with webkitRelativePath
12
+ * This property is set by browsers for folder uploads and drag-drop
13
+ * https://developer.mozilla.org/en-US/docs/Web/API/File/webkitRelativePath
14
+ */
15
+ interface FileWithPath extends File {
16
+ readonly webkitRelativePath: string;
17
+ }
10
18
  declare const FILE_STATUSES: {
11
19
  readonly PROCESSING: "processing";
12
20
  readonly UPLOADING: "uploading";
@@ -176,7 +184,7 @@ declare const formatFileSize: typeof formatFileSize$1;
176
184
  declare function createProcessedFile(file: File, options?: {
177
185
  /** Custom path (defaults to webkitRelativePath or file.name) */
178
186
  path?: string;
179
- }): Promise<ProcessedFile>;
187
+ }): ProcessedFile;
180
188
  /**
181
189
  * Strip common directory prefix from file paths
182
190
  * Only strips if ALL files share the same prefix
@@ -219,4 +227,4 @@ declare function isZipFile(file: File): boolean;
219
227
  */
220
228
  declare function getMimeType(path: string): string;
221
229
 
222
- export { type ClientError, type DropOptions, type DropReturn, type DropState, type DropStateValue, type DropStatus, FILE_STATUSES, type FileStatus, type ProcessedFile, type ZipExtractionResult, createProcessedFile, extractZipToFiles, formatFileSize, getMimeType, isZipFile, normalizePath, stripCommonPrefix, traverseFileTree, useDrop };
230
+ export { type ClientError, type DropOptions, type DropReturn, type DropState, type DropStateValue, type DropStatus, FILE_STATUSES, type FileStatus, type FileWithPath, type ProcessedFile, type ZipExtractionResult, createProcessedFile, extractZipToFiles, formatFileSize, getMimeType, isZipFile, normalizePath, stripCommonPrefix, traverseFileTree, useDrop };
package/dist/index.js CHANGED
@@ -11700,7 +11700,7 @@ var require_mime_db = __commonJS({
11700
11700
  }
11701
11701
  });
11702
11702
 
11703
- // node_modules/.pnpm/@shipstatic+types@0.3.18/node_modules/@shipstatic/types/dist/index.js
11703
+ // node_modules/.pnpm/@shipstatic+types@0.3.21/node_modules/@shipstatic/types/dist/index.js
11704
11704
  var ErrorType;
11705
11705
  (function(ErrorType2) {
11706
11706
  ErrorType2["Validation"] = "validation_failed";
@@ -11812,7 +11812,7 @@ function isZipFile(file) {
11812
11812
  return file.type === "application/zip" || file.type === "application/x-zip-compressed" || file.name.toLowerCase().endsWith(".zip");
11813
11813
  }
11814
11814
  var formatFileSize = formatFileSize$1;
11815
- async function createProcessedFile(file, options) {
11815
+ function createProcessedFile(file, options) {
11816
11816
  const webkitPath = file.webkitRelativePath || "";
11817
11817
  const path = options?.path || (webkitPath && webkitPath.trim() ? webkitPath : file.name);
11818
11818
  const type = file.type || getMimeType(path);
@@ -11969,9 +11969,7 @@ function useDrop(options) {
11969
11969
  ...prev,
11970
11970
  status: { title: "Processing...", details: "Processing files..." }
11971
11971
  }));
11972
- const processedFiles = await Promise.all(
11973
- cleanFiles.map((file) => createProcessedFile(file))
11974
- );
11972
+ const processedFiles = cleanFiles.map((file) => createProcessedFile(file));
11975
11973
  const finalFiles = stripPrefix ? stripCommonPrefix(processedFiles) : processedFiles;
11976
11974
  const config = await ship.getConfig();
11977
11975
  const validation = validateFiles(finalFiles, config);
@@ -12107,15 +12105,16 @@ function useDrop(options) {
12107
12105
  }
12108
12106
  if (files.length > 0) {
12109
12107
  await processFiles(files);
12110
- } else if (state.value === "dragging") {
12111
- setState((prev) => ({ ...prev, value: "idle" }));
12108
+ } else {
12109
+ setState((prev) => prev.value === "dragging" ? { ...prev, value: "idle" } : prev);
12112
12110
  }
12113
- }, [processFiles, state.value]);
12111
+ }, [processFiles]);
12114
12112
  const handleInputChange = useCallback((e) => {
12115
12113
  const files = Array.from(e.target.files || []);
12116
12114
  if (files.length > 0) {
12117
12115
  processFiles(files);
12118
12116
  }
12117
+ e.target.value = "";
12119
12118
  }, [processFiles]);
12120
12119
  const open = useCallback(() => {
12121
12120
  inputRef.current?.click();