UNPKG

3.13 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2018 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 { MDCMenuAdapter } from './adapter';
25import { DefaultFocusState } from './constants';
26export declare class MDCMenuFoundation extends MDCFoundation<MDCMenuAdapter> {
27 static get cssClasses(): {
28 MENU_SELECTED_LIST_ITEM: string;
29 MENU_SELECTION_GROUP: string;
30 ROOT: string;
31 };
32 static get strings(): {
33 ARIA_CHECKED_ATTR: string;
34 ARIA_DISABLED_ATTR: string;
35 CHECKBOX_SELECTOR: string;
36 LIST_SELECTOR: string;
37 SELECTED_EVENT: string;
38 SKIP_RESTORE_FOCUS: string;
39 };
40 static get numbers(): {
41 FOCUS_ROOT_INDEX: number;
42 };
43 private closeAnimationEndTimerId;
44 private defaultFocusState;
45 private selectedIndex;
46 /**
47 * @see {@link MDCMenuAdapter} for typing information on parameters and return types.
48 */
49 static get defaultAdapter(): MDCMenuAdapter;
50 constructor(adapter?: Partial<MDCMenuAdapter>);
51 destroy(): void;
52 handleKeydown(evt: KeyboardEvent): void;
53 handleItemAction(listItem: Element): void;
54 handleMenuSurfaceOpened(): void;
55 /**
56 * Sets default focus state where the menu should focus every time when menu
57 * is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
58 * default.
59 */
60 setDefaultFocusState(focusState: DefaultFocusState): void;
61 /** @return Index of the currently selected list item within the menu. */
62 getSelectedIndex(): number;
63 /**
64 * Selects the list item at `index` within the menu.
65 * @param index Index of list item within the menu.
66 */
67 setSelectedIndex(index: number): void;
68 /**
69 * Sets the enabled state to isEnabled for the menu item at the given index.
70 * @param index Index of the menu item
71 * @param isEnabled The desired enabled state of the menu item.
72 */
73 setEnabled(index: number, isEnabled: boolean): void;
74 private validatedIndex;
75}
76export default MDCMenuFoundation;