@progress/kendo-angular-upload
Version:
Kendo UI Angular Upload Component
299 lines (298 loc) • 12 kB
TypeScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { HttpHeaders } from '@angular/common/http';
import { ElementRef, EventEmitter, NgZone, OnDestroy, OnInit, Renderer2, ChangeDetectorRef, Injector } from '@angular/core';
import { ControlValueAccessor } from '@angular/forms';
import { LocalizationService } from '@progress/kendo-angular-l10n';
import { Direction } from './types/direction';
import { FileInfo } from './types';
import { NavigationService } from './navigation.service';
import { CancelEvent, ClearEvent, ErrorEvent, SuccessEvent, UploadEvent, UploadProgressEvent } from './events';
import { UploadService } from './upload.service';
import { ChunkSettings } from './types/chunk-settings';
import { DropZoneService } from './dropzone.service';
import { ActionsLayout } from './common/action-buttons-layout';
import { UploadFileSelectBase } from './common/base';
import * as i0 from "@angular/core";
/**
* @hidden
*/
export declare const UPLOAD_VALUE_ACCESSOR: any;
/**
* Represents the [Kendo UI Upload component for Angular]({% slug overview_upload %}).
*
* @example
* ```html
* <kendo-upload
* [saveUrl]="uploadSaveUrl"
* [removeUrl]="uploadRemoveUrl">
* </kendo-upload>
* ```
*
* @remarks
* Supported children components are: {@link CustomMessagesComponent}
*/
export declare class UploadComponent extends UploadFileSelectBase implements OnInit, OnDestroy, ControlValueAccessor {
protected uploadService: UploadService;
private localization;
protected navigation: NavigationService;
private dropZoneService;
protected zone: NgZone;
private renderer;
protected cdr: ChangeDetectorRef;
protected injector: Injector;
/**
* Specifies whether selected files upload automatically
* ([see example]({% slug fileprocessing_upload %}#toc-automatic-upload-of-files)).
* Set `autoUpload` to `false` to change this behavior.
*
* @default true
*/
set autoUpload(autoUpload: boolean);
get autoUpload(): boolean;
/**
* Specifies whether all files in the selection upload in a single request
* ([see example]({% slug fileprocessing_upload %}#toc-upload-of-batches-of-files)).
* Files selected one after the other upload in separate requests.
*
* @default false
*/
set batch(batch: boolean);
get batch(): boolean;
/**
* Specifies whether credentials (cookies, headers) are sent for cross-site requests
* ([see example]({% slug credentials_upload %}#toc-attaching-credentials-to-requests)).
* Set `withCredentials` has no effect on same-site requests.
* Use the `saveHeaders` or `removeHeaders` property to add credentials to the request.
* You can also use the [`upload`]({% slug api_upload_uploadevent %}) event.
*
* @default true
*/
set withCredentials(withCredentials: boolean);
get withCredentials(): boolean;
/**
* Specifies the [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) key which contains the files submitted to `saveUrl`.
*
*/
set saveField(saveField: string);
get saveField(): string;
/**
* Specifies the [`HttpHeaders`](https://angular.io/api/common/http/HttpHeaders) attached to each upload request.
*/
set saveHeaders(saveHeaders: HttpHeaders);
get saveHeaders(): HttpHeaders;
/**
* Specifies the [`RequestMethod`](https://angular.io/api/http/RequestMethod) of the upload request.
*
*/
set saveMethod(saveMethod: string);
get saveMethod(): string;
/**
* Specifies the URL of the endpoint for the upload request.
* The request [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) key uses the name from the `saveField` property.
* This key contains the list of files to be uploaded.
*/
set saveUrl(saveUrl: string);
get saveUrl(): string;
/**
* Specifies the expected [`response type`](https://angular.io/api/common/http/HttpRequest#responseType) of the server.
* The response type determines how the response is parsed.
*
* @default 'json'
*/
set responseType(responseType: 'arraybuffer' | 'blob' | 'json' | 'text');
get responseType(): 'arraybuffer' | 'blob' | 'json' | 'text';
/**
* Specifies the [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) key which contains the list of file names submitted to `removeUrl`.
*
*/
set removeField(removeField: string);
get removeField(): string;
/**
* Specifies the [`HttpHeaders`](https://angular.io/api/common/http/HttpHeaders) attached to each `remove` request.
*/
set removeHeaders(removeHeaders: HttpHeaders);
get removeHeaders(): HttpHeaders;
/**
* Specifies the [`RequestMethod`](https://angular.io/api/http/RequestMethod) of the `remove` request.
*
*/
set removeMethod(removeMethod: string);
get removeMethod(): string;
/**
* Specifies the URL of the endpoint for the `remove` request.
* The [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) request key uses the name from the `removeField` property.
* This key contains the list of file names to be removed.
*/
set removeUrl(removeUrl: string);
get removeUrl(): string;
/**
* Specifies whether the chunk functionality of the Upload is enabled.
*
* @default false
*/
chunkable: ChunkSettings | boolean;
/**
* Specifies whether selected files upload simultaneously or one by one.
*
* @default true
*/
set concurrent(concurrent: boolean);
get concurrent(): boolean;
/**
* Specifies whether the file list is visible.
*
* @default true
*/
showFileList: boolean;
/**
* @hidden
*/
set tabIndex(tabIndex: number);
get tabIndex(): number;
/**
* Specifies the layout of the action buttons.
*
* @default 'end'
*/
actionsLayout: ActionsLayout;
fileSelectInput: ElementRef;
/**
* Fires when the upload is canceled while in progress.
*/
cancel: EventEmitter<CancelEvent>;
/**
* Fires when the file list is about to be cleared.
* Prevent this event to keep the files in the list.
*/
clear: EventEmitter<ClearEvent>;
/**
* Fires when all active uploads complete successfully or with errors.
*/
complete: EventEmitter<any>;
/**
* Fires when an `upload` or `remove` operation fails.
*/
error: EventEmitter<ErrorEvent>;
/**
* Fires when the upload of a file is paused.
*/
pause: EventEmitter<any>;
/**
* Fires when the upload of a file is resumed.
*/
resume: EventEmitter<any>;
/**
* Fires when an `upload` or `remove` operation completes successfully.
*/
success: EventEmitter<SuccessEvent>;
/**
* Fires when one or more files are about to be uploaded.
* Prevent this event to stop the files from uploading and being added to the file list.
*/
upload: EventEmitter<UploadEvent>;
/**
* Fires when one or more files are uploading.
*/
uploadProgress: EventEmitter<UploadProgressEvent>;
/**
* Fires when the component value changes after a successful `upload`, `remove`, or `clear` operation.
*/
valueChange: EventEmitter<Array<FileInfo>>;
get dir(): string;
direction: Direction;
wrapper: HTMLElement;
fileListId: string;
private documentClick;
private blurSubscription;
private wrapperFocusSubscription;
private selectButtonFocusSubscription;
private localizationChangeSubscription;
private subs;
constructor(uploadService: UploadService, localization: LocalizationService, navigation: NavigationService, dropZoneService: DropZoneService, zone: NgZone, renderer: Renderer2, cdr: ChangeDetectorRef, wrapper: ElementRef, injector: Injector);
ngOnInit(): void;
ngOnChanges(changes: any): void;
ngOnDestroy(): void;
/**
* @hidden
*/
writeValue(newValue: any): void;
/**
* @hidden
*/
get showActionButtons(): boolean;
/**
* @hidden
*/
get showTotalStatus(): boolean;
/**
* @hidden
*/
textFor(key: string): string;
/**
* @hidden
*/
getIds(): {
buttonId: string;
fileListId: string;
};
/**
* Pauses the upload process of a file that is currently uploading.
* This method requires the `chunkable` option of the Upload to be enabled.
*
* @param uid The `uid` of the file that will be paused.
*/
pauseFileByUid(uid: string): void;
/**
* Resumes the upload process for a file that was previously paused.
* This method requires the `chunkable` option of the Upload to be enabled.
*
* @param uid The `uid` of the file that will be resumed.
*/
resumeFileByUid(uid: string): void;
/**
* Removes a file or a batch of files.
*
* @param uid The `uid` of the file or a batch of files that will be removed.
*/
removeFilesByUid(uid: string): void;
/**
* Retries the upload of a file or batch of files that failed to upload.
*
* @param uid The `uid` of the file or a batch of files to be retried.
*/
retryUploadByUid(uid: string): void;
/**
* Cancels the upload of a file or a batch of files.
*
* @param uid The `uid` of the file or a batch of files that will be canceled.
*/
cancelUploadByUid(uid: string): void;
/**
* Uploads the currently selected files that pass the set restrictions.
*/
uploadFiles(): void;
/**
* Clears all files from the UI without sending requests to the remove handler.
*/
clearFiles(): void;
/**
* @hidden
* Used by the external dropzone to add files to the Upload
*/
addFiles(files: FileInfo[]): void;
/**
* @hidden
* Used to determine if the component is empty.
*/
isEmpty(): boolean;
private verifySettings;
private subscribeBlur;
private handleKeydown;
private subscribeFocus;
private attachEventHandlers;
static ɵfac: i0.ɵɵFactoryDeclaration<UploadComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<UploadComponent, "kendo-upload", ["kendoUpload"], { "autoUpload": { "alias": "autoUpload"; "required": false; }; "batch": { "alias": "batch"; "required": false; }; "withCredentials": { "alias": "withCredentials"; "required": false; }; "saveField": { "alias": "saveField"; "required": false; }; "saveHeaders": { "alias": "saveHeaders"; "required": false; }; "saveMethod": { "alias": "saveMethod"; "required": false; }; "saveUrl": { "alias": "saveUrl"; "required": false; }; "responseType": { "alias": "responseType"; "required": false; }; "removeField": { "alias": "removeField"; "required": false; }; "removeHeaders": { "alias": "removeHeaders"; "required": false; }; "removeMethod": { "alias": "removeMethod"; "required": false; }; "removeUrl": { "alias": "removeUrl"; "required": false; }; "chunkable": { "alias": "chunkable"; "required": false; }; "concurrent": { "alias": "concurrent"; "required": false; }; "showFileList": { "alias": "showFileList"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; "actionsLayout": { "alias": "actionsLayout"; "required": false; }; }, { "cancel": "cancel"; "clear": "clear"; "complete": "complete"; "error": "error"; "pause": "pause"; "resume": "resume"; "success": "success"; "upload": "upload"; "uploadProgress": "uploadProgress"; "valueChange": "valueChange"; }, never, never, true, never>;
}