diff --git a/projects/file-picker/package.json b/projects/file-picker/package.json index 0030b1c..a7a346b 100644 --- a/projects/file-picker/package.json +++ b/projects/file-picker/package.json @@ -1,10 +1,10 @@ { "name": "ngx-awesome-uploader", - "version": "8.1.1", + "version": "8.1.2", "description": "Angular Library for uploading files with Real-Time Progress bar, File Preview, Drag && Drop and Custom Template with Multi Language support", "peerDependencies": { - "@angular/common": "^6.0.0 || ^7.0.0 || ^8.0.0", - "@angular/core": " ^6.0.0 || ^7.0.0 || ^8.0.0" + "@angular/common": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0", + "@angular/core": " ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0" }, "keywords": [ "ngx", diff --git a/projects/file-picker/src/lib/file-drop/file-drop.component.ts b/projects/file-picker/src/lib/file-drop/file-drop.component.ts index 30104c8..3a2287f 100644 --- a/projects/file-picker/src/lib/file-drop/file-drop.component.ts +++ b/projects/file-picker/src/lib/file-drop/file-drop.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, Output, EventEmitter, NgZone, OnDestroy, Renderer, TemplateRef } from '@angular/core'; +import { Component, Input, Output, EventEmitter, NgZone, OnDestroy, Renderer2 } from '@angular/core'; import { timer, Subscription } from 'rxjs'; import { UploadFile } from './upload-file.model'; @@ -40,7 +40,7 @@ export class FileComponent implements OnDestroy { numOfActiveReadEntries = 0; constructor( private zone: NgZone, - private renderer: Renderer + private renderer: Renderer2 ) { if (!this.customstyle) { this.customstyle = 'drop-zone'; diff --git a/projects/file-picker/src/lib/file-picker.component.ts b/projects/file-picker/src/lib/file-picker.component.ts index 701a88e..1b2ed17 100644 --- a/projects/file-picker/src/lib/file-picker.component.ts +++ b/projects/file-picker/src/lib/file-picker.component.ts @@ -1,5 +1,5 @@ import {FilePickerService} from './file-picker.service'; -import {Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, TemplateRef} from '@angular/core'; +import {Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, TemplateRef, ChangeDetectorRef} from '@angular/core'; import {SafeResourceUrl} from '@angular/platform-browser'; import {FilePreviewModel} from './file-preview.model'; import {getFileType} from './file-upload.utils'; @@ -96,7 +96,7 @@ export class FilePickerComponent implements OnInit, OnDestroy { accept: string; files: FilePreviewModel[] = []; /** File extensions filter */ - @Input() fileExtensions: String; + @Input() fileExtensions: String[]; cropper: any; /** Cropper options. */ @Input() cropperOptions: Object; @@ -116,7 +116,9 @@ export class FilePickerComponent implements OnInit, OnDestroy { cropClosed$ = new Subject(); _onDestroy$ = new Subject(); safeCropImgUrl: SafeResourceUrl; - constructor(private fileService: FilePickerService, private elementRef: ElementRef) { + constructor(private fileService: FilePickerService, + private elementRef: ElementRef + ) { } ngOnInit() { @@ -290,16 +292,17 @@ export class FilePickerComponent implements OnInit, OnDestroy { onUploadSuccess(fileItem: FilePreviewModel): void { this.uploadSuccess.next(fileItem); } - /** Validates file extension */ - isValidExtension(file: File, fileName: string): boolean { - if (!this.fileExtensions) {return true; } - const extension = fileName.split('.').pop(); - if (this.fileExtensions && (!this.fileExtensions.toLowerCase().includes(extension.toLowerCase()))) { - this.validationError.next({file: file, error: FileValidationTypes.extensions}); - return false; - } - return true; + /** Validates file extension */ + isValidExtension(file: File, fileName: string): boolean { + if (!this.fileExtensions) {return true; } + const extension = fileName.split('.').pop(); + const fileExtensions = this.fileExtensions.map(ext => ext.toLowerCase()); + if (fileExtensions.indexOf(extension.toLowerCase()) === -1) { + this.validationError.next({file: file, error: FileValidationTypes.extensions}); + return false; } + return true; +} /** Validates selected file size and total file size */ isValidSize(file: File, size: number): boolean { /** Validating selected file size */