UNPKG

3.4 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 */
23import { MDCFoundation } from '@material/base/foundation';
24import { MDCChipInteractionEventDetail, MDCChipNavigationEventDetail, MDCChipRemovalEventDetail, MDCChipSelectionEventDetail } from '../chip/types';
25import { MDCChipSetAdapter } from './adapter';
26export declare class MDCChipSetFoundation extends MDCFoundation<MDCChipSetAdapter> {
27 static get strings(): {
28 CHIP_SELECTOR: string;
29 };
30 static get cssClasses(): {
31 CHOICE: string;
32 FILTER: string;
33 };
34 static get defaultAdapter(): MDCChipSetAdapter;
35 /**
36 * The ids of the selected chips in the set. Only used for choice chip set or filter chip set.
37 */
38 private selectedChipIds;
39 constructor(adapter?: Partial<MDCChipSetAdapter>);
40 /**
41 * Returns an array of the IDs of all selected chips.
42 */
43 getSelectedChipIds(): ReadonlyArray<string>;
44 /**
45 * Selects the chip with the given id. Deselects all other chips if the chip set is of the choice variant.
46 * Does not notify clients of the updated selection state.
47 */
48 select(chipId: string): void;
49 /**
50 * Handles a chip interaction event
51 */
52 handleChipInteraction({ chipId }: MDCChipInteractionEventDetail): void;
53 /**
54 * Handles a chip selection event, used to handle discrepancy when selection state is set directly on the Chip.
55 */
56 handleChipSelection({ chipId, selected, shouldIgnore }: MDCChipSelectionEventDetail): void;
57 /**
58 * Handles the event when a chip is removed.
59 */
60 handleChipRemoval({ chipId, removedAnnouncement }: MDCChipRemovalEventDetail): void;
61 /**
62 * Handles a chip navigation event.
63 */
64 handleChipNavigation({ chipId, key, source }: MDCChipNavigationEventDetail): void;
65 private focusChipAction;
66 private getDirection;
67 /**
68 * Deselects the chip with the given id and optionally notifies clients.
69 */
70 private deselectImpl;
71 /**
72 * Deselects the chip with the given id and notifies clients.
73 */
74 private deselectAndNotifyClients;
75 /**
76 * Toggles selection of the chip with the given id.
77 */
78 private toggleSelect;
79 private removeFocusFromChipsExcept;
80 private selectAndNotifyClients;
81 private selectImpl;
82}
83export default MDCChipSetFoundation;