UNPKG

@evan.network/ui-angular-core

Version:

The angular-core operates as an global and central library for the evan.network Angular 5 frontend development. Using this project you will be able to to the following things:

150 lines (149 loc) 4.27 kB
import { ChangeDetectorRef, ControlValueAccessor, DomSanitizer, ElementRef, EventEmitter } from 'angular-libs'; import { EvanUtilService } from '../../services/utils'; import { EvanFileService } from '../../services/ui/files'; import { AsyncComponent } from '../../classes/AsyncComponent'; /**************************************************************************************************/ /** * file selector component for HTML 5 &IOS & Anroid * * Usage: * <evan-file-select * [label]="'_dapptaskboard.files' | translate" * [(ngModel)]="files" * [minFiles]="1" * [maxFiles]="10"> * </evan-file-select> * * @class Component EvanFileSelectComponent */ export declare class EvanFileSelectComponent extends AsyncComponent implements ControlValueAccessor { private _DomSanitizer; private fileService; private ref; private utils; /***************** inputs & outpus *****************/ /** * this component is displayed like an ionic input, defines property or hides it */ label: string; /** * optional button text that should be displayed for the add button */ buttonText: string; /** * files that should be uploaded */ ngModel: Array<any>; /** * disable file select or not */ disabled: boolean; /** * input type="file" accept attribute */ accept: string; /** * enable download of files */ downloadable: boolean; /** * minimum amount of files that must be uploaded */ minFiles: number; /** * maximum amount of files that can be uploaded */ maxFiles: number; /** * are multiple files allowed? */ multiple: boolean; /** * Event emitter to tell using component, that something has changed */ onChange: EventEmitter<any>; /***************** variables *****************/ /** * input element for selection more items */ fileSelect: ElementRef; /** * dropArea for files */ dropArea: ElementRef; /** * check if min files and max files requirements are resolved */ isValid: boolean; /** * true when file selector was opened initially */ touched: boolean; /** * From ControlValueAccessor interface */ private onTouchedCallback; /** * allow the drop of files */ private allowDropZone; /** * only deny drop, if one second after the event triggered, no dragover event occures */ private denyDropTimeout; /***************** initialization *****************/ constructor(_DomSanitizer: DomSanitizer, fileService: EvanFileService, ref: ChangeDetectorRef, utils: EvanUtilService); _ngOnInit(): Promise<void>; /** * Append this functions to handle a correct formular reaction including name, required and so on. */ writeValue(value: any): void; propagateChange: (_: any) => void; registerOnChange(fn: any): void; registerOnTouched(fn: any): void; /***************** functions *****************/ /** * Is everything is valid? * * @return {<type>} { description_of_the_return_value } */ setIsValid(): void; /** * Add new files to the file upload list */ selectFiles(): void; /** * Is triggered when files were changed. */ filesChanged($event: any): void; /** * Is triggered when files were dropped. */ filesDropped($event: any): void; /** * allows the drop of files * * @param {object} ev drop event */ allowDrop(ev: any): void; /** * deny the drop of files * * @param {object} ev drop event */ denyDrop(ev: any): void; /** * Remove a newly selected file from the upload list * * @param {file} file file object that should be removed * @param {number} index index of the file within the ngModel */ removeFile(file: any, index: number): void; /** * Parse the file size to a human readable format * * @param {number} size size in B * @return {string} XXX KB / XXX MB */ parseFileSize(size: number): string; }