Skip to content

Commit 61be4ad

Browse files
committed
[BUILD]: build version 5.0.0
1 parent 6cf6bfc commit 61be4ad

27 files changed

Lines changed: 1848 additions & 1809 deletions

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.github
22
.storybook
3-
example
3+
examples
44
node_modules
55
storybook-static
66
src

build/components/dropzone/components/Dropzone/DropzoneProps.d.ts

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { OverridableProps } from "@unlimited-react-components/kernel";
22
import { Localization } from "../../../../localization/localization";
33
import { 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";
56
export 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
}
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
import { DropzoneProps } from "../Dropzone/DropzoneProps";
22
import { FileValidated } from "./validation.utils";
3-
export declare const uploadPromiseAxios: (file: FileValidated, url: string, method: DropzoneProps["method"], config: any) => Promise<FileValidated>;
3+
export declare const uploadPromiseAxios: (file: FileValidated, url: string, method: DropzoneProps["method"], config: any) => Promise<UploadPromiseAxiosResponse>;
4+
export interface UploadPromiseAxiosResponse {
5+
serverResponse: FileDuiResponse;
6+
uploadedFile: FileValidated;
7+
}
8+
export interface FileDuiResponse {
9+
id: number | string | undefined;
10+
serverResponse: DropzoneUIResponse | {};
11+
}
12+
export interface DropzoneUIResponse {
13+
status: boolean;
14+
message: string;
15+
payload: any;
16+
}
417
/**
518
* In construction
619
*/

build/components/dropzone/components/utils/errors.utils.d.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

