UNPKG

ng-zorro-antd

Version:

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

24 lines (22 loc) 7.62 kB
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/observers"),require("@angular/core"),require("ng-zorro-antd/core/animation"),require("ng-zorro-antd/core/config"),require("ng-zorro-antd/core/util"),require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("ng-zorro-antd/core/outlet")):"function"==typeof define&&define.amd?define("ng-zorro-antd/badge",["exports","@angular/cdk/observers","@angular/core","ng-zorro-antd/core/animation","ng-zorro-antd/core/config","ng-zorro-antd/core/util","rxjs","rxjs/operators","@angular/common","ng-zorro-antd/core/outlet"],t):t(((n=n||self)["ng-zorro-antd"]=n["ng-zorro-antd"]||{},n["ng-zorro-antd"].badge={}),n.ng.cdk.observers,n.ng.core,n["ng-zorro-antd"].core.animation,n["ng-zorro-antd"].core.config,n["ng-zorro-antd"].core.util,n.rxjs,n.rxjs.operators,n.ng.common,n["ng-zorro-antd"].core.outlet)}(this,(function(n,t,e,o,r,a,s,i,u,c){"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 l(n,t,e,o){var r,a=arguments.length,s=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,e):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(n,t,e,o);else for(var i=n.length-1;i>=0;i--)(r=n[i])&&(s=(a<3?r(s):a>3?r(t,e,s):r(t,e))||s);return a>3&&s&&Object.defineProperty(t,e,s),s}function p(n,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(n,t)} /** * @license * Copyright Alibaba.com 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://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ var g=["pink","red","yellow","orange","cyan","green","blue","purple","geekblue","magenta","volcano","gold","lime"],d=function(){function n(n,t,e,o,r,a){this.nzConfigService=n,this.renderer=t,this.elementRef=e,this.contentObserver=o,this.cdr=r,this.ngZone=a,this.destroy$=new s.Subject,this.notWrapper=!0,this.viewInit=!1,this.maxNumberArray=[],this.countArray=[],this.countSingleArray=[0,1,2,3,4,5,6,7,8,9],this.presetColor=null,this.nzShowZero=!1,this.nzShowDot=!0,this.nzDot=!1}return n.prototype.checkContent=function(){this.notWrapper=a.isEmpty(this.contentElement.nativeElement),this.notWrapper?this.renderer.addClass(this.elementRef.nativeElement,"ant-badge-not-a-wrapper"):this.renderer.removeClass(this.elementRef.nativeElement,"ant-badge-not-a-wrapper")},Object.defineProperty(n.prototype,"showSup",{get:function(){return this.nzShowDot&&this.nzDot||this.count>0||0===this.count&&this.nzShowZero},enumerable:!0,configurable:!0}),n.prototype.generateMaxNumberArray=function(){this.maxNumberArray=this.nzOverflowCount.toString().split("")},n.prototype.ngOnInit=function(){this.generateMaxNumberArray()},n.prototype.ngAfterViewInit=function(){var n=this;this.ngZone.onStable.pipe(i.take(1)).subscribe((function(){n.viewInit=!0,n.cdr.markForCheck()})),this.contentObserver.observe(this.contentElement).pipe(i.startWith(!0),i.takeUntil(this.destroy$)).subscribe((function(){n.checkContent()}))},n.prototype.ngOnChanges=function(n){var t=n.nzOverflowCount,o=n.nzCount,r=n.nzColor;!o||o.currentValue instanceof e.TemplateRef||(this.count=Math.max(0,o.currentValue),this.countArray=this.count.toString().split("").map((function(n){return+n}))),t&&this.generateMaxNumberArray(),r&&(this.presetColor=-1!==g.indexOf(this.nzColor)?this.nzColor:null)},n.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},n.decorators=[{type:e.Component,args:[{selector:"nz-badge",exportAs:"nzBadge",preserveWhitespaces:!1,encapsulation:e.ViewEncapsulation.None,changeDetection:e.ChangeDetectionStrategy.OnPush,animations:[o.zoomBadgeMotion],template:'\n <span #contentElement><ng-content></ng-content></span>\n <span\n class="ant-badge-status-dot ant-badge-status-{{ nzStatus || presetColor }}"\n [style.background]="!presetColor && nzColor"\n *ngIf="nzStatus || nzColor"\n [ngStyle]="nzStyle"\n ></span>\n <span class="ant-badge-status-text" *ngIf="nzStatus || nzColor">{{ nzText }}</span>\n <ng-container *nzStringTemplateOutlet="nzCount">\n <sup\n class="ant-scroll-number"\n *ngIf="showSup && viewInit"\n [@.disabled]="notWrapper"\n [@zoomBadgeMotion]\n [ngStyle]="nzStyle"\n [attr.title]="nzTitle === null ? \'\' : nzTitle || nzCount"\n [style.right.px]="nzOffset && nzOffset[0] ? -nzOffset[0] : null"\n [style.marginTop.px]="nzOffset && nzOffset[1] ? nzOffset[1] : null"\n [class.ant-badge-count]="!nzDot"\n [class.ant-badge-dot]="nzDot"\n [class.ant-badge-multiple-words]="countArray.length >= 2"\n >\n <ng-container *ngFor="let n of maxNumberArray; let i = index">\n <span\n class="ant-scroll-number-only"\n *ngIf="count <= nzOverflowCount"\n [style.transform]="\'translateY(\' + -countArray[i] * 100 + \'%)\'"\n >\n <ng-container *ngIf="!nzDot && countArray[i] !== undefined">\n <p *ngFor="let p of countSingleArray" class="ant-scroll-number-only-unit" [class.current]="p === countArray[i]">\n {{ p }}\n </p>\n </ng-container>\n </span>\n </ng-container>\n <ng-container *ngIf="count > nzOverflowCount">{{ nzOverflowCount }}+</ng-container>\n </sup>\n </ng-container>\n ',host:{class:"ant-badge","[class.ant-badge-status]":"nzStatus"}}]}],n.ctorParameters=function(){return[{type:r.NzConfigService},{type:e.Renderer2},{type:e.ElementRef},{type:t.ContentObserver},{type:e.ChangeDetectorRef},{type:e.NgZone}]},n.propDecorators={contentElement:[{type:e.ViewChild,args:["contentElement",{static:!1}]}],nzShowZero:[{type:e.Input}],nzShowDot:[{type:e.Input}],nzDot:[{type:e.Input}],nzOverflowCount:[{type:e.Input}],nzText:[{type:e.Input}],nzColor:[{type:e.Input}],nzTitle:[{type:e.Input}],nzStyle:[{type:e.Input}],nzStatus:[{type:e.Input}],nzCount:[{type:e.Input}],nzOffset:[{type:e.Input}]},l([a.InputBoolean(),p("design:type",Boolean)],n.prototype,"nzShowZero",void 0),l([a.InputBoolean(),p("design:type",Object)],n.prototype,"nzShowDot",void 0),l([a.InputBoolean(),p("design:type",Object)],n.prototype,"nzDot",void 0),l([r.WithConfig("backTop",99),p("design:type",Number)],n.prototype,"nzOverflowCount",void 0),l([r.WithConfig("backTop"),p("design:type",String)],n.prototype,"nzColor",void 0),n}();var f=function(){function n(){}return n.decorators=[{type:e.NgModule,args:[{declarations:[d],exports:[d],imports:[u.CommonModule,t.ObserversModule,c.NzOutletModule]}]}],n}();n.NzBadgeComponent=d,n.NzBadgeModule=f,Object.defineProperty(n,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-badge.umd.min.js.map