ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
9 lines • 6.21 kB
JavaScript
!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,r,a,o){"use strict";var i=function(t,n){return(i=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 r,a,o=e.call(t),i=[];try{for(;(void 0===n||n-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(s){a={error:s}}finally{try{r&&!r.done&&(e=o["return"])&&e.call(o)}finally{if(a)throw a.error}}return i}
/**
* @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}(),c=function(t){function a(n,e,r){var a=t.call(this)||this;return a.cdr=n,a.ngZone=e,a.platform=r,a.nzFormat="HH:mm:ss",a}return function(t,n){function e(){this.constructor=t}i(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}(a,t),a.prototype.ngOnChanges=function(t){t.nzValue&&(this.target=Number(t.nzValue.currentValue),t.nzValue.isFirstChange()||this.syncTimer())},a.prototype.ngOnInit=function(){this.syncTimer()},a.prototype.ngOnDestroy=function(){this.stopTimer()},a.prototype.syncTimer=function(){this.target>=Date.now()?this.startTimer():this.stopTimer()},a.prototype.startTimer=function(){var t=this;this.platform.isBrowser&&this.ngZone.runOutsideAngular(function(){t.stopTimer(),t.updater_=r.interval(1e3/30).subscribe(function(){t.updateValue(),t.cdr.detectChanges()})})},a.prototype.stopTimer=function(){this.updater_&&(this.updater_.unsubscribe(),this.updater_=null)},a.prototype.updateValue=function(){this.diff=Math.max(this.target-Date.now(),0),0===this.diff&&this.stopTimer()},a.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>'}]}],a.ctorParameters=function(){return[{type:e.ChangeDetectorRef},{type:e.NgZone},{type:n.Platform}]},a.propDecorators={nzFormat:[{type:e.Input}]},a}(u),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?".":a.getLocaleNumberSymbol(this.locale_id,a.NumberSymbol.Decimal),n=s(String(this.nzValue).split(t),2),e=n[0],r=n[1];this.displayInt=e,this.displayDecimal=r?""+t+r:""},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}(),p=function(){function t(){}return t.prototype.transform=function(t,n){void 0===n&&(n="HH:mm:ss");var e=Number(t||0);return o.timeUnits.reduce(function(t,n){var r=s(n,2),a=r[0],i=r[1];if(-1!==t.indexOf(a)){var u=Math.floor(e/i);return e-=u*i,t.replace(new RegExp(a+"+","g"),function(t){return o.padStart(u.toString(),t.length,"0")})}return t},n)},t.decorators=[{type:e.Pipe,args:[{name:"nzTimeRange",pure:!0}]}],t}(),f=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[a.CommonModule,o.NzAddOnModule],declarations:[u,c,l,p],exports:[u,c,l,p]}]}],t}();t.NzCountdownComponent=c,t.NzStatisticComponent=u,t.NzStatisticModule=f,t.NzStatisticNumberComponent=l,t.NzTimeRangePipe=p,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ng-zorro-antd-statistic.umd.min.js.map