UNPKG

4.14 kBJavaScriptView Raw
1import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2import _extends from "@babel/runtime/helpers/esm/extends";
3var __rest = this && this.__rest || function (s, e) {
4 var t = {};
5 for (var p in s) {
6 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
7 }
8 if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
10 }
11 return t;
12};
13import * as React from 'react';
14import ExclamationCircleFilled from "@ant-design/icons/es/icons/ExclamationCircleFilled";
15import classNames from 'classnames';
16import Button from '../button';
17import { convertLegacyProps } from '../button/button';
18import ActionButton from '../_util/ActionButton';
19import LocaleReceiver from '../locale-provider/LocaleReceiver';
20import defaultLocale from '../locale/en_US';
21import { getRenderPropValue } from '../_util/getRenderPropValue';
22import { ConfigContext } from '../config-provider';
23import PopoverPurePanel from '../popover/PurePanel';
24import useStyle from './style';
25export var Overlay = function Overlay(props) {
26 var prefixCls = props.prefixCls,
27 okButtonProps = props.okButtonProps,
28 cancelButtonProps = props.cancelButtonProps,
29 title = props.title,
30 cancelText = props.cancelText,
31 okText = props.okText,
32 _props$okType = props.okType,
33 okType = _props$okType === void 0 ? 'primary' : _props$okType,
34 _props$icon = props.icon,
35 icon = _props$icon === void 0 ? /*#__PURE__*/React.createElement(ExclamationCircleFilled, null) : _props$icon,
36 _props$showCancel = props.showCancel,
37 showCancel = _props$showCancel === void 0 ? true : _props$showCancel,
38 close = props.close,
39 onConfirm = props.onConfirm,
40 onCancel = props.onCancel;
41 var _React$useContext = React.useContext(ConfigContext),
42 getPrefixCls = _React$useContext.getPrefixCls;
43 return /*#__PURE__*/React.createElement(LocaleReceiver, {
44 componentName: "Popconfirm",
45 defaultLocale: defaultLocale.Popconfirm
46 }, function (contextLocale) {
47 return /*#__PURE__*/React.createElement("div", {
48 className: prefixCls + "-inner-content"
49 }, /*#__PURE__*/React.createElement("div", {
50 className: prefixCls + "-message"
51 }, icon && /*#__PURE__*/React.createElement("span", {
52 className: prefixCls + "-message-icon"
53 }, icon), /*#__PURE__*/React.createElement("div", {
54 className: prefixCls + "-message-title"
55 }, getRenderPropValue(title))), /*#__PURE__*/React.createElement("div", {
56 className: prefixCls + "-buttons"
57 }, showCancel && /*#__PURE__*/React.createElement(Button, _extends({
58 onClick: onCancel,
59 size: "small"
60 }, cancelButtonProps), cancelText !== null && cancelText !== void 0 ? cancelText : contextLocale.cancelText), /*#__PURE__*/React.createElement(ActionButton, {
61 buttonProps: _extends(_extends({
62 size: 'small'
63 }, convertLegacyProps(okType)), okButtonProps),
64 actionFn: onConfirm,
65 close: close,
66 prefixCls: getPrefixCls('btn'),
67 quitOnNullishReturnValue: true,
68 emitEvent: true
69 }, okText !== null && okText !== void 0 ? okText : contextLocale.okText)));
70 });
71};
72export default function PurePanel(props) {
73 var customizePrefixCls = props.prefixCls,
74 placement = props.placement,
75 className = props.className,
76 style = props.style,
77 restProps = __rest(props, ["prefixCls", "placement", "className", "style"]);
78 var _React$useContext2 = React.useContext(ConfigContext),
79 getPrefixCls = _React$useContext2.getPrefixCls;
80 var prefixCls = getPrefixCls('popconfirm', customizePrefixCls);
81 var _useStyle = useStyle(prefixCls),
82 _useStyle2 = _slicedToArray(_useStyle, 1),
83 wrapSSR = _useStyle2[0];
84 return wrapSSR( /*#__PURE__*/React.createElement(PopoverPurePanel, {
85 placement: placement,
86 className: classNames(prefixCls, className),
87 style: style
88 }, /*#__PURE__*/React.createElement(Overlay, _extends({}, restProps, {
89 prefixCls: prefixCls
90 }))));
91}
\No newline at end of file