Skip to content

Commit 0e27cc3

Browse files
authored
Merge pull request #12 from files-ui/25-feat-add-dropzone-component-missing-features-and-finish-dropzone-demo-page
25 feat add dropzone component missing features and finish dropzone demo page
2 parents a051c18 + e40d64f commit 0e27cc3

File tree

72 files changed

+3441
-855
lines changed

Some content is hidden

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

72 files changed

+3441
-855
lines changed

bugs.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
- [SOLVED]on change progress the loader is reredered again and again, I think that the 3 states or layers must be there from the begining
66
"preparing", "uploading", "result" - on cancel, the 2nd layer will dissapear, it will not be any big deal
7-
- After uploading, progress must be reiitialized to 0
7+
- [SOLVED] After uploading, progress must be reiitialized to 0
88
- [SOLVED] FileItemMainLayer WORKS STRANGE AT THE TIME NEW fILEiTEM IS ADDED
99

1010

1111
## Dropzone
12-
- When no validation, upload removes all files.
12+
- [SOLVED] When no validation, upload removes all files.
1313

1414
- [SOLVED]: action buttons rendered again and again since they were created again every time "value" prop changed
1515
- [SOLVED]: Uploading works in 2 times (first time stops after setting progress = UPLOADING.progrss), but fails to recover from the manager. [UPDATED]: Problem is at `useDropzoneFileListUpdater.ts` file. The problem is that hook for updating when user wants to interrupt preparing, is called at the begining of the upload process, with value of undefined in all files. It is probably the last update on localFiles outside Dropzone component.
1616

17-
- When file is set from preparing to undefined it can be deleted, however, will appear again if onDelete is called. It would be great to add a reconciliation procedure to support different array sizes in updater hook. Or "canceled" upload status could be added and file Item should not show the "X" button when uploading and canceled. After Upload process, all files with "canceled" upload status should be set to "undefined" again. This can be a workaround.
17+
- [DONE] When file is set from preparing to undefined it can be deleted, however, will appear again if onDelete is called. It would be great to add a reconciliation procedure to support different array sizes in updater hook. Or "canceled" upload status could be added and file Item should not show the "X" button when uploading and canceled. After Upload process, all files with "canceled" upload status should be set to "undefined" again. This can be a workaround. (`Using the extraData for keeping track if a Filemosaic was deleted`)
1818

19-
- [SOLVED] Dropzpne is afected by adding more files as children
19+
- [SOLVED] Dropzone is afected by adding more files as children
2020
- offset should not be used, instead a padding, given header or footer
21-
- When layer is visible, border in the root container must dissapear
21+
- [SOLVED] When layer is visible, border in the root container must dissapear
2222

2323
## Tooltip
2424

features.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- Validate with accept prop
1515
- Validate with maxFileSize prop
1616
- Validate with maxFiles prop
17+
- custom validation
1718

1819
## Read
1920

@@ -31,6 +32,6 @@
3132
- ImagePreview
3233
- VideoPreview
3334
- PDFPreview
34-
- JsonPreview fix rc-highlight
35-
- FullScreenPreview
35+
- JsonPreview [DONE]fix rc-highlight
36+
- FullScreenPreview => FullScreen
3637
- DropLayer

future-features.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# Future Possible Features
22

3+
## DROP
4+
5+
WHen data transfer only text or iimage in string, event
6+
files dissapear in "replace". create a text file in memoory
7+
38
## UTILS
49

510
- custom icons
611
- menu icon for FileItem ( FileOptions (menu collapsed from click in option icon) )
712
- [DONE]: Outside actions or buttons for Dropzone
8-
- [WIP]:header and footer custom props
9-
- FileItem: checkbox support
13+
- [DONE]:header and footer custom props
14+
- [NOT_YET]: FileItem: checkbox support
1015
- [DONE] FileItem: ( smart prop ) detect when width of image is greater than height or viceversa in order to decide the orientation
1116

1217
## Upload

ideas.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
## Phrases
1010

11-
- Stop pain with developing a complex widget, don't need to create a file upload component from scratch
12-
- If you need to do it from scratch, there is an example [show some basic code] Bellow main page component
11+
- Stop pain with developing a complex widget, don't need to create a file upload component from scratch [landingpage_section_3]
12+
- If you need to do it from scratch, there is an example [show some basic code] Bellow main page component[landing_sec_3_pat_2]
1313

