Skip to content

Commit 125768c

Browse files
feat(module:tooltip): support standalone component (#8209)
1 parent 90edba6 commit 125768c

4 files changed

Lines changed: 54 additions & 55 deletions

File tree

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

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

1919
## API
2020

21-
### [nz-tooltip]
22-
23-
| Property | Description | Type | Default |
24-
| -------- | ----------- | ---- | ------- |
25-
| `[nzTooltipArrowPointAtCenter]` | Arrow point at center of the origin | `boolean` | `false` |
26-
| `[nzTooltipTitle]` | The text shown in the tooltip | `string \| TemplateRef<void>` | - |
27-
| `[nzTooltipTitleContext]` | The context of tooltip title | `object` | - |
28-
| `[nzTooltipTrigger]` | Tooltip trigger mode. If set to `null` it would not be triggered | `'click' \| 'focus' \| 'hover' \| null` | `'hover'` |
29-
| `[nzTooltipPlacement]` | The position of the tooltip relative to the target | `'top' \| 'left' \| 'right' \| 'bottom' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight' \| 'leftTop' \| 'leftBottom' \| 'rightTop' \| 'rightBottom' \| Array<string>` | `'top'` |
30-
| `[nzTooltipColor]` | The background color | `string` | - |
31-
| `[nzTooltipOrigin]` | Origin of the tooltip | `ElementRef` | - |
32-
| `[nzTooltipVisible]` | Show or hide tooltip | `boolean` | `false` |
33-
| `(nzTooltipVisibleChange)` | Callback of hide or show | `EventEmitter<boolean>` | - |
34-
| `[nzTooltipMouseEnterDelay]` | Delay in seconds, before tooltip is shown on mouse enter | `number` | `0.15` |
35-
| `[nzTooltipMouseLeaveDelay]` | Delay in seconds, before tooltip is hidden on mouse leave | `number` | `0.1` |
36-
| `[nzTooltipOverlayClassName]` | Class name of the tooltip card | `string` | - |
37-
| `[nzTooltipOverlayStyle]` | Style of the tooltip card | `object` | - |
21+
### [nz-tooltip]:standalone
22+
23+
| Property | Description | Type | Default |
24+
| ------------------------------- | ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
25+
| `[nzTooltipArrowPointAtCenter]` | Arrow point at center of the origin | `boolean` | `false` |
26+
| `[nzTooltipTitle]` | The text shown in the tooltip | `string \| TemplateRef<void>` | - |
27+
| `[nzTooltipTitleContext]` | The context of tooltip title | `object` | - |
28+
| `[nzTooltipTrigger]` | Tooltip trigger mode. If set to `null` it would not be triggered | `'click' \| 'focus' \| 'hover' \| null` | `'hover'` |
29+
| `[nzTooltipPlacement]` | The position of the tooltip relative to the target | `'top' \| 'left' \| 'right' \| 'bottom' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight' \| 'leftTop' \| 'leftBottom' \| 'rightTop' \| 'rightBottom' \| Array<string>` | `'top'` |
30+
| `[nzTooltipColor]` | The background color | `string` | - |
31+
| `[nzTooltipOrigin]` | Origin of the tooltip | `ElementRef` | - |
32+
| `[nzTooltipVisible]` | Show or hide tooltip | `boolean` | `false` |
33+
| `(nzTooltipVisibleChange)` | Callback of hide or show | `EventEmitter<boolean>` | - |
34+
| `[nzTooltipMouseEnterDelay]` | Delay in seconds, before tooltip is shown on mouse enter | `number` | `0.15` |
35+
| `[nzTooltipMouseLeaveDelay]` | Delay in seconds, before tooltip is hidden on mouse leave | `number` | `0.1` |
36+
| `[nzTooltipOverlayClassName]` | Class name of the tooltip card | `string` | - |
37+
| `[nzTooltipOverlayStyle]` | Style of the tooltip card | `object` | - |
3838

3939
### Common API
4040

4141
The following APIs are shared by `nz-tooltip`, `nz-popconfirm`, `nz-popover`.
4242

43-
| Method | Description |
44-
| --- | --- |
45-
| `show` | Show |
46-
| `hide` | Hide |
43+
| Method | Description |
44+
| ---------------- | --------------- |
45+
| `show` | Show |
46+
| `hide` | Hide |
4747
| `updatePosition` | Update position |
4848

4949
## Exclude body element's scroll event need to refresh the position of CDK

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,32 @@ import { NzToolTipModule } from 'ng-zorro-antd/tooltip';
2020

2121
## API
2222

23-
### [nz-tooltip]
24-
25-
| 参数 | 说明 | 类型 | 默认值 |
26-
| --- | --- | --- | --- |
27-
| `[nzTooltipArrowPointAtCenter]` | 箭头指向锚点的中心 | `boolean` | `false` |
28-
| `[nzTooltipTitle]` | 提示文字 | `string \| TemplateRef<void>` | - |
29-
| `[nzTooltipTitleContext]` | 提示文字模板上下文 | `object` | - |
30-
| `[nzTooltipTrigger]` | 触发行为,可选 `hover` \| `focus` \| `click`,为 `null` 时不响应光标事件 | `'click' \| 'focus' \| 'hover' \| null` | `'hover'` |
31-
| `[nzTooltipPlacement]` | 气泡框位置 | `'top' \| 'left' \| 'right' \| 'bottom' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight' \| 'leftTop' \| 'leftBottom' \| 'rightTop' \| 'rightBottom' \| Array<string>` | `'top'` |
32-
| `[nzTooltipColor]` | 背景颜色 | `string` | - |
33-
| `[nzTooltipOrigin]` | 气泡框定位元素 | `ElementRef` | - |
34-
| `[nzTooltipVisible]` | 显示隐藏气泡框 | `boolean` | `false` |
35-
| `(nzTooltipVisibleChange)` | 显示隐藏的事件 | `EventEmitter<boolean>` | - |
36-
| `[nzTooltipMouseEnterDelay]` | 鼠标移入后延时多少才显示 Tooltip,单位:秒 | `number` | `0.15` |
37-
| `[nzTooltipMouseLeaveDelay]` | 鼠标移出后延时多少才隐藏 Tooltip,单位:秒 | `number` | `0.1` |
38-
| `[nzTooltipOverlayClassName]` | 卡片类名 | `string` | - |
39-
| `[nzTooltipOverlayStyle]` | 卡片样式 | `object` | - |
23+
### [nz-tooltip]:standalone
24+
25+
| 参数 | 说明 | 类型 | 默认值 |
26+
| ------------------------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
27+
| `[nzTooltipArrowPointAtCenter]` | 箭头指向锚点的中心 | `boolean` | `false` |
28+
| `[nzTooltipTitle]` | 提示文字 | `string \| TemplateRef<void>` | - |
29+
| `[nzTooltipTitleContext]` | 提示文字模板上下文 | `object` | - |
30+
| `[nzTooltipTrigger]` | 触发行为,可选 `hover` \| `focus` \| `click`,为 `null` 时不响应光标事件 | `'click' \| 'focus' \| 'hover' \| null` | `'hover'` |
31+
| `[nzTooltipPlacement]` | 气泡框位置 | `'top' \| 'left' \| 'right' \| 'bottom' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight' \| 'leftTop' \| 'leftBottom' \| 'rightTop' \| 'rightBottom' \| Array<string>` | `'top'` |
32+
| `[nzTooltipColor]` | 背景颜色 | `string` | - |
33+
| `[nzTooltipOrigin]` | 气泡框定位元素 | `ElementRef` | - |
34+
| `[nzTooltipVisible]` | 显示隐藏气泡框 | `boolean` | `false` |
35+
| `(nzTooltipVisibleChange)` | 显示隐藏的事件 | `EventEmitter<boolean>` | - |
36+
| `[nzTooltipMouseEnterDelay]` | 鼠标移入后延时多少才显示 Tooltip,单位:秒 | `number` | `0.15` |
37+
| `[nzTooltipMouseLeaveDelay]` | 鼠标移出后延时多少才隐藏 Tooltip,单位:秒 | `number` | `0.1` |
38+
| `[nzTooltipOverlayClassName]` | 卡片类名 | `string` | - |
39+
| `[nzTooltipOverlayStyle]` | 卡片样式 | `object` | - |
4040

4141
### 共同的 API
4242

4343
以下 API 为 `nz-tooltip`、`nz-popconfirm`、`nz-popover` 共享的 API。
4444

45-
| 方法 | 说明 |
46-
| --- | --- |
47-
| `show` | 打开 |
48-
| `hide` | 隐藏 |
45+
| 方法 | 说明 |
46+
| ---------------- | -------- |
47+
| `show` | 打开 |
48+
| `hide` | 隐藏 |
4949
| `updatePosition` | 调整位置 |
5050

5151
## 非 body 滚轴事件需要更新 CDK 的位置

‎components/tooltip/tooltip.module.ts‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +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 { OverlayModule } from '@angular/cdk/overlay';
8-
import { CommonModule } from '@angular/common';
96
import { NgModule } from '@angular/core';
107

11-
import { NzNoAnimationModule } from 'ng-zorro-antd/core/no-animation';
12-
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
13-
import { NzOverlayModule } from 'ng-zorro-antd/core/overlay';
14-
158
// NOTE: the `t` is not uppercase in directives. Change this would however introduce breaking change.
169
import { NzToolTipComponent, NzTooltipDirective } from './tooltip';
1710

1811
@NgModule({
19-
declarations: [NzToolTipComponent, NzTooltipDirective],
20-
exports: [NzToolTipComponent, NzTooltipDirective],
21-
imports: [BidiModule, CommonModule, OverlayModule, NzOutletModule, NzOverlayModule, NzNoAnimationModule]
12+
imports: [NzToolTipComponent, NzTooltipDirective],
13+
exports: [NzToolTipComponent, NzTooltipDirective]
2214
})
2315
export class NzToolTipModule {}

‎components/tooltip/tooltip.ts‎

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

66
import { Directionality } from '@angular/cdk/bidi';
7+
import { OverlayModule } from '@angular/cdk/overlay';
8+
import { NgClass, NgStyle } from '@angular/common';
79
import {
810
ChangeDetectionStrategy,
911
ChangeDetectorRef,
@@ -24,7 +26,9 @@ import {
2426

2527
import { zoomBigMotion } from 'ng-zorro-antd/core/animation';
2628
import { isPresetColor, NzPresetColor } from 'ng-zorro-antd/core/color';
27-
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
29+
import { NzNoAnimationDirective, NzNoAnimationModule } from 'ng-zorro-antd/core/no-animation';
30+
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
31+
import { NzOverlayModule } from 'ng-zorro-antd/core/overlay';
2832
import { BooleanInput, NgStyleInterface, NzTSType } from 'ng-zorro-antd/core/types';
2933
import { InputBoolean } from 'ng-zorro-antd/core/util';
3034

@@ -41,7 +45,8 @@ import {
4145
exportAs: 'nzTooltip',
4246
host: {
4347
'[class.ant-tooltip-open]': 'visible'
44-
}
48+
},
49+
standalone: true
4550
})
4651
export class NzTooltipDirective extends NzTooltipBaseDirective {
4752
static ngAcceptInputType_nzTooltipArrowPointAtCenter: BooleanInput;
@@ -125,7 +130,9 @@ export class NzTooltipDirective extends NzTooltipBaseDirective {
125130
</div>
126131
</ng-template>
127132
`,
128-
preserveWhitespaces: false
133+
preserveWhitespaces: false,
134+
imports: [OverlayModule, NgClass, NgStyle, NzNoAnimationModule, NzOutletModule, NzOverlayModule],
135+
standalone: true
129136
})
130137
export class NzToolTipComponent extends NzTooltipBaseComponent {
131138
override nzTitle: NzTSType | null = null;

0 commit comments

Comments
 (0)