123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- import * as i0 from '@angular/core';
- import { inject, LOCALE_ID, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, ChangeDetectorRef, booleanAttribute, EventEmitter, Output, NgModule } from '@angular/core';
- import { Subject, interval } from 'rxjs';
- import * as i2$1 from 'ng-zorro-antd/core/pipe';
- import { NzPipesModule } from 'ng-zorro-antd/core/pipe';
- import { Directionality } from '@angular/cdk/bidi';
- import { takeUntil } from 'rxjs/operators';
- import * as i2 from 'ng-zorro-antd/core/outlet';
- import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
- import * as i1 from 'ng-zorro-antd/skeleton';
- import { NzSkeletonModule } from 'ng-zorro-antd/skeleton';
- import { getLocaleNumberSymbol, NumberSymbol, NgTemplateOutlet } from '@angular/common';
- import * as i1$1 from '@angular/cdk/platform';
- /**
- * 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
- */
- class NzStatisticNumberComponent {
- nzValue;
- nzValueTemplate;
- displayInt = '';
- displayDecimal = '';
- locale_id = inject(LOCALE_ID);
- ngOnChanges() {
- this.formatNumber();
- }
- formatNumber() {
- const decimalSeparator = typeof this.nzValue === 'number' ? '.' : getLocaleNumberSymbol(this.locale_id, NumberSymbol.Decimal);
- const value = String(this.nzValue);
- const [int, decimal] = value.split(decimalSeparator);
- this.displayInt = int;
- this.displayDecimal = decimal ? `${decimalSeparator}${decimal}` : '';
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzStatisticNumberComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzStatisticNumberComponent, isStandalone: true, selector: "nz-statistic-number", inputs: { nzValue: "nzValue", nzValueTemplate: "nzValueTemplate" }, exportAs: ["nzStatisticNumber"], usesOnChanges: true, ngImport: i0, template: `
- <span class="ant-statistic-content-value">
- @if (nzValueTemplate) {
- <ng-container
- [ngTemplateOutlet]="nzValueTemplate"
- [ngTemplateOutletContext]="{ $implicit: nzValue }"
- ></ng-container>
- } @else {
- @if (displayInt) {
- <span class="ant-statistic-content-value-int">{{ displayInt }}</span>
- }
- @if (displayDecimal) {
- <span class="ant-statistic-content-value-decimal">{{ displayDecimal }}</span>
- }
- }
- </span>
- `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzStatisticNumberComponent, decorators: [{
- type: Component,
- args: [{
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- preserveWhitespaces: false,
- selector: 'nz-statistic-number',
- exportAs: 'nzStatisticNumber',
- template: `
- <span class="ant-statistic-content-value">
- @if (nzValueTemplate) {
- <ng-container
- [ngTemplateOutlet]="nzValueTemplate"
- [ngTemplateOutletContext]="{ $implicit: nzValue }"
- ></ng-container>
- } @else {
- @if (displayInt) {
- <span class="ant-statistic-content-value-int">{{ displayInt }}</span>
- }
- @if (displayDecimal) {
- <span class="ant-statistic-content-value-decimal">{{ displayDecimal }}</span>
- }
- }
- </span>
- `,
- imports: [NgTemplateOutlet]
- }]
- }], propDecorators: { nzValue: [{
- type: Input
- }], nzValueTemplate: [{
- type: Input
- }] } });
- /**
- * 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
- */
- class NzStatisticComponent {
- nzPrefix;
- nzSuffix;
- nzTitle;
- nzValue;
- nzValueStyle = {};
- nzValueTemplate;
- nzLoading = false;
- dir = 'ltr';
- destroy$ = new Subject();
- cdr = inject(ChangeDetectorRef);
- directionality = inject(Directionality);
- ngOnInit() {
- this.directionality.change?.pipe(takeUntil(this.destroy$)).subscribe((direction) => {
- this.dir = direction;
- this.cdr.detectChanges();
- });
- this.dir = this.directionality.value;
- }
- ngOnDestroy() {
- this.destroy$.next();
- this.destroy$.complete();
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzStatisticComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzStatisticComponent, isStandalone: true, selector: "nz-statistic", inputs: { nzPrefix: "nzPrefix", nzSuffix: "nzSuffix", nzTitle: "nzTitle", nzValue: "nzValue", nzValueStyle: "nzValueStyle", nzValueTemplate: "nzValueTemplate", nzLoading: ["nzLoading", "nzLoading", booleanAttribute] }, host: { properties: { "class.ant-statistic-rtl": "dir === 'rtl'" }, classAttribute: "ant-statistic" }, exportAs: ["nzStatistic"], ngImport: i0, template: `
- <div class="ant-statistic-title">
- <ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
- </div>
- @if (nzLoading) {
- <nz-skeleton class="ant-statistic-skeleton" [nzParagraph]="false" />
- } @else {
- <div class="ant-statistic-content" [style]="nzValueStyle">
- @if (nzPrefix) {
- <span class="ant-statistic-content-prefix">
- <ng-container *nzStringTemplateOutlet="nzPrefix">{{ nzPrefix }}</ng-container>
- </span>
- }
- <nz-statistic-number [nzValue]="nzValue" [nzValueTemplate]="nzValueTemplate"></nz-statistic-number>
- @if (nzSuffix) {
- <span class="ant-statistic-content-suffix">
- <ng-container *nzStringTemplateOutlet="nzSuffix">{{ nzSuffix }}</ng-container>
- </span>
- }
- </div>
- }
- `, isInline: true, dependencies: [{ kind: "ngmodule", type: NzSkeletonModule }, { kind: "component", type: i1.NzSkeletonComponent, selector: "nz-skeleton", inputs: ["nzActive", "nzLoading", "nzRound", "nzTitle", "nzAvatar", "nzParagraph"], exportAs: ["nzSkeleton"] }, { kind: "component", type: NzStatisticNumberComponent, selector: "nz-statistic-number", inputs: ["nzValue", "nzValueTemplate"], exportAs: ["nzStatisticNumber"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i2.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzStatisticComponent, decorators: [{
- type: Component,
- args: [{
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- selector: 'nz-statistic',
- exportAs: 'nzStatistic',
- template: `
- <div class="ant-statistic-title">
- <ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
- </div>
- @if (nzLoading) {
- <nz-skeleton class="ant-statistic-skeleton" [nzParagraph]="false" />
- } @else {
- <div class="ant-statistic-content" [style]="nzValueStyle">
- @if (nzPrefix) {
- <span class="ant-statistic-content-prefix">
- <ng-container *nzStringTemplateOutlet="nzPrefix">{{ nzPrefix }}</ng-container>
- </span>
- }
- <nz-statistic-number [nzValue]="nzValue" [nzValueTemplate]="nzValueTemplate"></nz-statistic-number>
- @if (nzSuffix) {
- <span class="ant-statistic-content-suffix">
- <ng-container *nzStringTemplateOutlet="nzSuffix">{{ nzSuffix }}</ng-container>
- </span>
- }
- </div>
- }
- `,
- host: {
- class: 'ant-statistic',
- '[class.ant-statistic-rtl]': `dir === 'rtl'`
- },
- imports: [NzSkeletonModule, NzStatisticNumberComponent, NzOutletModule]
- }]
- }], propDecorators: { nzPrefix: [{
- type: Input
- }], nzSuffix: [{
- type: Input
- }], nzTitle: [{
- type: Input
- }], nzValue: [{
- type: Input
- }], nzValueStyle: [{
- type: Input
- }], nzValueTemplate: [{
- type: Input
- }], nzLoading: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }] } });
- const REFRESH_INTERVAL = 1000 / 30;
- class NzCountdownComponent extends NzStatisticComponent {
- ngZone;
- platform;
- nzFormat = 'HH:mm:ss';
- nzCountdownFinish = new EventEmitter();
- diff;
- target = 0;
- updater_;
- constructor(ngZone, platform) {
- super();
- this.ngZone = ngZone;
- this.platform = platform;
- }
- ngOnChanges(changes) {
- if (changes.nzValue) {
- this.target = Number(changes.nzValue.currentValue);
- if (!changes.nzValue.isFirstChange()) {
- this.syncTimer();
- }
- }
- }
- ngOnInit() {
- super.ngOnInit();
- this.syncTimer();
- }
- ngOnDestroy() {
- this.stopTimer();
- }
- syncTimer() {
- if (this.target >= Date.now()) {
- this.startTimer();
- }
- else {
- this.stopTimer();
- }
- }
- startTimer() {
- if (this.platform.isBrowser) {
- this.ngZone.runOutsideAngular(() => {
- this.stopTimer();
- this.updater_ = interval(REFRESH_INTERVAL).subscribe(() => {
- this.updateValue();
- this.cdr.detectChanges();
- });
- });
- }
- }
- stopTimer() {
- if (this.updater_) {
- this.updater_.unsubscribe();
- this.updater_ = null;
- }
- }
- /**
- * Update time that should be displayed on the screen.
- */
- updateValue() {
- this.diff = Math.max(this.target - Date.now(), 0);
- if (this.diff === 0) {
- this.stopTimer();
- if (this.nzCountdownFinish.observers.length) {
- this.ngZone.run(() => this.nzCountdownFinish.emit());
- }
- }
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCountdownComponent, deps: [{ token: i0.NgZone }, { token: i1$1.Platform }], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: NzCountdownComponent, isStandalone: true, selector: "nz-countdown", inputs: { nzFormat: "nzFormat" }, outputs: { nzCountdownFinish: "nzCountdownFinish" }, exportAs: ["nzCountdown"], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
- <nz-statistic
- [nzValue]="diff"
- [nzValueStyle]="nzValueStyle"
- [nzValueTemplate]="nzValueTemplate || countDownTpl"
- [nzTitle]="nzTitle"
- [nzPrefix]="nzPrefix"
- [nzSuffix]="nzSuffix"
- ></nz-statistic>
- <ng-template #countDownTpl>{{ diff | nzTimeRange: nzFormat }}</ng-template>
- `, isInline: true, dependencies: [{ kind: "component", type: NzStatisticComponent, selector: "nz-statistic", inputs: ["nzPrefix", "nzSuffix", "nzTitle", "nzValue", "nzValueStyle", "nzValueTemplate", "nzLoading"], exportAs: ["nzStatistic"] }, { kind: "ngmodule", type: NzPipesModule }, { kind: "pipe", type: i2$1.NzTimeRangePipe, name: "nzTimeRange" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCountdownComponent, decorators: [{
- type: Component,
- args: [{
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- selector: 'nz-countdown',
- exportAs: 'nzCountdown',
- template: `
- <nz-statistic
- [nzValue]="diff"
- [nzValueStyle]="nzValueStyle"
- [nzValueTemplate]="nzValueTemplate || countDownTpl"
- [nzTitle]="nzTitle"
- [nzPrefix]="nzPrefix"
- [nzSuffix]="nzSuffix"
- ></nz-statistic>
- <ng-template #countDownTpl>{{ diff | nzTimeRange: nzFormat }}</ng-template>
- `,
- imports: [NzStatisticComponent, NzPipesModule]
- }]
- }], ctorParameters: () => [{ type: i0.NgZone }, { type: i1$1.Platform }], propDecorators: { nzFormat: [{
- type: Input
- }], nzCountdownFinish: [{
- type: Output
- }] } });
- /**
- * 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
- */
- class NzStatisticModule {
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzStatisticModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: NzStatisticModule, imports: [NzStatisticComponent, NzCountdownComponent, NzStatisticNumberComponent], exports: [NzStatisticComponent, NzCountdownComponent, NzStatisticNumberComponent] });
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzStatisticModule, imports: [NzStatisticComponent, NzCountdownComponent] });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzStatisticModule, decorators: [{
- type: NgModule,
- args: [{
- imports: [NzStatisticComponent, NzCountdownComponent, NzStatisticNumberComponent],
- exports: [NzStatisticComponent, NzCountdownComponent, NzStatisticNumberComponent]
- }]
- }] });
- /**
- * 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
- */
- /**
- * Generated bundle index. Do not edit.
- */
- export { NzCountdownComponent, NzStatisticComponent, NzStatisticModule, NzStatisticNumberComponent };
- //# sourceMappingURL=ng-zorro-antd-statistic.mjs.map
|