button-toggle.mjs 30 KB

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