@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 CHANGED
@@ -11848,6 +11848,7 @@ function useDrop(options) {
11848
11848
  stripPrefix = true
11849
11849
  } = options;
11850
11850
  const [files, setFiles] = react.useState([]);
11851
+ const [sourceName, setSourceName] = react.useState("");
11851
11852
  const [statusText, setStatusText] = react.useState("");
11852
11853
  const [isProcessing, setIsProcessing] = react.useState(false);
11853
11854
  const [validationError, setValidationError] = react.useState(null);
@@ -11867,6 +11868,18 @@ function useDrop(options) {
11867
11868
  setValidationError(null);
11868
11869
  setStatusText("Processing files...");
11869
11870
  try {
11871
+ let detectedSourceName = "";
11872
+ if (newFiles.length === 1 && isZipFile(newFiles[0])) {
11873
+ detectedSourceName = newFiles[0].name.replace(/\.zip$/i, "");
11874
+ } else if (newFiles.length > 0) {
11875
+ const firstPath = newFiles[0].webkitRelativePath || "";
11876
+ if (firstPath && firstPath.includes("/")) {
11877
+ detectedSourceName = firstPath.split("/")[0];
11878
+ } else {
11879
+ detectedSourceName = newFiles[0].name;
11880
+ }
11881
+ }
11882
+ setSourceName(detectedSourceName);
11870
11883
  const allFiles = [];
11871
11884
  const shouldExtractZip = newFiles.length === 1 && isZipFile(newFiles[0]);
11872
11885
  if (shouldExtractZip) {
@@ -11921,6 +11934,7 @@ function useDrop(options) {
11921
11934
  }, [ship$1, onValidationError, onFilesReady, stripPrefix]);
11922
11935
  const clearAll = react.useCallback(() => {
11923
11936
  setFiles([]);
11937
+ setSourceName("");
11924
11938
  setStatusText("");
11925
11939
  setValidationError(null);
11926
11940
  isProcessingRef.current = false;
@@ -11936,6 +11950,7 @@ function useDrop(options) {
11936
11950
  }, []);
11937
11951
  return {
11938
11952
  files,
11953
+ sourceName,
11939
11954
  statusText,
11940
11955
  isProcessing,
11941
11956
  validationError,