mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
feat: add showCancel prop for popconfirm (#32620)
Co-authored-by: machixian <machixian@myweimai.com>
This commit is contained in:
parent
2769f44536
commit
16bb5489e6
@ -24,6 +24,7 @@ The difference with the `confirm` modal dialog is that it's more lightweight tha
|
||||
| okButtonProps | The ok button props | [ButtonProps](/components/button/#API) | - |
|
||||
| okText | The text of the Confirm button | string | `OK` |
|
||||
| okType | Button `type` of the Confirm button | string | `primary` |
|
||||
| showCancel | Show cancel button | boolean | true |
|
||||
| title | The title of the confirmation box | ReactNode \| () => ReactNode | - |
|
||||
| onCancel | A callback of cancel | function(e) | - |
|
||||
| onConfirm | A callback of confirmation | function(e) | - |
|
||||
|
@ -24,6 +24,7 @@ export interface PopconfirmProps extends AbstractTooltipProps {
|
||||
cancelText?: React.ReactNode;
|
||||
okButtonProps?: ButtonProps;
|
||||
cancelButtonProps?: ButtonProps;
|
||||
showCancel?: boolean;
|
||||
icon?: React.ReactNode;
|
||||
onVisibleChange?: (
|
||||
visible: boolean,
|
||||
@ -82,7 +83,16 @@ const Popconfirm = React.forwardRef<unknown, PopconfirmProps>((props, ref) => {
|
||||
};
|
||||
|
||||
const renderOverlay = (prefixCls: string, popconfirmLocale: PopconfirmLocale) => {
|
||||
const { okButtonProps, cancelButtonProps, title, cancelText, okText, okType, icon } = props;
|
||||
const {
|
||||
okButtonProps,
|
||||
cancelButtonProps,
|
||||
title,
|
||||
cancelText,
|
||||
okText,
|
||||
okType,
|
||||
icon,
|
||||
showCancel = true,
|
||||
} = props;
|
||||
return (
|
||||
<div className={`${prefixCls}-inner-content`}>
|
||||
<div className={`${prefixCls}-message`}>
|
||||
@ -90,9 +100,11 @@ const Popconfirm = React.forwardRef<unknown, PopconfirmProps>((props, ref) => {
|
||||
<div className={`${prefixCls}-message-title`}>{getRenderPropValue(title)}</div>
|
||||
</div>
|
||||
<div className={`${prefixCls}-buttons`}>
|
||||
{showCancel && (
|
||||
<Button onClick={onCancel} size="small" {...cancelButtonProps}>
|
||||
{cancelText || popconfirmLocale.cancelText}
|
||||
</Button>
|
||||
)}
|
||||
<ActionButton
|
||||
buttonProps={{ size: 'small', ...convertLegacyProps(okType), ...okButtonProps }}
|
||||
actionFn={onConfirm}
|
||||
|
@ -25,6 +25,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/fjMCD9xRq/Popconfirm.svg
|
||||
| okButtonProps | ok 按钮 props | [ButtonProps](/components/button/#API) | - |
|
||||
| okText | 确认按钮文字 | string | `确定` |
|
||||
| okType | 确认按钮类型 | string | `primary` |
|
||||
| showCancel | 是否显示取消按钮 | boolean | true |
|
||||
| title | 确认框的描述 | ReactNode \| () => ReactNode | - |
|
||||
| onCancel | 点击取消的回调 | function(e) | - |
|
||||
| onConfirm | 点击确认的回调 | function(e) | - |
|
||||
|
Loading…
Reference in New Issue
Block a user