@hzab/form-render 1.5.0-beta → 1.5.0-beta2
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/package.json +2 -2
- package/src/common/schema-handler.ts +25 -3
- package/src/components/Upload/index.tsx +2 -23
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -7,8 +7,30 @@ import { customAlphabet } from "nanoid";
|
|
7
7
|
export const alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
8
8
|
export const nanoid = customAlphabet(alphabet, 20);
|
9
9
|
|
10
|
+
/**
|
11
|
+
* You can use the built-in context variables
|
12
|
+
*
|
13
|
+
* 1. `$self` is the current Field Model
|
14
|
+
*
|
15
|
+
* 2. `$form` is the current Form Model
|
16
|
+
*
|
17
|
+
* 3. `$deps` is the dependencies value
|
18
|
+
*
|
19
|
+
* 4. `$observable` function is used to create an persistent observable state object
|
20
|
+
*
|
21
|
+
* 5. `$memo` function is is used to create a persistent data
|
22
|
+
*
|
23
|
+
* 6. `$effect` function is used to handle side-effect logic
|
24
|
+
*
|
25
|
+
* 7. `$props` function is used to set component props to current field
|
26
|
+
*
|
27
|
+
* Document Links
|
28
|
+
*
|
29
|
+
* https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F
|
30
|
+
**/
|
31
|
+
|
10
32
|
/** formily 执行函数作用域相关参数 */
|
11
|
-
export const formilyDataKeys = ["$form", "$self", "$observable", "$effect", "$memo", "$props", "$values"];
|
33
|
+
export const formilyDataKeys = ["$form", "$self", "$observable", "$effect", "$memo", "$props", "$values", "$deps"];
|
12
34
|
|
13
35
|
/** 自增容器 */
|
14
36
|
export const arrayList = ["ArrayTable", "ArrayCards"];
|
@@ -105,9 +127,9 @@ export const bindCallback = (opt) => {
|
|
105
127
|
}
|
106
128
|
// 设置一个唯一的函数名,用于从 schema scope 传入 formily 事件执行中
|
107
129
|
const fnKey = "fnKey_" + nanoid();
|
108
|
-
// 设置 schemaScope 中的唯一函数,获取执行函数作用域 $form, $self, $observable, $effect, $memo, $props, $values 相关参数
|
130
|
+
// 设置 schemaScope 中的唯一函数,获取执行函数作用域 $form, $self, $observable, $effect, $memo, $props, $values, $deps 相关参数
|
109
131
|
schemaScope._$tempData[fnKey] = function (params, sourceArgs) {
|
110
|
-
const { $form, $self, $observable, $effect, $memo, $props, $values } = params;
|
132
|
+
const { $form, $self, $observable, $effect, $memo, $props, $values, $deps } = params;
|
111
133
|
// 处理结果数据,各组件返回数据格式不一致
|
112
134
|
const res = handleChangeValue({
|
113
135
|
...opt,
|
@@ -4,35 +4,14 @@ import { useGlobalPropsContext } from "../../common/global-props-context";
|
|
4
4
|
export const Upload = (props) => {
|
5
5
|
// 组件外部传入的 props
|
6
6
|
const globalProps = useGlobalPropsContext() || {};
|
7
|
-
const { field = {}, onChange, value } = props;
|
8
|
-
const { name, mode, componentProps = {} } = field;
|
9
|
-
const { multiple } = componentProps;
|
10
|
-
|
11
|
-
async function onUploadChange(files) {
|
12
|
-
let _files = files;
|
13
|
-
if (field?.autoUpload && props.fieldsConf[name]?.onUpload) {
|
14
|
-
_files = await props.fieldsConf[name]?.onUpload(files);
|
15
|
-
if (!_files) {
|
16
|
-
return;
|
17
|
-
}
|
18
|
-
}
|
19
|
-
// 若单选模式,默认只返回对应数据,而非嵌套一层数组
|
20
|
-
if (!multiple && _files && _files.length === 1) {
|
21
|
-
_files = _files[0];
|
22
|
-
}
|
23
|
-
onChange && onChange(_files);
|
24
|
-
}
|
25
7
|
|
26
8
|
const _props = {
|
27
|
-
mode: mode,
|
28
|
-
...props,
|
29
|
-
value: typeof value === "string" ? [value] : value,
|
30
9
|
axios: globalProps?.axios,
|
31
10
|
axiosConf: globalProps?.axiosConf,
|
32
|
-
...
|
11
|
+
...props,
|
33
12
|
};
|
34
13
|
|
35
|
-
return <UploaderCom {..._props}
|
14
|
+
return <UploaderCom {..._props} />;
|
36
15
|
};
|
37
16
|
|
38
17
|
export default Upload;
|