ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
16 lines (14 loc) • 6.71 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/outlet"),require("ng-zorro-antd/core/pipe")):"function"==typeof define&&define.amd?define("ng-zorro-antd/statistic",["exports","@angular/cdk/platform","@angular/core","rxjs","@angular/common","ng-zorro-antd/core/outlet","ng-zorro-antd/core/pipe"],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.outlet,t["ng-zorro-antd"].core.pipe)}(this,(function(t,n,e,o,a,r,i){"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.
***************************************************************************** */var s=function(t,n){return(s=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 o,a,r=e.call(t),i=[];try{for(;(void 0===n||n-- >0)&&!(o=r.next()).done;)i.push(o.value)}catch(t){a={error:t}}finally{try{o&&!o.done&&(e=r.return)&&e.call(r)}finally{if(a)throw a.error}}return i}var c=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:'\n <div class="ant-statistic">\n <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 [nzValue]="nzValue" [nzValueTemplate]="nzValueTemplate"> </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 </div>\n '}]}],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 p=function(t){function a(n,o,a){var r=t.call(this)||this;return r.cdr=n,r.ngZone=o,r.platform=a,r.nzFormat="HH:mm:ss",r.nzCountdownFinish=new e.EventEmitter,r}return function(t,n){function e(){this.constructor=t}s(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_=o.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(),this.nzCountdownFinish.emit())},a.decorators=[{type:e.Component,args:[{changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,selector:"nz-countdown",exportAs:"nzCountdown",template:'\n <nz-statistic\n [nzValue]="diff"\n [nzValueStyle]="nzValueStyle"\n [nzValueTemplate]="nzValueTemplate || countDownTpl"\n [nzTitle]="nzTitle"\n [nzPrefix]="nzPrefix"\n [nzSuffix]="nzSuffix"\n >\n </nz-statistic>\n\n <ng-template #countDownTpl>{{ diff | nzTimeRange: nzFormat }}</ng-template>\n '}]}],a.ctorParameters=function(){return[{type:e.ChangeDetectorRef},{type:e.NgZone},{type:n.Platform}]},a.propDecorators={nzFormat:[{type:e.Input}],nzCountdownFinish:[{type:e.Output}]},a}(c);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?".":a.getLocaleNumberSymbol(this.locale_id,a.NumberSymbol.Decimal),n=u(String(this.nzValue).split(t),2),e=n[0],o=n[1];this.displayInt=e,this.displayDecimal=o?""+t+o:""},t.decorators=[{type:e.Component,args:[{changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,preserveWhitespaces:!1,selector:"nz-statistic-number",exportAs:"nzStatisticNumber",template:'\n <span class="ant-statistic-content-value">\n <ng-container *ngIf="nzValueTemplate" [ngTemplateOutlet]="nzValueTemplate" [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 </span>\n '}]}],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 f=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[a.CommonModule,n.PlatformModule,r.NzOutletModule,i.NzPipesModule],declarations:[c,p,l],exports:[c,p,l]}]}],t}();t.NzCountdownComponent=p,t.NzStatisticComponent=c,t.NzStatisticModule=f,t.NzStatisticNumberComponent=l,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-zorro-antd-statistic.umd.min.js.map