@zat-design/sisyphus-react 4.1.2-beta.2 → 4.1.2-beta.4

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.
Files changed (37) hide show
  1. package/dist/index.esm.css +1 -1
  2. package/dist/less.esm.css +1 -1
  3. package/es/ProEditTable/components/RenderField/index.js +134 -26
  4. package/es/ProEditTable/propsType.d.ts +6 -1
  5. package/es/ProEditTable/utils/index.js +26 -19
  6. package/es/ProEditTable/utils/useShouldUpdateForTable.d.ts +1 -0
  7. package/es/ProEditTable/utils/useShouldUpdateForTable.js +37 -10
  8. package/es/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
  9. package/es/ProForm/components/combination/Group/component/ComRender.js +15 -11
  10. package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +61 -7
  11. package/es/ProForm/components/combination/Group/style/index.less +26 -1
  12. package/es/ProForm/components/combination/Group/utils/index.d.ts +7 -7
  13. package/es/ProForm/components/combination/ProCascader/propsType.d.ts +1 -1
  14. package/es/ProForm/propsType.d.ts +3 -3
  15. package/es/ProForm/utils/transformValue.d.ts +1 -1
  16. package/es/ProForm/utils/useForm.d.ts +1 -1
  17. package/es/ProForm/utils/useWatch.d.ts +2 -1
  18. package/es/ProForm/utils/useWatch.js +3 -1
  19. package/es/ProUpload/propsType.d.ts +1 -1
  20. package/lib/ProEditTable/components/RenderField/index.js +134 -26
  21. package/lib/ProEditTable/propsType.d.ts +6 -1
  22. package/lib/ProEditTable/utils/index.js +26 -19
  23. package/lib/ProEditTable/utils/useShouldUpdateForTable.d.ts +1 -0
  24. package/lib/ProEditTable/utils/useShouldUpdateForTable.js +37 -10
  25. package/lib/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
  26. package/lib/ProForm/components/combination/Group/component/ComRender.js +15 -11
  27. package/lib/ProForm/components/combination/Group/component/FlexibleGroup.js +61 -7
  28. package/lib/ProForm/components/combination/Group/style/index.less +26 -1
  29. package/lib/ProForm/components/combination/Group/utils/index.d.ts +7 -7
  30. package/lib/ProForm/components/combination/ProCascader/propsType.d.ts +1 -1
  31. package/lib/ProForm/propsType.d.ts +3 -3
  32. package/lib/ProForm/utils/transformValue.d.ts +1 -1
  33. package/lib/ProForm/utils/useForm.d.ts +1 -1
  34. package/lib/ProForm/utils/useWatch.d.ts +2 -1
  35. package/lib/ProForm/utils/useWatch.js +3 -1
  36. package/lib/ProUpload/propsType.d.ts +1 -1
  37. package/package.json +4 -2
@@ -4,6 +4,15 @@
4
4
  display: flex;
5
5
  width: unset !important;
6
6
 
7
+ &.pro-group-view {
8
+ .pro-group-form-item {
9
+ flex: 0 0 auto !important;
10
+
11
+ }
12
+ .@{ant-prefix}-space-compact .pro-group-separator-compact{
13
+ color: #333 !important;
14
+ }
15
+ }
7
16
 
8
17
 
9
18
  &.pro-group-view {
@@ -385,6 +394,13 @@
385
394
  // margin: 0 !important;
386
395
  }
387
396
 
397
+ // 查看模式下,Form.Item不平分空间,而是根据内容自适应
398
+ &.pro-group-view {
399
+ .pro-group-form-item {
400
+ flex: 0 0 auto;
401
+ }
402
+ }
403
+
388
404
  // 当有自定义宽度时,只有设置了宽度的 Form.Item 不使用 flex:1
389
405
  &.pro-group-diy-width {
390
406
  // 覆盖 Space.Compact 内设置了宽度的 Form.Item
@@ -430,7 +446,7 @@
430
446
  }
431
447
 
432
448
  .@{ant-prefix}-input-number-input {
433
- border-left: 1px solid #ff4d4f !important;
449
+ border-left: 0 !important;
434
450
  }
