Skip to content

Commit 15fa91f

Browse files
committed
[BUILD]: make version 6.3.1
1 parent d824d5e commit 15fa91f

File tree

87 files changed

+1910
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1910
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from "react";
2+
import "./Dropzone.scss";
3+
import { DropzoneProps } from "./DropzoneProps";
4+
declare const Dropzone: React.FC<DropzoneProps>;
5+
export default Dropzone;
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
import { OverridableProps } from "@unlimited-react-components/kernel";
2+
import { Localization } from "../../../../localization/localization";
3+
import { FileItemContainerProps } from "../../../file-item/components/FileItemContainer/FileItemContainerProps";
4+
import { FileDuiResponse } from "../utils/dropzone-ui.upload.utils";
5+
import { CustomValidateFileResponse, FileValidated } from "../utils/validation.utils";
6+
export interface DropzoneProps extends OverridableProps {
7+
/**
8+
* This event is triggered when files are dropped or selected.
9+
* Returns as first parameter the list of FileValidate files dropped or selected.
10+
*/
11+
onDrop?: (filesDropped: FileValidated[]) => void;
12+
/**
13+
* server Url or endpoint to upload the files
14+
*/
15+
url?: string;
16+
/**
17+
* upload method, can be POST | PUT | PATCH
18+
*/
19+
method?: "POST" | "PUT" | "PATCH";
20+
/**
21+
* Extra configuration for uploading
22+
* e.g. headers or bearer token
23+
* default:
24+
* config = {
25+
* headers: {
26+
* "content-type": "multipart/form-data",
27+
* },
28+
* }
29+
*
30+
*/
31+
config?: Object;
32+
/**
33+
* If true, onDrop event will return the list of files, but also
34+
* will upload the files if url was set, and also config
35+
*/
36+
uploadOnDrop?: boolean;
37+
/**
38+
* Max number of files to be accepted.
39+
*/
40+
maxFiles?: number;
41+
/**
42+
* max file size allowed in bytes
43+
*/
44+
maxFileSize?: number;
45+
/**
46+
* If true, the dropzone component itself will be clickable
47+
*/
48+
clickable?: boolean;
49+
/**
50+
* Extra featur to perform on click
51+
* Only if clickable was set to true
52+
*/
53+
onClick?: Function;
54+
/**
55+
* The default implementation of accept
56+
* checks the file's mime type or extension
57+
* against this list. This is a comma
58+
* separated list of mime types or file extensions.
59+
* Eg.: image/*,application/pdf,.psd
60+
*/
61+
accept?: string;
62+
/**
63+
* If true, files that does not match accept
64+
* criteria will be ignored
65+
*/
66+
removeOnDrop?: boolean;
67+
/**
68+
* If present, delete all butoon will be visible
69+
* and will trigger this function onClick
70+
*/
71+
onReset?: Function;
72+
/**
73+
* if true, will show a ripple everytime
74+
* the user drops files os selects files
75+
*/
76+
disableRipple?: boolean;
77+
/**
78+
* The background color for dropzone,
79+
* by default is linear-gradient(to bottom, aliceblue,#b7a8a8)
80+
*/
81+
backgroundColor?: string;
82+
/**
83+
* custom validator
84+
* must be a function that recieves as first parameter a File Object
85+
* and must return a boolean value
86+
*/
87+
validator?: (f: File) => CustomValidateFileResponse;
88+
/**
89+
* The current number of valid files
90+
*/
91+
/**
92+
* If present will make change view visible
93+
* and also return the selected view mode
94+
*/
95+
onChangeView?: Function;
96+
/**
97+
* The current view
98+
*/
99+
view?: FileItemContainerProps["view"];
100+
/**
101+
* The max height of the container
102+
* in string format
103+
* by default "500px"
104+
*
105+
* examples:
106+
* "50vh"
107+
* "20%"
108+
* "40em"
109+
* "1rem"
110+
*/
111+
maxHeight?: string;
112+
/**
113+
* The max height of the container
114+
* in string format
115+
* by default "500px"
116+
*
117+
* examples:
118+
* "50vh"
119+
* "20%"
120+
* "40em"
121+
* "1rem"
122+
*/
123+
minHeight?: string;
124+
/**
125+
* if true, shows the dropzone footer
126+
*/
127+
footer?: boolean;
128+
/**
129+
* if true, shows the dropzone footer
130+
*/
131+
header?: boolean;
132+
/**
133+
* Just like any other input component
134+
* the value prop is the current value
135+
*/
136+
value?: FileValidated[];
137+
/**
138+
* This event is triggered when upload process starts
139+
* also returns the list of files that will be uploaded,
140+
* Unlike Onchange, onUploadStart will only return a list of files thta are candidates to be uploaded,
141+
* in case they are valid or upload status is "error"
142+
*/
143+
onUploadStart?: (files: FileValidated[]) => void;
144+
/**
145+
* This event returns as first aparameter the list of responses for each file following the structure:
146+
* responses = [
147+
* {id: <the file id>, serverResponse: the server response}
148+
* ]
149+
*/
150+
onUploadFinish?: (responses: FileDuiResponse[]) => void;
151+
/**
152+
* A message to show in the footer when the uploading process happens
153+
*/
154+
uploadingMessage?: string;
155+
/**
156+
* Probably one of the most important methods.
157+
* Onchange returns as first parameter the list of validated files,
158+
* following the structure:
159+
* file =
160+
* {
161+
* file: File;
162+
* valid: boolean;
163+
* id: number | string | undefined;
164+
* errors?: string[];
165+
* uploadMessage?: string;
166+
* uploadStatus?: undefined | "uploading", success, error;
167+
* }
168+
*
169+
* This event is also triggered when upload starts and when upload
170+
* finishes for each file in order to update the props on very FIleItem
171+
*/
172+
onChange?: (files: FileValidated[]) => void;
173+
/**
174+
* This event is triggered when "clean button is clicked"
175+
* Retuns as first parameter the list of files without not valid files
176+
*/
177+
onClean?: (files: FileValidated[]) => void;
178+
/**
179+
* The behaviuor on drop files
180+
*/
181+
behaviour?: "add" | "replace";
182+
/**
183+
* Label to place when no files selected
184+
*/
185+
label?: string;
186+
/**
187+
* Use this prop only in development mode
188+
* This will make dropzone to simulate a server upload
189+
*/
190+
fakeUploading?: boolean;
191+
/**
192+
* language to be used
193+
* for now
194+
* only English, French , Portuguese, Chinnese (traditional and simplyfied) and Spanish are supported
195+
*/
196+
localization?: Localization;
197+
/**
198+
* if present or true, removes scrolls
199+
* and sets the Dropzone in a grid view
200+
*/
201+
disableScroll?: boolean;
202+
}
203+
export declare const DropzonePropsDefault: DropzoneProps;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { FC } from "react";
2+
import { DropzoneFooterProps } from "./DropzoneFooterProps";
3+
declare const DropzoneFooter: FC<DropzoneFooterProps>;
4+
export default DropzoneFooter;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Localization } from "../../../../localization/localization";
2+
export interface DropzoneFooterProps {
3+
accept?: string;
4+
message?: string;
5+
/**
6+
* language to be used
7+
* for now
8+
* only English and Spanish is supported
9+
*/
10+
localization?: Localization;
11+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { FC } from "react";
2+
import { Localization } from "../../../../localization/localization";
3+
import { FileItemContainerProps } from "../../../file-item/components/FileItemContainer/FileItemContainerProps";
4+
export interface DropzoneHeaderProps {
5+
maxFileSize?: number;
6+
numberOfValidFiles?: number;
7+
maxFiles?: number;
8+
onReset?: Function;
9+
view: FileItemContainerProps["view"];
10+
onChangeView?: Function;
11+
onUploadStart?: Function;
12+
urlPresent?: boolean;
13+
onClean?: Function;
14+
onUploadingStart?: boolean;
15+
/**
16+
* language to be used
17+
* for now
18+
* only English and Spanish is supported
19+
*/
20+
localization?: Localization;
21+
hideViewIcon?: boolean;
22+
}
23+
declare const DropzoneHeader: FC<DropzoneHeaderProps>;
24+
export default DropzoneHeader;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React, { FC } from "react";
2+
export interface DropzoneLabelProps {
3+
children: React.ReactNode | string;
4+
}
5+
declare const DropzoneLabel: FC<DropzoneLabelProps>;
6+
export default DropzoneLabel;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
*
3+
* @param color The color theme
4+
* @param backgroundColor the background Color
5+
* @param maxHeight the max heigth for dropzone container
6+
* @param minHeight the min heigth for dropzone container
7+
* @returns a valid classnname for the component
8+
*/
9+
declare const useDropzoneStyles: (color: string | undefined, backgroundColor: string | undefined, maxHeight: string | undefined, minHeight: string | undefined) => string;
10+
export default useDropzoneStyles;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { DropzoneProps } from "../Dropzone/DropzoneProps";
2+
import { FileValidated } from "./validation.utils";
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+
}
17+
/**
18+
* In construction
19+
*/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference types="react" />
2+
export declare function createRipple<T extends HTMLButtonElement | HTMLAnchorElement | HTMLDivElement>(event: React.MouseEvent<T, MouseEvent>, color: string): void;
3+
export declare function createRippleFromElement<T extends HTMLButtonElement | HTMLAnchorElement | HTMLDivElement>(element: HTMLDivElement | null, event: React.MouseEvent<T, MouseEvent>, color: string): void;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { createRipple } from "./dropzone-ui.utils";
2+
export { createRipple, };

0 commit comments

Comments
 (0)