UNPKG

2.34 kBJavaScriptView Raw
1"use client";
2
3import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4import React from 'react';
5import CloseOutlined from "@ant-design/icons/es/icons/CloseOutlined";
6import { DisabledContextProvider } from '../config-provider/DisabledContext';
7import { useLocale } from '../locale';
8import NormalCancelBtn from './components/NormalCancelBtn';
9import NormalOkBtn from './components/NormalOkBtn';
10import { ModalContextProvider } from './context';
11import { getConfirmLocale } from './locale';
12export function renderCloseIcon(prefixCls, closeIcon) {
13 return /*#__PURE__*/React.createElement("span", {
14 className: `${prefixCls}-close-x`
15 }, closeIcon || /*#__PURE__*/React.createElement(CloseOutlined, {
16 className: `${prefixCls}-close-icon`
17 }));
18}
19export const Footer = props => {
20 const {
21 okText,
22 okType = 'primary',
23 cancelText,
24 confirmLoading,
25 onOk,
26 onCancel,
27 okButtonProps,
28 cancelButtonProps,
29 footer
30 } = props;
31 const [locale] = useLocale('Modal', getConfirmLocale());
32 // ================== Locale Text ==================
33 const okTextLocale = okText || (locale === null || locale === void 0 ? void 0 : locale.okText);
34 const cancelTextLocale = cancelText || (locale === null || locale === void 0 ? void 0 : locale.cancelText);
35 // ================= Context Value =================
36 const btnCtxValue = {
37 confirmLoading,
38 okButtonProps,
39 cancelButtonProps,
40 okTextLocale,
41 cancelTextLocale,
42 okType,
43 onOk,
44 onCancel
45 };
46 const btnCtxValueMemo = React.useMemo(() => btnCtxValue, _toConsumableArray(Object.values(btnCtxValue)));
47 let footerNode;
48 if (typeof footer === 'function' || typeof footer === 'undefined') {
49 footerNode = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(NormalCancelBtn, null), /*#__PURE__*/React.createElement(NormalOkBtn, null));
50 if (typeof footer === 'function') {
51 footerNode = footer(footerNode, {
52 OkBtn: NormalOkBtn,
53 CancelBtn: NormalCancelBtn
54 });
55 }
56 footerNode = /*#__PURE__*/React.createElement(ModalContextProvider, {
57 value: btnCtxValueMemo
58 }, footerNode);
59 } else {
60 footerNode = footer;
61 }
62 return /*#__PURE__*/React.createElement(DisabledContextProvider, {
63 disabled: false
64 }, footerNode);
65};
\No newline at end of file