UNPKG

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