UNPKG

ng-zorro-antd

Version:

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

10 lines 5.91 kB
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@angular/cdk/platform"),require("@angular/core"),require("rxjs"),require("@angular/common"),require("ng-zorro-antd/core")):"function"==typeof define&&define.amd?define("ng-zorro-antd/statistic",["exports","@angular/cdk/platform","@angular/core","rxjs","@angular/common","ng-zorro-antd/core"],n):n(((t=t||self)["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"].statistic={}),t.ng.cdk.platform,t.ng.core,t.rxjs,t.ng.common,t["ng-zorro-antd"].core)}(this,function(t,n,e,a,o,i){"use strict";var r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function s(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var a,o,i=e.call(t),r=[];try{for(;(void 0===n||n-- >0)&&!(a=i.next()).done;)r.push(a.value)}catch(t){o={error:t}}finally{try{a&&!a.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return r} /** * @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 u=function(){function t(){this.nzValueStyle={}}return t.decorators=[{type:e.Component,args:[{changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,selector:"nz-statistic",exportAs:"nzStatistic",template:'<div class="ant-statistic-title">\n <ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>\n</div>\n<div class="ant-statistic-content" [ngStyle]="nzValueStyle">\n <span *ngIf="nzPrefix" class="ant-statistic-content-prefix">\n <ng-container *nzStringTemplateOutlet="nzPrefix">{{ nzPrefix }}</ng-container>\n </span>\n <nz-statistic-number\n [nzValue]="nzValue"\n [nzValueTemplate]="nzValueTemplate">\n </nz-statistic-number>\n <span *ngIf="nzSuffix" class="ant-statistic-content-suffix">\n <ng-container *nzStringTemplateOutlet="nzSuffix">{{ nzSuffix }}</ng-container>\n </span>\n</div>\n',host:{class:"ant-statistic"},styles:["nz-statistic { display: block; }"]}]}],t.propDecorators={nzPrefix:[{type:e.Input}],nzSuffix:[{type:e.Input}],nzTitle:[{type:e.Input}],nzValue:[{type:e.Input}],nzValueStyle:[{type:e.Input}],nzValueTemplate:[{type:e.Input}]},t}();var c=function(t){function o(n,a,o){var i=t.call(this)||this;return i.cdr=n,i.ngZone=a,i.platform=o,i.nzFormat="HH:mm:ss",i.nzCountdownFinish=new e.EventEmitter,i}return function(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}(o,t),o.prototype.ngOnChanges=function(t){t.nzValue&&(this.target=Number(t.nzValue.currentValue),t.nzValue.isFirstChange()||this.syncTimer())},o.prototype.ngOnInit=function(){this.syncTimer()},o.prototype.ngOnDestroy=function(){this.stopTimer()},o.prototype.syncTimer=function(){this.target>=Date.now()?this.startTimer():this.stopTimer()},o.prototype.startTimer=function(){var t=this;this.platform.isBrowser&&this.ngZone.runOutsideAngular(function(){t.stopTimer(),t.updater_=a.interval(1e3/30).subscribe(function(){t.updateValue(),t.cdr.detectChanges()})})},o.prototype.stopTimer=function(){this.updater_&&(this.updater_.unsubscribe(),this.updater_=null)},o.prototype.updateValue=function(){this.diff=Math.max(this.target-Date.now(),0),0===this.diff&&(this.stopTimer(),this.nzCountdownFinish.emit())},o.decorators=[{type:e.Component,args:[{changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,selector:"nz-countdown",exportAs:"nzCountdown",template:'<nz-statistic\n [nzValue]="diff"\n [nzValueStyle]="nzValueStyle"\n [nzValueTemplate]="nzValueTemplate || countDownTpl"\n [nzTitle]="nzTitle"\n [nzPrefix]="nzPrefix"\n [nzSuffix]="nzSuffix">\n</nz-statistic>\n\n<ng-template #countDownTpl>{{ diff | nzTimeRange: nzFormat }}</ng-template>'}]}],o.ctorParameters=function(){return[{type:e.ChangeDetectorRef},{type:e.NgZone},{type:n.Platform}]},o.propDecorators={nzFormat:[{type:e.Input}],nzCountdownFinish:[{type:e.Output}]},o}(u);var l=function(){function t(t){this.locale_id=t,this.displayInt="",this.displayDecimal=""}return t.prototype.ngOnChanges=function(){this.formatNumber()},t.prototype.formatNumber=function(){var t="number"==typeof this.nzValue?".":o.getLocaleNumberSymbol(this.locale_id,o.NumberSymbol.Decimal),n=s(String(this.nzValue).split(t),2),e=n[0],a=n[1];this.displayInt=e,this.displayDecimal=a?""+t+a:""},t.decorators=[{type:e.Component,args:[{changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,preserveWhitespaces:!1,selector:"nz-statistic-number",exportAs:"nzStatisticNumber",template:'<ng-container\n *ngIf="nzValueTemplate"\n [ngTemplateOutlet]="nzValueTemplate"\n [ngTemplateOutletContext]="{ $implicit: nzValue }">\n</ng-container>\n<ng-container *ngIf="!nzValueTemplate">\n <span *ngIf="displayInt" class="ant-statistic-content-value-int">{{ displayInt }}</span>\n <span *ngIf="displayDecimal" class="ant-statistic-content-value-decimal">{{ displayDecimal }}</span>\n</ng-container>\n',host:{class:"ant-statistic-content-value"},styles:["nz-number { display: inline }"]}]}],t.ctorParameters=function(){return[{type:String,decorators:[{type:e.Inject,args:[e.LOCALE_ID]}]}]},t.propDecorators={nzValue:[{type:e.Input}],nzValueTemplate:[{type:e.Input}]},t}();var p=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[o.CommonModule,n.PlatformModule,i.NzAddOnModule,i.NzPipesModule],declarations:[u,c,l],exports:[u,c,l]}]}],t}();t.NzCountdownComponent=c,t.NzStatisticComponent=u,t.NzStatisticModule=p,t.NzStatisticNumberComponent=l,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=ng-zorro-antd-statistic.umd.min.js.map