sprint-asia-custom-component 0.1.148 → 0.1.149
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.js
CHANGED
|
@@ -26087,7 +26087,8 @@
|
|
|
26087
26087
|
maxFiles = 1,
|
|
26088
26088
|
selectedFile,
|
|
26089
26089
|
error = "",
|
|
26090
|
-
disabled
|
|
26090
|
+
disabled,
|
|
26091
|
+
acceptExcel = false
|
|
26091
26092
|
}) => {
|
|
26092
26093
|
const [errorMessage, setErrorMessage] = React.useState("");
|
|
26093
26094
|
const onDropRejected = rejectedFiles => {
|
|
@@ -26095,20 +26096,31 @@
|
|
|
26095
26096
|
if (file.errors[0]?.code === "file-too-large") {
|
|
26096
26097
|
setErrorMessage("Your file is too large. Max file size is 5 MB");
|
|
26097
26098
|
} else if (file.errors[0]?.code === "file-invalid-type") {
|
|
26098
|
-
setErrorMessage("File format not supported. Please try again with PNG, JPEG, JPG, or PDF file within 5 MB");
|
|
26099
|
+
setErrorMessage(excelAcceptedFiles ? "File format not supported. Please try again with XLSX, XLS, CSV, or TSV file within 5 MB" : "File format not supported. Please try again with PNG, JPEG, JPG, or PDF file within 5 MB");
|
|
26099
26100
|
}
|
|
26100
26101
|
};
|
|
26102
|
+
|
|
26103
|
+
// Default file types
|
|
26104
|
+
const defaultAcceptedFiles = {
|
|
26105
|
+
"image/jpeg": [".jpeg", ".jpg"],
|
|
26106
|
+
"image/png": [".png"],
|
|
26107
|
+
"application/pdf": [".pdf"]
|
|
26108
|
+
};
|
|
26109
|
+
|
|
26110
|
+
// Additional file types
|
|
26111
|
+
const excelAcceptedFiles = {
|
|
26112
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
|
|
26113
|
+
"application/vnd.ms-excel": [".xls"],
|
|
26114
|
+
"text/csv": [".csv"],
|
|
26115
|
+
"text/tab-separated-values": [".tsv"]
|
|
26116
|
+
};
|
|
26101
26117
|
const {
|
|
26102
26118
|
getRootProps,
|
|
26103
26119
|
getInputProps
|
|
26104
26120
|
} = useDropzone({
|
|
26105
26121
|
onDrop,
|
|
26106
26122
|
maxFiles,
|
|
26107
|
-
accept:
|
|
26108
|
-
"image/jpeg": [".jpeg", ".jpg"],
|
|
26109
|
-
"image/png": [".png"],
|
|
26110
|
-
"application/pdf": [".pdf"]
|
|
26111
|
-
},
|
|
26123
|
+
accept: acceptExcel ? excelAcceptedFiles : defaultAcceptedFiles,
|
|
26112
26124
|
noKeyboard: true,
|
|
26113
26125
|
maxSize: 5242881,
|
|
26114
26126
|
onDropRejected,
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ const DropzoneUploadFile = ({
|
|
|
11
11
|
selectedFile,
|
|
12
12
|
error = "",
|
|
13
13
|
disabled,
|
|
14
|
+
acceptExcel = false,
|
|
14
15
|
}) => {
|
|
15
16
|
const [errorMessage, setErrorMessage] = useState("");
|
|
16
17
|
|
|
@@ -19,18 +20,33 @@ const DropzoneUploadFile = ({
|
|
|
19
20
|
if (file.errors[0]?.code === "file-too-large") {
|
|
20
21
|
setErrorMessage("Your file is too large. Max file size is 5 MB");
|
|
21
22
|
} else if (file.errors[0]?.code === "file-invalid-type") {
|
|
22
|
-
setErrorMessage(
|
|
23
|
+
setErrorMessage(
|
|
24
|
+
excelAcceptedFiles
|
|
25
|
+
? "File format not supported. Please try again with XLSX, XLS, CSV, or TSV file within 5 MB"
|
|
26
|
+
: "File format not supported. Please try again with PNG, JPEG, JPG, or PDF file within 5 MB"
|
|
27
|
+
);
|
|
23
28
|
}
|
|
24
29
|
};
|
|
25
30
|
|
|
31
|
+
// Default file types
|
|
32
|
+
const defaultAcceptedFiles = {
|
|
33
|
+
"image/jpeg": [".jpeg", ".jpg"],
|
|
34
|
+
"image/png": [".png"],
|
|
35
|
+
"application/pdf": [".pdf"],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Additional file types
|
|
39
|
+
const excelAcceptedFiles = {
|
|
40
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
|
|
41
|
+
"application/vnd.ms-excel": [".xls"],
|
|
42
|
+
"text/csv": [".csv"],
|
|
43
|
+
"text/tab-separated-values": [".tsv"],
|
|
44
|
+
};
|
|
45
|
+
|
|
26
46
|
const { getRootProps, getInputProps } = useDropzone({
|
|
27
47
|
onDrop,
|
|
28
48
|
maxFiles,
|
|
29
|
-
accept:
|
|
30
|
-
"image/jpeg": [".jpeg", ".jpg"],
|
|
31
|
-
"image/png": [".png"],
|
|
32
|
-
"application/pdf": [".pdf"],
|
|
33
|
-
},
|
|
49
|
+
accept: acceptExcel ? excelAcceptedFiles : defaultAcceptedFiles,
|
|
34
50
|
noKeyboard: true,
|
|
35
51
|
maxSize: 5242881,
|
|
36
52
|
onDropRejected,
|
package/src/templates/index.js
CHANGED
|
@@ -1146,7 +1146,14 @@ const Templates = () => {
|
|
|
1146
1146
|
|
|
1147
1147
|
<div className="m-9"></div>
|
|
1148
1148
|
<p className="text-black font-bold text-2xl text-center py-2">Dropzone</p>
|
|
1149
|
-
<DropzoneUploadFile
|
|
1149
|
+
<DropzoneUploadFile
|
|
1150
|
+
title="Upload Your File"
|
|
1151
|
+
subtitle="Accepts PDF, JPEG, JPG. Max size 5 MB"
|
|
1152
|
+
required={true}
|
|
1153
|
+
onDrop={handleFileChange}
|
|
1154
|
+
selectedFile={currentImage}
|
|
1155
|
+
acceptExcel
|
|
1156
|
+
/>
|
|
1150
1157
|
|
|
1151
1158
|
<div className="m-9"></div>
|
|
1152
1159
|
<DropzoneUploadPhoto
|