UNPKG

ng-zorro-antd

Version:

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

9 lines 6.2 kB
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@angular/cdk/platform"),require("rxjs"),require("@angular/common"),require("@angular/core"),require("ng-zorro-antd/core")):"function"==typeof define&&define.amd?define("ng-zorro-antd/statistic",["exports","@angular/cdk/platform","rxjs","@angular/common","@angular/core","ng-zorro-antd/core"],n):n((t["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"].statistic={}),t.ng.cdk.platform,t.rxjs,t.ng.common,t.ng.core,t["ng-zorro-antd"].core)}(this,function(t,n,e,a,o,s){"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 u(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||0<n--)&&!(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 r=function(){function t(){this.nzValueStyle={}}return t.decorators=[{type:o.Component,args:[{changeDetection:o.ChangeDetectionStrategy.OnPush,encapsulation:o.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:o.Input}],nzSuffix:[{type:o.Input}],nzTitle:[{type:o.Input}],nzValue:[{type:o.Input}],nzValueStyle:[{type:o.Input}],nzValueTemplate:[{type:o.Input}]},t}(),c=function(a){function t(t,n,e){var r=a.call(this)||this;return r.cdr=t,r.ngZone=n,r.platform=e,r.nzFormat="HH:mm:ss",r}return function r(t,n){function e(){this.constructor=t}i(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}(t,a),t.prototype.ngOnChanges=function(t){t.nzValue&&(this.target=Number(t.nzValue.currentValue),t.nzValue.isFirstChange()||this.syncTimer())},t.prototype.ngOnInit=function(){this.syncTimer()},t.prototype.ngOnDestroy=function(){this.stopTimer()},t.prototype.syncTimer=function(){this.target>=Date.now()?this.startTimer():this.stopTimer()},t.prototype.startTimer=function(){var t=this;this.platform.isBrowser&&this.ngZone.runOutsideAngular(function(){t.stopTimer(),t.updater_=e.interval(1e3/30).subscribe(function(){t.updateValue(),t.cdr.detectChanges()})})},t.prototype.stopTimer=function(){this.updater_&&(this.updater_.unsubscribe(),this.updater_=null)},t.prototype.updateValue=function(){this.diff=Math.max(this.target-Date.now(),0),0===this.diff&&this.stopTimer()},t.decorators=[{type:o.Component,args:[{changeDetection:o.ChangeDetectionStrategy.OnPush,encapsulation:o.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>'}]}],t.ctorParameters=function(){return[{type:o.ChangeDetectorRef},{type:o.NgZone},{type:n.Platform}]},t.propDecorators={nzFormat:[{type:o.Input}]},t}(r),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=u(String(this.nzValue).split(t),2),e=n[0],r=n[1];this.displayInt=e,this.displayDecimal=r?""+t+r:""},t.decorators=[{type:o.Component,args:[{changeDetection:o.ChangeDetectionStrategy.OnPush,encapsulation:o.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:o.Inject,args:[o.LOCALE_ID]}]}]},t.propDecorators={nzValue:[{type:o.Input}],nzValueTemplate:[{type:o.Input}]},t}(),p=function(){function t(){}return t.prototype.transform=function(t,n){void 0===n&&(n="HH:mm:ss");var i=Number(t||0);return s.timeUnits.reduce(function(t,n){var e=u(n,2),r=e[0],a=e[1];if(-1===t.indexOf(r))return t;var o=Math.floor(i/a);return i-=o*a,t.replace(new RegExp(r+"+","g"),function(t){return s.padStart(o.toString(),t.length,"0")})},n)},t.decorators=[{type:o.Pipe,args:[{name:"nzTimeRange",pure:!0}]}],t}(),f=function(){function t(){}return t.decorators=[{type:o.NgModule,args:[{imports:[a.CommonModule,s.NzAddOnModule],declarations:[r,c,l,p],exports:[r,c,l,p]}]}],t}();t.NzCountdownComponent=c,t.NzStatisticComponent=r,t.NzStatisticModule=f,t.NzStatisticNumberComponent=l,t.NzTimeRangePipe=p,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=ng-zorro-antd-statistic.umd.min.js.map