@zat-design/sisyphus-react 4.1.2-beta.1 → 4.1.2-beta.10
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/.claudeignore +40 -0
- package/dist/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/ProEditTable/components/RcTable/BaseTable.js +12 -16
- package/es/ProEditTable/components/RcTable/DraggableTable.js +11 -16
- package/es/ProEditTable/components/RenderField/index.js +292 -97
- package/es/ProEditTable/index.js +14 -4
- package/es/ProEditTable/propsType.d.ts +6 -1
- package/es/ProEditTable/style/index.less +8 -0
- package/es/ProEditTable/utils/index.js +66 -24
- package/es/ProEditTable/utils/useShouldUpdateForTable.d.ts +1 -0
- package/es/ProEditTable/utils/useShouldUpdateForTable.js +37 -10
- package/es/ProForm/components/base/DatePicker/index.js +1 -7
- package/es/ProForm/components/base/RangePicker/index.js +62 -8
- package/es/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
- package/es/ProForm/components/combination/Group/component/ComRender.js +15 -11
- package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +61 -7
- package/es/ProForm/components/combination/Group/style/index.less +26 -1
- package/es/ProForm/components/combination/ProCascader/propsType.d.ts +1 -1
- package/es/ProForm/propsType.d.ts +3 -3
- package/es/ProForm/utils/transformValue.d.ts +1 -1
- package/es/ProForm/utils/useForm.d.ts +1 -1
- package/es/ProForm/utils/useWatch.d.ts +2 -1
- package/es/ProForm/utils/useWatch.js +3 -1
- package/es/ProSelect/index.js +117 -62
- package/es/ProUpload/propsType.d.ts +1 -1
- package/es/ProUpload/style/index.less +3 -3
- package/lib/ProEditTable/components/RcTable/BaseTable.js +11 -15
- package/lib/ProEditTable/components/RcTable/DraggableTable.js +11 -16
- package/lib/ProEditTable/components/RenderField/index.js +292 -97
- package/lib/ProEditTable/index.js +14 -4
- package/lib/ProEditTable/propsType.d.ts +6 -1
- package/lib/ProEditTable/style/index.less +8 -0
- package/lib/ProEditTable/utils/index.js +67 -23
- package/lib/ProEditTable/utils/useShouldUpdateForTable.d.ts +1 -0
- package/lib/ProEditTable/utils/useShouldUpdateForTable.js +37 -10
- package/lib/ProForm/components/base/DatePicker/index.js +1 -7
- package/lib/ProForm/components/base/RangePicker/index.js +62 -8
- package/lib/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
- package/lib/ProForm/components/combination/Group/component/ComRender.js +15 -11
- package/lib/ProForm/components/combination/Group/component/FlexibleGroup.js +61 -7
- package/lib/ProForm/components/combination/Group/style/index.less +26 -1
- package/lib/ProForm/components/combination/ProCascader/propsType.d.ts +1 -1
- package/lib/ProForm/propsType.d.ts +3 -3
- package/lib/ProForm/utils/transformValue.d.ts +1 -1
- package/lib/ProForm/utils/useForm.d.ts +1 -1
- package/lib/ProForm/utils/useWatch.d.ts +2 -1
- package/lib/ProForm/utils/useWatch.js +3 -1
- package/lib/ProSelect/index.js +115 -61
- package/lib/ProUpload/propsType.d.ts +1 -1
- package/lib/ProUpload/style/index.less +3 -3
- package/package.json +4 -2
|
@@ -37,7 +37,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
37
37
|
var OMIT_FORM_ITEM_AND_DOM_KEYS = ['format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow', 'dependNames', 'shouldCellUpdate' // 表格内部性能优化属性,不应传递给 Form.Item
|
|
38
38
|
];
|
|
39
39
|
var RenderField = _ref => {
|
|
40
|
-
var _type, _type$replace, _fieldProps2, _fieldProps4, _names, _TargetComponent5,
|
|
40
|
+
var _type, _type$replace, _fieldProps2, _fieldProps4, _names, _TargetComponent5, _componentProps2;
|
|
41
41
|
var value = _ref.text,
|
|
42
42
|
record = _ref.record,
|
|
43
43
|
index = _ref.index,
|
|
@@ -93,9 +93,7 @@ var RenderField = _ref => {
|
|
|
93
93
|
var _valueType = valueType;
|
|
94
94
|
var _disabled = false;
|
|
95
95
|
var _desensitization = desensitization || [];
|
|
96
|
-
|
|
97
|
-
// editRender弃用使用component同ProForm
|
|
98
|
-
var _editRender = component || editRender;
|
|
96
|
+
var _component = component || editRender;
|
|
99
97
|
var isCell = mode === 'cell';
|
|
100
98
|
var isSingleMode = mode === 'single';
|
|
101
99
|
if (isCell) {
|
|
@@ -184,6 +182,15 @@ var RenderField = _ref => {
|
|
|
184
182
|
isEditable = (_dynamicProps$isEdita = dynamicProps.isEditable) !== null && _dynamicProps$isEdita !== void 0 ? _dynamicProps$isEdita : isEditable(rowData, reactiveParams);
|
|
185
183
|
}
|
|
186
184
|
|
|
185
|
+
// component 处理 - 优先使用 hook 返回的值
|
|
186
|
+
if (isFunction(_component)) {
|
|
187
|
+
var _dynamicProps$compone;
|
|
188
|
+
_component = (_dynamicProps$compone = dynamicProps.component) !== null && _dynamicProps$compone !== void 0 ? _dynamicProps$compone : _component(rowData, reactiveParams);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 更新 _editRender 为处理后的 _component
|
|
192
|
+
var _editRender = _component;
|
|
193
|
+
|
|
187
194
|
// 是否只读文本
|
|
188
195
|
var isView = !isEditable || (record === null || record === void 0 ? void 0 : record['is-view']) || config.isView || virtualKey && !_isEditing || getDisabled({
|
|
189
196
|
globalControl: otherProps === null || otherProps === void 0 ? void 0 : otherProps.globalControl,
|
|
@@ -208,7 +215,7 @@ var RenderField = _ref => {
|
|
|
208
215
|
label: label,
|
|
209
216
|
labelRequired,
|
|
210
217
|
required: !isView && _required,
|
|
211
|
-
rules:
|
|
218
|
+
rules: !isView ? _rules : [],
|
|
212
219
|
isSelect: isSelect({
|
|
213
220
|
dataSource: (_fieldProps2 = _fieldProps) === null || _fieldProps2 === void 0 ? void 0 : _fieldProps2.dataSource,
|
|
214
221
|
type
|
|
@@ -230,10 +237,13 @@ var RenderField = _ref => {
|
|
|
230
237
|
// 允许formItem的属性放在column最外层 - 使用useMemo优化(剔除会透传到 DOM 的字段)
|
|
231
238
|
var _formItemProps = useMemo(() => _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultProps), omit(resetProps, OMIT_FORM_ITEM_AND_DOM_KEYS)), internalRule), {}, {
|
|
232
239
|
validateTrigger
|
|
240
|
+
// 注意:当 hasFunctionDependency 时会设置 shouldUpdate,shouldUpdate 与 dependencies 互斥,不透传 dependencies
|
|
233
241
|
}), [defaultProps, resetProps, internalRule, validateTrigger]);
|
|
234
242
|
|
|
235
|
-
//
|
|
243
|
+
// 当这些函数类型存在时,自动添加 shouldUpdate
|
|
236
244
|
// 因为这些函数依赖行数据,当行数据变化时需要重新计算
|
|
245
|
+
// 扩展到所有模式(single/multiple/cell),统一行为
|
|
246
|
+
// 注意:需要检查原始的 component/editRender,而不是处理后的 _component
|
|
237
247
|
var hasFunctionDependency = isFunction(column === null || column === void 0 ? void 0 : column.disabled) ||
|
|
238
248
|
// disabled 是函数
|
|
239
249
|
isFunction(fieldProps) ||
|
|
@@ -244,12 +254,16 @@ var RenderField = _ref => {
|
|
|
244
254
|
// rules 是函数
|
|
245
255
|
isFunction(isEditable) ||
|
|
246
256
|
// isEditable 是函数
|
|
247
|
-
isFunction(
|
|
248
|
-
// component
|
|
257
|
+
isFunction(component) ||
|
|
258
|
+
// component 是函数
|
|
259
|
+
isFunction(editRender) ||
|
|
260
|
+
// editRender 是函数
|
|
249
261
|
isFunction(viewRender); // viewRender 是函数
|
|
250
262
|
|
|
251
|
-
|
|
252
|
-
|
|
263
|
+
// 移除 isSingleMode 限制,让所有模式都支持响应式更新
|
|
264
|
+
// 性能优化已通过 useShouldUpdateForTable hook 的缓存和防抖机制实现
|
|
265
|
+
if (hasFunctionDependency) {
|
|
266
|
+
// 使用 shouldUpdate 监听同一行的数据变化;shouldUpdate 与 dependencies 互斥,始终优先 shouldUpdate
|
|
253
267
|
_formItemProps.shouldUpdate = (prevValues, currentValues) => {
|
|
254
268
|
var prevRow = get(prevValues, [...namePath, index]);
|
|
255
269
|
var currentRow = get(currentValues, [...namePath, index]);
|
|
@@ -327,11 +341,14 @@ var RenderField = _ref => {
|
|
|
327
341
|
TargetComponent = (_componentMap$type = componentMap[type]) !== null && _componentMap$type !== void 0 ? _componentMap$type : /*#__PURE__*/_jsx(_Fragment, {});
|
|
328
342
|
}
|
|
329
343
|
if (isEditable && _isEditing) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
344
|
+
// _editRender 已经是处理后的值(通过 dynamicProps.component 或直接计算)
|
|
345
|
+
// 如果原本是函数,此时 _editRender 已经是执行后的 ReactNode
|
|
346
|
+
// 如果原本是 ReactElement,_editRender 就是 ReactElement
|
|
333
347
|
if ( /*#__PURE__*/React.isValidElement(_editRender)) {
|
|
334
348
|
TargetComponent = _editRender;
|
|
349
|
+
} else if (_editRender) {
|
|
350
|
+
// 其他情况(可能是字符串或其他类型的 ReactNode)
|
|
351
|
+
TargetComponent = _editRender;
|
|
335
352
|
}
|
|
336
353
|
}
|
|
337
354
|
|
|
@@ -360,25 +377,25 @@ var RenderField = _ref => {
|
|
|
360
377
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
361
378
|
args[_key] = arguments[_key];
|
|
362
379
|
}
|
|
363
|
-
var
|
|
380
|
+
var rawArgs = (args === null || args === void 0 ? void 0 : args.length) === 1 && Array.isArray(args === null || args === void 0 ? void 0 : args[0]) ? args === null || args === void 0 ? void 0 : args[0] : args;
|
|
364
381
|
var nextArgs = [];
|
|
365
|
-
nextArgs[0] =
|
|
382
|
+
nextArgs[0] = rawArgs === null || rawArgs === void 0 ? void 0 : rawArgs[0];
|
|
366
383
|
// 返回表单元素默认值
|
|
367
384
|
nextArgs[2] = _objectSpread(_objectSpread({}, options), {}, {
|
|
368
|
-
extra:
|
|
385
|
+
extra: rawArgs
|
|
369
386
|
});
|
|
370
387
|
switch (type) {
|
|
371
388
|
case 'ProSelect':
|
|
372
389
|
case 'ProModalSelect':
|
|
373
390
|
case 'ProEnum':
|
|
374
|
-
nextArgs[2].option =
|
|
391
|
+
nextArgs[2].option = rawArgs === null || rawArgs === void 0 ? void 0 : rawArgs[1];
|
|
375
392
|
break;
|
|
376
393
|
case 'ProCascader':
|
|
377
|
-
nextArgs[2].selectedOptions =
|
|
394
|
+
nextArgs[2].selectedOptions = rawArgs === null || rawArgs === void 0 ? void 0 : rawArgs[1];
|
|
378
395
|
break;
|
|
379
396
|
case 'DatePicker':
|
|
380
397
|
case 'RangePicker':
|
|
381
|
-
nextArgs[2].dateString =
|
|
398
|
+
nextArgs[2].dateString = rawArgs === null || rawArgs === void 0 ? void 0 : rawArgs[1];
|
|
382
399
|
break;
|
|
383
400
|
default:
|
|
384
401
|
break;
|
|
@@ -401,13 +418,13 @@ var RenderField = _ref => {
|
|
|
401
418
|
|
|
402
419
|
// 使用 useCallback 创建稳定的 onChange 函数
|
|
403
420
|
var _onChange = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
404
|
-
var
|
|
421
|
+
var executeChange,
|
|
422
|
+
_args3 = arguments;
|
|
405
423
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
406
424
|
while (1) switch (_context2.prev = _context2.next) {
|
|
407
425
|
case 0:
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
debounceRef.current = debounce( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
426
|
+
executeChange = /*#__PURE__*/function () {
|
|
427
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
411
428
|
var _len2,
|
|
412
429
|
innerArgs,
|
|
413
430
|
_key2,
|
|
@@ -419,10 +436,11 @@ var RenderField = _ref => {
|
|
|
419
436
|
orgRow,
|
|
420
437
|
_TargetComponent,
|
|
421
438
|
_TargetComponent2,
|
|
422
|
-
|
|
423
|
-
_Object$
|
|
439
|
+
rowAfter,
|
|
440
|
+
_Object$keys2,
|
|
441
|
+
_Object$keys2$map,
|
|
424
442
|
diff,
|
|
425
|
-
|
|
443
|
+
_validateFieldKeys2,
|
|
426
444
|
_args2 = arguments;
|
|
427
445
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
428
446
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -447,7 +465,7 @@ var RenderField = _ref => {
|
|
|
447
465
|
row = form.getFieldValue(rowPath, true);
|
|
448
466
|
orgRow = cloneDeep(row);
|
|
449
467
|
if (!onFieldChange) {
|
|
450
|
-
_context.next =
|
|
468
|
+
_context.next = 22;
|
|
451
469
|
break;
|
|
452
470
|
}
|
|
453
471
|
_args = formatArgs(innerArgs);
|
|
@@ -468,58 +486,88 @@ var RenderField = _ref => {
|
|
|
468
486
|
_context.next = 19;
|
|
469
487
|
return onFieldChange(..._args);
|
|
470
488
|
case 19:
|
|
471
|
-
|
|
489
|
+
// onFieldChange 内已通过 form.setFieldValue(子路径) 或原地改 record 更新 store;此处再整行 setFieldValue(rowPath, rowAfter) 易用滞后快照覆盖 Field 刚写入的新值(如 formType)。仅延后读表做校验与 forceUpdate,不再整行回写。
|
|
490
|
+
setTimeout(() => {
|
|
491
|
+
var _form$getFieldValue;
|
|
492
|
+
var rowAfter = (_form$getFieldValue = form.getFieldValue(rowPath, true)) !== null && _form$getFieldValue !== void 0 ? _form$getFieldValue : row;
|
|
493
|
+
if (validateTrigger && validateTrigger.includes('onChange')) {
|
|
494
|
+
if (!isEqual(orgRow, rowAfter)) {
|
|
495
|
+
var _Object$keys, _Object$keys$map;
|
|
496
|
+
var diff = difference(rowAfter, orgRow) || {};
|
|
497
|
+
var _validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 || (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, key => [...rowPath, key]).concat(dependencies || []);
|
|
498
|
+
if (_validateFieldKeys !== null && _validateFieldKeys !== void 0 && _validateFieldKeys.length) {
|
|
499
|
+
debounceValidate(_validateFieldKeys);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
if (!isEqual(orgRow, rowAfter)) {
|
|
504
|
+
compatStartTransition(() => {
|
|
505
|
+
setState({
|
|
506
|
+
forceUpdate: {
|
|
507
|
+
rowKey: record === null || record === void 0 ? void 0 : record.rowKey
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
}, 0);
|
|
513
|
+
_context.next = 34;
|
|
472
514
|
break;
|
|
473
|
-
case
|
|
515
|
+
case 22:
|
|
474
516
|
_args = _args.concat([row, index, form]);
|
|
475
517
|
_context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 || (_TargetComponent2 = _TargetComponent2.props) === null || _TargetComponent2 === void 0 ? void 0 : _TargetComponent2.onChange;
|
|
476
518
|
if (!_context.t2) {
|
|
477
|
-
_context.next =
|
|
519
|
+
_context.next = 27;
|
|
478
520
|
break;
|
|
479
521
|
}
|
|
480
|
-
_context.next =
|
|
522
|
+
_context.next = 27;
|
|
481
523
|
return TargetComponent.props.onChange(..._args);
|
|
482
|
-
case
|
|
524
|
+
case 27:
|
|
483
525
|
_context.t3 = onChange;
|
|
484
526
|
if (!_context.t3) {
|
|
485
|
-
_context.next =
|
|
527
|
+
_context.next = 31;
|
|
486
528
|
break;
|
|
487
529
|
}
|
|
488
|
-
_context.next =
|
|
530
|
+
_context.next = 31;
|
|
489
531
|
return onChange(..._args);
|
|
490
|
-
case
|
|
491
|
-
|
|
492
|
-
form.setFieldValue(rowPath,
|
|
532
|
+
case 31:
|
|
533
|
+
rowAfter = row;
|
|
534
|
+
form.setFieldValue(rowPath, rowAfter);
|
|
493
535
|
if (validateTrigger && validateTrigger.includes('onChange')) {
|
|
494
|
-
if (!isEqual(orgRow,
|
|
495
|
-
diff = difference(
|
|
496
|
-
|
|
497
|
-
if (
|
|
498
|
-
debounceValidate(
|
|
536
|
+
if (!isEqual(orgRow, rowAfter)) {
|
|
537
|
+
diff = difference(rowAfter, orgRow) || {};
|
|
538
|
+
_validateFieldKeys2 = (_Object$keys2 = Object.keys(diff)) === null || _Object$keys2 === void 0 || (_Object$keys2$map = _Object$keys2.map) === null || _Object$keys2$map === void 0 ? void 0 : _Object$keys2$map.call(_Object$keys2, key => [...rowPath, key]).concat(dependencies || []);
|
|
539
|
+
if (_validateFieldKeys2 !== null && _validateFieldKeys2 !== void 0 && _validateFieldKeys2.length) {
|
|
540
|
+
debounceValidate(_validateFieldKeys2);
|
|
499
541
|
}
|
|
500
542
|
}
|
|
501
543
|
}
|
|
502
|
-
|
|
503
|
-
if (onFieldChange && !isEqual(orgRow, row)) {
|
|
504
|
-
compatStartTransition(() => {
|
|
505
|
-
setState({
|
|
506
|
-
forceUpdate: {
|
|
507
|
-
rowKey: record === null || record === void 0 ? void 0 : record.rowKey
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
case 33:
|
|
544
|
+
case 34:
|
|
513
545
|
case "end":
|
|
514
546
|
return _context.stop();
|
|
515
547
|
}
|
|
516
548
|
}, _callee);
|
|
517
|
-
}))
|
|
549
|
+
}));
|
|
550
|
+
return function executeChange() {
|
|
551
|
+
return _ref3.apply(this, arguments);
|
|
552
|
+
};
|
|
553
|
+
}(); // onFieldChange 立即执行,不走防抖
|
|
554
|
+
// 表格行数据变化会导致组件卸载重建,防抖回调会在 cleanup 中被取消
|
|
555
|
+
if (!onFieldChange) {
|
|
556
|
+
_context2.next = 5;
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
_context2.next = 4;
|
|
560
|
+
return executeChange(..._args3);
|
|
561
|
+
case 4:
|
|
562
|
+
return _context2.abrupt("return");
|
|
563
|
+
case 5:
|
|
564
|
+
// 没有 onFieldChange 时,使用防抖处理 onChange
|
|
565
|
+
if (!debounceRef.current) {
|
|
566
|
+
debounceRef.current = debounce(executeChange, 300);
|
|
518
567
|
}
|
|
519
|
-
|
|
520
568
|
// 调用防抖函数
|
|
521
569
|
debounceRef.current(..._args3);
|
|
522
|
-
case
|
|
570
|
+
case 7:
|
|
523
571
|
case "end":
|
|
524
572
|
return _context2.stop();
|
|
525
573
|
}
|
|
@@ -538,15 +586,12 @@ var RenderField = _ref => {
|
|
|
538
586
|
// 使用useCallback优化_onblur函数
|
|
539
587
|
var _onblur = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
540
588
|
var _TargetComponent3;
|
|
541
|
-
var
|
|
542
|
-
args,
|
|
543
|
-
_key3,
|
|
544
|
-
_args,
|
|
589
|
+
var _args,
|
|
545
590
|
rowPath,
|
|
546
591
|
row,
|
|
547
592
|
orgRow,
|
|
548
|
-
_Object$
|
|
549
|
-
_Object$
|
|
593
|
+
_Object$keys3,
|
|
594
|
+
_Object$keys3$map,
|
|
550
595
|
diff,
|
|
551
596
|
validateFieldKeys,
|
|
552
597
|
_args4 = arguments;
|
|
@@ -559,52 +604,49 @@ var RenderField = _ref => {
|
|
|
559
604
|
}
|
|
560
605
|
return _context3.abrupt("return", null);
|
|
561
606
|
case 2:
|
|
562
|
-
|
|
563
|
-
args[_key3] = _args4[_key3];
|
|
564
|
-
}
|
|
565
|
-
_args = formatArgs([...args]);
|
|
607
|
+
_args = formatArgs(..._args4);
|
|
566
608
|
rowPath = [...namePath, index];
|
|
567
609
|
row = form.getFieldValue(rowPath, true);
|
|
568
610
|
orgRow = cloneDeep(row);
|
|
569
611
|
_args[1] = row;
|
|
570
612
|
_context3.t0 = (_TargetComponent3 = TargetComponent) === null || _TargetComponent3 === void 0 || (_TargetComponent3 = _TargetComponent3.props) === null || _TargetComponent3 === void 0 ? void 0 : _TargetComponent3.onBlur;
|
|
571
613
|
if (!_context3.t0) {
|
|
572
|
-
_context3.next =
|
|
614
|
+
_context3.next = 11;
|
|
573
615
|
break;
|
|
574
616
|
}
|
|
575
|
-
_context3.next =
|
|
617
|
+
_context3.next = 11;
|
|
576
618
|
return TargetComponent.props.onBlur(..._args);
|
|
577
|
-
case
|
|
619
|
+
case 11:
|
|
578
620
|
_context3.t1 = onBlur;
|
|
579
621
|
if (!_context3.t1) {
|
|
580
|
-
_context3.next =
|
|
622
|
+
_context3.next = 15;
|
|
581
623
|
break;
|
|
582
624
|
}
|
|
583
|
-
_context3.next =
|
|
625
|
+
_context3.next = 15;
|
|
584
626
|
return onBlur(..._args);
|
|
585
|
-
case
|
|
627
|
+
case 15:
|
|
586
628
|
// 判断属性是否变动
|
|
587
629
|
form.setFieldValue(rowPath, row);
|
|
588
630
|
if (validateTrigger && validateTrigger.includes('onBlur')) {
|
|
589
631
|
if (!isEqual(orgRow, row)) {
|
|
590
632
|
diff = difference(row, orgRow) || {};
|
|
591
|
-
validateFieldKeys = (_Object$
|
|
633
|
+
validateFieldKeys = (_Object$keys3 = Object.keys(diff)) === null || _Object$keys3 === void 0 || (_Object$keys3$map = _Object$keys3.map) === null || _Object$keys3$map === void 0 ? void 0 : _Object$keys3$map.call(_Object$keys3, key => [...rowPath, key]).concat(dependencies || []);
|
|
592
634
|
if (validateFieldKeys !== null && validateFieldKeys !== void 0 && validateFieldKeys.length) {
|
|
593
635
|
debounceValidate(validateFieldKeys);
|
|
594
636
|
}
|
|
595
637
|
}
|
|
596
638
|
}
|
|
597
639
|
if (!isCell) {
|
|
598
|
-
_context3.next =
|
|
640
|
+
_context3.next = 21;
|
|
599
641
|
break;
|
|
600
642
|
}
|
|
601
|
-
_context3.next =
|
|
643
|
+
_context3.next = 20;
|
|
602
644
|
return form.validateFields([cellName]);
|
|
603
|
-
case
|
|
645
|
+
case 20:
|
|
604
646
|
setState({
|
|
605
647
|
cellNamePath: []
|
|
606
648
|
});
|
|
607
|
-
case
|
|
649
|
+
case 21:
|
|
608
650
|
// 单行编辑时需要 强制更新视图,仅对当前行打标记
|
|
609
651
|
compatStartTransition(() => {
|
|
610
652
|
setState({
|
|
@@ -613,7 +655,7 @@ var RenderField = _ref => {
|
|
|
613
655
|
}
|
|
614
656
|
});
|
|
615
657
|
});
|
|
616
|
-
case
|
|
658
|
+
case 22:
|
|
617
659
|
case "end":
|
|
618
660
|
return _context3.stop();
|
|
619
661
|
}
|
|
@@ -673,7 +715,38 @@ var RenderField = _ref => {
|
|
|
673
715
|
|
|
674
716
|
// 使用useMemo优化最终的formItemProps - 修复Hooks使用规则
|
|
675
717
|
var finalFormItemProps = useMemo(() => {
|
|
676
|
-
|
|
718
|
+
var _namesTransformProps$, _namesTransformProps$2;
|
|
719
|
+
var defaultTransformProps = defaultTransform();
|
|
720
|
+
var namesTransformProps = namesTransform();
|
|
721
|
+
var trimProps = isTrim(type, trim, proConfig); // 使用顶层调用的proConfig
|
|
722
|
+
|
|
723
|
+
var transformNormalize = (_namesTransformProps$ = namesTransformProps === null || namesTransformProps === void 0 ? void 0 : namesTransformProps.normalize) !== null && _namesTransformProps$ !== void 0 ? _namesTransformProps$ : defaultTransformProps === null || defaultTransformProps === void 0 ? void 0 : defaultTransformProps.normalize;
|
|
724
|
+
var userNormalize = _formItemProps === null || _formItemProps === void 0 ? void 0 : _formItemProps.normalize;
|
|
725
|
+
var transformGetValueProps = (_namesTransformProps$2 = namesTransformProps === null || namesTransformProps === void 0 ? void 0 : namesTransformProps.getValueProps) !== null && _namesTransformProps$2 !== void 0 ? _namesTransformProps$2 : defaultTransformProps === null || defaultTransformProps === void 0 ? void 0 : defaultTransformProps.getValueProps;
|
|
726
|
+
var userGetValueProps = _formItemProps === null || _formItemProps === void 0 ? void 0 : _formItemProps.getValueProps;
|
|
727
|
+
var finalNormalize = transformNormalize && userNormalize ? (value, prevValue, allValues, isDiffMode) => {
|
|
728
|
+
// 用户 normalize 需要拿到组件原始值(如 DatePicker 的 dayjs)
|
|
729
|
+
var userValue = userNormalize(value, prevValue, allValues, isDiffMode);
|
|
730
|
+
// 保持用户优先:用户有明确返回值时直接使用,不再强制走内置转换
|
|
731
|
+
if (userValue !== undefined) {
|
|
732
|
+
return userValue;
|
|
733
|
+
}
|
|
734
|
+
// 仅在用户未返回时,回退到内置 transform 逻辑
|
|
735
|
+
return transformNormalize(value, prevValue, allValues, isDiffMode);
|
|
736
|
+
} : userNormalize || transformNormalize;
|
|
737
|
+
var finalGetValueProps = transformGetValueProps && userGetValueProps ? function (value) {
|
|
738
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
739
|
+
args[_key3 - 1] = arguments[_key3];
|
|
740
|
+
}
|
|
741
|
+
var transformValueProps = transformGetValueProps(value, ...args) || {};
|
|
742
|
+
var nextValue = Object.prototype.hasOwnProperty.call(transformValueProps, 'value') ? transformValueProps.value : value;
|
|
743
|
+
var userValueProps = userGetValueProps(nextValue, ...args) || {};
|
|
744
|
+
return _objectSpread(_objectSpread({}, transformValueProps), userValueProps);
|
|
745
|
+
} : userGetValueProps || transformGetValueProps;
|
|
746
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, _formItemProps), defaultTransformProps), namesTransformProps), trimProps), {}, {
|
|
747
|
+
normalize: finalNormalize,
|
|
748
|
+
getValueProps: finalGetValueProps
|
|
749
|
+
});
|
|
677
750
|
}, [_formItemProps, defaultTransform, namesTransform, type, trim, proConfig]);
|
|
678
751
|
|
|
679
752
|
// 编辑&保存模式,在查看状态下移除表单的rules不做校验
|
|
@@ -691,20 +764,50 @@ var RenderField = _ref => {
|
|
|
691
764
|
// 如果处于 shouldUpdate 模式,需要重新获取最新的行数据并重新计算依赖值
|
|
692
765
|
var finalComponentProps = componentProps;
|
|
693
766
|
if (shouldUpdateMode) {
|
|
694
|
-
|
|
767
|
+
var _column$isEditable2;
|
|
768
|
+
// 重新获取最新的行数据(shouldUpdate 触发时,通过 getFieldValue 拿到最新值)
|
|
695
769
|
var latestRowData = form.getFieldValue([...namePath, index]) || record || {};
|
|
696
|
-
var
|
|
697
|
-
index,
|
|
770
|
+
var latestReactiveParams = {
|
|
698
771
|
form,
|
|
699
|
-
|
|
772
|
+
index,
|
|
700
773
|
namePath: [...namePath, index]
|
|
701
774
|
};
|
|
702
|
-
var latestRowParams = [latestRowData,
|
|
775
|
+
var latestRowParams = [latestRowData, latestReactiveParams];
|
|
703
776
|
|
|
704
|
-
//
|
|
777
|
+
// ⭐ 关键修改:shouldUpdate 模式下,跳过缓存,直接重新计算所有响应式属性
|
|
705
778
|
var latestFieldProps = fieldProps || formItemProps || {};
|
|
706
779
|
if (isFunction(fieldProps)) {
|
|
707
|
-
latestFieldProps = fieldProps(
|
|
780
|
+
latestFieldProps = fieldProps(latestRowData, latestReactiveParams);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// 重新计算 required(用于可能的后续逻辑)
|
|
784
|
+
var latestRequired = required;
|
|
785
|
+
if (isFunction(required)) {
|
|
786
|
+
latestRequired = required(latestRowData, latestReactiveParams);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// 重新计算 rules(用于可能的后续逻辑)
|
|
790
|
+
var latestRules = rules;
|
|
791
|
+
if (isFunction(rules)) {
|
|
792
|
+
latestRules = rules(latestRowData, latestReactiveParams);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// 重新计算 desensitization
|
|
796
|
+
var latestDesensitization = desensitization || [];
|
|
797
|
+
if (isFunction(desensitization)) {
|
|
798
|
+
latestDesensitization = desensitization(latestRowData, latestReactiveParams);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// 重新计算 component
|
|
802
|
+
var latestComponent = component || editRender;
|
|
803
|
+
if (isFunction(latestComponent)) {
|
|
804
|
+
latestComponent = latestComponent(latestRowData, latestReactiveParams);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// 重新计算 isEditable(使用原始的 column.isEditable,而不是处理后的 isEditable)
|
|
808
|
+
var latestIsEditable = (_column$isEditable2 = column.isEditable) !== null && _column$isEditable2 !== void 0 ? _column$isEditable2 : true;
|
|
809
|
+
if (isFunction(column.isEditable)) {
|
|
810
|
+
latestIsEditable = column.isEditable(latestRowData, latestReactiveParams);
|
|
708
811
|
}
|
|
709
812
|
|
|
710
813
|
// 重新计算 disabled
|
|
@@ -717,10 +820,75 @@ var RenderField = _ref => {
|
|
|
717
820
|
params: latestRowParams
|
|
718
821
|
});
|
|
719
822
|
|
|
720
|
-
// 更新 componentProps
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
823
|
+
// 更新 componentProps 中的所有响应式属性
|
|
824
|
+
// latestTargetComponent 稍后计算,此处先占位;最终 finalComponentProps 会在下方合并 latestTargetComponent?.props
|
|
825
|
+
finalComponentProps = _objectSpread(_objectSpread(_objectSpread({}, componentProps), latestFieldProps), {}, {
|
|
826
|
+
disabled: latestDisabled,
|
|
827
|
+
desensitization: latestDesensitization,
|
|
828
|
+
// shouldUpdate 模式下,确保事件包装函数不被 fieldProps 覆盖
|
|
829
|
+
onChange: _onChange,
|
|
830
|
+
onBlur: _onblur
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
// ⭐ 关键修改:在 shouldUpdate 模式下,需要重新设置 TargetComponent
|
|
834
|
+
// 因为 component 函数可能返回不同的结果
|
|
835
|
+
var latestTargetComponent = TargetComponent;
|
|
836
|
+
|
|
837
|
+
// 首先检查是否有内置type
|
|
838
|
+
if (!latestComponent && typeof type === 'string') {
|
|
839
|
+
var _componentMap$type2;
|
|
840
|
+
latestTargetComponent = (_componentMap$type2 = componentMap[type]) !== null && _componentMap$type2 !== void 0 ? _componentMap$type2 : /*#__PURE__*/_jsx(_Fragment, {});
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// 然后处理自定义 component
|
|
844
|
+
var latestIsView = !latestIsEditable || (record === null || record === void 0 ? void 0 : record['is-view']) || config.isView || virtualKey && !_isEditing || getDisabled({
|
|
845
|
+
globalControl: otherProps === null || otherProps === void 0 ? void 0 : otherProps.globalControl,
|
|
846
|
+
formDisabled: otherProps === null || otherProps === void 0 ? void 0 : otherProps.formDisabled,
|
|
847
|
+
column,
|
|
848
|
+
tabledDisabled: config === null || config === void 0 ? void 0 : config.disabled,
|
|
849
|
+
columnFieldProps: latestFieldProps,
|
|
850
|
+
params: latestRowParams,
|
|
851
|
+
rowDisabled: rowDisabled || 'empty'
|
|
852
|
+
});
|
|
853
|
+
if (latestIsEditable && _isEditing) {
|
|
854
|
+
if ( /*#__PURE__*/React.isValidElement(latestComponent)) {
|
|
855
|
+
latestTargetComponent = latestComponent;
|
|
856
|
+
} else if (latestComponent) {
|
|
857
|
+
latestTargetComponent = latestComponent;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// 查看模式
|
|
862
|
+
if (latestIsView) {
|
|
863
|
+
if (typeof viewRender === 'function') {
|
|
864
|
+
var latestCurrentValue = dataIndex ? latestRowData === null || latestRowData === void 0 ? void 0 : latestRowData[dataIndex] : null;
|
|
865
|
+
var _View = viewRender(latestCurrentValue, latestRowData || {}, options);
|
|
866
|
+
latestTargetComponent = /*#__PURE__*/_jsx(Container, {
|
|
867
|
+
viewEmpty: viewEmpty,
|
|
868
|
+
children: _View
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
if ( /*#__PURE__*/React.isValidElement(viewRender)) {
|
|
872
|
+
latestTargetComponent = viewRender;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
// 使用重新计算的 TargetComponent
|
|
877
|
+
TargetComponent = latestTargetComponent;
|
|
878
|
+
|
|
879
|
+
// componentProps 里展开了外层旧 TargetComponent?.props(如 { formType: "Input" }),
|
|
880
|
+
// 用 latestTargetComponent?.props 覆盖,确保不会被旧 cloneElement props 污染
|
|
881
|
+
if ( /*#__PURE__*/React.isValidElement(latestTargetComponent)) {
|
|
882
|
+
var _componentProps = latestTargetComponent.props;
|
|
883
|
+
// 确保 props 是对象类型才进行展开
|
|
884
|
+
if (_componentProps && typeof _componentProps === 'object') {
|
|
885
|
+
finalComponentProps = _objectSpread(_objectSpread(_objectSpread({}, finalComponentProps), _componentProps), {}, {
|
|
886
|
+
// 始终保证事件处理函数不被覆盖
|
|
887
|
+
onChange: _onChange,
|
|
888
|
+
onBlur: _onblur
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
}
|
|
724
892
|
}
|
|
725
893
|
var FormItem = null;
|
|
726
894
|
// 当 viewRender 存在时,需要排除 finalComponentProps 中的 children,避免覆盖 Container 的 children
|
|
@@ -730,7 +898,15 @@ var RenderField = _ref => {
|
|
|
730
898
|
if (isTargetDomElement) {
|
|
731
899
|
propsForTarget = omit(propsForTarget, ['disabled', ...OMIT_FORM_ITEM_AND_DOM_KEYS]);
|
|
732
900
|
}
|
|
733
|
-
|
|
901
|
+
// 当 TargetComponent 未定义时,使用空的占位组件避免渲染错误
|
|
902
|
+
var FieldComponent = null;
|
|
903
|
+
if ( /*#__PURE__*/React.isValidElement(TargetComponent)) {
|
|
904
|
+
FieldComponent = /*#__PURE__*/React.cloneElement(TargetComponent, propsForTarget);
|
|
905
|
+
} else if (TargetComponent) {
|
|
906
|
+
FieldComponent = /*#__PURE__*/_jsx(TargetComponent, _objectSpread({}, propsForTarget));
|
|
907
|
+
} else {
|
|
908
|
+
FieldComponent = /*#__PURE__*/_jsx(_Fragment, {});
|
|
909
|
+
}
|
|
734
910
|
if (originalValues && !getIsNew(record)) {
|
|
735
911
|
FieldComponent = /*#__PURE__*/_jsx(ListChangedWrapper, {
|
|
736
912
|
name: cellName,
|
|
@@ -761,7 +937,7 @@ var RenderField = _ref => {
|
|
|
761
937
|
}
|
|
762
938
|
FormItem = TargetComponent ? /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({
|
|
763
939
|
validateFirst: true
|
|
764
|
-
}, omit(finalFormItemProps, ['render', 'key', 'width', 'hiddenNames', 'name', 'onCell', _formItemProps.shouldUpdate ? 'shouldUpdate' : null])), {}, {
|
|
940
|
+
}, omit(finalFormItemProps, ['render', 'key', 'width', 'hiddenNames', 'name', 'onCell', 'disabled', _formItemProps.shouldUpdate ? 'shouldUpdate' : null])), {}, {
|
|
765
941
|
// 移除非必要字段,但保留 dependencies
|
|
766
942
|
className: _className,
|
|
767
943
|
name: formNamePath ? cellName.slice((formNamePath === null || formNamePath === void 0 ? void 0 : formNamePath.length) - 1) : cellName,
|
|
@@ -784,7 +960,7 @@ var RenderField = _ref => {
|
|
|
784
960
|
return FormItem;
|
|
785
961
|
};
|
|
786
962
|
return /*#__PURE__*/_jsx(FieldProvider, {
|
|
787
|
-
value: ((
|
|
963
|
+
value: ((_componentProps2 = componentProps) === null || _componentProps2 === void 0 ? void 0 : _componentProps2.otherProps) || {},
|
|
788
964
|
children: finalFormItemProps.shouldUpdate ? /*#__PURE__*/_jsx(Form.Item, {
|
|
789
965
|
noStyle: true,
|
|
790
966
|
shouldUpdate: finalFormItemProps.shouldUpdate,
|
|
@@ -805,6 +981,12 @@ export default /*#__PURE__*/memo(RenderField, (prevProps, nextProps) => {
|
|
|
805
981
|
nextColumn = nextProps.column,
|
|
806
982
|
nextConfig = nextProps.config;
|
|
807
983
|
|
|
984
|
+
// 自定义 component/editRender 且行对象为同引用时,浅比较无法区分原地修改,需强制重渲染
|
|
985
|
+
var hasFunctionComponent = isFunction(prevColumn === null || prevColumn === void 0 ? void 0 : prevColumn.component) || isFunction(prevColumn === null || prevColumn === void 0 ? void 0 : prevColumn.editRender) || isFunction(nextColumn === null || nextColumn === void 0 ? void 0 : nextColumn.component) || isFunction(nextColumn === null || nextColumn === void 0 ? void 0 : nextColumn.editRender);
|
|
986
|
+
if (hasFunctionComponent && prevRecord === nextRecord) {
|
|
987
|
+
return false;
|
|
988
|
+
}
|
|
989
|
+
|
|
808
990
|
// 构建新的参数格式(与 ProForm 保持一致)
|
|
809
991
|
var prevNamePath = getNamePath(prevConfig === null || prevConfig === void 0 ? void 0 : prevConfig.name, prevConfig === null || prevConfig === void 0 ? void 0 : prevConfig.virtualKey);
|
|
810
992
|
var nextNamePath = getNamePath(nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.name, nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.virtualKey);
|
|
@@ -827,20 +1009,33 @@ export default /*#__PURE__*/memo(RenderField, (prevProps, nextProps) => {
|
|
|
827
1009
|
}
|
|
828
1010
|
|
|
829
1011
|
// fieldProps 函数化直接更新,无法比对返回值是否一致
|
|
1012
|
+
// 优化:不直接调用函数,而是比较输入参数(record 和 reactiveParams)
|
|
1013
|
+
// 如果输入参数相同,fieldProps 的返回值应该相同(纯函数假设)
|
|
830
1014
|
if (isFunction(prevColumn === null || prevColumn === void 0 ? void 0 : prevColumn.fieldProps) && isFunction(nextColumn === null || nextColumn === void 0 ? void 0 : nextColumn.fieldProps)) {
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
1015
|
+
// 比较 record 数据是否变化
|
|
1016
|
+
if (!isEqualWith(prevRecord, nextRecord, customEqualForFunction)) {
|
|
1017
|
+
return false;
|
|
1018
|
+
}
|
|
1019
|
+
// reactiveParams 中的 form、index、namePath 已经在外层比较过了,无需重复比较
|
|
1020
|
+
}
|
|
1021
|
+
// fieldProps 为对象时,必须比较配置变化(如 dataSource 异步更新)
|
|
1022
|
+
if (!isFunction(prevColumn === null || prevColumn === void 0 ? void 0 : prevColumn.fieldProps) && !isFunction(nextColumn === null || nextColumn === void 0 ? void 0 : nextColumn.fieldProps)) {
|
|
1023
|
+
var isFieldPropsEqual = isEqualWith(prevColumn === null || prevColumn === void 0 ? void 0 : prevColumn.fieldProps, nextColumn === null || nextColumn === void 0 ? void 0 : nextColumn.fieldProps, customEqualForFunction);
|
|
1024
|
+
if (!isFieldPropsEqual) {
|
|
834
1025
|
return false;
|
|
835
1026
|
}
|
|
836
1027
|
}
|
|
837
1028
|
|
|
838
1029
|
// 通用函数比较方法
|
|
1030
|
+
// 优化:不直接调用函数,而是比较函数引用和输入参数
|
|
839
1031
|
var compareFunctionResult = (prevColumn, nextColumn, prevValues, nextValues, prevReactiveParams, nextReactiveParams, functionName) => {
|
|
840
1032
|
var prevFunc = prevColumn === null || prevColumn === void 0 ? void 0 : prevColumn[functionName];
|
|
841
1033
|
var nextFunc = nextColumn === null || nextColumn === void 0 ? void 0 : nextColumn[functionName];
|
|
842
1034
|
if (isFunction(prevFunc) && isFunction(nextFunc)) {
|
|
843
|
-
|
|
1035
|
+
// 函数引用变化说明闭包可能捕获了新的外部状态(如异步加载的 list),必须重渲染
|
|
1036
|
+
if (prevFunc !== nextFunc) return false;
|
|
1037
|
+
// 同引用函数,比较输入参数(纯函数假设:输入相同则输出相同)
|
|
1038
|
+
return isEqualWith(prevValues, nextValues, customEqualForFunction);
|
|
844
1039
|
}
|
|
845
1040
|
return true; // 如果不是函数或只有一个是函数,认为相等
|
|
846
1041
|
};
|