button-toggle.mjs 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. import { _IdGenerator, FocusMonitor } from '@angular/cdk/a11y';
  2. import { Directionality } from '@angular/cdk/bidi';
  3. import { SelectionModel } from '@angular/cdk/collections';
  4. import { RIGHT_ARROW, DOWN_ARROW, LEFT_ARROW, UP_ARROW, ENTER, SPACE } from '@angular/cdk/keycodes';
  5. import { _CdkPrivateStyleLoader } from '@angular/cdk/private';
  6. import * as i0 from '@angular/core';
  7. import { InjectionToken, forwardRef, inject, ChangeDetectorRef, EventEmitter, booleanAttribute, Directive, ContentChildren, Input, Output, ElementRef, ANIMATION_MODULE_TYPE, HostAttributeToken, Component, ViewEncapsulation, ChangeDetectionStrategy, ViewChild, NgModule } from '@angular/core';
  8. import { NG_VALUE_ACCESSOR } from '@angular/forms';
  9. import { M as MatRipple } from './ripple-BT3tzh6F.mjs';
  10. import { M as MatPseudoCheckbox } from './pseudo-checkbox-CJ7seqQH.mjs';
  11. import { _ as _StructuralStylesLoader } from './structural-styles-BQUT6wsL.mjs';
  12. import { M as MatCommonModule } from './common-module-WayjW0Pb.mjs';
  13. import { M as MatRippleModule } from './index-SYVYjXwK.mjs';
  14. import '@angular/cdk/platform';
  15. import '@angular/cdk/coercion';
  16. /**
  17. * Injection token that can be used to configure the
  18. * default options for all button toggles within an app.
  19. */
  20. const MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS = new InjectionToken('MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS', {
  21. providedIn: 'root',
  22. factory: MAT_BUTTON_TOGGLE_GROUP_DEFAULT_OPTIONS_FACTORY,
  23. });
  24. /**
  25. * @docs-private
  26. * @deprecated No longer used, will be removed.
  27. * @breaking-change 21.0.0
  28. */
  29. function MAT_BUTTON_TOGGLE_GROUP_DEFAULT_OPTIONS_FACTORY() {
  30. return {
  31. hideSingleSelectionIndicator: false,
  32. hideMultipleSelectionIndicator: false,
  33. disabledInteractive: false,
  34. };
  35. }
  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. const MAT_BUTTON_TOGGLE_GROUP = new 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. const MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR = {
  48. provide: NG_VALUE_ACCESSOR,
  49. useExisting: forwardRef(() => MatButtonToggleGroup),
  50. multi: true,
  51. };
  52. /** Change event object emitted by button toggle. */
  53. class MatButtonToggleChange {
  54. source;
  55. value;
  56. constructor(
  57. /** The button toggle that emits the event. */
  58. source,
  59. /** The value assigned to the button toggle. */
  60. value) {
  61. this.source = source;
  62. this.value = value;
  63. }
  64. }
  65. /** Exclusive selection button toggle group that behaves like a radio-button group. */
  66. class MatButtonToggleGroup {
  67. _changeDetector = inject(ChangeDetectorRef);
  68. _dir = inject(Directionality, { optional: true });
  69. _multiple = false;
  70. _disabled = false;
  71. _disabledInteractive = false;
  72. _selectionModel;
  73. /**
  74. * Reference to the raw value that the consumer tried to assign. The real
  75. * value will exclude any values from this one that don't correspond to a
  76. * toggle. Useful for the cases where the value is assigned before the toggles
  77. * have been initialized or at the same that they're being swapped out.
  78. */
  79. _rawValue;
  80. /**
  81. * The method to be called in order to update ngModel.
  82. * Now `ngModel` binding is not supported in multiple selection mode.
  83. */
  84. _controlValueAccessorChangeFn = () => { };
  85. /** onTouch function registered via registerOnTouch (ControlValueAccessor). */
  86. _onTouched = () => { };
  87. /** Child button toggle buttons. */
  88. _buttonToggles;
  89. /** The appearance for all the buttons in the group. */
  90. appearance;
  91. /** `name` attribute for the underlying `input` element. */
  92. get name() {
  93. return this._name;
  94. }
  95. set name(value) {
  96. this._name = value;
  97. this._markButtonsForCheck();
  98. }
  99. _name = inject(_IdGenerator).getId('mat-button-toggle-group-');
  100. /** Whether the toggle group is vertical. */
  101. vertical;
  102. /** Value of the toggle group. */
  103. get value() {
  104. const selected = this._selectionModel ? this._selectionModel.selected : [];
  105. if (this.multiple) {
  106. return selected.map(toggle => toggle.value);
  107. }
  108. return selected[0] ? selected[0].value : undefined;
  109. }
  110. set value(newValue) {
  111. this._setSelectionByValue(newValue);
  112. this.valueChange.emit(this.value);
  113. }
  114. /**
  115. * Event that emits whenever the value of the group changes.
  116. * Used to facilitate two-way data binding.
  117. * @docs-private
  118. */
  119. valueChange = new EventEmitter();
  120. /** Selected button toggles in the group. */
  121. get selected() {
  122. const selected = this._selectionModel ? this._selectionModel.selected : [];
  123. return this.multiple ? selected : selected[0] || null;
  124. }
  125. /** Whether multiple button toggles can be selected. */
  126. get multiple() {
  127. return this._multiple;
  128. }
  129. set multiple(value) {
  130. this._multiple = value;
  131. this._markButtonsForCheck();
  132. }
  133. /** Whether multiple button toggle group is disabled. */
  134. get disabled() {
  135. return this._disabled;
  136. }
  137. set disabled(value) {
  138. this._disabled = value;
  139. this._markButtonsForCheck();
  140. }
  141. /** Whether buttons in the group should be interactive while they're disabled. */
  142. get disabledInteractive() {
  143. return this._disabledInteractive;
  144. }
  145. set disabledInteractive(value) {
  146. this._disabledInteractive = value;
  147. this._markButtonsForCheck();
  148. }
  149. /** The layout direction of the toggle button group. */
  150. get dir() {
  151. return this._dir && this._dir.value === 'rtl' ? 'rtl' : 'ltr';
  152. }
  153. /** Event emitted when the group's value changes. */
  154. change = new EventEmitter();
  155. /** Whether checkmark indicator for single-selection button toggle groups is hidden. */
  156. get hideSingleSelectionIndicator() {
  157. return this._hideSingleSelectionIndicator;
  158. }
  159. set hideSingleSelectionIndicator(value) {
  160. this._hideSingleSelectionIndicator = value;
  161. this._markButtonsForCheck();
  162. }
  163. _hideSingleSelectionIndicator;
  164. /** Whether checkmark indicator for multiple-selection button toggle groups is hidden. */
  165. get hideMultipleSelectionIndicator() {
  166. return this._hideMultipleSelectionIndicator;
  167. }
  168. set hideMultipleSelectionIndicator(value) {
  169. this._hideMultipleSelectionIndicator = value;
  170. this._markButtonsForCheck();
  171. }
  172. _hideMultipleSelectionIndicator;
  173. constructor() {
  174. const defaultOptions = inject(MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS, { optional: true });
  175. this.appearance =
  176. defaultOptions && defaultOptions.appearance ? defaultOptions.appearance : 'standard';
  177. this.hideSingleSelectionIndicator = defaultOptions?.hideSingleSelectionIndicator ?? false;
  178. this.hideMultipleSelectionIndicator = defaultOptions?.hideMultipleSelectionIndicator ?? false;
  179. }
  180. ngOnInit() {
  181. this._selectionModel = new SelectionModel(this.multiple, undefined, false);
  182. }
  183. ngAfterContentInit() {
  184. this._selectionModel.select(...this._buttonToggles.filter(toggle => toggle.checked));
  185. if (!this.multiple) {
  186. this._initializeTabIndex();
  187. }
  188. }
  189. /**
  190. * Sets the model value. Implemented as part of ControlValueAccessor.
  191. * @param value Value to be set to the model.
  192. */
  193. writeValue(value) {
  194. this.value = value;
  195. this._changeDetector.markForCheck();
  196. }
  197. // Implemented as part of ControlValueAccessor.
  198. registerOnChange(fn) {
  199. this._controlValueAccessorChangeFn = fn;
  200. }
  201. // Implemented as part of ControlValueAccessor.
  202. registerOnTouched(fn) {
  203. this._onTouched = fn;
  204. }
  205. // Implemented as part of ControlValueAccessor.
  206. setDisabledState(isDisabled) {
  207. this.disabled = isDisabled;
  208. }
  209. /** Handle keydown event calling to single-select button toggle. */
  210. _keydown(event) {
  211. if (this.multiple || this.disabled) {
  212. return;
  213. }
  214. const target = event.target;
  215. const buttonId = target.id;
  216. const index = this._buttonToggles.toArray().findIndex(toggle => {
  217. return toggle.buttonId === buttonId;
  218. });
  219. let nextButton = null;
  220. switch (event.keyCode) {
  221. case SPACE:
  222. case ENTER:
  223. nextButton = this._buttonToggles.get(index) || null;
  224. break;
  225. case UP_ARROW:
  226. nextButton = this._getNextButton(index, -1);
  227. break;
  228. case LEFT_ARROW:
  229. nextButton = this._getNextButton(index, this.dir === 'ltr' ? -1 : 1);
  230. break;
  231. case DOWN_ARROW:
  232. nextButton = this._getNextButton(index, 1);
  233. break;
  234. case RIGHT_ARROW:
  235. nextButton = this._getNextButton(index, this.dir === 'ltr' ? 1 : -1);
  236. break;
  237. default:
  238. return;
  239. }
  240. if (nextButton) {
  241. event.preventDefault();
  242. nextButton._onButtonClick();
  243. nextButton.focus();
  244. }
  245. }
  246. /** Dispatch change event with current selection and group value. */
  247. _emitChangeEvent(toggle) {
  248. const event = new MatButtonToggleChange(toggle, this.value);
  249. this._rawValue = event.value;
  250. this._controlValueAccessorChangeFn(event.value);
  251. this.change.emit(event);
  252. }
  253. /**
  254. * Syncs a button toggle's selected state with the model value.
  255. * @param toggle Toggle to be synced.
  256. * @param select Whether the toggle should be selected.
  257. * @param isUserInput Whether the change was a result of a user interaction.
  258. * @param deferEvents Whether to defer emitting the change events.
  259. */
  260. _syncButtonToggle(toggle, select, isUserInput = false, deferEvents = false) {
  261. // Deselect the currently-selected toggle, if we're in single-selection
  262. // mode and the button being toggled isn't selected at the moment.
  263. if (!this.multiple && this.selected && !toggle.checked) {
  264. this.selected.checked = false;
  265. }
  266. if (this._selectionModel) {
  267. if (select) {
  268. this._selectionModel.select(toggle);
  269. }
  270. else {
  271. this._selectionModel.deselect(toggle);
  272. }
  273. }
  274. else {
  275. deferEvents = true;
  276. }
  277. // We need to defer in some cases in order to avoid "changed after checked errors", however
  278. // the side-effect is that we may end up updating the model value out of sequence in others
  279. // The `deferEvents` flag allows us to decide whether to do it on a case-by-case basis.
  280. if (deferEvents) {
  281. Promise.resolve().then(() => this._updateModelValue(toggle, isUserInput));
  282. }
  283. else {
  284. this._updateModelValue(toggle, isUserInput);
  285. }
  286. }
  287. /** Checks whether a button toggle is selected. */
  288. _isSelected(toggle) {
  289. return this._selectionModel && this._selectionModel.isSelected(toggle);
  290. }
  291. /** Determines whether a button toggle should be checked on init. */
  292. _isPrechecked(toggle) {
  293. if (typeof this._rawValue === 'undefined') {
  294. return false;
  295. }
  296. if (this.multiple && Array.isArray(this._rawValue)) {
  297. return this._rawValue.some(value => toggle.value != null && value === toggle.value);
  298. }
  299. return toggle.value === this._rawValue;
  300. }
  301. /** Initializes the tabindex attribute using the radio pattern. */
  302. _initializeTabIndex() {
  303. this._buttonToggles.forEach(toggle => {
  304. toggle.tabIndex = -1;
  305. });
  306. if (this.selected) {
  307. this.selected.tabIndex = 0;
  308. }
  309. else {
  310. for (let i = 0; i < this._buttonToggles.length; i++) {
  311. const toggle = this._buttonToggles.get(i);
  312. if (!toggle.disabled) {
  313. toggle.tabIndex = 0;
  314. break;
  315. }
  316. }
  317. }
  318. this._markButtonsForCheck();
  319. }
  320. /** Obtain the subsequent toggle to which the focus shifts. */
  321. _getNextButton(startIndex, offset) {
  322. const items = this._buttonToggles;
  323. for (let i = 1; i <= items.length; i++) {
  324. const index = (startIndex + offset * i + items.length) % items.length;
  325. const item = items.get(index);
  326. if (item && !item.disabled) {
  327. return item;
  328. }
  329. }
  330. return null;
  331. }
  332. /** Updates the selection state of the toggles in the group based on a value. */
  333. _setSelectionByValue(value) {
  334. this._rawValue = value;
  335. if (!this._buttonToggles) {
  336. return;
  337. }
  338. const toggles = this._buttonToggles.toArray();
  339. if (this.multiple && value) {
  340. if (!Array.isArray(value) && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  341. throw Error('Value must be an array in multiple-selection mode.');
  342. }
  343. this._clearSelection();
  344. value.forEach((currentValue) => this._selectValue(currentValue, toggles));
  345. }
  346. else {
  347. this._clearSelection();
  348. this._selectValue(value, toggles);
  349. }
  350. // In single selection mode we need at least one enabled toggle to always be focusable.
  351. if (!this.multiple && toggles.every(toggle => toggle.tabIndex === -1)) {
  352. for (const toggle of toggles) {
  353. if (!toggle.disabled) {
  354. toggle.tabIndex = 0;
  355. break;
  356. }
  357. }
  358. }
  359. }
  360. /** Clears the selected toggles. */
  361. _clearSelection() {
  362. this._selectionModel.clear();
  363. this._buttonToggles.forEach(toggle => {
  364. toggle.checked = false;
  365. // If the button toggle is in single select mode, initialize the tabIndex.
  366. if (!this.multiple) {
  367. toggle.tabIndex = -1;
  368. }
  369. });
  370. }
  371. /** Selects a value if there's a toggle that corresponds to it. */
  372. _selectValue(value, toggles) {
  373. for (const toggle of toggles) {
  374. if (toggle.value === value) {
  375. toggle.checked = true;
  376. this._selectionModel.select(toggle);
  377. if (!this.multiple) {
  378. // If the button toggle is in single select mode, reset the tabIndex.
  379. toggle.tabIndex = 0;
  380. }
  381. break;
  382. }
  383. }
  384. }
  385. /** Syncs up the group's value with the model and emits the change event. */
  386. _updateModelValue(toggle, isUserInput) {
  387. // Only emit the change event for user input.
  388. if (isUserInput) {
  389. this._emitChangeEvent(toggle);
  390. }
  391. // Note: we emit this one no matter whether it was a user interaction, because
  392. // it is used by Angular to sync up the two-way data binding.
  393. this.valueChange.emit(this.value);
  394. }
  395. /** Marks all of the child button toggles to be checked. */
  396. _markButtonsForCheck() {
  397. this._buttonToggles?.forEach(toggle => toggle._markForCheck());
  398. }
  399. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatButtonToggleGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
  400. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "19.2.6", type: MatButtonToggleGroup, isStandalone: true, selector: "mat-button-toggle-group", inputs: { appearance: "appearance", name: "name", vertical: ["vertical", "vertical", booleanAttribute], value: "value", multiple: ["multiple", "multiple", booleanAttribute], disabled: ["disabled", "disabled", booleanAttribute], disabledInteractive: ["disabledInteractive", "disabledInteractive", booleanAttribute], hideSingleSelectionIndicator: ["hideSingleSelectionIndicator", "hideSingleSelectionIndicator", booleanAttribute], hideMultipleSelectionIndicator: ["hideMultipleSelectionIndicator", "hideMultipleSelectionIndicator", booleanAttribute] }, outputs: { valueChange: "valueChange", change: "change" }, host: { listeners: { "keydown": "_keydown($event)" }, properties: { "attr.role": "multiple ? 'group' : 'radiogroup'", "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: [
  401. MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR,
  402. { provide: MAT_BUTTON_TOGGLE_GROUP, useExisting: MatButtonToggleGroup },
  403. ], queries: [{ propertyName: "_buttonToggles", predicate: i0.forwardRef(() => MatButtonToggle), descendants: true }], exportAs: ["matButtonToggleGroup"], ngImport: i0 });
  404. }
  405. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatButtonToggleGroup, decorators: [{
  406. type: Directive,
  407. args: [{
  408. selector: 'mat-button-toggle-group',
  409. providers: [
  410. MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR,
  411. { provide: MAT_BUTTON_TOGGLE_GROUP, useExisting: MatButtonToggleGroup },
  412. ],
  413. host: {
  414. 'class': 'mat-button-toggle-group',
  415. '(keydown)': '_keydown($event)',
  416. '[attr.role]': "multiple ? 'group' : 'radiogroup'",
  417. '[attr.aria-disabled]': 'disabled',
  418. '[class.mat-button-toggle-vertical]': 'vertical',
  419. '[class.mat-button-toggle-group-appearance-standard]': 'appearance === "standard"',
  420. },
  421. exportAs: 'matButtonToggleGroup',
  422. }]
  423. }], ctorParameters: () => [], propDecorators: { _buttonToggles: [{
  424. type: ContentChildren,
  425. args: [forwardRef(() => MatButtonToggle), {
  426. // Note that this would technically pick up toggles
  427. // from nested groups, but that's not a case that we support.
  428. descendants: true,
  429. }]
  430. }], appearance: [{
  431. type: Input
  432. }], name: [{
  433. type: Input
  434. }], vertical: [{
  435. type: Input,
  436. args: [{ transform: booleanAttribute }]
  437. }], value: [{
  438. type: Input
  439. }], valueChange: [{
  440. type: Output
  441. }], multiple: [{
  442. type: Input,
  443. args: [{ transform: booleanAttribute }]
  444. }], disabled: [{
  445. type: Input,
  446. args: [{ transform: booleanAttribute }]
  447. }], disabledInteractive: [{
  448. type: Input,
  449. args: [{ transform: booleanAttribute }]
  450. }], change: [{
  451. type: Output
  452. }], hideSingleSelectionIndicator: [{
  453. type: Input,
  454. args: [{ transform: booleanAttribute }]
  455. }], hideMultipleSelectionIndicator: [{
  456. type: Input,
  457. args: [{ transform: booleanAttribute }]
  458. }] } });
  459. /** Single button inside of a toggle group. */
  460. class MatButtonToggle {
  461. _changeDetectorRef = inject(ChangeDetectorRef);
  462. _elementRef = inject(ElementRef);
  463. _focusMonitor = inject(FocusMonitor);
  464. _idGenerator = inject(_IdGenerator);
  465. _animationMode = inject(ANIMATION_MODULE_TYPE, { optional: true });
  466. _checked = false;
  467. /**
  468. * Attached to the aria-label attribute of the host element. In most cases, aria-labelledby will
  469. * take precedence so this may be omitted.
  470. */
  471. ariaLabel;
  472. /**
  473. * Users can specify the `aria-labelledby` attribute which will be forwarded to the input element
  474. */
  475. ariaLabelledby = null;
  476. /** Underlying native `button` element. */
  477. _buttonElement;
  478. /** The parent button toggle group (exclusive selection). Optional. */
  479. buttonToggleGroup;
  480. /** Unique ID for the underlying `button` element. */
  481. get buttonId() {
  482. return `${this.id}-button`;
  483. }
  484. /** The unique ID for this button toggle. */
  485. id;
  486. /** HTML's 'name' attribute used to group radios for unique selection. */
  487. name;
  488. /** MatButtonToggleGroup reads this to assign its own value. */
  489. value;
  490. /** Tabindex of the toggle. */
  491. get tabIndex() {
  492. return this._tabIndex;
  493. }
  494. set tabIndex(value) {
  495. if (value !== this._tabIndex) {
  496. this._tabIndex = value;
  497. this._markForCheck();
  498. }
  499. }
  500. _tabIndex;
  501. /** Whether ripples are disabled on the button toggle. */
  502. disableRipple;
  503. /** The appearance style of the button. */
  504. get appearance() {
  505. return this.buttonToggleGroup ? this.buttonToggleGroup.appearance : this._appearance;
  506. }
  507. set appearance(value) {
  508. this._appearance = value;
  509. }
  510. _appearance;
  511. /** Whether the button is checked. */
  512. get checked() {
  513. return this.buttonToggleGroup ? this.buttonToggleGroup._isSelected(this) : this._checked;
  514. }
  515. set checked(value) {
  516. if (value !== this._checked) {
  517. this._checked = value;
  518. if (this.buttonToggleGroup) {
  519. this.buttonToggleGroup._syncButtonToggle(this, this._checked);
  520. }
  521. this._changeDetectorRef.markForCheck();
  522. }
  523. }
  524. /** Whether the button is disabled. */
  525. get disabled() {
  526. return this._disabled || (this.buttonToggleGroup && this.buttonToggleGroup.disabled);
  527. }
  528. set disabled(value) {
  529. this._disabled = value;
  530. }
  531. _disabled = false;
  532. /** Whether the button should remain interactive when it is disabled. */
  533. get disabledInteractive() {
  534. return (this._disabledInteractive ||
  535. (this.buttonToggleGroup !== null && this.buttonToggleGroup.disabledInteractive));
  536. }
  537. set disabledInteractive(value) {
  538. this._disabledInteractive = value;
  539. }
  540. _disabledInteractive;
  541. /** Event emitted when the group value changes. */
  542. change = new EventEmitter();
  543. constructor() {
  544. inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
  545. const toggleGroup = inject(MAT_BUTTON_TOGGLE_GROUP, { optional: true });
  546. const defaultTabIndex = inject(new HostAttributeToken('tabindex'), { optional: true }) || '';
  547. const defaultOptions = inject(MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS, { optional: true });
  548. this._tabIndex = parseInt(defaultTabIndex) || 0;
  549. this.buttonToggleGroup = toggleGroup;
  550. this.appearance =
  551. defaultOptions && defaultOptions.appearance ? defaultOptions.appearance : 'standard';
  552. this.disabledInteractive = defaultOptions?.disabledInteractive ?? false;
  553. }
  554. ngOnInit() {
  555. const group = this.buttonToggleGroup;
  556. this.id = this.id || this._idGenerator.getId('mat-button-toggle-');
  557. if (group) {
  558. if (group._isPrechecked(this)) {
  559. this.checked = true;
  560. }
  561. else if (group._isSelected(this) !== this._checked) {
  562. // As side effect of the circular dependency between the toggle group and the button,
  563. // we may end up in a state where the button is supposed to be checked on init, but it
  564. // isn't, because the checked value was assigned too early. This can happen when Ivy
  565. // assigns the static input value before the `ngOnInit` has run.
  566. group._syncButtonToggle(this, this._checked);
  567. }
  568. }
  569. }
  570. ngAfterViewInit() {
  571. // This serves two purposes:
  572. // 1. We don't want the animation to fire on the first render for pre-checked toggles so we
  573. // delay adding the class until the view is rendered.
  574. // 2. We don't want animation if the `NoopAnimationsModule` is provided.
  575. if (this._animationMode !== 'NoopAnimations') {
  576. this._elementRef.nativeElement.classList.add('mat-button-toggle-animations-enabled');
  577. }
  578. this._focusMonitor.monitor(this._elementRef, true);
  579. }
  580. ngOnDestroy() {
  581. const group = this.buttonToggleGroup;
  582. this._focusMonitor.stopMonitoring(this._elementRef);
  583. // Remove the toggle from the selection once it's destroyed. Needs to happen
  584. // on the next tick in order to avoid "changed after checked" errors.
  585. if (group && group._isSelected(this)) {
  586. group._syncButtonToggle(this, false, false, true);
  587. }
  588. }
  589. /** Focuses the button. */
  590. focus(options) {
  591. this._buttonElement.nativeElement.focus(options);
  592. }
  593. /** Checks the button toggle due to an interaction with the underlying native button. */
  594. _onButtonClick() {
  595. if (this.disabled) {
  596. return;
  597. }
  598. const newChecked = this.isSingleSelector() ? true : !this._checked;
  599. if (newChecked !== this._checked) {
  600. this._checked = newChecked;
  601. if (this.buttonToggleGroup) {
  602. this.buttonToggleGroup._syncButtonToggle(this, this._checked, true);
  603. this.buttonToggleGroup._onTouched();
  604. }
  605. }
  606. if (this.isSingleSelector()) {
  607. const focusable = this.buttonToggleGroup._buttonToggles.find(toggle => {
  608. return toggle.tabIndex === 0;
  609. });
  610. // Modify the tabindex attribute of the last focusable button toggle to -1.
  611. if (focusable) {
  612. focusable.tabIndex = -1;
  613. }
  614. // Modify the tabindex attribute of the presently selected button toggle to 0.
  615. this.tabIndex = 0;
  616. }
  617. // Emit a change event when it's the single selector
  618. this.change.emit(new MatButtonToggleChange(this, this.value));
  619. }
  620. /**
  621. * Marks the button toggle as needing checking for change detection.
  622. * This method is exposed because the parent button toggle group will directly
  623. * update bound properties of the radio button.
  624. */
  625. _markForCheck() {
  626. // When the group value changes, the button will not be notified.
  627. // Use `markForCheck` to explicit update button toggle's status.
  628. this._changeDetectorRef.markForCheck();
  629. }
  630. /** Gets the name that should be assigned to the inner DOM node. */
  631. _getButtonName() {
  632. if (this.isSingleSelector()) {
  633. return this.buttonToggleGroup.name;
  634. }
  635. return this.name || null;
  636. }
  637. /** Whether the toggle is in single selection mode. */
  638. isSingleSelector() {
  639. return this.buttonToggleGroup && !this.buttonToggleGroup.multiple;
  640. }
  641. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatButtonToggle, deps: [], target: i0.ɵɵFactoryTarget.Component });
  642. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.6", type: MatButtonToggle, isStandalone: true, selector: "mat-button-toggle", inputs: { ariaLabel: ["aria-label", "ariaLabel"], ariaLabelledby: ["aria-labelledby", "ariaLabelledby"], id: "id", name: "name", value: "value", tabIndex: "tabIndex", disableRipple: ["disableRipple", "disableRipple", booleanAttribute], appearance: "appearance", checked: ["checked", "checked", booleanAttribute], disabled: ["disabled", "disabled", booleanAttribute], disabledInteractive: ["disabledInteractive", "disabledInteractive", booleanAttribute] }, 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-disabled-interactive": "disabledInteractive", "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"], ngImport: i0, template: "<button #button class=\"mat-button-toggle-button mat-focus-indicator\"\n type=\"button\"\n [id]=\"buttonId\"\n [attr.role]=\"isSingleSelector() ? 'radio' : 'button'\"\n [attr.tabindex]=\"disabled && !disabledInteractive ? -1 : tabIndex\"\n [attr.aria-pressed]=\"!isSingleSelector() ? checked : null\"\n [attr.aria-checked]=\"isSingleSelector() ? checked : null\"\n [disabled]=\"(disabled && !disabledInteractive) || null\"\n [attr.name]=\"_getButtonName()\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [attr.aria-disabled]=\"disabled && disabledInteractive ? 'true' : null\"\n (click)=\"_onButtonClick()\">\n @if (buttonToggleGroup && (\n !buttonToggleGroup.multiple && !buttonToggleGroup.hideSingleSelectionIndicator ||\n buttonToggleGroup.multiple && !buttonToggleGroup.hideMultipleSelectionIndicator)\n ) {\n <div class=\"mat-button-toggle-checkbox-wrapper\">\n <mat-pseudo-checkbox\n [disabled]=\"disabled\"\n state=\"checked\"\n aria-hidden=\"true\"\n appearance=\"minimal\"/>\n </div>\n }\n\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;-webkit-tap-highlight-color:rgba(0,0,0,0);transform:translateZ(0);border-radius:var(--mat-legacy-button-toggle-shape)}.mat-button-toggle-standalone:not([class*=mat-elevation-z]),.mat-button-toggle-group:not([class*=mat-elevation-z]){box-shadow:0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12)}@media(forced-colors: active){.mat-button-toggle-standalone,.mat-button-toggle-group{outline:solid 1px}}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard,.mat-button-toggle-group-appearance-standard{border-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large));border:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard .mat-pseudo-checkbox,.mat-button-toggle-group-appearance-standard .mat-pseudo-checkbox{--mat-minimal-pseudo-checkbox-selected-checkmark-color: var(--mat-standard-button-toggle-selected-state-text-color, var(--mat-sys-on-secondary-container))}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard:not([class*=mat-elevation-z]),.mat-button-toggle-group-appearance-standard:not([class*=mat-elevation-z]){box-shadow:none}@media(forced-colors: active){.mat-button-toggle-standalone.mat-button-toggle-appearance-standard,.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;color:var(--mat-legacy-button-toggle-text-color);font-family:var(--mat-legacy-button-toggle-label-text-font);font-size:var(--mat-legacy-button-toggle-label-text-size);line-height:var(--mat-legacy-button-toggle-label-text-line-height);font-weight:var(--mat-legacy-button-toggle-label-text-weight);letter-spacing:var(--mat-legacy-button-toggle-label-text-tracking);--mat-minimal-pseudo-checkbox-selected-checkmark-color: var(--mat-legacy-button-toggle-selected-state-text-color)}.mat-button-toggle.cdk-keyboard-focused .mat-button-toggle-focus-overlay{opacity:var(--mat-legacy-button-toggle-focus-state-layer-opacity)}.mat-button-toggle .mat-icon svg{vertical-align:top}.mat-button-toggle-checkbox-wrapper{display:inline-block;justify-content:flex-start;align-items:center;width:0;height:18px;line-height:18px;overflow:hidden;box-sizing:border-box;position:absolute;top:50%;left:16px;transform:translate3d(0, -50%, 0)}[dir=rtl] .mat-button-toggle-checkbox-wrapper{left:auto;right:16px}.mat-button-toggle-appearance-standard .mat-button-toggle-checkbox-wrapper{left:12px}[dir=rtl] .mat-button-toggle-appearance-standard .mat-button-toggle-checkbox-wrapper{left:auto;right:12px}.mat-button-toggle-checked .mat-button-toggle-checkbox-wrapper{width:18px}.mat-button-toggle-animations-enabled .mat-button-toggle-checkbox-wrapper{transition:width 150ms 45ms cubic-bezier(0.4, 0, 0.2, 1)}.mat-button-toggle-vertical .mat-button-toggle-checkbox-wrapper{transition:none}.mat-button-toggle-checked{color:var(--mat-legacy-button-toggle-selected-state-text-color);background-color:var(--mat-legacy-button-toggle-selected-state-background-color)}.mat-button-toggle-disabled{pointer-events:none;color:var(--mat-legacy-button-toggle-disabled-state-text-color);background-color:var(--mat-legacy-button-toggle-disabled-state-background-color);--mat-minimal-pseudo-checkbox-disabled-selected-checkmark-color: var(--mat-legacy-button-toggle-disabled-state-text-color)}.mat-button-toggle-disabled.mat-button-toggle-checked{background-color:var(--mat-legacy-button-toggle-disabled-selected-state-background-color)}.mat-button-toggle-disabled-interactive{pointer-events:auto}.mat-button-toggle-appearance-standard{color:var(--mat-standard-button-toggle-text-color, var(--mat-sys-on-surface));background-color:var(--mat-standard-button-toggle-background-color, transparent);font-family:var(--mat-standard-button-toggle-label-text-font, var(--mat-sys-label-large-font));font-size:var(--mat-standard-button-toggle-label-text-size, var(--mat-sys-label-large-size));line-height:var(--mat-standard-button-toggle-label-text-line-height, var(--mat-sys-label-large-line-height));font-weight:var(--mat-standard-button-toggle-label-text-weight, var(--mat-sys-label-large-weight));letter-spacing:var(--mat-standard-button-toggle-label-text-tracking, var(--mat-sys-label-large-tracking))}.mat-button-toggle-group-appearance-standard .mat-button-toggle-appearance-standard+.mat-button-toggle-appearance-standard{border-left:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}[dir=rtl] .mat-button-toggle-group-appearance-standard .mat-button-toggle-appearance-standard+.mat-button-toggle-appearance-standard{border-left:none;border-right:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}.mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical .mat-button-toggle-appearance-standard+.mat-button-toggle-appearance-standard{border-left:none;border-right:none;border-top:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}.mat-button-toggle-appearance-standard.mat-button-toggle-checked{color:var(--mat-standard-button-toggle-selected-state-text-color, var(--mat-sys-on-secondary-container));background-color:var(--mat-standard-button-toggle-selected-state-background-color, var(--mat-sys-secondary-container))}.mat-button-toggle-appearance-standard.mat-button-toggle-disabled{color:var(--mat-standard-button-toggle-disabled-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent));background-color:var(--mat-standard-button-toggle-disabled-state-background-color, transparent)}.mat-button-toggle-appearance-standard.mat-button-toggle-disabled .mat-pseudo-checkbox{--mat-minimal-pseudo-checkbox-disabled-selected-checkmark-color: var(--mat-standard-button-toggle-disabled-selected-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-button-toggle-appearance-standard.mat-button-toggle-disabled.mat-button-toggle-checked{color:var(--mat-standard-button-toggle-disabled-selected-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent));background-color:var(--mat-standard-button-toggle-disabled-selected-state-background-color, color-mix(in srgb, var(--mat-sys-on-surface) 12%, transparent))}.mat-button-toggle-appearance-standard .mat-button-toggle-focus-overlay{background-color:var(--mat-standard-button-toggle-state-layer-color, var(--mat-sys-on-surface))}.mat-button-toggle-appearance-standard:hover .mat-button-toggle-focus-overlay{opacity:var(--mat-standard-button-toggle-hover-state-layer-opacity, var(--mat-sys-hover-state-layer-opacity))}.mat-button-toggle-appearance-standard.cdk-keyboard-focused .mat-button-toggle-focus-overlay{opacity:var(--mat-standard-button-toggle-focus-state-layer-opacity, var(--mat-sys-focus-state-layer-opacity))}@media(hover: none){.mat-button-toggle-appearance-standard:hover .mat-button-toggle-focus-overlay{display:none}}.mat-button-toggle-label-content{-webkit-user-select:none;user-select:none;display:inline-block;padding:0 16px;line-height:var(--mat-legacy-button-toggle-height);position:relative}.mat-button-toggle-appearance-standard .mat-button-toggle-label-content{padding:0 12px;line-height:var(--mat-standard-button-toggle-height, 40px)}.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;background-color:var(--mat-legacy-button-toggle-state-layer-color)}@media(forced-colors: active){.mat-button-toggle-checked .mat-button-toggle-focus-overlay{border-bottom:solid 500px;opacity:.5;height:0}.mat-button-toggle-checked:hover .mat-button-toggle-focus-overlay{opacity:.6}.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-animations-enabled .mat-button-toggle-button{transition:padding 150ms 45ms cubic-bezier(0.4, 0, 0.2, 1)}.mat-button-toggle-vertical .mat-button-toggle-button{transition:none}.mat-button-toggle-disabled .mat-button-toggle-button{cursor:default}.mat-button-toggle-button::-moz-focus-inner{border:0}.mat-button-toggle-checked .mat-button-toggle-button:has(.mat-button-toggle-checkbox-wrapper){padding-left:30px}[dir=rtl] .mat-button-toggle-checked .mat-button-toggle-button:has(.mat-button-toggle-checkbox-wrapper){padding-left:0;padding-right:30px}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard{--mat-focus-indicator-border-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large))}.mat-button-toggle-group-appearance-standard:not(.mat-button-toggle-vertical) .mat-button-toggle:last-of-type .mat-button-toggle-button::before{border-top-right-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large));border-bottom-right-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large))}.mat-button-toggle-group-appearance-standard:not(.mat-button-toggle-vertical) .mat-button-toggle:first-of-type .mat-button-toggle-button::before{border-top-left-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large));border-bottom-left-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large))}.mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical .mat-button-toggle:last-of-type .mat-button-toggle-button::before{border-bottom-right-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large));border-bottom-left-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large))}.mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical .mat-button-toggle:first-of-type .mat-button-toggle-button::before{border-top-right-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large));border-top-left-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large))}\n"], dependencies: [{ kind: "directive", type: MatRipple, selector: "[mat-ripple], [matRipple]", inputs: ["matRippleColor", "matRippleUnbounded", "matRippleCentered", "matRippleRadius", "matRippleAnimation", "matRippleDisabled", "matRippleTrigger"], exportAs: ["matRipple"] }, { kind: "component", type: MatPseudoCheckbox, selector: "mat-pseudo-checkbox", inputs: ["state", "disabled", "appearance"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
  643. }
  644. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatButtonToggle, decorators: [{
  645. type: Component,
  646. args: [{ selector: 'mat-button-toggle', encapsulation: ViewEncapsulation.None, exportAs: 'matButtonToggle', changeDetection: ChangeDetectionStrategy.OnPush, host: {
  647. '[class.mat-button-toggle-standalone]': '!buttonToggleGroup',
  648. '[class.mat-button-toggle-checked]': 'checked',
  649. '[class.mat-button-toggle-disabled]': 'disabled',
  650. '[class.mat-button-toggle-disabled-interactive]': 'disabledInteractive',
  651. '[class.mat-button-toggle-appearance-standard]': 'appearance === "standard"',
  652. 'class': 'mat-button-toggle',
  653. '[attr.aria-label]': 'null',
  654. '[attr.aria-labelledby]': 'null',
  655. '[attr.id]': 'id',
  656. '[attr.name]': 'null',
  657. '(focus)': 'focus()',
  658. 'role': 'presentation',
  659. }, imports: [MatRipple, MatPseudoCheckbox], template: "<button #button class=\"mat-button-toggle-button mat-focus-indicator\"\n type=\"button\"\n [id]=\"buttonId\"\n [attr.role]=\"isSingleSelector() ? 'radio' : 'button'\"\n [attr.tabindex]=\"disabled && !disabledInteractive ? -1 : tabIndex\"\n [attr.aria-pressed]=\"!isSingleSelector() ? checked : null\"\n [attr.aria-checked]=\"isSingleSelector() ? checked : null\"\n [disabled]=\"(disabled && !disabledInteractive) || null\"\n [attr.name]=\"_getButtonName()\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [attr.aria-disabled]=\"disabled && disabledInteractive ? 'true' : null\"\n (click)=\"_onButtonClick()\">\n @if (buttonToggleGroup && (\n !buttonToggleGroup.multiple && !buttonToggleGroup.hideSingleSelectionIndicator ||\n buttonToggleGroup.multiple && !buttonToggleGroup.hideMultipleSelectionIndicator)\n ) {\n <div class=\"mat-button-toggle-checkbox-wrapper\">\n <mat-pseudo-checkbox\n [disabled]=\"disabled\"\n state=\"checked\"\n aria-hidden=\"true\"\n appearance=\"minimal\"/>\n </div>\n }\n\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;-webkit-tap-highlight-color:rgba(0,0,0,0);transform:translateZ(0);border-radius:var(--mat-legacy-button-toggle-shape)}.mat-button-toggle-standalone:not([class*=mat-elevation-z]),.mat-button-toggle-group:not([class*=mat-elevation-z]){box-shadow:0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12)}@media(forced-colors: active){.mat-button-toggle-standalone,.mat-button-toggle-group{outline:solid 1px}}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard,.mat-button-toggle-group-appearance-standard{border-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large));border:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard .mat-pseudo-checkbox,.mat-button-toggle-group-appearance-standard .mat-pseudo-checkbox{--mat-minimal-pseudo-checkbox-selected-checkmark-color: var(--mat-standard-button-toggle-selected-state-text-color, var(--mat-sys-on-secondary-container))}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard:not([class*=mat-elevation-z]),.mat-button-toggle-group-appearance-standard:not([class*=mat-elevation-z]){box-shadow:none}@media(forced-colors: active){.mat-button-toggle-standalone.mat-button-toggle-appearance-standard,.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;color:var(--mat-legacy-button-toggle-text-color);font-family:var(--mat-legacy-button-toggle-label-text-font);font-size:var(--mat-legacy-button-toggle-label-text-size);line-height:var(--mat-legacy-button-toggle-label-text-line-height);font-weight:var(--mat-legacy-button-toggle-label-text-weight);letter-spacing:var(--mat-legacy-button-toggle-label-text-tracking);--mat-minimal-pseudo-checkbox-selected-checkmark-color: var(--mat-legacy-button-toggle-selected-state-text-color)}.mat-button-toggle.cdk-keyboard-focused .mat-button-toggle-focus-overlay{opacity:var(--mat-legacy-button-toggle-focus-state-layer-opacity)}.mat-button-toggle .mat-icon svg{vertical-align:top}.mat-button-toggle-checkbox-wrapper{display:inline-block;justify-content:flex-start;align-items:center;width:0;height:18px;line-height:18px;overflow:hidden;box-sizing:border-box;position:absolute;top:50%;left:16px;transform:translate3d(0, -50%, 0)}[dir=rtl] .mat-button-toggle-checkbox-wrapper{left:auto;right:16px}.mat-button-toggle-appearance-standard .mat-button-toggle-checkbox-wrapper{left:12px}[dir=rtl] .mat-button-toggle-appearance-standard .mat-button-toggle-checkbox-wrapper{left:auto;right:12px}.mat-button-toggle-checked .mat-button-toggle-checkbox-wrapper{width:18px}.mat-button-toggle-animations-enabled .mat-button-toggle-checkbox-wrapper{transition:width 150ms 45ms cubic-bezier(0.4, 0, 0.2, 1)}.mat-button-toggle-vertical .mat-button-toggle-checkbox-wrapper{transition:none}.mat-button-toggle-checked{color:var(--mat-legacy-button-toggle-selected-state-text-color);background-color:var(--mat-legacy-button-toggle-selected-state-background-color)}.mat-button-toggle-disabled{pointer-events:none;color:var(--mat-legacy-button-toggle-disabled-state-text-color);background-color:var(--mat-legacy-button-toggle-disabled-state-background-color);--mat-minimal-pseudo-checkbox-disabled-selected-checkmark-color: var(--mat-legacy-button-toggle-disabled-state-text-color)}.mat-button-toggle-disabled.mat-button-toggle-checked{background-color:var(--mat-legacy-button-toggle-disabled-selected-state-background-color)}.mat-button-toggle-disabled-interactive{pointer-events:auto}.mat-button-toggle-appearance-standard{color:var(--mat-standard-button-toggle-text-color, var(--mat-sys-on-surface));background-color:var(--mat-standard-button-toggle-background-color, transparent);font-family:var(--mat-standard-button-toggle-label-text-font, var(--mat-sys-label-large-font));font-size:var(--mat-standard-button-toggle-label-text-size, var(--mat-sys-label-large-size));line-height:var(--mat-standard-button-toggle-label-text-line-height, var(--mat-sys-label-large-line-height));font-weight:var(--mat-standard-button-toggle-label-text-weight, var(--mat-sys-label-large-weight));letter-spacing:var(--mat-standard-button-toggle-label-text-tracking, var(--mat-sys-label-large-tracking))}.mat-button-toggle-group-appearance-standard .mat-button-toggle-appearance-standard+.mat-button-toggle-appearance-standard{border-left:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}[dir=rtl] .mat-button-toggle-group-appearance-standard .mat-button-toggle-appearance-standard+.mat-button-toggle-appearance-standard{border-left:none;border-right:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}.mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical .mat-button-toggle-appearance-standard+.mat-button-toggle-appearance-standard{border-left:none;border-right:none;border-top:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}.mat-button-toggle-appearance-standard.mat-button-toggle-checked{color:var(--mat-standard-button-toggle-selected-state-text-color, var(--mat-sys-on-secondary-container));background-color:var(--mat-standard-button-toggle-selected-state-background-color, var(--mat-sys-secondary-container))}.mat-button-toggle-appearance-standard.mat-button-toggle-disabled{color:var(--mat-standard-button-toggle-disabled-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent));background-color:var(--mat-standard-button-toggle-disabled-state-background-color, transparent)}.mat-button-toggle-appearance-standard.mat-button-toggle-disabled .mat-pseudo-checkbox{--mat-minimal-pseudo-checkbox-disabled-selected-checkmark-color: var(--mat-standard-button-toggle-disabled-selected-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-button-toggle-appearance-standard.mat-button-toggle-disabled.mat-button-toggle-checked{color:var(--mat-standard-button-toggle-disabled-selected-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent));background-color:var(--mat-standard-button-toggle-disabled-selected-state-background-color, color-mix(in srgb, var(--mat-sys-on-surface) 12%, transparent))}.mat-button-toggle-appearance-standard .mat-button-toggle-focus-overlay{background-color:var(--mat-standard-button-toggle-state-layer-color, var(--mat-sys-on-surface))}.mat-button-toggle-appearance-standard:hover .mat-button-toggle-focus-overlay{opacity:var(--mat-standard-button-toggle-hover-state-layer-opacity, var(--mat-sys-hover-state-layer-opacity))}.mat-button-toggle-appearance-standard.cdk-keyboard-focused .mat-button-toggle-focus-overlay{opacity:var(--mat-standard-button-toggle-focus-state-layer-opacity, var(--mat-sys-focus-state-layer-opacity))}@media(hover: none){.mat-button-toggle-appearance-standard:hover .mat-button-toggle-focus-overlay{display:none}}.mat-button-toggle-label-content{-webkit-user-select:none;user-select:none;display:inline-block;padding:0 16px;line-height:var(--mat-legacy-button-toggle-height);position:relative}.mat-button-toggle-appearance-standard .mat-button-toggle-label-content{padding:0 12px;line-height:var(--mat-standard-button-toggle-height, 40px)}.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;background-color:var(--mat-legacy-button-toggle-state-layer-color)}@media(forced-colors: active){.mat-button-toggle-checked .mat-button-toggle-focus-overlay{border-bottom:solid 500px;opacity:.5;height:0}.mat-button-toggle-checked:hover .mat-button-toggle-focus-overlay{opacity:.6}.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-animations-enabled .mat-button-toggle-button{transition:padding 150ms 45ms cubic-bezier(0.4, 0, 0.2, 1)}.mat-button-toggle-vertical .mat-button-toggle-button{transition:none}.mat-button-toggle-disabled .mat-button-toggle-button{cursor:default}.mat-button-toggle-button::-moz-focus-inner{border:0}.mat-button-toggle-checked .mat-button-toggle-button:has(.mat-button-toggle-checkbox-wrapper){padding-left:30px}[dir=rtl] .mat-button-toggle-checked .mat-button-toggle-button:has(.mat-button-toggle-checkbox-wrapper){padding-left:0;padding-right:30px}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard{--mat-focus-indicator-border-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large))}.mat-button-toggle-group-appearance-standard:not(.mat-button-toggle-vertical) .mat-button-toggle:last-of-type .mat-button-toggle-button::before{border-top-right-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large));border-bottom-right-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large))}.mat-button-toggle-group-appearance-standard:not(.mat-button-toggle-vertical) .mat-button-toggle:first-of-type .mat-button-toggle-button::before{border-top-left-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large));border-bottom-left-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large))}.mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical .mat-button-toggle:last-of-type .mat-button-toggle-button::before{border-bottom-right-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large));border-bottom-left-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large))}.mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical .mat-button-toggle:first-of-type .mat-button-toggle-button::before{border-top-right-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large));border-top-left-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-extra-large))}\n"] }]
  660. }], ctorParameters: () => [], propDecorators: { ariaLabel: [{
  661. type: Input,
  662. args: ['aria-label']
  663. }], ariaLabelledby: [{
  664. type: Input,
  665. args: ['aria-labelledby']
  666. }], _buttonElement: [{
  667. type: ViewChild,
  668. args: ['button']
  669. }], id: [{
  670. type: Input
  671. }], name: [{
  672. type: Input
  673. }], value: [{
  674. type: Input
  675. }], tabIndex: [{
  676. type: Input
  677. }], disableRipple: [{
  678. type: Input,
  679. args: [{ transform: booleanAttribute }]
  680. }], appearance: [{
  681. type: Input
  682. }], checked: [{
  683. type: Input,
  684. args: [{ transform: booleanAttribute }]
  685. }], disabled: [{
  686. type: Input,
  687. args: [{ transform: booleanAttribute }]
  688. }], disabledInteractive: [{
  689. type: Input,
  690. args: [{ transform: booleanAttribute }]
  691. }], change: [{
  692. type: Output
  693. }] } });
  694. class MatButtonToggleModule {
  695. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatButtonToggleModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  696. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: MatButtonToggleModule, imports: [MatCommonModule, MatRippleModule, MatButtonToggleGroup, MatButtonToggle], exports: [MatCommonModule, MatButtonToggleGroup, MatButtonToggle] });
  697. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatButtonToggleModule, imports: [MatCommonModule, MatRippleModule, MatButtonToggle, MatCommonModule] });
  698. }
  699. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatButtonToggleModule, decorators: [{
  700. type: NgModule,
  701. args: [{
  702. imports: [MatCommonModule, MatRippleModule, MatButtonToggleGroup, MatButtonToggle],
  703. exports: [MatCommonModule, MatButtonToggleGroup, MatButtonToggle],
  704. }]
  705. }] });
  706. export { MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS, MAT_BUTTON_TOGGLE_GROUP, MAT_BUTTON_TOGGLE_GROUP_DEFAULT_OPTIONS_FACTORY, MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR, MatButtonToggle, MatButtonToggleChange, MatButtonToggleGroup, MatButtonToggleModule };
  707. //# sourceMappingURL=button-toggle.mjs.map