@tiller-ds/upload
Version:
Upload module of Tiller Design System
53 lines (52 loc) • 2.16 kB
TypeScript
import * as React from "react";
import { ButtonProps } from "@tiller-ds/core";
import { ComponentTokens } from "@tiller-ds/theme";
import { UploadyWrapperProps } from "./UploadyWrapper";
import { UseFileUpload, File } from "./useFileUpload";
import { BatchItem } from "@rpldy/shared";
export declare type UploadButtonProps<T extends File> = {
/**
* Url on the backend which is called for saving files
*/
url: string;
/**
* Object return from {@link useFileUpload} hook, used internally for correct behaviour of the file
* upload
*/
hook: UseFileUpload<T>;
/**
* The color of the component.
*/
color?: "primary" | "success" | "secondary" | "tertiary" | "info" | "danger" | "warning" | "red" | "orange" | "pink" | "blue" | "indigo" | "purple" | "yellow" | "green" | "teal" | "gray" | undefined;
/**
* Whether will user be able to upload multiple files at once
*/
allowMultiple?: boolean;
/**
* Is the UploadButton disabled
*/
disabled?: boolean;
/**
* Function which fired in case item upload failed.
*/
onError?: (message: string) => void;
/**
* Custom mapper for the backend response, used when a subclass of {@link File} is used to extend uploaded file data
* @param item file that is uploaded
* @param originalFileName original file name of the file (in case if the backend does a rename)
*/
mapUploadResponse?: (item: BatchItem, originalFileName: string) => T;
/**
* `withCredentials` flag on fetch requests for uploading
*/
withCredentials?: boolean;
/**
* UploadButton content
*/
children?: React.ReactNode;
} & Omit<UploadyWrapperProps, "children"> & Omit<ButtonProps, "onClick"> & StatusButtonTokensProps;
declare type StatusButtonTokensProps = {
tokens?: ComponentTokens<"StatusButton">;
};
export default function UploadButton<T extends File>({ color, url, send, enhancer, destinationOptions, allowMultiple, mapUploadResponse, withCredentials, listeners, ...props }: UploadButtonProps<T>): JSX.Element;
export {};