UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

139 lines 5.28 kB
import { ChangeDetectorRef, ElementRef, EventEmitter, OnInit } from '@angular/core'; import { ControlValueAccessor, AbstractControl } from '@angular/forms'; import { TranslateService } from '@ngx-translate/core'; import { BytesPipe } from '../common/bytes.pipe'; import { FilesService } from '../common/files.service'; import * as i0 from "@angular/core"; /** * A drop-zone which is a file selector allowing users to select file(s) from their file system, either natively or by drag and drop. * * ```html * <div> * <c8y-drop-area * (dropped)="uploadFile($event)" * [icon]="'upload'" * [accept]="'.zip,.7z,video'"> * </c8y-drop-area> * </div> * ``` */ export declare class DropAreaComponent implements OnInit, ControlValueAccessor { private cd; private filesService; private translate; private bytes; private ref; formControl: AbstractControl<any, any>; title: "Upload file"; message: "Drop file here"; icon: string; loadingMessage: "Uploading…"; forceHideList: boolean; /** Affects displaying both the drop zone and the list of dropped files. */ alwaysShow: boolean; clickToOpen: boolean; loading: boolean; /** * Current progress of the upload as a percentage. If not given a spinner will be displayed. */ progress: number; dropped: EventEmitter<DroppedFile[]>; maxAllowedFiles: number; files: FileList; maxFileSizeInMegaBytes: number; /** Specifies a filter for what file types the user can pick from the file input dialog box. * * Specify file types by extensions: * ```html * [accept]="'.zip,.7z'" * ``` * * Specify file types by extensions and generic types [GENERIC_FILE_TYPE]{@link GENERIC_FILE_TYPE}: * ```html * [accept]="'.pdf,archive'" * ``` * * Specify file types by generic types [GENERIC_FILE_TYPE]{@link GENERIC_FILE_TYPE}: * ```html * [accept]="'archive,video'" * ``` */ accept: string; isOver: boolean; errors: boolean; errorMessage: string; filesNameString: string; acceptedExts: string[]; hasDropAreaSmallClass: boolean; area: ElementRef; zone: ElementRef; picker: ElementRef; constructor(cd: ChangeDetectorRef, filesService: FilesService, translate: TranslateService, bytes: BytesPipe, ref: ElementRef); onkeyup(event: KeyboardEvent): void; ngOnInit(): void; ngAfterViewChecked(): void; /** * Toggles the style of the drop zone element when a file is dragged over the component. */ toggle(): void; /** * Shows computer browser with files to drop into drop-area zone. */ showPicker($event?: any): void; /** * Triggered when file is on over drop area, but not dropped. */ onOver(): void; /** * Triggered when file is dropped. */ onPick($event: any): void; /** * Handle file when it is dropped into drop-area. */ onDrop($event: any): void; /** * Checks condition what should be displayed: drop-area zone or list of dropped files. */ shouldShowFilesList(): boolean; /** * Triggered when file is picked over web application. */ stopDragging(): void; /** * Delete files already dropped files. */ onDelete(): void; onChange: (value: any) => void; onTouched: () => void; writeValue(value: any): void; registerOnChange(fn: any): void; registerOnTouched(fn: any): void; private onFilesSelected; private onFileInvalidNameLength; private onFileInvalidType; private onFileInvalidSize; private convertMegaBytesToBytes; private getFilesNamesAsString; private isFilesArrayEmpty; private isTooManyFiles; private isFilesAnObjectOrArray; private hasEmptyFiles; private isAnyFileEmpty; private clearErrors; private preventDefault; private compose; private read; private onLoad; static ɵfac: i0.ɵɵFactoryDeclaration<DropAreaComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<DropAreaComponent, "c8y-drop-area", never, { "formControl": { "alias": "formControl"; "required": false; }; "title": { "alias": "title"; "required": false; }; "message": { "alias": "message"; "required": false; }; "icon": { "alias": "icon"; "required": false; }; "loadingMessage": { "alias": "loadingMessage"; "required": false; }; "forceHideList": { "alias": "forceHideList"; "required": false; }; "alwaysShow": { "alias": "alwaysShow"; "required": false; }; "clickToOpen": { "alias": "clickToOpen"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "progress": { "alias": "progress"; "required": false; }; "maxAllowedFiles": { "alias": "maxAllowedFiles"; "required": false; }; "files": { "alias": "files"; "required": false; }; "maxFileSizeInMegaBytes": { "alias": "maxFileSizeInMegaBytes"; "required": false; }; "accept": { "alias": "accept"; "required": false; }; }, { "dropped": "dropped"; }, never, ["*"], true, never>; } export interface DroppedFile { file: File; readAsText(): any; readAsArrayBuffer(): any; readAsBinaryString(): any; readAsDataURL(): any; readAsJson(): any; } //# sourceMappingURL=drop-area.component.d.ts.map