UNPKG

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