{"version":3,"file":"button.mjs","sources":["../../../../../../src/material/button/button.ts","../../../../../../src/material/button/button.html","../../../../../../src/material/button/button-module.ts","../../../../../../src/material/button/public-api.ts","../../../../../../src/material/button/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {FocusMonitor, FocusableOption, FocusOrigin} from '@angular/cdk/a11y';\nimport {BooleanInput} from '@angular/cdk/coercion';\nimport {\n  ChangeDetectionStrategy,\n  Component,\n  ElementRef,\n  OnDestroy,\n  ViewChild,\n  ViewEncapsulation,\n  Optional,\n  Inject,\n  Input,\n  AfterViewInit,\n} from '@angular/core';\nimport {\n  CanColor,\n  CanDisable,\n  CanDisableRipple,\n  MatRipple,\n  mixinColor,\n  mixinDisabled,\n  mixinDisableRipple,\n} from '@angular/material/core';\nimport {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';\n\n/** Default color palette for round buttons (mat-fab and mat-mini-fab) */\nconst DEFAULT_ROUND_BUTTON_COLOR = 'accent';\n\n/**\n * List of classes to add to MatButton instances based on host attributes to\n * style as different variants.\n */\nconst BUTTON_HOST_ATTRIBUTES = [\n  'mat-button',\n  'mat-flat-button',\n  'mat-icon-button',\n  'mat-raised-button',\n  'mat-stroked-button',\n  'mat-mini-fab',\n  'mat-fab',\n];\n\n// Boilerplate for applying mixins to MatButton.\nconst _MatButtonBase = mixinColor(mixinDisabled(mixinDisableRipple(class {\n  constructor(public _elementRef: ElementRef) {}\n})));\n\n/**\n * Material design button.\n */\n@Component({\n  selector: `button[mat-button], button[mat-raised-button], button[mat-icon-button],\n             button[mat-fab], button[mat-mini-fab], button[mat-stroked-button],\n             button[mat-flat-button]`,\n  exportAs: 'matButton',\n  host: {\n    '[attr.disabled]': 'disabled || null',\n    '[class._mat-animation-noopable]': '_animationMode === \"NoopAnimations\"',\n    // Add a class for disabled button styling instead of the using attribute\n    // selector or pseudo-selector.  This allows users to create focusabled\n    // disabled buttons without recreating the styles.\n    '[class.mat-button-disabled]': 'disabled',\n    'class': 'mat-focus-indicator',\n  },\n  templateUrl: 'button.html',\n  styleUrls: ['button.css'],\n  inputs: ['disabled', 'disableRipple', 'color'],\n  encapsulation: ViewEncapsulation.None,\n  changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class MatButton extends _MatButtonBase\n    implements AfterViewInit, OnDestroy, CanDisable, CanColor, CanDisableRipple, FocusableOption {\n\n  /** Whether the button is round. */\n  readonly isRoundButton: boolean = this._hasHostAttributes('mat-fab', 'mat-mini-fab');\n\n  /** Whether the button is icon button. */\n  readonly isIconButton: boolean = this._hasHostAttributes('mat-icon-button');\n\n  /** Reference to the MatRipple instance of the button. */\n  @ViewChild(MatRipple) ripple: MatRipple;\n\n  constructor(elementRef: ElementRef,\n              private _focusMonitor: FocusMonitor,\n              @Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode: string) {\n    super(elementRef);\n\n    // For each of the variant selectors that is present in the button's host\n    // attributes, add the correct corresponding class.\n    for (const attr of BUTTON_HOST_ATTRIBUTES) {\n      if (this._hasHostAttributes(attr)) {\n        (this._getHostElement() as HTMLElement).classList.add(attr);\n      }\n    }\n\n    // Add a class that applies to all buttons. This makes it easier to target if somebody\n    // wants to target all Material buttons. We do it here rather than `host` to ensure that\n    // the class is applied to derived classes.\n    elementRef.nativeElement.classList.add('mat-button-base');\n\n    if (this.isRoundButton) {\n      this.color = DEFAULT_ROUND_BUTTON_COLOR;\n    }\n  }\n\n  ngAfterViewInit() {\n    this._focusMonitor.monitor(this._elementRef, true);\n  }\n\n  ngOnDestroy() {\n    this._focusMonitor.stopMonitoring(this._elementRef);\n  }\n\n  /** Focuses the button. */\n  focus(origin?: FocusOrigin, options?: FocusOptions): void {\n    if (origin) {\n      this._focusMonitor.focusVia(this._getHostElement(), origin, options);\n    } else {\n      this._getHostElement().focus(options);\n    }\n  }\n\n  _getHostElement() {\n    return this._elementRef.nativeElement;\n  }\n\n  _isRippleDisabled() {\n    return this.disableRipple || this.disabled;\n  }\n\n  /** Gets whether the button has one of the given attributes. */\n  _hasHostAttributes(...attributes: string[]) {\n    return attributes.some(attribute => this._getHostElement().hasAttribute(attribute));\n  }\n\n  static ngAcceptInputType_disabled: BooleanInput;\n  static ngAcceptInputType_disableRipple: BooleanInput;\n}\n\n/**\n * Material design anchor button.\n */\n@Component({\n  selector: `a[mat-button], a[mat-raised-button], a[mat-icon-button], a[mat-fab],\n             a[mat-mini-fab], a[mat-stroked-button], a[mat-flat-button]`,\n  exportAs: 'matButton, matAnchor',\n  host: {\n    // Note that we ignore the user-specified tabindex when it's disabled for\n    // consistency with the `mat-button` applied on native buttons where even\n    // though they have an index, they're not tabbable.\n    '[attr.tabindex]': 'disabled ? -1 : (tabIndex || 0)',\n    '[attr.disabled]': 'disabled || null',\n    '[attr.aria-disabled]': 'disabled.toString()',\n    '(click)': '_haltDisabledEvents($event)',\n    '[class._mat-animation-noopable]': '_animationMode === \"NoopAnimations\"',\n    '[class.mat-button-disabled]': 'disabled',\n    'class': 'mat-focus-indicator',\n  },\n  inputs: ['disabled', 'disableRipple', 'color'],\n  templateUrl: 'button.html',\n  styleUrls: ['button.css'],\n  encapsulation: ViewEncapsulation.None,\n  changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class MatAnchor extends MatButton {\n  /** Tabindex of the button. */\n  @Input() tabIndex: number;\n\n  constructor(\n    focusMonitor: FocusMonitor,\n    elementRef: ElementRef,\n    @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode: string) {\n    super(elementRef, focusMonitor, animationMode);\n  }\n\n  _haltDisabledEvents(event: Event) {\n    // A disabled button shouldn't apply any actions\n    if (this.disabled) {\n      event.preventDefault();\n      event.stopImmediatePropagation();\n    }\n  }\n}\n","<span class=\"mat-button-wrapper\"><ng-content></ng-content></span>\n<span matRipple class=\"mat-button-ripple\"\n      [class.mat-button-ripple-round]=\"isRoundButton || isIconButton\"\n      [matRippleDisabled]=\"_isRippleDisabled()\"\n      [matRippleCentered]=\"isIconButton\"\n      [matRippleTrigger]=\"_getHostElement()\"></span>\n<span class=\"mat-button-focus-overlay\"></span>\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {NgModule} from '@angular/core';\nimport {MatCommonModule, MatRippleModule} from '@angular/material/core';\nimport {MatAnchor, MatButton} from './button';\n\n\n@NgModule({\n  imports: [\n    MatRippleModule,\n    MatCommonModule,\n  ],\n  exports: [\n    MatButton,\n    MatAnchor,\n    MatCommonModule,\n  ],\n  declarations: [\n    MatButton,\n    MatAnchor,\n  ],\n})\nexport class MatButtonModule {}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './button-module';\nexport * from './button';\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAiCA;AACA,MAAM,0BAA0B,GAAG,QAAQ,CAAC;AAE5C;;;;AAIA,MAAM,sBAAsB,GAAG;IAC7B,YAAY;IACZ,iBAAiB;IACjB,iBAAiB;IACjB,mBAAmB;IACnB,oBAAoB;IACpB,cAAc;IACd,SAAS;CACV,CAAC;AAEF;AACA,MAAM,cAAc,GAAG,UAAU,CAAC,aAAa,CAAC,kBAAkB,CAAC;IACjE,YAAmB,WAAuB;QAAvB,gBAAW,GAAX,WAAW,CAAY;KAAI;CAC/C,CAAC,CAAC,CAAC,CAAC;AAEL;;;MAuBa,SAAU,SAAQ,cAAc;IAY3C,YAAY,UAAsB,EACd,aAA2B,EACe,cAAsB;QAClF,KAAK,CAAC,UAAU,CAAC,CAAC;QAFA,kBAAa,GAAb,aAAa,CAAc;QACe,mBAAc,GAAd,cAAc,CAAQ;;QAV3E,kBAAa,GAAY,IAAI,CAAC,kBAAkB,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