Skip to content

Commit 802b319

Browse files
committed
[MVP Dropzone ui]
1 parent ca7e4a0 commit 802b319

148 files changed

Lines changed: 870 additions & 25 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
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 DropzoneUI: React.FC<DropzoneProps>;
5+
export default DropzoneUI;
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { OverridableProps } from "@unlimited-react-components/kernel";
2+
import { FileListProps } from "../../../file-item/components/FileList/FileListProps";
3+
export interface DropzoneProps extends OverridableProps {
4+
/**
5+
* What to do when Drop event is triggered
6+
* In most cases is to retrieve the list of files validated
7+
*/
8+
onDrop?: Function;
9+
/**
10+
* Upload Url or endpoint
11+
*/
12+
url?: string;
13+
/**
14+
* upload method, can be POST | PUT | PATCH
15+
*/
16+
method?: "POST" | "PUT" | "PATCH";
17+
/**
18+
* Extra configuration for uploading
19+
* e.g. headers or token bearer
20+
*/
21+
config?: Object;
22+
/**
23+
* If true, onDrop event will return the list of files, but also
24+
* will upload the files if url was set, and also config
25+
*/
26+
uploadOnDrop?: boolean;
27+
/**
28+
* Max number of files to be accepted.
29+
*/
30+
maxFiles?: number;
31+
/**
32+
* max file size allowed in bytes
33+
*/
34+
maxFileSize?: number;
35+
/**
36+
* If true, the dropzone component itself will be clickable
37+
*/
38+
clickable?: boolean;
39+
/**
40+
* Extra featur to perform on click
41+
* Only if clickable was set to true
42+
*/
43+
onClick?: Function;
44+
/**
45+
* The default implementation of accept
46+
* checks the file's mime type or extension
47+
* against this list. This is a comma
48+
* separated list of mime types or file extensions.
49+
* Eg.: image/*,application/pdf,.psd
50+
*/
51+
accept?: string;
52+
/**
53+
* If true, files that does not match accept
54+
* criteria will be ignored
55+
*/
56+
removeOnDrop?: boolean;
57+
/**
58+
* If present, delete all butoon will be visible
59+
* and will trigger this function onClick
60+
*/
61+
onReset?: Function;
62+
/**
63+
* if true, will show a ripple everytime
64+
* the user drops files os selects files
65+
*/
66+
disableRipple?: boolean;
67+
/**
68+
* The background color for dropzone,
69+
* by default is linear-gradient(to bottom, aliceblue,#b7a8a8)
70+
*/
71+
backgroundColor?: string;
72+
/**
73+
* custom validator
74+
* must be a function that recieves as first parameter a File Object
75+
* and must return a boolean value
76+
*/
77+
validator?: any;
78+
/**
79+
* The current number of valid files
80+
*/
81+
numberOfValidFiles?: number;
82+
/**
83+
* If present will make change view visible
84+
* and also return the selected view mode
85+
*/
86+
onChangeView?: Function;
87+
/**
88+
* The current view
89+
*/
90+
view?: FileListProps["view"];
91+
/**
92+
* The max height of the container
93+
* in string format
94+
* by default "500px"
95+
*
96+
* examples:
97+
* "50vh"
98+
* "20%"
99+
* "40em"
100+
* "1rem"
101+
*/
102+
maxHeight?: string;
103+
}
104+
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface DropzoneFooterProps {
2+
accept?: string;
3+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { FC } from "react";
2+
import { FileListProps } from "../../../file-item/components/FileList/FileListProps";
3+
export interface DropzoneHeaderProps {
4+
maxFileSize: number | undefined;
5+
numberOfValidFiles: number | undefined;
6+
maxFiles: number | undefined;
7+
onReset: Function | undefined;
8+
handleReset: Function;
9+
view: FileListProps["view"];
10+
onChangeView: Function | undefined;
11+
}
12+
declare const DropzoneHeader: FC<DropzoneHeaderProps>;
13+
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare const useDropzoneStyles: (color: string | undefined, backgroundColor: string | undefined, maxHeight: string | undefined) => string;
2+
export default useDropzoneStyles;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="react" />
2+
export declare function createRipple<T extends HTMLButtonElement | HTMLAnchorElement | HTMLDivElement>(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+
export declare const ERROR_MAX_SIZE: (maxSize: number) => string;
2+
export declare const ERROR_ACCEPT = "File's type is not allowed";
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)