primevue-mirror/components/fileupload/FileUpload.d.ts

399 lines
9.8 KiB
TypeScript
Raw Normal View History

2023-03-01 15:18:57 +00:00
/**
*
* FileUpload is an advanced uploader with dragdrop support, multi file uploads, auto uploading, progress tracking and validations.
*
* [Live Demo](https://www.primevue.org/fileupload/)
*
* @module fileupload
*
*/
2022-09-06 12:03:37 +00:00
import { VNode } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
2023-03-01 15:18:57 +00:00
/**
* Custom select event.
* @see select
*/
2022-09-06 12:03:37 +00:00
export interface FileUploadSelectEvent {
/**
* Browser event.
*/
originalEvent: Event;
/**
* List of selected files.
*/
files: any;
}
2023-03-01 15:18:57 +00:00
/**
* Custom before upload event.
* @see before-upload
*/
2022-09-06 12:03:37 +00:00
export interface FileUploadBeforeUploadEvent {
/**
* XmlHttpRequest instance.
*/
xhr: XMLHttpRequest;
/**
* FormData object.
*/
formData: FormData;
}
2023-03-01 15:18:57 +00:00
/**
* Custom progress event.
* @see progress
*/
2022-09-06 12:03:37 +00:00
export interface FileUploadProgressEvent {
/**
* Browser event.
*/
originalEvent: Event;
/**
* Calculated progress value.
*/
progress: number;
}
2023-03-01 15:18:57 +00:00
/**
* Custom upload event.
* @see upload
*/
2022-09-06 12:03:37 +00:00
export interface FileUploadUploadEvent {
/**
* XmlHttpRequest instance.
*/
xhr: XMLHttpRequest;
/**
* Files that are not uploaded.
*/
files: File | File[];
}
2023-03-01 15:18:57 +00:00
/**
* Custom uploader event.
* @see uploader
*/
2022-09-06 12:03:37 +00:00
export interface FileUploadUploaderEvent {
/**
* List of selected files.
*/
files: File | File[];
}
2023-03-01 15:18:57 +00:00
/**
* Custom error event.
* @see error
*/
2022-09-06 12:03:37 +00:00
export interface FileUploadErrorEvent {
/**
* XmlHttpRequest instance.
*/
xhr: XMLHttpRequest;
/**
* Files that are not uploaded.
*/
files: File | File[];
}
2023-03-01 15:18:57 +00:00
/**
* Custom before send event.
* @see before-send
*/
2022-09-06 12:03:37 +00:00
export interface FileUploadBeforeSendEvent {
/**
* XmlHttpRequest instance.
*/
xhr: XMLHttpRequest;
/**
* FormData object.
*/
formData: FormData;
}
2023-03-01 15:18:57 +00:00
/**
* Custom remove event.
* @see remove
*/
2022-09-06 12:03:37 +00:00
export interface FileUploadRemoveEvent {
/**
* Removed file.
*/
file: File;
/**
* Remaining files to be uploaded.
*/
files: File[];
}
2023-03-01 15:18:57 +00:00
/**
* Custom remove upload file event.
* @see removeUploadFile
*/
2022-12-08 11:04:25 +00:00
export interface FileUploadRemoveUploadedFile {
/**
* Removed file.
*/
file: File;
/**
* Remaining files to be uploaded.
*/
files: File[];
}
2023-03-01 15:18:57 +00:00
/**
* Defines valid properties in FileUpload component.
*/
2022-09-06 12:03:37 +00:00
export interface FileUploadProps {
/**
* Name of the request parameter to identify the files at backend.
*/
name?: string | undefined;
/**
* Remote url to upload the files.
*/
url?: string | undefined;
/**
* Defines the UI of the component, possible values are 'advanced' and 'basic'.
2023-03-03 08:18:55 +00:00
* @defaultValue 'advanced'
2022-09-06 12:03:37 +00:00
*/
2023-03-01 15:18:57 +00:00
mode?: 'advanced' | 'basic' | undefined;
2022-09-06 12:03:37 +00:00
/**
* Used to select multiple files at once from file dialog.
2023-03-01 15:18:57 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
multiple?: boolean | undefined;
/**
* Pattern to restrict the allowed file types such as 'image/*'.
*/
accept?: string | undefined;
/**
* Disables the upload functionality.
2023-03-01 15:18:57 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
disabled?: boolean | undefined;
/**
* When enabled, upload begins automatically after selection is completed.
2023-03-01 15:18:57 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
auto?: boolean | undefined;
/**
* Maximum file size allowed in bytes.
*/
maxFileSize?: number | undefined;
/**
* Message of the invalid fize size.
2023-03-03 08:18:55 +00:00
* @defaultValue '{0}: Invalid file size, file size should be smaller than {1.}'
2022-09-06 12:03:37 +00:00
*/
invalidFileSizeMessage?: string | undefined;
/**
* Message to display when number of files to be uploaded exceeeds the limit.
2023-03-03 08:18:55 +00:00
* @defaultValue 'Maximum number of files to be uploaded is {0.}'
2022-09-06 12:03:37 +00:00
*/
invalidFileLimitMessage?: string | undefined;
/**
* Message of the invalid fize type.
2023-03-03 08:18:55 +00:00
* @defaultValue '{0}: Invalid file type.'
2022-09-06 12:03:37 +00:00
*/
invalidFileTypeMessage?: string | undefined;
/**
* Maximum number of files that can be uploaded.
*/
fileLimit?: number | undefined;
/**
* Cross-site Access-Control requests should be made using credentials such as cookies, authorization headers or TLS client certificates.
2023-03-01 15:18:57 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
withCredentials?: boolean | undefined;
/**
* Width of the image thumbnail in pixels.
2023-03-01 15:18:57 +00:00
* @defaultValue 50
2022-09-06 12:03:37 +00:00
*/
previewWidth?: number | undefined;
/**
* Label of the choose button. Defaults to PrimeVue Locale configuration.
*/
chooseLabel?: string | undefined;
/**
* Label of the upload button. Defaults to PrimeVue Locale configuration.
*/
uploadLabel?: string | undefined;
/**
* Label of the cancel button. Defaults to PrimeVue Locale configuration.
2023-03-01 15:18:57 +00:00
* @defaultValue Cancel
2022-09-06 12:03:37 +00:00
*/
cancelLabel?: string | undefined;
/**
* Whether to use the default upload or a manual implementation defined in uploadHandler callback. Defaults to PrimeVue Locale configuration.
*/
customUpload?: boolean | undefined;
/**
* Whether to show the upload button.
2023-03-01 15:18:57 +00:00
* @defaultValue true
2022-09-06 12:03:37 +00:00
*/
showUploadButton?: boolean | undefined;
/**
* Whether to show the cancel button.
2023-03-01 15:18:57 +00:00
* @defaultValue true
2022-09-06 12:03:37 +00:00
*/
showCancelButton?: boolean | undefined;
/**
* Icon of the choose button.
2023-03-03 08:18:55 +00:00
* @defaultValue 'pi pi-fw pi-plus'
2022-09-06 12:03:37 +00:00
*/
chooseIcon?: string | undefined;
/**
* Icon of the upload button.
2023-03-03 08:18:55 +00:00
* @defaultValue 'pi pi-fw pi-upload'
2022-09-06 12:03:37 +00:00
*/
uploadIcon?: string | undefined;
/**
* Icon of the cancel button.
2023-03-03 08:18:55 +00:00
* @defaultValue 'pi pi-fw pi-times'
2022-09-06 12:03:37 +00:00
*/
cancelIcon?: string | undefined;
/**
* Inline style of the component.
*/
style?: any;
/**
* Style class of the component.
*/
class?: any;
}
2023-03-01 15:18:57 +00:00
/**
* Defines valid slots in FileUpload slots.
*/
2022-09-06 12:03:37 +00:00
export interface FileUploadSlots {
/**
2022-12-08 11:04:25 +00:00
* Custom header content template.
*/
2023-03-01 15:18:57 +00:00
header(scope: {
2022-12-08 11:04:25 +00:00
/**
* Files to upload.
*/
files: File[];
/**
* Uploaded files.
*/
uploadedFiles: File[];
/**
* Choose function
*/
2023-03-01 15:18:57 +00:00
chooseCallback(): void;
2022-12-08 11:04:25 +00:00
/**
* Upload function
*/
2023-03-01 15:18:57 +00:00
uploadCallback(): void;
2022-12-08 11:04:25 +00:00
/**
* Clear function
*/
2023-03-01 15:18:57 +00:00
clearCallback(): void;
}): VNode[];
2022-12-08 11:04:25 +00:00
/**
* Custom uploaded content template.
*/
2023-03-01 15:18:57 +00:00
content(scope: {
2022-12-08 11:04:25 +00:00
/**
* Files to upload.
*/
files: File[];
/**
* Uploaded files.
*/
uploadedFiles: File[];
/**
* Function to remove an uploaded file.
*/
2023-03-01 15:18:57 +00:00
removeUploadedFileCallback(index: number): void;
2022-12-08 11:04:25 +00:00
/**
* Function to remove a file.
*/
2023-03-01 15:18:57 +00:00
removeFileCallback(index: number): void;
2022-12-08 11:04:25 +00:00
/**
* Uploaded progress as number.
*/
progress: number;
/**
* Status messages about upload process.
*/
messages: string | undefined;
2023-03-01 15:18:57 +00:00
}): VNode[];
2022-12-08 11:04:25 +00:00
/**
* Custom content when there is no selected file.
2022-09-06 12:03:37 +00:00
*/
2023-03-01 15:18:57 +00:00
empty(): VNode[];
2022-09-06 12:03:37 +00:00
}
2023-03-01 15:18:57 +00:00
export interface FileUploadEmits {
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when files are selected.
* @param {FileUploadSelectEvent} event - Custom select event.
*/
2023-03-01 15:18:57 +00:00
select(event: FileUploadSelectEvent): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke before file upload begins to customize the request such as post parameters before the files.
* @param {FileUploadBeforeUploadEvent} event - Custom before upload event.
*/
2023-03-01 15:18:57 +00:00
'before-upload'(event: FileUploadBeforeUploadEvent): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when files are being uploaded.
* @param {FileUploadProgressEvent} event - Custom progress event.
*/
2023-03-01 15:18:57 +00:00
progress(event: FileUploadProgressEvent): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when file upload is complete.
* @param {FileUploadUploadEvent} event - Custom upload event.
*/
2023-03-01 15:18:57 +00:00
upload(event: FileUploadUploadEvent): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke to implement a custom upload.
* @param {FileUploadUploaderEvent} event - Custom uploader event.
*/
2023-03-01 15:18:57 +00:00
uploader(event: FileUploadUploaderEvent): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke if file upload fails.
* @param {FileUploadErrorEvent} event - Custom error event.
*/
2023-03-01 15:18:57 +00:00
error(event: FileUploadErrorEvent): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke before file send begins to customize the request such as adding headers.
* @param {FileUploadBeforeSendEvent} event - Custom before send event.
*/
2023-03-01 15:18:57 +00:00
'before-send'(event: FileUploadBeforeSendEvent): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when files in queue are removed without uploading.
*/
2023-03-01 15:18:57 +00:00
clear(): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when a singe file is removed from the list.
* @param {FileUploadRemoveEvent} event - Custom remove event.
*/
2023-03-01 15:18:57 +00:00
remove(event: FileUploadRemoveEvent): void;
2022-12-08 11:04:25 +00:00
/**
* Callback to invoke when a single uploaded file is removed from the uploaded file list.
* @param {FileUploadRemoveUploadedFile} event - Custom uploaded file remove event.
*/
2023-03-01 15:18:57 +00:00
removeUploadedFile(event: FileUploadRemoveUploadedFile): void;
}
2022-09-06 12:03:37 +00:00
2023-03-01 15:18:57 +00:00
/**
* **PrimeVue - FileUpload**
*
* _FileUpload is an advanced uploader with dragdrop support, multi file uploads, auto uploading, progress tracking and validations._
*
* [Live Demo](https://www.primevue.org/fileupload/)
* --- ---
2023-03-03 10:55:20 +00:00
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
2023-03-01 15:18:57 +00:00
*
* @group Component
*
*/
2022-09-14 11:26:01 +00:00
declare class FileUpload extends ClassComponent<FileUploadProps, FileUploadSlots, FileUploadEmits> {}
2022-09-06 12:03:37 +00:00
declare module '@vue/runtime-core' {
interface GlobalComponents {
2022-09-14 11:26:01 +00:00
FileUpload: GlobalComponentConstructor<FileUpload>;
2022-09-06 12:03:37 +00:00
}
}
export default FileUpload;