ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
1 lines • 13.8 kB
Source Map (JSON)
{"version":3,"file":"ng-zorro-antd-statistic.mjs","sources":["../../components/statistic/statistic-number.component.ts","../../components/statistic/statistic.component.ts","../../components/statistic/countdown.component.ts","../../components/statistic/statistic.module.ts","../../components/statistic/public-api.ts","../../components/statistic/ng-zorro-antd-statistic.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { getLocaleNumberSymbol, NumberSymbol } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n Inject,\n Input,\n LOCALE_ID,\n OnChanges,\n TemplateRef,\n ViewEncapsulation\n} from '@angular/core';\n\nimport { NzStatisticValueType } from './typings';\n\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n preserveWhitespaces: false,\n selector: 'nz-statistic-number',\n exportAs: 'nzStatisticNumber',\n template: `\n <span class=\"ant-statistic-content-value\">\n <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 </span>\n `\n})\nexport class NzStatisticNumberComponent implements OnChanges {\n @Input() nzValue?: NzStatisticValueType;\n @Input() nzValueTemplate?: TemplateRef<{ $implicit: NzStatisticValueType }>;\n\n displayInt = '';\n displayDecimal = '';\n\n constructor(@Inject(LOCALE_ID) private locale_id: string) {}\n\n ngOnChanges(): void {\n this.formatNumber();\n }\n\n private formatNumber(): void {\n const decimalSeparator: string =\n typeof this.nzValue === 'number' ? '.' : getLocaleNumberSymbol(this.locale_id, NumberSymbol.Decimal);\n const value = String(this.nzValue);\n const [int, decimal] = value.split(decimalSeparator);\n\n this.displayInt = int;\n this.displayDecimal = decimal ? `${decimalSeparator}${decimal}` : '';\n }\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { Direction, Directionality } from '@angular/cdk/bidi';\nimport {\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n Input,\n OnDestroy,\n OnInit,\n Optional,\n TemplateRef,\n ViewEncapsulation\n} from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { NgStyleInterface } from 'ng-zorro-antd/core/types';\n\nimport { NzStatisticValueType } from './typings';\n\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n selector: 'nz-statistic',\n exportAs: 'nzStatistic',\n template: `\n <div class=\"ant-statistic\" [class.ant-statistic-rtl]=\"dir === 'rtl'\">\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 `\n})\nexport class NzStatisticComponent implements OnDestroy, OnInit {\n @Input() nzPrefix?: string | TemplateRef<void>;\n @Input() nzSuffix?: string | TemplateRef<void>;\n @Input() nzTitle?: string | TemplateRef<void>;\n @Input() nzValue?: NzStatisticValueType;\n @Input() nzValueStyle: NgStyleInterface = {};\n @Input() nzValueTemplate?: TemplateRef<{ $implicit: NzStatisticValueType }>;\n dir: Direction = 'ltr';\n\n private destroy$ = new Subject<void>();\n\n constructor(protected cdr: ChangeDetectorRef, @Optional() private directionality: Directionality) {}\n\n ngOnInit(): void {\n this.directionality.change?.pipe(takeUntil(this.destroy$)).subscribe((direction: Direction) => {\n this.dir = direction;\n this.cdr.detectChanges();\n });\n\n this.dir = this.directionality.value;\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n }\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { Directionality } from '@angular/cdk/bidi';\nimport { Platform } from '@angular/cdk/platform';\nimport {\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n EventEmitter,\n Input,\n NgZone,\n OnChanges,\n OnDestroy,\n OnInit,\n Optional,\n Output,\n SimpleChanges,\n ViewEncapsulation\n} from '@angular/core';\nimport { interval, Subscription } from 'rxjs';\n\nimport { NzStatisticComponent } from './statistic.component';\n\nconst REFRESH_INTERVAL = 1000 / 30;\n\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n selector: 'nz-countdown',\n exportAs: 'nzCountdown',\n template: `\n <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>\n `\n})\nexport class NzCountdownComponent extends NzStatisticComponent implements OnInit, OnChanges, OnDestroy {\n @Input() nzFormat: string = 'HH:mm:ss';\n @Output() readonly nzCountdownFinish = new EventEmitter<void>();\n\n diff!: number;\n\n private target: number = 0;\n private updater_?: Subscription | null;\n\n constructor(\n cdr: ChangeDetectorRef,\n private ngZone: NgZone,\n private platform: Platform,\n @Optional() directionality: Directionality\n ) {\n super(cdr, directionality);\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes.nzValue) {\n this.target = Number(changes.nzValue.currentValue);\n if (!changes.nzValue.isFirstChange()) {\n this.syncTimer();\n }\n }\n }\n\n override ngOnInit(): void {\n super.ngOnInit();\n this.syncTimer();\n }\n\n override ngOnDestroy(): void {\n this.stopTimer();\n }\n\n syncTimer(): void {\n if (this.target >= Date.now()) {\n this.startTimer();\n } else {\n this.stopTimer();\n }\n }\n\n startTimer(): void {\n if (this.platform.isBrowser) {\n this.ngZone.runOutsideAngular(() => {\n this.stopTimer();\n this.updater_ = interval(REFRESH_INTERVAL).subscribe(() => {\n this.updateValue();\n this.cdr.detectChanges();\n });\n });\n }\n }\n\n stopTimer(): void {\n if (this.updater_) {\n this.updater_.unsubscribe();\n this.updater_ = null;\n }\n }\n\n /**\n * Update time that should be displayed on the screen.\n */\n protected updateValue(): void {\n this.diff = Math.max(this.target - Date.now(), 0);\n\n if (this.diff === 0) {\n this.stopTimer();\n\n if (this.nzCountdownFinish.observers.length) {\n this.ngZone.run(() => this.nzCountdownFinish.emit());\n }\n }\n }\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { BidiModule } from '@angular/cdk/bidi';\nimport { PlatformModule } from '@angular/cdk/platform';\nimport { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\n\nimport { NzOutletModule } from 'ng-zorro-antd/core/outlet';\nimport { NzPipesModule as NzPipesModuleFromCore } from 'ng-zorro-antd/core/pipe';\n\nimport { NzCountdownComponent } from './countdown.component';\nimport { NzStatisticNumberComponent } from './statistic-number.component';\nimport { NzStatisticComponent } from './statistic.component';\n\n@NgModule({\n imports: [BidiModule, CommonModule, PlatformModule, NzOutletModule, NzPipesModuleFromCore],\n declarations: [NzStatisticComponent, NzCountdownComponent, NzStatisticNumberComponent],\n exports: [NzStatisticComponent, NzCountdownComponent, NzStatisticNumberComponent]\n})\nexport class NzStatisticModule {}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport * from './countdown.component';\nexport * from './statistic.component';\nexport * from './statistic.module';\nexport * from './statistic-number.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["NzPipesModuleFromCore"],"mappings":";;;;;;;;;;;;;;;AAAA;;;;MAuCa,0BAA0B;IAOrC,YAAuC,SAAiB;QAAjB,cAAS,GAAT,SAAS,CAAQ;QAHxD,eAAU,GAAG,EAAE,CAAC;QAChB,mBAAc,GAAG,EAAE,CAAC;KAEwC;IAE5D,WAAW;QACT,IAAI,CAAC,YAAY,EAAE,CAAC;KACrB;IAEO,YAAY;QAClB,MAAM,gBAAgB,GACpB,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,GAAG,GAAG,GAAG,qBAAqB,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QACvG,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAErD,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACtB,IAAI,CAAC,cAAc,GAAG,OAAO,GAAG,GAAG,gBAAgB,GAAG,OAAO,EAAE,GAAG,EAAE,CAAC;KACtE;;uHArBU,0BAA0B,kBAOjB,SAAS;2GAPlB,0BAA0B,qLAd3B;;;;;;;;;;;;GAYT;2FAEU,0BAA0B;kBApBtC,SAAS;mBAAC;oBACT,eAAe,EAAE,uBAAuB,C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