@mi-avalon/libs 0.0.7 → 0.0.8
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/package.json +12 -5
- package/src/components/ItemsRow/index.scss +0 -18
- package/src/components/ItemsRow/index.tsx +0 -85
- package/src/components/MBreadcrumb/index.scss +0 -82
- package/src/components/MBreadcrumb/index.tsx +0 -93
- package/src/components/MDescriptions/index.tsx +0 -131
- package/src/components/MForm/MFormItemConst.tsx +0 -206
- package/src/components/MForm/index.scss +0 -13
- package/src/components/MForm/index.tsx +0 -97
- package/src/components/MForm/type.ts +0 -229
- package/src/components/MSearch/index.scss +0 -63
- package/src/components/MSearch/index.tsx +0 -173
- package/src/components/MTable/index.tsx +0 -22
- package/src/components/MiModal/index.tsx +0 -106
- package/src/components/ThemeContext/CompThemeProvider.tsx +0 -19
- package/src/components/ThemeContext/index.ts +0 -20
- package/src/components/index.ts +0 -9
- package/src/constants/date.ts +0 -11
- package/src/constants/index.ts +0 -3
- package/src/constants/pageInfo.ts +0 -1
- package/src/constants/pattern.ts +0 -53
- package/src/hooks/index.ts +0 -7
- package/src/hooks/useFuncRequest.ts +0 -100
- package/src/hooks/useInterval.ts +0 -50
- package/src/hooks/usePagination.ts +0 -184
- package/src/hooks/useQuery.ts +0 -6
- package/src/hooks/useReactive.ts +0 -26
- package/src/hooks/useTimeout.ts +0 -50
- package/src/hooks/useVirtualList.ts +0 -209
- package/src/index.tsx +0 -4
- package/src/utils/calc.ts +0 -92
- package/src/utils/index.ts +0 -5
- package/src/utils/nextTick.ts +0 -89
- package/src/utils/openModal.tsx +0 -137
- package/src/utils/util.ts +0 -37
- package/src/utils/version.ts +0 -206
package/package.json
CHANGED
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
"name": "@mi-avalon/libs",
|
|
3
3
|
"author": "顾冬杰",
|
|
4
4
|
"module": "dist/lib.esm.js",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.8",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"typings": "dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
|
-
"dist"
|
|
11
|
-
"src"
|
|
10
|
+
"dist"
|
|
12
11
|
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/libs.esm.js",
|
|
15
|
+
"require": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./*": "./dist/*"
|
|
19
|
+
},
|
|
13
20
|
"engines": {
|
|
14
21
|
"node": ">=18"
|
|
15
22
|
},
|
|
@@ -25,8 +32,8 @@
|
|
|
25
32
|
"peerDependencies": {
|
|
26
33
|
"antd": ">=5",
|
|
27
34
|
"lodash": ">=4",
|
|
28
|
-
"react": ">=18",
|
|
29
|
-
"react-dom": ">=18"
|
|
35
|
+
"react": ">=18.0.0 || ^19.0.0",
|
|
36
|
+
"react-dom": ">=18.0.0 || ^19.0.0"
|
|
30
37
|
},
|
|
31
38
|
"husky": {
|
|
32
39
|
"hooks": {
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
$comp-name: 'items-row';
|
|
2
|
-
|
|
3
|
-
.#{$comp-name} {
|
|
4
|
-
display: flex;
|
|
5
|
-
height: 100%;
|
|
6
|
-
flex-direction: row;
|
|
7
|
-
justify-content: center;
|
|
8
|
-
align-items: center;
|
|
9
|
-
white-space: nowrap;
|
|
10
|
-
|
|
11
|
-
&-item {
|
|
12
|
-
margin-left: 10px;
|
|
13
|
-
max-width: 300px;
|
|
14
|
-
vertical-align: middle;
|
|
15
|
-
display: inline-block;
|
|
16
|
-
line-height: 0;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { Button, ButtonProps } from 'antd';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { getClassName } from '../../utils';
|
|
4
|
-
import CompThemeProvider from '../ThemeContext/CompThemeProvider';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 默认配置按钮,也可以通过render() 渲染其他组件
|
|
8
|
-
*/
|
|
9
|
-
export interface IRowItem {
|
|
10
|
-
/**
|
|
11
|
-
* 按钮名称
|
|
12
|
-
*/
|
|
13
|
-
label?: string;
|
|
14
|
-
/**
|
|
15
|
-
* 按钮类型
|
|
16
|
-
*/
|
|
17
|
-
type?: ButtonProps['type'];
|
|
18
|
-
/**
|
|
19
|
-
* 如果没有指定Render,则是按钮的onClick
|
|
20
|
-
*/
|
|
21
|
-
onClick?: (e: any) => void;
|
|
22
|
-
/**
|
|
23
|
-
* 其他按钮属性
|
|
24
|
-
*/
|
|
25
|
-
btnProps?: ButtonProps;
|
|
26
|
-
/**
|
|
27
|
-
* item 的className
|
|
28
|
-
*/
|
|
29
|
-
className?: string;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 自定义渲染
|
|
33
|
-
*/
|
|
34
|
-
render?: () => React.ReactNode;
|
|
35
|
-
}
|
|
36
|
-
export interface IItemRowProps {
|
|
37
|
-
route?: Array<{ name: string; url?: string }>;
|
|
38
|
-
items?: IRowItem[];
|
|
39
|
-
style?: React.CSSProperties;
|
|
40
|
-
className?: string;
|
|
41
|
-
offsetTop?: number;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const classname = (n: string = '') => {
|
|
45
|
-
const cn = 'items-row';
|
|
46
|
-
return getClassName(cn, n);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const ItemsRow = (props: IItemRowProps) => {
|
|
50
|
-
if (!props.items) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
return (
|
|
54
|
-
<CompThemeProvider>
|
|
55
|
-
<div
|
|
56
|
-
className={`${classname()} ${props.className || ''}`}
|
|
57
|
-
style={props.style}
|
|
58
|
-
>
|
|
59
|
-
{(props.items || []).map((item, index) => {
|
|
60
|
-
const className = `${classname('item')} ${item.className}`;
|
|
61
|
-
if (item.render) {
|
|
62
|
-
return (
|
|
63
|
-
<span key={index} className={className}>
|
|
64
|
-
{item.render()}
|
|
65
|
-
</span>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
return (
|
|
69
|
-
<Button
|
|
70
|
-
key={item.label}
|
|
71
|
-
className={className}
|
|
72
|
-
{...item.btnProps}
|
|
73
|
-
type={item.type || 'primary'}
|
|
74
|
-
onClick={item.onClick}
|
|
75
|
-
>
|
|
76
|
-
{item.label}
|
|
77
|
-
</Button>
|
|
78
|
-
);
|
|
79
|
-
})}
|
|
80
|
-
</div>
|
|
81
|
-
</CompThemeProvider>
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export default ItemsRow;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
$comp-name: 'm-breadcrumb';
|
|
2
|
-
|
|
3
|
-
@keyframes #{$comp-name}_show_ani {
|
|
4
|
-
0% {
|
|
5
|
-
opacity: 0;
|
|
6
|
-
}
|
|
7
|
-
100% {
|
|
8
|
-
opacity: 100;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.#{$comp-name} {
|
|
13
|
-
position: relative;
|
|
14
|
-
height: 64px;
|
|
15
|
-
width: 100%;
|
|
16
|
-
|
|
17
|
-
&-container {
|
|
18
|
-
transition: padding 0.3s ease;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&-body {
|
|
22
|
-
border-radius: 8px;
|
|
23
|
-
height: 64px;
|
|
24
|
-
line-height: 64px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.ant-card-body {
|
|
28
|
-
width: 100%;
|
|
29
|
-
padding: 0 12px;
|
|
30
|
-
align-items: center;
|
|
31
|
-
// background-color: var(--ant-color-bg-container); // 使用主题背景色
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.ant-affix {
|
|
35
|
-
z-index: 999;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.ant-affix > &-container {
|
|
39
|
-
z-index: 100;
|
|
40
|
-
width: auto;
|
|
41
|
-
box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12),
|
|
42
|
-
0 9px 28px 8px rgba(0, 0, 0, 0.05);
|
|
43
|
-
// box-shadow: var(--ant-box-shadow); // 使用主题阴影
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&-inner-breadcrumb {
|
|
47
|
-
display: inline-block;
|
|
48
|
-
vertical-align: middle;
|
|
49
|
-
line-height: 64px;
|
|
50
|
-
|
|
51
|
-
.ant-breadcrumb {
|
|
52
|
-
&-separator {
|
|
53
|
-
margin: 0 8px;
|
|
54
|
-
// color: var(--ant-color-text-secondary); // 使用主题文本颜色
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&-link {
|
|
58
|
-
// color: var(--ant-color-text); // 使用主题文本颜色
|
|
59
|
-
> a {
|
|
60
|
-
transition: all 0.3s;
|
|
61
|
-
padding: 4px 8px;
|
|
62
|
-
display: inline-block;
|
|
63
|
-
line-height: 1.5;
|
|
64
|
-
|
|
65
|
-
&:hover {
|
|
66
|
-
// background-color: var(--ant-color-primary-bg); // 使用主题主色背景
|
|
67
|
-
font-weight: bold;
|
|
68
|
-
text-decoration: none;
|
|
69
|
-
opacity: 0.8;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
&-custom-item-wrapper {
|
|
77
|
-
float: right;
|
|
78
|
-
height: 100%;
|
|
79
|
-
display: flex;
|
|
80
|
-
align-items: center;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { Affix, AffixRef, Breadcrumb, Card } from 'antd';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { getClassName } from '../../utils';
|
|
4
|
-
import ItemRow, { IRowItem } from '../ItemsRow';
|
|
5
|
-
import CompThemeProvider from '../ThemeContext/CompThemeProvider';
|
|
6
|
-
import './index.scss';
|
|
7
|
-
|
|
8
|
-
export interface RouteItem {
|
|
9
|
-
name: string;
|
|
10
|
-
url?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface IMBreadcrumbProps {
|
|
14
|
-
routes?: RouteItem[];
|
|
15
|
-
customItems?: IRowItem[];
|
|
16
|
-
style?: React.CSSProperties;
|
|
17
|
-
className?: string;
|
|
18
|
-
offsetTop?: number;
|
|
19
|
-
mainAppBaseUrl?: string;
|
|
20
|
-
microAppName?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const classname = (n: string = '') => {
|
|
24
|
-
const cn = 'm-breadcrumb';
|
|
25
|
-
return getClassName(cn, n);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const MBreadcrumb: React.FC<IMBreadcrumbProps> = props => {
|
|
29
|
-
const {
|
|
30
|
-
routes,
|
|
31
|
-
customItems,
|
|
32
|
-
style,
|
|
33
|
-
className,
|
|
34
|
-
offsetTop = 64,
|
|
35
|
-
mainAppBaseUrl,
|
|
36
|
-
microAppName,
|
|
37
|
-
} = props;
|
|
38
|
-
|
|
39
|
-
const affixRef = React.useRef<AffixRef>(null);
|
|
40
|
-
|
|
41
|
-
const onScroll = React.useCallback(() => {
|
|
42
|
-
affixRef.current?.updatePosition?.();
|
|
43
|
-
}, []);
|
|
44
|
-
|
|
45
|
-
React.useEffect(() => {
|
|
46
|
-
window.addEventListener('scroll', onScroll, true);
|
|
47
|
-
return () => window.removeEventListener('scroll', onScroll);
|
|
48
|
-
}, [onScroll]);
|
|
49
|
-
|
|
50
|
-
const getUrl = React.useCallback(
|
|
51
|
-
(url: string) => {
|
|
52
|
-
if (!url) return '';
|
|
53
|
-
const cleanedUrl = url.replace(/^\/+/, '');
|
|
54
|
-
const parts = [
|
|
55
|
-
mainAppBaseUrl?.replace(/\/+$/, ''),
|
|
56
|
-
microAppName?.replace(/\/+$/, ''),
|
|
57
|
-
cleanedUrl,
|
|
58
|
-
].filter(Boolean);
|
|
59
|
-
return `/${parts.join('/')}`;
|
|
60
|
-
},
|
|
61
|
-
[mainAppBaseUrl, microAppName]
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<CompThemeProvider>
|
|
66
|
-
<div className={`${classname()} ${className || ''}`} style={style}>
|
|
67
|
-
<Affix ref={affixRef} offsetTop={offsetTop}>
|
|
68
|
-
<Card
|
|
69
|
-
className={classname('container')}
|
|
70
|
-
rootClassName={classname('body')}
|
|
71
|
-
variant="borderless"
|
|
72
|
-
>
|
|
73
|
-
<Breadcrumb
|
|
74
|
-
className={classname('inner-breadcrumb')}
|
|
75
|
-
style={{ fontSize: '18px' }}
|
|
76
|
-
>
|
|
77
|
-
{routes?.map(v => (
|
|
78
|
-
<Breadcrumb.Item key={v.url || v.name}>
|
|
79
|
-
{v.url ? <a href={`#${getUrl(v.url)}`}>{v.name}</a> : v.name}
|
|
80
|
-
</Breadcrumb.Item>
|
|
81
|
-
))}
|
|
82
|
-
</Breadcrumb>
|
|
83
|
-
<div className={classname('custom-item-wrapper')}>
|
|
84
|
-
<ItemRow items={customItems} />
|
|
85
|
-
</div>
|
|
86
|
-
</Card>
|
|
87
|
-
</Affix>
|
|
88
|
-
</div>
|
|
89
|
-
</CompThemeProvider>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export default MBreadcrumb;
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 详情描述列表组件
|
|
3
|
-
* 用于展示对象的详细信息,如用户信息、产品详情等
|
|
4
|
-
*/
|
|
5
|
-
import { Descriptions } from 'antd';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import CompThemeProvider from '../ThemeContext/CompThemeProvider';
|
|
8
|
-
|
|
9
|
-
export interface IMDescriptionItem {
|
|
10
|
-
label: React.ReactNode;
|
|
11
|
-
value: React.ReactNode;
|
|
12
|
-
span?: number; // 可选项,控制该项跨越的列数
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface IMDescriptionProps {
|
|
16
|
-
/**
|
|
17
|
-
* 描述列表的数据[{label: '', value: '',}, ...]
|
|
18
|
-
*/
|
|
19
|
-
data: IMDescriptionItem[];
|
|
20
|
-
/**
|
|
21
|
-
* 标题
|
|
22
|
-
*/
|
|
23
|
-
title?: React.ReactNode;
|
|
24
|
-
/**
|
|
25
|
-
* 需要显示的列数
|
|
26
|
-
* @default 3
|
|
27
|
-
*/
|
|
28
|
-
column?: 1 | 2 | 3 | 4;
|
|
29
|
-
/**
|
|
30
|
-
* 行高
|
|
31
|
-
*/
|
|
32
|
-
lineHeight?: number;
|
|
33
|
-
/**
|
|
34
|
-
* 标签对齐方式
|
|
35
|
-
* @default 'left'
|
|
36
|
-
*/
|
|
37
|
-
align?: 'left' | 'center' | 'right';
|
|
38
|
-
/**
|
|
39
|
-
* 标签和值的布局配置
|
|
40
|
-
*/
|
|
41
|
-
itemLayout?: {
|
|
42
|
-
label?: number | undefined;
|
|
43
|
-
value?: number | undefined;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* 是否显示冒号
|
|
47
|
-
* @default true
|
|
48
|
-
*/
|
|
49
|
-
colon?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* 是否显示边框
|
|
52
|
-
* @default false
|
|
53
|
-
*/
|
|
54
|
-
bordered?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* 自定义样式
|
|
57
|
-
*/
|
|
58
|
-
style?: React.CSSProperties;
|
|
59
|
-
/**
|
|
60
|
-
* 自定义类名
|
|
61
|
-
*/
|
|
62
|
-
className?: string;
|
|
63
|
-
/**
|
|
64
|
-
* 标签样式
|
|
65
|
-
*/
|
|
66
|
-
labelStyle?: React.CSSProperties;
|
|
67
|
-
/**
|
|
68
|
-
* 内容样式
|
|
69
|
-
*/
|
|
70
|
-
contentStyle?: React.CSSProperties;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const DetailDescriptions: React.FC<IMDescriptionProps> = props => {
|
|
74
|
-
const {
|
|
75
|
-
data,
|
|
76
|
-
title,
|
|
77
|
-
column = 3,
|
|
78
|
-
lineHeight,
|
|
79
|
-
align = 'left',
|
|
80
|
-
itemLayout,
|
|
81
|
-
colon = true,
|
|
82
|
-
bordered = false,
|
|
83
|
-
style,
|
|
84
|
-
className,
|
|
85
|
-
labelStyle,
|
|
86
|
-
contentStyle,
|
|
87
|
-
} = props;
|
|
88
|
-
|
|
89
|
-
// 合并样式
|
|
90
|
-
const mergedLabelStyle = {
|
|
91
|
-
...(lineHeight ? { lineHeight: `${lineHeight}px` } : {}),
|
|
92
|
-
textAlign: align,
|
|
93
|
-
...(itemLayout?.label ? { width: `${itemLayout.label}px` } : {}),
|
|
94
|
-
...labelStyle,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const mergedContentStyle = {
|
|
98
|
-
...(lineHeight ? { lineHeight: `${lineHeight}px` } : {}),
|
|
99
|
-
...(itemLayout?.value ? { width: `${itemLayout.value}px` } : {}),
|
|
100
|
-
...contentStyle,
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<CompThemeProvider>
|
|
105
|
-
<Descriptions
|
|
106
|
-
title={title}
|
|
107
|
-
column={column}
|
|
108
|
-
colon={colon}
|
|
109
|
-
bordered={bordered}
|
|
110
|
-
style={style}
|
|
111
|
-
className={className}
|
|
112
|
-
labelStyle={mergedLabelStyle}
|
|
113
|
-
contentStyle={mergedContentStyle}
|
|
114
|
-
>
|
|
115
|
-
{data.map((item, index) => (
|
|
116
|
-
<Descriptions.Item
|
|
117
|
-
label={item.label}
|
|
118
|
-
key={item.label?.toString() || index}
|
|
119
|
-
span={item.span}
|
|
120
|
-
>
|
|
121
|
-
{item.value || '-'}
|
|
122
|
-
</Descriptions.Item>
|
|
123
|
-
))}
|
|
124
|
-
</Descriptions>
|
|
125
|
-
</CompThemeProvider>
|
|
126
|
-
);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
DetailDescriptions.displayName = 'DetailDescriptions';
|
|
130
|
-
|
|
131
|
-
export default DetailDescriptions;
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { UploadOutlined } from '@ant-design/icons';
|
|
2
|
-
import {
|
|
3
|
-
Button,
|
|
4
|
-
Cascader,
|
|
5
|
-
Checkbox,
|
|
6
|
-
DatePicker,
|
|
7
|
-
Input,
|
|
8
|
-
InputNumber,
|
|
9
|
-
Mentions,
|
|
10
|
-
Radio,
|
|
11
|
-
Select,
|
|
12
|
-
Slider,
|
|
13
|
-
TreeSelect,
|
|
14
|
-
Upload,
|
|
15
|
-
} from 'antd';
|
|
16
|
-
import React from 'react';
|
|
17
|
-
import {
|
|
18
|
-
IMFormCascaderItem,
|
|
19
|
-
IMFormChkBoxGroupItem,
|
|
20
|
-
IMFormDatePickerItem,
|
|
21
|
-
IMFormInputItem,
|
|
22
|
-
IMFormInputNumItem,
|
|
23
|
-
IMFormItem,
|
|
24
|
-
IMFormMentionsItem,
|
|
25
|
-
IMFormRadioGroupItem,
|
|
26
|
-
IMFormRangePickerItem,
|
|
27
|
-
IMFormSelectItem,
|
|
28
|
-
IMFormSliderItem,
|
|
29
|
-
IMFormTextItem,
|
|
30
|
-
IMFormTreeSelectItem,
|
|
31
|
-
IMFormUploadItem,
|
|
32
|
-
MFormItemTypeEnum,
|
|
33
|
-
} from './type';
|
|
34
|
-
|
|
35
|
-
const { RangePicker } = DatePicker;
|
|
36
|
-
|
|
37
|
-
export class MFormItemConst {
|
|
38
|
-
static readonly labelCol = { span: 7 };
|
|
39
|
-
static readonly wrapperCol = { span: 17 };
|
|
40
|
-
static readonly defaultRowGutter = 24;
|
|
41
|
-
|
|
42
|
-
static getDefaultArrayPlaceholder(item: IMFormItem) {
|
|
43
|
-
let placeholder;
|
|
44
|
-
switch (item.type) {
|
|
45
|
-
case 'rangePicker':
|
|
46
|
-
placeholder = ['开始时间', '结束时间'];
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
return placeholder as [string, string];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
static getDefaultPlaceholder(item: IMFormItem) {
|
|
53
|
-
let placeholder;
|
|
54
|
-
switch (item.type) {
|
|
55
|
-
case MFormItemTypeEnum.Input:
|
|
56
|
-
case MFormItemTypeEnum.Password:
|
|
57
|
-
case MFormItemTypeEnum.InputNumber:
|
|
58
|
-
case MFormItemTypeEnum.Text:
|
|
59
|
-
case MFormItemTypeEnum.Mentions:
|
|
60
|
-
placeholder = `请输入${item.label}`;
|
|
61
|
-
break;
|
|
62
|
-
case MFormItemTypeEnum.Select:
|
|
63
|
-
case MFormItemTypeEnum.Checkbox:
|
|
64
|
-
case MFormItemTypeEnum.Radio:
|
|
65
|
-
case MFormItemTypeEnum.DatePicker:
|
|
66
|
-
case MFormItemTypeEnum.RangePicker:
|
|
67
|
-
case MFormItemTypeEnum.Cascader:
|
|
68
|
-
case MFormItemTypeEnum.Upload:
|
|
69
|
-
case MFormItemTypeEnum.TreeSelect:
|
|
70
|
-
placeholder = `请选择${item.label}`;
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
return placeholder;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static input = (item: IMFormInputItem) => (
|
|
77
|
-
<Input
|
|
78
|
-
disabled={item.disabled}
|
|
79
|
-
maxLength={item.maxLength}
|
|
80
|
-
{...item.props}
|
|
81
|
-
placeholder={
|
|
82
|
-
item.placeholder || MFormItemConst.getDefaultPlaceholder(item)
|
|
83
|
-
}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
static password = (item: IMFormInputItem) => (
|
|
88
|
-
<Input.Password
|
|
89
|
-
disabled={item.disabled}
|
|
90
|
-
{...item.props}
|
|
91
|
-
placeholder={
|
|
92
|
-
item.placeholder || MFormItemConst.getDefaultPlaceholder(item)
|
|
93
|
-
}
|
|
94
|
-
/>
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
static text = (item: IMFormTextItem) => (
|
|
98
|
-
<Input.TextArea
|
|
99
|
-
disabled={item.disabled}
|
|
100
|
-
maxLength={item.maxLength}
|
|
101
|
-
{...item.props}
|
|
102
|
-
placeholder={
|
|
103
|
-
item.placeholder || MFormItemConst.getDefaultPlaceholder(item)
|
|
104
|
-
}
|
|
105
|
-
/>
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
static inputNumber = (item: IMFormInputNumItem) => (
|
|
109
|
-
<InputNumber
|
|
110
|
-
disabled={item.disabled}
|
|
111
|
-
maxLength={item.maxLength}
|
|
112
|
-
{...item.props}
|
|
113
|
-
placeholder={
|
|
114
|
-
item.placeholder || MFormItemConst.getDefaultPlaceholder(item)
|
|
115
|
-
}
|
|
116
|
-
/>
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
static datePicker = (item: IMFormDatePickerItem) => (
|
|
120
|
-
<DatePicker
|
|
121
|
-
disabled={item.disabled}
|
|
122
|
-
{...item.props}
|
|
123
|
-
placeholder={
|
|
124
|
-
item.placeholder || MFormItemConst.getDefaultPlaceholder(item)
|
|
125
|
-
}
|
|
126
|
-
/>
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
static rangePicker = (item: IMFormRangePickerItem) => (
|
|
130
|
-
<RangePicker
|
|
131
|
-
disabled={item.disabled}
|
|
132
|
-
{...item.props}
|
|
133
|
-
placeholder={
|
|
134
|
-
item.placeholder || MFormItemConst.getDefaultArrayPlaceholder(item)
|
|
135
|
-
}
|
|
136
|
-
/>
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
static select = (item: IMFormSelectItem) => {
|
|
140
|
-
return (
|
|
141
|
-
<Select
|
|
142
|
-
{...item.props}
|
|
143
|
-
disabled={item.disabled}
|
|
144
|
-
placeholder={
|
|
145
|
-
item.placeholder || MFormItemConst.getDefaultPlaceholder(item)
|
|
146
|
-
}
|
|
147
|
-
></Select>
|
|
148
|
-
);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
static radio = (item: IMFormRadioGroupItem) => {
|
|
152
|
-
return <Radio.Group disabled={item.disabled} {...item.props} />;
|
|
153
|
-
};
|
|
154
|
-
static checkbox = (item: IMFormChkBoxGroupItem) => {
|
|
155
|
-
return <Checkbox.Group disabled={item.disabled} {...item.props} />;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
static upload = (item: IMFormUploadItem) => {
|
|
159
|
-
return (
|
|
160
|
-
<Upload defaultFileList={item.initialValue} {...item.props}>
|
|
161
|
-
{item.children || (
|
|
162
|
-
<Button>
|
|
163
|
-
<UploadOutlined /> 点击上传
|
|
164
|
-
</Button>
|
|
165
|
-
)}
|
|
166
|
-
</Upload>
|
|
167
|
-
);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
static mentions = (item: IMFormMentionsItem) => {
|
|
171
|
-
return (
|
|
172
|
-
<Mentions
|
|
173
|
-
{...item.props}
|
|
174
|
-
placeholder={
|
|
175
|
-
item.placeholder || MFormItemConst.getDefaultPlaceholder(item)
|
|
176
|
-
}
|
|
177
|
-
/>
|
|
178
|
-
);
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
static cascader = (item: IMFormCascaderItem) => {
|
|
182
|
-
return (
|
|
183
|
-
<Cascader
|
|
184
|
-
{...item.props}
|
|
185
|
-
placeholder={
|
|
186
|
-
item.placeholder || MFormItemConst.getDefaultPlaceholder(item)
|
|
187
|
-
}
|
|
188
|
-
/>
|
|
189
|
-
);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
static treeSelect = (item: IMFormTreeSelectItem) => {
|
|
193
|
-
return (
|
|
194
|
-
<TreeSelect
|
|
195
|
-
{...item.props}
|
|
196
|
-
placeholder={
|
|
197
|
-
item.placeholder || MFormItemConst.getDefaultPlaceholder(item)
|
|
198
|
-
}
|
|
199
|
-
/>
|
|
200
|
-
);
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
static slider = (item: IMFormSliderItem) => {
|
|
204
|
-
return <Slider {...item.props} />;
|
|
205
|
-
};
|
|
206
|
-
}
|