import { FileItemProps, FileUploadProps } from "@lifesg/react-design-system/file-upload"; import { AxiosRequestConfig } from "axios"; import { IYupValidationRule } from "../../../context-providers"; import { TFieldEventListener } from "../../../utils"; import { TErrorMessage } from "../../frontend-engine"; import { IBaseFieldSchema } from "../types"; export type TUploadType = "base64" | "multipart"; export interface IFileUploadValidationRule extends IYupValidationRule { /** for customising upload error message */ upload?: boolean | undefined; /** accepted file types */ fileType?: string[] | undefined; /** max acceptable file size in kb */ maxSizeInKb?: number | undefined; /** To be used with file types. When TRUE, checks that uploaded file extensions are within accepted file types */ fileExtension?: string[] | undefined; } export interface IFileUploadSchema extends IBaseFieldSchema<"file-upload", V, IFileUploadValidationRule>, Pick { className?: string | undefined; description?: string | undefined; label: string; hideThumbnail?: boolean | undefined; uploadOnAddingFile: { type: TUploadType; url: string; headers?: AxiosRequestConfig["headers"] | undefined; sessionId?: string | undefined; }; warning?: string | undefined; compressImages?: boolean | undefined; } export declare enum EFileStatus { INJECTED = -99, INJECTING = -98, TO_DELETE = -4, ERROR_FORMAT = -3, ERROR_GENERIC = -2, ERROR_SIZE = -1, NONE = 0, UPLOAD_READY = 4, UPLOADING = 5, UPLOADED = 6 } export interface IFile { addedFrom: "input" | "schema"; dataURL?: string | undefined; fileItem?: FileItemProps | undefined; fileUrl?: string | undefined; rawFile: File; slot: number; status: EFileStatus; uploadResponse?: unknown | undefined; } export interface IFileUploadValue { dataURL?: string | undefined; fileId: string; fileName: string; fileUrl?: string | undefined; uploadResponse?: unknown | undefined; } type Implements = U; export type TFileUploadErrorObject = { message?: string | undefined; fileErrors?: { [fileId: string]: string; } | undefined; }; export type TFileUploadErrorMessage = Implements; export type TUploadErrorDetail = { fileId: string; errorData: unknown; }; /** fired when field is mounted */ declare function fileUploadEvent(uiType: "file-upload", type: "mount", id: string, listener: TFieldEventListener, options?: boolean | AddEventListenerOptions | undefined): void; /** fired when file upload throws error */ declare function fileUploadEvent(uiType: "file-upload", type: "upload-error", id: string, listener: TFieldEventListener, options?: boolean | AddEventListenerOptions | undefined): void; export type TFileUploadEvents = typeof fileUploadEvent; export {};