1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { FocusMonitor } from '@angular/cdk/a11y';
|
---|
9 | import { BooleanInput } from '@angular/cdk/coercion';
|
---|
10 | import { AfterContentInit, ChangeDetectorRef, ElementRef, EventEmitter, OnDestroy, OnInit, QueryList, InjectionToken, AfterViewInit } from '@angular/core';
|
---|
11 | import { ControlValueAccessor } from '@angular/forms';
|
---|
12 | import { CanDisableRipple } from '@angular/material/core';
|
---|
13 | /**
|
---|
14 | * @deprecated No longer used.
|
---|
15 | * @breaking-change 11.0.0
|
---|
16 | */
|
---|
17 | export declare type ToggleType = 'checkbox' | 'radio';
|
---|
18 | /** Possible appearance styles for the button toggle. */
|
---|
19 | export declare type MatButtonToggleAppearance = 'legacy' | 'standard';
|
---|
20 | /**
|
---|
21 | * Represents the default options for the button toggle that can be configured
|
---|
22 | * using the `MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS` injection token.
|
---|
23 | */
|
---|
24 | export interface MatButtonToggleDefaultOptions {
|
---|
25 | /**
|
---|
26 | * Default appearance to be used by button toggles. Can be overridden by explicitly
|
---|
27 | * setting an appearance on a button toggle or group.
|
---|
28 | */
|
---|
29 | appearance?: MatButtonToggleAppearance;
|
---|
30 | }
|
---|
31 | /**
|
---|
32 | * Injection token that can be used to configure the
|
---|
33 | * default options for all button toggles within an app.
|
---|
34 | */
|
---|
35 | export declare const MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS: InjectionToken<MatButtonToggleDefaultOptions>;
|
---|
36 | /**
|
---|
37 | * Injection token that can be used to reference instances of `MatButtonToggleGroup`.
|
---|
38 | * It serves as alternative token to the actual `MatButtonToggleGroup` class which
|
---|
39 | * could cause unnecessary retention of the class and its component metadata.
|
---|
40 | */
|
---|
41 | export declare const MAT_BUTTON_TOGGLE_GROUP: InjectionToken<MatButtonToggleGroup>;
|
---|
42 | /**
|
---|
43 | * Provider Expression that allows mat-button-toggle-group to register as a ControlValueAccessor.
|
---|
44 | * This allows it to support [(ngModel)].
|
---|
45 | * @docs-private
|
---|
46 | */
|
---|
47 | export declare const MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR: any;
|
---|
48 | /** Change event object emitted by MatButtonToggle. */
|
---|
49 | export declare class MatButtonToggleChange {
|
---|
50 | /** The MatButtonToggle that emits the event. */
|
---|
51 | source: MatButtonToggle;
|
---|
52 | /** The value assigned to the MatButtonToggle. */
|
---|
53 | value: any;
|
---|
54 | constructor(
|
---|
55 | /** The MatButtonToggle that emits the event. */
|
---|
56 | source: MatButtonToggle,
|
---|
57 | /** The value assigned to the MatButtonToggle. */
|
---|
58 | value: any);
|
---|
59 | }
|
---|
60 | /** Exclusive selection button toggle group that behaves like a radio-button group. */
|
---|
61 | export declare class MatButtonToggleGroup implements ControlValueAccessor, OnInit, AfterContentInit {
|
---|
62 | private _changeDetector;
|
---|
63 | private _vertical;
|
---|
64 | private _multiple;
|
---|
65 | private _disabled;
|
---|
66 | private _selectionModel;
|
---|
67 | /**
|
---|
68 | * Reference to the raw value that the consumer tried to assign. The real
|
---|
69 | * value will exclude any values from this one that don't correspond to a
|
---|
70 | * toggle. Useful for the cases where the value is assigned before the toggles
|
---|
71 | * have been initialized or at the same that they're being swapped out.
|
---|
72 | */
|
---|
73 | private _rawValue;
|
---|
74 | /**
|
---|
75 | * The method to be called in order to update ngModel.
|
---|
76 | * Now `ngModel` binding is not supported in multiple selection mode.
|
---|
77 | */
|
---|
78 | _controlValueAccessorChangeFn: (value: any) => void;
|
---|
79 | /** onTouch function registered via registerOnTouch (ControlValueAccessor). */
|
---|
80 | _onTouched: () => any;
|
---|
81 | /** Child button toggle buttons. */
|
---|
82 | _buttonToggles: QueryList<MatButtonToggle>;
|
---|
83 | /** The appearance for all the buttons in the group. */
|
---|
84 | appearance: MatButtonToggleAppearance;
|
---|
85 | /** `name` attribute for the underlying `input` element. */
|
---|
86 | get name(): string;
|
---|
87 | set name(value: string);
|
---|
88 | private _name;
|
---|
89 | /** Whether the toggle group is vertical. */
|
---|
90 | get vertical(): boolean;
|
---|
91 | set vertical(value: boolean);
|
---|
92 | /** Value of the toggle group. */
|
---|
93 | get value(): any;
|
---|
94 | set value(newValue: any);
|
---|
95 | /**
|
---|
96 | * Event that emits whenever the value of the group changes.
|
---|
97 | * Used to facilitate two-way data binding.
|
---|
98 | * @docs-private
|
---|
99 | */
|
---|
100 | readonly valueChange: EventEmitter<any>;
|
---|
101 | /** Selected button toggles in the group. */
|
---|
102 | get selected(): MatButtonToggle | MatButtonToggle[];
|
---|
103 | /** Whether multiple button toggles can be selected. */
|
---|
104 | get multiple(): boolean;
|
---|
105 | set multiple(value: boolean);
|
---|
106 | /** Whether multiple button toggle group is disabled. */
|
---|
107 | get disabled(): boolean;
|
---|
108 | set disabled(value: boolean);
|
---|
109 | /** Event emitted when the group's value changes. */
|
---|
110 | readonly change: EventEmitter<MatButtonToggleChange>;
|
---|
111 | constructor(_changeDetector: ChangeDetectorRef, defaultOptions?: MatButtonToggleDefaultOptions);
|
---|
112 | ngOnInit(): void;
|
---|
113 | ngAfterContentInit(): void;
|
---|
114 | /**
|
---|
115 | * Sets the model value. Implemented as part of ControlValueAccessor.
|
---|
116 | * @param value Value to be set to the model.
|
---|
117 | */
|
---|
118 | writeValue(value: any): void;
|
---|
119 | registerOnChange(fn: (value: any) => void): void;
|
---|
120 | registerOnTouched(fn: any): void;
|
---|
121 | setDisabledState(isDisabled: boolean): void;
|
---|
122 | /** Dispatch change event with current selection and group value. */
|
---|
123 | _emitChangeEvent(): void;
|
---|
124 | /**
|
---|
125 | * Syncs a button toggle's selected state with the model value.
|
---|
126 | * @param toggle Toggle to be synced.
|
---|
127 | * @param select Whether the toggle should be selected.
|
---|
128 | * @param isUserInput Whether the change was a result of a user interaction.
|
---|
129 | * @param deferEvents Whether to defer emitting the change events.
|
---|
130 | */
|
---|
131 | _syncButtonToggle(toggle: MatButtonToggle, select: boolean, isUserInput?: boolean, deferEvents?: boolean): void;
|
---|
132 | /** Checks whether a button toggle is selected. */
|
---|
133 | _isSelected(toggle: MatButtonToggle): boolean;
|
---|
134 | /** Determines whether a button toggle should be checked on init. */
|
---|
135 | _isPrechecked(toggle: MatButtonToggle): boolean;
|
---|
136 | /** Updates the selection state of the toggles in the group based on a value. */
|
---|
137 | private _setSelectionByValue;
|
---|
138 | /** Clears the selected toggles. */
|
---|
139 | private _clearSelection;
|
---|
140 | /** Selects a value if there's a toggle that corresponds to it. */
|
---|
141 | private _selectValue;
|
---|
142 | /** Syncs up the group's value with the model and emits the change event. */
|
---|
143 | private _updateModelValue;
|
---|
144 | static ngAcceptInputType_disabled: BooleanInput;
|
---|
145 | static ngAcceptInputType_multiple: BooleanInput;
|
---|
146 | static ngAcceptInputType_vertical: BooleanInput;
|
---|
147 | }
|
---|
148 | /** @docs-private */
|
---|
149 | declare const _MatButtonToggleBase: import("@angular/material/core/common-behaviors/constructor").Constructor<CanDisableRipple> & import("@angular/material/core/common-behaviors/constructor").AbstractConstructor<CanDisableRipple> & {
|
---|
150 | new (): {};
|
---|
151 | };
|
---|
152 | /** Single button inside of a toggle group. */
|
---|
153 | export declare class MatButtonToggle extends _MatButtonToggleBase implements OnInit, AfterViewInit, CanDisableRipple, OnDestroy {
|
---|
154 | private _changeDetectorRef;
|
---|
155 | private _elementRef;
|
---|
156 | private _focusMonitor;
|
---|
157 | private _isSingleSelector;
|
---|
158 | private _checked;
|
---|
159 | /**
|
---|
160 | * Attached to the aria-label attribute of the host element. In most cases, aria-labelledby will
|
---|
161 | * take precedence so this may be omitted.
|
---|
162 | */
|
---|
163 | ariaLabel: string;
|
---|
164 | /**
|
---|
165 | * Users can specify the `aria-labelledby` attribute which will be forwarded to the input element
|
---|
166 | */
|
---|
167 | ariaLabelledby: string | null;
|
---|
168 | /** Underlying native `button` element. */
|
---|
169 | _buttonElement: ElementRef<HTMLButtonElement>;
|
---|
170 | /** The parent button toggle group (exclusive selection). Optional. */
|
---|
171 | buttonToggleGroup: MatButtonToggleGroup;
|
---|
172 | /** Unique ID for the underlying `button` element. */
|
---|
173 | get buttonId(): string;
|
---|
174 | /** The unique ID for this button toggle. */
|
---|
175 | id: string;
|
---|
176 | /** HTML's 'name' attribute used to group radios for unique selection. */
|
---|
177 | name: string;
|
---|
178 | /** MatButtonToggleGroup reads this to assign its own value. */
|
---|
179 | value: any;
|
---|
180 | /** Tabindex for the toggle. */
|
---|
181 | tabIndex: number | null;
|
---|
182 | /** The appearance style of the button. */
|
---|
183 | get appearance(): MatButtonToggleAppearance;
|
---|
184 | set appearance(value: MatButtonToggleAppearance);
|
---|
185 | private _appearance;
|
---|
186 | /** Whether the button is checked. */
|
---|
187 | get checked(): boolean;
|
---|
188 | set checked(value: boolean);
|
---|
189 | /** Whether the button is disabled. */
|
---|
190 | get disabled(): boolean;
|
---|
191 | set disabled(value: boolean);
|
---|
192 | private _disabled;
|
---|
193 | /** Event emitted when the group value changes. */
|
---|
194 | readonly change: EventEmitter<MatButtonToggleChange>;
|
---|
195 | constructor(toggleGroup: MatButtonToggleGroup, _changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef<HTMLElement>, _focusMonitor: FocusMonitor, defaultTabIndex: string, defaultOptions?: MatButtonToggleDefaultOptions);
|
---|
196 | ngOnInit(): void;
|
---|
197 | ngAfterViewInit(): void;
|
---|
198 | ngOnDestroy(): void;
|
---|
199 | /** Focuses the button. */
|
---|
200 | focus(options?: FocusOptions): void;
|
---|
201 | /** Checks the button toggle due to an interaction with the underlying native button. */
|
---|
202 | _onButtonClick(): void;
|
---|
203 | /**
|
---|
204 | * Marks the button toggle as needing checking for change detection.
|
---|
205 | * This method is exposed because the parent button toggle group will directly
|
---|
206 | * update bound properties of the radio button.
|
---|
207 | */
|
---|
208 | _markForCheck(): void;
|
---|
209 | static ngAcceptInputType_checked: BooleanInput;
|
---|
210 | static ngAcceptInputType_disabled: BooleanInput;
|
---|
211 | static ngAcceptInputType_vertical: BooleanInput;
|
---|
212 | static ngAcceptInputType_multiple: BooleanInput;
|
---|
213 | static ngAcceptInputType_disableRipple: BooleanInput;
|
---|
214 | }
|
---|
215 | export {};
|
---|