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';
|
2023-12-05 07:06:55 +00:00
|
|
|
import { BadgePassThroughOptions } from '../badge';
|
2023-07-06 11:17:08 +00:00
|
|
|
import { ComponentHooks } from '../basecomponent';
|
2023-04-28 16:03:29 +00:00
|
|
|
import { ButtonPassThroughOptions } from '../button';
|
|
|
|
import { MessagePassThroughOptions } from '../message';
|
2023-09-05 08:50:46 +00:00
|
|
|
import { PassThroughOptions } from '../passthrough';
|
2024-05-06 15:23:01 +00:00
|
|
|
import { ProgressBarPassThroughOptions } from '../progressbar';
|
2024-05-16 10:50:43 +00:00
|
|
|
import { DefineComponent, DesignToken, EmitFn, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-07-11 22:42:43 +00:00
|
|
|
export declare type FileUploadPassThroughOptionType = FileUploadPassThroughAttributes | ((options: FileUploadPassThroughMethodOptions) => FileUploadPassThroughAttributes | string) | string | null | undefined;
|
2023-04-28 16:03:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) option method.
|
|
|
|
*/
|
|
|
|
export interface FileUploadPassThroughMethodOptions {
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines instance.
|
|
|
|
*/
|
2023-07-06 12:01:33 +00:00
|
|
|
instance: any;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties.
|
|
|
|
*/
|
2023-04-28 16:03:29 +00:00
|
|
|
props: FileUploadProps;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines current inline state.
|
|
|
|
*/
|
2023-04-28 16:03:29 +00:00
|
|
|
state: FileUploadState;
|
2023-12-10 21:41:17 +00:00
|
|
|
/**
|
|
|
|
* Defines valid attributes.
|
|
|
|
*/
|
|
|
|
attrs: any;
|
2023-12-05 11:06:32 +00:00
|
|
|
/**
|
|
|
|
* Defines parent options.
|
|
|
|
*/
|
|
|
|
parent: any;
|
2023-09-05 08:50:46 +00:00
|
|
|
/**
|
|
|
|
* Defines passthrough(pt) options in global config.
|
|
|
|
*/
|
|
|
|
global: object | undefined;
|
2023-04-28 16:03:29 +00:00
|
|
|
}
|
|
|
|
|
2023-12-05 07:06:55 +00:00
|
|
|
/**
|
|
|
|
* Custom shared passthrough(pt) option method.
|
|
|
|
*/
|
|
|
|
export interface FileUploadPassThroughMethodOptions {
|
|
|
|
/**
|
|
|
|
* Defines valid properties.
|
|
|
|
*/
|
|
|
|
props: FileUploadProps;
|
|
|
|
/**
|
|
|
|
* Defines current inline state.
|
|
|
|
*/
|
|
|
|
state: FileUploadState;
|
|
|
|
}
|
|
|
|
|
2023-03-01 15:18:57 +00:00
|
|
|
/**
|
|
|
|
* Custom select event.
|
2024-05-16 14:05:43 +00:00
|
|
|
* @see {@link FileUploadEmitsOptions.select}
|
2023-03-01 15:18:57 +00:00
|
|
|
*/
|
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.
|
2024-05-16 14:05:43 +00:00
|
|
|
* @see {@link FileUploadEmitsOptions['before-upload']}
|
2023-03-01 15:18:57 +00:00
|
|
|
*/
|
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.
|
2024-05-16 14:05:43 +00:00
|
|
|
* @see {@link FileUploadEmitsOptions.progress }
|
2023-03-01 15:18:57 +00:00
|
|
|
*/
|
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.
|
2024-05-16 14:05:43 +00:00
|
|
|
* @see {@link FileUploadEmitsOptions.upload}
|
2023-03-01 15:18:57 +00:00
|
|
|
*/
|
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.
|
2024-05-16 14:05:43 +00:00
|
|
|
* @see {@link FileUploadEmitsOptions.uploader}
|
2023-03-01 15:18:57 +00:00
|
|
|
*/
|
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.
|
2024-05-16 14:05:43 +00:00
|
|
|
* @see {@link FileUploadEmitsOptions.error}
|
2023-03-01 15:18:57 +00:00
|
|
|
*/
|
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.
|
2024-05-16 14:05:43 +00:00
|
|
|
* @see {@link FileUploadEmitsOptions['before-send']}
|
2023-03-01 15:18:57 +00:00
|
|
|
*/
|
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.
|
2024-05-16 14:05:43 +00:00
|
|
|
* @see {@link FileUploadEmitsOptions.remove}
|
2023-03-01 15:18:57 +00:00
|
|
|
*/
|
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.
|
2024-05-16 14:05:43 +00:00
|
|
|
* @see {@link FileUploadEmitsOptions['remove-uploaded-file']}
|
2023-03-01 15:18:57 +00:00
|
|
|
*/
|
2022-12-08 11:04:25 +00:00
|
|
|
export interface FileUploadRemoveUploadedFile {
|
|
|
|
/**
|
|
|
|
* Removed file.
|
|
|
|
*/
|
|
|
|
file: File;
|
|
|
|
/**
|
|
|
|
* Remaining files to be uploaded.
|
|
|
|
*/
|
|
|
|
files: File[];
|
|
|
|
}
|
|
|
|
|
2023-04-28 16:03:29 +00:00
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) options.
|
|
|
|
* @see {@link FileUploadProps.pt}
|
|
|
|
*/
|
|
|
|
export interface FileUploadPassThroughOptions {
|
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the root's DOM element.
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
|
|
|
root?: FileUploadPassThroughOptionType;
|
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the input's DOM element.
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
|
|
|
input?: FileUploadPassThroughOptionType;
|
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the header's DOM element.
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
2024-04-30 09:58:12 +00:00
|
|
|
header?: FileUploadPassThroughOptionType;
|
2023-04-28 16:03:29 +00:00
|
|
|
/**
|
2024-05-06 15:23:01 +00:00
|
|
|
* Used to pass attributes to the choose Button component.
|
2024-03-25 06:34:29 +00:00
|
|
|
* @see {@link ButtonPassThroughOptions}
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
2024-05-06 15:23:01 +00:00
|
|
|
pcChooseButton?: ButtonPassThroughOptions<FileUploadPassThroughMethodOptions>;
|
2023-04-28 16:03:29 +00:00
|
|
|
/**
|
2024-05-06 15:23:01 +00:00
|
|
|
* Used to pass attributes to the upload Button component.
|
2023-04-28 16:05:48 +00:00
|
|
|
* @see {@link ButtonPassThroughOptions}
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
2024-05-06 15:23:01 +00:00
|
|
|
pcUploadButton?: ButtonPassThroughOptions<FileUploadPassThroughMethodOptions>;
|
2023-04-28 16:03:29 +00:00
|
|
|
/**
|
2024-05-06 15:23:01 +00:00
|
|
|
* Used to pass attributes to the cancel Button component.
|
2023-04-28 16:05:48 +00:00
|
|
|
* @see {@link ButtonPassThroughOptions}
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
2024-05-06 15:23:01 +00:00
|
|
|
pcCancelButton?: ButtonPassThroughOptions<FileUploadPassThroughMethodOptions>;
|
2023-04-28 16:03:29 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the content's DOM element.
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
|
|
|
content?: FileUploadPassThroughOptionType;
|
|
|
|
/**
|
2024-05-06 15:23:01 +00:00
|
|
|
* Used to pass attributes to the ProgressBar component.
|
|
|
|
* @see {@link ProgressbarPassThroughOptions}
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
2024-05-06 15:23:01 +00:00
|
|
|
pcProgressbar?: ProgressBarPassThroughOptions<FileUploadPassThroughMethodOptions>;
|
2023-04-28 16:03:29 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the message's DOM element.
|
2023-04-28 16:05:48 +00:00
|
|
|
* @see {@link MessagePassThroughOptions}
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
2024-05-06 15:23:01 +00:00
|
|
|
pcMessage?: MessagePassThroughOptions<FileUploadPassThroughMethodOptions>;
|
2023-04-28 16:03:29 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the file's DOM element.
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
|
|
|
file?: FileUploadPassThroughOptionType;
|
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the file thumbnail's DOM element.
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
2024-04-30 09:58:12 +00:00
|
|
|
fileThumbnail?: FileUploadPassThroughOptionType;
|
2023-04-28 16:03:29 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the file info's DOM element.
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
2024-04-30 09:58:12 +00:00
|
|
|
fileInfo?: FileUploadPassThroughOptionType;
|
2023-04-28 16:03:29 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the fileName's DOM element.
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
|
|
|
fileName?: FileUploadPassThroughOptionType;
|
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the fileSize's DOM element.
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
|
|
|
fileSize?: FileUploadPassThroughOptionType;
|
|
|
|
/**
|
2023-12-05 07:06:55 +00:00
|
|
|
* Used to pass attributes to the Badge component.
|
|
|
|
* @see {@link BadgePassThroughOptions}
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
2024-05-06 15:23:01 +00:00
|
|
|
pcFileBadge?: BadgePassThroughOptions<FileUploadPassThroughMethodOptions>;
|
2023-04-28 16:03:29 +00:00
|
|
|
/**
|
2024-04-30 09:58:12 +00:00
|
|
|
* Used to pass attributes to the file actions' DOM element.
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
2024-04-30 09:58:12 +00:00
|
|
|
fileActions?: FileUploadPassThroughOptionType;
|
2023-04-28 16:03:29 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the file remove button's DOM element.
|
2023-04-28 16:05:48 +00:00
|
|
|
* @see {@link ButtonPassThroughOptions}
|
2023-04-28 16:03:29 +00:00
|
|
|
*/
|
2024-05-06 15:23:01 +00:00
|
|
|
pcFileRemoveButton?: ButtonPassThroughOptions<FileUploadPassThroughMethodOptions>;
|
2023-05-03 14:15:56 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the empty's DOM element.
|
2023-05-03 14:15:56 +00:00
|
|
|
*/
|
|
|
|
empty?: FileUploadPassThroughOptionType;
|
2024-05-06 15:23:01 +00:00
|
|
|
/**
|
|
|
|
* Used to pass attributes to the messages' DOM element.
|
|
|
|
* @see {@link MessagePassThroughOptions}
|
|
|
|
*/
|
|
|
|
pcMessages?: MessagePassThroughOptions<FileUploadPassThroughMethodOptions>;
|
2023-05-03 14:15:56 +00:00
|
|
|
/**
|
2024-05-15 09:24:26 +00:00
|
|
|
* Used to pass attributes to the basic mode's button's DOM element.
|
2024-03-25 06:34:29 +00:00
|
|
|
* @see {@link ButtonPassThroughOptions}
|
2023-05-03 14:15:56 +00:00
|
|
|
*/
|
2024-05-06 15:23:01 +00:00
|
|
|
pcButton?: ButtonPassThroughOptions<FileUploadPassThroughMethodOptions>;
|
2023-07-06 11:09:01 +00:00
|
|
|
/**
|
2023-11-07 06:16:39 +00:00
|
|
|
* Used to manage all lifecycle hooks.
|
2023-07-06 11:09:01 +00:00
|
|
|
* @see {@link BaseComponent.ComponentHooks}
|
|
|
|
*/
|
|
|
|
hooks?: ComponentHooks;
|
2023-04-28 16:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough attributes for each DOM elements
|
|
|
|
*/
|
|
|
|
export interface FileUploadPassThroughAttributes {
|
|
|
|
[key: string]: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines current inline state in FileUpload component.
|
|
|
|
*/
|
|
|
|
export interface FileUploadState {
|
|
|
|
/**
|
|
|
|
* Current uploaded file count state as a number.
|
|
|
|
* @defaultValue 0
|
|
|
|
*/
|
|
|
|
uploadedFileCount: number;
|
|
|
|
/**
|
|
|
|
* Current files.
|
|
|
|
*/
|
|
|
|
files: any[];
|
|
|
|
/**
|
|
|
|
* Current messages.
|
|
|
|
*/
|
|
|
|
messages: any[];
|
|
|
|
/**
|
|
|
|
* Current progress state as a number.
|
|
|
|
*/
|
|
|
|
progress: number;
|
|
|
|
/**
|
|
|
|
* Current uploaded files.
|
|
|
|
*/
|
|
|
|
uploadedFiles: any[];
|
|
|
|
}
|
|
|
|
|
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-08 10:51:52 +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-08 10:51:52 +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-08 10:51:52 +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-08 11:02:08 +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-04-18 10:51:10 +00:00
|
|
|
* @deprecated since v3.27.0. Use 'chooseicon' slot.
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
chooseIcon?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Icon of the upload button.
|
2023-04-18 10:51:10 +00:00
|
|
|
* @deprecated since v3.27.0. Use 'updateicon' slot.
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
uploadIcon?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Icon of the cancel button.
|
2023-04-18 10:51:10 +00:00
|
|
|
* @deprecated since v3.27.0. Use 'cancelicon' slot.
|
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;
|
2024-05-13 12:45:55 +00:00
|
|
|
/**
|
|
|
|
* Used to pass all properties of the ButtonProps to the choose button inside the component.
|
|
|
|
* @type {ButtonProps}
|
|
|
|
* @defaultValue null
|
|
|
|
*/
|
|
|
|
chooseButtonProps?: object | undefined;
|
|
|
|
/**
|
|
|
|
* Used to pass all properties of the ButtonProps to the upload button inside the component.
|
|
|
|
* @type {ButtonProps}
|
|
|
|
* @defaultValue { severity: 'secondary' }
|
|
|
|
*/
|
|
|
|
uploadButtonProps?: object | undefined;
|
|
|
|
/**
|
|
|
|
* Used to pass all properties of the ButtonProps to the cancel button inside the component.
|
|
|
|
* @type {ButtonProps}
|
|
|
|
* @defaultValue { severity: 'secondary' }
|
|
|
|
*/
|
|
|
|
cancelButtonProps?: object | undefined;
|
2024-04-02 08:24:31 +00:00
|
|
|
/**
|
|
|
|
* It generates scoped CSS variables using design tokens for the component.
|
|
|
|
*/
|
|
|
|
dt?: DesignToken<any>;
|
2023-04-28 16:03:29 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to DOM elements inside the component.
|
2023-04-28 16:03:29 +00:00
|
|
|
* @type {FileUploadPassThroughOptions}
|
|
|
|
*/
|
2023-09-05 11:28:04 +00:00
|
|
|
pt?: PassThrough<FileUploadPassThroughOptions>;
|
2023-09-05 08:50:46 +00:00
|
|
|
/**
|
|
|
|
* Used to configure passthrough(pt) options of the component.
|
|
|
|
* @type {PassThroughOptions}
|
|
|
|
*/
|
|
|
|
ptOptions?: PassThroughOptions;
|
2023-05-31 08:53:28 +00:00
|
|
|
/**
|
|
|
|
* When enabled, it removes component related styles in the core.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
unstyled?: boolean;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
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-08-17 07:16:25 +00:00
|
|
|
* @param {Object} scope - header slot's params.
|
2022-12-08 11:04:25 +00:00
|
|
|
*/
|
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-08-17 07:16:25 +00:00
|
|
|
chooseCallback: () => void;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Upload function
|
|
|
|
*/
|
2023-08-17 07:16:25 +00:00
|
|
|
uploadCallback: () => void;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Clear function
|
|
|
|
*/
|
2023-08-17 07:16:25 +00:00
|
|
|
clearCallback: () => void;
|
2023-03-01 15:18:57 +00:00
|
|
|
}): VNode[];
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Custom uploaded content template.
|
2023-08-17 07:16:25 +00:00
|
|
|
* @param {Object} scope - content slot's params.
|
2022-12-08 11:04:25 +00:00
|
|
|
*/
|
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-08-17 07:16:25 +00:00
|
|
|
* @param {number} index - Index of the uploaded file
|
2022-12-08 11:04:25 +00:00
|
|
|
*/
|
2023-08-17 07:16:25 +00:00
|
|
|
removeUploadedFileCallback: (index: number) => void;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Function to remove a file.
|
2023-08-17 07:16:25 +00:00
|
|
|
* @param {number} index - Index of the removed file
|
2022-12-08 11:04:25 +00:00
|
|
|
*/
|
2023-08-17 07:16:25 +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[];
|
2023-04-14 05:15:52 +00:00
|
|
|
/**
|
|
|
|
* Custom choose icon template.
|
|
|
|
*/
|
|
|
|
chooseicon(): VNode[];
|
|
|
|
/**
|
|
|
|
* Custom upload icon template.
|
|
|
|
*/
|
|
|
|
uploadicon(): VNode[];
|
|
|
|
/**
|
|
|
|
* Custom cancel icon template.
|
|
|
|
*/
|
|
|
|
cancelicon(): VNode[];
|
2023-04-15 11:34:56 +00:00
|
|
|
/**
|
|
|
|
* Custom remove icon template for each file.
|
2023-08-17 07:16:25 +00:00
|
|
|
* @param {Object} scope - fileremoveicon slot's params.
|
2023-04-15 11:34:56 +00:00
|
|
|
*/
|
|
|
|
fileremoveicon(scope: {
|
|
|
|
/**
|
|
|
|
* File to upload.
|
|
|
|
*/
|
|
|
|
file: File;
|
|
|
|
/**
|
|
|
|
* The index of file
|
|
|
|
*/
|
|
|
|
index: number;
|
|
|
|
}): VNode[];
|
2024-05-09 14:46:20 +00:00
|
|
|
/**
|
|
|
|
* Custom file label template.
|
|
|
|
* @param {Object} scope - filelabel slot's params.
|
|
|
|
*/
|
|
|
|
filelabel(scope: {
|
|
|
|
/**
|
|
|
|
* File to upload.
|
|
|
|
*/
|
|
|
|
files: File[];
|
|
|
|
}): VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2024-05-16 14:05:43 +00:00
|
|
|
export interface FileUploadEmitsOptions {
|
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
|
|
|
|
2024-05-16 10:50:43 +00:00
|
|
|
export declare type FileUploadEmits = EmitFn<FileUploadEmitsOptions>;
|
|
|
|
|
|
|
|
export interface FileUploadMethods {
|
|
|
|
/**
|
|
|
|
* Upload file.
|
|
|
|
*
|
|
|
|
* @memberof FileUpload
|
|
|
|
*/
|
|
|
|
upload(): void;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*
|
|
|
|
*/
|
2024-05-16 10:50:43 +00:00
|
|
|
declare const FileUpload: DefineComponent<FileUploadProps, FileUploadSlots, FileUploadEmits>;
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2024-03-14 22:58:11 +00:00
|
|
|
declare module 'vue' {
|
|
|
|
export interface GlobalComponents {
|
2024-05-16 10:50:43 +00:00
|
|
|
FileUpload: GlobalComponentConstructor<FileUploadProps, FileUploadSlots, FileUploadEmits>;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FileUpload;
|