1 | import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2 | import _extends from "@babel/runtime/helpers/esm/extends";
|
3 | var __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 | };
|
13 | import * as React from 'react';
|
14 | import ExclamationCircleFilled from "@ant-design/icons/es/icons/ExclamationCircleFilled";
|
15 | import classNames from 'classnames';
|
16 | import Button from '../button';
|
17 | import { convertLegacyProps } from '../button/button';
|
18 | import ActionButton from '../_util/ActionButton';
|
19 | import LocaleReceiver from '../locale-provider/LocaleReceiver';
|
20 | import defaultLocale from '../locale/en_US';
|
21 | import { getRenderPropValue } from '../_util/getRenderPropValue';
|
22 | import { ConfigContext } from '../config-provider';
|
23 | import PopoverPurePanel from '../popover/PurePanel';
|
24 | import useStyle from './style';
|
25 | export 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 ? 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 React.createElement(LocaleReceiver, {
|
44 | componentName: "Popconfirm",
|
45 | defaultLocale: defaultLocale.Popconfirm
|
46 | }, function (contextLocale) {
|
47 | return React.createElement("div", {
|
48 | className: prefixCls + "-inner-content"
|
49 | }, React.createElement("div", {
|
50 | className: prefixCls + "-message"
|
51 | }, icon && React.createElement("span", {
|
52 | className: prefixCls + "-message-icon"
|
53 | }, icon), React.createElement("div", {
|
54 | className: prefixCls + "-message-title"
|
55 | }, getRenderPropValue(title))), React.createElement("div", {
|
56 | className: prefixCls + "-buttons"
|
57 | }, showCancel && React.createElement(Button, _extends({
|
58 | onClick: onCancel,
|
59 | size: "small"
|
60 | }, cancelButtonProps), cancelText !== null && cancelText !== void 0 ? cancelText : contextLocale.cancelText), 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 | };
|
72 | export 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( React.createElement(PopoverPurePanel, {
|
85 | placement: placement,
|
86 | className: classNames(prefixCls, className),
|
87 | style: style
|
88 | }, React.createElement(Overlay, _extends({}, restProps, {
|
89 | prefixCls: prefixCls
|
90 | }))));
|
91 | } |
\ | No newline at end of file |