1 | import { FocusMonitor } from '@angular/cdk/a11y';
|
---|
2 | import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
---|
3 | import { SelectionModel } from '@angular/cdk/collections';
|
---|
4 | import { InjectionToken, forwardRef, EventEmitter, Directive, ChangeDetectorRef, Optional, Inject, ContentChildren, Input, Output, Component, ViewEncapsulation, ChangeDetectionStrategy, ElementRef, Attribute, ViewChild, NgModule } from '@angular/core';
|
---|
5 | import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
---|
6 | import { mixinDisableRipple, MatCommonModule, MatRippleModule } from '@angular/material/core';
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * @license
|
---|
10 | * Copyright Google LLC All Rights Reserved.
|
---|
11 | *
|
---|
12 | * Use of this source code is governed by an MIT-style license that can be
|
---|
13 | * found in the LICENSE file at https://angular.io/license
|
---|
14 | */
|
---|
15 | /**
|
---|
16 | * Injection token that can be used to configure the
|
---|
17 | * default options for all button toggles within an app.
|
---|
18 | */
|
---|
19 | const MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS = new InjectionToken('MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS');
|
---|
20 | /**
|
---|
21 | * Injection token that can be used to reference instances of `MatButtonToggleGroup`.
|
---|
22 | * It serves as alternative token to the actual `MatButtonToggleGroup` class which
|
---|
23 | * could cause unnecessary retention of the class and its component metadata.
|
---|
24 | */
|
---|
25 | const MAT_BUTTON_TOGGLE_GROUP = new InjectionToken('MatButtonToggleGroup');
|
---|
26 | /**
|
---|
27 | * Provider Expression that allows mat-button-toggle-group to register as a ControlValueAccessor.
|
---|
28 | * This allows it to support [(ngModel)].
|
---|
29 | * @docs-private
|
---|
30 | */
|
---|
31 | const MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR = {
|
---|
32 | provide: NG_VALUE_ACCESSOR,
|
---|
33 | useExisting: forwardRef(() => MatButtonToggleGroup),
|
---|
34 | multi: true
|
---|
35 | };
|
---|
36 | // Counter used to generate unique IDs.
|
---|
37 | let uniqueIdCounter = 0;
|
---|
38 | /** Change event object emitted by MatButtonToggle. */
|
---|
39 | class MatButtonToggleChange {
|
---|
40 | constructor(
|
---|
41 | /** The MatButtonToggle that emits the event. */
|
---|
42 | source,
|
---|
43 | /** The value assigned to the MatButtonToggle. */
|
---|
44 | value) {
|
---|
45 | this.source = source;
|
---|
46 | this.value = value;
|
---|
47 | }
|
---|
48 | }
|
---|
49 | /** Exclusive selection button toggle group that behaves like a radio-button group. */
|
---|
50 | class MatButtonToggleGroup {
|
---|
51 | constructor(_changeDetector, defaultOptions) {
|
---|
52 | this._changeDetector = _changeDetector;
|
---|
53 | this._vertical = false;
|
---|
54 | this._multiple = false;
|
---|
55 | this._disabled = false;
|
---|
56 | /**
|
---|
57 | * The method to be called in order to update ngModel.
|
---|
58 | * Now `ngModel` binding is not supported in multiple selection mode.
|
---|
59 | */
|
---|
60 | this._controlValueAccessorChangeFn = () => { };
|
---|
61 | /** onTouch function registered via registerOnTouch (ControlValueAccessor). */
|
---|
62 | this._onTouched = () => { };
|
---|
63 | this._name = `mat-button-toggle-group-${uniqueIdCounter++}`;
|
---|
64 | /**
|
---|
65 | * Event that emits whenever the value of the group changes.
|
---|
66 | * Used to facilitate two-way data binding.
|
---|
67 | * @docs-private
|
---|
68 | */
|
---|
69 | this.valueChange = new EventEmitter();
|
---|
70 | /** Event emitted when the group's value changes. */
|
---|
71 | this.change = new EventEmitter();
|
---|
72 | this.appearance =
|
---|
73 | defaultOptions && defaultOptions.appearance ? defaultOptions.appearance : 'standard';
|
---|
74 | }
|
---|
75 | /** `name` attribute for the underlying `input` element. */
|
---|
76 | get name() { return this._name; }
|
---|
77 | set name(value) {
|
---|
78 | this._name = value;
|
---|
79 | if (this._buttonToggles) {
|
---|
80 | this._buttonToggles.forEach(toggle => {
|
---|
81 | toggle.name = this._name;
|
---|
82 | toggle._markForCheck();
|
---|
83 | });
|
---|
84 | }
|
---|
85 | }
|
---|
86 | /** Whether the toggle group is vertical. */
|
---|
87 | get vertical() { return this._vertical; }
|
---|
88 | set vertical(value) {
|
---|
89 | this._vertical = coerceBooleanProperty(value);
|
---|
90 | }
|
---|
91 | /** Value of the toggle group. */
|
---|
92 | get value() {
|
---|
93 | const selected = this._selectionModel ? this._selectionModel.selected : [];
|
---|
94 | if (this.multiple) {
|
---|
95 | return selected.map(toggle => toggle.value);
|
---|
96 | }
|
---|
97 | return selected[0] ? selected[0].value : undefined;
|
---|
98 | }
|
---|
99 | set value(newValue) {
|
---|
100 | this._setSelectionByValue(newValue);
|
---|
101 | this.valueChange.emit(this.value);
|
---|
102 | }
|
---|
103 | /** Selected button toggles in the group. */
|
---|
104 | get selected() {
|
---|
105 | const selected = this._selectionModel ? this._selectionModel.selected : [];
|
---|
106 | return this.multiple ? selected : (selected[0] || null);
|
---|
107 | }
|
---|
108 | /** Whether multiple button toggles can be selected. */
|
---|
109 | get multiple() { return this._multiple; }
|
---|
110 | set multiple(value) {
|
---|
111 | this._multiple = coerceBooleanProperty(value);
|
---|
112 | }
|
---|
113 | /** Whether multiple button toggle group is disabled. */
|
---|
114 | get disabled() { return this._disabled; }
|
---|
115 | set disabled(value) {
|
---|
116 | this._disabled = coerceBooleanProperty(value);
|
---|
117 | if (this._buttonToggles) {
|
---|
118 | this._buttonToggles.forEach(toggle => toggle._markForCheck());
|
---|
119 | }
|
---|
120 | }
|
---|
121 | ngOnInit() {
|
---|
122 | this._selectionModel = new SelectionModel(this.multiple, undefined, false);
|
---|
123 | }
|
---|
124 | ngAfterContentInit() {
|
---|
125 | this._selectionModel.select(...this._buttonToggles.filter(toggle => toggle.checked));
|
---|
126 | }
|
---|
127 | /**
|
---|
128 | * Sets the model value. Implemented as part of ControlValueAccessor.
|
---|
129 | * @param value Value to be set to the model.
|
---|
130 | */
|
---|
131 | writeValue(value) {
|
---|
132 | this.value = value;
|
---|
133 | this._changeDetector.markForCheck();
|
---|
134 | }
|
---|
135 | // Implemented as part of ControlValueAccessor.
|
---|
136 | registerOnChange(fn) {
|
---|
137 | this._controlValueAccessorChangeFn = fn;
|
---|
138 | }
|
---|
139 | // Implemented as part of ControlValueAccessor.
|
---|
140 | registerOnTouched(fn) {
|
---|
141 | this._onTouched = fn;
|
---|
142 | }
|
---|
143 | // Implemented as part of ControlValueAccessor.
|
---|
144 | setDisabledState(isDisabled) {
|
---|
145 | this.disabled = isDisabled;
|
---|
146 | }
|
---|
147 | /** Dispatch change event with current selection and group value. */
|
---|
148 | _emitChangeEvent() {
|
---|
149 | const selected = this.selected;
|
---|
150 | const source = Array.isArray(selected) ? selected[selected.length - 1] : selected;
|
---|
151 | const event = new MatButtonToggleChange(source, this.value);
|
---|
152 | this._controlValueAccessorChangeFn(event.value);
|
---|
153 | this.change.emit(event);
|
---|
154 | }
|
---|
155 | /**
|
---|
156 | * Syncs a button toggle's selected state with the model value.
|
---|
157 | * @param toggle Toggle to be synced.
|
---|
158 | * @param select Whether the toggle should be selected.
|
---|
159 | * @param isUserInput Whether the change was a result of a user interaction.
|
---|
160 | * @param deferEvents Whether to defer emitting the change events.
|
---|
161 | */
|
---|
162 | _syncButtonToggle(toggle, select, isUserInput = false, deferEvents = false) {
|
---|
163 | // Deselect the currently-selected toggle, if we're in single-selection
|
---|
164 | // mode and the button being toggled isn't selected at the moment.
|
---|
165 | if (!this.multiple && this.selected && !toggle.checked) {
|
---|
166 | this.selected.checked = false;
|
---|
167 | }
|
---|
168 | if (this._selectionModel) {
|
---|
169 | if (select) {
|
---|
170 | this._selectionModel.select(toggle);
|
---|
171 | }
|
---|
172 | else {
|
---|
173 | this._selectionModel.deselect(toggle);
|
---|
174 | }
|
---|
175 | }
|
---|
176 | else {
|
---|
177 | deferEvents = true;
|
---|
178 | }
|
---|
179 | // We need to defer in some cases in order to avoid "changed after checked errors", however
|
---|
180 | // the side-effect is that we may end up updating the model value out of sequence in others
|
---|
181 | // The `deferEvents` flag allows us to decide whether to do it on a case-by-case basis.
|
---|
182 | if (deferEvents) {
|
---|
183 | Promise.resolve().then(() => this._updateModelValue(isUserInput));
|
---|
184 | }
|
---|
185 | else {
|
---|
186 | this._updateModelValue(isUserInput);
|
---|
187 | }
|
---|
188 | }
|
---|
189 | /** Checks whether a button toggle is selected. */
|
---|
190 | _isSelected(toggle) {
|
---|
191 | return this._selectionModel && this._selectionModel.isSelected(toggle);
|
---|
192 | }
|
---|
193 | /** Determines whether a button toggle should be checked on init. */
|
---|
194 | _isPrechecked(toggle) {
|
---|
195 | if (typeof this._rawValue === 'undefined') {
|
---|
196 | return false;
|
---|
197 | }
|
---|
198 | if (this.multiple && Array.isArray(this._rawValue)) {
|
---|
199 | return this._rawValue.some(value => toggle.value != null && value === toggle.value);
|
---|
200 | }
|
---|
201 | return toggle.value === this._rawValue;
|
---|
202 | }
|
---|
203 | /** Updates the selection state of the toggles in the group based on a value. */
|
---|
204 | _setSelectionByValue(value) {
|
---|
205 | this._rawValue = value;
|
---|
206 | if (!this._buttonToggles) {
|
---|
207 | return;
|
---|
208 | }
|
---|
209 | if (this.multiple && value) {
|
---|
210 | if (!Array.isArray(value) && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
211 | throw Error('Value must be an array in multiple-selection mode.');
|
---|
212 | }
|
---|
213 | this._clearSelection();
|
---|
214 | value.forEach((currentValue) => this._selectValue(currentValue));
|
---|
215 | }
|
---|
216 | else {
|
---|
217 | this._clearSelection();
|
---|
218 | this._selectValue(value);
|
---|
219 | }
|
---|
220 | }
|
---|
221 | /** Clears the selected toggles. */
|
---|
222 | _clearSelection() {
|
---|
223 | this._selectionModel.clear();
|
---|
224 | this._buttonToggles.forEach(toggle => toggle.checked = false);
|
---|
225 | }
|
---|
226 | /** Selects a value if there's a toggle that corresponds to it. */
|
---|
227 | _selectValue(value) {
|
---|
228 | const correspondingOption = this._buttonToggles.find(toggle => {
|
---|
229 | return toggle.value != null && toggle.value === value;
|
---|
230 | });
|
---|
231 | if (correspondingOption) {
|
---|
232 | correspondingOption.checked = true;
|
---|
233 | this._selectionModel.select(correspondingOption);
|
---|
234 | }
|
---|
235 | }
|
---|
236 | /** Syncs up the group's value with the model and emits the change event. */
|
---|
237 | _updateModelValue(isUserInput) {
|
---|
238 | // Only emit the change event for user input.
|
---|
239 | if (isUserInput) {
|
---|
240 | this._emitChangeEvent();
|
---|
241 | }
|
---|
242 | // Note: we emit this one no matter whether it was a user interaction, because
|
---|
243 | // it is used by Angular to sync up the two-way data binding.
|
---|
244 | this.valueChange.emit(this.value);
|
---|
245 | }
|
---|
246 | }
|
---|
247 | MatButtonToggleGroup.decorators = [
|
---|
248 | { type: Directive, args: [{
|
---|
249 | selector: 'mat-button-toggle-group',
|
---|
250 | providers: [
|
---|
251 | MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR,
|
---|
252 | { provide: MAT_BUTTON_TOGGLE_GROUP, useExisting: MatButtonToggleGroup },
|
---|
253 | ],
|
---|
254 | host: {
|
---|
255 | 'role': 'group',
|
---|
256 | 'class': 'mat-button-toggle-group',
|
---|
257 | '[attr.aria-disabled]': 'disabled',
|
---|
258 | '[class.mat-button-toggle-vertical]': 'vertical',
|
---|
259 | '[class.mat-button-toggle-group-appearance-standard]': 'appearance === "standard"',
|
---|
260 | },
|
---|
261 | exportAs: 'matButtonToggleGroup',
|
---|
262 | },] }
|
---|
263 | ];
|
---|
264 | MatButtonToggleGroup.ctorParameters = () => [
|
---|
265 | { type: ChangeDetectorRef },
|
---|
266 | { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS,] }] }
|
---|
267 | ];
|
---|
268 | MatButtonToggleGroup.propDecorators = {
|
---|
269 | _buttonToggles: [{ type: ContentChildren, args: [forwardRef(() => MatButtonToggle), {
|
---|
270 | // Note that this would technically pick up toggles
|
---|
271 | // from nested groups, but that's not a case that we support.
|
---|
272 | descendants: true
|
---|
273 | },] }],
|
---|
274 | appearance: [{ type: Input }],
|
---|
275 | name: [{ type: Input }],
|
---|
276 | vertical: [{ type: Input }],
|
---|
277 | value: [{ type: Input }],
|
---|
278 | valueChange: [{ type: Output }],
|
---|
279 | multiple: [{ type: Input }],
|
---|
280 | disabled: [{ type: Input }],
|
---|
281 | change: [{ type: Output }]
|
---|
282 | };
|
---|
283 | // Boilerplate for applying mixins to the MatButtonToggle class.
|
---|
284 | /** @docs-private */
|
---|
285 | const _MatButtonToggleBase = mixinDisableRipple(class {
|
---|
286 | });
|
---|
287 | /** Single button inside of a toggle group. */
|
---|
288 | class MatButtonToggle extends _MatButtonToggleBase {
|
---|
289 | constructor(toggleGroup, _changeDetectorRef, _elementRef, _focusMonitor, defaultTabIndex, defaultOptions) {
|
---|
290 | super();
|
---|
291 | this._changeDetectorRef = _changeDetectorRef;
|
---|
292 | this._elementRef = _elementRef;
|
---|
293 | this._focusMonitor = _focusMonitor;
|
---|
294 | this._isSingleSelector = false;
|
---|
295 | this._checked = false;
|
---|
296 | /**
|
---|
297 | * Users can specify the `aria-labelledby` attribute which will be forwarded to the input element
|
---|
298 | */
|
---|
299 | this.ariaLabelledby = null;
|
---|
300 | this._disabled = false;
|
---|
301 | /** Event emitted when the group value changes. */
|
---|
302 | this.change = new EventEmitter();
|
---|
303 | const parsedTabIndex = Number(defaultTabIndex);
|
---|
304 | this.tabIndex = (parsedTabIndex || parsedTabIndex === 0) ? parsedTabIndex : null;
|
---|
305 | this.buttonToggleGroup = toggleGroup;
|
---|
306 | this.appearance =
|
---|
307 | defaultOptions && defaultOptions.appearance ? defaultOptions.appearance : 'standard';
|
---|
308 | }
|
---|
309 | /** Unique ID for the underlying `button` element. */
|
---|
310 | get buttonId() { return `${this.id}-button`; }
|
---|
311 | /** The appearance style of the button. */
|
---|
312 | get appearance() {
|
---|
313 | return this.buttonToggleGroup ? this.buttonToggleGroup.appearance : this._appearance;
|
---|
314 | }
|
---|
315 | set appearance(value) {
|
---|
316 | this._appearance = value;
|
---|
317 | }
|
---|
318 | /** Whether the button is checked. */
|
---|
319 | get checked() {
|
---|
320 | return this.buttonToggleGroup ? this.buttonToggleGroup._isSelected(this) : this._checked;
|
---|
321 | }
|
---|
322 | set checked(value) {
|
---|
323 | const newValue = coerceBooleanProperty(value);
|
---|
324 | if (newValue !== this._checked) {
|
---|
325 | this._checked = newValue;
|
---|
326 | if (this.buttonToggleGroup) {
|
---|
327 | this.buttonToggleGroup._syncButtonToggle(this, this._checked);
|
---|
328 | }
|
---|
329 | this._changeDetectorRef.markForCheck();
|
---|
330 | }
|
---|
331 | }
|
---|
332 | /** Whether the button is disabled. */
|
---|
333 | get disabled() {
|
---|
334 | return this._disabled || (this.buttonToggleGroup && this.buttonToggleGroup.disabled);
|
---|
335 | }
|
---|
336 | set disabled(value) { this._disabled = coerceBooleanProperty(value); }
|
---|
337 | ngOnInit() {
|
---|
338 | const group = this.buttonToggleGroup;
|
---|
339 | this._isSingleSelector = group && !group.multiple;
|
---|
340 | this.id = this.id || `mat-button-toggle-${uniqueIdCounter++}`;
|
---|
341 | if (this._isSingleSelector) {
|
---|
342 | this.name = group.name;
|
---|
343 | }
|
---|
344 | if (group) {
|
---|
345 | if (group._isPrechecked(this)) {
|
---|
346 | this.checked = true;
|
---|
347 | }
|
---|
348 | else if (group._isSelected(this) !== this._checked) {
|
---|
349 | // As as side effect of the circular dependency between the toggle group and the button,
|
---|
350 | // we may end up in a state where the button is supposed to be checked on init, but it
|
---|
351 | // isn't, because the checked value was assigned too early. This can happen when Ivy
|
---|
352 | // assigns the static input value before the `ngOnInit` has run.
|
---|
353 | group._syncButtonToggle(this, this._checked);
|
---|
354 | }
|
---|
355 | }
|
---|
356 | }
|
---|
357 | ngAfterViewInit() {
|
---|
358 | this._focusMonitor.monitor(this._elementRef, true);
|
---|
359 | }
|
---|
360 | ngOnDestroy() {
|
---|
361 | const group = this.buttonToggleGroup;
|
---|
362 | this._focusMonitor.stopMonitoring(this._elementRef);
|
---|
363 | // Remove the toggle from the selection once it's destroyed. Needs to happen
|
---|
364 | // on the next tick in order to avoid "changed after checked" errors.
|
---|
365 | if (group && group._isSelected(this)) {
|
---|
366 | group._syncButtonToggle(this, false, false, true);
|
---|
367 | }
|
---|
368 | }
|
---|
369 | /** Focuses the button. */
|
---|
370 | focus(options) {
|
---|
371 | this._buttonElement.nativeElement.focus(options);
|
---|
372 | }
|
---|
373 | /** Checks the button toggle due to an interaction with the underlying native button. */
|
---|
374 | _onButtonClick() {
|
---|
375 | const newChecked = this._isSingleSelector ? true : !this._checked;
|
---|
376 | if (newChecked !== this._checked) {
|
---|
377 | this._checked = newChecked;
|
---|
378 | if (this.buttonToggleGroup) {
|
---|
379 | this.buttonToggleGroup._syncButtonToggle(this, this._checked, true);
|
---|
380 | this.buttonToggleGroup._onTouched();
|
---|
381 | }
|
---|
382 | }
|
---|
383 | // Emit a change event when it's the single selector
|
---|
384 | this.change.emit(new MatButtonToggleChange(this, this.value));
|
---|
385 | }
|
---|
386 | /**
|
---|
387 | * Marks the button toggle as needing checking for change detection.
|
---|
388 | * This method is exposed because the parent button toggle group will directly
|
---|
389 | * update bound properties of the radio button.
|
---|
390 | */
|
---|
391 | _markForCheck() {
|
---|
392 | // When the group value changes, the button will not be notified.
|
---|
393 | // Use `markForCheck` to explicit update button toggle's status.
|
---|
394 | this._changeDetectorRef.markForCheck();
|
---|
395 | }
|
---|
396 | }
|
---|
397 | MatButtonToggle.decorators = [
|
---|
398 | { type: Component, args: [{
|
---|
399 | selector: 'mat-button-toggle',
|
---|
400 | template: "<button #button class=\"mat-button-toggle-button mat-focus-indicator\"\n type=\"button\"\n [id]=\"buttonId\"\n [attr.tabindex]=\"disabled ? -1 : tabIndex\"\n [attr.aria-pressed]=\"checked\"\n [disabled]=\"disabled || null\"\n [attr.name]=\"name || null\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n (click)=\"_onButtonClick()\">\n <span class=\"mat-button-toggle-label-content\">\n <ng-content></ng-content>\n </span>\n</button>\n\n<span class=\"mat-button-toggle-focus-overlay\"></span>\n<span class=\"mat-button-toggle-ripple\" matRipple\n [matRippleTrigger]=\"button\"\n [matRippleDisabled]=\"this.disableRipple || this.disabled\">\n</span>\n",
|
---|
401 | encapsulation: ViewEncapsulation.None,
|
---|
402 | exportAs: 'matButtonToggle',
|
---|
403 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
404 | inputs: ['disableRipple'],
|
---|
405 | host: {
|
---|
406 | '[class.mat-button-toggle-standalone]': '!buttonToggleGroup',
|
---|
407 | '[class.mat-button-toggle-checked]': 'checked',
|
---|
408 | '[class.mat-button-toggle-disabled]': 'disabled',
|
---|
409 | '[class.mat-button-toggle-appearance-standard]': 'appearance === "standard"',
|
---|
410 | 'class': 'mat-button-toggle',
|
---|
411 | '[attr.aria-label]': 'null',
|
---|
412 | '[attr.aria-labelledby]': 'null',
|
---|
413 | '[attr.id]': 'id',
|
---|
414 | '[attr.name]': 'null',
|
---|
415 | '(focus)': 'focus()',
|
---|
416 | 'role': 'presentation',
|
---|
417 | },
|
---|
418 | styles: [".mat-button-toggle-standalone,.mat-button-toggle-group{position:relative;display:inline-flex;flex-direction:row;white-space:nowrap;overflow:hidden;border-radius:2px;-webkit-tap-highlight-color:transparent}.cdk-high-contrast-active .mat-button-toggle-standalone,.cdk-high-contrast-active .mat-button-toggle-group{outline:solid 1px}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard,.mat-button-toggle-group-appearance-standard{border-radius:4px}.cdk-high-contrast-active .mat-button-toggle-standalone.mat-button-toggle-appearance-standard,.cdk-high-contrast-active .mat-button-toggle-group-appearance-standard{outline:0}.mat-button-toggle-vertical{flex-direction:column}.mat-button-toggle-vertical .mat-button-toggle-label-content{display:block}.mat-button-toggle{white-space:nowrap;position:relative}.mat-button-toggle .mat-icon svg{vertical-align:top}.mat-button-toggle.cdk-keyboard-focused .mat-button-toggle-focus-overlay{opacity:1}.cdk-high-contrast-active .mat-button-toggle.cdk-keyboard-focused .mat-button-toggle-focus-overlay{opacity:.5}.mat-button-toggle-appearance-standard:not(.mat-button-toggle-disabled):hover .mat-button-toggle-focus-overlay{opacity:.04}.mat-button-toggle-appearance-standard.cdk-keyboard-focused:not(.mat-button-toggle-disabled) .mat-button-toggle-focus-overlay{opacity:.12}.cdk-high-contrast-active .mat-button-toggle-appearance-standard.cdk-keyboard-focused:not(.mat-button-toggle-disabled) .mat-button-toggle-focus-overlay{opacity:.5}@media(hover: none){.mat-button-toggle-appearance-standard:not(.mat-button-toggle-disabled):hover .mat-button-toggle-focus-overlay{display:none}}.mat-button-toggle-label-content{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:inline-block;line-height:36px;padding:0 16px;position:relative}.mat-button-toggle-appearance-standard .mat-button-toggle-label-content{padding:0 12px}.mat-button-toggle-label-content>*{vertical-align:middle}.mat-button-toggle-focus-overlay{border-radius:inherit;pointer-events:none;opacity:0;top:0;left:0;right:0;bottom:0;position:absolute}.mat-button-toggle-checked .mat-button-toggle-focus-overlay{border-bottom:solid 36px}.cdk-high-contrast-active .mat-button-toggle-checked .mat-button-toggle-focus-overlay{opacity:.5;height:0}.cdk-high-contrast-active .mat-button-toggle-checked.mat-button-toggle-appearance-standard .mat-button-toggle-focus-overlay{border-bottom:solid 500px}.mat-button-toggle .mat-button-toggle-ripple{top:0;left:0;right:0;bottom:0;position:absolute;pointer-events:none}.mat-button-toggle-button{border:0;background:none;color:inherit;padding:0;margin:0;font:inherit;outline:none;width:100%;cursor:pointer}.mat-button-toggle-disabled .mat-button-toggle-button{cursor:default}.mat-button-toggle-button::-moz-focus-inner{border:0}\n"]
|
---|
419 | },] }
|
---|
420 | ];
|
---|
421 | MatButtonToggle.ctorParameters = () => [
|
---|
422 | { type: MatButtonToggleGroup, decorators: [{ type: Optional }, { type: Inject, args: [MAT_BUTTON_TOGGLE_GROUP,] }] },
|
---|
423 | { type: ChangeDetectorRef },
|
---|
424 | { type: ElementRef },
|
---|
425 | { type: FocusMonitor },
|
---|
426 | { type: String, decorators: [{ type: Attribute, args: ['tabindex',] }] },
|
---|
427 | { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS,] }] }
|
---|
428 | ];
|
---|
429 | MatButtonToggle.propDecorators = {
|
---|
430 | ariaLabel: [{ type: Input, args: ['aria-label',] }],
|
---|
431 | ariaLabelledby: [{ type: Input, args: ['aria-labelledby',] }],
|
---|
432 | _buttonElement: [{ type: ViewChild, args: ['button',] }],
|
---|
433 | id: [{ type: Input }],
|
---|
434 | name: [{ type: Input }],
|
---|
435 | value: [{ type: Input }],
|
---|
436 | tabIndex: [{ type: Input }],
|
---|
437 | appearance: [{ type: Input }],
|
---|
438 | checked: [{ type: Input }],
|
---|
439 | disabled: [{ type: Input }],
|
---|
440 | change: [{ type: Output }]
|
---|
441 | };
|
---|
442 |
|
---|
443 | /**
|
---|
444 | * @license
|
---|
445 | * Copyright Google LLC All Rights Reserved.
|
---|
446 | *
|
---|
447 | * Use of this source code is governed by an MIT-style license that can be
|
---|
448 | * found in the LICENSE file at https://angular.io/license
|
---|
449 | */
|
---|
450 | class MatButtonToggleModule {
|
---|
451 | }
|
---|
452 | MatButtonToggleModule.decorators = [
|
---|
453 | { type: NgModule, args: [{
|
---|
454 | imports: [MatCommonModule, MatRippleModule],
|
---|
455 | exports: [MatCommonModule, MatButtonToggleGroup, MatButtonToggle],
|
---|
456 | declarations: [MatButtonToggleGroup, MatButtonToggle],
|
---|
457 | },] }
|
---|
458 | ];
|
---|
459 |
|
---|
460 | /**
|
---|
461 | * @license
|
---|
462 | * Copyright Google LLC All Rights Reserved.
|
---|
463 | *
|
---|
464 | * Use of this source code is governed by an MIT-style license that can be
|
---|
465 | * found in the LICENSE file at https://angular.io/license
|
---|
466 | */
|
---|
467 |
|
---|
468 | /**
|
---|
469 | * Generated bundle index. Do not edit.
|
---|
470 | */
|
---|
471 |
|
---|
472 | export { MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS, MAT_BUTTON_TOGGLE_GROUP, MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR, MatButtonToggle, MatButtonToggleChange, MatButtonToggleGroup, MatButtonToggleModule };
|
---|
473 | //# sourceMappingURL=button-toggle.js.map
|
---|