message-verify 0.0.30-beta.0 → 0.0.32-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.
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface ModalProps {
3
+ visible: boolean;
4
+ onClose: () => void;
5
+ children: React.ReactNode;
6
+ }
7
+ declare const Modal: React.FC<ModalProps>;
8
+ export default Modal;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ const modalStyle = {
3
+ position: 'fixed',
4
+ top: 0,
5
+ left: 0,
6
+ width: '100vw',
7
+ height: '100vh',
8
+ background: 'rgba(0,0,0,0.3)',
9
+ display: 'flex',
10
+ alignItems: 'center',
11
+ justifyContent: 'center',
12
+ zIndex: 1000,
13
+ };
14
+ const contentStyle = {
15
+ position: 'relative',
16
+ background: '#fff',
17
+ borderRadius: 8,
18
+ padding: 24,
19
+ minWidth: 320,
20
+ minHeight: 120,
21
+ boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
22
+ };
23
+ const closeBtnStyle = {
24
+ position: 'absolute',
25
+ top: 12,
26
+ right: 12,
27
+ width: 24,
28
+ height: 24,
29
+ border: 'none',
30
+ background: 'transparent',
31
+ fontSize: 20,
32
+ cursor: 'pointer',
33
+ lineHeight: 1,
34
+ };
35
+ const Modal = ({ visible, onClose, children }) => {
36
+ if (!visible)
37
+ return null;
38
+ return (_jsx("div", { style: modalStyle, children: _jsxs("div", { style: contentStyle, children: [_jsx("button", { style: closeBtnStyle, onClick: onClose, "aria-label": "\u5173\u95ED", children: "\u00D7" }), children] }) }));
39
+ };
40
+ export default Modal;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export type ModalConfig = {
2
2
  content: React.ReactNode;
3
+ title?: string;
4
+ width?: number;
3
5
  onClose?: () => void;
4
6
  };
5
7
  export declare const showModal: (config: ModalConfig) => void;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
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 './compoments/modal.js';
32
34
  import ReactDOM from 'react-dom/client';
33
35
  let modalRoot = null;
34
- const Modal = ({ content, onClose }) => (_jsx("div", { className: "modal-overlay", children: _jsxs("div", { className: "modal-content", children: [content, _jsx("button", { onClick: onClose, children: "Close" })] }) }));
36
+ const AntdModal = ({ config }) => (_jsx(Modal, { visible: true, onClose: () => { console.log('close'); }, children: config.content }));
35
37
  export const showModal = (config) => {
36
- // 创建容器
37
38
  const container = document.createElement('div');
38
- container.id = 'global-modal-container';
39
+ container.id = 'antd-modal-container';
39
40
  document.body.appendChild(container);
40
- // 渲染弹窗
41
41
  modalRoot = ReactDOM.createRoot(container);
42
- modalRoot.render(_jsx(Modal, { ...config, onClose: () => {
43
- config.onClose?.();
44
- destroyModal();
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('global-modal-container')?.remove();
53
+ document.getElementById('antd-modal-container')?.remove();
51
54
  modalRoot = null;
52
55
  }
53
56
  };
@@ -1 +1 @@
1
- {"root":["../src/app.tsx","../src/index.tsx","../src/main.tsx","../src/resource.ts","../src/vite-env.d.ts","../src/utils/getfingerprint.ts","../src/utils/index.ts","../src/utils/status.ts"],"version":"5.7.3"}
1
+ {"root":["../src/app.tsx","../src/index.tsx","../src/main.tsx","../src/resource.ts","../src/vite-env.d.ts","../src/compoments/modal.tsx","../src/utils/getfingerprint.ts","../src/utils/index.ts","../src/utils/status.ts"],"version":"5.7.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "message-verify",
3
- "version": "0.0.30-beta.0",
3
+ "version": "0.0.32-beta.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+
3
+ interface ModalProps {
4
+ visible: boolean;
5
+ onClose: () => void;
6
+ children: React.ReactNode;
7
+ }
8
+
9
+ const modalStyle: React.CSSProperties = {
10
+ position: 'fixed',
11
+ top: 0,
12
+ left: 0,
13
+ width: '100vw',
14
+ height: '100vh',
15
+ background: 'rgba(0,0,0,0.3)',
16
+ display: 'flex',
17
+ alignItems: 'center',
18
+ justifyContent: 'center',
19
+ zIndex: 1000,
20
+ };
21
+
22
+ const contentStyle: React.CSSProperties = {
23
+ position: 'relative',
24
+ background: '#fff',
25
+ borderRadius: 8,
26
+ padding: 24,
27
+ minWidth: 320,
28
+ minHeight: 120,
29
+ boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
30
+ };
31
+
32
+ const closeBtnStyle: React.CSSProperties = {
33
+ position: 'absolute',
34
+ top: 12,
35
+ right: 12,
36
+ width: 24,
37
+ height: 24,
38
+ border: 'none',
39
+ background: 'transparent',
40
+ fontSize: 20,
41
+ cursor: 'pointer',
42
+ lineHeight: 1,
43
+ };
44
+
45
+ const Modal: React.FC<ModalProps> = ({ visible, onClose, children }) => {
46
+ if (!visible) return null;
47
+
48
+ return (
49
+ <div style={modalStyle}>
50
+ <div style={contentStyle}>
51
+ <button style={closeBtnStyle} onClick={onClose} aria-label="关闭">
52
+ ×
53
+ </button>
54
+ {children}
55
+ </div>
56
+ </div>
57
+ );
58
+ };
59
+
60
+ export default Modal;
package/src/index.tsx CHANGED
@@ -33,38 +33,42 @@
33
33
  // export { createMessageVerify };
34
34
  // export default createMessageVerify;
35
35
  // src/modal.tsx
36
+ // src/modal.tsx
37
+ import Modal from './compoments/modal.js'
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 Modal = ({ content, onClose }: ModalConfig) => (
46
- <div className="modal-overlay">
47
- <div className="modal-content">
48
- {content}
49
- <button onClick={onClose}>Close</button>
50
- </div>
51
- </div>
49
+ const AntdModal = ({ config }: { config: ModalConfig }) => (
50
+ <Modal
51
+ visible={true}
52
+ onClose={() => {console.log('close')}}
53
+ >
54
+ {config.content}
55
+ </Modal>
52
56
  )
53
57
 
54
58
  export const showModal = (config: ModalConfig) => {
55
- // 创建容器
56
59
  const container = document.createElement('div')
57
- container.id = 'global-modal-container'
60
+ container.id = 'antd-modal-container'
58
61
  document.body.appendChild(container)
59
62
 
60
- // 渲染弹窗
61
63
  modalRoot = ReactDOM.createRoot(container)
62
64
  modalRoot.render(
63
- <Modal
64
- {...config}
65
- onClose={() => {
66
- config.onClose?.()
67
- destroyModal()
65
+ <AntdModal
66
+ config={{
67
+ ...config,
68
+ onClose: () => {
69
+ config.onClose?.()
70
+ destroyModal()
71
+ }
68
72
  }}
69
73
  />
70
74
  )
@@ -73,7 +77,7 @@ export const showModal = (config: ModalConfig) => {
73
77
  const destroyModal = () => {
74
78
  if (modalRoot) {
75
79
  modalRoot.unmount()
76
- document.getElementById('global-modal-container')?.remove()
80
+ document.getElementById('antd-modal-container')?.remove()
77
81
  modalRoot = null
78
82
  }
79
83
  }