Skip to content
Snippets Groups Projects
Commit d126df9b authored by Jose Manuel Serrano Amaut's avatar Jose Manuel Serrano Amaut
Browse files

[REF]: Refactored type name

parent a58ac3c6
No related branches found
No related tags found
No related merge requests found
import * as React from "react";
import { addClassName, Localization } from "../../../../core";
import { MaterialButton } from "../../../material-button";
import {
ActionButtonItem,
DropzoneActions,
} from "../dropzone/DropzoneProps";
import { ActionButtonItem, DropzoneActions } from "../dropzone/DropzoneProps";
import "./DropzoneButtons.scss";
interface DropzoneButtonsProps extends DropzoneActions {
......@@ -38,22 +35,38 @@ const DropzoneButtons: React.FC<DropzoneButtonsProps> = (
const actionButtonsList: ActionButtonItem[] = [
cleanButton
? { ...cleanButton, label: "Clean", onClick: onClean }
? {
...cleanButton,
label: "Clean",
onClick: cleanButton.onClick || onClean,
}
: undefined,
deleteButton
? { ...deleteButton, label: "Delete", onClick: onDelete }
? {
...deleteButton,
label: "Delete",
onClick: deleteButton.onClick || onDelete,
}
: undefined,
uploadButton
? { ...uploadButton, label: "Upload", onClick: onUpload }
? {
...uploadButton,
label: "Upload",
onClick: uploadButton.onClick || onUpload,
}
: undefined,
abortButton
? { ...abortButton, label: "Abort", onClick: onAbort }
? {
...abortButton,
label: "Abort",
onClick: abortButton.onClick || onAbort,
}
: undefined,
].filter(
(ab: ActionButtonItem | undefined) => ab !== undefined
) as ActionButtonItem[];
const tailClassName:string = `${top ? " top" : " bottom"}`;
const tailClassName: string = `${top ? " top" : " bottom"}`;
const finalClassName = addClassName(
"files-ui-buttons-container" + tailClassName,
containerClassName
......@@ -71,7 +84,7 @@ const DropzoneButtons: React.FC<DropzoneButtonsProps> = (
className={className}
style={style}
resetStyles={resetStyles}
onClick={() => onClick?.()}
onClick={(evt) => onClick?.(evt)}
disabled={disabled}
>
{children || label}
......
......@@ -690,7 +690,7 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
return (
<React.Fragment>
{actionButtonsPosition === "top" && (
{actionButtonsPosition === "before" && (
<DropzoneButtons
disabled={disabled}
abortButton={isUploading ? abortButton : undefined}
......@@ -828,7 +828,7 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
/>
</div>
{actionButtonsPosition === "bottom" && (
{actionButtonsPosition === "after" && (
<DropzoneButtons
disabled={disabled}
abortButton={isUploading ? abortButton : undefined}
......
......@@ -249,6 +249,10 @@ export type FooterConfig = {
customMessage?: JSX.Element;
customFooter?: JSX.Element;
style?: React.CSSProperties;
className?: string;
resetStyles?: boolean;
}
......@@ -263,7 +267,7 @@ export type ActionButtonItem = {
}
export interface DropzoneActions {
position?: "top" | "bottom";
position?: "before" | "after";
style?: React.CSSProperties;
className?: string;
uploadButton?: ActionButtonItem;
......
......@@ -486,9 +486,9 @@ const FileInputButton: React.FC<FileInputButtonProps> = (
return (
<React.Fragment>
{actionButtonsPosition === "top" && (
{actionButtonsPosition === "before" && (
<DropzoneButtons
disabled={disabled}
disabled={disabled}
abortButton={isUploading ? abortButton : undefined}
onAbort={handleAbortUpload}
deleteButton={deleteButton}
......@@ -527,9 +527,9 @@ const FileInputButton: React.FC<FileInputButtonProps> = (
onChange={handleChangeInput}
/>
{actionButtonsPosition === "bottom" && (
{actionButtonsPosition === "after" && (
<DropzoneButtons
disabled={disabled}
disabled={disabled}
abortButton={isUploading ? abortButton : undefined}
onAbort={handleAbortUpload}
deleteButton={deleteButton}
......
......@@ -4,22 +4,22 @@ import { MaterialButtonProps } from "./MaterialButtonProps";
import "./MaterialButton.scss";
import { createRippleButton } from "../../core";
const MaterialButton: React.FC<MaterialButtonProps> = (
props: MaterialButtonProps
) => {
const {
disabled,
href,
textTransform:textDecoration,
textTransform: textDecoration,
variant = "contained",
color = "#1976d2",
textColor ="white",
textColor = "white",
children,
className,
style,
onClick,
resetStyles,
disableRipple,
} = props;
const idClassName = React.useId();
......@@ -32,7 +32,7 @@ const MaterialButton: React.FC<MaterialButtonProps> = (
textColor,
textDecoration,
className,
idClassName.replaceAll(":",""),
idClassName.replaceAll(":", ""),
resetStyles
);
......@@ -40,15 +40,15 @@ const MaterialButton: React.FC<MaterialButtonProps> = (
e: React.MouseEvent<T, MouseEvent>
): void {
e.preventDefault();
//ripple
createRippleButton(e, variant as string, color as string);
if (!disableRipple)
createRippleButton(e, variant as string, color as string);
onClick?.(e as React.MouseEvent<HTMLButtonElement, MouseEvent>);
}
if (materialButtonClassName!==undefined || resetStyles)
if (materialButtonClassName !== undefined || resetStyles)
return React.createElement(href ? "a" : "button", {
className: resetStyles && className ? className : materialButtonClassName,
"data-testid": href ? "dui-anchor" : "dui-button",
......
......@@ -36,6 +36,14 @@ export interface MaterialButtonPropsInterface extends OverridableComponentProps
resetStyles?: boolean;
/**
* If true, will not show a ripple effect everytime
* the user drops files or clicks the dropzone for selecting files
* @default false
*/
disableRipple?: boolean;
}
type DefButtonPropsMap = React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
......
......@@ -16,9 +16,19 @@ export declare type UploadResponse = {
serverResponse: ServerResponse | {};
uploadedFile: ExtFile;
}
export type ServerResponse = {
/**
* If true, it means that the request was successful.
*/
success: boolean;
/**
* A message that describes the result of the request.
*/
message?: string;
/**
* The response of the server.
*/
payload?: any;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment