@zat-design/sisyphus-react 4.5.9 → 4.5.10-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 (280) hide show
  1. package/dist/index.esm.css +1 -1
  2. package/dist/less.esm.css +1 -1
  3. package/es/FormsProvider/index.js +14 -21
  4. package/es/ProAction/components/CheckModalContent/index.js +12 -26
  5. package/es/ProAction/index.js +79 -83
  6. package/es/ProAction/propsType.js +0 -1
  7. package/es/ProConfigProvider/index.js +63 -110
  8. package/es/ProConfigProvider/propsType.js +0 -1
  9. package/es/ProDownload/index.d.ts +2 -1
  10. package/es/ProDownload/index.js +74 -69
  11. package/es/ProDownload/propsType.js +0 -1
  12. package/es/ProDownload/utils.d.ts +10 -5
  13. package/es/ProDownload/utils.js +63 -95
  14. package/es/ProDrawerForm/components/ProDrawer/index.js +83 -113
  15. package/es/ProDrawerForm/components/ProModal/index.js +77 -108
  16. package/es/ProDrawerForm/components/index.js +6 -2
  17. package/es/ProDrawerForm/hooks/useConfirmClose.js +20 -39
  18. package/es/ProDrawerForm/index.js +29 -38
  19. package/es/ProDrawerForm/propsType.js +0 -1
  20. package/es/ProDrawerForm/utils/index.js +18 -36
  21. package/es/ProEditLabel/components/RenderProForm.js +45 -49
  22. package/es/ProEditLabel/index.js +126 -163
  23. package/es/ProEditLabel/propsType.js +0 -1
  24. package/es/ProEditLabel/utils/index.js +5 -8
  25. package/es/ProEditTable/components/ActionButton/index.js +111 -119
  26. package/es/ProEditTable/components/RcTable/BaseTable.js +38 -51
  27. package/es/ProEditTable/components/RcTable/DraggableTable.js +97 -129
  28. package/es/ProEditTable/components/RcTable/index.js +6 -4
  29. package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +77 -95
  30. package/es/ProEditTable/components/RenderField/index.js +490 -587
  31. package/es/ProEditTable/components/RenderField/propsType.js +0 -1
  32. package/es/ProEditTable/components/RenderField/tools.js +115 -112
  33. package/es/ProEditTable/components/RenderToolbar/index.js +47 -73
  34. package/es/ProEditTable/components/Summary/index.js +38 -64
  35. package/es/ProEditTable/components/Validator/index.js +46 -46
  36. package/es/ProEditTable/components/index.js +12 -5
  37. package/es/ProEditTable/index.js +456 -378
  38. package/es/ProEditTable/propsType.js +0 -1
  39. package/es/ProEditTable/utils/config.js +60 -122
  40. package/es/ProEditTable/utils/diffOriginal.js +45 -82
  41. package/es/ProEditTable/utils/getDefaultProps.js +19 -24
  42. package/es/ProEditTable/utils/index.js +154 -235
  43. package/es/ProEditTable/utils/tools.js +149 -286
  44. package/es/ProEditTable/utils/transform.js +25 -30
  45. package/es/ProEditTable/utils/useEditTableError.js +30 -43
  46. package/es/ProEditTable/utils/useShouldUpdateForTable.js +42 -72
  47. package/es/ProEditTable/utils/validateAll.js +87 -154
  48. package/es/ProEnum/components/Group.js +38 -30
  49. package/es/ProEnum/components/Tag.js +22 -26
  50. package/es/ProEnum/hooks/useEnum.js +48 -116
  51. package/es/ProEnum/hooks/useEnumRequest.js +182 -212
  52. package/es/ProEnum/hooks/useFrequentEnumRequest.js +40 -48
  53. package/es/ProEnum/index.js +162 -172
  54. package/es/ProEnum/propsType.js +0 -1
  55. package/es/ProEnum/utils/eventCenter.js +10 -12
  56. package/es/ProEnum/utils/frequentEnum.js +35 -92
  57. package/es/ProEnum/utils/getEnum.js +32 -90
  58. package/es/ProEnum/utils/getEnumLabel.js +44 -49
  59. package/es/ProEnum/utils/index.js +93 -207
  60. package/es/ProForm/components/Container.js +13 -28
  61. package/es/ProForm/components/FormFooter/index.js +36 -44
  62. package/es/ProForm/components/FormFooter/propsType.js +0 -1
  63. package/es/ProForm/components/base/Checkbox/index.js +32 -59
  64. package/es/ProForm/components/base/DatePicker/index.js +49 -71
  65. package/es/ProForm/components/base/Input/index.js +63 -97
  66. package/es/ProForm/components/base/Input/propsType.js +0 -1
  67. package/es/ProForm/components/base/InputNumber/index.js +118 -172
  68. package/es/ProForm/components/base/Radio/index.js +39 -52
  69. package/es/ProForm/components/base/RangePicker/index.js +109 -127
  70. package/es/ProForm/components/base/RangePicker/useDateRange.js +20 -17
  71. package/es/ProForm/components/base/Select/index.js +63 -89
  72. package/es/ProForm/components/base/Switch/index.js +27 -35
  73. package/es/ProForm/components/base/SwitchCheckbox/index.js +36 -54
  74. package/es/ProForm/components/base/TextArea/index.js +30 -41
  75. package/es/ProForm/components/base/TimePicker/index.js +27 -37
  76. package/es/ProForm/components/combination/Container/index.js +37 -47
  77. package/es/ProForm/components/combination/Container/propsType.js +0 -1
  78. package/es/ProForm/components/combination/FormList/components/ActionButton.js +165 -237
  79. package/es/ProForm/components/combination/FormList/components/BlockFields.js +98 -102
  80. package/es/ProForm/components/combination/FormList/components/Empty.js +28 -55
  81. package/es/ProForm/components/combination/FormList/components/LineFields.js +57 -54
  82. package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +61 -109
  83. package/es/ProForm/components/combination/FormList/index.js +151 -161
  84. package/es/ProForm/components/combination/FormList/propsType.js +0 -1
  85. package/es/ProForm/components/combination/FormList/style/index.less +6 -0
  86. package/es/ProForm/components/combination/FormList/utils.js +22 -38
  87. package/es/ProForm/components/combination/Group/component/AddonWrapper/index.js +12 -28
  88. package/es/ProForm/components/combination/Group/component/ComRender.js +50 -111
  89. package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +106 -213
  90. package/es/ProForm/components/combination/Group/hooks/index.js +69 -129
  91. package/es/ProForm/components/combination/Group/index.js +87 -126
  92. package/es/ProForm/components/combination/Group/propsType.js +0 -1
  93. package/es/ProForm/components/combination/Group/utils/index.js +124 -239
  94. package/es/ProForm/components/combination/ProCascader/index.js +156 -199
  95. package/es/ProForm/components/combination/ProCascader/propsType.js +0 -1
  96. package/es/ProForm/components/combination/ProCascader/utils/index.js +12 -21
  97. package/es/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +72 -70
  98. package/es/ProForm/components/combination/ProModalSelect/index.js +309 -347
  99. package/es/ProForm/components/combination/ProModalSelect/propsType.js +0 -1
  100. package/es/ProForm/components/combination/ProModalSelect/utils/index.js +32 -39
  101. package/es/ProForm/components/combination/ProNumberRange/index.js +100 -156
  102. package/es/ProForm/components/combination/ProNumberRange/propsType.js +0 -1
  103. package/es/ProForm/components/combination/ProRangeLimit/index.js +104 -115
  104. package/es/ProForm/components/combination/ProRangeLimit/propsType.js +0 -1
  105. package/es/ProForm/components/combination/ProTimeLimit/hooks/useControlled.js +16 -16
  106. package/es/ProForm/components/combination/ProTimeLimit/index.js +75 -109
  107. package/es/ProForm/components/index.js +56 -34
  108. package/es/ProForm/components/render/ChangedWrapper.js +85 -94
  109. package/es/ProForm/components/render/ConfirmWrapper.js +27 -39
  110. package/es/ProForm/components/render/CustomComponentViewWrapper.js +65 -82
  111. package/es/ProForm/components/render/Render.js +223 -329
  112. package/es/ProForm/components/render/RenderFields.js +76 -113
  113. package/es/ProForm/components/render/propsType.js +0 -1
  114. package/es/ProForm/hooks/useControlled.js +8 -10
  115. package/es/ProForm/hooks/useDeepCompareMemo.js +11 -11
  116. package/es/ProForm/hooks/useFieldProps.js +8 -4
  117. package/es/ProForm/hooks/useForm.js +50 -110
  118. package/es/ProForm/hooks/useRules.js +17 -33
  119. package/es/ProForm/hooks/useShouldUpdate.js +77 -152
  120. package/es/ProForm/hooks/useWatch.js +62 -134
  121. package/es/ProForm/index.js +157 -194
  122. package/es/ProForm/propsType.js +15 -7
  123. package/es/ProForm/utils/buildFormItemProps.js +51 -58
  124. package/es/ProForm/utils/diffOriginal.js +43 -73
  125. package/es/ProForm/utils/getDefaultProps.js +18 -24
  126. package/es/ProForm/utils/index.js +160 -235
  127. package/es/ProForm/utils/processDependencies.js +21 -60
  128. package/es/ProForm/utils/reactiveValues.js +20 -34
  129. package/es/ProForm/utils/rulesCreator.js +42 -40
  130. package/es/ProForm/utils/transformNames.js +10 -13
  131. package/es/ProForm/utils/transformValue.js +16 -29
  132. package/es/ProForm/utils/valueType.js +96 -178
  133. package/es/ProIcon/config/index.js +340 -274
  134. package/es/ProIcon/index.js +135 -209
  135. package/es/ProIcon/propsTypes.js +0 -1
  136. package/es/ProIcon/utils/index.js +24 -39
  137. package/es/ProLayout/components/Layout/Header/index.js +108 -141
  138. package/es/ProLayout/components/Layout/Menu/FoldMenu/index.js +134 -190
  139. package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +113 -139
  140. package/es/ProLayout/components/Layout/Menu/OpenMenu/propsType.js +0 -1
  141. package/es/ProLayout/components/Layout/Menu/SideMenu/index.js +23 -31
  142. package/es/ProLayout/components/Layout/Menu/index.js +92 -89
  143. package/es/ProLayout/components/Layout/Notice/index.js +13 -27
  144. package/es/ProLayout/components/Layout/index.js +8 -3
  145. package/es/ProLayout/components/ProCollapse/PropTypes.js +0 -1
  146. package/es/ProLayout/components/ProCollapse/index.js +89 -111
  147. package/es/ProLayout/components/ProFooter/PropTypes.js +0 -1
  148. package/es/ProLayout/components/ProFooter/index.js +27 -24
  149. package/es/ProLayout/components/ProHeader/PropTypes.js +0 -1
  150. package/es/ProLayout/components/ProHeader/components/Copy/index.js +23 -21
  151. package/es/ProLayout/components/ProHeader/components/Describe/index.js +67 -84
  152. package/es/ProLayout/components/ProHeader/components/ProBackBtn/index.js +18 -21
  153. package/es/ProLayout/components/ProHeader/components/ProBackBtn/propsType.js +0 -1
  154. package/es/ProLayout/components/ProHeader/components/index.js +6 -2
  155. package/es/ProLayout/components/ProHeader/index.js +216 -356
  156. package/es/ProLayout/components/ProHeader/utils/index.js +19 -26
  157. package/es/ProLayout/components/TabsManager/components/TabContextMenu.js +92 -85
  158. package/es/ProLayout/components/TabsManager/components/TabItem.js +53 -63
  159. package/es/ProLayout/components/TabsManager/components/TabsContext.js +5 -5
  160. package/es/ProLayout/components/TabsManager/components/TabsHeader.js +42 -52
  161. package/es/ProLayout/components/TabsManager/hooks/useActiveTab.js +8 -9
  162. package/es/ProLayout/components/TabsManager/hooks/useIframeRoute.js +19 -32
  163. package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.js +6 -20
  164. package/es/ProLayout/components/TabsManager/hooks/useTabsCache.js +25 -42
  165. package/es/ProLayout/components/TabsManager/hooks/useTabsState.js +320 -350
  166. package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.d.ts +19 -0
  167. package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.js +332 -0
  168. package/es/ProLayout/components/TabsManager/index.js +407 -351
  169. package/es/ProLayout/components/TabsManager/propTypes.d.ts +4 -0
  170. package/es/ProLayout/components/TabsManager/propTypes.js +7 -15
  171. package/es/ProLayout/components/TabsManager/style/index.less +1 -1
  172. package/es/ProLayout/components/TabsManager/utils/historyObserver.d.ts +7 -0
  173. package/es/ProLayout/components/TabsManager/utils/historyObserver.js +65 -0
  174. package/es/ProLayout/components/TabsManager/utils/index.d.ts +15 -2
  175. package/es/ProLayout/components/TabsManager/utils/index.js +156 -159
  176. package/es/ProLayout/components/index.js +8 -3
  177. package/es/ProLayout/index.js +173 -228
  178. package/es/ProLayout/propTypes.d.ts +28 -1
  179. package/es/ProLayout/propTypes.js +12 -52
  180. package/es/ProLayout/utils/index.js +48 -128
  181. package/es/ProSelect/components/AdaptiveTooltip.js +26 -25
  182. package/es/ProSelect/index.js +187 -223
  183. package/es/ProSelect/propsType.js +0 -1
  184. package/es/ProSelect/style/index.less +13 -0
  185. package/es/ProSelect/utils/index.js +100 -146
  186. package/es/ProStep/components/Anchor/index.js +71 -82
  187. package/es/ProStep/components/Item/index.js +49 -56
  188. package/es/ProStep/components/LazyLoad/index.js +23 -29
  189. package/es/ProStep/components/Listener/index.js +20 -33
  190. package/es/ProStep/components/Step/index.js +31 -38
  191. package/es/ProStep/constants.js +4 -1
  192. package/es/ProStep/index.js +166 -153
  193. package/es/ProStep/propsType.js +0 -1
  194. package/es/ProStep/style/index.less +1 -1
  195. package/es/ProStep/utils/index.js +29 -55
  196. package/es/ProStepTab/index.js +83 -138
  197. package/es/ProStepTab/propsType.js +0 -1
  198. package/es/ProTable/components/EditableCell/EditIcon.js +10 -14
  199. package/es/ProTable/components/EditableCell/index.js +37 -71
  200. package/es/ProTable/components/EditableCell/propsType.js +0 -1
  201. package/es/ProTable/components/FormatColumn/index.js +209 -340
  202. package/es/ProTable/components/FormatColumn/propsType.js +0 -1
  203. package/es/ProTable/components/RcTable/components/BaseTable/index.js +35 -39
  204. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +80 -107
  205. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index.js +54 -48
  206. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/propsType.js +0 -1
  207. package/es/ProTable/components/RcTable/components/DraggableTable/index.js +47 -54
  208. package/es/ProTable/components/RcTable/index.js +6 -4
  209. package/es/ProTable/components/RenderColumn/index.js +158 -186
  210. package/es/ProTable/components/RenderEmptyText/index.js +12 -21
  211. package/es/ProTable/components/RenderFooter/index.js +15 -15
  212. package/es/ProTable/components/RenderSummary/index.js +33 -50
  213. package/es/ProTable/components/RenderTableHeader/index.js +44 -46
  214. package/es/ProTable/components/RenderTabs/index.js +47 -51
  215. package/es/ProTable/components/TableResizable/index.js +56 -72
  216. package/es/ProTable/components/TooltipTitle/index.js +13 -21
  217. package/es/ProTable/components/index.js +16 -36
  218. package/es/ProTable/hooks/useAntdTable.js +191 -224
  219. package/es/ProTable/index.js +232 -249
  220. package/es/ProTable/propsType.js +0 -1
  221. package/es/ProTable/utils/columnStorage.js +63 -88
  222. package/es/ProTable/utils/index.js +57 -90
  223. package/es/ProTabs/components/Card/index.js +20 -48
  224. package/es/ProTabs/components/index.js +4 -1
  225. package/es/ProTabs/index.js +41 -58
  226. package/es/ProTabs/propType.js +0 -1
  227. package/es/ProThemeTools/component/ProTools/index.js +106 -158
  228. package/es/ProThemeTools/component/index.js +4 -1
  229. package/es/ProThemeTools/context/ThemeContext.js +67 -146
  230. package/es/ProThemeTools/index.js +103 -156
  231. package/es/ProThemeTools/propsType.js +0 -1
  232. package/es/ProThemeTools/utils/index.js +60 -109
  233. package/es/ProTooltip/index.js +132 -168
  234. package/es/ProTooltip/propsType.js +0 -1
  235. package/es/ProTree/components/AdaptiveTooltip.js +15 -17
  236. package/es/ProTree/components/CloseIcon.js +18 -26
  237. package/es/ProTree/components/List.js +28 -47
  238. package/es/ProTree/components/ProTree.js +152 -211
  239. package/es/ProTree/components/ProTreeSelect/index.js +255 -459
  240. package/es/ProTree/components/ProTreeSelect/propsType.js +0 -1
  241. package/es/ProTree/components/SearchTitle.js +23 -42
  242. package/es/ProTree/components/Tree.js +147 -195
  243. package/es/ProTree/components/index.js +10 -5
  244. package/es/ProTree/index.js +12 -16
  245. package/es/ProTree/propsType.js +0 -1
  246. package/es/ProTree/utils.js +46 -118
  247. package/es/ProTreeModal/components/Cascader.js +56 -64
  248. package/es/ProTreeModal/components/CloseIcon.js +18 -26
  249. package/es/ProTreeModal/components/List.js +114 -180
  250. package/es/ProTreeModal/components/SearchTitle.js +15 -18
  251. package/es/ProTreeModal/components/SortableItem.js +29 -58
  252. package/es/ProTreeModal/components/Tree.js +99 -113
  253. package/es/ProTreeModal/components/Trigger.js +87 -121
  254. package/es/ProTreeModal/components/index.js +14 -6
  255. package/es/ProTreeModal/index.js +397 -438
  256. package/es/ProTreeModal/propsType.js +0 -1
  257. package/es/ProTreeModal/utils.js +52 -95
  258. package/es/ProUpload/components/ButtonRender.js +44 -54
  259. package/es/ProUpload/components/DragRender.js +94 -148
  260. package/es/ProUpload/components/DraggableUploadListItem.js +12 -25
  261. package/es/ProUpload/components/Example.js +27 -31
  262. package/es/ProUpload/components/FileItem.js +69 -163
  263. package/es/ProUpload/components/ImageRender.js +134 -170
  264. package/es/ProUpload/index.js +68 -100
  265. package/es/ProUpload/propsType.js +0 -1
  266. package/es/ProUpload/uitls.js +8 -4
  267. package/es/ProUtils/utils/index.js +17 -13
  268. package/es/ProViewer/index.js +154 -175
  269. package/es/ProViewer/propsType.js +0 -5
  270. package/es/ProWaterMark/index.js +9 -16
  271. package/es/ProWaterMark/propsType.js +0 -1
  272. package/es/hooks/useDraggableRow.js +25 -53
  273. package/es/index.js +57 -77
  274. package/es/locale/en_US.js +153 -142
  275. package/es/locale/index.js +23 -36
  276. package/es/locale/zh_CN.js +145 -142
  277. package/es/tokens.js +84 -83
  278. package/es/utils/index.js +24 -51
  279. package/package.json +4 -2
  280. package/es/ProConfigProvider/demo/locale.js +0 -58
@@ -1,18 +1,24 @@
1
- import _get from "lodash/get";
2
- import _isFunction from "lodash/isFunction";
3
- import _omit from "lodash/omit";
4
- import _debounce from "lodash/debounce";
5
- import _isEqual from "lodash/isEqual";
6
- import _cloneDeep from "lodash/cloneDeep";
7
- /* eslint-disable prefer-destructuring */
8
- /* eslint-disable prefer-const */
9
- import React, { useEffect, useCallback, useMemo, memo, useRef } from 'react';
10
- import { Form } from 'antd';
11
- import classNames from 'classnames';
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import React, { useEffect, useCallback, useMemo, memo, useRef } from "react";
3
+ import { Form } from "antd";
4
+ import classNames from "classnames";
5
+ import cloneDeep from "lodash/cloneDeep";
6
+ import isEqual from "lodash/isEqual";
7
+ import debounce from "lodash/debounce";
8
+ import omit from "lodash/omit";
9
+ import isFunction from "lodash/isFunction";
10
+ import get from "lodash/get";
12
11
  import { compatStartTransition } from "../../../utils";
13
12
  import valueTypeMap from "../../../ProForm/utils/valueType";
14
13
  import transformMap from "../../utils/transform";
15
- import { getNamePath, difference, getDisabled, isRecordShallowEqual, resolveChangedFields, syncGroupCombinedValues } from "../../utils/tools";
14
+ import {
15
+ getNamePath,
16
+ difference,
17
+ getDisabled,
18
+ isRecordShallowEqual,
19
+ resolveChangedFields,
20
+ syncGroupCombinedValues
21
+ } from "../../utils/tools";
16
22
  import * as componentMap from "../../../ProForm/components";
17
23
  import { useProConfig } from "../../../ProConfigProvider";
18
24
  import Container from "../../../ProForm/components/Container";
@@ -25,15 +31,14 @@ import ConfirmWrapper from "../../../ProForm/components/render/ConfirmWrapper";
25
31
  import { getDefaultProps } from "../../utils/getDefaultProps";
26
32
  import ListChangedWrapper from "./ListChangedWrapper";
27
33
  import useShouldUpdateForTable from "../../utils/useShouldUpdateForTable";
28
- import { OMIT_FORM_ITEM_AND_DOM_KEYS, arePropsEqual, hasRowFunctionDependency, mergeOnFieldChangeRow } from "./tools";
29
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
30
- const RenderField = ({
31
- text: value,
32
- record,
33
- index,
34
- column,
35
- config
36
- }) => {
34
+ import {
35
+ OMIT_FORM_ITEM_AND_DOM_KEYS,
36
+ arePropsEqual,
37
+ hasRowFunctionDependency,
38
+ mergeOnFieldChangeRow
39
+ } from "./tools";
40
+ const RenderField = ({ text: value, record, index, column, config }) => {
41
+ var _a, _b, _c;
37
42
  let {
38
43
  type,
39
44
  valueType,
@@ -70,7 +75,7 @@ const RenderField = ({
70
75
  originalValues,
71
76
  namePath: formNamePath,
72
77
  rowDisabled,
73
- validateTrigger = ['onChange', 'onBlur', 'onSubmit'],
78
+ validateTrigger = ["onChange", "onBlur", "onSubmit"],
74
79
  otherProps,
75
80
  diffConfig,
76
81
  getIsNew,
@@ -86,230 +91,175 @@ const RenderField = ({
86
91
  let lastDisabled = false;
87
92
  let lastDesensitization = desensitization || [];
88
93
  let lastComponent = component || editRender;
89
- const isSingleMode = mode === 'single';
90
-
91
- // type类型 首字母转大写
92
- type = type?.replace?.(type[0], type[0].toUpperCase()) || 'Input';
94
+ const isSingleMode = mode === "single";
95
+ type = ((_a = type == null ? void 0 : type.replace) == null ? void 0 : _a.call(type, type[0], type[0].toUpperCase())) || "Input";
93
96
  const fallbackType = type;
94
- const hasCustomComponent = 'component' in column || 'editRender' in column;
95
-
96
- // 自定义组件时 防止默认值影像后续判断
97
- if ('component' in column) {
97
+ const hasCustomComponent = "component" in column || "editRender" in column;
98
+ if ("component" in column) {
98
99
  type = null;
99
100
  }
100
-
101
- // 单行正在编辑时,临时生成一套formItem用来存储中间值,点击取消时候重置回上一次状态
102
101
  const namePathKey = useMemo(() => {
103
102
  const path = getNamePath(name, virtualKey);
104
- return Array.isArray(path) ? path.join('.') : String(path);
103
+ return Array.isArray(path) ? path.join(".") : String(path);
105
104
  }, [name, virtualKey]);
106
105
  const namePath = useMemo(() => getNamePath(name, virtualKey), [namePathKey, name, virtualKey]);
107
106
  const rowNamePath = useMemo(() => [...namePath, index], [namePath, index]);
108
107
  const rowData = form.getFieldValue(rowNamePath) || record || {};
109
-
110
- // Form.Item shouldUpdate 可能在 RenderField 外层未重渲染时多次执行 render props。
111
- // 缓存本次外层渲染期间的最新行计算结果,避免同一行版本重复调用动态配置函数。
112
- const shouldUpdateStateCacheRef = useRef(undefined);
113
- shouldUpdateStateCacheRef.current = undefined;
114
- let currentValue = dataIndex ? rowData?.[dataIndex] : null;
115
-
116
- // 构建新的参数格式(与 ProForm 保持一致)
117
- const reactiveParams = useMemo(() => ({
118
- form,
119
- index,
120
- namePath: rowNamePath
121
- }), [form, index, rowNamePath]);
122
-
123
- // 保留 options 用于 viewRender 和 formatArgs(兼容旧格式)
124
- const options = useMemo(() => ({
125
- index,
126
- form,
127
- name: column?.name,
128
- namePath: rowNamePath
129
- }), [index, column?.name, rowNamePath, form]);
130
-
131
- // 行参数 - 使用useMemo优化(新格式:values, { form, index, namePath })
108
+ const shouldUpdateStateCacheRef = useRef(void 0);
109
+ shouldUpdateStateCacheRef.current = void 0;
110
+ let currentValue = dataIndex ? rowData == null ? void 0 : rowData[dataIndex] : null;
111
+ const reactiveParams = useMemo(
112
+ () => ({
113
+ form,
114
+ index,
115
+ namePath: rowNamePath
116
+ }),
117
+ [form, index, rowNamePath]
118
+ );
119
+ const options = useMemo(
120
+ () => ({
121
+ index,
122
+ form,
123
+ name: column == null ? void 0 : column.name,
124
+ namePath: rowNamePath
125
+ }),
126
+ [index, column == null ? void 0 : column.name, rowNamePath, form]
127
+ );
132
128
  const rowParams = useMemo(() => [rowData, reactiveParams], [rowData, reactiveParams]);
133
-
134
- // 使用 hook 处理动态属性(带选择性防抖)
135
129
  const dynamicProps = useShouldUpdateForTable({
136
130
  rowParams,
137
131
  column,
138
132
  shouldUpdateDebounce
139
133
  });
140
-
141
- // required & rules & fieldProps & disabled & valueType 函数化处理
142
- // 优先使用 hook 返回的值,fallback 到原始值
143
- if (_isFunction(required)) {
134
+ if (isFunction(required)) {
144
135
  lastRequired = dynamicProps.required ?? required(rowData, reactiveParams);
145
136
  }
146
- if (_isFunction(fieldProps)) {
137
+ if (isFunction(fieldProps)) {
147
138
  lastFieldProps = dynamicProps.fieldProps ?? fieldProps(rowData, reactiveParams);
148
139
  }
149
- if (_isFunction(rules)) {
140
+ if (isFunction(rules)) {
150
141
  lastRules = dynamicProps.rules ?? rules(rowData, reactiveParams);
151
142
  }
152
- if (_isFunction(valueType)) {
143
+ if (isFunction(valueType)) {
153
144
  lastValueType = dynamicProps.valueType ?? valueType(currentValue, rowData, {
154
145
  index,
155
146
  form,
156
147
  namePath: rowNamePath,
157
- name: column?.name
148
+ name: column == null ? void 0 : column.name
158
149
  });
159
150
  }
160
- if (_isFunction(desensitization)) {
151
+ if (isFunction(desensitization)) {
161
152
  lastDesensitization = dynamicProps.desensitization ?? desensitization(rowData, reactiveParams);
162
153
  }
163
-
164
- // 获取最终的disabled
165
154
  lastDisabled = getDisabled({
166
- globalControl: otherProps?.globalControl,
167
- formDisabled: otherProps?.formDisabled,
155
+ globalControl: otherProps == null ? void 0 : otherProps.globalControl,
156
+ formDisabled: otherProps == null ? void 0 : otherProps.formDisabled,
168
157
  column,
169
- tabledDisabled: config?.disabled,
158
+ tabledDisabled: config == null ? void 0 : config.disabled,
170
159
  columnFieldProps: lastFieldProps,
171
160
  params: rowParams
172
161
  });
173
-
174
- // isEditable 处理 - 优先使用 hook 返回的值
175
- if (_isFunction(isEditable)) {
162
+ if (isFunction(isEditable)) {
176
163
  isEditable = dynamicProps.isEditable ?? isEditable(rowData, reactiveParams);
177
164
  }
178
-
179
- // component 处理 - 优先使用 hook 返回的值
180
- if (_isFunction(lastComponent)) {
165
+ if (isFunction(lastComponent)) {
181
166
  lastComponent = dynamicProps.componentResolved ? dynamicProps.component : lastComponent(rowData, reactiveParams);
182
167
  }
183
-
184
- // 更新 lastEditRender 为处理后的 lastComponent
185
168
  const lastEditRender = lastComponent;
186
-
187
- // 是否只读文本
188
- const isView = !isEditable || record?.['is-view'] || config.isView || virtualKey && !isEditing || getDisabled({
189
- globalControl: otherProps?.globalControl,
190
- formDisabled: otherProps?.formDisabled,
169
+ const isView = !isEditable || (record == null ? void 0 : record["is-view"]) || config.isView || virtualKey && !isEditing || getDisabled({
170
+ globalControl: otherProps == null ? void 0 : otherProps.globalControl,
171
+ formDisabled: otherProps == null ? void 0 : otherProps.formDisabled,
191
172
  column,
192
- tabledDisabled: config?.disabled,
173
+ tabledDisabled: config == null ? void 0 : config.disabled,
193
174
  columnFieldProps: lastFieldProps,
194
175
  params: rowParams,
195
- rowDisabled: rowDisabled || 'empty'
176
+ rowDisabled: rowDisabled || "empty"
196
177
  });
197
-
198
- // 只读文本时,采用当前formItem的name,单行编辑时,使用生成的虚拟的name
199
178
  const baseName = isView ? name : namePath;
200
-
201
- // 多态:可能是内置组件类型、自定义 component,或已渲染的 ReactElement(lastEditRender),保留显式 any
202
179
  let TargetComponent;
203
- const fallbackTargetComponent = typeof fallbackType === 'string' ? componentMap[fallbackType] : undefined;
180
+ const fallbackTargetComponent = typeof fallbackType === "string" ? componentMap[fallbackType] : void 0;
204
181
  const invalidComponentWarnedRef = useRef(false);
205
- const resolveEditTargetComponent = candidate => {
206
- if ( /*#__PURE__*/React.isValidElement(candidate)) {
182
+ const resolveEditTargetComponent = (candidate) => {
183
+ if (React.isValidElement(candidate)) {
207
184
  invalidComponentWarnedRef.current = false;
208
185
  return candidate;
209
186
  }
210
- if (hasCustomComponent && !invalidComponentWarnedRef.current && process.env.NODE_ENV !== 'production') {
211
- const columnName = dataIndex ?? column?.name ?? title ?? originTitle ?? 'unknown';
212
- console.warn('[ProEditTable] component 必须返回合法的 ReactElement,已回退到内置组件。', {
213
- column: Array.isArray(columnName) ? columnName.join('.') : String(columnName),
187
+ if (hasCustomComponent && !invalidComponentWarnedRef.current && true) {
188
+ const columnName = dataIndex ?? (column == null ? void 0 : column.name) ?? title ?? originTitle ?? "unknown";
189
+ console.warn("[ProEditTable] component 必须返回合法的 ReactElement,已回退到内置组件。", {
190
+ column: Array.isArray(columnName) ? columnName.join(".") : String(columnName),
214
191
  received: candidate
215
192
  });
216
193
  invalidComponentWarnedRef.current = true;
217
194
  }
218
195
  return fallbackTargetComponent;
219
196
  };
220
-
221
- // 将Hooks调用移到组件顶层
222
197
  const proConfig = useProConfig();
223
-
224
- // 设置校验规则 - 不在此处过滤 isView,由 getFieldItem 内根据 latestIsView 动态决定是否应用规则
225
198
  const internalRule = useRules({
226
199
  names,
227
- label: label,
200
+ label,
228
201
  labelRequired,
229
202
  required: lastRequired,
230
203
  rules: lastRules,
231
204
  isSelect: isSelect({
232
- dataSource: lastFieldProps?.dataSource,
205
+ dataSource: lastFieldProps == null ? void 0 : lastFieldProps.dataSource,
233
206
  type
234
207
  }),
235
208
  type
236
209
  });
237
-
238
- // 分离form item参数,防止对于参数透传(如onChange,防止重复触发)并优先级高于 lastFieldProps 内部参数
239
- const formItemChildProps = {
240
- ...lastFieldProps
241
- };
242
-
243
- // 使用useMemo优化defaultProps计算
244
- const defaultProps = useMemo(() => getDefaultProps({
245
- name,
246
- namePath: formNamePath ? cellName.slice(formNamePath?.length - 1) : cellName,
247
- type: column?.type,
248
- fieldProps: column?.fieldProps
249
- }), [name, formNamePath, cellName, column?.type, column?.fieldProps]);
250
-
251
- // 允许formItem的属性放在column最外层 - 使用useMemo优化(剔除会透传到 DOM 的字段)
252
- const lastFormItemProps = useMemo(() => ({
253
- ...defaultProps,
254
- ..._omit(resetProps, OMIT_FORM_ITEM_AND_DOM_KEYS),
255
- ...internalRule,
256
- validateTrigger
257
- // 注意:当 hasFunctionDependency 时会设置 shouldUpdate,shouldUpdate 与 dependencies 互斥,不透传 dependencies
258
- }), [defaultProps, resetProps, internalRule, validateTrigger]);
259
-
260
- // 当这些函数类型存在时,自动添加 shouldUpdate
261
- // 因为这些函数依赖行数据,当行数据变化时需要重新计算
262
- // 扩展到所有模式(single/multiple/cell),统一行为
263
- // 注意:需要检查原始的 component/editRender,而不是处理后的 lastComponent
210
+ const formItemChildProps = { ...lastFieldProps };
211
+ const defaultProps = useMemo(
212
+ () => getDefaultProps({
213
+ name,
214
+ namePath: formNamePath ? cellName.slice((formNamePath == null ? void 0 : formNamePath.length) - 1) : cellName,
215
+ type: column == null ? void 0 : column.type,
216
+ fieldProps: column == null ? void 0 : column.fieldProps
217
+ }),
218
+ [name, formNamePath, cellName, column == null ? void 0 : column.type, column == null ? void 0 : column.fieldProps]
219
+ );
220
+ const lastFormItemProps = useMemo(
221
+ () => ({
222
+ ...defaultProps,
223
+ ...omit(resetProps, OMIT_FORM_ITEM_AND_DOM_KEYS),
224
+ ...internalRule,
225
+ validateTrigger
226
+ // 注意:当 hasFunctionDependency 时会设置 shouldUpdate,shouldUpdate 与 dependencies 互斥,不透传 dependencies
227
+ }),
228
+ [defaultProps, resetProps, internalRule, validateTrigger]
229
+ );
264
230
  const hasFunctionDependency = hasRowFunctionDependency(column);
265
-
266
- // 移除 isSingleMode 限制,让所有模式都支持响应式更新
267
- // 性能优化已通过 useShouldUpdateForTable hook 的缓存和防抖机制实现
268
231
  if (hasFunctionDependency) {
269
- // 使用 shouldUpdate 监听同一行的数据变化;shouldUpdate 与 dependencies 互斥,始终优先 shouldUpdate
270
232
  lastFormItemProps.shouldUpdate = (prevValues, currentValues) => {
271
- const prevRow = _get(prevValues, rowNamePath);
272
- const currentRow = _get(currentValues, rowNamePath);
273
- // 如果行数据发生变化,则重新渲染
274
- return !_isEqual(prevRow, currentRow);
233
+ const prevRow = get(prevValues, rowNamePath);
234
+ const currentRow = get(currentValues, rowNamePath);
235
+ return !isEqual(prevRow, currentRow);
275
236
  };
276
237
  }
277
- if (['Switch', 'SwitchCheckbox'].includes(type)) {
278
- lastFormItemProps.valuePropName = 'checked';
279
- lastValueType = 'switch';
238
+ if (["Switch", "SwitchCheckbox"].includes(type)) {
239
+ lastFormItemProps.valuePropName = "checked";
240
+ lastValueType = "switch";
280
241
  }
281
-
282
- /**
283
- * 针对一些特殊类型,基于formItem的normalize与getValueProps进行默认值类型转换
284
- * @returns {}
285
- */
286
242
  const defaultTransform = useCallback(() => {
287
- const types = ['DatePicker', 'RangePicker'];
243
+ var _a2, _b2;
244
+ const types = ["DatePicker", "RangePicker"];
288
245
  if (!lastValueType && types.includes(type)) {
289
- return transformMap?.[type]?.(lastFieldProps || {});
246
+ return (_b2 = (_a2 = transformMap) == null ? void 0 : _a2[type]) == null ? void 0 : _b2.call(_a2, lastFieldProps || {});
290
247
  }
291
248
  return {};
292
249
  }, [lastValueType, type, lastFieldProps]);
293
-
294
- /**
295
- * 配置valueType时,基于formItem的normalize与getValueProps进行值类型转换
296
- * @returns {}
297
- */
298
250
  const valueTypeTransform = useCallback(() => {
299
- // SwitchCheckbox默认YN, 兼容已有组件
300
- if (type === 'SwitchCheckbox') {
301
- lastValueType = 'switch';
251
+ if (type === "SwitchCheckbox") {
252
+ lastValueType = "switch";
302
253
  }
303
254
  const params = {
304
255
  ...column,
305
- mode: lastFieldProps?.mode
256
+ mode: lastFieldProps == null ? void 0 : lastFieldProps.mode
306
257
  };
307
258
  const valueTypeKey = lastValueType;
308
- return _isFunction(valueTypeMap[valueTypeKey]) ? valueTypeMap[valueTypeKey](params) : {};
309
- }, [type, lastValueType, column, lastFieldProps?.mode]);
310
- if (names?.length) {
311
- // 支持names配置,临时生成对应的formItem,用来存储单个对应的值
312
- names = names.map(key => {
259
+ return isFunction(valueTypeMap[valueTypeKey]) ? valueTypeMap[valueTypeKey](params) : {};
260
+ }, [type, lastValueType, column, lastFieldProps == null ? void 0 : lastFieldProps.mode]);
261
+ if (names == null ? void 0 : names.length) {
262
+ names = names.map((key) => {
313
263
  if (Array.isArray(key)) {
314
264
  return [...baseName, index, ...key];
315
265
  }
@@ -319,210 +269,188 @@ const RenderField = ({
319
269
  let originalName = cellName;
320
270
  let originalNames = names;
321
271
  if (virtualKey) {
322
- originalName = [...name, ...cellName?.slice?.(name.length)];
323
- originalNames = names?.map?.(item => {
324
- return [...name, ...item?.slice?.(name.length)];
272
+ originalName = [...name, ...(_b = cellName == null ? void 0 : cellName.slice) == null ? void 0 : _b.call(cellName, name.length)];
273
+ originalNames = (_c = names == null ? void 0 : names.map) == null ? void 0 : _c.call(names, (item) => {
274
+ var _a2;
275
+ return [...name, ...(_a2 = item == null ? void 0 : item.slice) == null ? void 0 : _a2.call(item, name.length)];
325
276
  });
326
277
  }
327
-
328
- /**
329
- * 配置names时,基于formItem的normalize与getValueProps进行值类型转换
330
- * @returns {}
331
- */
332
278
  const namesTransform = useCallback(() => {
333
- if (!names?.length) {
279
+ if (!(names == null ? void 0 : names.length)) {
334
280
  return valueTypeTransform();
335
281
  }
336
282
  const namesStr = [...baseName, index, dataIndex];
337
- return transformNames({
338
- ...lastFormItemProps,
339
- ...valueTypeTransform()
340
- }, form, names, namesStr, type);
283
+ return transformNames(
284
+ {
285
+ ...lastFormItemProps,
286
+ ...valueTypeTransform()
287
+ },
288
+ form,
289
+ names,
290
+ namesStr,
291
+ type
292
+ );
341
293
  }, [names, baseName, index, dataIndex, lastFormItemProps, type]);
342
294
  TargetComponent = fallbackTargetComponent;
343
295
  if (isEditable && isEditing && hasCustomComponent) {
344
296
  TargetComponent = resolveEditTargetComponent(lastEditRender);
345
297
  }
346
-
347
- // 查看模式
348
298
  if (isView) {
349
- // 存在viewRender覆盖默认值
350
- if (typeof viewRender === 'function') {
351
- const latestCurrentValue = dataIndex ? rowData?.[dataIndex] : value;
299
+ if (typeof viewRender === "function") {
300
+ const latestCurrentValue = dataIndex ? rowData == null ? void 0 : rowData[dataIndex] : value;
352
301
  const View = viewRender(latestCurrentValue, rowData || {}, options);
353
- TargetComponent = /*#__PURE__*/_jsx(Container, {
354
- viewEmpty: viewEmpty,
355
- children: View
356
- });
302
+ TargetComponent = /* @__PURE__ */ jsx(Container, { viewEmpty, children: View });
357
303
  }
358
- if ( /*#__PURE__*/React.isValidElement(viewRender)) {
304
+ if (React.isValidElement(viewRender)) {
359
305
  TargetComponent = viewRender;
360
306
  }
361
307
  }
362
- const onChange = formItemChildProps?.onChange;
363
- const onFieldChange = formItemChildProps?.onFieldChange;
364
- const onBlur = formItemChildProps?.onBlur;
365
-
366
- // 使用useCallback优化formatArgs函数
367
- const formatArgs = useCallback((...args) => {
368
- const rawArgs = args?.length === 1 && Array.isArray(args?.[0]) ? args?.[0] : args;
369
- const nextArgs = [];
370
- nextArgs[0] = rawArgs?.[0];
371
- // 返回表单元素默认值
372
- nextArgs[2] = {
373
- ...options,
374
- extra: rawArgs
375
- };
376
- switch (type) {
377
- case 'ProSelect':
378
- case 'ProModalSelect':
379
- case 'ProEnum':
380
- nextArgs[2].option = rawArgs?.[1];
381
- break;
382
- case 'ProCascader':
383
- nextArgs[2].selectedOptions = rawArgs?.[1];
384
- break;
385
- case 'DatePicker':
386
- case 'RangePicker':
387
- nextArgs[2].dateString = rawArgs?.[1];
388
- break;
389
- default:
390
- break;
391
- }
392
- return nextArgs;
393
- }, [options, type]);
394
-
395
- // 使用useCallback优化debounceValidate函数
396
- const debounceValidate = useCallback((validateFieldKeys = []) => {
397
- setTimeout(() => {
398
- // 行内联动被动触发的重校验:只校验、不滚动到报错位置(全局/主动保存校验仍会滚动)
399
- // @ts-ignore 内部选项
400
- form.validateFields(validateFieldKeys, {
401
- recursive: true,
402
- __skipScrollOnError: true
403
- });
404
- }, 100);
405
- }, [form]);
406
-
407
- // 使用 useRef 保存防抖函数
408
- const debounceRef = useRef(null);
409
-
410
- // 使用 useCallback 创建稳定的 onChange 函数
411
- const handleChange = useCallback(async (...args) => {
412
- const executeChange = async (...innerArgs) => {
413
- // 虚拟表格:用户编辑本单元格 → 清掉旧的常驻报错,提交时再以最新值统一重校
414
- if (virtual && errorStore && record?.rowKey != null) {
415
- errorStore.clearCell(record.rowKey, String(column?.dataIndex));
308
+ const onChange = formItemChildProps == null ? void 0 : formItemChildProps.onChange;
309
+ const onFieldChange = formItemChildProps == null ? void 0 : formItemChildProps.onFieldChange;
310
+ const onBlur = formItemChildProps == null ? void 0 : formItemChildProps.onBlur;
311
+ const formatArgs = useCallback(
312
+ (...args) => {
313
+ const rawArgs = (args == null ? void 0 : args.length) === 1 && Array.isArray(args == null ? void 0 : args[0]) ? args == null ? void 0 : args[0] : args;
314
+ const nextArgs = [];
315
+ nextArgs[0] = rawArgs == null ? void 0 : rawArgs[0];
316
+ nextArgs[2] = {
317
+ ...options,
318
+ extra: rawArgs
319
+ };
320
+ switch (type) {
321
+ case "ProSelect":
322
+ case "ProModalSelect":
323
+ case "ProEnum":
324
+ nextArgs[2].option = rawArgs == null ? void 0 : rawArgs[1];
325
+ break;
326
+ case "ProCascader":
327
+ nextArgs[2].selectedOptions = rawArgs == null ? void 0 : rawArgs[1];
328
+ break;
329
+ case "DatePicker":
330
+ case "RangePicker":
331
+ nextArgs[2].dateString = rawArgs == null ? void 0 : rawArgs[1];
332
+ break;
333
+ default:
334
+ break;
416
335
  }
417
- let callArgs = [...innerArgs];
418
- const rowPath = rowNamePath;
419
- if (!onFieldChange && !onChange) {
420
- if (dependencies?.length) {
421
- const validateFieldKeys = dependencies?.map?.(key => [...rowPath, key]);
422
- setTimeout(() => {
423
- // 依赖字段联动重校验:只校验、不滚动
424
- // @ts-ignore 内部选项
425
- form.validateFields(validateFieldKeys, {
426
- __skipScrollOnError: true
427
- });
428
- }, 100);
336
+ return nextArgs;
337
+ },
338
+ [options, type]
339
+ );
340
+ const debounceValidate = useCallback(
341
+ (validateFieldKeys = []) => {
342
+ setTimeout(() => {
343
+ form.validateFields(validateFieldKeys, { recursive: true, __skipScrollOnError: true });
344
+ }, 100);
345
+ },
346
+ [form]
347
+ );
348
+ const debounceRef = useRef(null);
349
+ const handleChange = useCallback(
350
+ async (...args) => {
351
+ const executeChange = async (...innerArgs) => {
352
+ var _a2, _b2, _c2;
353
+ if (virtual && errorStore && (record == null ? void 0 : record.rowKey) != null) {
354
+ errorStore.clearCell(record.rowKey, String(column == null ? void 0 : column.dataIndex));
429
355
  }
430
- return;
431
- }
432
- const row = form.getFieldValue(rowPath, true);
433
- const orgRow = _cloneDeep(row);
434
- if (onFieldChange) {
435
- callArgs = formatArgs(innerArgs);
436
- callArgs[1] = row;
437
- TargetComponent?.props?.onFieldChange && (await TargetComponent.props.onFieldChange(...callArgs));
438
- onFieldChange && (await onFieldChange(...callArgs));
439
-
440
- // 原地修改 row 会改变 store 内的对象,但不会通知 Form 和只读单元格重新渲染。
441
- // 只通知相对回调前真正变化的子字段,避免整行回写覆盖回调内显式 setFieldValue 的新值。
442
- const latestStoreRow = form.getFieldValue(rowPath, true) || {};
443
- const nextStoreRow = mergeOnFieldChangeRow(orgRow, row, latestStoreRow);
444
- if (nextStoreRow !== latestStoreRow) {
445
- // ProEditTable 注册在整个列表路径上,子行写入不会通知该 Form.Item。
446
- // 以最新列表为底只替换当前行,确保其他行与显式 store 写入不被覆盖。
447
- const latestList = form.getFieldValue(namePath, true) || [];
448
- const nextList = [...latestList];
449
- nextList[index] = nextStoreRow;
450
- form.setFieldValue(namePath, nextList);
356
+ let callArgs = [...innerArgs];
357
+ const rowPath = rowNamePath;
358
+ if (!onFieldChange && !onChange) {
359
+ if (dependencies == null ? void 0 : dependencies.length) {
360
+ const validateFieldKeys = (_a2 = dependencies == null ? void 0 : dependencies.map) == null ? void 0 : _a2.call(dependencies, (key) => [...rowPath, key]);
361
+ setTimeout(() => {
362
+ form.validateFields(validateFieldKeys, { __skipScrollOnError: true });
363
+ }, 100);
364
+ }
365
+ return;
451
366
  }
452
-
453
- // 延后读取通知后的最新 store,统一处理联动校验与行刷新。
454
- setTimeout(() => {
455
- const rowAfter = form.getFieldValue(rowPath, true) ?? row;
456
- if (validateTrigger && validateTrigger.includes('onChange')) {
457
- if (!_isEqual(orgRow, rowAfter)) {
367
+ const row = form.getFieldValue(rowPath, true);
368
+ const orgRow = cloneDeep(row);
369
+ if (onFieldChange) {
370
+ callArgs = formatArgs(innerArgs);
371
+ callArgs[1] = row;
372
+ ((_b2 = TargetComponent == null ? void 0 : TargetComponent.props) == null ? void 0 : _b2.onFieldChange) && await TargetComponent.props.onFieldChange(...callArgs);
373
+ onFieldChange && await onFieldChange(...callArgs);
374
+ const latestStoreRow = form.getFieldValue(rowPath, true) || {};
375
+ const nextStoreRow = mergeOnFieldChangeRow(orgRow, row, latestStoreRow);
376
+ if (nextStoreRow !== latestStoreRow) {
377
+ const latestList = form.getFieldValue(namePath, true) || [];
378
+ const nextList = [...latestList];
379
+ nextList[index] = nextStoreRow;
380
+ form.setFieldValue(namePath, nextList);
381
+ }
382
+ setTimeout(() => {
383
+ const rowAfter = form.getFieldValue(rowPath, true) ?? row;
384
+ if (validateTrigger && validateTrigger.includes("onChange")) {
385
+ if (!isEqual(orgRow, rowAfter)) {
386
+ const diff = difference(rowAfter, orgRow) || {};
387
+ const changedKeys = Object.keys(diff);
388
+ syncGroupCombinedValues(form, rowPath, changedKeys, columns);
389
+ const changedFields = resolveChangedFields(changedKeys, columns);
390
+ if (virtual && errorStore && (record == null ? void 0 : record.rowKey) != null) {
391
+ changedFields.forEach((id) => errorStore.clearCell(record.rowKey, id));
392
+ }
393
+ const validateFieldKeys = changedFields.map((id) => [...rowPath, id]).concat(dependencies || []);
394
+ if (validateFieldKeys == null ? void 0 : validateFieldKeys.length) {
395
+ debounceValidate(validateFieldKeys);
396
+ }
397
+ }
398
+ }
399
+ if (!isEqual(orgRow, rowAfter)) {
400
+ compatStartTransition(() => {
401
+ setState({
402
+ forceUpdate: {
403
+ rowKey: record == null ? void 0 : record.rowKey
404
+ }
405
+ });
406
+ });
407
+ }
408
+ }, 0);
409
+ } else {
410
+ callArgs = callArgs.concat([row, index, form]);
411
+ ((_c2 = TargetComponent == null ? void 0 : TargetComponent.props) == null ? void 0 : _c2.onChange) && await TargetComponent.props.onChange(...callArgs);
412
+ onChange && await onChange(...callArgs);
413
+ const rowAfter = row;
414
+ form.setFieldValue(rowPath, rowAfter);
415
+ if (validateTrigger && validateTrigger.includes("onChange")) {
416
+ if (!isEqual(orgRow, rowAfter)) {
458
417
  const diff = difference(rowAfter, orgRow) || {};
459
418
  const changedKeys = Object.keys(diff);
460
- // 联动回填只写了子键,names 组合列的合并字段值未同步 → 先按子键组合写回,确保校验读到最新值
461
419
  syncGroupCombinedValues(form, rowPath, changedKeys, columns);
462
- // 把变更子键映射回所属列字段名(names 组合列 → 合并名),否则 group 列重校验路径对不上、旧报错不清
463
420
  const changedFields = resolveChangedFields(changedKeys, columns);
464
- // 虚拟表格:联动改写到的列同步清掉常驻报错,避免滚动重挂载后回填旧错
465
- if (virtual && errorStore && record?.rowKey != null) {
466
- changedFields.forEach(id => errorStore.clearCell(record.rowKey, id));
421
+ if (virtual && errorStore && (record == null ? void 0 : record.rowKey) != null) {
422
+ changedFields.forEach((id) => errorStore.clearCell(record.rowKey, id));
467
423
  }
468
- const validateFieldKeys = changedFields.map(id => [...rowPath, id]).concat(dependencies || []);
469
- if (validateFieldKeys?.length) {
424
+ const validateFieldKeys = changedFields.map((id) => [...rowPath, id]).concat(dependencies || []);
425
+ if (validateFieldKeys == null ? void 0 : validateFieldKeys.length) {
470
426
  debounceValidate(validateFieldKeys);
471
427
  }
472
428
  }
473
429
  }
474
- if (!_isEqual(orgRow, rowAfter)) {
475
- compatStartTransition(() => {
476
- setState({
477
- forceUpdate: {
478
- rowKey: record?.rowKey
479
- }
480
- });
481
- });
482
- }
483
- }, 0);
484
- } else {
485
- callArgs = callArgs.concat([row, index, form]);
486
- TargetComponent?.props?.onChange && (await TargetComponent.props.onChange(...callArgs));
487
- onChange && (await onChange(...callArgs));
488
- const rowAfter = row;
489
- form.setFieldValue(rowPath, rowAfter);
490
- if (validateTrigger && validateTrigger.includes('onChange')) {
491
- if (!_isEqual(orgRow, rowAfter)) {
492
- const diff = difference(rowAfter, orgRow) || {};
493
- const changedKeys = Object.keys(diff);
494
- // 联动回填只写了子键,names 组合列的合并字段值未同步 → 先按子键组合写回,确保校验读到最新值
495
- syncGroupCombinedValues(form, rowPath, changedKeys, columns);
496
- // 把变更子键映射回所属列字段名(names 组合列 → 合并名),否则 group 列重校验路径对不上、旧报错不清
497
- const changedFields = resolveChangedFields(changedKeys, columns);
498
- if (virtual && errorStore && record?.rowKey != null) {
499
- changedFields.forEach(id => errorStore.clearCell(record.rowKey, id));
500
- }
501
- const validateFieldKeys = changedFields.map(id => [...rowPath, id]).concat(dependencies || []);
502
- if (validateFieldKeys?.length) {
503
- debounceValidate(validateFieldKeys);
504
- }
505
- }
506
430
  }
431
+ };
432
+ if (onFieldChange) {
433
+ await executeChange(...args);
434
+ return;
507
435
  }
508
- };
509
-
510
- // onFieldChange 立即执行,不走防抖
511
- // 表格行数据变化会导致组件卸载重建,防抖回调会在 cleanup 中被取消
512
- if (onFieldChange) {
513
- await executeChange(...args);
514
- return;
515
- }
516
-
517
- // 没有 onFieldChange 时,使用防抖处理 onChange
518
- if (!debounceRef.current) {
519
- debounceRef.current = _debounce(executeChange, 300);
520
- }
521
- // 调用防抖函数
522
- debounceRef.current(...args);
523
- }, [namePath, index, dependencies, formatArgs, onChange, onFieldChange, form, setState, TargetComponent, validateTrigger]);
524
-
525
- // 在组件卸载时清理防抖函数
436
+ if (!debounceRef.current) {
437
+ debounceRef.current = debounce(executeChange, 300);
438
+ }
439
+ debounceRef.current(...args);
440
+ },
441
+ [
442
+ namePath,
443
+ index,
444
+ dependencies,
445
+ formatArgs,
446
+ onChange,
447
+ onFieldChange,
448
+ form,
449
+ setState,
450
+ TargetComponent,
451
+ validateTrigger
452
+ ]
453
+ );
526
454
  useEffect(() => {
527
455
  return () => {
528
456
  if (debounceRef.current) {
@@ -530,120 +458,138 @@ const RenderField = ({
530
458
  }
531
459
  };
532
460
  }, []);
533
-
534
- // 虚拟表格:单元格(重新)挂载时,回填 errorStore 中已存储的真实报错,实现报错常驻。
535
- // 虚拟滚动会卸载视口外行的 Field 实体导致 antd 报错丢失,重新挂载后由此恢复红字。
536
461
  useEffect(() => {
537
- if (!virtual || !errorStore || record?.rowKey == null) {
462
+ if (!virtual || !errorStore || (record == null ? void 0 : record.rowKey) == null) {
538
463
  return;
539
464
  }
540
- const cellKey = String(column?.dataIndex);
465
+ const cellKey = String(column == null ? void 0 : column.dataIndex);
541
466
  const errs = errorStore.get(record.rowKey, cellKey);
542
- if (errs?.length) {
543
- const fieldName = formNamePath ? cellName.slice(formNamePath?.length - 1) : cellName;
544
- form.setFields([{
545
- name: fieldName,
546
- errors: errs
547
- }]);
548
- }
549
- // 仅在挂载或行/列标识变化时回填
550
- }, [virtual, record?.rowKey, column?.dataIndex]);
551
-
552
- // 使用useCallback优化handleBlur函数
553
- const handleBlur = useCallback(async (...args) => {
554
- if (!onBlur) {
555
- return;
556
- }
557
- let callArgs = formatArgs(...args);
558
- const rowPath = rowNamePath;
559
- const row = form.getFieldValue(rowPath, true);
560
- const orgRow = _cloneDeep(row);
561
- callArgs[1] = row;
562
- TargetComponent?.props?.onBlur && (await TargetComponent.props.onBlur(...callArgs));
563
- onBlur && (await onBlur(...callArgs));
564
- // 判断属性是否变动
565
- form.setFieldValue(rowPath, row);
566
- if (validateTrigger && validateTrigger.includes('onBlur')) {
567
- if (!_isEqual(orgRow, row)) {
568
- const diff = difference(row, orgRow) || {};
569
- const validateFieldKeys = Object.keys(diff)?.map?.(key => [...rowPath, key]).concat(dependencies || []);
570
- if (validateFieldKeys?.length) {
571
- debounceValidate(validateFieldKeys);
572
- }
467
+ if (errs == null ? void 0 : errs.length) {
468
+ const fieldName = formNamePath ? cellName.slice((formNamePath == null ? void 0 : formNamePath.length) - 1) : cellName;
469
+ form.setFields([{ name: fieldName, errors: errs }]);
470
+ }
471
+ }, [virtual, record == null ? void 0 : record.rowKey, column == null ? void 0 : column.dataIndex]);
472
+ const handleBlur = useCallback(
473
+ async (...args) => {
474
+ var _a2, _b2, _c2;
475
+ if (!onBlur) {
476
+ return;
573
477
  }
574
- }
575
- // 单行编辑时需要 强制更新视图,仅对当前行打标记
576
- compatStartTransition(() => {
577
- setState({
578
- forceUpdate: {
579
- rowKey: record?.rowKey
478
+ let callArgs = formatArgs(...args);
479
+ const rowPath = rowNamePath;
480
+ const row = form.getFieldValue(rowPath, true);
481
+ const orgRow = cloneDeep(row);
482
+ callArgs[1] = row;
483
+ ((_a2 = TargetComponent == null ? void 0 : TargetComponent.props) == null ? void 0 : _a2.onBlur) && await TargetComponent.props.onBlur(...callArgs);
484
+ onBlur && await onBlur(...callArgs);
485
+ form.setFieldValue(rowPath, row);
486
+ if (validateTrigger && validateTrigger.includes("onBlur")) {
487
+ if (!isEqual(orgRow, row)) {
488
+ const diff = difference(row, orgRow) || {};
489
+ const validateFieldKeys = (_c2 = (_b2 = Object.keys(diff)) == null ? void 0 : _b2.map) == null ? void 0 : _c2.call(_b2, (key) => [...rowPath, key]).concat(dependencies || []);
490
+ if (validateFieldKeys == null ? void 0 : validateFieldKeys.length) {
491
+ debounceValidate(validateFieldKeys);
492
+ }
580
493
  }
494
+ }
495
+ compatStartTransition(() => {
496
+ setState({
497
+ forceUpdate: {
498
+ rowKey: record == null ? void 0 : record.rowKey
499
+ }
500
+ });
581
501
  });
582
- });
583
- }, [onBlur, formatArgs, namePath, index, form, TargetComponent, validateTrigger, debounceValidate, cellName, setState]);
584
-
585
- // 使用useMemo优化componentProps对象
586
- let componentProps = useMemo(() => ({
587
- form,
588
- name: cellName,
589
- ...lastFieldProps,
590
- ...TargetComponent?.props,
591
- namePath: rowNamePath,
592
- disabled: lastDisabled,
593
- onChange: handleChange,
594
- onBlur: handleBlur,
595
- index,
596
- confirm,
597
- desensitization: lastDesensitization,
598
- otherProps: {
502
+ },
503
+ [
504
+ onBlur,
505
+ formatArgs,
506
+ namePath,
507
+ index,
599
508
  form,
600
- names,
509
+ TargetComponent,
510
+ validateTrigger,
511
+ debounceValidate,
512
+ cellName,
513
+ setState
514
+ ]
515
+ );
516
+ let componentProps = useMemo(
517
+ () => ({
518
+ form,
519
+ name: cellName,
520
+ ...lastFieldProps,
521
+ ...TargetComponent == null ? void 0 : TargetComponent.props,
601
522
  namePath: rowNamePath,
602
- name: originalName,
603
- listName: cellName,
604
- // 用于下拉框去重消费,保持和formlist一致
523
+ disabled: lastDisabled,
524
+ onChange: handleChange,
525
+ onBlur: handleBlur,
526
+ index,
527
+ confirm,
528
+ desensitization: lastDesensitization,
529
+ otherProps: {
530
+ form,
531
+ names,
532
+ namePath: rowNamePath,
533
+ name: originalName,
534
+ listName: cellName,
535
+ // 用于下拉框去重消费,保持和formlist一致
536
+ viewEmpty,
537
+ valueType: lastValueType,
538
+ isView,
539
+ desensitizationKey: otherProps == null ? void 0 : otherProps.desensitizationKey,
540
+ source: "ProEditTable"
541
+ }
542
+ }),
543
+ [
544
+ cellName,
545
+ lastFieldProps,
546
+ TargetComponent == null ? void 0 : TargetComponent.props,
547
+ namePath,
548
+ index,
549
+ lastDisabled,
550
+ handleChange,
551
+ handleBlur,
552
+ confirm,
553
+ lastDesensitization,
554
+ names,
555
+ originalName,
605
556
  viewEmpty,
606
- valueType: lastValueType,
557
+ lastValueType,
607
558
  isView,
608
- desensitizationKey: otherProps?.desensitizationKey,
609
- source: 'ProEditTable'
610
- }
611
- }), [cellName, lastFieldProps, TargetComponent?.props, namePath, index, lastDisabled, handleChange, handleBlur, confirm, lastDesensitization, names, originalName, viewEmpty, lastValueType, isView, otherProps?.desensitizationKey]);
612
- componentProps = _omit(componentProps, ['onFieldChange', 'namePath', 'index',
613
- // precision 是 InputNumber 的有效 fieldProps,仅在真正渲染原生 DOM 时过滤
614
- ...OMIT_FORM_ITEM_AND_DOM_KEYS.filter(key => key !== 'precision')]);
615
- if (['Switch', 'SwitchCheckbox'].includes(type)) {
616
- lastFormItemProps.valuePropName = 'checked';
559
+ otherProps == null ? void 0 : otherProps.desensitizationKey
560
+ ]
561
+ );
562
+ componentProps = omit(componentProps, [
563
+ "onFieldChange",
564
+ "namePath",
565
+ "index",
566
+ // precision InputNumber 的有效 fieldProps,仅在真正渲染原生 DOM 时过滤
567
+ ...OMIT_FORM_ITEM_AND_DOM_KEYS.filter((key) => key !== "precision")
568
+ ]);
569
+ if (["Switch", "SwitchCheckbox"].includes(type)) {
570
+ lastFormItemProps.valuePropName = "checked";
617
571
  }
618
-
619
- // 可编辑表格默认关闭scrollFollowParent
620
- if (['Select', 'ProSelect', 'ProEnum'].includes(type)) {
572
+ if (["Select", "ProSelect", "ProEnum"].includes(type)) {
621
573
  componentProps.scrollFollowParent = false;
622
574
  }
623
-
624
- // 使用useMemo优化最终的formItemProps - 修复Hooks使用规则
625
575
  const finalFormItemProps = useMemo(() => {
626
576
  const defaultTransformProps = defaultTransform();
627
577
  const namesTransformProps = namesTransform();
628
- const trimProps = isTrim(type, trim, proConfig); // 使用顶层调用的proConfig
629
-
630
- const transformNormalize = namesTransformProps?.normalize ?? defaultTransformProps?.normalize;
631
- const userNormalize = lastFormItemProps?.normalize;
632
- const transformGetValueProps = namesTransformProps?.getValueProps ?? defaultTransformProps?.getValueProps;
633
- const userGetValueProps = lastFormItemProps?.getValueProps;
634
- const finalNormalize = transformNormalize && userNormalize ? (value, prevValue, allValues, isDiffMode) => {
635
- // 用户 normalize 需要拿到组件原始值(如 DatePicker 的 dayjs)
636
- const userValue = userNormalize(value, prevValue, allValues, isDiffMode);
637
- // 保持用户优先:用户有明确返回值时直接使用,不再强制走内置转换
638
- if (userValue !== undefined) {
578
+ const trimProps = isTrim(type, trim, proConfig);
579
+ const transformNormalize = (namesTransformProps == null ? void 0 : namesTransformProps.normalize) ?? (defaultTransformProps == null ? void 0 : defaultTransformProps.normalize);
580
+ const userNormalize = lastFormItemProps == null ? void 0 : lastFormItemProps.normalize;
581
+ const transformGetValueProps = (namesTransformProps == null ? void 0 : namesTransformProps.getValueProps) ?? (defaultTransformProps == null ? void 0 : defaultTransformProps.getValueProps);
582
+ const userGetValueProps = lastFormItemProps == null ? void 0 : lastFormItemProps.getValueProps;
583
+ const finalNormalize = transformNormalize && userNormalize ? (value2, prevValue, allValues, isDiffMode) => {
584
+ const userValue = userNormalize(value2, prevValue, allValues, isDiffMode);
585
+ if (userValue !== void 0) {
639
586
  return userValue;
640
587
  }
641
- // 仅在用户未返回时,回退到内置 transform 逻辑
642
- return transformNormalize(value, prevValue, allValues, isDiffMode);
588
+ return transformNormalize(value2, prevValue, allValues, isDiffMode);
643
589
  } : userNormalize || transformNormalize;
644
- const finalGetValueProps = transformGetValueProps && userGetValueProps ? (value, ...args) => {
645
- const transformValueProps = transformGetValueProps(value, ...args) || {};
646
- const nextValue = Object.prototype.hasOwnProperty.call(transformValueProps, 'value') ? transformValueProps.value : value;
590
+ const finalGetValueProps = transformGetValueProps && userGetValueProps ? (value2, ...args) => {
591
+ const transformValueProps = transformGetValueProps(value2, ...args) || {};
592
+ const nextValue = Object.prototype.hasOwnProperty.call(transformValueProps, "value") ? transformValueProps.value : value2;
647
593
  const userValueProps = userGetValueProps(nextValue, ...args) || {};
648
594
  return {
649
595
  ...transformValueProps,
@@ -659,16 +605,13 @@ const RenderField = ({
659
605
  getValueProps: finalGetValueProps
660
606
  };
661
607
  }, [lastFormItemProps, defaultTransform, namesTransform, type, trim, proConfig]);
662
-
663
- // rules 的 isView 过滤已移至 getFieldItem 内处理(支持 shouldUpdate 模式下的动态 isEditable)
664
-
665
- const cellClassName = useMemo(() => classNames({
666
- [className]: className
667
- }), [className]);
668
-
669
- // shouldUpdate 模式下重新获取最新行数据并重算所有响应式属性,返回最新渲染状态(不修改外层闭包)
608
+ const cellClassName = useMemo(
609
+ () => classNames({
610
+ [className]: className
611
+ }),
612
+ [className]
613
+ );
670
614
  const recalcShouldUpdateState = () => {
671
- // 重新获取最新的行数据(shouldUpdate 触发时,通过 getFieldValue 拿到最新值)
672
615
  const latestRowData = form.getFieldValue(rowNamePath) || record || {};
673
616
  const latestReactiveParams = {
674
617
  form,
@@ -680,54 +623,49 @@ const RenderField = ({
680
623
  if (cachedState && isRecordShallowEqual(cachedState.rowSnapshot, latestRowData)) {
681
624
  return cachedState.result;
682
625
  }
683
-
684
- // 初次 render props 会与外层 RenderField 使用同一行数据,直接复用 hook 已计算结果。
685
626
  const canReuseCurrentState = isRecordShallowEqual(latestRowData, dynamicProps.rowSnapshot);
686
627
  let latestFieldProps = canReuseCurrentState ? lastFieldProps : fieldProps || {};
687
- if (!canReuseCurrentState && _isFunction(fieldProps)) {
628
+ if (!canReuseCurrentState && isFunction(fieldProps)) {
688
629
  latestFieldProps = fieldProps(latestRowData, latestReactiveParams);
689
630
  }
690
631
  let latestRequired = canReuseCurrentState ? lastRequired : required;
691
- if (!canReuseCurrentState && _isFunction(required)) {
632
+ if (!canReuseCurrentState && isFunction(required)) {
692
633
  latestRequired = required(latestRowData, latestReactiveParams);
693
634
  }
694
635
  let latestRules = canReuseCurrentState ? lastRules : rules;
695
- if (!canReuseCurrentState && _isFunction(rules)) {
636
+ if (!canReuseCurrentState && isFunction(rules)) {
696
637
  latestRules = rules(latestRowData, latestReactiveParams);
697
638
  }
698
639
  let latestDesensitization = canReuseCurrentState ? lastDesensitization : desensitization || [];
699
- if (!canReuseCurrentState && _isFunction(desensitization)) {
640
+ if (!canReuseCurrentState && isFunction(desensitization)) {
700
641
  latestDesensitization = desensitization(latestRowData, latestReactiveParams);
701
642
  }
702
643
  let latestComponent = canReuseCurrentState ? lastComponent : component || editRender;
703
- if (!canReuseCurrentState && _isFunction(latestComponent)) {
644
+ if (!canReuseCurrentState && isFunction(latestComponent)) {
704
645
  latestComponent = latestComponent(latestRowData, latestReactiveParams);
705
646
  }
706
647
  let latestIsEditable = canReuseCurrentState ? isEditable : column.isEditable ?? true;
707
- if (!canReuseCurrentState && _isFunction(column.isEditable)) {
648
+ if (!canReuseCurrentState && isFunction(column.isEditable)) {
708
649
  latestIsEditable = column.isEditable(latestRowData, latestReactiveParams);
709
650
  }
710
651
  let latestValueType = canReuseCurrentState ? lastValueType : valueType;
711
- if (!canReuseCurrentState && _isFunction(valueType)) {
712
- const latestCurrentValue = dataIndex ? latestRowData?.[dataIndex] : null;
652
+ if (!canReuseCurrentState && isFunction(valueType)) {
653
+ const latestCurrentValue = dataIndex ? latestRowData == null ? void 0 : latestRowData[dataIndex] : null;
713
654
  latestValueType = valueType(latestCurrentValue, latestRowData, {
714
655
  index,
715
656
  form,
716
657
  namePath: rowNamePath,
717
- name: column?.name
658
+ name: column == null ? void 0 : column.name
718
659
  });
719
660
  }
720
661
  const latestDisabled = canReuseCurrentState ? lastDisabled : getDisabled({
721
- globalControl: otherProps?.globalControl,
722
- formDisabled: otherProps?.formDisabled,
662
+ globalControl: otherProps == null ? void 0 : otherProps.globalControl,
663
+ formDisabled: otherProps == null ? void 0 : otherProps.formDisabled,
723
664
  column,
724
- tabledDisabled: config?.disabled,
665
+ tabledDisabled: config == null ? void 0 : config.disabled,
725
666
  columnFieldProps: latestFieldProps,
726
667
  params: latestRowParams
727
668
  });
728
-
729
- // 更新 componentProps 中的所有响应式属性
730
- // latestTargetComponent 稍后计算,此处先占位;最终会在下方合并 latestTargetComponent?.props
731
669
  let latestComponentProps = {
732
670
  ...componentProps,
733
671
  ...latestFieldProps,
@@ -738,37 +676,28 @@ const RenderField = ({
738
676
  onBlur: handleBlur
739
677
  };
740
678
  let latestTargetComponent = canReuseCurrentState ? TargetComponent : fallbackTargetComponent;
741
-
742
- // 然后处理自定义 component
743
- const latestIsView = !latestIsEditable || record?.['is-view'] || config.isView || virtualKey && !isEditing || getDisabled({
744
- globalControl: otherProps?.globalControl,
745
- formDisabled: otherProps?.formDisabled,
679
+ const latestIsView = !latestIsEditable || (record == null ? void 0 : record["is-view"]) || config.isView || virtualKey && !isEditing || getDisabled({
680
+ globalControl: otherProps == null ? void 0 : otherProps.globalControl,
681
+ formDisabled: otherProps == null ? void 0 : otherProps.formDisabled,
746
682
  column,
747
- tabledDisabled: config?.disabled,
683
+ tabledDisabled: config == null ? void 0 : config.disabled,
748
684
  columnFieldProps: latestFieldProps,
749
685
  params: latestRowParams,
750
- rowDisabled: rowDisabled || 'empty'
686
+ rowDisabled: rowDisabled || "empty"
751
687
  });
752
688
  if (!canReuseCurrentState && latestIsEditable && isEditing && hasCustomComponent) {
753
689
  latestTargetComponent = resolveEditTargetComponent(latestComponent);
754
690
  }
755
-
756
- // 查看模式
757
691
  if (!canReuseCurrentState && latestIsView) {
758
- if (typeof viewRender === 'function') {
759
- const latestCurrentValue = dataIndex ? latestRowData?.[dataIndex] : value;
692
+ if (typeof viewRender === "function") {
693
+ const latestCurrentValue = dataIndex ? latestRowData == null ? void 0 : latestRowData[dataIndex] : value;
760
694
  const View = viewRender(latestCurrentValue, latestRowData || {}, options);
761
- latestTargetComponent = /*#__PURE__*/_jsx(Container, {
762
- viewEmpty: viewEmpty,
763
- children: View
764
- });
695
+ latestTargetComponent = /* @__PURE__ */ jsx(Container, { viewEmpty, children: View });
765
696
  }
766
- if ( /*#__PURE__*/React.isValidElement(viewRender)) {
697
+ if (React.isValidElement(viewRender)) {
767
698
  latestTargetComponent = viewRender;
768
699
  }
769
700
  }
770
-
771
- // shouldUpdate 触发时外层 componentProps.otherProps.isView 是旧快照,需用最新值覆盖
772
701
  latestComponentProps = {
773
702
  ...latestComponentProps,
774
703
  otherProps: {
@@ -777,13 +706,9 @@ const RenderField = ({
777
706
  valueType: latestValueType
778
707
  }
779
708
  };
780
-
781
- // componentProps 里展开了外层旧 TargetComponent?.props(如 { formType: "Input" }),
782
- // 用 latestTargetComponent?.props 覆盖,确保不会被旧 cloneElement props 污染
783
- if ( /*#__PURE__*/React.isValidElement(latestTargetComponent)) {
709
+ if (React.isValidElement(latestTargetComponent)) {
784
710
  const elementProps = latestTargetComponent.props;
785
- // 确保 props 是对象类型才进行展开
786
- if (elementProps && typeof elementProps === 'object') {
711
+ if (elementProps && typeof elementProps === "object") {
787
712
  latestComponentProps = {
788
713
  ...latestComponentProps,
789
714
  ...elementProps,
@@ -802,16 +727,11 @@ const RenderField = ({
802
727
  effectiveFieldProps: latestFieldProps
803
728
  };
804
729
  shouldUpdateStateCacheRef.current = {
805
- rowSnapshot: {
806
- ...latestRowData
807
- },
730
+ rowSnapshot: { ...latestRowData },
808
731
  result
809
732
  };
810
733
  return result;
811
734
  };
812
-
813
- // 根据 latestIsView 和最新 required/rules 构建正确的 Form.Item props
814
- // 解决 shouldUpdate 触发时外层 finalFormItemProps 是旧闭包(rules 基于旧 isView 计算)的问题
815
735
  const buildActiveFormItemProps = ({
816
736
  latestIsView,
817
737
  shouldUpdateMode,
@@ -820,99 +740,82 @@ const RenderField = ({
820
740
  effectiveFieldProps
821
741
  }) => {
822
742
  if (latestIsView) {
823
- // 查看模式:移除 rules 不做校验
824
- return _omit(finalFormItemProps, ['rules']);
743
+ return omit(finalFormItemProps, ["rules"]);
825
744
  }
826
745
  if (shouldUpdateMode) {
827
- // shouldUpdate 模式下 finalFormItemProps 是旧闭包,需用最新 effectiveRequired/effectiveRules 重建 rules
828
746
  const activeRules = Array.isArray(effectiveRules) ? [...effectiveRules] : [];
829
- const hasRequiredRule = activeRules.some(r => r?.required === true);
747
+ const hasRequiredRule = activeRules.some((r) => (r == null ? void 0 : r.required) === true);
830
748
  if (effectiveRequired && !hasRequiredRule) {
831
749
  const isSelectVal = isSelect({
832
- dataSource: effectiveFieldProps?.dataSource,
750
+ dataSource: effectiveFieldProps == null ? void 0 : effectiveFieldProps.dataSource,
833
751
  type
834
752
  });
835
753
  activeRules.push({
836
754
  required: true,
837
- message: `${isSelectVal ? locale.ProForm.selectPlaceHolder : locale.ProForm.inputPlaceholder}${label || ''}`
755
+ message: `${isSelectVal ? locale.ProForm.selectPlaceHolder : locale.ProForm.inputPlaceholder}${label || ""}`
838
756
  });
839
757
  }
840
758
  return {
841
759
  ...finalFormItemProps,
842
- rules: activeRules.length > 0 ? activeRules : [{
843
- required: false
844
- }]
760
+ rules: activeRules.length > 0 ? activeRules : [{ required: false }]
845
761
  };
846
762
  }
847
763
  return finalFormItemProps;
848
764
  };
849
-
850
- // 组装字段组件:DOM 透传字段过滤、克隆/创建目标元素、原始值对比包裹(ListChangedWrapper)、确认弹窗包裹(ConfirmWrapper)
851
- const assembleFieldComponent = finalComponentProps => {
852
- // 当 viewRender 存在时,需要排除 finalComponentProps 中的 children,避免覆盖 Container 的 children
853
- let propsForTarget = isView && typeof viewRender === 'function' ? _omit(finalComponentProps, ['children']) : finalComponentProps;
854
- // 当目标为原生 DOM 元素(如 viewRender 返回 <div>)时,剔除 disabled、toCSTString 等,避免 React 警告
855
- const isTargetDomElement = /*#__PURE__*/React.isValidElement(TargetComponent) && typeof TargetComponent.type === 'string';
765
+ const assembleFieldComponent = (finalComponentProps) => {
766
+ let propsForTarget = isView && typeof viewRender === "function" ? omit(finalComponentProps, ["children"]) : finalComponentProps;
767
+ const isTargetDomElement = React.isValidElement(TargetComponent) && typeof TargetComponent.type === "string";
856
768
  if (isTargetDomElement) {
857
- propsForTarget = _omit(propsForTarget, ['disabled', ...OMIT_FORM_ITEM_AND_DOM_KEYS]);
769
+ propsForTarget = omit(propsForTarget, ["disabled", ...OMIT_FORM_ITEM_AND_DOM_KEYS]);
858
770
  }
859
- // 当 TargetComponent 未定义时,使用空的占位组件避免渲染错误
860
771
  let FieldComponent = null;
861
- if ( /*#__PURE__*/React.isValidElement(TargetComponent)) {
862
- FieldComponent = /*#__PURE__*/React.cloneElement(TargetComponent, propsForTarget);
772
+ if (React.isValidElement(TargetComponent)) {
773
+ FieldComponent = React.cloneElement(TargetComponent, propsForTarget);
863
774
  } else if (TargetComponent) {
864
- FieldComponent = /*#__PURE__*/_jsx(TargetComponent, {
865
- ...propsForTarget
866
- });
775
+ FieldComponent = /* @__PURE__ */ jsx(TargetComponent, { ...propsForTarget });
867
776
  } else {
868
- FieldComponent = /*#__PURE__*/_jsx(_Fragment, {});
777
+ FieldComponent = /* @__PURE__ */ jsx(Fragment, {});
869
778
  }
870
779
  if (originalValues && !getIsNew(record)) {
871
- FieldComponent = /*#__PURE__*/_jsx(ListChangedWrapper, {
872
- name: cellName,
873
- names: names,
874
- namesStr: [...baseName, index, dataIndex],
875
- rowKeyPath: [...baseName, index, 'rowKey'],
876
- originalName: originalName,
877
- originalNames: originalNames,
878
- originalValues: originalValues,
879
- form: form,
880
- onDiff: onDiff,
881
- type: type,
882
- onChange: handleChange,
883
- onBlur: handleBlur,
884
- valuePropName: finalFormItemProps.valuePropName,
885
- normalize: finalFormItemProps.normalize,
886
- getValueProps: finalFormItemProps.getValueProps,
887
- viewRender: viewRender,
888
- diffConfig: diffConfig,
889
- index: index,
890
- children: FieldComponent
891
- });
780
+ FieldComponent = /* @__PURE__ */ jsx(
781
+ ListChangedWrapper,
782
+ {
783
+ name: cellName,
784
+ names,
785
+ namesStr: [...baseName, index, dataIndex],
786
+ rowKeyPath: [...baseName, index, "rowKey"],
787
+ originalName,
788
+ originalNames,
789
+ originalValues,
790
+ form,
791
+ onDiff,
792
+ type,
793
+ onChange: handleChange,
794
+ onBlur: handleBlur,
795
+ valuePropName: finalFormItemProps.valuePropName,
796
+ normalize: finalFormItemProps.normalize,
797
+ getValueProps: finalFormItemProps.getValueProps,
798
+ viewRender,
799
+ diffConfig,
800
+ index,
801
+ children: FieldComponent
802
+ }
803
+ );
892
804
  }
893
- if (finalComponentProps?.confirm) {
894
- FieldComponent = /*#__PURE__*/_jsx(ConfirmWrapper, {
895
- ...finalComponentProps,
896
- children: FieldComponent
897
- });
805
+ if (finalComponentProps == null ? void 0 : finalComponentProps.confirm) {
806
+ FieldComponent = /* @__PURE__ */ jsx(ConfirmWrapper, { ...finalComponentProps, children: FieldComponent });
898
807
  }
899
808
  return FieldComponent;
900
809
  };
901
-
902
- // 使用useCallback优化getFieldItem函数
903
810
  const getFieldItem = (shouldUpdateMode = false) => {
904
- // 如果处于 shouldUpdate 模式,需要重新获取最新的行数据并重新计算依赖值
905
811
  let finalComponentProps = componentProps;
906
- // shouldUpdate 模式下会被更新为最新值,供外层 FieldProvider 消费
907
812
  let latestIsView = isView;
908
- // 用于在 shouldUpdate 模式下重建正确的 Form.Item rules(外层 finalFormItemProps 是旧闭包)
909
813
  let effectiveRequired = lastRequired;
910
814
  let effectiveRules = lastRules;
911
815
  let effectiveFieldProps = lastFieldProps;
912
816
  if (shouldUpdateMode) {
913
817
  const recomputed = recalcShouldUpdateState();
914
818
  finalComponentProps = recomputed.finalComponentProps;
915
- // shouldUpdate 模式下用重算结果覆盖外层 TargetComponent,供下方组装逻辑消费
916
819
  TargetComponent = recomputed.targetComponent;
917
820
  latestIsView = recomputed.latestIsView;
918
821
  effectiveRequired = recomputed.effectiveRequired;
@@ -927,52 +830,52 @@ const RenderField = ({
927
830
  effectiveFieldProps
928
831
  });
929
832
  const FieldComponent = assembleFieldComponent(finalComponentProps);
930
- let FormItem = TargetComponent ? /*#__PURE__*/_jsx(Form.Item, {
931
- validateFirst: true,
932
- ..._omit(activeFinalFormItemProps, ['render', 'key', 'width', 'hiddenNames', 'name', 'onCell', 'disabled', lastFormItemProps.shouldUpdate ? 'shouldUpdate' : null]),
933
- // 移除非必要字段,但保留 dependencies
934
- className: cellClassName,
935
- name: formNamePath ? cellName.slice(formNamePath?.length - 1) : cellName,
936
- children: FieldComponent
937
- }) : /*#__PURE__*/_jsx(Container, {
938
- viewEmpty: viewEmpty
939
- });
940
- if (type === 'FormList' && !hasCustomComponent && TargetComponent) {
941
- FormItem = /*#__PURE__*/_jsx(Form.List, {
942
- name: formNamePath ? cellName.slice(formNamePath?.length - 1) : cellName,
943
- ..._omit(activeFinalFormItemProps, ['render', 'key', 'width', 'hiddenNames', 'name']),
944
- children: (fields, operation, meta) => /*#__PURE__*/_jsx(TargetComponent, {
945
- ...finalComponentProps,
946
- otherProps: otherProps,
947
- fields: fields,
948
- operation: operation,
949
- meta: meta
950
- })
951
- });
833
+ let FormItem = TargetComponent ? /* @__PURE__ */ jsx(
834
+ Form.Item,
835
+ {
836
+ validateFirst: true,
837
+ ...omit(activeFinalFormItemProps, [
838
+ "render",
839
+ "key",
840
+ "width",
841
+ "hiddenNames",
842
+ "name",
843
+ "onCell",
844
+ "disabled",
845
+ lastFormItemProps.shouldUpdate ? "shouldUpdate" : null
846
+ ]),
847
+ className: cellClassName,
848
+ name: formNamePath ? cellName.slice((formNamePath == null ? void 0 : formNamePath.length) - 1) : cellName,
849
+ children: FieldComponent
850
+ }
851
+ ) : /* @__PURE__ */ jsx(Container, { viewEmpty });
852
+ if (type === "FormList" && !hasCustomComponent && TargetComponent) {
853
+ FormItem = /* @__PURE__ */ jsx(
854
+ Form.List,
855
+ {
856
+ name: formNamePath ? cellName.slice((formNamePath == null ? void 0 : formNamePath.length) - 1) : cellName,
857
+ ...omit(activeFinalFormItemProps, ["render", "key", "width", "hiddenNames", "name"]),
858
+ children: (fields, operation, meta) => /* @__PURE__ */ jsx(
859
+ TargetComponent,
860
+ {
861
+ ...finalComponentProps,
862
+ otherProps,
863
+ fields,
864
+ operation,
865
+ meta
866
+ }
867
+ )
868
+ }
869
+ );
952
870
  }
953
- // shouldUpdateMode 返回元组,将 latestIsView 暴露给外层用于更新 FieldProvider context
954
871
  return shouldUpdateMode ? [FormItem, latestIsView] : FormItem;
955
872
  };
956
- return /*#__PURE__*/_jsx(_Fragment, {
957
- children: finalFormItemProps.shouldUpdate ? /*#__PURE__*/_jsx(Form.Item, {
958
- noStyle: true,
959
- shouldUpdate: finalFormItemProps.shouldUpdate,
960
- children: () => {
961
- // shouldUpdate 触发时外层组件可能因 memo 未重渲染,FieldProvider context 是旧快照
962
- // 从 getFieldItem(true) 的元组返回值获取 latestIsView,更新 context 确保 Input 组件读到最新 isView
963
- const [formItem, latestIsView] = getFieldItem(true);
964
- return /*#__PURE__*/_jsx(FieldProvider, {
965
- value: {
966
- ...componentProps?.otherProps,
967
- isView: latestIsView
968
- },
969
- children: formItem
970
- });
971
- }
972
- }) : /*#__PURE__*/_jsx(FieldProvider, {
973
- value: componentProps?.otherProps || {},
974
- children: getFieldItem()
975
- })
976
- });
873
+ return /* @__PURE__ */ jsx(Fragment, { children: finalFormItemProps.shouldUpdate ? /* @__PURE__ */ jsx(Form.Item, { noStyle: true, shouldUpdate: finalFormItemProps.shouldUpdate, children: () => {
874
+ const [formItem, latestIsView] = getFieldItem(true);
875
+ return /* @__PURE__ */ jsx(FieldProvider, { value: { ...componentProps == null ? void 0 : componentProps.otherProps, isView: latestIsView }, children: formItem });
876
+ } }) : /* @__PURE__ */ jsx(FieldProvider, { value: (componentProps == null ? void 0 : componentProps.otherProps) || {}, children: getFieldItem() }) });
877
+ };
878
+ var RenderField_default = memo(RenderField, arePropsEqual);
879
+ export {
880
+ RenderField_default as default
977
881
  };
978
- export default /*#__PURE__*/memo(RenderField, arePropsEqual);