@hzab/form-render 1.6.18 → 1.6.19
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/CHANGELOG.md +4 -0
- package/README.md +239 -239
- package/package.json +57 -57
- package/src/common/formily-utils.ts +125 -125
- package/src/common/schema-handler.ts +253 -253
- package/src/common/schema-merge.ts +68 -68
- package/src/components/ArrayBase/index.tsx +349 -349
- package/src/components/ArrayBase/style.less +90 -90
- package/src/components/ArrayBase/style.ts +2 -2
- package/src/components/ArrayCards/index.tsx +149 -149
- package/src/components/ArrayCards/style.less +14 -14
- package/src/components/ArrayCards/style.ts +4 -4
- package/src/components/ArrayTable/index.tsx +411 -411
- package/src/components/ArrayTable/style.less +52 -52
- package/src/components/ArrayTable/style.ts +7 -7
- package/src/components/DatePicker/index.tsx +108 -108
- package/src/components/LocationListPicker/assets/icon.js +1 -1
- package/src/components/LocationListPicker/components/AddrList/index.less +55 -55
- package/src/components/LocationListPicker/components/AddrList/index.tsx +75 -75
- package/src/components/LocationListPicker/components/Popup/address.schema.json +21 -21
- package/src/components/LocationListPicker/components/Popup/index.less +22 -22
- package/src/components/LocationListPicker/components/Popup/index.tsx +92 -92
- package/src/components/LocationListPicker/index.less +34 -34
- package/src/components/LocationListPicker/index.tsx +521 -520
- package/src/components/LocationPicker/Map/AMap/common/loader.ts +58 -58
- package/src/components/LocationPicker/Map/AMap/common/utils.ts +431 -431
- package/src/components/LocationPicker/Map/AMap/index.jsx +51 -51
- package/src/components/LocationPicker/README.md +44 -44
- package/src/components/LocationPicker/common/utils.ts +30 -30
- package/src/components/LocationPicker/components/ModalContent/index.tsx +387 -387
- package/src/components/LocationPicker/components/PickerInfo/index.tsx +109 -109
- package/src/components/LocationPicker/components/ResInfo/index.less +38 -38
- package/src/components/LocationPicker/components/ResInfo/index.tsx +65 -65
- package/src/components/LocationPicker/index.tsx +197 -197
- package/src/components/PersonnelSelect/index.less +21 -21
- package/src/components/PersonnelSelect/index.module.less +33 -33
- package/src/components/PersonnelSelect/type.ts +92 -92
- package/src/components/RichEditor/index.less +38 -38
- package/src/components/RichEditor/index.tsx +238 -238
- package/src/components/TreeCheckbox/components/CheckboxTable/index.tsx +55 -55
- package/src/components/TreeCheckbox/components/TabsRender/index.tsx +58 -58
- package/src/components/TreeCheckbox/index.less +12 -12
- package/src/components/TreeCheckbox/index.tsx +63 -63
- package/src/components/Upload/README.md +64 -64
- package/src/components/Upload/common/OfflineUpload.ts +339 -339
- package/src/components/Upload/common/customRequest.ts +81 -81
- package/src/components/Upload/common/fileName.ts +142 -142
- package/src/components/Upload/common/handleIOFileList.ts +393 -393
- package/src/components/Upload/common/nanoid.ts +7 -7
- package/src/components/Upload/common/ossUpload.js +159 -159
- package/src/components/Upload/common/utils.js +194 -194
- package/src/components/Upload/components/ItemList/index.tsx +52 -52
- package/src/components/Upload/components/PreviewModal/previewRender.tsx +80 -80
- package/src/components/Upload/index.tsx +17 -17
- package/src/components/Upload/uploader-input.jsx +187 -187
- package/src/components/Upload/uploader.jsx +316 -316
- package/src/components/UserSelect/index.tsx +123 -123
- package/src/components/index.tsx +17 -17
- package/src/index.tsx +198 -198
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
import _ from "lodash";
|
|
2
|
-
|
|
3
|
-
export interface ISetTargetLevelValOpt {
|
|
4
|
-
/**
|
|
5
|
-
* 相对当前的层级数
|
|
6
|
-
*/
|
|
7
|
-
level?: number;
|
|
8
|
-
/**
|
|
9
|
-
* 目标数据为数组是否使用 push
|
|
10
|
-
*/
|
|
11
|
-
isArrPush?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 获取父级的数据(包括当前项的对象)
|
|
16
|
-
* @param field formily field 对象 const field: any = useField();
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
export function getParentValue(field) {
|
|
20
|
-
return getTargetLevelVal(field, -1);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 设置当前 field 同层级数据值。
|
|
25
|
-
* @param field formily field 对象 const field: any = useField();
|
|
26
|
-
* @param key 目标 key
|
|
27
|
-
* @param val 目标值
|
|
28
|
-
* @example
|
|
29
|
-
* 如当前的 field name 为 test, 设置同层级 testA
|
|
30
|
-
* // 初始值:
|
|
31
|
-
* {
|
|
32
|
-
* test: 1
|
|
33
|
-
* }
|
|
34
|
-
* // 设置同层级 key 为 testA 的值为 222
|
|
35
|
-
* setParentValue(field, 'testA', 222);
|
|
36
|
-
* // 设置结果
|
|
37
|
-
* {
|
|
38
|
-
* test: 1,
|
|
39
|
-
* testA: 222
|
|
40
|
-
* }
|
|
41
|
-
*/
|
|
42
|
-
export function setParentValue(field, key, val) {
|
|
43
|
-
setTargetLevelVal(field, key, val, { level: -1 });
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 获取相对当前层级的数据对象(包括当前项的对象)
|
|
48
|
-
* @param field formily field 对象 const field: any = useField();
|
|
49
|
-
* @param key 目标 key
|
|
50
|
-
* @param val 目标 value
|
|
51
|
-
* @param level 相对的层级 负数
|
|
52
|
-
* @returns
|
|
53
|
-
*/
|
|
54
|
-
export function getTargetLevelVal(field, level) {
|
|
55
|
-
if (typeof field !== "object" || !field.form || !field.path) {
|
|
56
|
-
console.warn("Warn setCurLevelData: field 入参不是一个正确的 formily field 数据");
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
// 设置目标参数的路径
|
|
60
|
-
let path = [...field.path.segments];
|
|
61
|
-
// 层级超出路径长度不进行设置
|
|
62
|
-
if (Math.abs(level) > path.length) {
|
|
63
|
-
console.info("Info setCurLevelData: level 层级超出路径长度不进行设置");
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (typeof level === "number") {
|
|
67
|
-
path = path.slice(0, level);
|
|
68
|
-
}
|
|
69
|
-
// 设置目标数据
|
|
70
|
-
return _.get(field.form.values, path.join("."));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* 设置相对当前层级的数据对象(包括当前项的对象)
|
|
75
|
-
* @param field formily field 对象 const field: any = useField();
|
|
76
|
-
* @param key 目标 key
|
|
77
|
-
* @param val 目标 value
|
|
78
|
-
* @param level 相对的层级
|
|
79
|
-
* @returns
|
|
80
|
-
*/
|
|
81
|
-
export function setTargetLevelVal(
|
|
82
|
-
field,
|
|
83
|
-
key,
|
|
84
|
-
val,
|
|
85
|
-
opt: ISetTargetLevelValOpt = { level: undefined, isArrPush: false },
|
|
86
|
-
) {
|
|
87
|
-
if (typeof field !== "object" || !field.form || !field.path) {
|
|
88
|
-
console.warn("Warn setCurLevelData: field 入参不是一个正确的 formily field 数据");
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const {
|
|
92
|
-
/**
|
|
93
|
-
* 数组是否进行 push 曹组
|
|
94
|
-
*/
|
|
95
|
-
isArrPush,
|
|
96
|
-
/**
|
|
97
|
-
* 相对的层级
|
|
98
|
-
*/
|
|
99
|
-
level,
|
|
100
|
-
} = opt || {};
|
|
101
|
-
// 设置目标参数的路径
|
|
102
|
-
let path = [...field.path.segments];
|
|
103
|
-
// 层级超出路径长度不进行设置
|
|
104
|
-
if (Math.abs(level) > path.length) {
|
|
105
|
-
console.info("Info setCurLevelData: level 层级超出路径长度不进行设置");
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (typeof level === "number") {
|
|
109
|
-
path = path.slice(0, -Math.abs(level));
|
|
110
|
-
}
|
|
111
|
-
const parentPath = path.join(".");
|
|
112
|
-
const parentType = _.get(field.form.values, path);
|
|
113
|
-
// 添加目标 key,得到目标完整 path
|
|
114
|
-
path.push(key);
|
|
115
|
-
// 克隆 form 数据,用于修改目标数据 ()
|
|
116
|
-
const data = _.cloneDeep(field.form.values);
|
|
117
|
-
// 设置目标数据
|
|
118
|
-
if (isArrPush && Array.isArray(parentType)) {
|
|
119
|
-
const _d = _.get(data, parentPath);
|
|
120
|
-
Array.isArray(_d) && _d.push({ [key]: val });
|
|
121
|
-
} else {
|
|
122
|
-
_.set(data, path.join("."), val);
|
|
123
|
-
}
|
|
124
|
-
field.form.setValues(data);
|
|
125
|
-
}
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
|
|
3
|
+
export interface ISetTargetLevelValOpt {
|
|
4
|
+
/**
|
|
5
|
+
* 相对当前的层级数
|
|
6
|
+
*/
|
|
7
|
+
level?: number;
|
|
8
|
+
/**
|
|
9
|
+
* 目标数据为数组是否使用 push
|
|
10
|
+
*/
|
|
11
|
+
isArrPush?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 获取父级的数据(包括当前项的对象)
|
|
16
|
+
* @param field formily field 对象 const field: any = useField();
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export function getParentValue(field) {
|
|
20
|
+
return getTargetLevelVal(field, -1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 设置当前 field 同层级数据值。
|
|
25
|
+
* @param field formily field 对象 const field: any = useField();
|
|
26
|
+
* @param key 目标 key
|
|
27
|
+
* @param val 目标值
|
|
28
|
+
* @example
|
|
29
|
+
* 如当前的 field name 为 test, 设置同层级 testA
|
|
30
|
+
* // 初始值:
|
|
31
|
+
* {
|
|
32
|
+
* test: 1
|
|
33
|
+
* }
|
|
34
|
+
* // 设置同层级 key 为 testA 的值为 222
|
|
35
|
+
* setParentValue(field, 'testA', 222);
|
|
36
|
+
* // 设置结果
|
|
37
|
+
* {
|
|
38
|
+
* test: 1,
|
|
39
|
+
* testA: 222
|
|
40
|
+
* }
|
|
41
|
+
*/
|
|
42
|
+
export function setParentValue(field, key, val) {
|
|
43
|
+
setTargetLevelVal(field, key, val, { level: -1 });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 获取相对当前层级的数据对象(包括当前项的对象)
|
|
48
|
+
* @param field formily field 对象 const field: any = useField();
|
|
49
|
+
* @param key 目标 key
|
|
50
|
+
* @param val 目标 value
|
|
51
|
+
* @param level 相对的层级 负数
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
export function getTargetLevelVal(field, level) {
|
|
55
|
+
if (typeof field !== "object" || !field.form || !field.path) {
|
|
56
|
+
console.warn("Warn setCurLevelData: field 入参不是一个正确的 formily field 数据");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// 设置目标参数的路径
|
|
60
|
+
let path = [...field.path.segments];
|
|
61
|
+
// 层级超出路径长度不进行设置
|
|
62
|
+
if (Math.abs(level) > path.length) {
|
|
63
|
+
console.info("Info setCurLevelData: level 层级超出路径长度不进行设置");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (typeof level === "number") {
|
|
67
|
+
path = path.slice(0, level);
|
|
68
|
+
}
|
|
69
|
+
// 设置目标数据
|
|
70
|
+
return _.get(field.form.values, path.join("."));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 设置相对当前层级的数据对象(包括当前项的对象)
|
|
75
|
+
* @param field formily field 对象 const field: any = useField();
|
|
76
|
+
* @param key 目标 key
|
|
77
|
+
* @param val 目标 value
|
|
78
|
+
* @param level 相对的层级
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
export function setTargetLevelVal(
|
|
82
|
+
field,
|
|
83
|
+
key,
|
|
84
|
+
val,
|
|
85
|
+
opt: ISetTargetLevelValOpt = { level: undefined, isArrPush: false },
|
|
86
|
+
) {
|
|
87
|
+
if (typeof field !== "object" || !field.form || !field.path) {
|
|
88
|
+
console.warn("Warn setCurLevelData: field 入参不是一个正确的 formily field 数据");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const {
|
|
92
|
+
/**
|
|
93
|
+
* 数组是否进行 push 曹组
|
|
94
|
+
*/
|
|
95
|
+
isArrPush,
|
|
96
|
+
/**
|
|
97
|
+
* 相对的层级
|
|
98
|
+
*/
|
|
99
|
+
level,
|
|
100
|
+
} = opt || {};
|
|
101
|
+
// 设置目标参数的路径
|
|
102
|
+
let path = [...field.path.segments];
|
|
103
|
+
// 层级超出路径长度不进行设置
|
|
104
|
+
if (Math.abs(level) > path.length) {
|
|
105
|
+
console.info("Info setCurLevelData: level 层级超出路径长度不进行设置");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (typeof level === "number") {
|
|
109
|
+
path = path.slice(0, -Math.abs(level));
|
|
110
|
+
}
|
|
111
|
+
const parentPath = path.join(".");
|
|
112
|
+
const parentType = _.get(field.form.values, path);
|
|
113
|
+
// 添加目标 key,得到目标完整 path
|
|
114
|
+
path.push(key);
|
|
115
|
+
// 克隆 form 数据,用于修改目标数据 ()
|
|
116
|
+
const data = _.cloneDeep(field.form.values);
|
|
117
|
+
// 设置目标数据
|
|
118
|
+
if (isArrPush && Array.isArray(parentType)) {
|
|
119
|
+
const _d = _.get(data, parentPath);
|
|
120
|
+
Array.isArray(_d) && _d.push({ [key]: val });
|
|
121
|
+
} else {
|
|
122
|
+
_.set(data, path.join("."), val);
|
|
123
|
+
}
|
|
124
|
+
field.form.setValues(data);
|
|
125
|
+
}
|