435
451
  }
436
452
 
@@ -467,6 +483,15 @@
467
483
  margin-left: -1px;
468
484
  }
469
485
 
486
+ // 查看模式下的分隔符样式 - 移除边框,使用简洁样式
487
+ .pro-group-separator-view {
488
+ border: none !important;
489
+ background: transparent !important;
490
+ padding: 0 2px !important;
491
+ margin-inline-start: 0 !important;
492
+ color: #999 !important;
493
+ }
494
+
470
495
 
471
496
  /* 1. 处理第一个子元素:左上、左下圆角 */
472
497
  > .pro-group-form-item:first-child{
@@ -75,16 +75,15 @@ 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
- id?: string;
78
+ status?: "" | "success" | "warning" | "error" | "validating";
79
79
  className?: string;
80
80
  hidden?: boolean;
81
+ id?: string;
81
82
  style?: React.CSSProperties;
82
83
  children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
83
84
  onReset?: () => void;
84
85
  prefixCls?: string;
85
- status?: "" | "warning" | "error" | "success" | "validating";
86
86
  rootClassName?: string;
87
- isView?: boolean;
88
87
  colon?: boolean;
89
88
  htmlFor?: string;
90
89
  labelAlign?: import("antd/es/form/interface").FormLabelAlign;
@@ -108,25 +107,26 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
108
107
  hasFeedback?: boolean | {
109
108
  icons: import("antd/es/form/FormItem").FeedbackIcons;
110
109
  };
111
- validateStatus?: "" | "warning" | "error" | "success" | "validating";
110
+ validateStatus?: "" | "success" | "warning" | "error" | "validating";
112
111
  layout?: import("antd/es/form/Form").FormItemLayout;
113
112
  wrapperCol?: import("antd").ColProps;
114
113
  help?: React.ReactNode;
115
114
  fieldId?: string;
116
115
  valueType?: import("../../../render/propsType").ProFormValueType;
117
- switchValue?: [any, any];
118
116
  viewRender?: (value: any, record: any, { form, index, namePath, }: {
119
117
  [key: string]: any;
120
118
  form: FormInstance<any>;
121
119
  index?: number;
122
120
  }) => string | React.ReactElement<any, any>;
121
+ desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
122
+ isView?: boolean;
123
+ switchValue?: [any, any];
123
124
  viewType?: import("../../../render/propsType").ViewType;
124
125
  trim?: boolean;
125
126
  upperCase?: boolean;
126
127
  toISOString?: boolean;
127
128
  toCSTString?: boolean;
128
129
  clearNotShow?: boolean;
129
- desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
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, "format" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "clearNotShow" | "precision">;
144
+ componentProps: import("lodash").Omit<any, "valueType" | "precision" | "format" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "clearNotShow">;
145
145
  formItemTransform: {
146
146
  getValueProps: any;
147
147
  normalize: any;
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { DefaultOptionType } from 'rc-select/lib/Select';
2
+ import { DefaultOptionType } from '@rc-component/select/es/Select';
3
3
  import { Service, Options } from 'ahooks/lib/useRequest/src/types';
4
4
  export interface FieldNamesType {
5
5
  label: string;
@@ -1,9 +1,9 @@
1
+ import React, { ReactNode } from 'react';
1
2
  import { ButtonProps, ColProps, RowProps } from 'antd';
2
3
  import { FormProps, FormInstance } from 'antd/es/form/Form';
3
4
  import { NamePath } from 'antd/es/form/interface';
4
- import { StoreValue, Store } from 'rc-field-form/es/interface.d';
5
- import { ShouldUpdate } from 'rc-field-form/es/Field.d';
6
- import React, { ReactNode } from 'react';
5
+ import type { StoreValue, Store } from '@rc-component/form/es/interface';
6
+ import type { ShouldUpdate } from '@rc-component/form/es/Field';
7
7
  import type { ProFormColumnType, ViewType } from './components/render/propsType';
8
8
  import type { ProFormComponentType } from './components';
9
9
  export interface ButtonType extends ButtonProps {
@@ -1,6 +1,6 @@
1
1
  import { FormInstance, FormItemProps } from 'antd';
2
2
  import { NamePath } from 'antd/es/form/interface';
3
- import { StoreValue, Store } from 'rc-field-form/es/interface.d';
3
+ import type { StoreValue, Store } from '@rc-component/form/es/interface';
4
4
  import type { TransformType } from '../propsType';
5
5
  export declare const transformValue: (names: NamePath[], form: FormInstance, fieldName: NamePath, normalize?: (value: StoreValue, prevValue: StoreValue, allValues: Store) => StoreValue, getValueProps?: FormItemProps['getValueProps']) => TransformType;
6
6
  export default transformValue;
@@ -1,6 +1,6 @@
1
1
  import { FormInstance } from 'antd';
2
2
  import { NamePath } from 'antd/es/form/interface';
3
- import { ValuedNotifyInfo } from 'rc-field-form/es/interface';
3
+ import type { ValuedNotifyInfo } from '@rc-component/form/es/interface';
4
4
  export type ModifiedFormInstanceType<T> = FormInstance<T> & {
5
5
  isModified?: boolean;
6
6
  /** 默认清空设置值的报错状态 */
@@ -1,4 +1,5 @@
1
- import { FormInstance, NamePath } from 'rc-field-form/es/interface';
1
+ import { FormInstance } from 'antd/es/form/Form';
2
+ import { NamePath } from 'antd/es/form/interface';
2
3
  export declare function toArray<T>(value?: T | T[] | null): T[];
3
4
  /**
4
5
  * ProForm的useWatch hook,用于监听表单字段变化
@@ -112,7 +112,9 @@ function useWatch(dependencies, form, wait) {
112
112
  }
113
113
  }
114
114
  return paths;
115
- }, [/* dependencies 故意忽略,与原实现一致 */]);
115
+ }, [
116
+ /* dependencies 故意忽略,与原实现一致 */
117
+ ]);
116
118
 
117
119
  // 保存防抖函数引用,避免重复创建
118
120
  var debouncedFn = useMemo(() => {
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { UploadFile } from 'antd/es/upload/interface';
3
- import { UploadRequestOption } from 'rc-upload/lib/interface';
3
+ import type { UploadRequestOption } from '@rc-component/upload/es/interface';
4
4
  export type UploadType = 'drag' | 'button' | 'image';
5
5
  export interface UploadFileResType {
6
6
  /**
@@ -100,9 +100,7 @@ var RenderField = _ref => {
100
100
  var _valueType = valueType;
101
101
  var _disabled = false;
102
102
  var _desensitization = desensitization || [];
103
-
104
- // editRender弃用使用component同ProForm
105
- var _editRender = component || editRender;
103
+ var _component = component || editRender;
106
104
  var isCell = mode === 'cell';
107
105
  var isSingleMode = mode === 'single';
108
106
  if (isCell) {
@@ -191,6 +189,15 @@ var RenderField = _ref => {
191
189
  isEditable = (_dynamicProps$isEdita = dynamicProps.isEditable) !== null && _dynamicProps$isEdita !== void 0 ? _dynamicProps$isEdita : isEditable(rowData, reactiveParams);
192
190
  }
193
191
 
192
+ // component 处理 - 优先使用 hook 返回的值
193
+ if ((0, _lodash.isFunction)(_component)) {
194
+ var _dynamicProps$compone;
195
+ _component = (_dynamicProps$compone = dynamicProps.component) !== null && _dynamicProps$compone !== void 0 ? _dynamicProps$compone : _component(rowData, reactiveParams);
196
+ }
197
+
198
+ // 更新 _editRender 为处理后的 _component
199
+ var _editRender = _component;
200
+
194
201
  // 是否只读文本
195
202
  var isView = !isEditable || (record === null || record === void 0 ? void 0 : record['is-view']) || config.isView || virtualKey && !_isEditing || (0, _tools.getDisabled)({
196
203
  globalControl: otherProps === null || otherProps === void 0 ? void 0 : otherProps.globalControl,
@@ -215,7 +222,7 @@ var RenderField = _ref => {
215
222
  label: label,
216
223
  labelRequired,
217
224
  required: !isView && _required,
218
- rules: _isEditing ? _rules : [],
225
+ rules: !isView ? _rules : [],
219
226
  isSelect: (0, _utils2.isSelect)({
220
227
  dataSource: (_fieldProps2 = _fieldProps) === null || _fieldProps2 === void 0 ? void 0 : _fieldProps2.dataSource,
221
228
  type
@@ -239,8 +246,10 @@ var RenderField = _ref => {
239
246
  validateTrigger
240
247
  }), [defaultProps, resetProps, internalRule, validateTrigger]);
241
248
 
242
- // 只在 single 模式下,当这些函数类型存在时,自动添加 shouldUpdate
249
+ // 当这些函数类型存在时,自动添加 shouldUpdate
243
250
  // 因为这些函数依赖行数据,当行数据变化时需要重新计算
251
+ // 扩展到所有模式(single/multiple/cell),统一行为
252
+ // 注意:需要检查原始的 component/editRender,而不是处理后的 _component
244
253
  var hasFunctionDependency = (0, _lodash.isFunction)(column === null || column === void 0 ? void 0 : column.disabled) ||
245
254
  // disabled 是函数
246
255
  (0, _lodash.isFunction)(fieldProps) ||
@@ -251,11 +260,15 @@ var RenderField = _ref => {
251
260
  // rules 是函数
252
261
  (0, _lodash.isFunction)(isEditable) ||
253
262
  // isEditable 是函数
254
- (0, _lodash.isFunction)(_editRender) ||
255
- // component/editRender 是函数
263
+ (0, _lodash.isFunction)(component) ||
264
+ // component 是函数
265
+ (0, _lodash.isFunction)(editRender) ||
266
+ // editRender 是函数
256
267
  (0, _lodash.isFunction)(viewRender); // viewRender 是函数
257
268
 
258
- if (isSingleMode && hasFunctionDependency && !(column !== null && column !== void 0 && column.dependencies)) {
269
+ // 移除 isSingleMode 限制,让所有模式都支持响应式更新
270
+ // 性能优化已通过 useShouldUpdateForTable hook 的缓存和防抖机制实现
271
+ if (hasFunctionDependency && !(column !== null && column !== void 0 && column.dependencies)) {
259
272
  // 使用 shouldUpdate 监听同一行的数据变化
260
273
  _formItemProps.shouldUpdate = (prevValues, currentValues) => {
261
274
  var prevRow = (0, _lodash.get)(prevValues, [...namePath, index]);
@@ -334,11 +347,14 @@ var RenderField = _ref => {
334
347
  TargetComponent = (_componentMap$type = componentMap[type]) !== null && _componentMap$type !== void 0 ? _componentMap$type : /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
335
348
  }
336
349
  if (isEditable && _isEditing) {
337
- if (typeof _editRender === 'function') {
338
- TargetComponent = _editRender(...rowParams);
339
- }
350
+ // _editRender 已经是处理后的值(通过 dynamicProps.component 或直接计算)
351
+ // 如果原本是函数,此时 _editRender 已经是执行后的 ReactNode
352
+ // 如果原本是 ReactElement,_editRender 就是 ReactElement
340
353
  if ( /*#__PURE__*/_react.default.isValidElement(_editRender)) {
341
354
  TargetComponent = _editRender;
355
+ } else if (_editRender) {
356
+ // 其他情况(可能是字符串或其他类型的 ReactNode)
357
+ TargetComponent = _editRender;
342
358
  }
343
359
  }
344
360
 
@@ -714,20 +730,50 @@ var RenderField = _ref => {
714
730
  // 如果处于 shouldUpdate 模式,需要重新获取最新的行数据并重新计算依赖值
715
731
  var finalComponentProps = componentProps;
716
732
  if (shouldUpdateMode) {
733
+ var _column$isEditable2;
717
734
  // 重新获取最新的行数据
718
735
  var latestRowData = form.getFieldValue([...namePath, index]) || record || {};
719
- var latestOptions = {
720
- index,
736
+ var latestReactiveParams = {
721
737
  form,
722
- name: column === null || column === void 0 ? void 0 : column.name,
738
+ index,
723
739
  namePath: [...namePath, index]
724
740
  };
725
- var latestRowParams = [latestRowData, latestOptions];
741
+ var latestRowParams = [latestRowData, latestReactiveParams];
726
742
 
727
- // 重新计算 fieldProps
743
+ // 关键修改:shouldUpdate 模式下,跳过缓存,直接重新计算所有响应式属性
728
744
  var latestFieldProps = fieldProps || formItemProps || {};
729
745
  if ((0, _lodash.isFunction)(fieldProps)) {
730
- latestFieldProps = fieldProps(...latestRowParams);
746
+ latestFieldProps = fieldProps(latestRowData, latestReactiveParams);
747
+ }
748
+
749
+ // 重新计算 required(用于可能的后续逻辑)
750
+ var latestRequired = required;
751
+ if ((0, _lodash.isFunction)(required)) {
752
+ latestRequired = required(latestRowData, latestReactiveParams);
753
+ }
754
+
755
+ // 重新计算 rules(用于可能的后续逻辑)
756
+ var latestRules = rules;
757
+ if ((0, _lodash.isFunction)(rules)) {
758
+ latestRules = rules(latestRowData, latestReactiveParams);
759
+ }
760
+
761
+ // 重新计算 desensitization
762
+ var latestDesensitization = desensitization || [];
763
+ if ((0, _lodash.isFunction)(desensitization)) {
764
+ latestDesensitization = desensitization(latestRowData, latestReactiveParams);
765
+ }
766
+
767
+ // 重新计算 component
768
+ var latestComponent = component || editRender;
769
+ if ((0, _lodash.isFunction)(latestComponent)) {
770
+ latestComponent = latestComponent(latestRowData, latestReactiveParams);
771
+ }
772
+
773
+ // 重新计算 isEditable(使用原始的 column.isEditable,而不是处理后的 isEditable)
774
+ var latestIsEditable = (_column$isEditable2 = column.isEditable) !== null && _column$isEditable2 !== void 0 ? _column$isEditable2 : true;
775
+ if ((0, _lodash.isFunction)(column.isEditable)) {
776
+ latestIsEditable = column.isEditable(latestRowData, latestReactiveParams);
731
777
  }
732
778
 
733
779
  // 重新计算 disabled
@@ -740,10 +786,58 @@ var RenderField = _ref => {
740
786
  params: latestRowParams
741
787
  });
742
788
 
743
- // 更新 componentProps 中的 disabled 和 fieldProps
744
- finalComponentProps = _objectSpread(_objectSpread({}, componentProps), {}, {
789
+ // 更新 componentProps 中的所有响应式属性
790
+ finalComponentProps = _objectSpread(_objectSpread(_objectSpread({}, componentProps), {}, {
745
791
  disabled: latestDisabled
746
- }, latestFieldProps);
792
+ }, latestFieldProps), {}, {
793
+ desensitization: latestDesensitization
794
+ });
795
+
796
+ // ⭐ 关键修改:在 shouldUpdate 模式下,需要重新设置 TargetComponent
797
+ // 因为 component 函数可能返回不同的结果
798
+ var latestTargetComponent = TargetComponent;
799
+
800
+ // 首先检查是否有内置type
801
+ if (!latestComponent && typeof type === 'string') {
802
+ var _componentMap$type2;
803
+ latestTargetComponent = (_componentMap$type2 = componentMap[type]) !== null && _componentMap$type2 !== void 0 ? _componentMap$type2 : /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
804
+ }
805
+
806
+ // 然后处理自定义 component
807
+ var latestIsView = !latestIsEditable || (record === null || record === void 0 ? void 0 : record['is-view']) || config.isView || virtualKey && !_isEditing || (0, _tools.getDisabled)({
808
+ globalControl: otherProps === null || otherProps === void 0 ? void 0 : otherProps.globalControl,
809
+ formDisabled: otherProps === null || otherProps === void 0 ? void 0 : otherProps.formDisabled,
810
+ column,
811
+ tabledDisabled: config === null || config === void 0 ? void 0 : config.disabled,
812
+ columnFieldProps: latestFieldProps,
813
+ params: latestRowParams,
814
+ rowDisabled: rowDisabled || 'empty'
815
+ });
816
+ if (latestIsEditable && _isEditing) {
817
+ if ( /*#__PURE__*/_react.default.isValidElement(latestComponent)) {
818
+ latestTargetComponent = latestComponent;
819
+ } else if (latestComponent) {
820
+ latestTargetComponent = latestComponent;
821
+ }
822
+ }
823
+
824
+ // 查看模式
825
+ if (latestIsView) {
826
+ if (typeof viewRender === 'function') {
827
+ var latestCurrentValue = dataIndex ? latestRowData === null || latestRowData === void 0 ? void 0 : latestRowData[dataIndex] : null;
828
+ var _View = viewRender(latestCurrentValue, latestRowData || {}, options);
829
+ latestTargetComponent = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Container.default, {
830
+ viewEmpty: viewEmpty,
831
+ children: _View
832
+ });
833
+ }
834
+ if ( /*#__PURE__*/_react.default.isValidElement(viewRender)) {
835
+ latestTargetComponent = viewRender;
836
+ }
837
+ }
838
+
839
+ // 使用重新计算的 TargetComponent
840
+ TargetComponent = latestTargetComponent;
747
841
  }
748
842
  var FormItem = null;
749
843
  // 当 viewRender 存在时,需要排除 finalComponentProps 中的 children,避免覆盖 Container 的 children
@@ -753,7 +847,15 @@ var RenderField = _ref => {
753
847
  if (isTargetDomElement) {
754
848
  propsForTarget = (0, _lodash.omit)(propsForTarget, ['disabled', ...OMIT_FORM_ITEM_AND_DOM_KEYS]);
755
849
  }
756
- var FieldComponent = /*#__PURE__*/_react.default.isValidElement(TargetComponent) ? ( /*#__PURE__*/_react.default.cloneElement(TargetComponent, propsForTarget)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(TargetComponent, _objectSpread({}, propsForTarget));
850
+ // TargetComponent 未定义时,使用空的占位组件避免渲染错误
851
+ var FieldComponent = null;
852
+ if ( /*#__PURE__*/_react.default.isValidElement(TargetComponent)) {
853
+ FieldComponent = /*#__PURE__*/_react.default.cloneElement(TargetComponent, propsForTarget);
854
+ } else if (TargetComponent) {
855
+ FieldComponent = /*#__PURE__*/(0, _jsxRuntime.jsx)(TargetComponent, _objectSpread({}, propsForTarget));
856
+ } else {
857
+ FieldComponent = /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
858
+ }
757
859
  if (originalValues && !getIsNew(record)) {
758
860
  FieldComponent = /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListChangedWrapper.default, {
759
861
  name: cellName,
@@ -784,7 +886,7 @@ var RenderField = _ref => {
784
886
  }
785
887
  FormItem = TargetComponent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Form.Item, _objectSpread(_objectSpread({
786
888
  validateFirst: true
787
- }, (0, _lodash.omit)(finalFormItemProps, ['render', 'key', 'width', 'hiddenNames', 'name', 'onCell', _formItemProps.shouldUpdate ? 'shouldUpdate' : null])), {}, {
889
+ }, (0, _lodash.omit)(finalFormItemProps, ['render', 'key', 'width', 'hiddenNames', 'name', 'onCell', 'disabled', _formItemProps.shouldUpdate ? 'shouldUpdate' : null])), {}, {
788
890
  // 移除非必要字段,但保留 dependencies
789
891
  className: _className,
790
892
  name: formNamePath ? cellName.slice((formNamePath === null || formNamePath === void 0 ? void 0 : formNamePath.length) - 1) : cellName,
@@ -850,20 +952,26 @@ var _default = exports.default = /*#__PURE__*/(0, _react.memo)(RenderField, (pre
850
952
  }
851
953
 
852
954
  // fieldProps 函数化直接更新,无法比对返回值是否一致
955
+ // 优化:不直接调用函数,而是比较输入参数(record 和 reactiveParams)
956
+ // 如果输入参数相同,fieldProps 的返回值应该相同(纯函数假设)
853
957
  if ((0, _lodash.isFunction)(prevColumn === null || prevColumn === void 0 ? void 0 : prevColumn.fieldProps) && (0, _lodash.isFunction)(nextColumn === null || nextColumn === void 0 ? void 0 : nextColumn.fieldProps)) {
854
- var prevFieldProps = prevColumn.fieldProps(prevRecord, prevReactiveParams);
855
- var nextFieldProps = nextColumn.fieldProps(nextRecord, nextReactiveParams);
856
- if (!(0, _lodash.isEqualWith)(prevFieldProps, nextFieldProps, _utils.customEqualForFunction)) {
958
+ // 比较 record 数据是否变化
959
+ if (!(0, _lodash.isEqualWith)(prevRecord, nextRecord, _utils.customEqualForFunction)) {
857
960
  return false;
858
961
  }
962
+ // reactiveParams 中的 form、index、namePath 已经在外层比较过了,无需重复比较
859
963
  }
860
964
 
861
965
  // 通用函数比较方法
966
+ // 优化:不直接调用函数,而是比较输入参数
967
+ // 对于纯函数,如果输入相同则输出相同
862
968
  var compareFunctionResult = (prevColumn, nextColumn, prevValues, nextValues, prevReactiveParams, nextReactiveParams, functionName) => {
863
969
  var prevFunc = prevColumn === null || prevColumn === void 0 ? void 0 : prevColumn[functionName];
864
970
  var nextFunc = nextColumn === null || nextColumn === void 0 ? void 0 : nextColumn[functionName];
865
971
  if ((0, _lodash.isFunction)(prevFunc) && (0, _lodash.isFunction)(nextFunc)) {
866
- return (0, _lodash.isEqualWith)(prevFunc(prevValues, prevReactiveParams), nextFunc(nextValues, nextReactiveParams), _utils.customEqualForFunction);
972
+ // 比较输入参数而不是调用函数
973
+ // 如果 values 相同,则函数结果应该相同(纯函数假设)
974
+ return (0, _lodash.isEqualWith)(prevValues, nextValues, _utils.customEqualForFunction);
867
975
  }
868
976
  return true; // 如果不是函数或只有一个是函数,认为相等
869
977
  };
@@ -130,6 +130,11 @@ export type RequiredFn<T = any> = ReactiveFunction<T, boolean | boolean[]>;
130
130
  * @template T 记录类型
131
131
  */
132
132
  export type viewRenderFn<T = any> = (text?: any, record?: T, options?: OptionsProps) => string | number | ReactNode | void;
133
+ /**
134
+ * 组件渲染函数类型(与 ReactiveFunction 保持一致)
135
+ * @template T 记录类型
136
+ */
137
+ export type ComponentRenderFn<T = any> = ReactiveFunction<T, string | number | ReactNode | void>;
133
138
  /**
134
139
  * 表格列属性接口
135
140
  * @template Values 值类型
@@ -153,7 +158,7 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro
153
158
  icon?: string | ReactNode;
154
159
  } & TooltipProps);
155
160
  /** 组件 */
156
- component?: string | number | ReactNode | viewRenderFn<T>;
161
+ component?: string | number | ReactNode | ComponentRenderFn<T>;
157
162
  /** 视图渲染 */
158
163
  viewRender?: string | number | ReactNode | viewRenderFn<T>;
159
164
  /** 隐藏的字段名 */
@@ -45,7 +45,8 @@ var getActionColumn = config => {
45
45
  actionProps = _cloneDeepWith.actionProps,
46
46
  page = _cloneDeepWith.page,
47
47
  rowDisabled = _cloneDeepWith.rowDisabled,
48
- actionDirection = _cloneDeepWith.actionDirection;
48
+ actionDirection = _cloneDeepWith.actionDirection,
49
+ editingKeys = _cloneDeepWith.editingKeys;
49
50
  var pageNum = _utils.tools.calc(page.pageNum, '-', 1);
50
51
  var firstIndex = _utils.tools.calc(pageNum, '*', page.pageSize);
51
52
  // actionProps配置为false 默认不插入
@@ -93,7 +94,7 @@ var getActionColumn = config => {
93
94
  action.onEvent = /*#__PURE__*/function () {
94
95
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(record, _ref) {
95
96
  var _form$getFieldValue;
96
- var index, form, name, namePath, tableLength, selectedRows, rowName, lastRecord, onEvent, result, actionHandler;
97
+ var index, form, name, namePath, tableLength, selectedRows, rowName, _isEditing, lastRecord, onEvent, result, actionHandler;
97
98
  return _regeneratorRuntime().wrap(function _callee$(_context) {
98
99
  while (1) switch (_context.prev = _context.next) {
99
100
  case 0:
@@ -101,33 +102,39 @@ var getActionColumn = config => {
101
102
  index = _utils.tools.calc(firstIndex, '+', index);
102
103
  rowName = [...virtualRowName, index];
103
104
  if (!(type === 'save')) {
104
- _context.next = 13;
105
+ _context.next = 15;
105
106
  break;
106
107
  }
107
- _context.prev = 4;
108
- _context.next = 7;
108
+ // 判断该行是否处于编辑状态
109
+ _isEditing = !virtualKey || editingKeys.includes(record.rowKey) || record._addFlag; // 只有编辑中的行才需要校验
110
+ if (!_isEditing) {
111
+ _context.next = 15;
112
+ break;
113
+ }
114
+ _context.prev = 6;
115
+ _context.next = 9;
109
116
  return (0, _tools.customValidate)(validateKeys, form, rowName);
110
- case 7:
111
- _context.next = 13;
112
- break;
113
117
  case 9:
114
- _context.prev = 9;
115
- _context.t0 = _context["catch"](4);
118
+ _context.next = 15;
119
+ break;
120
+ case 11:
121
+ _context.prev = 11;
122
+ _context.t0 = _context["catch"](6);
116
123
  (0, _tools.handleScrollToError)();
117
124
  return _context.abrupt("return", Promise.reject(_context.t0));
118
- case 13:
125
+ case 15:
119
126
  // 编辑状态使用自定义form值,非编辑状态直接使用行数据
120
127
  lastRecord = (0, _utils2.filterInternalFields)((_form$getFieldValue = form.getFieldValue(rowName)) !== null && _form$getFieldValue !== void 0 ? _form$getFieldValue : record); // 新增事件可以设置初始默认值,当做函数的出参导出
121
128
  onEvent = onClick || onHandle;
122
129
  if (onEvent) {
123
- _context.next = 19;
130
+ _context.next = 21;
124
131
  break;
125
132
  }
126
133
  result = true;
127
- _context.next = 22;
134
+ _context.next = 24;
128
135
  break;
129
- case 19:
130
- _context.next = 21;
136
+ case 21:
137
+ _context.next = 23;
131
138
  return onEvent === null || onEvent === void 0 ? void 0 : onEvent(lastRecord, {
132
139
  form,
133
140
  index,
@@ -136,9 +143,9 @@ var getActionColumn = config => {
136
143
  namePath,
137
144
  selectedRows
138
145
  });
139
- case 21:
146
+ case 23:
140
147
  result = _context.sent;
141
- case 22:
148
+ case 24:
142
149
  if (result !== false && type !== 'custom') {
143
150
  actionHandler = _config.actions[type];
144
151
  actionHandler(_objectSpread(_objectSpread({}, config), {}, {
@@ -149,11 +156,11 @@ var getActionColumn = config => {
149
156
  validateKeys
150
157
  }));
151
158
  }
152
- case 23:
159
+ case 25:
153
160
  case "end":
154
161
  return _context.stop();
155
162
  }
156
- }, _callee, null, [[4, 9]]);
163
+ }, _callee, null, [[6, 11]]);
157
164
  }));
158
165
  return function (_x, _x2) {
159
166
  return _ref2.apply(this, arguments);
@@ -10,6 +10,7 @@ interface Result {
10
10
  fieldProps: any;
11
11
  desensitization: any;
12
12
  valueType: any;
13
+ component: any;
13
14
  }
14
15
  declare const useShouldUpdateForTable: (props: UseShouldUpdateForTableProps) => Result;
15
16
  export default useShouldUpdateForTable;