@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 CHANGED
@@ -1,3 +1,13 @@
1
+
2
+ # @hzab/form-render@1.6.16
3
+
4
+ fix: ArrayTable value 空问题兼容
5
+ fix: 修复人员选择组件中isObject函数ts类型不明确导致在部分项目中出现类型错误提示的问题
6
+
7
+ # @hzab/form-render@1.6.15
8
+
9
+ feat: 新增 formily js 的 change 事件
10
+
1
11
  # @hzab/form-render@1.6.14
2
12
 
3
13
  fix: 修复 TreeCheckbox 隐藏不能点击问题。
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 | 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
- | onChange | Function | 否 | - | 表单 onChange 事件(目前仅做触发,值计算后续优化) |
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/form-render",
3
- "version": "1.6.14",
3
+ "version": "1.6.16",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -52,6 +52,6 @@
52
52
  "nanoid": "^3.3.7"
53
53
  },
54
54
  "directories": {
55
- "lib": "lib"
55
+ "src": "src"
56
56
  }
57
57
  }
@@ -397,7 +397,7 @@ const Addition: ArrayBaseMixins["Addition"] = (props) => {
397
397
  {...props}
398
398
  onClick={(e) => {
399
399
  // 如果添加数据后将超过当前页,则自动切换到下一页
400
- const total = array?.field?.value.length || 0;
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) => (isObject(opt) ? opt?.value ?? opt?.value : 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
  );