gbs-add-block 0.0.23 → 0.0.24
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/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# GBS Building Blocks 2.0 (v0.0.23)
|
|
2
|
+
|
|
3
|
+
Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
For detailed documentation on usage and props, Please visit: [Building Block Documentation v2.0](https://blackmax-designs.gitbook.io/building-block-v2.0)
|
|
8
|
+
|
|
9
|
+
## What's New 🎉 (Ver 0.0.23)
|
|
10
|
+
|
|
11
|
+
- Updated Uploader
|
|
12
|
+
- Global Style Customisation is Now available(beta)
|
|
13
|
+
|
|
14
|
+
## Authors
|
|
15
|
+
|
|
16
|
+
- [@anandhuremanan](https://www.github.com/anandhuremanan)
|
package/package.json
CHANGED
|
@@ -80,12 +80,14 @@ export default function UploadedFilePreview({
|
|
|
80
80
|
className="flex items-center justify-between bg-gray-50 p-2 rounded-md mt-2"
|
|
81
81
|
>
|
|
82
82
|
<div className="flex items-center space-x-2">
|
|
83
|
-
{isImageFile(item.FileName)
|
|
83
|
+
{isImageFile(item.FileName) ? (
|
|
84
84
|
<img
|
|
85
85
|
src={constructDownloadUrl(item.FileID)}
|
|
86
86
|
alt={item.FileName}
|
|
87
87
|
className="mt-2 w-8 h-8 object-cover rounded-lg"
|
|
88
88
|
/>
|
|
89
|
+
) : (
|
|
90
|
+
<GetFileIcon file={{ type: item.FileName.split(".").pop() }} />
|
|
89
91
|
)}
|
|
90
92
|
<div>
|
|
91
93
|
<p className="text-sm font-medium text-gray-700">
|
|
@@ -63,6 +63,7 @@ export const FileUploader = ({
|
|
|
63
63
|
}
|
|
64
64
|
);
|
|
65
65
|
setFileUploadStatus("Upload completed");
|
|
66
|
+
setFiles([]);
|
|
66
67
|
} else {
|
|
67
68
|
setFileUploadStatus("No files selected");
|
|
68
69
|
}
|
|
@@ -97,9 +98,34 @@ export const FileUploader = ({
|
|
|
97
98
|
|
|
98
99
|
// Adds files to file array
|
|
99
100
|
const handleFileChange = (newFiles: File[]) => {
|
|
101
|
+
// First check for duplicates
|
|
102
|
+
const duplicateFiles: string[] = [];
|
|
103
|
+
const nonDuplicateFiles = newFiles.filter((newFile) => {
|
|
104
|
+
const isDuplicate = files.some(
|
|
105
|
+
(existingFile) => existingFile.name === newFile.name
|
|
106
|
+
);
|
|
107
|
+
if (isDuplicate) {
|
|
108
|
+
duplicateFiles.push(newFile.name);
|
|
109
|
+
}
|
|
110
|
+
return !isDuplicate;
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// If there are duplicates, set error messages
|
|
114
|
+
if (duplicateFiles.length > 0) {
|
|
115
|
+
setFileSizeErrors((prev) => [
|
|
116
|
+
...prev,
|
|
117
|
+
...duplicateFiles.map(
|
|
118
|
+
(fileName) => `File "${fileName}" has already been uploaded`
|
|
119
|
+
),
|
|
120
|
+
]);
|
|
121
|
+
|
|
122
|
+
// If all files are duplicates, exit early
|
|
123
|
+
if (nonDuplicateFiles.length === 0) return;
|
|
124
|
+
}
|
|
125
|
+
|
|
100
126
|
let updatedFiles: File[] = multiple
|
|
101
|
-
? [...files, ...
|
|
102
|
-
: [
|
|
127
|
+
? [...files, ...nonDuplicateFiles]
|
|
128
|
+
: [nonDuplicateFiles[0]];
|
|
103
129
|
|
|
104
130
|
// Ensure the total number of files doesn't exceed the fileCount limit
|
|
105
131
|
if (updatedFiles.length > fileCount) {
|
|
@@ -143,7 +169,7 @@ export const FileUploader = ({
|
|
|
143
169
|
if (onChange) onChange(validFiles);
|
|
144
170
|
}
|
|
145
171
|
|
|
146
|
-
// Set file size errors
|
|
172
|
+
// Set file size errors (now includes both size and duplicate errors)
|
|
147
173
|
setFileSizeErrors(newErrors);
|
|
148
174
|
};
|
|
149
175
|
|
|
@@ -30,7 +30,7 @@ export const GetFileIcon = ({ file, showImagePreview, previewUrls }: any) => {
|
|
|
30
30
|
svgClass={"stroke-blue-500 fill-none dark:stroke-white"}
|
|
31
31
|
/>
|
|
32
32
|
);
|
|
33
|
-
if (file.type === "application/pdf")
|
|
33
|
+
if (file.type === "application/pdf" || file.type.includes("pdf"))
|
|
34
34
|
return (
|
|
35
35
|
<Icon
|
|
36
36
|
dimensions={{ width: "26", height: "26" }}
|