message-verify 0.0.30-beta.0 → 0.0.31-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12 -9
- package/package.json +1 -1
- package/src/index.tsx +23 -16
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { jsx as _jsx
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
// import App from './app.js';
|
3
3
|
// import { createRoot } from 'react-dom/client';
|
4
4
|
// interface Props {
|
@@ -29,25 +29,28 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
29
|
// export { createMessageVerify };
|
30
30
|
// export default createMessageVerify;
|
31
31
|
// src/modal.tsx
|
32
|
+
// src/modal.tsx
|
33
|
+
import { Modal } from 'antd';
|
32
34
|
import ReactDOM from 'react-dom/client';
|
33
35
|
let modalRoot = null;
|
34
|
-
const
|
36
|
+
const AntdModal = ({ config }) => (_jsx(Modal, { open: true, title: config.title || '提示', width: config.width || 600, onCancel: config.onClose, footer: null, children: config.content }));
|
35
37
|
export const showModal = (config) => {
|
36
|
-
// 创建容器
|
37
38
|
const container = document.createElement('div');
|
38
|
-
container.id = '
|
39
|
+
container.id = 'antd-modal-container';
|
39
40
|
document.body.appendChild(container);
|
40
|
-
// 渲染弹窗
|
41
41
|
modalRoot = ReactDOM.createRoot(container);
|
42
|
-
modalRoot.render(_jsx(
|
43
|
-
config
|
44
|
-
|
42
|
+
modalRoot.render(_jsx(AntdModal, { config: {
|
43
|
+
...config,
|
44
|
+
onClose: () => {
|
45
|
+
config.onClose?.();
|
46
|
+
destroyModal();
|
47
|
+
}
|
45
48
|
} }));
|
46
49
|
};
|
47
50
|
const destroyModal = () => {
|
48
51
|
if (modalRoot) {
|
49
52
|
modalRoot.unmount();
|
50
|
-
document.getElementById('
|
53
|
+
document.getElementById('antd-modal-container')?.remove();
|
51
54
|
modalRoot = null;
|
52
55
|
}
|
53
56
|
};
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
@@ -33,38 +33,45 @@
|
|
33
33
|
// export { createMessageVerify };
|
34
34
|
// export default createMessageVerify;
|
35
35
|
// src/modal.tsx
|
36
|
+
// src/modal.tsx
|
37
|
+
import { Modal } from 'antd'
|
36
38
|
import ReactDOM from 'react-dom/client'
|
37
39
|
|
38
40
|
export type ModalConfig = {
|
39
41
|
content: React.ReactNode
|
42
|
+
title?: string
|
43
|
+
width?: number
|
40
44
|
onClose?: () => void
|
41
45
|
}
|
42
46
|
|
43
47
|
let modalRoot: ReactDOM.Root | null = null
|
44
48
|
|
45
|
-
const
|
46
|
-
<
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
const AntdModal = ({ config }: { config: ModalConfig }) => (
|
50
|
+
<Modal
|
51
|
+
open={true}
|
52
|
+
title={config.title || '提示'}
|
53
|
+
width={config.width || 600}
|
54
|
+
onCancel={config.onClose}
|
55
|
+
footer={null}
|
56
|
+
>
|
57
|
+
{config.content}
|
58
|
+
</Modal>
|
52
59
|
)
|
53
60
|
|
54
61
|
export const showModal = (config: ModalConfig) => {
|
55
|
-
// 创建容器
|
56
62
|
const container = document.createElement('div')
|
57
|
-
container.id = '
|
63
|
+
container.id = 'antd-modal-container'
|
58
64
|
document.body.appendChild(container)
|
59
65
|
|
60
|
-
// 渲染弹窗
|
61
66
|
modalRoot = ReactDOM.createRoot(container)
|
62
67
|
modalRoot.render(
|
63
|
-
<
|
64
|
-
{
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
<AntdModal
|
69
|
+
config={{
|
70
|
+
...config,
|
71
|
+
onClose: () => {
|
72
|
+
config.onClose?.()
|
73
|
+
destroyModal()
|
74
|
+
}
|
68
75
|
}}
|
69
76
|
/>
|
70
77
|
)
|
@@ -73,7 +80,7 @@ export const showModal = (config: ModalConfig) => {
|
|
73
80
|
const destroyModal = () => {
|
74
81
|
if (modalRoot) {
|
75
82
|
modalRoot.unmount()
|
76
|
-
document.getElementById('
|
83
|
+
document.getElementById('antd-modal-container')?.remove()
|
77
84
|
modalRoot = null
|
78
85
|
}
|
79
86
|
}
|