diff --git a/src/createModal/demos/RootContainer.tsx b/src/createModal/demos/RootContainer.tsx new file mode 100644 index 0000000..93225ba --- /dev/null +++ b/src/createModal/demos/RootContainer.tsx @@ -0,0 +1,23 @@ +import React from 'react'; +import { ConfigProvider } from 'antd'; +import zhCN from 'antd/locale/zh_CN'; + +const RootContainer: React.FC = ({ children }) => ( + + {children} + +); + +export default RootContainer; diff --git a/src/createModal/demos/context.tsx b/src/createModal/demos/context.tsx new file mode 100644 index 0000000..539ada7 --- /dev/null +++ b/src/createModal/demos/context.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { Button } from 'antd'; +import { createModal } from 'create-antd-modal'; +import RootContainer from './RootContainer'; + +const Demo: React.FC = () => { + return ( + + ); +}; + +export default Demo; diff --git a/src/createModal/index.md b/src/createModal/index.md index 78e29cd..6e39858 100644 --- a/src/createModal/index.md +++ b/src/createModal/index.md @@ -39,6 +39,14 @@ group: desc="Custom Component is treated like a form." /> +### Custom Container + + + Everything else is the same as [Modal](https://ant.design/components/modal/#header). Returns: diff --git a/src/createModal/index.tsx b/src/createModal/index.tsx index 7c0b880..6d3ad8a 100644 --- a/src/createModal/index.tsx +++ b/src/createModal/index.tsx @@ -52,6 +52,11 @@ export type CreateModalProps = Omit< * @description.zh-CN “拒绝”按钮(传入此字段才显示)事件,返回 promise 可以延迟关闭 * */ // onDeny?: (values?: T) => Promise | void; + /** + * @description Container for Modal, usually various Context.Provider + * @description.zh-CN Modal 的容器,通常为各种 Context.Provider + */ + container?: React.FC; }; export type CreateModalReturn = { @@ -70,6 +75,7 @@ function App({ onOk, onCancel, onFailed, + container: Container, // onDeny, // denyText, // hideCancel = false, @@ -141,7 +147,7 @@ function App({ }); }; - return ( + const returnedElement = ( // // {(contextLocale) => ( ({ // )} // ); + return Container ? {returnedElement} : returnedElement; } /** @@ -235,3 +242,7 @@ export default function createModal( }); return { destory, promise: defered }; } + +// export function createFunction(render: (child: React)) { + +// }