1 | "use client";
|
2 |
|
3 | import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
4 | import React from 'react';
|
5 | import CloseOutlined from "@ant-design/icons/es/icons/CloseOutlined";
|
6 | import { DisabledContextProvider } from '../config-provider/DisabledContext';
|
7 | import { useLocale } from '../locale';
|
8 | import NormalCancelBtn from './components/NormalCancelBtn';
|
9 | import NormalOkBtn from './components/NormalOkBtn';
|
10 | import { ModalContextProvider } from './context';
|
11 | import { getConfirmLocale } from './locale';
|
12 | export function renderCloseIcon(prefixCls, closeIcon) {
|
13 | return React.createElement("span", {
|
14 | className: `${prefixCls}-close-x`
|
15 | }, closeIcon || React.createElement(CloseOutlined, {
|
16 | className: `${prefixCls}-close-icon`
|
17 | }));
|
18 | }
|
19 | export 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 |
|
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 |
|
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 = React.createElement(React.Fragment, null, React.createElement(NormalCancelBtn, null), React.createElement(NormalOkBtn, null));
|
50 | if (typeof footer === 'function') {
|
51 | footerNode = footer(footerNode, {
|
52 | OkBtn: NormalOkBtn,
|
53 | CancelBtn: NormalCancelBtn
|
54 | });
|
55 | }
|
56 | footerNode = React.createElement(ModalContextProvider, {
|
57 | value: btnCtxValueMemo
|
58 | }, footerNode);
|
59 | } else {
|
60 | footerNode = footer;
|
61 | }
|
62 | return React.createElement(DisabledContextProvider, {
|
63 | disabled: false
|
64 | }, footerNode);
|
65 | }; |
\ | No newline at end of file |