@mi-avalon/libs 0.0.24 → 0.0.26
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/components/MiModal/index.d.ts +15 -0
- package/dist/components/MiModal/index.js +70 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -1
- package/dist/constants/date.d.ts +2 -0
- package/dist/constants/date.js +2 -0
- package/dist/constants/pattern.d.ts +66 -0
- package/dist/constants/pattern.js +66 -22
- package/dist/index.es.js +1647 -1180
- package/dist/index.umd.js +15 -15
- package/dist/utils/calc.d.ts +179 -12
- package/dist/utils/calc.js +355 -81
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -1
- package/dist/utils/openModal.d.ts +15 -0
- package/dist/utils/openModal.js +98 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ThemeConfig } from 'antd';
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import { IModalBaseProps } from '../../utils';
|
|
4
|
+
export type IMiModalProps = IModalBaseProps & {
|
|
5
|
+
mode?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class MiModal extends Component<IMiModalProps> {
|
|
8
|
+
static setMode: (mode: string) => void;
|
|
9
|
+
static setThemeConfig: (fn: (m: string) => ThemeConfig) => void;
|
|
10
|
+
static open: (props: IMiModalProps) => import("../../utils").IModalControls<IMiModalProps>;
|
|
11
|
+
getTheme(): ThemeConfig;
|
|
12
|
+
handleCancel: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
13
|
+
handleOk: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
14
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Modal as AntModal, ConfigProvider, theme } from 'antd';
|
|
3
|
+
import { Component } from 'react';
|
|
4
|
+
import { openModal } from '../../utils';
|
|
5
|
+
// 全局状态管理
|
|
6
|
+
let globalMode = 'default';
|
|
7
|
+
const modalInstances = [];
|
|
8
|
+
let getThemeConfig = (mode) => {
|
|
9
|
+
switch (mode) {
|
|
10
|
+
case 'light':
|
|
11
|
+
return {
|
|
12
|
+
algorithm: [theme.defaultAlgorithm],
|
|
13
|
+
};
|
|
14
|
+
case 'dark':
|
|
15
|
+
return {
|
|
16
|
+
algorithm: [theme.darkAlgorithm],
|
|
17
|
+
};
|
|
18
|
+
default:
|
|
19
|
+
return {
|
|
20
|
+
algorithm: [theme.defaultAlgorithm],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export class MiModal extends Component {
|
|
25
|
+
// 静态方法设置全局模式并更新所有弹窗
|
|
26
|
+
static setMode = (mode) => {
|
|
27
|
+
globalMode = mode;
|
|
28
|
+
// 更新所有已打开的弹窗
|
|
29
|
+
modalInstances.forEach(instance => {
|
|
30
|
+
instance.update({ mode });
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
// 静态方法设置全局ThemeConfig
|
|
34
|
+
static setThemeConfig = (fn) => {
|
|
35
|
+
getThemeConfig = fn;
|
|
36
|
+
};
|
|
37
|
+
static open = (props) => {
|
|
38
|
+
const instance = openModal(MiModal, {
|
|
39
|
+
mode: globalMode, // 默认使用全局主题
|
|
40
|
+
...props,
|
|
41
|
+
});
|
|
42
|
+
// 注册实例以便全局更新
|
|
43
|
+
modalInstances.push(instance);
|
|
44
|
+
// 添加销毁时的清理逻辑
|
|
45
|
+
const originalDestroy = instance.destroy;
|
|
46
|
+
instance.destroy = (...args) => {
|
|
47
|
+
const index = modalInstances.indexOf(instance);
|
|
48
|
+
if (index !== -1) {
|
|
49
|
+
modalInstances.splice(index, 1);
|
|
50
|
+
}
|
|
51
|
+
return originalDestroy(...args);
|
|
52
|
+
};
|
|
53
|
+
return instance;
|
|
54
|
+
};
|
|
55
|
+
getTheme() {
|
|
56
|
+
const mode = this.props.mode || globalMode;
|
|
57
|
+
return getThemeConfig(mode);
|
|
58
|
+
}
|
|
59
|
+
handleCancel = (e) => {
|
|
60
|
+
this.props.onCancel?.(e);
|
|
61
|
+
this.props.onClosed?.({ cancel: true });
|
|
62
|
+
};
|
|
63
|
+
handleOk = (e) => {
|
|
64
|
+
this.props.onOk?.(e);
|
|
65
|
+
this.props.onClosed?.({ ok: true });
|
|
66
|
+
};
|
|
67
|
+
render() {
|
|
68
|
+
return (_jsx(ConfigProvider, { theme: this.getTheme(), componentSize: 'middle', componentDisabled: false, children: _jsx(AntModal, { maskClosable: false, open: this.props.open, onCancel: this.handleCancel, onOk: this.handleOk, okText: '\u786E\u5B9A', cancelText: '\u53D6\u6D88', ...this.props, children: this.props.children }) }));
|
|
69
|
+
}
|
|
70
|
+
}
|
package/dist/components/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export * from './MBreadcrumb';
|
|
|
3
3
|
export * from './MDescriptions';
|
|
4
4
|
export * from './MForm';
|
|
5
5
|
export { default as MForm } from './MForm';
|
|
6
|
-
|
|
6
|
+
export * from './MiModal';
|
|
7
7
|
export * from './MSearch';
|
|
8
8
|
export * from './MTable';
|
|
9
9
|
export * from './ThemeContext';
|
package/dist/constants/date.d.ts
CHANGED
package/dist/constants/date.js
CHANGED
|
@@ -1,24 +1,90 @@
|
|
|
1
1
|
export declare class PatternType {
|
|
2
|
+
/**
|
|
3
|
+
* 整数
|
|
4
|
+
*/
|
|
2
5
|
static readonly integerRegex: RegExp;
|
|
6
|
+
/**
|
|
7
|
+
* 正整数
|
|
8
|
+
*/
|
|
3
9
|
static readonly positiveIntegerRegex: RegExp;
|
|
10
|
+
/**
|
|
11
|
+
* 负整数
|
|
12
|
+
*/
|
|
4
13
|
static readonly negativeIntegerRegex: RegExp;
|
|
14
|
+
/**
|
|
15
|
+
* 浮点数
|
|
16
|
+
*/
|
|
5
17
|
static readonly floatRegex: RegExp;
|
|
18
|
+
/**
|
|
19
|
+
* 字母
|
|
20
|
+
*/
|
|
6
21
|
static readonly letter: RegExp;
|
|
22
|
+
/**
|
|
23
|
+
* 汉字
|
|
24
|
+
*/
|
|
7
25
|
static readonly chinese: RegExp;
|
|
26
|
+
/**
|
|
27
|
+
* 数字
|
|
28
|
+
*/
|
|
8
29
|
static readonly number: RegExp;
|
|
30
|
+
/**
|
|
31
|
+
* 用户名 字母开头,允许字母数字下划线,长度4-16
|
|
32
|
+
*/
|
|
9
33
|
static readonly username: RegExp;
|
|
34
|
+
/**
|
|
35
|
+
* 强用户名 必须包含大小写字母和数字,6-20位
|
|
36
|
+
*/
|
|
10
37
|
static readonly strongUsername: RegExp;
|
|
38
|
+
/**
|
|
39
|
+
* 密码 至少8位,包含字母和数字
|
|
40
|
+
*/
|
|
11
41
|
static readonly password: RegExp;
|
|
42
|
+
/**
|
|
43
|
+
* 强密码 至少8位,包含大小写字母、数字和特殊字符
|
|
44
|
+
*/
|
|
12
45
|
static readonly strongPassword: RegExp;
|
|
46
|
+
/**
|
|
47
|
+
* 中国大陆的手机号
|
|
48
|
+
*/
|
|
13
49
|
static readonly phone: RegExp;
|
|
50
|
+
/**
|
|
51
|
+
* 带区号的手机号
|
|
52
|
+
*/
|
|
14
53
|
static readonly phoneWithAreaCode: RegExp;
|
|
54
|
+
/**
|
|
55
|
+
* 邮箱
|
|
56
|
+
*/
|
|
15
57
|
static readonly email: RegExp;
|
|
58
|
+
/**
|
|
59
|
+
* 身份证
|
|
60
|
+
*/
|
|
16
61
|
static readonly idCard: RegExp;
|
|
62
|
+
/**
|
|
63
|
+
* 银行卡
|
|
64
|
+
*/
|
|
17
65
|
static readonly bankCard: RegExp;
|
|
66
|
+
/**
|
|
67
|
+
* 邮政编码
|
|
68
|
+
*/
|
|
18
69
|
static readonly zipCode: RegExp;
|
|
70
|
+
/**
|
|
71
|
+
* IP
|
|
72
|
+
*/
|
|
19
73
|
static readonly ip: RegExp;
|
|
74
|
+
/**
|
|
75
|
+
* URL
|
|
76
|
+
*/
|
|
20
77
|
static readonly url: RegExp;
|
|
78
|
+
/**
|
|
79
|
+
* 车牌
|
|
80
|
+
*/
|
|
21
81
|
static readonly carNumber: RegExp;
|
|
82
|
+
/**
|
|
83
|
+
* 时间 hh:mm:ss
|
|
84
|
+
*/
|
|
22
85
|
static readonly time: RegExp;
|
|
86
|
+
/**
|
|
87
|
+
* 日期 YYYY-MM-DD
|
|
88
|
+
*/
|
|
23
89
|
static readonly date: RegExp;
|
|
24
90
|
}
|
|
@@ -1,46 +1,90 @@
|
|
|
1
1
|
export class PatternType {
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* 整数
|
|
4
|
+
*/
|
|
3
5
|
static integerRegex = /^-?\d+$/;
|
|
4
|
-
|
|
6
|
+
/**
|
|
7
|
+
* 正整数
|
|
8
|
+
*/
|
|
5
9
|
static positiveIntegerRegex = /^[1-9]\d*$/;
|
|
6
|
-
|
|
10
|
+
/**
|
|
11
|
+
* 负整数
|
|
12
|
+
*/
|
|
7
13
|
static negativeIntegerRegex = /^-[1-9]\d*$/;
|
|
8
|
-
|
|
14
|
+
/**
|
|
15
|
+
* 浮点数
|
|
16
|
+
*/
|
|
9
17
|
static floatRegex = /^-?\d+(\.\d+)?$/;
|
|
10
|
-
|
|
18
|
+
/**
|
|
19
|
+
* 字母
|
|
20
|
+
*/
|
|
11
21
|
static letter = /^[a-zA-Z]+$/;
|
|
12
|
-
|
|
22
|
+
/**
|
|
23
|
+
* 汉字
|
|
24
|
+
*/
|
|
13
25
|
static chinese = /^[\u4e00-\u9fa5]+$/;
|
|
14
|
-
|
|
26
|
+
/**
|
|
27
|
+
* 数字
|
|
28
|
+
*/
|
|
15
29
|
static number = /^[0-9]*$/;
|
|
16
|
-
|
|
30
|
+
/**
|
|
31
|
+
* 用户名 字母开头,允许字母数字下划线,长度4-16
|
|
32
|
+
*/
|
|
17
33
|
static username = /^[a-zA-Z]\w{3,15}$/;
|
|
18
|
-
|
|
34
|
+
/**
|
|
35
|
+
* 强用户名 必须包含大小写字母和数字,6-20位
|
|
36
|
+
*/
|
|
19
37
|
static strongUsername = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,20}$/;
|
|
20
|
-
|
|
38
|
+
/**
|
|
39
|
+
* 密码 至少8位,包含字母和数字
|
|
40
|
+
*/
|
|
21
41
|
static password = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/;
|
|
22
|
-
|
|
42
|
+
/**
|
|
43
|
+
* 强密码 至少8位,包含大小写字母、数字和特殊字符
|
|
44
|
+
*/
|
|
23
45
|
static strongPassword = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
|
|
24
|
-
|
|
46
|
+
/**
|
|
47
|
+
* 中国大陆的手机号
|
|
48
|
+
*/
|
|
25
49
|
static phone = /^1[3-9]\d{9}$/;
|
|
26
|
-
|
|
50
|
+
/**
|
|
51
|
+
* 带区号的手机号
|
|
52
|
+
*/
|
|
27
53
|
static phoneWithAreaCode = /^\+?\d{2,3}-?\d{8,11}$/;
|
|
28
|
-
|
|
54
|
+
/**
|
|
55
|
+
* 邮箱
|
|
56
|
+
*/
|
|
29
57
|
static email = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
30
|
-
|
|
58
|
+
/**
|
|
59
|
+
* 身份证
|
|
60
|
+
*/
|
|
31
61
|
static idCard = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
|
|
32
|
-
|
|
62
|
+
/**
|
|
63
|
+
* 银行卡
|
|
64
|
+
*/
|
|
33
65
|
static bankCard = /^[1-9]\d{3,30}$/;
|
|
34
|
-
|
|
66
|
+
/**
|
|
67
|
+
* 邮政编码
|
|
68
|
+
*/
|
|
35
69
|
static zipCode = /^[1-9]\d{5}$/;
|
|
36
|
-
|
|
70
|
+
/**
|
|
71
|
+
* IP
|
|
72
|
+
*/
|
|
37
73
|
static ip = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
|
|
38
|
-
|
|
74
|
+
/**
|
|
75
|
+
* URL
|
|
76
|
+
*/
|
|
39
77
|
static url = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/;
|
|
40
|
-
|
|
78
|
+
/**
|
|
79
|
+
* 车牌
|
|
80
|
+
*/
|
|
41
81
|
static carNumber = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/;
|
|
42
|
-
|
|
82
|
+
/**
|
|
83
|
+
* 时间 hh:mm:ss
|
|
84
|
+
*/
|
|
43
85
|
static time = /^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/;
|
|
44
|
-
|
|
86
|
+
/**
|
|
87
|
+
* 日期 YYYY-MM-DD
|
|
88
|
+
*/
|
|
45
89
|
static date = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
46
90
|
}
|