From 6eb779cc7c71e443aea3bb6a2081ac27a8d00ea8 Mon Sep 17 00:00:00 2001 From: Tommy <35172239+ewenjo@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:49:04 +0200 Subject: [PATCH] Define a new File type extended with custom objectURL property (#7145) --- components/lib/fileupload/fileupload.d.ts | 29 +++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/components/lib/fileupload/fileupload.d.ts b/components/lib/fileupload/fileupload.d.ts index 54e8e072ec..50fa4daf29 100644 --- a/components/lib/fileupload/fileupload.d.ts +++ b/components/lib/fileupload/fileupload.d.ts @@ -136,6 +136,11 @@ export interface FileUploadPassThroughOptions { hooks?: ComponentHooks; } +/** + * Defines a custom File type extended with objectURL + */ +type FileUploadFile = File & { objectURL: string }; + /** * Defines current inline state in FileUpload component. */ @@ -143,7 +148,7 @@ export interface FileUploadState { /** * Current files. */ - files: any[]; + files: FileUploadFile[]; /** * Current uplaoding state as a boolean. * @defaultValue false @@ -162,7 +167,7 @@ export interface FileUploadState { /** * Current uploaded files. */ - uploadedFiles: any[]; + uploadedFiles: FileUploadFile[]; } /** @@ -270,7 +275,7 @@ interface ItemTemplateOptions { /** * Array of files. */ - files: File[]; + files: FileUploadFile[]; /** * Index of the file. */ @@ -317,7 +322,7 @@ interface FileUploadFilesEvent { /** * Uploaded files. */ - files: File[]; + files: FileUploadFile[]; } /** @@ -676,22 +681,22 @@ export declare class FileUpload extends React.Component { public getInput(): HTMLInputElement; /** * Gets the current files list. - * @return {File[]} Current files. + * @return {FileUploadFile[]} Current files. */ - public getFiles(): File[]; + public getFiles(): FileUploadFile[]; /** * Sets the current files list. - * @param {File[]} files - Current files. + * @param {FileUploadFile[]} files - Current files. */ - public setFiles(files: File[]): void; + public setFiles(files: FileUploadFile[]): void; /** * Gets the current uploaded files list. - * @return {File[]} Current uploaded files. + * @return {FileUploadFile[]} Current uploaded files. */ - public getUploadedFiles(): File[]; + public getUploadedFiles(): FileUploadFile[]; /** * Sets the current uploaded files list. - * @param {File[]} files - Current uploaded files. + * @param {FileUploadFile[]} files - Current uploaded files. */ - public setUploadedFiles(files: File[]): void; + public setUploadedFiles(files: FileUploadFile[]): void; }