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 | */
|
23 | import { MDCComponent } from '@material/base/component';
|
24 | import { MDCListFoundation } from './foundation';
|
25 | import { MDCListIndex } from './types';
|
26 | export declare type MDCListFactory = (el: Element, foundation?: MDCListFoundation) => MDCList;
|
27 | export declare class MDCList extends MDCComponent<MDCListFoundation> {
|
28 | set vertical(value: boolean);
|
29 | get listElements(): Element[];
|
30 | set wrapFocus(value: boolean);
|
31 | /**
|
32 | * @return Whether typeahead is currently matching a user-specified prefix.
|
33 | */
|
34 | get typeaheadInProgress(): boolean;
|
35 | /**
|
36 | * Sets whether typeahead functionality is enabled on the list.
|
37 | * @param hasTypeahead Whether typeahead is enabled.
|
38 | */
|
39 | set hasTypeahead(hasTypeahead: boolean);
|
40 | set singleSelection(isSingleSelectionList: boolean);
|
41 | set disabledItemsFocusable(areDisabledItemsFocusable: boolean);
|
42 | get selectedIndex(): MDCListIndex;
|
43 | set selectedIndex(index: MDCListIndex);
|
44 | static attachTo(root: Element): MDCList;
|
45 | private handleKeydown;
|
46 | private handleClick;
|
47 | private focusInEventListener;
|
48 | private focusOutEventListener;
|
49 | private classNameMap;
|
50 | private isEvolutionEnabled;
|
51 | private isInteractive;
|
52 | initialSyncWithDOM(): void;
|
53 | destroy(): void;
|
54 | layout(): void;
|
55 | /**
|
56 | * Extracts the primary text from a list item.
|
57 | * @param item The list item element.
|
58 | * @return The primary text in the element.
|
59 | */
|
60 | getPrimaryText(item: Element): string;
|
61 | /**
|
62 | * Initialize selectedIndex value based on pre-selected list items.
|
63 | */
|
64 | initializeListType(): void;
|
65 | /**
|
66 | * Updates the list item at itemIndex to the desired isEnabled state.
|
67 | * @param itemIndex Index of the list item
|
68 | * @param isEnabled Sets the list item to enabled or disabled.
|
69 | */
|
70 | setEnabled(itemIndex: number, isEnabled: boolean): void;
|
71 | /**
|
72 | * Given the next desired character from the user, adds it to the typeahead
|
73 | * buffer. Then, attempts to find the next option matching the buffer. Wraps
|
74 | * around if at the end of options.
|
75 | *
|
76 | * @param nextChar The next character to add to the prefix buffer.
|
77 | * @param startingIndex The index from which to start matching. Defaults to
|
78 | * the currently focused index.
|
79 | * @return The index of the matched item.
|
80 | */
|
81 | typeaheadMatchItem(nextChar: string, startingIndex?: number): number;
|
82 | getDefaultFoundation(): MDCListFoundation;
|
83 | /**
|
84 | * Ensures that at least one item is focusable if the list is interactive and
|
85 | * doesn't specify a suitable tabindex.
|
86 | */
|
87 | private ensureFocusable;
|
88 | private initialFocusIndex;
|
89 | /**
|
90 | * Used to figure out which list item this event is targetting. Or returns -1
|
91 | * if there is no list item
|
92 | */
|
93 | private getListItemIndex;
|
94 | /**
|
95 | * Used to figure out which element was clicked before sending the event to
|
96 | * the foundation.
|
97 | */
|
98 | private handleFocusInEvent;
|
99 | /**
|
100 | * Used to figure out which element was clicked before sending the event to
|
101 | * the foundation.
|
102 | */
|
103 | private handleFocusOutEvent;
|
104 | /**
|
105 | * Used to figure out which element was focused when keydown event occurred
|
106 | * before sending the event to the foundation.
|
107 | */
|
108 | private handleKeydownEvent;
|
109 | /**
|
110 | * Used to figure out which element was clicked before sending the event to
|
111 | * the foundation.
|
112 | */
|
113 | private handleClickEvent;
|
114 | }
|