1 | /**
|
2 | * @license
|
3 | * Copyright 2020 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 { MDCChipActionFocusBehavior, MDCChipActionType } from '../action/constants';
|
24 | import { MDCChipAnimation } from '../chip/constants';
|
25 | import { MDCChipSetAttributes, MDCChipSetEvents } from './constants';
|
26 | /**
|
27 | * Defines the shape of the adapter expected by the foundation.
|
28 | * Implement this adapter for your framework of choice to delegate updates to
|
29 | * the component in your framework of choice. See architecture documentation
|
30 | * for more details.
|
31 | * https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md
|
32 | */
|
33 | export interface MDCChipSetAdapter {
|
34 | /** Announces the message via an aria-live region */
|
35 | announceMessage(message: string): void;
|
36 | /** Emits the given event with the given detail. */
|
37 | emitEvent<D extends object>(eventName: MDCChipSetEvents, eventDetail: D): void;
|
38 | /** Returns the value for the given attribute, if it exists. */
|
39 | getAttribute(attrName: MDCChipSetAttributes): string | null;
|
40 | /** Returns the actions provided by the child chip at the given index. */
|
41 | getChipActionsAtIndex(index: number): MDCChipActionType[];
|
42 | /** Returns the number of child chips. */
|
43 | getChipCount(): number;
|
44 | /** Returns the ID of the chip at the given index. */
|
45 | getChipIdAtIndex(index: number): string;
|
46 | /** Returns the index of the child chip with the matching ID. */
|
47 | getChipIndexById(chipID: string): number;
|
48 | /** Proxies to the MDCChip#isActionFocusable method. */
|
49 | isChipFocusableAtIndex(index: number, actionType: MDCChipActionType): boolean;
|
50 | /** Proxies to the MDCChip#isActionSelectable method. */
|
51 | isChipSelectableAtIndex(index: number, actionType: MDCChipActionType): boolean;
|
52 | /** Proxies to the MDCChip#isActionSelected method. */
|
53 | isChipSelectedAtIndex(index: number, actionType: MDCChipActionType): boolean;
|
54 | /** Removes the chip at the given index. */
|
55 | removeChipAtIndex(index: number): void;
|
56 | /** Proxies to the MDCChip#setActionFocus method. */
|
57 | setChipFocusAtIndex(index: number, action: MDCChipActionType, focus: MDCChipActionFocusBehavior): void;
|
58 | /** Proxies to the MDCChip#setActionSelected method. */
|
59 | setChipSelectedAtIndex(index: number, actionType: MDCChipActionType, isSelected: boolean): void;
|
60 | /** Starts the chip animation at the given index. */
|
61 | startChipAnimationAtIndex(index: number, animation: MDCChipAnimation): void;
|
62 | }
|