@hzab/form-render 1.6.14 → 1.6.16
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 +10 -0
- package/README.md +12 -11
- package/package.json +2 -2
- package/src/components/ArrayTable/index.tsx +1 -1
- package/src/components/PersonnelSelect/index.tsx +3 -1
- package/src/index.tsx +8 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -116,17 +116,18 @@ import FormRender from "@hzab/form-render";
|
|
|
116
116
|
|
|
117
117
|
### InfoPanel Attributes
|
|
118
118
|
|
|
119
|
-
| 参数
|
|
120
|
-
|
|
|
121
|
-
| schema
|
|
122
|
-
| schemaScope
|
|
123
|
-
| layout
|
|
124
|
-
| initialValues
|
|
125
|
-
| components
|
|
126
|
-
| formOptions
|
|
127
|
-
| disabled
|
|
128
|
-
| readOnly
|
|
129
|
-
|
|
|
119
|
+
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|
|
120
|
+
| ------------------ | -------- | ---- | ---------- | -------------------------------------- |
|
|
121
|
+
| schema | Object | 是 | - | 数据信息的 schema |
|
|
122
|
+
| schemaScope | Object | 否 | - | 全局作用域,用于实现协议表达式变量注入 |
|
|
123
|
+
| layout | Object | 否 | horizontal | 表单布局,horizontal vertical \ inline |
|
|
124
|
+
| initialValues | Object | 否 | - | form 初始值 |
|
|
125
|
+
| components | Object | 否 | - | 自定义组件 |
|
|
126
|
+
| formOptions | Object | 否 | - | createForm 的参数 |
|
|
127
|
+
| disabled | boolean | 否 | - | 禁用状态 |
|
|
128
|
+
| readOnly | boolean | 否 | - | 只读状态 |
|
|
129
|
+
| onFormValuesChange | Function | 否 | - | 表单事件 (form)=>{} https://core.formilyjs.org/zh-CN/api/entry/form-effect-hooks |
|
|
130
|
+
| onFieldValueChange | Function | 否 | - | 表单项事件 (field, form)=>{} https://core.formilyjs.org/zh-CN/api/entry/field-effect-hooks |
|
|
130
131
|
|
|
131
132
|
### 方法 Methods
|
|
132
133
|
|
package/package.json
CHANGED
|
@@ -397,7 +397,7 @@ const Addition: ArrayBaseMixins["Addition"] = (props) => {
|
|
|
397
397
|
{...props}
|
|
398
398
|
onClick={(e) => {
|
|
399
399
|
// 如果添加数据后将超过当前页,则自动切换到下一页
|
|
400
|
-
const total = array?.field?.value
|
|
400
|
+
const total = array?.field?.value?.length || 0;
|
|
401
401
|
if (showPagination && total === totalPage * pageSize + 1 && isFn(changePage)) {
|
|
402
402
|
changePage(totalPage + 1);
|
|
403
403
|
}
|
|
@@ -191,7 +191,9 @@ const RemoteSelect: React.FC<RemoteSelectProps> = ({
|
|
|
191
191
|
const getSelectionStatus = () => {
|
|
192
192
|
if (mode === "multiple") {
|
|
193
193
|
if (!Array.isArray(selectedValue)) return false;
|
|
194
|
-
const selectedValues = (selectedValue || [])?.map((opt) =>
|
|
194
|
+
const selectedValues = (selectedValue || [])?.map((opt) =>
|
|
195
|
+
(isObject(opt) as unknown as Record<string, any>) ? opt?.value ?? opt?.value : opt,
|
|
196
|
+
);
|
|
195
197
|
return selectedValues.includes(value);
|
|
196
198
|
}
|
|
197
199
|
|
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useImperativeHandle, forwardRef, useCallback, useRef } from "react";
|
|
2
|
-
import { createForm } from "@formily/core";
|
|
2
|
+
import { createForm, onFormValuesChange, onFieldValueChange } from "@formily/core";
|
|
3
3
|
import { createSchemaField } from "@formily/react";
|
|
4
4
|
import {
|
|
5
5
|
Form,
|
|
@@ -67,6 +67,8 @@ const antdComponents = {
|
|
|
67
67
|
ArrayCards,
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
+
const noop = () => {};
|
|
71
|
+
|
|
70
72
|
const FormRender = forwardRef((props: any, parentRef) => {
|
|
71
73
|
/** schema scope 解决父级无 schema Scope 导致 scope 对象刷新的问题 */
|
|
72
74
|
const schemaScopeRef = useRef<{ _$tempData: Object }>();
|
|
@@ -125,6 +127,11 @@ const FormRender = forwardRef((props: any, parentRef) => {
|
|
|
125
127
|
readOnly: props.readOnly,
|
|
126
128
|
disabled: props.disabled,
|
|
127
129
|
...(props.formOptions || {}),
|
|
130
|
+
effects(...args) {
|
|
131
|
+
props.onFormValuesChange && onFormValuesChange(props.onFormValuesChange);
|
|
132
|
+
props.onFieldValueChange && onFieldValueChange("*", props.onFieldValueChange);
|
|
133
|
+
props.formOptions?.effects && props.formOptions?.effects(...args);
|
|
134
|
+
},
|
|
128
135
|
}),
|
|
129
136
|
[],
|
|
130
137
|
);
|