UNPKG

4.34 kBTypeScriptView Raw
1import { AfterContentInit, SimpleChange, ElementRef, QueryList, OnChanges, ModuleWithProviders } from '@angular/core';
2import { ControlValueAccessor } from '@angular/forms';
3import { MdError } from '@angular2-material/core';
4import { Observable } from 'rxjs/Observable';
5export declare const MD_INPUT_CONTROL_VALUE_ACCESSOR: any;
6export declare class MdInputPlaceholderConflictError extends MdError {
7 constructor();
8}
9export declare class MdInputUnsupportedTypeError extends MdError {
10 constructor(type: string);
11}
12export declare class MdInputDuplicatedHintError extends MdError {
13 constructor(align: string);
14}
15/**
16 * The placeholder directive. The content can declare this to implement more
17 * complex placeholders.
18 */
19export declare class MdPlaceholder {
20}
21/** The hint directive, used to tag content as hint labels (going under the input). */
22export declare class MdHint {
23 align: 'start' | 'end';
24}
25/**
26 * Component that represents a text input. It encapsulates the <input> HTMLElement and
27 * improve on its behaviour, along with styling it according to the Material Design.
28 */
29export declare class MdInput implements ControlValueAccessor, AfterContentInit, OnChanges {
30 private _focused;
31 private _value;
32 /** Callback registered via registerOnTouched (ControlValueAccessor) */
33 private _onTouchedCallback;
34 /** Callback registered via registerOnChange (ControlValueAccessor) */
35 private _onChangeCallback;
36 /**
37 * Aria related inputs.
38 */
39 ariaLabel: string;
40 ariaLabelledBy: string;
41 ariaDisabled: boolean;
42 ariaRequired: boolean;
43 ariaInvalid: boolean;
44 /**
45 * Content directives.
46 */
47 _placeholderChild: MdPlaceholder;
48 _hintChildren: QueryList<MdHint>;
49 /** Readonly properties. */
50 readonly focused: boolean;
51 readonly empty: boolean;
52 readonly characterCount: number;
53 readonly inputId: string;
54 /**
55 * Bindings.
56 */
57 align: 'start' | 'end';
58 dividerColor: 'primary' | 'accent' | 'warn';
59 floatingPlaceholder: boolean;
60 hintLabel: string;
61 autocomplete: string;
62 autocorrect: string;
63 autocapitalize: string;
64 autofocus: boolean;
65 disabled: boolean;
66 id: string;
67 list: string;
68 max: string | number;
69 maxlength: number;
70 min: string | number;
71 minlength: number;
72 placeholder: string;
73 readonly: boolean;
74 required: boolean;
75 spellcheck: boolean;
76 step: number;
77 tabindex: number;
78 type: string;
79 name: string;
80 private _blurEmitter;
81 private _focusEmitter;
82 readonly onBlur: Observable<FocusEvent>;
83 readonly onFocus: Observable<FocusEvent>;
84 value: any;
85 readonly _align: any;
86 _inputElement: ElementRef;
87 /** Set focus on input */
88 focus(): void;
89 _handleFocus(event: FocusEvent): void;
90 _handleBlur(event: FocusEvent): void;
91 _handleChange(event: Event): void;
92 _hasPlaceholder(): boolean;
93 /**
94 * Implemented as part of ControlValueAccessor.
95 * TODO: internal
96 */
97 writeValue(value: any): void;
98 /**
99 * Implemented as part of ControlValueAccessor.
100 * TODO: internal
101 */
102 registerOnChange(fn: any): void;
103 /**
104 * Implemented as part of ControlValueAccessor.
105 * TODO: internal
106 */
107 registerOnTouched(fn: any): void;
108 /** TODO: internal */
109 ngAfterContentInit(): void;
110 /** TODO: internal */
111 ngOnChanges(changes: {
112 [key: string]: SimpleChange;
113 }): void;
114 /**
115 * Convert the value passed in to a value that is expected from the type of the md-input.
116 * This is normally performed by the *_VALUE_ACCESSOR in forms, but since the type is bound
117 * on our internal input it won't work locally.
118 * @private
119 */
120 private _convertValueForInputType(v);
121 /**
122 * Ensure that all constraints defined by the API are validated, or throw errors otherwise.
123 * Constraints for now:
124 * - placeholder attribute and <md-placeholder> are mutually exclusive.
125 * - type attribute is not one of the forbidden types (see constant at the top).
126 * - Maximum one of each `<md-hint>` alignment specified, with the attribute being
127 * considered as align="start".
128 * @private
129 */
130 private _validateConstraints();
131}
132export declare class MdInputModule {
133 static forRoot(): ModuleWithProviders;
134}