Skip to content

Commit d126df9

Browse files
committed
[REF]: Refactored type name
1 parent a58ac3c commit d126df9

File tree

7 files changed

+59
-24
lines changed

7 files changed

+59
-24
lines changed

src/files-ui/components/dropzone/components/DropzoneButtons/DropzoneButtons.tsx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import * as React from "react";
22
import { addClassName, Localization } from "../../../../core";
33
import { MaterialButton } from "../../../material-button";
4-
import {
5-
ActionButtonItem,
6-
DropzoneActions,
7-
} from "../dropzone/DropzoneProps";
4+
import { ActionButtonItem, DropzoneActions } from "../dropzone/DropzoneProps";
85
import "./DropzoneButtons.scss";
96

107
interface DropzoneButtonsProps extends DropzoneActions {
@@ -38,22 +35,38 @@ const DropzoneButtons: React.FC<DropzoneButtonsProps> = (
3835

3936
const actionButtonsList: ActionButtonItem[] = [
4037
cleanButton
41-
? { ...cleanButton, label: "Clean", onClick: onClean }
38+
? {
39+
...cleanButton,
40+
label: "Clean",
41+
onClick: cleanButton.onClick || onClean,
42+
}
4243
: undefined,
4344
deleteButton
44-
? { ...deleteButton, label: "Delete", onClick: onDelete }
45+
? {
46+
...deleteButton,
47+
label: "Delete",
48+
onClick: deleteButton.onClick || onDelete,
49+
}
4550
: undefined,
4651
uploadButton
47-
? { ...uploadButton, label: "Upload", onClick: onUpload }
52+
? {
53+
...uploadButton,
54+
label: "Upload",
55+
onClick: uploadButton.onClick || onUpload,
56+
}
4857
: undefined,
4958
abortButton
50-
? { ...abortButton, label: "Abort", onClick: onAbort }
59+
? {
60+
...abortButton,
61+
label: "Abort",
62+
onClick: abortButton.onClick || onAbort,
63+
}
5164
: undefined,
5265
].filter(
5366
(ab: ActionButtonItem | undefined) => ab !== undefined
5467
) as ActionButtonItem[];
5568

56-
const tailClassName:string = `${top ? " top" : " bottom"}`;
69+
const tailClassName: string = `${top ? " top" : " bottom"}`;
5770
const finalClassName = addClassName(
5871
"files-ui-buttons-container" + tailClassName,
5972
containerClassName
@@ -71,7 +84,7 @@ const DropzoneButtons: React.FC<DropzoneButtonsProps> = (
7184
className={className}
7285
style={style}
7386
resetStyles={resetStyles}
74-
onClick={() => onClick?.()}
87+
onClick={(evt) => onClick?.(evt)}
7588
disabled={disabled}
7689
>
7790
{children || label}

src/files-ui/components/dropzone/components/dropzone/Dropzone.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
690690

691691
return (
692692
<React.Fragment>
693-
{actionButtonsPosition === "top" && (
693+
{actionButtonsPosition === "before" && (
694694
<DropzoneButtons
695695
disabled={disabled}
696696
abortButton={isUploading ? abortButton : undefined}
@@ -828,7 +828,7 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
828828
/>
829829
</div>
830830

831-
{actionButtonsPosition === "bottom" && (
831+
{actionButtonsPosition === "after" && (
832832
<DropzoneButtons
833833
disabled={disabled}
834834
abortButton={isUploading ? abortButton : undefined}

src/files-ui/components/dropzone/components/dropzone/DropzoneProps.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ export type FooterConfig = {
249249
customMessage?: JSX.Element;
250250

251251
customFooter?: JSX.Element;
252+
253+
style?: React.CSSProperties;
254+
className?: string;
255+
resetStyles?: boolean;
252256
}
253257

254258

@@ -263,7 +267,7 @@ export type ActionButtonItem = {
263267
}
264268

265269
export interface DropzoneActions {
266-
position?: "top" | "bottom";
270+
position?: "before" | "after";
267271
style?: React.CSSProperties;
268272
className?: string;
269273
uploadButton?: ActionButtonItem;

src/files-ui/components/file-input-button/FileInputButton.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,9 @@ const FileInputButton: React.FC<FileInputButtonProps> = (
486486

487487
return (
488488
<React.Fragment>
489-
{actionButtonsPosition === "top" && (
489+
{actionButtonsPosition === "before" && (
490490
<DropzoneButtons
491-
disabled={disabled}
491+
disabled={disabled}
492492
abortButton={isUploading ? abortButton : undefined}
493493
onAbort={handleAbortUpload}
494494
deleteButton={deleteButton}
@@ -527,9 +527,9 @@ const FileInputButton: React.FC<FileInputButtonProps> = (
527527
onChange={handleChangeInput}
528528
/>
529529

530-
{actionButtonsPosition === "bottom" && (
530+
{actionButtonsPosition === "after" && (
531531
<DropzoneButtons
532-
disabled={disabled}
532+
disabled={disabled}
533533
abortButton={isUploading ? abortButton : undefined}
534534
onAbort={handleAbortUpload}
535535
deleteButton={deleteButton}

src/files-ui/components/material-button/MaterialButton.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ import { MaterialButtonProps } from "./MaterialButtonProps";
44
import "./MaterialButton.scss";
55
import { createRippleButton } from "../../core";
66

7-
87
const MaterialButton: React.FC<MaterialButtonProps> = (
98
props: MaterialButtonProps
109
) => {
1110
const {
1211
disabled,
1312
href,
14-
textTransform:textDecoration,
13+
textTransform: textDecoration,
1514
variant = "contained",
1615
color = "#1976d2",
17-
textColor ="white",
16+
textColor = "white",
1817
children,
1918
className,
2019
style,
2120
onClick,
2221
resetStyles,
22+
disableRipple,
2323
} = props;
2424

2525
const idClassName = React.useId();
@@ -32,23 +32,23 @@ const MaterialButton: React.FC<MaterialButtonProps> = (
3232
textColor,
3333
textDecoration,
3434
className,
35-
idClassName.replaceAll(":",""),
35+
idClassName.replaceAll(":", ""),
3636
resetStyles
3737
);
3838

3939
function handleClick<T extends HTMLAnchorElement | HTMLButtonElement>(
4040
e: React.MouseEvent<T, MouseEvent>
4141
): void {
4242
e.preventDefault();
43-
4443

4544
//ripple
46-
createRippleButton(e, variant as string, color as string);
45+
if (!disableRipple)
46+
createRippleButton(e, variant as string, color as string);
4747

4848
onClick?.(e as React.MouseEvent<HTMLButtonElement, MouseEvent>);
4949
}
5050

51-
if (materialButtonClassName!==undefined || resetStyles)
51+
if (materialButtonClassName !== undefined || resetStyles)
5252
return React.createElement(href ? "a" : "button", {
5353
className: resetStyles && className ? className : materialButtonClassName,
5454
"data-testid": href ? "dui-anchor" : "dui-button",

src/files-ui/components/material-button/MaterialButtonProps.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ export interface MaterialButtonPropsInterface extends OverridableComponentProps
3636

3737
resetStyles?: boolean;
3838

39+
40+
/**
41+
* If true, will not show a ripple effect everytime
42+
* the user drops files or clicks the dropzone for selecting files
43+
* @default false
44+
*/
45+
disableRipple?: boolean;
46+
3947
}
4048
type DefButtonPropsMap = React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
4149

src/files-ui/core/types/uploadTypes.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,19 @@ export declare type UploadResponse = {
1616
serverResponse: ServerResponse | {};
1717
uploadedFile: ExtFile;
1818
}
19+
1920
export type ServerResponse = {
21+
/**
22+
* If true, it means that the request was successful.
23+
*/
2024
success: boolean;
25+
/**
26+
* A message that describes the result of the request.
27+
*/
2128
message?: string;
29+
/**
30+
* The response of the server.
31+
*/
2232
payload?: any;
2333
}
2434

0 commit comments

Comments
 (0)