1 | /**
|
2 | * @license
|
3 | * Copyright 2021 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 { MDCObserverFoundation } from '@material/base/observer-foundation';
|
24 | import { MDCSwitchAdapter, MDCSwitchRenderAdapter } from './adapter';
|
25 | /**
|
26 | * `MDCSwitchFoundation` provides a state-only foundation for a switch
|
27 | * component.
|
28 | *
|
29 | * State observers and event handler entrypoints update a component's adapter's
|
30 | * state with the logic needed for switch to function.
|
31 | */
|
32 | export declare class MDCSwitchFoundation extends MDCObserverFoundation<MDCSwitchAdapter> {
|
33 | constructor(adapter: MDCSwitchAdapter);
|
34 | /**
|
35 | * Initializes the foundation and starts observing state changes.
|
36 | */
|
37 | init(): void;
|
38 | /**
|
39 | * Event handler for switch click events. Clicking on a switch will toggle its
|
40 | * selected state.
|
41 | */
|
42 | handleClick(): void;
|
43 | protected stopProcessingIfDisabled(): void;
|
44 | }
|
45 | /**
|
46 | * `MDCSwitchRenderFoundation` provides a state and rendering foundation for a
|
47 | * switch component.
|
48 | *
|
49 | * State observers and event handler entrypoints update a component's
|
50 | * adapter's state with the logic needed for switch to function.
|
51 | *
|
52 | * In response to state changes, the rendering foundation uses the component's
|
53 | * render adapter to keep the component's DOM updated with the state.
|
54 | */
|
55 | export declare class MDCSwitchRenderFoundation extends MDCSwitchFoundation {
|
56 | protected adapter: MDCSwitchRenderAdapter;
|
57 | /**
|
58 | * Initializes the foundation and starts observing state changes.
|
59 | */
|
60 | init(): void;
|
61 | /**
|
62 | * Initializes the foundation from a server side rendered (SSR) component.
|
63 | * This will sync the adapter's state with the current state of the DOM.
|
64 | *
|
65 | * This method should be called after `init()`.
|
66 | */
|
67 | initFromDOM(): void;
|
68 | protected onDisabledChange(): void;
|
69 | protected onProcessingChange(): void;
|
70 | protected onSelectedChange(): void;
|
71 | private toggleClass;
|
72 | }
|