Skip to content

Commit 5af11ea

Browse files
feat(module:comment): support standalone component (#8266)
1 parent dc43fa5 commit 5af11ea

5 files changed

Lines changed: 33 additions & 29 deletions

File tree

‎components/comment/comment-cells.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,23 @@ import {
2121

2222
@Directive({
2323
selector: 'nz-avatar[nz-comment-avatar]',
24-
exportAs: 'nzCommentAvatar'
24+
exportAs: 'nzCommentAvatar',
25+
standalone: true
2526
})
2627
export class NzCommentAvatarDirective {}
2728

2829
@Directive({
2930
selector: 'nz-comment-content, [nz-comment-content]',
3031
exportAs: 'nzCommentContent',
31-
host: { class: 'ant-comment-content-detail' }
32+
host: { class: 'ant-comment-content-detail' },
33+
standalone: true
3234
})
3335
export class NzCommentContentDirective {}
3436

3537
@Directive({
3638
selector: '[nzCommentActionHost]',
37-
exportAs: 'nzCommentActionHost'
39+
exportAs: 'nzCommentActionHost',
40+
standalone: true
3841
})
3942
export class NzCommentActionHostDirective extends CdkPortalOutlet implements OnInit, OnDestroy, AfterViewInit {
4043
@Input() nzCommentActionHost?: TemplatePortal | null;
@@ -61,7 +64,8 @@ export class NzCommentActionHostDirective extends CdkPortalOutlet implements OnI
6164
exportAs: 'nzCommentAction',
6265
encapsulation: ViewEncapsulation.None,
6366
changeDetection: ChangeDetectionStrategy.OnPush,
64-
template: '<ng-template><ng-content></ng-content></ng-template>'
67+
template: '<ng-template><ng-content></ng-content></ng-template>',
68+
standalone: true
6569
})
6670
export class NzCommentActionComponent implements OnInit {
6771
@ViewChild(TemplateRef, { static: true }) implicitContent!: TemplateRef<void>;

‎components/comment/comment.component.ts‎

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

66
import { Direction, Directionality } from '@angular/cdk/bidi';
7+
import { NgForOf, NgIf } from '@angular/common';
78
import {
89
ChangeDetectionStrategy,
910
ChangeDetectorRef,
@@ -20,7 +21,9 @@ import {
2021
import { Subject } from 'rxjs';
2122
import { takeUntil } from 'rxjs/operators';
2223

23-
import { NzCommentActionComponent as CommentAction } from './comment-cells';
24+
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
25+
26+
import { NzCommentActionComponent as CommentAction, NzCommentActionHostDirective } from './comment-cells';
2427

2528
@Component({
2629
selector: 'nz-comment',
@@ -56,7 +59,9 @@ import { NzCommentActionComponent as CommentAction } from './comment-cells';
5659
host: {
5760
'[class.ant-comment]': `true`,
5861
'[class.ant-comment-rtl]': `dir === "rtl"`
59-
}
62+
},
63+
imports: [NgIf, NzOutletModule, NgForOf, NzCommentActionHostDirective],
64+
standalone: true
6065
})
6166
export class NzCommentComponent implements OnDestroy, OnInit {
6267
@Input() nzAuthor?: string | TemplateRef<void>;

‎components/comment/comment.module.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
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 { NzOutletModule } from 'ng-zorro-antd/core/outlet';
11-
128
import {
139
NzCommentActionComponent,
1410
NzCommentActionHostDirective,
@@ -25,8 +21,7 @@ const NZ_COMMENT_CELLS = [
2521
];
2622

2723
@NgModule({
28-
imports: [BidiModule, CommonModule, NzOutletModule],
29-
exports: [NzCommentComponent, ...NZ_COMMENT_CELLS],
30-
declarations: [NzCommentComponent, ...NZ_COMMENT_CELLS]
24+
imports: [NzCommentComponent, ...NZ_COMMENT_CELLS],
25+
exports: [NzCommentComponent, ...NZ_COMMENT_CELLS]
3126
})
3227
export class NzCommentModule {}

‎components/comment/doc/index.en-US.md‎

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

1919
## API
2020

21-
### nz-comment
21+
### nz-comment:standalone
2222

23-
| Property | Description | Type | Default |
24-
| -------- | ----------- | ---- | ------- |
25-
| [nzAuthor] | The element to display as the comment author | `string \| TemplateRef<void>` | - |
26-
| [nzDatetime] | A datetime element containing the time to be displayed | `string \| TemplateRef<void>` | - |
23+
| Property | Description | Type | Default |
24+
| ------------ | ------------------------------------------------------ | ----------------------------- | ------- |
25+
| [nzAuthor] | The element to display as the comment author | `string \| TemplateRef<void>` | - |
26+
| [nzDatetime] | A datetime element containing the time to be displayed | `string \| TemplateRef<void>` | - |
2727

28-
### [nz-comment-avatar]
28+
### [nz-comment-avatar]:standalone
2929

3030
The element to display as the comment avatar.
3131

32-
### nz-comment-content
32+
### nz-comment-content:standalone
3333

3434
The main content of the comment.
3535

36-
### nz-comment-action
36+
### nz-comment-action:standalone
3737

3838
The element items rendered below the comment content.

‎components/comment/doc/index.zh-CN.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ import { NzCommentModule } from 'ng-zorro-antd/comment';
1919

2020
## API
2121

22-
### nz-comment
22+
### nz-comment:standalone
2323

24-
| Property | Description | Type | Default |
25-
| -------- | ----------- | ---- | ------- |
26-
| [nzAuthor] | 显示评论的作者 | `string \| TemplateRef<void>` | - |
27-
| [nzDatetime] | 展示时间描述 | `string \| TemplateRef<void>` | - |
24+
| Property | Description | Type | Default |
25+
| ------------ | -------------- | ----------------------------- | ------- |
26+
| [nzAuthor] | 显示评论的作者 | `string \| TemplateRef<void>` | - |
27+
| [nzDatetime] | 展示时间描述 | `string \| TemplateRef<void>` | - |
2828

29-
### [nz-comment-avatar]
29+
### [nz-comment-avatar]:standalone
3030

3131
要显示为评论头像的元素。
3232

33-
### nz-comment-content
33+
### nz-comment-content:standalone
3434

3535
评论的主要内容。
3636

37-
### nz-comment-action
37+
### nz-comment-action:standalone
3838

3939
在评论内容下面呈现的操作项。

0 commit comments

Comments
 (0)