UNPKG

3.08 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2017 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/**
24 * Defines the shape of the adapter expected by the foundation.
25 * Implement this adapter for your framework of choice to delegate updates to
26 * the component in your framework of choice. See architecture documentation
27 * for more details.
28 * https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md
29 */
30export interface MDCChipSetAdapter {
31 /**
32 * @return true if the root element contains the given class name.
33 */
34 hasClass(className: string): boolean;
35 /**
36 * Removes the chip with the given index from the chip set.
37 * Make sure to remove it from the chip list, too.
38 */
39 removeChipAtIndex(index: number): void;
40 /**
41 * Sets the selected state of the chip at the given index.
42 */
43 selectChipAtIndex(index: number, isSelected: boolean, shouldNotifyClients: boolean): void;
44 /**
45 * Returns the index of the chip at the given ID.
46 * @param chipId the unique ID of the chip
47 * @return the numerical index of the chip with the matching id or -1.
48 */
49 getIndexOfChipById(chipId: string): number;
50 /**
51 * Calls Chip#focusPrimaryAction() on the chip at the given index.
52 * @param index the index of the chip
53 */
54 focusChipPrimaryActionAtIndex(index: number): void;
55 /**
56 * Calls Chip#focusTrailingAction() on the chip at the given index.
57 * @param index the index of the chip
58 */
59 focusChipTrailingActionAtIndex(index: number): void;
60 /**
61 * Removes focus from the chip at the given index.
62 * @param index the index of the chip
63 */
64 removeFocusFromChipAtIndex(index: number): void;
65 /**
66 * @return true if the text direction is RTL.
67 */
68 isRTL(): boolean;
69 /**
70 * @return the number of chips in the chip set.
71 */
72 getChipListCount(): number;
73 /**
74 * Announces the message via an aria-live region.
75 */
76 announceMessage(message: string): void;
77}