UNPKG

2.26 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import * as React from 'react';
3import Button from '../button';
4import { convertLegacyProps } from '../button/button';
5import ActionButton from '../_util/ActionButton';
6import LocaleReceiver from '../locale-provider/LocaleReceiver';
7import defaultLocale from '../locale/default';
8import { getRenderPropValue } from '../_util/getRenderPropValue';
9import { ConfigContext } from '../config-provider';
10export function Overlay(props) {
11 var prefixCls = props.prefixCls,
12 okButtonProps = props.okButtonProps,
13 cancelButtonProps = props.cancelButtonProps,
14 title = props.title,
15 cancelText = props.cancelText,
16 okText = props.okText,
17 okType = props.okType,
18 icon = props.icon,
19 _props$showCancel = props.showCancel,
20 showCancel = _props$showCancel === void 0 ? true : _props$showCancel,
21 close = props.close,
22 onConfirm = props.onConfirm,
23 onCancel = props.onCancel;
24
25 var _React$useContext = React.useContext(ConfigContext),
26 getPrefixCls = _React$useContext.getPrefixCls;
27
28 return /*#__PURE__*/React.createElement(LocaleReceiver, {
29 componentName: "Popconfirm",
30 defaultLocale: defaultLocale.Popconfirm
31 }, function (popconfirmLocale) {
32 return /*#__PURE__*/React.createElement("div", {
33 className: "".concat(prefixCls, "-inner-content")
34 }, /*#__PURE__*/React.createElement("div", {
35 className: "".concat(prefixCls, "-message")
36 }, icon, /*#__PURE__*/React.createElement("div", {
37 className: "".concat(prefixCls, "-message-title")
38 }, getRenderPropValue(title))), /*#__PURE__*/React.createElement("div", {
39 className: "".concat(prefixCls, "-buttons")
40 }, showCancel && /*#__PURE__*/React.createElement(Button, _extends({
41 onClick: onCancel,
42 size: "small"
43 }, cancelButtonProps), cancelText || popconfirmLocale.cancelText), /*#__PURE__*/React.createElement(ActionButton, {
44 buttonProps: _extends(_extends({
45 size: 'small'
46 }, convertLegacyProps(okType)), okButtonProps),
47 actionFn: onConfirm,
48 close: close,
49 prefixCls: getPrefixCls('btn'),
50 quitOnNullishReturnValue: true,
51 emitEvent: true
52 }, okText || popconfirmLocale.okText)));
53 });
54}
\No newline at end of file