1414

1515

1616
## MIgrating from dropzone-ui
17+
[landing_Sec_3_or_4]
1718

1819
## Migrating from react-dropzone
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export type DescParagraphProps = {
2-
content?:string;
3-
children?:React.ReactNode;
4-
margin?:string;
5-
darkMode?:boolean;
2+
content?: string;
3+
children?: React.ReactNode;
4+
margin?: string;
5+
darkMode?: boolean;
66
}

src/components/demo-components/dropzone-demo/AdvancedDropzoneDemo.jsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
FullScreen,
77
ImagePreview,
88
VideoPreview,
9-
109
} from "../../../files-ui";
1110
import { useEffect, useState } from "react";
1211
import axios from "axios";
@@ -20,13 +19,14 @@ export default function AdvancedDropzoneDemo() {
2019
const [videoSrc, setVideoSrc] = React.useState(undefined);
2120

2221
const updateFiles = (incommingFiles) => {
23-
console.log("incomming extFiles", incommingFiles);
24-
const arrExtFIleInstances = incommingFiles.map(
22+
console.log("incomming extFiles outside", incommingFiles.map(x=>x.uploadStatus));
23+
24+
const arrExtFIleInstances = incommingFiles.map(
2525
(extFile) => new ExtFileInstance(extFile)
2626
);
27-
27+
2828
console.log("incomming arrExtFIleInstances", arrExtFIleInstances);
29-
/* const listExtFileObjects = arrExtFIleInstances.map((extFileInstance) =>
29+
/* const listExtFileObjects = arrExtFIleInstances.map((extFileInstance) =>
3030
extFileInstance.toExtFile()
3131
);
3232
@@ -40,11 +40,12 @@ export default function AdvancedDropzoneDemo() {
4040
const handleSee = (imageSource) => {
4141
setImageSrc(imageSource);
4242
};
43-
/* const onClean = () => {
44-
setExtFiles(extFiles.filter((ef) => ef.valid !== false));
45-
}; */
43+
44+
const handleStart = (res) => {
45+
console.log("advanced demo start upload", res);
46+
};
4647
const handleFinish = (res) => {
47-
console.log("finish", res);
48+
console.log("advanced demo finish upload", res);
4849
};
4950
const handleWatch = (videoSource) => {
5051
console.log(
@@ -106,6 +107,7 @@ export default function AdvancedDropzoneDemo() {
106107
//url: "http://localhost:2800/file/28048465460",
107108
cleanOnUpload: true,
108109
}}
110+
onUploadStart={handleStart}
109111
onUploadFinish={handleFinish}
110112
//fakeUpload
111113
actionButtons={{

src/components/demo-components/dropzone-demo/BasicDropzoneCodeJS.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export default function BasicDemoDropzone() {
4747
};
4848
return (
4949
<Dropzone
50-
style={{ minWidth: "505px" }}
5150
onChange={updateFiles}
5251
value={files}
5352
>
@@ -74,7 +73,6 @@ export default function BasicDemoDropzone() {
7473
};
7574
return (
7675
<Dropzone
77-
style={{ minWidth: "505px" }}
7876
onChange={updateFiles}
7977
value={files}
8078
>

src/components/demo-components/dropzone-demo/BasicDropzoneDemo.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Dropzone } from "../../../files-ui";
2-
import { FileMosaic } from "../../../files-ui/components/file-mosaic";
1+
import { Dropzone, FileMosaic } from "../../../files-ui";
32
import * as React from "react";
43
export default function BasicDemoDropzone() {
54
const [files, setFiles] = React.useState([]);
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import ShowDemoCode from "../../show-demo-code/ShowDemoCode";
2+
const CodeDemoDropzoneActionButtons = ({ splittedOnly = false }) => {
3+
return (
4+
<ShowDemoCode
5+
splittedOnly={splittedOnly}
6+
codeCompleteJS={completeCodeJS}
7+
codeCompleteTS={completeCodeTS}
8+
codeSandboxJS="https://codesandbox.io/s/dropzone-ui-basic-3j01v"
9+
codeSandboxTS="https://codesandbox.io/s/dropzone-ui-basic-3j01v"
10+
codeSplittedJS={splittedCodeJS}
11+
codeSplittedTS={splittedCodeTS}
12+
/>
13+
);
14+
};
15+
export default CodeDemoDropzoneActionButtons;
16+
17+
const splittedCodeJS = `<Dropzone
18+
onChange={updateFiles}
19+
value={files}
20+
autoClean
21+
uploadConfig={{ url: "https://www.myawsomeserver.com/upload" }}
22+
fakeUpload
23+
actionButtons={{
24+
position: "bottom",
25+
uploadButton: { style: { textTransform: "uppercase" } },
26+
abortButton: {},
27+
cleanButton: {},
28+
deleteButton: {},
29+
}}
30+
>
31+
{files.length > 0 &&
32+
files.map((file) => (
33+
<FileMosaic key={file.id} {...file} onDelete={removeFile} info/>
34+
))}
35+
</Dropzone>`;
36+
const splittedCodeTS = `<Dropzone
37+
onChange={updateFiles}
38+
value={files}
39+
autoClean
40+
uploadConfig={{ url: "https://www.myawsomeserver.com/upload" }}
41+
fakeUpload
42+
actionButtons={{
43+
position: "bottom",
44+
uploadButton: { style: { textTransform: "uppercase" } },
45+
abortButton: {},
46+
cleanButton: {},
47+
deleteButton: {},
48+
}}
49+
>
50+
{files.length > 0 &&
51+
files.map((file: ExtFile) => (
52+
<FileMosaic key={file.id} {...file} onDelete={removeFile} info/>
53+
))}
54+
</Dropzone>`;
55+
const completeCodeJS = `import * as React from "react";
56+
import { Dropzone, FileMosaic } from "@files-ui/react";
57+
58+
export default function App() {
59+
const [files, setFiles] = React.useState([]);
60+
const updateFiles = (incommingFiles) => {
61+
//do something with the files
62+
setFiles(incommingFiles);
63+
//even your own upload implementation
64+
};
65+
const removeFile = (id) => {
66+
setFiles(files.filter((x) => x.id !== id));
67+
};
68+
return (
69+
<Dropzone
70+
onChange={updateFiles}
71+
value={files}
72+
autoClean
73+
uploadConfig={{ url: "https://www.myawsomeserver.com/upload" }}
74+
fakeUpload
75+
actionButtons={{
76+
position: "bottom",
77+
uploadButton: { style: { textTransform: "uppercase" } },
78+
abortButton: {},
79+
cleanButton: {},
80+
deleteButton: {},
81+
}}
82+
>
83+
{files.length > 0 &&
84+
files.map((file) => (
85+
<FileMosaic key={file.id} {...file} onDelete={removeFile} info />
86+
))}
87+
</Dropzone>
88+
);
89+
};`;
90+
91+
const completeCodeTS = `import * as React from "react";
92+
import { Dropzone, FileMosaic, ExtFile } from "@files-ui/react";
93+
94+
export default function App() {
95+
const [files, setFiles] = React.useState<ExtFile[]>([]);
96+
const updateFiles = (incommingFiles:ExtFile[]) => {
97+
//do something with the files
98+
setFiles(incommingFiles);
99+
//even your own upload implementation
100+
};
101+
const removeFile = (id: string | number | undefined) => {
102+
setFiles(files.filter((x: ExtFile) => x.id !== id));
103+
};
104+
return (
105+
<Dropzone
106+
onChange={updateFiles}
107+
value={files}
108+
autoClean
109+
uploadConfig={{ url: "https://www.myawsomeserver.com/upload" }}
110+
fakeUpload
111+
actionButtons={{
112+
position: "bottom",
113+
uploadButton: { style: { textTransform: "uppercase" } },
114+
abortButton: {},
115+
cleanButton: {},
116+
deleteButton: {},
117+
}}
118+
>
119+
{files.length > 0 &&
120+
files.map((file:ExtFile) => (
121+
<FileMosaic key={file.id} {...file} onDelete={removeFile} info />
122+
))}
123+
</Dropzone>
124+
);
125+
}`;

0 commit comments

Comments
 (0)