|
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
import * as React from 'react';
|
|
|
import classNames from 'classnames';
|
|
|
import Dialog from './Modal';
|
|
|
import ActionButton from '../_util/ActionButton';
|
|
|
import devWarning from '../_util/devWarning';
|
|
|
import ConfigProvider from '../config-provider';
|
|
|
import { getTransitionName } from '../_util/motion';
|
|
|
|
|
|
var ConfirmDialog = function ConfirmDialog(props) {
|
|
|
var icon = props.icon,
|
|
|
onCancel = props.onCancel,
|
|
|
onOk = props.onOk,
|
|
|
close = props.close,
|
|
|
zIndex = props.zIndex,
|
|
|
afterClose = props.afterClose,
|
|
|
visible = props.visible,
|
|
|
keyboard = props.keyboard,
|
|
|
centered = props.centered,
|
|
|
getContainer = props.getContainer,
|
|
|
maskStyle = props.maskStyle,
|
|
|
okText = props.okText,
|
|
|
okButtonProps = props.okButtonProps,
|
|
|
cancelText = props.cancelText,
|
|
|
cancelButtonProps = props.cancelButtonProps,
|
|
|
direction = props.direction,
|
|
|
prefixCls = props.prefixCls,
|
|
|
wrapClassName = props.wrapClassName,
|
|
|
rootPrefixCls = props.rootPrefixCls,
|
|
|
iconPrefixCls = props.iconPrefixCls,
|
|
|
bodyStyle = props.bodyStyle,
|
|
|
_props$closable = props.closable,
|
|
|
closable = _props$closable === void 0 ? false : _props$closable,
|
|
|
closeIcon = props.closeIcon,
|
|
|
modalRender = props.modalRender,
|
|
|
focusTriggerAfterClose = props.focusTriggerAfterClose;
|
|
|
devWarning(!(typeof icon === 'string' && icon.length > 2), 'Modal', "`icon` is using ReactNode instead of string naming in v4. Please check `".concat(icon, "` at https://ant.design/components/icon")); // 支持传入{ icon: null }来隐藏`Modal.confirm`默认的Icon
|
|
|
|
|
|
var okType = props.okType || 'primary';
|
|
|
var contentPrefixCls = "".concat(prefixCls, "-confirm"); // 默认为 true,保持向下兼容
|
|
|
|
|
|
var okCancel = 'okCancel' in props ? props.okCancel : true;
|
|
|
var width = props.width || 416;
|
|
|
var style = props.style || {};
|
|
|
var mask = props.mask === undefined ? true : props.mask; // 默认为 false,保持旧版默认行为
|
|
|
|
|
|
var maskClosable = props.maskClosable === undefined ? false : props.maskClosable;
|
|
|
var autoFocusButton = props.autoFocusButton === null ? false : props.autoFocusButton || 'ok';
|
|
|
var classString = classNames(contentPrefixCls, "".concat(contentPrefixCls, "-").concat(props.type), _defineProperty({}, "".concat(contentPrefixCls, "-rtl"), direction === 'rtl'), props.className);
|
|
|
var cancelButton = okCancel && /*#__PURE__*/React.createElement(ActionButton, {
|
|
|
actionFn: onCancel,
|
|
|
close: close,
|
|
|
autoFocus: autoFocusButton === 'cancel',
|
|
|
buttonProps: cancelButtonProps,
|
|
|
prefixCls: "".concat(rootPrefixCls, "-btn")
|
|
|
}, cancelText);
|
|
|
return /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
|
prefixCls: rootPrefixCls,
|
|
|
iconPrefixCls: iconPrefixCls,
|
|
|
direction: direction
|
|
|
}, /*#__PURE__*/React.createElement(Dialog, {
|
|
|
prefixCls: prefixCls,
|
|
|
className: classString,
|
|
|
wrapClassName: classNames(_defineProperty({}, "".concat(contentPrefixCls, "-centered"), !!props.centered), wrapClassName),
|
|
|
onCancel: function onCancel() {
|
|
|
return close({
|
|
|
triggerCancel: true
|
|
|
});
|
|
|
},
|
|
|
visible: visible,
|
|
|
title: "",
|
|
|
footer: "",
|
|
|
transitionName: getTransitionName(rootPrefixCls, 'zoom', props.transitionName),
|
|
|
maskTransitionName: getTransitionName(rootPrefixCls, 'fade', props.maskTransitionName),
|
|
|
mask: mask,
|
|
|
maskClosable: maskClosable,
|
|
|
maskStyle: maskStyle,
|
|
|
style: style,
|
|
|
bodyStyle: bodyStyle,
|
|
|
width: width,
|
|
|
zIndex: zIndex,
|
|
|
afterClose: afterClose,
|
|
|
keyboard: keyboard,
|
|
|
centered: centered,
|
|
|
getContainer: getContainer,
|
|
|
closable: closable,
|
|
|
closeIcon: closeIcon,
|
|
|
modalRender: modalRender,
|
|
|
focusTriggerAfterClose: focusTriggerAfterClose
|
|
|
}, /*#__PURE__*/React.createElement("div", {
|
|
|
className: "".concat(contentPrefixCls, "-body-wrapper")
|
|
|
}, /*#__PURE__*/React.createElement("div", {
|
|
|
className: "".concat(contentPrefixCls, "-body")
|
|
|
}, icon, props.title === undefined ? null : /*#__PURE__*/React.createElement("span", {
|
|
|
className: "".concat(contentPrefixCls, "-title")
|
|
|
}, props.title), /*#__PURE__*/React.createElement("div", {
|
|
|
className: "".concat(contentPrefixCls, "-content")
|
|
|
}, props.content)), /*#__PURE__*/React.createElement("div", {
|
|
|
className: "".concat(contentPrefixCls, "-btns")
|
|
|
}, cancelButton, /*#__PURE__*/React.createElement(ActionButton, {
|
|
|
type: okType,
|
|
|
actionFn: onOk,
|
|
|
close: close,
|
|
|
autoFocus: autoFocusButton === 'ok',
|
|
|
buttonProps: okButtonProps,
|
|
|
prefixCls: "".concat(rootPrefixCls, "-btn")
|
|
|
}, okText)))));
|
|
|
};
|
|
|
|
|
|
export default ConfirmDialog; |