@zat-design/sisyphus-react 4.4.2 → 4.4.3-beta.2

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 (45) hide show
  1. package/dist/index.esm.css +1 -1
  2. package/dist/less.esm.css +1 -1
  3. package/es/FormsProvider/index.d.ts +1 -1
  4. package/es/ProEditTable/components/RenderField/index.js +8 -8
  5. package/es/ProEditTable/utils/config.js +5 -2
  6. package/es/ProEditTable/utils/index.js +11 -6
  7. package/es/ProEditTable/utils/tools.js +3 -2
  8. package/es/ProEnum/index.js +1 -1
  9. package/es/ProForm/components/FormFooter/propsType.d.ts +1 -1
  10. package/es/ProForm/components/base/DatePicker/index.js +3 -2
  11. package/es/ProForm/components/combination/Group/component/ComRender.js +1 -1
  12. package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +4 -11
  13. package/es/ProForm/components/combination/Group/hooks/index.js +1 -2
  14. package/es/ProForm/components/combination/Group/utils/index.d.ts +20 -20
  15. package/es/ProForm/components/render/Render.js +149 -180
  16. package/es/ProForm/components/render/RenderFields.js +13 -38
  17. package/es/ProForm/components/render/propsType.d.ts +1 -18
  18. package/es/ProForm/components/render/propsType.js +0 -26
  19. package/es/ProForm/hooks/useControlled.d.ts +1 -0
  20. package/es/ProForm/hooks/useControlled.js +14 -0
  21. package/es/ProForm/hooks/useForm.d.ts +8 -0
  22. package/es/ProForm/{utils → hooks}/useForm.js +1 -1
  23. package/es/ProForm/{utils → hooks}/useRules.js +2 -2
  24. package/es/ProForm/{utils → hooks}/useShouldUpdate.d.ts +5 -1
  25. package/es/ProForm/{utils → hooks}/useShouldUpdate.js +30 -77
  26. package/es/ProForm/{utils → hooks}/useWatch.js +1 -1
  27. package/es/ProForm/index.js +5 -4
  28. package/es/ProForm/propsType.d.ts +13 -1
  29. package/es/ProForm/utils/buildFormItemProps.d.ts +25 -0
  30. package/es/ProForm/utils/buildFormItemProps.js +90 -0
  31. package/es/ProForm/utils/index.d.ts +2 -6
  32. package/es/ProForm/utils/index.js +3 -30
  33. package/es/ProForm/utils/reactiveValues.d.ts +34 -0
  34. package/es/ProForm/utils/reactiveValues.js +45 -0
  35. package/es/ProSelect/index.js +8 -7
  36. package/es/ProTreeModal/components/Trigger.js +13 -12
  37. package/es/ProTreeModal/style/index.less +12 -1
  38. package/package.json +1 -1
  39. package/es/ProForm/utils/useForm.d.ts +0 -22
  40. /package/es/ProForm/{utils → hooks}/useDeepCompareMemo.d.ts +0 -0
  41. /package/es/ProForm/{utils → hooks}/useDeepCompareMemo.js +0 -0
  42. /package/es/ProForm/{utils → hooks}/useFieldProps.d.ts +0 -0
  43. /package/es/ProForm/{utils → hooks}/useFieldProps.js +0 -0
  44. /package/es/ProForm/{utils → hooks}/useRules.d.ts +0 -0
  45. /package/es/ProForm/{utils → hooks}/useWatch.d.ts +0 -0
@@ -2,24 +2,29 @@ import _debounce from "lodash/debounce";
2
2
  import _set from "lodash/set";
3
3
  import _omit from "lodash/omit";
4
4
  import _isString from "lodash/isString";
5
- import _isFunction from "lodash/isFunction";
6
- /* eslint-disable prefer-destructuring */
7
5
  import { Col, Form, Input, Space } from 'antd';
8
- import React, { useMemo } from 'react';
6
+ import React, { useMemo, useRef, useEffect } from 'react';
9
7
  import classNames from 'classnames';
