UNPKG

ng-zorro-antd

Version:

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

16 lines (14 loc) 5.07 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/platform"),require("@angular/core"),require("ng-zorro-antd/core/config"),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/config","@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.config,t.ng.common,t["ng-zorro-antd"].icon)}(this,(function(t,e,n,r,o,a){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */function i(t,e,n,r){var o,a=arguments.length,i=a<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(i=(a<3?o(i):a>3?o(e,n,i):o(e,n))||i);return a>3&&i&&Object.defineProperty(e,n,i),i}function s(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var c=function(){function t(t,e,r,o){this.nzConfigService=t,this.elementRef=e,this.cdr=r,this.platform=o,this.nzError=new n.EventEmitter,this.hasText=!1,this.hasSrc=!0,this.hasIcon=!1,this.customSize=null,this.el=this.elementRef.nativeElement}return 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.cdr.detectChanges(),this.setSizeStyle(),this.notifyCalc())},t.prototype.ngOnChanges=function(){this.hasText=!this.nzSrc&&!!this.nzText,this.hasIcon=!this.nzSrc&&!!this.nzIcon,this.hasSrc=!!this.nzSrc,this.setSizeStyle(),this.notifyCalc()},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%)"},this.customSize&&Object.assign(this.textStyles,{lineHeight:this.customSize}),this.cdr.detectChanges()}},t.prototype.notifyCalc=function(){var t=this;this.platform.isBrowser&&setTimeout((function(){t.calcStringSize()}))},t.prototype.setSizeStyle=function(){"number"==typeof this.nzSize?this.customSize=this.nzSize+"px":this.customSize=null,this.cdr.markForCheck()},t.decorators=[{type:n.Component,args:[{selector:"nz-avatar",exportAs:"nzAvatar",template:'\n <i nz-icon *ngIf="nzIcon && hasIcon" [nzType]="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 ',host:{"[class.ant-avatar]":"true","[class.ant-avatar-lg]":"nzSize === 'large'","[class.ant-avatar-sm]":"nzSize === 'small'","[class.ant-avatar-square]":"nzShape === 'square'","[class.ant-avatar-circle]":"nzShape === 'circle'","[class.ant-avatar-icon]":"nzIcon","[class.ant-avatar-image]":"hasSrc ","[style.width]":"customSize","[style.height]":"customSize","[style.line-height]":"customSize","[style.font-size]":'(hasIcon && customSize) ? (nzSize / 2 + "px") : null'},preserveWhitespaces:!1,changeDetection:n.ChangeDetectionStrategy.OnPush,encapsulation:n.ViewEncapsulation.None}]}],t.ctorParameters=function(){return[{type:r.NzConfigService},{type:n.ElementRef},{type:n.ChangeDetectorRef},{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}]}]},i([r.WithConfig("avatar","circle"),s("design:type",String)],t.prototype,"nzShape",void 0),i([r.WithConfig("avatar","default"),s("design:type",Object)],t.prototype,"nzSize",void 0),t}();var l=function(){function t(){}return t.decorators=[{type:n.NgModule,args:[{declarations:[c],exports:[c],imports:[o.CommonModule,a.NzIconModule,e.PlatformModule]}]}],t}();t.NzAvatarComponent=c,t.NzAvatarModule=l,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-avatar.umd.min.js.map