Skip to content

Commit c0737aa

Browse files
committed
[REF]: Refactor coincidenses of validatefileresponse type
1 parent 25baedd commit c0737aa

File tree

7 files changed

+33
-36
lines changed

7 files changed

+33
-36
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default CodeDemoDropzoneCustomValidation;
3131

3232
const splittedCodeJSButton = ``;
3333
const splittedCodeTSButton = ``;
34-
const completeCodeJSButton =`import { FileInputButton, FileCard } from "@files-ui/react";
34+
const completeCodeJSButton = `import { FileInputButton, FileCard } from "@files-ui/react";
3535
import * as React from "react";
3636
3737
//validate files
@@ -94,16 +94,19 @@ export default function App() {
9494
</div>
9595
);
9696
}`;
97-
const completeCodeTSButton = `import { FileInputButton, FileCard, ExtFile } from "@files-ui/react";
97+
const completeCodeTSButton =
98+
`import { FileInputButton, FileCard, ExtFile } from "@files-ui/react";
9899
import * as React from "react";
99100
100101
//validate files
101102
// file name must start with the following prefix: "test_file"
102103
// (e.g. a valid file name could be "test_file_photo.png")
103-
const myOwnValidation = (file: File): CustomValidateFileResponse => {
104+
const myOwnValidation = (file: File): ValidateFileResponse => {
104105
let errorList: string[] = [];
105106
let validResult: boolean = true;
106-
const regExPrefix: RegExp = /\btest_file\w+/;
107+
` +
108+
// eslint-disable-next-line
109+
`const regExPrefix: RegExp = /\btest_file\w+/;
107110
if (!file.name.match(regExPrefix)) {
108111
validResult = false;
109112
errorList.push('Prefix "test_file" was not present in the file name');
@@ -161,11 +164,11 @@ export default function App() {
161164

162165
/////
163166

164-
165167
const splittedCodeJS = ``;
166168
const splittedCodeTS = ``;
167169
const completeCodeJS = `import { Dropzone, FileMosaic } from "@files-ui/react";
168170
import * as React from "react";
171+
169172
//validate files
170173
// file name must start with the following prefix: "test_file"
171174
// (e.g. a valid file name could be "test_file_photo.png")
@@ -179,6 +182,7 @@ const myOwnValidation = (file) => {
179182
}
180183
return { valid: validResult, errors: errorList };
181184
};
185+
182186
export default function App() {
183187
const [files, setFiles] = React.useState([]);
184188
const updateFiles = (incommingFiles) => {
@@ -204,16 +208,16 @@ export default function App() {
204208
);
205209
}`;
206210

207-
const completeCodeTS = `import { Dropzone, FileMosaic, ExtFile, CustomValidateFileResponse } from "@files-ui/react";
211+
const completeCodeTS = `import { Dropzone, FileMosaic, ExtFile, ValidateFileResponse } from "@files-ui/react";
208212
import * as React from "react";
209213
210214
//validate files
211215
// file name must start with the following prefix: "test_file"
212216
// (e.g. a valid file name could be "test_file_photo.png")
213-
const myOwnValidation = (file: File): CustomValidateFileResponse => {
217+
const myOwnValidation = (file: File): ValidateFileResponse => {
214218
let errorList: string[] = [];
215219
let validResult: boolean = true;
216-
const regExPrefix: RegExp = /\btest_file\w+/;
220+
const regExPrefix: RegExp = /\\btest_file\\w+/;
217221
if (!file.name.match(regExPrefix)) {
218222
validResult = false;
219223
errorList.push('Prefix "test_file" was not present in the file name');

src/components/demo-components/dropzone-demo/DemoDropzoneCustomValidation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import {
44
ExtFile,
55
FileMosaic,
66
FileMosaicProps,
7-
CustomValidateFileResponse,
7+
ValidateFileResponse,
88
FileInputButton,
99
FileCard,
1010
} from "../../../files-ui";
1111

1212
//validate files
1313
// file name must start with the following prefix: "test_file"
1414
// (e.g. a valid file name could be "test_file_photo.png")
15-
const myOwnValidation = (file: File): CustomValidateFileResponse => {
15+
const myOwnValidation = (file: File): ValidateFileResponse => {
1616
let errorList: string[] = [];
1717
let validResult: boolean = true;
1818
const regExPrefix: RegExp = /\btest_file\w+/;

src/data/DropzoneAPIPropsRows.tsx

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ export const DropzoneAPIPropsRows = [
2121
description: (
2222
<>
2323
Probably one of the most important methods (callbacks). Returns as first
24-
parameter an array of `ExtFile` objects.
25-
This callback is fired when the delete
26-
icon is clicked. If set, the delete icon will be shown.
24+
parameter an array of `ExtFile` objects. This callback is fired when the
25+
delete icon is clicked. If set, the delete icon will be shown.
2726
<br />
2827
<strong>Signature:</strong>
2928
<br />
@@ -77,8 +76,8 @@ export const DropzoneAPIPropsRows = [
7776
<br />
7877
<CodeHighlight>
7978
{"(f: File) => "}{" "}
80-
<AnchorToTab href="/api/dropzone#customvalidatefileresponse">
81-
CustomValidateFileResponse
79+
<AnchorToTab href="/api/types#validatefileresponse">
80+
ValidateFileResponse
8281
</AnchorToTab>
8382
</CodeHighlight>
8483
</>
@@ -124,9 +123,7 @@ export const DropzoneAPIPropsRows = [
124123
name: "uploadConfig",
125124
type: (
126125
<TypeHighlight np>
127-
<AnchorToTab href="/api/dropzone#uploadconfig">
128-
UploadConfig
129-
</AnchorToTab>
126+
<AnchorToTab href="/api/types#uploadconfig">UploadConfig</AnchorToTab>
130127
</TypeHighlight>
131128
),
132129
default: <TypeHighlight np></TypeHighlight>,
@@ -314,17 +311,17 @@ export const DropzoneAPIPropsRows = [
314311
name: "actionButtons",
315312
type: (
316313
<TypeHighlight np>
317-
<AnchorToTab href="/api/dropzone#dropzoneactions">
314+
<AnchorToTab href="/api/types#actionbuttons">
318315
ActionButtons
319316
</AnchorToTab>
320317
</TypeHighlight>
321318
),
322319
default: <TypeHighlight np></TypeHighlight>,
323320
description: (
324321
<>
325-
If set, buttons will be added before or after of the component.
326-
This buttons triggresthe common opertions of the component such as
327-
clean, upload, abort and delete all.
322+
If set, buttons will be added before or after of the component. This
323+
buttons triggresthe common opertions of the component such as clean,
324+
upload, abort and delete all.
328325
</>
329326
),
330327
},
@@ -356,9 +353,7 @@ export const DropzoneAPIPropsRows = [
356353
name: "headerConfig",
357354
type: (
358355
<TypeHighlight np>
359-
<AnchorToTab href="/api/dropzone#headerconfig">
360-
HeaderConfig
361-
</AnchorToTab>
356+
<AnchorToTab href="/api/types#headerconfig">HeaderConfig</AnchorToTab>
362357
</TypeHighlight>
363358
),
364359
default: <TypeHighlight np></TypeHighlight>,
@@ -368,9 +363,7 @@ export const DropzoneAPIPropsRows = [
368363
name: "footerConfig",
369364
type: (
370365
<TypeHighlight np>
371-
<AnchorToTab href="/api/dropzone#footerconfig">
372-
FooterConfig
373-
</AnchorToTab>
366+
<AnchorToTab href="/api/types#footerconfig">FooterConfig</AnchorToTab>
374367
</TypeHighlight>
375368
),
376369
default: <TypeHighlight np></TypeHighlight>,

src/data/FileInputButtonPropsRows.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export const FileInputButtonPropsRows=[
7777
<br />
7878
<CodeHighlight>
7979
{"(f: File) => "}{" "}
80-
<AnchorToTab href="/api/dropzone#customvalidatefileresponse">
81-
CustomValidateFileResponse
80+
<AnchorToTab href="/api/types#validatefileresponse">
81+
ValidateFileResponse
8282
</AnchorToTab>
8383
</CodeHighlight>
8484
</>
@@ -103,7 +103,7 @@ export const FileInputButtonPropsRows=[
103103
name: "uploadConfig",
104104
type: (
105105
<TypeHighlight np>
106-
<AnchorToTab href="/api/dropzone#uploadconfig">
106+
<AnchorToTab href="/api/types#uploadconfig">
107107
UploadConfig
108108
</AnchorToTab>
109109
</TypeHighlight>
@@ -245,7 +245,7 @@ export const FileInputButtonPropsRows=[
245245
name: "actionButtons",
246246
type: (
247247
<TypeHighlight np>
248-
<AnchorToTab href="/api/dropzone#dropzoneactions">
248+
<AnchorToTab href="/api/types#actionbuttons">
249249
ActionButtons
250250
</AnchorToTab>
251251
</TypeHighlight>

src/pages/demo/DropzoneDemoPage.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ const DropzoneDemoPage = (props) => {
176176
</AnchorToTab>
177177
{") => "}
178178
<AnchorToTab href="/types#custom-validate-file-response">
179-
CustomValidateFileResponse
179+
ValidateFileResponse
180180
</AnchorToTab>
181181
</CodeHighlight>
182182
. Custom validator can work together with{" "}

src/pages/demo/FileInputButtonDemoPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const FileInputButtonDemoPage: React.FC<FileInputButtonDemoPageProps> = (
168168
</AnchorToTab>
169169
{") => "}
170170
<AnchorToTab href="/types#custom-validate-file-response">
171-
CustomValidateFileResponse
171+
ValidateFileResponse
172172
</AnchorToTab>
173173
</CodeHighlight>
174174
. Custom validator can work together with{" "}

src/pages/types-page/TypesPage.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from "react";
2-
import DescParagraph from "../../components/demo-components/desc-paragraph/DescParagraph";
2+
//import DescParagraph from "../../components/demo-components/desc-paragraph/DescParagraph";
33
import MainContentContainer from "../../components/layout-pages/MainContentContainer";
44
import MainLayoutPage from "../../components/layout-pages/MainLayoutPage";
55
import RightMenuContainer from "../../components/layout-pages/RightMenuContainer";
@@ -43,7 +43,7 @@ const rightMenuItems = [
4343
},
4444
{
4545
id: 2,
46-
label: "CustomValidateFileResponse",
46+
label: "ValidateFileResponse",
4747
referTo: "/types#customvalidatefileresponse",
4848
},
4949
{

0 commit comments

Comments
 (0)