blob: f79c943cc52238e2ba50cc89484bb8e322a066a0 [file] [log] [blame]
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/a11y"),require("@angular/cdk/coercion"),require("@angular/core"),require("@angular/material/core"),require("@angular/platform-browser/animations")):"function"==typeof define&&define.amd?define("@angular/material/badge",["exports","@angular/cdk/a11y","@angular/cdk/coercion","@angular/core","@angular/material/core","@angular/platform-browser/animations"],t):t((e.ng=e.ng||{},e.ng.material=e.ng.material||{},e.ng.material.badge={}),e.ng.cdk.a11y,e.ng.cdk.coercion,e.ng.core,e.ng.material.core,e.ng.platformBrowser.animations)}(this,function(e,t,n,r,a,i){"use strict";function o(e,t){function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},c=0,d=function(){function e(){}return e}(),l=a.mixinDisabled(d),p=function(e){function a(t,n,a,i,o){var s=e.call(this)||this;if(s._ngZone=t,s._elementRef=n,s._ariaDescriber=a,s._renderer=i,s._animationMode=o,s._hasContent=!1,s._color="primary",s._overlap=!0,s.position="above after",s.size="medium",s._id=c++,r.isDevMode()){var d=n.nativeElement;if(d.nodeType!==d.ELEMENT_NODE)throw Error("matBadge must be attached to an element node.")}return s}return o(a,e),Object.defineProperty(a.prototype,"color",{get:function(){return this._color},set:function(e){this._setColor(e),this._color=e},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"overlap",{get:function(){return this._overlap},set:function(e){this._overlap=n.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"description",{get:function(){return this._description},set:function(e){if(e!==this._description){var t=this._badgeElement;this._updateHostAriaDescription(e,this._description),this._description=e,t&&(e?t.setAttribute("aria-label",e):t.removeAttribute("aria-label"))}},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"hidden",{get:function(){return this._hidden},set:function(e){this._hidden=n.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),a.prototype.isAbove=function(){return-1===this.position.indexOf("below")},a.prototype.isAfter=function(){return-1===this.position.indexOf("before")},a.prototype.ngOnChanges=function(e){var t=e.content;if(t){var n=t.currentValue;this._hasContent=null!=n&&(""+n).trim().length>0,this._updateTextContent()}},a.prototype.ngOnDestroy=function(){var e=this._badgeElement;e&&(this.description&&this._ariaDescriber.removeDescription(e,this.description),this._renderer.destroyNode&&this._renderer.destroyNode(e))},a.prototype.getBadgeElement=function(){return this._badgeElement},a.prototype._updateTextContent=function(){return this._badgeElement?this._badgeElement.textContent=this.content:this._badgeElement=this._createBadgeElement(),this._badgeElement},a.prototype._createBadgeElement=function(){var e=this._renderer.createElement("span");return this._clearExistingBadges("mat-badge-content"),e.setAttribute("id","mat-badge-content-"+this._id),e.classList.add("mat-badge-content"),e.textContent=this.content,"NoopAnimations"===this._animationMode&&e.classList.add("_mat-animation-noopable"),this.description&&e.setAttribute("aria-label",this.description),this._elementRef.nativeElement.appendChild(e),"function"==typeof requestAnimationFrame&&"NoopAnimations"!==this._animationMode?this._ngZone.runOutsideAngular(function(){requestAnimationFrame(function(){e.classList.add("mat-badge-active")})}):e.classList.add("mat-badge-active"),e},a.prototype._updateHostAriaDescription=function(e,t){var n=this._updateTextContent();t&&this._ariaDescriber.removeDescription(n,t),e&&this._ariaDescriber.describe(n,e)},a.prototype._setColor=function(e){e!==this._color&&(this._color&&this._elementRef.nativeElement.classList.remove("mat-badge-"+this._color),e&&this._elementRef.nativeElement.classList.add("mat-badge-"+e))},a.prototype._clearExistingBadges=function(e){for(var t=this._elementRef.nativeElement,n=t.children.length;n--;){var r=t.children[n];r.classList.contains(e)&&t.removeChild(r)}},a.decorators=[{type:r.Directive,args:[{selector:"[matBadge]",inputs:["disabled: matBadgeDisabled"],host:{class:"mat-badge","[class.mat-badge-overlap]":"overlap","[class.mat-badge-above]":"isAbove()","[class.mat-badge-below]":"!isAbove()","[class.mat-badge-before]":"!isAfter()","[class.mat-badge-after]":"isAfter()","[class.mat-badge-small]":'size === "small"',"[class.mat-badge-medium]":'size === "medium"',"[class.mat-badge-large]":'size === "large"',"[class.mat-badge-hidden]":"hidden || !_hasContent","[class.mat-badge-disabled]":"disabled"}}]}],a.ctorParameters=function(){return[{type:r.NgZone},{type:r.ElementRef},{type:t.AriaDescriber},{type:r.Renderer2},{type:String,decorators:[{type:r.Optional},{type:r.Inject,args:[i.ANIMATION_MODULE_TYPE]}]}]},a.propDecorators={color:[{type:r.Input,args:["matBadgeColor"]}],overlap:[{type:r.Input,args:["matBadgeOverlap"]}],position:[{type:r.Input,args:["matBadgePosition"]}],content:[{type:r.Input,args:["matBadge"]}],description:[{type:r.Input,args:["matBadgeDescription"]}],size:[{type:r.Input,args:["matBadgeSize"]}],hidden:[{type:r.Input,args:["matBadgeHidden"]}]},a}(l),u=function(){function e(){}return e.decorators=[{type:r.NgModule,args:[{imports:[t.A11yModule,a.MatCommonModule],exports:[p],declarations:[p]}]}],e}();e.MatBadgeModule=u,e.MatBadge=p,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=material-badge.umd.min.js.map