| import { EventEmitter, Directive, Optional, Host, Input, Output, HostBinding, HostListener, Renderer2, ElementRef, TemplateRef, ViewContainerRef, Component, ChangeDetectionStrategy, forwardRef, ChangeDetectorRef, ViewChild, ContentChild, Injectable, NgModule } from '@angular/core'; |
| import { CommonModule } from '@angular/common'; |
| import { NgModel, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms'; |
| import { TemplatePortalDirective, PortalModule } from '@angular/cdk/portal'; |
| import { MatIconModule } from '@angular/material/icon'; |
| import { MatButtonModule } from '@angular/material/button'; |
| import { coerceBooleanProperty } from '@angular/cdk/coercion'; |
| import { mixinDisabled, mixinControlValueAccessor } from '@covalent/core/common'; |
| import { HttpRequest, HttpHeaders, HttpParams, HttpEventType, HttpClient } from '@angular/common/http'; |
| import { Subject } from 'rxjs'; |
| import { tap } from 'rxjs/operators'; |
| |
| /** |
| * @fileoverview added by tsickle |
| * Generated from: directives/file-select.directive.ts |
| * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| class TdFileSelectDirective { |
| /** |
| * @param {?} model |
| */ |
| constructor(model) { |
| this.model = model; |
| this._multiple = false; |
| /** |
| * fileSelect?: function |
| * Event emitted when a file or files are selected in host [HTMLInputElement]. |
| * Emits a [FileList | File] object. |
| * Alternative to not use [(ngModel)]. |
| */ |
| this.fileSelect = new EventEmitter(); |
| } |
| /** |
| * multiple?: boolean |
| * Sets whether multiple files can be selected at once in host element, or just a single file. |
| * Can also be 'multiple' native attribute. |
| * @param {?} multiple |
| * @return {?} |
| */ |
| set multiple(multiple) { |
| this._multiple = coerceBooleanProperty(multiple); |
| } |
| /** |
| * Binds native 'multiple' attribute if [multiple] property is 'true'. |
| * @return {?} |
| */ |
| get multipleBinding() { |
| return this._multiple ? '' : undefined; |
| } |
| /** |
| * Listens to 'change' host event to get [HTMLInputElement] files. |
| * Emits the 'fileSelect' event with a [FileList] or [File] depending if 'multiple' attr exists in host. |
| * Uses [(ngModel)] if declared, instead of emitting 'fileSelect' event. |
| * @param {?} event |
| * @return {?} |
| */ |
| onChange(event) { |
| if (event.target instanceof HTMLInputElement) { |
| /** @type {?} */ |
| const fileInputEl = event.target; |
| /** @type {?} */ |
| const files = fileInputEl.files; |
| if (files.length) { |
| /** @type {?} */ |
| const value = this._multiple ? (files.length > 1 ? files : files[0]) : files[0]; |
| this.model ? this.model.update.emit(value) : this.fileSelect.emit(value); |
| } |
| } |
| } |
| } |
| TdFileSelectDirective.decorators = [ |
| { type: Directive, args: [{ |
| selector: '[tdFileSelect]', |
| },] } |
| ]; |
| /** @nocollapse */ |
| TdFileSelectDirective.ctorParameters = () => [ |
| { type: NgModel, decorators: [{ type: Optional }, { type: Host }] } |
| ]; |
| TdFileSelectDirective.propDecorators = { |
| multiple: [{ type: Input, args: ['multiple',] }], |
| fileSelect: [{ type: Output }], |
| multipleBinding: [{ type: HostBinding, args: ['attr.multiple',] }], |
| onChange: [{ type: HostListener, args: ['change', ['$event'],] }] |
| }; |
| if (false) { |
| /** |
| * @type {?} |
| * @private |
| */ |
| TdFileSelectDirective.prototype._multiple; |
| /** |
| * fileSelect?: function |
| * Event emitted when a file or files are selected in host [HTMLInputElement]. |
| * Emits a [FileList | File] object. |
| * Alternative to not use [(ngModel)]. |
| * @type {?} |
| */ |
| TdFileSelectDirective.prototype.fileSelect; |
| /** |
| * @type {?} |
| * @private |
| */ |
| TdFileSelectDirective.prototype.model; |
| } |
| |
| /** |
| * @fileoverview added by tsickle |
| * Generated from: directives/file-drop.directive.ts |
| * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| class TdFileDropBase { |
| } |
| /* tslint:disable-next-line */ |
| /** @type {?} */ |
| const _TdFileDropMixinBase = mixinDisabled(TdFileDropBase); |
| class TdFileDropDirective extends _TdFileDropMixinBase { |
| /** |
| * @param {?} _renderer |
| * @param {?} _element |
| */ |
| constructor(_renderer, _element) { |
| super(); |
| this._renderer = _renderer; |
| this._element = _element; |
| this._multiple = false; |
| /** |
| * fileDrop?: function |
| * Event emitted when a file or files are dropped in host element after being validated. |
| * Emits a [FileList | File] object. |
| */ |
| this.fileDrop = new EventEmitter(); |
| } |
| /** |
| * multiple?: boolean |
| * Sets whether multiple files can be dropped at once in host element, or just a single file. |
| * Can also be 'multiple' native attribute. |
| * @param {?} multiple |
| * @return {?} |
| */ |
| set multiple(multiple) { |
| this._multiple = coerceBooleanProperty(multiple); |
| } |
| /** |
| * Binds native 'multiple' attribute if [multiple] property is 'true'. |
| * @return {?} |
| */ |
| get multipleBinding() { |
| return this._multiple ? '' : undefined; |
| } |
| /** |
| * Binds native 'disabled' attribute if [disabled] property is 'true'. |
| * @return {?} |
| */ |
| get disabledBinding() { |
| return this.disabled ? '' : undefined; |
| } |
| /** |
| * Listens to 'drop' host event to get validated transfer items. |
| * Emits the 'fileDrop' event with a [FileList] or [File] depending if 'multiple' attr exists in host. |
| * Stops event propagation and default action from browser for 'drop' event. |
| * @param {?} event |
| * @return {?} |
| */ |
| onDrop(event) { |
| if (!this.disabled) { |
| /** @type {?} */ |
| const transfer = ((/** @type {?} */ (event))).dataTransfer; |
| /** @type {?} */ |
| const files = transfer.files; |
| if (files.length) { |
| /** @type {?} */ |
| const value = this._multiple ? (files.length > 1 ? files : files[0]) : files[0]; |
| this.fileDrop.emit(value); |
| } |
| } |
| this._renderer.removeClass(this._element.nativeElement, 'drop-zone'); |
| this._stopEvent(event); |
| } |
| /** |
| * Listens to 'dragover' host event to validate transfer items. |
| * Checks if 'multiple' attr exists in host to allow multiple file drops. |
| * Stops event propagation and default action from browser for 'dragover' event. |
| * @param {?} event |
| * @return {?} |
| */ |
| onDragOver(event) { |
| /** @type {?} */ |
| const transfer = ((/** @type {?} */ (event))).dataTransfer; |
| transfer.dropEffect = this._typeCheck(transfer.types); |
| if (this.disabled || |
| (!this._multiple && ((transfer.items && transfer.items.length > 1) || ((/** @type {?} */ (transfer))).mozItemCount > 1))) { |
| transfer.dropEffect = 'none'; |
| } |
| else { |
| transfer.dropEffect = 'copy'; |
| } |
| this._stopEvent(event); |
| } |
| /** |
| * Listens to 'dragenter' host event to add animation class 'drop-zone' which can be overriden in host. |
| * Stops event propagation and default action from browser for 'dragenter' event. |
| * @param {?} event |
| * @return {?} |
| */ |
| onDragEnter(event) { |
| if (!this.disabled) { |
| this._renderer.addClass(this._element.nativeElement, 'drop-zone'); |
| } |
| this._stopEvent(event); |
| } |
| /** |
| * Listens to 'dragleave' host event to remove animation class 'drop-zone'. |
| * Stops event propagation and default action from browser for 'dragleave' event. |
| * @param {?} event |
| * @return {?} |
| */ |
| onDragLeave(event) { |
| this._renderer.removeClass(this._element.nativeElement, 'drop-zone'); |
| this._stopEvent(event); |
| } |
| /** |
| * Validates if the transfer item types are 'Files'. |
| * @private |
| * @param {?} types |
| * @return {?} |
| */ |
| _typeCheck(types) { |
| /** @type {?} */ |
| let dropEffect = 'none'; |
| if (types && |
| ((((/** @type {?} */ (types))).contains && ((/** @type {?} */ (types))).contains('Files')) || |
| (((/** @type {?} */ (types))).indexOf && ((/** @type {?} */ (types))).indexOf('Files') !== -1))) { |
| dropEffect = 'copy'; |
| } |
| return dropEffect; |
| } |
| /** |
| * @private |
| * @param {?} event |
| * @return {?} |
| */ |
| _stopEvent(event) { |
| event.preventDefault(); |
| event.stopPropagation(); |
| } |
| } |
| TdFileDropDirective.decorators = [ |
| { type: Directive, args: [{ |
| selector: '[tdFileDrop]', |
| inputs: ['disabled'], |
| },] } |
| ]; |
| /** @nocollapse */ |
| TdFileDropDirective.ctorParameters = () => [ |
| { type: Renderer2 }, |
| { type: ElementRef } |
| ]; |
| TdFileDropDirective.propDecorators = { |
| multiple: [{ type: Input, args: ['multiple',] }], |
| fileDrop: [{ type: Output }], |
| multipleBinding: [{ type: HostBinding, args: ['attr.multiple',] }], |
| disabledBinding: [{ type: HostBinding, args: ['attr.disabled',] }], |
| onDrop: [{ type: HostListener, args: ['drop', ['$event'],] }], |
| onDragOver: [{ type: HostListener, args: ['dragover', ['$event'],] }], |
| onDragEnter: [{ type: HostListener, args: ['dragenter', ['$event'],] }], |
| onDragLeave: [{ type: HostListener, args: ['dragleave', ['$event'],] }] |
| }; |
| if (false) { |
| /** |
| * @type {?} |
| * @private |
| */ |
| TdFileDropDirective.prototype._multiple; |
| /** |
| * fileDrop?: function |
| * Event emitted when a file or files are dropped in host element after being validated. |
| * Emits a [FileList | File] object. |
| * @type {?} |
| */ |
| TdFileDropDirective.prototype.fileDrop; |
| /** |
| * @type {?} |
| * @private |
| */ |
| TdFileDropDirective.prototype._renderer; |
| /** |
| * @type {?} |
| * @private |
| */ |
| TdFileDropDirective.prototype._element; |
| } |
| |
| /** |
| * @fileoverview added by tsickle |
| * Generated from: file-input/file-input.component.ts |
| * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| class TdFileInputLabelDirective extends TemplatePortalDirective { |
| /** |
| * @param {?} templateRef |
| * @param {?} viewContainerRef |
| */ |
| constructor(templateRef, viewContainerRef) { |
| super(templateRef, viewContainerRef); |
| } |
| } |
| TdFileInputLabelDirective.decorators = [ |
| { type: Directive, args: [{ |
| selector: '[td-file-input-label]ng-template', |
| },] } |
| ]; |
| /** @nocollapse */ |
| TdFileInputLabelDirective.ctorParameters = () => [ |
| { type: TemplateRef }, |
| { type: ViewContainerRef } |
| ]; |
| class TdFileInputBase { |
| /** |
| * @param {?} _changeDetectorRef |
| */ |
| constructor(_changeDetectorRef) { |
| this._changeDetectorRef = _changeDetectorRef; |
| } |
| } |
| if (false) { |
| /** @type {?} */ |
| TdFileInputBase.prototype._changeDetectorRef; |
| } |
| /* tslint:disable-next-line */ |
| /** @type {?} */ |
| const _TdFileInputMixinBase = mixinControlValueAccessor(mixinDisabled(TdFileInputBase)); |
| class TdFileInputComponent extends _TdFileInputMixinBase { |
| /** |
| * @param {?} _renderer |
| * @param {?} _changeDetectorRef |
| */ |
| constructor(_renderer, _changeDetectorRef) { |
| super(_changeDetectorRef); |
| this._renderer = _renderer; |
| this._multiple = false; |
| /** |
| * select?: function |
| * Event emitted a file is selected |
| * Emits a [File | FileList] object. |
| */ |
| this.select = new EventEmitter(); |
| } |
| /** |
| * @return {?} |
| */ |
| get inputElement() { |
| return this._inputElement.nativeElement; |
| } |
| /** |
| * multiple?: boolean |
| * Sets if multiple files can be dropped/selected at once in [TdFileInputComponent]. |
| * @param {?} multiple |
| * @return {?} |
| */ |
| set multiple(multiple) { |
| this._multiple = coerceBooleanProperty(multiple); |
| } |
| /** |
| * @return {?} |
| */ |
| get multiple() { |
| return this._multiple; |
| } |
| /** |
| * Method executed when a file is selected. |
| * @param {?} files |
| * @return {?} |
| */ |
| handleSelect(files) { |
| this.writeValue(files); |
| this.select.emit(files); |
| } |
| /** |
| * Used to clear the selected files from the [TdFileInputComponent]. |
| * @return {?} |
| */ |
| clear() { |
| this.writeValue(undefined); |
| this._renderer.setProperty(this.inputElement, 'value', ''); |
| } |
| /** |
| * Method executed when the disabled value changes |
| * @param {?} v |
| * @return {?} |
| */ |
| onDisabledChange(v) { |
| if (v) { |
| this.clear(); |
| } |
| } |
| /** |
| * Sets disable to the component. Implemented as part of ControlValueAccessor. |
| * @param {?} isDisabled |
| * @return {?} |
| */ |
| setDisabledState(isDisabled) { |
| this.disabled = isDisabled; |
| } |
| } |
| TdFileInputComponent.decorators = [ |
| { type: Component, args: [{ |
| changeDetection: ChangeDetectionStrategy.OnPush, |
| providers: [ |
| { |
| provide: NG_VALUE_ACCESSOR, |
| useExisting: forwardRef((/** |
| * @return {?} |
| */ |
| () => TdFileInputComponent)), |
| multi: true, |
| }, |
| ], |
| selector: 'td-file-input', |
| inputs: ['disabled', 'value'], |
| template: "<div>\n <button\n mat-raised-button\n class=\"td-file-input\"\n type=\"button\"\n [color]=\"color\"\n [multiple]=\"multiple\"\n [disabled]=\"disabled\"\n (keyup.enter)=\"fileInput.click()\"\n (click)=\"fileInput.click()\"\n (fileDrop)=\"handleSelect($event)\"\n tdFileDrop\n >\n <ng-content></ng-content>\n </button>\n <input\n #fileInput\n class=\"td-file-input-hidden\"\n type=\"file\"\n [attr.accept]=\"accept\"\n (fileSelect)=\"handleSelect($event)\"\n [multiple]=\"multiple\"\n [disabled]=\"disabled\"\n tdFileSelect\n />\n</div>\n", |
| styles: [":host .td-file-input{padding-left:8px;padding-right:8px}:host input.td-file-input-hidden{display:none}:host .drop-zone{border-radius:3px}:host .drop-zone *{pointer-events:none}"] |
| }] } |
| ]; |
| /** @nocollapse */ |
| TdFileInputComponent.ctorParameters = () => [ |
| { type: Renderer2 }, |
| { type: ChangeDetectorRef } |
| ]; |
| TdFileInputComponent.propDecorators = { |
| _inputElement: [{ type: ViewChild, args: ['fileInput', { static: true },] }], |
| color: [{ type: Input }], |
| multiple: [{ type: Input, args: ['multiple',] }], |
| accept: [{ type: Input }], |
| select: [{ type: Output }] |
| }; |
| if (false) { |
| /** |
| * @type {?} |
| * @private |
| */ |
| TdFileInputComponent.prototype._multiple; |
| /** |
| * The native `<input type="file"> element |
| * @type {?} |
| */ |
| TdFileInputComponent.prototype._inputElement; |
| /** |
| * color?: 'accent' | 'primary' | 'warn' |
| * Sets button color. Uses same color palette accepted as [MatButton]. |
| * @type {?} |
| */ |
| TdFileInputComponent.prototype.color; |
| /** |
| * accept?: string |
| * Sets files accepted when opening the file browser dialog. |
| * Same as 'accept' attribute in <input/> element. |
| * @type {?} |
| */ |
| TdFileInputComponent.prototype.accept; |
| /** |
| * select?: function |
| * Event emitted a file is selected |
| * Emits a [File | FileList] object. |
| * @type {?} |
| */ |
| TdFileInputComponent.prototype.select; |
| /** |
| * @type {?} |
| * @private |
| */ |
| TdFileInputComponent.prototype._renderer; |
| } |
| |
| /** |
| * @fileoverview added by tsickle |
| * Generated from: file-upload/file-upload.component.ts |
| * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| class TdFileUploadBase { |
| /** |
| * @param {?} _changeDetectorRef |
| */ |
| constructor(_changeDetectorRef) { |
| this._changeDetectorRef = _changeDetectorRef; |
| } |
| } |
| if (false) { |
| /** @type {?} */ |
| TdFileUploadBase.prototype._changeDetectorRef; |
| } |
| /* tslint:disable-next-line */ |
| /** @type {?} */ |
| const _TdFileUploadMixinBase = mixinControlValueAccessor(mixinDisabled(TdFileUploadBase)); |
| class TdFileUploadComponent extends _TdFileUploadMixinBase { |
| /** |
| * @param {?} _changeDetectorRef |
| */ |
| constructor(_changeDetectorRef) { |
| super(_changeDetectorRef); |
| this._multiple = false; |
| this._required = false; |
| /** |
| * defaultColor?: 'accent' | 'primary' | 'warn' |
| * Sets browse button color. Uses same color palette accepted as [MatButton] and defaults to 'primary'. |
| */ |
| this.defaultColor = 'primary'; |
| /** |
| * activeColor?: 'accent' | 'primary' | 'warn' |
| * Sets upload button color. Uses same color palette accepted as [MatButton] and defaults to 'accent'. |
| */ |
| this.activeColor = 'accent'; |
| /** |
| * cancelColor?: 'accent' | 'primary' | 'warn' |
| * Sets cancel button color. Uses same color palette accepted as [MatButton] and defaults to 'warn'. |
| */ |
| this.cancelColor = 'warn'; |
| /** |
| * select?: function |
| * Event emitted when a file is selected. |
| * Emits a [File | FileList] object. |
| */ |
| this.select = new EventEmitter(); |
| /** |
| * upload?: function |
| * Event emitted when upload button is clicked. |
| * Emits a [File | FileList] object. |
| */ |
| this.upload = new EventEmitter(); |
| /** |
| * cancel?: function |
| * Event emitted when cancel button is clicked. |
| */ |
| this.cancel = new EventEmitter(); |
| } |
| /** |
| * multiple?: boolean |
| * Sets if multiple files can be dropped/selected at once in [TdFileUploadComponent]. |
| * @param {?} multiple |
| * @return {?} |
| */ |
| set multiple(multiple) { |
| this._multiple = coerceBooleanProperty(multiple); |
| } |
| /** |
| * @return {?} |
| */ |
| get multiple() { |
| return this._multiple; |
| } |
| /** |
| * required?: boolean |
| * Forces at least one file upload. |
| * Defaults to 'false' |
| * @param {?} required |
| * @return {?} |
| */ |
| set required(required) { |
| this._required = coerceBooleanProperty(required); |
| } |
| /** |
| * @return {?} |
| */ |
| get required() { |
| return this._required; |
| } |
| /** |
| * Method executed when upload button is clicked. |
| * @return {?} |
| */ |
| uploadPressed() { |
| if (this.value) { |
| this.upload.emit(this.value); |
| } |
| } |
| /** |
| * Method executed when a file is selected. |
| * @param {?} value |
| * @return {?} |
| */ |
| handleSelect(value) { |
| this.value = value; |
| this.select.emit(value); |
| } |
| /** |
| * Methods executed when cancel button is clicked. |
| * Clears files. |
| * @return {?} |
| */ |
| _cancel() { |
| this.value = undefined; |
| this.cancel.emit(); |
| // check if the file input is rendered before clearing it |
| if (this.fileInput) { |
| this.fileInput.clear(); |
| } |
| } |
| /** |
| * Method executed when the disabled value changes |
| * @param {?} v |
| * @return {?} |
| */ |
| onDisabledChange(v) { |
| if (v) { |
| this._cancel(); |
| } |
| } |
| } |
| TdFileUploadComponent.decorators = [ |
| { type: Component, args: [{ |
| changeDetection: ChangeDetectionStrategy.OnPush, |
| providers: [ |
| { |
| provide: NG_VALUE_ACCESSOR, |
| useExisting: forwardRef((/** |
| * @return {?} |
| */ |
| () => TdFileUploadComponent)), |
| multi: true, |
| }, |
| ], |
| selector: 'td-file-upload', |
| inputs: ['disabled', 'value'], |
| template: "<td-file-input\n *ngIf=\"!value\"\n [(ngModel)]=\"value\"\n [multiple]=\"multiple\"\n [disabled]=\"disabled\"\n [accept]=\"accept\"\n [color]=\"defaultColor\"\n (select)=\"handleSelect($event)\"\n>\n <ng-template [cdkPortalOutlet]=\"inputLabel\" [ngIf]=\"true\"></ng-template>\n</td-file-input>\n<div *ngIf=\"value\">\n <button\n #fileUpload\n class=\"td-file-upload\"\n mat-raised-button\n type=\"button\"\n [color]=\"activeColor\"\n (keyup.delete)=\"_cancel()\"\n (keyup.backspace)=\"_cancel()\"\n (keyup.escape)=\"_cancel()\"\n (click)=\"uploadPressed()\"\n >\n <ng-content></ng-content>\n </button>\n <button mat-icon-button type=\"button\" class=\"td-file-upload-cancel\" [color]=\"cancelColor\" (click)=\"_cancel()\">\n <mat-icon>cancel</mat-icon>\n </button>\n</div>\n", |
| styles: [".td-file-upload{padding-left:8px;padding-right:8px}.td-file-upload-cancel{height:24px;left:-12px;position:relative;top:24px;width:24px}::ng-deep [dir=rtl] .td-file-upload-cancel{left:0;right:-12px}.td-file-upload-cancel mat-icon{border-radius:12px;vertical-align:baseline}.drop-zone{border-radius:3px}.drop-zone *{pointer-events:none}"] |
| }] } |
| ]; |
| /** @nocollapse */ |
| TdFileUploadComponent.ctorParameters = () => [ |
| { type: ChangeDetectorRef } |
| ]; |
| TdFileUploadComponent.propDecorators = { |
| fileInput: [{ type: ViewChild, args: [TdFileInputComponent,] }], |
| inputLabel: [{ type: ContentChild, args: [TdFileInputLabelDirective,] }], |
| defaultColor: [{ type: Input }], |
| activeColor: [{ type: Input }], |
| cancelColor: [{ type: Input }], |
| multiple: [{ type: Input, args: ['multiple',] }], |
| required: [{ type: Input, args: ['required',] }], |
| accept: [{ type: Input }], |
| select: [{ type: Output }], |
| upload: [{ type: Output }], |
| cancel: [{ type: Output }] |
| }; |
| if (false) { |
| /** |
| * @type {?} |
| * @private |
| */ |
| TdFileUploadComponent.prototype._multiple; |
| /** |
| * @type {?} |
| * @private |
| */ |
| TdFileUploadComponent.prototype._required; |
| /** @type {?} */ |
| TdFileUploadComponent.prototype.fileInput; |
| /** @type {?} */ |
| TdFileUploadComponent.prototype.inputLabel; |
| /** |
| * defaultColor?: 'accent' | 'primary' | 'warn' |
| * Sets browse button color. Uses same color palette accepted as [MatButton] and defaults to 'primary'. |
| * @type {?} |
| */ |
| TdFileUploadComponent.prototype.defaultColor; |
| /** |
| * activeColor?: 'accent' | 'primary' | 'warn' |
| * Sets upload button color. Uses same color palette accepted as [MatButton] and defaults to 'accent'. |
| * @type {?} |
| */ |
| TdFileUploadComponent.prototype.activeColor; |
| /** |
| * cancelColor?: 'accent' | 'primary' | 'warn' |
| * Sets cancel button color. Uses same color palette accepted as [MatButton] and defaults to 'warn'. |
| * @type {?} |
| */ |
| TdFileUploadComponent.prototype.cancelColor; |
| /** |
| * accept?: string |
| * Sets files accepted when opening the file browser dialog. |
| * Same as 'accept' attribute in <input/> element. |
| * @type {?} |
| */ |
| TdFileUploadComponent.prototype.accept; |
| /** |
| * select?: function |
| * Event emitted when a file is selected. |
| * Emits a [File | FileList] object. |
| * @type {?} |
| */ |
| TdFileUploadComponent.prototype.select; |
| /** |
| * upload?: function |
| * Event emitted when upload button is clicked. |
| * Emits a [File | FileList] object. |
| * @type {?} |
| */ |
| TdFileUploadComponent.prototype.upload; |
| /** |
| * cancel?: function |
| * Event emitted when cancel button is clicked. |
| * @type {?} |
| */ |
| TdFileUploadComponent.prototype.cancel; |
| } |
| |
| /** |
| * @fileoverview added by tsickle |
| * Generated from: services/file.service.ts |
| * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| /** |
| * @record |
| */ |
| function IUploadExtras() { } |
| if (false) { |
| /** @type {?|undefined} */ |
| IUploadExtras.prototype.headers; |
| /** @type {?|undefined} */ |
| IUploadExtras.prototype.params; |
| } |
| class TdFileService { |
| /** |
| * Creates a new instance |
| * \@breaking-change 3.0.0 remove 'Optional' decorator once the legay upload method is removed |
| * @param {?} _http the http client instance |
| */ |
| constructor(_http) { |
| this._http = _http; |
| this._progressSubject = new Subject(); |
| this._progressObservable = this._progressSubject.asObservable(); |
| } |
| /** |
| * Gets progress observable to keep track of the files being uploaded. |
| * Needs to be supported by backend. |
| * @return {?} |
| */ |
| get progress() { |
| return this._progressObservable; |
| } |
| /** |
| * Uploads a file to a URL. |
| * @param {?} url |
| * @param {?} method |
| * @param {?} body |
| * @param {?=} __3 |
| * @return {?} |
| */ |
| send(url, method, body, { headers, params } = {}) { |
| if (!this._http) { |
| throw new Error('The HttpClient module needs to be imported at root module level'); |
| } |
| /** @type {?} */ |
| const req = new HttpRequest(method.toUpperCase(), url, body, { |
| reportProgress: true, |
| headers: new HttpHeaders(headers || {}), |
| params: new HttpParams({ fromObject: params || {} }), |
| }); |
| return this._http.request(req).pipe(tap((/** |
| * @param {?} event |
| * @return {?} |
| */ |
| (event) => this.handleEvent(event)))); |
| } |
| /** |
| * @private |
| * @template T |
| * @param {?} event |
| * @return {?} |
| */ |
| handleEvent(event) { |
| switch (event.type) { |
| case HttpEventType.Sent: |
| this._progressSubject.next(0); |
| break; |
| case HttpEventType.UploadProgress: |
| this._progressSubject.next(Math.round((100 * event.loaded) / event.total)); |
| break; |
| case HttpEventType.Response: |
| this._progressSubject.next(100); |
| break; |
| default: |
| break; |
| } |
| } |
| } |
| TdFileService.decorators = [ |
| { type: Injectable } |
| ]; |
| /** @nocollapse */ |
| TdFileService.ctorParameters = () => [ |
| { type: HttpClient, decorators: [{ type: Optional }] } |
| ]; |
| if (false) { |
| /** |
| * @type {?} |
| * @private |
| */ |
| TdFileService.prototype._progressSubject; |
| /** |
| * @type {?} |
| * @private |
| */ |
| TdFileService.prototype._progressObservable; |
| /** |
| * @type {?} |
| * @private |
| */ |
| TdFileService.prototype._http; |
| } |
| |
| /** |
| * @fileoverview added by tsickle |
| * Generated from: file.module.ts |
| * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| /** @type {?} */ |
| const TD_FILE = [ |
| TdFileSelectDirective, |
| TdFileDropDirective, |
| TdFileUploadComponent, |
| TdFileInputComponent, |
| TdFileInputLabelDirective, |
| ]; |
| class CovalentFileModule { |
| } |
| CovalentFileModule.decorators = [ |
| { type: NgModule, args: [{ |
| imports: [FormsModule, CommonModule, MatIconModule, MatButtonModule, PortalModule], |
| declarations: [TD_FILE], |
| exports: [TD_FILE], |
| providers: [TdFileService], |
| },] } |
| ]; |
| |
| /** |
| * @fileoverview added by tsickle |
| * Generated from: public-api.ts |
| * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| |
| /** |
| * @fileoverview added by tsickle |
| * Generated from: index.ts |
| * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| |
| /** |
| * @fileoverview added by tsickle |
| * Generated from: covalent-core-file.ts |
| * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| |
| export { CovalentFileModule, TdFileDropBase, TdFileDropDirective, TdFileInputBase, TdFileInputComponent, TdFileInputLabelDirective, TdFileSelectDirective, TdFileService, TdFileUploadBase, TdFileUploadComponent, _TdFileDropMixinBase, _TdFileInputMixinBase, _TdFileUploadMixinBase }; |
| //# sourceMappingURL=covalent-core-file.js.map |