@zat-design/sisyphus-react 4.4.2 → 4.4.3
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/README.md +1 -42
- package/dist/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/FormsProvider/index.d.ts +1 -1
- package/es/ProEditTable/components/RenderField/ListChangedWrapper.d.ts +1 -14
- package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +27 -102
- package/es/ProEditTable/components/RenderField/index.js +269 -364
- package/es/ProEditTable/components/RenderField/propsType.d.ts +30 -0
- package/es/ProEditTable/components/RenderField/propsType.js +1 -0
- package/es/ProEditTable/components/RenderField/tools.d.ts +22 -0
- package/es/ProEditTable/components/RenderField/tools.js +203 -0
- package/es/ProEditTable/utils/config.js +5 -2
- package/es/ProEditTable/utils/index.js +11 -6
- package/es/ProEditTable/utils/tools.js +3 -2
- package/es/ProEnum/index.js +1 -1
- package/es/ProForm/components/FormFooter/propsType.d.ts +1 -1
- package/es/ProForm/components/base/DatePicker/index.js +3 -2
- package/es/ProForm/components/combination/Group/component/ComRender.js +1 -1
- package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +4 -11
- package/es/ProForm/components/combination/Group/hooks/index.js +1 -2
- package/es/ProForm/components/combination/Group/utils/index.d.ts +16 -16
- package/es/ProForm/components/render/Render.js +149 -180
- package/es/ProForm/components/render/RenderFields.js +13 -38
- package/es/ProForm/components/render/propsType.d.ts +1 -18
- package/es/ProForm/components/render/propsType.js +0 -26
- package/es/ProForm/hooks/useControlled.d.ts +1 -0
- package/es/ProForm/hooks/useControlled.js +14 -0
- package/es/ProForm/hooks/useForm.d.ts +8 -0
- package/es/ProForm/{utils → hooks}/useForm.js +1 -1
- package/es/ProForm/{utils → hooks}/useRules.js +2 -2
- package/es/ProForm/{utils → hooks}/useShouldUpdate.d.ts +5 -1
- package/es/ProForm/{utils → hooks}/useShouldUpdate.js +30 -77
- package/es/ProForm/{utils → hooks}/useWatch.js +1 -1
- package/es/ProForm/index.js +5 -4
- package/es/ProForm/propsType.d.ts +13 -1
- package/es/ProForm/utils/buildFormItemProps.d.ts +25 -0
- package/es/ProForm/utils/buildFormItemProps.js +90 -0
- package/es/ProForm/utils/index.d.ts +2 -6
- package/es/ProForm/utils/index.js +3 -30
- package/es/ProForm/utils/reactiveValues.d.ts +34 -0
- package/es/ProForm/utils/reactiveValues.js +45 -0
- package/es/ProSelect/index.js +8 -7
- package/es/ProTree/components/ProTreeSelect/index.js +3 -2
- package/es/ProTree/utils.d.ts +9 -0
- package/es/ProTree/utils.js +31 -0
- package/es/ProTreeModal/components/Trigger.js +13 -12
- package/es/ProTreeModal/style/index.less +12 -1
- package/package.json +1 -2
- package/es/ProForm/utils/useForm.d.ts +0 -22
- /package/es/ProForm/{utils → hooks}/useDeepCompareMemo.d.ts +0 -0
- /package/es/ProForm/{utils → hooks}/useDeepCompareMemo.js +0 -0
- /package/es/ProForm/{utils → hooks}/useFieldProps.d.ts +0 -0
- /package/es/ProForm/{utils → hooks}/useFieldProps.js +0 -0
- /package/es/ProForm/{utils → hooks}/useRules.d.ts +0 -0
- /package/es/ProForm/{utils → hooks}/useWatch.d.ts +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FormInstance } from 'antd';
|
|
2
|
+
import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
|
|
3
|
+
import { DiffOriginalParams } from '../../utils/diffOriginal';
|
|
4
|
+
export interface GetOriginalValueParams {
|
|
5
|
+
namePath: InternalNamePath;
|
|
6
|
+
originalName: InternalNamePath;
|
|
7
|
+
originalNames?: InternalNamePath[];
|
|
8
|
+
originalValues?: any;
|
|
9
|
+
rowKeyPath?: InternalNamePath;
|
|
10
|
+
form: FormInstance;
|
|
11
|
+
}
|
|
12
|
+
export interface Props {
|
|
13
|
+
name?: NamePath;
|
|
14
|
+
names?: NamePath[];
|
|
15
|
+
originalName?: NamePath;
|
|
16
|
+
originalNames?: NamePath[];
|
|
17
|
+
namesStr?: NamePath;
|
|
18
|
+
originalValues?: any;
|
|
19
|
+
form: FormInstance;
|
|
20
|
+
onDiff?: DiffOriginalParams['onDiff'];
|
|
21
|
+
[name: string]: any;
|
|
22
|
+
}
|
|
23
|
+
/** RenderField 的 props 多为表格运行期动态结构(column/config/record),保留显式 any */
|
|
24
|
+
export interface RenderFieldComparableProps {
|
|
25
|
+
text?: any;
|
|
26
|
+
record?: any;
|
|
27
|
+
index: number;
|
|
28
|
+
column?: any;
|
|
29
|
+
config?: any;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
|
|
2
|
+
import { GetOriginalValueParams, RenderFieldComparableProps } from './propsType';
|
|
3
|
+
/** 列配置中不应透传到 Form.Item 或 DOM 的字段(与 ProForm Render 保持一致) */
|
|
4
|
+
export declare const OMIT_FORM_ITEM_AND_DOM_KEYS: string[];
|
|
5
|
+
/** 克隆子元素时需从 props 中剔除,避免透传到 div 等 DOM 导致 React 警告 */
|
|
6
|
+
export declare const OMIT_FROM_DOM_KEYS: string[];
|
|
7
|
+
export declare const toNamePath: (name: NamePath) => InternalNamePath;
|
|
8
|
+
export declare const toNamePaths: (names: NamePath[]) => InternalNamePath[];
|
|
9
|
+
export declare const getOriginalValue: ({ namePath, originalName, originalNames, originalValues, rowKeyPath, form, }: GetOriginalValueParams) => {
|
|
10
|
+
originalValue: any;
|
|
11
|
+
originRecord: any;
|
|
12
|
+
record: any;
|
|
13
|
+
} | {
|
|
14
|
+
originalValue: any;
|
|
15
|
+
originRecord: any;
|
|
16
|
+
record?: undefined;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* memo 自定义比较函数:只有关键 props 变化时才重新渲染。
|
|
20
|
+
* 从 RenderField 拆出,行为与原内联实现保持一致。
|
|
21
|
+
*/
|
|
22
|
+
export declare const arePropsEqual: (prevProps: RenderFieldComparableProps, nextProps: RenderFieldComparableProps) => boolean;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import _isFunction from "lodash/isFunction";
|
|
2
|
+
import _isEqualWith from "lodash/isEqualWith";
|
|
3
|
+
import _isEqual from "lodash/isEqual";
|
|
4
|
+
import _get from "lodash/get";
|
|
5
|
+
import { customEqualForFunction } from "../../../utils";
|
|
6
|
+
import { getNamePath } from "../../utils/tools";
|
|
7
|
+
/** 列配置中不应透传到 Form.Item 或 DOM 的字段(与 ProForm Render 保持一致) */
|
|
8
|
+
export const OMIT_FORM_ITEM_AND_DOM_KEYS = ['format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow', 'dependNames', 'shouldCellUpdate' // 表格内部性能优化属性,不应传递给 Form.Item
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
/** 克隆子元素时需从 props 中剔除,避免透传到 div 等 DOM 导致 React 警告 */
|
|
12
|
+
export const OMIT_FROM_DOM_KEYS = ['disabled',
|
|
13
|
+
// div 不支持 disabled,且值可能非 string/number
|
|
14
|
+
'toCSTString', 'toISOString', 'format', 'switchValue', 'precision', 'clearNotShow', 'dependNames'];
|
|
15
|
+
export const toNamePath = name => {
|
|
16
|
+
if (Array.isArray(name)) {
|
|
17
|
+
return name;
|
|
18
|
+
}
|
|
19
|
+
return [name];
|
|
20
|
+
};
|
|
21
|
+
export const toNamePaths = names => {
|
|
22
|
+
return names.map(name => toNamePath(name));
|
|
23
|
+
};
|
|
24
|
+
export const getOriginalValue = ({
|
|
25
|
+
namePath,
|
|
26
|
+
originalName,
|
|
27
|
+
originalNames,
|
|
28
|
+
originalValues,
|
|
29
|
+
rowKeyPath,
|
|
30
|
+
form
|
|
31
|
+
}) => {
|
|
32
|
+
if (!originalValues) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
let originRecord;
|
|
36
|
+
if (rowKeyPath) {
|
|
37
|
+
const rowValueNamePath = namePath.slice(0, rowKeyPath.length - 1); // 表单中变动值所在行
|
|
38
|
+
const rowKeyName = rowKeyPath[rowKeyPath.length - 1]; // rowKey在行内的name
|
|
39
|
+
|
|
40
|
+
const rowValue = form.getFieldValue(rowValueNamePath);
|
|
41
|
+
if (!rowValue) return undefined;
|
|
42
|
+
const keyValue = rowValue[rowKeyName]; // 获取表单中rowKey值
|
|
43
|
+
if (!keyValue) return undefined;
|
|
44
|
+
const originalValueList = _get(originalValues, originalName.slice(0, rowKeyPath.length - 2));
|
|
45
|
+
originRecord = originalValueList?.find(item => {
|
|
46
|
+
return item[rowKeyPath[rowKeyPath.length - 1]] === keyValue;
|
|
47
|
+
});
|
|
48
|
+
let originalValue;
|
|
49
|
+
if (originalNames?.length) {
|
|
50
|
+
const originalNamesValue = originalNames.map(originalName => {
|
|
51
|
+
return _get(originRecord, originalName.slice(rowKeyPath.length - 1));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// 有可能出现数组中全是undefined的情况 视为没有值
|
|
55
|
+
const fillUndefined = originalNamesValue.every(valItem => valItem === undefined);
|
|
56
|
+
originalValue = fillUndefined ? undefined : originalNamesValue;
|
|
57
|
+
} else {
|
|
58
|
+
originalValue = _get(originRecord, originalName.slice(rowKeyPath.length - 1));
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
originalValue,
|
|
62
|
+
originRecord,
|
|
63
|
+
record: rowValue
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 这个方法是给editTable专用的 暂时不存在不传rowKey的情况
|
|
68
|
+
return {
|
|
69
|
+
originalValue: originalNames?.length ? originalNames.map(originalName => _get(originalValues, originalName)) : _get(originalValues, originalName),
|
|
70
|
+
originRecord
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* memo 自定义比较函数:只有关键 props 变化时才重新渲染。
|
|
76
|
+
* 从 RenderField 拆出,行为与原内联实现保持一致。
|
|
77
|
+
*/
|
|
78
|
+
export const arePropsEqual = (prevProps, nextProps) => {
|
|
79
|
+
const {
|
|
80
|
+
text: prevText,
|
|
81
|
+
record: prevRecord,
|
|
82
|
+
index: prevIndex,
|
|
83
|
+
column: prevColumn,
|
|
84
|
+
config: prevConfig
|
|
85
|
+
} = prevProps;
|
|
86
|
+
const {
|
|
87
|
+
text: nextText,
|
|
88
|
+
record: nextRecord,
|
|
89
|
+
index: nextIndex,
|
|
90
|
+
column: nextColumn,
|
|
91
|
+
config: nextConfig
|
|
92
|
+
} = nextProps;
|
|
93
|
+
|
|
94
|
+
// 函数型动态属性(component/editRender/fieldProps/rules/required/disabled/isEditable/valueType)
|
|
95
|
+
// 可能依赖行内兄弟字段;行对象为同引用(原地修改)时,浅比较无法区分,需强制重渲染
|
|
96
|
+
const hasFunctionDependency = _isFunction(prevColumn?.component) || _isFunction(prevColumn?.editRender) || _isFunction(prevColumn?.fieldProps) || _isFunction(prevColumn?.rules) || _isFunction(prevColumn?.required) || _isFunction(prevColumn?.disabled) || _isFunction(prevColumn?.isEditable) || _isFunction(prevColumn?.valueType) || _isFunction(nextColumn?.component) || _isFunction(nextColumn?.editRender) || _isFunction(nextColumn?.fieldProps) || _isFunction(nextColumn?.rules) || _isFunction(nextColumn?.required) || _isFunction(nextColumn?.disabled) || _isFunction(nextColumn?.isEditable) || _isFunction(nextColumn?.valueType);
|
|
97
|
+
if (hasFunctionDependency && prevRecord === nextRecord) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 构建新的参数格式(与 ProForm 保持一致)
|
|
102
|
+
const prevNamePath = getNamePath(prevConfig?.name, prevConfig?.virtualKey);
|
|
103
|
+
const nextNamePath = getNamePath(nextConfig?.name, nextConfig?.virtualKey);
|
|
104
|
+
const prevReactiveParams = {
|
|
105
|
+
form: prevConfig?.form,
|
|
106
|
+
index: prevIndex,
|
|
107
|
+
namePath: [...prevNamePath, prevIndex]
|
|
108
|
+
};
|
|
109
|
+
const nextReactiveParams = {
|
|
110
|
+
form: nextConfig?.form,
|
|
111
|
+
index: nextIndex,
|
|
112
|
+
namePath: [...nextNamePath, nextIndex]
|
|
113
|
+
};
|
|
114
|
+
if (_isFunction(prevColumn?.disabled) && _isFunction(nextColumn?.disabled)) {
|
|
115
|
+
if (prevColumn?.disabled(prevRecord, prevReactiveParams) !== nextColumn?.disabled(nextRecord, nextReactiveParams)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// fieldProps 函数化直接更新,无法比对返回值是否一致
|
|
121
|
+
// 优化:不直接调用函数,而是比较输入参数(record 和 reactiveParams)
|
|
122
|
+
// 如果输入参数相同,fieldProps 的返回值应该相同(纯函数假设)
|
|
123
|
+
if (_isFunction(prevColumn?.fieldProps) && _isFunction(nextColumn?.fieldProps)) {
|
|
124
|
+
// 比较 record 数据是否变化
|
|
125
|
+
if (!_isEqualWith(prevRecord, nextRecord, customEqualForFunction)) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
// reactiveParams 中的 form、index、namePath 已经在外层比较过了,无需重复比较
|
|
129
|
+
}
|
|
130
|
+
// fieldProps 为对象时,必须比较配置变化(如 dataSource 异步更新)
|
|
131
|
+
if (!_isFunction(prevColumn?.fieldProps) && !_isFunction(nextColumn?.fieldProps)) {
|
|
132
|
+
const isFieldPropsEqual = _isEqualWith(prevColumn?.fieldProps, nextColumn?.fieldProps, customEqualForFunction);
|
|
133
|
+
if (!isFieldPropsEqual) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 通用函数比较方法
|
|
139
|
+
// 优化:不直接调用函数,而是比较函数引用和输入参数
|
|
140
|
+
const compareFunctionResult = (prevCol, nextCol, prevValues, nextValues, _prevReactiveParams, _nextReactiveParams, functionName) => {
|
|
141
|
+
const prevFunc = prevCol?.[functionName];
|
|
142
|
+
const nextFunc = nextCol?.[functionName];
|
|
143
|
+
if (_isFunction(prevFunc) && _isFunction(nextFunc)) {
|
|
144
|
+
// 函数引用变化说明闭包可能捕获了新的外部状态(如异步加载的 list),必须重渲染
|
|
145
|
+
if (prevFunc !== nextFunc) return false;
|
|
146
|
+
// 同引用函数,比较输入参数(纯函数假设:输入相同则输出相同)
|
|
147
|
+
return _isEqualWith(prevValues, nextValues, customEqualForFunction);
|
|
148
|
+
}
|
|
149
|
+
return true; // 如果不是函数或只有一个是函数,认为相等
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// 使用简化后的比较逻辑
|
|
153
|
+
const functionFields = ['rules', 'component', 'desensitization', 'isEditable', 'required'];
|
|
154
|
+
if (functionFields.some(field => !compareFunctionResult(prevColumn, nextColumn, prevRecord, nextRecord, prevReactiveParams, nextReactiveParams, field))) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// 基本props比较
|
|
159
|
+
if (!_isEqual(prevText, nextText) || prevIndex !== nextIndex) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 记录关键字段比较(避免完整对象比较的性能开销)
|
|
164
|
+
if (prevRecord?.rowKey !== nextRecord?.rowKey || prevRecord?._addFlag !== nextRecord?._addFlag) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// 列配置比较(只比较关键字段),required,disabled为函数时,需要重新计算
|
|
169
|
+
if (prevColumn?.dataIndex !== nextColumn?.dataIndex || prevColumn?.type !== nextColumn?.type || prevColumn?.name !== nextColumn?.name) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// config中关键字段比较
|
|
174
|
+
if (prevConfig?._isEditing !== nextConfig?._isEditing || prevConfig?.mode !== nextConfig?.mode) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 当前单元格的值比较
|
|
179
|
+
const prevDataIndex = prevColumn?.dataIndex;
|
|
180
|
+
const nextDataIndex = nextColumn?.dataIndex;
|
|
181
|
+
if (prevDataIndex && nextDataIndex && prevDataIndex === nextDataIndex) {
|
|
182
|
+
if (prevRecord?.[prevDataIndex] !== nextRecord?.[nextDataIndex]) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// 特殊处理:当使用自定义 component 函数时,比较整个 record 对象
|
|
188
|
+
// 因为自定义组件可能依赖 record 中的其他字段(不只是当前列的 dataIndex)
|
|
189
|
+
if (_isFunction(prevColumn?.component) || _isFunction(nextColumn?.component)) {
|
|
190
|
+
// 浅比较 record 的所有属性
|
|
191
|
+
const prevKeys = Object.keys(prevRecord || {});
|
|
192
|
+
const nextKeys = Object.keys(nextRecord || {});
|
|
193
|
+
if (prevKeys.length !== nextKeys.length) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// 使用 some 方法代替 for 循环
|
|
198
|
+
if (prevKeys.some(key => prevRecord?.[key] !== nextRecord?.[key])) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return true;
|
|
203
|
+
};
|
|
@@ -89,7 +89,9 @@ export const actions = {
|
|
|
89
89
|
delete record._isEditing;
|
|
90
90
|
}
|
|
91
91
|
// 防止value引用不变, 值不更新 - (自定义组件)
|
|
92
|
-
|
|
92
|
+
// 必须取全量 store(true):names 组合列只注册合并字段,拆分子字段(如 address/postcode)
|
|
93
|
+
// 未注册;getFieldsValue() 会丢掉它们,叠加 setFieldsValue 对数组「整体覆盖」会抹掉其他行的子字段
|
|
94
|
+
const values = form.getFieldsValue(true);
|
|
93
95
|
_set(values, rowName, record);
|
|
94
96
|
// 同步清理虚拟路径上的 _addFlag,避免再次编辑→取消时把已保存行误删
|
|
95
97
|
_set(values, virtualRowName, record);
|
|
@@ -128,8 +130,9 @@ export const actions = {
|
|
|
128
130
|
});
|
|
129
131
|
} else {
|
|
130
132
|
// 取消时使用主 form 原始行数据重置虚拟 form,避免编辑值残留
|
|
133
|
+
// 同 save:取全量 store(true),避免抹掉其他行未注册的 names 拆分子字段
|
|
131
134
|
const originalRecord = form.getFieldValue(rowName);
|
|
132
|
-
const values = form.getFieldsValue();
|
|
135
|
+
const values = form.getFieldsValue(true);
|
|
133
136
|
_set(values, virtualRowName, originalRecord ?? record);
|
|
134
137
|
form.setFieldsValue(values);
|
|
135
138
|
}
|
|
@@ -344,6 +344,9 @@ export const transformColumns = (columns = [], config, caches) => {
|
|
|
344
344
|
// 精准控制单元格更新,减少不必要的渲染
|
|
345
345
|
if (!item.shouldCellUpdate) {
|
|
346
346
|
const hasComponent = _isFunction(item.component);
|
|
347
|
+
// 函数型动态属性会依赖整行数据(可能是当前列之外的兄弟字段),
|
|
348
|
+
// 这类列在行内任意字段变化时都需重渲染,不能只比对本列 dataIndex
|
|
349
|
+
const hasFunctionDependency = hasComponent || _isFunction(item.editRender) || _isFunction(item.fieldProps) || _isFunction(item.rules) || _isFunction(item.required) || _isFunction(item.disabled) || _isFunction(item.isEditable) || _isFunction(item.valueType);
|
|
347
350
|
const columnCacheKey = `${Array.isArray(name) ? name.join('.') : String(name)}::${String(columnName)}`;
|
|
348
351
|
|
|
349
352
|
// Fix 问题1:用原始列引用(克隆前)比对 dataSource
|
|
@@ -387,22 +390,24 @@ export const transformColumns = (columns = [], config, caches) => {
|
|
|
387
390
|
if (virtualKey && record?._isEditing !== prevRecord?._isEditing) {
|
|
388
391
|
return true;
|
|
389
392
|
}
|
|
390
|
-
// 动态 component
|
|
393
|
+
// 动态 component 函数引用变化说明外部依赖(如异步 list)已更新,必须重渲染
|
|
394
|
+
// 即使行数据未变,旧闭包仍持有过时的外部状态
|
|
391
395
|
if (hasComponent) {
|
|
392
|
-
// component 函数引用变化说明外部依赖(如异步 list)已更新,必须重渲染
|
|
393
|
-
// 即使行数据未变,旧闭包仍持有过时的外部状态
|
|
394
396
|
const prevComponentRef = cellCaches.componentRef.get(columnCacheKey);
|
|
395
397
|
const currentComponentRef = item.component;
|
|
396
398
|
if (prevComponentRef !== currentComponentRef) {
|
|
397
399
|
cellCaches.componentRef.set(columnCacheKey, currentComponentRef);
|
|
398
400
|
return true;
|
|
399
401
|
}
|
|
400
|
-
|
|
402
|
+
}
|
|
403
|
+
// 函数型动态属性(component/fieldProps/rules/required/disabled/isEditable/valueType)
|
|
404
|
+
// 可能依赖行内其他字段(兄弟字段),需比较整行;
|
|
405
|
+
// 同引用原地修改时 isEqual 恒为 true,无法感知,必须强制重渲染
|
|
406
|
+
if (hasFunctionDependency) {
|
|
401
407
|
if (record === prevRecord) {
|
|
402
408
|
return true;
|
|
403
409
|
}
|
|
404
|
-
|
|
405
|
-
return rowChanged;
|
|
410
|
+
return !_isEqual(record, prevRecord);
|
|
406
411
|
}
|
|
407
412
|
const key = item.dataIndex || item.key;
|
|
408
413
|
if (!key) return true;
|
|
@@ -114,15 +114,16 @@ export const onDelete = ({
|
|
|
114
114
|
selectedRowKeys
|
|
115
115
|
}) => {
|
|
116
116
|
// 正常的form数据流处理
|
|
117
|
+
// 行可能为 undefined/null(单行编辑下虚拟数组多轮增删改后残留的空位),过滤时需先做空值守卫
|
|
117
118
|
let dataSource = form.getFieldValue(name);
|
|
118
|
-
dataSource = dataSource.filter(row => !selectedRowKeys.includes(row.rowKey));
|
|
119
|
+
dataSource = dataSource.filter(row => row && !selectedRowKeys.includes(row.rowKey));
|
|
119
120
|
form.setFieldValue(name, dataSource);
|
|
120
121
|
// 单行模式数据流处理 重置中间正在编辑状态单行数据
|
|
121
122
|
if (virtualKey) {
|
|
122
123
|
const namePath = getNamePath(name, virtualKey);
|
|
123
124
|
let virtualList = form.getFieldValue(namePath);
|
|
124
125
|
if (virtualList?.length) {
|
|
125
|
-
virtualList = virtualList.filter(row => !selectedRowKeys.includes(row.rowKey));
|
|
126
|
+
virtualList = virtualList.filter(row => row && !selectedRowKeys.includes(row.rowKey));
|
|
126
127
|
form.setFieldValue(namePath, virtualList);
|
|
127
128
|
}
|
|
128
129
|
}
|
package/es/ProEnum/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import getEnumLabel from "./utils/getEnumLabel";
|
|
|
16
16
|
import useEnum from "./hooks/useEnum";
|
|
17
17
|
import getEnum from "./utils/getEnum";
|
|
18
18
|
import locale from "../locale";
|
|
19
|
-
import { useFieldProps } from "../ProForm/
|
|
19
|
+
import { useFieldProps } from "../ProForm/hooks/useFieldProps";
|
|
20
20
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
21
|
const ProEnum = props => {
|
|
22
22
|
const {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ButtonProps, ColProps, FormInstance } from 'antd';
|
|
3
|
-
import { ModifiedFormInstanceType } from '../../
|
|
3
|
+
import type { ModifiedFormInstanceType } from '../../propsType';
|
|
4
4
|
export interface ButtonItem extends ButtonProps {
|
|
5
5
|
children?: any;
|
|
6
6
|
}
|
|
@@ -62,10 +62,11 @@ const DatePicker = props => {
|
|
|
62
62
|
let viewChildren = null;
|
|
63
63
|
if (!value) {
|
|
64
64
|
viewChildren = null;
|
|
65
|
-
} else if (typeof format === 'string' && _isObject(value)) {
|
|
66
|
-
viewChildren = value.format?.(format) || value;
|
|
67
65
|
} else if (_isFunction(format)) {
|
|
68
66
|
viewChildren = format(value);
|
|
67
|
+
} else if (_isObject(value) && _isFunction(value.format)) {
|
|
68
|
+
// dayjs / dayjs-like 对象:format 字符串优先,否则用 viewFormat(valueType > picker default)
|
|
69
|
+
viewChildren = value.format(typeof format === 'string' ? format : viewFormat);
|
|
69
70
|
} else if (_isString(value)) {
|
|
70
71
|
viewChildren = dayjs(value).format(viewFormat);
|
|
71
72
|
}
|
|
@@ -2,7 +2,7 @@ import _omit from "lodash/omit";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Form } from 'antd';
|
|
4
4
|
import ConfirmWrapper from "../../../../components/render/ConfirmWrapper";
|
|
5
|
-
import { FieldProvider } from "../../../../
|
|
5
|
+
import { FieldProvider } from "../../../../hooks/useFieldProps";
|
|
6
6
|
import * as componentMap from "../../../../../index";
|
|
7
7
|
import AddonWrapper from "./AddonWrapper";
|
|
8
8
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -3,7 +3,7 @@ import _isEmpty from "lodash/isEmpty";
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Space, Form } from 'antd';
|
|
5
5
|
import classnames from 'classnames';
|
|
6
|
-
import { FieldProvider } from "../../../../
|
|
6
|
+
import { FieldProvider } from "../../../../hooks/useFieldProps";
|
|
7
7
|
import ProForm from "../../../../../ProForm";
|
|
8
8
|
import Render from "../../../render/Render";
|
|
9
9
|
import * as componentMap from "../../../../../index";
|
|
@@ -189,6 +189,8 @@ const FlexibleGroupRender = props => {
|
|
|
189
189
|
namePath: childNamePath || contextProps.namePath,
|
|
190
190
|
formDisabled: otherProps?.formDisabled,
|
|
191
191
|
globalControl: otherProps?.globalControl,
|
|
192
|
+
diffConfig: otherProps?.diffConfig,
|
|
193
|
+
shouldUpdateDebounce: otherProps?.shouldUpdateDebounce,
|
|
192
194
|
// 灵活模式样式属性
|
|
193
195
|
flexibleGroupProps: {
|
|
194
196
|
className: formItemClassName,
|
|
@@ -204,27 +206,18 @@ const FlexibleGroupRender = props => {
|
|
|
204
206
|
value: renderOtherProps,
|
|
205
207
|
children: /*#__PURE__*/_jsx(Render, {
|
|
206
208
|
show: child.show,
|
|
207
|
-
form: form,
|
|
208
209
|
disabled: child.disabled,
|
|
209
|
-
formDisabled: otherProps?.formDisabled,
|
|
210
|
-
type: type,
|
|
211
210
|
originComponent: child.component,
|
|
212
211
|
component: TargetComponent,
|
|
213
212
|
formItemProps: formItemProps,
|
|
214
213
|
confirm: child.confirm,
|
|
215
|
-
colProps: {
|
|
216
|
-
span: 24
|
|
217
|
-
},
|
|
218
214
|
componentProps: adjustedFieldProps || {},
|
|
219
215
|
otherProps: renderOtherProps,
|
|
220
216
|
fieldProps: child.fieldProps,
|
|
221
217
|
isSelect: false // 由 Render 内部计算
|
|
222
218
|
,
|
|
223
|
-
diffConfig: otherProps?.diffConfig,
|
|
224
219
|
requiredOnView: otherProps?.requiredOnView,
|
|
225
|
-
|
|
226
|
-
viewRender: child.viewRender,
|
|
227
|
-
shouldUpdateDebounce: otherProps?.shouldUpdateDebounce
|
|
220
|
+
viewRender: child.viewRender
|
|
228
221
|
})
|
|
229
222
|
}, child.name || `item-${index}`);
|
|
230
223
|
};
|
|
@@ -3,7 +3,7 @@ import _isEqual from "lodash/isEqual";
|
|
|
3
3
|
import _cloneDeep from "lodash/cloneDeep";
|
|
4
4
|
/* eslint-disable no-lonely-if */
|
|
5
5
|
import { useRef, useEffect } from 'react';
|
|
6
|
-
import { useDeepCompareMemo } from "../../../../
|
|
6
|
+
import { useDeepCompareMemo } from "../../../../hooks/useDeepCompareMemo";
|
|
7
7
|
import { difference } from "../../../../../ProEditTable/utils/tools";
|
|
8
8
|
import { getReactiveProps, getValueTypeTrans, valueFromEventWrapper } from "../utils";
|
|
9
9
|
/** 转换columns */
|
|
@@ -65,7 +65,6 @@ export const useTransformColumns = params => {
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
// 响应式字段
|
|
68
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
69
68
|
const reactiveProps = useDeepCompareMemo(() => {
|
|
70
69
|
return getReactiveProps({
|
|
71
70
|
form,
|
|
@@ -75,33 +75,28 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
75
75
|
confirm?: boolean | import("antd").ModalFuncProps | import("../../../render/propsType").FunctionArgs<any, boolean | import("antd").ModalFuncProps>;
|
|
76
76
|
show?: boolean | ReactiveFunction<any, boolean>;
|
|
77
77
|
component?: React.ReactNode | ReactiveFunction<any, React.ReactNode>;
|
|
78
|
-
prefixCls?: string;
|
|
79
|
-
htmlFor?: string;
|
|
80
78
|
className?: string;
|
|
81
79
|
hidden?: boolean;
|
|
82
80
|
id?: string;
|
|
83
81
|
style?: React.CSSProperties;
|
|
84
82
|
children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
|
|
85
83
|
onReset?: () => void;
|
|
86
|
-
|
|
87
|
-
normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
|
|
88
|
-
vertical?: boolean;
|
|
84
|
+
prefixCls?: string;
|
|
89
85
|
isView?: boolean;
|
|
90
|
-
|
|
91
|
-
toISOString?: boolean;
|
|
92
|
-
toCSTString?: boolean;
|
|
93
|
-
switchValue?: [any, any];
|
|
94
|
-
clearNotShow?: boolean;
|
|
95
|
-
validateTrigger?: string | false | string[];
|
|
86
|
+
desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
|
|
96
87
|
rootClassName?: string;
|
|
97
88
|
status?: "" | "warning" | "error" | "success" | "validating";
|
|
98
|
-
|
|
89
|
+
vertical?: boolean;
|
|
99
90
|
getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
|
|
100
|
-
shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
|
|
101
91
|
colon?: boolean;
|
|
92
|
+
htmlFor?: string;
|
|
102
93
|
labelAlign?: import("antd/es/form/interface").FormLabelAlign;
|
|
103
94
|
labelCol?: import("antd").ColProps;
|
|
104
95
|
getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
|
|
96
|
+
normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
|
|
97
|
+
shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
|
|
98
|
+
trigger?: string;
|
|
99
|
+
validateTrigger?: string | false | string[];
|
|
105
100
|
validateDebounce?: number;
|
|
106
101
|
valuePropName?: string;
|
|
107
102
|
messageVariables?: Record<string, string>;
|
|
@@ -119,14 +114,19 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
119
114
|
wrapperCol?: import("antd").ColProps;
|
|
120
115
|
help?: React.ReactNode;
|
|
121
116
|
fieldId?: string;
|
|
122
|
-
|
|
117
|
+
valueType?: import("../../../render/propsType").ProFormValueType;
|
|
118
|
+
toISOString?: boolean;
|
|
119
|
+
toCSTString?: boolean;
|
|
120
|
+
switchValue?: [any, any];
|
|
121
|
+
clearNotShow?: boolean;
|
|
122
|
+
trim?: boolean;
|
|
123
|
+
upperCase?: boolean;
|
|
123
124
|
viewRender?: (value: any, record: any, { form, index, namePath, }: {
|
|
124
125
|
[key: string]: any;
|
|
125
126
|
form: FormInstance<any>;
|
|
126
127
|
index?: number;
|
|
127
128
|
}) => string | React.ReactElement<any, any>;
|
|
128
129
|
viewType?: import("../../../render/propsType").ViewType;
|
|
129
|
-
upperCase?: boolean;
|
|
130
130
|
name: any;
|
|
131
131
|
dependencies: any[];
|
|
132
132
|
tooltip: string | {
|
|
@@ -141,7 +141,7 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
141
141
|
* 创建组件属性
|
|
142
142
|
*/
|
|
143
143
|
export declare const createComponentProps: (column: FlexibleGroupColumnType, formItemProps: any) => {
|
|
144
|
-
componentProps: import("lodash").Omit<any, "
|
|
144
|
+
componentProps: import("lodash").Omit<any, "precision" | "valueType" | "toISOString" | "toCSTString" | "switchValue" | "format" | "clearNotShow" | "dependNames">;
|
|
145
145
|
formItemTransform: {
|
|
146
146
|
getValueProps: any;
|
|
147
147
|
normalize: any;
|