@shipstatic/drop 0.1.3 → 0.1.4
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 +15 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -66,6 +66,8 @@ interface DropOptions {
|
|
|
66
66
|
interface DropReturn {
|
|
67
67
|
/** All processed files with their status */
|
|
68
68
|
files: ProcessedFile[];
|
|
69
|
+
/** Name of the source (file/folder/ZIP) that was dropped/selected */
|
|
70
|
+
sourceName: string;
|
|
69
71
|
/** Current status text */
|
|
70
72
|
statusText: string;
|
|
71
73
|
/** Whether currently processing files (ZIP extraction, etc.) */
|
package/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,8 @@ interface DropOptions {
|
|
|
66
66
|
interface DropReturn {
|
|
67
67
|
/** All processed files with their status */
|
|
68
68
|
files: ProcessedFile[];
|
|
69
|
+
/** Name of the source (file/folder/ZIP) that was dropped/selected */
|
|
70
|
+
sourceName: string;
|
|
69
71
|
/** Current status text */
|
|
70
72
|
statusText: string;
|
|
71
73
|
/** Whether currently processing files (ZIP extraction, etc.) */
|
package/dist/index.js
CHANGED
|
@@ -11846,6 +11846,7 @@ function useDrop(options) {
|
|
|
11846
11846
|
stripPrefix = true
|
|
11847
11847
|
} = options;
|
|
11848
11848
|
const [files, setFiles] = useState([]);
|
|
11849
|
+
const [sourceName, setSourceName] = useState("");
|
|
11849
11850
|
const [statusText, setStatusText] = useState("");
|
|
11850
11851
|
const [isProcessing, setIsProcessing] = useState(false);
|
|
11851
11852
|
const [validationError, setValidationError] = useState(null);
|
|
@@ -11865,6 +11866,18 @@ function useDrop(options) {
|
|
|
11865
11866
|
setValidationError(null);
|
|
11866
11867
|
setStatusText("Processing files...");
|
|
11867
11868
|
try {
|
|
11869
|
+
let detectedSourceName = "";
|
|
11870
|
+
if (newFiles.length === 1 && isZipFile(newFiles[0])) {
|
|
11871
|
+
detectedSourceName = newFiles[0].name.replace(/\.zip$/i, "");
|
|
11872
|
+
} else if (newFiles.length > 0) {
|
|
11873
|
+
const firstPath = newFiles[0].webkitRelativePath || "";
|
|
11874
|
+
if (firstPath && firstPath.includes("/")) {
|
|
11875
|
+
detectedSourceName = firstPath.split("/")[0];
|
|
11876
|
+
} else {
|
|
11877
|
+
detectedSourceName = newFiles[0].name;
|
|
11878
|
+
}
|
|
11879
|
+
}
|
|
11880
|
+
setSourceName(detectedSourceName);
|
|
11868
11881
|
const allFiles = [];
|
|
11869
11882
|
const shouldExtractZip = newFiles.length === 1 && isZipFile(newFiles[0]);
|
|
11870
11883
|
if (shouldExtractZip) {
|
|
@@ -11919,6 +11932,7 @@ function useDrop(options) {
|
|
|
11919
11932
|
}, [ship, onValidationError, onFilesReady, stripPrefix]);
|
|
11920
11933
|
const clearAll = useCallback(() => {
|
|
11921
11934
|
setFiles([]);
|
|
11935
|
+
setSourceName("");
|
|
11922
11936
|
setStatusText("");
|
|
11923
11937
|
setValidationError(null);
|
|
11924
11938
|
isProcessingRef.current = false;
|
|
@@ -11934,6 +11948,7 @@ function useDrop(options) {
|
|
|
11934
11948
|
}, []);
|
|
11935
11949
|
return {
|
|
11936
11950
|
files,
|
|
11951
|
+
sourceName,
|
|
11937
11952
|
statusText,
|
|
11938
11953
|
isProcessing,
|
|
11939
11954
|
validationError,
|