UNPKG

7.15 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2016 Google Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23import { MDCFoundation } from '@material/base/foundation';
24import { MDCTextFieldAdapter } from './adapter';
25import { MDCTextFieldFoundationMap } from './types';
26export declare class MDCTextFieldFoundation extends MDCFoundation<MDCTextFieldAdapter> {
27 static get cssClasses(): {
28 DISABLED: string;
29 FOCUSED: string;
30 HELPER_LINE: string;
31 INVALID: string;
32 LABEL_FLOATING: string;
33 NO_LABEL: string;
34 OUTLINED: string;
35 ROOT: string;
36 TEXTAREA: string;
37 WITH_LEADING_ICON: string;
38 WITH_TRAILING_ICON: string;
39 WITH_INTERNAL_COUNTER: string;
40 };
41 static get strings(): {
42 ARIA_CONTROLS: string;
43 ARIA_DESCRIBEDBY: string;
44 INPUT_SELECTOR: string;
45 LABEL_SELECTOR: string;
46 LEADING_ICON_SELECTOR: string;
47 LINE_RIPPLE_SELECTOR: string;
48 OUTLINE_SELECTOR: string;
49 PREFIX_SELECTOR: string;
50 SUFFIX_SELECTOR: string;
51 TRAILING_ICON_SELECTOR: string;
52 };
53 static get numbers(): {
54 LABEL_SCALE: number;
55 };
56 private get shouldAlwaysFloat();
57 get shouldFloat(): boolean;
58 get shouldShake(): boolean;
59 /**
60 * See {@link MDCTextFieldAdapter} for typing information on parameters and
61 * return types.
62 */
63 static get defaultAdapter(): MDCTextFieldAdapter;
64 private isFocused;
65 private receivedUserInput;
66 private valid;
67 private useNativeValidation;
68 private validateOnValueChange;
69 private readonly inputFocusHandler;
70 private readonly inputBlurHandler;
71 private readonly inputInputHandler;
72 private readonly setPointerXOffset;
73 private readonly textFieldInteractionHandler;
74 private readonly validationAttributeChangeHandler;
75 private validationObserver;
76 private readonly helperText?;
77 private readonly characterCounter?;
78 private readonly leadingIcon?;
79 private readonly trailingIcon?;
80 /**
81 * @param adapter
82 * @param foundationMap Map from subcomponent names to their subfoundations.
83 */
84 constructor(adapter?: Partial<MDCTextFieldAdapter>, foundationMap?: Partial<MDCTextFieldFoundationMap>);
85 init(): void;
86 destroy(): void;
87 /**
88 * Handles user interactions with the Text Field.
89 */
90 handleTextFieldInteraction(): void;
91 /**
92 * Handles validation attribute changes
93 */
94 handleValidationAttributeChange(attributesList: string[]): void;
95 /**
96 * Opens/closes the notched outline.
97 */
98 notchOutline(openNotch: boolean): void;
99 /**
100 * Activates the text field focus state.
101 */
102 activateFocus(): void;
103 /**
104 * Sets the line ripple's transform origin, so that the line ripple activate
105 * animation will animate out from the user's click location.
106 */
107 setTransformOrigin(evt: TouchEvent | MouseEvent): void;
108 /**
109 * Handles input change of text input and text area.
110 */
111 handleInput(): void;
112 /**
113 * Activates the Text Field's focus state in cases when the input value
114 * changes without user input (e.g. programmatically).
115 */
116 autoCompleteFocus(): void;
117 /**
118 * Deactivates the Text Field's focus state.
119 */
120 deactivateFocus(): void;
121 getValue(): string;
122 /**
123 * @param value The value to set on the input Element.
124 */
125 setValue(value: string): void;
126 /**
127 * @return The custom validity state, if set; otherwise, the result of a
128 * native validity check.
129 */
130 isValid(): boolean;
131 /**
132 * @param isValid Sets the custom validity state of the Text Field.
133 */
134 setValid(isValid: boolean): void;
135 /**
136 * @param shouldValidate Whether or not validity should be updated on
137 * value change.
138 */
139 setValidateOnValueChange(shouldValidate: boolean): void;
140 /**
141 * @return Whether or not validity should be updated on value change. `true`
142 * by default.
143 */
144 getValidateOnValueChange(): boolean;
145 /**
146 * Enables or disables the use of native validation. Use this for custom
147 * validation.
148 * @param useNativeValidation Set this to false to ignore native input
149 * validation.
150 */
151 setUseNativeValidation(useNativeValidation: boolean): void;
152 isDisabled(): boolean;
153 /**
154 * @param disabled Sets the text-field disabled or enabled.
155 */
156 setDisabled(disabled: boolean): void;
157 /**
158 * @param content Sets the content of the helper text.
159 */
160 setHelperTextContent(content: string): void;
161 /**
162 * Sets the aria label of the leading icon.
163 */
164 setLeadingIconAriaLabel(label: string): void;
165 /**
166 * Sets the text content of the leading icon.
167 */
168 setLeadingIconContent(content: string): void;
169 /**
170 * Sets the aria label of the trailing icon.
171 */
172 setTrailingIconAriaLabel(label: string): void;
173 /**
174 * Sets the text content of the trailing icon.
175 */
176 setTrailingIconContent(content: string): void;
177 /**
178 * Sets character counter values that shows characters used and the total
179 * character limit.
180 */
181 private setcharacterCounter;
182 /**
183 * @return True if the Text Field input fails in converting the user-supplied
184 * value.
185 */
186 private isBadInput;
187 /**
188 * @return The result of native validity checking (ValidityState.valid).
189 */
190 private isNativeInputValid;
191 /**
192 * Styles the component based on the validity state.
193 */
194 private styleValidity;
195 /**
196 * Styles the component based on the focused state.
197 */
198 private styleFocused;
199 /**
200 * Styles the component based on the disabled state.
201 */
202 private styleDisabled;
203 /**
204 * Styles the component based on the label floating state.
205 */
206 private styleFloating;
207 /**
208 * @return The native text input element from the host environment, or an
209 * object with the same shape for unit tests.
210 */
211 private getNativeInput;
212}
213export default MDCTextFieldFoundation;