@bigbinary/neeto-molecules 3.2.19 → 3.3.0

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": "@bigbinary/neeto-molecules",
3
- "version": "3.2.19",
3
+ "version": "3.3.0",
4
4
  "description": "A package of reusable molecular components for neeto products.",
5
5
  "repository": "git@github.com:bigbinary/neeto-molecules.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
@@ -725,6 +725,20 @@
725
725
  "checkboxLabel": "Start at",
726
726
  "tooltipContent": "Copy link",
727
727
  "successTooltipContent": "Link copied"
728
+ },
729
+ "fileUpload": {
730
+ "filesDropzone": {
731
+ "errors": {
732
+ "fileTooLarge": "The file '{{fileName, anyCase}}' is larger than {{maxSize, anyCase}}",
733
+ "fileInvalidType": "Currently the file type {{fileType}} is not permitted.",
734
+ "tooManyFiles": "You can only upload {{maxFiles}} file.",
735
+ "defaultError": "Something went wrong while uploading {{fileName, anyCase}}"
736
+ },
737
+ "maxFileSize": "Maximum allowed size is {{size}} {{unit, anyCase}}",
738
+ "allowedFileTypes": "Allowed file types are {{types}}",
739
+ "oneFileAllowed": "Please upload only 1 file",
740
+ "chooseFileOrDragHere": "Choose file or drag here"
741
+ }
728
742
  }
729
743
  }
730
744
  }
@@ -0,0 +1,84 @@
1
+ import React from "react";
2
+ interface FileObject {
3
+ url: string;
4
+ size?: number;
5
+ name: string;
6
+ }
7
+ export interface FileUploadProps {
8
+ className?: string;
9
+ allowedFileTypes?: string;
10
+ multipleFilesAllowed?: boolean;
11
+ maxFileSize?: number;
12
+ isPreview?: boolean;
13
+ minFileSize?: number;
14
+ files?: FileObject[];
15
+ onChange?: (files: FileObject[] | []) => void;
16
+ error?: string;
17
+ setError?: (error: string) => void;
18
+ setTouched?: (touched: boolean) => void;
19
+ }
20
+ ;
21
+ export interface FormikFileUploadProps extends FileUploadProps {
22
+ name: string;
23
+ }
24
+ ;
25
+ export
26
+ /**
27
+ *
28
+ * The FileUpload component provides an interface for uploading files with drag-and-drop support, real-time previews, and comprehensive error handling.
29
+ *
30
+ * It allows users to configure file types, size limits, and whether multiple files can be uploaded simultaneously.
31
+ *
32
+ * @example
33
+ *
34
+ * import React, { useState } from "react";
35
+ * import { FileUpload } from "@bigbinary/neeto-molecules/FileUpload";
36
+ *
37
+ * const FileUploadComponent = () => {
38
+ * const [files, setFiles] = useState([]);
39
+ * const [error, setError] = useState("");
40
+ *
41
+ * const handleFileChange = (updatedFiles) => {
42
+ * // Perform any custom logic here
43
+ * setFiles(updatedFiles);
44
+ * };
45
+ *
46
+ * return (
47
+ * <FileUpload
48
+ * allowedFileTypes="image/jpeg, image/png"
49
+ * multipleFilesAllowed={true}
50
+ * maxFileSize={5} // in MB
51
+ * minFileSize={1} // in MB
52
+ * files={files}
53
+ * onChange={handleFileChange}
54
+ * error={error}
55
+ * setError={setError}
56
+ * />
57
+ * );
58
+ * };
59
+ *
60
+ * export default FileUploadComponent;
61
+ * @endexample
62
+ * The FileUpload component wrapped in Formik.
63
+ *
64
+ * @example
65
+ *
66
+ * import { FormikFileUpload } from "@bigbinary/neeto-molecules/FileUpload";
67
+ * import { Form } from "@bigbinary/neetoui/formik";
68
+ *
69
+ * const App = () => (
70
+ * return (
71
+ * <Form
72
+ * formikProps={{
73
+ * initialValues: { files: [] },
74
+ * onSubmit: handleSubmit,
75
+ * }}
76
+ * >
77
+ * <FormikFileUpload name="files" />
78
+ * </Form>
79
+ * );
80
+ * );
81
+ * @endexample
82
+ */
83
+ const FileUpload: React.FC<FileUploadProps>;
84
+ export const FormikFileUpload: React.FC<FormikFileUploadProps>;