Skip to content

Commit 63b8777

Browse files
feat(module:image): support standalone component (#8200)
1 parent 125768c commit 63b8777

File tree

6 files changed

+19
-21
lines changed

6 files changed

+19
-21
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { NzImageModule } from 'ng-zorro-antd/image';
1818

1919
## API
2020

21-
### [nz-image]
21+
### [nz-image]:standalone
2222

2323
| Property | Description | Type | Default | Global Config |
2424
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ------- | ------------- |
@@ -71,7 +71,7 @@ Other attributes [<img\>](https://developer.mozilla.org/en-US/docs/Web/HTML/Elem
7171
| next(): void | Next image |
7272
| close(): void | Close image preview |
7373

74-
### NzImageGroupComponent
74+
### NzImageGroupComponent:standalone
7575

7676
| Property | Description | Type | Default |
7777
| ----------- | ------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { NzImageModule } from 'ng-zorro-antd/image';
1919

2020
## API
2121

22-
### [nz-image]
22+
### [nz-image]:standalone
2323

2424
| 参数 | 说明 | 类型 | 默认值 | 支持全局配置 |
2525
| ------------------- | -------------------------------------------------------------------------------------------------------- | ----------- | ------- | ------------ |
@@ -72,8 +72,8 @@ import { NzImageModule } from 'ng-zorro-antd/image';
7272
| next(): void | 下一张 |
7373
| close(): void | 关闭预览 |
7474

75-
### NzImageGroupComponent
75+
### NzImageGroupComponent:standalone
7676

77-
| 名称 | 描述 | 类型 | 默认值 |
78-
| ----------- | ------------------------------------------------------------------------------------------------------------------------------ |----------|---|
79-
| nzScaleStep | `1 + nzScaleStep` 为缩放放大的每步倍数 | `number` | - |
77+
| 名称 | 描述 | 类型 | 默认值 |
78+
| ----------- | -------------------------------------- | -------- | ------ |
79+
| nzScaleStep | `1 + nzScaleStep` 为缩放放大的每步倍数 | `number` | - |

components/image/image-group.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import { NzImageDirective } from './image.directive';
1313
template: '<ng-content></ng-content>',
1414
preserveWhitespaces: false,
1515
changeDetection: ChangeDetectionStrategy.OnPush,
16-
encapsulation: ViewEncapsulation.None
16+
encapsulation: ViewEncapsulation.None,
17+
standalone: true
1718
})
1819
export class NzImageGroupComponent {
1920
@Input() nzScaleStep: number | null = null;

components/image/image-preview.component.ts

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

66
import { AnimationEvent } from '@angular/animations';
7+
import { CdkDrag, CdkDragHandle } from '@angular/cdk/drag-drop';
78
import { OverlayRef } from '@angular/cdk/overlay';
9+
import { NgForOf, NgIf } from '@angular/common';
810
import {
911
ChangeDetectionStrategy,
1012
ChangeDetectorRef,
@@ -25,11 +27,12 @@ import { NzConfigService } from 'ng-zorro-antd/core/config';
2527
import { NzDestroyService } from 'ng-zorro-antd/core/services';
2628
import { NzSafeAny } from 'ng-zorro-antd/core/types';
2729
import { isNotNil } from 'ng-zorro-antd/core/util';
30+
import { NzIconModule } from 'ng-zorro-antd/icon';
2831

2932
import { FADE_CLASS_NAME_MAP, NZ_CONFIG_MODULE_NAME } from './image-config';
3033
import { NzImage, NzImagePreviewOptions } from './image-preview-options';
3134
import { NzImagePreviewRef } from './image-preview-ref';
32-
import { NzImageUrl, NzImageScaleStep } from './image.directive';
35+
import { NzImageScaleStep, NzImageUrl } from './image.directive';
3336
import { getClientSize, getFitContentPosition, getOffset } from './utils';
3437

3538
export interface NzImageContainerOperation {
@@ -52,6 +55,7 @@ const NZ_DEFAULT_ROTATE = 0;
5255
selector: 'nz-image-preview',
5356
exportAs: 'nzImagePreview',
5457
animations: [fadeMotion],
58+
standalone: true,
5559
template: `
5660
<div class="ant-image-preview">
5761
<div tabindex="0" aria-hidden="true" style="width: 0; height: 0; overflow: hidden; outline: none;"></div>
@@ -125,6 +129,7 @@ const NZ_DEFAULT_ROTATE = 0;
125129
tabindex: '-1',
126130
role: 'document'
127131
},
132+
imports: [NgForOf, NzIconModule, CdkDragHandle, CdkDrag, NgIf],
128133
providers: [NzDestroyService]
129134
})
130135
export class NzImagePreviewComponent implements OnInit {

components/image/image.directive.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export type NzImageScaleStep = number;
3939
exportAs: 'nzImage',
4040
host: {
4141
'(click)': 'onPreview()'
42-
}
42+
},
43+
standalone: true
4344
})
4445
export class NzImageDirective implements OnInit, OnChanges, OnDestroy {
4546
readonly _nzModuleName: NzConfigKey = NZ_CONFIG_MODULE_NAME;

components/image/image.module.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,16 @@
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 { DragDropModule } from '@angular/cdk/drag-drop';
8-
import { OverlayModule } from '@angular/cdk/overlay';
9-
import { PortalModule } from '@angular/cdk/portal';
10-
import { CommonModule } from '@angular/common';
116
import { NgModule } from '@angular/core';
127

13-
import { NzIconModule } from 'ng-zorro-antd/icon';
14-
import { NzPipesModule } from 'ng-zorro-antd/pipes';
15-
168
import { NzImageGroupComponent } from './image-group.component';
179
import { NzImagePreviewComponent } from './image-preview.component';
1810
import { NzImageDirective } from './image.directive';
1911
import { NzImageService } from './image.service';
2012

2113
@NgModule({
22-
imports: [BidiModule, OverlayModule, PortalModule, DragDropModule, CommonModule, NzIconModule, NzPipesModule],
14+
imports: [NzImageDirective, NzImagePreviewComponent, NzImageGroupComponent],
2315
exports: [NzImageDirective, NzImagePreviewComponent, NzImageGroupComponent],
24-
providers: [NzImageService],
25-
declarations: [NzImageDirective, NzImagePreviewComponent, NzImageGroupComponent]
16+
providers: [NzImageService]
2617
})
2718
export class NzImageModule {}

0 commit comments

Comments
 (0)