UNPKG

@rws-aoa/react-library

Version:

RWS AOA Design System

77 lines 2.69 kB
import { PropsWithChildren, ReactNode } from 'react'; import { Accept } from 'react-dropzone'; export type AoaDropableFile<TProps extends object> = TProps & { /** * The file that was dropped */ file: File; }; export interface AoaFileDropzoneDataQas { /** * The data-qa tag for the input */ input: string; /** * The data-qa tag for the root element */ root: string; } export interface AoaFileDropzoneProps<TProps extends object, TFile extends AoaDropableFile<TProps>> { /** * The current set of files that are already dropped, coming from Redux or Tanstack Store */ currentFiles: TFile[]; /** * A custom function that can perform extra checks when validating files. * This should return `true` if the file should be rejected or `false` if it should be accepted * * @param file - The file to be validated */ customFileValidator?(file: File): boolean; /** * data-qa tags for testing */ dataQas?: AoaFileDropzoneDataQas; /** * The regular expression that validates if the dropped file should be accepted or rejected */ extensionRegex: RegExp; /** * The toast warning message to be shown when a file is rejection */ extensionWarning: string; /** * The extension map to be passed to the dropzone component */ extensions: Accept; /** * The children to show inside the box where files can be dropped */ fileDropChildren?: ReactNode; /** * Whether the dropzone should be disabled or not */ isDisabled?: boolean; /** * A maximum count of files that should be accepted, if exceeded no save action will be performed */ maxUploadFiles?: number; /** * The toast warning message to be shown when the files to be uploaded exceeds the maximum, * required if {@link AoaFileDropzoneProps.maxUploadFiles | maxUploadFiles} is specified. */ maxUploadSizeExceededWarning?: string; /** * Additional properties to set for every file that is to be saved */ perFileProperties?(acceptedFile: File): TProps; /** * The function to overwrite the files in the client store. * This should overwrite all files, not merge with current, which is handled in this component * * @param files - The new set of files to be stored */ storeFiles(files: TFile[]): void; } export declare function AoaFileDropzone<TProps extends object, TFile extends AoaDropableFile<TProps>>(props: Readonly<PropsWithChildren<AoaFileDropzoneProps<TProps, TFile>>>): import("react/jsx-runtime").JSX.Element; //# sourceMappingURL=FileDropzone.d.ts.map