UNPKG

@ngx-dropzone/cdk

Version:
82 lines (81 loc) 4.26 kB
import { DoCheck, ElementRef, EventEmitter, OnChanges, OnDestroy, OnInit } from '@angular/core'; import { ControlValueAccessor, FormGroupDirective, NgControl, NgForm } from '@angular/forms'; import { Subject } from 'rxjs'; import { BooleanInput } from '../coercion'; import { AcceptService } from './accept.service'; import { FileInputMode, FileInputValue } from './file-input-value'; import * as i0 from "@angular/core"; export declare class FileInputDirective implements ControlValueAccessor, OnInit, OnChanges, DoCheck, OnDestroy { private _acceptService; elementRef: ElementRef<HTMLInputElement>; ngControl: NgControl; private _value; private _parent; private _focused; private _touched; private _errorState; private _onChange; private _onTouched; /** Emits whenever the parent dropzone should re-render. */ readonly stateChanges: Subject<void>; /** The value of the file input control. */ get _fileValue(): FileInputValue; set _fileValue(newValue: FileInputValue); /** Returns the selected value of the file input control (alias as syntactic sugar). */ get value(): FileInputValue; /** Returns true if the file input has no selected item. */ get empty(): boolean; /** Returns the error state. */ get errorState(): boolean; /** Returns true if the file input element is focused. */ get focused(): boolean; /** Returns true if the `multiple` attribute is present on the input element. */ get multiple(): boolean; /** Controls the accepted file types. */ get accept(): string; set accept(value: string); private _accept; /** Controls the value setting strategy. */ get mode(): FileInputMode; set mode(value: FileInputMode); private _mode; /** The disabled state of the file input control. */ get disabled(): boolean; set disabled(value: BooleanInput); /** Event emitted when the selected files have been changed by the user. */ readonly selectionChange: EventEmitter<FileInputValue>; constructor(_acceptService: AcceptService, elementRef: ElementRef<HTMLInputElement>, _parentForm: NgForm, _parentFormGroup: FormGroupDirective, ngControl: NgControl); ngOnInit(): void; ngOnChanges(): void; ngDoCheck(): void; ngOnDestroy(): void; /** Opens the native OS file picker. */ openFilePicker(): void; /** Handles the native (change) event. */ _handleChange(fileList: FileList): void; /** Handles the drop of a file array. */ handleFileDrop(files: File[]): void; /** Sets the selected files value as required by the `ControlValueAccessor` interface. */ writeValue(value: FileInputValue): void; /** Registers the change handler as required by `ControlValueAccessor`. */ registerOnChange(fn: (value: FileInputValue) => void): void; /** Registers the touched handler as required by `ControlValueAccessor`. */ registerOnTouched(fn: () => void): void; /** Implements the disabled state setter from `ControlValueAccessor`. */ setDisabledState(disabled: boolean): void; /** Called when the input element is focused or blurred. */ _focusChanged(focused: boolean): void; /** * On directory drops, the readonly `webkitRelativePath` property is not available. * We manually set the `relativePath` property for dropped file trees instead. * To achieve a consistent behavior when using the file picker, we copy the value. */ private _copyRelativePaths; /** Asserts that the provided value type matches the input element's multiple attribute. */ private _assertMultipleValue; private _appendOrReplace; private _canAppend; private _updateErrorState; static ɵfac: i0.ɵɵFactoryDeclaration<FileInputDirective, [null, null, { optional: true; }, { optional: true; }, { optional: true; self: true; }]>; static ɵdir: i0.ɵɵDirectiveDeclaration<FileInputDirective, "input[fileInput]", ["fileInput"], { "_fileValue": { "alias": "value"; "required": false; }; "accept": { "alias": "accept"; "required": false; }; "mode": { "alias": "mode"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "selectionChange": "selectionChange"; }, never, never, true, never>; }