@hzab/form-render 1.6.13 → 1.6.15
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 +8 -0
- package/README.md +12 -11
- package/package.json +1 -1
- package/src/components/TreeCheckbox/components/CheckboxTable/index.tsx +3 -3
- package/src/components/TreeCheckbox/components/TabsRender/index.tsx +6 -1
- package/src/components/TreeCheckbox/index.less +1 -0
- package/src/components/TreeCheckbox/index.tsx +15 -6
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Checkbox } from "antd";
|
|
2
2
|
|
|
3
3
|
export const CheckboxTable = (props) => {
|
|
4
|
-
const { data } = props;
|
|
4
|
+
const { data, onChange } = props;
|
|
5
5
|
return (
|
|
6
6
|
<table className="tree-checkbox-table">
|
|
7
7
|
<tbody>
|
|
@@ -27,7 +27,7 @@ export const CheckboxTable = (props) => {
|
|
|
27
27
|
const itKey = it?.value;
|
|
28
28
|
return (
|
|
29
29
|
it && (
|
|
30
|
-
<Checkbox value={itKey} key={itKey}>
|
|
30
|
+
<Checkbox onChange={onChange} value={itKey} key={itKey}>
|
|
31
31
|
{it.label}
|
|
32
32
|
</Checkbox>
|
|
33
33
|
)
|
|
@@ -36,7 +36,7 @@ export const CheckboxTable = (props) => {
|
|
|
36
36
|
</>
|
|
37
37
|
) : (
|
|
38
38
|
col && (
|
|
39
|
-
<Checkbox value={colKey} key={colKey}>
|
|
39
|
+
<Checkbox onChange={onChange} value={colKey} key={colKey}>
|
|
40
40
|
{col.label}
|
|
41
41
|
</Checkbox>
|
|
42
42
|
)
|
|
@@ -36,7 +36,12 @@ export const TabRender = (props) => {
|
|
|
36
36
|
forceRender
|
|
37
37
|
tab={
|
|
38
38
|
<>
|
|
39
|
-
<Checkbox
|
|
39
|
+
<Checkbox
|
|
40
|
+
value={it[valueKey]}
|
|
41
|
+
onChange={props?.onChange}
|
|
42
|
+
key={it[valueKey]}
|
|
43
|
+
onClick={onStopPropagation}
|
|
44
|
+
></Checkbox>
|
|
40
45
|
{it[labelKey]}
|
|
41
46
|
</>
|
|
42
47
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import { Checkbox
|
|
2
|
+
import { Checkbox } from "antd";
|
|
3
3
|
import { useField } from "@formily/react";
|
|
4
4
|
|
|
5
5
|
import Render from "./components/Render";
|
|
6
6
|
import { getTabTableData } from "./common/utils";
|
|
7
7
|
|
|
8
|
-
const { TabPane } = Tabs;
|
|
9
|
-
|
|
10
8
|
import "./index.less";
|
|
11
9
|
|
|
12
10
|
export const TreeCheckbox = (props) => {
|
|
@@ -30,7 +28,6 @@ export const TreeCheckbox = (props) => {
|
|
|
30
28
|
// tab 配置列表
|
|
31
29
|
tabConfList,
|
|
32
30
|
} = props;
|
|
33
|
-
|
|
34
31
|
const tabLevel = tabBox === true ? 1 : tabConfList?.length ?? props.tabLevel;
|
|
35
32
|
|
|
36
33
|
const showDataSource = useMemo(() => {
|
|
@@ -45,8 +42,20 @@ export const TreeCheckbox = (props) => {
|
|
|
45
42
|
// 内部数据
|
|
46
43
|
};
|
|
47
44
|
return (
|
|
48
|
-
<Checkbox.Group className="tree-checkbox" disabled={disabled || readOnly} value={value}
|
|
49
|
-
<Render
|
|
45
|
+
<Checkbox.Group className="tree-checkbox" disabled={disabled || readOnly} value={value}>
|
|
46
|
+
<Render
|
|
47
|
+
{..._props}
|
|
48
|
+
onChange={(e) => {
|
|
49
|
+
let selectedValues = value && Array.isArray(value) ? value : [];
|
|
50
|
+
if (e.target.checked) {
|
|
51
|
+
selectedValues = [...selectedValues.filter((v) => v != e.target.value), e.target.value];
|
|
52
|
+
} else {
|
|
53
|
+
selectedValues = [...selectedValues.filter((v) => v != e.target.value)];
|
|
54
|
+
}
|
|
55
|
+
onChange(selectedValues);
|
|
56
|
+
}}
|
|
57
|
+
list={showDataSource}
|
|
58
|
+
/>
|
|
50
59
|
</Checkbox.Group>
|
|
51
60
|
);
|
|
52
61
|
};
|
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
|
);
|