UNPKG

@angular-mdc/web

Version:
8 lines 4.04 kB
/** * @license * Copyright (c) Dominic Carretto * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/trimox/angular-mdc-web/blob/master/LICENSE */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("@angular/cdk/coercion"),require("@angular-mdc/web/ripple"),require("@angular-mdc/web/icon")):"function"==typeof define&&define.amd?define("@angular-mdc/web/button",["exports","@angular/core","@angular/common","@angular/cdk/coercion","@angular-mdc/web/ripple","@angular-mdc/web/icon"],t):t(((e=e||self).ng=e.ng||{},e.ng.web=e.ng.web||{},e.ng.web.button={}),e.ng.core,e.ng.common,e.ng.cdk.coercion,e.ng.web.ripple,e.ng.web.icon)}(this,(function(e,t,n,o,i,r){"use strict";var c=function(){function e(){}return e.decorators=[{type:t.Directive,args:[{selector:"mdc-button-label, [mdcButtonLabel]",exportAs:"mdcButtonLabel",host:{class:"mdc-button__label"}}]}],e}(),u=function(){function e(e,t){this.elementRef=e,this._ripple=t,this._raised=!1,this._unelevated=!1,this._outlined=!1,this._touch=!1,this._disabled=!1,this._ripple=new i.MdcRipple(this.elementRef),this._ripple.init()}return Object.defineProperty(e.prototype,"raised",{get:function(){return this._raised},set:function(e){this._raised=o.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"unelevated",{get:function(){return this._unelevated},set:function(e){this._unelevated=o.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"outlined",{get:function(){return this._outlined},set:function(e){this._outlined=o.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"touch",{get:function(){return this._touch},set:function(e){this._touch=o.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{get:function(){return this._disabled},set:function(e){this.setDisabled(e)},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){this._icon&&this._icon.elementRef.nativeElement.classList.add("mdc-button__icon")},e.prototype.ngOnDestroy=function(){this._ripple.destroy()},e.prototype.setDisabled=function(e){this._disabled=o.coerceBooleanProperty(e),this._disabled?(this.getHostElement().setAttribute("disabled","true"),this.getHostElement().setAttribute("aria-disabled","true")):(this.getHostElement().removeAttribute("disabled"),this.getHostElement().removeAttribute("aria-disabled"))},e.prototype.focus=function(){this.getHostElement().focus()},e.prototype.getHostElement=function(){return this.elementRef.nativeElement},e.prototype.onClick=function(e){this.disabled&&(e.preventDefault(),e.stopImmediatePropagation())},e.decorators=[{type:t.Component,args:[{exportAs:"mdcButton",selector:"button[mdc-button], a[mdc-button]",host:{"[tabIndex]":"disabled ? -1 : 0",class:"mdc-button","[class.mdc-button--raised]":"raised","[class.mdc-button--unelevated]":"unelevated","[class.mdc-button--outlined]":"outlined","[class.mdc-button--touch]":"touch","(click)":"onClick($event)"},template:'\n <div class="mdc-button__ripple"></div>\n <mdc-button-label *ngIf="label">{{label}}</mdc-button-label>\n <div class="mdc-button__touch" *ngIf="touch"></div>\n <ng-content></ng-content>\n ',providers:[i.MdcRipple],encapsulation:t.ViewEncapsulation.None,changeDetection:t.ChangeDetectionStrategy.OnPush}]}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:i.MdcRipple}]},e.propDecorators={raised:[{type:t.Input}],unelevated:[{type:t.Input}],outlined:[{type:t.Input}],touch:[{type:t.Input}],disabled:[{type:t.Input}],_icon:[{type:t.ContentChild,args:[r.MdcIcon,{static:!0}]}],label:[{type:t.Input}]},e}(),s=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[n.CommonModule],exports:[u,c],declarations:[u,c]}]}],e}();e.MdcButton=u,e.MdcButtonLabel=c,e.MdcButtonModule=s,Object.defineProperty(e,"__esModule",{value:!0})}));