@mi-avalon/libs 1.0.1 → 1.0.2
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/MDescriptions/index.d.ts +11 -2
- package/dist/components/MDescriptions/index.js +8 -3
- package/dist/components/MForm/MFormItemConst.d.ts +4 -4
- package/dist/components/MForm/MFormItemConst.js +3 -2
- package/dist/components/MForm/index.js +5 -2
- package/dist/components/MForm/type.d.ts +15 -13
- package/dist/index.es.js +700 -692
- package/dist/index.umd.js +45 -45
- package/package.json +5 -5
|
@@ -53,13 +53,22 @@ export interface IMDescriptionProps {
|
|
|
53
53
|
*/
|
|
54
54
|
className?: string;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* 标签样式(兼容旧版本)
|
|
57
|
+
* @deprecated 使用styles.label代替
|
|
57
58
|
*/
|
|
58
59
|
labelStyle?: React.CSSProperties;
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
+
* 内容样式(兼容旧版本)
|
|
62
|
+
* @deprecated 使用styles.content代替
|
|
61
63
|
*/
|
|
62
64
|
contentStyle?: React.CSSProperties;
|
|
65
|
+
/**
|
|
66
|
+
* 样式配置对象(antd 6 推荐使用)
|
|
67
|
+
*/
|
|
68
|
+
styles?: {
|
|
69
|
+
label?: React.CSSProperties;
|
|
70
|
+
content?: React.CSSProperties;
|
|
71
|
+
};
|
|
63
72
|
}
|
|
64
73
|
declare const MDescriptions: React.FC<IMDescriptionProps>;
|
|
65
74
|
export { MDescriptions };
|
|
@@ -6,20 +6,25 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import { Descriptions } from 'antd';
|
|
7
7
|
import { CompThemeProvider } from '../ThemeContext';
|
|
8
8
|
const MDescriptions = props => {
|
|
9
|
-
const { data, title, column = 3, lineHeight, align = 'left', itemLayout, colon = true, bordered = false, style, className, labelStyle, contentStyle, } = props;
|
|
10
|
-
//
|
|
9
|
+
const { data, title, column = 3, lineHeight, align = 'left', itemLayout, colon = true, bordered = false, style, className, labelStyle, contentStyle, styles = {}, } = props;
|
|
10
|
+
// 合并样式,优先使用styles(antd 6 推荐),同时兼容旧版的labelStyle和contentStyle
|
|
11
11
|
const mergedLabelStyle = {
|
|
12
12
|
...(lineHeight ? { lineHeight: `${lineHeight}px` } : {}),
|
|
13
13
|
textAlign: align,
|
|
14
14
|
...(itemLayout?.label ? { width: `${itemLayout.label}px` } : {}),
|
|
15
15
|
...labelStyle,
|
|
16
|
+
...styles.label,
|
|
16
17
|
};
|
|
17
18
|
const mergedContentStyle = {
|
|
18
19
|
...(lineHeight ? { lineHeight: `${lineHeight}px` } : {}),
|
|
19
20
|
...(itemLayout?.value ? { width: `${itemLayout.value}px` } : {}),
|
|
20
21
|
...contentStyle,
|
|
22
|
+
...styles.content,
|
|
21
23
|
};
|
|
22
|
-
return (_jsx(CompThemeProvider, { children: _jsx(Descriptions, { title: title, column: column, colon: colon, bordered: bordered, style: style, className: className,
|
|
24
|
+
return (_jsx(CompThemeProvider, { children: _jsx(Descriptions, { title: title, column: column, colon: colon, bordered: bordered, style: style, className: className, styles: {
|
|
25
|
+
label: mergedLabelStyle,
|
|
26
|
+
content: mergedContentStyle,
|
|
27
|
+
}, children: data.map((item, index) => (_jsx(Descriptions.Item, { label: item.label, span: item.span, children: item.value || '-' }, item.label?.toString() || index))) }) }));
|
|
23
28
|
};
|
|
24
29
|
MDescriptions.displayName = 'MDescriptions';
|
|
25
30
|
export { MDescriptions };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type IMFormCascaderItem, type IMFormCheckBoxGroupItem, type IMFormDatePickerItem, type IMFormInputItem, type IMFormInputNumItem, type IMFormItem, type IMFormMentionsItem, type IMFormRadioGroupItem, type IMFormRangePickerItem, type IMFormSelectItem, type IMFormTextItem, type IMFormTreeSelectItem, type IMFormUploadItem } from './type';
|
|
2
2
|
export declare class MFormItemConst {
|
|
3
|
-
static readonly
|
|
4
|
-
|
|
3
|
+
static readonly defaultLabelStyle: {
|
|
4
|
+
flex: string;
|
|
5
5
|
};
|
|
6
|
-
static readonly
|
|
7
|
-
|
|
6
|
+
static readonly defaultContentStyle: {
|
|
7
|
+
flex: string;
|
|
8
8
|
};
|
|
9
9
|
static readonly defaultRowGutter = 24;
|
|
10
10
|
static getDefaultArrayPlaceholder(item: IMFormItem): [string, string];
|
|
@@ -4,8 +4,9 @@ import { Button, Cascader, Checkbox, DatePicker, Input, InputNumber, Mentions, R
|
|
|
4
4
|
import { MFormItemTypeEnum, } from './type';
|
|
5
5
|
const { RangePicker } = DatePicker;
|
|
6
6
|
export class MFormItemConst {
|
|
7
|
-
|
|
8
|
-
static
|
|
7
|
+
// antd 6不再使用labelCol和wrapperCol,改为使用新的布局方式
|
|
8
|
+
static defaultLabelStyle = { flex: '0 0 180px' };
|
|
9
|
+
static defaultContentStyle = { flex: '1 1 auto' };
|
|
9
10
|
static defaultRowGutter = 24;
|
|
10
11
|
static getDefaultArrayPlaceholder(item) {
|
|
11
12
|
let placeholder;
|
|
@@ -32,9 +32,12 @@ function MForm(props) {
|
|
|
32
32
|
if (item.required) {
|
|
33
33
|
rules.push({ required: true, message: item.required });
|
|
34
34
|
}
|
|
35
|
+
// antd 6使用styles替代labelCol和wrapperCol
|
|
35
36
|
const formItemLayout = {
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
styles: {
|
|
38
|
+
label: MFormItemConst.defaultLabelStyle,
|
|
39
|
+
content: MFormItemConst.defaultContentStyle,
|
|
40
|
+
},
|
|
38
41
|
...itemLayout,
|
|
39
42
|
...item.itemLayout,
|
|
40
43
|
};
|
|
@@ -19,9 +19,9 @@ export declare enum MFormItemTypeEnum {
|
|
|
19
19
|
Cascader = "cascader",
|
|
20
20
|
TreeSelect = "treeSelect"
|
|
21
21
|
}
|
|
22
|
-
export declare type
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
export declare type MFormItemStyle = {
|
|
23
|
+
flex?: string;
|
|
24
|
+
[key: string]: any;
|
|
25
25
|
};
|
|
26
26
|
export interface IMFormProps {
|
|
27
27
|
/**
|
|
@@ -41,13 +41,14 @@ export interface IMFormProps {
|
|
|
41
41
|
*/
|
|
42
42
|
formProps?: FormProps;
|
|
43
43
|
/**
|
|
44
|
-
* 全局 MFormItem layout,
|
|
45
|
-
* @type {{
|
|
46
|
-
* @memberof MFormItem
|
|
44
|
+
* 全局 MFormItem layout, antd 6使用styles替代labelCol和wrapperCol
|
|
45
|
+
* @type {{styles: {label?: MFormItemStyle, content?: MFormItemStyle}}}
|
|
47
46
|
*/
|
|
48
47
|
itemLayout?: {
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
styles?: {
|
|
49
|
+
label?: MFormItemStyle;
|
|
50
|
+
content?: MFormItemStyle;
|
|
51
|
+
};
|
|
51
52
|
};
|
|
52
53
|
/**
|
|
53
54
|
* Antd Row 的其他属性
|
|
@@ -92,13 +93,14 @@ export interface IMFormBaseItem {
|
|
|
92
93
|
*/
|
|
93
94
|
formItemProps?: FormItemProps;
|
|
94
95
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @type {{
|
|
97
|
-
* @memberof MFormItem
|
|
96
|
+
* MFormItem layout, antd 6使用styles替代labelCol和wrapperCol
|
|
97
|
+
* @type {{styles: {label?: MFormItemStyle, content?: MFormItemStyle}}}
|
|
98
98
|
*/
|
|
99
99
|
itemLayout?: {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
styles?: {
|
|
101
|
+
label?: MFormItemStyle;
|
|
102
|
+
content?: MFormItemStyle;
|
|
103
|
+
};
|
|
102
104
|
};
|
|
103
105
|
/**
|
|
104
106
|
* 当前表单占据行的宽度 1-24 默认 24 / column
|