Files
icehrm/web/node_modules/antd/lib/modal/ConfirmDialog.js
2020-05-20 18:47:29 +02:00

110 lines
5.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var React = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _Modal = _interopRequireDefault(require("./Modal"));
var _ActionButton = _interopRequireDefault(require("./ActionButton"));
var _warning = _interopRequireDefault(require("../_util/warning"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
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;
(0, _warning["default"])(!(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 prefixCls = props.prefixCls || 'ant-modal';
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 transitionName = props.transitionName || 'zoom';
var maskTransitionName = props.maskTransitionName || 'fade';
var classString = (0, _classnames["default"])(contentPrefixCls, "".concat(contentPrefixCls, "-").concat(props.type), props.className);
var cancelButton = okCancel && /*#__PURE__*/React.createElement(_ActionButton["default"], {
actionFn: onCancel,
closeModal: close,
autoFocus: autoFocusButton === 'cancel',
buttonProps: cancelButtonProps
}, cancelText);
return /*#__PURE__*/React.createElement(_Modal["default"], {
prefixCls: prefixCls,
className: classString,
wrapClassName: (0, _classnames["default"])(_defineProperty({}, "".concat(contentPrefixCls, "-centered"), !!props.centered)),
onCancel: function onCancel() {
return close({
triggerCancel: true
});
},
visible: visible,
title: "",
transitionName: transitionName,
footer: "",
maskTransitionName: maskTransitionName,
mask: mask,
maskClosable: maskClosable,
maskStyle: maskStyle,
style: style,
width: width,
zIndex: zIndex,
afterClose: afterClose,
keyboard: keyboard,
centered: centered,
getContainer: getContainer
}, /*#__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["default"], {
type: okType,
actionFn: onOk,
closeModal: close,
autoFocus: autoFocusButton === 'ok',
buttonProps: okButtonProps
}, okText))));
};
var _default = ConfirmDialog;
exports["default"] = _default;