UNPKG

@covalent/core

Version:

Core Teradata UI Platform for layouts, icons, custom components and themes. This should be added as a dependency for any project that wants to use layouts, icons and themes for Angular Material.

282 lines (274 loc) 11.9 kB
import * as i0 from '@angular/core'; import { EventEmitter, OnInit, OnDestroy, ChangeDetectorRef, ElementRef } from '@angular/core'; import { TemplatePortalDirective } from '@angular/cdk/portal'; import { IControlValueAccessor, ICanDisable } from '@covalent/core/common'; import { ControlValueAccessor } from '@angular/forms'; import { HttpEvent } from '@angular/common/http'; import { Observable } from 'rxjs'; declare class TdFileSelectDirective { private model; private _multiple; /** * 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. */ set multiple(multiple: boolean | string); /** * fileSelect?: function * Event emitted when a file or files are selected in host [HTMLInputElement]. * Emits a [FileList | File] object. * Alternative to not use [(ngModel)]. */ fileSelect: EventEmitter<FileList | File>; /** * Binds native 'multiple' attribute if [multiple] property is 'true'. */ get multipleBinding(): string | 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. */ onChange(event: Event): void; static ɵfac: i0.ɵɵFactoryDeclaration<TdFileSelectDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<TdFileSelectDirective, "[tdFileSelect]", never, { "multiple": { "alias": "multiple"; "required": false; }; }, { "fileSelect": "fileSelect"; }, never, never, true, never>; } declare class TdFileDropBase { } declare class TdFileDropDirective implements OnInit, OnDestroy { private _renderer; private _element; private _ngZone; private _multiple; private _dragenterListener?; private _dragleaveListener?; private _dragoverListener?; /** * 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. */ set multiple(multiple: boolean | string); disabled?: boolean | undefined; /** * fileDrop?: function * Event emitted when a file or files are dropped in host element after being validated. * Emits a [FileList | File] object. */ fileDrop: EventEmitter<FileList | File>; /** * Binds native 'multiple' attribute if [multiple] property is 'true'. */ get multipleBinding(): string | undefined; /** * Binds native 'disabled' attribute if [disabled] property is 'true'. */ get disabledBinding(): string | undefined; ngOnInit(): void; ngOnDestroy(): void; /** * 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. */ onDrop(event: Event): void; /** * Validates if the transfer item types are 'Files'. */ private _typeCheck; private _stopEvent; static ɵfac: i0.ɵɵFactoryDeclaration<TdFileDropDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<TdFileDropDirective, "[tdFileDrop]", never, { "multiple": { "alias": "multiple"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "fileDrop": "fileDrop"; }, never, never, true, never>; } declare class TdFileInputLabelDirective extends TemplatePortalDirective { constructor(); static ɵfac: i0.ɵɵFactoryDeclaration<TdFileInputLabelDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<TdFileInputLabelDirective, "[tdFileInputLabel]ng-template", never, {}, {}, never, never, true, never>; } declare class TdFileInputBase { _changeDetectorRef: ChangeDetectorRef; constructor(_changeDetectorRef: ChangeDetectorRef); } declare const _TdFileInputMixinBase: (new (...args: any[]) => IControlValueAccessor) & (new (...args: any[]) => ICanDisable) & typeof TdFileInputBase; declare class TdFileInputComponent extends _TdFileInputMixinBase implements OnInit, OnDestroy, IControlValueAccessor, ICanDisable { private _ngZone; private _renderer; private _multiple; /** The native `<button class="td-file-input"></button>` element */ _inputButton: ElementRef<HTMLElement>; /** The native `<input type="file"> element */ _inputElement: ElementRef<HTMLInputElement>; get inputElement(): HTMLInputElement; /** * color?: 'accent' | 'primary' | 'warn' * Sets button color. Uses same color palette accepted as [MatButton]. */ color?: 'accent' | 'primary' | 'warn'; /** * multiple?: boolean * Sets if multiple files can be dropped/selected at once in [TdFileInputComponent]. */ set multiple(multiple: boolean | string); get multiple(): boolean; /** * accept?: string * Sets files accepted when opening the file browser dialog. * Same as 'accept' attribute in <input/> element. */ accept?: string; /** * select?: function * Event emitted a file is selected * Emits a [File | FileList] object. */ selectFile: EventEmitter<File | FileList>; private _destroy$; constructor(); ngOnInit(): void; ngOnDestroy(): void; /** * Method executed when a file is selected. */ handleSelect(files: File | FileList): void; /** * Used to clear the selected files from the [TdFileInputComponent]. */ clear(): void; /** Method executed when the disabled value changes */ onDisabledChange(v: boolean): void; /** * Sets disable to the component. Implemented as part of ControlValueAccessor. */ setDisabledState(isDisabled: boolean): void; static ɵfac: i0.ɵɵFactoryDeclaration<TdFileInputComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<TdFileInputComponent, "td-file-input", never, { "disabled": { "alias": "disabled"; "required": false; }; "value": { "alias": "value"; "required": false; }; "color": { "alias": "color"; "required": false; }; "multiple": { "alias": "multiple"; "required": false; }; "accept": { "alias": "accept"; "required": false; }; }, { "selectFile": "selectFile"; }, never, ["*"], true, never>; } declare class TdFileUploadBase { _changeDetectorRef: ChangeDetectorRef; constructor(_changeDetectorRef: ChangeDetectorRef); } declare class TdFileUploadComponent implements ControlValueAccessor { private _changeDetectorRef; private _multiple; private _required; private _disabled; fileInput?: TdFileInputComponent; inputLabel?: TdFileInputLabelDirective; /** * defaultColor?: 'accent' | 'primary' | 'warn' * Sets browse button color. Uses same color palette accepted as [MatButton] and defaults to 'primary'. */ defaultColor: 'accent' | 'primary' | 'warn'; /** * activeColor?: 'accent' | 'primary' | 'warn' * Sets upload button color. Uses same color palette accepted as [MatButton] and defaults to 'accent'. */ activeColor: 'accent' | 'primary' | 'warn'; /** * cancelColor?: 'accent' | 'primary' | 'warn' * Sets cancel button color. Uses same color palette accepted as [MatButton] and defaults to 'warn'. */ cancelColor: 'accent' | 'primary' | 'warn'; /** * multiple?: boolean * Sets if multiple files can be dropped/selected at once in [TdFileUploadComponent]. */ set multiple(multiple: boolean); get multiple(): boolean; /** * required?: boolean * Forces at least one file upload. * Defaults to 'false' */ set required(required: boolean); get required(): boolean; /** * accept?: string * Sets files accepted when opening the file browser dialog. * Same as 'accept' attribute in <input/> element. */ accept?: string; set disabled(disabled: boolean); get disabled(): boolean; value?: File | FileList | undefined; /** * select?: function * Event emitted when a file is selected. * Emits a [File | FileList] object. */ selectFile: EventEmitter<File | FileList>; /** * upload?: function * Event emitted when upload button is clicked. * Emits a [File | FileList] object. */ upload: EventEmitter<File | FileList | unknown>; /** * cancel?: function * Event emitted when cancel button is clicked. */ cancel: EventEmitter<void>; writeValue(value: File | FileList): void; registerOnChange(): void; registerOnTouched(): void; /** * Method executed when upload button is clicked. */ uploadPressed(): void; /** * Method executed when a file is selected. */ handleSelect(value: File | FileList | undefined): void; /** * Methods executed when cancel button is clicked. * Clears files. */ _cancel(): void; /** Method executed when the disabled value changes */ onDisabledChange(v: boolean): void; static ɵfac: i0.ɵɵFactoryDeclaration<TdFileUploadComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<TdFileUploadComponent, "td-file-upload", never, { "defaultColor": { "alias": "defaultColor"; "required": false; }; "activeColor": { "alias": "activeColor"; "required": false; }; "cancelColor": { "alias": "cancelColor"; "required": false; }; "multiple": { "alias": "multiple"; "required": false; }; "required": { "alias": "required"; "required": false; }; "accept": { "alias": "accept"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "value": { "alias": "value"; "required": false; }; }, { "selectFile": "selectFile"; "upload": "upload"; "cancel": "cancel"; }, ["inputLabel"], ["*"], true, never>; } /** * @deprecated This module is deprecated and will be removed in future versions. * Please migrate to using standalone components as soon as possible. */ declare class CovalentFileModule { static ɵfac: i0.ɵɵFactoryDeclaration<CovalentFileModule, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<CovalentFileModule, never, [typeof TdFileSelectDirective, typeof TdFileDropDirective, typeof TdFileUploadComponent, typeof TdFileInputComponent, typeof TdFileInputLabelDirective], [typeof TdFileSelectDirective, typeof TdFileDropDirective, typeof TdFileUploadComponent, typeof TdFileInputComponent, typeof TdFileInputLabelDirective]>; static ɵinj: i0.ɵɵInjectorDeclaration<CovalentFileModule>; } interface IUploadExtras { headers?: { [name: string]: string | string[]; }; params?: { [param: string]: string | string[]; }; } declare class TdFileService { private readonly _http; private _progressSubject; private _progressObservable; /** * Gets progress observable to keep track of the files being uploaded. * Needs to be supported by backend. */ get progress(): Observable<number>; /** * Creates a new instance * @param _http the http client instance * @breaking-change 3.0.0 remove 'Optional' decorator once the legay upload method is removed */ constructor(); /** * Uploads a file to a URL. */ send(url: string, method: string, body: File | FormData, { headers, params }?: IUploadExtras): Observable<HttpEvent<any>>; private handleEvent; static ɵfac: i0.ɵɵFactoryDeclaration<TdFileService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TdFileService>; } export { CovalentFileModule, TdFileDropBase, TdFileDropDirective, TdFileInputBase, TdFileInputComponent, TdFileInputLabelDirective, TdFileSelectDirective, TdFileService, TdFileUploadBase, TdFileUploadComponent, _TdFileInputMixinBase }; export type { IUploadExtras };