10
8
  import { QuestionCircleOutlined } from '@ant-design/icons';
11
- import useShouldUpdate from "../../utils/useShouldUpdate";
12
- import { isTrim, isUpperCase, findOptionByValue, parseNamePath } from "../../utils/index";
9
+ import useShouldUpdate from "../../hooks/useShouldUpdate";
10
+ import { findOptionByValue, parseNamePath } from "../../utils/index";
11
+ import { buildFormItemProps } from "../../utils/buildFormItemProps";
13
12
  import { useProConfig } from "../../../ProConfigProvider";
14
- import transformNames from "../../utils/transformNames";
15
- import valueTypeMap from "../../utils/valueType";
16
- import useRules from "../../utils/useRules";
13
+ import useRules from "../../hooks/useRules";
17
14
  import ConfirmWrapper from "./ConfirmWrapper";
18
15
  import ChangedWrapper from "./ChangedWrapper";
19
16
  import CustomComponentViewWrapper from "./CustomComponentViewWrapper";
20
17
 
21
- // 这个组件只管渲染, 参数的整理在外部处理
18
+ /** 隐藏 FormItem 占位用的兜底 name,保证 shouldUpdate 监听有 FormItem 承载 */
22
19
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
20
+ const HIDDEN_FORM_ITEM_NAME = 'proFormItemHidden';
21
+ /** Group 默认校验延时(ms),等待 setFieldValue 同步最新值后再校验 */
22
+ const GROUP_VALIDATE_DELAY = 60;
23
+ /** 移除多余的组件属性,group 保留 onFieldChange */
24
+ const LAST_COMPONENT_PROPS_FILTER = ['onFieldChange', 'disabledStrictly'];
25
+ /** 需要从透传给 Form.Item 的属性中过滤掉的 key */
26
+ const FILTER_FORM_ITEM_KEYS = ['onFieldChange', 'shouldUpdate', 'namePath', 'isView', 'parentNames', 'space', 'before', 'after', 'globalControl', 'listName', 'fixed'];
27
+ // 这个组件只管渲染, 参数的整理在外部处理
23
28
  const Render = props => {
24
29
  const {
25
30
  component,
@@ -29,23 +34,26 @@ const Render = props => {
29
34
  componentProps,
30
35
  show = true,
31
36
  fieldProps,
32
- form,
33
37
  disabled,
34
- formDisabled,
35
- type,
36
38
  isSelect,
37
39
  onDiff,
38
40
  requiredOnView,
39
41
  confirm,
42
+ viewRender,
43
+ desensitization
44
+ } = props;
45
+
46
+ // 以下字段统一从 otherProps(Context)读取,避免与独立 prop 重复传递
47
+ const {
48
+ form,
49
+ formDisabled,
50
+ type,
51
+ colProps,
40
52
  globalControl,
41
53
  diffConfig,
42
- viewRender,
43
- desensitization,
44
54
  shouldUpdateDebounce
45
- } = props;
46
- let {
47
- colProps
48
- } = props;
55
+ } = otherProps || {};
56
+ const proConfig = useProConfig();
49
57
 
50
58
  // 剔除一些不是FormItem的属性, 防止控制台报warning
51
59
  const {
@@ -65,13 +73,13 @@ const Render = props => {
65
73
  // 更新show & disabled & rules
66
74
  const {
67
75
  shouldUpdate,
68
- show: _show,
69
- disabled: _disabled,
70
- rules: _rules,
71
- required: _required,
72
- fieldProps: _fieldProps,
76
+ show: resolvedShow,
77
+ disabled: resolvedDisabled,
78
+ rules: resolvedRules,
79
+ required: resolvedRequired,
80
+ fieldProps: resolvedFieldProps,
73
81
  component: AutoComponent,
74
- desensitization: _desensitization
82
+ desensitization: resolvedDesensitization
75
83
  } = useShouldUpdate({
76
84
  show,
77
85
  formItemProps,
@@ -86,7 +94,12 @@ const Render = props => {
86
94
  desensitization,
87
95
  shouldUpdateDebounce
88
96
  });
89
- otherFormItemProps.shouldUpdate = shouldUpdate;
97
+
98
+ // 以不可变方式补上 shouldUpdate,作为后续整理的基础对象
99
+ const baseFormItemProps = {
100
+ ...otherFormItemProps,
101
+ shouldUpdate
102
+ };
90
103
  const namesStr = useMemo(() => {
91
104
  if (!Array.isArray(otherProps?.names)) {
92
105
  return '';
@@ -101,121 +114,78 @@ const Render = props => {
101
114
  }, [otherProps?.names]);
102
115
  const internalRule = useRules({
103
116
  names: otherProps.names,
104
- label: otherFormItemProps.label,
117
+ label: baseFormItemProps.label,
105
118
  labelRequired,
106
- required: _required,
107
- rules: _rules,
119
+ required: resolvedRequired,
120
+ rules: resolvedRules,
108
121
  isSelect,
109
122
  type
110
123
  });
111
124
 
112
- /**
113
- * 基于formItem的normalize与getValueProps进行值类型转换
114
- * @returns {}
115
- */
116
- const valueTypeTransform = () => {
117
- let {
118
- valueType
119
- } = otherProps || {};
120
- // SwitchCheckbox默认YN, 兼容已有组件
121
- if (type === 'SwitchCheckbox') {
122
- valueType = 'switch';
123
- }
124
- if (type === 'Input') {
125
- valueType = valueType || 'trim';
126
- }
127
- // 不存在valueType返回空
128
- if (!valueType) {
129
- return {};
130
- }
131
- const params = {
132
- ...otherProps,
133
- ...otherFormItemProps
134
- };
135
- return _isFunction(valueTypeMap[valueType]) ? valueTypeMap[valueType](params) : {};
136
- };
137
-
138
- /**
139
- * transform对象
140
- * 存在names通过transformNames转换平铺处理
141
- * 没有默认走valueType的处理
142
- */
143
- const transforms = Array.isArray(otherProps?.names) ? transformNames({
144
- ...otherFormItemProps,
145
- ...valueTypeTransform()
146
- },
147
- // 合并valueType的transform
148
- form, otherProps.names, namesStr, otherProps.type) : valueTypeTransform();
149
-
150
125
  /**
151
126
  * globalControl 全局控制优先
152
127
  * globalControl true时,优先级 全局【formDisabled】> formitem上【column.disabled】 > 组件上【fieldProps.disabled】
153
128
  * globalControl false时,优先级 组件上【fieldProps.disabled】 > formitem上【column.disabled】 > 全局【formDisabled】
154
129
  */
155
- const lastDisabled = globalControl ? formDisabled ?? _disabled ?? _fieldProps?.disabled ?? componentProps?.disabled : _disabled ?? _fieldProps?.disabled ?? componentProps?.disabled ?? formDisabled;
130
+ const lastDisabled = globalControl ? formDisabled ?? resolvedDisabled ?? resolvedFieldProps?.disabled ?? componentProps?.disabled : resolvedDisabled ?? resolvedFieldProps?.disabled ?? componentProps?.disabled ?? formDisabled;
156
131
 
157
- // ↑↑↑↑↑↑ formItem参数整理 ↑↑↑↑↑↑
158
- Object.assign(otherFormItemProps, transforms, {
159
- names: otherProps.names
160
- }, internalRule, {
161
- required: _required || Array.isArray(rules) && rules?.some(item => item?.required) || (typeof labelRequired === 'boolean' ? labelRequired : false)
162
- }, otherProps.isView && !requiredOnView ? {
163
- required: false
164
- } : null, {
165
- ...isTrim(type, trim, useProConfig())
166
- },
167
- // 优先取传进来的,其次取ProConfigProvider配置的
168
- {
169
- ...isUpperCase(type, upperCase)
170
- }, {
171
- validateFirst
172
- },
173
- // 当某一规则校验不通过时,是否停止剩下的规则的校验
174
- {
175
- disabled: lastDisabled
132
+ // formItem 参数整理(纯函数,不可变合并,避免原地 mutate)
133
+ const lastFormItemProps = buildFormItemProps({
134
+ baseFormItemProps,
135
+ otherProps,
136
+ form,
137
+ namesStr,
138
+ internalRule,
139
+ resolvedRequired,
140
+ rules,
141
+ labelRequired,
142
+ requiredOnView,
143
+ type,
144
+ trim,
145
+ upperCase,
146
+ proConfig,
147
+ validateFirst,
148
+ lastDisabled,
149
+ labelWidth
176
150
  });
177
151
 
178
- // 添加label宽度
179
- if (labelWidth) {
180
- otherFormItemProps.labelCol = {
181
- flex: `${labelWidth}px`
182
- };
183
- }
184
-
185
- /** 移除多余参数,防止透传给formItem报错 */
186
- const _otherFormItemProps = _omit(otherFormItemProps, ['component', 'names', 'format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow', 'dependNames']);
187
-
188
152
  /**
189
153
  * 最新fieldProps: 更新后的组件Props
190
154
  */
191
- // 灵活模式:当存在 flexibleGroupProps 时,从 _fieldProps.style 中移除 width,避免透传到组件
155
+ // 灵活模式:当存在 flexibleGroupProps 时,从 resolvedFieldProps.style 中移除 width,避免透传到组件
192
156
  const flexibleGroupProps = otherProps?.flexibleGroupProps;
193
- const adjustedFieldProps = flexibleGroupProps && _fieldProps?.style?.width ? {
194
- ..._fieldProps,
157
+ const adjustedFieldProps = flexibleGroupProps && resolvedFieldProps?.style?.width ? {
158
+ ...resolvedFieldProps,
195
159
  style: (() => {
196
160
  const {
197
161
  width,
198
162
  ...restStyle
199
- } = _fieldProps.style;
163
+ } = resolvedFieldProps.style;
200
164
  return restStyle;
201
165
  })()
202
- } : _fieldProps;
166
+ } : resolvedFieldProps;
203
167
  const lastComponentProps = {
204
168
  ...componentProps,
205
169
  ...adjustedFieldProps,
206
170
  disabled: lastDisabled,
207
- desensitization: _desensitization
171
+ desensitization: resolvedDesensitization
208
172
  };
209
- const _className = classNames({
173
+
174
+ // 防抖记忆化:handlerRef 始终指向最新 handler,debounce 仅按 debounceWait 重建,避免每次渲染重置定时器导致防抖失效
175
+ const debounceWait = lastComponentProps?.debounceWait;
176
+ const handlerRef = useRef(() => undefined);
177
+ const debouncedHandleChange = useMemo(() => _debounce((...args) => handlerRef.current(...args), debounceWait), [debounceWait]);
178
+ useEffect(() => () => debouncedHandleChange.cancel(), [debouncedHandleChange]);
179
+ const itemClassName = classNames({
210
180
  [className]: className,
211
181
  'pro-form-item-width-auto': ['Switch'].includes(type)
212
182
  });
213
- if (formItemProps.hidden === true || _show === false) {
183
+ if (formItemProps.hidden === true || resolvedShow === false) {
214
184
  // 为了监听shouldUpdate 必须存在一个FormItem, 空Input解决 【[antd: Form.Item] `name` is only used for validate React element】
215
185
  return /*#__PURE__*/_jsx(Form.Item, {
216
- name: _otherFormItemProps.name || 'proFormItemHidden',
217
- shouldUpdate: _otherFormItemProps.shouldUpdate,
218
- className: _className,
186
+ name: lastFormItemProps.name || HIDDEN_FORM_ITEM_NAME,
187
+ shouldUpdate: lastFormItemProps.shouldUpdate,
188
+ className: itemClassName,
219
189
  noStyle: true,
220
190
  hidden: true,
221
191
  rules: [{
@@ -229,67 +199,67 @@ const Render = props => {
229
199
  * 函数新参数组装
230
200
  */
231
201
  const functionArgs = args => {
232
- const _args = [...args];
202
+ const nextArgs = [...args];
233
203
  const {
234
204
  valueType
235
205
  } = otherProps || {};
236
- _args[1] = form.getFieldsValue();
237
- _args[2] = {
206
+ nextArgs[1] = form.getFieldsValue();
207
+ nextArgs[2] = {
238
208
  form
239
209
  };
240
210
  // 优先处理FormList场景
241
- if (Array.isArray(_otherFormItemProps.namePath) && _otherFormItemProps?.namePath?.length) {
242
- _args[1] = form.getFieldValue(_otherFormItemProps.namePath);
243
- _args[2].namePath = _otherFormItemProps.namePath;
244
- _args[2].index = _otherFormItemProps.namePath[_otherFormItemProps?.namePath?.length - 1];
211
+ if (Array.isArray(lastFormItemProps.namePath) && lastFormItemProps?.namePath?.length) {
212
+ nextArgs[1] = form.getFieldValue(lastFormItemProps.namePath);
213
+ nextArgs[2].namePath = lastFormItemProps.namePath;
214
+ nextArgs[2].index = lastFormItemProps.namePath[lastFormItemProps?.namePath?.length - 1];
245
215
  }
246
216
 
247
217
  // 返回表单元素默认值
248
- _args[2].extra = args;
218
+ nextArgs[2].extra = args;
249
219
 
250
220
  // 当设置valueType后返回转换后的值
251
221
  if (valueType) {
252
- _args[2].transformValue = form.getFieldValue(_otherFormItemProps?.name) || undefined;
222
+ nextArgs[2].transformValue = form.getFieldValue(lastFormItemProps?.name) || undefined;
253
223
  }
254
- _args[2].option = args[1];
224
+ nextArgs[2].option = args[1];
255
225
  switch (type) {
256
226
  case 'ProCascader':
257
- _args[2].selectedOptions = args[1];
227
+ nextArgs[2].selectedOptions = args[1];
258
228
  break;
259
229
  case 'DatePicker':
260
230
  case 'RangePicker':
261
- _args[2].dateString = args[1];
231
+ nextArgs[2].dateString = args[1];
262
232
  break;
263
233
  default:
264
234
  break;
265
235
  }
266
- return _args;
236
+ return nextArgs;
267
237
  };
268
238
 
269
239
  /**
270
240
  * onChange参数重置 (value, record, { form, index, namePath, option }) => void
271
241
  */
272
242
  const defaultHandleChange = (...args) => {
273
- let _args = [...args];
243
+ let nextArgs = [...args];
274
244
 
275
245
  // 优先使用onFieldChange
276
246
  const changeKey = Object.keys(lastComponentProps).includes('onFieldChange') ? 'onFieldChange' : 'onChange';
277
247
  if (changeKey === 'onChange') {
278
- _args[2] = form;
248
+ nextArgs[2] = form;
279
249
  }
280
250
  if (changeKey === 'onFieldChange') {
281
- _args = functionArgs([...args]);
251
+ nextArgs = functionArgs([...args]);
282
252
  }
283
- const inList = _otherFormItemProps?.namePath?.length;
253
+ const inList = lastFormItemProps?.namePath?.length;
284
254
  if ( /*#__PURE__*/React.isValidElement(AutoComponent)) {
285
- (AutoComponent?.props)[changeKey]?.(..._args) || lastComponentProps[changeKey]?.(..._args);
255
+ (AutoComponent?.props)[changeKey]?.(...nextArgs) || lastComponentProps[changeKey]?.(...nextArgs);
286
256
  return false;
287
257
  }
288
258
 
289
259
  // FormList 和 Group场景 对比值改变的话, 回显到表单上
290
260
  if (inList && changeKey === 'onFieldChange') {
291
261
  const values = form.getFieldsValue();
292
- const newValues = _set(values, _otherFormItemProps.namePath, _args[1]);
262
+ const newValues = _set(values, lastFormItemProps.namePath, nextArgs[1]);
293
263
  form.setFieldsValue(newValues);
294
264
  }
295
265
 
@@ -299,30 +269,32 @@ const Render = props => {
299
269
  const namePath = parseNamePath(formItemProps?.parentNames);
300
270
  form.setFieldValue(formItemProps?.parentNames, form.getFieldValue(namePath));
301
271
  form.validateFields(namePath);
302
- }, 60);
272
+ }, GROUP_VALIDATE_DELAY);
303
273
  }
304
274
 
305
275
  // ProTreeSelect返回option
306
- if (['ProTree'].includes(type) && !_args[2].option) {
307
- _args[2].option = findOptionByValue(lastComponentProps?.dataSource, _args?.[0]?.[0], lastComponentProps?.fieldNames || {});
276
+ if (['ProTree'].includes(type) && !nextArgs[2].option) {
277
+ nextArgs[2].option = findOptionByValue(lastComponentProps?.dataSource, nextArgs?.[0]?.[0], lastComponentProps?.fieldNames || {});
308
278
  }
309
- lastComponentProps[changeKey]?.(..._args);
279
+ lastComponentProps[changeKey]?.(...nextArgs);
310
280
  };
311
- const debouncedHandleChange = _debounce(defaultHandleChange, lastComponentProps?.debounceWait);
281
+
282
+ // 更新 ref 到最新 handler,使记忆化的防抖函数始终调用最新闭包
283
+ handlerRef.current = defaultHandleChange;
312
284
  const handleChange = (...args) => {
313
- const _args = [...args];
285
+ const nextArgs = [...args];
314
286
  if (lastComponentProps?.debounceWait) {
315
287
  // 为了兼容 Input 和 TextArea 的 onChange 事件,需要将 event 对象转换为 value
316
288
  if (['Input', 'TextArea'].includes(type)) {
317
- _args[0] = {
289
+ nextArgs[0] = {
318
290
  target: {
319
- value: _args[0].target.value
291
+ value: nextArgs[0].target.value
320
292
  }
321
293
  };
322
294
  }
323
- debouncedHandleChange(..._args);
295
+ debouncedHandleChange(...nextArgs);
324
296
  } else {
325
- defaultHandleChange(..._args);
297
+ defaultHandleChange(...nextArgs);
326
298
  }
327
299
  };
328
300
 
@@ -330,18 +302,32 @@ const Render = props => {
330
302
  * onBlur参数重置 (value, record, { form, index, namePath, option }) => void
331
303
  */
332
304
  const handleBlur = async (...args) => {
333
- const _args = functionArgs([...args]);
334
- lastComponentProps?.onBlur && (await lastComponentProps?.onBlur(..._args));
305
+ const nextArgs = functionArgs([...args]);
306
+ lastComponentProps?.onBlur && (await lastComponentProps?.onBlur(...nextArgs));
335
307
  };
336
- const renderItem = () => {
337
- // 移除多余字段,group保留onFieldChange
338
- const lastComponentPropsFilter = ['onFieldChange', 'disabledStrictly'];
339
308
 
309
+ // colProps 一次派生:FormList / 容器组件需要覆盖 span
310
+ const lastColProps = (() => {
311
+ if (type === 'FormList') {
312
+ const lessMode = lastComponentProps.mode === 'less';
313
+ return {
314
+ ...colProps,
315
+ span: lessMode ? colProps?.span : 24
316
+ }; // 默认占一行
317
+ }
318
+ if (['ProCollapse', 'Container'].includes(type)) {
319
+ return {
320
+ ...colProps,
321
+ span: 24
322
+ }; // 默认占一行
323
+ }
324
+ return colProps;
325
+ })();
326
+ const renderItem = () => {
340
327
  // 表单渲染 start
341
328
  const childProps = {
342
329
  ...AutoComponent?.props,
343
- ..._omit(lastComponentProps, lastComponentPropsFilter),
344
- // @ts-ignore
330
+ ..._omit(lastComponentProps, LAST_COMPONENT_PROPS_FILTER),
345
331
  otherProps,
346
332
  onChange: handleChange,
347
333
  onBlur: handleBlur
@@ -397,7 +383,7 @@ const Render = props => {
397
383
 
398
384
  // 正常渲染逻辑
399
385
  let child = /*#__PURE__*/React.isValidElement(AutoComponent) ? ( /*#__PURE__*/React.cloneElement(AutoComponent, childProps)) : /*#__PURE__*/_jsx(AutoComponent, {
400
- ..._omit(lastComponentProps, [...lastComponentPropsFilter, 'debounceWait']),
386
+ ..._omit(lastComponentProps, [...LAST_COMPONENT_PROPS_FILTER, 'debounceWait']),
401
387
  otherProps: {
402
388
  ...otherProps,
403
389
  show,
@@ -418,7 +404,7 @@ const Render = props => {
418
404
  // 表单提示
419
405
 
420
406
  if (tooltip) {
421
- _otherFormItemProps.tooltip = _isString(tooltip) ? {
407
+ lastFormItemProps.tooltip = _isString(tooltip) ? {
422
408
  title: tooltip,
423
409
  icon: /*#__PURE__*/_jsx(QuestionCircleOutlined, {
424
410
  className: "pro-icon-tip"
@@ -430,27 +416,19 @@ const Render = props => {
430
416
  ...tooltip
431
417
  };
432
418
  }
433
-
434
- // 需要过滤掉的form_item的key
435
- const filterFormItemKey = ['onFieldChange', 'shouldUpdate', 'namePath', 'isView', 'parentNames', 'space', 'before', 'after', 'globalControl', 'listName', 'fixed'];
436
419
  if (type === 'FormList') {
437
420
  lastComponentProps.disabled = lastDisabled;
438
- const lessMode = lastComponentProps.mode === 'less';
439
- colProps = {
440
- ...colProps,
441
- span: lessMode ? colProps.span : 24 // 默认占一行
442
- };
443
421
  return /*#__PURE__*/_jsx(Form.Item, {
444
- ..._omit(_otherFormItemProps, filterFormItemKey),
445
- // @ts-ignore
422
+ ..._omit(lastFormItemProps, FILTER_FORM_ITEM_KEYS),
423
+ // @ts-ignore _internalItemRender 为 antd Form.Item 内部属性,未导出公开类型,无法去除
446
424
  _internalItemRender: internalItemRender,
447
- className: _className,
425
+ className: itemClassName,
448
426
  children: /*#__PURE__*/_jsx(Form.List, {
449
- name: _otherFormItemProps.name,
450
- ..._omit(_otherFormItemProps, ['rules']),
427
+ name: lastFormItemProps.name,
428
+ ..._omit(lastFormItemProps, ['rules']),
451
429
  children: (fields, operation, meta) => {
452
430
  return /*#__PURE__*/_jsx(AutoComponent, {
453
- ..._omit(lastComponentProps, lastComponentPropsFilter),
431
+ ..._omit(lastComponentProps, LAST_COMPONENT_PROPS_FILTER),
454
432
  otherProps: otherProps,
455
433
  fields: fields,
456
434
  operation: operation,
@@ -460,14 +438,6 @@ const Render = props => {
460
438
  })
461
439
  });
462
440
  }
463
-
464
- // 默认占据一行
465
- if (['ProCollapse', 'Container'].includes(type)) {
466
- colProps = {
467
- ...colProps,
468
- span: 24 // 默认占一行
469
- };
470
- }
471
441
  if (diffConfig?.originalValues) {
472
442
  let nextNames = otherProps.names;
473
443
  // FormList中的names字段需要去除前缀
@@ -485,17 +455,16 @@ const Render = props => {
485
455
  type: type,
486
456
  onChange: handleChange,
487
457
  onBlur: handleBlur,
488
- valuePropName: _otherFormItemProps.valuePropName,
489
- normalize: _otherFormItemProps.normalize,
490
- getValueProps: _otherFormItemProps.getValueProps,
458
+ valuePropName: lastFormItemProps.valuePropName,
459
+ normalize: lastFormItemProps.normalize,
460
+ getValueProps: lastFormItemProps.getValueProps,
491
461
  viewRender: viewRender,
492
462
  children: child
493
463
  });
494
464
  }
495
465
 
496
466
  // 灵活模式样式处理:从 flexibleGroupProps 获取样式
497
- const flexibleGroupProps = otherProps?.flexibleGroupProps;
498
- const finalClassName = flexibleGroupProps?.className ? classNames(_className, flexibleGroupProps.className) : _className;
467
+ const finalClassName = flexibleGroupProps?.className ? classNames(itemClassName, flexibleGroupProps.className) : itemClassName;
499
468
  const finalStyle = flexibleGroupProps?.style;
500
469
 
501
470
  // 判断是否应该使用自定义组件视图包装器
@@ -504,13 +473,13 @@ const Render = props => {
504
473
  // 如果应该使用自定义组件视图包装器,直接返回
505
474
  if (shouldUseCustomViewWrapper) {
506
475
  return /*#__PURE__*/_jsx(CustomComponentViewWrapper, {
507
- formItemProps: _otherFormItemProps,
476
+ formItemProps: lastFormItemProps,
508
477
  internalItemRender: internalItemRender,
509
478
  className: finalClassName,
510
479
  style: finalStyle,
511
- filterFormItemKey: filterFormItemKey,
480
+ filterFormItemKey: FILTER_FORM_ITEM_KEYS,
512
481
  form: form,
513
- name: _otherFormItemProps.name,
482
+ name: lastFormItemProps.name,
514
483
  isView: otherProps?.isView,
515
484
  viewRender: props.viewRender || viewRender,
516
485
  originComponent: props.originComponent || originComponent,
@@ -524,8 +493,8 @@ const Render = props => {
524
493
 
525
494
  // 正常情况:使用标准的 Form.Item
526
495
  return /*#__PURE__*/_jsx(Form.Item, {
527
- ..._omit(_otherFormItemProps, filterFormItemKey),
528
- // @ts-ignore
496
+ ..._omit(lastFormItemProps, FILTER_FORM_ITEM_KEYS),
497
+ // @ts-ignore _internalItemRender 为 antd Form.Item 内部属性,未导出公开类型,无法去除
529
498
  _internalItemRender: internalItemRender,
530
499
  className: finalClassName,
531
500
  style: finalStyle,
@@ -533,11 +502,11 @@ const Render = props => {
533
502
  });
534
503
  };
535
504
  const FormItem = /*#__PURE__*/_jsxs(_Fragment, {
536
- children: [_otherFormItemProps.shouldUpdate ?
505
+ children: [lastFormItemProps.shouldUpdate ?
537
506
  /*#__PURE__*/
538
507
  // 空标签防止气泡不显示
539
508
  _jsx(Form.Item, {
540
- shouldUpdate: _otherFormItemProps.shouldUpdate,
509
+ shouldUpdate: lastFormItemProps.shouldUpdate,
541
510
  noStyle: true,
542
511
  children: () => renderItem()
543
512
  }) : renderItem(), otherProps?.names?.length ? otherProps.names.map(name => {
@@ -557,7 +526,7 @@ const Render = props => {
557
526
  return FormItem;
558
527
  }
559
528
  return /*#__PURE__*/_jsx(Col, {
560
- ...colProps,
529
+ ...lastColProps,
561
530
  children: FormItem
562
531
  });
563
532
  };