gbs-add-block 0.0.19 → 0.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbs-add-block",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "React Component Library",
5
5
  "files": [
6
6
  "index.js",
@@ -14,7 +14,8 @@ import Icon from "../icon/Icon";
14
14
  import { GetFileIcon } from "./uploaderIcon";
15
15
  import AestheticProcessingAnimationWithStyles from "./ProgressAnimation";
16
16
  import { sendFiles } from "./uploaderService";
17
- import { cloudDownload } from "../../icon/iconPaths";
17
+ import { cloudDownload } from "../icon/iconPaths";
18
+ import type { FileUploadProps } from "./types";
18
19
 
19
20
  export const FileUploader = ({
20
21
  showImagePreview = false,
@@ -22,15 +23,15 @@ export const FileUploader = ({
22
23
  onChange,
23
24
  selectedFiles = [],
24
25
  accept,
25
- fileCount,
26
+ fileCount = 1,
26
27
  disabled = false,
27
28
  inputFileSize, // Max file size in MB
28
29
  startUpload = false,
29
30
  apiURL = "",
30
- chunk_size = "",
31
+ chunk_size = 1024 * 1024,
31
32
  uploadedFileIdArray = () => {},
32
33
  fileData = [],
33
- }: any) => {
34
+ }: FileUploadProps) => {
34
35
  const [files, setFiles] = useState<any[]>([]);
35
36
  const [previewUrls, setPreviewUrls] = useState<{ [key: string]: string }>({});
36
37
  const [isDragging, setIsDragging] = useState(false);
@@ -93,7 +94,7 @@ export const FileUploader = ({
93
94
  }
94
95
 
95
96
  // File size validation
96
- const validFiles: File[] = [];
97
+ const validFiles: any = [];
97
98
  const newErrors: string[] = [];
98
99
 
99
100
  updatedFiles.forEach((file) => {
@@ -111,7 +112,7 @@ export const FileUploader = ({
111
112
  if (validFiles.length > 0) {
112
113
  setFiles(validFiles);
113
114
  setPreviewUrls({});
114
- validFiles.forEach((file) => {
115
+ validFiles.forEach((file: any) => {
115
116
  if (showImagePreview && file.type.startsWith("image/")) {
116
117
  const reader = new FileReader();
117
118
  reader.onload = () => {
@@ -132,7 +133,7 @@ export const FileUploader = ({
132
133
 
133
134
  // Removes the file from file array
134
135
  const removeFile = (index: number) => {
135
- const updatedFiles = files.filter((_, i) => i !== index);
136
+ const updatedFiles: any = files.filter((_, i) => i !== index);
136
137
  setFiles(updatedFiles);
137
138
  setPreviewUrls((prevPreviews) => {
138
139
  const { [files[index].name]: _, ...rest } = prevPreviews;
@@ -0,0 +1,15 @@
1
+ export type FileUploadProps = {
2
+ showImagePreview?: boolean;
3
+ multiple?: boolean;
4
+ onChange: (files: FileList | null) => void;
5
+ selectedFiles?: File[];
6
+ accept?: string;
7
+ fileCount?: number;
8
+ disabled?: boolean;
9
+ inputFileSize?: number;
10
+ startUpload?: boolean;
11
+ apiURL?: string;
12
+ chunk_size?: number;
13
+ uploadedFileIdArray?: (ids: string[]) => void;
14
+ fileData?: File[];
15
+ };