UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

2 lines 4.61 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/platform"),require("@angular/core"),require("ng-zorro-antd/core"),require("@angular/common"),require("ng-zorro-antd/icon")):"function"==typeof define&&define.amd?define("ng-zorro-antd/avatar",["exports","@angular/cdk/platform","@angular/core","ng-zorro-antd/core","@angular/common","ng-zorro-antd/icon"],e):e(((t=t||self)["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"].avatar={}),t.ng.cdk.platform,t.ng.core,t["ng-zorro-antd"].core,t.ng.common,t["ng-zorro-antd"].icon)}(this,function(t,e,n,r,i,s){"use strict";function o(t,e,n,r){var i,s=arguments.length,o=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(o=(s<3?i(o):s>3?i(e,n,o):i(e,n))||o);return s>3&&o&&Object.defineProperty(e,n,o),o}function a(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var c=function(){function t(t,e,r,i,s,o){this.nzConfigService=t,this.elementRef=e,this.cd=r,this.updateHostClassService=i,this.renderer=s,this.platform=o,this.nzError=new n.EventEmitter,this.oldAPIIcon=!0,this.hasText=!1,this.hasSrc=!0,this.hasIcon=!1,this.el=this.elementRef.nativeElement,this.prefixCls="ant-avatar",this.sizeMap={large:"lg",small:"sm"}}return t.prototype.setClass=function(){var t,e=((t={})[this.prefixCls]=!0,t[this.prefixCls+"-"+this.sizeMap[this.nzSize]]=this.sizeMap[this.nzSize],t[this.prefixCls+"-"+this.nzShape]=this.nzShape,t[this.prefixCls+"-icon"]=this.nzIcon,t[this.prefixCls+"-image"]=this.hasSrc,t);return this.updateHostClassService.updateHostClass(this.el,e),this.cd.detectChanges(),this},t.prototype.imgError=function(t){this.nzError.emit(t),t.defaultPrevented||(this.hasSrc=!1,this.hasIcon=!1,this.hasText=!1,this.nzIcon?this.hasIcon=!0:this.nzText&&(this.hasText=!0),this.setClass().notifyCalc(),this.setSizeStyle())},t.prototype.ngOnChanges=function(t){t.hasOwnProperty("nzIcon")&&t.nzIcon.currentValue&&(this.oldAPIIcon=t.nzIcon.currentValue.indexOf("anticon")>-1),this.hasText=!this.nzSrc&&!!this.nzText,this.hasIcon=!this.nzSrc&&!!this.nzIcon,this.hasSrc=!!this.nzSrc,this.setClass().notifyCalc(),this.setSizeStyle()},t.prototype.calcStringSize=function(){if(this.hasText){var t=this.textEl.nativeElement.offsetWidth,e=this.el.getBoundingClientRect().width,n=e-8<t?(e-8)/t:1;this.textStyles={transform:"scale("+n+") translateX(-50%)"},"number"==typeof this.nzSize&&Object.assign(this.textStyles,{lineHeight:this.nzSize+"px"}),this.cd.detectChanges()}},t.prototype.notifyCalc=function(){var t=this;return this.platform.isBrowser&&setTimeout(function(){t.calcStringSize()}),this},t.prototype.setSizeStyle=function(){var t="string"==typeof this.nzSize?this.nzSize:this.nzSize+"px";this.renderer.setStyle(this.el,"width",t),this.renderer.setStyle(this.el,"height",t),this.renderer.setStyle(this.el,"line-height",t),this.hasIcon&&this.renderer.setStyle(this.el,"font-size","calc("+t+" / 2)")},t.decorators=[{type:n.Component,args:[{selector:"nz-avatar",exportAs:"nzAvatar",template:'<i nz-icon *ngIf="nzIcon && hasIcon" [nzType]="!oldAPIIcon && nzIcon" [ngClass]="oldAPIIcon && nzIcon"></i>\n<img *ngIf="nzSrc && hasSrc" [src]="nzSrc" [attr.srcset]="nzSrcSet" [attr.alt]="nzAlt" (error)="imgError($event)"/>\n<span class="ant-avatar-string" #textEl [ngStyle]="textStyles" *ngIf="nzText && hasText">{{ nzText }}</span>\n',providers:[r.NzUpdateHostClassService],preserveWhitespaces:!1,changeDetection:n.ChangeDetectionStrategy.OnPush,encapsulation:n.ViewEncapsulation.None}]}],t.ctorParameters=function(){return[{type:r.NzConfigService},{type:n.ElementRef},{type:n.ChangeDetectorRef},{type:r.NzUpdateHostClassService},{type:n.Renderer2},{type:e.Platform}]},t.propDecorators={nzShape:[{type:n.Input}],nzSize:[{type:n.Input}],nzText:[{type:n.Input}],nzSrc:[{type:n.Input}],nzSrcSet:[{type:n.Input}],nzAlt:[{type:n.Input}],nzIcon:[{type:n.Input}],nzError:[{type:n.Output}],textEl:[{type:n.ViewChild,args:["textEl",{static:!1}]}]},o([r.WithConfig("circle"),a("design:type",String)],t.prototype,"nzShape",void 0),o([r.WithConfig("default"),a("design:type",Object)],t.prototype,"nzSize",void 0),t}();var h=function(){function t(){}return t.decorators=[{type:n.NgModule,args:[{declarations:[c],exports:[c],imports:[i.CommonModule,s.NzIconModule,e.PlatformModule]}]}],t}();t.NzAvatarComponent=c,t.NzAvatarModule=h,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=ng-zorro-antd-avatar.umd.min.js.map