build/components/dropzone/components/utils/validation.utils.d.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
import { LocalLabels } from "../../../../localization/localization";
2+
export declare enum UPLOADSTATUS {
3+
uploading = "uploading",
4+
success = "success",
5+
error = "error"
6+
}
17
export interface FileValidated {
28
file: File;
39
valid: boolean;
4-
id: number;
10+
id: number | string | undefined;
511
errors?: string[];
612
uploadMessage?: string;
7-
uploadStatus?: undefined | "uploading" | "success" | "error";
13+
uploadStatus?: undefined | UPLOADSTATUS;
814
}
915
export interface FileValidator {
1016
maxFileSize?: number;
@@ -30,16 +36,37 @@ export declare const validateAccept: (accept: string[], file: File) => boolean;
3036
* @param validator the validator object
3137
* @returns a FileValidated object
3238
*/
33-
export declare const validateFile: (file: File, validator: FileValidator) => FileValidated;
39+
export declare const validateFile: (file: File, validator: FileValidator, localErrors: LocalLabels) => FileValidated;
40+
export interface CustomValidateFileResponse {
41+
valid: boolean;
42+
errors?: string[];
43+
}
3444
/**
3545
* Function that validate whether afile is valid or not
3646
* according to the Filevalidator properties
3747
* @param file
3848
* @param validator
3949
* @returns
4050
*/
41-
export declare const customValidateFile: (file: File, validator: (f: File) => boolean) => FileValidated;
51+
export declare const customValidateFile: (file: File, validator: (f: File) => CustomValidateFileResponse) => FileValidated;
52+
/**
53+
* An id generaor
54+
*/
4255
export declare abstract class FileIdGenerator {
4356
static nextId: number;
57+
/**
58+
* INcreases the id conter and returns the next id available.
59+
* @returns the next integer id available
60+
*/
4461
static getNextId(): number;
4562
}
63+
/**
64+
* Make a validated file that is ready to use on FileItem component,
65+
* if valid is not set, a random operation will decide whether the file is valid or not
66+
* @param file The file
67+
* @param valid true if it is a valid file, otherwise is false
68+
* @param uploadStatus the current upload status. If not given a random upload status will be set
69+
* @param uploadMessage the upload message after uploading
70+
* @returns a Vaidated File object
71+
*/
72+
export declare const makeSynthticFileValidate: (file: File, valid?: boolean, uploadStatus?: UPLOADSTATUS, uploadMessage?: string) => FileValidated;

build/components/file-item/components/FileItem/FileItemProps.d.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ export interface FileItemProps extends PaperProps {
3030
/**
3131
* A function of what to do when close button is pressed or clicked
3232
*/
33-
onDelete?: Function;
33+
onDelete?: (imageUrl: number | string | undefined) => void;
3434
/**
3535
* A function of what to do when "see" button is pressed or clicked
3636
*/
37-
onSee?: Function;
37+
onSee?: (imageUrl: string) => void;
3838
/**
3939
* Whether to see as grid or inline (horizontal list)
4040
*/
41+
errors?: string[];
4142
/**
4243
* individual validator for each file
4344
*/
@@ -59,8 +60,8 @@ export interface FileItemProps extends PaperProps {
5960
*/
6061
valid?: boolean;
6162
/**
62-
* This feature is hidden, it is not present on documentation
63-
* because is experimental. If you found this prop, you can test it
63+
* This feature is hidden, it is not present on the documentation
64+
* because it's experimental. If you found this prop, you can test it
6465
* and comment us if any issue is found. Thanks in advance.
6566
*
6667
* Make file name, info layer, size and "valid message"
@@ -73,6 +74,12 @@ export interface FileItemProps extends PaperProps {
7374
* Only works when given a image file
7475
*/
7576
info?: boolean;
77+
/**
78+
* A string representation or web url of the image
79+
* that will be set to the "src" prop of an <img/> tag
80+
* <img src={`${url}`} />
81+
*/
82+
imageUrl?: string;
7683
/**
7784
* The message from server
7885
*/

build/components/file-item/components/FileItemFullInfoLayer/FileItemFullInfoLayer.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ export interface FileItemFullInfoLayerProps {
1717
* only English and Spanish is supported
1818
*/
1919
localization?: Localization;
20+
errors?: string[];
2021
}

build/components/file-item/utils/utils.files.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ export declare const getExt: (fileName: string) => string;
3131
* @param word
3232
* @returns
3333
*/
34-
export declare const shrinkWord: (word: string) => string;
34+
export declare const shrinkWord: (word?: string) => string;

build/components/input-button/InputButtonProps.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { MaterialButtonProps } from "@unlimited-react-components/material-button";
2+
import { Localization } from "../../localization/localization";
3+
import { CustomValidateFileResponse } from "../dropzone/components/utils/validation.utils";
24
export interface InputButtonProps extends MaterialButtonProps {
35
/**
46
* the id of the component
@@ -28,14 +30,20 @@ export interface InputButtonProps extends MaterialButtonProps {
2830
* must be a function that recieves as first parameter a File Object
2931
* and must return a boolean value
3032
*/
31-
validator?: (f: File) => boolean;
33+
validator?: (f: File) => CustomValidateFileResponse;
3234
/**
3335
* Max number of files to be accepted.
3436
*/
3537
/**
3638
* max file size allowed in bytes
3739
*/
3840
maxFileSize?: number;
41+
/**
42+
* language to be used
43+
* for now
44+
* only English, French , Portuguese and Spanish are supported
45+
*/
46+
localization?: Localization;
3947
}
4048
/**
4149
* The default props when not given

build/index.d.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
import { createPDF, createWord } from "./utils/files.utils";
2-
export { createPDF, createWord };
1+
import { createPDF, createWord, createListOfMultiTypeFile } from "./utils/files.utils";
2+
import { makeSynthticFileValidate } from "./components/dropzone/components/utils/validation.utils";
3+
import { UploadPromiseAxiosResponse, FileDuiResponse, DropzoneUIResponse } from "./components/dropzone/components/utils/dropzone-ui.upload.utils";
4+
import { FileValidated, UPLOADSTATUS } from "./components/dropzone/components/utils/validation.utils";
5+
export declare type UploadPromiseAxiosResponseType = UploadPromiseAxiosResponse;
6+
export declare type FileDuiResponseType = FileDuiResponse;
7+
export declare type DropzoneUIResponseType = DropzoneUIResponse;
8+
export declare type FileValidatedType = FileValidated;
9+
export { createPDF, createWord, createListOfMultiTypeFile, makeSynthticFileValidate, UPLOADSTATUS };
310
export { default as Dropzone } from "./components/dropzone/components/Dropzone/Dropzone";
411
export * from "./components/dropzone/components/Dropzone/Dropzone";
512
export { default as DropzoneLabel } from "./components/dropzone/components/DropzoneLabel/DropzoneLabel";

0 commit comments

Comments
 (0)