Skip to content

Commit 90edba6

Browse files
feat(module:rate): support standalone component (#8226)
1 parent 7cd08ae commit 90edba6

File tree

5 files changed

+57
-53
lines changed

5 files changed

+57
-53
lines changed

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,27 @@ import { NzRateModule } from 'ng-zorro-antd/rate';
1818

1919
## API
2020

21-
### nz-rate
22-
23-
| Property | Description | type | Default | Global Config |
24-
| -------- | ----------- | ---- | ------- | ------------- |
25-
| `[nzAllowClear]` | whether to allow clear when click again | `boolean` | `true` ||
26-
| `[nzAllowHalf]` | whether to allow semi selection | `boolean` | `false` ||
27-
| `[nzAutoFocus]` | get focus when component mounted | `boolean` | `false` |
28-
| `[nzCharacter]` | custom character of rate | `TemplateRef<void>` | `<span nz-icon nzType="star"></span>` |
29-
| `[nzCount]` | star count | `number` | `5` |
30-
| `[nzDisabled]` | read only, unable to interact | `boolean` | `false` |
31-
| `[nzTooltips]` | Customize tooltip by each character | `string[]` | `[]` |
32-
| `[ngModel]` | current value , double binding | `number` | - |
33-
| `(ngModelChange)` | callback when select value | `EventEmitter<number>` | - |
34-
| `(nzOnBlur)` | callback when component lose focus | `EventEmitter<FocusEvent>` | - |
35-
| `(nzOnFocus)` | callback when component get focus | `EventEmitter<FocusEvent>` | - |
36-
| `(nzOnHoverChange)` | callback when hover item | `EventEmitter<number>` | - |
37-
| `(nzOnKeyDown)` | callback when keydown on component | `EventEmitter<KeyboardEvent>` | - |
21+
### nz-rate:standalone
22+
23+
| Property | Description | type | Default | Global Config |
24+
| ------------------- | --------------------------------------- | ----------------------------- | ------------------------------------- | ------------- |
25+
| `[nzAllowClear]` | whether to allow clear when click again | `boolean` | `true` | |
26+
| `[nzAllowHalf]` | whether to allow semi selection | `boolean` | `false` | |
27+
| `[nzAutoFocus]` | get focus when component mounted | `boolean` | `false` |
28+
| `[nzCharacter]` | custom character of rate | `TemplateRef<void>` | `<span nz-icon nzType="star"></span>` |
29+
| `[nzCount]` | star count | `number` | `5` |
30+
| `[nzDisabled]` | read only, unable to interact | `boolean` | `false` |
31+
| `[nzTooltips]` | Customize tooltip by each character | `string[]` | `[]` |
32+
| `[ngModel]` | current value , double binding | `number` | - |
33+
| `(ngModelChange)` | callback when select value | `EventEmitter<number>` | - |
34+
| `(nzOnBlur)` | callback when component lose focus | `EventEmitter<FocusEvent>` | - |
35+
| `(nzOnFocus)` | callback when component get focus | `EventEmitter<FocusEvent>` | - |
36+
| `(nzOnHoverChange)` | callback when hover item | `EventEmitter<number>` | - |
37+
| `(nzOnKeyDown)` | callback when keydown on component | `EventEmitter<KeyboardEvent>` | - |
3838

3939
#### Methods
4040

41-
| Name | Description |
42-
| ---- | ----------- |
43-
| blur() | remove focus |
44-
| focus() | get focus |
41+
| Name | Description |
42+
| ------- | ------------ |
43+
| blur() | remove focus |
44+
| focus() | get focus |

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ import { NzRateModule } from 'ng-zorro-antd/rate';
1919

2020
## API
2121

22-
### nz-rate
23-
24-
| 属性 | 说明 | 类型 | 默认值 | 支持全局配置 |
25-
| --- | --- | --- | --- | --- |
26-
| `[nzAllowClear]` | 是否允许再次点击后清除 | `boolean` | `true` ||
27-
| `[nzAllowHalf]` | 是否允许半选 | `boolean` | `false` ||
28-
| `[nzAutoFocus]` | 自动获取焦点 | `boolean` | `false` |
29-
| `[nzCharacter]` | 自定义字符 | `TemplateRef<void>` | `<span nz-icon nzType="star"></span>` |
30-
| `[nzCount]` | star 总数 | `number` | `5` |
31-
| `[nzDisabled]` | 只读,无法进行交互 | `boolean` | `false` |
32-
| `[nzTooltips]` | 自定义每项的提示信息 | `string[]` | `[]` |
33-
| `[ngModel]` | 当前数,可以双向绑定 | `number` | `0` |
34-
| `(ngModelChange)` | 当前数改变时的回调 | `EventEmitter<number>` | - |
35-
| `(nzOnBlur)` | 失去焦点时的回调 | `EventEmitter<FocusEvent>` | - |
36-
| `(nzOnFocus)` | 获取焦点时的回调 | `EventEmitter<FocusEvent>` | - |
37-
| `(nzOnHoverChange)` | 鼠标经过时数值变化的回调 | `EventEmitter<number>` | - |
38-
| `(nzOnKeyDown)` | 按键回调 | `EventEmitter<KeyboardEvent>` | - |
22+
### nz-rate:standalone
23+
24+
| 属性 | 说明 | 类型 | 默认值 | 支持全局配置 |
25+
| ------------------- | ------------------------ | ----------------------------- | ------------------------------------- | ------------ |
26+
| `[nzAllowClear]` | 是否允许再次点击后清除 | `boolean` | `true` | |
27+
| `[nzAllowHalf]` | 是否允许半选 | `boolean` | `false` | |
28+
| `[nzAutoFocus]` | 自动获取焦点 | `boolean` | `false` |
29+
| `[nzCharacter]` | 自定义字符 | `TemplateRef<void>` | `<span nz-icon nzType="star"></span>` |
30+
| `[nzCount]` | star 总数 | `number` | `5` |
31+
| `[nzDisabled]` | 只读,无法进行交互 | `boolean` | `false` |
32+
| `[nzTooltips]` | 自定义每项的提示信息 | `string[]` | `[]` |
33+
| `[ngModel]` | 当前数,可以双向绑定 | `number` | `0` |
34+
| `(ngModelChange)` | 当前数改变时的回调 | `EventEmitter<number>` | - |
35+
| `(nzOnBlur)` | 失去焦点时的回调 | `EventEmitter<FocusEvent>` | - |
36+
| `(nzOnFocus)` | 获取焦点时的回调 | `EventEmitter<FocusEvent>` | - |
37+
| `(nzOnHoverChange)` | 鼠标经过时数值变化的回调 | `EventEmitter<number>` | - |
38+
| `(nzOnKeyDown)` | 按键回调 | `EventEmitter<KeyboardEvent>` | - |
3939

4040
#### 方法
4141

42-
| 名称 | 描述 |
43-
| --- | --- |
44-
| blur() | 移除焦点 |
42+
| 名称 | 描述 |
43+
| ------- | -------- |
44+
| blur() | 移除焦点 |
4545
| focus() | 获取焦点 |

components/rate/rate-item.component.ts

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

6+
import { NgTemplateOutlet } from '@angular/common';
67
import {
78
ChangeDetectionStrategy,
89
Component,
@@ -15,6 +16,7 @@ import {
1516

1617
import { BooleanInput } from 'ng-zorro-antd/core/types';
1718
import { InputBoolean } from 'ng-zorro-antd/core/util';
19+
import { NzIconModule } from 'ng-zorro-antd/icon';
1820

1921
@Component({
2022
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -42,7 +44,9 @@ import { InputBoolean } from 'ng-zorro-antd/core/util';
4244
<ng-template #defaultCharacter>
4345
<span nz-icon nzType="star" nzTheme="fill"></span>
4446
</ng-template>
45-
`
47+
`,
48+
imports: [NgTemplateOutlet, NzIconModule],
49+
standalone: true
4650
})
4751
export class NzRateItemComponent {
4852
static ngAcceptInputType_allowHalf: BooleanInput;

components/rate/rate.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
import { Direction, Directionality } from '@angular/cdk/bidi';
77
import { LEFT_ARROW, RIGHT_ARROW } from '@angular/cdk/keycodes';
8+
import { NgClass, NgForOf } from '@angular/common';
89
import {
910
ChangeDetectionStrategy,
1011
ChangeDetectorRef,
1112
Component,
1213
ElementRef,
1314
EventEmitter,
15+
forwardRef,
1416
Input,
1517
NgZone,
1618
OnChanges,
@@ -21,8 +23,7 @@ import {
2123
SimpleChanges,
2224
TemplateRef,
2325
ViewChild,
24-
ViewEncapsulation,
25-
forwardRef
26+
ViewEncapsulation
2627
} from '@angular/core';
2728
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
2829
import { fromEvent } from 'rxjs';
@@ -32,6 +33,9 @@ import { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/con
3233
import { NzDestroyService } from 'ng-zorro-antd/core/services';
3334
import { BooleanInput, NgClassType, NumberInput } from 'ng-zorro-antd/core/types';
3435
import { InputBoolean, InputNumber } from 'ng-zorro-antd/core/util';
36+
import { NzToolTipModule } from 'ng-zorro-antd/tooltip';
37+
38+
import { NzRateItemComponent } from './rate-item.component';
3539

3640
const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'rate';
3741

@@ -77,7 +81,9 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'rate';
7781
useExisting: forwardRef(() => NzRateComponent),
7882
multi: true
7983
}
80-
]
84+
],
85+
imports: [NgClass, NgForOf, NzToolTipModule, NzRateItemComponent, NzToolTipModule],
86+
standalone: true
8187
})
8288
export class NzRateComponent implements OnInit, ControlValueAccessor, OnChanges {
8389
readonly _nzModuleName: NzConfigKey = NZ_CONFIG_MODULE_NAME;

components/rate/rate.module.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,13 @@
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 { CommonModule } from '@angular/common';
86
import { NgModule } from '@angular/core';
97

10-
import { NzIconModule } from 'ng-zorro-antd/icon';
11-
import { NzToolTipModule } from 'ng-zorro-antd/tooltip';
12-
138
import { NzRateItemComponent } from './rate-item.component';
149
import { NzRateComponent } from './rate.component';
1510

1611
@NgModule({
17-
exports: [NzRateComponent],
18-
declarations: [NzRateComponent, NzRateItemComponent],
19-
imports: [BidiModule, CommonModule, NzIconModule, NzToolTipModule]
12+
imports: [NzRateComponent, NzRateItemComponent],
13+
exports: [NzRateComponent]
2014
})
2115
export class NzRateModule {}

0 commit comments

Comments
 (0)