UNPKG

@progress/kendo-angular-upload

Version:

Kendo UI Angular Upload Component

276 lines (275 loc) 11.9 kB
/**----------------------------------------------------------------------------------------- * 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 %}). */ 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; /** * By default, the selected files are immediately uploaded * ([see example]({% slug fileprocessing_upload %}#toc-automatic-upload-of-files)). * To change this behavior, set `autoUpload` to `false`. */ set autoUpload(autoUpload: boolean); get autoUpload(): boolean; /** * When enabled, all files in the selection are uploaded in one request * ([see example]({% slug fileprocessing_upload %}#toc-upload-of-batches-of-files)). * Any files that are selected one after the other are uploaded in separate requests. */ set batch(batch: boolean); get batch(): boolean; /** * Configures whether credentials (cookies, headers) will be sent for cross-site requests * ([see example]({% slug credentials_upload %}#toc-attaching-credentials-to-requests)). * The default values is `true`. Setting `withCredentials` has no effect on same-site requests. * To add credentials to the request, use the `saveHeaders` or `removeHeaders` property, * or the [`upload`]({% slug api_upload_uploadevent %}) event. */ set withCredentials(withCredentials: boolean); get withCredentials(): boolean; /** * Sets the [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) key which contains the files submitted to `saveUrl`. * The default value is `files`. */ set saveField(saveField: string); get saveField(): string; /** * Configures the [`HttpHeaders`](https://angular.io/api/common/http/HttpHeaders) * that are attached to each upload request. */ set saveHeaders(saveHeaders: HttpHeaders); get saveHeaders(): HttpHeaders; /** * Sets the [`RequestMethod`](https://angular.io/api/http/RequestMethod) of the upload request. * The default value is `POST`. */ set saveMethod(saveMethod: string); get saveMethod(): string; /** * Sets the URL of the endpoint for the upload request. * The request [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) key is named after the `saveField` property. * It contains the list of files to be uploaded. */ set saveUrl(saveUrl: string); get saveUrl(): string; /** * Sets the expected [`response type`](https://angular.io/api/common/http/HttpRequest#responseType) of the server. * It is used to parse the response appropriately. * @default 'json' */ set responseType(responseType: 'arraybuffer' | 'blob' | 'json' | 'text'); get responseType(): 'arraybuffer' | 'blob' | 'json' | 'text'; /** * Sets the [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) key * which contains the list of file names that are submitted to `removeUrl`. * The default value is `fileNames`. */ set removeField(removeField: string); get removeField(): string; /** * Configures the [`HttpHeaders`](https://angular.io/api/common/http/HttpHeaders) * that are attached to each `remove` request. */ set removeHeaders(removeHeaders: HttpHeaders); get removeHeaders(): HttpHeaders; /** * Sets the [`RequestMethod`](https://angular.io/api/http/RequestMethod) of the `remove` request. * The default value is `POST`. */ set removeMethod(removeMethod: string); get removeMethod(): string; /** * Sets the URL of the endpoint for the `remove` request. * The [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) request key is named after the `removeField` property. * It contains the list of file names which will be removed. */ set removeUrl(removeUrl: string); get removeUrl(): string; /** * Enables the chunk functionality of the Upload. * * @default false */ chunkable: ChunkSettings | boolean; /** * Specifies if the selected files are uploaded simultaneously or one by one. * * @default true */ set concurrent(concurrent: boolean); get concurrent(): boolean; /** * Toggles the visibility of the file list. * @default true */ showFileList: boolean; /** * @hidden */ set tabIndex(tabIndex: number); get tabIndex(): number; /** * Specifies the possible layout of the action buttons. */ 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. If prevented, the files will not be cleared. */ clear: EventEmitter<ClearEvent>; /** * Fires when all active uploads are completed either successfully or with errors. */ complete: EventEmitter<any>; /** * Fires when an `upload` or `remove` operation has failed. */ error: EventEmitter<ErrorEvent>; /** * Fires when the upload of a file has been paused. */ pause: EventEmitter<any>; /** * Fires when the upload of a file has been resumed. */ resume: EventEmitter<any>; /** * Fires when an `upload` or `remove` operation is successfully completed. */ success: EventEmitter<SuccessEvent>; /** * Fires when one or more files are about to be uploaded. If prevented, the files will neither be uploaded, nor added to the file list. */ upload: EventEmitter<UploadEvent>; /** * Fires when one or more files are being uploaded. */ uploadProgress: EventEmitter<UploadProgressEvent>; /** * Fires when the value of the component has changed as a result of 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. * The `pauseFileByUid` 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 has been previously paused. * The `resumeFileByUid` 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; /** * Triggers the removal of 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; /** * Triggers another upload attempt of an unsuccessfully uploaded file or a batch of files. * @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 which pass the set restrictions. */ uploadFiles(): void; /** * Visually clears all files from the UI without issuing 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>; }