diff --git a/components/popconfirm/doc/index.en-US.md b/components/popconfirm/doc/index.en-US.md index 050bca7b965..d715252b45d 100644 --- a/components/popconfirm/doc/index.en-US.md +++ b/components/popconfirm/doc/index.en-US.md @@ -19,7 +19,6 @@ import { NzPopconfirmModule } from 'ng-zorro-antd/popconfirm'; ## API - ### [nz-popconfirm]:standalone | Param | Description | Type | Default value | @@ -38,6 +37,7 @@ import { NzPopconfirmModule } from 'ng-zorro-antd/popconfirm'; | `[nzPopconfirmOverlayClassName]` | Class name of the popconfirm card | `string` | - | | `[nzPopconfirmOverlayStyle]` | Style of the popconfirm card | `object` | - | | `[nzPopconfirmBackdrop]` | whether or not the overlay should attach a backdrop | `boolean` | `false` | +| `[nzPopconfirmOverlayClickable]` | Disable clicking the mask to close the panel | `boolean` | `false` | | Param | Description | Type | Default value | Global Config | | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- | ------------- | ------------- | @@ -45,7 +45,7 @@ import { NzPopconfirmModule } from 'ng-zorro-antd/popconfirm'; | `[nzOkText]` | Text of the Confirm button | `string` | `'Confirm'` | - | | `[nzOkType]` | Button `type` of the Confirm button | `'primary' \| 'ghost' \| 'dashed' \| 'danger' \| 'default'` | `'primary'` | - | | `[nzOkDanger]` | Danger status of the OK button. Consistent with the `nzDanger` of the `nz-button`. | `boolean` | `false` | - | -| `[nzOkDisabled]` | prevents a user from interacting with the OK button. Consistent with the `disabled` of the `nz-button`. | `boolean` | `false` | - | +| `[nzOkDisabled]` | prevents a user from interacting with the OK button. Consistent with the `disabled` of the `nz-button`. | `boolean` | `false` | - | | `[nzCondition]` | Whether to directly emit `onConfirm` without showing Popconfirm | `boolean` | `false` | - | | `[nzIcon]` | Customize icon of confirmation | `string \| TemplateRef` | - | - | | `[nzAutoFocus]` | Autofocus a button | `null \| 'ok' \| 'cancel'` | `null` | ✅ | diff --git a/components/popconfirm/doc/index.zh-CN.md b/components/popconfirm/doc/index.zh-CN.md index b7149a51378..8172814da6a 100644 --- a/components/popconfirm/doc/index.zh-CN.md +++ b/components/popconfirm/doc/index.zh-CN.md @@ -42,6 +42,7 @@ import { NzPopconfirmModule } from 'ng-zorro-antd/popconfirm'; | `[nzPopconfirmOverlayClassName]` | 卡片类名 | `string` | - | | `[nzPopconfirmOverlayStyle]` | 卡片样式 | `object` | - | | `[nzPopconfirmBackdrop]` | 浮层是否应带有背景板 | `boolean` | `false` | +| `[nzPopconfirmOverlayClickable]` | 禁止点击蒙板关闭面板 | `boolean` | `false` | | 参数 | 说明 | 类型 | 默认值 | 全局配置 | | ------------------- | ----------------------------------------------------------------------- | -------------------------------------------------------------------- | ----------- | -------- | diff --git a/components/popconfirm/popconfirm.ts b/components/popconfirm/popconfirm.ts index d2ad5620cd7..4c61f17523b 100644 --- a/components/popconfirm/popconfirm.ts +++ b/components/popconfirm/popconfirm.ts @@ -64,6 +64,7 @@ export class NzPopconfirmDirective extends NzTooltipBaseDirective { @Input('nzPopconfirmMouseLeaveDelay') override mouseLeaveDelay?: number; @Input('nzPopconfirmOverlayClassName') override overlayClassName?: string; @Input('nzPopconfirmOverlayStyle') override overlayStyle?: NgStyleInterface; + @Input('nzPopconfirmOverlayClickable') override overlayClickable?: boolean; @Input('nzPopconfirmVisible') override visible?: boolean; @Input() nzOkText?: string; @Input() nzOkType?: string; diff --git a/components/popover/doc/index.en-US.md b/components/popover/doc/index.en-US.md index 51f7c19ed44..2d2064ed16e 100644 --- a/components/popover/doc/index.en-US.md +++ b/components/popover/doc/index.en-US.md @@ -35,6 +35,7 @@ import { NzPopoverModule } from 'ng-zorro-antd/popover'; | `[nzPopoverMouseLeaveDelay]` | Delay in seconds, before popover is hidden on mouse leave | `number` | `0.1` | | `[nzPopoverOverlayClassName]` | Class name of the popover card | `string` | - | | `[nzPopoverOverlayStyle]` | Style of the popover card | `object` | - | +| `[nzPopoverOverlayClickable]` | Disable clicking the mask to close the panel | `boolean` | `false` | Consult [Tooltip's documentation](/components/tooltip/en#api) to find more APIs. | `[nzPopoverBackdrop]` | whether or not the overlay should attach a backdrop | `boolean` | `false` | diff --git a/components/popover/doc/index.zh-CN.md b/components/popover/doc/index.zh-CN.md index 8f84299cf2e..9ea527bc30a 100644 --- a/components/popover/doc/index.zh-CN.md +++ b/components/popover/doc/index.zh-CN.md @@ -37,6 +37,7 @@ import { NzPopoverModule } from 'ng-zorro-antd/popover'; | `[nzPopoverOverlayClassName]` | 卡片类名 | `string` | - | | `[nzPopoverOverlayStyle]` | 卡片样式 | `object` | - | | `[nzPopoverBackdrop]` | 浮层是否应带有背景板 | `boolean` | `false` | +| `[nzPopoverOverlayClickable]` | 禁止点击蒙板关闭面板 | `boolean` | `false` | 更多属性请参考 [Tooltip](/components/tooltip/zh#api)。 diff --git a/components/popover/popover.ts b/components/popover/popover.ts index 0392fdf57fc..078f214eb48 100644 --- a/components/popover/popover.ts +++ b/components/popover/popover.ts @@ -56,6 +56,7 @@ export class NzPopoverDirective extends NzTooltipBaseDirective { @Input('nzPopoverMouseLeaveDelay') override mouseLeaveDelay?: number; @Input('nzPopoverOverlayClassName') override overlayClassName?: string; @Input('nzPopoverOverlayStyle') override overlayStyle?: NgStyleInterface; + @Input('nzPopoverOverlayClickable') override overlayClickable?: boolean; @Input() @WithConfig() nzPopoverBackdrop?: boolean = false; diff --git a/components/tooltip/base.ts b/components/tooltip/base.ts index df3ee840d6a..ee2c49dc30e 100644 --- a/components/tooltip/base.ts +++ b/components/tooltip/base.ts @@ -56,6 +56,7 @@ export abstract class NzTooltipBaseDirective implements AfterViewInit, OnChanges mouseLeaveDelay?: number; overlayClassName?: string; overlayStyle?: NgStyleInterface; + overlayClickable?: boolean; cdkConnectedOverlayPush?: boolean; visibleChange = new EventEmitter(); @@ -99,6 +100,10 @@ export abstract class NzTooltipBaseDirective implements AfterViewInit, OnChanges return this.overlayStyle || null; } + protected get _overlayClickable(): boolean { + return this.overlayClickable ?? false; + } + private internalVisible = false; protected getProxyPropertyMap(): PropertyMapping { @@ -272,6 +277,7 @@ export abstract class NzTooltipBaseDirective implements AfterViewInit, OnChanges mouseLeaveDelay: ['nzMouseLeaveDelay', () => this._mouseLeaveDelay], overlayClassName: ['nzOverlayClassName', () => this._overlayClassName], overlayStyle: ['nzOverlayStyle', () => this._overlayStyle], + overlayClickable: ['nzOverlayClickable', () => this._overlayClickable], arrowPointAtCenter: ['nzArrowPointAtCenter', () => this.arrowPointAtCenter], cdkConnectedOverlayPush: ['cdkConnectedOverlayPush', () => this.cdkConnectedOverlayPush], ...this.getProxyPropertyMap() @@ -342,6 +348,7 @@ export abstract class NzTooltipBaseComponent implements OnDestroy, OnInit { nzArrowPointAtCenter: boolean = false; nzOverlayClassName!: string; nzOverlayStyle: NgStyleInterface = {}; + nzOverlayClickable: boolean = false; nzBackdrop = false; nzMouseEnterDelay?: number; nzMouseLeaveDelay?: number; @@ -425,6 +432,10 @@ export abstract class NzTooltipBaseComponent implements OnDestroy, OnInit { } hide(): void { + if (this.nzOverlayClickable) { + return; + } + if (!this.nzVisible) { return; } diff --git a/components/tooltip/doc/index.en-US.md b/components/tooltip/doc/index.en-US.md index 992868f9286..6a248d6c2db 100644 --- a/components/tooltip/doc/index.en-US.md +++ b/components/tooltip/doc/index.en-US.md @@ -35,6 +35,7 @@ import { NzToolTipModule } from 'ng-zorro-antd/tooltip'; | `[nzTooltipMouseLeaveDelay]` | Delay in seconds, before tooltip is hidden on mouse leave | `number` | `0.1` | | `[nzTooltipOverlayClassName]` | Class name of the tooltip card | `string` | - | | `[nzTooltipOverlayStyle]` | Style of the tooltip card | `object` | - | +| `[nzTooltipOverlayClickable]` | Disable clicking the mask to close the panel | `boolean` | `false` | ### Common API diff --git a/components/tooltip/doc/index.zh-CN.md b/components/tooltip/doc/index.zh-CN.md index 93ac56d37c9..949dbd9e47e 100644 --- a/components/tooltip/doc/index.zh-CN.md +++ b/components/tooltip/doc/index.zh-CN.md @@ -22,21 +22,22 @@ import { NzToolTipModule } from 'ng-zorro-antd/tooltip'; ### [nz-tooltip]:standalone -| 参数 | 说明 | 类型 | 默认值 | -| ------------------------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | -| `[nzTooltipArrowPointAtCenter]` | 箭头指向锚点的中心 | `boolean` | `false` | -| `[nzTooltipTitle]` | 提示文字 | `string \| TemplateRef` | - | -| `[nzTooltipTitleContext]` | 提示文字模板上下文 | `object` | - | +| 参数 | 说明 | 类型 | 默认值 | +| ------------------------------- |---------------------------------------------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | +| `[nzTooltipArrowPointAtCenter]` | 箭头指向锚点的中心 | `boolean` | `false` | +| `[nzTooltipTitle]` | 提示文字 | `string \| TemplateRef` | - | +| `[nzTooltipTitleContext]` | 提示文字模板上下文 | `object` | - | | `[nzTooltipTrigger]` | 触发行为,可选 `hover` \| `focus` \| `click`,为 `null` 时不响应光标事件 | `'click' \| 'focus' \| 'hover' \| null` | `'hover'` | -| `[nzTooltipPlacement]` | 气泡框位置 | `'top' \| 'left' \| 'right' \| 'bottom' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight' \| 'leftTop' \| 'leftBottom' \| 'rightTop' \| 'rightBottom' \| Array` | `'top'` | -| `[nzTooltipColor]` | 背景颜色 | `string` | - | -| `[nzTooltipOrigin]` | 气泡框定位元素 | `ElementRef` | - | -| `[nzTooltipVisible]` | 显示隐藏气泡框 | `boolean` | `false` | -| `(nzTooltipVisibleChange)` | 显示隐藏的事件 | `EventEmitter` | - | +| `[nzTooltipPlacement]` | 气泡框位置 | `'top' \| 'left' \| 'right' \| 'bottom' \| 'topLeft' \| 'topRight' \| 'bottomLeft' \| 'bottomRight' \| 'leftTop' \| 'leftBottom' \| 'rightTop' \| 'rightBottom' \| Array` | `'top'` | +| `[nzTooltipColor]` | 背景颜色 | `string` | - | +| `[nzTooltipOrigin]` | 气泡框定位元素 | `ElementRef` | - | +| `[nzTooltipVisible]` | 显示隐藏气泡框 | `boolean` | `false` | +| `(nzTooltipVisibleChange)` | 显示隐藏的事件 | `EventEmitter` | - | | `[nzTooltipMouseEnterDelay]` | 鼠标移入后延时多少才显示 Tooltip,单位:秒 | `number` | `0.15` | | `[nzTooltipMouseLeaveDelay]` | 鼠标移出后延时多少才隐藏 Tooltip,单位:秒 | `number` | `0.1` | -| `[nzTooltipOverlayClassName]` | 卡片类名 | `string` | - | -| `[nzTooltipOverlayStyle]` | 卡片样式 | `object` | - | +| `[nzTooltipOverlayClassName]` | 卡片类名 | `string` | - | +| `[nzTooltipOverlayStyle]` | 卡片样式 | `object` | - | +| `[nzTooltipOverlayClickable]` | 禁止点击蒙板关闭面板 | `boolean` | `false` | ### 共同的 API diff --git a/components/tooltip/tooltip.ts b/components/tooltip/tooltip.ts index 7fe627e3427..fc2ed43462b 100644 --- a/components/tooltip/tooltip.ts +++ b/components/tooltip/tooltip.ts @@ -52,6 +52,7 @@ export class NzTooltipDirective extends NzTooltipBaseDirective { @Input('nzTooltipMouseLeaveDelay') override mouseLeaveDelay?: number; @Input('nzTooltipOverlayClassName') override overlayClassName?: string; @Input('nzTooltipOverlayStyle') override overlayStyle?: NgStyleInterface; + @Input('nzTooltipOverlayClickable') override overlayClickable?: boolean; @Input({ alias: 'nzTooltipArrowPointAtCenter', transform: booleanAttribute }) override arrowPointAtCenter?: boolean; @Input({ transform: booleanAttribute }) override cdkConnectedOverlayPush?: boolean = true; @Input() nzTooltipColor?: string;