Skip to content

Commit 186ef60

Browse files
feat(module:statistics): support standalone component (#8216)
1 parent a84ddef commit 186ef60

File tree

6 files changed

+76
-72
lines changed

6 files changed

+76
-72
lines changed

components/statistic/countdown.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import {
2222
} from '@angular/core';
2323
import { interval, Subscription } from 'rxjs';
2424

25+
import { NzPipesModule } from 'ng-zorro-antd/core/pipe';
26+
2527
import { NzStatisticComponent } from './statistic.component';
2628

2729
const REFRESH_INTERVAL = 1000 / 30;
@@ -42,7 +44,9 @@ const REFRESH_INTERVAL = 1000 / 30;
4244
></nz-statistic>
4345
4446
<ng-template #countDownTpl>{{ diff | nzTimeRange: nzFormat }}</ng-template>
45-
`
47+
`,
48+
imports: [NzStatisticComponent, NzPipesModule],
49+
standalone: true
4650
})
4751
export class NzCountdownComponent extends NzStatisticComponent implements OnInit, OnChanges, OnDestroy {
4852
@Input() nzFormat: string = 'HH:mm:ss';

components/statistic/doc/index.en-US.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,37 @@ import { NzStatisticModule } from 'ng-zorro-antd/statistic';
1818

1919
## API
2020

21-
### nz-statistic
22-
23-
| Property | Description | Type | Default |
24-
| -------- | ----------- | ---- | ------- |
25-
| `[nzPrefix]` | Prefix of Value | `string \| TemplateRef<void>` | - |
26-
| `[nzSuffix]` | Suffix of Value | `string \| TemplateRef<void>` | - |
27-
| `[nzTitle]` | Title | `string \| TemplateRef<void>` | - |
28-
| `[nzValue]` | Value | `string \| number` | - |
29-
| `[nzValueStyle]` | Value CSS style | `Object` | - |
30-
| `[nzValueTemplate]` | Custom template to render a number | `TemplateRef<{ $implicit: string \| number }>` | - |
31-
32-
### nz-countdown
33-
34-
| Property | Description | Type | Default |
35-
| -------- | ----------- | ---- | ------- |
36-
| `[nzFormat]` | Format string | `string` | `"HH:mm:ss"` |
37-
| `[nzPrefix]` | Prefix of Value | `string \| TemplateRef<void>` | - |
38-
| `[nzSuffix]` | Suffix of Value | `string \| TemplateRef<void>` | - |
39-
| `[nzTitle]` | Title | `string \| TemplateRef<void>` | - |
40-
| `[nzValue]` | Target time in timestamp form | `string \| number` | - |
41-
| `[nzValueTemplate]` | Custom template to render a time | `TemplateRef<{ $implicit: number }>` | - |
42-
| `(nzCountdownFinish)` | Emit when countdown finishes | `void` | - |
21+
### nz-statistic:standalone
22+
23+
| Property | Description | Type | Default |
24+
| ------------------- | ---------------------------------- | ---------------------------------------------- | ------- |
25+
| `[nzPrefix]` | Prefix of Value | `string \| TemplateRef<void>` | - |
26+
| `[nzSuffix]` | Suffix of Value | `string \| TemplateRef<void>` | - |
27+
| `[nzTitle]` | Title | `string \| TemplateRef<void>` | - |
28+
| `[nzValue]` | Value | `string \| number` | - |
29+
| `[nzValueStyle]` | Value CSS style | `Object` | - |
30+
| `[nzValueTemplate]` | Custom template to render a number | `TemplateRef<{ $implicit: string \| number }>` | - |
31+
32+
### nz-countdown:standalone
33+
34+
| Property | Description | Type | Default |
35+
| --------------------- | -------------------------------- | ------------------------------------ | ------------ |
36+
| `[nzFormat]` | Format string | `string` | `"HH:mm:ss"` |
37+
| `[nzPrefix]` | Prefix of Value | `string \| TemplateRef<void>` | - |
38+
| `[nzSuffix]` | Suffix of Value | `string \| TemplateRef<void>` | - |
39+
| `[nzTitle]` | Title | `string \| TemplateRef<void>` | - |
40+
| `[nzValue]` | Target time in timestamp form | `string \| number` | - |
41+
| `[nzValueTemplate]` | Custom template to render a time | `TemplateRef<{ $implicit: number }>` | - |
42+
| `(nzCountdownFinish)` | Emit when countdown finishes | `void` | - |
4343

4444
### nzFormat
4545

4646
| Token | Description |
47-
| -------- | ----------- |
48-
| `Y` | Year |
49-
| `M` | Month |
50-
| `D` | Date |
51-
| `H` | Hour |
52-
| `m` | Minute |
53-
| `s` | Second |
54-
| `S` | Millisecond |
47+
| ----- | ----------- |
48+
| `Y` | Year |
49+
| `M` | Month |
50+
| `D` | Date |
51+
| `H` | Hour |
52+
| `m` | Minute |
53+
| `s` | Second |
54+
| `S` | Millisecond |

components/statistic/doc/index.zh-CN.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,37 @@ import { NzStatisticModule } from 'ng-zorro-antd/statistic';
1919

2020
## API
2121

22-
### nz-statistic
23-
24-
| 参数 | 说明 | 类型 | 默认值 |
25-
| -------- | ----------- | ---- | ------- |
26-
| `[nzPrefix]` | 设置数值的前缀 | `string \| TemplateRef<void>` | - |
27-
| `[nzSuffix]` | 设置数值的后缀 | `string \| TemplateRef<void>` | - |
28-
| `[nzTitle]` | 数值的标题 | `string \| TemplateRef<void>` | - |
29-
| `[nzValue]` | 数值内容 | `string \| number` | - |
30-
| `[nzValueStyle]` | 设置数值的样式 | `Object` | - |
31-
| `[nzValueTemplate]` | 自定义数值展示 | `TemplateRef<{ $implicit: string \| number }>` | - |
32-
33-
### nz-countdown
34-
35-
| 参数 | 说明 | 类型 | 默认值 |
36-
| -------- | ----------- | ---- | ------- |
37-
| `[nzFormat]` | 格式化倒计时展示 | `string` | `"HH:mm:ss"` |
38-
| `[nzPrefix]` | 设置数值的前缀 | `string \| TemplateRef<void>` | - |
39-
| `[nzSuffix]` | 设置数值的后缀 | `string \| TemplateRef<void>` | - |
40-
| `[nzTitle]` | 数值的标题 | `string \| TemplateRef<void>` | - |
41-
| `[nzValue]` | 时间戳格式的目标时间 | `string \| number` | - |
42-
| `[nzValueTemplate]` | 自定义时间展示 | `TemplateRef<{ $implicit: number }>` | - |
43-
| `(nzCountdownFinish)` | 当倒计时完成时发出事件 | `void` | - |
22+
### nz-statistic:standalone
23+
24+
| 参数 | 说明 | 类型 | 默认值 |
25+
| ------------------- | -------------- | ---------------------------------------------- | ------ |
26+
| `[nzPrefix]` | 设置数值的前缀 | `string \| TemplateRef<void>` | - |
27+
| `[nzSuffix]` | 设置数值的后缀 | `string \| TemplateRef<void>` | - |
28+
| `[nzTitle]` | 数值的标题 | `string \| TemplateRef<void>` | - |
29+
| `[nzValue]` | 数值内容 | `string \| number` | - |
30+
| `[nzValueStyle]` | 设置数值的样式 | `Object` | - |
31+
| `[nzValueTemplate]` | 自定义数值展示 | `TemplateRef<{ $implicit: string \| number }>` | - |
32+
33+
### nz-countdown:standalone
34+
35+
| 参数 | 说明 | 类型 | 默认值 |
36+
| --------------------- | ---------------------- | ------------------------------------ | ------------ |
37+
| `[nzFormat]` | 格式化倒计时展示 | `string` | `"HH:mm:ss"` |
38+
| `[nzPrefix]` | 设置数值的前缀 | `string \| TemplateRef<void>` | - |
39+
| `[nzSuffix]` | 设置数值的后缀 | `string \| TemplateRef<void>` | - |
40+
| `[nzTitle]` | 数值的标题 | `string \| TemplateRef<void>` | - |
41+
| `[nzValue]` | 时间戳格式的目标时间 | `string \| number` | - |
42+
| `[nzValueTemplate]` | 自定义时间展示 | `TemplateRef<{ $implicit: number }>` | - |
43+
| `(nzCountdownFinish)` | 当倒计时完成时发出事件 | `void` | - |
4444

4545
### nzFormat
4646

4747
| 占位符 | 描述 |
48-
| -------- | ----------- |
49-
| `Y` ||
50-
| `M` ||
51-
| `D` ||
52-
| `H` ||
53-
| `m` ||
54-
| `s` ||
55-
| `S` | 毫秒 |
48+
| ------ | ---- |
49+
| `Y` | |
50+
| `M` | |
51+
| `D` | |
52+
| `H` | |
53+
| `m` | |
54+
| `s` | |
55+
| `S` | 毫秒 |

components/statistic/statistic-number.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
44
*/
55

6-
import { getLocaleNumberSymbol, NumberSymbol } from '@angular/common';
6+
import { getLocaleNumberSymbol, NgIf, NgTemplateOutlet, NumberSymbol } from '@angular/common';
77
import {
88
ChangeDetectionStrategy,
99
Component,
@@ -35,7 +35,9 @@ import { NzStatisticValueType } from './typings';
3535
<span *ngIf="displayDecimal" class="ant-statistic-content-value-decimal">{{ displayDecimal }}</span>
3636
</ng-container>
3737
</span>
38-
`
38+
`,
39+
imports: [NgIf, NgTemplateOutlet],
40+
standalone: true
3941
})
4042
export class NzStatisticNumberComponent implements OnChanges {
4143
@Input() nzValue?: NzStatisticValueType;

components/statistic/statistic.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import { Direction, Directionality } from '@angular/cdk/bidi';
7+
import { NgIf, NgStyle } from '@angular/common';
78
import {
89
ChangeDetectionStrategy,
910
ChangeDetectorRef,
@@ -18,8 +19,10 @@ import {
1819
import { Subject } from 'rxjs';
1920
import { takeUntil } from 'rxjs/operators';
2021

22+
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
2123
import { NgStyleInterface } from 'ng-zorro-antd/core/types';
2224

25+
import { NzStatisticNumberComponent } from './statistic-number.component';
2326
import { NzStatisticValueType } from './typings';
2427

2528
@Component({
@@ -44,7 +47,9 @@ import { NzStatisticValueType } from './typings';
4447
host: {
4548
class: 'ant-statistic',
4649
'[class.ant-statistic-rtl]': `dir === 'rtl'`
47-
}
50+
},
51+
imports: [NzStatisticNumberComponent, NgIf, NzOutletModule, NgStyle],
52+
standalone: true
4853
})
4954
export class NzStatisticComponent implements OnDestroy, OnInit {
5055
@Input() nzPrefix?: string | TemplateRef<void>;

components/statistic/statistic.module.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,14 @@
33
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
44
*/
55

6-
import { BidiModule } from '@angular/cdk/bidi';
7-
import { PlatformModule } from '@angular/cdk/platform';
8-
import { CommonModule } from '@angular/common';
96
import { NgModule } from '@angular/core';
107

11-
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
12-
import { NzPipesModule as NzPipesModuleFromCore } from 'ng-zorro-antd/core/pipe';
13-
148
import { NzCountdownComponent } from './countdown.component';
159
import { NzStatisticNumberComponent } from './statistic-number.component';
1610
import { NzStatisticComponent } from './statistic.component';
1711

1812
@NgModule({
19-
imports: [BidiModule, CommonModule, PlatformModule, NzOutletModule, NzPipesModuleFromCore],
20-
declarations: [NzStatisticComponent, NzCountdownComponent, NzStatisticNumberComponent],
13+
imports: [NzStatisticComponent, NzCountdownComponent, NzStatisticNumberComponent],
2114
exports: [NzStatisticComponent, NzCountdownComponent, NzStatisticNumberComponent]
2215
})
2316
export class NzStatisticModule {}

0 commit comments

Comments
 (0)