From 5af11ea0232c90d74607c9e4a9ffb053d0f0950c Mon Sep 17 00:00:00 2001
From: Parsa Arvaneh <62149413+ParsaArvanehPA@users.noreply.github.com>
Date: Mon, 4 Dec 2023 20:38:34 +0330
Subject: [PATCH] feat(module:comment): support standalone component (#8266)
---
components/comment/comment-cells.ts | 12 ++++++++----
components/comment/comment.component.ts | 9 +++++++--
components/comment/comment.module.ts | 9 ++-------
components/comment/doc/index.en-US.md | 16 ++++++++--------
components/comment/doc/index.zh-CN.md | 16 ++++++++--------
5 files changed, 33 insertions(+), 29 deletions(-)
diff --git a/components/comment/comment-cells.ts b/components/comment/comment-cells.ts
index 011ca974f6..356f41c332 100644
--- a/components/comment/comment-cells.ts
+++ b/components/comment/comment-cells.ts
@@ -21,20 +21,23 @@ import {
@Directive({
selector: 'nz-avatar[nz-comment-avatar]',
- exportAs: 'nzCommentAvatar'
+ exportAs: 'nzCommentAvatar',
+ standalone: true
})
export class NzCommentAvatarDirective {}
@Directive({
selector: 'nz-comment-content, [nz-comment-content]',
exportAs: 'nzCommentContent',
- host: { class: 'ant-comment-content-detail' }
+ host: { class: 'ant-comment-content-detail' },
+ standalone: true
})
export class NzCommentContentDirective {}
@Directive({
selector: '[nzCommentActionHost]',
- exportAs: 'nzCommentActionHost'
+ exportAs: 'nzCommentActionHost',
+ standalone: true
})
export class NzCommentActionHostDirective extends CdkPortalOutlet implements OnInit, OnDestroy, AfterViewInit {
@Input() nzCommentActionHost?: TemplatePortal | null;
@@ -61,7 +64,8 @@ export class NzCommentActionHostDirective extends CdkPortalOutlet implements OnI
exportAs: 'nzCommentAction',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
- template: ''
+ template: '',
+ standalone: true
})
export class NzCommentActionComponent implements OnInit {
@ViewChild(TemplateRef, { static: true }) implicitContent!: TemplateRef;
diff --git a/components/comment/comment.component.ts b/components/comment/comment.component.ts
index 42e008b466..d628548703 100644
--- a/components/comment/comment.component.ts
+++ b/components/comment/comment.component.ts
@@ -4,6 +4,7 @@
*/
import { Direction, Directionality } from '@angular/cdk/bidi';
+import { NgForOf, NgIf } from '@angular/common';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
@@ -20,7 +21,9 @@ import {
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
-import { NzCommentActionComponent as CommentAction } from './comment-cells';
+import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
+
+import { NzCommentActionComponent as CommentAction, NzCommentActionHostDirective } from './comment-cells';
@Component({
selector: 'nz-comment',
@@ -56,7 +59,9 @@ import { NzCommentActionComponent as CommentAction } from './comment-cells';
host: {
'[class.ant-comment]': `true`,
'[class.ant-comment-rtl]': `dir === "rtl"`
- }
+ },
+ imports: [NgIf, NzOutletModule, NgForOf, NzCommentActionHostDirective],
+ standalone: true
})
export class NzCommentComponent implements OnDestroy, OnInit {
@Input() nzAuthor?: string | TemplateRef;
diff --git a/components/comment/comment.module.ts b/components/comment/comment.module.ts
index 985724805c..a39519eccc 100644
--- a/components/comment/comment.module.ts
+++ b/components/comment/comment.module.ts
@@ -3,12 +3,8 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
-import { BidiModule } from '@angular/cdk/bidi';
-import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
-import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
-
import {
NzCommentActionComponent,
NzCommentActionHostDirective,
@@ -25,8 +21,7 @@ const NZ_COMMENT_CELLS = [
];
@NgModule({
- imports: [BidiModule, CommonModule, NzOutletModule],
- exports: [NzCommentComponent, ...NZ_COMMENT_CELLS],
- declarations: [NzCommentComponent, ...NZ_COMMENT_CELLS]
+ imports: [NzCommentComponent, ...NZ_COMMENT_CELLS],
+ exports: [NzCommentComponent, ...NZ_COMMENT_CELLS]
})
export class NzCommentModule {}
diff --git a/components/comment/doc/index.en-US.md b/components/comment/doc/index.en-US.md
index eb951565f3..1c5a12aed5 100644
--- a/components/comment/doc/index.en-US.md
+++ b/components/comment/doc/index.en-US.md
@@ -18,21 +18,21 @@ import { NzCommentModule } from 'ng-zorro-antd/comment';
## API
-### nz-comment
+### nz-comment:standalone
-| Property | Description | Type | Default |
-| -------- | ----------- | ---- | ------- |
-| [nzAuthor] | The element to display as the comment author | `string \| TemplateRef` | - |
-| [nzDatetime] | A datetime element containing the time to be displayed | `string \| TemplateRef` | - |
+| Property | Description | Type | Default |
+| ------------ | ------------------------------------------------------ | ----------------------------- | ------- |
+| [nzAuthor] | The element to display as the comment author | `string \| TemplateRef` | - |
+| [nzDatetime] | A datetime element containing the time to be displayed | `string \| TemplateRef` | - |
-### [nz-comment-avatar]
+### [nz-comment-avatar]:standalone
The element to display as the comment avatar.
-### nz-comment-content
+### nz-comment-content:standalone
The main content of the comment.
-### nz-comment-action
+### nz-comment-action:standalone
The element items rendered below the comment content.
diff --git a/components/comment/doc/index.zh-CN.md b/components/comment/doc/index.zh-CN.md
index f18969130f..15822bb3f2 100644
--- a/components/comment/doc/index.zh-CN.md
+++ b/components/comment/doc/index.zh-CN.md
@@ -19,21 +19,21 @@ import { NzCommentModule } from 'ng-zorro-antd/comment';
## API
-### nz-comment
+### nz-comment:standalone
-| Property | Description | Type | Default |
-| -------- | ----------- | ---- | ------- |
-| [nzAuthor] | 显示评论的作者 | `string \| TemplateRef` | - |
-| [nzDatetime] | 展示时间描述 | `string \| TemplateRef` | - |
+| Property | Description | Type | Default |
+| ------------ | -------------- | ----------------------------- | ------- |
+| [nzAuthor] | 显示评论的作者 | `string \| TemplateRef` | - |
+| [nzDatetime] | 展示时间描述 | `string \| TemplateRef` | - |
-### [nz-comment-avatar]
+### [nz-comment-avatar]:standalone
要显示为评论头像的元素。
-### nz-comment-content
+### nz-comment-content:standalone
评论的主要内容。
-### nz-comment-action
+### nz-comment-action:standalone
在评论内容下面呈现的操作项。