1 | "use client";
|
2 |
|
3 | var __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 | };
|
11 | import * as React from 'react';
|
12 | import ExclamationCircleFilled from "@ant-design/icons/es/icons/ExclamationCircleFilled";
|
13 | import classNames from 'classnames';
|
14 | import ActionButton from '../_util/ActionButton';
|
15 | import { getRenderPropValue } from '../_util/getRenderPropValue';
|
16 | import Button from '../button';
|
17 | import { convertLegacyProps } from '../button/buttonHelpers';
|
18 | import { ConfigContext } from '../config-provider';
|
19 | import { useLocale } from '../locale';
|
20 | import defaultLocale from '../locale/en_US';
|
21 | import PopoverPurePanel from '../popover/PurePanel';
|
22 | import useStyle from './style';
|
23 | export const Overlay = props => {
|
24 | const {
|
25 | prefixCls,
|
26 | okButtonProps,
|
27 | cancelButtonProps,
|
28 | title,
|
29 | description,
|
30 | cancelText,
|
31 | okText,
|
32 | okType = 'primary',
|
33 | icon = 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 React.createElement("div", {
|
47 | className: `${prefixCls}-inner-content`,
|
48 | onClick: onPopupClick
|
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-text`
|
55 | }, titleNode && React.createElement("div", {
|
56 | className: `${prefixCls}-title`
|
57 | }, titleNode), descriptionNode && React.createElement("div", {
|
58 | className: `${prefixCls}-description`
|
59 | }, descriptionNode))), React.createElement("div", {
|
60 | className: `${prefixCls}-buttons`
|
61 | }, showCancel && (React.createElement(Button, Object.assign({
|
62 | onClick: onCancel,
|
63 | size: "small"
|
64 | }, cancelButtonProps), cancelText || (contextLocale === null || contextLocale === void 0 ? void 0 : contextLocale.cancelText))), 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 | };
|
75 | const 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(React.createElement(PopoverPurePanel, {
|
89 | placement: placement,
|
90 | className: classNames(prefixCls, className),
|
91 | style: style,
|
92 | content: React.createElement(Overlay, Object.assign({
|
93 | prefixCls: prefixCls
|
94 | }, restProps))
|
95 | }));
|
96 | };
|
97 | export default PurePanel; |
\ | No newline at end of file |