UNPKG

5.2 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 { MDCSelectAdapter } from './adapter';
25import { MDCSelectFoundationMap } from './types';
26export declare class MDCSelectFoundation extends MDCFoundation<MDCSelectAdapter> {
27 static get cssClasses(): {
28 ACTIVATED: string;
29 DISABLED: string;
30 FOCUSED: string;
31 INVALID: string;
32 MENU_INVALID: string;
33 OUTLINED: string;
34 REQUIRED: string;
35 ROOT: string;
36 WITH_LEADING_ICON: string;
37 };
38 static get numbers(): {
39 LABEL_SCALE: number;
40 UNSET_INDEX: number;
41 CLICK_DEBOUNCE_TIMEOUT_MS: number;
42 };
43 static get strings(): {
44 ARIA_CONTROLS: string;
45 ARIA_DESCRIBEDBY: string;
46 ARIA_SELECTED_ATTR: string;
47 CHANGE_EVENT: string;
48 HIDDEN_INPUT_SELECTOR: string;
49 LABEL_SELECTOR: string;
50 LEADING_ICON_SELECTOR: string;
51 LINE_RIPPLE_SELECTOR: string;
52 MENU_SELECTOR: string;
53 OUTLINE_SELECTOR: string;
54 SELECTED_TEXT_SELECTOR: string;
55 SELECT_ANCHOR_SELECTOR: string;
56 VALUE_ATTR: string;
57 };
58 /**
59 * See {@link MDCSelectAdapter} for typing information on parameters and return types.
60 */
61 static get defaultAdapter(): MDCSelectAdapter;
62 private readonly leadingIcon;
63 private readonly helperText;
64 private disabled;
65 private isMenuOpen;
66 private useDefaultValidation;
67 private customValidity;
68 private lastSelectedIndex;
69 private clickDebounceTimeout;
70 private recentlyClicked;
71 /**
72 * @param adapter
73 * @param foundationMap Map from subcomponent names to their subfoundations.
74 */
75 constructor(adapter?: Partial<MDCSelectAdapter>, foundationMap?: Partial<MDCSelectFoundationMap>);
76 /** Returns the index of the currently selected menu item, or -1 if none. */
77 getSelectedIndex(): number;
78 setSelectedIndex(index: number, closeMenu?: boolean, skipNotify?: boolean): void;
79 setValue(value: string, skipNotify?: boolean): void;
80 getValue(): string;
81 getDisabled(): boolean;
82 setDisabled(isDisabled: boolean): void;
83 /** Opens the menu. */
84 openMenu(): void;
85 /**
86 * @param content Sets the content of the helper text.
87 */
88 setHelperTextContent(content: string): void;
89 /**
90 * Re-calculates if the notched outline should be notched and if the label
91 * should float.
92 */
93 layout(): void;
94 /**
95 * Synchronizes the list of options with the state of the foundation. Call
96 * this whenever menu options are dynamically updated.
97 */
98 layoutOptions(): void;
99 handleMenuOpened(): void;
100 handleMenuClosing(): void;
101 handleMenuClosed(): void;
102 /**
103 * Handles value changes, via change event or programmatic updates.
104 */
105 handleChange(): void;
106 handleMenuItemAction(index: number): void;
107 /**
108 * Handles focus events from select element.
109 */
110 handleFocus(): void;
111 /**
112 * Handles blur events from select element.
113 */
114 handleBlur(): void;
115 handleClick(normalizedX: number): void;
116 /**
117 * Handles keydown events on select element. Depending on the type of
118 * character typed, does typeahead matching or opens menu.
119 */
120 handleKeydown(event: KeyboardEvent): void;
121 /**
122 * Opens/closes the notched outline.
123 */
124 notchOutline(openNotch: boolean): void;
125 /**
126 * Sets the aria label of the leading icon.
127 */
128 setLeadingIconAriaLabel(label: string): void;
129 /**
130 * Sets the text content of the leading icon.
131 */
132 setLeadingIconContent(content: string): void;
133 getUseDefaultValidation(): boolean;
134 setUseDefaultValidation(useDefaultValidation: boolean): void;
135 setValid(isValid: boolean): void;
136 isValid(): boolean;
137 setRequired(isRequired: boolean): void;
138 getRequired(): boolean;
139 init(): void;
140 /**
141 * Unfocuses the select component.
142 */
143 private blur;
144 private syncHelperTextValidity;
145 private setClickDebounceTimeout;
146}
147export default MDCSelectFoundation;