UNPKG

ng-zorro-antd-yj

Version:

An enterprise-class UI components based on Ant Design and Angular

522 lines 42.4 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { ENTER } from '@angular/cdk/keycodes'; import { HttpClient, HttpEventType, HttpHeaders, HttpRequest, HttpResponse } from '@angular/common/http'; import { Component, ElementRef, HostListener, Input, Optional, ViewChild, ViewEncapsulation } from '@angular/core'; import { of, Observable, Subscription } from 'rxjs'; import { switchMap } from 'rxjs/operators'; import { NzUpdateHostClassService } from '../core/services/update-host-class.service'; export class NzUploadBtnComponent { // #endregion /** * @param {?} http * @param {?} el * @param {?} updateHostClassService */ constructor(http, el, updateHostClassService) { this.http = http; this.el = el; this.updateHostClassService = updateHostClassService; this.reqs = {}; this.inited = false; this.destroy = false; // #region fields this.classes = {}; // #region styles this.prefixCls = 'ant-upload'; if (!http) { throw new Error(`Not found 'HttpClient', You can import 'HttpClientModule' in your root module.`); } } // #endregion /** * @return {?} */ onClick() { if (this.options.disabled || !this.options.openFileDialogOnClick) { return; } ((/** @type {?} */ (this.file.nativeElement))).click(); } /** * @param {?} e * @return {?} */ onKeyDown(e) { if (this.options.disabled) { return; } if (e.key === 'Enter' || e.keyCode === ENTER) { this.onClick(); } } /** * @param {?} e * @return {?} */ onFileDrop(e) { if (this.options.disabled || e.type === 'dragover') { e.preventDefault(); return; } if (this.options.directory) { this.traverseFileTree((/** @type {?} */ (e.dataTransfer)).items); } else { /** @type {?} */ const files = Array.prototype.slice .call((/** @type {?} */ (e.dataTransfer)).files) .filter((/** * @param {?} file * @return {?} */ (file) => this.attrAccept(file, this.options.accept))); if (files.length) { this.uploadFiles(files); } } e.preventDefault(); } /** * @param {?} e * @return {?} */ onChange(e) { if (this.options.disabled) { return; } /** @type {?} */ const hie = (/** @type {?} */ (e.target)); this.uploadFiles((/** @type {?} */ (hie.files))); hie.value = ''; } /** * @private * @param {?} files * @return {?} */ traverseFileTree(files) { // tslint:disable-next-line:no-any /** @type {?} */ const _traverseFileTree = (/** * @param {?} item * @param {?} path * @return {?} */ (item, path) => { if (item.isFile) { item.file((/** * @param {?} file * @return {?} */ (file) => { if (this.attrAccept(file, this.options.accept)) { this.uploadFiles([file]); } })); } else if (item.isDirectory) { /** @type {?} */ const dirReader = item.createReader(); // tslint:disable-next-line:no-any dirReader.readEntries((/** * @param {?} entries * @return {?} */ (entries) => { for (const entrieItem of entries) { _traverseFileTree(entrieItem, `${path}${item.name}/`); } })); } }); // tslint:disable-next-line:no-any for (const file of (/** @type {?} */ (files))) { _traverseFileTree(file.webkitGetAsEntry(), ''); } } /** * @private * @param {?} file * @param {?=} acceptedFiles * @return {?} */ attrAccept(file, acceptedFiles) { if (file && acceptedFiles) { /** @type {?} */ const acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(','); /** @type {?} */ const fileName = '' + file.name; /** @type {?} */ const mimeType = '' + file.type; /** @type {?} */ const baseMimeType = mimeType.replace(/\/.*$/, ''); return acceptedFilesArray.some((/** * @param {?} type * @return {?} */ type => { /** @type {?} */ const validType = type.trim(); if (validType.charAt(0) === '.') { return (fileName .toLowerCase() .indexOf(validType.toLowerCase(), fileName.toLowerCase().length - validType.toLowerCase().length) !== -1); } else if (/\/\*$/.test(validType)) { // This is something like a image/* mime type return baseMimeType === validType.replace(/\/.*$/, ''); } return mimeType === validType; })); } return true; } /** * @private * @param {?} file * @return {?} */ attachUid(file) { if (!file.uid) { file.uid = Math.random() .toString(36) .substring(2); } return file; } /** * @param {?} fileList * @return {?} */ uploadFiles(fileList) { /** @type {?} */ let filters$ = of(Array.prototype.slice.call(fileList)); if (this.options.filters) { this.options.filters.forEach((/** * @param {?} f * @return {?} */ f => { filters$ = filters$.pipe(switchMap((/** * @param {?} list * @return {?} */ list => { /** @type {?} */ const fnRes = f.fn(list); return fnRes instanceof Observable ? fnRes : of(fnRes); }))); })); } filters$.subscribe((/** * @param {?} list * @return {?} */ list => { list.forEach((/** * @param {?} file * @return {?} */ (file) => { this.attachUid(file); this.upload(file, list); })); }), (/** * @param {?} e * @return {?} */ e => { console.warn(`Unhandled upload filter error`, e); })); } /** * @private * @param {?} file * @param {?} fileList * @return {?} */ upload(file, fileList) { if (!this.options.beforeUpload) { return this.post(file); } /** @type {?} */ const before = this.options.beforeUpload(file, fileList); if (before instanceof Observable) { before.subscribe((/** * @param {?} processedFile * @return {?} */ (processedFile) => { /** @type {?} */ const processedFileType = Object.prototype.toString.call(processedFile); if (processedFileType === '[object File]' || processedFileType === '[object Blob]') { this.attachUid(processedFile); this.post(processedFile); } else if (typeof processedFile === 'boolean' && processedFile !== false) { this.post(file); } }), (/** * @param {?} e * @return {?} */ e => { console.warn(`Unhandled upload beforeUpload error`, e); })); } else if (before !== false) { return this.post(file); } } /** * @private * @param {?} file * @return {?} */ post(file) { if (this.destroy) { return; } /** @type {?} */ const opt = this.options; const { uid } = file; let { data, headers } = opt; if (typeof data === 'function') { data = ((/** @type {?} */ (data)))(file); } if (typeof headers === 'function') { headers = ((/** @type {?} */ (headers)))(file); } /** @type {?} */ const args = { action: opt.action, name: opt.name, headers, file, data, withCredentials: opt.withCredentials, onProgress: opt.onProgress ? (/** * @param {?} e * @return {?} */ e => { (/** @type {?} */ (opt.onProgress))(e, file); }) : undefined, onSuccess: (/** * @param {?} ret * @param {?} xhr * @return {?} */ (ret, xhr) => { this.clean(uid); (/** @type {?} */ (opt.onSuccess))(ret, file, xhr); }), onError: (/** * @param {?} xhr * @return {?} */ xhr => { this.clean(uid); (/** @type {?} */ (opt.onError))(xhr, file); }) }; /** @type {?} */ const req$ = (opt.customRequest || this.xhr).call(this, args); if (!(req$ instanceof Subscription)) { console.warn(`Must return Subscription type in '[nzCustomRequest]' property`); } this.reqs[uid] = req$; (/** @type {?} */ (opt.onStart))(file); } /** * @private * @param {?} args * @return {?} */ xhr(args) { /** @type {?} */ const formData = new FormData(); // tslint:disable-next-line:no-any formData.append((/** @type {?} */ (args.name)), (/** @type {?} */ (args.file))); if (args.data) { Object.keys(args.data).map((/** * @param {?} key * @return {?} */ key => { formData.append(key, (/** @type {?} */ (args.data))[key]); })); } if (!args.headers) { args.headers = {}; } if (args.headers['X-Requested-With'] !== null) { args.headers['X-Requested-With'] = `XMLHttpRequest`; } else { delete args.headers['X-Requested-With']; } /** @type {?} */ const req = new HttpRequest('POST', (/** @type {?} */ (args.action)), formData, { reportProgress: true, withCredentials: args.withCredentials, headers: new HttpHeaders(args.headers) }); return this.http.request(req).subscribe((/** * @param {?} event * @return {?} */ (event) => { if (event.type === HttpEventType.UploadProgress) { if ((/** @type {?} */ (event.total)) > 0) { // tslint:disable-next-line:no-any ((/** @type {?} */ (event))).percent = (event.loaded / (/** @type {?} */ (event.total))) * 100; } (/** @type {?} */ (args.onProgress))(event, args.file); } else if (event instanceof HttpResponse) { (/** @type {?} */ (args.onSuccess))(event.body, args.file, event); } }), (/** * @param {?} err * @return {?} */ err => { this.abort(args.file); (/** @type {?} */ (args.onError))(err, args.file); })); } /** * @private * @param {?} uid * @return {?} */ clean(uid) { /** @type {?} */ const req$ = this.reqs[uid]; if (req$ instanceof Subscription) { req$.unsubscribe(); } delete this.reqs[uid]; } /** * @param {?=} file * @return {?} */ abort(file) { if (file) { this.clean(file && file.uid); } else { Object.keys(this.reqs).forEach((/** * @param {?} uid * @return {?} */ uid => this.clean(uid))); } } /** * @private * @return {?} */ setClassMap() { /** @type {?} */ const classMap = Object.assign({ [this.prefixCls]: true, [`${this.prefixCls}-disabled`]: this.options.disabled }, this.classes); this.updateHostClassService.updateHostClass(this.el.nativeElement, classMap); } /** * @return {?} */ ngOnInit() { this.inited = true; this.setClassMap(); } /** * @return {?} */ ngOnChanges() { if (this.inited) { this.setClassMap(); } } /** * @return {?} */ ngOnDestroy() { this.destroy = true; this.abort(); } } NzUploadBtnComponent.decorators = [ { type: Component, args: [{ selector: '[nz-upload-btn]', template: "<input type=\"file\" #file (change)=\"onChange($event)\"\n [attr.accept]=\"options.accept\"\n [attr.directory]=\"options.directory ? 'directory': null\"\n [attr.webkitdirectory]=\"options.directory ? 'webkitdirectory': null\"\n [multiple]=\"options.multiple\" style=\"display: none;\">\n<ng-content></ng-content>", host: { '[attr.tabindex]': '"0"', '[attr.role]': '"button"' }, providers: [NzUpdateHostClassService], preserveWhitespaces: false, encapsulation: ViewEncapsulation.None }] } ]; /** @nocollapse */ NzUploadBtnComponent.ctorParameters = () => [ { type: HttpClient, decorators: [{ type: Optional }] }, { type: ElementRef }, { type: NzUpdateHostClassService } ]; NzUploadBtnComponent.propDecorators = { file: [{ type: ViewChild, args: ['file',] }], classes: [{ type: Input }], options: [{ type: Input }], onClick: [{ type: HostListener, args: ['click',] }], onKeyDown: [{ type: HostListener, args: ['keydown', ['$event'],] }], onFileDrop: [{ type: HostListener, args: ['drop', ['$event'],] }, { type: HostListener, args: ['dragover', ['$event'],] }] }; if (false) { /** @type {?} */ NzUploadBtnComponent.prototype.reqs; /** * @type {?} * @private */ NzUploadBtnComponent.prototype.inited; /** * @type {?} * @private */ NzUploadBtnComponent.prototype.destroy; /** @type {?} */ NzUploadBtnComponent.prototype.file; /** @type {?} */ NzUploadBtnComponent.prototype.classes; /** @type {?} */ NzUploadBtnComponent.prototype.options; /** * @type {?} * @private */ NzUploadBtnComponent.prototype.prefixCls; /** * @type {?} * @private */ NzUploadBtnComponent.prototype.http; /** * @type {?} * @private */ NzUploadBtnComponent.prototype.el; /** * @type {?} * @private */ NzUploadBtnComponent.prototype.updateHostClassService; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotdXBsb2FkLWJ0bi5jb21wb25lbnQuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZy16b3Jyby1hbnRkLXlqLyIsInNvdXJjZXMiOlsidXBsb2FkL256LXVwbG9hZC1idG4uY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7QUFBQSxPQUFPLEVBQUUsS0FBS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