11import { OverridableProps } from "@unlimited-react-components/kernel" ;
22import { Localization } from "../../../../localization/localization" ;
33import { FileItemContainerProps } from "../../../file-item/components/FileItemContainer/FileItemContainerProps" ;
4- import { FileValidated } from "../utils/validation.utils" ;
4+ import { FileDuiResponse } from "../utils/dropzone-ui.upload.utils" ;
5+ import { CustomValidateFileResponse , FileValidated } from "../utils/validation.utils" ;
56export interface DropzoneProps extends OverridableProps {
67 /**
7- * What to do when Drop event is triggered
8- * In most cases is to retrieve the list of files validated
8+ * This event is triggered when files are dropped or selected. Returns as first parameter the list of FileValidate files dropped or selected.
99 */
10- onDrop ?: Function ;
10+ onDrop ?: ( filesDropped : FileValidated [ ] ) => void ;
1111 /**
1212 * Upload Url or endpoint
1313 */
@@ -76,7 +76,7 @@ export interface DropzoneProps extends OverridableProps {
7676 * must be a function that recieves as first parameter a File Object
7777 * and must return a boolean value
7878 */
79- validator ?: ( f : File ) => boolean ;
79+ validator ?: ( f : File ) => CustomValidateFileResponse ;
8080 /**
8181 * The current number of valid files
8282 */
@@ -115,16 +115,39 @@ export interface DropzoneProps extends OverridableProps {
115115 */
116116 value ?: FileValidated [ ] ;
117117 /**
118- * In both cases of uploading (onDropUpload, or with clicking upload button)
119- * This event is the result one by one of the uploading process
118+ * This event is triggered when upload process starts
119+ * also returns the list of files that will be uploaded,
120+ * Unlike Onchange, onUploadStart will only return a list of files thta are candidates to be uploaded,
121+ * in case they are valid or upload status is "error"
120122 */
121- onUploading ?: ( files : FileValidated [ ] ) => void ;
123+ onUploadStart ?: ( files : FileValidated [ ] ) => void ;
124+ /**
125+ * This event returns as first aparameter the list of responses for each file following the structure:
126+ * responses = [
127+ * {id: <the file id>, serverResponse: the server response}
128+ * ]
129+ */
130+ onUploadFinish ?: ( responses : FileDuiResponse [ ] ) => void ;
122131 /**
123132 * A message to show in the footer when the uploading process happens
124133 */
125134 uploadingMessage ?: string ;
126135 /**
127- * The onChange Event occurs when the value is changed
136+ * Probably one of the most important methods.
137+ * Onchange returns as first parameter the list of validated files,
138+ * following the structure:
139+ * file =
140+ * {
141+ * file: File;
142+ * valid: boolean;
143+ * id: number | string | undefined;
144+ * errors?: string[];
145+ * uploadMessage?: string;
146+ * uploadStatus?: undefined | "uploading", success, error;
147+ * }
148+ *
149+ * This event is also triggered when upload starts and when upload
150+ * finishes for each file in order to update the props on very FIleItem
128151 */
129152 onChange ?: ( files : FileValidated [ ] ) => void ;
130153 /**
@@ -143,7 +166,7 @@ export interface DropzoneProps extends OverridableProps {
143166 /**
144167 * language to be used
145168 * for now
146- * only English, French and Spanish are supported
169+ * only English, French , Portuguese and Spanish are supported
147170 */
148171 localization ?: Localization ;
149172}
0 commit comments