import { HttpEvent } from '@angular/common/http'; import { TemplateRef } from '@angular/core'; import { PassThroughOption, PassThrough } from 'primeng/api'; import { BadgePassThrough } from 'primeng/types/badge'; import { ButtonPassThrough } from 'primeng/types/button'; import { MessagePassThrough } from 'primeng/types/message'; import { ProgressBarPassThrough } from 'primeng/types/progressbar'; /** * Custom pass-through(pt) options. * @template I Type of instance. * * @see {@link FileUpload.pt} * @group Interface */ interface FileUploadPassThroughOptions { /** * Used to pass attributes to the host's DOM element. */ host?: PassThroughOption; /** * Used to pass attributes to the root's DOM element. */ root?: PassThroughOption; /** * Used to pass attributes to the input's DOM element. */ input?: PassThroughOption; /** * Used to pass attributes to the header's DOM element. */ header?: PassThroughOption; /** * Used to pass attributes to the choose button component. */ pcChooseButton?: ButtonPassThrough; /** * Used to pass attributes to the upload button component. */ pcUploadButton?: ButtonPassThrough; /** * Used to pass attributes to the cancel button component. */ pcCancelButton?: ButtonPassThrough; /** * Used to pass attributes to the content's DOM element. */ content?: PassThroughOption; /** * Used to pass attributes to the progress bar component. */ pcProgressBar?: ProgressBarPassThrough; /** * Used to pass attributes to the message component. */ pcMessage?: MessagePassThrough; /** * Used to pass attributes to the file list's DOM element. */ fileList?: PassThroughOption; /** * Used to pass attributes to the file's DOM element. */ file?: PassThroughOption; /** * Used to pass attributes to the file thumbnail's DOM element. */ fileThumbnail?: PassThroughOption; /** * Used to pass attributes to the file info's DOM element. */ fileInfo?: PassThroughOption; /** * Used to pass attributes to the file name's DOM element. */ fileName?: PassThroughOption; /** * Used to pass attributes to the file size's DOM element. */ fileSize?: PassThroughOption; /** * Used to pass attributes to the file badge component. */ pcFileBadge?: BadgePassThrough; /** * Used to pass attributes to the file actions's DOM element. */ fileActions?: PassThroughOption; /** * Used to pass attributes to the file remove button component. */ pcFileRemoveButton?: ButtonPassThrough; /** * Used to pass attributes to the basic content's DOM element. */ basicContent?: PassThroughOption; /** * Used to pass attributes to the empty's DOM element. */ empty?: PassThroughOption; } /** * Defines valid pass-through options in FileUpload. * @see {@link FileUploadPassThroughOptions} * * @template I Type of instance. */ type FileUploadPassThrough = PassThrough>; /** * Upload event. * @group Events */ interface UploadEvent { /** * HTTP event. */ originalEvent: HttpEvent; } /** * Remove uploaded file event. * @group Events */ interface RemoveUploadedFileEvent { /** * Removed file. */ file: any; /** * Uploaded files. */ files: any[]; } /** * Form data event. * @group Events */ interface FormDataEvent { /** * FormData object. */ formData: FormData; } /** * An event indicating that the request was sent to the server. Useful when a request may be retried multiple times, to distinguish between retries on the final event stream. * @see {@link FileUpload.onSend} * @group Events */ interface FileSendEvent extends UploadEvent, FormDataEvent { } /** * Callback to invoke before file upload is initialized. * @see {@link FileUpload.onBeforeUpload} * @group Events */ interface FileBeforeUploadEvent extends FormDataEvent { } /** * Callback to invoke when file upload is complete. * @see {@link FileUpload.onUpload} * @group Events */ interface FileUploadEvent extends UploadEvent { /** * Uploaded files. */ files: File[]; } /** * Callback to invoke when a file is removed without uploading using clear button of a file. * @see {@link FileUpload.onRemove} * @group Events */ interface FileRemoveEvent { /** * Browser event. */ originalEvent: Event; /** * Selected file */ file: File; } /** * Callback to invoke when files are selected. * @see {@link FileUpload.onSelect} * @group Events */ interface FileSelectEvent { /** * Browser event. */ originalEvent: Event; /** * Uploaded files. */ files: File[]; /** * All files to be uploaded. */ currentFiles: File[]; } /** * Callback to invoke when files are being uploaded. * @see {@link FileUpload.onProgress} * @extends {UploadEvent} * @group Events */ interface FileProgressEvent extends UploadEvent { /** * Calculated progress value. */ progress: number; } /** * Callback to invoke in custom upload mode to upload the files manually. * @see {@link FileUpload.uploadHandler} * @group Events */ interface FileUploadHandlerEvent { /** * List of selected files. */ files: File[]; } /** * Callback to invoke on upload error. * @see {@link FileUpload.onError} * @group Events */ interface FileUploadErrorEvent { /** * List of selected files. */ error?: ErrorEvent; /** * List of selected files. */ files: File[]; } /** * Custom header template context. * @group Interface */ interface FileUploadHeaderTemplateContext { /** * File list. */ $implicit: File[]; /** * Uploaded files list. */ uploadedFiles: File[]; /** * Callback to invoke on choose button click. */ chooseCallback: () => void; /** * Callback to invoke on clear button click. */ clearCallback: () => void; /** * Callback to invoke on upload. */ uploadCallback: () => void; } /** * Custom content template context. * @group Interface */ interface FileUploadContentTemplateContext { /** * File list. */ $implicit: File[]; /** * Uploaded files list. */ uploadedFiles: File[]; /** * Upload progress value (0-100). */ progress: number; /** * Status messages about upload process. */ messages: any[]; /** * Callback to invoke on choose button click. */ chooseCallback: () => void; /** * Callback to invoke to remove a file from the list. */ removeFileCallback: (event: Event, index: number) => void; /** * Callback to invoke on clear button click. */ clearCallback: () => void; /** * Callback to invoke on remove uploaded file. */ removeUploadedFileCallback: (index: number) => void; } /** * Custom file label template context. * @group Interface */ interface FileUploadFileLabelTemplateContext { /** * File list. */ $implicit: File[]; } /** * Defines valid templates in FileUpload. * @group Templates */ interface FileUploadTemplates { /** * Custom file template. */ file(): TemplateRef; /** * Custom file label template. * @param {Object} context - file label template context. */ filelabel(context: FileUploadFileLabelTemplateContext): TemplateRef; /** * Custom header template. * @param {Object} context - header template context. */ header(context: FileUploadHeaderTemplateContext): TemplateRef; /** * Custom content template. * @param {Object} context - content template context. */ content(context: FileUploadContentTemplateContext): TemplateRef; /** * Custom toolbar template. */ toolbar(): TemplateRef; /** * Custom choose icon template. */ chooseicon(): TemplateRef; /** * Custom upload icon template. */ uploadicon(): TemplateRef; /** * Custom cancel icon template. */ cancelicon(): TemplateRef; /** * Custom empty state template. */ empty(): TemplateRef; } export type { FileBeforeUploadEvent, FileProgressEvent, FileRemoveEvent, FileSelectEvent, FileSendEvent, FileUploadContentTemplateContext, FileUploadErrorEvent, FileUploadEvent, FileUploadFileLabelTemplateContext, FileUploadHandlerEvent, FileUploadHeaderTemplateContext, FileUploadPassThrough, FileUploadPassThroughOptions, FileUploadTemplates, FormDataEvent, RemoveUploadedFileEvent, UploadEvent };